dsh-plugin-prompt-tool 2.0.1 → 2.1.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.
Files changed (60) hide show
  1. package/README.md +6 -6
  2. package/engine/actions/catalog.mjs +1 -1
  3. package/engine/actions/inbox-prepend.mjs +1 -2
  4. package/engine/actions/shared.mjs +1 -2
  5. package/engine/branch.mjs +1 -1
  6. package/engine/compositions/source/local/instruction-hint.yml +2 -3
  7. package/engine/conditions/composite.mjs +1 -1
  8. package/engine/conditions/count.mjs +1 -2
  9. package/engine/conditions/phase.mjs +1 -2
  10. package/engine/conditions/subject.mjs +1 -1
  11. package/engine/layers.mjs +3 -4
  12. package/engine/rule-spec.mjs +1 -1
  13. package/engine/shared.mjs +1 -13
  14. package/engine/subagent-tool-policy.mjs +2 -2
  15. package/engine/tool-config-engine.mjs +1 -1
  16. package/engine/trigger-spec.mjs +3 -3
  17. package/engine/trigger.mjs +2 -2
  18. package/lib/index.d.mts +1380 -1
  19. package/lib/index.mjs +33 -3
  20. package/lib/migrate-rules.mjs +572 -1
  21. package/lib/{module-package-CHPFweqK.mjs → module-package-DqJZaE71.mjs} +1 -1
  22. package/lib/{module-package-Cnd1_mwx.mjs → module-package-q2gDRu9H.mjs} +19 -22
  23. package/lib/{rules-migration-DJ6vASB5.mjs → rule-builder-DMrJten6.mjs} +28 -595
  24. package/package.json +4 -2
  25. package/skills/dsh-module/SKILL.md +199 -0
  26. package/skills/dsh-module/reference.md +158 -0
  27. package/templates/61-deny-tools-presentation.yml +27 -0
  28. package/templates/62-guard-deny-tools.yml +20 -0
  29. package/templates/63-append-context.yml +22 -0
  30. package/templates/64-pre-step-filter.yml +23 -0
  31. package/templates/67-inbox-prepend.yml +22 -0
  32. package/templates/80-tool-surface.yml +6 -6
  33. package/engine/compositions/library/agent-instructions.yml +0 -9
  34. package/engine/compositions/library/command-goal.yml +0 -7
  35. package/engine/compositions/library/compaction.yml +0 -22
  36. package/engine/compositions/library/delegation-ptc.yml +0 -58
  37. package/engine/compositions/library/delegation.yml +0 -56
  38. package/engine/compositions/library/persistent-shell.yml +0 -50
  39. package/engine/compositions/library/planning.yml +0 -26
  40. package/engine/compositions/library/skill-filesystem-cordis.yml +0 -10
  41. package/engine/compositions/library/skill-filesystem.yml +0 -7
  42. package/engine/compositions/library/tool-ask-user.yml +0 -7
  43. package/engine/compositions/library/tool-bash.yml +0 -8
  44. package/engine/compositions/library/tool-cordis.yml +0 -7
  45. package/engine/compositions/library/tool-fs-search.yml +0 -9
  46. package/engine/compositions/library/tool-fs.yml +0 -7
  47. package/engine/compositions/library/tool-goal.yml +0 -7
  48. package/engine/compositions/library/tool-jobs.yml +0 -7
  49. package/engine/compositions/library/tool-plugin-manager-disabled.yml +0 -8
  50. package/engine/compositions/library/tool-plugin-manager.yml +0 -8
  51. package/engine/compositions/library/tool-present.yml +0 -7
  52. package/engine/compositions/library/tool-presentation.yml +0 -9
  53. package/engine/compositions/library/tool-pwsh.yml +0 -8
  54. package/engine/compositions/library/tool-skill.yml +0 -7
  55. package/engine/compositions/library/tool-todo.yml +0 -9
  56. package/engine/compositions/library/tool-web.yml +0 -10
  57. package/engine/compositions/source/local/declared-triggers.yml +0 -12
  58. package/lib/paths-CyP0IkaM.d.mts +0 -1390
  59. package/lib/preset-transfer.d.mts +0 -2
  60. package/lib/preset-transfer.mjs +0 -3
package/lib/index.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- import { $ as SkillSourceKind, A as removeUserModule, B as BridgeEndpoint, C as ensureModuleSeed, Ct as moduleCapability, D as moduleDirExists, E as loadModuleSpec, F as saveModuleParams, G as MAX_CHARACTER_CARD_STREAM_BYTES, H as BridgeRequestMap, I as saveModulePersona, J as SkillCatalogEntry, K as ModuleSummary, L as userModulesDir, M as resolveModuleDir, N as resolveModuleFacts, O as removeModuleCapability, P as resolveModuleParams, Q as SkillPolicyScope, R as withModuleDefinition, S as createModuleCapability, St as isModuleCapabilityPresent, T as listModules, U as BridgeValueMap, V as BridgeErrorPayload, W as MAX_BRIDGE_BODY_BYTES, X as SkillInvocation, Y as SkillContentSnapshot, Z as SkillPolicyChange, _ as ModuleSpec, _t as MODULE_CAPABILITIES, a as installModulePackage, at as ImportChoices, b as buildModuleConfigsFromParams, bt as ModuleSourceMode, c as convertStToModule, ct as RuleDefinition, d as mergeStModulesWithReport, dt as InstructionFileSnapshot, et as SkillsCatalogSnapshot, f as processStText, ft as InstructionFileStatus, g as ModuleCapabilityRemoveResult, gt as InjectionPoint, h as ModuleCapabilityCreateResult, ht as INJECTION_POINT_ORDER, i as exportModulePackage, it as AssetFile, j as renderComposition, k as removeModuleCapabilityDeclaration, l as convertStToModuleWithReport, lt as INSTRUCTION_FILE_STATUSES, m as ModuleCapabilityCreateRequest, mt as ENGINE_RECIPES, n as USER_SKILLS_DIR, nt as invocationForScope, o as moduleImportPreview, ot as ModuleExportRequest, p as stModuleId, pt as MAX_INSTRUCTION_FILE_BYTES, q as SETTINGS_BRIDGE_PREFIX, r as expandModuleSource, rt as scopeOfInvocation, s as StConversionOptions, st as ModuleExportResult, tt as SkillsState, u as mergeStModules, ut as InstructionContextView, v as appendModuleCapabilities, vt as ModuleCapability, w as listBuiltinTemplates, wt as validateCustomToolIdentities, x as cloneBuiltinModule, xt as engineRecipe, y as applyModuleConfigs, yt as ModuleFacts, z as BRIDGE_ENDPOINTS } from "./paths-CyP0IkaM.mjs";
2
1
  import { parseDocument } from "yaml";
3
2
  import z from "@deepseek-ai/schemastery";
4
3
  import { ToolExecution } from "@deepseek-ai/dsh-tools";
@@ -28,6 +27,83 @@ interface PromptSettings {
28
27
  modulesEnabled: boolean;
29
28
  }
30
29
  //#endregion
30
+ //#region src/shared/engine-capabilities.d.ts
31
+ type ModuleSourceMode = 'explicit' | 'composition' | 'official' | 'unknown';
32
+ /** 官方九个注入层:与 engine/schema.mjs 的 LAYER_ORDER 同源,改一处必须同步另一处。 */
33
+ type InjectionPoint = 'pre-step' | 'system-section' | 'runtime-context' | 'agent-request' | 'llm-stream' | 'tool-pipeline' | 'turn-stop' | 'subagent-start' | 'subagent-end';
34
+ /** 旧公开类型名只作输入兼容。 */
35
+ /**
36
+ * 九层顺序的共享副本:宿主是旧版本(不下发 meta.layerOrder)时前端退化用它,
37
+ * 而不是各自再写一份层序清单。
38
+ */
39
+ declare const INJECTION_POINT_ORDER: readonly InjectionPoint[];
40
+ interface ModuleFacts {
41
+ declaredModules: string[] | null;
42
+ effectiveModules: string[] | null;
43
+ rowIds: string[];
44
+ sourceMode: ModuleSourceMode;
45
+ editable: boolean;
46
+ effectiveConfigs?: Record<string, Record<string, unknown>>;
47
+ /** 策略段真实存在;能力声明仍在并不代表策略已开启。 */
48
+ subagentToolPolicyEnabled?: boolean;
49
+ }
50
+ interface ModuleCapability {
51
+ id: string;
52
+ moduleKeys: readonly string[];
53
+ rowIds: readonly string[];
54
+ displayLayer: InjectionPoint;
55
+ /** 真实跨层影响的相关层(只在确有第二通道时登记,避免把归属铺满九层)。 */
56
+ relatedLayers?: readonly InjectionPoint[];
57
+ /**
58
+ * 该能力拥有的 preset 顶层数据段(不是行级 config)。
59
+ * 创建时若段缺失则写入 `skeleton`(保证"模块在 ⇒ 数据在");删除时一并移除该段。
60
+ */
61
+ ownSection?: {
62
+ /** preset.yml 顶层键名。 */
63
+ key: string;
64
+ /** 启用时写入的可用骨架(必须能通过该段的校验)。 */
65
+ skeleton: Readonly<Record<string, unknown>>;
66
+ };
67
+ }
68
+ /** 首期只登记已有 typed editor 的能力,避免万能 key/value 表单。 */
69
+ declare const MODULE_CAPABILITIES: readonly ModuleCapability[];
70
+ /**
71
+ * 编辑组 = 前端一张可编辑卡(能力卡或专用卡)的主归属层。
72
+ * id 必须是代码里真实存在的 card / 展开键名,不新增臆造 id。
73
+ */
74
+ interface EngineEditorGroup {
75
+ id: string;
76
+ displayLayer: InjectionPoint;
77
+ /** 真实跨层影响的相关层(只有确有第二通道时才写)。 */
78
+ relatedLayers?: readonly InjectionPoint[];
79
+ /** 真实生效通道的只读说明键(如 'agent-request' / 'system-section'):供 UI 显示「实际生效通道」,
80
+ * 只写代码里可核对的事实,不承诺未验证的通道。 */
81
+ hook: string;
82
+ }
83
+ interface EngineRecipe {
84
+ id: string;
85
+ capabilities: readonly string[];
86
+ initialParams?: Readonly<Record<string, unknown>>;
87
+ }
88
+ /**
89
+ * 只保留已有真实工作流的一键组合;recipe 本身不写入 preset.yml。
90
+ *
91
+ * B7 T3 清空:三条 recipe 的成员都是随本轮退场的专用能力(phase-control /
92
+ * phase-control-ptc / deliberation),没有任何一条还能组成合法能力集合。
93
+ * export 与 `engineRecipe()` 保留——调用点(创建菜单、bridge 校验)不必跟着改,
94
+ * 空表天然让组合项整个消失。
95
+ */
96
+ declare const ENGINE_RECIPES: readonly EngineRecipe[];
97
+ declare function moduleCapability(id: string): ModuleCapability | undefined;
98
+ declare function engineRecipe(id: string): EngineRecipe | undefined;
99
+ /** 显式模块声明中的实际能力;包含当前参数与顶层策略所需的装配。
100
+ * 创建补声明由 host 单独检查 declaredModules;官方组合行不伪装成可编辑能力。 */
101
+ declare function isModuleCapabilityPresent(id: string, facts: ModuleFacts | undefined): boolean;
102
+ /** custom tool 的运行时名称缺省回落 id;保存前拒绝会导致同层注册失败的重复项。 */
103
+ declare function validateCustomToolIdentities(tools: readonly unknown[]): string[];
104
+ /** 已发布名称只在此边界保留,内部使用模块能力与插入点命名。 */
105
+ type EngineLayer = InjectionPoint;
106
+ //#endregion
31
107
  //#region src/shared/legacy-prompt-params.d.ts
