@kedge-agentic/context-layer-core
v0.2.0
Published
Framework-free core of @kedge-agentic/context-layer. Entity registry, document edit provider, recommend/router/injector primitives, and the HTTP client SDK. Zero NestJS coupling — agent subprocesses, CLI tools, browsers, and NestJS services can all consum
Readme
@kedge-agentic/context-layer-core
Context layer 的框架无关核心: entity registry / document edit provider / recommend/router/injector 原语 / HTTP 客户端 SDK。
类型: 框架无关库 · 状态: public · v0.2.0
用途
AI chat UI 的 "@-mention" context layer — 让用户在对话中引用 entity (菜谱、教案等),并让 AI agent 把相关 entity 上下文注入到 prompt 里。 Solution backend 按 entity 类型注册 DocumentEditProvider 实现; framework 处理 browse / search / 解析 / 推荐 / 编辑应用。
零 NestJS 耦合。 Agent 子进程、CLI 工具、浏览器、NestJS 服务都能用。
主要导出
import {
EntityRegistry,
RelationInferrer,
ActivityEmitter,
RecommendEngine,
ContextInjector,
ContextRouter,
ShortcutManager,
DocumentEditProvider,
referenceableOptionsToPicker,
pickerToReferenceableOptions,
createSingleSlotManifestAccessor,
// 再导出的 interface
OrmAdapter,
CacheStore,
EntityBrowseProvider,
BrowseResponse,
SearchResponse,
ResolveResponse,
EditOperation,
EntityRef,
AtReference,
// 根方便再导出
ContextLayerClient,
} from '@kedge-agentic/context-layer-core'
// 新代码推荐用 subpath
import { ContextLayerClient } from '@kedge-agentic/context-layer-core/client'用法
// 在 solution backend 里
export class RecipeProvider implements DocumentEditProvider<Recipe> {
async load(id: string): Promise<Recipe> { ... }
async applyEdit(entity: Recipe, op: EditOperation): Promise<Recipe> { ... }
async save(entity: Recipe): Promise<void> { ... }
}
const registry = new EntityRegistry()
registry.register('recipe', new RecipeProvider())依赖
- 运行时:
@kedge-agentic/entity-document,@kedge-agentic/ontology - 无 peerDeps
关联包
- @kedge-agentic/context-layer-nest — NestJS Module / 装饰器 / controller
- @kedge-agentic/context-layer-react — React picker UI
Phase 2 (2026-05-31) 从原 @kedge-agentic/context-layer wrapper 拆出。
构建 / 测试
npm run build:context-layer-core
npm test -w @kedge-agentic/context-layer-core