@ai-agent-forge/plugin-memory 0.88.1 → 0.88.3
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 +10 -4
- package/agent-forge.json +1 -1
- package/bin/agent-forge-memory-inference.js +8 -0
- package/dist/capability.d.ts +42 -59
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +263 -2055
- package/dist/capability.js.map +1 -1
- package/dist/entry.d.ts +11 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +38 -2
- package/dist/entry.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/inference-bin.d.ts +21 -0
- package/dist/inference-bin.d.ts.map +1 -0
- package/dist/inference-bin.js +85 -0
- package/dist/inference-bin.js.map +1 -0
- package/dist/memory/command-face.d.ts +86 -0
- package/dist/memory/command-face.d.ts.map +1 -0
- package/dist/memory/command-face.js +377 -0
- package/dist/memory/command-face.js.map +1 -0
- package/dist/memory/embedding-provider.d.ts.map +1 -1
- package/dist/memory/embedding-provider.js +14 -2
- package/dist/memory/embedding-provider.js.map +1 -1
- package/dist/memory/embedding-reranker.d.ts.map +1 -1
- package/dist/memory/embedding-reranker.js +14 -2
- package/dist/memory/embedding-reranker.js.map +1 -1
- package/dist/memory/enabling.d.ts +104 -0
- package/dist/memory/enabling.d.ts.map +1 -0
- package/dist/memory/enabling.js +321 -0
- package/dist/memory/enabling.js.map +1 -0
- package/dist/memory/hooks.d.ts +110 -0
- package/dist/memory/hooks.d.ts.map +1 -0
- package/dist/memory/hooks.js +478 -0
- package/dist/memory/hooks.js.map +1 -0
- package/dist/memory/inference-channel.d.ts +33 -0
- package/dist/memory/inference-channel.d.ts.map +1 -0
- package/dist/memory/inference-channel.js +101 -0
- package/dist/memory/inference-channel.js.map +1 -0
- package/dist/memory/inference-client.d.ts +25 -0
- package/dist/memory/inference-client.d.ts.map +1 -0
- package/dist/memory/inference-client.js +216 -0
- package/dist/memory/inference-client.js.map +1 -0
- package/dist/memory/inference-protocol.d.ts +95 -0
- package/dist/memory/inference-protocol.d.ts.map +1 -0
- package/dist/memory/inference-protocol.js +27 -0
- package/dist/memory/inference-protocol.js.map +1 -0
- package/dist/memory/inference-server.d.ts +70 -0
- package/dist/memory/inference-server.d.ts.map +1 -0
- package/dist/memory/inference-server.js +395 -0
- package/dist/memory/inference-server.js.map +1 -0
- package/dist/memory/inference-service-main.d.ts +31 -0
- package/dist/memory/inference-service-main.d.ts.map +1 -0
- package/dist/memory/inference-service-main.js +89 -0
- package/dist/memory/inference-service-main.js.map +1 -0
- package/dist/memory/ledger.d.ts +15 -0
- package/dist/memory/ledger.d.ts.map +1 -1
- package/dist/memory/ledger.js +35 -2
- package/dist/memory/ledger.js.map +1 -1
- package/dist/memory/model-cache-hygiene.d.ts +10 -0
- package/dist/memory/model-cache-hygiene.d.ts.map +1 -1
- package/dist/memory/model-cache-hygiene.js +15 -0
- package/dist/memory/model-cache-hygiene.js.map +1 -1
- package/dist/memory/preference-promotion.d.ts +0 -14
- package/dist/memory/preference-promotion.d.ts.map +1 -1
- package/dist/memory/preference-promotion.js +17 -0
- package/dist/memory/preference-promotion.js.map +1 -1
- package/dist/memory/recall-pipeline.d.ts +85 -0
- package/dist/memory/recall-pipeline.d.ts.map +1 -0
- package/dist/memory/recall-pipeline.js +678 -0
- package/dist/memory/recall-pipeline.js.map +1 -0
- package/dist/memory/retention-sweep.d.ts +59 -0
- package/dist/memory/retention-sweep.d.ts.map +1 -0
- package/dist/memory/retention-sweep.js +103 -0
- package/dist/memory/retention-sweep.js.map +1 -0
- package/dist/memory/store.d.ts +17 -2
- package/dist/memory/store.d.ts.map +1 -1
- package/dist/memory/store.js +18 -2
- package/dist/memory/store.js.map +1 -1
- package/dist/memory/vector-channel.d.ts +120 -0
- package/dist/memory/vector-channel.d.ts.map +1 -0
- package/dist/memory/vector-channel.js +495 -0
- package/dist/memory/vector-channel.js.map +1 -0
- package/dist/memory/vector-projection.d.ts +87 -0
- package/dist/memory/vector-projection.d.ts.map +1 -0
- package/dist/memory/vector-projection.js +215 -0
- package/dist/memory/vector-projection.js.map +1 -0
- package/dist/memory/write-face.d.ts +128 -0
- package/dist/memory/write-face.d.ts.map +1 -0
- package/dist/memory/write-face.js +504 -0
- package/dist/memory/write-face.js.map +1 -0
- package/dist/testing/memory-testkit.d.ts +2 -0
- package/dist/testing/memory-testkit.d.ts.map +1 -1
- package/dist/testing/memory-testkit.js +1 -0
- package/dist/testing/memory-testkit.js.map +1 -1
- package/package.json +7 -3
- package/plugin.json +1 -1
package/README.md
CHANGED
|
@@ -23,10 +23,16 @@ capability (D-075 S4, fourth batch).
|
|
|
23
23
|
- mode resolution reuses `resolveMemoryMode`: config `memoryMode` (host
|
|
24
24
|
configOverride wiring lands with the host cutover batch) → env
|
|
25
25
|
`AGENT_FORGE_MEMORY_MODE` (read in the entry) → config
|
|
26
|
-
`memorySettingsMode` → legacy alias →
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
`memorySettingsMode` → legacy alias → light (the factory default since
|
|
27
|
+
the 2026-10-05 flip; invalid values fail closed to `off`)
|
|
28
|
+
- a resolved mode of `off`, a persisted consent decline
|
|
29
|
+
(`memoryConsent: "declined"` in the agent-dir config suppressing the
|
|
30
|
+
default tier), or a host without `agentDir` registers nothing (one debug
|
|
31
|
+
log line; the factory never throws for a disabled configuration)
|
|
32
|
+
- the model download runs in the background (host preheat via
|
|
33
|
+
`memory_enable`); `memoryConsent` and the persisted
|
|
34
|
+
`memorySettingsMode` preset live in the agent-dir config channel and are
|
|
35
|
+
written by the `/memory` command face
|
|
30
36
|
- `vectorComponents` does NOT ride the entry — it is the library/test face
|
|
31
37
|
only (deterministic mock gate)
|
|
32
38
|
|
package/agent-forge.json
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* npm bin wrapper for the memory inference service process entry (Slice B1).
|
|
4
|
+
* The spawn path used in-process is `node <plugin>/bin/agent-forge-memory-inference.js`
|
|
5
|
+
* (portable across platforms, no npm shim reliance); this file also registers
|
|
6
|
+
* the command for npm consumers. It only re-exports the real entry in dist.
|
|
7
|
+
*/
|
|
8
|
+
import "../dist/inference-bin.js";
|
package/dist/capability.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { MemoryCapabilityOverrideV1, MemoryModeV1, MemoryStorageComponentsV1 } from "@agent-forge/plugin-sdk";
|
|
2
2
|
import { type CapabilityAPI, type DisposableRegistration } from "@agent-forge/plugin-sdk";
|
|
3
3
|
export { MEMORY_RECALL_TOOL_NAME, type MemoryCapabilityOverrideV1, type MemoryEnablingOverrideV1, type MemoryModeV1, type MemoryStorageComponentsV1, type MemoryVectorComponentsOverrideV1, } from "@agent-forge/plugin-sdk";
|
|
4
|
+
export { MEMORY_AGENT_DIR_CONFIG_RELATIVE_PATH, MEMORY_CONSENT_DECLINED_VALUE, writeMemoryConsentDeclined, writeMemorySettingsMode, } from "./memory/enabling.ts";
|
|
5
|
+
export { MEMORY_AUTO_RECALL_DEADLINE_MS, MEMORY_AUTO_RECALL_DISCLAIMER, MEMORY_AUTO_RECALL_MARKER, type MemoryLessonsResolutionV1, type MemoryLessonsSettingV1, resolveMemoryLessons, } from "./memory/hooks.ts";
|
|
6
|
+
export { MEMORY_TOOLS_GUIDE } from "./memory/recall-pipeline.ts";
|
|
7
|
+
export { type MemoryCapabilityStateV1, type MemoryConsentNeededV1, type MemoryEnablingFailureV1, VECTOR_DB_DIRNAME, VECTOR_MODEL_CACHE_DIRNAME, VECTOR_RERANKER_MODEL_ID, } from "./memory/vector-channel.ts";
|
|
8
|
+
export { MEMORY_TIER_UPGRADE_STORE_THRESHOLD } from "./memory/write-face.ts";
|
|
9
|
+
import { type MemoryLessonsSettingV1 } from "./memory/hooks.ts";
|
|
10
|
+
import type { MemoryCapabilityStateV1, MemoryEnablingFailureV1 } from "./memory/vector-channel.ts";
|
|
4
11
|
export declare const capabilityManifest: {
|
|
5
12
|
readonly id: "agent-forge.builtin.memory";
|
|
6
13
|
readonly version: "0.1.0";
|
|
@@ -12,31 +19,6 @@ export declare const capabilityManifest: {
|
|
|
12
19
|
readonly kind: "service";
|
|
13
20
|
}];
|
|
14
21
|
};
|
|
15
|
-
/**
|
|
16
|
-
* Marker text of the auto-recall injection message (B1 记忆自动注入, D-071 增补
|
|
17
|
-
* 裁决自 sdk 迁入; pinned by test/memory-sdk-e2e.test.ts).
|
|
18
|
-
*/
|
|
19
|
-
export declare const MEMORY_AUTO_RECALL_MARKER = "<auto_recalled_memory>";
|
|
20
|
-
/**
|
|
21
|
-
* Tail line of every auto-recall injection block (错误教训与召回质量护栏设计
|
|
22
|
-
* §2.1): tells the model the block was recalled rather than written by the
|
|
23
|
-
* user and may be outdated. Pinned verbatim by test/memory-error-lessons.test.ts.
|
|
24
|
-
*/
|
|
25
|
-
export declare const MEMORY_AUTO_RECALL_DISCLAIMER = "(Recalled automatically from persistent memory for this request \u2014 not written by the user. Recalled items may be outdated; verify against current state before relying on them.)";
|
|
26
|
-
/**
|
|
27
|
-
* Memory tools guide(记忆 runtime 注入面,原 system-prompt.ts MEMORY_TOOL_GUIDE,
|
|
28
|
-
* D-071 迁移):the model-facing hint that the persistent memory tools exist.
|
|
29
|
-
* It rides memory_recall's promptGuidelines so the text lives with the plugin
|
|
30
|
-
* that owns the tools (宪法 §3) and renders whenever the tool face is active.
|
|
31
|
-
*/
|
|
32
|
-
export declare const MEMORY_TOOLS_GUIDE = "Memory: You have persistent memory tools (memory_write, memory_recall, memory_list, memory_forget). Use memory_recall to look up user preferences or project facts before answering. Use memory_write to save important decisions, preferences, or findings for future sessions.";
|
|
33
|
-
/**
|
|
34
|
-
* Owner (isolation principal) of every atom this capability writes. The
|
|
35
|
-
* Foundation owner is the store/facade isolation identity; this product ships
|
|
36
|
-
* one local user per agentDir, so one stable owner id partitions the ledger
|
|
37
|
-
* directory `<agentDir>/memory/<owner>/ledger-<suiteId|"legacy">.jsonl`.
|
|
38
|
-
*/
|
|
39
|
-
export declare const BUILTIN_MEMORY_OWNER = "local-user";
|
|
40
22
|
/**
|
|
41
23
|
* 解析后的全局模式 (2.4d6 S1)。`invalidEnvValue` 非空 = 配置的环境值非法,
|
|
42
24
|
* 已 fail-closed 回 off, 调用方负责以此输出一次 warn; `invalidSettingsValue`
|
|
@@ -54,28 +36,13 @@ export interface MemoryModeResolutionV1 {
|
|
|
54
36
|
/**
|
|
55
37
|
* memory.mode 解析 (2.4d6 S1)。优先级: context 显式值 → 环境变量
|
|
56
38
|
* `AGENT_FORGE_MEMORY_MODE` → settings.json `memory.mode` (settingsMode 参, 持
|
|
57
|
-
* 久配置面) → 旧别名 `AGENT_FORGE_MEMORY_VECTOR` (兼容期) → 默认
|
|
39
|
+
* 久配置面) → 旧别名 `AGENT_FORGE_MEMORY_VECTOR` (兼容期) → 默认 light
|
|
40
|
+
* (2026-10-05 用户裁决翻转默认 off→light, 对齐主流编程助手开箱即用方向)。env 是
|
|
58
41
|
* 临时覆盖、settings 是持久配置 (env > 文件, 沿用本仓 suite 解析先例)。任何
|
|
59
42
|
* 非法配置值 fail-closed 为 off 并在结果中携带原值供调用方告警一次, 绝不静默
|
|
60
43
|
* 改档或意外下载。
|
|
61
44
|
*/
|
|
62
45
|
export declare function resolveMemoryMode(explicitMode: string | undefined, env?: Readonly<Record<string, string | undefined>>, settingsMode?: string): MemoryModeResolutionV1;
|
|
63
|
-
/** bash 失败教训捕获开关取值 (§2.2)。 */
|
|
64
|
-
export type MemoryLessonsSettingV1 = "on" | "off";
|
|
65
|
-
/**
|
|
66
|
-
* lessons 开关解析结果: `invalidEnvValue` 非空 = 配置值非法, 已 fail 回默认 on,
|
|
67
|
-
* 调用方负责以此告警一次。
|
|
68
|
-
*/
|
|
69
|
-
export interface MemoryLessonsResolutionV1 {
|
|
70
|
-
readonly lessons: MemoryLessonsSettingV1;
|
|
71
|
-
readonly invalidEnvValue?: string;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* context.memory.lessons 解析 (§2.2, resolveMemoryMode 同构): 显式值 → 环境变量
|
|
75
|
-
* `AGENT_FORGE_MEMORY_LESSONS` → 默认 on。任何非法配置值回默认并在结果中携带
|
|
76
|
-
* 原值供调用方告警一次, 绝不静默改开关。
|
|
77
|
-
*/
|
|
78
|
-
export declare function resolveMemoryLessons(explicitLessons: string | undefined, env?: Readonly<Record<string, string | undefined>>): MemoryLessonsResolutionV1;
|
|
79
46
|
/** Host-provided factory context; provided by the host session assembly (sdk suite membership). */
|
|
80
47
|
export interface MemoryCapabilityContext {
|
|
81
48
|
/** Agent home directory — roots the durable ledger under `<agentDir>/memory/`. */
|
|
@@ -116,6 +83,22 @@ export interface MemoryCapabilityContext {
|
|
|
116
83
|
* 的第三参语义一致, 第三参优先。
|
|
117
84
|
*/
|
|
118
85
|
readonly vectorComponents?: MemoryCapabilityOverrideV1;
|
|
86
|
+
/**
|
|
87
|
+
* 共享推理服务装配缝 (Slice B2, 记忆共享推理服务设计 §3.1/§3.3/§3.6)。
|
|
88
|
+
* 缺省 (生产) = 真实路径: 模型在位时装配经 TCP loopback 走常驻服务,
|
|
89
|
+
* 连不上则懒 spawn 插件 bin (`agent-forge-memory-inference`), 重连失败按
|
|
90
|
+
* enabling failed 呈现 (裁决 A: 不回退本地装配)。测试注入替换对应环节
|
|
91
|
+
* (deterministic 门禁): `port` 直连测试服务、`spawnImpl` 替换进程拉起、
|
|
92
|
+
* `modelsInPlace` 声明模型在位 (跳过文件检查, 免写假权重文件)。
|
|
93
|
+
* loadImpl enabling 缝与 vectorComponents 注入仍走本地装配路径 (既有语义)。
|
|
94
|
+
*/
|
|
95
|
+
readonly inferenceService?: {
|
|
96
|
+
readonly port?: number;
|
|
97
|
+
readonly spawnImpl?: (agentDir: string, mode: "light" | "full", port: number,
|
|
98
|
+
/** spawn 异步失败 (EACCES/ENOMEM 等) 的回调; 缺省实现经 child 'error' 事件馈入。 */
|
|
99
|
+
onError?: (error: Error) => void) => Promise<void>;
|
|
100
|
+
readonly modelsInPlace?: boolean;
|
|
101
|
+
};
|
|
119
102
|
/**
|
|
120
103
|
* 记忆底层组件注入 (扩展位盘点 A1/A2 的宿主装配通道): store/ledger 工厂与
|
|
121
104
|
* 向量组件公共契约, 缺省成员走内置默认实现。装配方经
|
|
@@ -123,25 +106,19 @@ export interface MemoryCapabilityContext {
|
|
|
123
106
|
*/
|
|
124
107
|
readonly storage?: MemoryStorageComponentsV1;
|
|
125
108
|
}
|
|
126
|
-
/** capability 级状态机 (设计 §3.2): off 只出现在模式关闭 (零注册, 不可观测)。 */
|
|
127
|
-
export type MemoryCapabilityStateV1 = "enabling" | "ready" | "degraded" | "failed";
|
|
128
|
-
/** enabling 失败的结构化结果: 原因 + 行动清单 (硬性要求, 设计 §3.2)。 */
|
|
129
|
-
export interface MemoryEnablingFailureV1 {
|
|
130
|
-
readonly reason: string;
|
|
131
|
-
readonly actions: readonly string[];
|
|
132
|
-
}
|
|
133
109
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
110
|
+
* 默认档判定 (征询拒绝只抑制默认档): 显式值、env、settings、旧别名四层全部
|
|
111
|
+
* 未定档时, 模式来自出厂默认档 (light)。与 resolveMemoryMode 的优先级链同构,
|
|
112
|
+
* 不改 resolver 返回面。
|
|
113
|
+
*/
|
|
114
|
+
export declare function memoryModeSourceIsDefault(explicitMode: string | undefined, env: Readonly<Record<string, string | undefined>>, settingsMode?: string): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Owner (isolation principal) of every atom this capability writes. The
|
|
117
|
+
* Foundation owner is the store/facade isolation identity; this product ships
|
|
118
|
+
* one local user per agentDir, so one stable owner id partitions the ledger
|
|
119
|
+
* directory `<agentDir>/memory/<owner>/ledger-<suiteId|"legacy">.jsonl`.
|
|
140
120
|
*/
|
|
141
|
-
export declare
|
|
142
|
-
lancedb?: string;
|
|
143
|
-
transformers?: string;
|
|
144
|
-
}, resolveModule: (specifier: string) => string): string[];
|
|
121
|
+
export declare const BUILTIN_MEMORY_OWNER = "local-user";
|
|
145
122
|
/**
|
|
146
123
|
* Creates the builtin memory capability: four tools (memory_write,
|
|
147
124
|
* memory_recall, memory_list, memory_forget) over a per-session Foundation
|
|
@@ -171,6 +148,12 @@ export interface MemoryVectorCapabilityHarnessV1 {
|
|
|
171
148
|
* components): ready, or the structured failure (reason + action list).
|
|
172
149
|
*/
|
|
173
150
|
enablingOutcome(): Promise<"ready" | MemoryEnablingFailureV1>;
|
|
151
|
+
/**
|
|
152
|
+
* 释放共享推理服务连接 (服务路径) 或本地向量索引 (本地装配路径)。幂等: 引用
|
|
153
|
+
* 清空后二次调用为 no-op。同名注册项挂 registrations 首位——宿主反向逐个
|
|
154
|
+
* dispose 时它最后执行 (先拆消费者、后关通道)。
|
|
155
|
+
*/
|
|
156
|
+
teardown(): void;
|
|
174
157
|
}
|
|
175
158
|
/**
|
|
176
159
|
* Test-only assembly variant: the capability with an injected override (full
|