32
108
  /** 旧规则快捷参数只用于读取与旧 API 兼容;新编辑器直接保存规则实例。 */
33
109
  declare const LEGACY_PROMPT_PARAM_DEFINITIONS: {
@@ -280,6 +356,91 @@ declare function writeModule(prompt: string, options: WriteModuleOptions): strin
280
356
  /** @deprecated 使用 writeModule;旧字段仅在此边界适配。 */
281
357
  declare function writePreset(prompt: string, options: WritePresetOptions): string;
282
358
  //#endregion
359
+ //#region src/shared/instructions.d.ts
360
+ /**
361
+ * 指令文件(AGENTS.md / CLAUDE.md 等)跨 host/client 的最小契约。
362
+ * 只放两端都要理解的形状:读取快照、工作区上下文与写入结果;
363
+ * 引擎侧的位置/晋升/受众算法不在这里复制。
364
+ */
365
+ /** 文件卡正文读写上限;官方注入的读取与渲染预算由官方配置决定。 */
366
+ declare const MAX_INSTRUCTION_FILE_BYTES: number;
367
+ declare const INSTRUCTION_FILE_STATUSES: readonly ["ready", "missing", "unreadable", "too-large"];
368
+ /**
369
+ * 读取状态:`ready` 之外的任何状态都不代表空正文,也禁止写盘。
370
+ * 读取成功的空文件是 `ready` + `text: ''`,与读取失败严格区分。
371
+ */
372
+ type InstructionFileStatus = (typeof INSTRUCTION_FILE_STATUSES)[number];
373
+ /** 单次读取形成的一致快照:正文、身份、版本来自同一次读取。 */
374
+ interface InstructionFileSnapshot {
375
+ /** 服务端按真实文件身份生成;不是客户端写入授权本身。 */
376
+ fileId: string;
377
+ /** 服务端解析出的绝对路径(客户端不得据此写盘,只是展示与身份)。 */
378
+ path: string;
379
+ /** 展示用路径(DSH_HOME 内 `~/.dsh/…`,项目内相对项目根)。 */
380
+ displayPath: string;
381
+ scope: 'global' | 'project';
382
+ status: InstructionFileStatus;
383
+ /** status === 'ready' 时的原始 UTF-8 正文(可为空串);其他状态为 ''。 */
384
+ text: string;
385
+ /** status === 'ready' 时原始文件字节的 SHA-256;其他状态为 null。 */
386
+ revision: string | null;
387
+ /** 读取失败/超限的诊断信息;ready 时不带。 */
388
+ message?: string;
389
+ }
390
+ /**
391
+ * 本次工作区上下文:优先由存活本地 Agent 的会话 cwd 解析;拿不到会话时回退到
392
+ * 部署进程 cwd(与官方 agent-instructions 的 `session.header.cwd ?? process.cwd()`
393
+ * 同口径),并如实标记来源,让 UI 能辨别两种范围。
394
+ */
395
+ interface InstructionContextView {
396
+ /** 上下文 id(cwd + 文件身份集派生);无可解析本地会话时为 null。 */
397
+ contextId: string | null;
398
+ cwd: string | null;
399
+ /**
400
+ * session = 由存活本地 Agent 的会话 cwd 解析;
401
+ * deploy-cwd = 会话不可用,退回部署进程 cwd(范围提示,不构成写授权);
402
+ * global-only = 客户端尚无服务端解析结果时的空池标记。
403
+ */
404
+ source: 'session' | 'deploy-cwd' | 'global-only';
405
+ }
406
+ interface InstructionsSnapshot {
407
+ context: InstructionContextView;
408
+ files: InstructionFileSnapshot[];
409
+ owner: InstructionsOwnerView;
410
+ }
411
+ /**
412
+ * 指令负责人事实:本会话实际装配里是否仍挂着官方指令加载行。
413
+ * `true` 表示官方负责注入;`false` 表示模块未装配官方来源;`null` 表示尚未观察到。
414
+ */
415
+ interface InstructionsOwnerView {
416
+ officialInstructions: boolean | null;
417
+ }
418
+ /** /agents-file 成功返回值:写盘后的新版本,客户端据此更新基线。 */
419
+ interface InstructionFileWriteResult {
420
+ fileId: string;
421
+ revision: string;
422
+ }
423
+ /**
424
+ * 指令文件卡策略(独立于模块与 settings 的本插件自有状态)。
425
+ *
426
+ * 只承载逐文件开关与展示名;正文、读取版本、会话 ID 和路径不进入策略。
427
+ * 默认放行官方注入,关闭只过滤后续消息,不撤回已持久历史。
428
+ */
429
+ interface InstructionPolicyFileOverride {
430
+ /** 缺省开启;false 拦截该文件后续的官方注入。 */
431
+ enabled?: boolean;
432
+ /** 可选显示名(只影响 UI 标题)。 */
433
+ name?: string;
434
+ }
435
+ interface InstructionPolicy {
436
+ /** 按 fileId 的覆盖;删除覆盖恢复默认放行。 */
437
+ files: Record<string, InstructionPolicyFileOverride>;
438
+ }
439
+ /** 局部更新:只写传入的键;files[fileId] = null 表示删除该覆盖。 */
440
+ interface InstructionPolicyPatch {
441
+ files?: Record<string, InstructionPolicyFileOverride | null>;
442
+ }
443
+ //#endregion
283
444
  //#region src/host/agents-cards.d.ts
284
445
  /** 文件身份(fileId + 路径 + 展示路径):生成卡与读取快照共用的最小形状。 */
285
446
  interface AgentsFileIdentity {
@@ -393,6 +554,937 @@ interface PreStepCoordinatorService {
393
554
  }
394
555
  declare function installPreStepCoordinator(ctx: Context, options?: PreStepCoordinatorOptions): PreStepCoordinatorService;
395
556
  //#endregion
557
+ //#region src/shared/persona-section.d.ts
558
+ /**
559
+ * preset.yml 顶层 `persona` 段契约:与官方 `@deepseek-ai/dsh-persona` 行同构,
560
+ * 由渲染层写入 `deployment:persona-prefix`(order 0)与
561
+ * `deployment:persona-suffix`(order 10200)两段。
562
+ * 旧 params.sectionName 人设写法不做兼容也不迁移(本项目不含迁移代码)。
563
+ */
564
+ /**
565
+ * preset.yml 顶层 `persona` 段:与官方 `@deepseek-ai/dsh-persona` 行的 config 同构。
566
+ * 官方 schema:prefix required、suffix 默认 ''、complete 默认 false、
567
+ * includeRuntimeContext 默认 true。
568
+ */
569
+ interface PersonaSpec {
570
+ /** `deployment:persona-prefix` 文本(第一方指导之前,官方 order 0)。 */
571
+ prefix: string;
572
+ /** `deployment:persona-suffix` 文本(第一方指导之后,官方 order 10200)。 */
573
+ suffix?: string;
574
+ /** prefix 独占整个 system prompt(抑制其余段与 suffix)。 */
575
+ complete?: boolean;
576
+ /** false = 抑制该 scope 的动态 runtime-context 快照。 */
577
+ includeRuntimeContext?: boolean;
578
+ }
579
+ //#endregion
580
+ //#region src/shared/rules.d.ts
581
+ /** 一张独立配置卡的判断树;原语与组合的合法形状由引擎唯一校验。 */
582
+ type RuleCondition = Record<string, unknown>;
583
+ /** 动作拥有稳定身份;其执行点由动作目录推导,不能任意指定宿主事件。 */
584
+ interface RuleAction extends Record<string, unknown> {
585
+ id: string;
586
+ kind: string;
587
+ channelOrder?: number;
588
+ waterfallPosition?: 'default' | 'outermost';
589
+ }
590
+ /**
591
+ * module.yml.rules 的单一规则定义;层用于呈现归属,不建立跨层执行顺序。
592
+ *
593
+ * **旧名 `when`/`do` 已随引擎重构退役**(不再作为兼容输入),全链路只有 `if`/`then`/`else`。
594
+ * 定义迁移由 YAML Document API 改键名完成,注释与未知字段原地保留。
595
+ */
596
+ interface RuleDefinition {
597
+ id: string;
598
+ name?: string;
599
+ enabled?: boolean;
600
+ layer?: EngineLayer;
601
+ group?: string;
602
+ exclusive?: boolean;
603
+ /** 分支条件;缺省 = 无条件。 */
604
+ if?: RuleCondition;
605
+ /** 动作列表。 */
606
+ then: RuleAction[];
607
+ /** `if` 不命中时执行;与 `then` 结构互斥(编译期按 `not(if)` 展开)。 */
608
+ else?: RuleAction[];
609
+ }
610
+ /** 显式旧身份使改名、删除与 configOrder 在同一事务中更新。 */
611
+ interface RuleEdit {
612
+ previousId: string | null;
613
+ rule: RuleDefinition | null;
614
+ /** 正文编辑不拥有启停与互斥状态;修改状态须显式声明并校验 settings 版本。 */
615
+ settingsChanged?: boolean;
616
+ }
617
+ interface RuleRevisions {
618
+ rules: Record<string, string>;
619
+ settings: string;
620
+ variables: string;
621
+ }
622
+ interface RulesRequest {
623
+ expectedModuleId?: string;
624
+ /** 旧公开输入仅在边界归一。 */
625
+ expectedPresetId?: string;
626
+ expectedRevision?: string;
627
+ expectedRevisions?: Partial<RuleRevisions>;
628
+ edits?: RuleEdit[];
629
+ /** 显式启用目标;保存端同时停用同模块互斥组的其他卡。 */
630
+ activateRuleId?: string;
631
+ validateOnly?: boolean;
632
+ /** 只重新发布已提交定义,不能与规则修改或候选校验混用。 */
633
+ refreshOnly?: boolean;
634
+ }
635
+ interface RuleEditorMeta {
636
+ predicates: Array<{
637
+ kind: string;
638
+ example: Record<string, unknown>;
639
+ }>;
640
+ composites: string[];
641
+ actions: Array<{
642
+ kind: string;
643
+ example: Record<string, unknown>;
644
+ channel: string;
645
+ phase: string;
646
+ supportsWhen: boolean;
647
+ lifecycle?: 'event' | 'registration';
648
+ }>;
649
+ waterfallPositions: string[];
650
+ }
651
+ interface RulesSnapshot {
652
+ rules: RuleDefinition[];
653
+ revisions: RuleRevisions;
654
+ /** 仅旧客户端兼容输入,不是规范响应的版本来源。 */
655
+ revision?: string;
656
+ meta: RuleEditorMeta;
657
+ persisted?: boolean;
658
+ publicationPending?: boolean;
659
+ publicationError?: string;
660
+ }
661
+ //#endregion
662
+ //#region src/shared/module-config-order.d.ts
663
+ /** 配置卡身份与排序快照;序号归模块定义,正文不进入排序载荷。 */
664
+ interface ModuleConfigIdentity {
665
+ moduleId: string;
666
+ configId: string;
667
+ }
668
+ interface ModuleConfigOrderEntry extends ModuleConfigIdentity {
669
+ name: string;
670
+ layer: string;
671
+ position: string;
672
+ sequence: number;
673
+ enabled: boolean;
674
+ audience?: 'main' | 'subagent' | null;
675
+ strategy?: string;
676
+ /** 官方文本层的定位档位;其他层不使用。 */
677
+ order?: number;
678
+ }
679
+ interface ModuleConfigOrderSnapshot {
680
+ revision: string;
681
+ entries: ModuleConfigOrderEntry[];
682
+ }
683
+ //#endregion
684
+ //#region src/shared/asset-transfer.d.ts
685
+ /** 资产传输使用显式编码;省略编码仅兼容旧文本请求。 */
686
+ interface AssetFile {
687
+ path: string;
688
+ content: string;
689
+ encoding?: 'utf8' | 'base64';
690
+ }
691
+ type ImportKind = 'native-preset' | 'native-character' | 'st-preset' | 'st-character' | 'world-book';
692
+ interface ImportChoices {
693
+ targetId?: string;
694
+ targetName?: string;
695
+ overwrite?: boolean;
696
+ sourceKind?: ImportKind;
697
+ promptOrderCharacterId?: string;
698
+ }
699
+ interface AssetSummary {
700
+ sourceName: string;
701
+ kind: ImportKind;
702
+ targetId: string;
703
+ targetName: string;
704
+ exists: boolean;
705
+ files: Array<{
706
+ path: string;
707
+ bytes: number;
708
+ }>;
709
+ configCount: number;
710
+ warnings: string[];
711
+ }
712
+ interface AssetImportRequest extends ImportChoices {
713
+ files?: AssetFile[];
714
+ sourceId?: string;
715
+ preview?: boolean;
716
+ expectedSourceDigest?: string;
717
+ expectedPreviewRevision?: string;
718
+ }
719
+ interface ModuleExportRequest {
720
+ id: string;
721
+ mode?: 'definition' | 'zip';
722
+ preview?: boolean;
723
+ expectedRevision?: string;
724
+ memoryChoices?: Record<string, 'include' | 'exclude'>;
725
+ }
726
+ interface ModuleExportResult {
727
+ id: string;
728
+ name: string;
729
+ content: string;
730
+ encoding?: 'utf8' | 'base64';
731
+ filename?: string;
732
+ revision?: string;
733
+ files?: Array<{
734
+ path: string;
735
+ bytes: number;
736
+ }>;
737
+ warnings?: string[];
738
+ blockers?: string[];
739
+ memoryConflicts?: Array<{
740
+ id: string;
741
+ name: string;
742
+ }>;
743
+ excludedMemoryCount?: number;
744
+ }
745
+ //#endregion
746
+ //#region src/shared/managed-config-fields.d.ts
747
+ interface ConfigFieldSources {
748
+ configId: string;
749
+ fields: Array<{
750
+ path: string;
751
+ source: 'preset-param' | 'prompt-config';
752
+ }>;
753
+ }
754
+ //#endregion
755
+ //#region src/shared/official-orders.d.ts
756
+ /** 一个已求值的区段:`from` / `to` 是该组首末档位的**官方**数值。 */
757
+ interface OfficialOrderSegment {
758
+ readonly id: string;
759
+ readonly from: number;
760
+ readonly to: number;
761
+ }
762
+ /** 下发形状:两层各自一组区段。 */
763
+ interface OfficialOrdersView {
764
+ readonly sections: readonly OfficialOrderSegment[];
765
+ readonly contexts: readonly OfficialOrderSegment[];
766
+ }
767
+ //#endregion
768
+ //#region src/shared/skills.d.ts
769
+ interface SkillContentSnapshot {
770
+ /** Markdown 正文,不含 YAML frontmatter 与分隔线。 */
771
+ content: string;
772
+ description: string;
773
+ /** 当前原始内容的 SHA-256;只用于冲突检查,不保存历史版本。 */
774
+ revision: string;
775
+ }
776
+ /** 官方技能根分类;数值越小越优先,与官方 rank 一致。 */
777
+ type SkillSourceKind = 'project-dsh' | 'project-agents' | 'custom' | 'user-dsh' | 'user-agents' | 'bundled' | 'other';
778
+ /** 两个官方调用策略键:值就是「该端是否可调用」。 */
779
+ interface SkillInvocation {
780
+ /** `disable-model-invocation`:false 时模型不可发现、不可加载。 */
781
+ modelInvocable: boolean;
782
+ /** `user-invocable`:false 时用户斜杠命令不可加载。 */
783
+ userInvocable: boolean;
784
+ }
785
+ /** 两端调用策略的目标范围:'model' = 只让模型端不可调用,'user' = 只让用户端不可调用,
786
+ * 'all' = 两端都不可调用,'none' = 两端都恢复可调用。语义是「点击之后的目标状态」。 */
787
+ type SkillPolicyScope = 'none' | 'model' | 'user' | 'all';
788
+ /** 单端操作不携带另一端的旧快照;显式 scope 供两端批量操作和 TUI 使用。 */
789
+ type SkillPolicyChange = {
790
+ side: 'model' | 'user';
791
+ enabled: boolean;
792
+ } | {
793
+ scope: SkillPolicyScope;
794
+ };
795
+ interface SkillsCatalogSnapshot {
796
+ skills: SkillCatalogEntry[];
797
+ /** false 表示观测不完整,不能把未发现解释成不存在。 */
798
+ complete: boolean;
799
+ }
800
+ /** 目标范围 → 两个键的写入意图(true = 该端可调用)。 */
801
+ declare function invocationForScope(scope: SkillPolicyScope): SkillInvocation;
802
+ /** 当前两端状态 → 范围(两端都可调用时为 'none')。 */
803
+ declare function scopeOfInvocation(invocation: SkillInvocation): SkillPolicyScope;
804
+ /** 插件技能状态:只剩用户显式引用的技能文件夹(绝对路径,按引用顺序)。
805
+ * 技能是否可调用由技能文件自己声明,不再进状态文件。 */
806
+ interface SkillsState {
807
+ version: number;
808
+ folders: string[];
809
+ }
810
+ /** 清单条目:由插件扫描六类官方技能根得到,是管理面的事实来源。 */
811
+ interface SkillCatalogEntry {
812
+ /** 稳定键:来源类别 + 来源根 + 目录名。 */
813
+ id: string;
814
+ /** frontmatter name(缺失时回退目录名)。 */
815
+ name: string;
816
+ description: string;
817
+ /** 技能目录名(一层扫描,与官方发现规则一致)。 */
818
+ folder: string;
819
+ /** 来源根的绝对路径。 */
820
+ dir: string;
821
+ source: SkillSourceKind;
822
+ /** 来源优先级(越小越优先)。 */
823
+ rank: number;
824
+ valid: boolean;
825
+ issue?: string;
826
+ /** frontmatter 声明的模型端调用策略(唯一事实,缺省为可调用)。 */
827
+ modelInvocable: boolean;
828
+ /** frontmatter 声明的用户端调用策略(唯一事实,缺省为可调用)。 */
829
+ userInvocable: boolean;
830
+ /** 同名技能中的胜出者 id;本项未胜出时用于提示"被同名技能遮蔽"。 */
831
+ winnerId?: string;
832
+ /** 标记文件绝对路径(调用策略的写入目标与身份校验依据)。 */
833
+ path?: string;
834
+ /** 同名遮蔽事实:只有注册表确实报了同名技能时才标注;其余条目按文件声明为事实。 */
835
+ availability?: 'active' | 'shadowed';
836
+ provider?: string;
837
+ canSetPolicy?: boolean;
838
+ /** 普通本地资产可编辑描述和正文;缺描述可修复,损坏的 frontmatter 拒绝读取。 */
839
+ canEdit?: boolean;
840
+ canDelete?: boolean;
841
+ readonlyReason?: string;
842
+ }
843
+ //#endregion
844
+ //#region src/shared/bridge-contract.d.ts
845
+ declare const SETTINGS_BRIDGE_PREFIX = "/api/prompt-tool/settings";
846
+ /** JSON bridge 的统一内存缓冲上限;超过后改用原始文件流端点。 */
847
+ declare const MAX_BRIDGE_BODY_BYTES: number;
848
+ /** 角色卡原始文件流上限;独立于 JSON bridge,避免 base64 膨胀。 */
849
+ declare const MAX_CHARACTER_CARD_STREAM_BYTES: number;
850
+ /** 桥端点路径(相对前缀)。新增端点必须同时登记到契约测试。 */
851
+ declare const BRIDGE_ENDPOINTS: {
852
+ readonly meta: "/meta";
853
+ readonly bootstrap: "/bootstrap";
854
+ readonly describe: "/describe";
855
+ readonly models: "/models";
856
+ readonly modelReasoning: "/model-reasoning";
857
+ readonly mutate: "/mutate";
858
+ readonly skillsList: "/skills-list";
859
+ readonly skillPolicy: "/skill-policy";
860
+ readonly skillRead: "/skill-read";
861
+ readonly skillWrite: "/skill-write";
862
+ readonly skillsFolders: "/skills-folders";
863
+ readonly skillsImport: "/skills-import";
864
+ readonly skillsImportDirectory: "/skills-import-directory";
865
+ readonly skillCreate: "/skill-create";
866
+ readonly skillDelete: "/skill-delete";
867
+ readonly templates: "/templates";
868
+ readonly promptConfigs: "/prompt-configs";
869
+ readonly agentsFile: "/agents-file";
870
+ readonly instructionsPolicy: "/instructions-policy";
871
+ readonly moduleContent: "/module-content";
872
+ readonly importPreset: "/import-preset";
873
+ readonly paramOverrides: "/param-overrides";
874
+ readonly triggers: "/triggers";
875
+ readonly rules: "/rules";
876
+ readonly persona: "/persona";
877
+ readonly moduleVariables: "/module-variables";
878
+ readonly customTools: "/custom-tools";
879
+ readonly importModulePackage: "/import-module-package";
880
+ readonly assetUpload: "/asset-upload";
881
+ readonly assetRelease: "/asset-release";
882
+ readonly exportModule: "/export-module";
883
+ readonly moduleDelete: "/module-delete";
884
+ readonly moduleClone: "/module-clone";
885
+ readonly moduleDuplicate: "/module-duplicate";
886
+ readonly moduleOpen: "/module-open";
887
+ readonly moduleEnable: "/module-enable";
888
+ readonly moduleConfigOrder: "/module-config-order";
889
+ readonly charactersImport: "/characters-import";
890
+ readonly charactersImportStream: "/characters-import-stream";
891
+ readonly moduleMerge: "/module-merge";
892
+ readonly moduleUnmerge: "/module-unmerge";
893
+ readonly subagentToolPolicy: "/subagent-tool-policy";
894
+ readonly subagentToolPolicyPreview: "/subagent-tool-policy-preview";
895
+ readonly toolSurface: "/tool-surface";
896
+ readonly moduleCapability: "/module-capability";
897
+ readonly worldBookDiagnostics: "/world-book-diagnostics";
898
+ };
899
+ type BridgeEndpoint = (typeof BRIDGE_ENDPOINTS)[keyof typeof BRIDGE_ENDPOINTS];
900
+ /** 失败载荷:两端共用。 */
901
+ type BridgeErrorPayload = {
902
+ ok: false;
903
+ code?: string;
904
+ message?: string;
905
+ conflicts?: string[];
906
+ };
907
+ /** 插件可编辑模块的身份与展示元数据;不可渲染的项保留身份供用户修复。 */
908
+ interface ModuleSummary {
909
+ id: string;
910
+ name: string;
911
+ user?: boolean;
912
+ renderable?: boolean;
913
+ description?: string;
914
+ meta?: Record<string, unknown>;
915
+ broken?: string;
916
+ /** 是否在存储根 `config.yml` 的启用表里(启用即参与运行时装配)。 */
917
+ enabled?: boolean;
918
+ }
919
+ /**
920
+ * 端点级请求体契约(body 形状;无请求体端点 = undefined)。
921
+ * 与 BRIDGE_ENDPOINTS 一一对应:新增端点必须同时补请求/响应映射,否则编译期断言失败。
922
+ * 载荷仍统一走 { ok, value } 包装(见 BridgeResult),这里收敛每端的 value 具体形状。
923
+ */
924
+ interface BridgeRequestMap {
925
+ meta: undefined;
926
+ /** 可选 sessionId:服务端据此解析该本地 Agent 的工作区,返回对应指令文件快照。 */
927
+ bootstrap: {
928
+ sessionId?: string;
929
+ } | undefined;
930
+ describe: undefined;
931
+ /** 省略 body 或 `refresh: true`(显式刷新越过 10 分钟目录 TTL)。 */
932
+ models: {
933
+ refresh?: boolean;
934
+ } | undefined;
935
+ modelReasoning: {
936
+ provider: string;
937
+ model: string;
938
+ };
939
+ mutate: {
940
+ ops: unknown[];
941
+ expectedRevision?: number;
942
+ };
943
+ /** 技能清单:按会话工作区扫描官方六类技能根,调用策略取自各技能文件的 frontmatter。 */
944
+ skillsList: {
945
+ sessionId?: string;
946
+ } | undefined;
947
+ /** 调用策略开关:改写该技能 SKILL.md frontmatter 的官方两个键(正文不动);
948
+ * path 必须命中服务端当次扫描的同名条目,否则按陈旧界面拒绝。 */
949
+ skillPolicy: {
950
+ name: string;
951
+ path: string;
952
+ sessionId?: string;
953
+ } & SkillPolicyChange;
954
+ /** 技能描述、Markdown 正文和完整原文摘要;重新扫描同名同路径身份。 */
955
+ skillRead: {
956
+ name: string;
957
+ path: string;
958
+ sessionId?: string;
959
+ };
960
+ /** 仅保存描述与正文,保持其余 frontmatter,并用完整原文摘要拒绝并发覆盖。 */
961
+ skillWrite: {
962
+ name: string;
963
+ path: string;
964
+ sessionId?: string;
965
+ content: string;
966
+ description: string;
967
+ expectedRevision: string;
968
+ };
969
+ /** 添加 / 移除引用的技能文件夹(只记状态,不复制文件)。 */
970
+ skillsFolders: {
971
+ folders: string[];
972
+ sessionId?: string;
973
+ };
974
+ /** overwrite 仅包含用户已确认覆盖的技能目录名;缺省时遇到同名返回冲突且不写盘。 */
975
+ skillsImport: {
976
+ files: Array<{
977
+ path: string;
978
+ content: string;
979
+ }>;
980
+ overwrite?: string[];
981
+ };
982
+ skillsImportDirectory: {
983
+ path: string;
984
+ overwrite?: string[];
985
+ };
986
+ skillCreate: {
987
+ name: string;
988
+ description: string;
989
+ content: string;
990
+ };
991
+ skillDelete: {
992
+ name: string;
993
+ path: string;
994
+ sessionId?: string;
995
+ };
996
+ templates: undefined;
997
+ /** 可选 sessionId:与 /bootstrap 同源解析当前工作区(单读与聚合读取必须一致)。 */
998
+ promptConfigs: {
999
+ sessionId?: string;
1000
+ } | undefined;
1001
+ /**
1002
+ * 单文件写盘:fileId/contextId 必须命中服务端当次解析的白名单;
1003
+ * expectedRevision 是客户端已读取的字节版本(乐观并发控制,服务端重读校验)。
1004
+ */
1005
+ agentsFile: {
1006
+ sessionId?: string;
1007
+ contextId: string;
1008
+ fileId: string;
1009
+ expectedRevision: string | null;
1010
+ content: string;
1011
+ };
1012
+ /**
1013
+ * 指令文件卡策略(独立存储,默认禁用):省略 `policy` = 读取;
1014
+ * 写入必须带读取时的 `expectedRevision`(文件缺失为 null)。
1015
+ */
1016
+ /** 逐文件启停/名称;无 policy 时读取,写入仍校验原始字节版本。 */
1017
+ instructionsPolicy: {
1018
+ policy?: InstructionPolicyPatch;
1019
+ expectedRevision?: string | null;
1020
+ } | undefined;
1021
+ moduleContent: undefined;
1022
+ importPreset: {
1023
+ contents: Array<{
1024
+ scope: 'preset' | 'agents';
1025
+ content: string;
1026
+ }>;
1027
+ expectedModuleId?: string;
1028
+ };
1029
+ paramOverrides: {
1030
+ overrides?: Record<string, unknown>;
1031
+ promptConfigs?: unknown[];
1032
+ rebuild?: boolean;
1033
+ expectedModuleId?: string;
1034
+ };
1035
+ triggers: {
1036
+ expectedModuleId: string;
1037
+ triggers?: unknown[];
1038
+ expectedRevision?: string;
1039
+ validateOnly?: boolean;
1040
+ };
1041
+ rules: RulesRequest;
1042
+ /** 顶层 persona 段读写(官方 @deepseek-ai/dsh-persona 行 config 同构);省略 persona 键 = 读取。 */
1043
+ persona: {
1044
+ persona?: PersonaSpec | null;
1045
+ expectedModuleId?: string;
1046
+ } | undefined;
1047
+ moduleVariables: {
1048
+ variables?: Record<string, string>;
1049
+ enabled?: boolean;
1050
+ expectedModuleId?: string;
1051
+ expectedRevisions?: Partial<RuleRevisions>;
1052
+ refreshOnly?: boolean;
1053
+ };
1054
+ customTools: {
1055
+ customTools?: unknown[];
1056
+ expectedModuleId?: string;
1057
+ } | undefined;
1058
+ /**
1059
+ * 模块包导入(原生/ST/PNG/ZIP)。`preview: true` 只转换并返回报告,不写目标;
1060
+ * 提交必须携带 expectedSourceDigest 和 expectedPreviewRevision,服务端重算并拒绝过期预览。
1061
+ * `expectedPreviewRevision` 是预览返回的版本凭据:绑定文件、实际选组、转换器版本与
1062
+ * 目标身份(含目标当前内容),服务端提交时重算,不符返回 409 且零写盘。
1063
+ * `promptOrderCharacterId` 用于多顺序组包时显式选择:预览缺省时先返回候选
1064
+ * (`state: 'needs-order-selection'`),提交时仍无法明确对应则拒绝。
1065
+ * 上述参数只接受声明的类型,其它类型一律 400(见 docs/SillyTavern.md)。
1066
+ */
1067
+ importModulePackage: AssetImportRequest;
1068
+ assetUpload: undefined;
1069
+ assetRelease: {
1070
+ sourceId: string;
1071
+ };
1072
+ exportModule: ModuleExportRequest;
1073
+ moduleDelete: {
1074
+ id: string;
1075
+ };
1076
+ moduleClone: {
1077
+ id: string;
1078
+ autoSuffix?: boolean;
1079
+ };
1080
+ moduleDuplicate: {
1081
+ id: string;
1082
+ };
1083
+ moduleOpen: {
1084
+ id: string;
1085
+ };
1086
+ moduleEnable: {
1087
+ id: string;
1088
+ enabled: boolean;
1089
+ };
1090
+ moduleConfigOrder: {
1091
+ moduleId: string;
1092
+ } | {
1093
+ moduleId?: string;
1094
+ entries: ModuleConfigIdentity[];
1095
+ expectedRevision: string;
1096
+ } | undefined;
1097
+ /** 角色卡来源导入为普通模块;预览只读,提交与模块安装共用版本边界。 */
1098
+ charactersImport: AssetImportRequest;
1099
+ charactersImportStream: undefined;
1100
+ moduleMerge: {
1101
+ id: string;
1102
+ };
1103
+ moduleUnmerge: {
1104
+ id: string;
1105
+ };
1106
+ subagentToolPolicy: {
1107
+ policy?: unknown;
1108
+ expectedModuleId?: string;
1109
+ } | undefined;
1110
+ subagentToolPolicyPreview: {
1111
+ tool?: string;
1112
+ description?: string;
1113
+ prompt?: string;
1114
+ tool_profile?: string;
1115
+ character_id?: string;
1116
+ task_type?: string;
1117
+ additional_tools?: string[];
1118
+ restrict_tools?: string[];
1119
+ };
1120
+ toolSurface: {
1121
+ sessionId: string;
1122
+ presetId?: never;
1123
+ } | {
1124
+ presetId: string;
1125
+ sessionId?: never;
1126
+ };
1127
+ moduleCapability: ({
1128
+ action: 'create' | 'remove';
1129
+ capabilityId: string;
1130
+ } | {
1131
+ action: 'create-recipe';
1132
+ recipeId: string;
1133
+ }) & {
1134
+ expectedModuleId?: string;
1135
+ };
1136
+ /** 只读世界书诊断:只回当前授权会话最近一次选择的观测记录。 */
1137
+ worldBookDiagnostics: {
1138
+ sessionId?: string;
1139
+ } | undefined;
1140
+ }
1141
+ /** settings descriptor 的跨端最小结构。 */
1142
+ interface BridgeSettingsView {
1143
+ ns: string;
1144
+ value: unknown;
1145
+ base?: unknown;
1146
+ revision: number;
1147
+ }
1148
+ /**
1149
+ * 一条 provider/model 路由的推理档位元数据(官方模型元数据的展示子集)。
1150
+ *
1151
+ * `known` 区分「查过且该路由不提供档位」与「尚未取得元数据」:前者 UI 必须隐藏档位
1152
+ * 选择而不是拿固定列表伪造能力;后者只是还没查到,不能据此判断模型没有推理能力。
1153
+ * 目录/元数据只作展示,不是授权白名单——查询失败不影响保存任意模型 id。
1154
+ */
1155
+ interface ModelReasoningView {
1156
+ known: boolean;
1157
+ efforts: Array<{
1158
+ id: string;
1159
+ name: string;
1160
+ description?: string;
1161
+ }>;
1162
+ defaultEffort?: string;
1163
+ }
1164
+ /**
1165
+ * SillyTavern 转换报告(ST-03):host 在真实转换路径上生成的**只读派生元数据**。
1166
+ * 不落盘进 preset.yml、不进入模型上下文,也不是写入凭证——提交仍以本次上传文件重算的
1167
+ * `sourceDigest` 为准;预览返回的摘要不能替代后端对目标/类型/大小的既有校验。
1168
+ */
1169
+ type StConversionClass = 'equivalent' | 'degraded' | 'unsupported' | 'excluded';
1170
+ interface StConversionEntryReport {
1171
+ /** 来源条目身份:上传文件显示名内的原 identifier/uid(不含绝对路径)。 */
1172
+ sourceId: string;
1173
+ /** 来源在文件内的序号(prompts 数组下标或世界书 entries 序号)。 */
1174
+ sourceIndex: number;
1175
+ /** 生成的目标配置 id(被排除的条目没有目标)。多文件合并后重写为**最终** id。 */
1176
+ targetId?: string;
1177
+ /** 同源生成的 promptConfigs 下标:合并重命名时用它把 targetId 关联到最终配置。 */
1178
+ targetIndex?: number;
1179
+ /** 来源显示名(多文件合并时用于区分条目来自哪个上传文件)。 */
1180
+ sourceName?: string;
1181
+ /** 来源在本次合并中的序号(0 起)。 */
1182
+ sourceFileIndex?: number;
1183
+ layer?: string;
1184
+ order?: number;
1185
+ role?: string;
1186
+ position?: string;
1187
+ classification: StConversionClass;
1188
+ /** 稳定原因码(如 depth-collapsed / system-role-downgrade / marker-dropped)。 */
1189
+ codes: string[];
1190
+ }
1191
+ interface StConversionDiagnostic {
1192
+ code: string;
1193
+ severity: 'warning' | 'info';
1194
+ message: string;
1195
+ /** 源身份定位:来源条目 id(与 targetId 分开表达,不混用同一字段)。 */
1196
+ entryId?: string;
1197
+ /** 目标身份定位:生成/合并后的最终配置 id(源条目被排除时缺省)。 */
1198
+ targetId?: string;
1199
+ field?: string;
1200
+ }
1201
+ interface StConversionReport {
1202
+ /** 转换器版本:解释本次生成使用了哪一版语义。 */
1203
+ converter: string;
1204
+ /** 来源显示名(上传文件名,不含绝对路径)。 */
1205
+ sourceName: string;
1206
+ /** prompt_order 分组;`selected` 标记本次实际采用的组。 */
1207
+ orderGroups: Array<{
1208
+ characterId: string;
1209
+ selected: boolean;
1210
+ entries: number;
1211
+ }>;
1212
+ entries: StConversionEntryReport[];
1213
+ diagnostics: StConversionDiagnostic[];
1214
+ summary: {
1215
+ /** 来源条目总数(prompts + 世界书条目 + 角色卡正文段)。 */
1216
+ inputs: number;
1217
+ /** 生成的 promptConfigs 数量。 */
1218
+ converted: number;
1219
+ /** 生成但被禁用的条目数。 */
1220
+ disabled: number;
1221
+ excluded: number;
1222
+ unsupported: number;
1223
+ degraded: number;
1224
+ /** 需要用户确认的诊断数(warning 级)。 */
1225
+ needsReview: number;
1226
+ };
1227
+ /** 记录超出上限时为 true:只截断展示,不影响转换结果。 */
1228
+ truncated?: boolean;
1229
+ }
1230
+ /** 世界书入选/落选诊断记录(只读派生数据,由引擎真实求值路径产生)。 */
1231
+ interface WorldBookDiagnosticRecord {
1232
+ /** 配置 id(`lore-<来源条目>`)。 */
1233
+ id: string;
1234
+ stage: 'excluded' | 'rejected' | 'candidate' | 'selected' | 'committed';
1235
+ /** 稳定原因码:disabled / delay / cooldown / recursion / primary-miss / secondary-miss /
1236
+ * probability / group-lost / group-occupied / match-error / sticky / constant / key-match /
1237
+ * ungrouped / group-winner / injected。 */
1238
+ reason: string;
1239
+ [key: string]: unknown;
1240
+ }
1241
+ /** 顺序组候选:多 prompt_order 组需要用户先选择时的有界选项(不含转换结果)。 */
1242
+ interface StOrderGroupCandidate {
1243
+ characterId: string;
1244
+ entries: number;
1245
+ }
1246
+ /** 导入预览状态:`ready` 才有报告与写入凭据;候选状态不得启用确认。 */
1247
+ type ImportPreviewState = 'ready' | 'needs-order-selection' | 'needs-kind-selection';
1248
+ /** 引擎实际消费的实例参数;只下发可序列化约束,未知扩展键仍由原配置保留。 */
1249
+ interface LayerParamContract {
1250
+ type: 'string' | 'boolean' | 'object' | 'enum';
1251
+ values?: readonly string[];
1252
+ }
1253
+ /** 声明编辑目录由引擎提供;示例同时经过声明编译器验证。 */
1254
+ interface TriggerEditorMeta {
1255
+ predicates: Array<{
1256
+ kind: string;
1257
+ example: Record<string, unknown>;
1258
+ }>;
1259
+ actions: Array<{
1260
+ kind: string;
1261
+ example: Record<string, unknown>;
1262
+ channel: string;
1263
+ phase: string;
1264
+ supportsWhen: boolean;
1265
+ }>;
1266
+ composites: string[];
1267
+ waterfallPositions: string[];
1268
+ }
1269
+ interface LayerContract {
1270
+ strategies: readonly string[];
1271
+ subjects: readonly string[];
1272
+ content: 'text' | 'request' | 'stream' | 'tool-result' | 'subagent-result';
1273
+ variables: boolean;
1274
+ messageMetadata: boolean;
1275
+ params: Readonly<Record<string, LayerParamContract>>;
1276
+ }
1277
+ /**
1278
+ * /meta 与 /bootstrap 的 meta 段下发的层契约:九层顺序 + 编辑组主归属。
1279
+ * 只含可序列化白名单字段(组 id / displayLayer / relatedLayers / hook):
1280
+ * 不含路径、行级配置、校验函数或服务实例 —— 展示归属不扩大写权限。
1281
+ * 插件与内置引擎同步发布,这些字段由当前 bridge 完整下发。
1282
+ */
1283
+ interface EngineMetaLayerContract {
1284
+ /** 九层固定顺序(引擎 LAYER_ORDER,host 不另写一份)。 */
1285
+ layerOrder: readonly EngineLayer[];
1286
+ /** 编辑组主归属总表(能力组 id = 能力 id);前端据此组织九层卡片。 */
1287
+ editorGroups: readonly EngineEditorGroup[];
1288
+ /** 每层真实可编辑的行为契约,来自独立可分发的 engine/schema.mjs。 */
1289
+ layerContracts: Record<EngineLayer, LayerContract>;
1290
+ }
1291
+ /** 物化配置的只读来源;与配置一同读回,不能作为写入字段或授权。 */
1292
+ interface PromptConfigSourceView {
1293
+ fieldSources?: ConfigFieldSources;
1294
+ /** 只读排序投影;不能作为客户端提供的写盘序号。 */
1295
+ sequence?: number;
1296
+ }
1297
+ /** 端点级响应 value 契约(value 字段形状;扩展字段仍以 value 旁可选字段出现)。 */
1298
+ interface BridgeValueMap {
1299
+ /**
1300
+ * `/meta` 与 `/bootstrap` 的 meta 段:层契约 + 官方装配刻度。
1301
+ * `officialOrders` 缺席表示服务降级或官方档位名不匹配,消费方必须退化(不渲染刻度)。
1302
+ */
1303
+ meta: {
1304
+ meta: Record<string, unknown> & EngineMetaLayerContract & {
1305
+ officialOrders?: OfficialOrdersView;
1306
+ };
1307
+ };
1308
+ bootstrap: BridgeSettingsView;
1309
+ describe: BridgeSettingsView;
1310
+ models: {
1311
+ modelCatalog: Record<string, string[]>;
1312
+ };
1313
+ modelReasoning: {
1314
+ reasoning: ModelReasoningView;
1315
+ };
1316
+ mutate: BridgeSettingsView;
1317
+ /** 技能清单 + 引用目录 + 技能根(客户端据此渲染来源分组与调用策略)。 */
1318
+ skillsList: SkillsCatalogSnapshot & {
1319
+ folders: string[];
1320
+ roots: string[];
1321
+ };
1322
+ skillPolicy: SkillsCatalogSnapshot;
1323
+ skillRead: SkillContentSnapshot;
1324
+ skillWrite: SkillContentSnapshot;
1325
+ skillsFolders: SkillsCatalogSnapshot & {
1326
+ folders: string[];
1327
+ };
1328
+ skillsImport: {
1329
+ path: string;
1330
+ count: number;
1331
+ overwritten: number;
1332
+ warning?: string;
1333
+ };
1334
+ skillCreate: {
1335
+ id: string;
1336
+ path: string;
1337
+ };
1338
+ skillDelete: {
1339
+ id: string;
1340
+ path: string;
1341
+ };
1342
+ skillsImportDirectory: {
1343
+ path: string;
1344
+ count: number;
1345
+ overwritten: number;
1346
+ warning?: string;
1347
+ };
1348
+ templates: {
1349
+ templates?: unknown[];
1350
+ toolTemplates?: unknown[];
1351
+ };
1352
+ promptConfigs: {
1353
+ promptConfigs: Array<Record<string, unknown> & PromptConfigSourceView>;
1354
+ instructions?: InstructionsSnapshot;
1355
+ };
1356
+ agentsFile: InstructionFileWriteResult;
1357
+ instructionsPolicy: {
1358
+ policy: InstructionPolicy;
1359
+ revision: string | null;
1360
+ exists: boolean;
1361
+ error?: string;
1362
+ };
1363
+ moduleContent: Record<string, unknown>;
1364
+ importPreset: {
1365
+ scopes: Array<'preset' | 'agents'>;
1366
+ };
1367
+ /** 参数/提示词配置只保存当前模块,不同步宿主全局默认模型。 */
1368
+ paramOverrides: {
1369
+ overrides?: Record<string, unknown>;
1370
+ promptConfigs?: unknown[];
1371
+ };
1372
+ triggers: {
1373
+ triggers: unknown[];
1374
+ revision: string;
1375
+ meta: TriggerEditorMeta;
1376
+ };
1377
+ rules: RulesSnapshot;
1378
+ persona: {
1379
+ persona: PersonaSpec | null;
1380
+ };
1381
+ moduleVariables: {
1382
+ variables: Record<string, string>;
1383
+ enabled: boolean;
1384
+ revisions: RuleRevisions;
1385
+ persisted?: boolean;
1386
+ publicationPending?: boolean;
1387
+ publicationError?: string;
1388
+ };
1389
+ customTools: {
1390
+ customTools?: unknown[];
1391
+ };
1392
+ importModulePackage: {
1393
+ id?: string;
1394
+ backupPath?: string;
1395
+ preview?: boolean;
1396
+ state?: ImportPreviewState;
1397
+ /** 候选状态下的歧义来源文件显示名(不含绝对路径)。 */
1398
+ sourceName?: string;
1399
+ candidates?: StOrderGroupCandidate[];
1400
+ sourceDigest?: string;
1401
+ previewRevision?: string;
1402
+ report?: StConversionReport;
1403
+ summary?: AssetSummary;
1404
+ kinds?: ImportKind[];
1405
+ };
1406
+ assetUpload: {
1407
+ sourceId: string;
1408
+ name: string;
1409
+ bytes: number;
1410
+ };
1411
+ assetRelease: {
1412
+ released: boolean;
1413
+ };
1414
+ exportModule: ModuleExportResult;
1415
+ moduleDelete: {
1416
+ id: string;
1417
+ };
1418
+ moduleClone: {
1419
+ id: string;
1420
+ };
1421
+ moduleDuplicate: {
1422
+ id: string;
1423
+ };
1424
+ moduleOpen: {
1425
+ path: string;
1426
+ };
1427
+ moduleEnable: {
1428
+ enabled: string[];
1429
+ };
1430
+ moduleConfigOrder: ModuleConfigOrderSnapshot;
1431
+ charactersImport: {
1432
+ id?: string;
1433
+ name?: string;
1434
+ preview?: boolean;
1435
+ state?: ImportPreviewState;
1436
+ candidates?: StOrderGroupCandidate[];
1437
+ sourceDigest?: string;
1438
+ previewRevision?: string;
1439
+ report?: StConversionReport;
1440
+ summary?: AssetSummary;
1441
+ kinds?: ImportKind[];
1442
+ };
1443
+ charactersImportStream: {
1444
+ id: string;
1445
+ name: string;
1446
+ };
1447
+ moduleMerge: {
1448
+ id: string;
1449
+ count: number;
1450
+ };
1451
+ moduleUnmerge: {
1452
+ id: string;
1453
+ count: number;
1454
+ };
1455
+ subagentToolPolicy: {
1456
+ policy: unknown;
1457
+ defaultProfile?: string;
1458
+ errors?: string[];
1459
+ };
1460
+ subagentToolPolicyPreview: {
1461
+ result: unknown;
1462
+ errors?: string[];
1463
+ };
1464
+ toolSurface: {
1465
+ source: 'session' | 'preset';
1466
+ sessionId?: string;
1467
+ presetId?: string;
1468
+ tools: Array<{
1469
+ name: string;
1470
+ description: string;
1471
+ }>;
1472
+ };
1473
+ moduleCapability: {
1474
+ changed: boolean;
1475
+ addedModules?: string[];
1476
+ removedModules?: string[];
1477
+ capabilityIds: string[];
1478
+ };
1479
+ /** 只读世界书诊断:只回当前授权会话最近一次选择的观测记录(读取不重新求值)。 */
1480
+ worldBookDiagnostics: {
1481
+ records: WorldBookDiagnosticRecord[];
1482
+ truncated: boolean;
1483
+ step: number;
1484
+ evaluated: boolean;
1485
+ };
1486
+ }
1487
+ //#endregion
396
1488
  //#region src/runtime/models.d.ts
397
1489
  /**
398
1490
  * 官方子代理 seam 的类型锚点:本插件只读 `list()` / `getProvider()` 并显式传参,
@@ -547,6 +1639,243 @@ declare class ModuleLayerSettingsError extends Error {
547
1639
  /** 仅消费当前 layerSettings;其余段作为未知字段留存,不投影为运行时参数。 */
548
1640
  declare function readModuleLayerSettings(source: unknown): Record<string, unknown>;
549
1641
  //#endregion
1642
+ //#region src/host/module-storage.d.ts
1643
+ interface ModuleDefinitionSnapshot {
1644
+ dir: string;
1645
+ file: string;
1646
+ text: string;
1647
+ doc: ReturnType<typeof parseDocument>;
1648
+ source: Record<string, unknown>;
1649
+ revision: string;
1650
+ revisions: RuleRevisions;
1651
+ rules: RuleDefinition[];
1652
+ configOrder: Record<string, number>;
1653
+ variables: Record<string, string>;
1654
+ variablesEnabled: boolean;
1655
+ }
1656
+ declare function withModuleDefinition$1(directory: string, mutate: (doc: ReturnType<typeof parseDocument>, source: Record<string, unknown>) => void): ModuleDefinitionSnapshot;
1657
+ //#endregion
1658
+ //#region src/host/manifest.d.ts
1659
+ /**
1660
+ * 模块目录确实存在于本插件存储根(身份判定与官方登记状态无关)。
1661
+ *
1662
+ * 启用表过滤、工具写入目标、TUI 目标共用这一条判据:本插件管理的模块 = 存储根里含
1663
+ * `module.yml` 的目录,与「宿主有没有把它登记成官方预设」是两回事。
1664
+ */
1665
+ declare function moduleDirExists(root: string, id: string): boolean;
1666
+ interface ModuleSpec {
1667
+ id: string;
1668
+ name: string;
1669
+ /** 官方预设列表顺序;省略时由宿主排序。 */
1670
+ order?: number;
1671
+ /** 预设说明(官方用户预设格式元数据;列表展示用,可选)。 */
1672
+ description?: string;
1673
+ version: string;
1674
+ engineCompat: string;
1675
+ meta?: Record<string, unknown>;
1676
+ content?: {
1677
+ presetText?: string;
1678
+ agentsText?: string;
1679
+ };
1680
+ /** 模块清单(参数文件决定组合内容):按序装配 source/local 与 library 中的唯一模块。 */
1681
+ modules?: string[];
1682
+ /** 手写组合:内联文本或组合清单名。 */
1683
+ composition?: string;
1684
+ /** 内部运行时平铺适配面;磁盘上的同名段不参与运行参数。 */
1685
+ params?: Record<string, unknown>;
1686
+ /** 共享引擎参数按编辑组的主归属插入点存储;规则实例仍拥有各自 params。 */
1687
+ layerSettings?: Record<string, Record<string, unknown>>;
1688
+ /** 顶层人设段(官方 @deepseek-ai/dsh-persona 行同构):prefix/suffix/complete/includeRuntimeContext。 */
1689
+ persona?: PersonaSpec;
1690
+ /** 模块级模板变量({{key}} 插值源;与 layerSettings 分离,顶层 variables 段)。 */
1691
+ variables?: Record<string, string>;
1692
+ /** 自定义工具定义(tool-config-engine 渲染进 custom-tools/ 后运行时注册)。 */
1693
+ customTools?: unknown[];
1694
+ /** 子代理实例级工具策略(subagentToolPolicy 顶层领域段;缺省 = 官方 delegation 行为)。 */
1695
+ subagentToolPolicy?: Record<string, unknown>;
1696
+ /** @deprecated 仅标记旧导入形状;loadModuleSpec 拒绝,须先离线迁移。 */
1697
+ triggers?: unknown[];
1698
+ /** 模板变量插值开关(缺省 true = 启用;false = 停用,writePreset 不生成变量文件)。 */
1699
+ variablesEnabled?: boolean;
1700
+ /** @deprecated 仅标记旧导入形状;loadModuleSpec 拒绝,须先离线迁移。 */
1701
+ promptConfigs?: unknown[];
1702
+ /** 配置卡的持久文件序号;跨模块UI排序只改此轻量元数据。 */
1703
+ configOrder?: Record<string, number>;
1704
+ /** 模块唯一的条件→动作定义;旧源只供离线迁移器读取。 */
1705
+ rules?: RuleDefinition[];
1706
+ /** 可选:引擎组合模块行参数直写(行级 map config 浅合并;参数桥未覆盖的键生效,参数桥优先)。 */
1707
+ moduleConfigs?: Record<string, Record<string, unknown>>;
1708
+ upstream?: Record<string, unknown>;
1709
+ }
1710
+ /**
1711
+ * 从模块 module.yml 的 modules 清单移除一个模块 id(YAML Document 保留注释
1712
+ * 与其余字段)。返回是否发生修改;文件缺失或没有该模块时返回 false。
1713
+ */
1714
+ declare function removeModuleCapabilityDeclaration(dir: string, moduleId: string): boolean;
1715
+ /** 加载某个模块模板的单一参数文件 modules/<name>/module.yml。 */
1716
+ declare function loadModuleSpec(dir: string): ModuleSpec;
1717
+ /** 模块根:本插件的存储根(~/.dsh/.prompt-tool),导入/新建/种子化的模块都放这里。 */
1718
+ declare function userModulesDir(): string;
1719
+ /**
1720
+ * 解析模块模板目录:当前模块根优先,包内模板回退;不读取其他部署根的同名模块。
1721
+ * 目录名与声明的 module.yml id 一致;不扫描其他目录的 id 别名。
1722
+ */
1723
+ declare function resolveModuleDir(template: string, moduleRoot?: string): string;
1724
+ /** 本插件模块清单;所有目录按同一身份与组合源规则列举。 */
1725
+ declare function listModules(moduleRoot?: string): Array<{
1726
+ id: string;
1727
+ name: string;
1728
+ user: boolean;
1729
+ renderable: boolean;
1730
+ description?: string;
1731
+ meta?: Record<string, unknown>;
1732
+ }>;
1733
+ /** 插件目录模板清单(「新建」选择器与首次种子化数据源;不直接出现在模块列表)。 */
1734
+ declare function listBuiltinTemplates(): Array<{
1735
+ id: string;
1736
+ name: string;
1737
+ }>;
1738
+ /** 按包内同名目录补建缺失的内置模块;已有目录的定义、生成物和资源保持原样。 */
1739
+ declare function ensureModuleSeed(root?: string): {
1740
+ created: string[];
1741
+ };
1742
+ /** 从包内同名目录复制模块;autoSuffix=true 时递增目录名并同步定义身份。 */
1743
+ declare function cloneBuiltinModule(id: string, autoSuffix?: boolean, moduleRoot?: string): {
1744
+ ok: true;
1745
+ id: string;
1746
+ } | {
1747
+ ok: false;
1748
+ message: string;
1749
+ };
1750
+ /**
1751
+ * 保存部署能力参数与模板变量;规则写入只走 module-rules 的版本事务。
1752
+ * parseDocument 保留注释与未知键(module.yml 模板含大量注释);空值键删除('' / [],
1753
+ * 回落模板/引擎默认;0 与 false 照常写入——语义与函数内注释、docs §3 一致)。
1754
+ */
1755
+ declare function saveModuleParams(moduleRoot: string, templateName: string, params: Record<string, unknown> | undefined, promptConfigs: unknown[] | undefined, variables?: Record<string, string>, variablesEnabled?: boolean, expectedRevisions?: Partial<RuleRevisions>): void;
1756
+ /**
1757
+ * 保存激活模块的顶层 persona 段(官方 `@deepseek-ai/dsh-persona` 行 config 同构)。
1758
+ * null = 删除该段(回落宿主部署人设);默认值不落键(见 personaRowConfig)。
1759
+ */
1760
+ declare function saveModulePersona(moduleRoot: string, templateName: string, persona: PersonaSpec | null): void;
1761
+ /** 模块文件读-改-写(parseDocument 保留注释与未知键;mutate 内 setIn/deleteIn)。
1762
+ * 角色卡库(characters)与世界书工具(world-book-tools)共用此入口,避免
1763
+ * 各自实现 parseDocument 往返。写盘走原子替换,失败保留旧文件。 */
1764
+ declare function withModuleDefinition(moduleDir: string, mutate: (doc: ReturnType<typeof parseDocument>, source: Record<string, unknown>) => void): ReturnType<typeof withModuleDefinition$1>;
1765
+ /** 向 module.yml 的 modules 追加功能模块;空数组保持按需装配语义。 */
1766
+ declare function appendModuleCapabilities(doc: ReturnType<typeof parseDocument>, additions: readonly string[]): void;
1767
+ /** 删除具有合法身份的模块目录(模块根/<id>);隐藏备份不经公共接口删除。
1768
+ * 仅作用于插件自有模块根,包内置模板不受影响;路径越界与非法 id 拒绝。
1769
+ * 模块不在宿主预设注册表里,删除后无需撤销官方登记;调用方按需重建当前模块。 */
1770
+ declare function removeUserModule(id: string, moduleRoot?: string): {
1771
+ ok: true;
1772
+ } | {
1773
+ ok: false;
1774
+ message: string;
1775
+ };
1776
+ /** 当前 layerSettings 与显式运行参数合并;不从旧磁盘 params 段回退取值。 */
1777
+ declare function resolveModuleParams(spec: ModuleSpec, runtime: Record<string, unknown>): Record<string, unknown>;
1778
+ /**
1779
+ * 参数桥:params 扁平键 → 引擎模块行 config 对象(取代旧 __TOKEN__ 文本渲染)。
1780
+ *
1781
+ * 原则:
1782
+ * - 未声明的键不合并(composition 行默认 / 引擎默认生效),与旧"空值删行"语义等价;
1783
+ * - 值类型直达(布尔/数字/数组不再字符串化再解析);
1784
+ * - 合并优先级:参数桥(UI/基础层)> moduleConfigs(模板/ST 行级直写)> 行默认。
1785
+ * 模型路由/委派参数统一扁平键(modelProvider/subagentModelProvider/maxDepth 等),
1786
+ * 与官方 AgentOptions{provider,model} / maxDepth 对齐。
1787
+ */
1788
+ declare function buildModuleConfigsFromParams(params: Record<string, unknown>, options?: {
1789
+ subagentPolicyEnabled?: boolean;
1790
+ }): Record<string, Record<string, unknown>>;
1791
+ /**
1792
+ * 行级 config 合并:仅支持 map 型 config 浅合并;
1793
+ * 数组型 config(如 delegation 组)按子行 id 嵌套合并;未声明模块原样保留。
1794
+ * 未声明 configs 时返回原文(零开销);parseDocument 往返保留注释。
1795
+ * 本函数是参数桥产物落位组合行的唯一机制(含 delegation 组子行嵌套),不是模块覆盖通道。
1796
+ */
1797
+ declare function applyModuleConfigs(raw: string, configs: Record<string, Record<string, unknown>> | undefined): string;
1798
+ /**
1799
+ * 解析模块的模块事实,供 UI 卡片存在性和受控创建共用。
1800
+ * 显式模块及当前参数/策略所需的装配是可编辑插件能力;官方组合 row 仅保留为运行事实。
1801
+ */
1802
+ declare function resolveModuleFacts(spec: ModuleSpec, templateDir?: string, editable?: boolean): ModuleFacts;
1803
+ type ModuleCapabilityCreateRequest = {
1804
+ action: 'create';
1805
+ capabilityId: string;
1806
+ } | {
1807
+ action: 'create-recipe';
1808
+ recipeId: string;
1809
+ };
1810
+ interface ModuleCapabilityCreateResult {
1811
+ changed: boolean;
1812
+ addedModules: string[];
1813
+ capabilityIds: string[];
1814
+ }
1815
+ interface ModuleCapabilityRemoveResult {
1816
+ changed: boolean;
1817
+ removedModules: string[];
1818
+ capabilityIds: string[];
1819
+ }
1820
+ /** 在内存候选文档中展开能力/recipe,校验成功后一次原子替换 module.yml。 */
1821
+ declare function createModuleCapability(moduleDir: string, request: ModuleCapabilityCreateRequest): ModuleCapabilityCreateResult;
1822
+ /** 删除能力:模块声明、顶层数据段,以及该能力的**显式参数与行配置**一起移除。
1823
+ * 参数在 ⇒ 装配在(见 impliedModulesFromParams):留下参数会让移除立刻被隐含装配拉回来,
1824
+ * 所以"移除能力"必须是完整移除。未登记参数、其他能力的数据与未知字段一律不动。 */
1825
+ declare function removeModuleCapability(moduleDir: string, capabilityId: string): ModuleCapabilityRemoveResult;
1826
+ /**
1827
+ * 模块组合渲染完整链路:模块装配 → 参数桥(moduleConfigs + params)行级合并。
1828
+ * 合并优先级:参数桥(params/UI 基础层) > moduleConfigs(模板/ST 行级直写) > 行默认。
1829
+ * moduleConfigs 仅补充参数桥未覆盖的行级 config(如 ST 导入的 tool-web.fetch),
1830
+ * 不再锁定覆盖 UI 可管理参数(旧作者锁定语义已移除)。
1831
+ */
1832
+ declare function renderComposition(spec: ModuleSpec, runtime: Record<string, unknown>, templateDir?: string): string;
1833
+ //#endregion
1834
+ //#region src/host/sillytavern.d.ts
1835
+ /** ST marker prompts(marker: true):content 不发送给模型(仅标记注入位置,ST
1836
+ * 以运行时内容填充该位置);SPresetSettings 是旧版 ST 的预设设置 dump(正则
1837
+ * 脚本/扩展配置/ToolBindings,动辄数百 KB)。两者转换时整体丢弃并计数进
1838
+ * meta.stDroppedMarkers——防止设置 dump 与位置占位污染 promptConfigs 与注入。 */
1839
+ /** 显式文本求值工具;导入本身仅 prepare,避免执行禁用卡的副作用。 */
1840
+ declare function processStText(text: string, cardName: string, variables: Record<string, string | number>): string;
1841
+ /** 合并后的最终 id 映射:来源索引 → 该来源 promptConfigs 下标 → 合并后的配置 id。 */
1842
+ type MergeIdMap = Map<number, Map<number, string>>;
1843
+ /**
1844
+ * 合并多个转换结果为一个预设,并返回「来源 + 生成配置下标 → 最终 id」的同一份映射。
1845
+ *
1846
+ * 报告必须消费这份映射,而不是按后缀规则另行推测:后缀分配只发生在这里一次。
1847
+ */
1848
+ declare function mergeStModulesWithReport(specs: ModuleSpec[]): {
1849
+ spec: ModuleSpec;
1850
+ idMap: MergeIdMap;
1851
+ };
1852
+ /** 合并多个转换结果为一个预设(角色卡 × 响应预设 → 单预设)。 */
1853
+ declare function mergeStModules(specs: ModuleSpec[]): ModuleSpec;
1854
+ /** 转换选项:多 prompt_order 分组时显式选择来源角色,避免照搬「默认任取首组」。 */
1855
+ interface StConversionOptions {
1856
+ characterId?: string;
1857
+ }
1858
+ /** prompt_order 分组候选:预览选组 UI 与实际转换消费同一份事实。 */
1859
+ interface StOrderGroupSummary {
1860
+ characterId: string;
1861
+ entries: number;
1862
+ }
1863
+ /** SillyTavern JSON 预设卡片 → 本项目 ModuleSpec(导入端点直接消费)。 */
1864
+ declare function convertStToModule(card: unknown, baseName: string, options?: StConversionOptions): ModuleSpec;
1865
+ /**
1866
+ * 同源转换 + 结构化报告:预览与实际提交共用这一个纯函数实现,
1867
+ * 报告只是派生元数据(不进 module.yml、不作写入凭证)。
1868
+ */
1869
+ declare function convertStToModuleWithReport(card: unknown, baseName: string, options?: StConversionOptions): {
1870
+ spec: ModuleSpec;
1871
+ report: StConversionReport;
1872
+ };
1873
+ /** ST 导入预设 id:必须是官方 agent-presets 可发现的目录名(PRESET_ID =
1874
+ * /^[a-z0-9][a-z0-9-]*$/——含中文的目录会被宿主 discovery 静默跳过,会话
1875
+ * resume 报 preset not found)。文件名 slug 化(去中文);纯中文名退化为
1876
+ * st-<文件名短哈希>(唯一且合法);显示名 name 仍保留中文原名。 */
1877
+ declare function stModuleId(baseName: string): string;
1878
+ //#endregion
550
1879
  //#region src/host/worldbook.d.ts
551
1880
  type WorldBookEntry = Record<string, unknown>;
552
1881
  /** buildWorldBookEntry 输入(两通道共用:ST 导入转换与模型 world_book_upsert 工具)。 */
@@ -581,6 +1910,51 @@ declare function upsertWorldBookEntry(moduleDir: string, entry: WorldBookEntry):
581
1910
  /** 删除一条世界书条目;不存在抛错。返回删除后条目总数。 */
582
1911
  declare function deleteWorldBookEntry(moduleDir: string, id: string): number;
583
1912
  //#endregion
1913
+ //#region src/host/import-source.d.ts
1914
+ type PreparedImport = {
1915
+ state: 'ready';
1916
+ kind: ImportKind;
1917
+ spec: ModuleSpec;
1918
+ yaml: string;
1919
+ files: AssetFile[];
1920
+ sourceName: string;
1921
+ sourceDigest: string;
1922
+ report?: StConversionReport;
1923
+ avatar?: Buffer;
1924
+ sourceText?: string;
1925
+ } | {
1926
+ state: 'needs-order-selection';
1927
+ candidates: StOrderGroupSummary[];
1928
+ sourceName: string;
1929
+ } | {
1930
+ state: 'needs-kind-selection';
1931
+ kinds: ImportKind[];
1932
+ sourceName: string;
1933
+ };
1934
+ /** 字节集合 → 同一规范化候选;没有目标写入和静默的未知 JSON 回退。 */
1935
+ declare function prepareImport(input: AssetFile[], target: 'preset' | 'character', choices?: ImportChoices): PreparedImport;
1936
+ //#endregion
1937
+ //#region src/host/module-package.d.ts
1938
+ declare function expandModuleSource(input: AssetFile[]): Promise<AssetFile[]>;
1939
+ type ReadyImport = Extract<ReturnType<typeof prepareImport>, {
1940
+ state: 'ready';
1941
+ }>;
1942
+ declare function moduleImportPreview(root: string, files: AssetFile[], request: AssetImportRequest): {
1943
+ prepared: ReadyImport;
1944
+ summary: AssetSummary;
1945
+ sourceDigest: string;
1946
+ previewRevision: string;
1947
+ } | Exclude<ReturnType<typeof prepareImport>, {
1948
+ state: 'ready';
1949
+ }>;
1950
+ declare function installModulePackage(root: string, files: AssetFile[], request: AssetImportRequest, options?: {
1951
+ preserveAssets?: boolean;
1952
+ }): Promise<{
1953
+ id: string;
1954
+ backupPath?: string;
1955
+ }>;
1956
+ declare function exportModulePackage(root: string, request: ModuleExportRequest): Promise<ModuleExportResult>;
1957
+ //#endregion
584
1958
  //#region src/web-surface.d.ts
585
1959
  /** 从 loader 根 Include 的 baseUrl 推导 profile 目录。 */
586
1960
  declare function resolveProfileDir(ctx: Context): string | undefined;
@@ -591,6 +1965,11 @@ declare function ensureWebSurface(ctx: Context, warn: (message: string) => void)
591
1965
  */
592
1966
  declare function scheduleWebSurfaceRepair(ctx: Context, warn: (message: string) => void): void;
593
1967
  //#endregion
1968
+ //#region src/host/paths.d.ts
1969
+ /** 用户技能根:官方 `user-dsh` 技能根,也是本插件创建、复制导入、回收站与内置技能种子化的落点。
1970
+ * 内置技能按「只补缺失」补建(见 `ensureSkillSeed`):已有目录的正文、资源与调用策略保持原样。 */
1971
+ declare const USER_SKILLS_DIR: string;
1972
+ //#endregion
594
1973
  //#region src/host/skills-import.d.ts
595
1974
  interface SkillsImportFile {
596
1975
  path?: unknown;