dsh-plugin-om 0.0.46 → 0.0.47
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 +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +58 -13
- package/dist/progress-reminder.d.ts +18 -0
- package/dist/progress-reminder.d.ts.map +1 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
## 功能
|
|
8
8
|
|
|
9
9
|
- 自动压缩主会话历史,并在摘要过大时再次合并
|
|
10
|
-
- OM
|
|
11
|
-
- 完整系统提示词预设保持原文,不追加关键节点提示
|
|
10
|
+
- OM 启用时以 system-reminder 消息提示模型边做边简述计划与进展,压缩后自动补发
|
|
12
11
|
- 通过工具循环生成摘要,保留用户消息、系统消息和未压缩内容
|
|
13
12
|
- 保留工具加载与手动加载的 skill 原文,并在压缩前再次确认
|
|
14
13
|
- 有效提问首次直接压缩需再次确认,保留时查看选项后在下一轮重写问答并展开选项引用
|
|
@@ -56,7 +55,7 @@ pnpm 11 安装失败时,在 profile 的 `pnpm-workspace.yaml` 中设置 `allow
|
|
|
56
55
|
| `compressSkipReasoning` | `true` | 是否忽略 reasoning |
|
|
57
56
|
| `rateLimitWaitMs` | `60000` | 429 后的等待毫秒数,`0` 表示不等待 |
|
|
58
57
|
| `modelDir` | DSH 共享目录 | 嵌入模型目录 |
|
|
59
|
-
| `omEnabled` | `true` |
|
|
58
|
+
| `omEnabled` | `true` | 是否启用自动压缩和进度提醒 |
|
|
60
59
|
| `recallEnabled` | `true` | 是否启用原文召回 |
|
|
61
60
|
| `semanticRecallEnabled` | `true` | 是否启用语义召回 |
|
|
62
61
|
| `debug` | 开发环境启用 | 是否输出步骤日志 |
|
|
@@ -90,7 +89,8 @@ pnpm 11 安装失败时,在 profile 的 `pnpm-workspace.yaml` 中设置 `allow
|
|
|
90
89
|
```text
|
|
91
90
|
cordis.patch.yml # bundle patch,dsh plugin add 后作为组合层插入插件行
|
|
92
91
|
src/
|
|
93
|
-
├── index.ts # 打包入口:注册 recall
|
|
92
|
+
├── index.ts # 打包入口:注册 recall 工具并接线自动压缩和进度提醒
|
|
93
|
+
├── progress-reminder.ts # 进度提醒:system-reminder 消息的构造与缺失时补发
|
|
94
94
|
├── config.ts # 配置默认值与宽松合并,未知键忽略、非法值回退默认
|
|
95
95
|
├── constants.ts # 共享常量:插件标识、history 标签、完整消息定义、格式说明注释
|
|
96
96
|
├── degrade.ts # 挂载失败降级上报:console 外部输出与 om/warning 会话事件
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ export declare const name = "dsh-plugin-om";
|
|
|
5
5
|
export { Config };
|
|
6
6
|
/** 插件注入的服务依赖(tools/llm/tokenMeter/sessions),由宿主按序注入。 */
|
|
7
7
|
export declare const inject: string[];
|
|
8
|
-
/**
|
|
8
|
+
/** 插件激活入口:解析配置、注册工具、接线 pre-step 自动压缩与进度提醒。 */
|
|
9
9
|
export declare function apply(ctx: Context, config?: unknown): void;
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAiB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAiB,MAAM,aAAa,CAAC;AAMpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,6BAA6B;AAC7B,eAAO,MAAM,IAAI,kBAAkB,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,wDAAwD;AACxD,eAAO,MAAM,MAAM,UAA6C,CAAC;AAEjE,8CAA8C;AAC9C,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CA0F1D"}
|
package/dist/index.mjs
CHANGED
|
@@ -10268,6 +10268,57 @@ function resolveConfig(raw) {
|
|
|
10268
10268
|
return Object.freeze(config);
|
|
10269
10269
|
}
|
|
10270
10270
|
//#endregion
|
|
10271
|
+
//#region src/progress-reminder.ts
|
|
10272
|
+
/**
|
|
10273
|
+
* 进度提醒:以 <system-reminder> 用户消息提示模型边做边简述计划与进展。
|
|
10274
|
+
* 提醒不进系统提示词;每个 step 检查表层,被压缩遮蔽或文本过期时补发,保证模型请求中恒有一条。
|
|
10275
|
+
* 导出 PROGRESS_REMINDER_SOURCE_KIND / ProgressReminderSource / PROGRESS_REMINDER_TEXT /
|
|
10276
|
+
* progressReminderMessage / ensureProgressReminder。
|
|
10277
|
+
*/
|
|
10278
|
+
/** 提醒消息的 producer-owned source kind(区别于压缩日志消息的 plugin:dsh-plugin-om)。 */
|
|
10279
|
+
const PROGRESS_REMINDER_SOURCE_KIND = "plugin:dsh-plugin-om:progress";
|
|
10280
|
+
/** 提醒全文(含 system-reminder 包裹)。 */
|
|
10281
|
+
const PROGRESS_REMINDER_TEXT = [
|
|
10282
|
+
"<system-reminder>",
|
|
10283
|
+
"Narrate your progress while you work, not only when the task is finished.",
|
|
10284
|
+
"- Before your first tool call on a task, state your plan in one or two sentences.",
|
|
10285
|
+
"- After each meaningful chunk of work (a group of related tool calls, a finished investigation, a completed edit), briefly report what you found or did and what you will do next, then continue.",
|
|
10286
|
+
"- Do not narrate every individual tool call; one short note per chunk is enough.",
|
|
10287
|
+
"- Do not save all commentary for the final answer. The final answer summarizes outcomes.",
|
|
10288
|
+
"This reminder does not override system, developer, or direct user instructions.",
|
|
10289
|
+
"</system-reminder>"
|
|
10290
|
+
].join("\n");
|
|
10291
|
+
/** 构造一条新的提醒消息。 */
|
|
10292
|
+
function progressReminderMessage() {
|
|
10293
|
+
return createUserMessage({
|
|
10294
|
+
content: [{
|
|
10295
|
+
type: "text",
|
|
10296
|
+
text: PROGRESS_REMINDER_TEXT
|
|
10297
|
+
}],
|
|
10298
|
+
source: {
|
|
10299
|
+
kind: PROGRESS_REMINDER_SOURCE_KIND,
|
|
10300
|
+
form: "instructions"
|
|
10301
|
+
}
|
|
10302
|
+
});
|
|
10303
|
+
}
|
|
10304
|
+
/** 消息是否为当前文本的提醒。 */
|
|
10305
|
+
function isCurrentReminder(source, content) {
|
|
10306
|
+
return source.kind === "plugin:dsh-plugin-om:progress" && content.length === 1 && content[0]?.type === "text" && content[0].text === PROGRESS_REMINDER_TEXT;
|
|
10307
|
+
}
|
|
10308
|
+
/**
|
|
10309
|
+
* 保证本 step 之后的消息列表中有一条当前提醒:本 step 已带上或表层已有则原样返回,
|
|
10310
|
+
* 否则在末尾追加。返回新数组,不修改入参。
|
|
10311
|
+
*/
|
|
10312
|
+
function ensureProgressReminder(session, messages) {
|
|
10313
|
+
if (messages.some((message) => isCurrentReminder(message.source, message.content))) return [...messages];
|
|
10314
|
+
const events = session.snapshotEvents();
|
|
10315
|
+
for (const seq of session.surface.nodes) {
|
|
10316
|
+
const event = events[seq];
|
|
10317
|
+
if (event?.type === "user/message" && isCurrentReminder(event.data.source, event.data.content)) return [...messages];
|
|
10318
|
+
}
|
|
10319
|
+
return [...messages, progressReminderMessage()];
|
|
10320
|
+
}
|
|
10321
|
+
//#endregion
|
|
10271
10322
|
//#region src/json-schema.ts
|
|
10272
10323
|
/**
|
|
10273
10324
|
* zod schema → 工具 wire 参数 JSON Schema 的转换工具。导出 parametersFromZod。
|
|
@@ -10739,9 +10790,7 @@ const inject = [
|
|
|
10739
10790
|
"tokenMeter",
|
|
10740
10791
|
"sessions"
|
|
10741
10792
|
];
|
|
10742
|
-
/**
|
|
10743
|
-
const PROGRESS_PROMPT = "在任务推进的关键节点,简要输出后续规划,并在执行后说明对应结果;无需逐次播报工具调用。";
|
|
10744
|
-
/** 插件激活入口:解析配置、注册工具、接线系统提示与 pre-step 自动压缩。 */
|
|
10793
|
+
/** 插件激活入口:解析配置、注册工具、接线 pre-step 自动压缩与进度提醒。 */
|
|
10745
10794
|
function apply(ctx, config) {
|
|
10746
10795
|
const resolved = currentConfig(config);
|
|
10747
10796
|
const logger = makeLogger(ctx, () => currentConfig(config).debug);
|
|
@@ -10778,15 +10827,6 @@ function apply(ctx, config) {
|
|
|
10778
10827
|
}
|
|
10779
10828
|
syncTools();
|
|
10780
10829
|
ctx.on("loader/volatile-update", () => syncTools());
|
|
10781
|
-
ctx.on("system-prompt/assemble", async (_assembly, context, next) => {
|
|
10782
|
-
const assembly = await next();
|
|
10783
|
-
if (currentConfig(config).omEnabled && context.agent && isMainSession(context.agent.session)) assembly.sections.push({
|
|
10784
|
-
name: "dsh-plugin-om:progress",
|
|
10785
|
-
text: PROGRESS_PROMPT,
|
|
10786
|
-
interpolate: false
|
|
10787
|
-
});
|
|
10788
|
-
return assembly;
|
|
10789
|
-
});
|
|
10790
10830
|
ctx.on("agent/pre-step", async ({ agent, signal }, next) => {
|
|
10791
10831
|
let outcome = { failed: false };
|
|
10792
10832
|
try {
|
|
@@ -10804,7 +10844,12 @@ function apply(ctx, config) {
|
|
|
10804
10844
|
logger.warn(`上下文压缩失败,拒绝本 step 中断当前 turn:${outcome.error}${diagnostic}`);
|
|
10805
10845
|
return { kind: "reject" };
|
|
10806
10846
|
}
|
|
10807
|
-
|
|
10847
|
+
const decision = await next();
|
|
10848
|
+
if (decision.kind === "enter" && !signal.aborted && currentConfig(config).omEnabled && isMainSession(agent.session)) return {
|
|
10849
|
+
...decision,
|
|
10850
|
+
messages: ensureProgressReminder(agent.session, decision.messages)
|
|
10851
|
+
};
|
|
10852
|
+
return decision;
|
|
10808
10853
|
});
|
|
10809
10854
|
}
|
|
10810
10855
|
//#endregion
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Session, UserMessage } from './types.ts';
|
|
2
|
+
/** 提醒消息的 producer-owned source kind(区别于压缩日志消息的 plugin:dsh-plugin-om)。 */
|
|
3
|
+
export declare const PROGRESS_REMINDER_SOURCE_KIND = "plugin:dsh-plugin-om:progress";
|
|
4
|
+
/** 提醒消息的 source。 */
|
|
5
|
+
export type ProgressReminderSource = {
|
|
6
|
+
readonly kind: typeof PROGRESS_REMINDER_SOURCE_KIND;
|
|
7
|
+
readonly form: 'instructions';
|
|
8
|
+
};
|
|
9
|
+
/** 提醒全文(含 system-reminder 包裹)。 */
|
|
10
|
+
export declare const PROGRESS_REMINDER_TEXT: string;
|
|
11
|
+
/** 构造一条新的提醒消息。 */
|
|
12
|
+
export declare function progressReminderMessage(): UserMessage;
|
|
13
|
+
/**
|
|
14
|
+
* 保证本 step 之后的消息列表中有一条当前提醒:本 step 已带上或表层已有则原样返回,
|
|
15
|
+
* 否则在末尾追加。返回新数组,不修改入参。
|
|
16
|
+
*/
|
|
17
|
+
export declare function ensureProgressReminder(session: Session, messages: readonly UserMessage[]): UserMessage[];
|
|
18
|
+
//# sourceMappingURL=progress-reminder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-reminder.d.ts","sourceRoot":"","sources":["../src/progress-reminder.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEvD,yEAAyE;AACzE,eAAO,MAAM,6BAA6B,kCAAkC,CAAC;AAE7E,oBAAoB;AACpB,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,IAAI,EAAE,OAAO,6BAA6B,CAAC;IACpD,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;CAC/B,CAAC;AAEF,kCAAkC;AAClC,eAAO,MAAM,sBAAsB,QASvB,CAAC;AAEb,kBAAkB;AAClB,wBAAgB,uBAAuB,IAAI,WAAW,CASrD;AAeD;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,SAAS,WAAW,EAAE,GAC/B,WAAW,EAAE,CAef"}
|
package/dist/types.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type { SystemPrompt } from '@deepseek-ai/dsh-system-prompt';
|
|
|
17
17
|
import type { TokenMeter } from '@deepseek-ai/dsh-token-meter';
|
|
18
18
|
import type { JsonSchemaNode, ToolDefinition, ToolRunContext } from '@deepseek-ai/dsh-tools';
|
|
19
19
|
import type { OmMessageSource } from './constants.ts';
|
|
20
|
+
import type { ProgressReminderSource } from './progress-reminder.ts';
|
|
20
21
|
/** 插件配置类型(来自 config.ts)。 */
|
|
21
22
|
export type { PluginConfig } from './config.ts';
|
|
22
23
|
declare module '@deepseek-ai/dsh-llm' {
|
|
@@ -27,6 +28,8 @@ declare module '@deepseek-ai/dsh-llm' {
|
|
|
27
28
|
* 插件写入的 source 形态,宿主持久化读路径的 producer-owned 准入随之满足。
|
|
28
29
|
*/
|
|
29
30
|
'plugin:dsh-plugin-om': OmMessageSource;
|
|
31
|
+
/** 进度提醒消息(system-reminder 用户消息)的 producer-owned source。 */
|
|
32
|
+
'plugin:dsh-plugin-om:progress': ProgressReminderSource;
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
declare module '@deepseek-ai/dsh-session/types' {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,OA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