用途与设计边界
直传任务数据可与显式存储中检索到的记录一起构成上下文。命名空间限制检索范围,优先级使预算决策可检查,快照摘要可与复审证据一道保存。持久化依赖存储接口,内存实现可用于测试夹具。
上手与兼容性
项目仍在开发中。可检出固定提交,安装开发依赖,在仓库根目录运行 npm run build。ESM 构建要求 Node.js ^20.19.0 || >=22.12.0,产物入口是 dist/index.js。下例是放在根目录的 .mjs 文件,使用内存存储并打印所选上下文与预算的摘要。 固定源码入口 · 固定构建清单
import { createContextBuilder, InMemoryMemoryStore } from './dist/index.js';
const context = await createContextBuilder({ memory: new InMemoryMemoryStore(), budget: { maxTokens: 64 } })
.addItem({ id: 'task', type: 'task.input', content: 'Review a route.', priority: 10 })
.build();
console.log(context.snapshot.digest);