@botbotgo/agent-harness 0.0.281 → 0.0.283

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +20 -9
  2. package/README.zh.md +20 -9
  3. package/dist/config/catalogs/stores.yaml +1 -1
  4. package/dist/config/catalogs/vector-stores.yaml +1 -1
  5. package/dist/config/knowledge/knowledge-runtime.yaml +60 -0
  6. package/dist/config/runtime/runtime-memory.yaml +3 -3
  7. package/dist/contracts/runtime.d.ts +9 -0
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.js +1 -0
  10. package/dist/init-project.js +50 -4
  11. package/dist/knowledge/config.d.ts +11 -0
  12. package/dist/knowledge/config.js +32 -0
  13. package/dist/knowledge/contracts.d.ts +45 -0
  14. package/dist/knowledge/contracts.js +1 -0
  15. package/dist/knowledge/index.d.ts +4 -0
  16. package/dist/knowledge/index.js +2 -0
  17. package/dist/knowledge/module.d.ts +21 -0
  18. package/dist/knowledge/module.js +594 -0
  19. package/dist/package-version.d.ts +1 -1
  20. package/dist/package-version.js +1 -1
  21. package/dist/persistence/file-store.d.ts +1 -0
  22. package/dist/persistence/file-store.js +29 -25
  23. package/dist/persistence/sqlite-store.js +1 -1
  24. package/dist/runtime/harness/run/resources.js +4 -2
  25. package/dist/runtime/harness/system/runtime-memory-policy.js +1 -1
  26. package/dist/runtime/harness/system/runtime-memory-records.js +4 -0
  27. package/dist/runtime/harness/system/runtime-memory-sync.js +2 -2
  28. package/dist/runtime/harness/system/thread-memory-sync.js +1 -1
  29. package/dist/runtime/harness.d.ts +1 -16
  30. package/dist/runtime/harness.js +95 -613
  31. package/dist/runtime/maintenance/checkpoint-maintenance.js +2 -1
  32. package/dist/runtime/maintenance/runtime-record-maintenance.js +2 -1
  33. package/dist/runtime/support/llamaindex.js +1 -1
  34. package/dist/runtime/support/runtime-factories.js +6 -3
  35. package/dist/runtime/support/runtime-layout.d.ts +6 -0
  36. package/dist/runtime/support/runtime-layout.js +19 -0
  37. package/package.json +1 -1
package/README.md CHANGED
@@ -524,7 +524,7 @@ Use `normalizeUserChatInput(...)` when a product already has chat-style user mes
524
524
  import { memorize, recall } from "@botbotgo/agent-harness";
525
525
 
