@chaoset/adaptive-perf 0.7.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/README.md +2 -1
- package/client/client.cjs +171 -96
- package/client/index.tsx +93 -23
- package/lib/index.d.ts +18 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +125 -32
- package/lib/index.js.map +1 -1
- package/lib/remote.d.ts +1 -1
- package/lib/remote.js +1 -1
- package/package.json +4 -1
package/client/index.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol";
|
|
3
3
|
|
|
4
4
|
// ── 样式(注入 style 标签,模仿官方卡片外观)──────────────────────────
|
|
5
|
-
var css = ".ap_card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:10px;min-width:0;overflow:hidden}.ap_card[data-open=true]{border-color:var(--dsw-alias-border-l1);box-shadow:var(--dsw-shadow-lv1)}.ap_header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:10px;align-items:center;gap:12px;padding:12px 14px;display:flex}.ap_header:hover,.ap_card[data-open=true]>.ap_header{background:var(--dsw-alias-interactive-bg-hover)}.ap_title{flex:1;min-width:0;font-size:14px;font-weight:600;line-height:20px}.ap_badge{white-space:nowrap;background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 10%,transparent);color:var(--dsw-alias-state-success-primary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:16px}.ap_body{border-top:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-module-platform);padding:10px 14px 12px}.ap_field{flex-direction:column;gap:4px;padding:8px 0;display:flex}.ap_label{font-size:12px;font-weight:500;line-height:18px}.ap_input{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);height:32px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:6px;padding:0 10px;font-size:13px;line-height:20px}.ap_textarea{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);font:inherit;color:var(--dsw-alias-label-primary);border-radius:6px;padding:6px 10px;font-size:12px;line-height:18px;resize:vertical;min-height:120px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.ap_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:11px;line-height:16px}.ap_footer{border-top:1px solid var(--dsw-alias-border-l2);justify-content:flex-end;align-items:center;gap:8px;padding:8px 0 2px;display:flex}.ap_save{font:inherit;cursor:pointer;border:1px solid transparent;border-radius:6px;padding:4px 14px;font-size:12px;line-height:18px;background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.ap_discard{font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l2);border-radius:6px;padding:4px 14px;font-size:12px;line-height:18px;background:0 0;color:inherit}.ap_status{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary);flex:1}.ap_status.ap_error{color:var(--dsw-alias-state-
|
|
5
|
+
var css = ".ap_card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:10px;min-width:0;overflow:hidden}.ap_card[data-open=true]{border-color:var(--dsw-alias-border-l1);box-shadow:var(--dsw-shadow-lv1)}.ap_header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:10px;align-items:center;gap:12px;padding:12px 14px;display:flex}.ap_header:hover,.ap_card[data-open=true]>.ap_header{background:var(--dsw-alias-interactive-bg-hover)}.ap_title{flex:1;min-width:0;font-size:14px;font-weight:600;line-height:20px}.ap_badge{white-space:nowrap;background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 10%,transparent);color:var(--dsw-alias-state-success-primary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:16px}.ap_body{border-top:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-module-platform);padding:10px 14px 12px}.ap_field{flex-direction:column;gap:4px;padding:8px 0;display:flex}.ap_label{font-size:12px;font-weight:500;line-height:18px}.ap_input{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);height:32px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:6px;padding:0 10px;font-size:13px;line-height:20px}.ap_textarea{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);font:inherit;color:var(--dsw-alias-label-primary);border-radius:6px;padding:6px 10px;font-size:12px;line-height:18px;resize:vertical;min-height:120px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.ap_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:11px;line-height:16px}.ap_footer{border-top:1px solid var(--dsw-alias-border-l2);justify-content:flex-end;align-items:center;gap:8px;padding:8px 0 2px;display:flex}.ap_save{font:inherit;cursor:pointer;border:1px solid transparent;border-radius:6px;padding:4px 14px;font-size:12px;line-height:18px;background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.ap_discard{font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l2);border-radius:6px;padding:4px 14px;font-size:12px;line-height:18px;background:0 0;color:inherit}.ap_status{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary);flex:1}.ap_section{border-top:1px dashed var(--dsw-alias-border-l2);margin-top:8px;padding-top:2px}.ap_sectionHead{appearance:none;width:100%;font:inherit;color:var(--dsw-alias-label-secondary);text-align:left;cursor:pointer;background:0 0;border:0;border-radius:6px;align-items:center;justify-content:space-between;gap:8px;padding:6px 2px;display:flex}.ap_sectionHead:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.ap_sectionTitle{font-size:12px;font-weight:600;line-height:18px}.ap_sectionChevron{flex:none;font-size:10px}.ap_sectionBody{flex-direction:column;display:flex}.ap_status.ap_error{color:var(--dsw-alias-state-error-primary)}.ap_badge_error{white-space:nowrap;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent);color:var(--dsw-alias-state-error-primary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:16px;max-width:260px;overflow:hidden;text-overflow:ellipsis}";
|
|
6
6
|
var tagId = "@chaoset/adaptive-perf/client.css";
|
|
7
7
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=\"" + tagId + "\"]") === null) {
|
|
8
8
|
var tag = document.createElement("style");
|
|
@@ -27,7 +27,7 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
27
27
|
invalidFamilies: "families 必须是合法 JSON 对象",
|
|
28
28
|
enabled: "启用插件",
|
|
29
29
|
presets: "目标 preset",
|
|
30
|
-
fieldPresets: "逗号分隔的 preset id(如 standard, code
|
|
30
|
+
fieldPresets: "逗号分隔的 preset id(如 standard, code)。留空 = 不应用任何 preset",
|
|
31
31
|
suppressRuntimeContext: "抑制运行时上下文快照",
|
|
32
32
|
fieldSuppressRuntimeContext: "等同极简模式的 includeRuntimeContext: false,每次请求省掉快照文本(零功能损失)",
|
|
33
33
|
leanByDefault: "启动即精简工具目录",
|
|
@@ -61,7 +61,10 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
61
61
|
minimalPromptPersona: "persona 文本",
|
|
62
62
|
fieldMinimalPromptPersona: "按名替换 deployment:persona;默认与极简模式逐字相同。留空 = 不替换(保留原 persona)",
|
|
63
63
|
minimalPromptSuppressSections: "屏蔽全局引导段",
|
|
64
|
-
fieldMinimalPromptSuppressSections: "屏蔽 harness:identity / harness:source / app:web-surface 三个全局段(等同极简 complete persona 的效果;plan-mode 与 PTC 的 SDK 段不受影响)"
|
|
64
|
+
fieldMinimalPromptSuppressSections: "屏蔽 harness:identity / harness:source / app:web-surface 三个全局段(等同极简 complete persona 的效果;plan-mode 与 PTC 的 SDK 段不受影响)",
|
|
65
|
+
sectionBootstrap: "首轮锚定(bootstrap)",
|
|
66
|
+
sectionPrompt: "极简提示词层(语域锚定)",
|
|
67
|
+
sectionAdvanced: "高级:工具族与核心工具"
|
|
65
68
|
};
|
|
66
69
|
const en = {
|
|
67
70
|
title: "Adaptive performance (adaptive-perf)",
|
|
@@ -76,7 +79,7 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
76
79
|
invalidFamilies: "families must be valid JSON object",
|
|
77
80
|
enabled: "Enable plugin",
|
|
78
81
|
presets: "Target presets",
|
|
79
|
-
fieldPresets: "Comma-separated preset ids (e.g. standard, code)",
|
|
82
|
+
fieldPresets: "Comma-separated preset ids (e.g. standard, code). Empty = apply to no preset.",
|
|
80
83
|
suppressRuntimeContext: "Suppress runtime-context snapshot",
|
|
81
84
|
fieldSuppressRuntimeContext: "Same as minimal's includeRuntimeContext: false; drops the snapshot text from every request (zero feature loss)",
|
|
82
85
|
leanByDefault: "Lean tool catalog at session start",
|
|
@@ -110,7 +113,10 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
110
113
|
minimalPromptPersona: "Persona text",
|
|
111
114
|
fieldMinimalPromptPersona: "Shadows deployment:persona by name; defaults to the exact minimal-mode text. Empty = keep the original persona",
|
|
112
115
|
minimalPromptSuppressSections: "Suppress global orientation sections",
|
|
113
|
-
fieldMinimalPromptSuppressSections: "Shadow harness:identity / harness:source / app:web-surface to empty (same effect as minimal's complete persona; plan-mode and the PTC SDK sections are unaffected)"
|
|
116
|
+
fieldMinimalPromptSuppressSections: "Shadow harness:identity / harness:source / app:web-surface to empty (same effect as minimal's complete persona; plan-mode and the PTC SDK sections are unaffected)",
|
|
117
|
+
sectionBootstrap: "First-request bootstrap",
|
|
118
|
+
sectionPrompt: "Minimal prompt layer (register anchor)",
|
|
119
|
+
sectionAdvanced: "Advanced: tool families & core tools"
|
|
114
120
|
};
|
|
115
121
|
|
|
116
122
|
// ── 表单字段 ─────────────────────────────────────────────────────────
|
|
@@ -143,6 +149,22 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
143
149
|
})
|
|
144
150
|
);
|
|
145
151
|
}
|
|
152
|
+
// 可折叠分组:20+ 字段平铺会淹没主开关;按语义区块(bootstrap /
|
|
153
|
+
// 提示词层 / 高级 JSON)渐进披露,默认展开常用组、收起高级组。
|
|
154
|
+
function Section(props: any) {
|
|
155
|
+
const [expanded, setExpanded] = React.useState(props.defaultOpen !== false);
|
|
156
|
+
return React.createElement(
|
|
157
|
+
"div",
|
|
158
|
+
{ className: "ap_section" },
|
|
159
|
+
React.createElement(
|
|
160
|
+
"button",
|
|
161
|
+
{ type: "button", className: "ap_sectionHead", onClick: () => setExpanded(!expanded), "aria-expanded": expanded },
|
|
162
|
+
React.createElement("span", { className: "ap_sectionTitle" }, props.title),
|
|
163
|
+
React.createElement("span", { className: "ap_sectionChevron", "aria-hidden": true }, expanded ? "▲" : "▼")
|
|
164
|
+
),
|
|
165
|
+
expanded ? React.createElement("div", { className: "ap_sectionBody" }, props.children) : null
|
|
166
|
+
);
|
|
167
|
+
}
|
|
146
168
|
function familiesToText(families: any) {
|
|
147
169
|
return JSON.stringify(families, null, 2);
|
|
148
170
|
}
|
|
@@ -168,12 +190,28 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
168
190
|
}
|
|
169
191
|
|
|
170
192
|
// ── 配置卡片 ─────────────────────────────────────────────────────────
|
|
193
|
+
/** 逐字段深比较(键序无关):dirty 判定不能用 JSON.stringify——服务端
|
|
194
|
+
* effective() 与本地草稿的键序可能不同,会产生假"未保存"徽标。 */
|
|
195
|
+
function valuesEqual(a: any, b: any): boolean {
|
|
196
|
+
if (a === b) return true;
|
|
197
|
+
if (typeof a !== typeof b || a === null || b === null) return false;
|
|
198
|
+
if (typeof a !== "object") return false;
|
|
199
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
200
|
+
if (Array.isArray(a)) {
|
|
201
|
+
return a.length === b.length && a.every((v: any, i: number) => valuesEqual(v, b[i]));
|
|
202
|
+
}
|
|
203
|
+
const ka = Object.keys(a);
|
|
204
|
+
const kb = Object.keys(b);
|
|
205
|
+
return ka.length === kb.length && ka.every((k: string) => Object.prototype.hasOwnProperty.call(b, k) && valuesEqual(a[k], b[k]));
|
|
206
|
+
}
|
|
171
207
|
function AdaptivePerfCard(props: any) {
|
|
172
208
|
const t = props.t;
|
|
173
209
|
const [open, setOpen] = React.useState(false);
|
|
174
210
|
const [cfg, setCfg] = React.useState<any>(null);
|
|
175
211
|
const [draft, setDraft] = React.useState<any>(null);
|
|
176
212
|
const [familiesText, setFamiliesText] = React.useState("");
|
|
213
|
+
// maxTokens 的编辑期草稿:显示原始输入(允许中间态如空串),失焦才归一化。
|
|
214
|
+
const [maxTokensText, setMaxTokensText] = React.useState<any>(null);
|
|
177
215
|
const [saving, setSaving] = React.useState(false);
|
|
178
216
|
const [status, setStatus] = React.useState<any>(null);
|
|
179
217
|
|
|
@@ -184,6 +222,7 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
184
222
|
setCfg(value);
|
|
185
223
|
setDraft(value);
|
|
186
224
|
setFamiliesText(familiesToText(value.families));
|
|
225
|
+
setMaxTokensText(null);
|
|
187
226
|
}).catch((error: any) => {
|
|
188
227
|
if (!cancelled) setStatus({ kind: "error", text: t("loadFailed") + ": " + (error && error.message || error) });
|
|
189
228
|
});
|
|
@@ -200,11 +239,12 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
200
239
|
familiesError = (error as Error)?.message ?? String(error);
|
|
201
240
|
}
|
|
202
241
|
}
|
|
203
|
-
const dirty = draft !== null && (
|
|
242
|
+
const dirty = draft !== null && (!valuesEqual(draft, cfg) || familiesInvalid === false && familiesToText(draft.families) !== familiesText);
|
|
204
243
|
const invalid = draft !== null && familiesInvalid;
|
|
205
244
|
const discard = () => {
|
|
206
245
|
setDraft(cfg);
|
|
207
246
|
setFamiliesText(cfg === null ? "" : familiesToText(cfg.families));
|
|
247
|
+
setMaxTokensText(null);
|
|
208
248
|
setStatus(null);
|
|
209
249
|
};
|
|
210
250
|
const save = () => {
|
|
@@ -222,6 +262,7 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
222
262
|
setCfg(next);
|
|
223
263
|
setDraft(next);
|
|
224
264
|
setFamiliesText(familiesToText(next.families));
|
|
265
|
+
setMaxTokensText(null);
|
|
225
266
|
setStatus({ kind: "ok", text: t("saved") });
|
|
226
267
|
}).catch((error: any) => {
|
|
227
268
|
setStatus({ kind: "error", text: t("saveFailed") + ": " + (error && error.message || error) });
|
|
@@ -240,6 +281,7 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
240
281
|
"aria-expanded": open
|
|
241
282
|
},
|
|
242
283
|
React.createElement("span", { className: "ap_title" }, t("title")),
|
|
284
|
+
status !== null && status.kind === "error" ? React.createElement("span", { className: "ap_badge ap_badge_error", title: status.text }, status.text) : null,
|
|
243
285
|
dirty ? React.createElement("span", { className: "ap_badge" }, t("unsaved")) : null,
|
|
244
286
|
React.createElement("span", null, open ? "▲" : "▼")
|
|
245
287
|
),
|
|
@@ -291,10 +333,12 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
291
333
|
React.createElement(BoolField, {
|
|
292
334
|
label: t("suppressInjectedContext"),
|
|
293
335
|
hint: t("fieldSuppressInjectedContext"),
|
|
294
|
-
value: draft === null ?
|
|
336
|
+
value: draft === null ? true : draft.suppressInjectedContext,
|
|
295
337
|
disabled: draft === null,
|
|
296
338
|
onChange: (v: any) => setDraft({ ...draft, suppressInjectedContext: v })
|
|
297
339
|
}),
|
|
340
|
+
// ── 首轮锚定(bootstrap)分组 ──
|
|
341
|
+
React.createElement(Section, { title: t("sectionBootstrap") },
|
|
298
342
|
React.createElement(BoolField, {
|
|
299
343
|
label: t("bootstrapEnabled"),
|
|
300
344
|
hint: t("fieldBootstrapEnabled"),
|
|
@@ -316,13 +360,20 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
316
360
|
disabled: draft === null || (draft.bootstrap && draft.bootstrap.enabled === false),
|
|
317
361
|
onChange: (v: any) => setDraft({ ...draft, bootstrap: { ...(draft.bootstrap || {}), tools: v.split(/[,,\s]+/).filter((x: any) => x.length > 0) } })
|
|
318
362
|
}),
|
|
319
|
-
React.createElement(
|
|
363
|
+
React.createElement(Field, {
|
|
320
364
|
label: t("bootstrapPromoteOn"),
|
|
321
|
-
hint: t("fieldBootstrapPromoteOn")
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
365
|
+
hint: t("fieldBootstrapPromoteOn")
|
|
366
|
+
},
|
|
367
|
+
React.createElement("select", {
|
|
368
|
+
className: "ap_input",
|
|
369
|
+
value: draft === null ? "either" : (draft.bootstrap && draft.bootstrap.promoteOn) || "either",
|
|
370
|
+
disabled: draft === null || (draft.bootstrap && draft.bootstrap.enabled === false),
|
|
371
|
+
onChange: (e: any) => setDraft({ ...draft, bootstrap: { ...(draft.bootstrap || {}), promoteOn: e.target.value } })
|
|
372
|
+
},
|
|
373
|
+
["either", "tool-call", "assistant-message"].map((v: string) =>
|
|
374
|
+
React.createElement("option", { key: v, value: v }, v))
|
|
375
|
+
)
|
|
376
|
+
),
|
|
326
377
|
React.createElement(TextField, {
|
|
327
378
|
label: t("bootstrapSuppressed"),
|
|
328
379
|
hint: t("fieldBootstrapSuppressed"),
|
|
@@ -337,16 +388,31 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
337
388
|
disabled: draft === null || (draft.bootstrap && draft.bootstrap.enabled === false),
|
|
338
389
|
onChange: (v: any) => setDraft({ ...draft, bootstrap: { ...(draft.bootstrap || {}), discoveryTools: v.split(/[,,\s]+/).filter((x: any) => x.length > 0) } })
|
|
339
390
|
}),
|
|
340
|
-
React.createElement(
|
|
391
|
+
React.createElement(Field, {
|
|
341
392
|
label: t("bootstrapMaxTokens"),
|
|
342
|
-
hint: t("fieldBootstrapMaxTokens")
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
393
|
+
hint: t("fieldBootstrapMaxTokens")
|
|
394
|
+
},
|
|
395
|
+
React.createElement("input", {
|
|
396
|
+
className: "ap_input",
|
|
397
|
+
type: "number",
|
|
398
|
+
min: 0,
|
|
399
|
+
step: 1,
|
|
400
|
+
// 草稿态:编辑期间显示原始输入(清空/删改中间态不立即跳回 0),
|
|
401
|
+
// 失焦后才把显示归一化为生效数字,避免输入被强制改写的突兀感。
|
|
402
|
+
value: maxTokensText !== null ? maxTokensText : String(draft === null ? 0 : (draft.bootstrap && draft.bootstrap.maxTokens) || 0),
|
|
403
|
+
disabled: draft === null || (draft.bootstrap && draft.bootstrap.enabled === false),
|
|
404
|
+
onChange: (e: any) => {
|
|
405
|
+
const n = Number(e.target.value);
|
|
406
|
+
// 非法/清空归 0(= 不封顶);number input 本身已挡住大部分非法输入。
|
|
407
|
+
setMaxTokensText(e.target.value);
|
|
408
|
+
setDraft({ ...draft, bootstrap: { ...(draft.bootstrap || {}), maxTokens: Number.isSafeInteger(n) && n > 0 ? n : 0 } });
|
|
409
|
+
},
|
|
410
|
+
onBlur: () => setMaxTokensText(null)
|
|
411
|
+
})
|
|
412
|
+
)
|
|
413
|
+
),
|
|
414
|
+
// ── 极简提示词层分组 ──
|
|
415
|
+
React.createElement(Section, { title: t("sectionPrompt") },
|
|
350
416
|
React.createElement(BoolField, {
|
|
351
417
|
label: t("minimalPromptEnabled"),
|
|
352
418
|
hint: t("fieldMinimalPromptEnabled"),
|
|
@@ -367,7 +433,10 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
367
433
|
value: draft === null ? "" : ((draft.minimalPrompt && draft.minimalPrompt.persona) || ""),
|
|
368
434
|
disabled: draft === null || (draft.minimalPrompt && draft.minimalPrompt.enabled === false),
|
|
369
435
|
onChange: (v: any) => setDraft({ ...draft, minimalPrompt: { ...(draft.minimalPrompt || {}), persona: v } })
|
|
370
|
-
})
|
|
436
|
+
})
|
|
437
|
+
),
|
|
438
|
+
// ── 高级分组(默认收起):工具族 JSON 与核心工具展示 ──
|
|
439
|
+
React.createElement(Section, { title: t("sectionAdvanced"), defaultOpen: false },
|
|
371
440
|
React.createElement(Field, {
|
|
372
441
|
label: t("families"),
|
|
373
442
|
hint: familiesInvalid ? t("invalidFamilies") + (familiesError !== null ? " — " + familiesError : "") : t("fieldFamilies")
|
|
@@ -385,6 +454,7 @@ import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol"
|
|
|
385
454
|
hint: t("fieldCoreTools")
|
|
386
455
|
},
|
|
387
456
|
React.createElement("p", { className: "ap_hint" }, draft === null ? "" : (draft.coreTools || []).join(", "))
|
|
457
|
+
)
|
|
388
458
|
),
|
|
389
459
|
React.createElement(
|
|
390
460
|
"div",
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// ── dsh.d.ts augmentations (appended by scripts/build.mjs) ──
|
|
1
2
|
import type { Context as CordisContext } from "@deepseek-ai/cordis";
|
|
2
3
|
|
|
3
4
|
declare module "@deepseek-ai/cordis" {
|
|
@@ -122,7 +123,8 @@ export declare const name = "adaptive-perf";
|
|
|
122
123
|
*
|
|
123
124
|
* families:工具族。每族可配 tools(该族工具名,需存在于目标 preset 的目录,
|
|
124
125
|
* 插件运行时按实际可见工具取交集,不会因改名/缺失而崩溃)与 keywords(用户消息
|
|
125
|
-
*
|
|
126
|
+
* 命中任一触发词即放行该族;大小写不敏感;匹配方式由 keywordMatchMode 决定,
|
|
127
|
+
* 默认 smart:含 CJK 的触发词用子串匹配、纯 ASCII 词用词边界匹配)。
|
|
126
128
|
*
|
|
127
129
|
* bootstrap:首轮锚定(参照 dsh-anchored-standard 的实测结论)。请求 #1 只暴露
|
|
128
130
|
* bootstrap.tools(真实 Minimal 工具对),剥离 suppressedContextSources 列出的
|
|
@@ -154,6 +156,15 @@ export declare const DEFAULT_CONFIG: {
|
|
|
154
156
|
escalateOnKeyword: boolean;
|
|
155
157
|
/** 工具调用失败(UNKNOWN_TOOL 文本含隐藏工具名)时自动放行该族。 */
|
|
156
158
|
escalateOnUnknownTool: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* 触发词匹配模式:smart(默认)= 含 CJK 的关键词保持子串匹配(\b 词边界
|
|
161
|
+
* 对非 [A-Za-z0-9_] 字符无定义,纯 CJK 词会永不命中),纯 ASCII 词用词
|
|
162
|
+
* 边界匹配——避免 "goalish"/"goalie" 命中 "goal"、"refork" 命中 "fork"
|
|
163
|
+
* 这类常见英文词的子串误触发;substring = 一律子串(0.7.2 及以前的行为);
|
|
164
|
+
* word = 一律词边界(ASCII 字母/数字/下划线之外的位置视为边界,CJK 词
|
|
165
|
+
* 也可用)。
|
|
166
|
+
*/
|
|
167
|
+
keywordMatchMode: string;
|
|
157
168
|
/**
|
|
158
169
|
* 常驻上下文抑制(0.5.0):true = 整个会话剥离自动注入上下文
|
|
159
170
|
* (skill-catalog 技能目录提醒、agent-instructions AGENTS.md 摘要);
|
|
@@ -232,6 +243,7 @@ export declare const DEFAULT_CONFIG: {
|
|
|
232
243
|
};
|
|
233
244
|
export declare function normalizeConfig(source: any, defaults?: any): any;
|
|
234
245
|
/** remote.set 的严格校验:非法值直接拒绝并返回错误,而不是静默写坏文件。 */
|
|
246
|
+
export declare const MATCH_MODES: string[];
|
|
235
247
|
export declare function validateConfig(partial: any): void;
|
|
236
248
|
/** 被极简提示词层屏蔽的全局引导段(name, order,与 dsh-app-boot /
|
|
237
249
|
* dsh-web-app / dsh-system-prompt 的注册一致)。 */
|
|
@@ -241,8 +253,11 @@ export declare const PERSONA_SECTION_NAME = "deployment:persona";
|
|
|
241
253
|
export declare const PERSONA_SECTION_ORDER = 0;
|
|
242
254
|
/** 提取一条用户消息的顶层文本(text 块拼接)。 */
|
|
243
255
|
export declare function extractUserText(message: any): string;
|
|
244
|
-
/**
|
|
245
|
-
|
|
256
|
+
/**
|
|
257
|
+
* 大小写不敏感的关键词匹配:任一关键词命中即返回 true。
|
|
258
|
+
* @param mode - 'smart'(默认)/ 'substring' / 'word',见 DEFAULT_CONFIG.keywordMatchMode。
|
|
259
|
+
*/
|
|
260
|
+
export declare function matchKeywords(text: any, keywords: any, mode?: any): boolean;
|
|
246
261
|
/** 收集一次工具调用失败的模型可见文本(error 字段 + content 文本块)。 */
|
|
247
262
|
export declare function collectFailureText(result: any): string;
|
|
248
263
|
/**
|
|
@@ -299,7 +314,6 @@ export declare const PROMOTE_EVENTS: {
|
|
|
299
314
|
either: string[];
|
|
300
315
|
};
|
|
301
316
|
/**
|
|
302
|
-
/**
|
|
303
317
|
* dev_tool_search:搜索完整可见目录并按名解锁工具(解锁结果下一请求生效,
|
|
304
318
|
* 经 syncBootstrap 重算 deny 集;解锁记录写入 a.unlocked,resume-safe 由
|
|
305
319
|
* loadUnlockedFromEvents 从持久事件恢复)。
|
|
@@ -332,8 +346,6 @@ export declare function observePhase(state: any, sessionId: any, event: any): vo
|
|
|
332
346
|
* 调用方决定是否降级(全目录放行)。
|
|
333
347
|
*/
|
|
334
348
|
export declare function filterBootstrapTools(assembly: any, keep: any): any;
|
|
335
|
-
/** 按 source.kind 剥离自动注入的上下文消息(保留主动的用户消息)。 */
|
|
336
|
-
export declare function filterBootstrapMessages(messages: any, suppressedSources: any): any;
|
|
337
349
|
/** 首轮输出预算:未晋升 → 封顶;已晋升 → 若仍带着封顶值则剥离。
|
|
338
350
|
* 剥离条件是"值等于当前配置的 cap 或本会话曾写入过的任何旧 cap":
|
|
339
351
|
* 用户在晋升前后改过 cap 的话,header 里残留的是旧值,只比对当前值
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;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