@frogmoo/dsh-supermemory 0.0.0-stage → 1.4.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/CHANGELOG.md +442 -0
- package/INSTALL.md +193 -0
- package/LICENSE +21 -0
- package/README.md +220 -2
- package/cordis.patch.yml +9 -0
- package/lib/capability-T5x_17iK.js +2971 -0
- package/lib/client.js +4217 -0
- package/lib/clip-kqqR05NC.js +279 -0
- package/lib/export-XY8Bfglx.js +144 -0
- package/lib/filemap-CsF4oYtT.js +166 -0
- package/lib/group-CkFv7052.js +313 -0
- package/lib/hub-sessions-pzURuUmH.js +1010 -0
- package/lib/memory-collections-DaSVGbrR.js +686 -0
- package/lib/model-Z4_-9sAj.js +735 -0
- package/lib/rolldown-runtime-BJohB4LM.js +13 -0
- package/lib/skill-forge-DHxPo_w6.js +2348 -0
- package/lib/store-DD2L3GDr.js +531 -0
- package/lib/supermemory.js +15015 -0
- package/lib/toolize-B9Mbl7sp.js +426 -0
- package/package.json +67 -4
package/lib/client.js
ADDED
|
@@ -0,0 +1,4217 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({id:"@frogmoo/dsh-supermemory",factory:require=>{var module={exports:{}};var exports=module.exports;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
let react = require("react");
|
|
4
|
+
// src/client/remote.ts
|
|
5
|
+
/**
|
|
6
|
+
* Client half of the SuperMemory panel wire contract. Mirrors the host-side
|
|
7
|
+
* PANEL_DESCRIPTORS in src/panel.ts (registered through
|
|
8
|
+
* ctx.get('typert').register with face 'host'); mounted here so the browser can call the
|
|
9
|
+
* panel service. The id set must stay identical on both halves —
|
|
10
|
+
* scripts/mechanism-smoke.mjs asserts that parity.
|
|
11
|
+
* Shape follows the dsh-ops runtime-host pattern ({package, descriptors}).
|
|
12
|
+
* @module supermemory/client/remote
|
|
13
|
+
*/
|
|
14
|
+
/** Passthrough codec: values are plain JSON produced by the host service. */
|
|
15
|
+
const jsonCodec = (symbol) => ({
|
|
16
|
+
mode: "strict",
|
|
17
|
+
typeSymbol: `dsh-supermemory#${symbol}`,
|
|
18
|
+
create: () => ({ parse: (value) => value })
|
|
19
|
+
});
|
|
20
|
+
const param = (name, optional = false) => ({
|
|
21
|
+
name,
|
|
22
|
+
wire: name,
|
|
23
|
+
source: "json",
|
|
24
|
+
...optional ? { acceptsUndefined: true } : {},
|
|
25
|
+
codec: jsonCodec(name)
|
|
26
|
+
});
|
|
27
|
+
const method = (name, parameters = []) => ({
|
|
28
|
+
id: `dsh-supermemory#supermemoryPanel/${name}`,
|
|
29
|
+
service: "supermemoryPanel",
|
|
30
|
+
namespace: "supermemoryPanel",
|
|
31
|
+
method: name,
|
|
32
|
+
invocation: { kind: "direct" },
|
|
33
|
+
result: jsonCodec(`${name}:result`),
|
|
34
|
+
parameters
|
|
35
|
+
});
|
|
36
|
+
/** The mountable contribution for `ctx.remote.$mount`. */
|
|
37
|
+
const PANEL_REMOTE = Object.freeze({
|
|
38
|
+
package: "dsh-supermemory",
|
|
39
|
+
descriptors: Object.freeze([
|
|
40
|
+
method("listTopicSets", [param("cwd")]),
|
|
41
|
+
method("activate", [param("sessionId"), param("topicSetId")]),
|
|
42
|
+
method("activeTopicSet", [param("sessionId")]),
|
|
43
|
+
method("hubState", [param("cwd"), param("sessionId")]),
|
|
44
|
+
method("listMemories", [
|
|
45
|
+
param("cwd"),
|
|
46
|
+
param("query", true),
|
|
47
|
+
param("limit", true)
|
|
48
|
+
]),
|
|
49
|
+
method("createMemory", [
|
|
50
|
+
param("cwd"),
|
|
51
|
+
param("text"),
|
|
52
|
+
param("key", true),
|
|
53
|
+
param("title", true),
|
|
54
|
+
param("tags", true)
|
|
55
|
+
]),
|
|
56
|
+
method("updateMemory", [
|
|
57
|
+
param("cwd"),
|
|
58
|
+
param("id"),
|
|
59
|
+
param("text"),
|
|
60
|
+
param("key", true),
|
|
61
|
+
param("title", true),
|
|
62
|
+
param("tags", true)
|
|
63
|
+
]),
|
|
64
|
+
method("deleteMemory", [param("cwd"), param("id")]),
|
|
65
|
+
method("setMemoryStatus", [
|
|
66
|
+
param("cwd"),
|
|
67
|
+
param("id"),
|
|
68
|
+
param("status")
|
|
69
|
+
]),
|
|
70
|
+
method("listMemoryCollections", [param("cwd")]),
|
|
71
|
+
method("listMemoriesByCollection", [
|
|
72
|
+
param("cwd"),
|
|
73
|
+
param("collectionId"),
|
|
74
|
+
param("query", true),
|
|
75
|
+
param("limit", true)
|
|
76
|
+
]),
|
|
77
|
+
method("getMemoryDetail", [param("cwd"), param("id")]),
|
|
78
|
+
method("getHubPolicy", [param("cwd")]),
|
|
79
|
+
method("setHubPolicy", [param("cwd"), param("patch")]),
|
|
80
|
+
method("cleanupStaleHubPolicy", [param("cwd")]),
|
|
81
|
+
method("getModelDefaults", [param("cwd")]),
|
|
82
|
+
method("setModelDefaults", [param("cwd"), param("patch")]),
|
|
83
|
+
method("listSkills", [param("cwd")]),
|
|
84
|
+
method("updateSkill", [
|
|
85
|
+
param("cwd"),
|
|
86
|
+
param("name"),
|
|
87
|
+
param("patch")
|
|
88
|
+
]),
|
|
89
|
+
method("createTopicSet", [
|
|
90
|
+
param("cwd"),
|
|
91
|
+
param("title"),
|
|
92
|
+
param("tags", true),
|
|
93
|
+
param("summary", true)
|
|
94
|
+
]),
|
|
95
|
+
method("suggestMemoryShape", [param("text")]),
|
|
96
|
+
method("listHubSessions", [param("cwd")]),
|
|
97
|
+
method("listHubBranches", [
|
|
98
|
+
param("cwd"),
|
|
99
|
+
param("hubSessionId"),
|
|
100
|
+
param("limit", true)
|
|
101
|
+
]),
|
|
102
|
+
method("listAllTopicSets", [param("cwd")]),
|
|
103
|
+
method("listAllBranches", [
|
|
104
|
+
param("cwd"),
|
|
105
|
+
param("topicSetId", true),
|
|
106
|
+
param("limit", true)
|
|
107
|
+
]),
|
|
108
|
+
method("readSessionMessages", [param("sessionId"), param("limit", true)]),
|
|
109
|
+
method("sendSessionMessage", [param("sessionId"), param("text")]),
|
|
110
|
+
method("updateTopicSetSummary", [
|
|
111
|
+
param("id"),
|
|
112
|
+
param("summary"),
|
|
113
|
+
param("tags", true)
|
|
114
|
+
]),
|
|
115
|
+
method("createTopicSetSession", [
|
|
116
|
+
param("cwd"),
|
|
117
|
+
param("topicSetIds"),
|
|
118
|
+
param("options", true),
|
|
119
|
+
param("firstMessage", true)
|
|
120
|
+
]),
|
|
121
|
+
method("createHubSession", [
|
|
122
|
+
param("cwd"),
|
|
123
|
+
param("options", true),
|
|
124
|
+
param("firstMessage", true)
|
|
125
|
+
]),
|
|
126
|
+
method("listAgentPresets", []),
|
|
127
|
+
method("listModelCatalog", []),
|
|
128
|
+
method("listPermissions", []),
|
|
129
|
+
method("followupTopicSet", [
|
|
130
|
+
param("cwd"),
|
|
131
|
+
param("topicSetId"),
|
|
132
|
+
param("text")
|
|
133
|
+
]),
|
|
134
|
+
method("listTools", [param("cwd", true)]),
|
|
135
|
+
method("editTool", [param("id"), param("patch")]),
|
|
136
|
+
method("deleteTool", [param("id")]),
|
|
137
|
+
method("runTool", [param("id"), param("options", true)]),
|
|
138
|
+
method("acceptProposal", [param("cwd"), param("id")]),
|
|
139
|
+
method("declineProposal", [param("cwd"), param("id")]),
|
|
140
|
+
method("sessionBadge", [param("sessionId")])
|
|
141
|
+
])
|
|
142
|
+
});
|
|
143
|
+
// src/client/locales.ts
|
|
144
|
+
/** SuperMemory panel dictionaries (namespace `supermemory`). */
|
|
145
|
+
const NS = "supermemory";
|
|
146
|
+
const zh = {
|
|
147
|
+
"panel": "超级记忆",
|
|
148
|
+
"panel.title": "超级记忆",
|
|
149
|
+
"tab.hub": "中枢会话",
|
|
150
|
+
"tab.sets": "话题集",
|
|
151
|
+
"tab.memories": "记忆",
|
|
152
|
+
"tab.branches": "分支会话",
|
|
153
|
+
"tab.settings": "设置",
|
|
154
|
+
"tab.tools": "固化能力",
|
|
155
|
+
"settings.policy.title": "中枢权限(白名单,默认拒绝)",
|
|
156
|
+
"settings.models.title": "默认模型",
|
|
157
|
+
"settings.models.hint": "只影响新建会话:中枢默认用于新建中枢会话;分支默认用于新派发分支(话题集/分支级覆盖仍优先)。",
|
|
158
|
+
"settings.models.hub": "中枢会话模型",
|
|
159
|
+
"settings.models.branch": "分支会话模型",
|
|
160
|
+
"settings.models.follow": "跟随默认(宿主链路)",
|
|
161
|
+
"settings.models.save": "保存默认模型",
|
|
162
|
+
"settings.models.reset": "恢复默认设置",
|
|
163
|
+
"settings.models.precedence": "优先级:分支级覆盖 > 话题集默认 > 分支会话默认 > 中枢当前模型 > 宿主默认;新建中枢:显式选择 > 中枢默认 > 宿主默认。",
|
|
164
|
+
"settings.skills.title": "已生成的 skills",
|
|
165
|
+
"settings.skills.hint": "能力知识面写在 <仓库>/.dsh/capabilities/<name>.md(不在宿主 skill 根,不进 available_skills);中枢/分支会话只注入精简索引,正文由 sm_cap_doc 按需读取。可改路由描述或停用;同名更新会升版并保留 changelog,人工编辑的正文不会被覆盖。",
|
|
166
|
+
"settings.skills.empty": "还没有生成的 skill:重复流程达到阈值后自动生成,或用 memory_toolize register 手工登记。",
|
|
167
|
+
"settings.skills.uses": "加载 {count} 次",
|
|
168
|
+
"settings.skills.save": "保存描述",
|
|
169
|
+
"settings.skills.enable": "启用",
|
|
170
|
+
"settings.skills.disable": "停用",
|
|
171
|
+
"settings.skills.disabled": "已停用",
|
|
172
|
+
"sets.search": "按标题或标签搜索话题集…",
|
|
173
|
+
"sets.clear": "清空",
|
|
174
|
+
"sets.stats": "显示 {shown} / {total} 个话题集",
|
|
175
|
+
"sets.empty": "(没有匹配的话题集)",
|
|
176
|
+
"sets.empty.hint": "新建话题集后,把同类会话与它们的记忆收在一起。",
|
|
177
|
+
"sets.created": "已创建",
|
|
178
|
+
"sets.sessions": "{count} 个会话",
|
|
179
|
+
"sets.live": "{count} 个在线",
|
|
180
|
+
"sets.open": "进入",
|
|
181
|
+
"sets.noBody": "(暂无正文/梗概)",
|
|
182
|
+
"sets.archived": "已归档",
|
|
183
|
+
"hub.current": "当前会话",
|
|
184
|
+
"hub.active": "活跃话题集",
|
|
185
|
+
"hub.none": "(未激活)",
|
|
186
|
+
"hub.activate": "激活",
|
|
187
|
+
"hub.topicSets": "话题集",
|
|
188
|
+
"hub.empty": "当前工作区还没有话题集。",
|
|
189
|
+
"hub.empty.hint": "在中枢会话里派发第一个任务后,这里会出现对应的话题集。",
|
|
190
|
+
"side.title": "中枢会话(发现视图)",
|
|
191
|
+
"side.authority": "发现视图:按会话形状列出可打开的顶层会话,不代表角色权限;会话角色由插件正证据判定(hub 记录 / 话题集 root / 派发记录)。",
|
|
192
|
+
"side.count": "{count} 个",
|
|
193
|
+
"side.empty": "还没有中枢会话",
|
|
194
|
+
"side.empty.hint": "判断与汇总留在这里,读写与命令交给分支。",
|
|
195
|
+
"side.new": "+ 新中枢会话",
|
|
196
|
+
"side.running": "运行中",
|
|
197
|
+
"side.current": "当前",
|
|
198
|
+
"side.branches": "{count} 个关联分支({working} 个工作中)",
|
|
199
|
+
"branches.title": "关联分支",
|
|
200
|
+
"branches.empty": "本会话还没有拉起分支。",
|
|
201
|
+
"branches.empty.hint": "派发任务后,这里会显示它拉起的每个分支:名称、状态、所属话题集与共享它的中枢数。",
|
|
202
|
+
"branches.working": "工作中",
|
|
203
|
+
"branches.idle": "空闲",
|
|
204
|
+
"branches.failed": "失败待处理",
|
|
205
|
+
"branches.shared": "与 {count} 个中枢共享",
|
|
206
|
+
"branches.set": "话题集「{title}」",
|
|
207
|
+
"branches.ownSet": "所属话题集",
|
|
208
|
+
"branches.noSet": "无话题集",
|
|
209
|
+
"branches.dispatches": "{count} 次派发",
|
|
210
|
+
"branches.group": "并行组",
|
|
211
|
+
"branches.ago.just": "刚刚",
|
|
212
|
+
"branches.ago.min": "{count} 分钟前",
|
|
213
|
+
"branches.ago.hour": "{count} 小时前",
|
|
214
|
+
"branches.ago.day": "{count} 天前",
|
|
215
|
+
"branches.search": "搜索标题 / 标签 / 分支 id / 话题集…",
|
|
216
|
+
"branches.stats": "显示 {shown} / {total} 个分支会话",
|
|
217
|
+
"hub.counts": "记忆 {memories} · 需求 {requirements} · 梗概 {episodes} · 进行中派发 {dispatches}",
|
|
218
|
+
"hub.refresh": "刷新",
|
|
219
|
+
"hub.openSession": "打开会话",
|
|
220
|
+
"hub.allBranches": "全部分支会话",
|
|
221
|
+
"hub.allBranches.filter": "按话题集筛选",
|
|
222
|
+
"hub.allBranches.allSets": "全部话题集",
|
|
223
|
+
"hub.allBranches.empty": "(没有分支会话)",
|
|
224
|
+
"hub.allBranches.hint": "派发任务后,这里会列出跨话题集的全部分支:标题、标签、状态与最后活动。",
|
|
225
|
+
"topic.members": "分支会话",
|
|
226
|
+
"topic.noMembers": "(暂无分支会话)",
|
|
227
|
+
"topic.reply": "回复到话题集",
|
|
228
|
+
"topic.reply.placeholder": "输入要送入话题集分支的内容…",
|
|
229
|
+
"topic.reply.send": "发送",
|
|
230
|
+
"topic.summary": "梗概",
|
|
231
|
+
"topic.summary.save": "保存梗概",
|
|
232
|
+
"topic.create": "新建话题集",
|
|
233
|
+
"topic.create.placeholder": "新话题集标题",
|
|
234
|
+
"topic.back": "返回话题集页签",
|
|
235
|
+
"memory.search": "按标题、标签或正文搜索…",
|
|
236
|
+
"memory.title": "标题",
|
|
237
|
+
"memory.tags": "标签",
|
|
238
|
+
"memory.body": "正文",
|
|
239
|
+
"memory.empty": "(没有匹配的记忆)",
|
|
240
|
+
"memory.empty.hint": "记忆由中枢/分支在会话中写入(memory_remember),这里只浏览与管理。",
|
|
241
|
+
"memory.locate": "定位会话",
|
|
242
|
+
"memory.edit": "编辑",
|
|
243
|
+
"memory.save": "保存",
|
|
244
|
+
"memory.cancel": "取消",
|
|
245
|
+
"memory.delete": "删除",
|
|
246
|
+
"memory.deleteConfirm": "确认删除",
|
|
247
|
+
"memory.disable": "停用",
|
|
248
|
+
"memory.enable": "启用",
|
|
249
|
+
"memory.status": "状态",
|
|
250
|
+
"memory.source": "来源会话",
|
|
251
|
+
"memory.group.ungrouped": "未归集",
|
|
252
|
+
"memory.group.count": "{count} 条",
|
|
253
|
+
"memory.collection.search": "按标题或标签搜索记忆集合…",
|
|
254
|
+
"memory.collection.open": "打开这个记忆集合的条目",
|
|
255
|
+
"memory.collection.empty": "(没有匹配的记忆集合)",
|
|
256
|
+
"memory.collection.empty.hint": "写入一条记忆后,这里会出现它的记忆集合卡片;点卡片看里面的条目。",
|
|
257
|
+
"memory.detail.open": "打开这条记忆的详情与历史版本",
|
|
258
|
+
"memory.back": "返回",
|
|
259
|
+
"memory.updated": "更新",
|
|
260
|
+
"memory.history": "历史版本",
|
|
261
|
+
"memory.history.none": "(这条记忆还没有历史版本行)",
|
|
262
|
+
"memory.history.toggle": "展开/收起这个版本的完整内容",
|
|
263
|
+
"memory.history.create": "新建",
|
|
264
|
+
"memory.history.update": "更新",
|
|
265
|
+
"memory.history.migrate": "迁移",
|
|
266
|
+
"tool.empty": "(暂无能力;重复任务出现 3 次会先产生待接受的知识提案)",
|
|
267
|
+
"tool.empty.hint": "单一能力 = 知识面 .dsh/capabilities/<name>.md(何时用/怎么判断/关键坑)+ 执行面 sm_cap_*(固定入口,默认预演,写操作需确认)。正文用 sm_cap_doc 按需读取,不进 available_skills;自动提案只产知识,接受后才占每根 8 个上限。",
|
|
268
|
+
"tool.steps": "步骤",
|
|
269
|
+
"tool.params": "参数",
|
|
270
|
+
"tool.uses": "使用次数",
|
|
271
|
+
"tool.runCount": "执行次数",
|
|
272
|
+
"tool.loadCount": "加载次数",
|
|
273
|
+
"tool.conversion": "加载→执行转化率",
|
|
274
|
+
"tool.successRate": "成功率",
|
|
275
|
+
"tool.preview": "预演执行",
|
|
276
|
+
"tool.enableRun": "启用执行",
|
|
277
|
+
"tool.accept": "接受提案",
|
|
278
|
+
"tool.decline": "拒绝提案",
|
|
279
|
+
"tool.badge.auto": "自动",
|
|
280
|
+
"tool.badge.draft": "入口待验证",
|
|
281
|
+
"tool.live": "已注册",
|
|
282
|
+
"tool.offline": "未注册",
|
|
283
|
+
"tool.retire": "停用",
|
|
284
|
+
"tool.enable": "启用",
|
|
285
|
+
"tool.delete": "删除",
|
|
286
|
+
"tool.deleteConfirm": "确认删除",
|
|
287
|
+
"tool.desc.save": "保存",
|
|
288
|
+
"tool.desc.edit": "编辑标题/标签/简介",
|
|
289
|
+
"tool.body.label": "知识面正文(事实块自动维护,块外散文可编辑)",
|
|
290
|
+
"tool.body.placeholder": "Markdown 正文:何时用 / 决策 / 步骤 / 关键坑 / 验证 / 反例",
|
|
291
|
+
"tool.body.save": "保存正文",
|
|
292
|
+
"tool.kind.capability": "可执行能力",
|
|
293
|
+
"tool.kind.knowledge": "仅知识",
|
|
294
|
+
"tool.kind.proposal": "提案",
|
|
295
|
+
"tool.kind.sequence": "历史序列(已退役)",
|
|
296
|
+
"tool.detail.entryDraft": "入口草稿",
|
|
297
|
+
"tool.detail.unverified": "(未验证:人工启用后才执行)",
|
|
298
|
+
"tool.detail.skill": "知识面文件",
|
|
299
|
+
"tool.detail.expires": "提案过期时间",
|
|
300
|
+
"tool.detail.toggle": "点击展开/收起能力详情",
|
|
301
|
+
"tool.detail.kind": "类型",
|
|
302
|
+
"tool.detail.version": "版本",
|
|
303
|
+
"tool.detail.builtin": "内置 v{version}",
|
|
304
|
+
"tool.detail.created": "增加时间",
|
|
305
|
+
"tool.detail.lastUsed": "最后使用",
|
|
306
|
+
"tool.detail.entry": "入口命令",
|
|
307
|
+
"tool.detail.doc": "文档",
|
|
308
|
+
"tool.detail.scope": "适用范围",
|
|
309
|
+
"tool.detail.route": "路由描述",
|
|
310
|
+
"tool.detail.run": "执行方式",
|
|
311
|
+
"tool.detail.noRun": "仅作路由/文档存在,不执行",
|
|
312
|
+
"tool.detail.dryRun": "默认预演",
|
|
313
|
+
"tool.detail.realRun": "直接执行",
|
|
314
|
+
"tool.detail.confirm": "真实执行需 confirm",
|
|
315
|
+
"tool.detail.stats": "使用统计",
|
|
316
|
+
"tool.detail.success": "成功",
|
|
317
|
+
"tool.detail.fail": "失败",
|
|
318
|
+
"tool.detail.streak": "连续失败",
|
|
319
|
+
"tool.detail.last": "最近一次",
|
|
320
|
+
"tool.detail.ok": "成功",
|
|
321
|
+
"tool.detail.failed": "失败",
|
|
322
|
+
"tool.detail.preview": "预演",
|
|
323
|
+
"tool.detail.lastSummary": "最近结果",
|
|
324
|
+
"tool.detail.health": "健康信号",
|
|
325
|
+
"tool.detail.missing": "(缺失)",
|
|
326
|
+
"launch.title": "快速新建会话",
|
|
327
|
+
"launch.workspace": "工作区",
|
|
328
|
+
"launch.preset": "Agent 模式",
|
|
329
|
+
"launch.model": "模型",
|
|
330
|
+
"launch.permission": "权限",
|
|
331
|
+
"launch.default": "跟随默认",
|
|
332
|
+
"launch.defaultMark": "默认",
|
|
333
|
+
"launch.sets": "话题集(可多选)",
|
|
334
|
+
"launch.start": "创建中枢会话",
|
|
335
|
+
"launch.startSets": "创建话题集会话",
|
|
336
|
+
"launch.hint": "不选话题集即创建普通中枢会话;选中后创建绑定这些话题集的新会话。",
|
|
337
|
+
"launch.needWorkspace": "请先选择工作区。",
|
|
338
|
+
"composer.title": "中枢会话",
|
|
339
|
+
"composer.desc": "说清要中枢做什么;会话在后台新建并立刻送达,不跳页。",
|
|
340
|
+
"composer.placeholder": "例如:整理这个仓库的记忆,并派发一个分支去补测试…",
|
|
341
|
+
"composer.start": "开始对话",
|
|
342
|
+
"composer.createOnly": "仅创建会话",
|
|
343
|
+
"composer.createOnly.hint": "只建会话,先不发消息",
|
|
344
|
+
"composer.hint": "Ctrl/Cmd + Enter 发送",
|
|
345
|
+
"composer.newSet": "+新话题集",
|
|
346
|
+
"composer.setsEmpty": "当前工作区还没有话题集",
|
|
347
|
+
"composer.open": "打开会话",
|
|
348
|
+
"composer.dismiss": "收起",
|
|
349
|
+
"composer.receipt.hub": "中枢会话",
|
|
350
|
+
"composer.receipt.sets": "话题集会话",
|
|
351
|
+
"newSession.create": "新建话题集…",
|
|
352
|
+
"workspace.label": "工作区",
|
|
353
|
+
"side.set": "话题集",
|
|
354
|
+
"topic.root": "中枢",
|
|
355
|
+
"topic.branch": "分支",
|
|
356
|
+
"chat.live": "运行中",
|
|
357
|
+
"chat.cold": "未运行",
|
|
358
|
+
"chat.empty": "(还没有可显示的消息)",
|
|
359
|
+
"chat.empty.hint": "在下方输入并发送,消息会直接进入该会话;回复会自动刷新。",
|
|
360
|
+
"chat.placeholder": "输入消息,直接送入该会话…",
|
|
361
|
+
"chat.send": "发送",
|
|
362
|
+
"chat.refresh": "刷新",
|
|
363
|
+
"chat.open": "在 DSH 打开",
|
|
364
|
+
"chat.truncated": "仅显示最近消息",
|
|
365
|
+
"chat.hint": "Ctrl/Cmd + Enter 发送;面板会轮询该会话的新回复。",
|
|
366
|
+
"chat.you": "你",
|
|
367
|
+
"chat.assistant": "助手",
|
|
368
|
+
"chat.tool": "工具",
|
|
369
|
+
"memory.modal.title": "编辑记忆",
|
|
370
|
+
"memory.modal.hint": "只写结论性、可复用的事实/决策;过程步骤留在会话里。标题与标签用于检索。",
|
|
371
|
+
"hubPolicy.model": "白名单 {count} 项 · 默认拒绝白名单以外的工具",
|
|
372
|
+
"hubPolicy.hint": "中枢会话只能调用白名单内的工具;不在名单内的一律拒绝,未来新增的未知工具同样默认拒绝。目录每次打开/刷新都从运行时重新生成,保存后下一个工具调用即生效。固化能力执行面 sm_cap_* 在中枢被结构性拒绝(HUB_CAPABILITY_EXEC_DENIED),只能派发到分支执行;sm_cap_doc 只读。",
|
|
373
|
+
"hubPolicy.source.stored": "工作区自定义",
|
|
374
|
+
"hubPolicy.source.default": "内置默认",
|
|
375
|
+
"hubPolicy.reset": "恢复默认",
|
|
376
|
+
"hubPolicy.save": "保存",
|
|
377
|
+
"hubPolicy.loading": "(正在读取白名单…)",
|
|
378
|
+
"hubPolicy.loading.hint": "读取失败时会回退内置默认白名单,派发链路不受影响。",
|
|
379
|
+
"hubPolicy.locked": "锁定",
|
|
380
|
+
"hubPolicy.locked.tip": "核心锁定项:派发/收线/提问/运行码传输,以及 R55 的只读能力知识面(sm_cap_doc)。取消会导致中枢无法派发或无法判断能力是否适用,因此不可关闭。",
|
|
381
|
+
"hubPolicy.risk": "实操",
|
|
382
|
+
"hubPolicy.risk.tip": "实操执行类工具:中枢本该派发给分支执行,勾选即允许中枢亲自执行。",
|
|
383
|
+
"hubPolicy.note.pluginManager": "关掉后中枢也不能重载插件(需在宿主插件页操作)。",
|
|
384
|
+
"hubPolicy.note.capabilityDoc": "只读路由,锁定",
|
|
385
|
+
"hubPolicy.note.capabilityDoc.tip": "固化能力的知识面:中枢只读检查(判断是否适用),执行必须派发到分支;该项默认允许且不可在面板移除。",
|
|
386
|
+
"hubPolicy.note.capabilityExecDenied": "中枢不可执行",
|
|
387
|
+
"hubPolicy.note.capabilityExecDenied.tip": "固化能力执行面(sm_cap_*):中枢调用会被 HUB_CAPABILITY_EXEC_DENIED 拒绝,请用 memory_dispatch 派发到分支执行(默认预演,写操作 confirm=true)。即使在此勾选也不会让中枢获得执行权。",
|
|
388
|
+
"hubPolicy.custom.placeholder": "添加自定义工具名(未知工具默认拒绝,可在此放行)",
|
|
389
|
+
"hubPolicy.custom.add": "添加",
|
|
390
|
+
"hubPolicy.catalog.dynamic": "动态目录",
|
|
391
|
+
"hubPolicy.catalog.fallback": "内置回退",
|
|
392
|
+
"hubPolicy.catalog.meta": "工具 {tools} 项 / {groups} 组",
|
|
393
|
+
"hubPolicy.refresh": "刷新目录",
|
|
394
|
+
"hubPolicy.lastRefresh": "上次刷新 {time}",
|
|
395
|
+
"hubPolicy.search.placeholder": "搜索工具名或描述(跨来源分组)",
|
|
396
|
+
"hubPolicy.empty": "没有匹配的工具",
|
|
397
|
+
"hubPolicy.empty.hint": "换个关键词,或点「刷新目录」重新读取运行时工具。",
|
|
398
|
+
"hubPolicy.group.count": "{count} 项",
|
|
399
|
+
"hubPolicy.group.enabled": "已启用 {enabled}",
|
|
400
|
+
"hubPolicy.group.match": "匹配 {count} / 共 {total}",
|
|
401
|
+
"hubPolicy.group.expand": "展开该来源",
|
|
402
|
+
"hubPolicy.group.collapse": "折叠该来源",
|
|
403
|
+
"hubPolicy.inferred": "来源为推断",
|
|
404
|
+
"hubPolicy.inferred.tip": "宿主工具定义不含来源字段;分组按命名前缀与插件归属推断(可解释、非精确)。若宿主未来声明来源,该组会自动改为「宿主声明」。",
|
|
405
|
+
"hubPolicy.source.supermemory": "SuperMemory 插件",
|
|
406
|
+
"hubPolicy.source.composite": "固化能力(SuperMemory)",
|
|
407
|
+
"hubPolicy.source.schedule": "调度",
|
|
408
|
+
"hubPolicy.source.hostSession": "宿主会话工具",
|
|
409
|
+
"hubPolicy.source.host": "宿主内置 / 未归属",
|
|
410
|
+
"hubPolicy.source.mcp": "MCP · {server}",
|
|
411
|
+
"hubPolicy.synthetic": "合成",
|
|
412
|
+
"hubPolicy.synthetic.tip": "不在全局注册面(宿主保留名 / agent 级注册 / 会话级 API),但中枢会话实际可用;永不判失效,清理不会移除。",
|
|
413
|
+
"hubPolicy.catalog.synthetic": "合成 {count} 项",
|
|
414
|
+
"hubPolicy.group.stale": "已失效条目",
|
|
415
|
+
"hubPolicy.stale.tip": "白名单中存在、但当前运行时已不存在的条目(插件卸载/改名)。一键清理会先保存当前白名单,再按运行时移除这些条目;锁定项永不移除。",
|
|
416
|
+
"hubPolicy.stale.badge": "失效",
|
|
417
|
+
"hubPolicy.stale.clean": "一键清理({count})",
|
|
418
|
+
"hubPolicy.viaPrefix": "前缀放行",
|
|
419
|
+
"hubPolicy.viaPrefix.tip": "该项由前缀规则放行;要移出白名单请取消同组的前缀条目。",
|
|
420
|
+
"badge.hubSet": "话题集",
|
|
421
|
+
"badge.hubSet.tip": "中枢会话属于话题集 · {title}",
|
|
422
|
+
"badge.branch": "分支",
|
|
423
|
+
"badge.tip": "话题集分支 · {title}",
|
|
424
|
+
"badge.hub": "中枢",
|
|
425
|
+
"badge.hub.tip": "SuperMemory 中枢会话",
|
|
426
|
+
"error.load": "加载失败",
|
|
427
|
+
"error.retry": "重试",
|
|
428
|
+
"error.generic": "操作失败",
|
|
429
|
+
"ok.saved": "已保存",
|
|
430
|
+
"chat.card.from": "来自 {session} 的执行请求",
|
|
431
|
+
"chat.card.kind.hub": "中枢派发",
|
|
432
|
+
"chat.card.kind.branch": "分支回报",
|
|
433
|
+
"chat.card.kind.group": "并行组回报",
|
|
434
|
+
"chat.card.kind.system": "系统通知",
|
|
435
|
+
"chat.card.task": "任务",
|
|
436
|
+
"chat.card.topicSet": "话题集",
|
|
437
|
+
"chat.card.capability": "能力档位",
|
|
438
|
+
"chat.card.dispatch": "派发回执",
|
|
439
|
+
"chat.card.sourceId": "来源会话",
|
|
440
|
+
"chat.card.expand": "展开详情",
|
|
441
|
+
"chat.card.collapse": "收起",
|
|
442
|
+
"chat.card.empty": "(无正文)"
|
|
443
|
+
};
|
|
444
|
+
const en = {
|
|
445
|
+
"panel": "SuperMemory",
|
|
446
|
+
"panel.title": "SuperMemory",
|
|
447
|
+
"tab.hub": "Hub session",
|
|
448
|
+
"tab.sets": "Topic sets",
|
|
449
|
+
"tab.memories": "Memories",
|
|
450
|
+
"tab.branches": "Branches",
|
|
451
|
+
"tab.settings": "Settings",
|
|
452
|
+
"tab.tools": "Fixated capabilities",
|
|
453
|
+
"settings.policy.title": "Hub permissions (whitelist, default deny)",
|
|
454
|
+
"settings.models.title": "Default models",
|
|
455
|
+
"settings.models.hint": "Affects NEW sessions only: the hub default names new hub sessions; the branch default names new dispatches (topic-set/branch overrides still win).",
|
|
456
|
+
"settings.models.hub": "Hub session model",
|
|
457
|
+
"settings.models.branch": "Branch session model",
|
|
458
|
+
"settings.models.follow": "Follow default (host chain)",
|
|
459
|
+
"settings.models.save": "Save default models",
|
|
460
|
+
"settings.models.reset": "Restore defaults",
|
|
461
|
+
"settings.models.precedence": "Precedence: branch override > topic-set default > branch default > hub current model > host default; new hub: explicit choice > hub default > host default.",
|
|
462
|
+
"settings.skills.title": "Generated skills",
|
|
463
|
+
"settings.skills.hint": "Capability knowledge lives under <repo>/.dsh/capabilities/<name>.md (outside every skill root, so it never enters available_skills). Hub/branch sessions get a compact index; sm_cap_doc loads the body on demand. You can edit the routing description or disable one; same-name updates bump the version and keep the changelog, and human-edited bodies are never overwritten.",
|
|
464
|
+
"settings.skills.empty": "No skills yet: repeated flows are fixated past the threshold, or register one manually with memory_toolize register.",
|
|
465
|
+
"settings.skills.uses": "loaded {count} times",
|
|
466
|
+
"settings.skills.save": "Save description",
|
|
467
|
+
"settings.skills.enable": "Enable",
|
|
468
|
+
"settings.skills.disable": "Disable",
|
|
469
|
+
"settings.skills.disabled": "disabled",
|
|
470
|
+
"sets.search": "Search topic sets by title or tag…",
|
|
471
|
+
"sets.clear": "Clear",
|
|
472
|
+
"sets.stats": "Showing {shown} of {total} topic sets",
|
|
473
|
+
"sets.empty": "(no matching topic sets)",
|
|
474
|
+
"sets.empty.hint": "Create a topic set to collect related sessions and their memories.",
|
|
475
|
+
"sets.created": "Created",
|
|
476
|
+
"sets.sessions": "{count} sessions",
|
|
477
|
+
"sets.live": "{count} live",
|
|
478
|
+
"sets.open": "Open",
|
|
479
|
+
"sets.noBody": "(no body yet)",
|
|
480
|
+
"sets.archived": "archived",
|
|
481
|
+
"hub.current": "Current session",
|
|
482
|
+
"hub.active": "Active topic set",
|
|
483
|
+
"hub.none": "(none)",
|
|
484
|
+
"hub.activate": "Activate",
|
|
485
|
+
"hub.topicSets": "Topic sets",
|
|
486
|
+
"hub.empty": "No topic sets in this workspace yet.",
|
|
487
|
+
"hub.empty.hint": "Dispatch the first task from a hub session and its topic set appears here.",
|
|
488
|
+
"side.title": "Hub sessions (discovery)",
|
|
489
|
+
"side.authority": "Discovery view: lists openable top-level sessions by shape, not role authority. Roles come from positive plugin marks (hub record / topic-set root / dispatch).",
|
|
490
|
+
"side.count": "{count}",
|
|
491
|
+
"side.empty": "No hub sessions yet",
|
|
492
|
+
"side.empty.hint": "Keep judgement and summaries here; files and commands go to branches.",
|
|
493
|
+
"side.new": "+ New hub session",
|
|
494
|
+
"side.running": "live",
|
|
495
|
+
"side.current": "current",
|
|
496
|
+
"side.branches": "{count} linked branches ({working} working)",
|
|
497
|
+
"branches.title": "Linked branches",
|
|
498
|
+
"branches.empty": "This hub has not started any branch yet.",
|
|
499
|
+
"branches.empty.hint": "After a dispatch, every branch this hub started appears here: name, state, owning topic set, and how many hubs share it.",
|
|
500
|
+
"branches.working": "working",
|
|
501
|
+
"branches.idle": "idle",
|
|
502
|
+
"branches.failed": "failed",
|
|
503
|
+
"branches.shared": "shared with {count} hub(s)",
|
|
504
|
+
"branches.set": "set「{title}」",
|
|
505
|
+
"branches.ownSet": "owning set",
|
|
506
|
+
"branches.noSet": "no set",
|
|
507
|
+
"branches.dispatches": "{count} dispatches",
|
|
508
|
+
"branches.group": "parallel group",
|
|
509
|
+
"branches.ago.just": "just now",
|
|
510
|
+
"branches.ago.min": "{count} min ago",
|
|
511
|
+
"branches.ago.hour": "{count} h ago",
|
|
512
|
+
"branches.ago.day": "{count} d ago",
|
|
513
|
+
"branches.search": "Search title / tags / branch id / topic set…",
|
|
514
|
+
"branches.stats": "Showing {shown} of {total} branch sessions",
|
|
515
|
+
"hub.counts": "{memories} memories · {requirements} requirements · {episodes} episodes · {dispatches} running dispatches",
|
|
516
|
+
"hub.refresh": "Refresh",
|
|
517
|
+
"hub.openSession": "Open session",
|
|
518
|
+
"hub.allBranches": "All branch sessions",
|
|
519
|
+
"hub.allBranches.filter": "Filter by topic set",
|
|
520
|
+
"hub.allBranches.allSets": "All topic sets",
|
|
521
|
+
"hub.allBranches.empty": "(no branch sessions)",
|
|
522
|
+
"hub.allBranches.hint": "After a dispatch this lists every branch across topic sets: title, tags, status and last activity.",
|
|
523
|
+
"topic.members": "Branch sessions",
|
|
524
|
+
"topic.noMembers": "(no branch sessions)",
|
|
525
|
+
"topic.reply": "Reply into topic set",
|
|
526
|
+
"topic.reply.placeholder": "Text to deliver to the topic-set branch…",
|
|
527
|
+
"topic.reply.send": "Send",
|
|
528
|
+
"topic.summary": "Summary",
|
|
529
|
+
"topic.summary.save": "Save summary",
|
|
530
|
+
"topic.create": "New topic set",
|
|
531
|
+
"topic.create.placeholder": "New topic set title",
|
|
532
|
+
"topic.back": "Back to topic sets",
|
|
533
|
+
"memory.search": "Search title, tags or body…",
|
|
534
|
+
"memory.title": "Title",
|
|
535
|
+
"memory.tags": "Tags",
|
|
536
|
+
"memory.body": "Body",
|
|
537
|
+
"memory.empty": "(no matching memories)",
|
|
538
|
+
"memory.empty.hint": "Memories are written in the conversation (memory_remember); this tab browses and manages them.",
|
|
539
|
+
"memory.locate": "Locate session",
|
|
540
|
+
"memory.edit": "Edit",
|
|
541
|
+
"memory.save": "Save",
|
|
542
|
+
"memory.cancel": "Cancel",
|
|
543
|
+
"memory.delete": "Delete",
|
|
544
|
+
"memory.deleteConfirm": "Confirm delete",
|
|
545
|
+
"memory.disable": "Disable",
|
|
546
|
+
"memory.enable": "Enable",
|
|
547
|
+
"memory.status": "Status",
|
|
548
|
+
"memory.source": "Source session",
|
|
549
|
+
"memory.group.ungrouped": "Ungrouped",
|
|
550
|
+
"memory.group.count": "{count} entries",
|
|
551
|
+
"memory.collection.search": "Search memory collections by title or tags…",
|
|
552
|
+
"memory.collection.open": "Open the entries of this memory collection",
|
|
553
|
+
"memory.collection.empty": "(no matching memory collections)",
|
|
554
|
+
"memory.collection.empty.hint": "Remember a fact and its collection card appears here; open a card to see its entries.",
|
|
555
|
+
"memory.detail.open": "Open this memory's detail and version history",
|
|
556
|
+
"memory.back": "Back",
|
|
557
|
+
"memory.updated": "Updated",
|
|
558
|
+
"memory.history": "Version history",
|
|
559
|
+
"memory.history.none": "(this memory has no history rows yet)",
|
|
560
|
+
"memory.history.toggle": "Expand/collapse this version's full content",
|
|
561
|
+
"memory.history.create": "created",
|
|
562
|
+
"memory.history.update": "updated",
|
|
563
|
+
"memory.history.migrate": "migrated",
|
|
564
|
+
"tool.empty": "(no capabilities yet; a task repeated 3 times becomes a pending knowledge proposal first)",
|
|
565
|
+
"tool.empty.hint": "ONE capability = knowledge .dsh/capabilities/<name>.md (when to use / decisions / pitfalls) + execution sm_cap_* (fixed entry, dry-run by default, confirm for writes). sm_cap_doc loads the body on demand; it never enters available_skills. Auto proposals are knowledge-only and consume the per-root cap of 8 only when accepted.",
|
|
566
|
+
"tool.steps": "Steps",
|
|
567
|
+
"tool.params": "Parameters",
|
|
568
|
+
"tool.uses": "Uses",
|
|
569
|
+
"tool.runCount": "Runs",
|
|
570
|
+
"tool.loadCount": "Loads",
|
|
571
|
+
"tool.conversion": "loads to runs",
|
|
572
|
+
"tool.successRate": "success rate",
|
|
573
|
+
"tool.preview": "Preview run",
|
|
574
|
+
"tool.enableRun": "Enable execution",
|
|
575
|
+
"tool.accept": "Accept proposal",
|
|
576
|
+
"tool.decline": "Decline proposal",
|
|
577
|
+
"tool.badge.auto": "auto",
|
|
578
|
+
"tool.badge.draft": "entry unverified",
|
|
579
|
+
"tool.live": "registered",
|
|
580
|
+
"tool.offline": "not registered",
|
|
581
|
+
"tool.retire": "Retire",
|
|
582
|
+
"tool.enable": "Enable",
|
|
583
|
+
"tool.delete": "Delete",
|
|
584
|
+
"tool.deleteConfirm": "Confirm delete",
|
|
585
|
+
"tool.desc.save": "Save",
|
|
586
|
+
"tool.desc.edit": "Edit title/tags/description",
|
|
587
|
+
"tool.body.label": "Knowledge body (the facts block is machine-maintained; prose is editable)",
|
|
588
|
+
"tool.body.placeholder": "Markdown: when to use / decisions / steps / pitfalls / verification / anti-patterns",
|
|
589
|
+
"tool.body.save": "Save body",
|
|
590
|
+
"tool.kind.capability": "executable",
|
|
591
|
+
"tool.kind.knowledge": "knowledge only",
|
|
592
|
+
"tool.kind.proposal": "proposal",
|
|
593
|
+
"tool.kind.sequence": "legacy sequence (retired)",
|
|
594
|
+
"tool.detail.entryDraft": "Entry draft",
|
|
595
|
+
"tool.detail.unverified": "(unverified; runs only after the human enable step)",
|
|
596
|
+
"tool.detail.skill": "Knowledge file",
|
|
597
|
+
"tool.detail.expires": "Proposal expires",
|
|
598
|
+
"tool.detail.toggle": "Expand/collapse the capability detail",
|
|
599
|
+
"tool.detail.kind": "Kind",
|
|
600
|
+
"tool.detail.version": "Version",
|
|
601
|
+
"tool.detail.builtin": "builtin v{version}",
|
|
602
|
+
"tool.detail.created": "Created",
|
|
603
|
+
"tool.detail.lastUsed": "Last used",
|
|
604
|
+
"tool.detail.entry": "Entry",
|
|
605
|
+
"tool.detail.doc": "Doc",
|
|
606
|
+
"tool.detail.scope": "Scope",
|
|
607
|
+
"tool.detail.route": "Routing",
|
|
608
|
+
"tool.detail.run": "Execution",
|
|
609
|
+
"tool.detail.noRun": "routing/doc only, never executes",
|
|
610
|
+
"tool.detail.dryRun": "dry-run first",
|
|
611
|
+
"tool.detail.realRun": "runs directly",
|
|
612
|
+
"tool.detail.confirm": "confirm required",
|
|
613
|
+
"tool.detail.stats": "Usage",
|
|
614
|
+
"tool.detail.success": "ok",
|
|
615
|
+
"tool.detail.fail": "fail",
|
|
616
|
+
"tool.detail.streak": "consecutive failures",
|
|
617
|
+
"tool.detail.last": "last run",
|
|
618
|
+
"tool.detail.ok": "succeeded",
|
|
619
|
+
"tool.detail.failed": "failed",
|
|
620
|
+
"tool.detail.preview": "dry-run",
|
|
621
|
+
"tool.detail.lastSummary": "Last result",
|
|
622
|
+
"tool.detail.health": "Health",
|
|
623
|
+
"tool.detail.missing": "(missing)",
|
|
624
|
+
"launch.title": "Quick new session",
|
|
625
|
+
"launch.workspace": "Workspace",
|
|
626
|
+
"launch.preset": "Agent mode",
|
|
627
|
+
"launch.model": "Model",
|
|
628
|
+
"launch.permission": "Permission",
|
|
629
|
+
"launch.default": "Default",
|
|
630
|
+
"launch.defaultMark": "default",
|
|
631
|
+
"launch.sets": "Topic sets (multi-select)",
|
|
632
|
+
"launch.start": "Create hub session",
|
|
633
|
+
"launch.startSets": "Create topic-set session",
|
|
634
|
+
"launch.hint": "Leave empty for a plain hub session; selected sets bind the new session to them.",
|
|
635
|
+
"launch.needWorkspace": "Pick a workspace first.",
|
|
636
|
+
"composer.title": "Hub conversation",
|
|
637
|
+
"composer.desc": "Say what the hub should do; the session is created and the message delivered in place.",
|
|
638
|
+
"composer.placeholder": "e.g. tidy this repo’s memories and dispatch a branch to add tests…",
|
|
639
|
+
"composer.start": "Start conversation",
|
|
640
|
+
"composer.createOnly": "Create only",
|
|
641
|
+
"composer.createOnly.hint": "Create the session without sending a message",
|
|
642
|
+
"composer.hint": "Ctrl/Cmd + Enter to send",
|
|
643
|
+
"composer.newSet": "+ New topic set",
|
|
644
|
+
"composer.setsEmpty": "No topic sets in this workspace yet",
|
|
645
|
+
"composer.open": "Open session",
|
|
646
|
+
"composer.dismiss": "Dismiss",
|
|
647
|
+
"composer.receipt.hub": "Hub session",
|
|
648
|
+
"composer.receipt.sets": "Topic-set session",
|
|
649
|
+
"newSession.create": "New topic set…",
|
|
650
|
+
"workspace.label": "Workspace",
|
|
651
|
+
"side.set": "topic set",
|
|
652
|
+
"topic.root": "hub",
|
|
653
|
+
"topic.branch": "branch",
|
|
654
|
+
"chat.live": "live",
|
|
655
|
+
"chat.cold": "not running",
|
|
656
|
+
"chat.empty": "(no messages yet)",
|
|
657
|
+
"chat.empty.hint": "Type below and send: the message goes straight into this session and replies refresh automatically.",
|
|
658
|
+
"chat.placeholder": "Message this session…",
|
|
659
|
+
"chat.send": "Send",
|
|
660
|
+
"chat.refresh": "Refresh",
|
|
661
|
+
"chat.open": "Open in DSH",
|
|
662
|
+
"chat.truncated": "recent messages only",
|
|
663
|
+
"chat.hint": "Ctrl/Cmd + Enter sends; the panel polls the session for new replies.",
|
|
664
|
+
"chat.you": "You",
|
|
665
|
+
"chat.assistant": "Assistant",
|
|
666
|
+
"chat.tool": "Tool",
|
|
667
|
+
"memory.modal.title": "Edit memory",
|
|
668
|
+
"memory.modal.hint": "Record conclusions only: reusable facts/decisions. Keep process steps in the conversation; title and tags are the index.",
|
|
669
|
+
"hubPolicy.model": "{count} whitelisted · everything else denied by default",
|
|
670
|
+
"hubPolicy.hint": "A hub may call only whitelisted tools; anything else is denied, including future tools nobody reviewed yet. The catalog is regenerated from the runtime on every open/refresh; a save takes effect on the next tool call. The capability execution face (sm_cap_*) is structurally denied in a hub (HUB_CAPABILITY_EXEC_DENIED) and must be dispatched to a branch; sm_cap_doc stays read-only.",
|
|
671
|
+
"hubPolicy.source.stored": "Workspace custom",
|
|
672
|
+
"hubPolicy.source.default": "Built-in default",
|
|
673
|
+
"hubPolicy.reset": "Restore default",
|
|
674
|
+
"hubPolicy.save": "Save",
|
|
675
|
+
"hubPolicy.loading": "(reading the whitelist…)",
|
|
676
|
+
"hubPolicy.loading.hint": "A read failure falls back to the built-in default; the dispatch link is never broken.",
|
|
677
|
+
"hubPolicy.locked": "Locked",
|
|
678
|
+
"hubPolicy.locked.tip": "Core locked entry: dispatch / relay / user question / the run_code transport, plus the read-only capability knowledge face (sm_cap_doc, R55). Removing it would leave a hub unable to dispatch or to judge whether a capability applies, so it cannot be switched off.",
|
|
679
|
+
"hubPolicy.risk": "Hands-on",
|
|
680
|
+
"hubPolicy.risk.tip": "Hands-on execution tool: a hub is supposed to dispatch these to a branch. Enabling one lets the hub do the work itself.",
|
|
681
|
+
"hubPolicy.note.pluginManager": "Switching this off also stops a hub from reloading the plugin (use the host plugin page).",
|
|
682
|
+
"hubPolicy.note.capabilityDoc": "Read-only routing, locked",
|
|
683
|
+
"hubPolicy.note.capabilityDoc.tip": "A capability knowledge face: a hub reads it to decide whether it applies; execution must be dispatched to a branch. Always allowed and not removable in the panel.",
|
|
684
|
+
"hubPolicy.note.capabilityExecDenied": "Cannot run from a hub",
|
|
685
|
+
"hubPolicy.note.capabilityExecDenied.tip": "The capability execution face (sm_cap_*). A hub call is refused with HUB_CAPABILITY_EXEC_DENIED; dispatch it to a branch (dry-run by default, write operations need confirm=true). Ticking it here does not grant hub execution.",
|
|
686
|
+
"hubPolicy.custom.placeholder": "Add a custom tool name (unknown tools are denied until whitelisted here)",
|
|
687
|
+
"hubPolicy.custom.add": "Add",
|
|
688
|
+
"hubPolicy.catalog.dynamic": "Dynamic catalog",
|
|
689
|
+
"hubPolicy.catalog.fallback": "Built-in fallback",
|
|
690
|
+
"hubPolicy.catalog.meta": "{tools} tools / {groups} groups",
|
|
691
|
+
"hubPolicy.refresh": "Refresh catalog",
|
|
692
|
+
"hubPolicy.lastRefresh": "Last refreshed {time}",
|
|
693
|
+
"hubPolicy.search.placeholder": "Search tool names or descriptions (across source groups)",
|
|
694
|
+
"hubPolicy.empty": "No matching tools",
|
|
695
|
+
"hubPolicy.empty.hint": "Try another keyword, or press \"Refresh catalog\" to re-read the runtime tools.",
|
|
696
|
+
"hubPolicy.group.count": "{count} entries",
|
|
697
|
+
"hubPolicy.group.enabled": "{enabled} enabled",
|
|
698
|
+
"hubPolicy.group.match": "{count} of {total} match",
|
|
699
|
+
"hubPolicy.group.expand": "Expand this source",
|
|
700
|
+
"hubPolicy.group.collapse": "Collapse this source",
|
|
701
|
+
"hubPolicy.inferred": "Source inferred",
|
|
702
|
+
"hubPolicy.inferred.tip": "Host tool definitions carry no source field, so groups are inferred from naming prefixes and plugin ownership (explainable, not exact). If a host ever declares a source, that group switches to \"declared\" automatically.",
|
|
703
|
+
"hubPolicy.source.supermemory": "SuperMemory plugin",
|
|
704
|
+
"hubPolicy.source.composite": "Composite capabilities (SuperMemory)",
|
|
705
|
+
"hubPolicy.source.schedule": "Scheduling",
|
|
706
|
+
"hubPolicy.source.hostSession": "Host session tools",
|
|
707
|
+
"hubPolicy.source.host": "Host built-in / unattributed",
|
|
708
|
+
"hubPolicy.source.mcp": "MCP · {server}",
|
|
709
|
+
"hubPolicy.synthetic": "synthetic",
|
|
710
|
+
"hubPolicy.synthetic.tip": "Not on the global registration surface (host-reserved name / agent-scope registration / session-level API), yet callable from a hub session. Never stale and never removed by cleanup.",
|
|
711
|
+
"hubPolicy.catalog.synthetic": "{count} synthetic",
|
|
712
|
+
"hubPolicy.group.stale": "Stale entries",
|
|
713
|
+
"hubPolicy.stale.tip": "Whitelisted names that no longer exist at runtime (uninstalled or renamed tools). \"Clean up\" first saves the current whitelist, then removes them; locked entries are never removed.",
|
|
714
|
+
"hubPolicy.stale.badge": "stale",
|
|
715
|
+
"hubPolicy.stale.clean": "Clean up ({count})",
|
|
716
|
+
"hubPolicy.viaPrefix": "via prefix",
|
|
717
|
+
"hubPolicy.viaPrefix.tip": "This tool is allowed by a prefix rule; remove the prefix entry in this group to take it out of the whitelist.",
|
|
718
|
+
"badge.hubSet": "Topic set",
|
|
719
|
+
"badge.hubSet.tip": "Hub session of a topic set · {title}",
|
|
720
|
+
"badge.branch": "Branch",
|
|
721
|
+
"badge.tip": "Topic-set branch · {title}",
|
|
722
|
+
"badge.hub": "Hub",
|
|
723
|
+
"badge.hub.tip": "SuperMemory hub session",
|
|
724
|
+
"error.load": "Load failed",
|
|
725
|
+
"error.retry": "Retry",
|
|
726
|
+
"error.generic": "Operation failed",
|
|
727
|
+
"ok.saved": "Saved",
|
|
728
|
+
"chat.card.from": "Execution requested by {session}",
|
|
729
|
+
"chat.card.kind.hub": "Hub dispatch",
|
|
730
|
+
"chat.card.kind.branch": "Branch report",
|
|
731
|
+
"chat.card.kind.group": "Parallel group report",
|
|
732
|
+
"chat.card.kind.system": "System notice",
|
|
733
|
+
"chat.card.task": "Task",
|
|
734
|
+
"chat.card.topicSet": "Topic set",
|
|
735
|
+
"chat.card.capability": "Capability",
|
|
736
|
+
"chat.card.dispatch": "Dispatch receipt",
|
|
737
|
+
"chat.card.sourceId": "Source session",
|
|
738
|
+
"chat.card.expand": "Expand details",
|
|
739
|
+
"chat.card.collapse": "Collapse",
|
|
740
|
+
"chat.card.empty": "(no text)"
|
|
741
|
+
};
|
|
742
|
+
// src/client/icon.tsx
|
|
743
|
+
/** Decorative glyph for the SuperMemory sidebar panel row. */
|
|
744
|
+
/**
|
|
745
|
+
* Render the SuperMemory mark at the size the sidebar asks for.
|
|
746
|
+
* @param props - the sidebar's icon share: requested edge and active state.
|
|
747
|
+
* @returns decorative inline SVG.
|
|
748
|
+
*/
|
|
749
|
+
function SupermemoryIcon(props) {
|
|
750
|
+
const size = props.size ?? 18;
|
|
751
|
+
const stroke = props.active ? "currentColor" : "currentColor";
|
|
752
|
+
return (0, react.createElement)("svg", {
|
|
753
|
+
width: size,
|
|
754
|
+
height: size,
|
|
755
|
+
viewBox: "0 0 24 24",
|
|
756
|
+
fill: "none",
|
|
757
|
+
stroke,
|
|
758
|
+
strokeWidth: 1.6,
|
|
759
|
+
strokeLinecap: "round",
|
|
760
|
+
strokeLinejoin: "round",
|
|
761
|
+
"aria-hidden": true,
|
|
762
|
+
focusable: false
|
|
763
|
+
}, (0, react.createElement)("path", {
|
|
764
|
+
key: "a",
|
|
765
|
+
d: "M12 3a7 7 0 0 0-7 7c0 1.6.5 3 1.4 4.2L12 21l5.6-6.8A7 7 0 0 0 12 3z"
|
|
766
|
+
}), (0, react.createElement)("path", {
|
|
767
|
+
key: "b",
|
|
768
|
+
d: "M9.5 10.5a2.5 2.5 0 1 1 3.4 2.33c-.78.35-1.4 1-1.4 1.92"
|
|
769
|
+
}), (0, react.createElement)("circle", {
|
|
770
|
+
key: "c",
|
|
771
|
+
cx: 11.5,
|
|
772
|
+
cy: 16.4,
|
|
773
|
+
r: .4,
|
|
774
|
+
fill: stroke,
|
|
775
|
+
stroke: "none"
|
|
776
|
+
}));
|
|
777
|
+
}
|
|
778
|
+
// src/client/open-dispatch.ts
|
|
779
|
+
const listeners$1 = /* @__PURE__ */ new Set();
|
|
780
|
+
/** The receipt a not-yet-mounted panel should show on mount. */
|
|
781
|
+
let pending;
|
|
782
|
+
/**
|
|
783
|
+
* Deliver one receipt to every live listener (each mounted panel page) and
|
|
784
|
+
* keep it for the next mount when nobody is listening yet. One throwing
|
|
785
|
+
* listener never blocks the others.
|
|
786
|
+
*/
|
|
787
|
+
function publishHubReceipt(receipt) {
|
|
788
|
+
if (listeners$1.size === 0) pending = receipt;
|
|
789
|
+
for (const listener of [...listeners$1]) try {
|
|
790
|
+
listener(receipt);
|
|
791
|
+
} catch {}
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Subscribe to receipts. Returns the unsubscribe function; call it from the
|
|
795
|
+
* effect cleanup so a remount never leaks a listener.
|
|
796
|
+
*/
|
|
797
|
+
function subscribeHubReceipt(listener) {
|
|
798
|
+
listeners$1.add(listener);
|
|
799
|
+
return () => {
|
|
800
|
+
listeners$1.delete(listener);
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Take the receipt published before this panel mounted (and clear it, so a
|
|
805
|
+
* later remount never shows a stale creation). Undefined when there is none.
|
|
806
|
+
*/
|
|
807
|
+
function takePendingHubReceipt() {
|
|
808
|
+
const receipt = pending;
|
|
809
|
+
pending = void 0;
|
|
810
|
+
return receipt;
|
|
811
|
+
}
|
|
812
|
+
// src/rail-selection.ts
|
|
813
|
+
/**
|
|
814
|
+
* @param view - current panel view.
|
|
815
|
+
* @param hubSessionId - the rail row being tested.
|
|
816
|
+
* @param shellSessionId - the host session the panel was opened for.
|
|
817
|
+
* @returns true for exactly one row in any given state.
|
|
818
|
+
*/
|
|
819
|
+
function isRailCurrent(view, hubSessionId, shellSessionId) {
|
|
820
|
+
if (view.kind === "chat") return !!view.id && view.id === hubSessionId;
|
|
821
|
+
return !!shellSessionId && shellSessionId === hubSessionId;
|
|
822
|
+
}
|
|
823
|
+
// src/client/panel-page.tsx
|
|
824
|
+
/**
|
|
825
|
+
* SuperMemory main panel (the `main` slot keyed by panel id 'supermemory').
|
|
826
|
+
* Level 1 shows the hub session and the workspace's topic sets; level 2
|
|
827
|
+
* opens one topic set (its branch sessions, reply box and summary); the
|
|
828
|
+
* Memories tab is two levels (R30 需求②): 记忆集卡片 → 集合内条目(带版本
|
|
829
|
+
* 徽标)→ 记忆详情(完整正文 + 历史版本);the Tools tab lists and edits
|
|
830
|
+
* composite tools (R6) with their lifecycle timestamps (R28 需求②).
|
|
831
|
+
* @module supermemory/client/panel-page
|
|
832
|
+
*/
|
|
833
|
+
/**
|
|
834
|
+
* R22 需求③: one composite tool / capability rendered as readable detail rows.
|
|
835
|
+
* Every field comes from the host (panel.listTools now ships routeNote /
|
|
836
|
+
* builtin / scopeMissing / docMissing / notes); a missing field is simply
|
|
837
|
+
* omitted — never printed as "undefined".
|
|
838
|
+
*/
|
|
839
|
+
function kindLabel(kind, t) {
|
|
840
|
+
if (kind === "capability") return t("tool.kind.capability");
|
|
841
|
+
if (kind === "knowledge") return t("tool.kind.knowledge");
|
|
842
|
+
if (kind === "proposal") return t("tool.kind.proposal");
|
|
843
|
+
return t("tool.kind.sequence");
|
|
844
|
+
}
|
|
845
|
+
function capabilityDetail(tool, t) {
|
|
846
|
+
const rows = [];
|
|
847
|
+
const row = (key, label, value) => {
|
|
848
|
+
rows.push((0, react.createElement)("div", {
|
|
849
|
+
key,
|
|
850
|
+
className: "sm-kv"
|
|
851
|
+
}, (0, react.createElement)("span", {
|
|
852
|
+
key: "k",
|
|
853
|
+
className: "sm-kv-k"
|
|
854
|
+
}, label), (0, react.createElement)("span", {
|
|
855
|
+
key: "v",
|
|
856
|
+
className: "sm-kv-v"
|
|
857
|
+
}, value)));
|
|
858
|
+
};
|
|
859
|
+
const code = (key, value) => (0, react.createElement)("code", {
|
|
860
|
+
key,
|
|
861
|
+
className: "sm-code"
|
|
862
|
+
}, value);
|
|
863
|
+
row("kind", t("tool.detail.kind"), kindLabel(tool.kind, t));
|
|
864
|
+
if (tool.version !== void 0) row("version", t("tool.detail.version"), `v${tool.version}` + (tool.builtin && tool.builtinVersion !== void 0 ? ` · ${t("tool.detail.builtin", { version: tool.builtinVersion })}` : ""));
|
|
865
|
+
if (tool.createdAt !== void 0 || tool.usage?.lastUsedAt !== void 0) {
|
|
866
|
+
row("created", t("tool.detail.created"), fmtTime(tool.createdAt));
|
|
867
|
+
row("lastUsed", t("tool.detail.lastUsed"), fmtTime(tool.usage?.lastUsedAt));
|
|
868
|
+
}
|
|
869
|
+
if (tool.entry) row("entry", t("tool.detail.entry"), code("code", tool.entry));
|
|
870
|
+
if (tool.entryDraft) row("entryDraft", t("tool.detail.entryDraft"), (0, react.createElement)("span", null, code("code", tool.entryDraft), tool.entryVerified ? null : (0, react.createElement)("span", {
|
|
871
|
+
key: "w",
|
|
872
|
+
className: "sm-warn"
|
|
873
|
+
}, t("tool.detail.unverified"))));
|
|
874
|
+
if (tool.skillPath) row("skill", t("tool.detail.skill"), code("code", tool.skillPath));
|
|
875
|
+
if (tool.kind === "proposal" && tool.expiresAt !== void 0) row("expires", t("tool.detail.expires"), fmtTime(tool.expiresAt));
|
|
876
|
+
if (tool.doc) row("doc", t("tool.detail.doc"), (0, react.createElement)("span", null, code("code", tool.doc), tool.docMissing ? (0, react.createElement)("span", {
|
|
877
|
+
key: "w",
|
|
878
|
+
className: "sm-warn"
|
|
879
|
+
}, t("tool.detail.missing")) : null));
|
|
880
|
+
if (tool.scope) row("scope", t("tool.detail.scope"), (0, react.createElement)("span", null, code("code", tool.scope), tool.scopeMissing ? (0, react.createElement)("span", {
|
|
881
|
+
key: "w",
|
|
882
|
+
className: "sm-warn"
|
|
883
|
+
}, t("tool.detail.missing")) : null));
|
|
884
|
+
if (tool.routeNote) row("route", t("tool.detail.route"), tool.routeNote);
|
|
885
|
+
if (tool.kind === "capability") {
|
|
886
|
+
const how = tool.runnable === false ? t("tool.detail.noRun") : [tool.dryRunArg ? `${t("tool.detail.dryRun")}(${tool.dryRunArg})` : t("tool.detail.realRun"), tool.writeConfirm ? t("tool.detail.confirm") : null].filter(Boolean).join(" · ");
|
|
887
|
+
row("run", t("tool.detail.run"), how);
|
|
888
|
+
}
|
|
889
|
+
const usage = tool.usage;
|
|
890
|
+
const stats = [
|
|
891
|
+
`${t("tool.runCount")} ${tool.runCount ?? tool.useCount}`,
|
|
892
|
+
`${t("tool.loadCount")} ${tool.loadCount ?? 0}`,
|
|
893
|
+
`${t("tool.conversion")} ${tool.loadsToRuns ?? 0}`,
|
|
894
|
+
`${t("tool.successRate")} ${tool.successRate ?? 0}`,
|
|
895
|
+
usage ? `${t("tool.detail.success")} ${usage.successCount} / ${t("tool.detail.fail")} ${usage.failCount}` : null,
|
|
896
|
+
usage && usage.consecutiveFailures >= 2 ? `${t("tool.detail.streak")} ${usage.consecutiveFailures}` : null,
|
|
897
|
+
usage?.lastStatus ? `${t("tool.detail.last")} ${usage.lastStatus === "completed" ? t("tool.detail.ok") : t("tool.detail.failed")}${usage.lastDryRun ? `(${t("tool.detail.preview")})` : ""}` : null
|
|
898
|
+
].filter(Boolean).join(" · ");
|
|
899
|
+
row("stats", t("tool.detail.stats"), stats);
|
|
900
|
+
if (usage?.lastSummary) row("lastSummary", t("tool.detail.lastSummary"), usage.lastSummary);
|
|
901
|
+
if (tool.notes && tool.notes.length > 0) rows.push((0, react.createElement)("div", {
|
|
902
|
+
key: "notes",
|
|
903
|
+
className: "sm-kv"
|
|
904
|
+
}, (0, react.createElement)("span", {
|
|
905
|
+
key: "k",
|
|
906
|
+
className: "sm-kv-k"
|
|
907
|
+
}, t("tool.detail.health")), (0, react.createElement)("ul", {
|
|
908
|
+
key: "v",
|
|
909
|
+
className: "sm-kv-v sm-notes"
|
|
910
|
+
}, tool.notes.map((note, index) => (0, react.createElement)("li", { key: index }, note)))));
|
|
911
|
+
if (tool.steps.length > 0) row("steps", t("tool.steps"), tool.steps.join(" → "));
|
|
912
|
+
if (tool.parameters.length > 0) row("params", t("tool.params"), tool.parameters.join("、"));
|
|
913
|
+
return rows;
|
|
914
|
+
}
|
|
915
|
+
const PANEL_CSS = `
|
|
916
|
+
/* R18 需求⑥: 8px grid, 10px cards, hover lift, underline tabs, compact head.
|
|
917
|
+
Every colour rides the host theme vocabulary (--dsw-alias-*), never a
|
|
918
|
+
hardcoded palette: the panel must follow light/dark like the shell. */
|
|
919
|
+
.sm-panel{display:flex;flex-direction:column;height:100%;min-height:0;color:var(--dsw-alias-label-primary,#f9fafb);background:var(--dsw-alias-bg-base,#151517);font-size:13px}
|
|
920
|
+
.sm-panel *{box-sizing:border-box}
|
|
921
|
+
.sm-shell{display:flex;height:100%;min-height:0;width:100%}
|
|
922
|
+
|
|
923
|
+
/* ---- R41: settings section headings (默认模型 / 中枢权限) ---- */
|
|
924
|
+
.sm-section-title{font-size:11px;font-weight:600;letter-spacing:.04em;opacity:.6;margin:4px 0 0}
|
|
925
|
+
|
|
926
|
+
/* ---- left rail: hub sessions (R18 需求①) ---- */
|
|
927
|
+
.sm-side{display:flex;flex-direction:column;gap:8px;width:232px;flex:none;min-height:0;padding:12px 8px;border-right:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1));background:var(--dsw-alias-bg-layer-1,#1c1c1e)}
|
|
928
|
+
.sm-side-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 6px;font-size:11px;font-weight:600;letter-spacing:.04em;opacity:.55}
|
|
929
|
+
.sm-side-count{font-weight:400;letter-spacing:0}
|
|
930
|
+
.sm-side-list{flex:1;min-height:0;overflow:auto;display:flex;flex-direction:column;gap:2px}
|
|
931
|
+
.sm-hub{display:flex;align-items:center;gap:6px;width:100%;padding:7px 8px;border:1px solid transparent;border-radius:8px;background:transparent;color:inherit;font-family:inherit;font-size:12px;text-align:left;cursor:pointer;transition:background .12s ease,border-color .12s ease}
|
|
932
|
+
.sm-hub:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.06))}
|
|
933
|
+
.sm-hub[data-current="true"]{border-color:var(--dsw-alias-link,#7aaaff);background:color-mix(in srgb,var(--dsw-alias-link,#7aaaff) 14%,transparent)}
|
|
934
|
+
.sm-hub-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
935
|
+
.sm-hub-meta{font-size:9px;opacity:.6;flex:none;max-width:72px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
936
|
+
.sm-hub-set{color:var(--dsw-alias-link,#7aaaff);opacity:.85}
|
|
937
|
+
.sm-dot{width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-state-success-primary,#22c55e);flex:none;box-shadow:0 0 0 2px color-mix(in srgb,var(--dsw-alias-state-success-primary,#22c55e) 18%,transparent)}
|
|
938
|
+
.sm-side-empty{padding:10px 8px;font-size:11px;line-height:1.5;opacity:.5}
|
|
939
|
+
.sm-side-foot{margin-top:auto;padding-top:6px;border-top:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1))}
|
|
940
|
+
.sm-newhub{width:100%;justify-content:center}
|
|
941
|
+
|
|
942
|
+
/* ---- right body ---- */
|
|
943
|
+
.sm-main{display:flex;flex-direction:column;flex:1;min-width:0;min-height:0}
|
|
944
|
+
.sm-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:10px 16px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1))}
|
|
945
|
+
.sm-brand{font-size:13px;font-weight:650;letter-spacing:.01em}
|
|
946
|
+
.sm-head-sub{font-size:11px;opacity:.5;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:240px}
|
|
947
|
+
.sm-pills{display:flex;align-items:center;gap:4px;margin-left:auto;flex-wrap:wrap}
|
|
948
|
+
.sm-pill{padding:1px 8px;border-radius:999px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));font-size:10px;line-height:16px;opacity:.75;white-space:nowrap}
|
|
949
|
+
.sm-tabs{display:flex;align-items:stretch;gap:4px;padding:0 12px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1));overflow-x:auto}
|
|
950
|
+
.sm-tab{padding:8px 10px;border:none;border-bottom:2px solid transparent;border-radius:0;background:transparent;color:inherit;opacity:.62;cursor:pointer;font-size:12px;font-family:inherit;white-space:nowrap;margin-bottom:-1px;transition:opacity .12s ease,border-color .12s ease}
|
|
951
|
+
.sm-tab:hover{opacity:.9;background:transparent}
|
|
952
|
+
.sm-tab[data-active="true"]{opacity:1;border-bottom-color:var(--dsw-alias-link,#7aaaff);font-weight:600;background:transparent}
|
|
953
|
+
.sm-body{flex:1;min-height:0;overflow:auto;padding:12px 16px 20px}
|
|
954
|
+
|
|
955
|
+
/* ---- surfaces ---- */
|
|
956
|
+
.sm-card{border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1));border-radius:10px;padding:10px 12px;margin-bottom:8px;background:var(--dsw-alias-bg-layer-1,#1f1f21);transition:border-color .12s ease,box-shadow .12s ease}
|
|
957
|
+
.sm-card:hover,.sm-item:hover{border-color:var(--dsw-alias-border-l1,rgba(255,255,255,.2))}
|
|
958
|
+
.sm-card h3{margin:0 0 6px;font-size:12.5px;font-weight:600;opacity:.9}
|
|
959
|
+
.sm-item{border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1));border-radius:10px;padding:8px 10px;background:var(--dsw-alias-bg-layer-1,#1f1f21);transition:border-color .12s ease,transform .12s ease,box-shadow .12s ease}
|
|
960
|
+
.sm-item[data-clickable="true"]{cursor:pointer}
|
|
961
|
+
.sm-item[data-clickable="true"]:hover{border-color:var(--dsw-alias-link,#7aaaff);box-shadow:0 2px 10px rgba(0,0,0,.18)}
|
|
962
|
+
/* R36 需求②: 「中枢权限」开关行——label 即整行,checkbox 与标题同一基线;
|
|
963
|
+
锁定行置灰且禁点,风险/锁定徽标跟在标题后。 */
|
|
964
|
+
.sm-item:has(> input[type="checkbox"]){display:flex;align-items:center;gap:8px;flex-wrap:wrap;cursor:pointer}
|
|
965
|
+
.sm-item:has(> input[type="checkbox"]:disabled){opacity:.62;cursor:not-allowed}
|
|
966
|
+
.sm-item > input[type="checkbox"]{flex:none;width:14px;height:14px;margin:0;accent-color:var(--dsw-alias-link,#7aaaff);cursor:inherit}
|
|
967
|
+
.sm-item .sm-title{font-weight:600;font-size:12.5px}
|
|
968
|
+
.sm-item .sm-sub{opacity:.58;font-size:11px;margin-top:2px;word-break:break-all}
|
|
969
|
+
.sm-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
970
|
+
.sm-muted{opacity:.58;font-size:11px}
|
|
971
|
+
.sm-list{display:flex;flex-direction:column;gap:8px}
|
|
972
|
+
|
|
973
|
+
/* ---- buttons: three levels (primary / secondary / danger), two sizes ---- */
|
|
974
|
+
.sm-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:5px 11px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));background:var(--dsw-alias-bg-layer-2,#2c2c2e);color:inherit;cursor:pointer;font-size:12px;font-family:inherit;line-height:1.4;transition:background .12s ease,border-color .12s ease,opacity .12s ease}
|
|
975
|
+
.sm-btn:hover{border-color:var(--dsw-alias-link,#7aaaff)}
|
|
976
|
+
.sm-btn[data-size="sm"]{padding:3px 8px;font-size:11px;border-radius:7px}
|
|
977
|
+
.sm-btn[data-variant="primary"]{background:var(--dsw-alias-button-primary-fill,#f9fafb);border-color:transparent;color:var(--dsw-alias-label-primary-foreground,#0f1115);font-weight:600}
|
|
978
|
+
.sm-btn[data-variant="primary"]:hover{background:var(--dsw-alias-button-primary-hover,#ebeef2);border-color:transparent}
|
|
979
|
+
.sm-btn[data-variant="danger"]{border-color:var(--dsw-alias-state-error-primary,#f25a5a);color:var(--dsw-alias-state-error-primary,#f25a5a);background:transparent}
|
|
980
|
+
.sm-btn[data-variant="danger"]:hover{background:color-mix(in srgb,var(--dsw-alias-state-error-primary,#f25a5a) 12%,transparent)}
|
|
981
|
+
.sm-btn:disabled{opacity:.45;cursor:default}
|
|
982
|
+
|
|
983
|
+
/* ---- fields ---- */
|
|
984
|
+
.sm-input,.sm-select,.sm-textarea{width:100%;padding:6px 9px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));background:var(--dsw-specific-input-major,#2c2c2e);color:inherit;font-size:12px;font-family:inherit}
|
|
985
|
+
.sm-input:focus,.sm-select:focus,.sm-textarea:focus{outline:none;border-color:var(--dsw-alias-link,#7aaaff)}
|
|
986
|
+
.sm-textarea{min-height:56px;resize:vertical;line-height:1.5}
|
|
987
|
+
.sm-field{display:flex;flex-direction:column;gap:6px;margin-bottom:8px}
|
|
988
|
+
.sm-field .sm-field-label{font-size:11px;opacity:.55}
|
|
989
|
+
.sm-check{display:flex;gap:8px;align-items:center;padding:4px 6px;border-radius:8px;cursor:pointer;font-size:12px}
|
|
990
|
+
.sm-check:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08))}
|
|
991
|
+
.sm-form{display:flex;gap:8px;margin-bottom:8px}
|
|
992
|
+
.sm-form .sm-input{flex:1}
|
|
993
|
+
.sm-form-col{display:flex;flex-direction:column;gap:8px;margin-bottom:10px}
|
|
994
|
+
.sm-form-row{display:flex;gap:8px;flex-wrap:wrap}
|
|
995
|
+
.sm-form-row .sm-input{flex:1;min-width:120px}
|
|
996
|
+
.sm-form-label{font-size:11px;opacity:.55}
|
|
997
|
+
.sm-back{margin-bottom:8px}
|
|
998
|
+
|
|
999
|
+
/* ---- feedback ---- */
|
|
1000
|
+
.sm-actions{display:flex;gap:6px;margin-top:8px;flex-wrap:wrap}
|
|
1001
|
+
.sm-error{color:var(--dsw-alias-state-error-primary,#f25a5a);font-size:12px;padding:8px 0}
|
|
1002
|
+
.sm-ok{color:var(--dsw-alias-state-success-primary,#22c55e);font-size:12px;padding:4px 0}
|
|
1003
|
+
.sm-badge{display:inline-block;padding:1px 7px;border-radius:999px;font-size:10px;line-height:16px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));opacity:.8;margin-right:4px}
|
|
1004
|
+
.sm-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:28px 12px;text-align:center;opacity:.6}
|
|
1005
|
+
.sm-empty-art{opacity:.5;margin-bottom:2px}
|
|
1006
|
+
.sm-empty-label{font-size:12px}
|
|
1007
|
+
.sm-empty-hint{font-size:11px;opacity:.75;max-width:280px;line-height:1.5}
|
|
1008
|
+
.sm-shape-hint{font-size:11px;opacity:.55;margin-top:-2px}
|
|
1009
|
+
|
|
1010
|
+
/* ---- composer (hub tab) ---- */
|
|
1011
|
+
.sm-composer{border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1));border-radius:12px;padding:14px;margin-bottom:10px;background:var(--dsw-alias-bg-layer-1,#1f1f21)}
|
|
1012
|
+
.sm-composer-head{margin-bottom:10px}
|
|
1013
|
+
.sm-composer-title{margin:0 0 4px;font-size:16px;font-weight:650}
|
|
1014
|
+
.sm-composer-desc{margin:0;font-size:11.5px;opacity:.58;line-height:1.55}
|
|
1015
|
+
.sm-composer-input{width:100%;min-height:92px;padding:10px 12px;border-radius:10px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));background:var(--dsw-specific-input-major,#2c2c2e);color:inherit;font-size:13px;font-family:inherit;resize:vertical;line-height:1.55}
|
|
1016
|
+
.sm-composer-input:focus{outline:none;border-color:var(--dsw-alias-link,#7aaaff)}
|
|
1017
|
+
.sm-composer-bar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:8px}
|
|
1018
|
+
.sm-composer-opts{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin-top:10px;padding-top:10px;border-top:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.08))}
|
|
1019
|
+
.sm-opt{display:inline-flex;align-items:center;gap:4px;padding:2px 9px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));border-radius:999px;background:transparent;font-size:11px}
|
|
1020
|
+
.sm-opt-label{opacity:.55;font-size:11px;white-space:nowrap}
|
|
1021
|
+
.sm-opt-select{border:none;background:transparent;color:inherit;font-size:11px;padding:1px 2px;max-width:160px}
|
|
1022
|
+
.sm-opt-select:focus{outline:none}
|
|
1023
|
+
.sm-composer-sets{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin-top:8px}
|
|
1024
|
+
.sm-chip{padding:3px 10px;border-radius:999px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));background:transparent;color:inherit;font-size:11px;cursor:pointer;font-family:inherit}
|
|
1025
|
+
.sm-chip:hover{border-color:var(--dsw-alias-link,#7aaaff)}
|
|
1026
|
+
.sm-chip[data-active="true"]{border-color:var(--dsw-alias-link,#7aaaff);background:color-mix(in srgb,var(--dsw-alias-link,#7aaaff) 14%,transparent)}
|
|
1027
|
+
.sm-chip[data-dashed="true"]{border-style:dashed;opacity:.75}
|
|
1028
|
+
.sm-set-created{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin-top:8px;font-size:11px;opacity:.85}
|
|
1029
|
+
.sm-receipt{border:1px solid var(--dsw-alias-link,#7aaaff);border-radius:10px;padding:10px 12px;margin-bottom:10px;font-size:12px;background:color-mix(in srgb,var(--dsw-alias-link,#7aaaff) 8%,transparent)}
|
|
1030
|
+
.sm-receipt .sm-sub{margin-top:4px}
|
|
1031
|
+
|
|
1032
|
+
/* ---- retrieval shape: title + tags + body ---- */
|
|
1033
|
+
.sm-tags{display:flex;gap:4px;flex-wrap:wrap;margin-top:4px}
|
|
1034
|
+
.sm-tag{padding:0 7px;border-radius:999px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.18));font-size:10px;opacity:.85;line-height:16px;max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1035
|
+
.sm-tag[data-hit="true"]{border-color:var(--dsw-alias-link,#7aaaff);color:var(--dsw-alias-link,#7aaaff);opacity:1}
|
|
1036
|
+
.sm-body-text{margin-top:4px;font-size:12px;line-height:1.55;white-space:pre-wrap;word-break:break-word;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
|
|
1037
|
+
.sm-body-text[data-open="true"]{-webkit-line-clamp:unset;overflow:visible}
|
|
1038
|
+
|
|
1039
|
+
/* ---- R22: 派发卡片(需求②)与能力详情(需求③) ---- */
|
|
1040
|
+
.sm-dispatch h3{margin:0}
|
|
1041
|
+
.sm-dispatch .sm-composer-opts{margin-top:8px}
|
|
1042
|
+
.sm-dispatch .sm-actions{margin-top:10px;padding-top:10px;border-top:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1))}
|
|
1043
|
+
.sm-caret{flex:none;width:10px;font-size:10px;opacity:.55;text-align:center}
|
|
1044
|
+
.sm-detail{display:flex;flex-direction:column;gap:3px;margin:8px 0 2px;padding-top:8px;border-top:1px dashed var(--dsw-alias-border-l2,rgba(255,255,255,.12))}
|
|
1045
|
+
.sm-kv{display:flex;align-items:flex-start;gap:8px;font-size:11.5px;line-height:1.65}
|
|
1046
|
+
.sm-kv-k{flex:none;width:74px;opacity:.55}
|
|
1047
|
+
.sm-kv-v{flex:1;min-width:0;word-break:break-word;white-space:pre-wrap}
|
|
1048
|
+
.sm-code{display:inline-block;padding:0 5px;border-radius:5px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));background:var(--dsw-alias-bg-layer-2,#2c2c2e);font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:11px;word-break:break-all}
|
|
1049
|
+
.sm-notes{margin:0;padding-left:15px}
|
|
1050
|
+
.sm-warn{margin-left:4px;font-size:10.5px;color:var(--dsw-alias-state-error-primary,#f25a5a)}
|
|
1051
|
+
/* ---- R39: dynamic hub-policy catalog (source groups, collapse, stale) ---- */
|
|
1052
|
+
.sm-chevbtn{flex:none;background:none;border:0;padding:0;margin:0;color:inherit;font:inherit;font-size:11px;opacity:.6;cursor:pointer;line-height:1}
|
|
1053
|
+
.sm-chevbtn:hover{opacity:1}
|
|
1054
|
+
.sm-desc{flex:1 1 100%;font-size:11px;line-height:1.5;opacity:.58;word-break:break-word;margin-top:2px}
|
|
1055
|
+
.sm-warnbox{margin-top:6px;padding:6px 9px;border:1px solid var(--dsw-alias-state-warning-primary,#e8a33d);border-radius:8px;font-size:11px;line-height:1.5;color:var(--dsw-alias-state-warning-primary,#e8a33d);word-break:break-word}
|
|
1056
|
+
|
|
1057
|
+
/* ---- R19: global workspace selector, in-panel chat, memory modal ---- */
|
|
1058
|
+
.sm-ws{display:inline-flex;align-items:center;gap:5px;font-size:11px;opacity:.9;min-width:0}
|
|
1059
|
+
.sm-ws-select{max-width:280px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));border-radius:999px;background:transparent;color:inherit;font-size:11px;padding:2px 7px;font-family:inherit}
|
|
1060
|
+
.sm-ws-select:focus{outline:none;border-color:var(--dsw-alias-link,#7aaaff)}
|
|
1061
|
+
.sm-chat{display:flex;flex-direction:column;gap:8px}
|
|
1062
|
+
.sm-chat-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding-bottom:8px;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1));margin-bottom:4px}
|
|
1063
|
+
.sm-msg{display:flex;flex-direction:column;gap:2px;padding:8px 10px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1));border-radius:10px;background:var(--dsw-alias-bg-layer-1,#1f1f21)}
|
|
1064
|
+
.sm-msg[data-role="user"]{border-color:color-mix(in srgb,var(--dsw-alias-link,#7aaaff) 45%,transparent);background:color-mix(in srgb,var(--dsw-alias-link,#7aaaff) 7%,transparent)}
|
|
1065
|
+
.sm-msg[data-role="tool"]{opacity:.72}
|
|
1066
|
+
.sm-msg-role{font-size:10px;opacity:.55;letter-spacing:.04em}
|
|
1067
|
+
.sm-msg-text{white-space:pre-wrap;word-break:break-word;font-size:12.5px;line-height:1.6}
|
|
1068
|
+
.sm-msg[data-role="tool"] .sm-msg-text{font-size:11px;font-family:ui-monospace,SFMono-Regular,Consolas,monospace}
|
|
1069
|
+
.sm-chat-bar{display:flex;align-items:flex-end;gap:8px;margin-top:8px}
|
|
1070
|
+
.sm-chat-bar textarea{flex:1;min-height:60px;padding:8px 10px;border-radius:10px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));background:var(--dsw-specific-input-major,#2c2c2e);color:inherit;font-family:inherit;font-size:12.5px;resize:vertical;line-height:1.5}
|
|
1071
|
+
.sm-chat-bar textarea:focus{outline:none;border-color:var(--dsw-alias-link,#7aaaff)}
|
|
1072
|
+
.sm-modal-backdrop{position:fixed;inset:0;z-index:80;display:flex;align-items:center;justify-content:center;padding:24px;background:rgba(0,0,0,.52)}
|
|
1073
|
+
.sm-modal{width:min(560px,100%);max-height:82vh;overflow:auto;padding:14px;border:1px solid var(--dsw-alias-border-l1,rgba(255,255,255,.2));border-radius:12px;background:var(--dsw-alias-bg-layer-1,#1f1f21);box-shadow:0 18px 48px rgba(0,0,0,.4)}
|
|
1074
|
+
.sm-modal h3{margin:0 0 10px;font-size:14px;font-weight:650}
|
|
1075
|
+
.sm-modal-hint{font-size:11px;opacity:.58;line-height:1.55;margin:-4px 0 10px}
|
|
1076
|
+
|
|
1077
|
+
/* ---- narrow windows: the rail folds into a horizontal strip ---- */
|
|
1078
|
+
@media (max-width:760px){
|
|
1079
|
+
.sm-shell{flex-direction:column}
|
|
1080
|
+
.sm-side{width:auto;flex:none;flex-direction:row;align-items:center;gap:8px;padding:8px;border-right:none;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.1));overflow:hidden}
|
|
1081
|
+
.sm-side-head{padding:0;white-space:nowrap}
|
|
1082
|
+
.sm-side-count{display:none}
|
|
1083
|
+
.sm-side-list{flex-direction:row;overflow-x:auto;overflow-y:hidden;gap:6px;min-width:0}
|
|
1084
|
+
.sm-hub{width:auto;max-width:180px;flex:none}
|
|
1085
|
+
.sm-side-foot{margin:0;padding:0;border:none;flex:none}
|
|
1086
|
+
.sm-newhub{width:auto;white-space:nowrap}
|
|
1087
|
+
.sm-body{padding:10px 12px 16px}
|
|
1088
|
+
}
|
|
1089
|
+
`;
|
|
1090
|
+
let cssInstalled$1 = false;
|
|
1091
|
+
function installCss$1() {
|
|
1092
|
+
if (cssInstalled$1 || typeof document === "undefined") return;
|
|
1093
|
+
cssInstalled$1 = true;
|
|
1094
|
+
const style = document.createElement("style");
|
|
1095
|
+
style.setAttribute("data-plugin", "dsh-supermemory");
|
|
1096
|
+
style.textContent = PANEL_CSS;
|
|
1097
|
+
document.head.append(style);
|
|
1098
|
+
}
|
|
1099
|
+
function Button(props) {
|
|
1100
|
+
return (0, react.createElement)("button", {
|
|
1101
|
+
type: "button",
|
|
1102
|
+
className: ["sm-btn", props.className].filter(Boolean).join(" "),
|
|
1103
|
+
"data-variant": props.variant,
|
|
1104
|
+
"data-size": props.size,
|
|
1105
|
+
disabled: props.disabled,
|
|
1106
|
+
title: props.title,
|
|
1107
|
+
onClick: props.onClick
|
|
1108
|
+
}, props.label);
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* R18 需求⑥: illustration-style empty state. A tiny inline SVG (drawn with the
|
|
1112
|
+
* theme's own label colour) replaces the bare "暂无" line everywhere.
|
|
1113
|
+
*/
|
|
1114
|
+
function EmptyState(props) {
|
|
1115
|
+
return (0, react.createElement)("div", { className: "sm-empty" }, (0, react.createElement)("svg", {
|
|
1116
|
+
key: "art",
|
|
1117
|
+
className: "sm-empty-art",
|
|
1118
|
+
width: 48,
|
|
1119
|
+
height: 48,
|
|
1120
|
+
viewBox: "0 0 48 48",
|
|
1121
|
+
fill: "none",
|
|
1122
|
+
stroke: "currentColor",
|
|
1123
|
+
strokeWidth: 1.6,
|
|
1124
|
+
strokeLinecap: "round",
|
|
1125
|
+
strokeLinejoin: "round",
|
|
1126
|
+
"aria-hidden": true,
|
|
1127
|
+
focusable: false
|
|
1128
|
+
}, (0, react.createElement)("rect", {
|
|
1129
|
+
key: "a",
|
|
1130
|
+
x: 9,
|
|
1131
|
+
y: 13,
|
|
1132
|
+
width: 30,
|
|
1133
|
+
height: 23,
|
|
1134
|
+
rx: 4
|
|
1135
|
+
}), (0, react.createElement)("path", {
|
|
1136
|
+
key: "b",
|
|
1137
|
+
d: "M9 20h30"
|
|
1138
|
+
}), (0, react.createElement)("circle", {
|
|
1139
|
+
key: "c",
|
|
1140
|
+
cx: 15,
|
|
1141
|
+
cy: 17,
|
|
1142
|
+
r: 1.4,
|
|
1143
|
+
fill: "currentColor",
|
|
1144
|
+
stroke: "none"
|
|
1145
|
+
}), (0, react.createElement)("path", {
|
|
1146
|
+
key: "d",
|
|
1147
|
+
d: "M16 27h12"
|
|
1148
|
+
}), (0, react.createElement)("path", {
|
|
1149
|
+
key: "e",
|
|
1150
|
+
d: "M16 31h8"
|
|
1151
|
+
})), (0, react.createElement)("div", {
|
|
1152
|
+
key: "label",
|
|
1153
|
+
className: "sm-empty-label"
|
|
1154
|
+
}, props.label), props.hint ? (0, react.createElement)("div", {
|
|
1155
|
+
key: "hint",
|
|
1156
|
+
className: "sm-empty-hint"
|
|
1157
|
+
}, props.hint) : null);
|
|
1158
|
+
}
|
|
1159
|
+
/** R19 协同②: coarse relative time for branch cards, localized (no date lib). */
|
|
1160
|
+
function branchAgo(at, t) {
|
|
1161
|
+
if (!Number.isFinite(at) || at <= 0) return "—";
|
|
1162
|
+
const delta = Math.max(0, Date.now() - at);
|
|
1163
|
+
if (delta < 6e4) return t("branches.ago.just");
|
|
1164
|
+
if (delta < 36e5) return t("branches.ago.min", { count: Math.floor(delta / 6e4) });
|
|
1165
|
+
if (delta < 864e5) return t("branches.ago.hour", { count: Math.floor(delta / 36e5) });
|
|
1166
|
+
return t("branches.ago.day", { count: Math.floor(delta / 864e5) });
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* R28 需求②: local YYYY-MM-DD HH:mm for the capability lifecycle timestamps
|
|
1170
|
+
* (增加时间 / 最后使用). A missing or nonsensical value renders '—' — the host
|
|
1171
|
+
* ships these fields from R28 on, older hosts simply leave them undefined.
|
|
1172
|
+
*/
|
|
1173
|
+
function fmtTime(at) {
|
|
1174
|
+
if (at === void 0 || !Number.isFinite(at) || at <= 0) return "—";
|
|
1175
|
+
const date = new Date(at);
|
|
1176
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
1177
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* R19 协同②: the hub's linked branches. One card, every consumer (hub tab and
|
|
1181
|
+
* the in-panel chat of a hub) passes its own rows; a branch row opens that
|
|
1182
|
+
* branch's conversation in the panel.
|
|
1183
|
+
*/
|
|
1184
|
+
function BranchList(props) {
|
|
1185
|
+
const rows = Array.isArray(props.rows) ? props.rows : [];
|
|
1186
|
+
const { t, onOpen } = props;
|
|
1187
|
+
return (0, react.createElement)("div", {
|
|
1188
|
+
key: "branches",
|
|
1189
|
+
className: "sm-card"
|
|
1190
|
+
}, (0, react.createElement)("div", {
|
|
1191
|
+
key: "head",
|
|
1192
|
+
className: "sm-row"
|
|
1193
|
+
}, (0, react.createElement)("h3", { key: "title" }, t("branches.title")), (0, react.createElement)("span", {
|
|
1194
|
+
key: "count",
|
|
1195
|
+
className: "sm-badge"
|
|
1196
|
+
}, String(rows.length))), rows.length === 0 ? (0, react.createElement)(EmptyState, {
|
|
1197
|
+
key: "empty",
|
|
1198
|
+
label: t("branches.empty"),
|
|
1199
|
+
hint: props.compact ? void 0 : t("branches.empty.hint")
|
|
1200
|
+
}) : (0, react.createElement)("div", {
|
|
1201
|
+
key: "list",
|
|
1202
|
+
className: "sm-list"
|
|
1203
|
+
}, rows.map((row) => (0, react.createElement)("div", {
|
|
1204
|
+
key: row.branchSessionId,
|
|
1205
|
+
className: "sm-item",
|
|
1206
|
+
"data-clickable": "true",
|
|
1207
|
+
title: `${row.title} · ${row.branchSessionId}`,
|
|
1208
|
+
onClick: () => onOpen(row.branchSessionId)
|
|
1209
|
+
}, (0, react.createElement)("div", {
|
|
1210
|
+
key: "row",
|
|
1211
|
+
className: "sm-row"
|
|
1212
|
+
}, (0, react.createElement)("span", {
|
|
1213
|
+
key: "title",
|
|
1214
|
+
className: "sm-title"
|
|
1215
|
+
}, row.title), (0, react.createElement)("span", {
|
|
1216
|
+
key: "state",
|
|
1217
|
+
className: "sm-badge",
|
|
1218
|
+
"data-state": row.status
|
|
1219
|
+
}, t(`branches.${row.status}`)), row.shared ? (0, react.createElement)("span", {
|
|
1220
|
+
key: "shared",
|
|
1221
|
+
className: "sm-badge",
|
|
1222
|
+
title: row.hubs.join("、")
|
|
1223
|
+
}, t("branches.shared", { count: row.hubs.length - 1 })) : null, row.groupId ? (0, react.createElement)("span", {
|
|
1224
|
+
key: "grp",
|
|
1225
|
+
className: "sm-badge"
|
|
1226
|
+
}, t("branches.group")) : null), (0, react.createElement)("div", {
|
|
1227
|
+
key: "meta",
|
|
1228
|
+
className: "sm-sub"
|
|
1229
|
+
}, `${row.topicSetTitle ? t("branches.set", { title: row.topicSetTitle }) : t("branches.noSet")} · ${branchAgo(row.lastActivityAt, t)} · ${t("branches.dispatches", { count: row.dispatches })}`), row.tags && row.tags.length > 0 ? tagChips(row.tags) : null, (0, react.createElement)("div", {
|
|
1230
|
+
key: "id",
|
|
1231
|
+
className: "sm-sub"
|
|
1232
|
+
}, row.branchSessionId)))));
|
|
1233
|
+
}
|
|
1234
|
+
/** Tag chips: the record's index fields, rendered beside the title. */
|
|
1235
|
+
function tagChips(tags, needle = "") {
|
|
1236
|
+
const list = (tags ?? []).filter(Boolean);
|
|
1237
|
+
if (list.length === 0) return null;
|
|
1238
|
+
const lowered = needle.trim().toLowerCase();
|
|
1239
|
+
return (0, react.createElement)("div", { className: "sm-tags" }, list.map((tag) => (0, react.createElement)("span", {
|
|
1240
|
+
key: tag,
|
|
1241
|
+
className: "sm-tag",
|
|
1242
|
+
"data-hit": String(lowered.length > 0 && tag.toLowerCase().includes(lowered)),
|
|
1243
|
+
title: tag
|
|
1244
|
+
}, tag)));
|
|
1245
|
+
}
|
|
1246
|
+
/** Split a tag input ("a,b c" / "a,b") into the array the host expects. */
|
|
1247
|
+
function splitTags(raw) {
|
|
1248
|
+
return String(raw ?? "").split(/[,,、;;\s]+/).map((tag) => tag.trim()).filter(Boolean);
|
|
1249
|
+
}
|
|
1250
|
+
/** Client-side title fallback for records written before titles existed. */
|
|
1251
|
+
function deriveTitleClient(body) {
|
|
1252
|
+
const clean = String(body ?? "").replace(/\s+/g, " ").trim();
|
|
1253
|
+
if (!clean) return "";
|
|
1254
|
+
const clause = clean.split(/[。!?;;.!?]/)[0]?.trim() || clean;
|
|
1255
|
+
return clause.length <= 48 ? clause : `${clause.slice(0, 47)}…`;
|
|
1256
|
+
}
|
|
1257
|
+
/** The SuperMemory main panel page. */
|
|
1258
|
+
function SupermemoryPanelPage(props) {
|
|
1259
|
+
installCss$1();
|
|
1260
|
+
const { t, api } = props;
|
|
1261
|
+
const [view, setView] = (0, react.useState)({ kind: "hub" });
|
|
1262
|
+
const [hub, setHub] = (0, react.useState)();
|
|
1263
|
+
const [memoryCollections, setMemoryCollections] = (0, react.useState)([]);
|
|
1264
|
+
const [collectionMemories, setCollectionMemories] = (0, react.useState)([]);
|
|
1265
|
+
const [memoryDetail, setMemoryDetail] = (0, react.useState)();
|
|
1266
|
+
const [hubPolicy, setHubPolicy] = (0, react.useState)();
|
|
1267
|
+
const [hubPolicyDraft, setHubPolicyDraft] = (0, react.useState)();
|
|
1268
|
+
const [hubPolicyCustom, setHubPolicyCustom] = (0, react.useState)("");
|
|
1269
|
+
const [hubPolicyQuery, setHubPolicyQuery] = (0, react.useState)("");
|
|
1270
|
+
const [hubPolicyCollapsed, setHubPolicyCollapsed] = (0, react.useState)([]);
|
|
1271
|
+
const [modelDefaults, setModelDefaults] = (0, react.useState)();
|
|
1272
|
+
const [hubModelDraft, setHubModelDraft] = (0, react.useState)("");
|
|
1273
|
+
const [skills, setSkills] = (0, react.useState)([]);
|
|
1274
|
+
const [skillDrafts, setSkillDrafts] = (0, react.useState)({});
|
|
1275
|
+
const [branchModelDraft, setBranchModelDraft] = (0, react.useState)("");
|
|
1276
|
+
const [tools, setTools] = (0, react.useState)([]);
|
|
1277
|
+
const [loading, setLoading] = (0, react.useState)(false);
|
|
1278
|
+
const [error, setError] = (0, react.useState)();
|
|
1279
|
+
const [notice, setNotice] = (0, react.useState)();
|
|
1280
|
+
const [query, setQuery] = (0, react.useState)("");
|
|
1281
|
+
const [memoryQuery, setMemoryQuery] = (0, react.useState)("");
|
|
1282
|
+
const [setsQuery, setSetsQuery] = (0, react.useState)("");
|
|
1283
|
+
const [reply, setReply] = (0, react.useState)("");
|
|
1284
|
+
const [summaryDraft, setSummaryDraft] = (0, react.useState)();
|
|
1285
|
+
const [summaryTagsDraft, setSummaryTagsDraft] = (0, react.useState)();
|
|
1286
|
+
const [editingMemory, setEditingMemory] = (0, react.useState)();
|
|
1287
|
+
const [editingTool, setEditingTool] = (0, react.useState)();
|
|
1288
|
+
const [confirmDeleteTool, setConfirmDeleteTool] = (0, react.useState)();
|
|
1289
|
+
const [expandedTool, setExpandedTool] = (0, react.useState)();
|
|
1290
|
+
const [confirmDeleteMemory, setConfirmDeleteMemory] = (0, react.useState)();
|
|
1291
|
+
const [expandedVersion, setExpandedVersion] = (0, react.useState)();
|
|
1292
|
+
const [presets, setPresets] = (0, react.useState)([]);
|
|
1293
|
+
const [catalog, setCatalog] = (0, react.useState)();
|
|
1294
|
+
const [permissions, setPermissions] = (0, react.useState)();
|
|
1295
|
+
const [workspacePath, setWorkspacePath] = (0, react.useState)("");
|
|
1296
|
+
const [launchPreset, setLaunchPreset] = (0, react.useState)("");
|
|
1297
|
+
const [launchModel, setLaunchModel] = (0, react.useState)("");
|
|
1298
|
+
const [launchPermission, setLaunchPermission] = (0, react.useState)("");
|
|
1299
|
+
const [launchSets, setLaunchSets] = (0, react.useState)([]);
|
|
1300
|
+
const [launchSelected, setLaunchSelected] = (0, react.useState)([]);
|
|
1301
|
+
const [launchNewTitle, setLaunchNewTitle] = (0, react.useState)("");
|
|
1302
|
+
const [launching, setLaunching] = (0, react.useState)(false);
|
|
1303
|
+
const [composerText, setComposerText] = (0, react.useState)("");
|
|
1304
|
+
const [showNewSet, setShowNewSet] = (0, react.useState)(false);
|
|
1305
|
+
const [receipt, setReceipt] = (0, react.useState)();
|
|
1306
|
+
const [hubs, setHubs] = (0, react.useState)([]);
|
|
1307
|
+
const [hubBranches, setHubBranches] = (0, react.useState)([]);
|
|
1308
|
+
const [chatBranches, setChatBranches] = (0, react.useState)([]);
|
|
1309
|
+
const [allSets, setAllSets] = (0, react.useState)([]);
|
|
1310
|
+
const [allBranches, setAllBranches] = (0, react.useState)([]);
|
|
1311
|
+
const [branchFilter, setBranchFilter] = (0, react.useState)("");
|
|
1312
|
+
const [branchQuery, setBranchQuery] = (0, react.useState)("");
|
|
1313
|
+
const [createdSet, setCreatedSet] = (0, react.useState)();
|
|
1314
|
+
const [chatData, setChatData] = (0, react.useState)();
|
|
1315
|
+
const [chatDraft, setChatDraft] = (0, react.useState)("");
|
|
1316
|
+
const [chatSending, setChatSending] = (0, react.useState)(false);
|
|
1317
|
+
const [chatError, setChatError] = (0, react.useState)();
|
|
1318
|
+
const workspaces = props.useWorkspaces((state) => state.items);
|
|
1319
|
+
const sessionId = props.useSessions((state) => {
|
|
1320
|
+
for (const session of Object.values(state.byId)) if ((session.retainedBy?.mainView ?? 0) > 0) return session.id;
|
|
1321
|
+
return "";
|
|
1322
|
+
});
|
|
1323
|
+
const sessionCwd = props.useSessions((state) => {
|
|
1324
|
+
for (const session of Object.values(state.byId)) if ((session.retainedBy?.mainView ?? 0) > 0) return String(session.header?.cwd ?? "");
|
|
1325
|
+
return "";
|
|
1326
|
+
});
|
|
1327
|
+
const cwd = (0, react.useMemo)(() => workspacePath || sessionCwd || workspaces[0]?.path || "", [
|
|
1328
|
+
workspacePath,
|
|
1329
|
+
sessionCwd,
|
|
1330
|
+
workspaces
|
|
1331
|
+
]);
|
|
1332
|
+
(0, react.useEffect)(() => {
|
|
1333
|
+
if (workspacePath) {
|
|
1334
|
+
if (workspaces.length === 0 || workspaces.some((workspace) => workspace.path === workspacePath)) return;
|
|
1335
|
+
}
|
|
1336
|
+
let remembered = "";
|
|
1337
|
+
try {
|
|
1338
|
+
remembered = localStorage.getItem("sm-panel-ws") || "";
|
|
1339
|
+
} catch {}
|
|
1340
|
+
const known = (path) => workspaces.length === 0 || workspaces.some((workspace) => workspace.path === path);
|
|
1341
|
+
const next = remembered && known(remembered) ? remembered : sessionCwd || workspaces[0]?.path || "";
|
|
1342
|
+
if (next) setWorkspacePath(next);
|
|
1343
|
+
}, [
|
|
1344
|
+
sessionCwd,
|
|
1345
|
+
workspacePath,
|
|
1346
|
+
workspaces
|
|
1347
|
+
]);
|
|
1348
|
+
const [lastSessionCwd, setLastSessionCwd] = (0, react.useState)("");
|
|
1349
|
+
(0, react.useEffect)(() => {
|
|
1350
|
+
if (!sessionCwd) return;
|
|
1351
|
+
if (lastSessionCwd && lastSessionCwd !== sessionCwd) setWorkspacePath(sessionCwd);
|
|
1352
|
+
if (sessionCwd !== lastSessionCwd) setLastSessionCwd(sessionCwd);
|
|
1353
|
+
}, [sessionCwd, lastSessionCwd]);
|
|
1354
|
+
/** Switch the panel's one workspace and reset every workspace-scoped view. */
|
|
1355
|
+
const changeWorkspace = (0, react.useCallback)((path) => {
|
|
1356
|
+
if (!path || path === workspacePath) return;
|
|
1357
|
+
setWorkspacePath(path);
|
|
1358
|
+
try {
|
|
1359
|
+
localStorage.setItem("sm-panel-ws", path);
|
|
1360
|
+
} catch {}
|
|
1361
|
+
setHub(void 0);
|
|
1362
|
+
setHubs([]);
|
|
1363
|
+
setHubBranches([]);
|
|
1364
|
+
setChatBranches([]);
|
|
1365
|
+
setAllSets([]);
|
|
1366
|
+
setAllBranches([]);
|
|
1367
|
+
setBranchFilter("");
|
|
1368
|
+
setLaunchSelected([]);
|
|
1369
|
+
setLaunchSets([]);
|
|
1370
|
+
setReceipt(void 0);
|
|
1371
|
+
setCreatedSet(void 0);
|
|
1372
|
+
setTools([]);
|
|
1373
|
+
setMemoryCollections([]);
|
|
1374
|
+
setCollectionMemories([]);
|
|
1375
|
+
setMemoryDetail(void 0);
|
|
1376
|
+
setChatData(void 0);
|
|
1377
|
+
setChatDraft("");
|
|
1378
|
+
setChatError(void 0);
|
|
1379
|
+
setView({ kind: "hub" });
|
|
1380
|
+
}, [workspacePath]);
|
|
1381
|
+
const refreshHub = (0, react.useCallback)(async () => {
|
|
1382
|
+
if (!cwd) return;
|
|
1383
|
+
setLoading(true);
|
|
1384
|
+
setError(void 0);
|
|
1385
|
+
try {
|
|
1386
|
+
const [state, hubRows, branchRows, setRows, allBranchRows] = await Promise.all([
|
|
1387
|
+
api.loadHub(cwd, sessionId),
|
|
1388
|
+
api.listHubSessions(cwd).then((rows) => rows, () => []),
|
|
1389
|
+
sessionId ? api.listHubBranches(cwd, sessionId).then((rows) => rows, () => []) : Promise.resolve([]),
|
|
1390
|
+
api.listAllTopicSets(cwd).then((rows) => rows, () => []),
|
|
1391
|
+
api.listAllBranches(cwd).then((rows) => rows, () => [])
|
|
1392
|
+
]);
|
|
1393
|
+
setHub(state);
|
|
1394
|
+
setHubs(hubRows);
|
|
1395
|
+
setHubBranches(branchRows);
|
|
1396
|
+
setAllSets(setRows);
|
|
1397
|
+
setAllBranches(allBranchRows);
|
|
1398
|
+
api.invalidateBadges();
|
|
1399
|
+
} catch (loadError) {
|
|
1400
|
+
setError(`${t("error.load")}: ${String(loadError instanceof Error ? loadError.message : loadError)}`);
|
|
1401
|
+
} finally {
|
|
1402
|
+
setLoading(false);
|
|
1403
|
+
}
|
|
1404
|
+
}, [
|
|
1405
|
+
api,
|
|
1406
|
+
cwd,
|
|
1407
|
+
sessionId,
|
|
1408
|
+
t
|
|
1409
|
+
]);
|
|
1410
|
+
const refreshMemoryCollections = (0, react.useCallback)(async () => {
|
|
1411
|
+
if (!cwd) return;
|
|
1412
|
+
try {
|
|
1413
|
+
setMemoryCollections(await api.listMemoryCollections(cwd));
|
|
1414
|
+
} catch (loadError) {
|
|
1415
|
+
setError(`${t("error.load")}: ${String(loadError instanceof Error ? loadError.message : loadError)}`);
|
|
1416
|
+
}
|
|
1417
|
+
}, [
|
|
1418
|
+
api,
|
|
1419
|
+
cwd,
|
|
1420
|
+
t
|
|
1421
|
+
]);
|
|
1422
|
+
const refreshCollectionMemories = (0, react.useCallback)(async (collectionId) => {
|
|
1423
|
+
if (!cwd) return;
|
|
1424
|
+
try {
|
|
1425
|
+
setCollectionMemories(await api.listMemoriesByCollection(cwd, collectionId, query.trim() || void 0));
|
|
1426
|
+
} catch (loadError) {
|
|
1427
|
+
setError(`${t("error.load")}: ${String(loadError instanceof Error ? loadError.message : loadError)}`);
|
|
1428
|
+
}
|
|
1429
|
+
}, [
|
|
1430
|
+
api,
|
|
1431
|
+
cwd,
|
|
1432
|
+
query,
|
|
1433
|
+
t
|
|
1434
|
+
]);
|
|
1435
|
+
const refreshMemoryDetail = (0, react.useCallback)(async (id) => {
|
|
1436
|
+
if (!cwd) return;
|
|
1437
|
+
try {
|
|
1438
|
+
setMemoryDetail(await api.getMemoryDetail(cwd, id));
|
|
1439
|
+
} catch (loadError) {
|
|
1440
|
+
setError(`${t("error.load")}: ${String(loadError instanceof Error ? loadError.message : loadError)}`);
|
|
1441
|
+
}
|
|
1442
|
+
}, [
|
|
1443
|
+
api,
|
|
1444
|
+
cwd,
|
|
1445
|
+
t
|
|
1446
|
+
]);
|
|
1447
|
+
const refreshModelDefaults = (0, react.useCallback)(async () => {
|
|
1448
|
+
if (!cwd) return;
|
|
1449
|
+
try {
|
|
1450
|
+
const view = await api.getModelDefaults(cwd);
|
|
1451
|
+
setModelDefaults(view);
|
|
1452
|
+
setHubModelDraft(view.hub ? `${view.hub.provider}/${view.hub.model}` : "");
|
|
1453
|
+
setBranchModelDraft(view.branch ? `${view.branch.provider}/${view.branch.model}` : "");
|
|
1454
|
+
} catch (loadError) {
|
|
1455
|
+
setError(`${t("error.load")}: ${String(loadError instanceof Error ? loadError.message : loadError)}`);
|
|
1456
|
+
}
|
|
1457
|
+
}, [
|
|
1458
|
+
api,
|
|
1459
|
+
cwd,
|
|
1460
|
+
t
|
|
1461
|
+
]);
|
|
1462
|
+
const refreshSkills = (0, react.useCallback)(async () => {
|
|
1463
|
+
if (!cwd) return;
|
|
1464
|
+
try {
|
|
1465
|
+
const rows = await api.listSkills(cwd);
|
|
1466
|
+
setSkills(rows);
|
|
1467
|
+
setSkillDrafts(Object.fromEntries(rows.map((row) => [row.name, row.description])));
|
|
1468
|
+
} catch (loadError) {
|
|
1469
|
+
setError(`${t("error.load")}: ${String(loadError instanceof Error ? loadError.message : loadError)}`);
|
|
1470
|
+
}
|
|
1471
|
+
}, [
|
|
1472
|
+
api,
|
|
1473
|
+
cwd,
|
|
1474
|
+
t
|
|
1475
|
+
]);
|
|
1476
|
+
const refreshHubPolicy = (0, react.useCallback)(async () => {
|
|
1477
|
+
if (!cwd) return;
|
|
1478
|
+
try {
|
|
1479
|
+
const view = await api.getHubPolicy(cwd);
|
|
1480
|
+
setHubPolicy(view);
|
|
1481
|
+
setHubPolicyDraft({
|
|
1482
|
+
tools: [...view.tools],
|
|
1483
|
+
prefixes: [...view.prefixes]
|
|
1484
|
+
});
|
|
1485
|
+
setHubPolicyCustom("");
|
|
1486
|
+
} catch (loadError) {
|
|
1487
|
+
setError(`${t("error.load")}: ${String(loadError instanceof Error ? loadError.message : loadError)}`);
|
|
1488
|
+
}
|
|
1489
|
+
}, [
|
|
1490
|
+
api,
|
|
1491
|
+
cwd,
|
|
1492
|
+
t
|
|
1493
|
+
]);
|
|
1494
|
+
const refreshHubPolicyCatalog = (0, react.useCallback)(async () => {
|
|
1495
|
+
if (!cwd) return;
|
|
1496
|
+
try {
|
|
1497
|
+
const view = await api.getHubPolicy(cwd);
|
|
1498
|
+
setHubPolicy(view);
|
|
1499
|
+
setHubPolicyDraft((draft) => draft ?? {
|
|
1500
|
+
tools: [...view.tools],
|
|
1501
|
+
prefixes: [...view.prefixes]
|
|
1502
|
+
});
|
|
1503
|
+
} catch (loadError) {
|
|
1504
|
+
setError(`${t("error.load")}: ${String(loadError instanceof Error ? loadError.message : loadError)}`);
|
|
1505
|
+
}
|
|
1506
|
+
}, [
|
|
1507
|
+
api,
|
|
1508
|
+
cwd,
|
|
1509
|
+
t
|
|
1510
|
+
]);
|
|
1511
|
+
const refreshMemoryViews = (0, react.useCallback)(() => {
|
|
1512
|
+
if (view.kind === "memory-collection") refreshCollectionMemories(view.id);
|
|
1513
|
+
else if (view.kind === "memory-detail") refreshMemoryDetail(view.id);
|
|
1514
|
+
else refreshMemoryCollections();
|
|
1515
|
+
refreshHub();
|
|
1516
|
+
}, [
|
|
1517
|
+
view,
|
|
1518
|
+
refreshCollectionMemories,
|
|
1519
|
+
refreshMemoryDetail,
|
|
1520
|
+
refreshMemoryCollections,
|
|
1521
|
+
refreshHub
|
|
1522
|
+
]);
|
|
1523
|
+
const openMemoryDetail = (0, react.useCallback)((id) => {
|
|
1524
|
+
setExpandedVersion(void 0);
|
|
1525
|
+
setMemoryDetail(void 0);
|
|
1526
|
+
setView({
|
|
1527
|
+
kind: "memory-detail",
|
|
1528
|
+
id
|
|
1529
|
+
});
|
|
1530
|
+
}, []);
|
|
1531
|
+
const backFromMemoryDetail = (0, react.useCallback)(() => {
|
|
1532
|
+
setExpandedVersion(void 0);
|
|
1533
|
+
setView({
|
|
1534
|
+
kind: "memory-collection",
|
|
1535
|
+
id: memoryDetail?.view.collectionId ?? ""
|
|
1536
|
+
});
|
|
1537
|
+
}, [memoryDetail]);
|
|
1538
|
+
const refreshTools = (0, react.useCallback)(async () => {
|
|
1539
|
+
if (!cwd) return;
|
|
1540
|
+
try {
|
|
1541
|
+
setTools(await api.listTools(cwd));
|
|
1542
|
+
} catch (loadError) {
|
|
1543
|
+
setError(`${t("error.load")}: ${String(loadError instanceof Error ? loadError.message : loadError)}`);
|
|
1544
|
+
}
|
|
1545
|
+
}, [
|
|
1546
|
+
api,
|
|
1547
|
+
cwd,
|
|
1548
|
+
t
|
|
1549
|
+
]);
|
|
1550
|
+
(0, react.useEffect)(() => {
|
|
1551
|
+
refreshHub();
|
|
1552
|
+
}, [refreshHub]);
|
|
1553
|
+
(0, react.useEffect)(() => {
|
|
1554
|
+
if (view.kind === "memories") refreshMemoryCollections();
|
|
1555
|
+
}, [view, refreshMemoryCollections]);
|
|
1556
|
+
(0, react.useEffect)(() => {
|
|
1557
|
+
if (view.kind === "memory-collection") refreshCollectionMemories(view.id);
|
|
1558
|
+
}, [view, refreshCollectionMemories]);
|
|
1559
|
+
(0, react.useEffect)(() => {
|
|
1560
|
+
if (view.kind === "memory-detail") refreshMemoryDetail(view.id);
|
|
1561
|
+
}, [view, refreshMemoryDetail]);
|
|
1562
|
+
(0, react.useEffect)(() => {
|
|
1563
|
+
if (view.kind === "settings") {
|
|
1564
|
+
refreshHubPolicy();
|
|
1565
|
+
refreshModelDefaults();
|
|
1566
|
+
refreshSkills();
|
|
1567
|
+
}
|
|
1568
|
+
}, [
|
|
1569
|
+
view,
|
|
1570
|
+
refreshHubPolicy,
|
|
1571
|
+
refreshSkills
|
|
1572
|
+
]);
|
|
1573
|
+
(0, react.useEffect)(() => {
|
|
1574
|
+
if (view.kind === "tools") refreshTools();
|
|
1575
|
+
}, [view, refreshTools]);
|
|
1576
|
+
(0, react.useEffect)(() => {
|
|
1577
|
+
if (view.kind !== "branches" || !cwd) return;
|
|
1578
|
+
if (allBranches.length > 0) return;
|
|
1579
|
+
api.listAllBranches(cwd).then(setAllBranches, () => []);
|
|
1580
|
+
}, [
|
|
1581
|
+
view,
|
|
1582
|
+
cwd,
|
|
1583
|
+
api,
|
|
1584
|
+
allBranches.length
|
|
1585
|
+
]);
|
|
1586
|
+
(0, react.useEffect)(() => {
|
|
1587
|
+
const show = (incoming) => {
|
|
1588
|
+
setView({ kind: "hub" });
|
|
1589
|
+
setReceipt(incoming);
|
|
1590
|
+
refreshHub();
|
|
1591
|
+
};
|
|
1592
|
+
const unsubscribe = subscribeHubReceipt(show);
|
|
1593
|
+
const pending = takePendingHubReceipt();
|
|
1594
|
+
if (pending) show(pending);
|
|
1595
|
+
return unsubscribe;
|
|
1596
|
+
}, [refreshHub]);
|
|
1597
|
+
const loadChat = (0, react.useCallback)(async (id) => {
|
|
1598
|
+
try {
|
|
1599
|
+
const [data, branches] = await Promise.all([api.readSessionMessages(id, 80), cwd ? api.listHubBranches(cwd, id).then((rows) => rows, () => []) : Promise.resolve([])]);
|
|
1600
|
+
setChatData(data);
|
|
1601
|
+
setChatBranches(branches);
|
|
1602
|
+
setChatError(void 0);
|
|
1603
|
+
} catch (loadError) {
|
|
1604
|
+
setChatError(`${t("error.load")}: ${String(loadError instanceof Error ? loadError.message : loadError)}`);
|
|
1605
|
+
}
|
|
1606
|
+
}, [
|
|
1607
|
+
api,
|
|
1608
|
+
cwd,
|
|
1609
|
+
t
|
|
1610
|
+
]);
|
|
1611
|
+
const openChat = (0, react.useCallback)((id) => {
|
|
1612
|
+
setChatData(void 0);
|
|
1613
|
+
setChatDraft("");
|
|
1614
|
+
setChatError(void 0);
|
|
1615
|
+
setView({
|
|
1616
|
+
kind: "chat",
|
|
1617
|
+
id
|
|
1618
|
+
});
|
|
1619
|
+
}, []);
|
|
1620
|
+
(0, react.useEffect)(() => {
|
|
1621
|
+
if (view.kind !== "chat") return;
|
|
1622
|
+
const id = view.id;
|
|
1623
|
+
loadChat(id);
|
|
1624
|
+
const timer = setInterval(() => {
|
|
1625
|
+
if (typeof document === "undefined" || !document.hidden) loadChat(id);
|
|
1626
|
+
}, 2500);
|
|
1627
|
+
return () => clearInterval(timer);
|
|
1628
|
+
}, [loadChat, view]);
|
|
1629
|
+
const sendChat = async (id) => {
|
|
1630
|
+
const text = chatDraft.trim();
|
|
1631
|
+
if (!text) return;
|
|
1632
|
+
setChatSending(true);
|
|
1633
|
+
setChatError(void 0);
|
|
1634
|
+
try {
|
|
1635
|
+
const result = await api.sendSessionMessage(id, text);
|
|
1636
|
+
if (result.status === "ok") {
|
|
1637
|
+
setChatDraft("");
|
|
1638
|
+
await loadChat(id);
|
|
1639
|
+
} else setChatError(result.message);
|
|
1640
|
+
} catch (sendError) {
|
|
1641
|
+
setChatError(`${t("error.generic")}: ${String(sendError instanceof Error ? sendError.message : sendError)}`);
|
|
1642
|
+
} finally {
|
|
1643
|
+
setChatSending(false);
|
|
1644
|
+
}
|
|
1645
|
+
};
|
|
1646
|
+
(0, react.useEffect)(() => {
|
|
1647
|
+
let alive = true;
|
|
1648
|
+
api.listAgentPresets().then((rows) => {
|
|
1649
|
+
if (alive) setPresets(rows);
|
|
1650
|
+
}, () => {});
|
|
1651
|
+
api.listModelCatalog().then((rows) => {
|
|
1652
|
+
if (alive) setCatalog(rows);
|
|
1653
|
+
}, () => {});
|
|
1654
|
+
api.listPermissions().then((rows) => {
|
|
1655
|
+
if (alive) setPermissions(rows);
|
|
1656
|
+
}, () => {});
|
|
1657
|
+
return () => {
|
|
1658
|
+
alive = false;
|
|
1659
|
+
};
|
|
1660
|
+
}, [api]);
|
|
1661
|
+
(0, react.useEffect)(() => {
|
|
1662
|
+
if (!cwd) return;
|
|
1663
|
+
let alive = true;
|
|
1664
|
+
api.loadTopicSets(cwd).then((rows) => {
|
|
1665
|
+
if (!alive) return;
|
|
1666
|
+
setLaunchSets(rows);
|
|
1667
|
+
setLaunchSelected((current) => current.filter((id) => rows.some((row) => row.id === id)));
|
|
1668
|
+
}, () => {
|
|
1669
|
+
if (alive) setLaunchSets([]);
|
|
1670
|
+
});
|
|
1671
|
+
return () => {
|
|
1672
|
+
alive = false;
|
|
1673
|
+
};
|
|
1674
|
+
}, [api, cwd]);
|
|
1675
|
+
const launchCwd = cwd;
|
|
1676
|
+
const launchCreateSet = async () => {
|
|
1677
|
+
const title = launchNewTitle.trim();
|
|
1678
|
+
if (!title || !launchCwd) return;
|
|
1679
|
+
setError(void 0);
|
|
1680
|
+
try {
|
|
1681
|
+
const created = await api.createTopicSet(launchCwd, title);
|
|
1682
|
+
if (created.status !== "ok" || !created.id) {
|
|
1683
|
+
setError(created.message);
|
|
1684
|
+
return;
|
|
1685
|
+
}
|
|
1686
|
+
const id = created.id;
|
|
1687
|
+
setLaunchNewTitle("");
|
|
1688
|
+
const rows = await api.loadTopicSets(launchCwd);
|
|
1689
|
+
setLaunchSets(rows);
|
|
1690
|
+
setLaunchSelected((current) => current.includes(id) ? current : [...current, id]);
|
|
1691
|
+
const createdRow = rows.find((row) => row.id === id);
|
|
1692
|
+
setCreatedSet(createdRow ? {
|
|
1693
|
+
title: createdRow.title,
|
|
1694
|
+
tags: createdRow.tags
|
|
1695
|
+
} : {
|
|
1696
|
+
title: created.message,
|
|
1697
|
+
tags: []
|
|
1698
|
+
});
|
|
1699
|
+
refreshHub();
|
|
1700
|
+
} catch (createError) {
|
|
1701
|
+
setError(`${t("error.generic")}: ${String(createError instanceof Error ? createError.message : createError)}`);
|
|
1702
|
+
}
|
|
1703
|
+
};
|
|
1704
|
+
/**
|
|
1705
|
+
* 需求②: one click on 「+ 新中枢会话」 (the panel rail) creates the hub session
|
|
1706
|
+
* immediately — no form, no type picker — and renders the same in-place
|
|
1707
|
+
* receipt as the shell's 新建会话 entry.
|
|
1708
|
+
*
|
|
1709
|
+
* Defaults: the panel's current workspace; host defaults for agent preset /
|
|
1710
|
+
* model / permission (no options passed, so the host applies its own);
|
|
1711
|
+
* NO topic set, because a hub session owns none by definition — the dispatch
|
|
1712
|
+
* card still picks the sticky / automatically matched set when dispatching.
|
|
1713
|
+
*/
|
|
1714
|
+
const createHubNow = (0, react.useCallback)(async () => {
|
|
1715
|
+
if (!launchCwd) {
|
|
1716
|
+
setError(t("launch.needWorkspace"));
|
|
1717
|
+
return;
|
|
1718
|
+
}
|
|
1719
|
+
setLaunching(true);
|
|
1720
|
+
setError(void 0);
|
|
1721
|
+
setNotice(void 0);
|
|
1722
|
+
try {
|
|
1723
|
+
const result = await api.createHubSession(launchCwd, {}, "");
|
|
1724
|
+
if (result.status === "ok" && result.id) {
|
|
1725
|
+
setView({ kind: "hub" });
|
|
1726
|
+
setReceipt({
|
|
1727
|
+
id: result.id,
|
|
1728
|
+
message: result.message,
|
|
1729
|
+
kind: "hub"
|
|
1730
|
+
});
|
|
1731
|
+
setComposerText("");
|
|
1732
|
+
refreshHub();
|
|
1733
|
+
} else setError(result.message);
|
|
1734
|
+
} catch (createError) {
|
|
1735
|
+
setError(`${t("error.generic")}: ${String(createError instanceof Error ? createError.message : createError)}`);
|
|
1736
|
+
} finally {
|
|
1737
|
+
setLaunching(false);
|
|
1738
|
+
}
|
|
1739
|
+
}, [
|
|
1740
|
+
api,
|
|
1741
|
+
launchCwd,
|
|
1742
|
+
refreshHub,
|
|
1743
|
+
t
|
|
1744
|
+
]);
|
|
1745
|
+
const startLaunch = async (mode = "chat") => {
|
|
1746
|
+
if (!launchCwd) {
|
|
1747
|
+
setError(t("launch.needWorkspace"));
|
|
1748
|
+
return;
|
|
1749
|
+
}
|
|
1750
|
+
const text = composerText.trim();
|
|
1751
|
+
if (mode === "chat" && !text) return;
|
|
1752
|
+
setLaunching(true);
|
|
1753
|
+
setError(void 0);
|
|
1754
|
+
setNotice(void 0);
|
|
1755
|
+
try {
|
|
1756
|
+
const options = {};
|
|
1757
|
+
if (launchPreset) options.agentPreset = launchPreset;
|
|
1758
|
+
if (launchModel) {
|
|
1759
|
+
const slash = launchModel.indexOf("/");
|
|
1760
|
+
if (slash > 0) options.model = {
|
|
1761
|
+
provider: launchModel.slice(0, slash),
|
|
1762
|
+
model: launchModel.slice(slash + 1)
|
|
1763
|
+
};
|
|
1764
|
+
}
|
|
1765
|
+
if (launchPermission) options.permission = launchPermission;
|
|
1766
|
+
const ids = launchSelected;
|
|
1767
|
+
const opening = mode === "chat" ? text : "";
|
|
1768
|
+
const result = ids.length > 0 ? await api.createTopicSetSession(launchCwd, ids, options, opening) : await api.createHubSession(launchCwd, options, opening);
|
|
1769
|
+
if (result.status === "ok" && result.id) {
|
|
1770
|
+
setComposerText("");
|
|
1771
|
+
setReceipt({
|
|
1772
|
+
id: result.id,
|
|
1773
|
+
message: result.message,
|
|
1774
|
+
kind: ids.length > 0 ? "sets" : "hub"
|
|
1775
|
+
});
|
|
1776
|
+
refreshHub();
|
|
1777
|
+
} else setError(result.message);
|
|
1778
|
+
} catch (launchError) {
|
|
1779
|
+
setError(`${t("error.generic")}: ${String(launchError instanceof Error ? launchError.message : launchError)}`);
|
|
1780
|
+
} finally {
|
|
1781
|
+
setLaunching(false);
|
|
1782
|
+
}
|
|
1783
|
+
};
|
|
1784
|
+
const filteredBranchRows = (0, react.useMemo)(() => {
|
|
1785
|
+
const needle = branchQuery.trim().toLowerCase();
|
|
1786
|
+
return allBranches.filter((row) => {
|
|
1787
|
+
if (branchFilter && row.topicSetId !== branchFilter) return false;
|
|
1788
|
+
if (!needle) return true;
|
|
1789
|
+
return [
|
|
1790
|
+
row.title,
|
|
1791
|
+
row.branchSessionId,
|
|
1792
|
+
row.topicSetTitle ?? "",
|
|
1793
|
+
...row.tags ?? []
|
|
1794
|
+
].join(" ").toLowerCase().includes(needle);
|
|
1795
|
+
});
|
|
1796
|
+
}, [
|
|
1797
|
+
allBranches,
|
|
1798
|
+
branchFilter,
|
|
1799
|
+
branchQuery
|
|
1800
|
+
]);
|
|
1801
|
+
const filteredSets = (0, react.useMemo)(() => {
|
|
1802
|
+
const needle = setsQuery.trim().toLowerCase();
|
|
1803
|
+
const rows = hub?.topicSets ?? [];
|
|
1804
|
+
if (!needle) return rows;
|
|
1805
|
+
const inIndex = (topicSet) => topicSet.title.toLowerCase().includes(needle) || topicSet.tags.some((tag) => tag.toLowerCase().includes(needle));
|
|
1806
|
+
return [...rows.filter(inIndex), ...rows.filter((topicSet) => !inIndex(topicSet) && topicSet.summary.toLowerCase().includes(needle))];
|
|
1807
|
+
}, [hub, setsQuery]);
|
|
1808
|
+
const currentTopicSet = view.kind === "topic" ? hub?.topicSets.find((topicSet) => topicSet.id === view.id) : void 0;
|
|
1809
|
+
const run = async (action, after) => {
|
|
1810
|
+
setNotice(void 0);
|
|
1811
|
+
setError(void 0);
|
|
1812
|
+
try {
|
|
1813
|
+
const result = await action();
|
|
1814
|
+
if (result === true) {
|
|
1815
|
+
setNotice(t("ok.saved"));
|
|
1816
|
+
after?.();
|
|
1817
|
+
return;
|
|
1818
|
+
}
|
|
1819
|
+
if (result && result.status === "ok") setNotice(result.message);
|
|
1820
|
+
else if (result) setError(result.message);
|
|
1821
|
+
if (result && result.status === "ok") api.invalidateBadges();
|
|
1822
|
+
after?.();
|
|
1823
|
+
} catch (actionError) {
|
|
1824
|
+
setError(`${t("error.generic")}: ${String(actionError instanceof Error ? actionError.message : actionError)}`);
|
|
1825
|
+
}
|
|
1826
|
+
};
|
|
1827
|
+
const tabActive = (kind) => {
|
|
1828
|
+
if (view.kind === kind) return true;
|
|
1829
|
+
if (kind === "hub") return view.kind === "chat";
|
|
1830
|
+
if (kind === "sets") return view.kind === "topic";
|
|
1831
|
+
if (kind === "memories") return view.kind === "memory-collection" || view.kind === "memory-detail";
|
|
1832
|
+
return false;
|
|
1833
|
+
};
|
|
1834
|
+
const tabProps = (kind) => ({
|
|
1835
|
+
"data-active": String(tabActive(kind)),
|
|
1836
|
+
className: "sm-tab",
|
|
1837
|
+
onClick: () => setView(kind === "hub" ? { kind: "hub" } : kind === "sets" ? { kind: "sets" } : kind === "branches" ? { kind: "branches" } : kind === "memories" ? { kind: "memories" } : kind === "settings" ? { kind: "settings" } : { kind: "tools" })
|
|
1838
|
+
});
|
|
1839
|
+
const hubView = [
|
|
1840
|
+
(0, react.createElement)("div", {
|
|
1841
|
+
key: "composer",
|
|
1842
|
+
className: "sm-card sm-dispatch"
|
|
1843
|
+
}, (0, react.createElement)("div", {
|
|
1844
|
+
key: "head",
|
|
1845
|
+
className: "sm-row"
|
|
1846
|
+
}, (0, react.createElement)("h3", { key: "title" }, t("composer.title")), (0, react.createElement)("span", {
|
|
1847
|
+
key: "desc",
|
|
1848
|
+
className: "sm-muted"
|
|
1849
|
+
}, t("composer.desc"))), (0, react.createElement)("textarea", {
|
|
1850
|
+
key: "input",
|
|
1851
|
+
className: "sm-textarea",
|
|
1852
|
+
rows: 3,
|
|
1853
|
+
value: composerText,
|
|
1854
|
+
placeholder: t("composer.placeholder"),
|
|
1855
|
+
onChange: (event) => setComposerText(event.target.value),
|
|
1856
|
+
onKeyDown: (event) => {
|
|
1857
|
+
if (event.key === "Enter" && (event.ctrlKey || event.metaKey)) {
|
|
1858
|
+
event.preventDefault();
|
|
1859
|
+
startLaunch("chat");
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
}), (0, react.createElement)("div", {
|
|
1863
|
+
key: "opts",
|
|
1864
|
+
className: "sm-composer-opts"
|
|
1865
|
+
}, (0, react.createElement)("label", {
|
|
1866
|
+
key: "ws",
|
|
1867
|
+
className: "sm-opt"
|
|
1868
|
+
}, (0, react.createElement)("span", {
|
|
1869
|
+
key: "label",
|
|
1870
|
+
className: "sm-opt-label"
|
|
1871
|
+
}, t("launch.workspace")), (0, react.createElement)("select", {
|
|
1872
|
+
key: "select",
|
|
1873
|
+
className: "sm-opt-select",
|
|
1874
|
+
value: launchCwd,
|
|
1875
|
+
onChange: (event) => changeWorkspace(event.target.value)
|
|
1876
|
+
}, workspaces.length === 0 ? (0, react.createElement)("option", {
|
|
1877
|
+
key: "current",
|
|
1878
|
+
value: launchCwd
|
|
1879
|
+
}, launchCwd || "—") : [...launchCwd && !workspaces.some((workspace) => workspace.path === launchCwd) ? [(0, react.createElement)("option", {
|
|
1880
|
+
key: "current",
|
|
1881
|
+
value: launchCwd
|
|
1882
|
+
}, launchCwd)] : [], ...workspaces.map((workspace) => (0, react.createElement)("option", {
|
|
1883
|
+
key: workspace.id,
|
|
1884
|
+
value: workspace.path
|
|
1885
|
+
}, workspace.title || workspace.path))])), (0, react.createElement)("label", {
|
|
1886
|
+
key: "preset",
|
|
1887
|
+
className: "sm-opt"
|
|
1888
|
+
}, (0, react.createElement)("span", {
|
|
1889
|
+
key: "label",
|
|
1890
|
+
className: "sm-opt-label"
|
|
1891
|
+
}, t("launch.preset")), (0, react.createElement)("select", {
|
|
1892
|
+
key: "select",
|
|
1893
|
+
className: "sm-opt-select",
|
|
1894
|
+
value: launchPreset,
|
|
1895
|
+
onChange: (event) => setLaunchPreset(event.target.value)
|
|
1896
|
+
}, (0, react.createElement)("option", {
|
|
1897
|
+
key: "default",
|
|
1898
|
+
value: ""
|
|
1899
|
+
}, t("launch.default")), presets.map((preset) => (0, react.createElement)("option", {
|
|
1900
|
+
key: preset.id,
|
|
1901
|
+
value: preset.id,
|
|
1902
|
+
title: preset.description || void 0
|
|
1903
|
+
}, (preset.name || preset.id) + (preset.isDefault ? `(${t("launch.defaultMark")})` : ""))))), (0, react.createElement)("label", {
|
|
1904
|
+
key: "model",
|
|
1905
|
+
className: "sm-opt"
|
|
1906
|
+
}, (0, react.createElement)("span", {
|
|
1907
|
+
key: "label",
|
|
1908
|
+
className: "sm-opt-label"
|
|
1909
|
+
}, t("launch.model")), (0, react.createElement)("select", {
|
|
1910
|
+
key: "select",
|
|
1911
|
+
className: "sm-opt-select",
|
|
1912
|
+
value: launchModel,
|
|
1913
|
+
onChange: (event) => setLaunchModel(event.target.value)
|
|
1914
|
+
}, (0, react.createElement)("option", {
|
|
1915
|
+
key: "default",
|
|
1916
|
+
value: ""
|
|
1917
|
+
}, t("launch.default")), (catalog?.models ?? []).map((model) => (0, react.createElement)("option", {
|
|
1918
|
+
key: `${model.provider}/${model.id}`,
|
|
1919
|
+
value: `${model.provider}/${model.id}`,
|
|
1920
|
+
title: model.name || void 0
|
|
1921
|
+
}, `${model.provider}/${model.id}`)))), (0, react.createElement)("label", {
|
|
1922
|
+
key: "permission",
|
|
1923
|
+
className: "sm-opt"
|
|
1924
|
+
}, (0, react.createElement)("span", {
|
|
1925
|
+
key: "label",
|
|
1926
|
+
className: "sm-opt-label"
|
|
1927
|
+
}, t("launch.permission")), (0, react.createElement)("select", {
|
|
1928
|
+
key: "select",
|
|
1929
|
+
className: "sm-opt-select",
|
|
1930
|
+
value: launchPermission,
|
|
1931
|
+
onChange: (event) => setLaunchPermission(event.target.value)
|
|
1932
|
+
}, (0, react.createElement)("option", {
|
|
1933
|
+
key: "default",
|
|
1934
|
+
value: "",
|
|
1935
|
+
title: (permissions?.options ?? []).find((option) => option.value === permissions?.defaultPreset)?.description || void 0
|
|
1936
|
+
}, permissions?.defaultPreset ? `${t("launch.default")}(${permissions.defaultPreset})` : t("launch.default")), (permissions?.options ?? []).map((option) => (0, react.createElement)("option", {
|
|
1937
|
+
key: option.value,
|
|
1938
|
+
value: option.value,
|
|
1939
|
+
title: option.description || void 0
|
|
1940
|
+
}, option.name || option.value))))), (0, react.createElement)("div", {
|
|
1941
|
+
key: "sets",
|
|
1942
|
+
className: "sm-composer-sets"
|
|
1943
|
+
}, (0, react.createElement)("span", {
|
|
1944
|
+
key: "label",
|
|
1945
|
+
className: "sm-opt-label"
|
|
1946
|
+
}, t("launch.sets")), launchSets.length === 0 ? (0, react.createElement)("span", {
|
|
1947
|
+
key: "empty",
|
|
1948
|
+
className: "sm-muted"
|
|
1949
|
+
}, t("composer.setsEmpty")) : launchSets.map((topicSet) => (0, react.createElement)("button", {
|
|
1950
|
+
key: topicSet.id,
|
|
1951
|
+
type: "button",
|
|
1952
|
+
className: "sm-chip",
|
|
1953
|
+
"data-active": String(launchSelected.includes(topicSet.id)),
|
|
1954
|
+
onClick: () => setLaunchSelected((current) => current.includes(topicSet.id) ? current.filter((entry) => entry !== topicSet.id) : [...current, topicSet.id])
|
|
1955
|
+
}, topicSet.title)), (0, react.createElement)("button", {
|
|
1956
|
+
key: "new",
|
|
1957
|
+
type: "button",
|
|
1958
|
+
className: "sm-chip",
|
|
1959
|
+
"data-dashed": "true",
|
|
1960
|
+
onClick: () => setShowNewSet((value) => !value)
|
|
1961
|
+
}, t("composer.newSet"))), showNewSet ? (0, react.createElement)("div", {
|
|
1962
|
+
key: "newset",
|
|
1963
|
+
className: "sm-form",
|
|
1964
|
+
style: {
|
|
1965
|
+
marginTop: 8,
|
|
1966
|
+
marginBottom: 0
|
|
1967
|
+
}
|
|
1968
|
+
}, (0, react.createElement)("input", {
|
|
1969
|
+
key: "input",
|
|
1970
|
+
className: "sm-input",
|
|
1971
|
+
value: launchNewTitle,
|
|
1972
|
+
placeholder: t("newSession.create"),
|
|
1973
|
+
onChange: (event) => setLaunchNewTitle(event.target.value)
|
|
1974
|
+
}), (0, react.createElement)(Button, {
|
|
1975
|
+
key: "add",
|
|
1976
|
+
label: t("topic.create"),
|
|
1977
|
+
disabled: !launchNewTitle.trim() || !launchCwd,
|
|
1978
|
+
onClick: () => void launchCreateSet()
|
|
1979
|
+
})) : null, createdSet ? (0, react.createElement)("div", {
|
|
1980
|
+
key: "createdSet",
|
|
1981
|
+
className: "sm-set-created"
|
|
1982
|
+
}, (0, react.createElement)("span", {
|
|
1983
|
+
key: "badge",
|
|
1984
|
+
className: "sm-badge"
|
|
1985
|
+
}, t("sets.created")), (0, react.createElement)("span", { key: "title" }, createdSet.title), createdSet.tags.length > 0 ? tagChips(createdSet.tags) : null) : null, (0, react.createElement)("div", {
|
|
1986
|
+
key: "actions",
|
|
1987
|
+
className: "sm-actions"
|
|
1988
|
+
}, (0, react.createElement)(Button, {
|
|
1989
|
+
key: "send",
|
|
1990
|
+
variant: "primary",
|
|
1991
|
+
label: t("composer.start"),
|
|
1992
|
+
disabled: launching || !composerText.trim() || !launchCwd,
|
|
1993
|
+
onClick: () => void startLaunch("chat")
|
|
1994
|
+
}), (0, react.createElement)(Button, {
|
|
1995
|
+
key: "createOnly",
|
|
1996
|
+
label: t("composer.createOnly"),
|
|
1997
|
+
title: t("composer.createOnly.hint"),
|
|
1998
|
+
disabled: launching || !launchCwd,
|
|
1999
|
+
onClick: () => void startLaunch("bare")
|
|
2000
|
+
}), (0, react.createElement)("span", {
|
|
2001
|
+
key: "hint",
|
|
2002
|
+
className: "sm-muted"
|
|
2003
|
+
}, t("composer.hint")))),
|
|
2004
|
+
receipt ? (0, react.createElement)("div", {
|
|
2005
|
+
key: "receipt",
|
|
2006
|
+
className: "sm-receipt"
|
|
2007
|
+
}, (0, react.createElement)("div", {
|
|
2008
|
+
key: "row",
|
|
2009
|
+
className: "sm-row"
|
|
2010
|
+
}, (0, react.createElement)("span", {
|
|
2011
|
+
key: "mark",
|
|
2012
|
+
className: "sm-badge"
|
|
2013
|
+
}, receipt.kind === "sets" ? t("composer.receipt.sets") : t("composer.receipt.hub")), (0, react.createElement)("span", { key: "text" }, receipt.message)), (0, react.createElement)("div", {
|
|
2014
|
+
key: "meta",
|
|
2015
|
+
className: "sm-sub"
|
|
2016
|
+
}, receipt.id), (0, react.createElement)("div", {
|
|
2017
|
+
key: "actions",
|
|
2018
|
+
className: "sm-actions"
|
|
2019
|
+
}, receipt.id ? (0, react.createElement)(Button, {
|
|
2020
|
+
key: "open",
|
|
2021
|
+
label: t("composer.open"),
|
|
2022
|
+
onClick: () => api.openSession(receipt.id)
|
|
2023
|
+
}) : null, (0, react.createElement)(Button, {
|
|
2024
|
+
key: "dismiss",
|
|
2025
|
+
label: t("composer.dismiss"),
|
|
2026
|
+
onClick: () => setReceipt(void 0)
|
|
2027
|
+
}))) : null,
|
|
2028
|
+
BranchList({
|
|
2029
|
+
rows: hubBranches,
|
|
2030
|
+
t,
|
|
2031
|
+
onOpen: openChat
|
|
2032
|
+
}),
|
|
2033
|
+
(0, react.createElement)("div", {
|
|
2034
|
+
key: "current",
|
|
2035
|
+
className: "sm-card"
|
|
2036
|
+
}, (0, react.createElement)("h3", null, t("hub.current")), (0, react.createElement)("div", { className: "sm-row" }, (0, react.createElement)("span", { className: "sm-muted" }, sessionId || "—"), (0, react.createElement)(Button, {
|
|
2037
|
+
key: "refresh",
|
|
2038
|
+
label: t("hub.refresh"),
|
|
2039
|
+
onClick: () => void refreshHub()
|
|
2040
|
+
})))
|
|
2041
|
+
];
|
|
2042
|
+
const branchesView = [
|
|
2043
|
+
(0, react.createElement)("div", {
|
|
2044
|
+
key: "filters",
|
|
2045
|
+
className: "sm-form"
|
|
2046
|
+
}, (0, react.createElement)("label", {
|
|
2047
|
+
key: "set",
|
|
2048
|
+
className: "sm-opt"
|
|
2049
|
+
}, (0, react.createElement)("span", {
|
|
2050
|
+
key: "text",
|
|
2051
|
+
className: "sm-opt-label"
|
|
2052
|
+
}, t("hub.allBranches.filter")), (0, react.createElement)("select", {
|
|
2053
|
+
key: "select",
|
|
2054
|
+
className: "sm-opt-select",
|
|
2055
|
+
value: branchFilter,
|
|
2056
|
+
onChange: (event) => setBranchFilter(event.target.value)
|
|
2057
|
+
}, (0, react.createElement)("option", {
|
|
2058
|
+
key: "all",
|
|
2059
|
+
value: ""
|
|
2060
|
+
}, t("hub.allBranches.allSets")), allSets.map((topicSet) => (0, react.createElement)("option", {
|
|
2061
|
+
key: topicSet.id,
|
|
2062
|
+
value: topicSet.id
|
|
2063
|
+
}, topicSet.title)))), (0, react.createElement)("input", {
|
|
2064
|
+
key: "search",
|
|
2065
|
+
className: "sm-input",
|
|
2066
|
+
value: branchQuery,
|
|
2067
|
+
placeholder: t("branches.search"),
|
|
2068
|
+
onChange: (event) => setBranchQuery(event.target.value)
|
|
2069
|
+
}), (0, react.createElement)(Button, {
|
|
2070
|
+
key: "clear",
|
|
2071
|
+
label: t("sets.clear"),
|
|
2072
|
+
onClick: () => {
|
|
2073
|
+
setBranchFilter("");
|
|
2074
|
+
setBranchQuery("");
|
|
2075
|
+
}
|
|
2076
|
+
})),
|
|
2077
|
+
(0, react.createElement)("div", {
|
|
2078
|
+
key: "stats",
|
|
2079
|
+
className: "sm-muted"
|
|
2080
|
+
}, t("branches.stats", {
|
|
2081
|
+
shown: filteredBranchRows.length,
|
|
2082
|
+
total: allBranches.length
|
|
2083
|
+
})),
|
|
2084
|
+
(0, react.createElement)("div", {
|
|
2085
|
+
key: "list",
|
|
2086
|
+
className: "sm-list"
|
|
2087
|
+
}, filteredBranchRows.length === 0 ? (0, react.createElement)(EmptyState, {
|
|
2088
|
+
key: "empty",
|
|
2089
|
+
label: t("hub.allBranches.empty"),
|
|
2090
|
+
hint: t("hub.allBranches.hint")
|
|
2091
|
+
}) : filteredBranchRows.map((row) => (0, react.createElement)("div", {
|
|
2092
|
+
key: row.branchSessionId,
|
|
2093
|
+
className: "sm-item",
|
|
2094
|
+
"data-clickable": "true",
|
|
2095
|
+
title: `${row.title} · ${row.branchSessionId}`,
|
|
2096
|
+
onClick: () => openChat(row.branchSessionId)
|
|
2097
|
+
}, (0, react.createElement)("div", {
|
|
2098
|
+
key: "row",
|
|
2099
|
+
className: "sm-row"
|
|
2100
|
+
}, (0, react.createElement)("span", {
|
|
2101
|
+
key: "title",
|
|
2102
|
+
className: "sm-title"
|
|
2103
|
+
}, row.title), (0, react.createElement)("span", {
|
|
2104
|
+
key: "state",
|
|
2105
|
+
className: "sm-badge",
|
|
2106
|
+
"data-state": row.status
|
|
2107
|
+
}, t(`branches.${row.status}`)), row.shared ? (0, react.createElement)("span", {
|
|
2108
|
+
key: "shared",
|
|
2109
|
+
className: "sm-badge",
|
|
2110
|
+
title: row.hubs.join("、")
|
|
2111
|
+
}, t("branches.shared", { count: row.hubs.length - 1 })) : null, row.groupId ? (0, react.createElement)("span", {
|
|
2112
|
+
key: "grp",
|
|
2113
|
+
className: "sm-badge"
|
|
2114
|
+
}, t("branches.group")) : null), (0, react.createElement)("div", {
|
|
2115
|
+
key: "meta",
|
|
2116
|
+
className: "sm-sub"
|
|
2117
|
+
}, `${row.topicSetTitle ? t("branches.set", { title: row.topicSetTitle }) : t("branches.noSet")} · ${branchAgo(row.lastActivityAt, t)} · ${t("branches.dispatches", { count: row.dispatches })}`), row.tags && row.tags.length > 0 ? tagChips(row.tags) : null, (0, react.createElement)("div", {
|
|
2118
|
+
key: "id",
|
|
2119
|
+
className: "sm-sub"
|
|
2120
|
+
}, row.branchSessionId))))
|
|
2121
|
+
];
|
|
2122
|
+
const setsView = [
|
|
2123
|
+
(0, react.createElement)("div", {
|
|
2124
|
+
key: "search",
|
|
2125
|
+
className: "sm-form"
|
|
2126
|
+
}, (0, react.createElement)("input", {
|
|
2127
|
+
key: "input",
|
|
2128
|
+
className: "sm-input",
|
|
2129
|
+
value: setsQuery,
|
|
2130
|
+
placeholder: t("sets.search"),
|
|
2131
|
+
onChange: (event) => setSetsQuery(event.target.value)
|
|
2132
|
+
}), (0, react.createElement)(Button, {
|
|
2133
|
+
key: "clear",
|
|
2134
|
+
label: t("sets.clear"),
|
|
2135
|
+
onClick: () => setSetsQuery("")
|
|
2136
|
+
})),
|
|
2137
|
+
(0, react.createElement)("div", {
|
|
2138
|
+
key: "stats",
|
|
2139
|
+
className: "sm-muted"
|
|
2140
|
+
}, t("sets.stats", {
|
|
2141
|
+
shown: filteredSets.length,
|
|
2142
|
+
total: hub?.topicSets.length ?? 0
|
|
2143
|
+
})),
|
|
2144
|
+
(0, react.createElement)("div", {
|
|
2145
|
+
key: "list",
|
|
2146
|
+
className: "sm-list"
|
|
2147
|
+
}, filteredSets.length === 0 ? (0, react.createElement)(EmptyState, {
|
|
2148
|
+
key: "empty",
|
|
2149
|
+
label: t("sets.empty"),
|
|
2150
|
+
hint: t("sets.empty.hint")
|
|
2151
|
+
}) : filteredSets.map((topicSet) => (0, react.createElement)("div", {
|
|
2152
|
+
key: topicSet.id,
|
|
2153
|
+
className: "sm-item",
|
|
2154
|
+
"data-clickable": "true",
|
|
2155
|
+
onClick: () => {
|
|
2156
|
+
setView({
|
|
2157
|
+
kind: "topic",
|
|
2158
|
+
id: topicSet.id
|
|
2159
|
+
});
|
|
2160
|
+
setSummaryDraft(void 0);
|
|
2161
|
+
setSummaryTagsDraft(void 0);
|
|
2162
|
+
setReply("");
|
|
2163
|
+
}
|
|
2164
|
+
}, (0, react.createElement)("div", { className: "sm-row" }, (0, react.createElement)("span", { className: "sm-title" }, topicSet.title), hub?.activeTopicSetId === topicSet.id ? (0, react.createElement)("span", {
|
|
2165
|
+
key: "a",
|
|
2166
|
+
className: "sm-badge"
|
|
2167
|
+
}, t("hub.active")) : null, (0, react.createElement)("span", {
|
|
2168
|
+
key: "n",
|
|
2169
|
+
className: "sm-badge"
|
|
2170
|
+
}, t("sets.sessions", { count: topicSet.sessions })), topicSet.live > 0 ? (0, react.createElement)("span", {
|
|
2171
|
+
key: "l",
|
|
2172
|
+
className: "sm-badge"
|
|
2173
|
+
}, t("sets.live", { count: topicSet.live })) : null, topicSet.model ? (0, react.createElement)("span", {
|
|
2174
|
+
key: "m",
|
|
2175
|
+
className: "sm-badge"
|
|
2176
|
+
}, topicSet.model) : null), tagChips(topicSet.tags), (0, react.createElement)("div", { className: "sm-body-text" }, topicSet.summary || t("sets.noBody")), (0, react.createElement)("div", { className: "sm-actions" }, (0, react.createElement)(Button, {
|
|
2177
|
+
key: "act",
|
|
2178
|
+
label: t("hub.activate"),
|
|
2179
|
+
onClick: (event) => {
|
|
2180
|
+
event.stopPropagation();
|
|
2181
|
+
run(async () => api.activate(sessionId, topicSet.id), () => void refreshHub());
|
|
2182
|
+
}
|
|
2183
|
+
}), (0, react.createElement)(Button, {
|
|
2184
|
+
key: "open",
|
|
2185
|
+
label: t("sets.open"),
|
|
2186
|
+
onClick: (event) => {
|
|
2187
|
+
event.stopPropagation();
|
|
2188
|
+
setView({
|
|
2189
|
+
kind: "topic",
|
|
2190
|
+
id: topicSet.id
|
|
2191
|
+
});
|
|
2192
|
+
setReply("");
|
|
2193
|
+
}
|
|
2194
|
+
})))))
|
|
2195
|
+
];
|
|
2196
|
+
const topicView = currentTopicSet ? [
|
|
2197
|
+
(0, react.createElement)(Button, {
|
|
2198
|
+
key: "back",
|
|
2199
|
+
className: "sm-back",
|
|
2200
|
+
label: t("topic.back"),
|
|
2201
|
+
onClick: () => setView({ kind: "sets" })
|
|
2202
|
+
}),
|
|
2203
|
+
(0, react.createElement)("div", {
|
|
2204
|
+
key: "card",
|
|
2205
|
+
className: "sm-card"
|
|
2206
|
+
}, (0, react.createElement)("h3", null, currentTopicSet.title), tagChips(currentTopicSet.tags), (0, react.createElement)("div", {
|
|
2207
|
+
className: "sm-row",
|
|
2208
|
+
style: { marginTop: 6 }
|
|
2209
|
+
}, (0, react.createElement)(Button, {
|
|
2210
|
+
key: "act",
|
|
2211
|
+
variant: "primary",
|
|
2212
|
+
label: t("hub.activate"),
|
|
2213
|
+
onClick: () => void run(async () => api.activate(sessionId, currentTopicSet.id), () => void refreshHub())
|
|
2214
|
+
}), (0, react.createElement)("span", {
|
|
2215
|
+
key: "n",
|
|
2216
|
+
className: "sm-badge"
|
|
2217
|
+
}, t("sets.sessions", { count: currentTopicSet.sessions })), currentTopicSet.model ? (0, react.createElement)("span", {
|
|
2218
|
+
key: "m",
|
|
2219
|
+
className: "sm-badge"
|
|
2220
|
+
}, currentTopicSet.model) : null)),
|
|
2221
|
+
(0, react.createElement)("div", {
|
|
2222
|
+
key: "members",
|
|
2223
|
+
className: "sm-card"
|
|
2224
|
+
}, (0, react.createElement)("h3", null, t("topic.members")), currentTopicSet.branches.length === 0 ? (0, react.createElement)(EmptyState, { label: t("topic.noMembers") }) : (0, react.createElement)("div", { className: "sm-list" }, currentTopicSet.branches.map((branch) => (0, react.createElement)("div", {
|
|
2225
|
+
key: branch.sessionId,
|
|
2226
|
+
className: "sm-item",
|
|
2227
|
+
"data-clickable": "true",
|
|
2228
|
+
onClick: () => openChat(branch.sessionId)
|
|
2229
|
+
}, (0, react.createElement)("div", { className: "sm-row" }, (0, react.createElement)("span", { className: "sm-title" }, branch.title || branch.sessionId.slice(0, 12)), (0, react.createElement)("span", {
|
|
2230
|
+
key: "k",
|
|
2231
|
+
className: "sm-badge"
|
|
2232
|
+
}, branch.kind === "fork" ? t("topic.branch") : t("topic.root")), (0, react.createElement)("span", {
|
|
2233
|
+
key: "s",
|
|
2234
|
+
className: "sm-badge"
|
|
2235
|
+
}, branch.status), branch.kind === "fork" && branch.topicSetTitle ? (0, react.createElement)("span", {
|
|
2236
|
+
key: "own",
|
|
2237
|
+
className: "sm-badge",
|
|
2238
|
+
title: t("branches.ownSet")
|
|
2239
|
+
}, branch.topicSetTitle) : null, branch.kind === "fork" && (branch.hubs ?? 0) > 1 ? (0, react.createElement)("span", {
|
|
2240
|
+
key: "sh",
|
|
2241
|
+
className: "sm-badge"
|
|
2242
|
+
}, t("branches.shared", { count: (branch.hubs ?? 1) - 1 })) : null, branch.model ? (0, react.createElement)("span", {
|
|
2243
|
+
key: "m",
|
|
2244
|
+
className: "sm-badge"
|
|
2245
|
+
}, branch.model) : null), (0, react.createElement)("div", { className: "sm-sub" }, branch.sessionId), branch.task ? (0, react.createElement)("div", {
|
|
2246
|
+
key: "task",
|
|
2247
|
+
className: "sm-sub"
|
|
2248
|
+
}, `任务:${branch.task}`) : null, branch.tags && branch.tags.length > 0 ? tagChips(branch.tags) : null)))),
|
|
2249
|
+
(0, react.createElement)("div", {
|
|
2250
|
+
key: "reply",
|
|
2251
|
+
className: "sm-card"
|
|
2252
|
+
}, (0, react.createElement)("h3", null, t("topic.reply")), (0, react.createElement)("textarea", {
|
|
2253
|
+
key: "input",
|
|
2254
|
+
className: "sm-textarea",
|
|
2255
|
+
value: reply,
|
|
2256
|
+
placeholder: t("topic.reply.placeholder"),
|
|
2257
|
+
onChange: (event) => setReply(event.target.value)
|
|
2258
|
+
}), (0, react.createElement)("div", { className: "sm-actions" }, (0, react.createElement)(Button, {
|
|
2259
|
+
key: "send",
|
|
2260
|
+
variant: "primary",
|
|
2261
|
+
label: t("topic.reply.send"),
|
|
2262
|
+
disabled: !reply.trim(),
|
|
2263
|
+
onClick: () => void run(async () => api.followupTopicSet(cwd, currentTopicSet.id, reply.trim()), () => {
|
|
2264
|
+
hub?.topicSets.find((topicSet) => topicSet.id === currentTopicSet.id);
|
|
2265
|
+
setReply("");
|
|
2266
|
+
})
|
|
2267
|
+
}))),
|
|
2268
|
+
(0, react.createElement)("div", {
|
|
2269
|
+
key: "summary",
|
|
2270
|
+
className: "sm-card"
|
|
2271
|
+
}, (0, react.createElement)("h3", null, t("topic.summary")), (0, react.createElement)("div", { className: "sm-form-label" }, t("memory.tags")), (0, react.createElement)("input", {
|
|
2272
|
+
key: "tags",
|
|
2273
|
+
className: "sm-input",
|
|
2274
|
+
value: (summaryTagsDraft ?? currentTopicSet.tags).join(","),
|
|
2275
|
+
placeholder: t("memory.tags.placeholder"),
|
|
2276
|
+
onChange: (event) => setSummaryTagsDraft(String(event.target.value).split(/[,,、;;\s]+/).map((tag) => tag.trim()).filter(Boolean))
|
|
2277
|
+
}), (0, react.createElement)("div", {
|
|
2278
|
+
key: "bodyLabel",
|
|
2279
|
+
className: "sm-form-label",
|
|
2280
|
+
style: { marginTop: 6 }
|
|
2281
|
+
}, t("memory.body")), (0, react.createElement)("textarea", {
|
|
2282
|
+
key: "input",
|
|
2283
|
+
className: "sm-textarea",
|
|
2284
|
+
value: summaryDraft ?? currentTopicSet.summary,
|
|
2285
|
+
onChange: (event) => setSummaryDraft(event.target.value)
|
|
2286
|
+
}), (0, react.createElement)("div", { className: "sm-actions" }, (0, react.createElement)(Button, {
|
|
2287
|
+
key: "save",
|
|
2288
|
+
label: t("topic.summary.save"),
|
|
2289
|
+
onClick: () => void run(async () => api.updateTopicSetSummary(currentTopicSet.id, (summaryDraft ?? currentTopicSet.summary).slice(0, 500), summaryTagsDraft ?? currentTopicSet.tags), () => {
|
|
2290
|
+
setSummaryDraft(void 0);
|
|
2291
|
+
setSummaryTagsDraft(void 0);
|
|
2292
|
+
refreshHub();
|
|
2293
|
+
})
|
|
2294
|
+
})))
|
|
2295
|
+
] : (0, react.createElement)(EmptyState, {
|
|
2296
|
+
key: "missing",
|
|
2297
|
+
label: t("hub.empty"),
|
|
2298
|
+
hint: t("hub.empty.hint")
|
|
2299
|
+
});
|
|
2300
|
+
const memoryEntryRow = (memory) => (0, react.createElement)("div", {
|
|
2301
|
+
key: memory.id,
|
|
2302
|
+
className: "sm-item"
|
|
2303
|
+
}, (0, react.createElement)("div", {
|
|
2304
|
+
key: "head",
|
|
2305
|
+
className: "sm-row",
|
|
2306
|
+
"data-clickable": "true",
|
|
2307
|
+
title: t("memory.detail.open"),
|
|
2308
|
+
style: { cursor: "pointer" },
|
|
2309
|
+
onClick: () => openMemoryDetail(memory.id)
|
|
2310
|
+
}, (0, react.createElement)("span", {
|
|
2311
|
+
key: "title",
|
|
2312
|
+
className: "sm-title"
|
|
2313
|
+
}, memory.title || deriveTitleClient(memory.text)), (0, react.createElement)("span", {
|
|
2314
|
+
key: "ver",
|
|
2315
|
+
className: "sm-badge"
|
|
2316
|
+
}, `v${memory.version ?? 1}`), (0, react.createElement)("span", {
|
|
2317
|
+
key: "st",
|
|
2318
|
+
className: "sm-badge"
|
|
2319
|
+
}, memory.status)), tagChips(memory.tags, query), (0, react.createElement)("div", { className: "sm-body-text" }, memory.text), (0, react.createElement)("div", { className: "sm-sub" }, `${t("memory.updated")}:${fmtTime(memory.updatedAt)}`, ` · ${t("memory.source")}:${memory.sourceSessionId || "—"}`), (0, react.createElement)("div", { className: "sm-actions" }, memory.sourceSessionId ? (0, react.createElement)(Button, {
|
|
2320
|
+
key: "loc",
|
|
2321
|
+
label: t("memory.locate"),
|
|
2322
|
+
onClick: () => api.openSession(memory.sourceSessionId)
|
|
2323
|
+
}) : null, (0, react.createElement)(Button, {
|
|
2324
|
+
key: "edit",
|
|
2325
|
+
label: t("memory.edit"),
|
|
2326
|
+
onClick: () => setEditingMemory({
|
|
2327
|
+
id: memory.id,
|
|
2328
|
+
title: memory.title,
|
|
2329
|
+
tags: memory.tags,
|
|
2330
|
+
text: memory.text,
|
|
2331
|
+
key: memory.key
|
|
2332
|
+
})
|
|
2333
|
+
}), (0, react.createElement)(Button, {
|
|
2334
|
+
key: "toggle",
|
|
2335
|
+
label: memory.status === "active" ? t("memory.disable") : t("memory.enable"),
|
|
2336
|
+
onClick: () => void run(async () => api.setMemoryStatus(cwd, memory.id, memory.status === "active" ? "superseded" : "active"), () => void refreshMemoryViews())
|
|
2337
|
+
}), confirmDeleteMemory === memory.id ? (0, react.createElement)(Button, {
|
|
2338
|
+
key: "delYes",
|
|
2339
|
+
variant: "danger",
|
|
2340
|
+
label: t("memory.deleteConfirm"),
|
|
2341
|
+
onClick: () => void run(async () => api.deleteMemory(cwd, memory.id), () => {
|
|
2342
|
+
setConfirmDeleteMemory(void 0);
|
|
2343
|
+
refreshMemoryViews();
|
|
2344
|
+
})
|
|
2345
|
+
}) : (0, react.createElement)(Button, {
|
|
2346
|
+
key: "del",
|
|
2347
|
+
variant: "danger",
|
|
2348
|
+
label: t("memory.delete"),
|
|
2349
|
+
onClick: () => setConfirmDeleteMemory(memory.id)
|
|
2350
|
+
}), confirmDeleteMemory === memory.id ? (0, react.createElement)(Button, {
|
|
2351
|
+
key: "delNo",
|
|
2352
|
+
label: t("memory.cancel"),
|
|
2353
|
+
onClick: () => setConfirmDeleteMemory(void 0)
|
|
2354
|
+
}) : null));
|
|
2355
|
+
const filteredCollections = (0, react.useMemo)(() => {
|
|
2356
|
+
const needle = memoryQuery.trim().toLowerCase();
|
|
2357
|
+
if (!needle) return memoryCollections;
|
|
2358
|
+
return memoryCollections.filter((collection) => collection.title.toLowerCase().includes(needle) || collection.tags.some((tag) => tag.toLowerCase().includes(needle)));
|
|
2359
|
+
}, [memoryCollections, memoryQuery]);
|
|
2360
|
+
const collectionCard = (collection) => (0, react.createElement)("div", {
|
|
2361
|
+
key: collection.id || "ungrouped",
|
|
2362
|
+
className: "sm-card",
|
|
2363
|
+
"data-clickable": "true",
|
|
2364
|
+
title: t("memory.collection.open"),
|
|
2365
|
+
style: { cursor: "pointer" },
|
|
2366
|
+
onClick: () => setView({
|
|
2367
|
+
kind: "memory-collection",
|
|
2368
|
+
id: collection.id
|
|
2369
|
+
})
|
|
2370
|
+
}, (0, react.createElement)("div", {
|
|
2371
|
+
key: "head",
|
|
2372
|
+
className: "sm-row"
|
|
2373
|
+
}, (0, react.createElement)("h3", { key: "title" }, collection.title), (0, react.createElement)("span", {
|
|
2374
|
+
key: "count",
|
|
2375
|
+
className: "sm-badge"
|
|
2376
|
+
}, t("memory.group.count", { count: collection.count }))), tagChips(collection.tags), (0, react.createElement)("div", {
|
|
2377
|
+
key: "meta",
|
|
2378
|
+
className: "sm-sub"
|
|
2379
|
+
}, `${t("memory.updated")}:${fmtTime(collection.latestUpdatedAt)}`));
|
|
2380
|
+
const collectionList = filteredCollections.length === 0 ? (0, react.createElement)(EmptyState, {
|
|
2381
|
+
key: "empty",
|
|
2382
|
+
label: t("memory.collection.empty"),
|
|
2383
|
+
hint: t("memory.collection.empty.hint")
|
|
2384
|
+
}) : (0, react.createElement)("div", {
|
|
2385
|
+
key: "cards",
|
|
2386
|
+
className: "sm-list"
|
|
2387
|
+
}, filteredCollections.map(collectionCard));
|
|
2388
|
+
const currentCollection = view.kind === "memory-collection" ? memoryCollections.find((collection) => collection.id === view.id) : void 0;
|
|
2389
|
+
const memoryCollectionView = (0, react.createElement)("div", { key: "mc" }, (0, react.createElement)("div", {
|
|
2390
|
+
key: "crumb",
|
|
2391
|
+
className: "sm-row"
|
|
2392
|
+
}, (0, react.createElement)(Button, {
|
|
2393
|
+
key: "back",
|
|
2394
|
+
label: t("memory.back"),
|
|
2395
|
+
onClick: () => setView({ kind: "memories" })
|
|
2396
|
+
}), (0, react.createElement)("span", {
|
|
2397
|
+
key: "path",
|
|
2398
|
+
className: "sm-muted"
|
|
2399
|
+
}, `${t("tab.memories")} / ${currentCollection?.title ?? (view.kind === "memory-collection" ? view.id : "")}`)), (0, react.createElement)("div", {
|
|
2400
|
+
key: "search",
|
|
2401
|
+
className: "sm-form"
|
|
2402
|
+
}, (0, react.createElement)("input", {
|
|
2403
|
+
key: "input",
|
|
2404
|
+
className: "sm-input",
|
|
2405
|
+
value: query,
|
|
2406
|
+
placeholder: t("memory.search"),
|
|
2407
|
+
onChange: (event) => setQuery(event.target.value)
|
|
2408
|
+
}), (0, react.createElement)(Button, {
|
|
2409
|
+
key: "go",
|
|
2410
|
+
label: t("hub.refresh"),
|
|
2411
|
+
onClick: () => {
|
|
2412
|
+
if (view.kind === "memory-collection") refreshCollectionMemories(view.id);
|
|
2413
|
+
}
|
|
2414
|
+
})), collectionMemories.length === 0 ? (0, react.createElement)(EmptyState, {
|
|
2415
|
+
key: "empty",
|
|
2416
|
+
label: t("memory.empty"),
|
|
2417
|
+
hint: t("memory.empty.hint")
|
|
2418
|
+
}) : (0, react.createElement)("div", {
|
|
2419
|
+
key: "list",
|
|
2420
|
+
className: "sm-list"
|
|
2421
|
+
}, collectionMemories.map(memoryEntryRow)));
|
|
2422
|
+
const detail = memoryDetail;
|
|
2423
|
+
const detailVersions = detail?.versions ?? [];
|
|
2424
|
+
const expandedVersionKey = expandedVersion;
|
|
2425
|
+
const memoryDetailView = detail ? (0, react.createElement)("div", { key: "md" }, (0, react.createElement)("div", {
|
|
2426
|
+
key: "crumb",
|
|
2427
|
+
className: "sm-row"
|
|
2428
|
+
}, (0, react.createElement)(Button, {
|
|
2429
|
+
key: "back",
|
|
2430
|
+
label: t("memory.back"),
|
|
2431
|
+
onClick: () => backFromMemoryDetail()
|
|
2432
|
+
}), (0, react.createElement)("span", {
|
|
2433
|
+
key: "path",
|
|
2434
|
+
className: "sm-muted"
|
|
2435
|
+
}, `${t("tab.memories")} / ${detail.view.collectionTitle || t("memory.group.ungrouped")} / ${detail.view.title || deriveTitleClient(detail.view.text)}`)), (0, react.createElement)("div", {
|
|
2436
|
+
key: "head",
|
|
2437
|
+
className: "sm-row"
|
|
2438
|
+
}, (0, react.createElement)("span", {
|
|
2439
|
+
key: "title",
|
|
2440
|
+
className: "sm-title"
|
|
2441
|
+
}, detail.view.title || deriveTitleClient(detail.view.text)), (0, react.createElement)("span", {
|
|
2442
|
+
key: "ver",
|
|
2443
|
+
className: "sm-badge"
|
|
2444
|
+
}, `v${detail.view.version ?? 1}`), (0, react.createElement)("span", {
|
|
2445
|
+
key: "st",
|
|
2446
|
+
className: "sm-badge"
|
|
2447
|
+
}, detail.view.status)), tagChips(detail.view.tags, query), (0, react.createElement)("div", {
|
|
2448
|
+
key: "body",
|
|
2449
|
+
className: "sm-body-text"
|
|
2450
|
+
}, detail.view.text), (0, react.createElement)("div", {
|
|
2451
|
+
key: "meta",
|
|
2452
|
+
className: "sm-sub"
|
|
2453
|
+
}, `${t("memory.updated")}:${fmtTime(detail.view.updatedAt)}`, detail.view.key ? ` · key ${detail.view.key}` : "", detail.view.sourceSessionId ? ` · ${t("memory.source")}:${detail.view.sourceSessionId}` : ""), (0, react.createElement)("div", {
|
|
2454
|
+
key: "actions",
|
|
2455
|
+
className: "sm-actions"
|
|
2456
|
+
}, (0, react.createElement)(Button, {
|
|
2457
|
+
key: "edit",
|
|
2458
|
+
label: t("memory.edit"),
|
|
2459
|
+
onClick: () => setEditingMemory({
|
|
2460
|
+
id: detail.view.id,
|
|
2461
|
+
title: detail.view.title,
|
|
2462
|
+
tags: detail.view.tags,
|
|
2463
|
+
text: detail.view.text,
|
|
2464
|
+
key: detail.view.key
|
|
2465
|
+
})
|
|
2466
|
+
}), (0, react.createElement)(Button, {
|
|
2467
|
+
key: "toggle",
|
|
2468
|
+
label: detail.view.status === "active" ? t("memory.disable") : t("memory.enable"),
|
|
2469
|
+
onClick: () => void run(async () => api.setMemoryStatus(cwd, detail.view.id, detail.view.status === "active" ? "superseded" : "active"), () => void refreshMemoryViews())
|
|
2470
|
+
}), confirmDeleteMemory === detail.view.id ? (0, react.createElement)(Button, {
|
|
2471
|
+
key: "delYes",
|
|
2472
|
+
variant: "danger",
|
|
2473
|
+
label: t("memory.deleteConfirm"),
|
|
2474
|
+
onClick: () => void run(async () => api.deleteMemory(cwd, detail.view.id), () => {
|
|
2475
|
+
setConfirmDeleteMemory(void 0);
|
|
2476
|
+
setView({
|
|
2477
|
+
kind: "memory-collection",
|
|
2478
|
+
id: detail.view.collectionId ?? ""
|
|
2479
|
+
});
|
|
2480
|
+
})
|
|
2481
|
+
}) : (0, react.createElement)(Button, {
|
|
2482
|
+
key: "del",
|
|
2483
|
+
variant: "danger",
|
|
2484
|
+
label: t("memory.delete"),
|
|
2485
|
+
onClick: () => setConfirmDeleteMemory(detail.view.id)
|
|
2486
|
+
}), confirmDeleteMemory === detail.view.id ? (0, react.createElement)(Button, {
|
|
2487
|
+
key: "delNo",
|
|
2488
|
+
label: t("memory.cancel"),
|
|
2489
|
+
onClick: () => setConfirmDeleteMemory(void 0)
|
|
2490
|
+
}) : null), (0, react.createElement)("div", {
|
|
2491
|
+
key: "history",
|
|
2492
|
+
className: "sm-form-col"
|
|
2493
|
+
}, (0, react.createElement)("div", {
|
|
2494
|
+
key: "label",
|
|
2495
|
+
className: "sm-form-label"
|
|
2496
|
+
}, `${t("memory.history")}(${detailVersions.length})`), detailVersions.length === 0 ? (0, react.createElement)("div", {
|
|
2497
|
+
key: "none",
|
|
2498
|
+
className: "sm-muted"
|
|
2499
|
+
}, t("memory.history.none")) : (0, react.createElement)("div", {
|
|
2500
|
+
key: "rows",
|
|
2501
|
+
className: "sm-list"
|
|
2502
|
+
}, detailVersions.map((row) => {
|
|
2503
|
+
const rowKey = `${detail.view.id}:${row.version}`;
|
|
2504
|
+
const open = expandedVersionKey === rowKey;
|
|
2505
|
+
return (0, react.createElement)("div", {
|
|
2506
|
+
key: rowKey,
|
|
2507
|
+
className: "sm-item"
|
|
2508
|
+
}, (0, react.createElement)("div", {
|
|
2509
|
+
key: "head",
|
|
2510
|
+
className: "sm-row",
|
|
2511
|
+
"data-clickable": "true",
|
|
2512
|
+
title: t("memory.history.toggle"),
|
|
2513
|
+
style: { cursor: "pointer" },
|
|
2514
|
+
onClick: () => setExpandedVersion(open ? void 0 : rowKey)
|
|
2515
|
+
}, (0, react.createElement)("span", {
|
|
2516
|
+
key: "caret",
|
|
2517
|
+
className: "sm-caret"
|
|
2518
|
+
}, open ? "▾" : "▸"), (0, react.createElement)("span", {
|
|
2519
|
+
key: "ver",
|
|
2520
|
+
className: "sm-badge"
|
|
2521
|
+
}, `v${row.version}`), (0, react.createElement)("span", {
|
|
2522
|
+
key: "type",
|
|
2523
|
+
className: "sm-badge"
|
|
2524
|
+
}, t(`memory.history.${row.changeType}`)), (0, react.createElement)("span", {
|
|
2525
|
+
key: "title",
|
|
2526
|
+
className: "sm-title"
|
|
2527
|
+
}, row.title || "—"), (0, react.createElement)("span", {
|
|
2528
|
+
key: "at",
|
|
2529
|
+
className: "sm-sub"
|
|
2530
|
+
}, fmtTime(row.updatedAt))), tagChips(row.tags), open ? (0, react.createElement)("div", {
|
|
2531
|
+
key: "text",
|
|
2532
|
+
className: "sm-body-text"
|
|
2533
|
+
}, row.text) : null);
|
|
2534
|
+
})))) : (0, react.createElement)(EmptyState, {
|
|
2535
|
+
key: "missing",
|
|
2536
|
+
label: t("memory.empty"),
|
|
2537
|
+
hint: t("memory.empty.hint")
|
|
2538
|
+
});
|
|
2539
|
+
const hubPolicySelected = (name, prefix = false) => {
|
|
2540
|
+
if (!hubPolicyDraft) return false;
|
|
2541
|
+
return prefix ? hubPolicyDraft.prefixes.includes(name) : hubPolicyDraft.tools.includes(name);
|
|
2542
|
+
};
|
|
2543
|
+
const hubPolicyToggle = (name, prefix = false) => {
|
|
2544
|
+
if (!hubPolicyDraft) return;
|
|
2545
|
+
if (prefix) {
|
|
2546
|
+
const has = hubPolicyDraft.prefixes.includes(name);
|
|
2547
|
+
setHubPolicyDraft({
|
|
2548
|
+
...hubPolicyDraft,
|
|
2549
|
+
prefixes: has ? hubPolicyDraft.prefixes.filter((entry) => entry !== name) : [...hubPolicyDraft.prefixes, name]
|
|
2550
|
+
});
|
|
2551
|
+
return;
|
|
2552
|
+
}
|
|
2553
|
+
const has = hubPolicyDraft.tools.includes(name);
|
|
2554
|
+
setHubPolicyDraft({
|
|
2555
|
+
...hubPolicyDraft,
|
|
2556
|
+
tools: has ? hubPolicyDraft.tools.filter((entry) => entry !== name) : [...hubPolicyDraft.tools, name]
|
|
2557
|
+
});
|
|
2558
|
+
};
|
|
2559
|
+
const hubPolicyAddCustom = () => {
|
|
2560
|
+
const name = hubPolicyCustom.trim();
|
|
2561
|
+
if (!name || !hubPolicyDraft) return;
|
|
2562
|
+
if (!hubPolicyDraft.tools.includes(name)) setHubPolicyDraft({
|
|
2563
|
+
...hubPolicyDraft,
|
|
2564
|
+
tools: [...hubPolicyDraft.tools, name]
|
|
2565
|
+
});
|
|
2566
|
+
setHubPolicyCustom("");
|
|
2567
|
+
};
|
|
2568
|
+
/** R39: 当前草稿是否通过前缀规则覆盖了某工具(此时单项开关由前缀决定)。 */
|
|
2569
|
+
const hubPolicyPrefixCovered = (name) => Boolean(hubPolicyDraft && !hubPolicyDraft.tools.includes(name) && hubPolicyDraft.prefixes.some((prefix) => prefix.length > 0 && name.startsWith(prefix)));
|
|
2570
|
+
/** R39: 已知来源 id 本地化;未知来源(含宿主声明的来源名)直接用宿主 label。 */
|
|
2571
|
+
const hubPolicyGroupLabel = (group) => {
|
|
2572
|
+
if (group.id === "stale") return t("hubPolicy.group.stale");
|
|
2573
|
+
if (group.id === "source:supermemory") return t("hubPolicy.source.supermemory");
|
|
2574
|
+
if (group.id === "source:composite") return t("hubPolicy.source.composite");
|
|
2575
|
+
if (group.id === "source:schedule") return t("hubPolicy.source.schedule");
|
|
2576
|
+
if (group.id === "source:host-session") return t("hubPolicy.source.hostSession");
|
|
2577
|
+
if (group.id === "source:host") return t("hubPolicy.source.host");
|
|
2578
|
+
if (group.id.startsWith("source:mcp:")) return t("hubPolicy.source.mcp", { server: group.id.slice(11) });
|
|
2579
|
+
return group.label;
|
|
2580
|
+
};
|
|
2581
|
+
const hubPolicyCount = hubPolicyDraft ? hubPolicyDraft.tools.length + hubPolicyDraft.prefixes.length : 0;
|
|
2582
|
+
const hubPolicyNeedle = hubPolicyQuery.trim().toLowerCase();
|
|
2583
|
+
const hubPolicyFiltered = (hubPolicy?.catalog ?? []).map((group) => {
|
|
2584
|
+
const label = hubPolicyGroupLabel(group);
|
|
2585
|
+
return {
|
|
2586
|
+
group,
|
|
2587
|
+
items: hubPolicyNeedle.length > 0 && (label.toLowerCase().includes(hubPolicyNeedle) || group.label.toLowerCase().includes(hubPolicyNeedle)) ? group.items : group.items.filter((item) => hubPolicyNeedle.length === 0 || item.name.toLowerCase().includes(hubPolicyNeedle) || (item.description ?? "").toLowerCase().includes(hubPolicyNeedle))
|
|
2588
|
+
};
|
|
2589
|
+
}).filter((row) => row.items.length > 0);
|
|
2590
|
+
const toggleHubPolicyGroup = (id) => {
|
|
2591
|
+
setHubPolicyCollapsed((current) => current.includes(id) ? current.filter((entry) => entry !== id) : [...current, id]);
|
|
2592
|
+
};
|
|
2593
|
+
/** R39: 一键清理 —— 先保存当前草稿(不丢未保存勾选),再由宿主按运行时清理。 */
|
|
2594
|
+
const cleanHubPolicyStale = () => void run(async () => {
|
|
2595
|
+
if (!hubPolicyDraft) return {
|
|
2596
|
+
status: "error",
|
|
2597
|
+
message: t("hubPolicy.loading")
|
|
2598
|
+
};
|
|
2599
|
+
const saved = await api.setHubPolicy(cwd, {
|
|
2600
|
+
tools: hubPolicyDraft.tools,
|
|
2601
|
+
prefixes: hubPolicyDraft.prefixes
|
|
2602
|
+
});
|
|
2603
|
+
if (saved.status !== "ok") return saved;
|
|
2604
|
+
return api.cleanupStaleHubPolicy(cwd);
|
|
2605
|
+
}, () => void refreshHubPolicy());
|
|
2606
|
+
const hubPolicySwitch = (entry) => {
|
|
2607
|
+
const locked = entry.locked === true || (hubPolicy?.locked ?? []).includes(entry.name);
|
|
2608
|
+
const prefixCovered = !locked && entry.prefix !== true && hubPolicyPrefixCovered(entry.name);
|
|
2609
|
+
const checked = locked || prefixCovered || hubPolicySelected(entry.name, entry.prefix === true);
|
|
2610
|
+
const disabled = locked || prefixCovered;
|
|
2611
|
+
const title = locked ? t("hubPolicy.locked.tip") : prefixCovered ? t("hubPolicy.viaPrefix.tip") : entry.risk === true ? t("hubPolicy.risk.tip") : entry.description;
|
|
2612
|
+
return (0, react.createElement)("label", {
|
|
2613
|
+
key: `${entry.source}:${entry.name}`,
|
|
2614
|
+
className: "sm-item",
|
|
2615
|
+
"data-locked": String(disabled),
|
|
2616
|
+
title
|
|
2617
|
+
}, (0, react.createElement)("input", {
|
|
2618
|
+
key: "box",
|
|
2619
|
+
type: "checkbox",
|
|
2620
|
+
checked,
|
|
2621
|
+
disabled,
|
|
2622
|
+
onChange: () => hubPolicyToggle(entry.name, entry.prefix === true)
|
|
2623
|
+
}), (0, react.createElement)("span", {
|
|
2624
|
+
key: "name",
|
|
2625
|
+
className: "sm-title"
|
|
2626
|
+
}, entry.prefix === true ? `${entry.name}*` : entry.name), locked ? (0, react.createElement)("span", {
|
|
2627
|
+
key: "lock",
|
|
2628
|
+
className: "sm-badge"
|
|
2629
|
+
}, t("hubPolicy.locked")) : null, entry.noteKey === "capabilityDoc" ? (0, react.createElement)("span", {
|
|
2630
|
+
key: "capdoc",
|
|
2631
|
+
className: "sm-badge",
|
|
2632
|
+
title: t("hubPolicy.note.capabilityDoc.tip")
|
|
2633
|
+
}, t("hubPolicy.note.capabilityDoc")) : null, entry.noteKey === "capabilityExecDenied" ? (0, react.createElement)("span", {
|
|
2634
|
+
key: "capexec",
|
|
2635
|
+
className: "sm-badge",
|
|
2636
|
+
title: t("hubPolicy.note.capabilityExecDenied.tip")
|
|
2637
|
+
}, t("hubPolicy.note.capabilityExecDenied")) : null, prefixCovered ? (0, react.createElement)("span", {
|
|
2638
|
+
key: "prefix",
|
|
2639
|
+
className: "sm-badge"
|
|
2640
|
+
}, t("hubPolicy.viaPrefix")) : null, entry.risk === true ? (0, react.createElement)("span", {
|
|
2641
|
+
key: "risk",
|
|
2642
|
+
className: "sm-badge"
|
|
2643
|
+
}, t("hubPolicy.risk")) : null, entry.synthetic === true ? (0, react.createElement)("span", {
|
|
2644
|
+
key: "synthetic",
|
|
2645
|
+
className: "sm-badge",
|
|
2646
|
+
title: t("hubPolicy.synthetic.tip")
|
|
2647
|
+
}, t("hubPolicy.synthetic")) : null, entry.stale === true ? (0, react.createElement)("span", {
|
|
2648
|
+
key: "stale",
|
|
2649
|
+
className: "sm-badge"
|
|
2650
|
+
}, t("hubPolicy.stale.badge")) : null, entry.noteKey === "pluginManager" && !locked ? (0, react.createElement)("span", {
|
|
2651
|
+
key: "note",
|
|
2652
|
+
className: "sm-sub"
|
|
2653
|
+
}, t("hubPolicy.note.pluginManager")) : null, entry.description ? (0, react.createElement)("div", {
|
|
2654
|
+
key: "desc",
|
|
2655
|
+
className: "sm-desc"
|
|
2656
|
+
}, entry.description) : null);
|
|
2657
|
+
};
|
|
2658
|
+
const hubPolicyGroupCard = (group, items) => {
|
|
2659
|
+
const collapsed = hubPolicyCollapsed.includes(group.id);
|
|
2660
|
+
const enabled = group.items.filter((item) => item.locked === true || hubPolicySelected(item.name, item.prefix === true) || item.prefix !== true && hubPolicyPrefixCovered(item.name)).length;
|
|
2661
|
+
const isStale = group.kind === "stale";
|
|
2662
|
+
return (0, react.createElement)("div", {
|
|
2663
|
+
key: group.id,
|
|
2664
|
+
className: "sm-card"
|
|
2665
|
+
}, (0, react.createElement)("div", {
|
|
2666
|
+
key: "head",
|
|
2667
|
+
className: "sm-row"
|
|
2668
|
+
}, (0, react.createElement)("button", {
|
|
2669
|
+
key: "chev",
|
|
2670
|
+
type: "button",
|
|
2671
|
+
className: "sm-chevbtn",
|
|
2672
|
+
title: collapsed ? t("hubPolicy.group.expand") : t("hubPolicy.group.collapse"),
|
|
2673
|
+
onClick: () => toggleHubPolicyGroup(group.id)
|
|
2674
|
+
}, collapsed ? "▸" : "▾"), (0, react.createElement)("h3", {
|
|
2675
|
+
key: "title",
|
|
2676
|
+
style: { margin: 0 }
|
|
2677
|
+
}, hubPolicyGroupLabel(group)), group.inferred ? (0, react.createElement)("span", {
|
|
2678
|
+
key: "inferred",
|
|
2679
|
+
className: "sm-badge",
|
|
2680
|
+
title: t("hubPolicy.inferred.tip")
|
|
2681
|
+
}, t("hubPolicy.inferred")) : null, group.synthetic === true ? (0, react.createElement)("span", {
|
|
2682
|
+
key: "synthetic",
|
|
2683
|
+
className: "sm-badge",
|
|
2684
|
+
title: t("hubPolicy.synthetic.tip")
|
|
2685
|
+
}, t("hubPolicy.synthetic")) : null, (0, react.createElement)("span", {
|
|
2686
|
+
key: "count",
|
|
2687
|
+
className: "sm-badge"
|
|
2688
|
+
}, hubPolicyNeedle.length > 0 ? t("hubPolicy.group.match", {
|
|
2689
|
+
count: items.length,
|
|
2690
|
+
total: group.total
|
|
2691
|
+
}) : t("hubPolicy.group.count", { count: group.total })), (0, react.createElement)("span", {
|
|
2692
|
+
key: "enabled",
|
|
2693
|
+
className: "sm-badge"
|
|
2694
|
+
}, t("hubPolicy.group.enabled", { enabled })), isStale ? (0, react.createElement)(Button, {
|
|
2695
|
+
key: "clean",
|
|
2696
|
+
size: "sm",
|
|
2697
|
+
label: t("hubPolicy.stale.clean", { count: group.items.length }),
|
|
2698
|
+
title: t("hubPolicy.stale.tip"),
|
|
2699
|
+
disabled: group.items.every((item) => item.locked === true),
|
|
2700
|
+
onClick: () => cleanHubPolicyStale()
|
|
2701
|
+
}) : null), group.hint && !collapsed ? (0, react.createElement)("div", {
|
|
2702
|
+
key: "hint",
|
|
2703
|
+
className: "sm-muted"
|
|
2704
|
+
}, group.hint) : null, collapsed ? null : (0, react.createElement)("div", {
|
|
2705
|
+
key: "rows",
|
|
2706
|
+
className: "sm-list"
|
|
2707
|
+
}, items.map(hubPolicySwitch)));
|
|
2708
|
+
};
|
|
2709
|
+
const hubPolicyView = !hubPolicy || !hubPolicyDraft ? (0, react.createElement)(EmptyState, {
|
|
2710
|
+
key: "loading",
|
|
2711
|
+
label: t("hubPolicy.loading"),
|
|
2712
|
+
hint: t("hubPolicy.loading.hint")
|
|
2713
|
+
}) : (0, react.createElement)("div", { key: "hp" }, (0, react.createElement)("div", {
|
|
2714
|
+
key: "head",
|
|
2715
|
+
className: "sm-card"
|
|
2716
|
+
}, (0, react.createElement)("div", {
|
|
2717
|
+
key: "line",
|
|
2718
|
+
className: "sm-row"
|
|
2719
|
+
}, (0, react.createElement)("span", {
|
|
2720
|
+
key: "model",
|
|
2721
|
+
className: "sm-title"
|
|
2722
|
+
}, t("hubPolicy.model", { count: hubPolicyCount })), (0, react.createElement)("span", {
|
|
2723
|
+
key: "source",
|
|
2724
|
+
className: "sm-badge"
|
|
2725
|
+
}, hubPolicy.source === "stored" ? t("hubPolicy.source.stored") : t("hubPolicy.source.default")), (0, react.createElement)("span", {
|
|
2726
|
+
key: "mode",
|
|
2727
|
+
className: "sm-badge"
|
|
2728
|
+
}, hubPolicy.catalogMeta.mode === "fallback" ? t("hubPolicy.catalog.fallback") : t("hubPolicy.catalog.dynamic"))), (0, react.createElement)("div", {
|
|
2729
|
+
key: "meta",
|
|
2730
|
+
className: "sm-muted"
|
|
2731
|
+
}, t("hubPolicy.catalog.meta", {
|
|
2732
|
+
tools: hubPolicy.catalogMeta.toolCount,
|
|
2733
|
+
groups: hubPolicy.catalogMeta.groupCount
|
|
2734
|
+
}), hubPolicy.catalogMeta.syntheticCount > 0 ? " · " + t("hubPolicy.catalog.synthetic", { count: hubPolicy.catalogMeta.syntheticCount }) : "", " · ", t("hubPolicy.lastRefresh", { time: fmtTime(hubPolicy.catalogMeta.generatedAt) })), hubPolicy.catalogMeta.warning ? (0, react.createElement)("div", {
|
|
2735
|
+
key: "warning",
|
|
2736
|
+
className: "sm-warnbox"
|
|
2737
|
+
}, hubPolicy.catalogMeta.warning) : null, (0, react.createElement)("div", {
|
|
2738
|
+
key: "hint",
|
|
2739
|
+
className: "sm-muted"
|
|
2740
|
+
}, t("hubPolicy.hint")), (0, react.createElement)("div", {
|
|
2741
|
+
key: "actions",
|
|
2742
|
+
className: "sm-actions"
|
|
2743
|
+
}, (0, react.createElement)(Button, {
|
|
2744
|
+
key: "reset",
|
|
2745
|
+
label: t("hubPolicy.reset"),
|
|
2746
|
+
onClick: () => void run(async () => api.setHubPolicy(cwd, { reset: true }), () => void refreshHubPolicy())
|
|
2747
|
+
}), (0, react.createElement)(Button, {
|
|
2748
|
+
key: "save",
|
|
2749
|
+
variant: "primary",
|
|
2750
|
+
label: t("hubPolicy.save"),
|
|
2751
|
+
onClick: () => void run(async () => api.setHubPolicy(cwd, {
|
|
2752
|
+
tools: hubPolicyDraft.tools,
|
|
2753
|
+
prefixes: hubPolicyDraft.prefixes
|
|
2754
|
+
}), () => void refreshHubPolicy())
|
|
2755
|
+
})), (0, react.createElement)("div", {
|
|
2756
|
+
key: "search",
|
|
2757
|
+
className: "sm-form"
|
|
2758
|
+
}, (0, react.createElement)("input", {
|
|
2759
|
+
key: "searchInput",
|
|
2760
|
+
className: "sm-input",
|
|
2761
|
+
value: hubPolicyQuery,
|
|
2762
|
+
placeholder: t("hubPolicy.search.placeholder"),
|
|
2763
|
+
onChange: (event) => setHubPolicyQuery(event.target.value)
|
|
2764
|
+
}), (0, react.createElement)(Button, {
|
|
2765
|
+
key: "refresh",
|
|
2766
|
+
label: t("hubPolicy.refresh"),
|
|
2767
|
+
onClick: () => void refreshHubPolicyCatalog()
|
|
2768
|
+
})), (0, react.createElement)("div", {
|
|
2769
|
+
key: "add",
|
|
2770
|
+
className: "sm-form"
|
|
2771
|
+
}, (0, react.createElement)("input", {
|
|
2772
|
+
key: "input",
|
|
2773
|
+
className: "sm-input",
|
|
2774
|
+
value: hubPolicyCustom,
|
|
2775
|
+
placeholder: t("hubPolicy.custom.placeholder"),
|
|
2776
|
+
onChange: (event) => setHubPolicyCustom(event.target.value),
|
|
2777
|
+
onKeyDown: (event) => {
|
|
2778
|
+
if (event.key === "Enter") hubPolicyAddCustom();
|
|
2779
|
+
}
|
|
2780
|
+
}), (0, react.createElement)(Button, {
|
|
2781
|
+
key: "addBtn",
|
|
2782
|
+
label: t("hubPolicy.custom.add"),
|
|
2783
|
+
onClick: () => hubPolicyAddCustom()
|
|
2784
|
+
}))), hubPolicyFiltered.length === 0 ? (0, react.createElement)(EmptyState, {
|
|
2785
|
+
key: "noMatch",
|
|
2786
|
+
label: t("hubPolicy.empty"),
|
|
2787
|
+
hint: t("hubPolicy.empty.hint")
|
|
2788
|
+
}) : (0, react.createElement)("div", {
|
|
2789
|
+
key: "groups",
|
|
2790
|
+
className: "sm-list"
|
|
2791
|
+
}, hubPolicyFiltered.map((row) => hubPolicyGroupCard(row.group, row.items))));
|
|
2792
|
+
const memoriesView = [(0, react.createElement)("div", {
|
|
2793
|
+
key: "search",
|
|
2794
|
+
className: "sm-form"
|
|
2795
|
+
}, (0, react.createElement)("input", {
|
|
2796
|
+
key: "input",
|
|
2797
|
+
className: "sm-input",
|
|
2798
|
+
value: memoryQuery,
|
|
2799
|
+
placeholder: t("memory.collection.search"),
|
|
2800
|
+
onChange: (event) => setMemoryQuery(event.target.value)
|
|
2801
|
+
}), (0, react.createElement)(Button, {
|
|
2802
|
+
key: "go",
|
|
2803
|
+
label: t("hub.refresh"),
|
|
2804
|
+
onClick: () => void refreshMemoryCollections()
|
|
2805
|
+
})), collectionList];
|
|
2806
|
+
const toolsView = [(0, react.createElement)("div", {
|
|
2807
|
+
key: "list",
|
|
2808
|
+
className: "sm-list"
|
|
2809
|
+
}, tools.length === 0 ? (0, react.createElement)(EmptyState, {
|
|
2810
|
+
key: "empty",
|
|
2811
|
+
label: t("tool.empty"),
|
|
2812
|
+
hint: t("tool.empty.hint")
|
|
2813
|
+
}) : tools.map((tool) => (0, react.createElement)("div", {
|
|
2814
|
+
key: tool.id,
|
|
2815
|
+
className: "sm-item"
|
|
2816
|
+
}, (0, react.createElement)("div", {
|
|
2817
|
+
key: "head",
|
|
2818
|
+
className: "sm-row",
|
|
2819
|
+
"data-clickable": "true",
|
|
2820
|
+
title: t("tool.detail.toggle"),
|
|
2821
|
+
style: { cursor: "pointer" },
|
|
2822
|
+
onClick: () => setExpandedTool(expandedTool === tool.id ? void 0 : tool.id)
|
|
2823
|
+
}, (0, react.createElement)("span", {
|
|
2824
|
+
key: "caret",
|
|
2825
|
+
className: "sm-caret"
|
|
2826
|
+
}, expandedTool === tool.id ? "▾" : "▸"), (0, react.createElement)("span", {
|
|
2827
|
+
key: "title",
|
|
2828
|
+
className: "sm-title"
|
|
2829
|
+
}, tool.title || tool.name), (0, react.createElement)("span", {
|
|
2830
|
+
key: "kind",
|
|
2831
|
+
className: "sm-badge"
|
|
2832
|
+
}, kindLabel(tool.kind, t)), tool.source === "auto" ? (0, react.createElement)("span", {
|
|
2833
|
+
key: "auto",
|
|
2834
|
+
className: "sm-badge"
|
|
2835
|
+
}, t("tool.badge.auto")) : null, tool.entryDraft && !tool.entryVerified ? (0, react.createElement)("span", {
|
|
2836
|
+
key: "draft",
|
|
2837
|
+
className: "sm-badge"
|
|
2838
|
+
}, t("tool.badge.draft")) : null, (0, react.createElement)("span", {
|
|
2839
|
+
key: "status",
|
|
2840
|
+
className: "sm-badge"
|
|
2841
|
+
}, tool.enabled === false ? "retired" : tool.status), (0, react.createElement)("span", {
|
|
2842
|
+
key: "live",
|
|
2843
|
+
className: "sm-badge"
|
|
2844
|
+
}, tool.live ? t("tool.live") : t("tool.offline"))), tagChips(tool.tags), expandedTool === tool.id ? (0, react.createElement)("div", {
|
|
2845
|
+
key: "detail",
|
|
2846
|
+
className: "sm-detail"
|
|
2847
|
+
}, capabilityDetail(tool, t)) : null, editingTool && editingTool.id === tool.id ? (0, react.createElement)("div", { key: "edit" }, (0, react.createElement)("div", {
|
|
2848
|
+
key: "title",
|
|
2849
|
+
className: "sm-form-row"
|
|
2850
|
+
}, (0, react.createElement)("input", {
|
|
2851
|
+
key: "t",
|
|
2852
|
+
className: "sm-input",
|
|
2853
|
+
value: editingTool.title,
|
|
2854
|
+
placeholder: t("memory.title.placeholder"),
|
|
2855
|
+
onChange: (event) => setEditingTool({
|
|
2856
|
+
...editingTool,
|
|
2857
|
+
title: event.target.value
|
|
2858
|
+
})
|
|
2859
|
+
}), (0, react.createElement)("input", {
|
|
2860
|
+
key: "tags",
|
|
2861
|
+
className: "sm-input",
|
|
2862
|
+
value: editingTool.tags.join(","),
|
|
2863
|
+
placeholder: t("memory.tags.placeholder"),
|
|
2864
|
+
onChange: (event) => setEditingTool({
|
|
2865
|
+
...editingTool,
|
|
2866
|
+
tags: splitTags(event.target.value)
|
|
2867
|
+
})
|
|
2868
|
+
})), (0, react.createElement)("textarea", {
|
|
2869
|
+
key: "input",
|
|
2870
|
+
className: "sm-textarea",
|
|
2871
|
+
value: editingTool.description,
|
|
2872
|
+
onChange: (event) => setEditingTool({
|
|
2873
|
+
...editingTool,
|
|
2874
|
+
description: event.target.value
|
|
2875
|
+
})
|
|
2876
|
+
}), (0, react.createElement)("div", { className: "sm-form-label" }, t("tool.body.label")), (0, react.createElement)("textarea", {
|
|
2877
|
+
key: "body",
|
|
2878
|
+
className: "sm-textarea",
|
|
2879
|
+
value: editingTool.body,
|
|
2880
|
+
rows: 12,
|
|
2881
|
+
placeholder: t("tool.body.placeholder"),
|
|
2882
|
+
onChange: (event) => setEditingTool({
|
|
2883
|
+
...editingTool,
|
|
2884
|
+
body: event.target.value
|
|
2885
|
+
})
|
|
2886
|
+
}), (0, react.createElement)("div", { className: "sm-actions" }, (0, react.createElement)(Button, {
|
|
2887
|
+
key: "save",
|
|
2888
|
+
variant: "primary",
|
|
2889
|
+
label: t("tool.desc.save"),
|
|
2890
|
+
onClick: () => void run(async () => api.editTool(tool.id, {
|
|
2891
|
+
title: editingTool.title,
|
|
2892
|
+
tags: editingTool.tags,
|
|
2893
|
+
description: editingTool.description
|
|
2894
|
+
}), () => {
|
|
2895
|
+
setEditingTool(void 0);
|
|
2896
|
+
refreshTools();
|
|
2897
|
+
})
|
|
2898
|
+
}), (0, react.createElement)(Button, {
|
|
2899
|
+
key: "saveBody",
|
|
2900
|
+
label: t("tool.body.save"),
|
|
2901
|
+
onClick: () => void run(async () => api.editTool(tool.id, { body: editingTool.body }), () => {
|
|
2902
|
+
setEditingTool(void 0);
|
|
2903
|
+
refreshTools();
|
|
2904
|
+
})
|
|
2905
|
+
}), (0, react.createElement)(Button, {
|
|
2906
|
+
key: "cancel",
|
|
2907
|
+
label: t("memory.cancel"),
|
|
2908
|
+
onClick: () => setEditingTool(void 0)
|
|
2909
|
+
}))) : (0, react.createElement)("div", { key: "desc" }, (0, react.createElement)("div", { className: "sm-body-text" }, tool.description || "—"), (0, react.createElement)("div", { className: "sm-actions" }, tool.kind === "proposal" ? (0, react.createElement)(Button, {
|
|
2910
|
+
key: "accept",
|
|
2911
|
+
variant: "primary",
|
|
2912
|
+
label: t("tool.accept"),
|
|
2913
|
+
onClick: () => void run(async () => api.acceptProposal(cwd, tool.id), () => void refreshTools())
|
|
2914
|
+
}) : null, tool.kind === "proposal" ? (0, react.createElement)(Button, {
|
|
2915
|
+
key: "decline",
|
|
2916
|
+
label: t("tool.decline"),
|
|
2917
|
+
onClick: () => void run(async () => api.declineProposal(cwd, tool.id), () => void refreshTools())
|
|
2918
|
+
}) : null, tool.kind === "capability" && tool.entry ? (0, react.createElement)(Button, {
|
|
2919
|
+
key: "preview",
|
|
2920
|
+
label: t("tool.preview"),
|
|
2921
|
+
onClick: () => void run(async () => {
|
|
2922
|
+
const result = await api.runTool(tool.id);
|
|
2923
|
+
const detail = [
|
|
2924
|
+
result.summary,
|
|
2925
|
+
result.stdout ? result.stdout.slice(0, 1200) : "",
|
|
2926
|
+
result.stderr ? result.stderr.slice(0, 800) : ""
|
|
2927
|
+
].filter(Boolean).join("\n");
|
|
2928
|
+
return {
|
|
2929
|
+
status: result.status === "failed" ? "error" : "ok",
|
|
2930
|
+
message: detail
|
|
2931
|
+
};
|
|
2932
|
+
})
|
|
2933
|
+
}) : null, tool.entryDraft && !tool.entryVerified ? (0, react.createElement)(Button, {
|
|
2934
|
+
key: "enableRun",
|
|
2935
|
+
variant: "primary",
|
|
2936
|
+
label: t("tool.enableRun"),
|
|
2937
|
+
onClick: () => void run(async () => api.editTool(tool.id, {
|
|
2938
|
+
entry: tool.entryDraft,
|
|
2939
|
+
changelog: "人工启用执行(入口草稿已验证)"
|
|
2940
|
+
}), () => void refreshTools())
|
|
2941
|
+
}) : null, tool.kind !== "proposal" ? (0, react.createElement)(Button, {
|
|
2942
|
+
key: "edit",
|
|
2943
|
+
label: t("tool.desc.edit"),
|
|
2944
|
+
onClick: () => setEditingTool({
|
|
2945
|
+
id: tool.id,
|
|
2946
|
+
title: tool.title,
|
|
2947
|
+
tags: tool.tags,
|
|
2948
|
+
description: tool.description,
|
|
2949
|
+
body: tool.body ?? ""
|
|
2950
|
+
})
|
|
2951
|
+
}) : null, tool.kind !== "proposal" ? tool.status === "active" ? (0, react.createElement)(Button, {
|
|
2952
|
+
key: "retire",
|
|
2953
|
+
variant: "danger",
|
|
2954
|
+
label: t("tool.retire"),
|
|
2955
|
+
onClick: () => void run(async () => api.editTool(tool.id, { status: "retired" }), () => void refreshTools())
|
|
2956
|
+
}) : (0, react.createElement)(Button, {
|
|
2957
|
+
key: "enable",
|
|
2958
|
+
variant: "primary",
|
|
2959
|
+
label: t("tool.enable"),
|
|
2960
|
+
onClick: () => void run(async () => api.editTool(tool.id, { status: "active" }), () => void refreshTools())
|
|
2961
|
+
}) : null, confirmDeleteTool === tool.id ? (0, react.createElement)(Button, {
|
|
2962
|
+
key: "delYes",
|
|
2963
|
+
variant: "danger",
|
|
2964
|
+
label: t("tool.deleteConfirm"),
|
|
2965
|
+
onClick: () => void run(async () => api.deleteTool(tool.id), () => {
|
|
2966
|
+
setConfirmDeleteTool(void 0);
|
|
2967
|
+
refreshTools();
|
|
2968
|
+
refreshHub();
|
|
2969
|
+
})
|
|
2970
|
+
}) : (0, react.createElement)(Button, {
|
|
2971
|
+
key: "del",
|
|
2972
|
+
variant: "danger",
|
|
2973
|
+
label: t("tool.delete"),
|
|
2974
|
+
onClick: () => setConfirmDeleteTool(tool.id)
|
|
2975
|
+
}), confirmDeleteTool === tool.id ? (0, react.createElement)(Button, {
|
|
2976
|
+
key: "delNo",
|
|
2977
|
+
label: t("memory.cancel"),
|
|
2978
|
+
onClick: () => setConfirmDeleteTool(void 0)
|
|
2979
|
+
}) : null)), tool.steps.length > 0 ? (0, react.createElement)("div", { className: "sm-sub" }, t("tool.steps") + ":" + tool.steps.join(" → ")) : (0, react.createElement)("div", { className: "sm-sub" }, t("tool.detail.entry") + ":" + (tool.entry || "—") + " · " + t("tool.detail.scope") + ":" + (tool.scope || "—") + " · " + t("tool.detail.skill") + ":" + (tool.skillPath || "—")), (0, react.createElement)("div", { className: "sm-sub" }, t("tool.runCount") + ":" + (tool.runCount ?? tool.useCount) + " · " + t("tool.loadCount") + ":" + (tool.loadCount ?? 0) + " · " + t("tool.conversion") + ":" + (tool.loadsToRuns ?? 0) + " · " + t("tool.successRate") + ":" + (tool.successRate ?? 0) + " · " + t("tool.detail.last") + ":" + (tool.lastStatus ?? "—")), tool.version !== void 0 || tool.usage?.lastStatus || tool.createdAt !== void 0 || tool.usage?.lastUsedAt !== void 0 ? (0, react.createElement)("div", {
|
|
2980
|
+
key: "capmeta",
|
|
2981
|
+
className: "sm-sub"
|
|
2982
|
+
}, `${tool.version !== void 0 ? `版本 v${tool.version} · ` : ""}` + (tool.usage?.lastStatus ? `最近执行 ${tool.usage.lastStatus === "completed" ? "成功" : "失败"}${tool.usage.lastDryRun ? "(预演)" : ""} · 成功 ${tool.usage.successCount}/失败 ${tool.usage.failCount}` + (tool.usage.consecutiveFailures >= 2 ? ` · 连续失败 ${tool.usage.consecutiveFailures}` : "") : "") + (tool.createdAt !== void 0 || tool.usage?.lastUsedAt !== void 0 ? `${tool.version !== void 0 || tool.usage?.lastStatus ? " · " : ""}${t("tool.detail.created")} ${fmtTime(tool.createdAt)} · ${t("tool.detail.lastUsed")} ${fmtTime(tool.usage?.lastUsedAt)}` : "")) : null)))];
|
|
2983
|
+
const chatView = view.kind === "chat" ? (0, react.createElement)("div", {
|
|
2984
|
+
key: "chat",
|
|
2985
|
+
className: "sm-chat"
|
|
2986
|
+
}, (0, react.createElement)("div", {
|
|
2987
|
+
key: "head",
|
|
2988
|
+
className: "sm-chat-head"
|
|
2989
|
+
}, (0, react.createElement)("span", {
|
|
2990
|
+
key: "title",
|
|
2991
|
+
className: "sm-title"
|
|
2992
|
+
}, chatData?.title || view.id.slice(-8)), chatData?.live ? (0, react.createElement)("span", {
|
|
2993
|
+
key: "live",
|
|
2994
|
+
className: "sm-badge"
|
|
2995
|
+
}, t("chat.live")) : (0, react.createElement)("span", {
|
|
2996
|
+
key: "cold",
|
|
2997
|
+
className: "sm-badge"
|
|
2998
|
+
}, t("chat.cold")), chatData?.truncated ? (0, react.createElement)("span", {
|
|
2999
|
+
key: "tr",
|
|
3000
|
+
className: "sm-badge"
|
|
3001
|
+
}, t("chat.truncated")) : null, (0, react.createElement)("span", {
|
|
3002
|
+
key: "grow",
|
|
3003
|
+
style: { flex: 1 }
|
|
3004
|
+
}), (0, react.createElement)(Button, {
|
|
3005
|
+
key: "refresh",
|
|
3006
|
+
size: "sm",
|
|
3007
|
+
label: t("chat.refresh"),
|
|
3008
|
+
onClick: () => void loadChat(view.id)
|
|
3009
|
+
}), (0, react.createElement)(Button, {
|
|
3010
|
+
key: "open",
|
|
3011
|
+
size: "sm",
|
|
3012
|
+
label: t("chat.open"),
|
|
3013
|
+
onClick: () => api.openSession(view.id)
|
|
3014
|
+
})), chatError ? (0, react.createElement)("div", {
|
|
3015
|
+
key: "err",
|
|
3016
|
+
className: "sm-error"
|
|
3017
|
+
}, chatError) : null, chatData?.note ? (0, react.createElement)("div", {
|
|
3018
|
+
key: "note",
|
|
3019
|
+
className: "sm-muted"
|
|
3020
|
+
}, chatData.note) : null, chatBranches.length > 0 ? BranchList({
|
|
3021
|
+
rows: chatBranches,
|
|
3022
|
+
t,
|
|
3023
|
+
onOpen: openChat,
|
|
3024
|
+
compact: true
|
|
3025
|
+
}) : null, (chatData?.messages ?? []).length === 0 && !chatData?.note ? (0, react.createElement)(EmptyState, {
|
|
3026
|
+
key: "empty",
|
|
3027
|
+
label: t("chat.empty"),
|
|
3028
|
+
hint: t("chat.empty.hint")
|
|
3029
|
+
}) : (0, react.createElement)("div", {
|
|
3030
|
+
key: "msgs",
|
|
3031
|
+
className: "sm-list"
|
|
3032
|
+
}, (chatData?.messages ?? []).map((message) => (0, react.createElement)("div", {
|
|
3033
|
+
key: `${message.role}-${message.seq}`,
|
|
3034
|
+
className: "sm-msg",
|
|
3035
|
+
"data-role": message.role
|
|
3036
|
+
}, (0, react.createElement)("span", {
|
|
3037
|
+
key: "role",
|
|
3038
|
+
className: "sm-msg-role"
|
|
3039
|
+
}, message.role === "user" ? t("chat.you") : message.role === "assistant" ? t("chat.assistant") : t("chat.tool")), (0, react.createElement)("div", {
|
|
3040
|
+
key: "text",
|
|
3041
|
+
className: "sm-msg-text"
|
|
3042
|
+
}, message.text)))), (0, react.createElement)("div", {
|
|
3043
|
+
key: "bar",
|
|
3044
|
+
className: "sm-chat-bar"
|
|
3045
|
+
}, (0, react.createElement)("textarea", {
|
|
3046
|
+
key: "input",
|
|
3047
|
+
className: "sm-textarea",
|
|
3048
|
+
value: chatDraft,
|
|
3049
|
+
rows: 3,
|
|
3050
|
+
placeholder: t("chat.placeholder"),
|
|
3051
|
+
onChange: (event) => setChatDraft(event.target.value),
|
|
3052
|
+
onKeyDown: (event) => {
|
|
3053
|
+
if (event.key === "Enter" && (event.ctrlKey || event.metaKey)) {
|
|
3054
|
+
event.preventDefault();
|
|
3055
|
+
sendChat(view.id);
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
3058
|
+
}), (0, react.createElement)(Button, {
|
|
3059
|
+
key: "send",
|
|
3060
|
+
variant: "primary",
|
|
3061
|
+
label: t("chat.send"),
|
|
3062
|
+
disabled: chatSending || !chatDraft.trim(),
|
|
3063
|
+
onClick: () => void sendChat(view.id)
|
|
3064
|
+
})), (0, react.createElement)("div", {
|
|
3065
|
+
key: "hint",
|
|
3066
|
+
className: "sm-muted"
|
|
3067
|
+
}, t("chat.hint"))) : null;
|
|
3068
|
+
const modelDefaultsCard = () => {
|
|
3069
|
+
const choices = catalog?.models ?? [];
|
|
3070
|
+
const known = (value) => choices.some((model) => `${model.provider}/${model.id}` === value);
|
|
3071
|
+
const select = (key, value, onChange) => (0, react.createElement)("select", {
|
|
3072
|
+
key,
|
|
3073
|
+
className: "sm-opt-select",
|
|
3074
|
+
value,
|
|
3075
|
+
onChange: (event) => onChange(String(event.target.value))
|
|
3076
|
+
}, (0, react.createElement)("option", {
|
|
3077
|
+
key: "follow",
|
|
3078
|
+
value: ""
|
|
3079
|
+
}, t("settings.models.follow")), choices.map((model) => {
|
|
3080
|
+
const id = `${model.provider}/${model.id}`;
|
|
3081
|
+
return (0, react.createElement)("option", {
|
|
3082
|
+
key: id,
|
|
3083
|
+
value: id,
|
|
3084
|
+
title: model.name || void 0
|
|
3085
|
+
}, id);
|
|
3086
|
+
}), value && !known(value) ? (0, react.createElement)("option", {
|
|
3087
|
+
key: "custom",
|
|
3088
|
+
value
|
|
3089
|
+
}, value) : null);
|
|
3090
|
+
const saveDefaults = () => void run(async () => {
|
|
3091
|
+
const parse = (text) => {
|
|
3092
|
+
const slash = text.indexOf("/");
|
|
3093
|
+
return slash > 0 ? {
|
|
3094
|
+
provider: text.slice(0, slash),
|
|
3095
|
+
model: text.slice(slash + 1)
|
|
3096
|
+
} : null;
|
|
3097
|
+
};
|
|
3098
|
+
return api.setModelDefaults(cwd, {
|
|
3099
|
+
hub: hubModelDraft ? parse(hubModelDraft) : null,
|
|
3100
|
+
branch: branchModelDraft ? parse(branchModelDraft) : null
|
|
3101
|
+
});
|
|
3102
|
+
}, () => void refreshModelDefaults());
|
|
3103
|
+
return (0, react.createElement)("div", {
|
|
3104
|
+
key: "models",
|
|
3105
|
+
className: "sm-card"
|
|
3106
|
+
}, (0, react.createElement)("div", {
|
|
3107
|
+
key: "head",
|
|
3108
|
+
className: "sm-row"
|
|
3109
|
+
}, (0, react.createElement)("h3", { key: "title" }, t("settings.models.title")), (0, react.createElement)("span", {
|
|
3110
|
+
key: "source",
|
|
3111
|
+
className: "sm-badge"
|
|
3112
|
+
}, modelDefaults?.source === "stored" ? t("hubPolicy.source.stored") : t("hubPolicy.source.default"))), (0, react.createElement)("div", {
|
|
3113
|
+
key: "hint",
|
|
3114
|
+
className: "sm-muted"
|
|
3115
|
+
}, t("settings.models.hint")), (0, react.createElement)("div", {
|
|
3116
|
+
key: "form",
|
|
3117
|
+
className: "sm-form"
|
|
3118
|
+
}, (0, react.createElement)("label", {
|
|
3119
|
+
key: "hub",
|
|
3120
|
+
className: "sm-opt"
|
|
3121
|
+
}, (0, react.createElement)("span", {
|
|
3122
|
+
key: "label",
|
|
3123
|
+
className: "sm-opt-label"
|
|
3124
|
+
}, t("settings.models.hub")), select("hub", hubModelDraft, setHubModelDraft)), (0, react.createElement)("label", {
|
|
3125
|
+
key: "branch",
|
|
3126
|
+
className: "sm-opt"
|
|
3127
|
+
}, (0, react.createElement)("span", {
|
|
3128
|
+
key: "label",
|
|
3129
|
+
className: "sm-opt-label"
|
|
3130
|
+
}, t("settings.models.branch")), select("branch", branchModelDraft, setBranchModelDraft))), (0, react.createElement)("div", {
|
|
3131
|
+
key: "actions",
|
|
3132
|
+
className: "sm-actions"
|
|
3133
|
+
}, (0, react.createElement)(Button, {
|
|
3134
|
+
key: "save",
|
|
3135
|
+
variant: "primary",
|
|
3136
|
+
label: t("settings.models.save"),
|
|
3137
|
+
disabled: !cwd,
|
|
3138
|
+
onClick: saveDefaults
|
|
3139
|
+
}), (0, react.createElement)(Button, {
|
|
3140
|
+
key: "reset",
|
|
3141
|
+
label: t("settings.models.reset"),
|
|
3142
|
+
disabled: !cwd,
|
|
3143
|
+
onClick: () => void run(async () => api.setModelDefaults(cwd, { reset: true }), () => void refreshModelDefaults())
|
|
3144
|
+
})), (0, react.createElement)("div", {
|
|
3145
|
+
key: "precedence",
|
|
3146
|
+
className: "sm-desc"
|
|
3147
|
+
}, t("settings.models.precedence")));
|
|
3148
|
+
};
|
|
3149
|
+
const settingsView = (0, react.createElement)("div", { key: "settings" }, modelDefaultsCard(), (0, react.createElement)("div", {
|
|
3150
|
+
key: "policyTitle",
|
|
3151
|
+
className: "sm-section-title"
|
|
3152
|
+
}, t("settings.policy.title")), hubPolicyView);
|
|
3153
|
+
const body = view.kind === "hub" ? hubView : view.kind === "sets" ? setsView : view.kind === "topic" ? topicView : view.kind === "branches" ? branchesView : view.kind === "memories" ? memoriesView : view.kind === "memory-collection" ? memoryCollectionView : view.kind === "memory-detail" ? memoryDetailView : view.kind === "settings" ? settingsView : view.kind === "chat" ? chatView : toolsView;
|
|
3154
|
+
const sideRail = (0, react.createElement)("aside", {
|
|
3155
|
+
key: "side",
|
|
3156
|
+
className: "sm-side"
|
|
3157
|
+
}, (0, react.createElement)("div", {
|
|
3158
|
+
key: "head",
|
|
3159
|
+
className: "sm-side-head",
|
|
3160
|
+
title: t("side.authority")
|
|
3161
|
+
}, (0, react.createElement)("span", { key: "title" }, t("side.title")), (0, react.createElement)("span", {
|
|
3162
|
+
key: "count",
|
|
3163
|
+
className: "sm-side-count"
|
|
3164
|
+
}, t("side.count", { count: hubs.length }))), hubs.length === 0 ? (0, react.createElement)("div", {
|
|
3165
|
+
key: "empty",
|
|
3166
|
+
className: "sm-side-empty"
|
|
3167
|
+
}, `${t("side.empty")} · ${t("side.empty.hint")}`) : (0, react.createElement)("div", {
|
|
3168
|
+
key: "list",
|
|
3169
|
+
className: "sm-side-list"
|
|
3170
|
+
}, hubs.map((hubRow) => {
|
|
3171
|
+
const current = isRailCurrent(view, hubRow.sessionId, sessionId);
|
|
3172
|
+
return (0, react.createElement)("button", {
|
|
3173
|
+
key: hubRow.sessionId,
|
|
3174
|
+
type: "button",
|
|
3175
|
+
className: "sm-hub",
|
|
3176
|
+
"data-current": String(current),
|
|
3177
|
+
title: `${hubRow.title}${hubRow.topicSetTitle ? ` · 话题集 ${hubRow.topicSetTitle}` : ""} · ${hubRow.sessionId}`,
|
|
3178
|
+
onClick: () => openChat(hubRow.sessionId)
|
|
3179
|
+
}, hubRow.live ? (0, react.createElement)("span", {
|
|
3180
|
+
key: "dot",
|
|
3181
|
+
className: "sm-dot",
|
|
3182
|
+
title: t("side.running")
|
|
3183
|
+
}) : null, (0, react.createElement)("span", {
|
|
3184
|
+
key: "title",
|
|
3185
|
+
className: "sm-hub-title"
|
|
3186
|
+
}, hubRow.title || hubRow.sessionId.slice(-4)), hubRow.topicSetTitle ? (0, react.createElement)("span", {
|
|
3187
|
+
key: "set",
|
|
3188
|
+
className: "sm-hub-meta sm-hub-set",
|
|
3189
|
+
title: `${t("badge.hubSet.tip", { title: hubRow.topicSetTitle })}`
|
|
3190
|
+
}, hubRow.topicSetTitle) : null, hubRow.branches > 0 ? (0, react.createElement)("span", {
|
|
3191
|
+
key: "branches",
|
|
3192
|
+
className: "sm-hub-meta",
|
|
3193
|
+
title: t("side.branches", {
|
|
3194
|
+
count: hubRow.branches,
|
|
3195
|
+
working: hubRow.workingBranches
|
|
3196
|
+
})
|
|
3197
|
+
}, hubRow.workingBranches > 0 ? `${hubRow.branches}·${hubRow.workingBranches}` : String(hubRow.branches)) : null, current ? (0, react.createElement)("span", {
|
|
3198
|
+
key: "cur",
|
|
3199
|
+
className: "sm-hub-meta"
|
|
3200
|
+
}, t("side.current")) : null);
|
|
3201
|
+
})), (0, react.createElement)("div", {
|
|
3202
|
+
key: "foot",
|
|
3203
|
+
className: "sm-side-foot"
|
|
3204
|
+
}, (0, react.createElement)(Button, {
|
|
3205
|
+
key: "new",
|
|
3206
|
+
className: "sm-newhub",
|
|
3207
|
+
size: "sm",
|
|
3208
|
+
label: t("side.new"),
|
|
3209
|
+
title: t("composer.title"),
|
|
3210
|
+
disabled: launching,
|
|
3211
|
+
onClick: () => {
|
|
3212
|
+
createHubNow();
|
|
3213
|
+
}
|
|
3214
|
+
})));
|
|
3215
|
+
const bodyScroll = (0, react.createElement)("div", {
|
|
3216
|
+
key: "body",
|
|
3217
|
+
className: "sm-body"
|
|
3218
|
+
}, loading ? (0, react.createElement)("div", {
|
|
3219
|
+
key: "loading",
|
|
3220
|
+
className: "sm-muted"
|
|
3221
|
+
}, "…") : null, error ? (0, react.createElement)("div", {
|
|
3222
|
+
key: "error",
|
|
3223
|
+
className: "sm-error"
|
|
3224
|
+
}, error) : null, notice ? (0, react.createElement)("div", {
|
|
3225
|
+
key: "notice",
|
|
3226
|
+
className: "sm-ok"
|
|
3227
|
+
}, notice) : null, body);
|
|
3228
|
+
const wsOptions = workspaces.map((workspace) => ({
|
|
3229
|
+
path: workspace.path,
|
|
3230
|
+
label: workspace.title || workspace.path
|
|
3231
|
+
}));
|
|
3232
|
+
if (cwd && !wsOptions.some((option) => option.path === cwd)) wsOptions.unshift({
|
|
3233
|
+
path: cwd,
|
|
3234
|
+
label: cwd
|
|
3235
|
+
});
|
|
3236
|
+
const memoryModal = editingMemory ? (0, react.createElement)("div", {
|
|
3237
|
+
key: "memory-modal",
|
|
3238
|
+
className: "sm-modal-backdrop",
|
|
3239
|
+
onClick: () => setEditingMemory(void 0)
|
|
3240
|
+
}, (0, react.createElement)("div", {
|
|
3241
|
+
key: "dialog",
|
|
3242
|
+
className: "sm-modal",
|
|
3243
|
+
role: "dialog",
|
|
3244
|
+
"aria-modal": "true",
|
|
3245
|
+
onClick: (event) => event.stopPropagation()
|
|
3246
|
+
}, (0, react.createElement)("h3", { key: "title" }, t("memory.modal.title")), (0, react.createElement)("p", {
|
|
3247
|
+
key: "hint",
|
|
3248
|
+
className: "sm-modal-hint"
|
|
3249
|
+
}, t("memory.modal.hint")), (0, react.createElement)("div", {
|
|
3250
|
+
key: "meta",
|
|
3251
|
+
className: "sm-form-row"
|
|
3252
|
+
}, (0, react.createElement)("input", {
|
|
3253
|
+
key: "t",
|
|
3254
|
+
className: "sm-input",
|
|
3255
|
+
value: editingMemory.title,
|
|
3256
|
+
placeholder: t("memory.title.placeholder"),
|
|
3257
|
+
onChange: (event) => setEditingMemory({
|
|
3258
|
+
...editingMemory,
|
|
3259
|
+
title: event.target.value
|
|
3260
|
+
})
|
|
3261
|
+
}), (0, react.createElement)("input", {
|
|
3262
|
+
key: "tags",
|
|
3263
|
+
className: "sm-input",
|
|
3264
|
+
value: editingMemory.tags.join(","),
|
|
3265
|
+
placeholder: t("memory.tags.placeholder"),
|
|
3266
|
+
onChange: (event) => setEditingMemory({
|
|
3267
|
+
...editingMemory,
|
|
3268
|
+
tags: splitTags(event.target.value)
|
|
3269
|
+
})
|
|
3270
|
+
})), (0, react.createElement)("textarea", {
|
|
3271
|
+
key: "body",
|
|
3272
|
+
className: "sm-textarea",
|
|
3273
|
+
value: editingMemory.text,
|
|
3274
|
+
placeholder: t("memory.new.placeholder"),
|
|
3275
|
+
onChange: (event) => setEditingMemory({
|
|
3276
|
+
...editingMemory,
|
|
3277
|
+
text: event.target.value
|
|
3278
|
+
})
|
|
3279
|
+
}), (0, react.createElement)("div", {
|
|
3280
|
+
key: "actions",
|
|
3281
|
+
className: "sm-actions"
|
|
3282
|
+
}, (0, react.createElement)(Button, {
|
|
3283
|
+
key: "save",
|
|
3284
|
+
variant: "primary",
|
|
3285
|
+
label: t("memory.save"),
|
|
3286
|
+
onClick: () => void run(async () => api.updateMemory(cwd, editingMemory.id, editingMemory.text, editingMemory.key, editingMemory.title, editingMemory.tags), () => {
|
|
3287
|
+
setEditingMemory(void 0);
|
|
3288
|
+
refreshMemoryViews();
|
|
3289
|
+
})
|
|
3290
|
+
}), (0, react.createElement)(Button, {
|
|
3291
|
+
key: "cancel",
|
|
3292
|
+
label: t("memory.cancel"),
|
|
3293
|
+
onClick: () => setEditingMemory(void 0)
|
|
3294
|
+
})))) : null;
|
|
3295
|
+
const main = (0, react.createElement)("main", {
|
|
3296
|
+
key: "main",
|
|
3297
|
+
className: "sm-main"
|
|
3298
|
+
}, (0, react.createElement)("div", {
|
|
3299
|
+
key: "head",
|
|
3300
|
+
className: "sm-head"
|
|
3301
|
+
}, (0, react.createElement)("span", {
|
|
3302
|
+
key: "brand",
|
|
3303
|
+
className: "sm-brand"
|
|
3304
|
+
}, t("panel.title")), wsOptions.length > 0 ? (0, react.createElement)("label", {
|
|
3305
|
+
key: "ws",
|
|
3306
|
+
className: "sm-ws"
|
|
3307
|
+
}, (0, react.createElement)("span", {
|
|
3308
|
+
key: "label",
|
|
3309
|
+
className: "sm-opt-label"
|
|
3310
|
+
}, t("workspace.label")), (0, react.createElement)("select", {
|
|
3311
|
+
key: "select",
|
|
3312
|
+
className: "sm-ws-select",
|
|
3313
|
+
value: cwd,
|
|
3314
|
+
title: cwd,
|
|
3315
|
+
onChange: (event) => changeWorkspace(event.target.value)
|
|
3316
|
+
}, wsOptions.map((option) => (0, react.createElement)("option", {
|
|
3317
|
+
key: option.path,
|
|
3318
|
+
value: option.path
|
|
3319
|
+
}, option.label)))) : hub ? (0, react.createElement)("span", {
|
|
3320
|
+
key: "sub",
|
|
3321
|
+
className: "sm-head-sub"
|
|
3322
|
+
}, hub.workspaceKey) : null, hub ? (0, react.createElement)("div", {
|
|
3323
|
+
key: "pills",
|
|
3324
|
+
className: "sm-pills"
|
|
3325
|
+
}, (0, react.createElement)("span", {
|
|
3326
|
+
key: "sets",
|
|
3327
|
+
className: "sm-pill"
|
|
3328
|
+
}, `${t("tab.sets")} ${hub.topicSets.length}`), (0, react.createElement)("span", {
|
|
3329
|
+
key: "mem",
|
|
3330
|
+
className: "sm-pill"
|
|
3331
|
+
}, `${t("tab.memories")} ${hub.counts.memories}`), (0, react.createElement)("span", {
|
|
3332
|
+
key: "tools",
|
|
3333
|
+
className: "sm-pill"
|
|
3334
|
+
}, `${t("tab.tools")} ${hub.counts.tools}`)) : null), (0, react.createElement)("div", {
|
|
3335
|
+
key: "tabs",
|
|
3336
|
+
className: "sm-tabs"
|
|
3337
|
+
}, (0, react.createElement)("button", {
|
|
3338
|
+
key: "hub",
|
|
3339
|
+
...tabProps("hub")
|
|
3340
|
+
}, t("tab.hub")), (0, react.createElement)("button", {
|
|
3341
|
+
key: "sets",
|
|
3342
|
+
...tabProps("sets")
|
|
3343
|
+
}, t("tab.sets")), (0, react.createElement)("button", {
|
|
3344
|
+
key: "branches",
|
|
3345
|
+
...tabProps("branches")
|
|
3346
|
+
}, t("tab.branches")), (0, react.createElement)("button", {
|
|
3347
|
+
key: "memories",
|
|
3348
|
+
...tabProps("memories")
|
|
3349
|
+
}, t("tab.memories")), (0, react.createElement)("button", {
|
|
3350
|
+
key: "tools",
|
|
3351
|
+
...tabProps("tools")
|
|
3352
|
+
}, t("tab.tools")), (0, react.createElement)("button", {
|
|
3353
|
+
key: "settings",
|
|
3354
|
+
...tabProps("settings")
|
|
3355
|
+
}, t("tab.settings"))), bodyScroll);
|
|
3356
|
+
return (0, react.createElement)("div", {
|
|
3357
|
+
className: "sm-panel",
|
|
3358
|
+
"data-sm-panel": "true"
|
|
3359
|
+
}, (0, react.createElement)("div", {
|
|
3360
|
+
key: "shell",
|
|
3361
|
+
className: "sm-shell"
|
|
3362
|
+
}, sideRail, main), memoryModal);
|
|
3363
|
+
}
|
|
3364
|
+
// src/client/new-session.tsx
|
|
3365
|
+
/**
|
|
3366
|
+
* New-session entry (需求①: 「新会话」 must have an immediate, visible effect).
|
|
3367
|
+
*
|
|
3368
|
+
* The click on the shell's 新建会话 control (sidebar header / sidebar new-session
|
|
3369
|
+
* row / a workspace row's 新会话 action) now CREATES a hub session right away
|
|
3370
|
+
* with host defaults — current workspace, default agent preset / model /
|
|
3371
|
+
* permission, no topic set (a hub session owns no set; the panel's dispatch
|
|
3372
|
+
* card still picks the sticky/auto set when dispatching) — and hands the
|
|
3373
|
+
* receipt to the panel, which renders it in place (message + session id +
|
|
3374
|
+
* 「打开会话」). No choice dialog, no type picker, no waiting for a form: one
|
|
3375
|
+
* click, one session.
|
|
3376
|
+
*
|
|
3377
|
+
* Why an interceptor instead of a slot: this shell exposes no "new session
|
|
3378
|
+
* action" slot to replace (the verified vocabulary is sidebar.panellist /
|
|
3379
|
+
* sidebar.session.row.leading / sidebar.workspaces.session.row.action /
|
|
3380
|
+
* sidebar.footer.action — the sidebar's own 新建会话 row renders
|
|
3381
|
+
* `sidebar.session.action`, which ADDS a control instead of replacing it), so
|
|
3382
|
+
* the entry lives in `shell.overlay` (a global render slot) and installs a
|
|
3383
|
+
* capture-phase document listener that matches the control by accessible name
|
|
3384
|
+
* (aria-label / title / text). Capture runs before the shell's own bubble
|
|
3385
|
+
* handler, so a matched click never creates the shell's plain session behind
|
|
3386
|
+
* the panel.
|
|
3387
|
+
*
|
|
3388
|
+
* Degradation is explicit and never a dead button: without the panel api, a
|
|
3389
|
+
* resolvable workspace, or a matching label, the click is NOT prevented and the
|
|
3390
|
+
* shell's own new-session flow runs untouched. If the session was created but
|
|
3391
|
+
* the panel could not be revealed (no layout service), the created session is
|
|
3392
|
+
* opened directly so the click still has a visible result.
|
|
3393
|
+
*
|
|
3394
|
+
* R43 ①: two surfaces are skipped because they are OUR OWN and merely contain
|
|
3395
|
+
* matching text — the panel (`[data-sm-panel]`, whose in-panel controls act
|
|
3396
|
+
* locally) and a SuperMemory chat card (`[data-supermemory-card]`), whose head
|
|
3397
|
+
* button's accessible name is 「来自 <来源会话> 的执行请求」 and therefore
|
|
3398
|
+
* matches the pattern whenever the source session is named 「新会话」.
|
|
3399
|
+
* @module supermemory/client/new-session
|
|
3400
|
+
*/
|
|
3401
|
+
/**
|
|
3402
|
+
* The shell's New-session control, in the shipped zh and en dictionaries plus
|
|
3403
|
+
* the plausible variants (the sidebar uses 新建会话 / New session, a workspace
|
|
3404
|
+
* row uses 在“…”中新建会话).
|
|
3405
|
+
*/
|
|
3406
|
+
const NEW_SESSION_CONTROL = /(新建|新的?)\s*会话|新建对话|新对话|new\s+(session|chat|conversation)/i;
|
|
3407
|
+
/** Whether an accessible name/value describes the shell's New-session control. */
|
|
3408
|
+
function isNewSessionControl(value) {
|
|
3409
|
+
if (!value) return false;
|
|
3410
|
+
if (PER_WORKSPACE_ACTION.test(value.trim())) return false;
|
|
3411
|
+
return NEW_SESSION_CONTROL.test(value);
|
|
3412
|
+
}
|
|
3413
|
+
/**
|
|
3414
|
+
* A workspace ROW's own action ("在“X”中新建会话" / New session in "X"): that
|
|
3415
|
+
* control belongs to one workspace the overlay cannot see, so it keeps the
|
|
3416
|
+
* shell's own behaviour — intercepting it here would create the session in the
|
|
3417
|
+
* MAIN-VIEW workspace instead of the clicked one. Only the global 新建会话
|
|
3418
|
+
* control (sidebar header / new-session row / brand) is ours.
|
|
3419
|
+
*/
|
|
3420
|
+
const PER_WORKSPACE_ACTION = /^在.*中\s*(新建|新的?)\s*(会话|对话)/;
|
|
3421
|
+
/** The New-session entry: an interceptor that renders nothing. */
|
|
3422
|
+
function NewSessionChoice(props) {
|
|
3423
|
+
const api = props.api;
|
|
3424
|
+
const cwd = props.cwd;
|
|
3425
|
+
const selectPanel = props.selectPanel;
|
|
3426
|
+
(0, react.useEffect)(() => {
|
|
3427
|
+
if (typeof document === "undefined") return;
|
|
3428
|
+
const onCapture = (event) => {
|
|
3429
|
+
const target = event.target;
|
|
3430
|
+
if (!(target instanceof Element)) return;
|
|
3431
|
+
if (target.closest("[data-sm-panel]") !== null) return;
|
|
3432
|
+
if (target.closest("[data-supermemory-card]") !== null) return;
|
|
3433
|
+
const control = target.closest("button, [role=\"button\"], a");
|
|
3434
|
+
if (control === null) return;
|
|
3435
|
+
if (!isNewSessionControl([
|
|
3436
|
+
control.getAttribute("aria-label"),
|
|
3437
|
+
control.getAttribute("title"),
|
|
3438
|
+
control.textContent
|
|
3439
|
+
].filter((value) => typeof value === "string").join(" "))) return;
|
|
3440
|
+
if (typeof api?.createHubSession !== "function") return;
|
|
3441
|
+
const workspace = typeof cwd === "function" ? String(cwd() ?? "") : "";
|
|
3442
|
+
if (!workspace) return;
|
|
3443
|
+
event.preventDefault();
|
|
3444
|
+
event.stopPropagation();
|
|
3445
|
+
const panelOpened = typeof selectPanel === "function" && selectPanel() === true;
|
|
3446
|
+
api.createHubSession(workspace, {}, "").then((result) => {
|
|
3447
|
+
if (result && result.status === "ok" && result.id) {
|
|
3448
|
+
publishHubReceipt({
|
|
3449
|
+
id: result.id,
|
|
3450
|
+
message: result.message,
|
|
3451
|
+
kind: "hub"
|
|
3452
|
+
});
|
|
3453
|
+
if (!panelOpened) api.openSession?.(result.id);
|
|
3454
|
+
return;
|
|
3455
|
+
}
|
|
3456
|
+
publishHubReceipt({
|
|
3457
|
+
id: "",
|
|
3458
|
+
message: result?.message || "创建中枢会话失败",
|
|
3459
|
+
kind: "hub"
|
|
3460
|
+
});
|
|
3461
|
+
if (!panelOpened) api.startSession?.();
|
|
3462
|
+
}).catch((error) => {
|
|
3463
|
+
publishHubReceipt({
|
|
3464
|
+
id: "",
|
|
3465
|
+
message: "创建中枢会话失败:" + String(error instanceof Error ? error.message : error),
|
|
3466
|
+
kind: "hub"
|
|
3467
|
+
});
|
|
3468
|
+
if (!panelOpened) api.startSession?.();
|
|
3469
|
+
});
|
|
3470
|
+
};
|
|
3471
|
+
document.addEventListener("click", onCapture, true);
|
|
3472
|
+
return () => document.removeEventListener("click", onCapture, true);
|
|
3473
|
+
}, [
|
|
3474
|
+
api,
|
|
3475
|
+
cwd,
|
|
3476
|
+
selectPanel
|
|
3477
|
+
]);
|
|
3478
|
+
return null;
|
|
3479
|
+
}
|
|
3480
|
+
// src/client/session-badge.tsx
|
|
3481
|
+
/**
|
|
3482
|
+
* Sidebar session-row badge (GUI 问题③, R31 需求②): marks the sessions this
|
|
3483
|
+
* plugin knows about, so a hub session, the branches it dispatched to and a
|
|
3484
|
+
* topic-set hub stay distinguishable in the left sidebar.
|
|
3485
|
+
*
|
|
3486
|
+
* Seated in `sidebar.session.row.trailing`. The host gates that cell by
|
|
3487
|
+
* `!row.blank` only (upstream in dsh-client-ui-workspace's Rows component:
|
|
3488
|
+
* the trailing `rowResting` span wraps the time label, the slot render and the
|
|
3489
|
+
* pin mark, all inside `{!row.blank && …}`), so the badge stays visible while
|
|
3490
|
+
* the session runs and in approval states. It USED to sit in
|
|
3491
|
+
* `sidebar.session.row.leading`, whose gate is
|
|
3492
|
+
* `!row.archived && !row.blank && (showStatus ? <SessionStatusDots/> : renderSlot(...))`
|
|
3493
|
+
* with `showStatus = primary status is not idle` — a busy row kept its status
|
|
3494
|
+
* dot in that cell and the badge disappeared (the 「运行中隐藏」 report). The
|
|
3495
|
+
* trailing slot has no other registrant in the host bundle (verified in
|
|
3496
|
+
* app.asar). Known limitation, unchanged by the move: a blank row (no first
|
|
3497
|
+
* message) renders neither cell, so a brand-new empty hub session shows no
|
|
3498
|
+
* badge until it has a message.
|
|
3499
|
+
*
|
|
3500
|
+
* R19 需求③④ + R31 需求②: four kinds are projected by the host
|
|
3501
|
+
* `sessionBadge()` and rendered here —
|
|
3502
|
+
* - `branch` (a plugin-minted `branch-*`/`fork-*` session, or a fork member):
|
|
3503
|
+
* the work branch badge. A fresh dispatch is recorded as `kind:'root'`, so
|
|
3504
|
+
* the id prefix — not the member kind — decides this case;
|
|
3505
|
+
* - `hub-set` (a HOST session that is the set's root member, e.g. the session
|
|
3506
|
+
* `createTopicSetSession` created): a 「话题集」 badge carrying the set name,
|
|
3507
|
+
* so a topic-set hub is no longer mislabelled as a branch (the R18
|
|
3508
|
+
* conflation) and is not left unmarked;
|
|
3509
|
+
* - `hub` (R31 需求②; R35 tightened): a session with a POSITIVE `hub_sessions`
|
|
3510
|
+
* record — the same mark resolveRole trusts. The old `session-*` id-shape
|
|
3511
|
+
* guess is gone (a stale/foreign session-* id must not claim 「中枢」);
|
|
3512
|
+
* - `none` (R31 需求②: a plugin branch that has not joined a set yet, an
|
|
3513
|
+
* ordinary session, or an id the plugin cannot classify): renders nothing.
|
|
3514
|
+
* The badge is a projection of host membership and positive hub records; it
|
|
3515
|
+
* never fabricates one when the read fails.
|
|
3516
|
+
* @module supermemory/client/session-badge
|
|
3517
|
+
*/
|
|
3518
|
+
const BADGE_CSS = [
|
|
3519
|
+
".sm-sb-badge{display:inline-flex;align-items:center;gap:3px;flex:none;box-sizing:border-box;height:16px;padding:0 6px 0 4px;border-radius:99px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));background:var(--dsw-alias-bg-layer-2,#2c2c2e);color:var(--dsw-alias-label-secondary,#cfd3d6);font-size:10px;line-height:14px;opacity:.8;cursor:default;user-select:none;vertical-align:middle}",
|
|
3520
|
+
".sm-sb-badge:hover{opacity:1}",
|
|
3521
|
+
".sm-sb-badge[data-kind=\"hub-set\"]{color:var(--dsw-alias-link,#7aaaff);border-color:color-mix(in srgb,var(--dsw-alias-link,#7aaaff) 45%,transparent)}",
|
|
3522
|
+
".sm-sb-badge[data-kind=\"hub\"]{color:var(--dsw-alias-state-done-primary,#8b5cf6);border-color:color-mix(in srgb,var(--dsw-alias-state-done-primary,#8b5cf6) 45%,transparent)}",
|
|
3523
|
+
".sm-sb-badge svg{display:block;flex:none}"
|
|
3524
|
+
].join("\n");
|
|
3525
|
+
let cssInstalled = false;
|
|
3526
|
+
function installCss() {
|
|
3527
|
+
if (cssInstalled || typeof document === "undefined") return;
|
|
3528
|
+
cssInstalled = true;
|
|
3529
|
+
const style = document.createElement("style");
|
|
3530
|
+
style.setAttribute("data-plugin", "dsh-supermemory");
|
|
3531
|
+
style.textContent = BADGE_CSS;
|
|
3532
|
+
document.head.append(style);
|
|
3533
|
+
}
|
|
3534
|
+
const badgeCache = /* @__PURE__ */ new Map();
|
|
3535
|
+
/** Negative (`hub`/`none`) answers expire fast; a later dispatch may add the member. */
|
|
3536
|
+
const HUB_BADGE_TTL_MS = 8e3;
|
|
3537
|
+
/** Mounted rows subscribe here so invalidateBadge() updates them immediately. */
|
|
3538
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
3539
|
+
function readBadgeCache(sessionId) {
|
|
3540
|
+
const entry = badgeCache.get(sessionId);
|
|
3541
|
+
if (!entry) return void 0;
|
|
3542
|
+
if (entry.badge.kind === "branch") return entry.badge;
|
|
3543
|
+
return Date.now() - entry.at < HUB_BADGE_TTL_MS ? entry.badge : void 0;
|
|
3544
|
+
}
|
|
3545
|
+
/**
|
|
3546
|
+
* Drop the cached membership for one session (or every session) and re-render
|
|
3547
|
+
* the mounted badges.
|
|
3548
|
+
*
|
|
3549
|
+
* Called after a panel hub refresh and after a dispatch receipt: both are
|
|
3550
|
+
* moments when a session may have just joined a topic set.
|
|
3551
|
+
*/
|
|
3552
|
+
function invalidateBadge(sessionId) {
|
|
3553
|
+
if (sessionId) badgeCache.delete(sessionId);
|
|
3554
|
+
else badgeCache.clear();
|
|
3555
|
+
for (const listener of [...listeners]) try {
|
|
3556
|
+
listener();
|
|
3557
|
+
} catch {}
|
|
3558
|
+
}
|
|
3559
|
+
/**
|
|
3560
|
+
* Render the badge for one session row.
|
|
3561
|
+
* @returns the badge for a topic-set branch / topic-set hub / plugin hub,
|
|
3562
|
+
* null for an unclassified session (`none`) or an unreadable row.
|
|
3563
|
+
*/
|
|
3564
|
+
function SupermemorySessionBadge(props) {
|
|
3565
|
+
installCss();
|
|
3566
|
+
const t = typeof props.t === "function" ? props.t : (key) => key;
|
|
3567
|
+
const { api, sessionId } = props;
|
|
3568
|
+
const [badge, setBadge] = (0, react.useState)(() => readBadgeCache(sessionId));
|
|
3569
|
+
const [revision, setRevision] = (0, react.useState)(0);
|
|
3570
|
+
(0, react.useEffect)(() => {
|
|
3571
|
+
const listener = () => {
|
|
3572
|
+
setBadge(readBadgeCache(sessionId));
|
|
3573
|
+
setRevision((value) => value + 1);
|
|
3574
|
+
};
|
|
3575
|
+
listeners.add(listener);
|
|
3576
|
+
return () => {
|
|
3577
|
+
listeners.delete(listener);
|
|
3578
|
+
};
|
|
3579
|
+
}, [sessionId]);
|
|
3580
|
+
(0, react.useEffect)(() => {
|
|
3581
|
+
let alive = true;
|
|
3582
|
+
try {
|
|
3583
|
+
const cached = readBadgeCache(sessionId);
|
|
3584
|
+
if (cached !== void 0) {
|
|
3585
|
+
setBadge(cached);
|
|
3586
|
+
return () => {
|
|
3587
|
+
alive = false;
|
|
3588
|
+
};
|
|
3589
|
+
}
|
|
3590
|
+
api.sessionBadge(sessionId).then((result) => {
|
|
3591
|
+
badgeCache.set(sessionId, {
|
|
3592
|
+
badge: result,
|
|
3593
|
+
at: Date.now()
|
|
3594
|
+
});
|
|
3595
|
+
if (alive) setBadge(result);
|
|
3596
|
+
}, () => {});
|
|
3597
|
+
} catch {}
|
|
3598
|
+
return () => {
|
|
3599
|
+
alive = false;
|
|
3600
|
+
};
|
|
3601
|
+
}, [
|
|
3602
|
+
api,
|
|
3603
|
+
sessionId,
|
|
3604
|
+
revision
|
|
3605
|
+
]);
|
|
3606
|
+
if (!badge || badge.kind === "none") return null;
|
|
3607
|
+
const isBranch = badge.kind === "branch";
|
|
3608
|
+
const isHub = badge.kind === "hub";
|
|
3609
|
+
const stop = (event) => {
|
|
3610
|
+
event.stopPropagation();
|
|
3611
|
+
};
|
|
3612
|
+
const glyph = isBranch ? (0, react.createElement)("svg", {
|
|
3613
|
+
key: "glyph",
|
|
3614
|
+
width: 12,
|
|
3615
|
+
height: 12,
|
|
3616
|
+
viewBox: "0 0 24 24",
|
|
3617
|
+
fill: "none",
|
|
3618
|
+
stroke: "currentColor",
|
|
3619
|
+
strokeWidth: 1.8,
|
|
3620
|
+
strokeLinecap: "round",
|
|
3621
|
+
strokeLinejoin: "round",
|
|
3622
|
+
"aria-hidden": true,
|
|
3623
|
+
focusable: false
|
|
3624
|
+
}, (0, react.createElement)("path", {
|
|
3625
|
+
key: "a",
|
|
3626
|
+
d: "M6 3v12"
|
|
3627
|
+
}), (0, react.createElement)("circle", {
|
|
3628
|
+
key: "b",
|
|
3629
|
+
cx: 18,
|
|
3630
|
+
cy: 6,
|
|
3631
|
+
r: 3
|
|
3632
|
+
}), (0, react.createElement)("circle", {
|
|
3633
|
+
key: "c",
|
|
3634
|
+
cx: 6,
|
|
3635
|
+
cy: 18,
|
|
3636
|
+
r: 3
|
|
3637
|
+
}), (0, react.createElement)("path", {
|
|
3638
|
+
key: "d",
|
|
3639
|
+
d: "M18 9a9 9 0 0 1-9 9"
|
|
3640
|
+
})) : isHub ? (0, react.createElement)("svg", {
|
|
3641
|
+
key: "glyph",
|
|
3642
|
+
width: 12,
|
|
3643
|
+
height: 12,
|
|
3644
|
+
viewBox: "0 0 24 24",
|
|
3645
|
+
fill: "none",
|
|
3646
|
+
stroke: "currentColor",
|
|
3647
|
+
strokeWidth: 1.8,
|
|
3648
|
+
strokeLinecap: "round",
|
|
3649
|
+
strokeLinejoin: "round",
|
|
3650
|
+
"aria-hidden": true,
|
|
3651
|
+
focusable: false
|
|
3652
|
+
}, (0, react.createElement)("circle", {
|
|
3653
|
+
key: "a",
|
|
3654
|
+
cx: 12,
|
|
3655
|
+
cy: 12,
|
|
3656
|
+
r: 2.4
|
|
3657
|
+
}), (0, react.createElement)("path", {
|
|
3658
|
+
key: "b",
|
|
3659
|
+
d: "M12 3.2v2.6"
|
|
3660
|
+
}), (0, react.createElement)("path", {
|
|
3661
|
+
key: "c",
|
|
3662
|
+
d: "M12 18.2v2.6"
|
|
3663
|
+
}), (0, react.createElement)("path", {
|
|
3664
|
+
key: "d",
|
|
3665
|
+
d: "M3.2 12h2.6"
|
|
3666
|
+
}), (0, react.createElement)("path", {
|
|
3667
|
+
key: "e",
|
|
3668
|
+
d: "M18.2 12h2.6"
|
|
3669
|
+
}), (0, react.createElement)("path", {
|
|
3670
|
+
key: "f",
|
|
3671
|
+
d: "M5.8 5.8l1.9 1.9"
|
|
3672
|
+
}), (0, react.createElement)("path", {
|
|
3673
|
+
key: "g",
|
|
3674
|
+
d: "M16.3 16.3l1.9 1.9"
|
|
3675
|
+
}), (0, react.createElement)("path", {
|
|
3676
|
+
key: "h",
|
|
3677
|
+
d: "M18.2 5.8l-1.9 1.9"
|
|
3678
|
+
}), (0, react.createElement)("path", {
|
|
3679
|
+
key: "i",
|
|
3680
|
+
d: "M7.7 16.3l-1.9 1.9"
|
|
3681
|
+
})) : (0, react.createElement)("svg", {
|
|
3682
|
+
key: "glyph",
|
|
3683
|
+
width: 12,
|
|
3684
|
+
height: 12,
|
|
3685
|
+
viewBox: "0 0 24 24",
|
|
3686
|
+
fill: "none",
|
|
3687
|
+
stroke: "currentColor",
|
|
3688
|
+
strokeWidth: 1.8,
|
|
3689
|
+
strokeLinecap: "round",
|
|
3690
|
+
strokeLinejoin: "round",
|
|
3691
|
+
"aria-hidden": true,
|
|
3692
|
+
focusable: false
|
|
3693
|
+
}, (0, react.createElement)("path", {
|
|
3694
|
+
key: "a",
|
|
3695
|
+
d: "M4 7a8 5 0 1 0 16 0 8 5 0 1 0-16 0"
|
|
3696
|
+
}), (0, react.createElement)("path", {
|
|
3697
|
+
key: "b",
|
|
3698
|
+
d: "M4 7v6a8 5 0 0 0 16 0V7"
|
|
3699
|
+
}));
|
|
3700
|
+
return (0, react.createElement)("span", {
|
|
3701
|
+
key: "badge",
|
|
3702
|
+
className: "sm-sb-badge",
|
|
3703
|
+
"data-kind": badge.kind,
|
|
3704
|
+
title: isBranch ? t("badge.tip", { title: badge.topicSetTitle }) : isHub ? t("badge.hub.tip") : t("badge.hubSet.tip", { title: badge.topicSetTitle }),
|
|
3705
|
+
onClick: stop
|
|
3706
|
+
}, glyph, (0, react.createElement)("span", { key: "text" }, isBranch ? t("badge.branch") : isHub ? t("badge.hub") : t("badge.hubSet")));
|
|
3707
|
+
}
|
|
3708
|
+
function record(value) {
|
|
3709
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
3710
|
+
}
|
|
3711
|
+
function text(value) {
|
|
3712
|
+
return typeof value === "string" ? value : "";
|
|
3713
|
+
}
|
|
3714
|
+
/** Last four characters of an id (the documented title fallback). */
|
|
3715
|
+
function idTail(id) {
|
|
3716
|
+
const value = text(id).trim();
|
|
3717
|
+
return value.length > 4 ? value.slice(-4) : value;
|
|
3718
|
+
}
|
|
3719
|
+
/** Parse the plugin's source marker; null for every message the card must not own. */
|
|
3720
|
+
function cardMetaOf(source) {
|
|
3721
|
+
const shaped = record(source);
|
|
3722
|
+
if (!shaped) return null;
|
|
3723
|
+
const form = text(shaped.form);
|
|
3724
|
+
const isRelay = text(shaped.kind) === "supermemory" && form === "relay";
|
|
3725
|
+
if (!isRelay && !(form === "supermemory-dispatch")) return null;
|
|
3726
|
+
const rawKind = text(shaped.fromKind);
|
|
3727
|
+
return {
|
|
3728
|
+
kind: rawKind === "hub" || rawKind === "branch" || rawKind === "group" || rawKind === "system" ? rawKind : isRelay ? "branch" : "hub",
|
|
3729
|
+
fromSessionId: text(shaped.fromSessionId),
|
|
3730
|
+
fromTitle: text(shaped.fromTitle),
|
|
3731
|
+
task: text(shaped.task),
|
|
3732
|
+
topicSetTitle: text(shaped.topicSetTitle),
|
|
3733
|
+
capability: text(shaped.capability),
|
|
3734
|
+
dispatchId: text(shaped.dispatchId),
|
|
3735
|
+
groupId: text(shaped.groupId),
|
|
3736
|
+
status: text(shaped.status)
|
|
3737
|
+
};
|
|
3738
|
+
}
|
|
3739
|
+
/**
|
|
3740
|
+
* The source label the card title uses: the sender's session title, else the
|
|
3741
|
+
* id's last four characters, else a neutral placeholder (never an empty title).
|
|
3742
|
+
*/
|
|
3743
|
+
function cardSourceLabel(meta) {
|
|
3744
|
+
const title = text(meta.fromTitle).trim();
|
|
3745
|
+
if (title) return title;
|
|
3746
|
+
return idTail(meta.fromSessionId) || "未知会话";
|
|
3747
|
+
}
|
|
3748
|
+
// src/client/chat-card.tsx
|
|
3749
|
+
/**
|
|
3750
|
+
* R32 需求③——render hub↔branch requests as ONE collapsible card in both
|
|
3751
|
+
* directions, titled "来自 <来源会话> 的执行请求".
|
|
3752
|
+
*
|
|
3753
|
+
* Why a client slot and not just the host card:
|
|
3754
|
+
* - the host's turn-trigger card derives its title only from \`source.kind\`
|
|
3755
|
+
* ("收到执行请求") and a branch's first dispatch input is a \`user\` message
|
|
3756
|
+
* (R25 recency), so neither direction carries the sender's name;
|
|
3757
|
+
* - the plugin owns the messages that carry its marker (\\`chat-card.ts\\`), so it
|
|
3758
|
+
* shadows the two keyed cells (\`user\`, \`turn-trigger\`) at priority -100 and
|
|
3759
|
+
* delegates EVERY other message back to the host's shipped renderer via
|
|
3760
|
+
* \`entries()\`. Other triggers (goal/subagent/schedule/...) are untouched.
|
|
3761
|
+
*
|
|
3762
|
+
* The slot machinery is DSH's documented replacement path for a keyed cell;
|
|
3763
|
+
* only the client bundle is replaced here, the host checkout is never edited.
|
|
3764
|
+
* @module supermemory/client/chat-card
|
|
3765
|
+
*/
|
|
3766
|
+
/**
|
|
3767
|
+
* The host locale namespace the keyed chat cells are registered under. The
|
|
3768
|
+
* shipped renderers' `t` comes from the registration's `locale` option, so a
|
|
3769
|
+
* shadowing cell that omits it hands the host renderer `t === undefined`.
|
|
3770
|
+
*/
|
|
3771
|
+
const CHAT_LOCALE_NS = "chat";
|
|
3772
|
+
/**
|
|
3773
|
+
* Delegation props for the host's shipped renderer.
|
|
3774
|
+
*
|
|
3775
|
+
* The shipped UserMessageNodeView needs `t` (from `locale`) and
|
|
3776
|
+
* `renderSlotChain` (from a declared child, or an injected no-op); the
|
|
3777
|
+
* turn-trigger/context views need `t`. The host injects both through our
|
|
3778
|
+
* registration, but a shell that binds our cell without the locale/child face
|
|
3779
|
+
* must not turn every ordinary message into a crashed slot entry, so fill the
|
|
3780
|
+
* missing two defensively. A no-op `renderSlotChain` drops the
|
|
3781
|
+
* `conversation.chat.user.before` decoration of a delegated user message —
|
|
3782
|
+
* documented in DEV-NOTES §43.
|
|
3783
|
+
*/
|
|
3784
|
+
function delegationProps(props, env) {
|
|
3785
|
+
const next = { ...props };
|
|
3786
|
+
if (typeof next.t !== "function" && env) next.t = env.t;
|
|
3787
|
+
if (typeof next.renderSlotChain !== "function") next.renderSlotChain = () => null;
|
|
3788
|
+
return next;
|
|
3789
|
+
}
|
|
3790
|
+
const CSS_ID = "supermemory-chat-card-css";
|
|
3791
|
+
/** One translator bound at render time (locale switches take effect). */
|
|
3792
|
+
function translator(ctx) {
|
|
3793
|
+
return (key, params) => {
|
|
3794
|
+
try {
|
|
3795
|
+
return ctx.locale.bind(NS)(key, params);
|
|
3796
|
+
} catch {
|
|
3797
|
+
return key;
|
|
3798
|
+
}
|
|
3799
|
+
};
|
|
3800
|
+
}
|
|
3801
|
+
/** Find the host's shipped renderer for one keyed cell (skip our own entry). */
|
|
3802
|
+
function findOriginal(ctx, key, ours) {
|
|
3803
|
+
try {
|
|
3804
|
+
const candidates = (ctx.slots.entries?.("conversation.chat.node") ?? []).filter((entry) => entry.options?.key === key && entry.options?.id !== ours && entry.component !== void 0).sort((left, right) => (left.options?.priority ?? 0) - (right.options?.priority ?? 0));
|
|
3805
|
+
if (candidates.length > 0) return candidates[0].component;
|
|
3806
|
+
} catch {}
|
|
3807
|
+
}
|
|
3808
|
+
/** The text of a message's content blocks (the model-facing body). */
|
|
3809
|
+
function contentText(content) {
|
|
3810
|
+
if (!Array.isArray(content)) return "";
|
|
3811
|
+
const parts = [];
|
|
3812
|
+
for (const block of content) {
|
|
3813
|
+
if (typeof block !== "object" || block === null) continue;
|
|
3814
|
+
const shaped = block;
|
|
3815
|
+
if (shaped.type === "text" && typeof shaped.text === "string" && shaped.text) parts.push(shaped.text);
|
|
3816
|
+
}
|
|
3817
|
+
return parts.join("\n");
|
|
3818
|
+
}
|
|
3819
|
+
/** Clock label for the card header (never a locale-dependent title). */
|
|
3820
|
+
function clockText(time) {
|
|
3821
|
+
if (typeof time !== "number" || !Number.isFinite(time)) return "";
|
|
3822
|
+
try {
|
|
3823
|
+
return new Date(time).toLocaleTimeString([], {
|
|
3824
|
+
hour: "2-digit",
|
|
3825
|
+
minute: "2-digit"
|
|
3826
|
+
});
|
|
3827
|
+
} catch {
|
|
3828
|
+
return "";
|
|
3829
|
+
}
|
|
3830
|
+
}
|
|
3831
|
+
/** One field row, rendered only when the source actually carries it. */
|
|
3832
|
+
function fieldRow(label, value, key) {
|
|
3833
|
+
if (!value) return null;
|
|
3834
|
+
return (0, react.createElement)("div", {
|
|
3835
|
+
key,
|
|
3836
|
+
className: "sm-chat-card-field"
|
|
3837
|
+
}, (0, react.createElement)("dt", {
|
|
3838
|
+
key: "k",
|
|
3839
|
+
className: "sm-chat-card-field-k"
|
|
3840
|
+
}, label), (0, react.createElement)("dd", {
|
|
3841
|
+
key: "v",
|
|
3842
|
+
className: "sm-chat-card-field-v"
|
|
3843
|
+
}, value));
|
|
3844
|
+
}
|
|
3845
|
+
/** The collapsible card itself. */
|
|
3846
|
+
function SupermemoryCard(props) {
|
|
3847
|
+
const { meta, node, env } = props;
|
|
3848
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
3849
|
+
const t = env?.t ?? ((key) => key);
|
|
3850
|
+
const title = t("chat.card.from", { session: cardSourceLabel(meta) });
|
|
3851
|
+
const kind = t("chat.card.kind." + meta.kind);
|
|
3852
|
+
const body = contentText(node?.data?.content);
|
|
3853
|
+
const time = clockText(node?.data?.time);
|
|
3854
|
+
const receipt = [meta.dispatchId, meta.status].filter(Boolean).join(" · ");
|
|
3855
|
+
const toggle = (event) => {
|
|
3856
|
+
try {
|
|
3857
|
+
event?.stopPropagation?.();
|
|
3858
|
+
} catch {}
|
|
3859
|
+
setOpen((value) => !value);
|
|
3860
|
+
};
|
|
3861
|
+
return (0, react.createElement)("section", {
|
|
3862
|
+
className: "sm-chat-card",
|
|
3863
|
+
"data-supermemory-card": meta.kind
|
|
3864
|
+
}, (0, react.createElement)("button", {
|
|
3865
|
+
key: "head",
|
|
3866
|
+
type: "button",
|
|
3867
|
+
className: "sm-chat-card-head",
|
|
3868
|
+
"aria-expanded": String(open),
|
|
3869
|
+
"aria-label": t(open ? "chat.card.collapse" : "chat.card.expand"),
|
|
3870
|
+
onClick: toggle
|
|
3871
|
+
}, (0, react.createElement)("span", {
|
|
3872
|
+
key: "dot",
|
|
3873
|
+
className: "sm-chat-card-dot",
|
|
3874
|
+
"aria-hidden": "true"
|
|
3875
|
+
}, "↔"), (0, react.createElement)("span", {
|
|
3876
|
+
key: "title",
|
|
3877
|
+
className: "sm-chat-card-title"
|
|
3878
|
+
}, title), (0, react.createElement)("span", {
|
|
3879
|
+
key: "kind",
|
|
3880
|
+
className: "sm-chat-card-badge"
|
|
3881
|
+
}, kind), time ? (0, react.createElement)("time", {
|
|
3882
|
+
key: "time",
|
|
3883
|
+
className: "sm-chat-card-time"
|
|
3884
|
+
}, time) : null, (0, react.createElement)("span", {
|
|
3885
|
+
key: "chevron",
|
|
3886
|
+
className: "sm-chat-card-chevron",
|
|
3887
|
+
"aria-hidden": "true"
|
|
3888
|
+
}, open ? "▴" : "▾")), open ? (0, react.createElement)("div", {
|
|
3889
|
+
key: "body",
|
|
3890
|
+
className: "sm-chat-card-body"
|
|
3891
|
+
}, (0, react.createElement)("dl", {
|
|
3892
|
+
key: "fields",
|
|
3893
|
+
className: "sm-chat-card-fields"
|
|
3894
|
+
}, fieldRow(t("chat.card.task"), meta.task, "task"), fieldRow(t("chat.card.topicSet"), meta.topicSetTitle, "set"), fieldRow(t("chat.card.capability"), meta.capability, "cap"), fieldRow(t("chat.card.dispatch"), receipt, "receipt"), meta.groupId ? fieldRow(t("chat.card.kind.group"), meta.groupId, "group") : null, fieldRow(t("chat.card.sourceId"), meta.fromSessionId, "source")), body ? (0, react.createElement)("pre", {
|
|
3895
|
+
key: "text",
|
|
3896
|
+
className: "sm-chat-card-text"
|
|
3897
|
+
}, body) : (0, react.createElement)("div", {
|
|
3898
|
+
key: "empty",
|
|
3899
|
+
className: "sm-chat-card-empty"
|
|
3900
|
+
}, t("chat.card.empty"))) : null);
|
|
3901
|
+
}
|
|
3902
|
+
/**
|
|
3903
|
+
* Build the keyed-cell component for one host node kind.
|
|
3904
|
+
* Card-marked messages render the card; everything else is delegated to the
|
|
3905
|
+
* host's shipped renderer, so no other user/trigger message changes.
|
|
3906
|
+
*/
|
|
3907
|
+
function createCardComponent(key, ours) {
|
|
3908
|
+
return function SupermemoryChatNodeCard(props) {
|
|
3909
|
+
const env = props.smCardEnv;
|
|
3910
|
+
const node = props.node;
|
|
3911
|
+
const meta = cardMetaOf(node?.data?.source);
|
|
3912
|
+
if (!meta) {
|
|
3913
|
+
const Original = env?.findOriginal(key, ours);
|
|
3914
|
+
if (Original !== void 0) return (0, react.createElement)(Original, delegationProps(props, env));
|
|
3915
|
+
const fallback = contentText(node?.data?.content);
|
|
3916
|
+
return fallback ? (0, react.createElement)("div", {
|
|
3917
|
+
key: "fallback",
|
|
3918
|
+
className: "sm-chat-card-fallback"
|
|
3919
|
+
}, (0, react.createElement)("pre", {
|
|
3920
|
+
key: "text",
|
|
3921
|
+
className: "sm-chat-card-text"
|
|
3922
|
+
}, fallback)) : null;
|
|
3923
|
+
}
|
|
3924
|
+
return (0, react.createElement)(SupermemoryCard, {
|
|
3925
|
+
meta,
|
|
3926
|
+
env,
|
|
3927
|
+
node
|
|
3928
|
+
});
|
|
3929
|
+
};
|
|
3930
|
+
}
|
|
3931
|
+
/** Register one cell (called for both directions). */
|
|
3932
|
+
function registerCell(ctx, key) {
|
|
3933
|
+
const id = "supermemory-chat-card-" + key;
|
|
3934
|
+
return ctx.slots.register({
|
|
3935
|
+
name: "conversation.chat.node",
|
|
3936
|
+
key,
|
|
3937
|
+
id,
|
|
3938
|
+
priority: -100,
|
|
3939
|
+
locale: CHAT_LOCALE_NS,
|
|
3940
|
+
inject: () => ({
|
|
3941
|
+
smCardEnv: {
|
|
3942
|
+
t: translator(ctx),
|
|
3943
|
+
findOriginal: (target, ours) => findOriginal(ctx, target, ours)
|
|
3944
|
+
},
|
|
3945
|
+
...key === "user" || key === "steering" ? { renderSlotChain: () => null } : {}
|
|
3946
|
+
})
|
|
3947
|
+
}, createCardComponent(key, id));
|
|
3948
|
+
}
|
|
3949
|
+
/** Inject the card stylesheet once per page. */
|
|
3950
|
+
function ensureCss() {
|
|
3951
|
+
if (typeof document === "undefined") return;
|
|
3952
|
+
if (document.getElementById(CSS_ID)) return;
|
|
3953
|
+
const style = document.createElement("style");
|
|
3954
|
+
style.id = CSS_ID;
|
|
3955
|
+
style.textContent = `
|
|
3956
|
+
.sm-chat-card{margin:6px 0;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.12));border-radius:10px;background:var(--dsw-alias-bg-layer-1,rgba(255,255,255,.03));overflow:hidden;font-size:12.5px}
|
|
3957
|
+
.sm-chat-card-head{display:flex;align-items:center;gap:8px;width:100%;padding:8px 12px;border:0;background:none;color:inherit;font:inherit;text-align:left;cursor:pointer}
|
|
3958
|
+
.sm-chat-card-head:hover{background:rgba(255,255,255,.04)}
|
|
3959
|
+
.sm-chat-card-dot{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:50%;background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.08));font-size:11px;opacity:.85}
|
|
3960
|
+
.sm-chat-card-title{font-weight:600;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
3961
|
+
.sm-chat-card-badge{flex:none;font-size:10.5px;padding:1px 6px;border-radius:999px;border:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.14));opacity:.8}
|
|
3962
|
+
.sm-chat-card-time{flex:none;margin-left:auto;font-size:11px;opacity:.55}
|
|
3963
|
+
.sm-chat-card-chevron{flex:none;font-size:11px;opacity:.6}
|
|
3964
|
+
.sm-chat-card-body{padding:0 12px 10px;border-top:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.08))}
|
|
3965
|
+
.sm-chat-card-fields{display:grid;grid-template-columns:auto 1fr;gap:4px 10px;margin:8px 0}
|
|
3966
|
+
.sm-chat-card-field{display:contents}
|
|
3967
|
+
.sm-chat-card-field-k{opacity:.6;white-space:nowrap}
|
|
3968
|
+
.sm-chat-card-field-v{min-width:0;word-break:break-word}
|
|
3969
|
+
.sm-chat-card-text{margin:0;padding:8px;border-radius:8px;background:rgba(0,0,0,.18);white-space:pre-wrap;word-break:break-word;max-height:360px;overflow:auto;font-family:var(--dsw-font-mono,ui-monospace,SFMono-Regular,Menlo,monospace);font-size:12px;line-height:1.5}
|
|
3970
|
+
.sm-chat-card-empty{opacity:.6;padding:6px 0}
|
|
3971
|
+
.sm-chat-card-fallback{margin:6px 0}
|
|
3972
|
+
`;
|
|
3973
|
+
document.head.append(style);
|
|
3974
|
+
}
|
|
3975
|
+
/**
|
|
3976
|
+
* Mount the two shadowing card cells.
|
|
3977
|
+
*
|
|
3978
|
+
* If the shell does not expose raw registrations, the plugin deliberately does
|
|
3979
|
+
* NOT shadow anything: replacing a cell without a way to delegate would blank
|
|
3980
|
+
* every ordinary user message. That degradation is logged (never silent).
|
|
3981
|
+
* @param ctx - browser root context.
|
|
3982
|
+
*/
|
|
3983
|
+
function attachChatCards(ctx) {
|
|
3984
|
+
if (typeof ctx.slots.entries !== "function") {
|
|
3985
|
+
console.warn("supermemory: conversation.chat.node entries() unavailable; hub/branch chat card not mounted");
|
|
3986
|
+
return;
|
|
3987
|
+
}
|
|
3988
|
+
ensureCss();
|
|
3989
|
+
ctx.effect(() => ctx.slots.inject("conversation.chat.node", () => {
|
|
3990
|
+
const disposers = [
|
|
3991
|
+
"user",
|
|
3992
|
+
"steering",
|
|
3993
|
+
"turn-trigger",
|
|
3994
|
+
"context"
|
|
3995
|
+
].map((cell) => registerCell(ctx, cell));
|
|
3996
|
+
return () => {
|
|
3997
|
+
for (const dispose of disposers) dispose();
|
|
3998
|
+
};
|
|
3999
|
+
}), "supermemory: chat card");
|
|
4000
|
+
}
|
|
4001
|
+
// src/client/index.ts
|
|
4002
|
+
const name = "dsh-supermemory-client";
|
|
4003
|
+
/** Services this client half needs. */
|
|
4004
|
+
const inject = [
|
|
4005
|
+
"slots",
|
|
4006
|
+
"locale",
|
|
4007
|
+
"remote",
|
|
4008
|
+
"uiWorkspace"
|
|
4009
|
+
];
|
|
4010
|
+
/** The panel id shared by the sidebar launcher and the main-slot key. */
|
|
4011
|
+
const PANEL_ID = "supermemory";
|
|
4012
|
+
/** Unwrap one RemoteResult, throwing a readable error on failure. */
|
|
4013
|
+
function unwrap(result) {
|
|
4014
|
+
if (result.ok) return result.value;
|
|
4015
|
+
const failure = result.error;
|
|
4016
|
+
throw new Error(failure?.message ?? "remote call failed");
|
|
4017
|
+
}
|
|
4018
|
+
/**
|
|
4019
|
+
* Build the panel API the components use: every host-panel call goes through
|
|
4020
|
+
* the mounted remote namespace; navigation goes through uiWorkspace.
|
|
4021
|
+
*/
|
|
4022
|
+
function buildApi(ctx) {
|
|
4023
|
+
let namespace;
|
|
4024
|
+
try {
|
|
4025
|
+
namespace = ctx.get("remote.supermemoryPanel");
|
|
4026
|
+
} catch {
|
|
4027
|
+
namespace = void 0;
|
|
4028
|
+
}
|
|
4029
|
+
if (!namespace) return void 0;
|
|
4030
|
+
const call = async (method, ...args) => {
|
|
4031
|
+
const fn = namespace[method];
|
|
4032
|
+
if (typeof fn !== "function") throw new Error(`supermemoryPanel.${method} unavailable`);
|
|
4033
|
+
return unwrap(await fn(...args));
|
|
4034
|
+
};
|
|
4035
|
+
return {
|
|
4036
|
+
loadHub: (cwd, sessionId) => call("hubState", cwd, sessionId),
|
|
4037
|
+
listMemories: (cwd, query) => call("listMemories", cwd, query, 200),
|
|
4038
|
+
createMemory: (cwd, text, key, title, tags) => call("createMemory", cwd, text, key, title, tags),
|
|
4039
|
+
updateMemory: (cwd, id, text, key, title, tags) => call("updateMemory", cwd, id, text, key, title, tags),
|
|
4040
|
+
deleteMemory: (cwd, id) => call("deleteMemory", cwd, id),
|
|
4041
|
+
setMemoryStatus: (cwd, id, status) => call("setMemoryStatus", cwd, id, status),
|
|
4042
|
+
listMemoryCollections: (cwd) => call("listMemoryCollections", cwd),
|
|
4043
|
+
listMemoriesByCollection: (cwd, collectionId, query) => call("listMemoriesByCollection", cwd, collectionId, query, 200),
|
|
4044
|
+
getMemoryDetail: (cwd, id) => call("getMemoryDetail", cwd, id),
|
|
4045
|
+
getHubPolicy: (cwd) => call("getHubPolicy", cwd),
|
|
4046
|
+
setHubPolicy: (cwd, patch) => call("setHubPolicy", cwd, patch),
|
|
4047
|
+
cleanupStaleHubPolicy: (cwd) => call("cleanupStaleHubPolicy", cwd),
|
|
4048
|
+
getModelDefaults: (cwd) => call("getModelDefaults", cwd),
|
|
4049
|
+
setModelDefaults: (cwd, patch) => call("setModelDefaults", cwd, patch),
|
|
4050
|
+
listSkills: (cwd) => call("listSkills", cwd),
|
|
4051
|
+
updateSkill: (cwd, name, patch) => call("updateSkill", cwd, name, patch),
|
|
4052
|
+
createTopicSet: (cwd, title, tags, summary) => call("createTopicSet", cwd, title, tags, summary),
|
|
4053
|
+
listHubSessions: (cwd) => call("listHubSessions", cwd),
|
|
4054
|
+
listHubBranches: (cwd, hubSessionId, limit) => call("listHubBranches", cwd, hubSessionId, limit),
|
|
4055
|
+
listAllTopicSets: (cwd) => call("listAllTopicSets", cwd),
|
|
4056
|
+
listAllBranches: (cwd, topicSetId, limit) => call("listAllBranches", cwd, topicSetId, limit),
|
|
4057
|
+
readSessionMessages: (sessionId, limit) => call("readSessionMessages", sessionId, limit),
|
|
4058
|
+
sendSessionMessage: (sessionId, text) => call("sendSessionMessage", sessionId, text),
|
|
4059
|
+
suggestMemoryShape: (text) => call("suggestMemoryShape", text),
|
|
4060
|
+
invalidateBadges: (sessionId) => {
|
|
4061
|
+
invalidateBadge(sessionId);
|
|
4062
|
+
},
|
|
4063
|
+
activate: async (sessionId, topicSetId) => call("activate", sessionId, topicSetId),
|
|
4064
|
+
updateTopicSetSummary: (id, summary, tags) => call("updateTopicSetSummary", id, summary, tags),
|
|
4065
|
+
createTopicSetSession: (cwd, ids, options, firstMessage) => call("createTopicSetSession", cwd, ids, options, firstMessage),
|
|
4066
|
+
createHubSession: (cwd, options, firstMessage) => call("createHubSession", cwd, options, firstMessage),
|
|
4067
|
+
followupTopicSet: (cwd, topicSetId, text) => call("followupTopicSet", cwd, topicSetId, text),
|
|
4068
|
+
listTools: (cwd) => call("listTools", cwd),
|
|
4069
|
+
editTool: (id, patch) => call("editTool", id, patch),
|
|
4070
|
+
deleteTool: (id) => call("deleteTool", id),
|
|
4071
|
+
runTool: (id, options) => call("runTool", id, options),
|
|
4072
|
+
acceptProposal: (cwd, id) => call("acceptProposal", cwd, id),
|
|
4073
|
+
declineProposal: (cwd, id) => call("declineProposal", cwd, id),
|
|
4074
|
+
listAgentPresets: () => call("listAgentPresets"),
|
|
4075
|
+
listModelCatalog: () => call("listModelCatalog"),
|
|
4076
|
+
listPermissions: () => call("listPermissions"),
|
|
4077
|
+
sessionBadge: (sessionId) => call("sessionBadge", sessionId),
|
|
4078
|
+
openSession: (sessionId) => {
|
|
4079
|
+
ctx.get("uiWorkspace")?.openSession(sessionId);
|
|
4080
|
+
},
|
|
4081
|
+
startSession: () => {
|
|
4082
|
+
ctx.get("uiWorkspace")?.startSession();
|
|
4083
|
+
},
|
|
4084
|
+
loadTopicSets: (cwd) => call("listTopicSets", cwd)
|
|
4085
|
+
};
|
|
4086
|
+
}
|
|
4087
|
+
/**
|
|
4088
|
+
* Resolve the workspace a click-created hub session should live in.
|
|
4089
|
+
*
|
|
4090
|
+
* The MAIN-VIEW session's own cwd wins: with more than one workspace open,
|
|
4091
|
+
* `workspaces.items[0].path` points the session (and every later write) at the
|
|
4092
|
+
* wrong project. Both services are optional seams: an older shell simply
|
|
4093
|
+
* yields '' and the New-session entry then leaves the click to the shell
|
|
4094
|
+
* instead of creating a session in an unknown workspace.
|
|
4095
|
+
*/
|
|
4096
|
+
function resolveCwd(ctx) {
|
|
4097
|
+
try {
|
|
4098
|
+
const byId = ctx.get("sessions")?.list?.getSnapshot?.()?.byId ?? {};
|
|
4099
|
+
for (const session of Object.values(byId)) {
|
|
4100
|
+
if ((session?.retainedBy?.mainView ?? 0) <= 0) continue;
|
|
4101
|
+
const cwd = session.cwd ?? session.header?.cwd;
|
|
4102
|
+
if (typeof cwd === "string" && cwd) return cwd;
|
|
4103
|
+
}
|
|
4104
|
+
} catch {}
|
|
4105
|
+
try {
|
|
4106
|
+
const items = ctx.get("workspaces")?.list?.getSnapshot?.()?.items ?? [];
|
|
4107
|
+
for (const item of items) if (typeof item?.path === "string" && item.path) return item.path;
|
|
4108
|
+
} catch {}
|
|
4109
|
+
return "";
|
|
4110
|
+
}
|
|
4111
|
+
/**
|
|
4112
|
+
* Open the SuperMemory panel in the shell's main column — the same
|
|
4113
|
+
* `layout.selectPanel(PANEL_ID)` call the shell's plugin-manager makes.
|
|
4114
|
+
*
|
|
4115
|
+
* The shell provides the layout service as a reflected value and its own
|
|
4116
|
+
* plugins read it as `ctx.layout`; `ctx.get('layout')` is the abstracted form.
|
|
4117
|
+
* Both are tried, because the reflected property is the verified one while
|
|
4118
|
+
* `get` keeps this working if the property is renamed. Returns false when
|
|
4119
|
+
* neither is usable, so the caller can fall back to opening the created
|
|
4120
|
+
* session directly — never a dead click.
|
|
4121
|
+
*/
|
|
4122
|
+
function selectSuperPanel(ctx) {
|
|
4123
|
+
try {
|
|
4124
|
+
const layout = ctx.layout ?? ctx.get("layout");
|
|
4125
|
+
const select = layout?.selectPanel;
|
|
4126
|
+
if (typeof select !== "function") return false;
|
|
4127
|
+
Promise.resolve(select.call(layout, PANEL_ID)).catch(() => {
|
|
4128
|
+
try {
|
|
4129
|
+
ctx.get("uiWorkspace")?.startSession();
|
|
4130
|
+
} catch {}
|
|
4131
|
+
});
|
|
4132
|
+
return true;
|
|
4133
|
+
} catch {
|
|
4134
|
+
return false;
|
|
4135
|
+
}
|
|
4136
|
+
}
|
|
4137
|
+
/**
|
|
4138
|
+
* Register the SuperMemory surfaces. Every registration is defensive: a
|
|
4139
|
+
* failure in one contribution must not take down the others (or the boot).
|
|
4140
|
+
* @param ctx - browser root context.
|
|
4141
|
+
*/
|
|
4142
|
+
async function apply(ctx) {
|
|
4143
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
4144
|
+
zh,
|
|
4145
|
+
en
|
|
4146
|
+
}), "supermemory: dictionaries");
|
|
4147
|
+
try {
|
|
4148
|
+
attachChatCards(ctx);
|
|
4149
|
+
} catch (error) {
|
|
4150
|
+
console.error("supermemory: chat card registration failed", error);
|
|
4151
|
+
}
|
|
4152
|
+
try {
|
|
4153
|
+
const remote = ctx.get("remote");
|
|
4154
|
+
if (remote && typeof remote.$mount === "function") await remote.$mount(PANEL_REMOTE);
|
|
4155
|
+
} catch (error) {
|
|
4156
|
+
console.error("supermemory: panel remote mount failed", error);
|
|
4157
|
+
}
|
|
4158
|
+
const api = buildApi(ctx);
|
|
4159
|
+
if (!api) {
|
|
4160
|
+
console.error("supermemory: panel remote unavailable; the panel stays empty");
|
|
4161
|
+
return;
|
|
4162
|
+
}
|
|
4163
|
+
const t = (key, params) => {
|
|
4164
|
+
return ctx.locale.bind(NS)(key, params);
|
|
4165
|
+
};
|
|
4166
|
+
const contribute = (label, attach) => {
|
|
4167
|
+
try {
|
|
4168
|
+
attach();
|
|
4169
|
+
} catch (error) {
|
|
4170
|
+
console.error(`supermemory: ${label} registration failed`, error);
|
|
4171
|
+
}
|
|
4172
|
+
};
|
|
4173
|
+
contribute("panel launcher", () => {
|
|
4174
|
+
ctx.effect(() => ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
|
|
4175
|
+
name: "sidebar.panellist",
|
|
4176
|
+
id: PANEL_ID,
|
|
4177
|
+
order: 25,
|
|
4178
|
+
locale: NS,
|
|
4179
|
+
label: () => t("panel")
|
|
4180
|
+
}, SupermemoryIcon)), "supermemory: panel launcher");
|
|
4181
|
+
});
|
|
4182
|
+
contribute("panel page", () => {
|
|
4183
|
+
ctx.effect(() => ctx.slots.inject("main", () => ctx.slots.register({
|
|
4184
|
+
name: "main",
|
|
4185
|
+
key: PANEL_ID,
|
|
4186
|
+
locale: NS,
|
|
4187
|
+
inject: () => ({ api })
|
|
4188
|
+
}, SupermemoryPanelPage)), "supermemory: panel page");
|
|
4189
|
+
});
|
|
4190
|
+
contribute("new-session entry", () => {
|
|
4191
|
+
ctx.effect(() => ctx.slots.inject("shell.overlay", () => ctx.slots.register({
|
|
4192
|
+
name: "shell.overlay",
|
|
4193
|
+
id: "supermemory-new-session",
|
|
4194
|
+
order: 30,
|
|
4195
|
+
locale: NS,
|
|
4196
|
+
inject: () => ({
|
|
4197
|
+
api,
|
|
4198
|
+
cwd: () => resolveCwd(ctx),
|
|
4199
|
+
selectPanel: () => selectSuperPanel(ctx)
|
|
4200
|
+
})
|
|
4201
|
+
}, NewSessionChoice)), "supermemory: new-session entry");
|
|
4202
|
+
});
|
|
4203
|
+
contribute("session badge", () => {
|
|
4204
|
+
ctx.effect(() => ctx.slots.inject("sidebar.session.row.trailing", () => ctx.slots.register({
|
|
4205
|
+
name: "sidebar.session.row.trailing",
|
|
4206
|
+
id: "supermemory-branch",
|
|
4207
|
+
order: 30,
|
|
4208
|
+
locale: NS,
|
|
4209
|
+
inject: () => ({ api })
|
|
4210
|
+
}, SupermemorySessionBadge)), "supermemory: session badge");
|
|
4211
|
+
});
|
|
4212
|
+
}
|
|
4213
|
+
exports.apply = apply;
|
|
4214
|
+
exports.inject = inject;
|
|
4215
|
+
exports.name = name;
|
|
4216
|
+
|
|
4217
|
+
return module.exports}});
|