dsh-plugin-agent-memory 0.2.0 → 0.2.2
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/client.js +24 -1
- package/index.js +41 -26
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -121,6 +121,9 @@ window.__ModuleLoader__.load({
|
|
|
121
121
|
...init,
|
|
122
122
|
});
|
|
123
123
|
const payload = await response.json().catch(() => null);
|
|
124
|
+
if (response.status === 404) {
|
|
125
|
+
throw new Error('插件路由未就绪(404):重新加载插件或刷新页面后重试');
|
|
126
|
+
}
|
|
124
127
|
if (!response.ok) throw new Error(payload?.error ?? `HTTP ${response.status}`);
|
|
125
128
|
return payload;
|
|
126
129
|
}
|
|
@@ -139,7 +142,7 @@ window.__ModuleLoader__.load({
|
|
|
139
142
|
const [configured, setConfigured] = React.useState(true);
|
|
140
143
|
const [health, setHealth] = React.useState({ state: 'idle', text: '连接未检测' });
|
|
141
144
|
const [form, setForm] = React.useState({ hubUrl: '', instanceId: '', kernelUrl: '', userKey: '' });
|
|
142
|
-
const [flags, setFlags] = React.useState({ injectMemory: true, writeMemory: false });
|
|
145
|
+
const [flags, setFlags] = React.useState({ injectMemory: true, writeMemory: false, skillLearning: false });
|
|
143
146
|
const [refreshMs, setRefreshMs] = React.useState(10000);
|
|
144
147
|
const [saving, setSaving] = React.useState(false);
|
|
145
148
|
|
|
@@ -166,6 +169,7 @@ window.__ModuleLoader__.load({
|
|
|
166
169
|
setFlags({
|
|
167
170
|
injectMemory: current.injectMemory !== false,
|
|
168
171
|
writeMemory: current.writeMemory === true,
|
|
172
|
+
skillLearning: current.skillLearning === true,
|
|
169
173
|
});
|
|
170
174
|
}
|
|
171
175
|
})
|
|
@@ -206,6 +210,7 @@ window.__ModuleLoader__.load({
|
|
|
206
210
|
kernelUrl: form.kernelUrl,
|
|
207
211
|
userKey: form.userKey,
|
|
208
212
|
injectMemory: flags.injectMemory,
|
|
213
|
+
skillLearning: flags.skillLearning,
|
|
209
214
|
refreshMs,
|
|
210
215
|
writeMemory: flags.writeMemory,
|
|
211
216
|
}),
|
|
@@ -452,6 +457,24 @@ window.__ModuleLoader__.load({
|
|
|
452
457
|
}),
|
|
453
458
|
h('span', { style: { fontSize: '12px' } }, '对话结束后写回记忆库'),
|
|
454
459
|
),
|
|
460
|
+
h(
|
|
461
|
+
'label',
|
|
462
|
+
{
|
|
463
|
+
style: { ...fieldStyle, display: 'flex', alignItems: 'flex-start', gap: '6px' },
|
|
464
|
+
title: '每轮结束后把该轮对话(含工具调用与结果)写入内核,agent-memory 归档后抽取技能;内核按阈值归档,短回合不会立刻产出技能',
|
|
465
|
+
},
|
|
466
|
+
h('input', {
|
|
467
|
+
type: 'checkbox',
|
|
468
|
+
style: { marginTop: '3px' },
|
|
469
|
+
checked: flags.skillLearning,
|
|
470
|
+
onChange: (event) => setFlags({ ...flags, skillLearning: event.target.checked }),
|
|
471
|
+
}),
|
|
472
|
+
h(
|
|
473
|
+
'span',
|
|
474
|
+
{ style: { fontSize: '12px' } },
|
|
475
|
+
'把对话写回内核,用于技能自学习',
|
|
476
|
+
),
|
|
477
|
+
),
|
|
455
478
|
h(
|
|
456
479
|
'label',
|
|
457
480
|
{ style: fieldStyle },
|
package/index.js
CHANGED
|
@@ -684,8 +684,17 @@ export function apply(ctx, config) {
|
|
|
684
684
|
}
|
|
685
685
|
const textOutput = { schema: { type: 'string' }, render: (_args, text) => [{ type: 'text', text }] };
|
|
686
686
|
const disposers = [];
|
|
687
|
-
|
|
688
|
-
|
|
687
|
+
// A duplicate name (a stale fiber still holding it) must not abort activation: the
|
|
688
|
+
// rest of `apply` — the browser routes included — would be skipped.
|
|
689
|
+
const register = (definition) => {
|
|
690
|
+
try {
|
|
691
|
+
disposers.push(tools.register(definition));
|
|
692
|
+
} catch (error) {
|
|
693
|
+
ctx.logger?.warn?.(`[agent-memory] tool ${definition.name} not registered: ${error?.message ?? error}`);
|
|
694
|
+
debug({ at: 'tool-error', name: definition.name, message: String(error?.message ?? error) });
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
register({
|
|
689
698
|
name: 'am_knowledge_resources',
|
|
690
699
|
description:
|
|
691
700
|
'列出当前团队 agent-memory 的知识资源:code-graph(仓库的预建代码索引:符号/调用图/结构)与 wiki(工程设计文档)。code-graph 的 repo 与你当前工作区一致时才值得查;wiki 与工作区无关,按 about 判断相关性。拿到 id 后用 am_knowledge_call 读取。',
|
|
@@ -704,10 +713,8 @@ export function apply(ctx, config) {
|
|
|
704
713
|
const items = await knowledgeResourcesAll();
|
|
705
714
|
return knowledgeListText(scope, items, args ?? {});
|
|
706
715
|
},
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
disposers.push(
|
|
710
|
-
tools.register({
|
|
716
|
+
});
|
|
717
|
+
register({
|
|
711
718
|
name: 'am_knowledge_call',
|
|
712
719
|
description:
|
|
713
720
|
'调用 agent-memory 知识资源上的工具。省略 tool 时返回该资源可用的工具清单(含参数);给出 tool 时执行它。code-graph 适合跨文件结构、调用链、影响面、定位实现等问题(explore/search/callers/callees/impact/node/files);wiki 适合设计意图、背景、团队约定等问题(search/read_page/list_pages)。索引是分支快照,需要某段代码此刻的精确内容时请读工作区源码。',
|
|
@@ -747,10 +754,8 @@ export function apply(ctx, config) {
|
|
|
747
754
|
if (typeof data.text === 'string') return clip(data.text);
|
|
748
755
|
return clip(JSON.stringify(data, null, 2));
|
|
749
756
|
},
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
disposers.push(
|
|
753
|
-
tools.register({
|
|
757
|
+
});
|
|
758
|
+
register({
|
|
754
759
|
name: 'am_memory_search',
|
|
755
760
|
description:
|
|
756
761
|
'按需检索当前专家的分层记忆。默认查 L1(原子记忆)与 L0(原始对话);需要稳定结论时也可传 L2/L3。每轮预注入会使用的层由配置 layers 决定(默认 L3,L2),这里用于补充更细的细节。',
|
|
@@ -781,10 +786,8 @@ export function apply(ctx, config) {
|
|
|
781
786
|
}
|
|
782
787
|
return hits.map((hit, index) => `${index + 1}. (${hit.layer}) ${hit.body}`).join('\n');
|
|
783
788
|
},
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
disposers.push(
|
|
787
|
-
tools.register({
|
|
789
|
+
});
|
|
790
|
+
register({
|
|
788
791
|
name: 'am_skill_search',
|
|
789
792
|
description:
|
|
790
793
|
'在团队的 agent-memory 技能库(skill)里检索可复用技能,返回 skill_id、名称与描述。命中后用 am_skill_read 读取正文并按其步骤执行。',
|
|
@@ -813,10 +816,8 @@ export function apply(ctx, config) {
|
|
|
813
816
|
)
|
|
814
817
|
.join('\n');
|
|
815
818
|
},
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
disposers.push(
|
|
819
|
-
tools.register({
|
|
819
|
+
});
|
|
820
|
+
register({
|
|
820
821
|
name: 'am_skill_read',
|
|
821
822
|
description:
|
|
822
823
|
'读取 agent-memory 技能库里某个 skill 的完整正文(Markdown,含 frontmatter 说明与执行步骤)。参数可传 skill_id(skl-...)或技能名。',
|
|
@@ -845,8 +846,7 @@ export function apply(ctx, config) {
|
|
|
845
846
|
if (content === '') return `技能 ${data.name ?? skillId} 没有正文内容。`;
|
|
846
847
|
return clip(`# 技能 ${data.name ?? skillId}(id=${skillId} v${data.version ?? '?'})\n\n${content}`);
|
|
847
848
|
},
|
|
848
|
-
|
|
849
|
-
);
|
|
849
|
+
});
|
|
850
850
|
return () => {
|
|
851
851
|
for (const dispose of disposers) {
|
|
852
852
|
try {
|
|
@@ -864,6 +864,21 @@ export function apply(ctx, config) {
|
|
|
864
864
|
return;
|
|
865
865
|
}
|
|
866
866
|
|
|
867
|
+
/**
|
|
868
|
+
* Route registration is best effort per route: one refused path (a duplicate left behind
|
|
869
|
+
* by a stale fiber, a carrier that rejects it) must not cost the browser every route.
|
|
870
|
+
*/
|
|
871
|
+
const mount = (registerRoute, label) =>
|
|
872
|
+
ctx.effect(() => {
|
|
873
|
+
try {
|
|
874
|
+
return registerRoute();
|
|
875
|
+
} catch (error) {
|
|
876
|
+
ctx.logger?.warn?.(`[agent-memory] ${label} not mounted: ${error?.message ?? error}`);
|
|
877
|
+
debug({ at: 'route-error', label, message: String(error?.message ?? error) });
|
|
878
|
+
return () => {};
|
|
879
|
+
}
|
|
880
|
+
}, label);
|
|
881
|
+
|
|
867
882
|
const origin = (() => {
|
|
868
883
|
try {
|
|
869
884
|
return webServer.getOrigin();
|
|
@@ -930,7 +945,7 @@ export function apply(ctx, config) {
|
|
|
930
945
|
return JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
931
946
|
}
|
|
932
947
|
|
|
933
|
-
|
|
948
|
+
mount(
|
|
934
949
|
() =>
|
|
935
950
|
webServer.register({
|
|
936
951
|
kind: 'exact',
|
|
@@ -983,7 +998,7 @@ export function apply(ctx, config) {
|
|
|
983
998
|
);
|
|
984
999
|
|
|
985
1000
|
/** Connectivity probe used by the selector's settings panel and by the detail page. */
|
|
986
|
-
|
|
1001
|
+
mount(
|
|
987
1002
|
() =>
|
|
988
1003
|
webServer.register({
|
|
989
1004
|
kind: 'exact',
|
|
@@ -1075,7 +1090,7 @@ export function apply(ctx, config) {
|
|
|
1075
1090
|
* Saves the connection settings from the UI. The `configEditor` service owns the profile
|
|
1076
1091
|
* patch file; editing an ordinary field restarts this plugin so `apply` rebuilds state.
|
|
1077
1092
|
*/
|
|
1078
|
-
|
|
1093
|
+
mount(
|
|
1079
1094
|
() =>
|
|
1080
1095
|
webServer.register({
|
|
1081
1096
|
kind: 'exact',
|
|
@@ -1145,7 +1160,7 @@ export function apply(ctx, config) {
|
|
|
1145
1160
|
'agent-memory: config route',
|
|
1146
1161
|
);
|
|
1147
1162
|
|
|
1148
|
-
|
|
1163
|
+
mount(
|
|
1149
1164
|
() =>
|
|
1150
1165
|
webServer.register({
|
|
1151
1166
|
kind: 'exact',
|
|
@@ -1181,7 +1196,7 @@ export function apply(ctx, config) {
|
|
|
1181
1196
|
'agent-memory: agents route',
|
|
1182
1197
|
);
|
|
1183
1198
|
|
|
1184
|
-
|
|
1199
|
+
mount(
|
|
1185
1200
|
() =>
|
|
1186
1201
|
webServer.register({
|
|
1187
1202
|
kind: 'exact',
|
|
@@ -1243,7 +1258,7 @@ export function apply(ctx, config) {
|
|
|
1243
1258
|
'agent-memory: select route',
|
|
1244
1259
|
);
|
|
1245
1260
|
|
|
1246
|
-
|
|
1261
|
+
mount(
|
|
1247
1262
|
() =>
|
|
1248
1263
|
webServer.register({
|
|
1249
1264
|
kind: 'exact',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-agent-memory",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Tencent agent-memory integration for DeepSeek Harness: pick a team agent as an expert, recall its memories each turn, use its wiki / code-graph / skill assets as tools, and feed finished turns back for skill learning.",
|
|
6
6
|
"license": "MIT",
|