526
526
  await memorize(runtime, {
527
- threadId: "thread-123",
527
+ sessionId: "session-123",
528
528
  records: [
529
529
  {
530
530
  content: "The release checklist requires a smoke test before publish.",
@@ -685,6 +685,7 @@ Core workspace files:
685
685
  - `config/catalogs/embedding-models.yaml`
686
686
  - `config/catalogs/vector-stores.yaml`
687
687
  - `config/catalogs/stores.yaml`
688
+ - `config/knowledge/knowledge-runtime.yaml`
688
689
  - `config/runtime/runtime-memory.yaml`
689
690
  - `config/catalogs/backends.yaml`
690
691
  - `config/catalogs/tools.yaml`
@@ -703,12 +704,16 @@ Discovery rules:
703
704
 
704
705
  Example workspaces:
705
706
 
706
- - `examples/hello-skill-app/` keeps the smallest local tool + skill workspace
707
- - `examples/local-scheduled-task-app/` runs recurring prompt-driven tasks with a local `node-llama-cpp` GGUF workspace and one local tool
708
- - `examples/multimodal-app/` keeps the smallest image-plus-PDF example and sends both through one `request(...)` call
709
- - `examples/plan-and-run-app/` keeps the smallest public-API planning example and prints both the plan and the observed execution steps
710
- - `examples/runtime-flow-demo/` runs one real hosted-model request and exports a Mermaid flowchart from runtime plus upstream events
711
- - `examples/protocol-hello-world/` shows the same minimal direct agent wired to ACP, A2A, and AG-UI hello-world transport samples
707
+ - prefixes indicate complexity order, where `00_` is the simplest starting point
708
+ - `examples/00_local-tools-and-skills/` is the Local Tools and Skills Example: the smallest local tool + skill workspace
709
+ - `examples/01_multimodal-request/` is the Multimodal Request Example: the smallest image-plus-PDF request flow
710
+ - `examples/02_subagent-planning/` is the Subagent Planning Example: a compact planning flow with one subagent, tools, and trace output
711
+ - `examples/03_protocol-surfaces/` is the Protocol Surfaces Example: the same minimal direct agent wired to ACP, ACP stdio, A2A, AG-UI, and runtime MCP
712
+ - `examples/04_local-model-tool-calling/` is the Local Model Tool Calling Example: one local GGUF-backed task loop plus one local tool
713
+ - `examples/05_runtime-trace-export/` is the Runtime Trace Export Example: one real run plus Mermaid flow export from runtime and upstream events
714
+ - `examples/06_repository-analysis/` is the Repository Analysis Example: repo analysis around one workspace-local tool plus embedding-backed indexing
715
+ - `examples/07_multi-agent-research/` is the Multi-Agent Research Example: the most complete multi-agent research workspace with reusable backends, skills, and local tools
716
+ - `examples/08_long-term-memory-learning/` is the Long-Term Memory Learning Example: repeated requests that store durable memory, inspect recall, and make later answers more context-aware
712
717
 
713
718
  Workspace-local tool modules in `resources/tools/` should be exported with `tool({...})`.
714
719
  Any other local module shape is not supported, and unsupported shapes are rejected at load time.
@@ -870,6 +875,12 @@ Keep bootstrap context in `config/agent-context.md`. Keep resumable execution st
870
875
  - `formation.manager` for rule-driven or model-driven candidate normalization before persistence
871
876
  - `formation.background` for reflection after run completion or approval resolution
872
877
 
878
+ ### `config/knowledge/knowledge-runtime.yaml`
879
+
880
+ Use this singleton when the same durable-memory policy should also run outside `AgentHarnessRuntime`, such as a standalone knowledge worker or knowledge server.
881
+
882
+ `KnowledgeRuntime` mirrors the durable policy shape on purpose. Keep `RuntimeMemory` for runtime-owned defaults, and keep `KnowledgeRuntime` as the externalizable mirror when a separate knowledge service needs the same memorize/recall policy.
883
+
873
884
  ### `config/catalogs/backends.yaml`
874
885
 
875
886
  Use reusable backend presets so filesystem and `/memories/*` topology stays in YAML:
@@ -961,7 +972,7 @@ spec:
961
972
  maxFileSizeMb: 10
962
973
  sessionStorage:
963
974
  enabled: true
964
- rootDir: "{runRoot}/threads/{threadId}/filesystem"
975
+ rootDir: "{runRoot}/sessions/{sessionId}/filesystem"
965
976
  middleware: []
966
977
  systemPrompt: Answer simple requests directly.
967
978
  ```
@@ -1068,7 +1079,7 @@ ACP transport notes:
1068
1079
  - `serveAcpHttp(runtime)` exposes JSON-RPC over HTTP plus SSE runtime events so remote operator surfaces can connect without importing the runtime in-process.
1069
1080
  - ACP transport validation now covers the reference-client core flow: capability discovery, request submit, session lookup, request lookup, invalid-JSON handling, notification calls without response ids, stdio JSON-RPC, and HTTP plus SSE runtime notifications.
1070
1081
  - Cross-protocol conformance now has an explicit regression gate as well: ACP submission, A2A task lookup and continuation, and runtime MCP inspection must all project the same persisted `sessionId` / `requestId` runtime records instead of drifting into surface-specific identifiers or side stores.
1071
- - For the thinnest editor or CLI starter, begin with `agent-harness acp serve --workspace . --transport stdio` and mirror the `examples/protocol-hello-world/app/acp-stdio-hello-world.mjs` wire shape. Applications that want an in-process reference client can use `createAcpStdioClient(...)` to issue JSON-RPC requests and route runtime notifications without hand-rolling line parsing.
1082
+ - For the thinnest editor or CLI starter, begin with `agent-harness acp serve --workspace . --transport stdio` and mirror the `examples/03_protocol-surfaces/app/acp-stdio/main.mjs` wire shape. Applications that want an in-process reference client can use `createAcpStdioClient(...)` to issue JSON-RPC requests and route runtime notifications without hand-rolling line parsing.
1072
1083
  - `serveA2aHttp(runtime)` exposes an A2A-compatible HTTP JSON-RPC bridge plus agent card discovery, mapping both existing methods such as `message/send` and A2A v1.0 PascalCase methods such as `SendMessage`, `SendStreamingMessage`, `GetTask`, `ListTasks`, `CancelTask`, `SubscribeToTask`, `GetAgentCard`, `GetExtendedAgentCard`, and task push-notification config methods onto the existing session/request runtime surface. The bridge now advertises both `1.0` and `0.3` JSON-RPC interfaces, answers `HEAD` / `OPTIONS` discovery on the agent-card path, sets supported-version discovery headers, can optionally expose registry URLs plus detached signed-card metadata for surrounding discovery systems, validates `A2A-Version`, records `A2A-Extensions` into runtime invocation metadata, publishes `TASK_STATE_*` statuses plus the `{ task }` `SendMessage` wrapper, streams an initial `{ task }` snapshot plus later `{ statusUpdate }` payloads over SSE for v1 streaming methods, and can send best-effort webhook task snapshots for configured push notification receivers.
1073
1084
  - `serveAgUiHttp(runtime)` exposes an AG-UI-compatible HTTP SSE bridge that projects runtime lifecycle, text output, upstream thinking, step progress, and tool calls onto `RUN_*`, `TEXT_MESSAGE_*`, `THINKING_TEXT_MESSAGE_*`, `STEP_*`, and `TOOL_CALL_*` events for UI clients.
1074
1085
  - `createRuntimeMcpServer(runtime)` and `serveRuntimeMcpOverStdio(runtime)` expose the persisted runtime control surface itself as MCP tools, including sessions, requests, approvals, artifacts, events, and package export helpers.
package/README.zh.md CHANGED
@@ -495,7 +495,7 @@ const result = await request(runtime, {
495
495
  import { memorize, recall } from "@botbotgo/agent-harness";
496
496
 
497
497
  await memorize(runtime, {
498
- threadId: "thread-123",
498
+ sessionId: "session-123",
499
499
  records: [
500
500
  {
501
501
  content: "The release checklist requires a smoke test before publish.",
@@ -648,6 +648,7 @@ await stop(runtime);
648
648
  - `config/catalogs/embedding-models.yaml`
649
649
  - `config/catalogs/vector-stores.yaml`
650
650
  - `config/catalogs/stores.yaml`
651
+ - `config/knowledge/knowledge-runtime.yaml`
651
652
  - `config/runtime/runtime-memory.yaml`
652
653
  - `config/catalogs/backends.yaml`
653
654
  - `config/catalogs/tools.yaml`
@@ -666,12 +667,16 @@ await stop(runtime);
666
667
 
667
668
  示例工作区:
668
669
 
669
- - `examples/hello-skill-app/` 保留最小的本地 tool + skill 工作区
670
- - `examples/local-scheduled-task-app/` 展示如何用本地 `node-llama-cpp` GGUF 工作区和一个本地 tool 执行周期性 prompt 任务
671
- - `examples/multimodal-app/` 保留最小的图片 + PDF 示例,并通过一次 `request(...)` 调用发送
672
- - `examples/plan-and-run-app/` 保留最小的公开 API 规划示例,并同时打印规划步骤和真实执行步骤
673
- - `examples/runtime-flow-demo/` 会跑一次真实 hosted model 请求,并把 runtime upstream events 导出为 Mermaid flowchart
674
- - `examples/protocol-hello-world/` 展示同一个最小 direct agent ACP、A2A AG-UI 三种 hello-world 传输示例
670
+ - 前缀表示复杂度顺序,`00_` 是最简单的起点
671
+ - `examples/00_local-tools-and-skills/` Local Tools and Skills Example:最小的本地 tool + skill 工作区
672
+ - `examples/01_multimodal-request/` Multimodal Request Example:最小的图片 + PDF 请求流
673
+ - `examples/02_subagent-planning/` Subagent Planning Example:带一个 subagent、工具和 trace 输出的紧凑规划流程
674
+ - `examples/03_protocol-surfaces/` Protocol Surfaces Example:同一个最小 direct agent ACP、ACP stdio、A2A、AG-UI runtime MCP 示例
675
+ - `examples/04_local-model-tool-calling/` Local Model Tool Calling Example:一个本地 GGUF task loop 加一个本地 tool
676
+ - `examples/05_runtime-trace-export/` 是 Runtime Trace Export Example:一次真实运行,加上 runtime 与 upstream events 的 Mermaid 导出
677
+ - `examples/06_repository-analysis/` 是 Repository Analysis Example:围绕一个工作区本地 tool 和 embedding 索引的仓库分析示例
678
+ - `examples/07_multi-agent-research/` 是 Multi-Agent Research Example:最完整的多 agent 研究工作区,包含可复用 backend、skill 和本地 tool
679
+ - `examples/08_long-term-memory-learning/` 是 Long-Term Memory Learning Example:通过多次 request 写入 durable memory、检查 recall,并让后续回答更懂上下文
675
680
 
676
681
  `resources/tools/` 下的工作区本地工具模块应统一用 `tool({...})` 导出。
677
682
  不支持历史/兼容写法,任何不带该导出形式的工具模块都会在工作区加载时被拒绝。
@@ -829,6 +834,12 @@ spec:
829
834
  - `formation.manager`:持久化前的规则式或模型式 candidate 归一化
830
835
  - `formation.background`:在 run 完成或 approval resolve 后做 reflection
831
836
 
837
+ ### `config/knowledge/knowledge-runtime.yaml`
838
+
839
+ 当同一套 durable-memory policy 还需要运行在 `AgentHarnessRuntime` 之外,例如独立 knowledge worker 或 knowledge server 时,使用这个单例对象。
840
+
841
+ `KnowledgeRuntime` 故意镜像 durable policy 的主形状。`RuntimeMemory` 继续承载 runtime 内部默认值;而当外部 knowledge service 也需要同一套 memorize/recall policy 时,再保留 `KnowledgeRuntime` 作为可外置的镜像对象。
842
+
832
843
  ### `config/catalogs/backends.yaml`
833
844
 
834
845
  可复用的后端预设,使文件系统与 `/memories/*` 拓扑保留在 YAML 中:
@@ -918,7 +929,7 @@ spec:
918
929
  maxFileSizeMb: 10
919
930
  sessionStorage:
920
931
  enabled: true
921
- rootDir: "{runRoot}/threads/{threadId}/filesystem"
932
+ rootDir: "{runRoot}/sessions/{sessionId}/filesystem"
922
933
  middleware: []
923
934
  systemPrompt: Answer simple requests directly.
924
935
  ```
@@ -1025,7 +1036,7 @@ ACP transport 说明:
1025
1036
  - `serveAcpHttp(runtime)` 提供基于 HTTP 的 JSON-RPC 与 SSE runtime events,适合远程界面或独立控制面接入。
1026
1037
  - ACP transport 现已覆盖核心参考客户端流程验证:capability discovery、request submit、session lookup、request lookup、invalid JSON 处理、无 id notification 不返回响应,以及 stdio JSON-RPC 与 HTTP + SSE runtime notifications。
1027
1038
  - 现在还额外有一条跨协议一致性回归门:ACP 发起的 request、A2A 读取或继续的 task,以及 runtime MCP 暴露的检查结果,必须始终指向同一组持久化 `sessionId` / `requestId` 运行时记录,不能漂移成各协议各自维护的标识体系。
1028
- - 如果要从最薄的一层 editor / CLI starter 开始,优先用 `agent-harness acp serve --workspace . --transport stdio`,并直接参考 `examples/protocol-hello-world/app/acp-stdio-hello-world.mjs` 的 wire shape。需要在应用内使用 reference client 时,可直接用 `createAcpStdioClient(...)` 发起 JSON-RPC 请求并分流 runtime notifications,避免每个 sidecar 自己重写 line parsing。
1039
+ - 如果要从最薄的一层 editor / CLI starter 开始,优先用 `agent-harness acp serve --workspace . --transport stdio`,并直接参考 `examples/03_protocol-surfaces/app/acp-stdio/main.mjs` 的 wire shape。需要在应用内使用 reference client 时,可直接用 `createAcpStdioClient(...)` 发起 JSON-RPC 请求并分流 runtime notifications,避免每个 sidecar 自己重写 line parsing。
1029
1040
  - `serveA2aHttp(runtime)` 提供 A2A HTTP JSON-RPC bridge 与 agent card discovery,同时兼容 `message/send` 这类旧方法,以及 `SendMessage`、`SendStreamingMessage`、`GetTask`、`ListTasks`、`CancelTask`、`SubscribeToTask`、`GetAgentCard`、`GetExtendedAgentCard` 与 task push-notification config 这类 A2A v1.0 方法,并统一映射到现有 session/request 运行记录。bridge 现在会同时声明 `1.0` 与 `0.3` 两个 JSON-RPC interface、在 agent card 路径上响应 `HEAD` / `OPTIONS` discovery、写出支持版本的 discovery headers、可选暴露 registry URL 与 detached signed-card metadata 供外围发现系统使用、校验 `A2A-Version`、把 `A2A-Extensions` 记录进 runtime invocation metadata、发布 `TASK_STATE_*` 状态与 `SendMessage` 的 `{ task }` wrapper、在 v1 streaming 方法上先通过 SSE 输出 `{ task }` 初始快照,再输出 `{ statusUpdate }` 增量状态,并可向已配置的 webhook receiver 发送 best-effort task push notifications。
1030
1041
  - `serveAgUiHttp(runtime)` 提供 AG-UI HTTP SSE bridge,把 runtime 生命周期、文本输出、upstream thinking、step 进度与 tool call 投影成 `RUN_*`、`TEXT_MESSAGE_*`、`THINKING_TEXT_MESSAGE_*`、`STEP_*` 与 `TOOL_CALL_*` 事件,便于 UI 客户端直接接入。
1031
1042
  - `createRuntimeMcpServer(runtime)` 与 `serveRuntimeMcpOverStdio(runtime)` 会把持久化 runtime 控制面本身暴露成 MCP tools,包括 sessions、requests、approvals、artifacts、events 与 package export helpers。
@@ -8,7 +8,7 @@ spec:
8
8
  name: default
9
9
  description: Default sqlite-backed store preset for runtime-managed agent state and durable memory.
10
10
  storeKind: SqliteStore
11
- path: store.sqlite
11
+ path: knowledge/records.sqlite
12
12
 
13
13
  # agent-harness feature: reusable checkpointer preset for resumable execution state.
14
14
  - kind: Checkpointer
@@ -13,7 +13,7 @@ spec:
13
13
  storeKind: LibSQLVectorStore
14
14
  # LangChain aligned feature: libSQL connection URL.
15
15
  # Local SQLite files use the `file:` prefix.
16
- url: file:.agent/vector-store.db
16
+ url: file:.agent/knowledge/vectors.sqlite
17
17
  # LangChain aligned feature: target table and embedding column.
18
18
  table: rag_chunks
19
19
  column: embedding
@@ -0,0 +1,60 @@
1
+ ## agent-harness feature: schema version for this declarative config object.
2
+ apiVersion: agent-harness/v1alpha1
3
+ ## agent-harness feature: standalone durable knowledge runtime defaults.
4
+ ## This object mirrors the runtime memory policy shape for future knowledge workers or servers.
5
+ kind: KnowledgeRuntime
6
+ metadata:
7
+ ## agent-harness feature: stable singleton name for the default knowledge runtime object.
8
+ name: default
9
+ spec:
10
+ ## agent-harness feature: enable or disable standalone durable knowledge policy.
11
+ enabled: true
12
+ store:
13
+ ## agent-harness feature: primary durable store used by the standalone knowledge runtime.
14
+ ref: store/default
15
+ vectorStore:
16
+ ## agent-harness feature: optional semantic retrieval substrate for standalone knowledge recall.
17
+ ref: vector-store/default
18
+ embeddingModel:
19
+ ## agent-harness feature: default embedding model used with the configured vector store.
20
+ ref: embedding-model/default
21
+ namespaces:
22
+ ## agent-harness feature: stable namespace roots shared with runtime memory policy.
23
+ users: memories/users/{userId}
24
+ projects: memories/projects/{projectId}
25
+ sessions: memories/sessions/{sessionId}
26
+ agents: memories/agents/{agentId}
27
+ workspaces: memories/workspaces/{workspaceId}
28
+ retrieval:
29
+ ## agent-harness feature: bounded retrieval defaults for standalone knowledge recall.
30
+ defaultTopK: 5
31
+ maxPromptMemories: 8
32
+ consolidation:
33
+ ## agent-harness feature: background consolidation and retention defaults.
34
+ dedupe: true
35
+ decay:
36
+ enabled: true
37
+ maxAgeDays: 180
38
+ formation:
39
+ ## agent-harness feature: LangMem-style formation defaults shared with the standalone module.
40
+ hotPath:
41
+ enabled: true
42
+ manager:
43
+ enabled: true
44
+ strategy: rules
45
+ maxContextRecords: 12
46
+ background:
47
+ enabled: true
48
+ scopes:
49
+ - thread
50
+ stateStorePath: knowledge/formation-state.json
51
+ maxMessagesPerRun: 40
52
+ writeOnApprovalResolution: true
53
+ writeOnRunCompletion: true
54
+ mem0:
55
+ ## agent-harness feature: optional Mem0 OSS ingestion defaults for standalone knowledge extraction.
56
+ enabled: false
57
+ apiKeyEnv: MEM0_API_KEY
58
+ appId: agent-harness
59
+ stateStorePath: knowledge/mem0-sync-state.json
60
+ maxMessagesPerRun: 200
@@ -30,7 +30,7 @@ spec:
30
30
  namespaces:
31
31
  users: memories/users/{userId}
32
32
  projects: memories/projects/{projectId}
33
- threads: memories/threads/{threadId}
33
+ sessions: memories/sessions/{sessionId}
34
34
  agents: memories/agents/{agentId}
35
35
  workspaces: memories/workspaces/{workspaceId}
36
36
 
@@ -78,7 +78,7 @@ spec:
78
78
  enabled: true
79
79
  scopes:
80
80
  - thread
81
- stateStorePath: runtime-memory-formation-state.json
81
+ stateStorePath: knowledge/formation-state.json
82
82
  maxMessagesPerRun: 40
83
83
  writeOnApprovalResolution: true
84
84
  writeOnRunCompletion: true
@@ -92,5 +92,5 @@ spec:
92
92
  enabled: false
93
93
  apiKeyEnv: MEM0_API_KEY
94
94
  appId: agent-harness
95
- stateStorePath: mem0-sync-state.json
95
+ stateStorePath: knowledge/mem0-sync-state.json
96
96
  maxMessagesPerRun: 200
@@ -281,6 +281,15 @@ export type MemorizeInput = {
281
281
  projectId?: string;
282
282
  recordedAt?: string;
283
283
  };
284
+ export type KnowledgeRuntimeContext = {
285
+ sessionId?: string;
286
+ requestId?: string;
287
+ agentId?: string;
288
+ workspaceId: string;
289
+ userId?: string;
290
+ projectId?: string;
291
+ recordedAt?: string;
292
+ };
284
293
  export type MemorizeResult = {
285
294
  records: MemoryRecord[];
286
295
  decisions: MemoryDecision[];
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { AgentHarnessAcpServer, AgentHarnessRuntime, cancelRun, createAgentHarness, createAcpServer, createAcpStdioClient, createRuntimeMcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, exportFlow, exportSequence, exportRequestPackage, exportSessionPackage, replayEvaluationBundle, getArtifact, getAgent, getApproval, getOperatorOverview, getRequest, getHealth, listMemories, listRequestTraceItems, getSession, listAgentSkills, listArtifacts, listApprovals, listRequests, listRequestEvents, listSessionSummaries, listSessions, memorize, normalizeUserChatInput, request, recall, removeMemory, resolveApproval, serveA2aHttp, serveAcpHttp, serveAcpStdio, serveAgUiHttp, serveRuntimeMcpOverStdio, serveToolsOverStdio, subscribe, stop, updateMemory, } from "./api.js";
2
+ export { createKnowledgeModule, readKnowledgeRuntimeConfig } from "./knowledge/index.js";
2
3
  export type { AcpApproval, AcpArtifact, AcpEventNotification, AcpJsonRpcError, AcpJsonRpcRequest, AcpJsonRpcResponse, AcpJsonRpcSuccess, AcpRequestRecord, AcpRunRequestParams, AcpServerCapabilities, AcpSessionRecord, AcpStdioClient, AcpStdioClientOptions, } from "./acp.js";
3
4
  export type { Approval, ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, NormalizeUserChatInputOptions, OperatorOverview, PublicRunListeners, RequestArtifactListing, RequestEvent, RequestEventType, RequestPackage, RequestPackageInput, RequestFlowGraphInput, RequestResult, RequestTraceItem, RecallInput, RecallResult, RemoveMemoryInput, RuntimeEvaluationExport, RuntimeEvaluationExportInput, RuntimeEvaluationReplayInput, RuntimeEvaluationReplayResult, SessionListSummary, RuntimeSessionPackage, RuntimeSessionPackageInput, UpdateMemoryInput, UserChatInput, UserChatMessage, } from "./api.js";
5
+ export type { KnowledgeListInput, KnowledgeMemorizeInput, KnowledgeModule, KnowledgeModuleDependencies, KnowledgeRecallInput, KnowledgeRuntimeConfig, KnowledgeRuntimeContext, } from "./knowledge/index.js";
4
6
  export type { A2aAgentCard, A2aHttpServer, A2aHttpServerOptions, A2aTask, A2aTaskState, AcpHttpServer, AcpHttpServerOptions, AcpStdioServer, AcpStdioServerOptions, AgUiEvent, AgUiHttpServer, AgUiHttpServerOptions, AgUiRunAgentInput, } from "./api.js";
5
7
  export type { RuntimeMcpServerOptions, ToolMcpServerOptions } from "./mcp.js";
6
8
  export { tool } from "./tools.js";
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { AgentHarnessAcpServer, AgentHarnessRuntime, cancelRun, createAgentHarness, createAcpServer, createAcpStdioClient, createRuntimeMcpServer, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, exportEvaluationBundle, exportFlow, exportSequence, exportRequestPackage, exportSessionPackage, replayEvaluationBundle, getArtifact, getAgent, getApproval, getOperatorOverview, getRequest, getHealth, listMemories, listRequestTraceItems, getSession, listAgentSkills, listArtifacts, listApprovals, listRequests, listRequestEvents, listSessionSummaries, listSessions, memorize, normalizeUserChatInput, request, recall, removeMemory, resolveApproval, serveA2aHttp, serveAcpHttp, serveAcpStdio, serveAgUiHttp, serveRuntimeMcpOverStdio, serveToolsOverStdio, subscribe, stop, updateMemory, } from "./api.js";
2
+ export { createKnowledgeModule, readKnowledgeRuntimeConfig } from "./knowledge/index.js";
2
3
  export { tool } from "./tools.js";
@@ -69,11 +69,14 @@ ${providerEnvLine}npm run start -- "Research the latest model serving stack for
69
69
 
70
70
  - \`src/run.mjs\`: minimal launcher
71
71
  - \`config/\`: workspace runtime and agent topology
72
+ - \`config/knowledge/knowledge-runtime.yaml\`: optional standalone durable-knowledge policy mirror
72
73
  - \`resources/\`: place local \`tool({...})\` tools and skills here as your product grows
73
74
 
74
75
  ## Customize
75
76
 
76
77
  - change \`config/catalogs/models.yaml\` to switch models or providers
78
+ - keep \`config/runtime/runtime-memory.yaml\` for runtime-owned durable memory defaults
79
+ - keep \`config/knowledge/knowledge-runtime.yaml\` when the same policy should also run in a standalone knowledge worker or server
77
80
  - add local \`tool({...})\` tools under \`resources/tools/\`
78
81
  - add product-specific skills under \`resources/skills/\`
79
82
  - edit the prompts in \`config/agents/\` to turn this into your own product
@@ -140,11 +143,11 @@ spec:
140
143
  enabled: true
141
144
  store:
142
145
  kind: SqliteStore
143
- path: runtime-memory.sqlite
146
+ path: knowledge/records.sqlite
144
147
  namespaces:
145
148
  users: memories/users/{userId}
146
149
  projects: memories/projects/{projectId}
147
- threads: memories/threads/{threadId}
150
+ sessions: memories/sessions/{sessionId}
148
151
  agents: memories/agents/{agentId}
149
152
  workspaces: memories/workspaces/{workspaceId}
150
153
  retrieval:
@@ -176,7 +179,7 @@ spec:
176
179
  enabled: true
177
180
  scopes:
178
181
  - thread
179
- stateStorePath: runtime-memory-formation-state.json
182
+ stateStorePath: knowledge/formation-state.json
180
183
  maxMessagesPerRun: 40
181
184
  writeOnApprovalResolution: true
182
185
  writeOnRunCompletion: true
@@ -186,7 +189,49 @@ spec:
186
189
  enabled: false
187
190
  apiKeyEnv: MEM0_API_KEY
188
191
  appId: ${projectSlug}
189
- stateStorePath: mem0-sync-state.json
192
+ stateStorePath: knowledge/mem0-sync-state.json
193
+ maxMessagesPerRun: 200
194
+ `;
195
+ }
196
+ function renderKnowledgeRuntimeYaml(projectSlug) {
197
+ return `apiVersion: agent-harness/v1alpha1
198
+ kind: KnowledgeRuntime
199
+ metadata:
200
+ name: default
201
+ spec:
202
+ enabled: true
203
+ store:
204
+ kind: SqliteStore
205
+ path: knowledge/records.sqlite
206
+ namespaces:
207
+ users: memories/users/{userId}
208
+ projects: memories/projects/{projectId}
209
+ sessions: memories/sessions/{sessionId}
210
+ agents: memories/agents/{agentId}
211
+ workspaces: memories/workspaces/{workspaceId}
212
+ retrieval:
213
+ defaultTopK: 5
214
+ maxPromptMemories: 8
215
+ formation:
216
+ hotPath:
217
+ enabled: true
218
+ manager:
219
+ enabled: true
220
+ strategy: rules
221
+ maxContextRecords: 12
222
+ background:
223
+ enabled: true
224
+ scopes:
225
+ - thread
226
+ stateStorePath: knowledge/formation-state.json
227
+ maxMessagesPerRun: 40
228
+ writeOnApprovalResolution: true
229
+ writeOnRunCompletion: true
230
+ mem0:
231
+ enabled: false
232
+ apiKeyEnv: MEM0_API_KEY
233
+ appId: ${projectSlug}
234
+ stateStorePath: knowledge/mem0-sync-state.json
190
235
  maxMessagesPerRun: 200
191
236
  `;
192
237
  }
@@ -346,6 +391,7 @@ export async function initProject(projectRoot, projectName, options = {}) {
346
391
  ["config/runtime/workspace.yaml", renderWorkspaceYaml()],
347
392
  ["config/agent-context.md", renderAgentContext(resolved)],
348
393
  ["config/catalogs/models.yaml", renderModelsYaml(resolved)],
394
+ ["config/knowledge/knowledge-runtime.yaml", renderKnowledgeRuntimeYaml(projectSlug)],
349
395
  ["config/runtime/runtime-memory.yaml", renderRuntimeMemoryYaml(projectSlug)],
350
396
  ["config/catalogs/backends.yaml", renderBackendsYaml()],
351
397
  ["config/catalogs/tools.yaml", renderToolsYaml(resolved)],
@@ -0,0 +1,11 @@
1
+ import type { ResolvedMem0Config } from "../runtime/harness/system/mem0-ingestion-sync.js";
2
+ import { type ResolvedRuntimeMemoryFormationConfig } from "../runtime/harness/system/runtime-memory-manager.js";
3
+ import { type ResolvedRuntimeMemoryMaintenanceConfig, type ResolvedRuntimeMemoryPolicyConfig } from "../runtime/harness/system/runtime-memory-policy.js";
4
+ export type KnowledgeRuntimeConfig = {
5
+ enabled: boolean;
6
+ policy: ResolvedRuntimeMemoryPolicyConfig | null;
7
+ maintenance: ResolvedRuntimeMemoryMaintenanceConfig | null;
8
+ formation: ResolvedRuntimeMemoryFormationConfig | null;
9
+ mem0: ResolvedMem0Config | null;
10
+ };
11
+ export declare function readKnowledgeRuntimeConfig(runtimeMemory: Record<string, unknown> | undefined, workspaceRoot: string): KnowledgeRuntimeConfig;
@@ -0,0 +1,32 @@
1
+ import { readRuntimeMemoryFormationConfig, } from "../runtime/harness/system/runtime-memory-manager.js";
2
+ import { readRuntimeMemoryMaintenanceConfig, readRuntimeMemoryPolicyConfig, } from "../runtime/harness/system/runtime-memory-policy.js";
3
+ import { readMem0RuntimeConfig } from "../runtime/harness/system/mem0-ingestion-sync.js";
4
+ function asObject(value) {
5
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
6
+ }
7
+ function readKnowledgeRuntimeSpec(source) {
8
+ const typed = asObject(source);
9
+ if (!typed) {
10
+ return undefined;
11
+ }
12
+ const kind = typeof typed.kind === "string" ? typed.kind : undefined;
13
+ const hasTypedEnvelope = typeof typed.apiVersion === "string" || !!asObject(typed.metadata);
14
+ if (kind === "KnowledgeRuntime" || kind === "RuntimeMemory") {
15
+ return asObject(typed.spec);
16
+ }
17
+ if (hasTypedEnvelope && asObject(typed.spec)) {
18
+ return asObject(typed.spec);
19
+ }
20
+ return typed;
21
+ }
22
+ export function readKnowledgeRuntimeConfig(runtimeMemory, workspaceRoot) {
23
+ const runtimeMemorySpec = readKnowledgeRuntimeSpec(runtimeMemory);
24
+ const enabled = runtimeMemorySpec?.enabled === true;
25
+ return {
26
+ enabled,
27
+ policy: readRuntimeMemoryPolicyConfig(runtimeMemorySpec, workspaceRoot) ?? null,
28
+ maintenance: readRuntimeMemoryMaintenanceConfig(runtimeMemorySpec) ?? null,
29
+ formation: readRuntimeMemoryFormationConfig(runtimeMemorySpec, workspaceRoot) ?? null,
30
+ mem0: readMem0RuntimeConfig(runtimeMemorySpec, workspaceRoot) ?? null,
31
+ };
32
+ }
@@ -0,0 +1,45 @@
1
+ import type { KnowledgeRuntimeContext, ListMemoriesInput, ListMemoriesResult, MemoryCandidate, MemoryKind, MemoryRecord, MemoryScope, MemorizeInputRecord, MemorizeResult, RecallResult, RemoveMemoryInput, UpdateMemoryInput } from "../contracts/types.js";
2
+ export type { KnowledgeRuntimeContext } from "../contracts/types.js";
3
+ import type { ResolvedRuntimeMemoryMaintenanceConfig, ResolvedRuntimeMemoryPolicyConfig } from "../runtime/harness/system/runtime-memory-policy.js";
4
+ import type { StoreLike } from "../runtime/harness/system/store.js";
5
+ import type { VectorStoreRuntimeLike } from "../runtime/support/llamaindex.js";
6
+ import type { Mem0SearchInput, Mem0SearchResult } from "../runtime/harness/system/mem0-ingestion-sync.js";
7
+ export type KnowledgeMemorizeInput = {
8
+ records: MemorizeInputRecord[];
9
+ storeCandidateLog?: boolean;
10
+ };
11
+ export type KnowledgeRecallInput = {
12
+ query: string;
13
+ scopes?: MemoryScope[];
14
+ kinds?: MemoryKind[];
15
+ topK?: number;
16
+ includeStale?: boolean;
17
+ };
18
+ export type KnowledgeListInput = Omit<ListMemoriesInput, "sessionId" | "agentId" | "workspaceId" | "userId" | "projectId">;
19
+ export type KnowledgeNamespaceResolver = (scope: MemoryScope, context: KnowledgeRuntimeContext) => string[];
20
+ export type KnowledgeVectorStore = Pick<VectorStoreRuntimeLike, "similaritySearch" | "addDocuments" | "delete">;
21
+ export type KnowledgeMem0Recall = {
22
+ search(input: Mem0SearchInput): Promise<Mem0SearchResult[]>;
23
+ };
24
+ export type KnowledgeCandidateTransformer = (input: {
25
+ candidates: MemoryCandidate[];
26
+ context: KnowledgeRuntimeContext;
27
+ existingRecords: MemoryRecord[];
28
+ }) => Promise<MemoryCandidate[]>;
29
+ export type KnowledgeModuleDependencies = {
30
+ store: StoreLike;
31
+ policy: ResolvedRuntimeMemoryPolicyConfig | null;
32
+ maintenanceConfig: ResolvedRuntimeMemoryMaintenanceConfig | null;
33
+ resolveNamespace: KnowledgeNamespaceResolver;
34
+ resolveVectorStore: () => Promise<KnowledgeVectorStore | null>;
35
+ transformCandidates?: KnowledgeCandidateTransformer;
36
+ getMem0SemanticRecall?: () => KnowledgeMem0Recall | null | undefined;
37
+ };
38
+ export type KnowledgeModule = {
39
+ memorize(input: KnowledgeMemorizeInput, context: KnowledgeRuntimeContext): Promise<MemorizeResult>;
40
+ recall(input: KnowledgeRecallInput, context: KnowledgeRuntimeContext): Promise<RecallResult>;
41
+ buildPromptContext(input: KnowledgeRecallInput, context: KnowledgeRuntimeContext): Promise<string | undefined>;
42
+ list(input: KnowledgeListInput, context: KnowledgeRuntimeContext): Promise<ListMemoriesResult>;
43
+ update(input: UpdateMemoryInput, context: KnowledgeRuntimeContext): Promise<MemoryRecord>;
44
+ remove(input: RemoveMemoryInput, context: KnowledgeRuntimeContext): Promise<MemoryRecord>;
45
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export { readKnowledgeRuntimeConfig } from "./config.js";
2
+ export type { KnowledgeRuntimeConfig } from "./config.js";
3
+ export type { KnowledgeListInput, KnowledgeMemorizeInput, KnowledgeModule, KnowledgeModuleDependencies, KnowledgeNamespaceResolver, KnowledgeRecallInput, KnowledgeRuntimeContext, } from "./contracts.js";
4
+ export { createKnowledgeModule, DefaultKnowledgeModule } from "./module.js";
@@ -0,0 +1,2 @@
1
+ export { readKnowledgeRuntimeConfig } from "./config.js";
2
+ export { createKnowledgeModule, DefaultKnowledgeModule } from "./module.js";
@@ -0,0 +1,21 @@
1
+ import type { ListMemoriesResult, MemoryCandidate, MemoryRecord, MemorizeResult, RecallResult, UpdateMemoryInput, RemoveMemoryInput } from "../contracts/types.js";
2
+ import type { KnowledgeListInput, KnowledgeMemorizeInput, KnowledgeModule, KnowledgeModuleDependencies, KnowledgeRecallInput, KnowledgeRuntimeContext } from "./contracts.js";
3
+ export declare class DefaultKnowledgeModule implements KnowledgeModule {
4
+ private readonly deps;
5
+ constructor(deps: KnowledgeModuleDependencies);
6
+ memorize(input: KnowledgeMemorizeInput, context: KnowledgeRuntimeContext): Promise<MemorizeResult>;
7
+ recall(input: KnowledgeRecallInput, context: KnowledgeRuntimeContext): Promise<RecallResult>;
8
+ buildPromptContext(input: KnowledgeRecallInput, context: KnowledgeRuntimeContext): Promise<string | undefined>;
9
+ list(input: KnowledgeListInput | undefined, context: KnowledgeRuntimeContext): Promise<ListMemoriesResult>;
10
+ update(input: UpdateMemoryInput, context: KnowledgeRuntimeContext): Promise<MemoryRecord>;
11
+ remove(input: RemoveMemoryInput, context: KnowledgeRuntimeContext): Promise<MemoryRecord>;
12
+ memorizeCandidates(candidates: MemoryCandidate[], context: KnowledgeRuntimeContext, options: {
13
+ storeCandidateLog: boolean;
14
+ }): Promise<MemorizeResult>;
15
+ private refreshAfterWrite;
16
+ private appendMemoryDigest;
17
+ private refreshStructuredMemoryScope;
18
+ private rebuildVectorIndex;
19
+ private rankRecallCandidates;
20
+ }
21
+ export declare function createKnowledgeModule(dependencies: KnowledgeModuleDependencies): DefaultKnowledgeModule;