dsh-plugin-prompt-tool 0.7.2 → 0.8.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/README.md +185 -46
- package/engine/THIRD_PARTY_LICENSES +25 -0
- package/engine/actions.mjs +931 -0
- package/engine/anchor-match.mjs +6 -3
- package/engine/character-tools.mjs +11 -0
- package/engine/classify-task.mjs +18 -0
- package/engine/compaction-epoch.mjs +41 -20
- package/engine/compositions/library/agent-instructions.yml +9 -0
- package/engine/compositions/library/command-goal.yml +2 -6
- package/engine/compositions/library/compaction.yml +2 -32
- package/engine/compositions/library/delegation-ptc.yml +58 -0
- package/engine/compositions/library/delegation.yml +5 -38
- package/engine/compositions/library/persistent-shell.yml +4 -13
- package/engine/compositions/library/planning.yml +8 -23
- package/engine/compositions/library/skill-filesystem-cordis.yml +10 -0
- package/engine/compositions/library/skill-filesystem.yml +2 -8
- package/engine/compositions/library/tool-ask-user.yml +2 -3
- package/engine/compositions/library/tool-bash.yml +4 -12
- package/engine/compositions/library/tool-cordis.yml +7 -0
- package/engine/compositions/library/tool-fs-search.yml +2 -11
- package/engine/compositions/library/tool-fs.yml +2 -5
- package/engine/compositions/library/tool-goal.yml +2 -6
- package/engine/compositions/library/tool-jobs.yml +2 -18
- package/engine/compositions/library/tool-plugin-manager-disabled.yml +8 -0
- package/engine/compositions/library/tool-plugin-manager.yml +8 -0
- package/engine/compositions/library/tool-present.yml +7 -0
- package/engine/compositions/library/tool-presentation.yml +9 -0
- package/engine/compositions/library/tool-pwsh.yml +2 -6
- package/engine/compositions/library/tool-skill.yml +7 -0
- package/engine/compositions/library/tool-todo.yml +2 -4
- package/engine/compositions/library/tool-web.yml +2 -1
- package/engine/compositions/source/local/character-tools.yml +5 -0
- package/engine/compositions/source/local/declared-triggers.yml +12 -0
- package/engine/compositions/source/local/filesystem-editor.yml +30 -0
- package/engine/compositions/source/local/instruction-hint.yml +15 -0
- package/engine/compositions/{library/official-persistent-shell.yml → source/local/persistent-shell-posix.yml} +10 -8
- package/engine/compositions/source/local/prompt-config-engine.yml +3 -9
- package/engine/compositions/source/local/run-code-env.yml +4 -7
- package/engine/compositions/source/local/session-var-tools.yml +5 -0
- package/engine/compositions/source/local/skill-search.yml +3 -9
- package/engine/compositions/source/local/subagent-tool-policy.yml +21 -0
- package/engine/compositions/source/local/tool-bash-disabled.yml +9 -0
- package/engine/compositions/source/local/tool-config-engine.yml +8 -0
- package/engine/compositions/source/local/tool-git-bash.yml +15 -0
- package/engine/compositions/source/local/world-book-tools.yml +5 -0
- package/engine/condition.mjs +83 -0
- package/engine/declared-triggers.mjs +93 -0
- package/engine/executor.mjs +364 -185
- package/engine/fields.mjs +219 -0
- package/engine/fillers.mjs +12 -141
- package/engine/host-package.mjs +51 -0
- package/engine/instruction-hint.mjs +285 -0
- package/engine/interpolate.mjs +157 -29
- package/engine/layers.mjs +495 -75
- package/engine/predicates.mjs +753 -0
- package/engine/prompt-config-engine.mjs +63 -8
- package/engine/run-code-env.mjs +48 -31
- package/engine/schema.mjs +444 -103
- package/engine/sdk-strip.mjs +365 -0
- package/engine/session-var-tools.mjs +11 -0
- package/engine/session-vars.mjs +8 -6
- package/engine/shared.mjs +137 -0
- package/engine/skill-search.mjs +34 -21
- package/engine/st-macros.d.mts +22 -0
- package/engine/st-macros.mjs +208 -0
- package/engine/st-render.mjs +105 -0
- package/engine/st-world-book.d.mts +10 -0
- package/engine/st-world-book.mjs +259 -0
- package/engine/strategies.mjs +31 -20
- package/engine/subagent-tool-policy-core.mjs +400 -0
- package/engine/subagent-tool-policy.mjs +327 -0
- package/engine/tool-config-engine.mjs +207 -145
- package/engine/tool-definition.mjs +143 -0
- package/engine/{custom-bash.mjs → tool-git-bash.mjs} +38 -13
- package/engine/trigger-editor-meta.mjs +48 -0
- package/engine/trigger-spec.mjs +257 -0
- package/engine/trigger.mjs +304 -0
- package/engine/world-book-tools.mjs +11 -0
- package/lib/client.js +16495 -5456
- package/lib/client.js.map +1 -1
- package/lib/index.d.mts +628 -382
- package/lib/index.mjs +5391 -2942
- package/lib/paths-CY5psBqE.d.mts +1233 -0
- package/lib/preset-package-BnJqrU4R.mjs +16792 -0
- package/lib/preset-transfer.d.mts +2 -0
- package/lib/preset-transfer.mjs +2 -0
- package/package.json +91 -49
- package/preset/pt-cordis/preset.yml +43 -0
- package/preset/pt-cordis/skills/cordis-composition-reference/SKILL.md +29 -0
- package/preset/pt-cordis/skills/cordis-composition-reference/references/packages.md +501 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/SKILL.md +38 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/references/host-plugin.md +60 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/references/mcp-bundle.md +5 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/references/ui-plugin.md +13 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/references/verification.md +5 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/templates/decoration/client.js +22 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/templates/decoration/cordis.patch.yml +3 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/templates/decoration/index.js +2 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/templates/decoration/package.json +15 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/templates/mcp/cordis.patch.yml +8 -0
- package/preset/pt-cordis/skills/cordis-plugin-development/templates/mcp/package.json +7 -0
- package/preset/pt-cordis/skills/editing-cordis-compositions/SKILL.md +84 -0
- package/preset/pt-custom/preset.yml +15 -0
- package/preset/pt-minimal/preset.yml +27 -0
- package/preset/pt-ptc/preset.yml +45 -0
- package/preset/pt-standard/preset.yml +43 -0
- package/templates/14-first-turn-anchor.yml +4 -4
- package/templates/15-guide-auto.yml +3 -3
- package/templates/16-custom-fallback.yml +1 -0
- package/templates/18-placeholder-env-facts.yml +3 -3
- package/templates/20-system-section.yml +3 -2
- package/templates/65-turn-stop.yml +18 -0
- package/templates/66-subagent-start.yml +14 -0
- package/templates/75-subagent-end.yml +15 -0
- package/templates/tools/10-shell-command.yml +1 -1
- package/templates/tools/40-delegate-character.yml +1 -1
- package/templates/tools/50-delegate-worldbook.yml +1 -1
- package/templates/tools/60-delegate-session-var.yml +1 -1
- package/templates/tools/70-delegate-worldbook-upsert.yml +1 -1
- package/engine/anchor-turn.mjs +0 -68
- package/engine/code-presentation.mjs +0 -103
- package/engine/compositions/library/anchor-turn.yml +0 -10
- package/engine/compositions/library/bootstrap-filesystem.yml +0 -19
- package/engine/compositions/library/code-presentation.yml +0 -8
- package/engine/compositions/library/context-gate.yml +0 -39
- package/engine/compositions/library/cot-drip.yml +0 -11
- package/engine/compositions/library/custom-bash.yml +0 -14
- package/engine/compositions/library/deliberation-gate.yml +0 -11
- package/engine/compositions/library/official-agent-instructions.yml +0 -17
- package/engine/compositions/library/official-skill-filesystem-cordis.yml +0 -10
- package/engine/compositions/library/official-tool-bash.yml +0 -6
- package/engine/compositions/library/official-tool-cordis.yml +0 -13
- package/engine/compositions/library/official-tool-presentation.yml +0 -7
- package/engine/compositions/library/official-tool-skill.yml +0 -14
- package/engine/compositions/library/persona.yml +0 -13
- package/engine/compositions/library/prompt-config-engine.yml +0 -16
- package/engine/compositions/library/run-code-env.yml +0 -15
- package/engine/compositions/library/skill-search.yml +0 -14
- package/engine/compositions/library/str-replace-editor.yml +0 -10
- package/engine/compositions/library/tool-bootstrap.yml +0 -14
- package/engine/compositions/library/tool-config-engine.yml +0 -9
- package/engine/compositions/library/tool-filter.yml +0 -8
- package/engine/compositions/source/local/code-presentation.yml +0 -8
- package/engine/compositions/source/local/context-gate.yml +0 -36
- package/engine/compositions/source/local/custom-bash.yml +0 -11
- package/engine/compositions/source/local/str-replace-editor.yml +0 -10
- package/engine/compositions/source/local/tool-bootstrap.yml +0 -11
- package/engine/compositions/source/local/tool-filter.yml +0 -8
- package/engine/context-gate.mjs +0 -305
- package/engine/cot-drip.mjs +0 -137
- package/engine/deliberation-gate.mjs +0 -127
- package/engine/tool-bootstrap.mjs +0 -476
- package/engine/tool-filter.mjs +0 -80
- package/lib/preset-core.d.mts +0 -10
- package/lib/preset-core.mjs +0 -77
- package/lib/prompt-configs-BnQKRHVb.mjs +0 -884
- package/lib/prompt-configs-CN0sJTUL.d.mts +0 -193
- package/preset/anchored/preset.yml +0 -296
- package/preset/creative/preset.yml +0 -67
- package/preset/creative/skills/cordis-plugin-development/SKILL.md +0 -420
- package/preset/creative/skills/editing-cordis-compositions/SKILL.md +0 -165
- package/preset/custom/preset.yml +0 -12
- package/preset/liangshen/preset.yml +0 -75
- package/preset/minimal/preset.yml +0 -45
- package/preset/ptc/preset.yml +0 -58
- package/preset/standard/preset.yml +0 -57
- package/skills/manifest.json +0 -7
- package/skills/sandboxmod/SKILL.md +0 -49
- package/skills/web ui/SKILL.md +0 -42
package/lib/index.d.mts
CHANGED
|
@@ -1,103 +1,250 @@
|
|
|
1
|
-
import { c as
|
|
1
|
+
import { $ as ENGINE_RECIPES, A as resolvePresetParams, B as MAX_CHARACTER_CARD_STREAM_BYTES, C as loadPresetSpec, D as renderComposition, E as removeUserPreset, F as BridgeEndpoint, G as SkillPolicyChange, H as SkillCatalogEntry, I as BridgeErrorPayload, J as SkillsCatalogSnapshot, K as SkillPolicyScope, L as BridgeRequestMap, M as savePresetPersona, N as userPresetsDir, O as resolvePresetDir, P as BRIDGE_ENDPOINTS, Q as ENGINE_CAPABILITIES, R as BridgeValueMap, S as listPresets, T as removePresetModule, U as SkillContentSnapshot, V as SETTINGS_BRIDGE_PREFIX, W as SkillInvocation, X as invocationForScope, Y as SkillsState, Z as scopeOfInvocation, _ as buildModuleConfigsFromParams, a as installPresetPackage, at as isEngineCapabilityPresent, b as ensurePresetSeed, c as convertStToPreset, ct as ImportChoices, d as stPresetId, dt as InstructionFileSnapshot, et as EngineCapability, f as EngineCapabilityCreateRequest, ft as InstructionFileStatus, g as applyModuleConfigs, h as PresetSpec, i as exportPresetPackage, it as engineRecipe, j as savePresetParams, k as resolvePresetModuleFacts, l as mergeStPresets, lt as INSTRUCTION_FILE_STATUSES, m as EngineCapabilityRemoveResult, n as USER_SKILLS_DIR, nt as PresetModuleFacts, o as presetImportPreview, ot as validateCustomToolIdentities, p as EngineCapabilityCreateResult, pt as MAX_INSTRUCTION_FILE_BYTES, q as SkillSourceKind, r as expandPresetSource, rt as engineCapability, s as StConversionOptions, st as AssetFile, tt as ModuleSourceMode, u as processStText, ut as InstructionContextView, v as cloneBuiltinPreset, w as removeEngineCapabilityFromPreset, x as listBuiltinTemplates, y as createEngineCapabilityInPreset, z as MAX_BRIDGE_BODY_BYTES } from "./paths-CY5psBqE.mjs";
|
|
2
2
|
import { parseDocument } from "yaml";
|
|
3
3
|
import z from "@deepseek-ai/schemastery";
|
|
4
|
-
import { Context } from "@deepseek-ai/cordis";
|
|
4
|
+
import { Context, Volatile } from "@deepseek-ai/cordis";
|
|
5
|
+
import { SkillViewOptions } from "@deepseek-ai/dsh-skill";
|
|
6
|
+
import { AgentOptions } from "@deepseek-ai/dsh-agent";
|
|
7
|
+
import { SubagentRuntime } from "@deepseek-ai/dsh-subagent";
|
|
8
|
+
//#region src/host/prompt-configs.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* `PromptConfigSpec` 各枚举字段的**运行期值清单**。
|
|
11
|
+
*
|
|
12
|
+
* 类型由它派生(`(typeof X)[number]`),守卫测试也读它——于是「类型允许的值」与
|
|
13
|
+
* 「守卫断言的值」是同一份,不可能各自漂移;而这两个值集合都必须与 `engine/schema.mjs`
|
|
14
|
+
* 的对应 `KNOWN_*` 一致(守卫见 `test/shared/prompt-config-spec-enums.test.mjs`)。
|
|
15
|
+
*
|
|
16
|
+
* 为什么不直接从引擎派生类型:引擎是仓库根的纯 `.mjs`(无 `.d.mts`,`src/` 侧靠
|
|
17
|
+
* `@ts-expect-error` 引入),其 `KNOWN_*` 在 TS 看来是 `any`,派生不出字面量联合。
|
|
18
|
+
*/
|
|
19
|
+
declare const PROMPT_CONFIG_SPEC_ENUMS: {
|
|
20
|
+
readonly configKind: readonly ["ordered", "anchor"];
|
|
21
|
+
readonly role: readonly ["user"];
|
|
22
|
+
readonly position: readonly ["after-user", "before-all", "after-all"];
|
|
23
|
+
readonly dedupe: readonly ["session", "batch", "none"];
|
|
24
|
+
readonly promotion: readonly ["none", "main", "include-subagents"];
|
|
25
|
+
readonly audience: readonly ["main", "subagent"];
|
|
26
|
+
readonly subject: readonly ["toolArgs", "toolResult", "userMessage", "assistantText", "subagentInfo"];
|
|
27
|
+
readonly modelScope: readonly ["all", "pro", "flash"];
|
|
28
|
+
readonly mergeMode: readonly ["separate", "merged"];
|
|
29
|
+
};
|
|
30
|
+
/** 取上面某一条枚举的值联合。 */
|
|
31
|
+
type SpecEnum<K extends keyof typeof PROMPT_CONFIG_SPEC_ENUMS> = (typeof PROMPT_CONFIG_SPEC_ENUMS[K])[number];
|
|
32
|
+
interface PromptConfigSpec {
|
|
33
|
+
id: string;
|
|
34
|
+
name?: string;
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
strategy?: string;
|
|
37
|
+
layer?: string;
|
|
38
|
+
configKind?: SpecEnum<'configKind'>;
|
|
39
|
+
order?: number;
|
|
40
|
+
role?: SpecEnum<'role'>;
|
|
41
|
+
group?: string;
|
|
42
|
+
exclusive?: boolean;
|
|
43
|
+
position?: SpecEnum<'position'>;
|
|
44
|
+
dedupe?: SpecEnum<'dedupe'>;
|
|
45
|
+
promotion?: SpecEnum<'promotion'>;
|
|
46
|
+
/** 消息受众:缺省(省略/null)= 公用(主会话+子代理);main=仅主会话;subagent=仅子代理。 */
|
|
47
|
+
audience?: SpecEnum<'audience'> | null;
|
|
48
|
+
/** 条件判定的匹配对象;缺省由层决定(engine/schema.mjs 的 LAYER_DEFAULT_SUBJECT)。 */
|
|
49
|
+
subject?: SpecEnum<'subject'>;
|
|
50
|
+
/** 条件判定的键集合;省略 = 无条件(旧行为)。 */
|
|
51
|
+
match?: PromptConfigMatch;
|
|
52
|
+
modelScope?: SpecEnum<'modelScope'>;
|
|
53
|
+
sourceKind?: string;
|
|
54
|
+
form?: string;
|
|
55
|
+
summary?: string;
|
|
56
|
+
identity?: {
|
|
57
|
+
field: 'plugin';
|
|
58
|
+
value: string;
|
|
59
|
+
};
|
|
60
|
+
text?: string;
|
|
61
|
+
/** 单条提示词配置的多段文本:注入为一条消息的多个 text 内容块。 */
|
|
62
|
+
texts?: string[];
|
|
63
|
+
/** 同位置多条提示词配置的插入方式:separate=先后插入独立消息(默认);merged=拼接为一条消息。 */
|
|
64
|
+
mergeMode?: SpecEnum<'mergeMode'>;
|
|
65
|
+
templateFile?: string;
|
|
66
|
+
fill?: string;
|
|
67
|
+
variables?: Record<string, string>;
|
|
68
|
+
params?: Record<string, unknown>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 提示词配置 / 自定义工具 ID 的安全文件名段校验:ID 直接拼进生成文件名
|
|
72
|
+
* (prompt-configs/<n>-<id>.yml / custom-tools/<n>-<id>.yml),含路径分隔符
|
|
73
|
+
* 或 Windows 非法字符会越出生成目录或写盘失败,保存/物化前 fail loud 拒绝。
|
|
74
|
+
* 允许 [a-zA-Z0-9._-] 与常见中文/多字节字符(ST 导入 id 含中文),
|
|
75
|
+
* 仅拒绝分隔符、控制字符、点目录与 Windows 保留字符。
|
|
76
|
+
*/
|
|
77
|
+
declare function assertSafeConfigId(id: string): void;
|
|
78
|
+
/** 生成文件名统一 4 位零填充前缀(0000-…),超过 10 条后字典序仍稳定。 */
|
|
79
|
+
declare function configFileName(index: number, id: string): string;
|
|
80
|
+
interface PromptConfigFile {
|
|
81
|
+
/** 模块文件夹内文件名(数字前缀决定引擎执行顺序)。 */
|
|
82
|
+
file: string;
|
|
83
|
+
/** yml 文件内容。 */
|
|
84
|
+
content: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 条件判定的键集合:与 `engine/anchor-match.mjs` 的匹配语义同构。
|
|
88
|
+
* 键按字面文本匹配(正则元字符会被转义);要写正则须用 `/pattern/flags` 形态或 `useRegex: true`。
|
|
89
|
+
*/
|
|
90
|
+
interface PromptConfigMatch {
|
|
91
|
+
keys?: string[];
|
|
92
|
+
secondaryKeys?: string[];
|
|
93
|
+
logic?: 'any' | 'all' | 'not' | 'notAny';
|
|
94
|
+
caseSensitive?: boolean;
|
|
95
|
+
wholeWords?: boolean;
|
|
96
|
+
useRegex?: boolean;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/shared/engine-params.d.ts
|
|
100
|
+
/**
|
|
101
|
+
* 引擎行为参数契约(单一来源)。
|
|
102
|
+
*
|
|
103
|
+
* 这是「可配置引擎参数」的类型唯一权威:所有消费引擎参数的接口(RuntimeOptions /
|
|
104
|
+
* WritePresetOptions)从这里派生,不再各自手写一遍字段
|
|
105
|
+
* (此前多处重复声明导致同字段签名漂移,如 maxDepth / modelTemperature)。
|
|
106
|
+
*
|
|
107
|
+
* 分层约定:
|
|
108
|
+
* - 本文件 = 引擎参数「契约层」(类型):参数桥/模板/UI 可配置的键与类型;
|
|
109
|
+
* - ENGINE_PARAM_DEFINITIONS 统一键、校验、卡片、默认草稿与组合映射;
|
|
110
|
+
* Record<keyof EngineParams, ...> 强制完整覆盖,ENGINE_PARAM_KEYS 与 PARAM_KEYS 从其派生;
|
|
111
|
+
* - layerSettings ↔ 运行时平铺键:loadPresetSpec 展平 / savePresetParams 按层写入。
|
|
112
|
+
*
|
|
113
|
+
* 全部字段可选:缺省 = 模板 preset.yml layerSettings / 引擎默认,符合「一切皆可自定义」。
|
|
114
|
+
*/
|
|
115
|
+
interface EngineParams {
|
|
116
|
+
/** 首轮近距离锚定:首条真实用户消息后追加一次性首句锚点。 */
|
|
117
|
+
firstTurnAnchor?: boolean;
|
|
118
|
+
/** 自定义锚点文本;firstTurnCustom=true 时固定使用。 */
|
|
119
|
+
firstTurnText?: string;
|
|
120
|
+
/** 自定义锚点开关:true 固定使用 firstTurnText;false 按任务自动选择。 */
|
|
121
|
+
firstTurnCustom?: boolean;
|
|
122
|
+
/** 自定义每轮引导文本;guideCustom=true 时固定使用。 */
|
|
123
|
+
guideText?: string;
|
|
124
|
+
/** 自定义每轮引导开关:true 固定使用 guideText;false 按任务自动选择。 */
|
|
125
|
+
guideCustom?: boolean;
|
|
126
|
+
/** 每轮引导独立开关;缺省关闭。 */
|
|
127
|
+
guideEnabled?: boolean;
|
|
128
|
+
/** 锚定确认后注入 preset.md;关闭时仍保留工具引导,但不生成 prompt-injector 提示词配置内容。 */
|
|
129
|
+
injectPrompt?: boolean;
|
|
130
|
+
/** 模型路由 provider;与模型名同时非空时给 subagent/subagent_fork 行加 agentOptions(主对话直派子代理与委派子代理通用)。 */
|
|
131
|
+
modelProvider?: string;
|
|
132
|
+
/** 模型名;与 provider 同时非空时生效。 */
|
|
133
|
+
modelName?: string;
|
|
134
|
+
/** 子代理固定模型路由 provider(agentOptions 注入 tool-subagent)。 */
|
|
135
|
+
subagentModelProvider?: string;
|
|
136
|
+
/** 子代理固定模型名。 */
|
|
137
|
+
subagentModelName?: string;
|
|
138
|
+
/** 主对话思维程度(agent-request patch reasoningEffort;''=不设置,官方档位 off/low/high/max)。 */
|
|
139
|
+
modelReasoningEffort?: string;
|
|
140
|
+
/** 主对话采样温度(agent-request patch temperature;''=不设置)。 */
|
|
141
|
+
modelTemperature?: string;
|
|
142
|
+
/** 主对话输出上限(agent-request patch maxTokens;''=不设置)。 */
|
|
143
|
+
modelMaxTokens?: string;
|
|
144
|
+
/** 子代理思维程度(agent-request patch,audience=subagent;''=不设置)。 */
|
|
145
|
+
subagentReasoningEffort?: string;
|
|
146
|
+
/** 子代理采样温度(agent-request patch,audience=subagent;''=不设置)。 */
|
|
147
|
+
subagentTemperature?: string;
|
|
148
|
+
/** 子代理输出上限(agent-request patch,audience=subagent;''=不设置)。 */
|
|
149
|
+
subagentMaxTokens?: string;
|
|
150
|
+
/** 委派递归深度上限(0 禁止委派 / provider-managed / 正整数;数字字符串同义)。 */
|
|
151
|
+
maxDepth?: number | 'provider-managed' | string;
|
|
152
|
+
/** custom-fallback 锚定词(prompt-injector params.firstTurnWord)。 */
|
|
153
|
+
firstTurnWord?: string;
|
|
154
|
+
/**
|
|
155
|
+
* 锚定/引导内容键:writePreset 把它们映射进 near-anchor / router-guide 的
|
|
156
|
+
* promptConfig params(由对应策略消费)。此前只在 PARAM_KEYS 旁路白名单里,
|
|
157
|
+
* 保存链接受键名却被值校验拒绝,形成「白名单通过、写盘前报未知键」的断层。
|
|
158
|
+
*/
|
|
159
|
+
/** 构建任务正则(锚定三档分类的 build 档;编译规则与 engine/classify-task.mjs 同源,flags=i)。 */
|
|
160
|
+
buildPattern?: string;
|
|
161
|
+
/** 复杂任务正则(锚定 complex 档与引导深度判定共用)。 */
|
|
162
|
+
complexPattern?: string;
|
|
163
|
+
/** 构建档锚句。 */
|
|
164
|
+
firstTurnBuild?: string;
|
|
165
|
+
/** 排查档锚句。 */
|
|
166
|
+
firstTurnInspect?: string;
|
|
167
|
+
/** 深度档锚句。 */
|
|
168
|
+
firstTurnDeep?: string;
|
|
169
|
+
/** 引导-简短档正文。 */
|
|
170
|
+
guideWeak?: string;
|
|
171
|
+
/** 引导-深度档正文。 */
|
|
172
|
+
guideDeep?: string;
|
|
173
|
+
/** 晋升后 agent-instructions 全文 → 一次性 hint。 */
|
|
174
|
+
instructionHint?: boolean;
|
|
175
|
+
/** str-replace-editor 最大输出字符数(参数桥默认官方值 16000;由引擎能力卡编辑)。 */
|
|
176
|
+
strReplaceEditorMaxOutputChars?: number;
|
|
177
|
+
/** tool-git-bash 行的能力开关(B2 T3 补;此前该行只能靠「在不在组合里」决定启停)。 */
|
|
178
|
+
toolGitBashEnabled?: boolean;
|
|
179
|
+
/** 自定义模型工具在执行前需用户批准的执行器种类。 */
|
|
180
|
+
customToolRequireApproval?: string[] | string;
|
|
181
|
+
}
|
|
182
|
+
type EngineParamKey = keyof EngineParams;
|
|
183
|
+
/**
|
|
184
|
+
* writePreset.runtimeOf 实际透传进运行时 params 的引擎参数子集。
|
|
185
|
+
* RuntimeOptions(装配态)与 WritePresetOptions(写入态)都从这里派生,
|
|
186
|
+
* 防止「加参数只改一处、writePreset 忘透传」的静默漂移(如 stageAdvanceDescription 历史事故)。
|
|
187
|
+
*/
|
|
188
|
+
type PresetWriterParams = Partial<EngineParams>;
|
|
189
|
+
/**
|
|
190
|
+
* 数值型引擎参数保存前校验(与 write-preset.modelRequestConfigs 消费规则同源)。
|
|
191
|
+
* 保存层响亮失败(400 逐字段错误),渲染层保持宽容(never-brick):
|
|
192
|
+
* - 布尔键:必须是 boolean;
|
|
193
|
+
* - 数值键(temperature / maxTokens / 字符数):'' = 合法(删键回落默认);
|
|
194
|
+
* 非空必须可解析为数字并满足各自约束(有限数 / 正整数);
|
|
195
|
+
* - 字符串键:必须是 string('' = 删键回落默认);
|
|
196
|
+
* - 列表键(执行器种类等):必须是 string 或 string[];
|
|
197
|
+
* - maxDepth:'' / 'provider-managed' / 非负安全整数及其数字字符串。
|
|
198
|
+
* 未知键(旧内容别名等不兼容键)在保存期响亮失败,不做运行时自动兼容。
|
|
199
|
+
* 注意:内容占位变量(variables)的空字符串是合理设计(世界书动态引用),
|
|
200
|
+
* 本函数只校验引擎行为参数,绝不碰 variables 通道。
|
|
201
|
+
*/
|
|
202
|
+
interface EngineParamValueError {
|
|
203
|
+
key: string;
|
|
204
|
+
message: string;
|
|
205
|
+
}
|
|
206
|
+
declare const ENGINE_PARAM_KEYS: EngineParamKey[];
|
|
207
|
+
/** writePreset.runtimeOf 实际透传键:全部引擎参数可直接进入 writer。 */
|
|
208
|
+
declare const WRITER_PARAM_KEYS: (keyof EngineParams)[];
|
|
209
|
+
/**
|
|
210
|
+
* 校验参数键值(键集合合法性由调用方白名单先行校验,本函数同样拒绝未知键)。
|
|
211
|
+
* 返回逐字段错误;空数组 = 通过。类型收窄:布尔/字符串/数值/列表各按 canonical
|
|
212
|
+
* 规则校验;'' 是合法删键值,其余非法类型与越界值在保存层响亮失败。
|
|
213
|
+
*/
|
|
214
|
+
declare function validateEngineParamValues(overrides: Record<string, unknown>): EngineParamValueError[];
|
|
215
|
+
//#endregion
|
|
5
216
|
//#region src/shared/param-keys.d.ts
|
|
6
217
|
declare const PARAM_KEYS: ReadonlySet<string>;
|
|
7
218
|
//#endregion
|
|
8
219
|
//#region src/config.d.ts
|
|
9
220
|
interface Config {
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
/** 是否生成锚定注入 preset(默认 true)。 */
|
|
15
|
-
writePreset: boolean;
|
|
16
|
-
/** 预设模板名(默认 anchored;其他模板时 anchored 专属 UI 可隐藏)。 */
|
|
17
|
-
presetTemplate: string;
|
|
18
|
-
/** 以技能目录名为键的逐技能开关,缺省视为 true。 */
|
|
19
|
-
skillSwitches: Record<string, boolean>;
|
|
20
|
-
/** 技能展示顺序(目录名数组):排前面的技能 rank 更小,模型最先看到。 */
|
|
21
|
-
skillOrder: string[];
|
|
22
|
-
/** 用户自定义技能目录列表(按添加顺序,首个目录优先级最高);空 = 自动使用当前 profile 下的 skills/ 副本。 */
|
|
23
|
-
skillsDirs: string[];
|
|
24
|
-
/** 旧版单值技能目录(仅读取迁移用,新版本统一写回 skillsDirs)。 */
|
|
25
|
-
skillsDir?: string;
|
|
26
|
-
/** 技能候选排序基数,技能目录内按下标递增。 */
|
|
27
|
-
skillRankBase: number;
|
|
28
|
-
/** 常驻规则文件目标路径。 */
|
|
29
|
-
residentAgentsPath: string;
|
|
30
|
-
/** 生成的 agent preset 目录。 */
|
|
31
|
-
presetDir: string;
|
|
221
|
+
/** 是否生成注入预设(默认 true)。 */
|
|
222
|
+
writePreset: Volatile<boolean>;
|
|
223
|
+
/** 预设模板名(默认 pt-standard:与宿主内置 standard 同名的用户目录会被遮蔽)。 */
|
|
224
|
+
presetTemplate: Volatile<string>;
|
|
32
225
|
/** 生成 preset 的显示顺序。 */
|
|
33
|
-
presetOrder: number
|
|
226
|
+
presetOrder: Volatile<number>;
|
|
34
227
|
/** preset.md 缺失或不可读时使用的文本。 */
|
|
35
|
-
fallbackText: string
|
|
36
|
-
}
|
|
37
|
-
declare const Config: z<Config>;
|
|
38
|
-
interface SkillEntry {
|
|
39
|
-
/** 来源技能目录的绝对路径(多目录合并后用于修复定位与归属展示)。 */
|
|
40
|
-
dir: string;
|
|
41
|
-
folder: string;
|
|
42
|
-
file: string;
|
|
43
|
-
name: string;
|
|
44
|
-
description: string;
|
|
45
|
-
whenToUse?: string;
|
|
46
|
-
metadata?: Record<string, unknown>;
|
|
47
|
-
body: string;
|
|
48
|
-
/** 是否通过官方 dsh-skill 候选校验;false 时只进管理界面,不注册给模型。 */
|
|
49
|
-
valid: boolean;
|
|
50
|
-
/** invalid 条目的原因(可为空)。 */
|
|
51
|
-
issue?: string;
|
|
52
|
-
/** 通过符号链接/junction 挂入的目录(删除类操作需谨慎)。 */
|
|
53
|
-
linked?: boolean;
|
|
54
|
-
/** 官方调用策略:disable-model-invocation: true 时模型不可调用。 */
|
|
55
|
-
modelInvocable: boolean;
|
|
56
|
-
/** 官方调用策略:user-invocable: false 时用户不可调用。 */
|
|
57
|
-
userInvocable: boolean;
|
|
58
|
-
}
|
|
59
|
-
interface SkillCatalogEntry {
|
|
60
|
-
folder: string;
|
|
61
|
-
name: string;
|
|
62
|
-
description: string;
|
|
63
|
-
/** 是否通过官方 dsh-skill 候选校验;false 时 UI 灰显并展示 issue。 */
|
|
64
|
-
valid: boolean;
|
|
65
|
-
/** 来源技能目录绝对路径(多目录管理:修复定位 / 归属展示 / 目录计数)。 */
|
|
66
|
-
dir?: string;
|
|
67
|
-
/** 同名标记:多个目录存在相同 folder 时全部保留,UI 标注同名。 */
|
|
68
|
-
duplicate?: boolean;
|
|
69
|
-
/** invalid 条目的原因。 */
|
|
70
|
-
issue?: string;
|
|
71
|
-
/** 通过符号链接/junction 挂入的目录(删除类操作需谨慎)。 */
|
|
72
|
-
linked?: boolean;
|
|
73
|
-
modelInvocable: boolean;
|
|
74
|
-
userInvocable: boolean;
|
|
228
|
+
fallbackText: Volatile<string>;
|
|
75
229
|
}
|
|
230
|
+
declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
231
|
+
writePreset: z<boolean, boolean, "volatile-defined">;
|
|
232
|
+
presetTemplate: z<string, string, "volatile-defined">;
|
|
233
|
+
presetOrder: z<number, number, "volatile-defined">;
|
|
234
|
+
fallbackText: z<string, string, "volatile-defined">;
|
|
235
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
236
|
+
writePreset: z<boolean, boolean, "volatile-defined">;
|
|
237
|
+
presetTemplate: z<string, string, "volatile-defined">;
|
|
238
|
+
presetOrder: z<number, number, "volatile-defined">;
|
|
239
|
+
fallbackText: z<string, string, "volatile-defined">;
|
|
240
|
+
}>>, "plain">;
|
|
76
241
|
interface PromptSettings {
|
|
77
|
-
injectAgentsPrompt: boolean;
|
|
78
242
|
/** 运行时检测:是否检测到任何模型服务商(不写入 settings)。 */
|
|
79
243
|
modelsAvailable: boolean;
|
|
80
|
-
skillSwitches: Record<string, boolean>;
|
|
81
|
-
/** 技能展示顺序(目录名数组)。 */
|
|
82
|
-
skillOrder: string[];
|
|
83
|
-
skillCatalog: SkillCatalogEntry[];
|
|
84
|
-
/** 用户自定义技能目录列表(按添加顺序);空 = 自动使用 profile skills 副本。 */
|
|
85
|
-
skillsDirs: string[];
|
|
86
|
-
/** 当前实际生效的技能目录列表(空配置 = [profile 副本路径])。 */
|
|
87
|
-
activeSkillsDirs: string[];
|
|
88
|
-
/** 生效目录存在性(path → 目录是否存在,供 UI 状态徽章)。 */
|
|
89
|
-
skillsDirExists: Record<string, boolean>;
|
|
90
|
-
/** 技能候选排序基数。 */
|
|
91
|
-
skillRankBase: number;
|
|
92
|
-
/** 常驻规则文件目标路径。 */
|
|
93
|
-
residentAgentsPath: string;
|
|
94
|
-
/** 生成的 agent preset 目录。 */
|
|
95
|
-
presetDir: string;
|
|
96
244
|
/** 生成 preset 的显示顺序。 */
|
|
97
245
|
presetOrder: number;
|
|
98
246
|
/** preset.md 缺失或不可读时使用的文本。 */
|
|
99
247
|
fallbackText: string;
|
|
100
|
-
writeAgents: boolean;
|
|
101
248
|
writePreset: boolean;
|
|
102
249
|
presetTemplate: string;
|
|
103
250
|
}
|
|
@@ -110,189 +257,314 @@ declare const PromptSettingsSchema: z<PromptSettings>;
|
|
|
110
257
|
* 此处只保留 writePreset 专属字段——加引擎参数只需改一处契约,漏透传变成编译错误。
|
|
111
258
|
*/
|
|
112
259
|
interface WritePresetOptions extends PresetWriterParams {
|
|
113
|
-
/**
|
|
114
|
-
injectAgentsPrompt?: boolean;
|
|
115
|
-
/** 写入 agents-instruction.txt 供 instruction-hint 配置读取;不传则使用本地默认 hint。 */
|
|
260
|
+
/** AGENTS.md 内容资产(写生成目录 agents.md):常驻层写盘的唯一来源,不再注入提示词。 */
|
|
116
261
|
agentsInstructionText?: string;
|
|
117
262
|
presetDir: string;
|
|
118
263
|
presetOrder: number;
|
|
119
264
|
/** settings 层用户自定义提示词配置(优先级最高)。 */
|
|
120
265
|
promptConfigs: PromptConfigSpec[];
|
|
121
|
-
/**
|
|
266
|
+
/** 当前预设目录名;默认 pt-standard。 */
|
|
122
267
|
presetTemplate?: string;
|
|
123
|
-
/** 输出目录/预设 id
|
|
268
|
+
/** 输出目录/预设 id 覆盖;缺省 = presetTemplate 同名输出。 */
|
|
124
269
|
outputId?: string;
|
|
125
|
-
/**
|
|
126
|
-
|
|
270
|
+
/** 隔离的定义/资源来源;与最终 outputId 分离,不回退同名已安装预设。 */
|
|
271
|
+
sourceDir?: string;
|
|
272
|
+
/** 只生成并返回暂存目录;调用方负责安装或清理,不更新共享引擎及目标目录。 */
|
|
273
|
+
materializeOnly?: boolean;
|
|
127
274
|
/** 目录加载失败等非致命告警回调。 */
|
|
128
275
|
warn?: (message: string) => void;
|
|
129
276
|
}
|
|
130
277
|
/** 把任意单一参数预设模板物化到生成目录;全部失败 fail loud。 */
|
|
131
|
-
declare function writePreset(prompt: string, options: WritePresetOptions):
|
|
278
|
+
declare function writePreset(prompt: string, options: WritePresetOptions): string;
|
|
132
279
|
//#endregion
|
|
133
|
-
//#region src/host/
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
content?: {
|
|
143
|
-
presetText?: string;
|
|
144
|
-
agentsText?: string;
|
|
145
|
-
};
|
|
146
|
-
/** 模块清单(参数文件决定组合内容):按序装配 engine/compositions/library/<name>.yml。 */
|
|
147
|
-
modules?: string[];
|
|
148
|
-
/** 兼容字段:内联组合文本或组合清单名。 */
|
|
149
|
-
composition?: string;
|
|
150
|
-
/** 扁平参数:全部直读(true/false、数字、字符串),on/off 作为兼容写法。 */
|
|
151
|
-
params?: Record<string, unknown>;
|
|
152
|
-
/** 顶层模型段(主对话,官方 agent-default-model 同构):provider/name/reasoningEffort/temperature/maxTokens。 */
|
|
153
|
-
model?: Record<string, unknown>;
|
|
154
|
-
/** 顶层子代理模型段:provider/name/reasoningEffort/temperature/maxTokens。 */
|
|
155
|
-
subagentModel?: Record<string, unknown>;
|
|
156
|
-
/** 预设级模板变量({{key}} 插值源;与引擎行为参数 params 分离,顶层 variables 段)。 */
|
|
157
|
-
variables?: Record<string, string>;
|
|
158
|
-
/** 自定义工具定义(tool-config-engine 渲染进 custom-tools/ 后运行时注册)。 */
|
|
159
|
-
customTools?: unknown[];
|
|
160
|
-
/** 模板变量插值开关(缺省 true = 启用;false = 停用,writePreset 不生成变量文件)。 */
|
|
161
|
-
variablesEnabled?: boolean;
|
|
162
|
-
/** 可选:模板自定义提示词配置覆盖(纯数据,不使用模板语法)。 */
|
|
163
|
-
promptConfigs?: unknown[];
|
|
164
|
-
/** 可选:引擎组合模块行参数直写(行级 map config 浅合并;参数桥未覆盖的键生效,参数桥优先)。 */
|
|
165
|
-
moduleConfigs?: Record<string, Record<string, unknown>>;
|
|
166
|
-
/** 世界书(独立存储段,不进 promptConfigs):injectMode + 条目。 */
|
|
167
|
-
worldBook?: {
|
|
168
|
-
injectMode?: 'full' | 'keyword';
|
|
169
|
-
entries: Array<Record<string, unknown>>;
|
|
170
|
-
};
|
|
171
|
-
legacyCleanup?: string[];
|
|
172
|
-
upstream?: Record<string, unknown>;
|
|
280
|
+
//#region src/host/agents-cards.d.ts
|
|
281
|
+
/** 文件身份(fileId + 路径 + 展示路径):生成卡与读取快照共用的最小形状。 */
|
|
282
|
+
interface AgentsFileIdentity {
|
|
283
|
+
/** 稳定文件 id(规范化真实路径哈希;bridge 写白名单与卡 id 共用)。 */
|
|
284
|
+
fileId: string;
|
|
285
|
+
/** 探测到的路径(普通文件;符号链接在 realPath 解析)。 */
|
|
286
|
+
path: string;
|
|
287
|
+
displayPath: string;
|
|
288
|
+
scope: 'global' | 'project';
|
|
173
289
|
}
|
|
174
|
-
|
|
175
|
-
|
|
290
|
+
interface AgentsFileCard extends AgentsFileIdentity {
|
|
291
|
+
/** 解析后的真实路径:同一实际文件去重与身份校验用。 */
|
|
292
|
+
realPath: string;
|
|
293
|
+
}
|
|
294
|
+
declare function agentsFileId(path: string): string;
|
|
176
295
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* 共用本常量,杜绝两处字面量漂移。段结构 = 官方 agent-default-model 同构。
|
|
296
|
+
* 探测当前可见的 AGENTS 指令文件:用户级 `$DSH_HOME/AGENTS.md` + cwd→项目根链的全部候选。
|
|
297
|
+
* 只返回已存在的文件——探测不到就不生成卡。
|
|
180
298
|
*/
|
|
181
|
-
declare
|
|
182
|
-
|
|
183
|
-
|
|
299
|
+
declare function detectAgentsFiles(options?: {
|
|
300
|
+
cwd?: string;
|
|
301
|
+
home?: string;
|
|
302
|
+
projects?: boolean;
|
|
303
|
+
}): AgentsFileCard[];
|
|
184
304
|
/**
|
|
185
|
-
*
|
|
186
|
-
*
|
|
305
|
+
* 探测结果 → pre-step 提示卡(每个文件一张,不落 preset.yml)。
|
|
306
|
+
* 插入点对齐官方 `@deepseek-ai/dsh-agent-instructions`:pre-step 层、紧随真实用户消息;
|
|
307
|
+
* 注入内容 = 该文件当前正文(`fill=instruction-file` 运行时读取,params.file 精确到单个文件)。
|
|
187
308
|
*/
|
|
188
|
-
declare function
|
|
189
|
-
/** 可用预设清单:全部来自预设根 ~/.dsh/.agent-presets(官方预设目录,含 agent.cordis.yml
|
|
190
|
-
* 即被宿主挂载;点前缀目录与无 preset.yml 的官方目录跳过,不占本插件列表)。 */
|
|
191
|
-
declare function listPresets(): Array<{
|
|
192
|
-
id: string;
|
|
193
|
-
name: string;
|
|
194
|
-
user: boolean;
|
|
195
|
-
description?: string;
|
|
196
|
-
meta?: Record<string, unknown>;
|
|
197
|
-
}>;
|
|
198
|
-
/** 插件目录模板清单(「新建」选择器与首次种子化数据源;不直接出现在预设列表)。 */
|
|
199
|
-
declare function listBuiltinTemplates(): Array<{
|
|
200
|
-
id: string;
|
|
201
|
-
name: string;
|
|
202
|
-
}>;
|
|
203
|
-
interface PromptToolState {
|
|
204
|
-
seeded?: boolean;
|
|
205
|
-
paramsMigrated?: boolean;
|
|
206
|
-
/** 旧容器 id 兼容快照已处理;删除后不再自动复活。 */
|
|
207
|
-
legacyAliasHandled?: boolean;
|
|
208
|
-
}
|
|
209
|
-
/** 读插件状态;文件缺失/损坏返回空对象(按未标记处理,触发首次动作)。 */
|
|
210
|
-
declare function readPluginState(): PromptToolState;
|
|
211
|
-
/** 原子写插件状态(tmp+rename)。 */
|
|
212
|
-
declare function writePluginState(state: PromptToolState): void;
|
|
213
|
-
/** 首次启动种子化:把插件目录全部内置模板复制到预设根(state.seeded 后不再自动补)。
|
|
214
|
-
* 用户删除的预设不会自动复活;升级新增的模板用「新建」按需复制。
|
|
215
|
-
* 兼容旧版预设根内 .pt-seeded 标记:存在即视为已种子化,并迁入状态文件后删除。 */
|
|
216
|
-
declare function ensurePresetSeed(): {
|
|
217
|
-
created: string[];
|
|
218
|
-
};
|
|
219
|
-
/** 从插件目录复制内置预设到预设根(新建/还原)。
|
|
220
|
-
* autoSuffix=true(自定义预设入口)时同名自动递增(custom → custom-2 → …);否则同名拒绝。 */
|
|
221
|
-
declare function cloneBuiltinPreset(id: string, autoSuffix?: boolean): {
|
|
222
|
-
ok: true;
|
|
223
|
-
id: string;
|
|
224
|
-
} | {
|
|
225
|
-
ok: false;
|
|
226
|
-
message: string;
|
|
227
|
-
};
|
|
309
|
+
declare function agentsFileCardSpecs(files?: readonly AgentsFileIdentity[]): PromptConfigSpec[];
|
|
228
310
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
* 回落模板/引擎默认;0 与 false 照常写入--语义与函数内注释、docs §3 一致)。写入后删除 prompt-tool.overrides.yml(旧参数覆盖
|
|
232
|
-
* 通道残留——参数已并入 preset.yml,避免旧值覆盖新值)。
|
|
311
|
+
* 单次读取形成一致快照:正文、revision、身份、读取状态来自同一次读取。
|
|
312
|
+
* 只支持可正确解码的 UTF-8;有 BOM 的文件保留 BOM 字符,不让无关保存悄悄改写字节。
|
|
233
313
|
*/
|
|
234
|
-
declare function
|
|
235
|
-
/**
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
314
|
+
declare function readAgentsFileSnapshot(file: AgentsFileCard): InstructionFileSnapshot;
|
|
315
|
+
/** 探测 + 读取:同一套探测规则下每个文件一份快照。 */
|
|
316
|
+
declare function detectAgentsFileSnapshots(options?: {
|
|
317
|
+
cwd?: string;
|
|
318
|
+
home?: string;
|
|
319
|
+
projects?: boolean;
|
|
320
|
+
}): InstructionFileSnapshot[];
|
|
321
|
+
type AgentsFileWriteOutcome = {
|
|
239
322
|
ok: true;
|
|
323
|
+
fileId: string;
|
|
324
|
+
revision: string;
|
|
240
325
|
} | {
|
|
241
326
|
ok: false;
|
|
327
|
+
status: 400 | 404 | 409 | 413;
|
|
328
|
+
code: string;
|
|
242
329
|
message: string;
|
|
243
330
|
};
|
|
244
|
-
/**
|
|
245
|
-
declare function
|
|
331
|
+
/** 原子写指令文件(tmp + rename);调用方必须先用 detectAgentsFiles() 校验路径白名单。 */
|
|
332
|
+
declare function writeAgentsFile(path: string, content: string): void;
|
|
246
333
|
/**
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
334
|
+
* 带版本校验的单文件写:
|
|
335
|
+
* 1. 写前在同一段内重读文件,expectedRevision 不一致 = 409(不做「猜到用户意图」的重试);
|
|
336
|
+
* 2. 目标消失 = 404,不自动重建用户文件;
|
|
337
|
+
* 3. 正文超限 = 413,不截断保存;
|
|
338
|
+
* 4. 替换前复查目标身份(真实路径未变),失败保留原文件并清理临时文件。
|
|
339
|
+
*/
|
|
340
|
+
declare function writeAgentsFileChecked(options: {
|
|
341
|
+
file: AgentsFileCard;
|
|
342
|
+
content: string;
|
|
343
|
+
expectedRevision: string | null;
|
|
344
|
+
}): Promise<AgentsFileWriteOutcome>;
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region src/runtime/pre-step-coordinator.d.ts
|
|
347
|
+
/** 协调服务名:引擎行通过 ctx.get 解析本服务决定走管理路径还是独立路径。 */
|
|
348
|
+
declare const PRE_STEP_COORDINATOR_SERVICE = "promptToolPreStep";
|
|
349
|
+
/** 服务契约版本:引擎与协调器不同步时按「不认识就不接管」处理。 */
|
|
350
|
+
declare const PRE_STEP_COORDINATOR_VERSION = 1;
|
|
351
|
+
/** 批执行算法消费的提示词配置(与 engine/schema.mjs 产出的形状同源)。 */
|
|
352
|
+
interface PreStepPromptConfig {
|
|
353
|
+
id: string;
|
|
354
|
+
layer: string;
|
|
355
|
+
enabled?: boolean;
|
|
356
|
+
order: number;
|
|
357
|
+
position: string;
|
|
358
|
+
promotion: string;
|
|
359
|
+
audience: string | null;
|
|
360
|
+
modelScope: string;
|
|
361
|
+
role: string;
|
|
362
|
+
dedupe: string;
|
|
363
|
+
mergeMode: string;
|
|
364
|
+
sourceKind: string;
|
|
365
|
+
form?: string;
|
|
366
|
+
texts: string[];
|
|
367
|
+
params: Record<string, unknown>;
|
|
368
|
+
variables: Record<string, unknown>;
|
|
369
|
+
identity: {
|
|
370
|
+
field: 'plugin';
|
|
371
|
+
value: string;
|
|
372
|
+
};
|
|
373
|
+
resolve: (input: Record<string, unknown>) => unknown;
|
|
374
|
+
}
|
|
375
|
+
/** 一个预设 mount 注册进来的来源:提示词配置 + 装配事实(晋升/去重由协调器统一持有)。 */
|
|
376
|
+
interface PreStepSource {
|
|
377
|
+
configs: readonly PreStepPromptConfig[];
|
|
378
|
+
officialInstructions?: boolean;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* 文件来源每次 pre-step 编译出的最小候选。
|
|
382
|
+
* `available: false` 表示读取失败/超限/空内容:只在「该文件曾经注入过」时转成
|
|
383
|
+
* 一次性失效通知,不冒充空正文。
|
|
384
|
+
*/
|
|
385
|
+
interface PreStepFileContribution {
|
|
386
|
+
fileId: string;
|
|
387
|
+
displayPath: string;
|
|
388
|
+
revision: string;
|
|
389
|
+
text: string;
|
|
390
|
+
available: boolean;
|
|
391
|
+
reason?: string;
|
|
392
|
+
order: number;
|
|
393
|
+
position: string;
|
|
394
|
+
promotion: string;
|
|
395
|
+
audience: string | null;
|
|
396
|
+
modelScope: string;
|
|
397
|
+
}
|
|
398
|
+
interface PreStepCoordinatorOptions {
|
|
399
|
+
/** 每次 pre-step 现读指令文件;缺省实现走 host 探测 + 独立策略。测试可注入。 */
|
|
400
|
+
collectFiles?: (agent: unknown, session: unknown) => PreStepFileContribution[];
|
|
401
|
+
/** 策略文件位置覆盖(测试隔离用)。 */
|
|
402
|
+
policyFile?: string;
|
|
403
|
+
/** 用户级指令文件根(DSH_HOME)覆盖(测试隔离用)。 */
|
|
404
|
+
home?: string;
|
|
405
|
+
}
|
|
406
|
+
interface PreStepCoordinatorService {
|
|
407
|
+
readonly version: number;
|
|
408
|
+
/**
|
|
409
|
+
* 把 preset mount 的 pre-step 配置登记进协调器。
|
|
410
|
+
* 同一 scope 内同一个 `sourceId` 再次登记时后来者接管:先撤销旧登记再插入新登记。
|
|
411
|
+
* 宿主重挂同一个 preset(或其引擎行的旧 fiber 尚未释放)时这是正常路径,不是配置错误,
|
|
412
|
+
* 因此不抛错——抛错会让整行未激活,进而让 preset 挂载整体失败(无法切换预设)。
|
|
413
|
+
* @param sourceCtx 注册 ctx:同时决定来源作用域与释放时机(挂在这个 fiber 上)。
|
|
414
|
+
* @param sourceId 来源 id(同一 scope 内唯一:同名登记以最新一次为准)。
|
|
415
|
+
* @returns 幂等的撤销函数;登记已被后来者顶替时调用它是空操作。
|
|
416
|
+
*/
|
|
417
|
+
registerPreset(sourceCtx: Context, sourceId: string, source: PreStepSource): () => void;
|
|
418
|
+
/** 该会话最近一次 pre-step 观察到的负责人事实;未知返回 undefined。 */
|
|
419
|
+
officialOwnerOf(sessionId: string): boolean | undefined;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* 安装协调器:发布 `promptToolPreStep` 服务并注册唯一的 pre-step 监听器。
|
|
423
|
+
* 普通监听器留在 prepend 门控内侧;来源监听器只登记后交出执行权。
|
|
424
|
+
* 即使服务迟到或重挂,下游的 pre-step 过滤(声明式触发器的 `pre-step-filter` 动作)
|
|
425
|
+
* 仍能在本监听器交出执行权之后过滤最终消息批。
|
|
426
|
+
*/
|
|
427
|
+
declare function installPreStepCoordinator(ctx: Context, options?: PreStepCoordinatorOptions): PreStepCoordinatorService;
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region src/runtime/models.d.ts
|
|
430
|
+
/**
|
|
431
|
+
* 官方子代理 seam 的类型锚点:本插件只读 `list()` / `getProvider()` 并显式传参,
|
|
432
|
+
* 不替换 {@link SubagentRuntime.start} 或 `startContinuable`;这里保留类型引用是为了
|
|
433
|
+
* 让「不碰 registry 方法」这条边界在类型层随 rc.2 契约一起编译校验。
|
|
255
434
|
*/
|
|
256
|
-
|
|
435
|
+
type PluginSubagentSeam = Pick<SubagentRuntime, 'list' | 'getProvider'>;
|
|
436
|
+
/** 模型服务商检测结果(含诊断信息,供 Web/TUI 展示)。 */
|
|
437
|
+
interface ModelDetection {
|
|
438
|
+
/** 是否检测到任何已注册/可配置的服务商路由。 */
|
|
439
|
+
available: boolean;
|
|
440
|
+
/** 已检测到(live 注册)的模型服务商 id——状态提示用。 */
|
|
441
|
+
providers: string[];
|
|
442
|
+
error?: string;
|
|
443
|
+
}
|
|
444
|
+
/** 检测模型服务商:只统计 live 注册路由(状态提示与下拉共用同一来源)。 */
|
|
445
|
+
declare function detectModels(ctx: Context): ModelDetection;
|
|
257
446
|
/**
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
447
|
+
* 目录失效:provider 注册/移除(官方 `llm/adapters-updated`)、服务重挂或显式刷新时
|
|
448
|
+
* 调用。代次前进让已在飞的旧查询回来后不再写缓存(M-11:变更必须让相关缓存失效)。
|
|
449
|
+
* 只清目录,不碰 provider 单点失败的既有语义。
|
|
261
450
|
*/
|
|
451
|
+
declare function invalidateModelCatalog(ctx: Context): void;
|
|
452
|
+
/** 同步读模型目录缓存(命中返回,未命中/过期返回空):/describe 不触发查询。 */
|
|
453
|
+
declare function peekModelCatalog(ctx: Context): Record<string, string[]>;
|
|
262
454
|
/**
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
455
|
+
* 查询各已注册服务商公布的模型 id(对齐官方 web 选择器 buildModelCatalog:只遍历
|
|
456
|
+
* listProviders() live 路由,单点失败/超时不拖垮整体;仅作展示,不构成路由白名单)。
|
|
457
|
+
* 并行查询 + 10min 缓存 + 单点超时;同 Context 的并发刷新合并为一次查询,
|
|
458
|
+
* 失败只影响该次刷新(不写空缓存),旧代次结果不回写新数据。
|
|
267
459
|
*/
|
|
268
|
-
declare function
|
|
460
|
+
declare function listAdvertisedModels(ctx: Context): Promise<Record<string, string[]>>;
|
|
269
461
|
/**
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
462
|
+
* 本插件子代理入口的显式模型路由(subagentModelProvider + subagentModelName 同时非空时生效)。
|
|
463
|
+
*
|
|
464
|
+
* 只产出要传给 {@link SubagentRuntime.start} 的 `agentOptions`,由调用方显式传入;
|
|
465
|
+
* 不修改 registry 上的 `start` / `startContinuable` 方法,也不在根 scope 强加默认值——
|
|
466
|
+
* 官方 API 的替换会让第三方直派调用也带上本插件的模型,超出插件授权范围。
|
|
274
467
|
*/
|
|
275
|
-
declare function
|
|
468
|
+
declare function resolveSubagentStartOptions(isEnabled: () => boolean, provider: () => string, model: () => string, getReasoningEffort?: () => string): AgentOptions | undefined;
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region src/host/skills-actions.d.ts
|
|
471
|
+
type SkillActionResult = {
|
|
472
|
+
ok: true;
|
|
473
|
+
id: string;
|
|
474
|
+
path: string;
|
|
475
|
+
} | {
|
|
476
|
+
ok: false;
|
|
477
|
+
message: string;
|
|
478
|
+
};
|
|
276
479
|
//#endregion
|
|
277
|
-
//#region src/host/
|
|
480
|
+
//#region src/host/skills-policy.d.ts
|
|
481
|
+
type SkillPolicyRead = {
|
|
482
|
+
ok: true;
|
|
483
|
+
invocation: SkillInvocation;
|
|
484
|
+
frontmatter?: string;
|
|
485
|
+
body?: string;
|
|
486
|
+
} | {
|
|
487
|
+
ok: false;
|
|
488
|
+
message: string;
|
|
489
|
+
};
|
|
490
|
+
type SkillPolicyWrite = {
|
|
491
|
+
ok: true;
|
|
492
|
+
changed: boolean;
|
|
493
|
+
invocation: SkillInvocation;
|
|
494
|
+
} | {
|
|
495
|
+
ok: false;
|
|
496
|
+
message: string;
|
|
497
|
+
};
|
|
498
|
+
/** 读取技能文件当前的调用策略(缺省即可调用)。 */
|
|
499
|
+
declare function readSkillInvocation(file: string): SkillPolicyRead;
|
|
500
|
+
/** 把技能文件的调用策略写到目标范围;返回是否发生写入。 */
|
|
501
|
+
declare function setSkillInvocation(file: string, change: SkillPolicyChange | SkillPolicyScope): SkillPolicyWrite;
|
|
502
|
+
//#endregion
|
|
503
|
+
//#region src/host/skills-content.d.ts
|
|
504
|
+
type SkillContentResult = ({
|
|
505
|
+
ok: true;
|
|
506
|
+
changed?: boolean;
|
|
507
|
+
} & SkillContentSnapshot) | {
|
|
508
|
+
ok: false;
|
|
509
|
+
message: string;
|
|
510
|
+
};
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/host/skills-config.d.ts
|
|
513
|
+
/** 与官方 `SKILL_NAME` 同规则;技能目录名、引用校验与调用策略写入共用。 */
|
|
514
|
+
declare const SKILL_NAME_PATTERN: RegExp;
|
|
515
|
+
type SkillsStateRead = {
|
|
516
|
+
ok: true;
|
|
517
|
+
state: SkillsState;
|
|
518
|
+
exists: boolean;
|
|
519
|
+
} | {
|
|
520
|
+
ok: false;
|
|
521
|
+
state: SkillsState;
|
|
522
|
+
message: string;
|
|
523
|
+
};
|
|
524
|
+
declare function skillsStatePath(dshHome?: string): string;
|
|
525
|
+
declare function readSkillsState(file?: string): SkillsStateRead;
|
|
526
|
+
/** 写状态:Document API 保留注释与未知字段;内容无变化时不落盘;提交前核对本次读取的原文,失败清理暂存文件。 */
|
|
527
|
+
declare function writeSkillsState(patch: Partial<Pick<SkillsState, 'folders'>>, file?: string): SkillsStateRead;
|
|
528
|
+
//#endregion
|
|
529
|
+
//#region src/runtime/settings-bridge.d.ts
|
|
530
|
+
interface SkillsBridgeState {
|
|
531
|
+
/** 用户技能根(技能实体的落点)。 */
|
|
532
|
+
skillsRoot: string;
|
|
533
|
+
/** 用户添加的技能文件夹(只引用,不复制)。 */
|
|
534
|
+
folders: string[];
|
|
535
|
+
/** 技能清单:按会话工作区扫描官方六类技能根,调用策略取自各技能文件的 frontmatter。 */
|
|
536
|
+
listSkills: (cwd?: string) => SkillCatalogEntry[];
|
|
537
|
+
snapshot?: (options: SkillViewOptions) => Promise<SkillsCatalogSnapshot>;
|
|
538
|
+
/** 单端写入只提交本端意图;路径必须命中当前来源白名单。 */
|
|
539
|
+
setSkillPolicy: (name: string, path: string, change: SkillPolicyChange, cwd?: string) => SkillPolicyWrite;
|
|
540
|
+
readSkillContent: (name: string, path: string, cwd?: string) => SkillContentResult;
|
|
541
|
+
writeSkillContent: (name: string, path: string, content: string, description: string, expectedRevision: string, cwd?: string) => SkillContentResult;
|
|
542
|
+
deleteSkill: (name: string, path: string, cwd?: string) => SkillActionResult;
|
|
543
|
+
/** 添加 / 移除引用的技能文件夹。 */
|
|
544
|
+
patchSkillFolders: (folders: string[]) => SkillsStateRead | Promise<SkillsStateRead>;
|
|
545
|
+
}
|
|
278
546
|
/**
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
* {{getvar::k::default}} → 改写为 {{k}} 且 variables 缺 k 时写入 default(fallback 落顶层 variables);
|
|
283
|
-
* {{trim}}/{{//注释}}/{{ERA:...}} → 剥离(格式化/注释/第三方运行时);
|
|
284
|
-
* {{user}}/{{char}} → 替换占位符。
|
|
547
|
+
* 两类卡合并:预设卡原样保留,文件卡换成本次工作区的文件快照。
|
|
548
|
+
* 生成目录里属于其他工作区的文件卡不再展示(写盘白名单也不含它们);
|
|
549
|
+
* 当前工作区里没有对应生成卡的文件按默认文件卡补齐。
|
|
285
550
|
*/
|
|
286
|
-
declare function
|
|
287
|
-
/**
|
|
288
|
-
declare function
|
|
289
|
-
/**
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
551
|
+
declare function mergeInstructionCards(presetCards: readonly unknown[], files: readonly InstructionFileSnapshot[]): unknown[];
|
|
552
|
+
/** 自建 loopback settings bridge:替代 registerConfigurableProviders,避免模型设置区出现插件条目。 */
|
|
553
|
+
declare function registerSettingsBridge(ctx: Context, ns: string, getModelsState: () => ModelDetection, getSkillsState: () => SkillsBridgeState, getEngineStrategyDir: () => string, afterSkillsChange?: () => void,
|
|
554
|
+
/** 生成目录(presetDir):读取实际生效的提示词配置(引擎加载源)。 */
|
|
555
|
+
getPresetConfigsDir?: () => string,
|
|
556
|
+
/** 内容导入完成回调:批量 scope 只触发一次重建(更新运行时文本并重建预设)。 */
|
|
557
|
+
afterPresetImport?: (scopes: Array<'preset' | 'agents'>) => void,
|
|
558
|
+
/** 参数覆盖写入后重建当前预设。 */
|
|
559
|
+
afterOverridesChange?: () => void | Promise<void>,
|
|
560
|
+
/** 预设已完整安装后的刷新回调;失败只返回 refreshWarning,不再物化或撤销安装。 */
|
|
561
|
+
afterPresetPackageImport?: (id: string) => void | Promise<void>,
|
|
562
|
+
/** 能力/recipe 原子创建后重建回调;抛错时调用方恢复 preset.yml。 */
|
|
563
|
+
afterCapabilityChange?: () => void,
|
|
564
|
+
/** 新建、复制或删除预设后刷新官方注册。 */
|
|
565
|
+
afterPresetListChange?: () => void | Promise<void>): {
|
|
566
|
+
invalidateDescriptor: () => void;
|
|
567
|
+
};
|
|
296
568
|
//#endregion
|
|
297
569
|
//#region src/host/worldbook.d.ts
|
|
298
570
|
type WorldBookEntry = Record<string, unknown>;
|
|
@@ -337,40 +609,31 @@ declare function resolveProfileDir(ctx: Context): string | undefined;
|
|
|
337
609
|
* 2. 不修改同级 profile,不主动退出进程。
|
|
338
610
|
*/
|
|
339
611
|
declare function ensureWebSurface(ctx: Context, warn: (message: string) => void): void;
|
|
340
|
-
//#endregion
|
|
341
|
-
//#region src/profile-skills.d.ts
|
|
342
612
|
/**
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
* 或复制失败时回退到 sourceDir(默认包内 `skills/`)。
|
|
613
|
+
* 把首次启动自愈挂到插件生命周期上:延迟到本轮装配结束后执行,
|
|
614
|
+
* 插件卸载会取消计时器,卸载后不再异步补写 profile。
|
|
346
615
|
*/
|
|
347
|
-
declare function
|
|
348
|
-
//#endregion
|
|
349
|
-
//#region src/host/migration.d.ts
|
|
350
|
-
declare function migrateLegacyLayout(presetRoot: string, legacyUserPresets: string): boolean;
|
|
351
|
-
/** 旧版 presetDir 配置值(容器根/旧用户目录)归一化为预设根;其余原样。 */
|
|
352
|
-
declare function normalizePresetRootDir(presetDir: string, presetRoot: string, legacyContainer: string): string;
|
|
616
|
+
declare function scheduleWebSurfaceRepair(ctx: Context, warn: (message: string) => void): void;
|
|
353
617
|
//#endregion
|
|
354
|
-
//#region src/
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
available: boolean;
|
|
359
|
-
/** 已检测到(live 注册)的模型服务商 id——状态提示用。 */
|
|
360
|
-
providers: string[];
|
|
361
|
-
error?: string;
|
|
618
|
+
//#region src/host/skills-import.d.ts
|
|
619
|
+
interface SkillsImportFile {
|
|
620
|
+
path?: unknown;
|
|
621
|
+
content?: unknown;
|
|
362
622
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
623
|
+
type SkillsImportResult = {
|
|
624
|
+
ok: true;
|
|
625
|
+
path: string;
|
|
626
|
+
count: number;
|
|
627
|
+
overwritten: number;
|
|
628
|
+
warning?: string;
|
|
629
|
+
} | {
|
|
630
|
+
ok: false;
|
|
631
|
+
message: string;
|
|
632
|
+
code?: 'skills-overwrite-required';
|
|
633
|
+
conflicts?: string[];
|
|
634
|
+
};
|
|
635
|
+
/** 浏览器上传:base64 文件列表;单技能包(无顶层目录)按 frontmatter.name 归类。 */
|
|
636
|
+
declare function importSkillsPackage(root: string, files: SkillsImportFile[], overwrite?: readonly string[]): SkillsImportResult;
|
|
374
637
|
//#endregion
|
|
375
638
|
//#region src/runtime/configs-validate.d.ts
|
|
376
639
|
interface PromptConfigValidationError {
|
|
@@ -395,26 +658,9 @@ interface PromptConfigValidationResult {
|
|
|
395
658
|
*/
|
|
396
659
|
declare function validatePromptConfigs(value: unknown, options?: {
|
|
397
660
|
strategyDir?: string;
|
|
661
|
+
presetDir?: string;
|
|
398
662
|
}): Promise<PromptConfigValidationResult>;
|
|
399
663
|
//#endregion
|
|
400
|
-
//#region src/runtime/settings-bridge.d.ts
|
|
401
|
-
interface SkillsBridgeState {
|
|
402
|
-
activeSkillsDirs: string[];
|
|
403
|
-
skillCatalog: SkillCatalogEntry[];
|
|
404
|
-
}
|
|
405
|
-
/** 自建 loopback settings bridge:替代 registerConfigurableProviders,避免模型设置区出现插件条目。 */
|
|
406
|
-
declare function registerSettingsBridge(ctx: Context, ns: string, getModelsState: () => ModelDetection, getSkillsState: () => SkillsBridgeState, getEngineStrategyDir: () => string, afterSkillFix?: () => void,
|
|
407
|
-
/** 生成目录(presetDir):读取实际生效的提示词配置(引擎加载源)。 */
|
|
408
|
-
getPresetConfigsDir?: () => string,
|
|
409
|
-
/** 内容导入完成回调:批量 scope 只触发一次重建(更新运行时文本并重建预设)。 */
|
|
410
|
-
afterPresetImport?: (scopes: Array<'preset' | 'agents'>) => void,
|
|
411
|
-
/** 参数覆盖写入回调(重建预设使参数生效)。 */
|
|
412
|
-
afterOverridesChange?: () => void,
|
|
413
|
-
/** 预设包导入完成回调(物化导入预设:组合/配置目录/共享引擎落盘,宿主 discovery 可见)。 */
|
|
414
|
-
afterPresetPackageImport?: (id: string) => void): {
|
|
415
|
-
invalidateDescriptor: () => void;
|
|
416
|
-
};
|
|
417
|
-
//#endregion
|
|
418
664
|
//#region src/runtime/character-tools.d.ts
|
|
419
665
|
/** 工具执行所需的运行时宿主能力(index.ts 闭包提供)。 */
|
|
420
666
|
interface CharacterToolHost {
|
|
@@ -425,7 +671,7 @@ interface CharacterToolHost {
|
|
|
425
671
|
/** 应用/移除后重建生成目录(写 preset.yml 后使参数生效)。 */
|
|
426
672
|
rebuild: () => void;
|
|
427
673
|
}
|
|
428
|
-
/** 注册角色卡库模型工具;返回 disposer
|
|
674
|
+
/** 注册角色卡库模型工具;返回 disposer,随 character-tools 预设模块生命周期清理。 */
|
|
429
675
|
declare function registerCharacterTools(ctx: Context, host: CharacterToolHost): () => void;
|
|
430
676
|
//#endregion
|
|
431
677
|
//#region src/runtime/world-book-tools.d.ts
|
|
@@ -437,10 +683,33 @@ interface WorldBookToolHost {
|
|
|
437
683
|
/** 写盘后重建生成目录。 */
|
|
438
684
|
rebuild: () => void;
|
|
439
685
|
}
|
|
440
|
-
/** 注册世界书条目级模型工具;返回 disposer
|
|
686
|
+
/** 注册世界书条目级模型工具;返回 disposer,随 world-book-tools 预设模块生命周期清理。 */
|
|
441
687
|
declare function registerWorldBookTools(ctx: Context, host: WorldBookToolHost): () => void;
|
|
442
688
|
//#endregion
|
|
443
689
|
//#region src/host/characters.d.ts
|
|
690
|
+
/** meta 下记录「每张卡引入了哪些模块」的键;来源保留到模块不再被消费并完成回退。 */
|
|
691
|
+
declare const CHARACTER_MODULES_KEY = "characterModules";
|
|
692
|
+
/** 读取 preset.yml `meta.modules` 之外的模块来源记录;非法形状一律视为无记录(老卡与手改文件不报错)。 */
|
|
693
|
+
declare function recordedCharacterModules(meta: unknown): Record<string, string[]>;
|
|
694
|
+
/** 卡自身声明的模块(声明优先:ST 转换产物自带六件套声明,行为因此不变)。
|
|
695
|
+
* 只丢弃非字符串与空串;模块名合法性仍由 appendPresetModules 校验(非法名 fail loud)。 */
|
|
696
|
+
declare function declaredCharacterModules(spec: PresetSpec): string[];
|
|
697
|
+
/** 必需模块:`prompt-config-engine` 缺失会让 promptConfigs 静默失效,因此始终补齐;
|
|
698
|
+
* 卡内含 world-book 策略配置时另需 `world-book-tools`(与旧实现同判据)。 */
|
|
699
|
+
declare function requiredCharacterModules(configs: readonly unknown[]): string[];
|
|
700
|
+
/** 移除一张卡之后,某个模块是否仍被预设内容或其他卡需要(需要则不回退)。 */
|
|
701
|
+
interface CharacterModuleContext {
|
|
702
|
+
/** 移除本卡前缀配置之后的提示词配置。 */
|
|
703
|
+
configs: readonly Record<string, unknown>[];
|
|
704
|
+
/** 移除本卡声明的 params 键之后的预设参数。 */
|
|
705
|
+
params: Record<string, unknown>;
|
|
706
|
+
/** 预设顶层是否仍有自定义工具。 */
|
|
707
|
+
customTools: boolean;
|
|
708
|
+
/** 移除本卡之后仍标记为已导入的角色卡 id。 */
|
|
709
|
+
importedCharacters: readonly string[];
|
|
710
|
+
}
|
|
711
|
+
/** 模块的消费者判据。未知模块保守保留:宁可留一个无消费者的模块,也不误删用户或引擎要用的装配。 */
|
|
712
|
+
declare function characterModuleStillNeeded(module: string, context: CharacterModuleContext): boolean;
|
|
444
713
|
/** 角色卡记忆变更后同步已导入预设的 chara-<id>-memory 注入条目
|
|
445
714
|
* (world_book note 写入卡记忆后调用;未导入当前预设的卡返回 synced=false)。 */
|
|
446
715
|
declare function syncImportedCharacterMemory(presetRoot: string, templateName: string, cardId: string): {
|
|
@@ -456,18 +725,20 @@ declare function appendCharacterMemory(presetRoot: string, cardId: string, note:
|
|
|
456
725
|
declare function appendMemoryFile(file: string, note: string, header?: string): void;
|
|
457
726
|
/** 读角色卡本地记忆文本(无记忆返回空串)。 */
|
|
458
727
|
declare function readCharacterMemory(presetRoot: string, cardId: string): string;
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
path: string;
|
|
462
|
-
content: string;
|
|
463
|
-
}>): {
|
|
728
|
+
type CharacterImportOptions = StConversionOptions & ImportChoices;
|
|
729
|
+
type CharacterImportResult = {
|
|
464
730
|
ok: true;
|
|
465
731
|
id: string;
|
|
466
732
|
name: string;
|
|
733
|
+
warning?: string;
|
|
467
734
|
} | {
|
|
468
735
|
ok: false;
|
|
469
736
|
message: string;
|
|
470
737
|
};
|
|
738
|
+
/** 角色卡入库:PNG 原图(可选)+ 角色卡 JSON → 转换参数存 converted.yml。 */
|
|
739
|
+
declare function importCharacterCard(presetRoot: string, files: AssetFile[], options?: CharacterImportOptions): CharacterImportResult;
|
|
740
|
+
/** 原始文件流导入:识别 PNG 魔数后在 host 侧提取角色卡,避免客户端 base64 膨胀 JSON。 */
|
|
741
|
+
declare function importCharacterCardFile(presetRoot: string, filePath: string, fileName?: string, options?: CharacterImportOptions): CharacterImportResult;
|
|
471
742
|
interface CharacterCardListItem {
|
|
472
743
|
id: string;
|
|
473
744
|
name: string;
|
|
@@ -527,110 +798,80 @@ declare function loadPromptTemplates(): PromptConfigTemplate[];
|
|
|
527
798
|
declare function loadToolTemplates(): ToolTemplate[];
|
|
528
799
|
//#endregion
|
|
529
800
|
//#region src/runtime/tui.d.ts
|
|
801
|
+
type TuiSource = PromptSettings & {
|
|
802
|
+
skillCatalog: SkillCatalogEntry[];
|
|
803
|
+
activeSkillsDirs: string[];
|
|
804
|
+
};
|
|
530
805
|
/** 参数保存回调:写激活预设 preset.yml;失败必须抛给命令层渲染为错误。 */
|
|
531
806
|
type SavePresetParam = (key: string, value: unknown) => void | Promise<void>;
|
|
807
|
+
/** 技能启停回调:切换受管实体的根链接。 */
|
|
808
|
+
type ToggleSkillState = (folder: string, enabled: boolean) => {
|
|
809
|
+
ok: boolean;
|
|
810
|
+
message?: string;
|
|
811
|
+
};
|
|
532
812
|
/** 通过 DSH 命令注册表暴露 /prompt-tool,Web 与 dsh-tui 都能执行。 */
|
|
533
|
-
declare function registerTuiCommand(ctx: Context, ns: 'prompt-tool', getSource: () =>
|
|
813
|
+
declare function registerTuiCommand(ctx: Context, ns: 'prompt-tool', getSource: () => TuiSource, getModelsState: () => ModelDetection, getModelCatalog: () => Promise<Record<string, string[]>>, getPresetConfigsDir?: () => string, savePresetParam?: SavePresetParam, toggleSkillState?: ToggleSkillState): void;
|
|
534
814
|
//#endregion
|
|
535
|
-
//#region src/
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
declare function mergeSkillDirs(dirs: string[], read: (dir: string, warn?: (message: string) => void) => SkillEntry[], warn?: (message: string) => void): SkillEntry[];
|
|
559
|
-
/**
|
|
560
|
-
* 进程内技能扫描缓存:按目录 + 每个 SKILL.md 的 mtime/size 签名失效。
|
|
561
|
-
* 同一目录在内容未变化时,list/get 可复用同一次扫描结果。
|
|
562
|
-
*/
|
|
563
|
-
interface CachedSkillsReader {
|
|
564
|
-
read: (skillsDir: string, warn?: (message: string) => void) => SkillEntry[];
|
|
565
|
-
invalidate: (skillsDir?: string) => void;
|
|
815
|
+
//#region src/host/skills-refresh.d.ts
|
|
816
|
+
interface SkillsReloaderDeps {
|
|
817
|
+
stateFile: string;
|
|
818
|
+
currentSnapshot: () => string;
|
|
819
|
+
accept: (state: SkillsState, snapshot: string) => void;
|
|
820
|
+
warn: (message: string) => void;
|
|
821
|
+
}
|
|
822
|
+
declare function createSkillsReloader(deps: SkillsReloaderDeps): {
|
|
823
|
+
reload: () => void;
|
|
824
|
+
};
|
|
825
|
+
//#endregion
|
|
826
|
+
//#region src/host/skills-runtime.d.ts
|
|
827
|
+
interface SkillsRuntime {
|
|
828
|
+
readonly skillsRoot: string;
|
|
829
|
+
readonly folders: string[];
|
|
830
|
+
listSkills: (cwd?: string) => SkillCatalogEntry[];
|
|
831
|
+
snapshot: (options?: SkillViewOptions) => Promise<SkillsCatalogSnapshot>;
|
|
832
|
+
setPolicy: (name: string, path: string, change: SkillPolicyChange, cwd?: string) => SkillPolicyWrite;
|
|
833
|
+
readContent: (name: string, path: string, cwd?: string) => SkillContentResult;
|
|
834
|
+
writeContent: (name: string, path: string, content: string, description: string, expectedRevision: string, cwd?: string) => SkillContentResult;
|
|
835
|
+
deleteSkill: (name: string, path: string, cwd?: string) => SkillActionResult;
|
|
836
|
+
setFolders: (folders: string[]) => SkillsStateRead;
|
|
837
|
+
invalidate: () => void;
|
|
566
838
|
}
|
|
567
|
-
declare function
|
|
839
|
+
declare function createSkillsRuntime(ctx: Context, options?: {
|
|
840
|
+
dshHome?: string;
|
|
841
|
+
}): SkillsRuntime;
|
|
568
842
|
//#endregion
|
|
569
|
-
//#region src/
|
|
570
|
-
interface
|
|
571
|
-
|
|
572
|
-
|
|
843
|
+
//#region src/host/skills-scan.d.ts
|
|
844
|
+
interface ScanRoot {
|
|
845
|
+
kind: SkillSourceKind;
|
|
846
|
+
path: string;
|
|
847
|
+
}
|
|
848
|
+
interface ScannedSkill {
|
|
849
|
+
id: string;
|
|
850
|
+
source: SkillSourceKind;
|
|
851
|
+
rank: number;
|
|
852
|
+
dir: string;
|
|
573
853
|
folder: string;
|
|
574
|
-
|
|
575
|
-
fixedFolder: string;
|
|
576
|
-
/** 修复后注册名(与目录一致)。 */
|
|
854
|
+
file: string;
|
|
577
855
|
name: string;
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
856
|
+
description: string;
|
|
857
|
+
whenToUse?: string;
|
|
858
|
+
metadata?: Record<string, unknown>;
|
|
859
|
+
body: string;
|
|
860
|
+
valid: boolean;
|
|
861
|
+
issue?: string;
|
|
862
|
+
modelInvocable: boolean;
|
|
863
|
+
userInvocable: boolean;
|
|
581
864
|
}
|
|
582
|
-
|
|
583
|
-
declare function
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
*/
|
|
589
|
-
declare function
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
/**
|
|
593
|
-
* settings bridge 跨端契约(host 注册 / client 消费的唯一来源)。
|
|
594
|
-
* 铁律:25 端点载荷统一成功 `{ ok: true, value }`、失败 `{ ok: false, code?, message? }`;
|
|
595
|
-
* 端点附加字段只能以 value 旁的可选扩展字段出现(describe)。
|
|
596
|
-
* 改路径或载荷形状必须同步更新 test/shared/bridge-contract.test.mjs。
|
|
597
|
-
*/
|
|
598
|
-
declare const SETTINGS_BRIDGE_PREFIX = "/api/prompt-tool/settings";
|
|
599
|
-
/** 桥端点路径(相对前缀)。新增端点必须同时登记到契约测试。 */
|
|
600
|
-
declare const BRIDGE_ENDPOINTS: {
|
|
601
|
-
readonly meta: "/meta";
|
|
602
|
-
readonly bootstrap: "/bootstrap";
|
|
603
|
-
readonly describe: "/describe";
|
|
604
|
-
readonly models: "/models";
|
|
605
|
-
readonly mutate: "/mutate";
|
|
606
|
-
readonly configsValidate: "/configs-validate";
|
|
607
|
-
readonly skillFix: "/skill-fix";
|
|
608
|
-
readonly templates: "/templates";
|
|
609
|
-
readonly promptConfigs: "/prompt-configs";
|
|
610
|
-
readonly presetContent: "/preset-content";
|
|
611
|
-
readonly importPreset: "/import-preset";
|
|
612
|
-
readonly paramOverrides: "/param-overrides";
|
|
613
|
-
readonly presetVariables: "/preset-variables";
|
|
614
|
-
readonly customTools: "/custom-tools";
|
|
615
|
-
readonly importPresetPackage: "/import-preset-package";
|
|
616
|
-
readonly exportPreset: "/export-preset";
|
|
617
|
-
readonly presetDelete: "/preset-delete";
|
|
618
|
-
readonly presetClone: "/preset-clone";
|
|
619
|
-
readonly presetDuplicate: "/preset-duplicate";
|
|
620
|
-
readonly presetOpen: "/preset-open";
|
|
621
|
-
readonly charactersImport: "/characters-import";
|
|
622
|
-
readonly charactersList: "/characters-list";
|
|
623
|
-
readonly charactersDelete: "/characters-delete";
|
|
624
|
-
readonly charactersApply: "/characters-apply";
|
|
625
|
-
readonly charactersRemove: "/characters-remove";
|
|
626
|
-
};
|
|
627
|
-
type BridgeEndpoint = (typeof BRIDGE_ENDPOINTS)[keyof typeof BRIDGE_ENDPOINTS];
|
|
628
|
-
/** 失败载荷:两端共用。 */
|
|
629
|
-
type BridgeErrorPayload = {
|
|
630
|
-
ok: false;
|
|
631
|
-
code?: string;
|
|
632
|
-
message?: string;
|
|
633
|
-
};
|
|
865
|
+
declare function resolveProjectRoot(cwd: string): string;
|
|
866
|
+
declare function skillRoots(options: {
|
|
867
|
+
cwd?: string;
|
|
868
|
+
dshHome: string;
|
|
869
|
+
folders: readonly string[];
|
|
870
|
+
}): ScanRoot[];
|
|
871
|
+
/** 只扫描普通目录包和直属 Markdown 文件;链接技能由 registry 补充为只读条目。 */
|
|
872
|
+
declare function scanRoot(root: ScanRoot): ScannedSkill[];
|
|
873
|
+
declare function scanRoots(roots: readonly ScanRoot[]): ScannedSkill[];
|
|
874
|
+
declare function catalogFromScan(skills: readonly ScannedSkill[]): SkillCatalogEntry[];
|
|
634
875
|
//#endregion
|
|
635
876
|
//#region src/runtime/skills-parse.d.ts
|
|
636
877
|
interface SkillFrontmatter {
|
|
@@ -646,11 +887,16 @@ interface SkillFrontmatter {
|
|
|
646
887
|
declare function parseFrontmatter(text: string): {
|
|
647
888
|
data: SkillFrontmatter;
|
|
648
889
|
body: string;
|
|
890
|
+
issue?: string;
|
|
649
891
|
};
|
|
650
892
|
//#endregion
|
|
893
|
+
//#region src/shared/preset-ids.d.ts
|
|
894
|
+
/** 包内模板、用户副本与当前预设共用同名 ID;避免与宿主官方预设重名。 */
|
|
895
|
+
declare const DEFAULT_PRESET_ID = "pt-standard";
|
|
896
|
+
//#endregion
|
|
651
897
|
//#region src/index.d.ts
|
|
652
898
|
declare const name = "prompt-tool";
|
|
653
899
|
declare const inject: string[];
|
|
654
900
|
declare function apply(ctx: Context, configIn: Config): void;
|
|
655
901
|
//#endregion
|
|
656
|
-
export { BRIDGE_ENDPOINTS, type BridgeEndpoint, type BridgeErrorPayload, type
|
|
902
|
+
export { BRIDGE_ENDPOINTS, type BridgeEndpoint, type BridgeErrorPayload, type BridgeRequestMap, type BridgeValueMap, CHARACTER_MODULES_KEY, type CharacterModuleContext, Config, DEFAULT_PRESET_ID, ENGINE_CAPABILITIES, ENGINE_PARAM_KEYS, ENGINE_RECIPES, type EngineCapability, type EngineCapabilityCreateRequest, type EngineCapabilityCreateResult, type EngineCapabilityRemoveResult, INSTRUCTION_FILE_STATUSES, type InstructionContextView, type InstructionFileSnapshot, type InstructionFileStatus, MAX_BRIDGE_BODY_BYTES, MAX_CHARACTER_CARD_STREAM_BYTES, MAX_INSTRUCTION_FILE_BYTES, type ModuleSourceMode, PARAM_KEYS, PRE_STEP_COORDINATOR_SERVICE, PRE_STEP_COORDINATOR_VERSION, type PluginSubagentSeam, type PreStepCoordinatorOptions, type PreStepCoordinatorService, type PreStepFileContribution, type PreStepPromptConfig, type PreStepSource, type PresetModuleFacts, type PresetSpec, type PromptConfigTemplate, type PromptConfigValidationError, type PromptConfigValidationResult, PromptSettingsSchema, SETTINGS_BRIDGE_PREFIX, SKILL_NAME_PATTERN, type SkillCatalogEntry, type SkillFrontmatter, type SkillPolicyChange, type SkillPolicyRead, type SkillPolicyScope, type SkillPolicyWrite, type SkillsCatalogSnapshot, type SkillsRuntime, type SkillsState, type ToolTemplate, USER_SKILLS_DIR, WRITER_PARAM_KEYS, type WritePresetOptions, agentsFileCardSpecs, agentsFileId, appendCharacterMemory, appendMemoryFile, apply, applyCharacterToPreset, applyModuleConfigs, assertSafeConfigId, buildModuleConfigsFromParams, buildWorldBookEntry, catalogFromScan, characterModuleStillNeeded, cloneBuiltinPreset, configFileName, convertStToPreset, createEngineCapabilityInPreset, createSkillsReloader, createSkillsRuntime, declaredCharacterModules, deleteCharacterCard, deleteWorldBookEntry, detectAgentsFileSnapshots, detectAgentsFiles, detectModels, engineCapability, engineRecipe, ensurePresetSeed, ensureWebSurface, expandPresetSource, exportPresetPackage, importCharacterCard, importCharacterCardFile, importSkillsPackage, inject, installPreStepCoordinator, installPresetPackage, invalidateModelCatalog, invocationForScope, isEngineCapabilityPresent, listAdvertisedModels, listBuiltinTemplates, listCharacterCards, listPresets, listWorldBookEntries, loadPresetSpec, loadPromptTemplates, loadToolTemplates, mergeInstructionCards, mergeStPresets, name, parseFrontmatter, peekModelCatalog, presetImportPreview, processStText, readAgentsFileSnapshot, readCharacterMemory, readSkillInvocation, readSkillsState, recordedCharacterModules, registerCharacterTools, registerSettingsBridge, registerTuiCommand, registerWorldBookTools, removeCharacterFromPreset, removeEngineCapabilityFromPreset, removePresetModule, removeUserPreset, renderComposition, requiredCharacterModules, resolvePresetDir, resolvePresetModuleFacts, resolvePresetParams, resolveProfileDir, resolveProjectRoot, resolveSubagentStartOptions, savePresetParams, savePresetPersona, scanRoot, scanRoots, scheduleWebSurfaceRepair, scopeOfInvocation, setSkillInvocation, skillRoots, skillsStatePath, stPresetId, syncImportedCharacterMemory, upsertWorldBookEntry, userPresetsDir, validateCustomToolIdentities, validateEngineParamValues, validatePromptConfigs, writeAgentsFile, writeAgentsFileChecked, writePreset, writeSkillsState };
|