sage-mem 2.24.1 → 2.26.0
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 +69 -1
- package/README.md +69 -1
- package/lib/assembly/index.js +3 -0
- package/lib/assembly/mirror-mount.js +195 -0
- package/lib/client.js +599 -0
- package/lib/index.js +48 -3
- package/lib/intake/merge.js +193 -0
- package/lib/intake/policy.js +238 -0
- package/lib/intake/store.js +247 -0
- package/lib/memory/config.js +7 -15
- package/lib/mirror/export.js +224 -0
- package/lib/mirror/mcp.js +443 -0
- package/lib/mirror/policy.js +311 -0
- package/lib/settings.js +34 -6
- package/lib/shared/int-spec.js +28 -0
- package/lib/typert/schemas.js +105 -0
- package/lib/typert.host.js +51 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -2188,6 +2188,57 @@ const StarmapRuntime = (function (require, _react) {
|
|
|
2188
2188
|
result: { mode: "strict", typeSymbol: "sage-mem/types#MemorySettingsResult", schema: objCodec, create: () => objCodec },
|
|
2189
2189
|
sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
|
|
2190
2190
|
},
|
|
2191
|
+
{
|
|
2192
|
+
// 2.25.0:外部访问读侧的**运行状态**(只读、无入参)。设置走 setSettings({ external }),
|
|
2193
|
+
// 这里回答「现在跑成什么样」—— 暴露条目数 / 最近一轮的时间与错误 / 端点是否在听。
|
|
2194
|
+
// 与 getSettings 同一个理由用 objCodec:顶层严格、内部宽松,host 加字段不用改这里。
|
|
2195
|
+
id: "sage-mem#memory/externalStatus",
|
|
2196
|
+
service: "memory",
|
|
2197
|
+
namespace: "memory",
|
|
2198
|
+
method: "externalStatus",
|
|
2199
|
+
invocation: { kind: "direct" },
|
|
2200
|
+
parameters: [],
|
|
2201
|
+
result: { mode: "strict", typeSymbol: "sage-mem/types#ExternalStatus", schema: objCodec, create: () => objCodec },
|
|
2202
|
+
sourceLocation: { "file": "lib/index.js", "line": 1, "column": 1 },
|
|
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
|
+
},
|
|
2191
2242
|
{
|
|
2192
2243
|
id: "sage-mem#memory/readRaw",
|
|
2193
2244
|
service: "memory",
|
|
@@ -2901,6 +2952,27 @@ const StarmapRuntime = (function (require, _react) {
|
|
|
2901
2952
|
".smem-todo-cp-note{font-size:11px;color:var(--dsw-alias-label-secondary);}",
|
|
2902
2953
|
".smem-todo-done-state{display:flex;flex-direction:column;gap:6px;padding:16px 12px;}",
|
|
2903
2954
|
".smem-todo-done-title{font-weight:600;}",
|
|
2955
|
+
// 2.25.0:「外部访问」逐条勾选清单 —— 只是一个带边框的滚动列表,
|
|
2956
|
+
// 勾上的行用左侧强调条区分(不整行换底色,长列表里那样太吵)。
|
|
2957
|
+
".smem-ext-list{display:flex;flex-direction:column;gap:2px;max-height:260px;overflow:auto;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:6px 8px;}",
|
|
2958
|
+
".smem-ext-row{display:flex;align-items:center;gap:8px;padding:3px 4px;border-radius:6px;border-left:2px solid transparent;cursor:pointer;font-size:12.5px;}",
|
|
2959
|
+
".smem-ext-row:hover{background:var(--dsw-alias-bg-l2,transparent);}",
|
|
2960
|
+
'.smem-ext-row--on{border-left-color:var(--dsw-alias-brand-primary,#4d76e6);}',
|
|
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;}',
|
|
2904
2976
|
].join("\n");
|
|
2905
2977
|
|
|
2906
2978
|
/**
|
|
@@ -4254,6 +4326,66 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
4254
4326
|
"tab.auto": "自动整理",
|
|
4255
4327
|
"tab.health": "库健康",
|
|
4256
4328
|
"tab.lab": "实验性",
|
|
4329
|
+
"tab.external": "外部访问",
|
|
4330
|
+
// ── 2.25.0 外部访问(读侧)──────────────────────────────────
|
|
4331
|
+
"ext.title": "外部访问(只读)",
|
|
4332
|
+
"ext.switch": "允许本机其他 agent 读取记忆副本",
|
|
4333
|
+
"ext.switch.onTitle": "现在开启:白名单内的记忆会被导出成副本,端点对 127.0.0.1 开放",
|
|
4334
|
+
"ext.switch.offTitle": "现在关闭:不导出、不开端口(默认)",
|
|
4335
|
+
"ext.what1": "开关打开后,白名单内的记忆会被复制到状态目录下的 mirror/ 里,其他 agent 通过 127.0.0.1 上的只读接口读那一份副本。",
|
|
4336
|
+
"ext.what2": "接口只有读:没有写入、不给文件路径、拿不到没勾选的条目。主库一个字都不会被它们改到。",
|
|
4337
|
+
"ext.status.on": "已开启 · 暴露 {count} 条",
|
|
4338
|
+
"ext.status.off": "关闭(默认)",
|
|
4339
|
+
"ext.prefixes": "按前缀整类开放",
|
|
4340
|
+
"ext.prefixesHint": "默认只开 project_ 与 reference_;user_ 与 feedback_ 是「关于我自己」的记忆,默认不给。",
|
|
4341
|
+
"ext.tags": "按标签开放",
|
|
4342
|
+
"ext.tagsPlaceholder": "用逗号分隔,例如:记忆系统, 发布",
|
|
4343
|
+
"ext.tagsHint": "留空 = 不按标签开放。标签写在记忆的 frontmatter 里。",
|
|
4344
|
+
"ext.files": "逐条勾选",
|
|
4345
|
+
"ext.filesHint": "勾上就包含、取消就排除;前缀整类开着时,取消勾选会记成「逐条排除」并压过前缀。",
|
|
4346
|
+
"ext.filesEmpty": "记忆目录里还没有可导出的条目。",
|
|
4347
|
+
"ext.exposed": "当前实际暴露 {count} 条(以上一轮导出为准)",
|
|
4348
|
+
"ext.port": "端点端口",
|
|
4349
|
+
"ext.endpointLabel": "只读端点:",
|
|
4350
|
+
"ext.endpoint.on": "在听 {url}",
|
|
4351
|
+
"ext.endpoint.off": "未启动",
|
|
4352
|
+
"ext.endpoint.error": "起不来:{error}",
|
|
4353
|
+
"ext.lastExport": "最近一轮:{time} · 写 {written} / 未变 {unchanged} / 删 {deleted}",
|
|
4354
|
+
"ext.lastExport.never": "最近一轮:还没有导出过",
|
|
4355
|
+
"ext.dir": "副本目录:{dir}",
|
|
4356
|
+
"ext.notice.on": "已开启:下一轮导出最多 10 秒后开始,端点随即就绪",
|
|
4357
|
+
"ext.notice.off": "已关闭,端点已停",
|
|
4358
|
+
"ext.notice.prefix": "前缀白名单已更新",
|
|
4359
|
+
"ext.notice.file": "逐条名单已更新",
|
|
4360
|
+
"ext.notice.port": "端口已保存(端点已按新端口重启)",
|
|
4361
|
+
"ext.notice.saved": "已保存",
|
|
4362
|
+
"ext.err.noSettings": "宿主侧还没有外部访问接口(插件版本较旧)",
|
|
4363
|
+
"ext.err.rejected": "保存被拒绝",
|
|
4364
|
+
"ext.err.port": "端口要填 1024–65535 的整数",
|
|
4365
|
+
// ── 2.26.0 外部来件(写侧)──────────────────────────────────
|
|
4366
|
+
"ext.intake.title": "外部来件",
|
|
4367
|
+
"ext.intake.pending": "待处理 {count} 条",
|
|
4368
|
+
"ext.intake.what1": "别的 agent 提交过来的记忆与修改建议会先落在这里,插件**不会**自动写进主库。",
|
|
4369
|
+
"ext.intake.what2": "「新条目」可以批准落库(排他创建,不覆盖同名);「修改建议」只给一段建议,要你复制过去手工并入 —— 半成品直接写会毁掉目标文件。",
|
|
4370
|
+
"ext.intake.empty": "现在没有待处理的来件。",
|
|
4371
|
+
"ext.intake.approve": "批准并写入",
|
|
4372
|
+
"ext.intake.reject": "拒绝",
|
|
4373
|
+
"ext.intake.rejectReason": "在面板里拒绝",
|
|
4374
|
+
"ext.intake.copySuggestion": "复制建议",
|
|
4375
|
+
"ext.intake.kind.new": "新条目",
|
|
4376
|
+
"ext.intake.kind.patch": "修改建议",
|
|
4377
|
+
"ext.intake.action.create": "可批准",
|
|
4378
|
+
"ext.intake.action.conflict": "同名冲突",
|
|
4379
|
+
"ext.intake.action.manual": "需人工",
|
|
4380
|
+
"ext.intake.action.reject": "不建议收",
|
|
4381
|
+
"ext.intake.notice.approved": "已写入 {file}",
|
|
4382
|
+
"ext.intake.notice.rejected": "已拒绝(原件留在 rejected/ 里)",
|
|
4383
|
+
"ext.intake.notice.copied": "建议已复制,去目标文件里粘上",
|
|
4384
|
+
"ext.intake.reports.show": "最近报告 {count} 份",
|
|
4385
|
+
"ext.intake.reports.hide": "收起报告",
|
|
4386
|
+
"ext.intake.err.noRemote": "宿主侧还没有外部来件接口(插件版本较旧)",
|
|
4387
|
+
"ext.intake.err.rejected": "处理被拒绝",
|
|
4388
|
+
"ext.intake.err.noClipboard": "剪贴板不可用,请手动复制",
|
|
4257
4389
|
"lab.title": "MMR 去重(实验性)",
|
|
4258
4390
|
"lab.switch": "启用 MMR 去重",
|
|
4259
4391
|
"lab.switch.onTitle": "现在开启:注入时优先让不同主题的记忆占名额",
|
|
@@ -4924,6 +5056,64 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
4924
5056
|
"tab.auto": "Automation",
|
|
4925
5057
|
"tab.health": "Health",
|
|
4926
5058
|
"tab.lab": "Lab",
|
|
5059
|
+
"tab.external": "External",
|
|
5060
|
+
"ext.title": "External access (read-only)",
|
|
5061
|
+
"ext.switch": "Let other local agents read a copy of the memory library",
|
|
5062
|
+
"ext.switch.onTitle": "On: whitelisted memories are exported to a copy, and the endpoint listens on 127.0.0.1",
|
|
5063
|
+
"ext.switch.offTitle": "Off: nothing is exported and no port is opened (default)",
|
|
5064
|
+
"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.",
|
|
5065
|
+
"ext.what2": "The endpoint can only read: no writes, no file paths, nothing outside the whitelist. Your main library is never modified by them.",
|
|
5066
|
+
"ext.status.on": "On · {count} exposed",
|
|
5067
|
+
"ext.status.off": "Off (default)",
|
|
5068
|
+
"ext.prefixes": "Expose whole prefix groups",
|
|
5069
|
+
"ext.prefixesHint": "Only project_ and reference_ are on by default; user_ and feedback_ are memories about you and stay private.",
|
|
5070
|
+
"ext.tags": "Expose by tag",
|
|
5071
|
+
"ext.tagsPlaceholder": "Comma separated, e.g. memory-system, release",
|
|
5072
|
+
"ext.tagsHint": "Empty means no tag-based exposure. Tags live in each memory's frontmatter.",
|
|
5073
|
+
"ext.files": "Per-file selection",
|
|
5074
|
+
"ext.filesHint": "Checked means included, unchecked means excluded; when a prefix group is on, unchecking records a per-file exclusion that overrides it.",
|
|
5075
|
+
"ext.filesEmpty": "No exportable entries in the memory directory yet.",
|
|
5076
|
+
"ext.exposed": "{count} exposed right now (from the last export)",
|
|
5077
|
+
"ext.port": "Endpoint port",
|
|
5078
|
+
"ext.endpointLabel": "Read-only endpoint:",
|
|
5079
|
+
"ext.endpoint.on": "listening on {url}",
|
|
5080
|
+
"ext.endpoint.off": "not running",
|
|
5081
|
+
"ext.endpoint.error": "failed to start: {error}",
|
|
5082
|
+
"ext.lastExport": "Last export: {time} · {written} written / {unchanged} unchanged / {deleted} deleted",
|
|
5083
|
+
"ext.lastExport.never": "Last export: never ran",
|
|
5084
|
+
"ext.dir": "Copy directory: {dir}",
|
|
5085
|
+
"ext.notice.on": "Enabled: the first export starts within 10 seconds and the endpoint comes up right after",
|
|
5086
|
+
"ext.notice.off": "Disabled, endpoint stopped",
|
|
5087
|
+
"ext.notice.prefix": "Prefix whitelist updated",
|
|
5088
|
+
"ext.notice.file": "Per-file selection updated",
|
|
5089
|
+
"ext.notice.port": "Port saved (endpoint restarted on the new port)",
|
|
5090
|
+
"ext.notice.saved": "Saved",
|
|
5091
|
+
"ext.err.noSettings": "The host has no external-access API yet (older plugin version)",
|
|
5092
|
+
"ext.err.rejected": "The save was rejected",
|
|
5093
|
+
"ext.err.port": "Port must be an integer between 1024 and 65535",
|
|
5094
|
+
"ext.intake.title": "Incoming submissions",
|
|
5095
|
+
"ext.intake.pending": "{count} pending",
|
|
5096
|
+
"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.",
|
|
5097
|
+
"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.",
|
|
5098
|
+
"ext.intake.empty": "Nothing pending right now.",
|
|
5099
|
+
"ext.intake.approve": "Approve and write",
|
|
5100
|
+
"ext.intake.reject": "Reject",
|
|
5101
|
+
"ext.intake.rejectReason": "rejected from the panel",
|
|
5102
|
+
"ext.intake.copySuggestion": "Copy suggestion",
|
|
5103
|
+
"ext.intake.kind.new": "New entry",
|
|
5104
|
+
"ext.intake.kind.patch": "Edit suggestion",
|
|
5105
|
+
"ext.intake.action.create": "Approvable",
|
|
5106
|
+
"ext.intake.action.conflict": "Name conflict",
|
|
5107
|
+
"ext.intake.action.manual": "Needs a human",
|
|
5108
|
+
"ext.intake.action.reject": "Not applicable",
|
|
5109
|
+
"ext.intake.notice.approved": "Written to {file}",
|
|
5110
|
+
"ext.intake.notice.rejected": "Rejected (the original stays in rejected/)",
|
|
5111
|
+
"ext.intake.notice.copied": "Suggestion copied - paste it into the target file",
|
|
5112
|
+
"ext.intake.reports.show": "Last {count} reports",
|
|
5113
|
+
"ext.intake.reports.hide": "Hide reports",
|
|
5114
|
+
"ext.intake.err.noRemote": "The host has no incoming-submissions API yet (older plugin version)",
|
|
5115
|
+
"ext.intake.err.rejected": "The action was rejected",
|
|
5116
|
+
"ext.intake.err.noClipboard": "Clipboard unavailable, please copy manually",
|
|
4927
5117
|
"lab.title": "MMR de-duplication (experimental)",
|
|
4928
5118
|
"lab.switch": "Enable MMR de-duplication",
|
|
4929
5119
|
"lab.switch.onTitle": "On: injection prefers memories on different topics for the same slots",
|
|
@@ -7822,6 +8012,409 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
7822
8012
|
]),
|
|
7823
8013
|
]);
|
|
7824
8014
|
}
|
|
8015
|
+
/**
|
|
8016
|
+
* 「外部访问」一屏(2.25.0)—— **读侧**:把白名单内的记忆导出成副本,本机其他 agent 只能读它。
|
|
8017
|
+
*
|
|
8018
|
+
* 为什么单开一屏而不是塞进「实验性」:这一屏控制的是**谁能看见我的记忆**,不是选材
|
|
8019
|
+
* 也不是预算。它出事的样子和前两屏都不一样 —— 「本不该给外面看的那条,被导出去了」。
|
|
8020
|
+
* 用户必须能一眼看到「现在暴露了几条」,并且能一条条关掉。
|
|
8021
|
+
*
|
|
8022
|
+
* 数据全走已有的 remote:
|
|
8023
|
+
* - `memory.getSettings()` → `{ external, externalDiagnostics, ... }`(设置是生效值,**不进重启**)
|
|
8024
|
+
* - `memory.externalStatus()` → 暴露条目数 / 名单 / 最近一轮 / 端点状态(只读)
|
|
8025
|
+
* - `memory.listFiles()` → 逐条勾选的那个列表
|
|
8026
|
+
* - `memory.setSettings({ external })` → 补丁式保存;返回 `{ ok, settings, restartRequired }`
|
|
8027
|
+
*
|
|
8028
|
+
* ⚠️ **白名单判据不在客户端复制一份**:哪些条目现在算暴露,由宿主 `externalStatus().exposedNames`
|
|
8029
|
+
* 直接给(它就是副本目录里的实际内容)。客户端只负责「勾 / 取消 → 写成 include / exclude」,
|
|
8030
|
+
* 判据仍然只有 `lib/mirror/policy.js` 一处 —— 面板算一套、导出算另一套,正是要避免的那种漂移。
|
|
8031
|
+
*/
|
|
8032
|
+
function ExternalAccessPanel(props) {
|
|
8033
|
+
const remote = stableRemote(props.ctx, "remote.memory");
|
|
8034
|
+
const sSet = react.useState(null); const memSet = sSet[0], setMemSet = sSet[1];
|
|
8035
|
+
const sStatus = react.useState(null); const status = sStatus[0], setStatus = sStatus[1];
|
|
8036
|
+
const sFiles = react.useState([]); const files = sFiles[0], setFiles = sFiles[1];
|
|
8037
|
+
const sTags = react.useState(""); const tagDraft = sTags[0], setTagDraft = sTags[1];
|
|
8038
|
+
const sPort = react.useState(""); const portDraft = sPort[0], setPortDraft = sPort[1];
|
|
8039
|
+
const sBusy = react.useState(false); const busy = sBusy[0], setBusy = sBusy[1];
|
|
8040
|
+
const sErr = react.useState(null); const err = sErr[0], setErr = sErr[1];
|
|
8041
|
+
const sNotice = react.useState(""); const notice = sNotice[0], setNotice = sNotice[1];
|
|
8042
|
+
|
|
8043
|
+
const ext = (memSet && memSet.external) || null;
|
|
8044
|
+
const enabled = !!(ext && ext.enabled);
|
|
8045
|
+
const prefixes = (ext && ext.prefixes) || [];
|
|
8046
|
+
const exposedNames = (status && status.exposedNames) || [];
|
|
8047
|
+
const exposed = new Set(exposedNames);
|
|
8048
|
+
const endpoint = (status && status.endpoint) || null;
|
|
8049
|
+
|
|
8050
|
+
/** 前缀候选:默认那两个 + 另外两类(面板把「不给」也画出来,免得以为漏了)。 */
|
|
8051
|
+
const PREFIX_CHOICES = ["project_", "reference_", "user_", "feedback_"];
|
|
8052
|
+
|
|
8053
|
+
function load() {
|
|
8054
|
+
if (!remote || typeof remote.getSettings !== "function") {
|
|
8055
|
+
setErr(t("ext.err.noSettings"));
|
|
8056
|
+
return;
|
|
8057
|
+
}
|
|
8058
|
+
Promise.resolve(remote.getSettings()).then(function (res) {
|
|
8059
|
+
const d = unwrap(res) || {};
|
|
8060
|
+
setMemSet(d);
|
|
8061
|
+
const cur = d.external || {};
|
|
8062
|
+
setTagsOf(cur.tags);
|
|
8063
|
+
setPortDraft(String(typeof cur.port === "number" ? cur.port : ""));
|
|
8064
|
+
}, function (e) { setErr(String((e && e.message) || e)); });
|
|
8065
|
+
if (typeof remote.externalStatus === "function") {
|
|
8066
|
+
Promise.resolve(remote.externalStatus()).then(function (res) {
|
|
8067
|
+
setStatus(unwrap(res) || {});
|
|
8068
|
+
}, function () { /* 状态读不到不影响设置那一半 */ });
|
|
8069
|
+
}
|
|
8070
|
+
if (typeof remote.listFiles === "function") {
|
|
8071
|
+
Promise.resolve(remote.listFiles()).then(function (res) {
|
|
8072
|
+
setFiles(Array.isArray(unwrap(res)) ? unwrap(res) : []);
|
|
8073
|
+
}, function () { /* 列表读不到就只显示开关与端点 */ });
|
|
8074
|
+
}
|
|
8075
|
+
}
|
|
8076
|
+
|
|
8077
|
+
function setTagsOf(list) { setTagDraft((Array.isArray(list) ? list : []).join(", ")); }
|
|
8078
|
+
|
|
8079
|
+
react.useEffect(function () { load(); }, []);
|
|
8080
|
+
|
|
8081
|
+
/** 保存一段 `external` 补丁。`setSettings` 自带 `{ok, settings}`,不要过 unwrap。 */
|
|
8082
|
+
function saveExternal(patch, okMsg) {
|
|
8083
|
+
if (!remote || typeof remote.setSettings !== "function") { setErr(t("ext.err.noSettings")); return; }
|
|
8084
|
+
setBusy(true); setErr(null); setNotice("");
|
|
8085
|
+
Promise.resolve(remote.setSettings({ external: patch })).then(function (out) {
|
|
8086
|
+
setBusy(false);
|
|
8087
|
+
if (out && out.ok === false) { setErr(out.error || t("ext.err.rejected")); return; }
|
|
8088
|
+
if (out && out.settings) {
|
|
8089
|
+
setMemSet(out.settings);
|
|
8090
|
+
const cur = out.settings.external || {};
|
|
8091
|
+
setTagsOf(cur.tags);
|
|
8092
|
+
setPortDraft(String(typeof cur.port === "number" ? cur.port : ""));
|
|
8093
|
+
}
|
|
8094
|
+
// 保存完立刻重读状态:暴露条数与端点都要马上反映出来(宿主那边已经 refresh 过)。
|
|
8095
|
+
refreshStatus();
|
|
8096
|
+
setNotice(okMsg);
|
|
8097
|
+
}, function (e) {
|
|
8098
|
+
setBusy(false);
|
|
8099
|
+
setErr(String((e && e.message) || e));
|
|
8100
|
+
});
|
|
8101
|
+
}
|
|
8102
|
+
|
|
8103
|
+
function refreshStatus() {
|
|
8104
|
+
if (!remote || typeof remote.externalStatus !== "function") return;
|
|
8105
|
+
Promise.resolve(remote.externalStatus()).then(function (res) {
|
|
8106
|
+
setStatus(unwrap(res) || {});
|
|
8107
|
+
}, function () { /* 同上 */ });
|
|
8108
|
+
}
|
|
8109
|
+
|
|
8110
|
+
function toggleEnabled() {
|
|
8111
|
+
saveExternal({ enabled: enabled ? 0 : 1 }, enabled ? t("ext.notice.off") : t("ext.notice.on"));
|
|
8112
|
+
}
|
|
8113
|
+
|
|
8114
|
+
/** 前缀整类开关:在数组里加 / 减一项,其余原样(顺序按 PREFIX_CHOICES 归一)。 */
|
|
8115
|
+
function togglePrefix(prefix) {
|
|
8116
|
+
const has = prefixes.some(function (p) { return String(p).toLowerCase() === prefix.toLowerCase(); });
|
|
8117
|
+
const next = has
|
|
8118
|
+
? prefixes.filter(function (p) { return String(p).toLowerCase() !== prefix.toLowerCase(); })
|
|
8119
|
+
: prefixes.concat([prefix]);
|
|
8120
|
+
saveExternal({ prefixes: next }, t("ext.notice.prefix"));
|
|
8121
|
+
}
|
|
8122
|
+
|
|
8123
|
+
/** 标签白名单:逗号分隔(中英文逗号都收)。空 = 不按标签开放。 */
|
|
8124
|
+
function saveTags() {
|
|
8125
|
+
const list = String(tagDraft == null ? "" : tagDraft)
|
|
8126
|
+
.split(/[,,]/)
|
|
8127
|
+
.map(function (s) { return s.trim(); })
|
|
8128
|
+
.filter(function (s) { return s !== ""; });
|
|
8129
|
+
saveExternal({ tags: list }, t("ext.notice.saved"));
|
|
8130
|
+
}
|
|
8131
|
+
|
|
8132
|
+
/**
|
|
8133
|
+
* 逐条勾选:勾上 → include、取消 → exclude(同时从另一侧摘掉,免得两份名单都记着它)。
|
|
8134
|
+
* 「取消」写的是 exclude 而不是「什么都不做」—— 前缀整类打开时,只有 exclude 能压过它。
|
|
8135
|
+
*/
|
|
8136
|
+
function toggleFile(name) {
|
|
8137
|
+
if (!ext) return;
|
|
8138
|
+
const include = (ext.include || []).filter(function (n) { return n !== name; });
|
|
8139
|
+
const exclude = (ext.exclude || []).filter(function (n) { return n !== name; });
|
|
8140
|
+
if (exposed.has(name)) exclude.push(name);
|
|
8141
|
+
else include.push(name);
|
|
8142
|
+
saveExternal({ include: include, exclude: exclude }, t("ext.notice.file"));
|
|
8143
|
+
}
|
|
8144
|
+
|
|
8145
|
+
function savePort() {
|
|
8146
|
+
const raw = String(portDraft == null ? "" : portDraft).trim();
|
|
8147
|
+
const n = Number(raw);
|
|
8148
|
+
if (raw === "" || !Number.isInteger(n) || n < 1024 || n > 65535) { setErr(t("ext.err.port")); return; }
|
|
8149
|
+
saveExternal({ port: n }, t("ext.notice.port"));
|
|
8150
|
+
}
|
|
8151
|
+
|
|
8152
|
+
const statusText = busy
|
|
8153
|
+
? t("lab.action.saving")
|
|
8154
|
+
: (enabled
|
|
8155
|
+
? t("ext.status.on", { count: exposedNames.length })
|
|
8156
|
+
: t("ext.status.off"));
|
|
8157
|
+
|
|
8158
|
+
/** 最近一轮那一行:没有导出过就明说「还没跑过」,不要显示成 0 秒前。 */
|
|
8159
|
+
const lastLine = !status || !status.lastExportAt
|
|
8160
|
+
? t("ext.lastExport.never")
|
|
8161
|
+
: t("ext.lastExport", {
|
|
8162
|
+
time: new Date(status.lastExportAt).toLocaleTimeString(),
|
|
8163
|
+
written: status.written, unchanged: status.unchanged, deleted: status.deleted,
|
|
8164
|
+
});
|
|
8165
|
+
|
|
8166
|
+
const endpointLine = !endpoint
|
|
8167
|
+
? t("ext.endpoint.off")
|
|
8168
|
+
: (endpoint.listening
|
|
8169
|
+
? t("ext.endpoint.on", { url: endpoint.url })
|
|
8170
|
+
: (endpoint.error ? t("ext.endpoint.error", { error: endpoint.error }) : t("ext.endpoint.off")));
|
|
8171
|
+
|
|
8172
|
+
return h("div", { className: "smem-external smem-module-card" }, [
|
|
8173
|
+
h("div", { className: "smem-modcard-head", key: "head" }, [
|
|
8174
|
+
h(Switch, {
|
|
8175
|
+
key: "sw",
|
|
8176
|
+
on: enabled,
|
|
8177
|
+
label: t("ext.switch"),
|
|
8178
|
+
title: enabled ? t("ext.switch.onTitle") : t("ext.switch.offTitle"),
|
|
8179
|
+
disabled: busy || !memSet,
|
|
8180
|
+
onClick: toggleEnabled,
|
|
8181
|
+
}),
|
|
8182
|
+
h("span", { className: "smem-modcard-title", key: "t" }, t("ext.title")),
|
|
8183
|
+
h("span", { className: "smem-modcard-status", key: "s" }, statusText),
|
|
8184
|
+
]),
|
|
8185
|
+
|
|
8186
|
+
h("div", { className: "smem-autodream-sec", key: "what" }, [
|
|
8187
|
+
h("div", { className: "smem-autodream-note", key: "p1" }, t("ext.what1")),
|
|
8188
|
+
h("div", { className: "smem-autodream-note", key: "p2" }, t("ext.what2")),
|
|
8189
|
+
]),
|
|
8190
|
+
|
|
8191
|
+
// ── 白名单:按前缀整类 ──
|
|
8192
|
+
h("div", { className: "smem-autodream-sec", key: "prefix" }, [
|
|
8193
|
+
h("div", { className: "smem-autodream-key", key: "k" }, t("ext.prefixes")),
|
|
8194
|
+
h("div", { className: "smem-chips", key: "chips" }, PREFIX_CHOICES.map(function (p) {
|
|
8195
|
+
const on = prefixes.some(function (x) { return String(x).toLowerCase() === p.toLowerCase(); });
|
|
8196
|
+
return h(Chip, {
|
|
8197
|
+
key: p,
|
|
8198
|
+
label: p + "*",
|
|
8199
|
+
on: on,
|
|
8200
|
+
onClick: function () { if (!busy && memSet) togglePrefix(p); },
|
|
8201
|
+
});
|
|
8202
|
+
})),
|
|
8203
|
+
h("div", { className: "smem-autodream-note", key: "hint" }, t("ext.prefixesHint")),
|
|
8204
|
+
]),
|
|
8205
|
+
|
|
8206
|
+
// ── 白名单:按标签 ──
|
|
8207
|
+
h("div", { className: "smem-autodream-sec", key: "tags" }, [
|
|
8208
|
+
h("div", { className: "smem-autodream-row", key: "r" }, [
|
|
8209
|
+
h("span", { className: "smem-autodream-key", key: "k" }, t("ext.tags")),
|
|
8210
|
+
h("input", {
|
|
8211
|
+
className: "smem-input", key: "i", type: "text",
|
|
8212
|
+
value: tagDraft,
|
|
8213
|
+
disabled: busy || !memSet,
|
|
8214
|
+
placeholder: t("ext.tagsPlaceholder"),
|
|
8215
|
+
onChange: function (e) { setTagDraft(e.target.value); },
|
|
8216
|
+
}),
|
|
8217
|
+
h("button", {
|
|
8218
|
+
type: "button", className: "smem-btn smem-btn-primary", key: "save",
|
|
8219
|
+
disabled: busy || !memSet, onClick: saveTags,
|
|
8220
|
+
}, busy ? t("lab.action.saving") : t("lab.action.save")),
|
|
8221
|
+
]),
|
|
8222
|
+
h("div", { className: "smem-autodream-note", key: "hint" }, t("ext.tagsHint")),
|
|
8223
|
+
]),
|
|
8224
|
+
|
|
8225
|
+
// ── 逐条勾选 ──
|
|
8226
|
+
h("div", { className: "smem-autodream-sec", key: "files" }, [
|
|
8227
|
+
h("div", { className: "smem-autodream-key", key: "k" }, t("ext.files")),
|
|
8228
|
+
h("div", { className: "smem-autodream-note", key: "hint" }, t("ext.filesHint")),
|
|
8229
|
+
files.length === 0
|
|
8230
|
+
? h("div", { className: "smem-muted", key: "empty" }, t("ext.filesEmpty"))
|
|
8231
|
+
: h("div", { className: "smem-ext-list", key: "list" }, files.map(function (f) {
|
|
8232
|
+
const name = String(f && f.file ? f.file : "");
|
|
8233
|
+
const on = exposed.has(name);
|
|
8234
|
+
return h("label", { className: "smem-ext-row" + (on ? " smem-ext-row--on" : ""), key: name, title: String((f && f.description) || "") }, [
|
|
8235
|
+
h("input", {
|
|
8236
|
+
type: "checkbox", key: "c", checked: on,
|
|
8237
|
+
disabled: busy || !memSet,
|
|
8238
|
+
onChange: function () { toggleFile(name); },
|
|
8239
|
+
}),
|
|
8240
|
+
h("span", { className: "smem-ext-name", key: "n" }, name),
|
|
8241
|
+
h("span", { className: "smem-muted", key: "d" }, String((f && f.description) || "").slice(0, 60)),
|
|
8242
|
+
]);
|
|
8243
|
+
})),
|
|
8244
|
+
exposed.size > 0
|
|
8245
|
+
? h("div", { className: "smem-autodream-note", key: "count" }, t("ext.exposed", { count: exposed.size }))
|
|
8246
|
+
: null,
|
|
8247
|
+
]),
|
|
8248
|
+
|
|
8249
|
+
// ── 端点与最近一轮 ──
|
|
8250
|
+
h("div", { className: "smem-autodream-sec", key: "endpoint" }, [
|
|
8251
|
+
h("div", { className: "smem-autodream-row", key: "r" }, [
|
|
8252
|
+
h("span", { className: "smem-autodream-key", key: "k" }, t("ext.port")),
|
|
8253
|
+
h("input", {
|
|
8254
|
+
className: "smem-input smem-num", key: "i", type: "number", min: 1024, max: 65535, step: 1,
|
|
8255
|
+
value: portDraft,
|
|
8256
|
+
disabled: busy || !memSet,
|
|
8257
|
+
onChange: function (e) { setPortDraft(e.target.value); },
|
|
8258
|
+
}),
|
|
8259
|
+
h("button", {
|
|
8260
|
+
type: "button", className: "smem-btn smem-btn-primary", key: "save",
|
|
8261
|
+
disabled: busy || !memSet, onClick: savePort,
|
|
8262
|
+
}, busy ? t("lab.action.saving") : t("lab.action.save")),
|
|
8263
|
+
]),
|
|
8264
|
+
h("div", { className: "smem-autodream-note", key: "ep" }, t("ext.endpointLabel") + " " + endpointLine),
|
|
8265
|
+
h("div", { className: "smem-autodream-note", key: "last" }, lastLine),
|
|
8266
|
+
status && status.mirrorDir
|
|
8267
|
+
? h("div", { className: "smem-autodream-note", key: "dir" }, t("ext.dir", { dir: status.mirrorDir }))
|
|
8268
|
+
: null,
|
|
8269
|
+
status && Array.isArray(status.errors) && status.errors.length > 0
|
|
8270
|
+
? h("div", { className: "smem-err", key: "errs" }, "⚠ " + status.errors.join(" · "))
|
|
8271
|
+
: null,
|
|
8272
|
+
(memSet && Array.isArray(memSet.externalDiagnostics) && memSet.externalDiagnostics.length > 0)
|
|
8273
|
+
? h("div", { className: "smem-err", key: "diag" }, "⚠ " + memSet.externalDiagnostics.join(" · "))
|
|
8274
|
+
: null,
|
|
8275
|
+
]),
|
|
8276
|
+
|
|
8277
|
+
// ── 2.26.0 写侧:外部来件 ──
|
|
8278
|
+
h(ExternalIntakeCard, { key: "intake", ctx: props.ctx }),
|
|
8279
|
+
|
|
8280
|
+
err ? h("div", { className: "smem-err", key: "err" }, "⚠ " + err) : null,
|
|
8281
|
+
notice ? h("div", { className: "smem-ok", key: "ok" }, "✓ " + notice) : null,
|
|
8282
|
+
]);
|
|
8283
|
+
}
|
|
8284
|
+
|
|
8285
|
+
/**
|
|
8286
|
+
* 「外部来件」卡(2.26.0 写侧)—— 别的 agent 提交过来的东西,一条一条等人批。
|
|
8287
|
+
*
|
|
8288
|
+
* 三条不许变的产品规则:
|
|
8289
|
+
* 1. **先批后写**:插件不会自动把任何外来内容写进主库;`patch` 更是永远不自动写,
|
|
8290
|
+
* 只给一段「建议」,由人复制过去。
|
|
8291
|
+
* 2. **提案每次现算**(宿主侧算):主库随时会变,缓存一份提案等于让面板说旧话。
|
|
8292
|
+
* 3. **拒绝不删**:原件留在 `intake/agents/<来源>/rejected/`,理由进报告。
|
|
8293
|
+
*/
|
|
8294
|
+
function ExternalIntakeCard(props) {
|
|
8295
|
+
const remote = stableRemote(props.ctx, "remote.memory");
|
|
8296
|
+
const sOv = react.useState(null); const ov = sOv[0], setOv = sOv[1];
|
|
8297
|
+
const sBusy = react.useState(""); const busy = sBusy[0], setBusy = sBusy[1];
|
|
8298
|
+
const sErr = react.useState(null); const err = sErr[0], setErr = sErr[1];
|
|
8299
|
+
const sNotice = react.useState(""); const notice = sNotice[0], setNotice = sNotice[1];
|
|
8300
|
+
const sReports = react.useState(false); const reportsOpen = sReports[0], setReportsOpen = sReports[1];
|
|
8301
|
+
|
|
8302
|
+
function load() {
|
|
8303
|
+
if (!remote || typeof remote.externalSubmissions !== "function") {
|
|
8304
|
+
setErr(t("ext.intake.err.noRemote"));
|
|
8305
|
+
return;
|
|
8306
|
+
}
|
|
8307
|
+
Promise.resolve(remote.externalSubmissions()).then(function (res) {
|
|
8308
|
+
setOv(unwrap(res) || { pending: 0, items: [], scanError: "", reports: [] });
|
|
8309
|
+
}, function (e) { setErr(String((e && e.message) || e)); });
|
|
8310
|
+
}
|
|
8311
|
+
|
|
8312
|
+
react.useEffect(function () { load(); }, []);
|
|
8313
|
+
|
|
8314
|
+
/** 批准 / 拒绝一条。批准只对 `create` 有效,其余动作宿主会回原因。 */
|
|
8315
|
+
function act(kind, id) {
|
|
8316
|
+
const fn = kind === "approve" ? remote && remote.intakeApprove : remote && remote.intakeReject;
|
|
8317
|
+
if (typeof fn !== "function") { setErr(t("ext.intake.err.noRemote")); return; }
|
|
8318
|
+
setBusy(id); setErr(null); setNotice("");
|
|
8319
|
+
const args = kind === "approve" ? [id] : [id, t("ext.intake.rejectReason")];
|
|
8320
|
+
Promise.resolve(fn.apply(remote, args)).then(function (out) {
|
|
8321
|
+
setBusy("");
|
|
8322
|
+
const r = unwrap(out) || out || {};
|
|
8323
|
+
if (r.ok === false) { setErr(r.error || t("ext.intake.err.rejected")); load(); return; }
|
|
8324
|
+
setNotice(kind === "approve"
|
|
8325
|
+
? t("ext.intake.notice.approved", { file: r.targetFile || "" })
|
|
8326
|
+
: t("ext.intake.notice.rejected"));
|
|
8327
|
+
load();
|
|
8328
|
+
}, function (e) { setBusy(""); setErr(String((e && e.message) || e)); });
|
|
8329
|
+
}
|
|
8330
|
+
|
|
8331
|
+
/** patch 的「复制建议」:只复制「建议改成」那一段,不复制整份 patch。 */
|
|
8332
|
+
function copySuggestion(text) {
|
|
8333
|
+
const clip = typeof navigator !== "undefined" ? navigator.clipboard : null;
|
|
8334
|
+
if (!clip || typeof clip.writeText !== "function") { setErr(t("ext.intake.err.noClipboard")); return; }
|
|
8335
|
+
Promise.resolve(clip.writeText(String(text || ""))).then(function () {
|
|
8336
|
+
setNotice(t("ext.intake.notice.copied"));
|
|
8337
|
+
}, function () { setErr(t("ext.intake.err.noClipboard")); });
|
|
8338
|
+
}
|
|
8339
|
+
|
|
8340
|
+
const items = (ov && ov.items) || [];
|
|
8341
|
+
const reports = (ov && ov.reports) || [];
|
|
8342
|
+
const ACTION_LABEL = {
|
|
8343
|
+
create: t("ext.intake.action.create"),
|
|
8344
|
+
conflict: t("ext.intake.action.conflict"),
|
|
8345
|
+
manual: t("ext.intake.action.manual"),
|
|
8346
|
+
reject: t("ext.intake.action.reject"),
|
|
8347
|
+
};
|
|
8348
|
+
|
|
8349
|
+
return h("div", { className: "smem-intake smem-module-card" }, [
|
|
8350
|
+
h("div", { className: "smem-modcard-head", key: "head" }, [
|
|
8351
|
+
h("span", { className: "smem-modcard-title", key: "t" }, t("ext.intake.title")),
|
|
8352
|
+
h("span", { className: "smem-modcard-status", key: "s" }, t("ext.intake.pending", { count: items.length })),
|
|
8353
|
+
]),
|
|
8354
|
+
|
|
8355
|
+
h("div", { className: "smem-autodream-sec", key: "what" }, [
|
|
8356
|
+
h("div", { className: "smem-autodream-note", key: "p1" }, t("ext.intake.what1")),
|
|
8357
|
+
h("div", { className: "smem-autodream-note", key: "p2" }, t("ext.intake.what2")),
|
|
8358
|
+
]),
|
|
8359
|
+
|
|
8360
|
+
ov && ov.scanError ? h("div", { className: "smem-err", key: "scan" }, "⚠ " + ov.scanError) : null,
|
|
8361
|
+
|
|
8362
|
+
items.length === 0
|
|
8363
|
+
? h("div", { className: "smem-muted", key: "empty" }, t("ext.intake.empty"))
|
|
8364
|
+
: h("div", { className: "smem-intake-list", key: "list" }, items.map(function (it) {
|
|
8365
|
+
const disabled = busy === it.id;
|
|
8366
|
+
const buttons = [];
|
|
8367
|
+
if (it.action === "create") {
|
|
8368
|
+
buttons.push(h("button", {
|
|
8369
|
+
type: "button", className: "smem-btn smem-btn-primary", key: "ok",
|
|
8370
|
+
disabled: disabled || !!ov.scanError,
|
|
8371
|
+
onClick: function () { act("approve", it.id); },
|
|
8372
|
+
}, t("ext.intake.approve")));
|
|
8373
|
+
}
|
|
8374
|
+
if (it.action === "manual" && it.suggestion) {
|
|
8375
|
+
buttons.push(h("button", {
|
|
8376
|
+
type: "button", className: "smem-btn", key: "copy",
|
|
8377
|
+
disabled: disabled,
|
|
8378
|
+
onClick: function () { copySuggestion(it.suggestion); },
|
|
8379
|
+
}, t("ext.intake.copySuggestion")));
|
|
8380
|
+
}
|
|
8381
|
+
buttons.push(h("button", {
|
|
8382
|
+
type: "button", className: "smem-btn", key: "no",
|
|
8383
|
+
disabled: disabled,
|
|
8384
|
+
onClick: function () { act("reject", it.id); },
|
|
8385
|
+
}, t("ext.intake.reject")));
|
|
8386
|
+
|
|
8387
|
+
return h("div", { className: "smem-intake-row", key: it.id }, [
|
|
8388
|
+
h("div", { className: "smem-intake-line", key: "l" }, [
|
|
8389
|
+
h("span", { className: "smem-intake-src", key: "src" }, it.source || "?"),
|
|
8390
|
+
h("span", { className: "smem-muted", key: "kind" }, it.kind === "patch" ? t("ext.intake.kind.patch") : t("ext.intake.kind.new")),
|
|
8391
|
+
h("span", { className: "smem-intake-name", key: "n" }, it.targetFile || it.name || ""),
|
|
8392
|
+
h("span", { className: "smem-intake-badge smem-intake-badge--" + String(it.action || ""), key: "a" }, ACTION_LABEL[it.action] || String(it.action || "")),
|
|
8393
|
+
]),
|
|
8394
|
+
h("div", { className: "smem-intake-why", key: "w" }, it.reason || ""),
|
|
8395
|
+
it.excerpt ? h("div", { className: "smem-intake-excerpt", key: "e" }, it.excerpt) : null,
|
|
8396
|
+
h("div", { className: "smem-intake-actions", key: "b" }, buttons),
|
|
8397
|
+
]);
|
|
8398
|
+
})),
|
|
8399
|
+
|
|
8400
|
+
reports.length > 0
|
|
8401
|
+
? h("div", { className: "smem-autodream-sec", key: "reports" }, [
|
|
8402
|
+
h("button", {
|
|
8403
|
+
type: "button", className: "smem-btn", key: "toggle",
|
|
8404
|
+
onClick: function () { setReportsOpen(!reportsOpen); },
|
|
8405
|
+
}, reportsOpen ? t("ext.intake.reports.hide") : t("ext.intake.reports.show", { count: reports.length })),
|
|
8406
|
+
reportsOpen
|
|
8407
|
+
? h("div", { className: "smem-intake-reports", key: "list" }, reports.map(function (r) {
|
|
8408
|
+
return h("pre", { className: "smem-intake-report", key: r.name }, r.text);
|
|
8409
|
+
}))
|
|
8410
|
+
: null,
|
|
8411
|
+
])
|
|
8412
|
+
: null,
|
|
8413
|
+
|
|
8414
|
+
err ? h("div", { className: "smem-err", key: "err" }, "⚠ " + err) : null,
|
|
8415
|
+
notice ? h("div", { className: "smem-ok", key: "ok" }, "✓ " + notice) : null,
|
|
8416
|
+
]);
|
|
8417
|
+
}
|
|
7825
8418
|
// ── 文件列表这一屏(1.5.3 从 Section 里抽出;D23 计划的 72 片)──────────
|
|
7826
8419
|
// 只负责「按状态/筛选把卡片摆出来 + 四种空态」;状态、筛选语义、动作回调全部由 Section 传。
|
|
7827
8420
|
// 抽出的判据:它是 Section 里最大的一块纯渲染,而卡片组件(Card / ArchivedCard)本来就在 50 共享层。
|
|
@@ -9243,6 +9836,9 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
9243
9836
|
// 2.9.0:实验性设置单开一页(只放会改变**选材**的开关;见 64-lab-settings.js 开头)。
|
|
9244
9837
|
// 排在库健康之后:先看「库有没有事」,再决定「要不要动实验性开关」。
|
|
9245
9838
|
h("button", { type: "button", className: "smem-tab" + (tab === "lab" ? " smem-tab--on" : ""), key: "l", role: "tab", "aria-selected": tab === "lab" ? "true" : "false", onClick: function () { setTab("lab"); } }, t("tab.lab")),
|
|
9839
|
+
// 2.25.0:外部访问(读侧)—— 控制「谁能看见我的记忆」,与选材 / 预算都不是一回事,
|
|
9840
|
+
// 所以单开一页而不是塞进实验性(见 68-external-settings.js 开头)。
|
|
9841
|
+
h("button", { type: "button", className: "smem-tab" + (tab === "ext" ? " smem-tab--on" : ""), key: "x", role: "tab", "aria-selected": tab === "ext" ? "true" : "false", onClick: function () { setTab("ext"); } }, t("tab.external")),
|
|
9246
9842
|
]),
|
|
9247
9843
|
// 四个 tab 共用的一条头部带:我在哪 · 目录状态 · 活动/归档计数 · 体检徽标 · 待重启徽标 · 主操作。
|
|
9248
9844
|
// 层级形状固定:导航=下划线(.smem-tabs)、筛选=chip、动作=按钮,三种不混用。
|
|
@@ -9521,6 +10117,9 @@ h("span", { key: "sep", className: "smem-actions-sep", "aria-hidden": "true" }),
|
|
|
9521
10117
|
])
|
|
9522
10118
|
: tab === "lab"
|
|
9523
10119
|
? h("div", { className: "smem-stack smem-view", key: "lab" }, [guideCard, h(LabSettingsPanel, { key: "lab-card", ctx: props.ctx })])
|
|
10120
|
+
: tab === "ext"
|
|
10121
|
+
// 2.25.0 外部访问(读侧):白名单 + 逐条勾选 + 只读端点状态。
|
|
10122
|
+
? h("div", { className: "smem-stack smem-view", key: "ext" }, [h(ExternalAccessPanel, { key: "ext-card", ctx: props.ctx })])
|
|
9524
10123
|
: h("div", { className: "smem-view", key: "files" }, filesView),
|
|
9525
10124
|
// 2.8.0:第三方注入的视图(`settings.memory.starmap` 子槽)。没有占用者时是 null,
|
|
9526
10125
|
// 一个 div 都不出 —— 所以默认安装下界面与 2.7.0 逐像素相同。
|