dsh-model-switch 0.4.59 → 0.4.61

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.
@@ -0,0 +1,410 @@
1
+ /** Catalog lookup by id. */
2
+ const SOURCE_BY_ID = new Map([
3
+ {
4
+ id: "core",
5
+ kind: "core",
6
+ label: "DSH 核心",
7
+ repo: "https://github.com/deepseek-ai/deepseek-harness"
8
+ },
9
+ {
10
+ id: "dsh-ops",
11
+ kind: "plugin",
12
+ label: "插件 · dsh-ops",
13
+ repo: "https://github.com/T-Auto/dsh-ops"
14
+ },
15
+ {
16
+ id: "dsh-browser-cdp",
17
+ kind: "plugin",
18
+ label: "插件 · dsh-browser-cdp",
19
+ repo: "https://github.com/drscrewdriver/dsh-browser-cdp"
20
+ },
21
+ {
22
+ id: "dsh-auto-memory",
23
+ kind: "plugin",
24
+ label: "插件 · dsh-auto-memory",
25
+ repo: "https://github.com/AskTheWay/dsh-auto-memory"
26
+ },
27
+ {
28
+ id: "dsh-model-switch",
29
+ kind: "plugin",
30
+ label: "插件 · dsh-model-switch",
31
+ repo: "https://github.com/vandoor7-droid/dsh-model-switch"
32
+ },
33
+ {
34
+ id: "dsh-prime-memory",
35
+ kind: "plugin",
36
+ label: "插件 · dsh-prime-memory",
37
+ repo: "https://github.com/drscrewdriver/dsh-prime-memory"
38
+ },
39
+ {
40
+ id: "dsh-embedded-browser",
41
+ kind: "plugin",
42
+ label: "插件 · dsh-embedded-browser",
43
+ repo: "https://github.com/imroc/dsh-embedded-browser"
44
+ },
45
+ {
46
+ id: "mcp:wincu",
47
+ kind: "mcp",
48
+ label: "MCP · wincu(dsh-computer-use-win)",
49
+ repo: "https://github.com/Yu-tao-Li/dsh-computer-use-win"
50
+ },
51
+ {
52
+ id: "qqbot-extension",
53
+ kind: "extension",
54
+ label: "QQ 机器人扩展(框架 @zaofan/dsh-qqbot)",
55
+ repo: "https://github.com/zaofan-make/dsh-qqbot"
56
+ }
57
+ ].map((entry) => [entry.id, entry]));
58
+ /**
59
+ * Tool names the released Host owns, calibrated against dsh 0.2.1-rc.2.
60
+ *
61
+ * A name outside the catalog would otherwise be reported as core, which is the
62
+ * one guess a reader could act on wrongly; it resolves to `unknown` instead.
63
+ */
64
+ const CORE_TOOLS = /* @__PURE__ */ new Set([
65
+ "ask_user_question",
66
+ "conversation_search",
67
+ "create_goal",
68
+ "create_skill",
69
+ "create_worktree",
70
+ "edit",
71
+ "exit_plan_mode",
72
+ "get_goal",
73
+ "glob",
74
+ "grep",
75
+ "interrupt_agent",
76
+ "job_kill",
77
+ "job_list",
78
+ "job_output",
79
+ "list_agents",
80
+ "list_mcp_resource_templates",
81
+ "list_mcp_resources",
82
+ "load_workspace_dependencies",
83
+ "present",
84
+ "pwsh",
85
+ "ralph",
86
+ "read",
87
+ "read_image",
88
+ "read_mcp_resource",
89
+ "schedule_create",
90
+ "schedule_delete",
91
+ "schedule_list",
92
+ "schedule_update",
93
+ "send_message",
94
+ "session_event_read",
95
+ "session_event_search",
96
+ "session_event_trace",
97
+ "session_search",
98
+ "session_trace",
99
+ "sidebar_open",
100
+ "skill",
101
+ "spawn_teammate",
102
+ "subagent",
103
+ "subagent_fork",
104
+ "team_task_create",
105
+ "team_task_get",
106
+ "team_task_list",
107
+ "team_task_update",
108
+ "terminal_close",
109
+ "terminal_list",
110
+ "terminal_open",
111
+ "terminal_read",
112
+ "terminal_send",
113
+ "terminal_signal",
114
+ "todo_write",
115
+ "update_goal",
116
+ "wait_agent",
117
+ "web_fetch",
118
+ "web_search",
119
+ "web_search_pro",
120
+ "workflow",
121
+ "working_directory",
122
+ "write"
123
+ ]);
124
+ /** MCP server name → catalog id, for the servers this allowlist knows. */
125
+ const MCP_SERVERS = /* @__PURE__ */ new Map([["wincu", "mcp:wincu"]]);
126
+ /** Plugin identity by tool-name prefix (checked before the core catalog). */
127
+ const PLUGIN_PREFIXES = [
128
+ ["bcdp_", "dsh-browser-cdp"],
129
+ ["browser_window_", "dsh-browser-cdp"],
130
+ ["browser_embedded_", "dsh-embedded-browser"],
131
+ ["ops_", "dsh-ops"]
132
+ ];
133
+ /**
134
+ * Single plugin tools that carry no usable prefix.
135
+ *
136
+ * `memory_` is shared by two installed plugins with disjoint names, so it cannot
137
+ * be a prefix rule: the calibration below names each tool explicitly.
138
+ */
139
+ const PLUGIN_TOOLS = /* @__PURE__ */ new Map([
140
+ ["generate_image", "dsh-model-switch"],
141
+ ["memory_add", "dsh-prime-memory"],
142
+ ["memory_conflicts", "dsh-prime-memory"],
143
+ ["memory_conflicts_rejected", "dsh-prime-memory"],
144
+ ["memory_delete", "dsh-prime-memory"],
145
+ ["memory_expand_graph_node", "dsh-prime-memory"],
146
+ ["memory_import", "dsh-prime-memory"],
147
+ ["memory_migrate_relation", "dsh-prime-memory"],
148
+ ["memory_read_scene", "dsh-prime-memory"],
149
+ ["memory_receipts", "dsh-prime-memory"],
150
+ ["memory_reproject", "dsh-prime-memory"],
151
+ ["memory_resolve_conflict", "dsh-prime-memory"],
152
+ ["memory_room_admin", "dsh-prime-memory"],
153
+ ["memory_room_review", "dsh-prime-memory"],
154
+ ["memory_ruminate", "dsh-prime-memory"],
155
+ ["memory_ruminate_cancel", "dsh-prime-memory"],
156
+ ["memory_ruminate_status", "dsh-prime-memory"],
157
+ ["memory_search", "dsh-prime-memory"],
158
+ ["memory_search_graph", "dsh-prime-memory"],
159
+ ["memory_skill_archive", "dsh-prime-memory"],
160
+ ["memory_skill_list", "dsh-prime-memory"],
161
+ ["memory_skill_pin", "dsh-prime-memory"],
162
+ ["memory_skill_read", "dsh-prime-memory"],
163
+ ["memory_slot_close", "dsh-prime-memory"],
164
+ ["memory_slot_list", "dsh-prime-memory"],
165
+ ["memory_slot_write", "dsh-prime-memory"],
166
+ ["memory_update", "dsh-prime-memory"],
167
+ ["memory_context", "dsh-auto-memory"],
168
+ ["memory_delete_all", "dsh-auto-memory"],
169
+ ["memory_list", "dsh-auto-memory"],
170
+ ["memory_prune", "dsh-auto-memory"],
171
+ ["memory_read", "dsh-auto-memory"],
172
+ ["memory_write", "dsh-auto-memory"]
173
+ ]);
174
+ /** `<base>__<owner>` — the extension-tool naming the QQ bot framework uses. */
175
+ const EXTENSION_TOOL = /^([A-Za-z0-9_-]+)__(.+)$/;
176
+ /**
177
+ * Default allowlist: every pure-read tool this deployment exposes plus the
178
+ * no-side-effect and autonomy entries the user explicitly released, calibrated
179
+ * on a live desktop profile (105 tools) at dsh 0.2.1-rc.2.
180
+ *
181
+ * Grouped by origin so a reader can trace each entry through {@link SOURCE_CATALOG}.
182
+ * Entries ending in `*` are patterns: the QQ bot extension suffixes its tools with
183
+ * the bot's own name, so `sessions_list__*` keeps working when the persona is
184
+ * renamed.
185
+ *
186
+ * Everything here follows one rule: releasing it must not let a side effect escape
187
+ * the reviewer. Calls that merely dispatch, ask, present, wait or navigate qualify
188
+ * because the work they trigger still runs under the same auto preset. Delegation
189
+ * tools (`subagent`, `subagent_fork`, `spawn_teammate`) deliberately stay out: a
190
+ * child session seeds its preset from `permissionPresets.current(parent.session)`,
191
+ * and this bypass answers `'custom'` for an allowlisted call in flight — releasing
192
+ * them would hand the child no `auto` preset at all, i.e. no review.
193
+ */
194
+ const DEFAULT_READ_ONLY_TOOLS = [
195
+ "read",
196
+ "grep",
197
+ "glob",
198
+ "read_image",
199
+ "skill",
200
+ "web_search",
201
+ "web_search_pro",
202
+ "web_fetch",
203
+ "load_workspace_dependencies",
204
+ "ask_user_question",
205
+ "present",
206
+ "sidebar_open",
207
+ "exit_plan_mode",
208
+ "job_list",
209
+ "job_output",
210
+ "terminal_list",
211
+ "terminal_read",
212
+ "list_agents",
213
+ "team_task_list",
214
+ "team_task_get",
215
+ "get_goal",
216
+ "schedule_list",
217
+ "wait_agent",
218
+ "send_message",
219
+ "team_task_create",
220
+ "list_mcp_resources",
221
+ "list_mcp_resource_templates",
222
+ "read_mcp_resource",
223
+ "session_search",
224
+ "session_event_search",
225
+ "session_event_read",
226
+ "session_event_trace",
227
+ "session_trace",
228
+ "create_goal",
229
+ "schedule_create",
230
+ "terminal_open",
231
+ "ops_read_files",
232
+ "ops_discover_tools",
233
+ "bcdp_status",
234
+ "bcdp_help",
235
+ "bcdp_doctor",
236
+ "bcdp_snapshot",
237
+ "browser_window_status",
238
+ "memory_list",
239
+ "memory_read",
240
+ "memory_search",
241
+ "memory_search_graph",
242
+ "memory_expand_graph_node",
243
+ "memory_read_scene",
244
+ "memory_skill_list",
245
+ "memory_skill_read",
246
+ "memory_slot_list",
247
+ "memory_receipts",
248
+ "memory_conflicts",
249
+ "memory_conflicts_rejected",
250
+ "memory_ruminate_status",
251
+ "ops_glob",
252
+ "ops_grep",
253
+ "ops_inspect_local_file",
254
+ "ops_read_docx",
255
+ "ops_diff",
256
+ "ops_result",
257
+ "bcdp_captcha",
258
+ "bcdp_page_info",
259
+ "bcdp_read_element",
260
+ "bcdp_screenshot",
261
+ "browser_embedded_status",
262
+ "browser_embedded_snapshot",
263
+ "browser_embedded_screenshot",
264
+ "browser_embedded_ask_human",
265
+ "conversation_search",
266
+ "mcp__wincu__windows_computer_use_accessibility_tree",
267
+ "mcp__wincu__windows_computer_use_element_info",
268
+ "mcp__wincu__windows_computer_use_find",
269
+ "mcp__wincu__windows_computer_use_health",
270
+ "mcp__wincu__windows_computer_use_list_windows",
271
+ "mcp__wincu__windows_computer_use_ocr",
272
+ "mcp__wincu__windows_computer_use_screenshot",
273
+ "mcp__wincu__windows_computer_use_snapshot",
274
+ "mcp__wincu__windows_computer_use_tools",
275
+ "mcp__wincu__windows_computer_use_wait",
276
+ "mcp__wincu__windows_computer_use_wait_for",
277
+ "sessions_list__*",
278
+ "bing_search__*"
279
+ ];
280
+ /**
281
+ * Validate one allowlist entry.
282
+ *
283
+ * `*` is a suffix wildcard: the entry must keep at least one literal leading
284
+ * character, so a stray `*` can never turn the list into "allow everything".
285
+ *
286
+ * @param entry - the raw entry as typed in settings.
287
+ * @returns `ok`, or the specific problem.
288
+ */
289
+ function validateAllowEntry(entry) {
290
+ const trimmed = entry.trim();
291
+ if (trimmed === "") return "empty";
292
+ if (/^\*+$/.test(trimmed)) return "bare-wildcard";
293
+ if (trimmed.startsWith("*")) return "leading-wildcard";
294
+ return "ok";
295
+ }
296
+ /**
297
+ * Whether a tool name matches one allowlist entry.
298
+ *
299
+ * Exact names match exactly; an entry may end in `*`, which matches any
300
+ * remaining characters (including none). Invalid entries never match.
301
+ *
302
+ * @param name - the tool name from `exec.name`.
303
+ * @param entry - one allowlist entry.
304
+ * @returns true when the call may skip review.
305
+ */
306
+ function matchesAllowPattern(name, entry) {
307
+ if (name === "" || validateAllowEntry(entry) !== "ok") return false;
308
+ const trimmed = entry.trim();
309
+ const star = trimmed.indexOf("*");
310
+ if (star === -1) return name === trimmed;
311
+ const prefix = trimmed.slice(0, star);
312
+ const suffix = trimmed.slice(star + 1);
313
+ if (!name.startsWith(prefix) || !name.endsWith(suffix)) return false;
314
+ return name.length >= prefix.length + suffix.length;
315
+ }
316
+ /**
317
+ * Whether a tool name is covered by an allowlist.
318
+ * @param name - the tool name under review.
319
+ * @param allowlist - configured entries, patterns included.
320
+ * @returns true when at least one entry matches.
321
+ */
322
+ function isAllowedByList(name, allowlist) {
323
+ return allowlist.some((entry) => matchesAllowPattern(name, entry));
324
+ }
325
+ /**
326
+ * Resolve the origin of one tool name for display.
327
+ *
328
+ * Resolution order: MCP bridge → `<tool>__<owner>` extension → plugin prefix →
329
+ * plugin table → core catalog → unknown. Only the first two are structural; the
330
+ * rest are calibrated names, so an unlisted tool is reported as unknown rather
331
+ * than guessed into a package.
332
+ *
333
+ * @param name - the tool name.
334
+ * @returns The origin, with its repository when known.
335
+ */
336
+ function resolveToolSource(name) {
337
+ const trimmed = name.trim().replace(/\*+$/, "");
338
+ const mcp = /^mcp__([A-Za-z0-9_-]+)__/.exec(trimmed);
339
+ if (mcp !== null) {
340
+ const server = mcp[1];
341
+ const entry = SOURCE_BY_ID.get(MCP_SERVERS.get(server) ?? "");
342
+ if (entry !== void 0) return {
343
+ kind: "mcp",
344
+ label: entry.label,
345
+ repo: entry.repo,
346
+ owner: server
347
+ };
348
+ return {
349
+ kind: "mcp",
350
+ label: `MCP · ${server}`,
351
+ owner: server
352
+ };
353
+ }
354
+ const extension = EXTENSION_TOOL.exec(trimmed);
355
+ if (extension !== null && !trimmed.startsWith("mcp__")) {
356
+ const entry = SOURCE_BY_ID.get("qqbot-extension");
357
+ const base = extension[1];
358
+ const owner = extension[2];
359
+ return {
360
+ kind: "extension",
361
+ label: `扩展 · ${base}__${owner}`,
362
+ ...entry === void 0 ? {} : { repo: entry.repo },
363
+ owner
364
+ };
365
+ }
366
+ if (trimmed.endsWith("__")) {
367
+ const entry = SOURCE_BY_ID.get("qqbot-extension");
368
+ return {
369
+ kind: "extension",
370
+ label: `扩展 · ${trimmed.slice(0, -2)}__*`,
371
+ ...entry === void 0 ? {} : { repo: entry.repo },
372
+ owner: "*"
373
+ };
374
+ }
375
+ for (const [prefix, id] of PLUGIN_PREFIXES) {
376
+ if (!trimmed.startsWith(prefix)) continue;
377
+ const entry = SOURCE_BY_ID.get(id);
378
+ if (entry !== void 0) return {
379
+ kind: "plugin",
380
+ label: entry.label,
381
+ repo: entry.repo,
382
+ owner: id
383
+ };
384
+ }
385
+ const plugin = PLUGIN_TOOLS.get(trimmed);
386
+ if (plugin !== void 0) {
387
+ const entry = SOURCE_BY_ID.get(plugin);
388
+ if (entry !== void 0) return {
389
+ kind: "plugin",
390
+ label: entry.label,
391
+ repo: entry.repo,
392
+ owner: plugin
393
+ };
394
+ }
395
+ if (CORE_TOOLS.has(trimmed)) {
396
+ const entry = SOURCE_BY_ID.get("core");
397
+ return {
398
+ kind: "core",
399
+ label: entry?.label ?? "DSH 核心",
400
+ ...entry === void 0 ? {} : { repo: entry.repo },
401
+ owner: "core"
402
+ };
403
+ }
404
+ return {
405
+ kind: "unknown",
406
+ label: "未知来源"
407
+ };
408
+ }
409
+ //#endregion
410
+ export { isAllowedByList as n, resolveToolSource as r, DEFAULT_READ_ONLY_TOOLS as t };
@@ -86,6 +86,16 @@ export declare function mountWithStartupFallback<T>(candidate: (track: StartupCl
86
86
  export declare function routedRuntimeUnavailableNotice(error: StartupIncompatibilityError): string;
87
87
  /** Profile replacement that selects the routed runtime or the untouched official runtime. */
88
88
  export declare const profileSubagentRuntime: (ctx: Context) => Promise<() => Promise<void>>;
89
+ /**
90
+ * The plugin dependency list for the mounted runtime.
91
+ *
92
+ * Static inheritance does not merge `inject`: cordis reads the static list off
93
+ * the class it mounts, so the subclass must repeat every service the official
94
+ * runtime's own code reads and add the route surface this adapter uses.
95
+ * @param officialInject - the installed runtime's declared dependencies (absent on 0.1.7/0.2.0).
96
+ * @returns The deduplicated list, official dependencies first.
97
+ */
98
+ export declare function subagentRuntimeInject(officialInject: readonly string[] | undefined): string[];
89
99
  /** Official runtime with only a pre-descriptor route-selection adapter. */
90
100
  export declare class ModelSwitchSubagentRuntime extends OfficialSubagentRuntime {
91
101
  static inject: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-model-switch",
3
- "version": "0.4.59",
3
+ "version": "0.4.61",
4
4
  "description": "Explicit model routing plus composer/Plan picker for DeepSeek Harness",
5
5
  "repository": {
6
6
  "type": "git",