dsh-plugin-agent-memory 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/client.js +21 -3
- package/docs/DETAIL.md +13 -0
- package/index.js +64 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ Open the plugin's settings page (or the panel's gear button) and set:
|
|
|
49
49
|
| `topK` | Max memories per recall (1–10, default 4) |
|
|
50
50
|
| `layers` | Memory layers injected each turn (default `L3,L2`, matching the official proxy) |
|
|
51
51
|
| `timeoutMs` | Per-request timeout (default 6000) |
|
|
52
|
-
| `kernelUrl` | Kernel API base for wiki / code-graph / skills (default: Hub host on port 8420) |
|
|
52
|
+
| `kernelUrl` | Kernel API base for wiki / code-graph / skills (default: Hub host on port 8420). The knowledge service address is discovered from the kernel, and the proxy endpoint is not used |
|
|
53
53
|
| `tools` | Register the four read-only asset tools (default on) |
|
|
54
54
|
| `debug` | Append diagnostics to `~/.dsh/agent-memory-debug.log` (default off, 256 KiB cap) |
|
|
55
55
|
|
package/client.js
CHANGED
|
@@ -138,7 +138,7 @@ window.__ModuleLoader__.load({
|
|
|
138
138
|
const [config, setConfig] = React.useState(null);
|
|
139
139
|
const [configured, setConfigured] = React.useState(true);
|
|
140
140
|
const [health, setHealth] = React.useState({ state: 'idle', text: '连接未检测' });
|
|
141
|
-
const [form, setForm] = React.useState({ hubUrl: '', instanceId: '', userKey: '' });
|
|
141
|
+
const [form, setForm] = React.useState({ hubUrl: '', instanceId: '', kernelUrl: '', userKey: '' });
|
|
142
142
|
const [flags, setFlags] = React.useState({ injectMemory: true, writeMemory: false });
|
|
143
143
|
const [refreshMs, setRefreshMs] = React.useState(10000);
|
|
144
144
|
const [saving, setSaving] = React.useState(false);
|
|
@@ -160,6 +160,7 @@ window.__ModuleLoader__.load({
|
|
|
160
160
|
setForm({
|
|
161
161
|
hubUrl: String(current.hubUrl ?? ''),
|
|
162
162
|
instanceId: String(current.instanceId ?? ''),
|
|
163
|
+
kernelUrl: String(current.kernelUrl ?? ''),
|
|
163
164
|
userKey: '',
|
|
164
165
|
});
|
|
165
166
|
setFlags({
|
|
@@ -181,9 +182,13 @@ window.__ModuleLoader__.load({
|
|
|
181
182
|
json(`${ROUTE}/health`)
|
|
182
183
|
.then((payload) => {
|
|
183
184
|
const agents = (payload.teams ?? []).reduce((total, team) => total + (team.agents ?? 0), 0);
|
|
185
|
+
const down = (payload.services ?? []).filter((service) => service.ok !== true);
|
|
184
186
|
setHealth({
|
|
185
|
-
state: 'ok',
|
|
186
|
-
text:
|
|
187
|
+
state: down.length === 0 && payload.ok !== false ? 'ok' : 'bad',
|
|
188
|
+
text:
|
|
189
|
+
down.length === 0
|
|
190
|
+
? `已连接 · ${payload.user?.username ?? '未知用户'} · ${(payload.teams ?? []).length} 团队 / ${agents} agent`
|
|
191
|
+
: `部分服务不可用:${down.map((service) => `${service.name}(${service.detail})`).join(';')}`,
|
|
187
192
|
});
|
|
188
193
|
})
|
|
189
194
|
.catch((failure) => setHealth({ state: 'bad', text: `连接失败:${String(failure.message ?? failure)}` }));
|
|
@@ -198,6 +203,7 @@ window.__ModuleLoader__.load({
|
|
|
198
203
|
body: JSON.stringify({
|
|
199
204
|
hubUrl: form.hubUrl,
|
|
200
205
|
instanceId: form.instanceId,
|
|
206
|
+
kernelUrl: form.kernelUrl,
|
|
201
207
|
userKey: form.userKey,
|
|
202
208
|
injectMemory: flags.injectMemory,
|
|
203
209
|
refreshMs,
|
|
@@ -402,6 +408,18 @@ window.__ModuleLoader__.load({
|
|
|
402
408
|
onChange: (event) => setForm({ ...form, instanceId: event.target.value }),
|
|
403
409
|
}),
|
|
404
410
|
),
|
|
411
|
+
h(
|
|
412
|
+
'label',
|
|
413
|
+
{ style: fieldStyle },
|
|
414
|
+
h('span', { style: fieldLabelStyle }, '内核地址(选填,默认 Hub 主机名:8420)'),
|
|
415
|
+
h('input', {
|
|
416
|
+
style: inputStyle,
|
|
417
|
+
type: 'text',
|
|
418
|
+
value: form.kernelUrl,
|
|
419
|
+
placeholder: 'http://memhub.example.com:8420',
|
|
420
|
+
onChange: (event) => setForm({ ...form, kernelUrl: event.target.value }),
|
|
421
|
+
}),
|
|
422
|
+
),
|
|
405
423
|
h(
|
|
406
424
|
'label',
|
|
407
425
|
{ style: fieldStyle },
|
package/docs/DETAIL.md
CHANGED
|
@@ -28,6 +28,19 @@
|
|
|
28
28
|
|
|
29
29
|
Host 半侧导出了 `z.object` 形式的 `Config`(`userKey` 标了 `role('secret')`),因此插件详情页也能看到同名字段的表单;字段保存走框架的 `configEditor`,写入后提示重启插件以重建内存状态。
|
|
30
30
|
|
|
31
|
+
## 需要配置哪些服务
|
|
32
|
+
|
|
33
|
+
AM 一套部署有四个服务,插件只用到其中三个,且只有两个需要填:
|
|
34
|
+
|
|
35
|
+
| 服务 | 本实例地址 | 插件是否用 | 配置项 |
|
|
36
|
+
| --- | --- | --- | --- |
|
|
37
|
+
| Panel UI(Memory Hub 控制面) | `:8125` | 用:`auth/verify`、`team/list`、`agent/list`、`chat-memory/*` | `hubUrl` + `userKey`(必填) |
|
|
38
|
+
| Core Gateway(记忆内核) | `:8420` | 用:`/v3/knowledge/list`、`/v3/skill/*` | `kernelUrl`(可留空,按 Hub 主机名 + 8420 推断) |
|
|
39
|
+
| Knowledge 知识服务 | `:8424` | 用:每个资源的 `/tools/list`、`/tools/call` | **不需要配**:地址由内核 `knowledge/list` 返回的 `service_url` 下发,一个实例可能有多个 |
|
|
40
|
+
| Proxy 客户端接入点 | `:8096` | **不用**:那条链路是把整轮 LLM 请求换到 AM,本插件走 Host 内直连 | 无 |
|
|
41
|
+
|
|
42
|
+
「检测连接」会分别探测这三个用到的服务,任何一项挂掉会在面板上直接点名。
|
|
43
|
+
|
|
31
44
|
## 边界
|
|
32
45
|
|
|
33
46
|
- user key 只存在 Host 进程里,浏览器侧只访问本机同源路由,不接触凭据。
|
package/index.js
CHANGED
|
@@ -346,6 +346,20 @@ export function apply(ctx, config) {
|
|
|
346
346
|
return payload.data ?? {};
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
+
async function knowledgeResourcesAll() {
|
|
350
|
+
const known = await teams();
|
|
351
|
+
const merged = [];
|
|
352
|
+
for (const team of known) {
|
|
353
|
+
try {
|
|
354
|
+
const items = await knowledgeResources(team.team_id);
|
|
355
|
+
for (const item of items) merged.push(item);
|
|
356
|
+
} catch {
|
|
357
|
+
/* one unreachable team must not hide the rest */
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return merged;
|
|
361
|
+
}
|
|
362
|
+
|
|
349
363
|
async function knowledgeResources(teamId) {
|
|
350
364
|
const key = `knowledge:${teamId}`;
|
|
351
365
|
const cached = state.assets.get(key);
|
|
@@ -384,7 +398,8 @@ export function apply(ctx, config) {
|
|
|
384
398
|
const known = await teams();
|
|
385
399
|
const first = known[0];
|
|
386
400
|
if (first === undefined) throw new Error('当前 userkey 下没有可见团队');
|
|
387
|
-
|
|
401
|
+
// No expert picked yet: team-level assets still work, memory does not (it needs an agent).
|
|
402
|
+
return { teamId: first.team_id, teamName: first.name, agentId: '', agentName: '', unscoped: true };
|
|
388
403
|
}
|
|
389
404
|
|
|
390
405
|
const TOOL_TEXT_LIMIT = 12000;
|
|
@@ -561,7 +576,7 @@ export function apply(ctx, config) {
|
|
|
561
576
|
isConcurrencySafe: () => true,
|
|
562
577
|
async execute(args, exec) {
|
|
563
578
|
const scope = await toolScope(exec);
|
|
564
|
-
const items = await
|
|
579
|
+
const items = await knowledgeResourcesAll();
|
|
565
580
|
return knowledgeListText(scope, items, args ?? {});
|
|
566
581
|
},
|
|
567
582
|
}),
|
|
@@ -587,7 +602,7 @@ export function apply(ctx, config) {
|
|
|
587
602
|
const scope = await toolScope(exec);
|
|
588
603
|
const knowledgeId = String(args.knowledge_id ?? '').trim();
|
|
589
604
|
if (knowledgeId === '') throw new Error('knowledge_id 不能为空');
|
|
590
|
-
const items = await
|
|
605
|
+
const items = await knowledgeResourcesAll();
|
|
591
606
|
const resource = items.find((item) => item.knowledge_id === knowledgeId);
|
|
592
607
|
if (resource === undefined) {
|
|
593
608
|
throw new Error(`未知的 knowledge_id:${knowledgeId}(先用 am_knowledge_resources 查看)`);
|
|
@@ -869,13 +884,58 @@ export function apply(ctx, config) {
|
|
|
869
884
|
owned,
|
|
870
885
|
});
|
|
871
886
|
}
|
|
887
|
+
// The asset tools depend on two more services; report them separately so a
|
|
888
|
+
// broken kernel or knowledge endpoint is visible without reading logs.
|
|
889
|
+
const services = [
|
|
890
|
+
{ name: 'hub', url: settings.hubUrl, ok: true, detail: `user ${me.username || me.userId}` },
|
|
891
|
+
];
|
|
892
|
+
let knowledgeItem = null;
|
|
893
|
+
try {
|
|
894
|
+
const items = await knowledgeResourcesAll();
|
|
895
|
+
knowledgeItem = items[0] ?? null;
|
|
896
|
+
services.push({
|
|
897
|
+
name: 'kernel',
|
|
898
|
+
url: kernelBase(),
|
|
899
|
+
ok: true,
|
|
900
|
+
detail: `${items.length} 个知识资源`,
|
|
901
|
+
});
|
|
902
|
+
} catch (error) {
|
|
903
|
+
services.push({
|
|
904
|
+
name: 'kernel',
|
|
905
|
+
url: kernelBase(),
|
|
906
|
+
ok: false,
|
|
907
|
+
detail: String(error?.message ?? error),
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
if (knowledgeItem !== null) {
|
|
911
|
+
try {
|
|
912
|
+
await knowledgeService(knowledgeItem.service_url, '/tools/list', {
|
|
913
|
+
knowledge_id: knowledgeItem.knowledge_id,
|
|
914
|
+
});
|
|
915
|
+
services.push({
|
|
916
|
+
name: 'knowledge',
|
|
917
|
+
url: String(knowledgeItem.service_url),
|
|
918
|
+
ok: true,
|
|
919
|
+
detail: `tools/list 可达(${knowledgeItem.name})`,
|
|
920
|
+
});
|
|
921
|
+
} catch (error) {
|
|
922
|
+
services.push({
|
|
923
|
+
name: 'knowledge',
|
|
924
|
+
url: String(knowledgeItem.service_url),
|
|
925
|
+
ok: false,
|
|
926
|
+
detail: String(error?.message ?? error),
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
}
|
|
872
930
|
reply(response, 200, {
|
|
873
|
-
ok:
|
|
931
|
+
ok: services.every((service) => service.ok),
|
|
874
932
|
hubUrl: settings.hubUrl,
|
|
933
|
+
kernelUrl: kernelBase(),
|
|
875
934
|
latencyMs: Date.now() - startedAt,
|
|
876
935
|
user: { userId: me.userId, username: me.username },
|
|
877
936
|
agents: agentCount,
|
|
878
937
|
teams: teamDetails,
|
|
938
|
+
services,
|
|
879
939
|
});
|
|
880
940
|
} catch (error) {
|
|
881
941
|
reply(response, 502, { ok: false, error: String(error?.message ?? error) });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-agent-memory",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Tencent agent-memory integration: pick a team agent as an expert at the composer, recall its memories into each turn, and expose its wiki, code-graph and skill assets as tools.",
|
|
6
6
|
"license": "MIT",
|