@botbotgo/agent-harness 0.0.154 → 0.0.156
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.
- package/README.md +34 -8
- package/README.zh.md +41 -8
- package/dist/api.d.ts +5 -2
- package/dist/api.js +9 -0
- package/dist/config/catalogs/stores.yaml +3 -3
- package/dist/config/catalogs/vector-stores.yaml +8 -1
- package/dist/config/runtime/runtime-memory.yaml +17 -0
- package/dist/contracts/runtime.d.ts +31 -0
- package/dist/contracts/workspace.d.ts +6 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/init-project.js +18 -0
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/runtime/harness/system/mem0-ingestion-sync.d.ts +28 -2
- package/dist/runtime/harness/system/mem0-ingestion-sync.js +112 -1
- package/dist/runtime/harness/system/runtime-memory-manager.d.ts +90 -0
- package/dist/runtime/harness/system/runtime-memory-manager.js +371 -0
- package/dist/runtime/harness/system/runtime-memory-records.d.ts +4 -0
- package/dist/runtime/harness/system/runtime-memory-records.js +57 -2
- package/dist/runtime/harness/system/store.d.ts +27 -0
- package/dist/runtime/harness/system/store.js +96 -0
- package/dist/runtime/harness.d.ts +21 -1
- package/dist/runtime/harness.js +469 -45
- package/dist/runtime/support/runtime-factories.js +5 -1
- package/dist/runtime/support/vector-stores.js +97 -0
- package/dist/workspace/object-loader.js +9 -44
- package/dist/workspace/resource-compilers.js +19 -0
- package/dist/workspace/yaml-object-reader.d.ts +0 -4
- package/dist/workspace/yaml-object-reader.js +6 -32
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -118,7 +118,7 @@ That means:
|
|
|
118
118
|
|
|
119
119
|
The runtime provides:
|
|
120
120
|
|
|
121
|
-
- `createAgentHarness(workspaceRoot)`, `run(...)`, `memorize(...)`, `recall(...)`, `resolveApproval(...)`, `subscribe(...)`, inspection methods, and `stop(...)`
|
|
121
|
+
- `createAgentHarness(workspaceRoot)`, `run(...)`, `memorize(...)`, `recall(...)`, `listMemories(...)`, `updateMemory(...)`, `removeMemory(...)`, `resolveApproval(...)`, `subscribe(...)`, inspection methods, and `stop(...)`
|
|
122
122
|
- YAML-defined workspace assembly for routing, models, tools, stores, backends, MCP, recovery, and maintenance
|
|
123
123
|
- backend-adapted execution with current LangChain v1 and DeepAgents adapters
|
|
124
124
|
- local `resources/tools/` `tool({...})` modules and `resources/skills/` discovery
|
|
@@ -291,6 +291,7 @@ If you want the shortest possible mental model:
|
|
|
291
291
|
- structured output and multimodal content preservation in run results
|
|
292
292
|
- MCP bridge support for agent-declared MCP servers
|
|
293
293
|
- MCP server support for exposing harness tools outward
|
|
294
|
+
- optional `mem0` semantic recall augmentation over canonical SQLite durable memory
|
|
294
295
|
|
|
295
296
|
### Runtime Strengths
|
|
296
297
|
|
|
@@ -413,10 +414,13 @@ const recalled = await recall(runtime, {
|
|
|
413
414
|
});
|
|
414
415
|
```
|
|
415
416
|
|
|
416
|
-
Use `memorize(...)` and `
|
|
417
|
+
Use `memorize(...)`, `recall(...)`, `listMemories(...)`, `updateMemory(...)`, and `removeMemory(...)` when an application needs a stable public runtime memory surface without importing internal `runtime/harness/system/*` modules.
|
|
417
418
|
|
|
418
419
|
- `memorize(...)` returns stable `MemoryRecord` and `MemoryDecision` results while leaving merge, review, archive, and storage layout runtime-managed
|
|
419
420
|
- `recall(...)` returns ranked `MemoryRecord` items filtered by runtime memory scope and kind
|
|
421
|
+
- `listMemories(...)` returns stable `MemoryRecord` items for inspection and admin workflows, defaulting to `active` records unless status filters are provided
|
|
422
|
+
- `updateMemory(...)` edits one durable memory record by `memoryId` without exposing internal store namespaces
|
|
423
|
+
- `removeMemory(...)` deletes one durable memory record by `memoryId` and rebuilds runtime-managed projections
|
|
420
424
|
- app-specific knowledge taxonomy, review UI, and admin surfaces still belong in the application layer
|
|
421
425
|
|
|
422
426
|
### Let The Runtime Route
|
|
@@ -466,6 +470,7 @@ The runtime event stream includes:
|
|
|
466
470
|
|
|
467
471
|
```ts
|
|
468
472
|
import {
|
|
473
|
+
deleteSession,
|
|
469
474
|
getSession,
|
|
470
475
|
getApproval,
|
|
471
476
|
listSessions,
|
|
@@ -484,6 +489,10 @@ if (approval) {
|
|
|
484
489
|
decision: "approve",
|
|
485
490
|
});
|
|
486
491
|
}
|
|
492
|
+
|
|
493
|
+
if (session && session.currentState === "completed") {
|
|
494
|
+
await deleteSession(runtime, session.sessionId);
|
|
495
|
+
}
|
|
487
496
|
```
|
|
488
497
|
|
|
489
498
|
These methods return runtime-facing records, not raw checkpoint or backend objects.
|
|
@@ -547,6 +556,13 @@ Core workspace files:
|
|
|
547
556
|
- `resources/tools/`
|
|
548
557
|
- `resources/skills/`
|
|
549
558
|
|
|
559
|
+
Discovery rules:
|
|
560
|
+
|
|
561
|
+
- every YAML document under `config/**` is discovered recursively; filenames and subfolders are organizational only
|
|
562
|
+
- YAML object semantics come from `kind`, `metadata.name` or `id`, and object content rather than the file path
|
|
563
|
+
- local tools are auto-discovered from `resources/tools/**/*.js|*.mjs|*.cjs` when they export `tool({...})`
|
|
564
|
+
- skills are auto-discovered from `resources/skills/**/SKILL.md`
|
|
565
|
+
|
|
550
566
|
Workspace-local tool modules in `resources/tools/` should be exported with `tool({...})`.
|
|
551
567
|
Any other local module shape is not supported, and unsupported shapes are rejected at load time.
|
|
552
568
|
|
|
@@ -562,7 +578,7 @@ There are three main configuration layers:
|
|
|
562
578
|
|
|
563
579
|
- runtime policy in `config/runtime/workspace.yaml`
|
|
564
580
|
- reusable object catalogs in `config/catalogs/*.yaml`
|
|
565
|
-
- agent assembly in `config
|
|
581
|
+
- agent assembly in `config/**/*.yaml`
|
|
566
582
|
|
|
567
583
|
### Backend Guidance
|
|
568
584
|
|
|
@@ -632,7 +648,7 @@ Use this file for shared bootstrap memory loaded at agent construction time.
|
|
|
632
648
|
|
|
633
649
|
Keep stable project context here. Treat it as startup context, not mutable long-term memory.
|
|
634
650
|
|
|
635
|
-
### `config
|
|
651
|
+
### Models Catalogs In `config/**`
|
|
636
652
|
|
|
637
653
|
Use named chat-model presets:
|
|
638
654
|
|
|
@@ -648,7 +664,9 @@ spec:
|
|
|
648
664
|
|
|
649
665
|
These load as `model/default`.
|
|
650
666
|
|
|
651
|
-
|
|
667
|
+
You can place `kind: Models` catalogs anywhere under `config/`; `config/catalogs/models.yaml` is only the recommended layout.
|
|
668
|
+
|
|
669
|
+
### Embedding Model Catalogs In `config/**`
|
|
652
670
|
|
|
653
671
|
Use named embedding-model presets for retrieval-oriented tools.
|
|
654
672
|
|
|
@@ -666,8 +684,8 @@ kind: Stores
|
|
|
666
684
|
spec:
|
|
667
685
|
- kind: Store
|
|
668
686
|
name: default
|
|
669
|
-
storeKind:
|
|
670
|
-
path: store.
|
|
687
|
+
storeKind: SqliteStore
|
|
688
|
+
path: store.sqlite
|
|
671
689
|
- kind: Checkpointer
|
|
672
690
|
name: default
|
|
673
691
|
checkpointerKind: MemorySaver
|
|
@@ -683,6 +701,12 @@ Use this singleton file for runtime-owned durable long-term memory defaults.
|
|
|
683
701
|
|
|
684
702
|
Keep bootstrap context in `config/agent-context.md`. Keep resumable execution state in the checkpointer. Use `RuntimeMemory` for durable memory policy and retrieval defaults.
|
|
685
703
|
|
|
704
|
+
`RuntimeMemory` also carries LangMem-style formation defaults:
|
|
705
|
+
|
|
706
|
+
- `formation.hotPath` for immediate write-time capture
|
|
707
|
+
- `formation.manager` for rule-driven or model-driven candidate normalization before persistence
|
|
708
|
+
- `formation.background` for reflection after run completion or approval resolution
|
|
709
|
+
|
|
686
710
|
### `config/catalogs/backends.yaml`
|
|
687
711
|
|
|
688
712
|
Use reusable DeepAgents backend presets so filesystem and `/memories/*` topology stays in YAML:
|
|
@@ -733,10 +757,12 @@ spec:
|
|
|
733
757
|
|
|
734
758
|
`spec[].kind` can be omitted here; catalog entries default to `McpServer`.
|
|
735
759
|
|
|
736
|
-
### `config
|
|
760
|
+
### Agents In `config/**`
|
|
737
761
|
|
|
738
762
|
Agents always use `kind: Agent` plus `spec.backend`.
|
|
739
763
|
|
|
764
|
+
Agent YAML can live anywhere under `config/`; `config/agents/*.yaml` is the recommended layout, not a loader requirement.
|
|
765
|
+
|
|
740
766
|
Use two sections:
|
|
741
767
|
|
|
742
768
|
- `spec.runtime` for harness-owned runtime placement such as `spec.runtime.runRoot`
|
package/README.zh.md
CHANGED
|
@@ -118,7 +118,7 @@ AI 让 agent 逻辑、工具调用和工作流代码更容易生成,真正更
|
|
|
118
118
|
|
|
119
119
|
运行时提供:
|
|
120
120
|
|
|
121
|
-
- `createAgentHarness(workspaceRoot)`、`run(...)`、`memorize(...)`、`recall(...)`、`resolveApproval(...)`、`subscribe(...)`、各类查询方法,以及 `stop(...)`
|
|
121
|
+
- `createAgentHarness(workspaceRoot)`、`run(...)`、`memorize(...)`、`recall(...)`、`listMemories(...)`、`updateMemory(...)`、`removeMemory(...)`、`resolveApproval(...)`、`subscribe(...)`、各类查询方法,以及 `stop(...)`
|
|
122
122
|
- 以 YAML 描述的工作区装配:路由、模型、工具、存储、后端、MCP、恢复与维护等
|
|
123
123
|
- 通过适配器对接当前的 LangChain v1 与 DeepAgents 执行
|
|
124
124
|
- 本地 `resources/tools/` 中 `tool({...})` 工具模块与 `resources/skills/` 的发现
|
|
@@ -360,6 +360,8 @@ const result = await run(runtime, {
|
|
|
360
360
|
- `invocation.inputs`:结构化运行时输入
|
|
361
361
|
- `invocation.attachments`:当前后端可解释的类附件负载
|
|
362
362
|
|
|
363
|
+
可选地,runtime memory 还可以在 SQLite canonical durable memory 之上叠加 `mem0` 语义召回增强,用于更强的长期知识命中,而不改变正式知识记录的 contract。
|
|
364
|
+
|
|
363
365
|
### 写入与召回 durable runtime memory
|
|
364
366
|
|
|
365
367
|
```ts
|
|
@@ -384,10 +386,13 @@ const recalled = await recall(runtime, {
|
|
|
384
386
|
});
|
|
385
387
|
```
|
|
386
388
|
|
|
387
|
-
当应用需要稳定的公开 runtime memory 接口,而不想依赖内部 `runtime/harness/system/*` 模块时,使用 `memorize(...)` 与 `
|
|
389
|
+
当应用需要稳定的公开 runtime memory 接口,而不想依赖内部 `runtime/harness/system/*` 模块时,使用 `memorize(...)`、`recall(...)`、`listMemories(...)`、`updateMemory(...)` 与 `removeMemory(...)`。
|
|
388
390
|
|
|
389
391
|
- `memorize(...)` 返回稳定的 `MemoryRecord` 与 `MemoryDecision` 结果,而 merge、review、archive 与存储布局仍由 runtime 内部托管
|
|
390
392
|
- `recall(...)` 返回按相关性排序、并按 scope / kind 过滤后的 `MemoryRecord`
|
|
393
|
+
- `listMemories(...)` 返回稳定的 `MemoryRecord`,用于 inspection / admin 场景;如果不传 status 过滤器,默认只返回 `active`
|
|
394
|
+
- `updateMemory(...)` 通过 `memoryId` 更新单条 durable memory,而不暴露内部 store namespace
|
|
395
|
+
- `removeMemory(...)` 通过 `memoryId` 删除单条 durable memory,并重建运行时托管的 projection
|
|
391
396
|
- 业务知识分类、review UI 与管理后台仍应留在应用层
|
|
392
397
|
|
|
393
398
|
### 由运行时路由
|
|
@@ -437,6 +442,7 @@ const result = await run(runtime, {
|
|
|
437
442
|
|
|
438
443
|
```ts
|
|
439
444
|
import {
|
|
445
|
+
deleteSession,
|
|
440
446
|
getApproval,
|
|
441
447
|
getSession,
|
|
442
448
|
listApprovals,
|
|
@@ -455,6 +461,10 @@ if (approval) {
|
|
|
455
461
|
decision: "approve",
|
|
456
462
|
});
|
|
457
463
|
}
|
|
464
|
+
|
|
465
|
+
if (session && session.currentState === "completed") {
|
|
466
|
+
await deleteSession(runtime, session.sessionId);
|
|
467
|
+
}
|
|
458
468
|
```
|
|
459
469
|
|
|
460
470
|
这些方法返回面向运行时的记录,而非原始 checkpoint 或后端对象。
|
|
@@ -518,6 +528,13 @@ await stop(runtime);
|
|
|
518
528
|
- `resources/tools/`
|
|
519
529
|
- `resources/skills/`
|
|
520
530
|
|
|
531
|
+
发现规则:
|
|
532
|
+
|
|
533
|
+
- `config/**` 下的所有 YAML 文档都会被递归发现;文件名与子目录只用于组织,不参与语义
|
|
534
|
+
- YAML 对象语义由 `kind`、`metadata.name` 或 `id` 以及对象内容决定,而不是由文件路径决定
|
|
535
|
+
- 本地工具会从 `resources/tools/**/*.js|*.mjs|*.cjs` 中自动发现,前提是模块导出 `tool({...})`
|
|
536
|
+
- skills 会从 `resources/skills/**/SKILL.md` 自动发现
|
|
537
|
+
|
|
521
538
|
`resources/tools/` 下的工作区本地工具模块应统一用 `tool({...})` 导出。
|
|
522
539
|
不支持历史/兼容写法,任何不带该导出形式的工具模块都会在工作区加载时被拒绝。
|
|
523
540
|
|
|
@@ -527,7 +544,7 @@ await stop(runtime);
|
|
|
527
544
|
- agent 再按名字白名单选择 tools 与 skills
|
|
528
545
|
- `config/runtime/workspace.yaml` 中的运行时策略
|
|
529
546
|
- `config/catalogs/*.yaml` 中的可复用对象目录
|
|
530
|
-
- `config
|
|
547
|
+
- `config/**/*.yaml` 中的 agent 装配
|
|
531
548
|
|
|
532
549
|
### Backend 选择建议
|
|
533
550
|
|
|
@@ -600,7 +617,7 @@ spec:
|
|
|
600
617
|
|
|
601
618
|
在此放置稳定的项目上下文;视为启动上下文,而非可变长期记忆。
|
|
602
619
|
|
|
603
|
-
### `config
|
|
620
|
+
### `config/**` 下的 Models Catalog
|
|
604
621
|
|
|
605
622
|
命名聊天模型预设:
|
|
606
623
|
|
|
@@ -616,7 +633,9 @@ spec:
|
|
|
616
633
|
|
|
617
634
|
加载为 `model/default`。
|
|
618
635
|
|
|
619
|
-
|
|
636
|
+
`kind: Models` catalog 可以放在 `config/` 下任意位置;`config/catalogs/models.yaml` 只是推荐布局。
|
|
637
|
+
|
|
638
|
+
### `config/**` 下的 Embedding Model Catalog
|
|
620
639
|
|
|
621
640
|
面向检索类工具的命名嵌入模型预设。
|
|
622
641
|
|
|
@@ -634,8 +653,8 @@ kind: Stores
|
|
|
634
653
|
spec:
|
|
635
654
|
- kind: Store
|
|
636
655
|
name: default
|
|
637
|
-
storeKind:
|
|
638
|
-
path: store.
|
|
656
|
+
storeKind: SqliteStore
|
|
657
|
+
path: store.sqlite
|
|
639
658
|
- kind: Checkpointer
|
|
640
659
|
name: default
|
|
641
660
|
checkpointerKind: MemorySaver
|
|
@@ -645,6 +664,18 @@ spec:
|
|
|
645
664
|
path: checkpoints.sqlite
|
|
646
665
|
```
|
|
647
666
|
|
|
667
|
+
### `config/runtime/runtime-memory.yaml`
|
|
668
|
+
|
|
669
|
+
这个单例文件用于配置 runtime 持有的 durable long-term memory 默认值。
|
|
670
|
+
|
|
671
|
+
把稳定启动上下文放在 `config/agent-context.md`,把可恢复执行状态留给 checkpointer,把长期记忆策略与检索默认值放在 `RuntimeMemory`。
|
|
672
|
+
|
|
673
|
+
`RuntimeMemory` 也承载 LangMem 风格的 formation 默认值:
|
|
674
|
+
|
|
675
|
+
- `formation.hotPath`:运行中的即时捕获
|
|
676
|
+
- `formation.manager`:持久化前的规则式或模型式 candidate 归一化
|
|
677
|
+
- `formation.background`:在 run 完成或 approval resolve 后做 reflection
|
|
678
|
+
|
|
648
679
|
### `config/catalogs/backends.yaml`
|
|
649
680
|
|
|
650
681
|
可复用的 DeepAgents 后端预设,使文件系统与 `/memories/*` 拓扑保留在 YAML 中:
|
|
@@ -693,10 +724,12 @@ spec:
|
|
|
693
724
|
|
|
694
725
|
这里可以省略 `spec[].kind`;catalog 项会默认按 `McpServer` 处理。
|
|
695
726
|
|
|
696
|
-
### `config
|
|
727
|
+
### `config/**` 下的 Agent YAML
|
|
697
728
|
|
|
698
729
|
Agent 始终使用 `kind: Agent` 以及 `spec.backend`。
|
|
699
730
|
|
|
731
|
+
Agent YAML 可以放在 `config/` 下任意位置;`config/agents/*.yaml` 是推荐布局,不是 loader 的硬性要求。
|
|
732
|
+
|
|
700
733
|
两个区块:
|
|
701
734
|
|
|
702
735
|
- `spec.runtime`:harness 侧运行时放置,例如 `spec.runtime.runRoot`
|
package/dist/api.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { CancelOptions, InvocationEnvelope, MemorizeInput, MemorizeResult, MessageContent, RecallInput, RecallResult, RequestRecord, RequestSummary, ResumeOptions, RunDecisionOptions, RunResult, RunStartOptions, RuntimeHealthSnapshot, RuntimeAdapterOptions, SessionRecord, SessionSummary, WorkspaceLoadOptions } from "./contracts/types.js";
|
|
1
|
+
import type { CancelOptions, InvocationEnvelope, ListMemoriesInput, ListMemoriesResult, MemoryRecord, MemorizeInput, MemorizeResult, MessageContent, RecallInput, RecallResult, RemoveMemoryInput, RequestRecord, RequestSummary, ResumeOptions, RunDecisionOptions, RunResult, RunStartOptions, RuntimeHealthSnapshot, RuntimeAdapterOptions, SessionRecord, SessionSummary, UpdateMemoryInput, WorkspaceLoadOptions } from "./contracts/types.js";
|
|
2
2
|
import { AgentHarnessRuntime } from "./runtime/harness.js";
|
|
3
3
|
import type { InventoryAgentRecord, InventorySkillRecord } from "./runtime/harness/system/inventory.js";
|
|
4
4
|
import type { RequirementAssessmentOptions } from "./runtime/harness/system/skill-requirements.js";
|
|
5
5
|
import type { ToolMcpServerOptions } from "./mcp.js";
|
|
6
6
|
export { AgentHarnessRuntime } from "./runtime/harness.js";
|
|
7
7
|
export { createUpstreamTimelineReducer } from "./upstream-events.js";
|
|
8
|
-
export type { MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, RecallInput, RecallResult, } from "./contracts/types.js";
|
|
8
|
+
export type { ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, RecallInput, RecallResult, RemoveMemoryInput, UpdateMemoryInput, } from "./contracts/types.js";
|
|
9
9
|
type PublicApprovalRecord = {
|
|
10
10
|
approvalId: string;
|
|
11
11
|
pendingActionId: string;
|
|
@@ -57,6 +57,9 @@ export declare function normalizeUserChatInput(input: UserChatInput, options?: N
|
|
|
57
57
|
export declare function run(runtime: AgentHarnessRuntime, options: PublicRunOptions): Promise<PublicRunResult>;
|
|
58
58
|
export declare function memorize(runtime: AgentHarnessRuntime, input: MemorizeInput): Promise<MemorizeResult>;
|
|
59
59
|
export declare function recall(runtime: AgentHarnessRuntime, input: RecallInput): Promise<RecallResult>;
|
|
60
|
+
export declare function listMemories(runtime: AgentHarnessRuntime, input?: ListMemoriesInput): Promise<ListMemoriesResult>;
|
|
61
|
+
export declare function updateMemory(runtime: AgentHarnessRuntime, input: UpdateMemoryInput): Promise<MemoryRecord>;
|
|
62
|
+
export declare function removeMemory(runtime: AgentHarnessRuntime, input: RemoveMemoryInput): Promise<MemoryRecord>;
|
|
60
63
|
export declare function subscribe(runtime: AgentHarnessRuntime, listener: Parameters<AgentHarnessRuntime["subscribe"]>[0]): () => void;
|
|
61
64
|
export declare function listSessions(runtime: AgentHarnessRuntime, filter?: Parameters<AgentHarnessRuntime["listThreads"]>[0]): Promise<SessionSummary[]>;
|
|
62
65
|
export declare function listRequests(runtime: AgentHarnessRuntime, filter?: {
|
package/dist/api.js
CHANGED
|
@@ -134,6 +134,15 @@ export async function memorize(runtime, input) {
|
|
|
134
134
|
export async function recall(runtime, input) {
|
|
135
135
|
return runtime.recall(input);
|
|
136
136
|
}
|
|
137
|
+
export async function listMemories(runtime, input = {}) {
|
|
138
|
+
return runtime.listMemories(input);
|
|
139
|
+
}
|
|
140
|
+
export async function updateMemory(runtime, input) {
|
|
141
|
+
return runtime.updateMemory(input);
|
|
142
|
+
}
|
|
143
|
+
export async function removeMemory(runtime, input) {
|
|
144
|
+
return runtime.removeMemory(input);
|
|
145
|
+
}
|
|
137
146
|
export function subscribe(runtime, listener) {
|
|
138
147
|
return runtime.subscribe(listener);
|
|
139
148
|
}
|
|
@@ -6,9 +6,9 @@ spec:
|
|
|
6
6
|
# agent-harness feature: reusable store preset for agent backends that need a durable key-value store.
|
|
7
7
|
- kind: Store
|
|
8
8
|
name: default
|
|
9
|
-
description: Default
|
|
10
|
-
storeKind:
|
|
11
|
-
path: store.
|
|
9
|
+
description: Default sqlite-backed store preset for runtime-managed agent state and durable memory.
|
|
10
|
+
storeKind: SqliteStore
|
|
11
|
+
path: store.sqlite
|
|
12
12
|
|
|
13
13
|
# agent-harness feature: reusable checkpointer preset for resumable execution state.
|
|
14
14
|
- kind: Checkpointer
|
|
@@ -9,7 +9,7 @@ spec:
|
|
|
9
9
|
# LangChain v1 Features
|
|
10
10
|
# ====================
|
|
11
11
|
# LangChain aligned feature: concrete vector store implementation.
|
|
12
|
-
# The built-in runtime currently supports `LibSQLVectorStore`
|
|
12
|
+
# The built-in runtime currently supports `LibSQLVectorStore`, `QdrantVectorStore`, and `LlamaIndexSimpleVectorStore`.
|
|
13
13
|
storeKind: LibSQLVectorStore
|
|
14
14
|
# LangChain aligned feature: libSQL connection URL.
|
|
15
15
|
# Local SQLite files use the `file:` prefix.
|
|
@@ -23,3 +23,10 @@ spec:
|
|
|
23
23
|
# ======================
|
|
24
24
|
# Retrieval tools use this to resolve their default embeddings when indexing or querying this vector store.
|
|
25
25
|
embeddingModelRef: embedding-model/default
|
|
26
|
+
|
|
27
|
+
- name: qdrant
|
|
28
|
+
storeKind: QdrantVectorStore
|
|
29
|
+
host: 127.0.0.1
|
|
30
|
+
port: 6333
|
|
31
|
+
collection: runtime_memory
|
|
32
|
+
embeddingModelRef: embedding-model/default
|
|
@@ -66,6 +66,23 @@ spec:
|
|
|
66
66
|
writeOnApprovalResolution: true
|
|
67
67
|
writeOnRunCompletion: true
|
|
68
68
|
|
|
69
|
+
# agent-harness feature: LangMem-style memory formation defaults for hot-path and background reflection.
|
|
70
|
+
formation:
|
|
71
|
+
hotPath:
|
|
72
|
+
enabled: true
|
|
73
|
+
manager:
|
|
74
|
+
enabled: true
|
|
75
|
+
strategy: rules
|
|
76
|
+
maxContextRecords: 12
|
|
77
|
+
background:
|
|
78
|
+
enabled: true
|
|
79
|
+
scopes:
|
|
80
|
+
- thread
|
|
81
|
+
stateStorePath: runtime-memory-formation-state.json
|
|
82
|
+
maxMessagesPerRun: 40
|
|
83
|
+
writeOnApprovalResolution: true
|
|
84
|
+
writeOnRunCompletion: true
|
|
85
|
+
|
|
69
86
|
# agent-harness feature: optional thread snapshot projection for operational state and pending approvals.
|
|
70
87
|
threadMemorySync:
|
|
71
88
|
enabled: true
|
|
@@ -195,6 +195,37 @@ export type RecallInput = {
|
|
|
195
195
|
export type RecallResult = {
|
|
196
196
|
items: MemoryRecord[];
|
|
197
197
|
};
|
|
198
|
+
export type ListMemoriesInput = {
|
|
199
|
+
scopes?: MemoryScope[];
|
|
200
|
+
kinds?: MemoryKind[];
|
|
201
|
+
status?: MemoryRecordStatus[];
|
|
202
|
+
threadId?: string;
|
|
203
|
+
agentId?: string;
|
|
204
|
+
workspaceId?: string;
|
|
205
|
+
userId?: string;
|
|
206
|
+
projectId?: string;
|
|
207
|
+
limit?: number;
|
|
208
|
+
};
|
|
209
|
+
export type ListMemoriesResult = {
|
|
210
|
+
items: MemoryRecord[];
|
|
211
|
+
};
|
|
212
|
+
export type UpdateMemoryInput = {
|
|
213
|
+
memoryId: string;
|
|
214
|
+
content?: string;
|
|
215
|
+
summary?: string;
|
|
216
|
+
status?: MemoryRecordStatus;
|
|
217
|
+
confidence?: number;
|
|
218
|
+
expiresAt?: string | null;
|
|
219
|
+
sourceType?: string;
|
|
220
|
+
sourceRefs?: string[];
|
|
221
|
+
tags?: string[];
|
|
222
|
+
observedAt?: string;
|
|
223
|
+
lastConfirmedAt?: string;
|
|
224
|
+
provenance?: Record<string, unknown>;
|
|
225
|
+
};
|
|
226
|
+
export type RemoveMemoryInput = {
|
|
227
|
+
memoryId: string;
|
|
228
|
+
};
|
|
198
229
|
/**
|
|
199
230
|
* Operator-facing projection of tool execution policy already compiled into a binding.
|
|
200
231
|
* This summarizes existing timeout, retry, validation, and retry-safety hints without
|
|
@@ -52,9 +52,12 @@ export type ParsedVectorStoreObject = {
|
|
|
52
52
|
id: string;
|
|
53
53
|
kind: string;
|
|
54
54
|
url?: string;
|
|
55
|
+
host?: string;
|
|
56
|
+
port?: number;
|
|
55
57
|
authToken?: string;
|
|
56
58
|
table?: string;
|
|
57
59
|
column?: string;
|
|
60
|
+
collection?: string;
|
|
58
61
|
embeddingModelRef?: string;
|
|
59
62
|
metadata?: Record<string, unknown>;
|
|
60
63
|
sourcePath: string;
|
|
@@ -112,9 +115,12 @@ export type CompiledVectorStore = {
|
|
|
112
115
|
id: string;
|
|
113
116
|
kind: string;
|
|
114
117
|
url?: string;
|
|
118
|
+
host?: string;
|
|
119
|
+
port?: number;
|
|
115
120
|
authToken?: string;
|
|
116
121
|
table?: string;
|
|
117
122
|
column?: string;
|
|
123
|
+
collection?: string;
|
|
118
124
|
embeddingModelRef?: string;
|
|
119
125
|
runtimeValue: string;
|
|
120
126
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { AgentHarnessRuntime, cancelRun, createAgentHarness, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, getAgent, getApproval, getRequest, getHealth, getSession, listAgentSkills, listApprovals, listRequests, listSessions, memorize, normalizeUserChatInput, recall, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
|
|
2
|
-
export type { MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, NormalizeUserChatInputOptions, RecallInput, RecallResult, UserChatInput, UserChatMessage, } from "./api.js";
|
|
1
|
+
export { AgentHarnessRuntime, cancelRun, createAgentHarness, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, getAgent, getApproval, getRequest, getHealth, listMemories, getSession, listAgentSkills, listApprovals, listRequests, listSessions, memorize, normalizeUserChatInput, recall, removeMemory, resolveApproval, run, serveToolsOverStdio, subscribe, stop, updateMemory, } from "./api.js";
|
|
2
|
+
export type { ListMemoriesInput, ListMemoriesResult, MemoryDecision, MemoryKind, MemoryRecord, MemoryScope, MemorizeInput, MemorizeResult, NormalizeUserChatInputOptions, RecallInput, RecallResult, RemoveMemoryInput, UpdateMemoryInput, UserChatInput, UserChatMessage, } from "./api.js";
|
|
3
3
|
export type { ToolMcpServerOptions } from "./mcp.js";
|
|
4
4
|
export { tool } from "./tools.js";
|
|
5
5
|
export type { UpstreamTimelineProjection, UpstreamTimelineReducer } from "./upstream-events.js";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AgentHarnessRuntime, cancelRun, createAgentHarness, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, getAgent, getApproval, getRequest, getHealth, getSession, listAgentSkills, listApprovals, listRequests, listSessions, memorize, normalizeUserChatInput, recall, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
|
|
1
|
+
export { AgentHarnessRuntime, cancelRun, createAgentHarness, createUpstreamTimelineReducer, createToolMcpServer, deleteSession, describeInventory, getAgent, getApproval, getRequest, getHealth, listMemories, getSession, listAgentSkills, listApprovals, listRequests, listSessions, memorize, normalizeUserChatInput, recall, removeMemory, resolveApproval, run, serveToolsOverStdio, subscribe, stop, updateMemory, } from "./api.js";
|
|
2
2
|
export { tool } from "./tools.js";
|
package/dist/init-project.js
CHANGED
|
@@ -138,6 +138,9 @@ metadata:
|
|
|
138
138
|
name: default
|
|
139
139
|
spec:
|
|
140
140
|
enabled: true
|
|
141
|
+
store:
|
|
142
|
+
kind: SqliteStore
|
|
143
|
+
path: runtime-memory.sqlite
|
|
141
144
|
namespaces:
|
|
142
145
|
users: memories/users/{userId}
|
|
143
146
|
projects: memories/projects/{projectId}
|
|
@@ -162,6 +165,21 @@ spec:
|
|
|
162
165
|
backgroundConsolidation: true
|
|
163
166
|
writeOnApprovalResolution: true
|
|
164
167
|
writeOnRunCompletion: true
|
|
168
|
+
formation:
|
|
169
|
+
hotPath:
|
|
170
|
+
enabled: true
|
|
171
|
+
manager:
|
|
172
|
+
enabled: true
|
|
173
|
+
strategy: rules
|
|
174
|
+
maxContextRecords: 12
|
|
175
|
+
background:
|
|
176
|
+
enabled: true
|
|
177
|
+
scopes:
|
|
178
|
+
- thread
|
|
179
|
+
stateStorePath: runtime-memory-formation-state.json
|
|
180
|
+
maxMessagesPerRun: 40
|
|
181
|
+
writeOnApprovalResolution: true
|
|
182
|
+
writeOnRunCompletion: true
|
|
165
183
|
threadMemorySync:
|
|
166
184
|
enabled: true
|
|
167
185
|
mem0:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export declare const AGENT_HARNESS_VERSION = "0.0.155";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.155";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Message as Mem0Message } from "mem0ai";
|
|
1
|
+
import { type Memory as Mem0Memory, type Message as Mem0Message } from "mem0ai";
|
|
2
2
|
import type { HarnessEvent, HarnessEventProjection } from "../../../contracts/types.js";
|
|
3
3
|
import type { RuntimePersistence } from "../../../persistence/types.js";
|
|
4
4
|
import { type StoreLike } from "./store.js";
|
|
@@ -19,8 +19,26 @@ export type ResolvedMem0Config = {
|
|
|
19
19
|
};
|
|
20
20
|
type Mem0ClientLike = {
|
|
21
21
|
add(messages: Mem0Message[], options?: Record<string, unknown>): Promise<unknown>;
|
|
22
|
+
search(query: string, options?: Record<string, unknown>): Promise<Mem0Memory[]>;
|
|
23
|
+
};
|
|
24
|
+
export type Mem0ClientFactory = (config: ResolvedMem0Config) => Promise<Mem0ClientLike> | Mem0ClientLike;
|
|
25
|
+
export type Mem0SearchInput = {
|
|
26
|
+
query: string;
|
|
27
|
+
topK: number;
|
|
28
|
+
agentId?: string;
|
|
29
|
+
threadId?: string;
|
|
30
|
+
};
|
|
31
|
+
export type Mem0SearchResult = {
|
|
32
|
+
id: string;
|
|
33
|
+
memory: string;
|
|
34
|
+
score: number;
|
|
35
|
+
categories: string[];
|
|
36
|
+
metadata: Record<string, unknown>;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
updatedAt: string;
|
|
39
|
+
agentId?: string;
|
|
40
|
+
runId?: string;
|
|
22
41
|
};
|
|
23
|
-
type Mem0ClientFactory = (config: ResolvedMem0Config) => Promise<Mem0ClientLike> | Mem0ClientLike;
|
|
24
42
|
export declare function readMem0RuntimeConfig(runtimeMemory: Record<string, unknown> | undefined, workspaceRoot: string): ResolvedMem0Config | undefined;
|
|
25
43
|
export declare class Mem0IngestionSync implements HarnessEventProjection {
|
|
26
44
|
private readonly persistence;
|
|
@@ -39,4 +57,12 @@ export declare class Mem0IngestionSync implements HarnessEventProjection {
|
|
|
39
57
|
private syncRun;
|
|
40
58
|
close(): Promise<void>;
|
|
41
59
|
}
|
|
60
|
+
export declare class Mem0SemanticRecall {
|
|
61
|
+
private readonly config;
|
|
62
|
+
private readonly clientFactory;
|
|
63
|
+
private clientPromise;
|
|
64
|
+
constructor(config: ResolvedMem0Config, clientFactory?: Mem0ClientFactory);
|
|
65
|
+
private getClient;
|
|
66
|
+
search(input: Mem0SearchInput): Promise<Mem0SearchResult[]>;
|
|
67
|
+
}
|
|
42
68
|
export {};
|
|
@@ -69,7 +69,10 @@ export function readMem0RuntimeConfig(runtimeMemory, workspaceRoot) {
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
async function createDefaultMem0Client(config) {
|
|
72
|
-
const apiKey = process.env[config.apiKeyEnv];
|
|
72
|
+
const apiKey = process.env[config.apiKeyEnv]?.trim();
|
|
73
|
+
if (!apiKey && config.host) {
|
|
74
|
+
return createSelfHostedMem0Client(config);
|
|
75
|
+
}
|
|
73
76
|
if (!apiKey) {
|
|
74
77
|
throw new Error(`runtimeMemory.mem0 is enabled but environment variable ${config.apiKeyEnv} is not set`);
|
|
75
78
|
}
|
|
@@ -82,6 +85,47 @@ async function createDefaultMem0Client(config) {
|
|
|
82
85
|
...(config.projectId ? { projectId: config.projectId } : {}),
|
|
83
86
|
});
|
|
84
87
|
}
|
|
88
|
+
function normalizeMem0Host(host) {
|
|
89
|
+
return host.replace(/\/+$/, "");
|
|
90
|
+
}
|
|
91
|
+
async function selfHostedMem0Request(config, pathname, options = {}) {
|
|
92
|
+
if (!config.host) {
|
|
93
|
+
throw new Error("Self-hosted mem0 client requires runtimeMemory.mem0.host.");
|
|
94
|
+
}
|
|
95
|
+
const response = await fetch(`${normalizeMem0Host(config.host)}${pathname}`, {
|
|
96
|
+
method: options.method ?? "GET",
|
|
97
|
+
headers: {
|
|
98
|
+
"Content-Type": "application/json",
|
|
99
|
+
},
|
|
100
|
+
...(options.body ? { body: JSON.stringify(options.body) } : {}),
|
|
101
|
+
});
|
|
102
|
+
if (!response.ok) {
|
|
103
|
+
throw new Error(`Self-hosted mem0 request failed: ${response.status} ${response.statusText}`);
|
|
104
|
+
}
|
|
105
|
+
return response.json();
|
|
106
|
+
}
|
|
107
|
+
function createSelfHostedMem0Client(config) {
|
|
108
|
+
return {
|
|
109
|
+
async add(messages, options = {}) {
|
|
110
|
+
return selfHostedMem0Request(config, "/v1/memories/", {
|
|
111
|
+
method: "POST",
|
|
112
|
+
body: {
|
|
113
|
+
messages,
|
|
114
|
+
...options,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
async search(query, options = {}) {
|
|
119
|
+
return selfHostedMem0Request(config, "/v1/memories/search/", {
|
|
120
|
+
method: "POST",
|
|
121
|
+
body: {
|
|
122
|
+
query,
|
|
123
|
+
...options,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
85
129
|
export class Mem0IngestionSync {
|
|
86
130
|
persistence;
|
|
87
131
|
config;
|
|
@@ -179,3 +223,70 @@ export class Mem0IngestionSync {
|
|
|
179
223
|
await Promise.allSettled(Array.from(this.pending));
|
|
180
224
|
}
|
|
181
225
|
}
|
|
226
|
+
function toIsoString(value) {
|
|
227
|
+
if (value instanceof Date && !Number.isNaN(value.getTime())) {
|
|
228
|
+
return value.toISOString();
|
|
229
|
+
}
|
|
230
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
231
|
+
const parsed = new Date(value);
|
|
232
|
+
return Number.isNaN(parsed.getTime()) ? undefined : parsed.toISOString();
|
|
233
|
+
}
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
export class Mem0SemanticRecall {
|
|
237
|
+
config;
|
|
238
|
+
clientFactory;
|
|
239
|
+
clientPromise = null;
|
|
240
|
+
constructor(config, clientFactory = createDefaultMem0Client) {
|
|
241
|
+
this.config = config;
|
|
242
|
+
this.clientFactory = clientFactory;
|
|
243
|
+
}
|
|
244
|
+
async getClient() {
|
|
245
|
+
if (!this.clientPromise) {
|
|
246
|
+
this.clientPromise = Promise.resolve(this.clientFactory(this.config));
|
|
247
|
+
}
|
|
248
|
+
return this.clientPromise;
|
|
249
|
+
}
|
|
250
|
+
async search(input) {
|
|
251
|
+
if (input.query.trim().length === 0 || input.topK <= 0) {
|
|
252
|
+
return [];
|
|
253
|
+
}
|
|
254
|
+
const client = await this.getClient();
|
|
255
|
+
const records = await client.search(input.query, {
|
|
256
|
+
top_k: input.topK,
|
|
257
|
+
limit: input.topK,
|
|
258
|
+
app_id: this.config.appId,
|
|
259
|
+
...(input.agentId ? { agent_id: input.agentId } : {}),
|
|
260
|
+
...(input.threadId && this.config.userIdPrefix ? { user_id: `${this.config.userIdPrefix}${input.threadId}` } : {}),
|
|
261
|
+
});
|
|
262
|
+
return records
|
|
263
|
+
.map((record) => {
|
|
264
|
+
const memory = typeof record.memory === "string" && record.memory.trim().length > 0
|
|
265
|
+
? record.memory.trim()
|
|
266
|
+
: typeof record.data?.memory === "string" && record.data.memory.trim().length > 0
|
|
267
|
+
? record.data.memory.trim()
|
|
268
|
+
: "";
|
|
269
|
+
if (!memory) {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
const createdAt = toIsoString(record.created_at) ?? new Date(0).toISOString();
|
|
273
|
+
const updatedAt = toIsoString(record.updated_at) ?? createdAt;
|
|
274
|
+
return {
|
|
275
|
+
id: record.id,
|
|
276
|
+
memory,
|
|
277
|
+
score: typeof record.score === "number" && Number.isFinite(record.score) ? record.score : 0,
|
|
278
|
+
categories: Array.isArray(record.categories)
|
|
279
|
+
? record.categories.filter((item) => typeof item === "string" && item.trim().length > 0)
|
|
280
|
+
: [],
|
|
281
|
+
metadata: typeof record.metadata === "object" && record.metadata && !Array.isArray(record.metadata)
|
|
282
|
+
? { ...record.metadata }
|
|
283
|
+
: {},
|
|
284
|
+
createdAt,
|
|
285
|
+
updatedAt,
|
|
286
|
+
agentId: typeof record.agent_id === "string" && record.agent_id.trim().length > 0 ? record.agent_id : undefined,
|
|
287
|
+
runId: typeof record.run_id === "string" && record.run_id.trim().length > 0 ? record.run_id : undefined,
|
|
288
|
+
};
|
|
289
|
+
})
|
|
290
|
+
.filter((record) => record !== null);
|
|
291
|
+
}
|
|
292
|
+
}
|