sage-mem 2.25.0 → 2.26.1
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.en.md +34 -1
- package/README.md +34 -1
- package/lib/assembly/mirror-mount.js +14 -3
- package/lib/client.js +269 -0
- package/lib/index.js +19 -0
- package/lib/intake/merge.js +193 -0
- package/lib/intake/policy.js +238 -0
- package/lib/intake/store.js +247 -0
- package/lib/mirror/mcp.js +53 -6
- package/lib/mirror/policy.js +17 -6
- package/lib/typert/schemas.js +47 -0
- package/lib/typert.host.js +39 -1
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
**Cross-session memory for DeepSeek Harness — plain markdown files, no database, no worker.**
|
|
14
14
|
|
|
15
|
-
**Current release: `2.
|
|
15
|
+
**Current release: `2.26.1`** — the npm badge above is the dynamic source of truth. **Contract baseline: `1.0.0`** — the first stable release, whose public commitments, the capability boundaries and the list of things it explicitly cannot do are frozen in the
|
|
16
16
|
[frozen contract](https://github.com/gezi-wen/sage-mem/blob/main/docs/1.0.0-contract.md).
|
|
17
17
|
|
|
18
18
|
If it is useful to you, a Star is the most direct feedback.
|
|
@@ -589,6 +589,38 @@ Triggering is a 45 second poll plus a 10 second debounce on directory events, so
|
|
|
589
589
|
|
|
590
590
|
**Out of scope on purpose**: the write side (an `intake/` area and a merger for incoming submissions) belongs to 2.26.0; there is no per-agent tiered permission model (ACLs are useless under one OS user, so visibility replaces permissions); there is no endpoint auth and no cross-machine access - use an SSH port forward if you need that.
|
|
591
591
|
|
|
592
|
+
## Incoming submissions: other agents can submit, only you let them in (2.26.0)
|
|
593
|
+
|
|
594
|
+
The read side solved "they cannot see your memories"; this release solves the other direction: **how what they want to tell you gets in**. The answer is a queue, and you approve it entry by entry.
|
|
595
|
+
|
|
596
|
+
The endpoint gains one tool, `memory_submit` (the only write entry point it has). It does **not** write your library: the submission lands in `<state dir>/intake/agents/<source>/pending/` and shows up in the **Incoming submissions** card on the External access page. It is **off** by default: with `external.acceptSubmissions = 0` submissions are rejected outright - "can read the copy" and "can put things in" are two separate switches.
|
|
597
|
+
|
|
598
|
+
```jsonc
|
|
599
|
+
// roughly what they send to memory_submit
|
|
600
|
+
{ "kind": "new", "source": "claude-code",
|
|
601
|
+
"name": "project_tile-cache", "description": "Tile cache hit-rate findings",
|
|
602
|
+
"type": "project", "tags": ["tiles"], "body": "...markdown..." }
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
Two kinds: `kind=new` is a complete new memory (`type` is limited to `project` / `reference`); `kind=patch` is an edit suggestion for an existing entry. Malformed submissions are rejected **at the entry point** and never reach the queue.
|
|
606
|
+
|
|
607
|
+
### Only a new entry can be approved into the library
|
|
608
|
+
|
|
609
|
+
Each pending item carries a proposal in one of four states: **approvable** (a new name), **name conflict** (the library already has that name; reject it or ask for a rename), **needs a human** (an edit suggestion - you get a snippet to copy over), **not applicable** (a suggestion pointing at a memory that does not exist). Approval is an **exclusive create**: if the name is taken it reports a conflict and overwrites nothing.
|
|
610
|
+
|
|
611
|
+
`kind=patch` **never writes the library automatically** - a half-finished patch would destroy the target file. The panel offers a "Copy suggestion" button that copies just the "suggested" section, not the whole patch.
|
|
612
|
+
|
|
613
|
+
Rejecting **does not delete**: the original stays in `intake/agents/<source>/rejected/`, and the reason goes into the report and the audit log (`intake/audit.jsonl`, one line each).
|
|
614
|
+
|
|
615
|
+
| Setting | Default | Description |
|
|
616
|
+
|---|---|---|
|
|
617
|
+
| `external.acceptSubmissions` | `0` (off) | Whether submissions are accepted. While off `memory_submit` is rejected; anything already queued can still be reviewed |
|
|
618
|
+
| Submission size | body <= 32 KB / whole item <= 64 KB | Larger is rejected at the entry point; the body may not carry its own frontmatter |
|
|
619
|
+
| Allowed types | `project` / `reference` | Other agents cannot write `user_*` or `feedback_*` - those are about you, only the main session writes them |
|
|
620
|
+
| After a rejection | original kept in `rejected/` | Never deleted; an approved original is removed, but its full text is already in the report |
|
|
621
|
+
|
|
622
|
+
**Out of scope on purpose**: model-driven auto-merging, automatic rename deduplication, bulk approval (clicking one at a time is the physical guarantee behind "approve first, write later"); `intake/devices/` (cross-device) belongs to 4.0.0.
|
|
623
|
+
|
|
592
624
|
## Configuration Reference
|
|
593
625
|
|
|
594
626
|
### Environment Variables
|
|
@@ -607,6 +639,7 @@ Triggering is a 45 second poll plus a 10 second debounce on directory events, so
|
|
|
607
639
|
| `SAGE_MEM_VALIDITY` | on | master switch for invalidity filtering and contradiction suppression. **Only `0` / `false` / `off` turn it off** (empty or misspelled values count as on); off restores the 1.9.x injection behaviour |
|
|
608
640
|
| `SAGE_MEM_EXTERNAL` | `0` (off) | external access (read side) master switch: `1` exports the copy and opens the read-only endpoint |
|
|
609
641
|
| `SAGE_MEM_EXTERNAL_PORT` | `7461` (1024-65535) | read-only MCP endpoint port, bound to `127.0.0.1` |
|
|
642
|
+
| `SAGE_MEM_EXTERNAL_SUBMIT` | `0` (off) | whether submissions are accepted (`memory_submit`); a separate switch from the one above |`n| `SAGE_MEM_EXTERNAL_SUBMIT` | `0` (off) | whether submissions are accepted (`memory_submit`); a separate switch from the one above |
|
|
610
643
|
|
|
611
644
|
Value semantics: **out-of-range values are clamped to the boundary, illegal values (including pure whitespace) fall back to the default.**
|
|
612
645
|
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
> File-based cross-session memory for DeepSeek Harness — every memory is a plain markdown file you can open, edit and delete. No database, no worker, no port.
|
|
16
16
|
|
|
17
|
-
**当前发布版本:`2.
|
|
17
|
+
**当前发布版本:`2.26.1`** —— 顶部 npm 徽章是动态权威。**契约基线:`1.0.0`** —— 第一个稳定版,公开承诺、能力边界与「明确做不到」的清单冻结在
|
|
18
18
|
[契约冻结](https://github.com/gezi-wen/sage-mem/blob/main/docs/1.0.0-contract.md)。
|
|
19
19
|
|
|
20
20
|
如果它对你有用,给个 Star 是最直接的反馈。
|
|
@@ -591,6 +591,38 @@ sage-mem 给记忆目录的写入加了**版本守卫**:写入前记下当前
|
|
|
591
591
|
|
|
592
592
|
**明确不做**:写侧(外来提交的 `intake/` 与归并器)留给 2.26.0;不做「按 agent 分三档权限」(单用户同 SID 下 ACL 无效,改用「可见性」);不做端点鉴权和跨机器访问 —— 真要跨机器,走 SSH 端口转发。
|
|
593
593
|
|
|
594
|
+
## 外部来件:别的 agent 能提交,进不进库你说了算(2.26.0)
|
|
595
|
+
|
|
596
|
+
读侧解决「它们看不见你的记忆」,这一版解决反方向:**它们想告诉你的事,怎么进来**。答案是只收进队列,主库由你一条条批。
|
|
597
|
+
|
|
598
|
+
端点多了一个工具 `memory_submit`(全端点唯一的写入口)。它**不会**直接写你的记忆库 —— 提交落进 `<状态目录>/intake/agents/<来源>/pending/`,你在「外部访问」页的**外部来件**卡里逐条审。默认**关**:`external.acceptSubmissions = 0` 时提交直接被拒(「能不能读副本」与「能不能往里塞东西」是两个开关)。
|
|
599
|
+
|
|
600
|
+
```jsonc
|
|
601
|
+
// 它们调用 memory_submit 时大概是这个形状
|
|
602
|
+
{ "kind": "new", "source": "claude-code",
|
|
603
|
+
"name": "project_tile-cache", "description": "瓦片缓存的命中率结论",
|
|
604
|
+
"type": "project", "tags": ["瓦片"], "body": "……正文……" }
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
两种提交:`kind=new` 是一条完整新记忆(`type` 只许 `project` / `reference`);`kind=patch` 是对现有条目的修改建议。格式不对**在入口就拒**,连队列都进不去。
|
|
608
|
+
|
|
609
|
+
### 只有「新条目」能被批准落库
|
|
610
|
+
|
|
611
|
+
面板上每条来件带一个提案,四种:**可批准**(新名字)、**同名冲突**(主库已有同名,只能拒绝或让它改名重提)、**需人工**(修改建议,只给一段「建议」让你复制过去)、**不建议收**(修改建议指向一条不存在的记忆)。批准是**排他创建**:同名文件在你就报冲突,一个字节都不覆盖。
|
|
612
|
+
|
|
613
|
+
`kind=patch` **永远不自动写主库** —— 半成品直接落盘会毁掉目标文件。面板给的是「复制建议」按钮,复制的是「建议改成」那一段,不是整份 patch。
|
|
614
|
+
|
|
615
|
+
拒绝**不删**:原件留在 `intake/agents/<来源>/rejected/`,理由进报告与审计(`intake/audit.jsonl` 一行一条)。
|
|
616
|
+
|
|
617
|
+
| 设置项 | 默认值 | 说明 |
|
|
618
|
+
|---|---|---|
|
|
619
|
+
| `external.acceptSubmissions` | `0`(不收) | 收不收外来提交。关着时 `memory_submit` 直接拒,已收到的照样能审 |
|
|
620
|
+
| 提交体积 | 正文 ≤ 32 KB / 整条 ≤ 64 KB | 超了在入口就拒;正文不许自带 frontmatter |
|
|
621
|
+
| 允许的类型 | `project` / `reference` | 外来 agent 写不了 `user_*` 与 `feedback_*` —— 那是关于你本人的,只有主会话能写 |
|
|
622
|
+
| 拒绝之后 | 原件留 `rejected/` | 不删;批准的原件删掉,但全文已进报告 |
|
|
623
|
+
|
|
624
|
+
**明确不做**:模型参与的自动归并、自动改名去重、批量批准(一条条点,才是「先批后写」的物理保证);`intake/devices/`(跨设备)留给 4.0.0。
|
|
625
|
+
|
|
594
626
|
## 配置参考
|
|
595
627
|
|
|
596
628
|
### 环境变量
|
|
@@ -609,6 +641,7 @@ sage-mem 给记忆目录的写入加了**版本守卫**:写入前记下当前
|
|
|
609
641
|
| `SAGE_MEM_VALIDITY` | 开 | 失效过滤与矛盾抑制的总开关。**只认 `0` / `false` / `off` 为关闭**(空值、拼错都按开启);关掉后回到 1.9.x 的注入行为 |
|
|
610
642
|
| `SAGE_MEM_EXTERNAL` | `0`(关) | 外部访问(读侧)总开关:`1` 才导出副本并开只读端点 |
|
|
611
643
|
| `SAGE_MEM_EXTERNAL_PORT` | `7461`(1024–65535) | 只读 MCP 端点端口,只绑 `127.0.0.1` |
|
|
644
|
+
| `SAGE_MEM_EXTERNAL_SUBMIT` | `0`(不收) | 收不收外来提交(`memory_submit`)。与上一个开关是两件事 |
|
|
612
645
|
|
|
613
646
|
取值语义:**越界夹到边界,非法值(含纯空格)回落默认。**
|
|
614
647
|
|
|
@@ -16,6 +16,8 @@ import { MIRROR_DEBOUNCE_MS } from '../mirror/policy.js'
|
|
|
16
16
|
import { createMirrorExporter } from '../mirror/export.js'
|
|
17
17
|
import { createMirrorMcpServer } from '../mirror/mcp.js'
|
|
18
18
|
import { createDirWatcher } from '../memory/watch.js'
|
|
19
|
+
import { createIntakeStore } from '../intake/store.js'
|
|
20
|
+
import { createIntakeMerger } from '../intake/merge.js'
|
|
19
21
|
import { warnLog } from '../memory/util.js'
|
|
20
22
|
|
|
21
23
|
/**
|
|
@@ -27,10 +29,19 @@ import { warnLog } from '../memory/util.js'
|
|
|
27
29
|
*/
|
|
28
30
|
export function mountMirror(ctx, { memoryDir, stateRoot, readExternal }) {
|
|
29
31
|
const exporter = createMirrorExporter({ ctx, memoryDir, stateRoot })
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
// 2.26.0 写侧:提交只进 intake/,归并器只出提案;两者都不在主库之外自己写主库。
|
|
33
|
+
const store = createIntakeStore({ ctx, stateRoot })
|
|
34
|
+
const merger = createIntakeMerger({ ctx, memoryDir, store })
|
|
32
35
|
/** 当前生效设置(null = 还没读过)。 */
|
|
33
36
|
let external = null
|
|
37
|
+
|
|
38
|
+
const mcp = createMirrorMcpServer({
|
|
39
|
+
ctx,
|
|
40
|
+
exporter,
|
|
41
|
+
// 开关现读现用(与读侧同一个 external 段):关着时 memory_submit 直接拒。
|
|
42
|
+
intake: { store, acceptSubmissions: () => !!(external && external.acceptSubmissions) },
|
|
43
|
+
})
|
|
44
|
+
|
|
34
45
|
/** 端点用的端口(-1 = 没起过)。 */
|
|
35
46
|
let mcpPort = -1
|
|
36
47
|
let watcher = null
|
|
@@ -180,5 +191,5 @@ export function mountMirror(ctx, { memoryDir, stateRoot, readExternal }) {
|
|
|
180
191
|
mcpPort = -1
|
|
181
192
|
}
|
|
182
193
|
|
|
183
|
-
return { refresh, status, runOnce, dispose, exporter }
|
|
194
|
+
return { refresh, status, runOnce, dispose, exporter, intake: { store, merger } }
|
|
184
195
|
}
|
package/lib/client.js
CHANGED
|
@@ -2201,6 +2201,44 @@ const StarmapRuntime = (function (require, _react) {
|
|
|
2201
2201
|
result: { mode: "strict", typeSymbol: "sage-mem/types#ExternalStatus", schema: objCodec, create: () => objCodec },
|
|
2202
2202
|
sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
|
|
2203
2203
|
},
|
|
2204
|
+
{
|
|
2205
|
+
// 2.26.0:外部来件(写侧)—— 待处理提交 + 每条现算的提案。只读。
|
|
2206
|
+
id: "sage-mem#memory/externalSubmissions",
|
|
2207
|
+
service: "memory",
|
|
2208
|
+
namespace: "memory",
|
|
2209
|
+
method: "externalSubmissions",
|
|
2210
|
+
invocation: { kind: "direct" },
|
|
2211
|
+
parameters: [],
|
|
2212
|
+
result: { mode: "strict", typeSymbol: "sage-mem/types#IntakeOverview", schema: objCodec, create: () => objCodec },
|
|
2213
|
+
sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
|
|
2214
|
+
},
|
|
2215
|
+
{
|
|
2216
|
+
// 2.26.0:批准一条 new 提交(只有 create 会被接受;patch 永远不自动写)。
|
|
2217
|
+
id: "sage-mem#memory/intakeApprove",
|
|
2218
|
+
service: "memory",
|
|
2219
|
+
namespace: "memory",
|
|
2220
|
+
method: "intakeApprove",
|
|
2221
|
+
invocation: { kind: "direct" },
|
|
2222
|
+
parameters: [
|
|
2223
|
+
{ name: "id", wire: "id", source: "json", codec: { mode: "strict", typeSymbol: "sage-mem/types#SubId", schema: strSchema, create: () => strSchema } },
|
|
2224
|
+
],
|
|
2225
|
+
result: { mode: "strict", typeSymbol: "sage-mem/types#IntakeApproveResult", schema: objCodec, create: () => objCodec },
|
|
2226
|
+
sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
|
|
2227
|
+
},
|
|
2228
|
+
{
|
|
2229
|
+
// 2.26.0:拒绝一条(原件留档在 intake/…/rejected/,不删)。
|
|
2230
|
+
id: "sage-mem#memory/intakeReject",
|
|
2231
|
+
service: "memory",
|
|
2232
|
+
namespace: "memory",
|
|
2233
|
+
method: "intakeReject",
|
|
2234
|
+
invocation: { kind: "direct" },
|
|
2235
|
+
parameters: [
|
|
2236
|
+
{ name: "id", wire: "id", source: "json", codec: { mode: "strict", typeSymbol: "sage-mem/types#SubId", schema: strSchema, create: () => strSchema } },
|
|
2237
|
+
{ name: "reason", wire: "reason", source: "json", acceptsUndefined: true, codec: { mode: "strict", typeSymbol: "sage-mem/types#SubReason", schema: strSchema, create: () => strSchema } },
|
|
2238
|
+
],
|
|
2239
|
+
result: { mode: "strict", typeSymbol: "sage-mem/types#IntakeRejectResult", schema: objCodec, create: () => objCodec },
|
|
2240
|
+
sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
|
|
2241
|
+
},
|
|
2204
2242
|
{
|
|
2205
2243
|
id: "sage-mem#memory/readRaw",
|
|
2206
2244
|
service: "memory",
|
|
@@ -2921,6 +2959,20 @@ const StarmapRuntime = (function (require, _react) {
|
|
|
2921
2959
|
".smem-ext-row:hover{background:var(--dsw-alias-bg-l2,transparent);}",
|
|
2922
2960
|
'.smem-ext-row--on{border-left-color:var(--dsw-alias-brand-primary,#4d76e6);}',
|
|
2923
2961
|
".smem-ext-name{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;color:var(--dsw-alias-label-primary);overflow-wrap:anywhere;}",
|
|
2962
|
+
// 2.26.0「外部来件」:一条提交一块,动作按钮靠右;徽标用颜色区分「可批准 / 需人工 / 冲突」。
|
|
2963
|
+
'.smem-intake-list{display:flex;flex-direction:column;gap:8px;}',
|
|
2964
|
+
'.smem-intake-row{display:flex;flex-direction:column;gap:4px;padding:8px 10px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;}',
|
|
2965
|
+
'.smem-intake-line{display:flex;align-items:center;gap:8px;flex-wrap:wrap;font-size:12px;}',
|
|
2966
|
+
'.smem-intake-src{font-weight:600;color:var(--dsw-alias-label-primary);}',
|
|
2967
|
+
'.smem-intake-name{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;}',
|
|
2968
|
+
'.smem-intake-badge{border:1px solid var(--dsw-alias-border-l2);border-radius:999px;padding:1px 8px;font-size:11px;color:var(--dsw-alias-label-secondary);}',
|
|
2969
|
+
'.smem-intake-badge--create{border-color:var(--dsw-alias-brand-primary,#4d76e6);color:var(--dsw-alias-brand-primary,#4d76e6);}',
|
|
2970
|
+
'.smem-intake-badge--conflict{border-color:var(--dsw-alias-static-red-600,#c62828);color:var(--dsw-alias-static-red-600,#c62828);}',
|
|
2971
|
+
'.smem-intake-why{font-size:11.5px;color:var(--dsw-alias-label-secondary);}',
|
|
2972
|
+
'.smem-intake-excerpt{font-size:12px;color:var(--dsw-alias-label-primary);overflow-wrap:anywhere;}',
|
|
2973
|
+
'.smem-intake-actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:2px;}',
|
|
2974
|
+
'.smem-intake-reports{display:flex;flex-direction:column;gap:8px;margin-top:8px;}',
|
|
2975
|
+
'.smem-intake-report{margin:0;padding:8px;border-radius:6px;background:var(--dsw-alias-bg-l2,transparent);font-size:11.5px;white-space:pre-wrap;overflow-wrap:anywhere;max-height:220px;overflow:auto;}',
|
|
2924
2976
|
].join("\n");
|
|
2925
2977
|
|
|
2926
2978
|
/**
|
|
@@ -4283,6 +4335,10 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
4283
4335
|
"ext.what1": "开关打开后,白名单内的记忆会被复制到状态目录下的 mirror/ 里,其他 agent 通过 127.0.0.1 上的只读接口读那一份副本。",
|
|
4284
4336
|
"ext.what2": "接口只有读:没有写入、不给文件路径、拿不到没勾选的条目。主库一个字都不会被它们改到。",
|
|
4285
4337
|
"ext.status.on": "已开启 · 暴露 {count} 条",
|
|
4338
|
+
"ext.poll": "轮询间隔",
|
|
4339
|
+
"ext.unit.seconds": "秒",
|
|
4340
|
+
"ext.err.poll": "轮询间隔要填 15–600 的整数",
|
|
4341
|
+
"ext.notice.poll": "轮询间隔已保存",
|
|
4286
4342
|
"ext.status.off": "关闭(默认)",
|
|
4287
4343
|
"ext.prefixes": "按前缀整类开放",
|
|
4288
4344
|
"ext.prefixesHint": "默认只开 project_ 与 reference_;user_ 与 feedback_ 是「关于我自己」的记忆,默认不给。",
|
|
@@ -4310,6 +4366,30 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
4310
4366
|
"ext.err.noSettings": "宿主侧还没有外部访问接口(插件版本较旧)",
|
|
4311
4367
|
"ext.err.rejected": "保存被拒绝",
|
|
4312
4368
|
"ext.err.port": "端口要填 1024–65535 的整数",
|
|
4369
|
+
// ── 2.26.0 外部来件(写侧)──────────────────────────────────
|
|
4370
|
+
"ext.intake.title": "外部来件",
|
|
4371
|
+
"ext.intake.pending": "待处理 {count} 条",
|
|
4372
|
+
"ext.intake.what1": "别的 agent 提交过来的记忆与修改建议会先落在这里,插件**不会**自动写进主库。",
|
|
4373
|
+
"ext.intake.what2": "「新条目」可以批准落库(排他创建,不覆盖同名);「修改建议」只给一段建议,要你复制过去手工并入 —— 半成品直接写会毁掉目标文件。",
|
|
4374
|
+
"ext.intake.empty": "现在没有待处理的来件。",
|
|
4375
|
+
"ext.intake.approve": "批准并写入",
|
|
4376
|
+
"ext.intake.reject": "拒绝",
|
|
4377
|
+
"ext.intake.rejectReason": "在面板里拒绝",
|
|
4378
|
+
"ext.intake.copySuggestion": "复制建议",
|
|
4379
|
+
"ext.intake.kind.new": "新条目",
|
|
4380
|
+
"ext.intake.kind.patch": "修改建议",
|
|
4381
|
+
"ext.intake.action.create": "可批准",
|
|
4382
|
+
"ext.intake.action.conflict": "同名冲突",
|
|
4383
|
+
"ext.intake.action.manual": "需人工",
|
|
4384
|
+
"ext.intake.action.reject": "不建议收",
|
|
4385
|
+
"ext.intake.notice.approved": "已写入 {file}",
|
|
4386
|
+
"ext.intake.notice.rejected": "已拒绝(原件留在 rejected/ 里)",
|
|
4387
|
+
"ext.intake.notice.copied": "建议已复制,去目标文件里粘上",
|
|
4388
|
+
"ext.intake.reports.show": "最近报告 {count} 份",
|
|
4389
|
+
"ext.intake.reports.hide": "收起报告",
|
|
4390
|
+
"ext.intake.err.noRemote": "宿主侧还没有外部来件接口(插件版本较旧)",
|
|
4391
|
+
"ext.intake.err.rejected": "处理被拒绝",
|
|
4392
|
+
"ext.intake.err.noClipboard": "剪贴板不可用,请手动复制",
|
|
4313
4393
|
"lab.title": "MMR 去重(实验性)",
|
|
4314
4394
|
"lab.switch": "启用 MMR 去重",
|
|
4315
4395
|
"lab.switch.onTitle": "现在开启:注入时优先让不同主题的记忆占名额",
|
|
@@ -4988,6 +5068,10 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
4988
5068
|
"ext.what1": "When enabled, whitelisted memories are copied into mirror/ under the state directory, and other agents read that copy through a read-only endpoint on 127.0.0.1.",
|
|
4989
5069
|
"ext.what2": "The endpoint can only read: no writes, no file paths, nothing outside the whitelist. Your main library is never modified by them.",
|
|
4990
5070
|
"ext.status.on": "On · {count} exposed",
|
|
5071
|
+
"ext.poll": "Poll interval",
|
|
5072
|
+
"ext.unit.seconds": "s",
|
|
5073
|
+
"ext.err.poll": "Poll interval must be an integer between 15 and 600",
|
|
5074
|
+
"ext.notice.poll": "Poll interval saved",
|
|
4991
5075
|
"ext.status.off": "Off (default)",
|
|
4992
5076
|
"ext.prefixes": "Expose whole prefix groups",
|
|
4993
5077
|
"ext.prefixesHint": "Only project_ and reference_ are on by default; user_ and feedback_ are memories about you and stay private.",
|
|
@@ -5015,6 +5099,29 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
5015
5099
|
"ext.err.noSettings": "The host has no external-access API yet (older plugin version)",
|
|
5016
5100
|
"ext.err.rejected": "The save was rejected",
|
|
5017
5101
|
"ext.err.port": "Port must be an integer between 1024 and 65535",
|
|
5102
|
+
"ext.intake.title": "Incoming submissions",
|
|
5103
|
+
"ext.intake.pending": "{count} pending",
|
|
5104
|
+
"ext.intake.what1": "Memories and edit suggestions submitted by other agents land here first. The plugin **never** writes them into your library on its own.",
|
|
5105
|
+
"ext.intake.what2": "A new entry can be approved into the library (created exclusively, never overwriting an existing name). An edit suggestion only produces a snippet you can copy over by hand - writing a half-finished patch would destroy the target file.",
|
|
5106
|
+
"ext.intake.empty": "Nothing pending right now.",
|
|
5107
|
+
"ext.intake.approve": "Approve and write",
|
|
5108
|
+
"ext.intake.reject": "Reject",
|
|
5109
|
+
"ext.intake.rejectReason": "rejected from the panel",
|
|
5110
|
+
"ext.intake.copySuggestion": "Copy suggestion",
|
|
5111
|
+
"ext.intake.kind.new": "New entry",
|
|
5112
|
+
"ext.intake.kind.patch": "Edit suggestion",
|
|
5113
|
+
"ext.intake.action.create": "Approvable",
|
|
5114
|
+
"ext.intake.action.conflict": "Name conflict",
|
|
5115
|
+
"ext.intake.action.manual": "Needs a human",
|
|
5116
|
+
"ext.intake.action.reject": "Not applicable",
|
|
5117
|
+
"ext.intake.notice.approved": "Written to {file}",
|
|
5118
|
+
"ext.intake.notice.rejected": "Rejected (the original stays in rejected/)",
|
|
5119
|
+
"ext.intake.notice.copied": "Suggestion copied - paste it into the target file",
|
|
5120
|
+
"ext.intake.reports.show": "Last {count} reports",
|
|
5121
|
+
"ext.intake.reports.hide": "Hide reports",
|
|
5122
|
+
"ext.intake.err.noRemote": "The host has no incoming-submissions API yet (older plugin version)",
|
|
5123
|
+
"ext.intake.err.rejected": "The action was rejected",
|
|
5124
|
+
"ext.intake.err.noClipboard": "Clipboard unavailable, please copy manually",
|
|
5018
5125
|
"lab.title": "MMR de-duplication (experimental)",
|
|
5019
5126
|
"lab.switch": "Enable MMR de-duplication",
|
|
5020
5127
|
"lab.switch.onTitle": "On: injection prefers memories on different topics for the same slots",
|
|
@@ -7937,6 +8044,7 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
7937
8044
|
const sFiles = react.useState([]); const files = sFiles[0], setFiles = sFiles[1];
|
|
7938
8045
|
const sTags = react.useState(""); const tagDraft = sTags[0], setTagDraft = sTags[1];
|
|
7939
8046
|
const sPort = react.useState(""); const portDraft = sPort[0], setPortDraft = sPort[1];
|
|
8047
|
+
const sPoll = react.useState(""); const pollDraft = sPoll[0], setPollDraft = sPoll[1];
|
|
7940
8048
|
const sBusy = react.useState(false); const busy = sBusy[0], setBusy = sBusy[1];
|
|
7941
8049
|
const sErr = react.useState(null); const err = sErr[0], setErr = sErr[1];
|
|
7942
8050
|
const sNotice = react.useState(""); const notice = sNotice[0], setNotice = sNotice[1];
|
|
@@ -7962,6 +8070,7 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
7962
8070
|
const cur = d.external || {};
|
|
7963
8071
|
setTagsOf(cur.tags);
|
|
7964
8072
|
setPortDraft(String(typeof cur.port === "number" ? cur.port : ""));
|
|
8073
|
+
setPollDraft(String(typeof cur.pollSeconds === "number" ? cur.pollSeconds : ""));
|
|
7965
8074
|
}, function (e) { setErr(String((e && e.message) || e)); });
|
|
7966
8075
|
if (typeof remote.externalStatus === "function") {
|
|
7967
8076
|
Promise.resolve(remote.externalStatus()).then(function (res) {
|
|
@@ -7991,6 +8100,7 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
7991
8100
|
const cur = out.settings.external || {};
|
|
7992
8101
|
setTagsOf(cur.tags);
|
|
7993
8102
|
setPortDraft(String(typeof cur.port === "number" ? cur.port : ""));
|
|
8103
|
+
setPollDraft(String(typeof cur.pollSeconds === "number" ? cur.pollSeconds : ""));
|
|
7994
8104
|
}
|
|
7995
8105
|
// 保存完立刻重读状态:暴露条数与端点都要马上反映出来(宿主那边已经 refresh 过)。
|
|
7996
8106
|
refreshStatus();
|
|
@@ -8050,6 +8160,14 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
8050
8160
|
saveExternal({ port: n }, t("ext.notice.port"));
|
|
8051
8161
|
}
|
|
8052
8162
|
|
|
8163
|
+
/** 轮询间隔(15–600 秒)。它是第二道保险:目录事件漏了也有它兜底。 */
|
|
8164
|
+
function savePoll() {
|
|
8165
|
+
const raw = String(pollDraft == null ? "" : pollDraft).trim();
|
|
8166
|
+
const n = Number(raw);
|
|
8167
|
+
if (raw === "" || !Number.isInteger(n) || n < 15 || n > 600) { setErr(t("ext.err.poll")); return; }
|
|
8168
|
+
saveExternal({ pollSeconds: n }, t("ext.notice.poll"));
|
|
8169
|
+
}
|
|
8170
|
+
|
|
8053
8171
|
const statusText = busy
|
|
8054
8172
|
? t("lab.action.saving")
|
|
8055
8173
|
: (enabled
|
|
@@ -8162,6 +8280,20 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
8162
8280
|
disabled: busy || !memSet, onClick: savePort,
|
|
8163
8281
|
}, busy ? t("lab.action.saving") : t("lab.action.save")),
|
|
8164
8282
|
]),
|
|
8283
|
+
h("div", { className: "smem-autodream-row", key: "poll" }, [
|
|
8284
|
+
h("span", { className: "smem-autodream-key", key: "k" }, t("ext.poll")),
|
|
8285
|
+
h("input", {
|
|
8286
|
+
className: "smem-input smem-num", key: "i", type: "number", min: 15, max: 600, step: 5,
|
|
8287
|
+
value: pollDraft,
|
|
8288
|
+
disabled: busy || !memSet,
|
|
8289
|
+
onChange: function (e) { setPollDraft(e.target.value); },
|
|
8290
|
+
}),
|
|
8291
|
+
h("span", { className: "smem-muted", key: "u" }, t("ext.unit.seconds")),
|
|
8292
|
+
h("button", {
|
|
8293
|
+
type: "button", className: "smem-btn smem-btn-primary", key: "save",
|
|
8294
|
+
disabled: busy || !memSet, onClick: savePoll,
|
|
8295
|
+
}, busy ? t("lab.action.saving") : t("lab.action.save")),
|
|
8296
|
+
]),
|
|
8165
8297
|
h("div", { className: "smem-autodream-note", key: "ep" }, t("ext.endpointLabel") + " " + endpointLine),
|
|
8166
8298
|
h("div", { className: "smem-autodream-note", key: "last" }, lastLine),
|
|
8167
8299
|
status && status.mirrorDir
|
|
@@ -8175,6 +8307,143 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
8175
8307
|
: null,
|
|
8176
8308
|
]),
|
|
8177
8309
|
|
|
8310
|
+
// ── 2.26.0 写侧:外部来件 ──
|
|
8311
|
+
h(ExternalIntakeCard, { key: "intake", ctx: props.ctx }),
|
|
8312
|
+
|
|
8313
|
+
err ? h("div", { className: "smem-err", key: "err" }, "⚠ " + err) : null,
|
|
8314
|
+
notice ? h("div", { className: "smem-ok", key: "ok" }, "✓ " + notice) : null,
|
|
8315
|
+
]);
|
|
8316
|
+
}
|
|
8317
|
+
|
|
8318
|
+
/**
|
|
8319
|
+
* 「外部来件」卡(2.26.0 写侧)—— 别的 agent 提交过来的东西,一条一条等人批。
|
|
8320
|
+
*
|
|
8321
|
+
* 三条不许变的产品规则:
|
|
8322
|
+
* 1. **先批后写**:插件不会自动把任何外来内容写进主库;`patch` 更是永远不自动写,
|
|
8323
|
+
* 只给一段「建议」,由人复制过去。
|
|
8324
|
+
* 2. **提案每次现算**(宿主侧算):主库随时会变,缓存一份提案等于让面板说旧话。
|
|
8325
|
+
* 3. **拒绝不删**:原件留在 `intake/agents/<来源>/rejected/`,理由进报告。
|
|
8326
|
+
*/
|
|
8327
|
+
function ExternalIntakeCard(props) {
|
|
8328
|
+
const remote = stableRemote(props.ctx, "remote.memory");
|
|
8329
|
+
const sOv = react.useState(null); const ov = sOv[0], setOv = sOv[1];
|
|
8330
|
+
const sBusy = react.useState(""); const busy = sBusy[0], setBusy = sBusy[1];
|
|
8331
|
+
const sErr = react.useState(null); const err = sErr[0], setErr = sErr[1];
|
|
8332
|
+
const sNotice = react.useState(""); const notice = sNotice[0], setNotice = sNotice[1];
|
|
8333
|
+
const sReports = react.useState(false); const reportsOpen = sReports[0], setReportsOpen = sReports[1];
|
|
8334
|
+
|
|
8335
|
+
function load() {
|
|
8336
|
+
if (!remote || typeof remote.externalSubmissions !== "function") {
|
|
8337
|
+
setErr(t("ext.intake.err.noRemote"));
|
|
8338
|
+
return;
|
|
8339
|
+
}
|
|
8340
|
+
Promise.resolve(remote.externalSubmissions()).then(function (res) {
|
|
8341
|
+
setOv(unwrap(res) || { pending: 0, items: [], scanError: "", reports: [] });
|
|
8342
|
+
}, function (e) { setErr(String((e && e.message) || e)); });
|
|
8343
|
+
}
|
|
8344
|
+
|
|
8345
|
+
react.useEffect(function () { load(); }, []);
|
|
8346
|
+
|
|
8347
|
+
/** 批准 / 拒绝一条。批准只对 `create` 有效,其余动作宿主会回原因。 */
|
|
8348
|
+
function act(kind, id) {
|
|
8349
|
+
const fn = kind === "approve" ? remote && remote.intakeApprove : remote && remote.intakeReject;
|
|
8350
|
+
if (typeof fn !== "function") { setErr(t("ext.intake.err.noRemote")); return; }
|
|
8351
|
+
setBusy(id); setErr(null); setNotice("");
|
|
8352
|
+
const args = kind === "approve" ? [id] : [id, t("ext.intake.rejectReason")];
|
|
8353
|
+
Promise.resolve(fn.apply(remote, args)).then(function (out) {
|
|
8354
|
+
setBusy("");
|
|
8355
|
+
const r = unwrap(out) || out || {};
|
|
8356
|
+
if (r.ok === false) { setErr(r.error || t("ext.intake.err.rejected")); load(); return; }
|
|
8357
|
+
setNotice(kind === "approve"
|
|
8358
|
+
? t("ext.intake.notice.approved", { file: r.targetFile || "" })
|
|
8359
|
+
: t("ext.intake.notice.rejected"));
|
|
8360
|
+
load();
|
|
8361
|
+
}, function (e) { setBusy(""); setErr(String((e && e.message) || e)); });
|
|
8362
|
+
}
|
|
8363
|
+
|
|
8364
|
+
/** patch 的「复制建议」:只复制「建议改成」那一段,不复制整份 patch。 */
|
|
8365
|
+
function copySuggestion(text) {
|
|
8366
|
+
const clip = typeof navigator !== "undefined" ? navigator.clipboard : null;
|
|
8367
|
+
if (!clip || typeof clip.writeText !== "function") { setErr(t("ext.intake.err.noClipboard")); return; }
|
|
8368
|
+
Promise.resolve(clip.writeText(String(text || ""))).then(function () {
|
|
8369
|
+
setNotice(t("ext.intake.notice.copied"));
|
|
8370
|
+
}, function () { setErr(t("ext.intake.err.noClipboard")); });
|
|
8371
|
+
}
|
|
8372
|
+
|
|
8373
|
+
const items = (ov && ov.items) || [];
|
|
8374
|
+
const reports = (ov && ov.reports) || [];
|
|
8375
|
+
const ACTION_LABEL = {
|
|
8376
|
+
create: t("ext.intake.action.create"),
|
|
8377
|
+
conflict: t("ext.intake.action.conflict"),
|
|
8378
|
+
manual: t("ext.intake.action.manual"),
|
|
8379
|
+
reject: t("ext.intake.action.reject"),
|
|
8380
|
+
};
|
|
8381
|
+
|
|
8382
|
+
return h("div", { className: "smem-intake smem-module-card" }, [
|
|
8383
|
+
h("div", { className: "smem-modcard-head", key: "head" }, [
|
|
8384
|
+
h("span", { className: "smem-modcard-title", key: "t" }, t("ext.intake.title")),
|
|
8385
|
+
h("span", { className: "smem-modcard-status", key: "s" }, t("ext.intake.pending", { count: items.length })),
|
|
8386
|
+
]),
|
|
8387
|
+
|
|
8388
|
+
h("div", { className: "smem-autodream-sec", key: "what" }, [
|
|
8389
|
+
h("div", { className: "smem-autodream-note", key: "p1" }, t("ext.intake.what1")),
|
|
8390
|
+
h("div", { className: "smem-autodream-note", key: "p2" }, t("ext.intake.what2")),
|
|
8391
|
+
]),
|
|
8392
|
+
|
|
8393
|
+
ov && ov.scanError ? h("div", { className: "smem-err", key: "scan" }, "⚠ " + ov.scanError) : null,
|
|
8394
|
+
|
|
8395
|
+
items.length === 0
|
|
8396
|
+
? h("div", { className: "smem-muted", key: "empty" }, t("ext.intake.empty"))
|
|
8397
|
+
: h("div", { className: "smem-intake-list", key: "list" }, items.map(function (it) {
|
|
8398
|
+
const disabled = busy === it.id;
|
|
8399
|
+
const buttons = [];
|
|
8400
|
+
if (it.action === "create") {
|
|
8401
|
+
buttons.push(h("button", {
|
|
8402
|
+
type: "button", className: "smem-btn smem-btn-primary", key: "ok",
|
|
8403
|
+
disabled: disabled || !!ov.scanError,
|
|
8404
|
+
onClick: function () { act("approve", it.id); },
|
|
8405
|
+
}, t("ext.intake.approve")));
|
|
8406
|
+
}
|
|
8407
|
+
if (it.action === "manual" && it.suggestion) {
|
|
8408
|
+
buttons.push(h("button", {
|
|
8409
|
+
type: "button", className: "smem-btn", key: "copy",
|
|
8410
|
+
disabled: disabled,
|
|
8411
|
+
onClick: function () { copySuggestion(it.suggestion); },
|
|
8412
|
+
}, t("ext.intake.copySuggestion")));
|
|
8413
|
+
}
|
|
8414
|
+
buttons.push(h("button", {
|
|
8415
|
+
type: "button", className: "smem-btn", key: "no",
|
|
8416
|
+
disabled: disabled,
|
|
8417
|
+
onClick: function () { act("reject", it.id); },
|
|
8418
|
+
}, t("ext.intake.reject")));
|
|
8419
|
+
|
|
8420
|
+
return h("div", { className: "smem-intake-row", key: it.id }, [
|
|
8421
|
+
h("div", { className: "smem-intake-line", key: "l" }, [
|
|
8422
|
+
h("span", { className: "smem-intake-src", key: "src" }, it.source || "?"),
|
|
8423
|
+
h("span", { className: "smem-muted", key: "kind" }, it.kind === "patch" ? t("ext.intake.kind.patch") : t("ext.intake.kind.new")),
|
|
8424
|
+
h("span", { className: "smem-intake-name", key: "n" }, it.targetFile || it.name || ""),
|
|
8425
|
+
h("span", { className: "smem-intake-badge smem-intake-badge--" + String(it.action || ""), key: "a" }, ACTION_LABEL[it.action] || String(it.action || "")),
|
|
8426
|
+
]),
|
|
8427
|
+
h("div", { className: "smem-intake-why", key: "w" }, it.reason || ""),
|
|
8428
|
+
it.excerpt ? h("div", { className: "smem-intake-excerpt", key: "e" }, it.excerpt) : null,
|
|
8429
|
+
h("div", { className: "smem-intake-actions", key: "b" }, buttons),
|
|
8430
|
+
]);
|
|
8431
|
+
})),
|
|
8432
|
+
|
|
8433
|
+
reports.length > 0
|
|
8434
|
+
? h("div", { className: "smem-autodream-sec", key: "reports" }, [
|
|
8435
|
+
h("button", {
|
|
8436
|
+
type: "button", className: "smem-btn", key: "toggle",
|
|
8437
|
+
onClick: function () { setReportsOpen(!reportsOpen); },
|
|
8438
|
+
}, reportsOpen ? t("ext.intake.reports.hide") : t("ext.intake.reports.show", { count: reports.length })),
|
|
8439
|
+
reportsOpen
|
|
8440
|
+
? h("div", { className: "smem-intake-reports", key: "list" }, reports.map(function (r) {
|
|
8441
|
+
return h("pre", { className: "smem-intake-report", key: r.name }, r.text);
|
|
8442
|
+
}))
|
|
8443
|
+
: null,
|
|
8444
|
+
])
|
|
8445
|
+
: null,
|
|
8446
|
+
|
|
8178
8447
|
err ? h("div", { className: "smem-err", key: "err" }, "⚠ " + err) : null,
|
|
8179
8448
|
notice ? h("div", { className: "smem-ok", key: "ok" }, "✓ " + notice) : null,
|
|
8180
8449
|
]);
|
package/lib/index.js
CHANGED
|
@@ -536,6 +536,21 @@ export class MemoryGateway extends TypertRemoteService {
|
|
|
536
536
|
return this.mirror.status()
|
|
537
537
|
}
|
|
538
538
|
|
|
539
|
+
/** 外部来件(2.26.0):待处理提交 + 每条现算的提案 + 最近报告。只读。 */
|
|
540
|
+
async externalSubmissions() {
|
|
541
|
+
return this.mirror.intake.merger.overview()
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/** 批准一条 `new`:排他写主库 + 补索引。`conflict` / `manual` / `patch` 一律不写,回原因。 */
|
|
545
|
+
async intakeApprove(id) {
|
|
546
|
+
return this.mirror.intake.merger.approve(id)
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/** 拒绝一条:原件留档 `rejected/`(不删),理由进报告与审计。 */
|
|
550
|
+
async intakeReject(id, reason) {
|
|
551
|
+
return this.mirror.intake.merger.reject(id, reason)
|
|
552
|
+
}
|
|
553
|
+
|
|
539
554
|
/**
|
|
540
555
|
* 原样读保留名文件(`MEMORY.md` / `session-log.md` / 用户声明的保护名)。
|
|
541
556
|
*
|
|
@@ -606,6 +621,10 @@ markRemote(MemoryGateway, 'getSettings', 'getSettings')
|
|
|
606
621
|
markRemote(MemoryGateway, 'setSettings', 'setSettings')
|
|
607
622
|
// 2.25.0:外部访问读侧的运行状态(第 41 条)。只读、无入参 —— 面板不看账,只看出没出问题。
|
|
608
623
|
markRemote(MemoryGateway, 'externalStatus', 'externalStatus')
|
|
624
|
+
// 2.26.0:写侧三条 —— 来件总览 / 批准 / 拒绝。批准是唯一能把外来内容写进主库的入口。
|
|
625
|
+
markRemote(MemoryGateway, 'externalSubmissions', 'externalSubmissions')
|
|
626
|
+
markRemote(MemoryGateway, 'intakeApprove', 'intakeApprove')
|
|
627
|
+
markRemote(MemoryGateway, 'intakeReject', 'intakeReject')
|
|
609
628
|
markRemote(MemoryGateway, 'readRaw', 'readRaw')
|
|
610
629
|
markRemote(MemoryGateway, 'writeRaw', 'writeRaw')
|
|
611
630
|
// 1.7.0:注入调试账(只读;开关关着时返回 { enabled: false, records: [] })
|