dsh-plugin-prompt-tool 0.7.1 → 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
|
@@ -0,0 +1,1233 @@
|
|
|
1
|
+
import { parseDocument } from "yaml";
|
|
2
|
+
//#region src/shared/instructions.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* 指令文件(AGENTS.md / CLAUDE.md 等)跨 host/client 的最小契约。
|
|
5
|
+
* 只放两端都要理解的形状:读取快照、工作区上下文与写入结果;
|
|
6
|
+
* 引擎侧的位置/晋升/受众算法不在这里复制。
|
|
7
|
+
*/
|
|
8
|
+
/** 单个指令文件正文上限(与官方指令行的 maxBytes 基线对齐;读写限制一致)。 */
|
|
9
|
+
declare const MAX_INSTRUCTION_FILE_BYTES: number;
|
|
10
|
+
declare const INSTRUCTION_FILE_STATUSES: readonly ["ready", "missing", "unreadable", "too-large"];
|
|
11
|
+
/**
|
|
12
|
+
* 读取状态:`ready` 之外的任何状态都不代表空正文,也禁止写盘。
|
|
13
|
+
* 读取成功的空文件是 `ready` + `text: ''`,与读取失败严格区分。
|
|
14
|
+
*/
|
|
15
|
+
type InstructionFileStatus = (typeof INSTRUCTION_FILE_STATUSES)[number];
|
|
16
|
+
/** 单次读取形成的一致快照:正文、身份、版本来自同一次读取。 */
|
|
17
|
+
interface InstructionFileSnapshot {
|
|
18
|
+
/** 服务端按真实文件身份生成;不是客户端写入授权本身。 */
|
|
19
|
+
fileId: string;
|
|
20
|
+
/** 服务端解析出的绝对路径(客户端不得据此写盘,只是展示与身份)。 */
|
|
21
|
+
path: string;
|
|
22
|
+
/** 展示用路径(DSH_HOME 内 `~/.dsh/…`,项目内相对项目根)。 */
|
|
23
|
+
displayPath: string;
|
|
24
|
+
scope: 'global' | 'project';
|
|
25
|
+
status: InstructionFileStatus;
|
|
26
|
+
/** status === 'ready' 时的原始 UTF-8 正文(可为空串);其他状态为 ''。 */
|
|
27
|
+
text: string;
|
|
28
|
+
/** status === 'ready' 时原始文件字节的 SHA-256;其他状态为 null。 */
|
|
29
|
+
revision: string | null;
|
|
30
|
+
/** 读取失败/超限的诊断信息;ready 时不带。 */
|
|
31
|
+
message?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 本次工作区上下文:优先由存活本地 Agent 的会话 cwd 解析;拿不到会话时回退到
|
|
35
|
+
* 部署进程 cwd(与官方 agent-instructions 的 `session.header.cwd ?? process.cwd()`
|
|
36
|
+
* 同口径),并如实标记来源,让 UI 能辨别两种范围。
|
|
37
|
+
*/
|
|
38
|
+
interface InstructionContextView {
|
|
39
|
+
/** 上下文 id(cwd + 文件身份集派生);无可解析本地会话时为 null。 */
|
|
40
|
+
contextId: string | null;
|
|
41
|
+
cwd: string | null;
|
|
42
|
+
/**
|
|
43
|
+
* session = 由存活本地 Agent 的会话 cwd 解析;
|
|
44
|
+
* deploy-cwd = 会话不可用,退回部署进程 cwd(范围提示,不构成写授权);
|
|
45
|
+
* global-only = 客户端尚无服务端解析结果时的空池标记。
|
|
46
|
+
*/
|
|
47
|
+
source: 'session' | 'deploy-cwd' | 'global-only';
|
|
48
|
+
}
|
|
49
|
+
interface InstructionsSnapshot {
|
|
50
|
+
context: InstructionContextView;
|
|
51
|
+
files: InstructionFileSnapshot[];
|
|
52
|
+
owner: InstructionsOwnerView;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 指令负责人事实:本会话实际装配里是否仍挂着官方指令加载行。
|
|
56
|
+
* `true` 时独立文件来源整体不参战(同一正文只由一方注入);`false` 表示由本插件
|
|
57
|
+
* 的独立来源负责;`null` 表示本次请求还没有该会话的装配观察结果(不猜)。
|
|
58
|
+
*/
|
|
59
|
+
interface InstructionsOwnerView {
|
|
60
|
+
officialInstructions: boolean | null;
|
|
61
|
+
}
|
|
62
|
+
/** /agents-file 成功返回值:写盘后的新版本,客户端据此更新基线。 */
|
|
63
|
+
interface InstructionFileWriteResult {
|
|
64
|
+
fileId: string;
|
|
65
|
+
revision: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 指令文件卡策略(独立于预设与 settings 的本插件自有状态)。
|
|
69
|
+
*
|
|
70
|
+
* 只承载行为开关与展示名:正文永远在用户的原文件里,策略不存正文、读取版本、
|
|
71
|
+
* 会话 ID 或任意客户端路径。缺省 `enabled: false`——独立来源必须先完成负责人
|
|
72
|
+
* 切换验收,再由用户显式开启。
|
|
73
|
+
*/
|
|
74
|
+
interface InstructionPolicyValues {
|
|
75
|
+
order: number;
|
|
76
|
+
position: string;
|
|
77
|
+
promotion: string;
|
|
78
|
+
audience: string | null;
|
|
79
|
+
modelScope: string;
|
|
80
|
+
}
|
|
81
|
+
interface InstructionPolicyFileOverride extends Partial<InstructionPolicyValues> {
|
|
82
|
+
/** 每文件可关闭注入(默认开启);部署级 enabled 为 false 时整体不注入。 */
|
|
83
|
+
enabled?: boolean;
|
|
84
|
+
/** 可选显示名(只影响 UI 标题)。 */
|
|
85
|
+
name?: string;
|
|
86
|
+
}
|
|
87
|
+
interface InstructionPolicy {
|
|
88
|
+
/** 部署级开关:文件来源是否参与注入。 */
|
|
89
|
+
enabled: boolean;
|
|
90
|
+
/** 未单独覆盖的文件使用这些值。 */
|
|
91
|
+
defaults: InstructionPolicyValues;
|
|
92
|
+
/** 按 fileId 的覆盖;缺省即用 defaults,删除覆盖恢复默认。 */
|
|
93
|
+
files: Record<string, InstructionPolicyFileOverride>;
|
|
94
|
+
}
|
|
95
|
+
/** 局部更新:只写传入的键;files[fileId] = null 表示删除该覆盖。 */
|
|
96
|
+
interface InstructionPolicyPatch {
|
|
97
|
+
enabled?: boolean;
|
|
98
|
+
defaults?: Partial<InstructionPolicyValues>;
|
|
99
|
+
files?: Record<string, InstructionPolicyFileOverride | null>;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/shared/persona-section.d.ts
|
|
103
|
+
/**
|
|
104
|
+
* preset.yml 顶层 `persona` 段契约:与官方 `@deepseek-ai/dsh-persona` 行同构,
|
|
105
|
+
* 由渲染层写入 `deployment:persona-prefix`(order 0)与
|
|
106
|
+
* `deployment:persona-suffix`(order 10200)两段。
|
|
107
|
+
* 旧 params.sectionName 人设写法不做兼容也不迁移(本项目不含迁移代码)。
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
* preset.yml 顶层 `persona` 段:与官方 `@deepseek-ai/dsh-persona` 行的 config 同构。
|
|
111
|
+
* 官方 schema:prefix required、suffix 默认 ''、complete 默认 false、
|
|
112
|
+
* includeRuntimeContext 默认 true。
|
|
113
|
+
*/
|
|
114
|
+
interface PersonaSpec {
|
|
115
|
+
/** `deployment:persona-prefix` 文本(第一方指导之前,官方 order 0)。 */
|
|
116
|
+
prefix: string;
|
|
117
|
+
/** `deployment:persona-suffix` 文本(第一方指导之后,官方 order 10200)。 */
|
|
118
|
+
suffix?: string;
|
|
119
|
+
/** prefix 独占整个 system prompt(抑制其余段与 suffix)。 */
|
|
120
|
+
complete?: boolean;
|
|
121
|
+
/** false = 抑制该 scope 的动态 runtime-context 快照。 */
|
|
122
|
+
includeRuntimeContext?: boolean;
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/shared/asset-transfer.d.ts
|
|
126
|
+
/** 资产传输使用显式编码;省略编码仅兼容旧文本请求。 */
|
|
127
|
+
interface AssetFile {
|
|
128
|
+
path: string;
|
|
129
|
+
content: string;
|
|
130
|
+
encoding?: 'utf8' | 'base64';
|
|
131
|
+
}
|
|
132
|
+
type ImportKind = 'native-preset' | 'native-character' | 'st-preset' | 'st-character' | 'world-book';
|
|
133
|
+
interface ImportChoices {
|
|
134
|
+
targetId?: string;
|
|
135
|
+
targetName?: string;
|
|
136
|
+
overwrite?: boolean;
|
|
137
|
+
sourceKind?: ImportKind;
|
|
138
|
+
promptOrderCharacterId?: string;
|
|
139
|
+
}
|
|
140
|
+
interface AssetSummary {
|
|
141
|
+
sourceName: string;
|
|
142
|
+
kind: ImportKind;
|
|
143
|
+
targetId: string;
|
|
144
|
+
targetName: string;
|
|
145
|
+
exists: boolean;
|
|
146
|
+
files: Array<{
|
|
147
|
+
path: string;
|
|
148
|
+
bytes: number;
|
|
149
|
+
}>;
|
|
150
|
+
configCount: number;
|
|
151
|
+
warnings: string[];
|
|
152
|
+
}
|
|
153
|
+
interface AssetImportRequest extends ImportChoices {
|
|
154
|
+
files?: AssetFile[];
|
|
155
|
+
sourceId?: string;
|
|
156
|
+
preview?: boolean;
|
|
157
|
+
expectedSourceDigest?: string;
|
|
158
|
+
expectedPreviewRevision?: string;
|
|
159
|
+
}
|
|
160
|
+
interface PresetExportRequest {
|
|
161
|
+
id: string;
|
|
162
|
+
mode?: 'definition' | 'zip';
|
|
163
|
+
preview?: boolean;
|
|
164
|
+
expectedRevision?: string;
|
|
165
|
+
memoryChoices?: Record<string, 'include' | 'exclude'>;
|
|
166
|
+
}
|
|
167
|
+
interface PresetExportResult {
|
|
168
|
+
id: string;
|
|
169
|
+
name: string;
|
|
170
|
+
content: string;
|
|
171
|
+
encoding?: 'utf8' | 'base64';
|
|
172
|
+
filename?: string;
|
|
173
|
+
revision?: string;
|
|
174
|
+
files?: Array<{
|
|
175
|
+
path: string;
|
|
176
|
+
bytes: number;
|
|
177
|
+
}>;
|
|
178
|
+
warnings?: string[];
|
|
179
|
+
blockers?: string[];
|
|
180
|
+
memoryConflicts?: Array<{
|
|
181
|
+
id: string;
|
|
182
|
+
name: string;
|
|
183
|
+
}>;
|
|
184
|
+
excludedMemoryCount?: number;
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/shared/engine-capabilities.d.ts
|
|
188
|
+
type ModuleSourceMode = 'explicit' | 'composition' | 'official' | 'unknown';
|
|
189
|
+
/** 官方九个注入层:与 engine/schema.mjs 的 LAYER_ORDER 同源,改一处必须同步另一处。 */
|
|
190
|
+
type EngineLayer = 'pre-step' | 'system-section' | 'runtime-context' | 'agent-request' | 'llm-stream' | 'tool-pipeline' | 'turn-stop' | 'subagent-start' | 'subagent-end';
|
|
191
|
+
interface PresetModuleFacts {
|
|
192
|
+
declaredModules: string[] | null;
|
|
193
|
+
effectiveModules: string[] | null;
|
|
194
|
+
rowIds: string[];
|
|
195
|
+
sourceMode: ModuleSourceMode;
|
|
196
|
+
editable: boolean;
|
|
197
|
+
effectiveConfigs?: Record<string, Record<string, unknown>>;
|
|
198
|
+
}
|
|
199
|
+
interface EngineCapability {
|
|
200
|
+
id: string;
|
|
201
|
+
moduleKeys: readonly string[];
|
|
202
|
+
rowIds: readonly string[];
|
|
203
|
+
displayLayer: EngineLayer;
|
|
204
|
+
/** 真实跨层影响的相关层(只在确有第二通道时登记,避免把归属铺满九层)。 */
|
|
205
|
+
relatedLayers?: readonly EngineLayer[];
|
|
206
|
+
/**
|
|
207
|
+
* 该能力拥有的 preset 顶层数据段(不是行级 config)。
|
|
208
|
+
* 创建时若段缺失则写入 `skeleton`(保证"模块在 ⇒ 数据在");删除时一并移除该段。
|
|
209
|
+
*/
|
|
210
|
+
ownSection?: {
|
|
211
|
+
/** preset.yml 顶层键名。 */
|
|
212
|
+
key: string;
|
|
213
|
+
/** 启用时写入的可用骨架(必须能通过该段的校验)。 */
|
|
214
|
+
skeleton: Readonly<Record<string, unknown>>;
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
/** 首期只登记已有 typed editor 的能力,避免万能 key/value 表单。 */
|
|
218
|
+
declare const ENGINE_CAPABILITIES: readonly EngineCapability[];
|
|
219
|
+
/**
|
|
220
|
+
* 编辑组 = 前端一张可编辑卡(能力卡或专用卡)的主归属层。
|
|
221
|
+
* id 必须是代码里真实存在的 card / 展开键名,不新增臆造 id。
|
|
222
|
+
*/
|
|
223
|
+
interface EngineEditorGroup {
|
|
224
|
+
id: string;
|
|
225
|
+
displayLayer: EngineLayer;
|
|
226
|
+
/** 真实跨层影响的相关层(只有确有第二通道时才写)。 */
|
|
227
|
+
relatedLayers?: readonly EngineLayer[];
|
|
228
|
+
/** 真实生效通道的只读说明键(如 'agent-request' / 'system-section'):供 UI 显示「实际生效通道」,
|
|
229
|
+
* 只写代码里可核对的事实,不承诺未验证的通道。 */
|
|
230
|
+
hook: string;
|
|
231
|
+
}
|
|
232
|
+
interface EngineRecipe {
|
|
233
|
+
id: string;
|
|
234
|
+
capabilities: readonly string[];
|
|
235
|
+
initialParams?: Readonly<Record<string, unknown>>;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* 只保留已有真实工作流的一键组合;recipe 本身不写入 preset.yml。
|
|
239
|
+
*
|
|
240
|
+
* B7 T3 清空:三条 recipe 的成员都是随本轮退场的专用能力(phase-control /
|
|
241
|
+
* phase-control-ptc / deliberation),没有任何一条还能组成合法能力集合。
|
|
242
|
+
* export 与 `engineRecipe()` 保留——调用点(创建菜单、bridge 校验)不必跟着改,
|
|
243
|
+
* 空表天然让组合项整个消失。
|
|
244
|
+
*/
|
|
245
|
+
declare const ENGINE_RECIPES: readonly EngineRecipe[];
|
|
246
|
+
declare function engineCapability(id: string): EngineCapability | undefined;
|
|
247
|
+
declare function engineRecipe(id: string): EngineRecipe | undefined;
|
|
248
|
+
/** 显式模块预设中的实际能力;包含当前参数与顶层策略所需的装配。
|
|
249
|
+
* 创建补声明由 host 单独检查 declaredModules;官方组合行不伪装成可编辑能力。 */
|
|
250
|
+
declare function isEngineCapabilityPresent(id: string, facts: PresetModuleFacts | undefined): boolean;
|
|
251
|
+
/** custom tool 的运行时名称缺省回落 id;保存前拒绝会导致同层注册失败的重复项。 */
|
|
252
|
+
declare function validateCustomToolIdentities(tools: readonly unknown[]): string[];
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region src/shared/managed-config-fields.d.ts
|
|
255
|
+
interface ConfigFieldSources {
|
|
256
|
+
configId: string;
|
|
257
|
+
fields: Array<{
|
|
258
|
+
path: string;
|
|
259
|
+
source: 'preset-param' | 'prompt-config';
|
|
260
|
+
}>;
|
|
261
|
+
}
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/shared/official-orders.d.ts
|
|
264
|
+
/** 一个已求值的区段:`from` / `to` 是该组首末档位的**官方**数值。 */
|
|
265
|
+
interface OfficialOrderSegment {
|
|
266
|
+
readonly id: string;
|
|
267
|
+
readonly from: number;
|
|
268
|
+
readonly to: number;
|
|
269
|
+
}
|
|
270
|
+
/** 下发形状:两层各自一组区段。 */
|
|
271
|
+
interface OfficialOrdersView {
|
|
272
|
+
readonly sections: readonly OfficialOrderSegment[];
|
|
273
|
+
readonly contexts: readonly OfficialOrderSegment[];
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/shared/skills.d.ts
|
|
277
|
+
interface SkillContentSnapshot {
|
|
278
|
+
/** Markdown 正文,不含 YAML frontmatter 与分隔线。 */
|
|
279
|
+
content: string;
|
|
280
|
+
description: string;
|
|
281
|
+
/** 当前原始内容的 SHA-256;只用于冲突检查,不保存历史版本。 */
|
|
282
|
+
revision: string;
|
|
283
|
+
}
|
|
284
|
+
/** 官方技能根分类;数值越小越优先,与官方 rank 一致。 */
|
|
285
|
+
type SkillSourceKind = 'project-dsh' | 'project-agents' | 'custom' | 'user-dsh' | 'user-agents' | 'bundled' | 'other';
|
|
286
|
+
/** 两个官方调用策略键:值就是「该端是否可调用」。 */
|
|
287
|
+
interface SkillInvocation {
|
|
288
|
+
/** `disable-model-invocation`:false 时模型不可发现、不可加载。 */
|
|
289
|
+
modelInvocable: boolean;
|
|
290
|
+
/** `user-invocable`:false 时用户斜杠命令不可加载。 */
|
|
291
|
+
userInvocable: boolean;
|
|
292
|
+
}
|
|
293
|
+
/** 两端调用策略的目标范围:'model' = 只让模型端不可调用,'user' = 只让用户端不可调用,
|
|
294
|
+
* 'all' = 两端都不可调用,'none' = 两端都恢复可调用。语义是「点击之后的目标状态」。 */
|
|
295
|
+
type SkillPolicyScope = 'none' | 'model' | 'user' | 'all';
|
|
296
|
+
/** 单端操作不携带另一端的旧快照;显式 scope 供两端批量操作和 TUI 使用。 */
|
|
297
|
+
type SkillPolicyChange = {
|
|
298
|
+
side: 'model' | 'user';
|
|
299
|
+
enabled: boolean;
|
|
300
|
+
} | {
|
|
301
|
+
scope: SkillPolicyScope;
|
|
302
|
+
};
|
|
303
|
+
interface SkillsCatalogSnapshot {
|
|
304
|
+
skills: SkillCatalogEntry[];
|
|
305
|
+
/** false 表示观测不完整,不能把未发现解释成不存在。 */
|
|
306
|
+
complete: boolean;
|
|
307
|
+
}
|
|
308
|
+
/** 目标范围 → 两个键的写入意图(true = 该端可调用)。 */
|
|
309
|
+
declare function invocationForScope(scope: SkillPolicyScope): SkillInvocation;
|
|
310
|
+
/** 当前两端状态 → 范围(两端都可调用时为 'none')。 */
|
|
311
|
+
declare function scopeOfInvocation(invocation: SkillInvocation): SkillPolicyScope;
|
|
312
|
+
/** 插件技能状态:只剩用户显式引用的技能文件夹(绝对路径,按引用顺序)。
|
|
313
|
+
* 技能是否可调用由技能文件自己声明,不再进状态文件。 */
|
|
314
|
+
interface SkillsState {
|
|
315
|
+
version: number;
|
|
316
|
+
folders: string[];
|
|
317
|
+
}
|
|
318
|
+
/** 清单条目:由插件扫描六类官方技能根得到,是管理面的事实来源。 */
|
|
319
|
+
interface SkillCatalogEntry {
|
|
320
|
+
/** 稳定键:来源类别 + 来源根 + 目录名。 */
|
|
321
|
+
id: string;
|
|
322
|
+
/** frontmatter name(缺失时回退目录名)。 */
|
|
323
|
+
name: string;
|
|
324
|
+
description: string;
|
|
325
|
+
/** 技能目录名(一层扫描,与官方发现规则一致)。 */
|
|
326
|
+
folder: string;
|
|
327
|
+
/** 来源根的绝对路径。 */
|
|
328
|
+
dir: string;
|
|
329
|
+
source: SkillSourceKind;
|
|
330
|
+
/** 来源优先级(越小越优先)。 */
|
|
331
|
+
rank: number;
|
|
332
|
+
valid: boolean;
|
|
333
|
+
issue?: string;
|
|
334
|
+
/** frontmatter 声明的模型端调用策略(唯一事实,缺省为可调用)。 */
|
|
335
|
+
modelInvocable: boolean;
|
|
336
|
+
/** frontmatter 声明的用户端调用策略(唯一事实,缺省为可调用)。 */
|
|
337
|
+
userInvocable: boolean;
|
|
338
|
+
/** 同名技能中的胜出者 id;本项未胜出时用于提示"被同名技能遮蔽"。 */
|
|
339
|
+
winnerId?: string;
|
|
340
|
+
/** 标记文件绝对路径(调用策略的写入目标与身份校验依据)。 */
|
|
341
|
+
path?: string;
|
|
342
|
+
/** 同名遮蔽事实:只有注册表确实报了同名技能时才标注;其余条目按文件声明为事实。 */
|
|
343
|
+
availability?: 'active' | 'shadowed';
|
|
344
|
+
provider?: string;
|
|
345
|
+
canSetPolicy?: boolean;
|
|
346
|
+
/** 普通本地资产可编辑描述和正文;缺描述可修复,损坏的 frontmatter 拒绝读取。 */
|
|
347
|
+
canEdit?: boolean;
|
|
348
|
+
canDelete?: boolean;
|
|
349
|
+
readonlyReason?: string;
|
|
350
|
+
}
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region src/shared/bridge-contract.d.ts
|
|
353
|
+
declare const SETTINGS_BRIDGE_PREFIX = "/api/prompt-tool/settings";
|
|
354
|
+
/** JSON bridge 的统一内存缓冲上限;超过后改用原始文件流端点。 */
|
|
355
|
+
declare const MAX_BRIDGE_BODY_BYTES: number;
|
|
356
|
+
/** 角色卡原始文件流上限;独立于 JSON bridge,避免 base64 膨胀。 */
|
|
357
|
+
declare const MAX_CHARACTER_CARD_STREAM_BYTES: number;
|
|
358
|
+
/** 桥端点路径(相对前缀)。新增端点必须同时登记到契约测试。 */
|
|
359
|
+
declare const BRIDGE_ENDPOINTS: {
|
|
360
|
+
readonly meta: "/meta";
|
|
361
|
+
readonly bootstrap: "/bootstrap";
|
|
362
|
+
readonly describe: "/describe";
|
|
363
|
+
readonly models: "/models";
|
|
364
|
+
readonly modelReasoning: "/model-reasoning";
|
|
365
|
+
readonly mutate: "/mutate";
|
|
366
|
+
readonly configsValidate: "/configs-validate";
|
|
367
|
+
readonly skillsList: "/skills-list";
|
|
368
|
+
readonly skillPolicy: "/skill-policy";
|
|
369
|
+
readonly skillRead: "/skill-read";
|
|
370
|
+
readonly skillWrite: "/skill-write";
|
|
371
|
+
readonly skillsFolders: "/skills-folders";
|
|
372
|
+
readonly skillsImport: "/skills-import";
|
|
373
|
+
readonly skillsImportDirectory: "/skills-import-directory";
|
|
374
|
+
readonly skillCreate: "/skill-create";
|
|
375
|
+
readonly skillDelete: "/skill-delete";
|
|
376
|
+
readonly templates: "/templates";
|
|
377
|
+
readonly promptConfigs: "/prompt-configs";
|
|
378
|
+
readonly agentsFile: "/agents-file";
|
|
379
|
+
readonly instructionsPolicy: "/instructions-policy";
|
|
380
|
+
readonly presetContent: "/preset-content";
|
|
381
|
+
readonly importPreset: "/import-preset";
|
|
382
|
+
readonly paramOverrides: "/param-overrides";
|
|
383
|
+
readonly triggers: "/triggers";
|
|
384
|
+
readonly persona: "/persona";
|
|
385
|
+
readonly presetVariables: "/preset-variables";
|
|
386
|
+
readonly customTools: "/custom-tools";
|
|
387
|
+
readonly importPresetPackage: "/import-preset-package";
|
|
388
|
+
readonly assetUpload: "/asset-upload";
|
|
389
|
+
readonly assetRelease: "/asset-release";
|
|
390
|
+
readonly exportPreset: "/export-preset";
|
|
391
|
+
readonly presetDelete: "/preset-delete";
|
|
392
|
+
readonly presetClone: "/preset-clone";
|
|
393
|
+
readonly presetDuplicate: "/preset-duplicate";
|
|
394
|
+
readonly presetOpen: "/preset-open";
|
|
395
|
+
readonly charactersImport: "/characters-import";
|
|
396
|
+
readonly charactersImportStream: "/characters-import-stream";
|
|
397
|
+
readonly charactersList: "/characters-list";
|
|
398
|
+
readonly charactersDelete: "/characters-delete";
|
|
399
|
+
readonly charactersApply: "/characters-apply";
|
|
400
|
+
readonly charactersRemove: "/characters-remove";
|
|
401
|
+
readonly subagentToolPolicy: "/subagent-tool-policy";
|
|
402
|
+
readonly subagentToolPolicyPreview: "/subagent-tool-policy-preview";
|
|
403
|
+
readonly toolSurface: "/tool-surface";
|
|
404
|
+
readonly engineCapability: "/engine-capability";
|
|
405
|
+
readonly worldBookDiagnostics: "/world-book-diagnostics";
|
|
406
|
+
};
|
|
407
|
+
type BridgeEndpoint = (typeof BRIDGE_ENDPOINTS)[keyof typeof BRIDGE_ENDPOINTS];
|
|
408
|
+
/** 失败载荷:两端共用。 */
|
|
409
|
+
type BridgeErrorPayload = {
|
|
410
|
+
ok: false;
|
|
411
|
+
code?: string;
|
|
412
|
+
message?: string;
|
|
413
|
+
conflicts?: string[];
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* 端点级请求体契约(body 形状;无请求体端点 = undefined)。
|
|
417
|
+
* 与 BRIDGE_ENDPOINTS 一一对应:新增端点必须同时补请求/响应映射,否则编译期断言失败。
|
|
418
|
+
* 载荷仍统一走 { ok, value } 包装(见 BridgeResult),这里收敛每端的 value 具体形状。
|
|
419
|
+
*/
|
|
420
|
+
interface BridgeRequestMap {
|
|
421
|
+
meta: undefined;
|
|
422
|
+
/** 可选 sessionId:服务端据此解析该本地 Agent 的工作区,返回对应指令文件快照。 */
|
|
423
|
+
bootstrap: {
|
|
424
|
+
sessionId?: string;
|
|
425
|
+
} | undefined;
|
|
426
|
+
describe: undefined;
|
|
427
|
+
/** 省略 body 或 `refresh: true`(显式刷新越过 10 分钟目录 TTL)。 */
|
|
428
|
+
models: {
|
|
429
|
+
refresh?: boolean;
|
|
430
|
+
} | undefined;
|
|
431
|
+
modelReasoning: {
|
|
432
|
+
provider: string;
|
|
433
|
+
model: string;
|
|
434
|
+
};
|
|
435
|
+
mutate: {
|
|
436
|
+
ops: unknown[];
|
|
437
|
+
expectedRevision?: number;
|
|
438
|
+
};
|
|
439
|
+
configsValidate: {
|
|
440
|
+
promptConfigs: unknown[];
|
|
441
|
+
strategyDir?: string;
|
|
442
|
+
};
|
|
443
|
+
/** 技能清单:按会话工作区扫描官方六类技能根,调用策略取自各技能文件的 frontmatter。 */
|
|
444
|
+
skillsList: {
|
|
445
|
+
sessionId?: string;
|
|
446
|
+
} | undefined;
|
|
447
|
+
/** 调用策略开关:改写该技能 SKILL.md frontmatter 的官方两个键(正文不动);
|
|
448
|
+
* path 必须命中服务端当次扫描的同名条目,否则按陈旧界面拒绝。 */
|
|
449
|
+
skillPolicy: {
|
|
450
|
+
name: string;
|
|
451
|
+
path: string;
|
|
452
|
+
sessionId?: string;
|
|
453
|
+
} & SkillPolicyChange;
|
|
454
|
+
/** 技能描述、Markdown 正文和完整原文摘要;重新扫描同名同路径身份。 */
|
|
455
|
+
skillRead: {
|
|
456
|
+
name: string;
|
|
457
|
+
path: string;
|
|
458
|
+
sessionId?: string;
|
|
459
|
+
};
|
|
460
|
+
/** 仅保存描述与正文,保持其余 frontmatter,并用完整原文摘要拒绝并发覆盖。 */
|
|
461
|
+
skillWrite: {
|
|
462
|
+
name: string;
|
|
463
|
+
path: string;
|
|
464
|
+
sessionId?: string;
|
|
465
|
+
content: string;
|
|
466
|
+
description: string;
|
|
467
|
+
expectedRevision: string;
|
|
468
|
+
};
|
|
469
|
+
/** 添加 / 移除引用的技能文件夹(只记状态,不复制文件)。 */
|
|
470
|
+
skillsFolders: {
|
|
471
|
+
folders: string[];
|
|
472
|
+
sessionId?: string;
|
|
473
|
+
};
|
|
474
|
+
/** overwrite 仅包含用户已确认覆盖的技能目录名;缺省时遇到同名返回冲突且不写盘。 */
|
|
475
|
+
skillsImport: {
|
|
476
|
+
files: Array<{
|
|
477
|
+
path: string;
|
|
478
|
+
content: string;
|
|
479
|
+
}>;
|
|
480
|
+
overwrite?: string[];
|
|
481
|
+
};
|
|
482
|
+
skillsImportDirectory: {
|
|
483
|
+
path: string;
|
|
484
|
+
overwrite?: string[];
|
|
485
|
+
};
|
|
486
|
+
skillCreate: {
|
|
487
|
+
name: string;
|
|
488
|
+
description: string;
|
|
489
|
+
content: string;
|
|
490
|
+
};
|
|
491
|
+
skillDelete: {
|
|
492
|
+
name: string;
|
|
493
|
+
path: string;
|
|
494
|
+
sessionId?: string;
|
|
495
|
+
};
|
|
496
|
+
templates: undefined;
|
|
497
|
+
/** 可选 sessionId:与 /bootstrap 同源解析当前工作区(单读与聚合读取必须一致)。 */
|
|
498
|
+
promptConfigs: {
|
|
499
|
+
sessionId?: string;
|
|
500
|
+
} | undefined;
|
|
501
|
+
/**
|
|
502
|
+
* 单文件写盘:fileId/contextId 必须命中服务端当次解析的白名单;
|
|
503
|
+
* expectedRevision 是客户端已读取的字节版本(乐观并发控制,服务端重读校验)。
|
|
504
|
+
*/
|
|
505
|
+
agentsFile: {
|
|
506
|
+
sessionId?: string;
|
|
507
|
+
contextId: string;
|
|
508
|
+
fileId: string;
|
|
509
|
+
expectedRevision: string | null;
|
|
510
|
+
content: string;
|
|
511
|
+
};
|
|
512
|
+
/**
|
|
513
|
+
* 指令文件卡策略(独立存储,默认禁用):省略 `policy` = 读取;
|
|
514
|
+
* 写入必须带读取时的 `expectedRevision`(文件缺失为 null)。
|
|
515
|
+
*/
|
|
516
|
+
instructionsPolicy: {
|
|
517
|
+
policy?: InstructionPolicyPatch;
|
|
518
|
+
expectedRevision?: string | null;
|
|
519
|
+
} | undefined;
|
|
520
|
+
presetContent: undefined;
|
|
521
|
+
importPreset: {
|
|
522
|
+
contents: Array<{
|
|
523
|
+
scope: 'preset' | 'agents';
|
|
524
|
+
content: string;
|
|
525
|
+
}>;
|
|
526
|
+
expectedPresetId?: string;
|
|
527
|
+
};
|
|
528
|
+
paramOverrides: {
|
|
529
|
+
overrides?: Record<string, unknown>;
|
|
530
|
+
promptConfigs?: unknown[];
|
|
531
|
+
rebuild?: boolean;
|
|
532
|
+
expectedPresetId?: string;
|
|
533
|
+
};
|
|
534
|
+
triggers: {
|
|
535
|
+
expectedPresetId: string;
|
|
536
|
+
triggers?: unknown[];
|
|
537
|
+
expectedRevision?: string;
|
|
538
|
+
validateOnly?: boolean;
|
|
539
|
+
};
|
|
540
|
+
/** 顶层 persona 段读写(官方 @deepseek-ai/dsh-persona 行 config 同构);省略 persona 键 = 读取。 */
|
|
541
|
+
persona: {
|
|
542
|
+
persona?: PersonaSpec | null;
|
|
543
|
+
expectedPresetId?: string;
|
|
544
|
+
} | undefined;
|
|
545
|
+
presetVariables: {
|
|
546
|
+
variables?: Record<string, string>;
|
|
547
|
+
enabled?: boolean;
|
|
548
|
+
expectedPresetId?: string;
|
|
549
|
+
};
|
|
550
|
+
customTools: {
|
|
551
|
+
customTools?: unknown[];
|
|
552
|
+
expectedPresetId?: string;
|
|
553
|
+
} | undefined;
|
|
554
|
+
/**
|
|
555
|
+
* 预设包导入(原生/ST/PNG/ZIP)。`preview: true` 只转换并返回报告,不写目标;
|
|
556
|
+
* 提交必须携带 expectedSourceDigest 和 expectedPreviewRevision,服务端重算并拒绝过期预览。
|
|
557
|
+
* `expectedPreviewRevision` 是预览返回的版本凭据:绑定文件、实际选组、转换器版本与
|
|
558
|
+
* 目标身份(含目标当前内容),服务端提交时重算,不符返回 409 且零写盘。
|
|
559
|
+
* `promptOrderCharacterId` 用于多顺序组包时显式选择:预览缺省时先返回候选
|
|
560
|
+
* (`state: 'needs-order-selection'`),提交时仍无法明确对应则拒绝。
|
|
561
|
+
* 上述参数只接受声明的类型,其它类型一律 400(见 docs/SillyTavern.md)。
|
|
562
|
+
*/
|
|
563
|
+
importPresetPackage: AssetImportRequest;
|
|
564
|
+
assetUpload: undefined;
|
|
565
|
+
assetRelease: {
|
|
566
|
+
sourceId: string;
|
|
567
|
+
};
|
|
568
|
+
exportPreset: PresetExportRequest;
|
|
569
|
+
presetDelete: {
|
|
570
|
+
id: string;
|
|
571
|
+
};
|
|
572
|
+
presetClone: {
|
|
573
|
+
id: string;
|
|
574
|
+
autoSuffix?: boolean;
|
|
575
|
+
};
|
|
576
|
+
presetDuplicate: {
|
|
577
|
+
id: string;
|
|
578
|
+
};
|
|
579
|
+
presetOpen: {
|
|
580
|
+
id: string;
|
|
581
|
+
};
|
|
582
|
+
/** 角色卡 PNG/JSON/YAML 导入;预览不写角色库,提交必验版本,目标和选组均绑定预览。 */
|
|
583
|
+
charactersImport: AssetImportRequest;
|
|
584
|
+
charactersImportStream: undefined;
|
|
585
|
+
charactersList: undefined;
|
|
586
|
+
charactersDelete: {
|
|
587
|
+
id: string;
|
|
588
|
+
};
|
|
589
|
+
charactersApply: {
|
|
590
|
+
id: string;
|
|
591
|
+
};
|
|
592
|
+
charactersRemove: {
|
|
593
|
+
id: string;
|
|
594
|
+
};
|
|
595
|
+
subagentToolPolicy: {
|
|
596
|
+
policy?: unknown;
|
|
597
|
+
expectedPresetId?: string;
|
|
598
|
+
} | undefined;
|
|
599
|
+
subagentToolPolicyPreview: {
|
|
600
|
+
tool?: string;
|
|
601
|
+
description?: string;
|
|
602
|
+
prompt?: string;
|
|
603
|
+
tool_profile?: string;
|
|
604
|
+
character_id?: string;
|
|
605
|
+
task_type?: string;
|
|
606
|
+
additional_tools?: string[];
|
|
607
|
+
restrict_tools?: string[];
|
|
608
|
+
};
|
|
609
|
+
toolSurface: {
|
|
610
|
+
sessionId: string;
|
|
611
|
+
presetId?: never;
|
|
612
|
+
} | {
|
|
613
|
+
presetId: string;
|
|
614
|
+
sessionId?: never;
|
|
615
|
+
};
|
|
616
|
+
engineCapability: ({
|
|
617
|
+
action: 'create' | 'remove';
|
|
618
|
+
capabilityId: string;
|
|
619
|
+
} | {
|
|
620
|
+
action: 'create-recipe';
|
|
621
|
+
recipeId: string;
|
|
622
|
+
}) & {
|
|
623
|
+
expectedPresetId?: string;
|
|
624
|
+
};
|
|
625
|
+
/** 只读世界书诊断:只回当前授权会话最近一次选择的观测记录。 */
|
|
626
|
+
worldBookDiagnostics: {
|
|
627
|
+
sessionId?: string;
|
|
628
|
+
} | undefined;
|
|
629
|
+
}
|
|
630
|
+
/** settings descriptor 的跨端最小结构。 */
|
|
631
|
+
interface BridgeSettingsView {
|
|
632
|
+
ns: string;
|
|
633
|
+
value: unknown;
|
|
634
|
+
base?: unknown;
|
|
635
|
+
revision: number;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* 一条 provider/model 路由的推理档位元数据(官方模型元数据的展示子集)。
|
|
639
|
+
*
|
|
640
|
+
* `known` 区分「查过且该路由不提供档位」与「尚未取得元数据」:前者 UI 必须隐藏档位
|
|
641
|
+
* 选择而不是拿固定列表伪造能力;后者只是还没查到,不能据此判断模型没有推理能力。
|
|
642
|
+
* 目录/元数据只作展示,不是授权白名单——查询失败不影响保存任意模型 id。
|
|
643
|
+
*/
|
|
644
|
+
interface ModelReasoningView {
|
|
645
|
+
known: boolean;
|
|
646
|
+
efforts: Array<{
|
|
647
|
+
id: string;
|
|
648
|
+
name: string;
|
|
649
|
+
description?: string;
|
|
650
|
+
}>;
|
|
651
|
+
defaultEffort?: string;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* SillyTavern 转换报告(ST-03):host 在真实转换路径上生成的**只读派生元数据**。
|
|
655
|
+
* 不落盘进 preset.yml、不进入模型上下文,也不是写入凭证——提交仍以本次上传文件重算的
|
|
656
|
+
* `sourceDigest` 为准;预览返回的摘要不能替代后端对目标/类型/大小的既有校验。
|
|
657
|
+
*/
|
|
658
|
+
type StConversionClass = 'equivalent' | 'degraded' | 'unsupported' | 'excluded';
|
|
659
|
+
interface StConversionEntryReport {
|
|
660
|
+
/** 来源条目身份:上传文件显示名内的原 identifier/uid(不含绝对路径)。 */
|
|
661
|
+
sourceId: string;
|
|
662
|
+
/** 来源在文件内的序号(prompts 数组下标或世界书 entries 序号)。 */
|
|
663
|
+
sourceIndex: number;
|
|
664
|
+
/** 生成的目标配置 id(被排除的条目没有目标)。多文件合并后重写为**最终** id。 */
|
|
665
|
+
targetId?: string;
|
|
666
|
+
/** 同源生成的 promptConfigs 下标:合并重命名时用它把 targetId 关联到最终配置。 */
|
|
667
|
+
targetIndex?: number;
|
|
668
|
+
/** 来源显示名(多文件合并时用于区分条目来自哪个上传文件)。 */
|
|
669
|
+
sourceName?: string;
|
|
670
|
+
/** 来源在本次合并中的序号(0 起)。 */
|
|
671
|
+
sourceFileIndex?: number;
|
|
672
|
+
layer?: string;
|
|
673
|
+
order?: number;
|
|
674
|
+
role?: string;
|
|
675
|
+
position?: string;
|
|
676
|
+
classification: StConversionClass;
|
|
677
|
+
/** 稳定原因码(如 depth-collapsed / system-role-downgrade / marker-dropped)。 */
|
|
678
|
+
codes: string[];
|
|
679
|
+
}
|
|
680
|
+
interface StConversionDiagnostic {
|
|
681
|
+
code: string;
|
|
682
|
+
severity: 'warning' | 'info';
|
|
683
|
+
message: string;
|
|
684
|
+
/** 源身份定位:来源条目 id(与 targetId 分开表达,不混用同一字段)。 */
|
|
685
|
+
entryId?: string;
|
|
686
|
+
/** 目标身份定位:生成/合并后的最终配置 id(源条目被排除时缺省)。 */
|
|
687
|
+
targetId?: string;
|
|
688
|
+
field?: string;
|
|
689
|
+
}
|
|
690
|
+
interface StConversionReport {
|
|
691
|
+
/** 转换器版本:解释本次生成使用了哪一版语义。 */
|
|
692
|
+
converter: string;
|
|
693
|
+
/** 来源显示名(上传文件名,不含绝对路径)。 */
|
|
694
|
+
sourceName: string;
|
|
695
|
+
/** prompt_order 分组;`selected` 标记本次实际采用的组。 */
|
|
696
|
+
orderGroups: Array<{
|
|
697
|
+
characterId: string;
|
|
698
|
+
selected: boolean;
|
|
699
|
+
entries: number;
|
|
700
|
+
}>;
|
|
701
|
+
entries: StConversionEntryReport[];
|
|
702
|
+
diagnostics: StConversionDiagnostic[];
|
|
703
|
+
summary: {
|
|
704
|
+
/** 来源条目总数(prompts + 世界书条目 + 角色卡正文段)。 */
|
|
705
|
+
inputs: number;
|
|
706
|
+
/** 生成的 promptConfigs 数量。 */
|
|
707
|
+
converted: number;
|
|
708
|
+
/** 生成但被禁用的条目数。 */
|
|
709
|
+
disabled: number;
|
|
710
|
+
excluded: number;
|
|
711
|
+
unsupported: number;
|
|
712
|
+
degraded: number;
|
|
713
|
+
/** 需要用户确认的诊断数(warning 级)。 */
|
|
714
|
+
needsReview: number;
|
|
715
|
+
};
|
|
716
|
+
/** 记录超出上限时为 true:只截断展示,不影响转换结果。 */
|
|
717
|
+
truncated?: boolean;
|
|
718
|
+
}
|
|
719
|
+
/** 世界书入选/落选诊断记录(只读派生数据,由引擎真实求值路径产生)。 */
|
|
720
|
+
interface WorldBookDiagnosticRecord {
|
|
721
|
+
/** 配置 id(`lore-<来源条目>`)。 */
|
|
722
|
+
id: string;
|
|
723
|
+
stage: 'excluded' | 'rejected' | 'candidate' | 'selected' | 'committed';
|
|
724
|
+
/** 稳定原因码:disabled / delay / cooldown / recursion / primary-miss / secondary-miss /
|
|
725
|
+
* probability / group-lost / group-occupied / match-error / sticky / constant / key-match /
|
|
726
|
+
* ungrouped / group-winner / injected。 */
|
|
727
|
+
reason: string;
|
|
728
|
+
[key: string]: unknown;
|
|
729
|
+
}
|
|
730
|
+
/** 顺序组候选:多 prompt_order 组需要用户先选择时的有界选项(不含转换结果)。 */
|
|
731
|
+
interface StOrderGroupCandidate {
|
|
732
|
+
characterId: string;
|
|
733
|
+
entries: number;
|
|
734
|
+
}
|
|
735
|
+
/** 导入预览状态:`ready` 才有报告与写入凭据;候选状态不得启用确认。 */
|
|
736
|
+
type ImportPreviewState = 'ready' | 'needs-order-selection' | 'needs-kind-selection';
|
|
737
|
+
/** 引擎实际消费的实例参数;只下发可序列化约束,未知扩展键仍由原配置保留。 */
|
|
738
|
+
interface LayerParamContract {
|
|
739
|
+
type: 'string' | 'boolean' | 'object' | 'enum';
|
|
740
|
+
values?: readonly string[];
|
|
741
|
+
}
|
|
742
|
+
/** 声明编辑目录由引擎提供;示例同时经过声明编译器验证。 */
|
|
743
|
+
interface TriggerEditorMeta {
|
|
744
|
+
predicates: Array<{
|
|
745
|
+
kind: string;
|
|
746
|
+
example: Record<string, unknown>;
|
|
747
|
+
}>;
|
|
748
|
+
actions: Array<{
|
|
749
|
+
kind: string;
|
|
750
|
+
example: Record<string, unknown>;
|
|
751
|
+
channel: string;
|
|
752
|
+
phase: string;
|
|
753
|
+
supportsWhen: boolean;
|
|
754
|
+
}>;
|
|
755
|
+
composites: string[];
|
|
756
|
+
waterfallPositions: string[];
|
|
757
|
+
}
|
|
758
|
+
interface LayerContract {
|
|
759
|
+
strategies: readonly string[];
|
|
760
|
+
subjects: readonly string[];
|
|
761
|
+
content: 'text' | 'request' | 'stream' | 'tool-result' | 'subagent-result';
|
|
762
|
+
variables: boolean;
|
|
763
|
+
messageMetadata: boolean;
|
|
764
|
+
params: Readonly<Record<string, LayerParamContract>>;
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* /meta 与 /bootstrap 的 meta 段下发的层契约:九层顺序 + 编辑组主归属。
|
|
768
|
+
* 只含可序列化白名单字段(组 id / displayLayer / relatedLayers / hook):
|
|
769
|
+
* 不含路径、行级配置、校验函数或服务实例 —— 展示归属不扩大写权限。
|
|
770
|
+
* 插件与内置引擎同步发布,这些字段由当前 bridge 完整下发。
|
|
771
|
+
*/
|
|
772
|
+
interface EngineMetaLayerContract {
|
|
773
|
+
/** 九层固定顺序(引擎 LAYER_ORDER,host 不另写一份)。 */
|
|
774
|
+
layerOrder: readonly EngineLayer[];
|
|
775
|
+
/** 编辑组主归属总表(能力组 id = 能力 id);前端据此组织九层卡片。 */
|
|
776
|
+
editorGroups: readonly EngineEditorGroup[];
|
|
777
|
+
/** 每层真实可编辑的行为契约,来自独立可分发的 engine/schema.mjs。 */
|
|
778
|
+
layerContracts: Record<EngineLayer, LayerContract>;
|
|
779
|
+
}
|
|
780
|
+
/** 物化配置的只读来源;与配置一同读回,不能作为写入字段或授权。 */
|
|
781
|
+
interface PromptConfigSourceView {
|
|
782
|
+
fieldSources?: ConfigFieldSources;
|
|
783
|
+
}
|
|
784
|
+
/** 端点级响应 value 契约(value 字段形状;扩展字段仍以 value 旁可选字段出现)。 */
|
|
785
|
+
interface BridgeValueMap {
|
|
786
|
+
/**
|
|
787
|
+
* `/meta` 与 `/bootstrap` 的 meta 段:层契约 + 官方装配刻度。
|
|
788
|
+
* `officialOrders` 缺席表示服务降级或官方档位名不匹配,消费方必须退化(不渲染刻度)。
|
|
789
|
+
*/
|
|
790
|
+
meta: {
|
|
791
|
+
meta: Record<string, unknown> & EngineMetaLayerContract & {
|
|
792
|
+
officialOrders?: OfficialOrdersView;
|
|
793
|
+
};
|
|
794
|
+
};
|
|
795
|
+
bootstrap: BridgeSettingsView;
|
|
796
|
+
describe: BridgeSettingsView;
|
|
797
|
+
models: {
|
|
798
|
+
modelCatalog: Record<string, string[]>;
|
|
799
|
+
};
|
|
800
|
+
modelReasoning: {
|
|
801
|
+
reasoning: ModelReasoningView;
|
|
802
|
+
};
|
|
803
|
+
mutate: BridgeSettingsView;
|
|
804
|
+
configsValidate: {
|
|
805
|
+
valid: boolean;
|
|
806
|
+
errors: Array<{
|
|
807
|
+
index: number;
|
|
808
|
+
id: string;
|
|
809
|
+
message: string;
|
|
810
|
+
}>;
|
|
811
|
+
configs?: unknown[];
|
|
812
|
+
files?: unknown[];
|
|
813
|
+
};
|
|
814
|
+
/** 技能清单 + 引用目录 + 技能根(客户端据此渲染来源分组与调用策略)。 */
|
|
815
|
+
skillsList: SkillsCatalogSnapshot & {
|
|
816
|
+
folders: string[];
|
|
817
|
+
roots: string[];
|
|
818
|
+
};
|
|
819
|
+
skillPolicy: SkillsCatalogSnapshot;
|
|
820
|
+
skillRead: SkillContentSnapshot;
|
|
821
|
+
skillWrite: SkillContentSnapshot;
|
|
822
|
+
skillsFolders: SkillsCatalogSnapshot & {
|
|
823
|
+
folders: string[];
|
|
824
|
+
};
|
|
825
|
+
skillsImport: {
|
|
826
|
+
path: string;
|
|
827
|
+
count: number;
|
|
828
|
+
overwritten: number;
|
|
829
|
+
warning?: string;
|
|
830
|
+
};
|
|
831
|
+
skillCreate: {
|
|
832
|
+
id: string;
|
|
833
|
+
path: string;
|
|
834
|
+
};
|
|
835
|
+
skillDelete: {
|
|
836
|
+
id: string;
|
|
837
|
+
path: string;
|
|
838
|
+
};
|
|
839
|
+
skillsImportDirectory: {
|
|
840
|
+
path: string;
|
|
841
|
+
count: number;
|
|
842
|
+
overwritten: number;
|
|
843
|
+
warning?: string;
|
|
844
|
+
};
|
|
845
|
+
templates: {
|
|
846
|
+
templates?: unknown[];
|
|
847
|
+
toolTemplates?: unknown[];
|
|
848
|
+
};
|
|
849
|
+
promptConfigs: {
|
|
850
|
+
promptConfigs: Array<Record<string, unknown> & PromptConfigSourceView>;
|
|
851
|
+
instructions?: InstructionsSnapshot;
|
|
852
|
+
};
|
|
853
|
+
agentsFile: InstructionFileWriteResult;
|
|
854
|
+
instructionsPolicy: {
|
|
855
|
+
policy: InstructionPolicy;
|
|
856
|
+
revision: string | null;
|
|
857
|
+
exists: boolean;
|
|
858
|
+
error?: string;
|
|
859
|
+
};
|
|
860
|
+
presetContent: Record<string, unknown>;
|
|
861
|
+
importPreset: {
|
|
862
|
+
scopes: Array<'preset' | 'agents'>;
|
|
863
|
+
};
|
|
864
|
+
/** 参数/提示词配置只保存当前预设,不同步宿主全局默认模型。 */
|
|
865
|
+
paramOverrides: {
|
|
866
|
+
overrides?: Record<string, unknown>;
|
|
867
|
+
promptConfigs?: unknown[];
|
|
868
|
+
};
|
|
869
|
+
triggers: {
|
|
870
|
+
triggers: unknown[];
|
|
871
|
+
revision: string;
|
|
872
|
+
meta: TriggerEditorMeta;
|
|
873
|
+
};
|
|
874
|
+
persona: {
|
|
875
|
+
persona: PersonaSpec | null;
|
|
876
|
+
};
|
|
877
|
+
presetVariables: {
|
|
878
|
+
variables: Record<string, string>;
|
|
879
|
+
enabled: boolean;
|
|
880
|
+
};
|
|
881
|
+
customTools: {
|
|
882
|
+
customTools?: unknown[];
|
|
883
|
+
};
|
|
884
|
+
importPresetPackage: {
|
|
885
|
+
id?: string;
|
|
886
|
+
backupPath?: string;
|
|
887
|
+
preview?: boolean;
|
|
888
|
+
state?: ImportPreviewState;
|
|
889
|
+
/** 候选状态下的歧义来源文件显示名(不含绝对路径)。 */
|
|
890
|
+
sourceName?: string;
|
|
891
|
+
candidates?: StOrderGroupCandidate[];
|
|
892
|
+
sourceDigest?: string;
|
|
893
|
+
previewRevision?: string;
|
|
894
|
+
report?: StConversionReport;
|
|
895
|
+
summary?: AssetSummary;
|
|
896
|
+
kinds?: ImportKind[];
|
|
897
|
+
refreshWarning?: string;
|
|
898
|
+
};
|
|
899
|
+
assetUpload: {
|
|
900
|
+
sourceId: string;
|
|
901
|
+
name: string;
|
|
902
|
+
bytes: number;
|
|
903
|
+
};
|
|
904
|
+
assetRelease: {
|
|
905
|
+
released: boolean;
|
|
906
|
+
};
|
|
907
|
+
exportPreset: PresetExportResult;
|
|
908
|
+
presetDelete: {
|
|
909
|
+
id: string;
|
|
910
|
+
};
|
|
911
|
+
presetClone: {
|
|
912
|
+
id: string;
|
|
913
|
+
};
|
|
914
|
+
presetDuplicate: {
|
|
915
|
+
id: string;
|
|
916
|
+
};
|
|
917
|
+
presetOpen: {
|
|
918
|
+
path: string;
|
|
919
|
+
};
|
|
920
|
+
charactersImport: {
|
|
921
|
+
id?: string;
|
|
922
|
+
name?: string;
|
|
923
|
+
preview?: boolean;
|
|
924
|
+
state?: ImportPreviewState;
|
|
925
|
+
candidates?: StOrderGroupCandidate[];
|
|
926
|
+
sourceDigest?: string;
|
|
927
|
+
previewRevision?: string;
|
|
928
|
+
report?: StConversionReport;
|
|
929
|
+
summary?: AssetSummary;
|
|
930
|
+
kinds?: ImportKind[];
|
|
931
|
+
};
|
|
932
|
+
charactersImportStream: {
|
|
933
|
+
id: string;
|
|
934
|
+
name: string;
|
|
935
|
+
};
|
|
936
|
+
charactersList: {
|
|
937
|
+
characters: Array<{
|
|
938
|
+
id: string;
|
|
939
|
+
name: string;
|
|
940
|
+
description?: string;
|
|
941
|
+
hasAvatar: boolean;
|
|
942
|
+
imported: boolean;
|
|
943
|
+
}>;
|
|
944
|
+
};
|
|
945
|
+
charactersDelete: {
|
|
946
|
+
id: string;
|
|
947
|
+
};
|
|
948
|
+
charactersApply: {
|
|
949
|
+
id: string;
|
|
950
|
+
count: number;
|
|
951
|
+
};
|
|
952
|
+
charactersRemove: {
|
|
953
|
+
id: string;
|
|
954
|
+
count: number;
|
|
955
|
+
};
|
|
956
|
+
subagentToolPolicy: {
|
|
957
|
+
policy: unknown;
|
|
958
|
+
defaultProfile?: string;
|
|
959
|
+
errors?: string[];
|
|
960
|
+
};
|
|
961
|
+
subagentToolPolicyPreview: {
|
|
962
|
+
result: unknown;
|
|
963
|
+
errors?: string[];
|
|
964
|
+
};
|
|
965
|
+
toolSurface: {
|
|
966
|
+
source: 'session' | 'preset';
|
|
967
|
+
sessionId?: string;
|
|
968
|
+
presetId?: string;
|
|
969
|
+
tools: Array<{
|
|
970
|
+
name: string;
|
|
971
|
+
description: string;
|
|
972
|
+
}>;
|
|
973
|
+
};
|
|
974
|
+
engineCapability: {
|
|
975
|
+
changed: boolean;
|
|
976
|
+
addedModules?: string[];
|
|
977
|
+
removedModules?: string[];
|
|
978
|
+
capabilityIds: string[];
|
|
979
|
+
};
|
|
980
|
+
/** 只读世界书诊断:只回当前授权会话最近一次选择的观测记录(读取不重新求值)。 */
|
|
981
|
+
worldBookDiagnostics: {
|
|
982
|
+
records: WorldBookDiagnosticRecord[];
|
|
983
|
+
truncated: boolean;
|
|
984
|
+
step: number;
|
|
985
|
+
evaluated: boolean;
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
//#endregion
|
|
989
|
+
//#region src/host/manifest.d.ts
|
|
990
|
+
interface PresetSpec {
|
|
991
|
+
id: string;
|
|
992
|
+
name: string;
|
|
993
|
+
/** 官方预设列表顺序;省略时由宿主排序。 */
|
|
994
|
+
order?: number;
|
|
995
|
+
/** 预设说明(官方用户预设格式元数据;列表展示用,可选)。 */
|
|
996
|
+
description?: string;
|
|
997
|
+
version: string;
|
|
998
|
+
engineCompat: string;
|
|
999
|
+
meta?: Record<string, unknown>;
|
|
1000
|
+
content?: {
|
|
1001
|
+
presetText?: string;
|
|
1002
|
+
agentsText?: string;
|
|
1003
|
+
};
|
|
1004
|
+
/** 模块清单(参数文件决定组合内容):按序装配 source/local 与 library 中的唯一模块。 */
|
|
1005
|
+
modules?: string[];
|
|
1006
|
+
/** 手写组合:内联文本或组合清单名。 */
|
|
1007
|
+
composition?: string;
|
|
1008
|
+
/** 内部运行时平铺适配面;磁盘上的同名段不参与运行参数。 */
|
|
1009
|
+
params?: Record<string, unknown>;
|
|
1010
|
+
/** 共享引擎参数按编辑组的主归属插入点存储;规则实例仍拥有各自 params。 */
|
|
1011
|
+
layerSettings?: Record<string, Record<string, unknown>>;
|
|
1012
|
+
/** 顶层人设段(官方 @deepseek-ai/dsh-persona 行同构):prefix/suffix/complete/includeRuntimeContext。 */
|
|
1013
|
+
persona?: PersonaSpec;
|
|
1014
|
+
/** 预设级模板变量({{key}} 插值源;与 layerSettings 分离,顶层 variables 段)。 */
|
|
1015
|
+
variables?: Record<string, string>;
|
|
1016
|
+
/** 自定义工具定义(tool-config-engine 渲染进 custom-tools/ 后运行时注册)。 */
|
|
1017
|
+
customTools?: unknown[];
|
|
1018
|
+
/** 子代理实例级工具策略(subagentToolPolicy 顶层领域段;缺省 = 官方 delegation 行为)。 */
|
|
1019
|
+
subagentToolPolicy?: Record<string, unknown>;
|
|
1020
|
+
/**
|
|
1021
|
+
* 触发器声明(`triggers` 顶层段):`{ id, channel, when?, do, … }` 的数组。
|
|
1022
|
+
* 声明**由预设提供**(引擎不带默认),物化为 `triggers.yml` 后由 `declared-triggers`
|
|
1023
|
+
* 运行时模块读入并注册;形状与校验归 `engine/trigger-spec.mjs` 的声明编译器。
|
|
1024
|
+
*/
|
|
1025
|
+
triggers?: unknown[];
|
|
1026
|
+
/** 模板变量插值开关(缺省 true = 启用;false = 停用,writePreset 不生成变量文件)。 */
|
|
1027
|
+
variablesEnabled?: boolean;
|
|
1028
|
+
/** 可选:模板自定义提示词配置覆盖(纯数据,不使用模板语法)。 */
|
|
1029
|
+
promptConfigs?: unknown[];
|
|
1030
|
+
/** 可选:引擎组合模块行参数直写(行级 map config 浅合并;参数桥未覆盖的键生效,参数桥优先)。 */
|
|
1031
|
+
moduleConfigs?: Record<string, Record<string, unknown>>;
|
|
1032
|
+
upstream?: Record<string, unknown>;
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* 从预设 preset.yml 的 modules 清单移除一个模块 id(YAML Document 保留注释
|
|
1036
|
+
* 与其余字段)。返回是否发生修改;文件缺失或没有该模块时返回 false。
|
|
1037
|
+
*/
|
|
1038
|
+
declare function removePresetModule(dir: string, moduleId: string): boolean;
|
|
1039
|
+
/** 加载某个预设模板的单一参数文件 preset/<name>/preset.yml。 */
|
|
1040
|
+
declare function loadPresetSpec(dir: string): PresetSpec;
|
|
1041
|
+
/** 预设根:官方 USER_PRESET_DIR(~/.dsh/.agent-presets),导入/新建/种子化的预设都放这里。 */
|
|
1042
|
+
declare function userPresetsDir(): string;
|
|
1043
|
+
/**
|
|
1044
|
+
* 解析预设模板目录:当前预设根优先,包内模板回退;不读取其他部署根的同名预设。
|
|
1045
|
+
* 目录名与声明的 preset.yml id 一致;不扫描其他目录的 id 别名。
|
|
1046
|
+
*/
|
|
1047
|
+
declare function resolvePresetDir(template: string, presetRoot?: string): string;
|
|
1048
|
+
/** 本插件预设清单;所有目录按同一身份与组合源规则列举。 */
|
|
1049
|
+
declare function listPresets(presetRoot?: string): Array<{
|
|
1050
|
+
id: string;
|
|
1051
|
+
name: string;
|
|
1052
|
+
user: boolean;
|
|
1053
|
+
renderable: boolean;
|
|
1054
|
+
description?: string;
|
|
1055
|
+
meta?: Record<string, unknown>;
|
|
1056
|
+
}>;
|
|
1057
|
+
/** 插件目录模板清单(「新建」选择器与首次种子化数据源;不直接出现在预设列表)。 */
|
|
1058
|
+
declare function listBuiltinTemplates(): Array<{
|
|
1059
|
+
id: string;
|
|
1060
|
+
name: string;
|
|
1061
|
+
}>;
|
|
1062
|
+
/** 按包内同名目录补建缺失预设;已有目录的定义、生成物和资源保持原样。 */
|
|
1063
|
+
declare function ensurePresetSeed(root?: string): {
|
|
1064
|
+
created: string[];
|
|
1065
|
+
};
|
|
1066
|
+
/** 从包内同名目录复制预设;autoSuffix=true 时递增目录名并同步定义身份。 */
|
|
1067
|
+
declare function cloneBuiltinPreset(id: string, autoSuffix?: boolean, presetRoot?: string): {
|
|
1068
|
+
ok: true;
|
|
1069
|
+
id: string;
|
|
1070
|
+
} | {
|
|
1071
|
+
ok: false;
|
|
1072
|
+
message: string;
|
|
1073
|
+
};
|
|
1074
|
+
/**
|
|
1075
|
+
* 保存预设参数:写 layerSettings(merge)/ promptConfigs(整体替换)。
|
|
1076
|
+
* parseDocument 保留注释与未知键(preset.yml 模板含大量注释);空值键删除('' / [],
|
|
1077
|
+
* 回落模板/引擎默认;0 与 false 照常写入——语义与函数内注释、docs §3 一致)。
|
|
1078
|
+
*/
|
|
1079
|
+
declare function savePresetParams(presetRoot: string, templateName: string, params: Record<string, unknown> | undefined, promptConfigs: unknown[] | undefined, variables?: Record<string, string>, variablesEnabled?: boolean): void;
|
|
1080
|
+
/**
|
|
1081
|
+
* 保存激活预设的顶层 persona 段(官方 `@deepseek-ai/dsh-persona` 行 config 同构)。
|
|
1082
|
+
* null = 删除该段(回落宿主部署人设);默认值不落键(见 personaRowConfig)。
|
|
1083
|
+
*/
|
|
1084
|
+
declare function savePresetPersona(presetRoot: string, templateName: string, persona: PersonaSpec | null): void;
|
|
1085
|
+
/** 删除具有合法身份的预设目录(预设根/<id>);隐藏备份不经公共接口删除。
|
|
1086
|
+
* 仅作用于预设根(官方 USER_PRESET_DIR),包内置模板天然不受影响;路径越界与非法 id 拒绝。
|
|
1087
|
+
* 删除后宿主 agent-presets 目录列表自然不再出现该预设(官方 roster 即目录列表)。 */
|
|
1088
|
+
declare function removeUserPreset(id: string, presetRoot?: string): {
|
|
1089
|
+
ok: true;
|
|
1090
|
+
} | {
|
|
1091
|
+
ok: false;
|
|
1092
|
+
message: string;
|
|
1093
|
+
};
|
|
1094
|
+
/** 当前 layerSettings 与显式运行参数合并;不从旧磁盘 params 段回退取值。 */
|
|
1095
|
+
declare function resolvePresetParams(spec: PresetSpec, runtime: Record<string, unknown>): Record<string, unknown>;
|
|
1096
|
+
/**
|
|
1097
|
+
* 参数桥:params 扁平键 → 引擎模块行 config 对象(取代旧 __TOKEN__ 文本渲染)。
|
|
1098
|
+
*
|
|
1099
|
+
* 原则:
|
|
1100
|
+
* - 未声明的键不合并(composition 行默认 / 引擎默认生效),与旧"空值删行"语义等价;
|
|
1101
|
+
* - 值类型直达(布尔/数字/数组不再字符串化再解析);
|
|
1102
|
+
* - 合并优先级:参数桥(UI/基础层)> moduleConfigs(模板/ST 行级直写)> 行默认。
|
|
1103
|
+
* 模型路由/委派参数统一扁平键(modelProvider/subagentModelProvider/maxDepth 等),
|
|
1104
|
+
* 与官方 AgentOptions{provider,model} / maxDepth 对齐。
|
|
1105
|
+
*/
|
|
1106
|
+
declare function buildModuleConfigsFromParams(params: Record<string, unknown>, options?: {
|
|
1107
|
+
subagentPolicyEnabled?: boolean;
|
|
1108
|
+
}): Record<string, Record<string, unknown>>;
|
|
1109
|
+
/**
|
|
1110
|
+
* 行级 config 合并:仅支持 map 型 config 浅合并;
|
|
1111
|
+
* 数组型 config(如 delegation 组)按子行 id 嵌套合并;未声明模块原样保留。
|
|
1112
|
+
* 未声明 configs 时返回原文(零开销);parseDocument 往返保留注释。
|
|
1113
|
+
* 本函数是参数桥产物落位组合行的唯一机制(含 delegation 组子行嵌套),不是预设覆盖通道。
|
|
1114
|
+
*/
|
|
1115
|
+
declare function applyModuleConfigs(raw: string, configs: Record<string, Record<string, unknown>> | undefined): string;
|
|
1116
|
+
/**
|
|
1117
|
+
* 解析预设的模块事实,供 UI 卡片存在性和受控创建共用。
|
|
1118
|
+
* 显式模块及当前参数/策略所需的装配是可编辑插件能力;官方组合 row 仅保留为运行事实。
|
|
1119
|
+
*/
|
|
1120
|
+
declare function resolvePresetModuleFacts(spec: PresetSpec, templateDir?: string, editable?: boolean): PresetModuleFacts;
|
|
1121
|
+
type EngineCapabilityCreateRequest = {
|
|
1122
|
+
action: 'create';
|
|
1123
|
+
capabilityId: string;
|
|
1124
|
+
} | {
|
|
1125
|
+
action: 'create-recipe';
|
|
1126
|
+
recipeId: string;
|
|
1127
|
+
};
|
|
1128
|
+
interface EngineCapabilityCreateResult {
|
|
1129
|
+
changed: boolean;
|
|
1130
|
+
addedModules: string[];
|
|
1131
|
+
capabilityIds: string[];
|
|
1132
|
+
}
|
|
1133
|
+
interface EngineCapabilityRemoveResult {
|
|
1134
|
+
changed: boolean;
|
|
1135
|
+
removedModules: string[];
|
|
1136
|
+
capabilityIds: string[];
|
|
1137
|
+
}
|
|
1138
|
+
/** 在内存候选文档中展开能力/recipe,校验成功后一次原子替换 preset.yml。 */
|
|
1139
|
+
declare function createEngineCapabilityInPreset(presetDir: string, request: EngineCapabilityCreateRequest): EngineCapabilityCreateResult;
|
|
1140
|
+
/** 删除能力:模块声明、顶层数据段,以及该能力的**显式参数与行配置**一起移除。
|
|
1141
|
+
* 参数在 ⇒ 装配在(见 impliedModulesFromParams):留下参数会让移除立刻被隐含装配拉回来,
|
|
1142
|
+
* 所以"移除能力"必须是完整移除。未登记参数、其他能力的数据与未知字段一律不动。 */
|
|
1143
|
+
declare function removeEngineCapabilityFromPreset(presetDir: string, capabilityId: string): EngineCapabilityRemoveResult;
|
|
1144
|
+
/**
|
|
1145
|
+
* 预设组合渲染完整链路:模块装配 → 参数桥(moduleConfigs + params)行级合并。
|
|
1146
|
+
* 合并优先级:参数桥(params/UI 基础层) > moduleConfigs(模板/ST 行级直写) > 行默认。
|
|
1147
|
+
* moduleConfigs 仅补充参数桥未覆盖的行级 config(如 ST 导入的 tool-web.fetch),
|
|
1148
|
+
* 不再锁定覆盖 UI 可管理参数(旧作者锁定语义已移除)。
|
|
1149
|
+
*/
|
|
1150
|
+
declare function renderComposition(spec: PresetSpec, runtime: Record<string, unknown>, templateDir?: string): string;
|
|
1151
|
+
//#endregion
|
|
1152
|
+
//#region src/host/sillytavern.d.ts
|
|
1153
|
+
/** ST marker prompts(marker: true):content 不发送给模型(仅标记注入位置,ST
|
|
1154
|
+
* 以运行时内容填充该位置);SPresetSettings 是旧版 ST 的预设设置 dump(正则
|
|
1155
|
+
* 脚本/扩展配置/ToolBindings,动辄数百 KB)。两者转换时整体丢弃并计数进
|
|
1156
|
+
* meta.stDroppedMarkers——防止设置 dump 与位置占位污染 promptConfigs 与注入。 */
|
|
1157
|
+
/** 显式文本求值工具;导入本身仅 prepare,避免执行禁用卡的副作用。 */
|
|
1158
|
+
declare function processStText(text: string, cardName: string, variables: Record<string, string | number>): string;
|
|
1159
|
+
/** 合并多个转换结果为一个预设(角色卡 × 响应预设 → 单预设)。 */
|
|
1160
|
+
declare function mergeStPresets(specs: PresetSpec[]): PresetSpec;
|
|
1161
|
+
/** 转换选项:多 prompt_order 分组时显式选择来源角色,避免照搬「默认任取首组」。 */
|
|
1162
|
+
interface StConversionOptions {
|
|
1163
|
+
characterId?: string;
|
|
1164
|
+
}
|
|
1165
|
+
/** prompt_order 分组候选:预览选组 UI 与实际转换消费同一份事实。 */
|
|
1166
|
+
interface StOrderGroupSummary {
|
|
1167
|
+
characterId: string;
|
|
1168
|
+
entries: number;
|
|
1169
|
+
}
|
|
1170
|
+
/** SillyTavern JSON 预设卡片 → 本项目 PresetSpec(导入端点直接消费)。 */
|
|
1171
|
+
declare function convertStToPreset(card: unknown, baseName: string, options?: StConversionOptions): PresetSpec;
|
|
1172
|
+
/** ST 导入预设 id:必须是官方 agent-presets 可发现的目录名(PRESET_ID =
|
|
1173
|
+
* /^[a-z0-9][a-z0-9-]*$/——含中文的目录会被宿主 discovery 静默跳过,会话
|
|
1174
|
+
* resume 报 preset not found)。文件名 slug 化(去中文);纯中文名退化为
|
|
1175
|
+
* st-<文件名短哈希>(唯一且合法);显示名 name 仍保留中文原名。 */
|
|
1176
|
+
declare function stPresetId(baseName: string): string;
|
|
1177
|
+
//#endregion
|
|
1178
|
+
//#region src/host/import-source.d.ts
|
|
1179
|
+
type PreparedImport = {
|
|
1180
|
+
state: 'ready';
|
|
1181
|
+
kind: ImportKind;
|
|
1182
|
+
spec: PresetSpec;
|
|
1183
|
+
yaml: string;
|
|
1184
|
+
files: AssetFile[];
|
|
1185
|
+
sourceName: string;
|
|
1186
|
+
sourceDigest: string;
|
|
1187
|
+
report?: StConversionReport;
|
|
1188
|
+
avatar?: Buffer;
|
|
1189
|
+
sourceText?: string;
|
|
1190
|
+
} | {
|
|
1191
|
+
state: 'needs-order-selection';
|
|
1192
|
+
candidates: StOrderGroupSummary[];
|
|
1193
|
+
sourceName: string;
|
|
1194
|
+
} | {
|
|
1195
|
+
state: 'needs-kind-selection';
|
|
1196
|
+
kinds: ImportKind[];
|
|
1197
|
+
sourceName: string;
|
|
1198
|
+
};
|
|
1199
|
+
/** 字节集合 → 同一规范化候选;没有目标写入和静默的未知 JSON 回退。 */
|
|
1200
|
+
declare function prepareImport(input: AssetFile[], target: 'preset' | 'character', choices?: ImportChoices): PreparedImport;
|
|
1201
|
+
//#endregion
|
|
1202
|
+
//#region src/host/preset-package.d.ts
|
|
1203
|
+
declare function expandPresetSource(input: AssetFile[]): Promise<AssetFile[]>;
|
|
1204
|
+
type ReadyImport = Extract<ReturnType<typeof prepareImport>, {
|
|
1205
|
+
state: 'ready';
|
|
1206
|
+
}>;
|
|
1207
|
+
declare function presetImportPreview(root: string, files: AssetFile[], request: AssetImportRequest): {
|
|
1208
|
+
prepared: ReadyImport;
|
|
1209
|
+
summary: AssetSummary;
|
|
1210
|
+
sourceDigest: string;
|
|
1211
|
+
previewRevision: string;
|
|
1212
|
+
} | Exclude<ReturnType<typeof prepareImport>, {
|
|
1213
|
+
state: 'ready';
|
|
1214
|
+
}>;
|
|
1215
|
+
declare function installPresetPackage(root: string, files: AssetFile[], request: AssetImportRequest): Promise<{
|
|
1216
|
+
id: string;
|
|
1217
|
+
backupPath?: string;
|
|
1218
|
+
}>;
|
|
1219
|
+
declare function exportPresetPackage(root: string, request: PresetExportRequest): Promise<PresetExportResult>;
|
|
1220
|
+
//#endregion
|
|
1221
|
+
//#region src/host/paths.d.ts
|
|
1222
|
+
/** 用户技能根:官方 `user-dsh` 技能根,也是本插件创建、复制导入与回收站的落点。
|
|
1223
|
+
* 插件不再内置任何技能:包内没有 skills 目录,也不再有安装副本与内容账本。 */
|
|
1224
|
+
declare const USER_SKILLS_DIR: string;
|
|
1225
|
+
/**
|
|
1226
|
+
* 预设根:官方 USER_PRESET_DIR(DSH_HOME/.agent-presets)。
|
|
1227
|
+
* 每个预设一个官方预设目录(agent.cordis.yml 组合本体 + preset.yml 参数),
|
|
1228
|
+
* 宿主 agent-presets 直接可挂载;共享引擎自阶段 2 起由**插件包**提供(组合行写包名说明符),
|
|
1229
|
+
* 不再物化到预设根下。
|
|
1230
|
+
*/
|
|
1231
|
+
declare const DEFAULT_PRESET_DIR: string;
|
|
1232
|
+
//#endregion
|
|
1233
|
+
export { ENGINE_RECIPES as $, resolvePresetParams as A, MAX_CHARACTER_CARD_STREAM_BYTES as B, loadPresetSpec as C, renderComposition as D, removeUserPreset as E, BridgeEndpoint as F, SkillPolicyChange as G, SkillCatalogEntry as H, BridgeErrorPayload as I, SkillsCatalogSnapshot as J, SkillPolicyScope as K, BridgeRequestMap as L, savePresetPersona as M, userPresetsDir as N, resolvePresetDir as O, BRIDGE_ENDPOINTS as P, ENGINE_CAPABILITIES as Q, BridgeValueMap as R, listPresets as S, removePresetModule as T, SkillContentSnapshot as U, SETTINGS_BRIDGE_PREFIX as V, SkillInvocation as W, invocationForScope as X, SkillsState as Y, scopeOfInvocation as Z, buildModuleConfigsFromParams as _, installPresetPackage as a, isEngineCapabilityPresent as at, ensurePresetSeed as b, convertStToPreset as c, ImportChoices as ct, stPresetId as d, InstructionFileSnapshot as dt, EngineCapability as et, EngineCapabilityCreateRequest as f, InstructionFileStatus as ft, applyModuleConfigs as g, PresetSpec as h, exportPresetPackage as i, engineRecipe as it, savePresetParams as j, resolvePresetModuleFacts as k, mergeStPresets as l, INSTRUCTION_FILE_STATUSES as lt, EngineCapabilityRemoveResult as m, USER_SKILLS_DIR as n, PresetModuleFacts as nt, presetImportPreview as o, validateCustomToolIdentities as ot, EngineCapabilityCreateResult as p, MAX_INSTRUCTION_FILE_BYTES as pt, SkillSourceKind as q, expandPresetSource as r, engineCapability as rt, StConversionOptions as s, AssetFile as st, DEFAULT_PRESET_DIR as t, ModuleSourceMode as tt, processStText as u, InstructionContextView as ut, cloneBuiltinPreset as v, removeEngineCapabilityFromPreset as w, listBuiltinTemplates as x, createEngineCapabilityInPreset as y, MAX_BRIDGE_BODY_BYTES as z };
|