dsh-desktop-enhance 0.3.0 → 0.3.2
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 +17 -7
- package/lib/client.js +2532 -589
- package/lib/index.d.ts +56 -3
- package/lib/index.js +1315 -110
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Schema from "@deepseek-ai/schemastery";
|
|
2
|
+
import * as nodeInspector from "node:inspector";
|
|
2
3
|
const ESCAPE_SEQUENCES = /\x1b\[[0-?]*[ -/]*[@-~]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[@-Z\\-_]/g;
|
|
3
4
|
const TAG_CHARACTERS = /[\u{E0000}-\u{E007F}]/u;
|
|
4
5
|
const UNSEEN_CHARACTERS = /[\p{Cc}\p{Cf}\p{Cn}\p{Co}\p{Cs}\p{Variation_Selector}\u115f\u1160\u3164\uffa0]/gu;
|
|
@@ -95,6 +96,7 @@ const SUGGEST_MODELS_ROUTE = "/api/desktop-enhance/suggest-models";
|
|
|
95
96
|
const SUGGEST_EFFORTS_ROUTE = "/api/desktop-enhance/suggest-efforts";
|
|
96
97
|
const SESSION_INFO_ROUTE = "/api/desktop-enhance/session-info";
|
|
97
98
|
const TOOLS_ROUTE = "/api/desktop-enhance/tools";
|
|
99
|
+
const SKILLS_ROUTE = "/api/desktop-enhance/skills";
|
|
98
100
|
//#endregion
|
|
99
101
|
//#region src/suggest/host.ts
|
|
100
102
|
const SUGGEST_PATH = SUGGEST_ROUTE;
|
|
@@ -158,7 +160,7 @@ function knownNamesOf(messages) {
|
|
|
158
160
|
return found ? names : null;
|
|
159
161
|
}
|
|
160
162
|
async function handleSuggest(ctx, request, timeoutMs = MODEL_TIMEOUT_MS) {
|
|
161
|
-
const empty = () => json
|
|
163
|
+
const empty = () => json({ items: [] });
|
|
162
164
|
let sessionId;
|
|
163
165
|
let preference = FOLLOW_SESSION;
|
|
164
166
|
try {
|
|
@@ -170,9 +172,9 @@ async function handleSuggest(ctx, request, timeoutMs = MODEL_TIMEOUT_MS) {
|
|
|
170
172
|
prompt: typeof body.prompt === "string" ? body.prompt : ""
|
|
171
173
|
};
|
|
172
174
|
} catch {
|
|
173
|
-
return json
|
|
175
|
+
return json({ items: [] }, 400);
|
|
174
176
|
}
|
|
175
|
-
if (typeof sessionId !== "string" || sessionId === "") return json
|
|
177
|
+
if (typeof sessionId !== "string" || sessionId === "") return json({ items: [] }, 400);
|
|
176
178
|
const sessions = ctx.get("sessions");
|
|
177
179
|
const llm = ctx.get("llm");
|
|
178
180
|
if (sessions === null || sessions === void 0 || llm === null || llm === void 0) return empty();
|
|
@@ -231,7 +233,7 @@ async function handleSuggest(ctx, request, timeoutMs = MODEL_TIMEOUT_MS) {
|
|
|
231
233
|
}
|
|
232
234
|
function withDiag(ctx, body, record) {
|
|
233
235
|
logDiag(ctx, record);
|
|
234
|
-
return json
|
|
236
|
+
return json({
|
|
235
237
|
...body,
|
|
236
238
|
diag: record
|
|
237
239
|
});
|
|
@@ -303,7 +305,7 @@ async function listEfforts(ctx, provider, model) {
|
|
|
303
305
|
};
|
|
304
306
|
}
|
|
305
307
|
}
|
|
306
|
-
function json
|
|
308
|
+
function json(body, status = 200) {
|
|
307
309
|
return new Response(JSON.stringify(body), {
|
|
308
310
|
status,
|
|
309
311
|
headers: { "content-type": "application/json" }
|
|
@@ -324,7 +326,7 @@ function registerSuggestRoute(ctx) {
|
|
|
324
326
|
path: SUGGEST_MODELS_PATH,
|
|
325
327
|
methods: ["GET"],
|
|
326
328
|
requestBody: "buffered",
|
|
327
|
-
fetch: async () => json
|
|
329
|
+
fetch: async () => json(await listModels(ctx))
|
|
328
330
|
}));
|
|
329
331
|
disposers.push(registry.register({
|
|
330
332
|
path: SUGGEST_EFFORTS_PATH,
|
|
@@ -332,11 +334,11 @@ function registerSuggestRoute(ctx) {
|
|
|
332
334
|
requestBody: "buffered",
|
|
333
335
|
fetch: async (request) => {
|
|
334
336
|
const route = splitRoute(new URL(request.url).searchParams.get("model") ?? "");
|
|
335
|
-
if (route === null) return json
|
|
337
|
+
if (route === null) return json({
|
|
336
338
|
efforts: [],
|
|
337
339
|
defaultEffort: null
|
|
338
340
|
});
|
|
339
|
-
return json
|
|
341
|
+
return json(await listEfforts(ctx, route.provider, route.model));
|
|
340
342
|
}
|
|
341
343
|
}));
|
|
342
344
|
} catch (error) {
|
|
@@ -460,82 +462,6 @@ function projectSkills(events) {
|
|
|
460
462
|
};
|
|
461
463
|
}
|
|
462
464
|
//#endregion
|
|
463
|
-
//#region src/session-info/host.ts
|
|
464
|
-
const SESSION_INFO_PATH = SESSION_INFO_ROUTE;
|
|
465
|
-
const EMPTY_PROJECTION = {
|
|
466
|
-
skills: [],
|
|
467
|
-
nodes: [],
|
|
468
|
-
windowStartSeq: null,
|
|
469
|
-
replacedRanges: [],
|
|
470
|
-
shadowedSeqs: []
|
|
471
|
-
};
|
|
472
|
-
function json$1(body, status = 200) {
|
|
473
|
-
return new Response(JSON.stringify(body), {
|
|
474
|
-
status,
|
|
475
|
-
headers: { "content-type": "application/json" }
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
async function disposeObservation(observation) {
|
|
479
|
-
if (observation === null || observation === void 0 || typeof observation !== "object") return;
|
|
480
|
-
try {
|
|
481
|
-
const asyncDispose = observation[Symbol.asyncDispose];
|
|
482
|
-
if (typeof asyncDispose === "function") {
|
|
483
|
-
await asyncDispose.call(observation);
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
const syncDispose = observation[Symbol.dispose];
|
|
487
|
-
if (typeof syncDispose === "function") syncDispose.call(observation);
|
|
488
|
-
} catch {}
|
|
489
|
-
}
|
|
490
|
-
async function readAllSessionEvents(ctx, sessionId) {
|
|
491
|
-
const sessions = ctx.get("sessions");
|
|
492
|
-
if (sessions !== null && sessions !== void 0 && typeof sessions.get === "function") try {
|
|
493
|
-
const live = sessions.get(sessionId);
|
|
494
|
-
if (live !== void 0 && typeof live.snapshotEvents === "function") {
|
|
495
|
-
const events = live.snapshotEvents();
|
|
496
|
-
if (Array.isArray(events)) return events;
|
|
497
|
-
}
|
|
498
|
-
} catch {}
|
|
499
|
-
const query = ctx.get("sessionQuery");
|
|
500
|
-
if (query === null || query === void 0 || typeof query.observeSession !== "function") return null;
|
|
501
|
-
let observation;
|
|
502
|
-
try {
|
|
503
|
-
observation = await query.observeSession(sessionId, { projectionMode: "none" });
|
|
504
|
-
const events = observation?.events;
|
|
505
|
-
return Array.isArray(events) ? events : null;
|
|
506
|
-
} catch {
|
|
507
|
-
return null;
|
|
508
|
-
} finally {
|
|
509
|
-
await disposeObservation(observation);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
async function handleSessionInfo(ctx, request) {
|
|
513
|
-
let sessionId;
|
|
514
|
-
try {
|
|
515
|
-
sessionId = (await request.json())?.sessionId;
|
|
516
|
-
} catch {
|
|
517
|
-
return json$1(EMPTY_PROJECTION, 400);
|
|
518
|
-
}
|
|
519
|
-
if (typeof sessionId !== "string" || sessionId === "") return json$1(EMPTY_PROJECTION, 400);
|
|
520
|
-
const events = await readAllSessionEvents(ctx, sessionId);
|
|
521
|
-
if (events === null) return json$1(EMPTY_PROJECTION);
|
|
522
|
-
return json$1(projectSkills(events));
|
|
523
|
-
}
|
|
524
|
-
function registerSessionInfoRoute(ctx) {
|
|
525
|
-
const connection = ctx.get("connection");
|
|
526
|
-
const register = connection?.fetch?.register;
|
|
527
|
-
if (typeof register !== "function") return () => {};
|
|
528
|
-
const dispose = register.call(connection?.fetch, {
|
|
529
|
-
path: SESSION_INFO_PATH,
|
|
530
|
-
methods: ["POST"],
|
|
531
|
-
requestBody: "buffered",
|
|
532
|
-
fetch: (request) => handleSessionInfo(ctx, request)
|
|
533
|
-
});
|
|
534
|
-
return () => {
|
|
535
|
-
Promise.resolve().then(() => dispose()).catch(() => void 0);
|
|
536
|
-
};
|
|
537
|
-
}
|
|
538
|
-
//#endregion
|
|
539
465
|
//#region src/shared/tools-manager.ts
|
|
540
466
|
const DISABLED_TOOL_PREFIX = "tool is disabled by desktop-enhance:";
|
|
541
467
|
function compareCodeUnits(a, b) {
|
|
@@ -550,6 +476,548 @@ function parseDisabledTools(raw) {
|
|
|
550
476
|
}
|
|
551
477
|
return out;
|
|
552
478
|
}
|
|
479
|
+
const ACTION_VERB_PREFIXES = new Set([
|
|
480
|
+
"add",
|
|
481
|
+
"call",
|
|
482
|
+
"check",
|
|
483
|
+
"clear",
|
|
484
|
+
"close",
|
|
485
|
+
"create",
|
|
486
|
+
"delete",
|
|
487
|
+
"edit",
|
|
488
|
+
"enable",
|
|
489
|
+
"disable",
|
|
490
|
+
"enter",
|
|
491
|
+
"exit",
|
|
492
|
+
"fetch",
|
|
493
|
+
"find",
|
|
494
|
+
"generate",
|
|
495
|
+
"get",
|
|
496
|
+
"interrupt",
|
|
497
|
+
"kill",
|
|
498
|
+
"list",
|
|
499
|
+
"load",
|
|
500
|
+
"open",
|
|
501
|
+
"query",
|
|
502
|
+
"remove",
|
|
503
|
+
"reset",
|
|
504
|
+
"resolve",
|
|
505
|
+
"run",
|
|
506
|
+
"save",
|
|
507
|
+
"search",
|
|
508
|
+
"select",
|
|
509
|
+
"send",
|
|
510
|
+
"set",
|
|
511
|
+
"show",
|
|
512
|
+
"spawn",
|
|
513
|
+
"start",
|
|
514
|
+
"stop",
|
|
515
|
+
"trigger",
|
|
516
|
+
"update",
|
|
517
|
+
"verify",
|
|
518
|
+
"view",
|
|
519
|
+
"wait",
|
|
520
|
+
"write"
|
|
521
|
+
]);
|
|
522
|
+
const OPTIONAL_OFFICIAL_TOOL_PACKAGES = new Set([
|
|
523
|
+
"@deepseek-ai/dsh-tool-terminal",
|
|
524
|
+
"@deepseek-ai/dsh-tool-session-query",
|
|
525
|
+
"@deepseek-ai/dsh-tool-ralph",
|
|
526
|
+
"@deepseek-ai/dsh-mcp-resources",
|
|
527
|
+
"@deepseek-ai/dsh-mcp-client"
|
|
528
|
+
]);
|
|
529
|
+
function isPluginToolPackage(pkg) {
|
|
530
|
+
if (pkg.startsWith("mcp:")) return true;
|
|
531
|
+
if (!pkg.startsWith("@deepseek-ai/")) return true;
|
|
532
|
+
if (pkg.startsWith("@deepseek-ai/dsh-experimental-")) return true;
|
|
533
|
+
return OPTIONAL_OFFICIAL_TOOL_PACKAGES.has(pkg);
|
|
534
|
+
}
|
|
535
|
+
const BUILTIN_TOOL_PACKAGES = new Map([
|
|
536
|
+
["@deepseek-ai/dsh-tool-bash", "bash"],
|
|
537
|
+
["@deepseek-ai/dsh-tool-bash-persistent", "bash"],
|
|
538
|
+
["@deepseek-ai/dsh-tool-pwsh", "pwsh"],
|
|
539
|
+
["@deepseek-ai/dsh-tool-pwsh-persistent", "pwsh"],
|
|
540
|
+
["@deepseek-ai/dsh-tool-fs", "fs"],
|
|
541
|
+
["@deepseek-ai/dsh-tool-fs-search", "fs_search"],
|
|
542
|
+
["@deepseek-ai/dsh-tool-str-replace-editor", "str_replace_editor"],
|
|
543
|
+
["@deepseek-ai/dsh-tool-working-directory", "working_directory"],
|
|
544
|
+
["@deepseek-ai/dsh-tool-workspace-dependencies", "workspace_dependencies"],
|
|
545
|
+
["@deepseek-ai/dsh-tool-jobs", "job"],
|
|
546
|
+
["@deepseek-ai/dsh-tool-schedule", "schedule"],
|
|
547
|
+
["@deepseek-ai/dsh-schedule", "schedule"],
|
|
548
|
+
["@deepseek-ai/dsh-tool-goal", "goal"],
|
|
549
|
+
["@deepseek-ai/dsh-plan-mode", "plan"],
|
|
550
|
+
["@deepseek-ai/dsh-tool-todo", "todo"],
|
|
551
|
+
["@deepseek-ai/dsh-tool-ask-user", "ask_user"],
|
|
552
|
+
["@deepseek-ai/dsh-tool-skill", "skill"],
|
|
553
|
+
["@deepseek-ai/dsh-tool-present", "present"],
|
|
554
|
+
["@deepseek-ai/dsh-tool-web", "web"],
|
|
555
|
+
["@deepseek-ai/dsh-tool-subagent", "subagent"],
|
|
556
|
+
["@deepseek-ai/dsh-tool-subagent-control", "subagent"],
|
|
557
|
+
["@deepseek-ai/dsh-subagent", "subagent"],
|
|
558
|
+
["@deepseek-ai/dsh-tool-workflow", "workflow"],
|
|
559
|
+
["@deepseek-ai/dsh-tool-cordis", "cordis_inspect"],
|
|
560
|
+
["@deepseek-ai/dsh-cordis-host-runner", "cordis_inspect"],
|
|
561
|
+
["@deepseek-ai/dsh-plugin-manager", "plugin_manager"],
|
|
562
|
+
["@deepseek-ai/dsh-plugin-market", "plugin_manager"],
|
|
563
|
+
["@deepseek-ai/dsh-tools", "builtin"]
|
|
564
|
+
]);
|
|
565
|
+
const KNOWN_TOOL_SPECS = {
|
|
566
|
+
bash: {
|
|
567
|
+
scope: "builtin",
|
|
568
|
+
pluginName: "@deepseek-ai/dsh-tool-bash",
|
|
569
|
+
groupKey: "bash"
|
|
570
|
+
},
|
|
571
|
+
pwsh: {
|
|
572
|
+
scope: "builtin",
|
|
573
|
+
pluginName: "@deepseek-ai/dsh-tool-pwsh",
|
|
574
|
+
groupKey: "pwsh"
|
|
575
|
+
},
|
|
576
|
+
read: {
|
|
577
|
+
scope: "builtin",
|
|
578
|
+
pluginName: "@deepseek-ai/dsh-tool-fs",
|
|
579
|
+
groupKey: "read"
|
|
580
|
+
},
|
|
581
|
+
read_image: {
|
|
582
|
+
scope: "builtin",
|
|
583
|
+
pluginName: "@deepseek-ai/dsh-tool-fs",
|
|
584
|
+
groupKey: "read"
|
|
585
|
+
},
|
|
586
|
+
write: {
|
|
587
|
+
scope: "builtin",
|
|
588
|
+
pluginName: "@deepseek-ai/dsh-tool-fs",
|
|
589
|
+
groupKey: "write"
|
|
590
|
+
},
|
|
591
|
+
edit: {
|
|
592
|
+
scope: "builtin",
|
|
593
|
+
pluginName: "@deepseek-ai/dsh-tool-fs",
|
|
594
|
+
groupKey: "edit"
|
|
595
|
+
},
|
|
596
|
+
str_replace_editor: {
|
|
597
|
+
scope: "builtin",
|
|
598
|
+
pluginName: "@deepseek-ai/dsh-tool-str-replace-editor",
|
|
599
|
+
groupKey: "str_replace_editor"
|
|
600
|
+
},
|
|
601
|
+
glob: {
|
|
602
|
+
scope: "builtin",
|
|
603
|
+
pluginName: "@deepseek-ai/dsh-tool-fs-search",
|
|
604
|
+
groupKey: "glob"
|
|
605
|
+
},
|
|
606
|
+
grep: {
|
|
607
|
+
scope: "builtin",
|
|
608
|
+
pluginName: "@deepseek-ai/dsh-tool-fs-search",
|
|
609
|
+
groupKey: "grep"
|
|
610
|
+
},
|
|
611
|
+
working_directory: {
|
|
612
|
+
scope: "builtin",
|
|
613
|
+
pluginName: "@deepseek-ai/dsh-tool-working-directory",
|
|
614
|
+
groupKey: "working_directory"
|
|
615
|
+
},
|
|
616
|
+
load_workspace_dependencies: {
|
|
617
|
+
scope: "builtin",
|
|
618
|
+
pluginName: "@deepseek-ai/dsh-tool-workspace-dependencies",
|
|
619
|
+
groupKey: "load_workspace_dependencies"
|
|
620
|
+
},
|
|
621
|
+
job_output: {
|
|
622
|
+
scope: "builtin",
|
|
623
|
+
pluginName: "@deepseek-ai/dsh-tool-jobs",
|
|
624
|
+
groupKey: "job"
|
|
625
|
+
},
|
|
626
|
+
job_list: {
|
|
627
|
+
scope: "builtin",
|
|
628
|
+
pluginName: "@deepseek-ai/dsh-tool-jobs",
|
|
629
|
+
groupKey: "job"
|
|
630
|
+
},
|
|
631
|
+
job_kill: {
|
|
632
|
+
scope: "builtin",
|
|
633
|
+
pluginName: "@deepseek-ai/dsh-tool-jobs",
|
|
634
|
+
groupKey: "job"
|
|
635
|
+
},
|
|
636
|
+
schedule_create: {
|
|
637
|
+
scope: "builtin",
|
|
638
|
+
pluginName: "@deepseek-ai/dsh-tool-schedule",
|
|
639
|
+
groupKey: "schedule"
|
|
640
|
+
},
|
|
641
|
+
schedule_list: {
|
|
642
|
+
scope: "builtin",
|
|
643
|
+
pluginName: "@deepseek-ai/dsh-tool-schedule",
|
|
644
|
+
groupKey: "schedule"
|
|
645
|
+
},
|
|
646
|
+
schedule_update: {
|
|
647
|
+
scope: "builtin",
|
|
648
|
+
pluginName: "@deepseek-ai/dsh-tool-schedule",
|
|
649
|
+
groupKey: "schedule"
|
|
650
|
+
},
|
|
651
|
+
schedule_delete: {
|
|
652
|
+
scope: "builtin",
|
|
653
|
+
pluginName: "@deepseek-ai/dsh-tool-schedule",
|
|
654
|
+
groupKey: "schedule"
|
|
655
|
+
},
|
|
656
|
+
create_goal: {
|
|
657
|
+
scope: "builtin",
|
|
658
|
+
pluginName: "@deepseek-ai/dsh-tool-goal",
|
|
659
|
+
groupKey: "goal"
|
|
660
|
+
},
|
|
661
|
+
get_goal: {
|
|
662
|
+
scope: "builtin",
|
|
663
|
+
pluginName: "@deepseek-ai/dsh-tool-goal",
|
|
664
|
+
groupKey: "goal"
|
|
665
|
+
},
|
|
666
|
+
update_goal: {
|
|
667
|
+
scope: "builtin",
|
|
668
|
+
pluginName: "@deepseek-ai/dsh-tool-goal",
|
|
669
|
+
groupKey: "goal"
|
|
670
|
+
},
|
|
671
|
+
plan: {
|
|
672
|
+
scope: "builtin",
|
|
673
|
+
pluginName: "@deepseek-ai/dsh-plan-mode",
|
|
674
|
+
groupKey: "plan"
|
|
675
|
+
},
|
|
676
|
+
exit_plan_mode: {
|
|
677
|
+
scope: "builtin",
|
|
678
|
+
pluginName: "@deepseek-ai/dsh-plan-mode",
|
|
679
|
+
groupKey: "plan"
|
|
680
|
+
},
|
|
681
|
+
todo_write: {
|
|
682
|
+
scope: "builtin",
|
|
683
|
+
pluginName: "@deepseek-ai/dsh-tool-todo",
|
|
684
|
+
groupKey: "todo_write"
|
|
685
|
+
},
|
|
686
|
+
ask_user_question: {
|
|
687
|
+
scope: "builtin",
|
|
688
|
+
pluginName: "@deepseek-ai/dsh-tool-ask-user",
|
|
689
|
+
groupKey: "ask_user_question"
|
|
690
|
+
},
|
|
691
|
+
skill: {
|
|
692
|
+
scope: "builtin",
|
|
693
|
+
pluginName: "@deepseek-ai/dsh-tool-skill",
|
|
694
|
+
groupKey: "skill"
|
|
695
|
+
},
|
|
696
|
+
present: {
|
|
697
|
+
scope: "builtin",
|
|
698
|
+
pluginName: "@deepseek-ai/dsh-tool-present",
|
|
699
|
+
groupKey: "present"
|
|
700
|
+
},
|
|
701
|
+
web_search: {
|
|
702
|
+
scope: "builtin",
|
|
703
|
+
pluginName: "@deepseek-ai/dsh-tool-web",
|
|
704
|
+
groupKey: "web"
|
|
705
|
+
},
|
|
706
|
+
web_fetch: {
|
|
707
|
+
scope: "builtin",
|
|
708
|
+
pluginName: "@deepseek-ai/dsh-tool-web",
|
|
709
|
+
groupKey: "web"
|
|
710
|
+
},
|
|
711
|
+
subagent: {
|
|
712
|
+
scope: "builtin",
|
|
713
|
+
pluginName: "@deepseek-ai/dsh-tool-subagent",
|
|
714
|
+
groupKey: "subagent"
|
|
715
|
+
},
|
|
716
|
+
subagent_fork: {
|
|
717
|
+
scope: "builtin",
|
|
718
|
+
pluginName: "@deepseek-ai/dsh-tool-subagent",
|
|
719
|
+
groupKey: "subagent"
|
|
720
|
+
},
|
|
721
|
+
list_subagent_models: {
|
|
722
|
+
scope: "builtin",
|
|
723
|
+
pluginName: "@deepseek-ai/dsh-tool-subagent",
|
|
724
|
+
groupKey: "subagent"
|
|
725
|
+
},
|
|
726
|
+
send_message: {
|
|
727
|
+
scope: "builtin",
|
|
728
|
+
pluginName: "@deepseek-ai/dsh-tool-subagent-control",
|
|
729
|
+
groupKey: "subagent"
|
|
730
|
+
},
|
|
731
|
+
interrupt_agent: {
|
|
732
|
+
scope: "builtin",
|
|
733
|
+
pluginName: "@deepseek-ai/dsh-tool-subagent-control",
|
|
734
|
+
groupKey: "subagent"
|
|
735
|
+
},
|
|
736
|
+
list_agents: {
|
|
737
|
+
scope: "builtin",
|
|
738
|
+
pluginName: "@deepseek-ai/dsh-tool-subagent-control",
|
|
739
|
+
groupKey: "subagent"
|
|
740
|
+
},
|
|
741
|
+
workflow: {
|
|
742
|
+
scope: "builtin",
|
|
743
|
+
pluginName: "@deepseek-ai/dsh-tool-workflow",
|
|
744
|
+
groupKey: "workflow"
|
|
745
|
+
},
|
|
746
|
+
cordis_inspect_list: {
|
|
747
|
+
scope: "builtin",
|
|
748
|
+
pluginName: "@deepseek-ai/dsh-tool-cordis",
|
|
749
|
+
groupKey: "cordis_inspect"
|
|
750
|
+
},
|
|
751
|
+
cordis_inspect_query: {
|
|
752
|
+
scope: "builtin",
|
|
753
|
+
pluginName: "@deepseek-ai/dsh-tool-cordis",
|
|
754
|
+
groupKey: "cordis_inspect"
|
|
755
|
+
},
|
|
756
|
+
cordis_dynamic: {
|
|
757
|
+
scope: "builtin",
|
|
758
|
+
pluginName: "@deepseek-ai/dsh-cordis-host-runner",
|
|
759
|
+
groupKey: "cordis_inspect"
|
|
760
|
+
},
|
|
761
|
+
plugin_manager: {
|
|
762
|
+
scope: "builtin",
|
|
763
|
+
pluginName: "@deepseek-ai/dsh-plugin-manager",
|
|
764
|
+
groupKey: "plugin_manager"
|
|
765
|
+
},
|
|
766
|
+
plugin_market: {
|
|
767
|
+
scope: "builtin",
|
|
768
|
+
pluginName: "@deepseek-ai/dsh-plugin-market",
|
|
769
|
+
groupKey: "plugin_manager"
|
|
770
|
+
},
|
|
771
|
+
create_worktree: {
|
|
772
|
+
scope: "plugin",
|
|
773
|
+
pluginName: "@deepseek-ai/dsh-experimental-tool-worktree",
|
|
774
|
+
groupKey: "dsh-experimental-tool-worktree"
|
|
775
|
+
},
|
|
776
|
+
spawn_teammate: {
|
|
777
|
+
scope: "plugin",
|
|
778
|
+
pluginName: "@deepseek-ai/dsh-experimental-tool-agent-team",
|
|
779
|
+
groupKey: "dsh-experimental-tool-agent-team"
|
|
780
|
+
},
|
|
781
|
+
wait_agent: {
|
|
782
|
+
scope: "plugin",
|
|
783
|
+
pluginName: "@deepseek-ai/dsh-experimental-tool-agent-team",
|
|
784
|
+
groupKey: "dsh-experimental-tool-agent-team"
|
|
785
|
+
},
|
|
786
|
+
team_task_create: {
|
|
787
|
+
scope: "plugin",
|
|
788
|
+
pluginName: "@deepseek-ai/dsh-experimental-tool-agent-team",
|
|
789
|
+
groupKey: "dsh-experimental-tool-agent-team"
|
|
790
|
+
},
|
|
791
|
+
team_task_list: {
|
|
792
|
+
scope: "plugin",
|
|
793
|
+
pluginName: "@deepseek-ai/dsh-experimental-tool-agent-team",
|
|
794
|
+
groupKey: "dsh-experimental-tool-agent-team"
|
|
795
|
+
},
|
|
796
|
+
team_task_get: {
|
|
797
|
+
scope: "plugin",
|
|
798
|
+
pluginName: "@deepseek-ai/dsh-experimental-tool-agent-team",
|
|
799
|
+
groupKey: "dsh-experimental-tool-agent-team"
|
|
800
|
+
},
|
|
801
|
+
team_task_update: {
|
|
802
|
+
scope: "plugin",
|
|
803
|
+
pluginName: "@deepseek-ai/dsh-experimental-tool-agent-team",
|
|
804
|
+
groupKey: "dsh-experimental-tool-agent-team"
|
|
805
|
+
},
|
|
806
|
+
terminal_open: {
|
|
807
|
+
scope: "plugin",
|
|
808
|
+
pluginName: "@deepseek-ai/dsh-tool-terminal",
|
|
809
|
+
groupKey: "dsh-tool-terminal"
|
|
810
|
+
},
|
|
811
|
+
terminal_send: {
|
|
812
|
+
scope: "plugin",
|
|
813
|
+
pluginName: "@deepseek-ai/dsh-tool-terminal",
|
|
814
|
+
groupKey: "dsh-tool-terminal"
|
|
815
|
+
},
|
|
816
|
+
terminal_read: {
|
|
817
|
+
scope: "plugin",
|
|
818
|
+
pluginName: "@deepseek-ai/dsh-tool-terminal",
|
|
819
|
+
groupKey: "dsh-tool-terminal"
|
|
820
|
+
},
|
|
821
|
+
terminal_signal: {
|
|
822
|
+
scope: "plugin",
|
|
823
|
+
pluginName: "@deepseek-ai/dsh-tool-terminal",
|
|
824
|
+
groupKey: "dsh-tool-terminal"
|
|
825
|
+
},
|
|
826
|
+
terminal_close: {
|
|
827
|
+
scope: "plugin",
|
|
828
|
+
pluginName: "@deepseek-ai/dsh-tool-terminal",
|
|
829
|
+
groupKey: "dsh-tool-terminal"
|
|
830
|
+
},
|
|
831
|
+
terminal_list: {
|
|
832
|
+
scope: "plugin",
|
|
833
|
+
pluginName: "@deepseek-ai/dsh-tool-terminal",
|
|
834
|
+
groupKey: "dsh-tool-terminal"
|
|
835
|
+
},
|
|
836
|
+
session_search: {
|
|
837
|
+
scope: "plugin",
|
|
838
|
+
pluginName: "@deepseek-ai/dsh-tool-session-query",
|
|
839
|
+
groupKey: "dsh-tool-session-query"
|
|
840
|
+
},
|
|
841
|
+
session_event_search: {
|
|
842
|
+
scope: "plugin",
|
|
843
|
+
pluginName: "@deepseek-ai/dsh-tool-session-query",
|
|
844
|
+
groupKey: "dsh-tool-session-query"
|
|
845
|
+
},
|
|
846
|
+
session_trace: {
|
|
847
|
+
scope: "plugin",
|
|
848
|
+
pluginName: "@deepseek-ai/dsh-tool-session-query",
|
|
849
|
+
groupKey: "dsh-tool-session-query"
|
|
850
|
+
},
|
|
851
|
+
session_event_trace: {
|
|
852
|
+
scope: "plugin",
|
|
853
|
+
pluginName: "@deepseek-ai/dsh-tool-session-query",
|
|
854
|
+
groupKey: "dsh-tool-session-query"
|
|
855
|
+
},
|
|
856
|
+
session_event_read: {
|
|
857
|
+
scope: "plugin",
|
|
858
|
+
pluginName: "@deepseek-ai/dsh-tool-session-query",
|
|
859
|
+
groupKey: "dsh-tool-session-query"
|
|
860
|
+
},
|
|
861
|
+
ralph: {
|
|
862
|
+
scope: "plugin",
|
|
863
|
+
pluginName: "@deepseek-ai/dsh-tool-ralph",
|
|
864
|
+
groupKey: "dsh-tool-ralph"
|
|
865
|
+
},
|
|
866
|
+
list_mcp_resources: {
|
|
867
|
+
scope: "plugin",
|
|
868
|
+
pluginName: "@deepseek-ai/dsh-mcp-resources",
|
|
869
|
+
groupKey: "dsh-mcp-resources"
|
|
870
|
+
},
|
|
871
|
+
list_mcp_resource_templates: {
|
|
872
|
+
scope: "plugin",
|
|
873
|
+
pluginName: "@deepseek-ai/dsh-mcp-resources",
|
|
874
|
+
groupKey: "dsh-mcp-resources"
|
|
875
|
+
},
|
|
876
|
+
read_mcp_resource: {
|
|
877
|
+
scope: "plugin",
|
|
878
|
+
pluginName: "@deepseek-ai/dsh-mcp-resources",
|
|
879
|
+
groupKey: "dsh-mcp-resources"
|
|
880
|
+
},
|
|
881
|
+
sidebar_open: {
|
|
882
|
+
scope: "plugin",
|
|
883
|
+
pluginName: "dsh-better-sidebar",
|
|
884
|
+
groupKey: "dsh-better-sidebar"
|
|
885
|
+
},
|
|
886
|
+
task_memory_write: {
|
|
887
|
+
scope: "plugin",
|
|
888
|
+
pluginName: "dsh-expedition-memory",
|
|
889
|
+
groupKey: "dsh-expedition-memory"
|
|
890
|
+
},
|
|
891
|
+
task_memory_write_document: {
|
|
892
|
+
scope: "plugin",
|
|
893
|
+
pluginName: "dsh-expedition-memory",
|
|
894
|
+
groupKey: "dsh-expedition-memory"
|
|
895
|
+
},
|
|
896
|
+
task_memory_update: {
|
|
897
|
+
scope: "plugin",
|
|
898
|
+
pluginName: "dsh-expedition-memory",
|
|
899
|
+
groupKey: "dsh-expedition-memory"
|
|
900
|
+
},
|
|
901
|
+
task_memory_retire: {
|
|
902
|
+
scope: "plugin",
|
|
903
|
+
pluginName: "dsh-expedition-memory",
|
|
904
|
+
groupKey: "dsh-expedition-memory"
|
|
905
|
+
},
|
|
906
|
+
canvas_state: {
|
|
907
|
+
scope: "plugin",
|
|
908
|
+
pluginName: "dsh-image-gen",
|
|
909
|
+
groupKey: "dsh-image-gen"
|
|
910
|
+
},
|
|
911
|
+
view_canvas: {
|
|
912
|
+
scope: "plugin",
|
|
913
|
+
pluginName: "dsh-image-gen",
|
|
914
|
+
groupKey: "dsh-image-gen"
|
|
915
|
+
},
|
|
916
|
+
generate_image: {
|
|
917
|
+
scope: "plugin",
|
|
918
|
+
pluginName: "dsh-image-gen",
|
|
919
|
+
groupKey: "dsh-image-gen"
|
|
920
|
+
},
|
|
921
|
+
generate_images: {
|
|
922
|
+
scope: "plugin",
|
|
923
|
+
pluginName: "dsh-image-gen",
|
|
924
|
+
groupKey: "dsh-image-gen"
|
|
925
|
+
},
|
|
926
|
+
edit_image: {
|
|
927
|
+
scope: "plugin",
|
|
928
|
+
pluginName: "dsh-image-gen",
|
|
929
|
+
groupKey: "dsh-image-gen"
|
|
930
|
+
},
|
|
931
|
+
find_inspiration: {
|
|
932
|
+
scope: "plugin",
|
|
933
|
+
pluginName: "dsh-image-gen",
|
|
934
|
+
groupKey: "dsh-image-gen"
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
function normalizeBarePackageName(raw) {
|
|
938
|
+
const trimmed = raw.trim();
|
|
939
|
+
if (trimmed === "" || trimmed.startsWith("mcp:")) return trimmed;
|
|
940
|
+
const parts = trimmed.split("/");
|
|
941
|
+
if (trimmed.startsWith("@") && parts.length >= 2) return `${parts[0]}/${parts[1]}`;
|
|
942
|
+
return parts[0] ?? trimmed;
|
|
943
|
+
}
|
|
944
|
+
function shortBadgeOfPackage(pkgName) {
|
|
945
|
+
return pkgName.startsWith("@deepseek-ai/") ? pkgName.slice(13) : pkgName;
|
|
946
|
+
}
|
|
947
|
+
function makeMcpOrigin(rawServer) {
|
|
948
|
+
const server = rawServer.trim() || "mcp";
|
|
949
|
+
return {
|
|
950
|
+
scope: "plugin",
|
|
951
|
+
pluginName: `mcp:${server}`,
|
|
952
|
+
sourceBadge: `mcp:${server}`,
|
|
953
|
+
groupKey: `mcp__${server}`
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
function makeKnownOrigin(spec) {
|
|
957
|
+
const badge = shortBadgeOfPackage(spec.pluginName);
|
|
958
|
+
return {
|
|
959
|
+
scope: spec.scope,
|
|
960
|
+
pluginName: spec.pluginName,
|
|
961
|
+
sourceBadge: badge,
|
|
962
|
+
groupKey: spec.groupKey ?? badge
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
function splitToolName(name) {
|
|
966
|
+
const parts = name.split("__");
|
|
967
|
+
if (parts.length > 1) {
|
|
968
|
+
const result = [];
|
|
969
|
+
for (let i = 0; i < parts.length; i++) {
|
|
970
|
+
const part = parts[i];
|
|
971
|
+
if (part === void 0 || part === "") continue;
|
|
972
|
+
if (i === 0 || i === parts.length - 1) result.push(part);
|
|
973
|
+
else {
|
|
974
|
+
const sub = part.split("_").filter((s) => s !== "");
|
|
975
|
+
result.push(...sub);
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
return result.length > 0 ? result : [name];
|
|
979
|
+
}
|
|
980
|
+
const sub = name.split("_").filter((s) => s !== "");
|
|
981
|
+
if (sub.length <= 1) return [name];
|
|
982
|
+
const firstWord = sub[0]?.toLowerCase() ?? "";
|
|
983
|
+
if (ACTION_VERB_PREFIXES.has(firstWord)) return [name];
|
|
984
|
+
return sub;
|
|
985
|
+
}
|
|
986
|
+
function classifyToolOrigin(toolName, rawPluginName) {
|
|
987
|
+
const name = typeof toolName === "string" ? toolName.trim() : "";
|
|
988
|
+
if (name.startsWith("mcp__")) return makeMcpOrigin(name.split("__").filter((s) => s !== "")[1] ?? "mcp");
|
|
989
|
+
const explicitPkg = typeof rawPluginName === "string" ? normalizeBarePackageName(rawPluginName) : "";
|
|
990
|
+
const known = KNOWN_TOOL_SPECS[name];
|
|
991
|
+
if (explicitPkg !== "" && explicitPkg !== "root" && explicitPkg !== "builtin") {
|
|
992
|
+
if (explicitPkg.startsWith("mcp:")) return makeMcpOrigin(explicitPkg.slice(4));
|
|
993
|
+
if (isPluginToolPackage(explicitPkg)) {
|
|
994
|
+
const badge = shortBadgeOfPackage(explicitPkg);
|
|
995
|
+
return {
|
|
996
|
+
scope: "plugin",
|
|
997
|
+
pluginName: explicitPkg,
|
|
998
|
+
sourceBadge: badge,
|
|
999
|
+
groupKey: badge
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
if (known !== void 0 && known.scope === "builtin") return makeKnownOrigin(known);
|
|
1003
|
+
const builtinGroup = BUILTIN_TOOL_PACKAGES.get(explicitPkg);
|
|
1004
|
+
const groupKey = builtinGroup === void 0 || builtinGroup === "builtin" ? splitToolName(name)[0] ?? name : builtinGroup === "fs" ? name === "read" || name === "read_image" ? "read" : name : builtinGroup === "fs_search" ? name : builtinGroup;
|
|
1005
|
+
return {
|
|
1006
|
+
scope: "builtin",
|
|
1007
|
+
pluginName: explicitPkg,
|
|
1008
|
+
sourceBadge: shortBadgeOfPackage(explicitPkg),
|
|
1009
|
+
groupKey
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
if (known !== void 0) return makeKnownOrigin(known);
|
|
1013
|
+
const segments = splitToolName(name);
|
|
1014
|
+
return {
|
|
1015
|
+
scope: "builtin",
|
|
1016
|
+
pluginName: "builtin",
|
|
1017
|
+
sourceBadge: "builtin",
|
|
1018
|
+
groupKey: segments.length > 1 ? segments[0] ?? name : name
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
553
1021
|
function disabledToolReason(toolName, enabled, disabled) {
|
|
554
1022
|
if (!enabled || disabled.size === 0) return void 0;
|
|
555
1023
|
if (disabled.has(toolName)) return `${DISABLED_TOOL_PREFIX} ${JSON.stringify(toolName)}`;
|
|
@@ -562,22 +1030,91 @@ function normalizeToolSummaries(list, excludedNames) {
|
|
|
562
1030
|
const byName = new Map();
|
|
563
1031
|
for (const item of list) {
|
|
564
1032
|
if (item === null || item === void 0 || typeof item !== "object") continue;
|
|
565
|
-
const
|
|
1033
|
+
const rec = item;
|
|
1034
|
+
const name = rec.name;
|
|
566
1035
|
if (typeof name !== "string" || name.trim() === "") continue;
|
|
567
1036
|
const trimmed = name.trim();
|
|
568
|
-
if (excludedNames?.has(trimmed)
|
|
569
|
-
const desc =
|
|
1037
|
+
if (excludedNames?.has(trimmed)) continue;
|
|
1038
|
+
const desc = typeof rec.description === "string" ? rec.description.trim() : "";
|
|
1039
|
+
const origin = classifyToolOrigin(trimmed, rec.pluginName);
|
|
1040
|
+
const existing = byName.get(trimmed);
|
|
1041
|
+
if (existing !== void 0) {
|
|
1042
|
+
if (typeof rec.pluginName === "string" && rec.pluginName.trim() !== "" && existing.pluginName !== origin.pluginName) byName.set(trimmed, {
|
|
1043
|
+
name: trimmed,
|
|
1044
|
+
description: existing.description !== "" ? existing.description : desc,
|
|
1045
|
+
scope: origin.scope,
|
|
1046
|
+
pluginName: origin.pluginName,
|
|
1047
|
+
sourceBadge: origin.sourceBadge,
|
|
1048
|
+
groupKey: origin.groupKey
|
|
1049
|
+
});
|
|
1050
|
+
continue;
|
|
1051
|
+
}
|
|
570
1052
|
byName.set(trimmed, {
|
|
571
1053
|
name: trimmed,
|
|
572
|
-
description:
|
|
1054
|
+
description: desc,
|
|
1055
|
+
scope: origin.scope,
|
|
1056
|
+
pluginName: origin.pluginName,
|
|
1057
|
+
sourceBadge: origin.sourceBadge,
|
|
1058
|
+
groupKey: origin.groupKey
|
|
573
1059
|
});
|
|
574
1060
|
}
|
|
575
1061
|
return [...byName.values()].sort((a, b) => compareCodeUnits(a.name, b.name));
|
|
576
1062
|
}
|
|
1063
|
+
function isValidOverrideKey(value) {
|
|
1064
|
+
return value !== "" && !/[\s;:+,]/.test(value);
|
|
1065
|
+
}
|
|
1066
|
+
function parseSessionOverrides(raw) {
|
|
1067
|
+
const out = new Map();
|
|
1068
|
+
if (typeof raw !== "string" || raw.trim() === "") return out;
|
|
1069
|
+
for (const entry of raw.split(";")) {
|
|
1070
|
+
const trimmedEntry = entry.trim();
|
|
1071
|
+
if (trimmedEntry === "") continue;
|
|
1072
|
+
const colonIdx = trimmedEntry.indexOf(":");
|
|
1073
|
+
if (colonIdx <= 0) continue;
|
|
1074
|
+
const sessionId = trimmedEntry.slice(0, colonIdx).trim();
|
|
1075
|
+
if (!isValidOverrideKey(sessionId)) continue;
|
|
1076
|
+
const tokensRaw = trimmedEntry.slice(colonIdx + 1);
|
|
1077
|
+
const allow = new Set();
|
|
1078
|
+
const deny = new Set();
|
|
1079
|
+
for (const token of tokensRaw.split(",")) {
|
|
1080
|
+
const t = token.trim();
|
|
1081
|
+
if (t.length < 2) continue;
|
|
1082
|
+
const op = t[0];
|
|
1083
|
+
const name = t.slice(1).trim();
|
|
1084
|
+
if (!isValidOverrideKey(name)) continue;
|
|
1085
|
+
if (op === "+") {
|
|
1086
|
+
deny.delete(name);
|
|
1087
|
+
allow.add(name);
|
|
1088
|
+
} else if (op === "-") {
|
|
1089
|
+
allow.delete(name);
|
|
1090
|
+
deny.add(name);
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
if (allow.size > 0 || deny.size > 0) {
|
|
1094
|
+
out.delete(sessionId);
|
|
1095
|
+
out.set(sessionId, {
|
|
1096
|
+
allow,
|
|
1097
|
+
deny
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
return out;
|
|
1102
|
+
}
|
|
1103
|
+
function resolveEffectiveDisabled(globalRaw, overridesRaw, sessionId) {
|
|
1104
|
+
const globalSet = parseDisabledTools(globalRaw);
|
|
1105
|
+
const sid = typeof sessionId === "string" ? sessionId.trim() : "";
|
|
1106
|
+
if (sid === "") return globalSet;
|
|
1107
|
+
const delta = parseSessionOverrides(overridesRaw).get(sid);
|
|
1108
|
+
if (delta === void 0) return globalSet;
|
|
1109
|
+
const effective = new Set(globalSet);
|
|
1110
|
+
for (const name of delta.deny) effective.add(name);
|
|
1111
|
+
for (const name of delta.allow) effective.delete(name);
|
|
1112
|
+
return effective;
|
|
1113
|
+
}
|
|
577
1114
|
//#endregion
|
|
578
1115
|
//#region src/tools-manager/host.ts
|
|
579
1116
|
const TOOLS_PATH = TOOLS_ROUTE;
|
|
580
|
-
function
|
|
1117
|
+
function jsonResponse(body, status = 200) {
|
|
581
1118
|
return new Response(JSON.stringify(body), {
|
|
582
1119
|
status,
|
|
583
1120
|
headers: { "content-type": "application/json" }
|
|
@@ -595,7 +1132,35 @@ function unwrapVolatile(cell) {
|
|
|
595
1132
|
if (cell !== null && typeof cell === "object") return void 0;
|
|
596
1133
|
return cell;
|
|
597
1134
|
}
|
|
598
|
-
function
|
|
1135
|
+
function directSessionIdOf(candidate) {
|
|
1136
|
+
if (candidate === null || candidate === void 0 || typeof candidate !== "object") return void 0;
|
|
1137
|
+
const rec = candidate;
|
|
1138
|
+
if (typeof rec.sessionId === "string" && rec.sessionId.trim() !== "") return rec.sessionId.trim();
|
|
1139
|
+
if (typeof rec.id === "string" && rec.id.trim() !== "") return rec.id.trim();
|
|
1140
|
+
const session = rec.session;
|
|
1141
|
+
if (session !== null && session !== void 0 && typeof session === "object") {
|
|
1142
|
+
const sid = session.id;
|
|
1143
|
+
if (typeof sid === "string" && sid.trim() !== "") return sid.trim();
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
function resolveSessionIdFromScope(candidate, ctx) {
|
|
1147
|
+
if (candidate === null || candidate === void 0 || typeof candidate !== "object") return void 0;
|
|
1148
|
+
const rec = candidate;
|
|
1149
|
+
let currentId = directSessionIdOf(rec.agent ?? rec.scope ?? candidate);
|
|
1150
|
+
if (currentId === void 0) return void 0;
|
|
1151
|
+
const store = (ctx?.get("agents"))?.store;
|
|
1152
|
+
if (store !== void 0 && typeof store.get === "function") {
|
|
1153
|
+
const visited = new Set();
|
|
1154
|
+
while (currentId !== void 0 && !visited.has(currentId) && visited.size < 8) {
|
|
1155
|
+
visited.add(currentId);
|
|
1156
|
+
const ownerId = directSessionIdOf(store.get(currentId)?.owner);
|
|
1157
|
+
if (ownerId === void 0) break;
|
|
1158
|
+
currentId = ownerId;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
return currentId;
|
|
1162
|
+
}
|
|
1163
|
+
function readToolsConfig(config, sessionId) {
|
|
599
1164
|
if (config === null || config === void 0 || typeof config !== "object") return {
|
|
600
1165
|
enabled: true,
|
|
601
1166
|
disabled: new Set()
|
|
@@ -603,34 +1168,237 @@ function readToolsConfig(config) {
|
|
|
603
1168
|
const raw = config;
|
|
604
1169
|
const flag = unwrapVolatile(raw.toolsManager);
|
|
605
1170
|
const list = unwrapVolatile(raw.disabledTools);
|
|
1171
|
+
const overrides = unwrapVolatile(raw.sessionToolOverrides);
|
|
606
1172
|
return {
|
|
607
1173
|
enabled: typeof flag === "boolean" ? flag : true,
|
|
608
|
-
disabled:
|
|
1174
|
+
disabled: resolveEffectiveDisabled(list, overrides, sessionId)
|
|
609
1175
|
};
|
|
610
1176
|
}
|
|
611
|
-
async function
|
|
612
|
-
if (
|
|
1177
|
+
async function disposeResource(resource) {
|
|
1178
|
+
if (resource === null || resource === void 0 || typeof resource !== "object") return;
|
|
613
1179
|
try {
|
|
614
|
-
const asyncDispose =
|
|
1180
|
+
const asyncDispose = resource[Symbol.asyncDispose];
|
|
615
1181
|
if (typeof asyncDispose === "function") {
|
|
616
|
-
await asyncDispose.call(
|
|
1182
|
+
await asyncDispose.call(resource);
|
|
617
1183
|
return;
|
|
618
1184
|
}
|
|
619
|
-
const syncDispose =
|
|
620
|
-
if (typeof syncDispose === "function") syncDispose.call(
|
|
1185
|
+
const syncDispose = resource[Symbol.dispose];
|
|
1186
|
+
if (typeof syncDispose === "function") syncDispose.call(resource);
|
|
621
1187
|
} catch {}
|
|
622
1188
|
}
|
|
1189
|
+
const disposePresetLease = disposeResource;
|
|
623
1190
|
const EXCLUDED_TOOLS = new Set(["run_code"]);
|
|
624
|
-
|
|
1191
|
+
const CORDIS_ORIGINAL_SYMBOL = Symbol.for("cordis.original");
|
|
1192
|
+
const CORDIS_ENTRY_SYMBOL = Symbol.for("cordis.entry");
|
|
1193
|
+
const CORDIS_EFFECT_SYMBOL = Symbol.for("cordis.effect");
|
|
1194
|
+
const attributionByRoot = new WeakMap();
|
|
1195
|
+
const instrumentedToolServices = new WeakSet();
|
|
1196
|
+
function unwrapCordisOriginal(value) {
|
|
1197
|
+
if (value !== null && value !== void 0 && typeof value === "object") {
|
|
1198
|
+
const orig = value[CORDIS_ORIGINAL_SYMBOL];
|
|
1199
|
+
if (orig !== null && orig !== void 0 && typeof orig === "object") return orig;
|
|
1200
|
+
}
|
|
1201
|
+
return value;
|
|
1202
|
+
}
|
|
1203
|
+
function resolveFiberModuleName(fiber) {
|
|
1204
|
+
if (fiber === null || fiber === void 0 || typeof fiber !== "object") return void 0;
|
|
1205
|
+
let cur = fiber;
|
|
1206
|
+
const visited = new Set();
|
|
1207
|
+
while (cur !== void 0 && !visited.has(cur) && visited.size < 16) {
|
|
1208
|
+
visited.add(cur);
|
|
1209
|
+
const directEntryName = cur.entry?.options?.name;
|
|
1210
|
+
const parentEntry = cur.parent?.[CORDIS_ENTRY_SYMBOL];
|
|
1211
|
+
const candidate = typeof directEntryName === "string" && directEntryName.trim() !== "" ? directEntryName.trim() : typeof parentEntry?.options?.name === "string" && parentEntry.options.name.trim() !== "" ? parentEntry.options.name.trim() : "";
|
|
1212
|
+
if (candidate !== "" && candidate !== "cordis:group" && candidate !== "@deepseek-ai/dsh-agent-preset") return candidate;
|
|
1213
|
+
const next = cur.parent?.fiber;
|
|
1214
|
+
if (next === cur) break;
|
|
1215
|
+
cur = next;
|
|
1216
|
+
}
|
|
1217
|
+
const fallbackName = fiber.name;
|
|
1218
|
+
if (typeof fallbackName === "string" && fallbackName.trim() !== "" && fallbackName !== "root" && fallbackName !== "scope" && fallbackName !== "anonymous") return fallbackName.trim();
|
|
1219
|
+
}
|
|
1220
|
+
function getAttributionStateForCtx(ctx) {
|
|
1221
|
+
const rootKey = ctx.root ?? ctx;
|
|
1222
|
+
let state = attributionByRoot.get(rootKey);
|
|
1223
|
+
if (state === void 0) {
|
|
1224
|
+
state = {
|
|
1225
|
+
owners: new Map(),
|
|
1226
|
+
scanned: new WeakSet()
|
|
1227
|
+
};
|
|
1228
|
+
attributionByRoot.set(rootKey, state);
|
|
1229
|
+
}
|
|
1230
|
+
return state;
|
|
1231
|
+
}
|
|
1232
|
+
function shouldInspectDisposableEffect(disp) {
|
|
1233
|
+
const meta = disp[CORDIS_EFFECT_SYMBOL];
|
|
1234
|
+
if (meta === void 0 || typeof meta !== "object") return true;
|
|
1235
|
+
const label = typeof meta.label === "string" ? meta.label : "";
|
|
1236
|
+
if (label === "tools.register()") return true;
|
|
1237
|
+
if (!(Array.isArray(meta.children) && meta.children.length > 0) && (label.startsWith("ctx.on(") || label.startsWith("ctx.provide(") || label.startsWith("ctx.accessor(") || label.startsWith("ctx.mixin(") || label.startsWith("ctx.plugin(") || label.startsWith("ctx.logger."))) return false;
|
|
1238
|
+
return true;
|
|
1239
|
+
}
|
|
1240
|
+
function scanCordisFiberToolOwners(ctx, targetOwners) {
|
|
1241
|
+
const state = getAttributionStateForCtx(ctx);
|
|
1242
|
+
const owners = state.owners;
|
|
1243
|
+
const syncTarget = () => {
|
|
1244
|
+
if (targetOwners !== void 0 && targetOwners !== owners) {
|
|
1245
|
+
for (const [k, v] of owners) targetOwners.set(k, v);
|
|
1246
|
+
return targetOwners;
|
|
1247
|
+
}
|
|
1248
|
+
return owners;
|
|
1249
|
+
};
|
|
1250
|
+
const root = ctx.root;
|
|
1251
|
+
const valuesFn = root?.registry?.values;
|
|
1252
|
+
if (typeof valuesFn !== "function") return syncTarget();
|
|
1253
|
+
const pendingToScan = [];
|
|
1254
|
+
try {
|
|
1255
|
+
for (const runtime of valuesFn.call(root?.registry)) {
|
|
1256
|
+
if (runtime === null || runtime === void 0 || typeof runtime !== "object") continue;
|
|
1257
|
+
const fibers = runtime.fibers;
|
|
1258
|
+
if (fibers === null || fibers === void 0 || typeof fibers[Symbol.iterator] !== "function") continue;
|
|
1259
|
+
for (const fiber of fibers) {
|
|
1260
|
+
if (fiber === null || fiber === void 0 || typeof fiber !== "object") continue;
|
|
1261
|
+
if (fiber.uid === null) continue;
|
|
1262
|
+
const modName = resolveFiberModuleName(fiber);
|
|
1263
|
+
if (modName === void 0 || modName === "root") continue;
|
|
1264
|
+
const disposables = fiber._disposables;
|
|
1265
|
+
if (disposables === null || disposables === void 0 || typeof disposables[Symbol.iterator] !== "function") continue;
|
|
1266
|
+
for (const disp of disposables) {
|
|
1267
|
+
if (disp === null || disp === void 0 || typeof disp !== "function" && typeof disp !== "object") continue;
|
|
1268
|
+
if (state.scanned.has(disp)) continue;
|
|
1269
|
+
if (!shouldInspectDisposableEffect(disp)) {
|
|
1270
|
+
state.scanned.add(disp);
|
|
1271
|
+
continue;
|
|
1272
|
+
}
|
|
1273
|
+
pendingToScan.push({
|
|
1274
|
+
modName,
|
|
1275
|
+
disp
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
} catch {
|
|
1281
|
+
return syncTarget();
|
|
1282
|
+
}
|
|
1283
|
+
if (pendingToScan.length === 0) return syncTarget();
|
|
1284
|
+
const probeKey = "__dshDesktopEnhanceToolProbe__";
|
|
1285
|
+
let session;
|
|
1286
|
+
try {
|
|
1287
|
+
session = new nodeInspector.Session();
|
|
1288
|
+
session.connect();
|
|
1289
|
+
const activeSession = session;
|
|
1290
|
+
const postSync = (method, params) => {
|
|
1291
|
+
let out;
|
|
1292
|
+
activeSession.post(method, params, (err, res) => {
|
|
1293
|
+
if (!err) out = res;
|
|
1294
|
+
});
|
|
1295
|
+
return out;
|
|
1296
|
+
};
|
|
1297
|
+
const getClosureVars = (objectId) => {
|
|
1298
|
+
const scopesId = (postSync("Runtime.getProperties", {
|
|
1299
|
+
objectId,
|
|
1300
|
+
ownProperties: false
|
|
1301
|
+
})?.internalProperties?.find((p) => p.name === "[[Scopes]]"))?.value?.objectId;
|
|
1302
|
+
if (typeof scopesId !== "string") return [];
|
|
1303
|
+
const scopeList = postSync("Runtime.getProperties", {
|
|
1304
|
+
objectId: scopesId,
|
|
1305
|
+
ownProperties: true
|
|
1306
|
+
});
|
|
1307
|
+
const vars = [];
|
|
1308
|
+
for (const scopeItem of scopeList?.result ?? []) {
|
|
1309
|
+
const sid = scopeItem.value?.objectId;
|
|
1310
|
+
if (typeof sid !== "string") continue;
|
|
1311
|
+
const scopeVars = postSync("Runtime.getProperties", {
|
|
1312
|
+
objectId: sid,
|
|
1313
|
+
ownProperties: true
|
|
1314
|
+
});
|
|
1315
|
+
if (Array.isArray(scopeVars?.result)) vars.push(...scopeVars.result);
|
|
1316
|
+
}
|
|
1317
|
+
return vars;
|
|
1318
|
+
};
|
|
1319
|
+
const extractToolNames = (objectId, depth = 0) => {
|
|
1320
|
+
if (depth > 3) return [];
|
|
1321
|
+
const found = [];
|
|
1322
|
+
const vars = getClosureVars(objectId);
|
|
1323
|
+
const undoFn = vars.find((v) => v.name === "undo");
|
|
1324
|
+
if (typeof undoFn?.value?.objectId === "string") {
|
|
1325
|
+
const nameVar = getClosureVars(undoFn.value.objectId).find((v) => v.name === "name");
|
|
1326
|
+
if (typeof nameVar?.value?.value === "string" && nameVar.value.value.trim() !== "") found.push(nameVar.value.value.trim());
|
|
1327
|
+
}
|
|
1328
|
+
for (const arrName of ["disposables", "disposers"]) {
|
|
1329
|
+
const arr = vars.find((v) => v.name === arrName);
|
|
1330
|
+
if (typeof arr?.value?.objectId === "string") {
|
|
1331
|
+
const items = postSync("Runtime.getProperties", {
|
|
1332
|
+
objectId: arr.value.objectId,
|
|
1333
|
+
ownProperties: true
|
|
1334
|
+
});
|
|
1335
|
+
for (const item of items?.result ?? []) if (typeof item.name === "string" && /^\d+$/.test(item.name) && typeof item.value?.objectId === "string") found.push(...extractToolNames(item.value.objectId, depth + 1));
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
return found;
|
|
1339
|
+
};
|
|
1340
|
+
for (const { modName, disp } of pendingToScan) {
|
|
1341
|
+
globalThis[probeKey] = disp;
|
|
1342
|
+
const objId = postSync("Runtime.evaluate", { expression: `globalThis.${probeKey}` })?.result?.objectId;
|
|
1343
|
+
if (typeof objId === "string") {
|
|
1344
|
+
for (const toolName of extractToolNames(objId)) owners.set(toolName, modName);
|
|
1345
|
+
state.scanned.add(disp);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
} catch {} finally {
|
|
1349
|
+
delete globalThis[probeKey];
|
|
1350
|
+
try {
|
|
1351
|
+
session?.disconnect();
|
|
1352
|
+
} catch {}
|
|
1353
|
+
}
|
|
1354
|
+
return syncTarget();
|
|
1355
|
+
}
|
|
1356
|
+
function attachToolRegisterAttribution(ctx, toolsService) {
|
|
1357
|
+
const rawTools = unwrapCordisOriginal(toolsService);
|
|
1358
|
+
if (rawTools === null || rawTools === void 0 || typeof rawTools !== "object") return void 0;
|
|
1359
|
+
if (instrumentedToolServices.has(rawTools)) return void 0;
|
|
1360
|
+
const origRegister = rawTools.register;
|
|
1361
|
+
if (typeof origRegister !== "function") return void 0;
|
|
1362
|
+
const { owners } = getAttributionStateForCtx(ctx);
|
|
1363
|
+
instrumentedToolServices.add(rawTools);
|
|
1364
|
+
const wrappedRegister = function(definition) {
|
|
1365
|
+
const toolName = definition !== null && definition !== void 0 && typeof definition === "object" ? definition.name : void 0;
|
|
1366
|
+
const callerFiber = this?.ctx?.fiber;
|
|
1367
|
+
const modName = resolveFiberModuleName(callerFiber);
|
|
1368
|
+
if (typeof toolName === "string" && toolName.trim() !== "" && modName !== void 0 && modName !== "root") owners.set(toolName.trim(), modName);
|
|
1369
|
+
return origRegister.call(this, definition);
|
|
1370
|
+
};
|
|
1371
|
+
try {
|
|
1372
|
+
rawTools.register = wrappedRegister;
|
|
1373
|
+
return () => {
|
|
1374
|
+
if (rawTools.register === wrappedRegister) rawTools.register = origRegister;
|
|
1375
|
+
instrumentedToolServices.delete(rawTools);
|
|
1376
|
+
};
|
|
1377
|
+
} catch {
|
|
1378
|
+
instrumentedToolServices.delete(rawTools);
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
function appendSchemas(target, list, owners) {
|
|
625
1383
|
if (!Array.isArray(list)) return;
|
|
626
|
-
for (const item of list)
|
|
1384
|
+
for (const item of list) {
|
|
1385
|
+
if (item === null || item === void 0 || typeof item !== "object") continue;
|
|
1386
|
+
const rawName = typeof item.name === "string" ? item.name.trim() : "";
|
|
1387
|
+
const existingPlugin = item.pluginName;
|
|
1388
|
+
const attributedPlugin = typeof existingPlugin === "string" && existingPlugin.trim() !== "" ? existingPlugin.trim() : rawName !== "" ? owners.get(rawName) : void 0;
|
|
1389
|
+
target.push({
|
|
1390
|
+
...item,
|
|
1391
|
+
...attributedPlugin !== void 0 ? { pluginName: attributedPlugin } : {}
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
627
1394
|
}
|
|
628
1395
|
async function collectAllToolSchemas(ctx) {
|
|
629
1396
|
const toolsService = ctx.get("tools");
|
|
630
1397
|
if (toolsService === null || toolsService === void 0 || typeof toolsService.schemas !== "function") return [];
|
|
1398
|
+
const owners = scanCordisFiberToolOwners(ctx);
|
|
631
1399
|
const rawItems = [];
|
|
632
1400
|
try {
|
|
633
|
-
appendSchemas(rawItems, toolsService.schemas());
|
|
1401
|
+
appendSchemas(rawItems, toolsService.schemas(), owners);
|
|
634
1402
|
} catch {}
|
|
635
1403
|
const presetsService = ctx.get("agentPresets");
|
|
636
1404
|
if (presetsService !== null && presetsService !== void 0 && typeof presetsService.list === "function" && typeof presetsService.acquireScope === "function") {
|
|
@@ -647,7 +1415,7 @@ async function collectAllToolSchemas(ctx) {
|
|
|
647
1415
|
let lease;
|
|
648
1416
|
try {
|
|
649
1417
|
lease = await presetsService.acquireScope(id);
|
|
650
|
-
if (lease !== null && lease !== void 0 && lease.key !== void 0) appendSchemas(rawItems, toolsService.schemas(lease.key));
|
|
1418
|
+
if (lease !== null && lease !== void 0 && lease.key !== void 0) appendSchemas(rawItems, toolsService.schemas(lease.key), owners);
|
|
651
1419
|
} catch {} finally {
|
|
652
1420
|
await disposePresetLease(lease);
|
|
653
1421
|
}
|
|
@@ -656,7 +1424,7 @@ async function collectAllToolSchemas(ctx) {
|
|
|
656
1424
|
try {
|
|
657
1425
|
const scopedMap = toolsService.layers?.scoped;
|
|
658
1426
|
if (scopedMap !== void 0 && typeof scopedMap.keys === "function") for (const scopeKey of scopedMap.keys()) try {
|
|
659
|
-
appendSchemas(rawItems, toolsService.schemas(scopeKey));
|
|
1427
|
+
appendSchemas(rawItems, toolsService.schemas(scopeKey), owners);
|
|
660
1428
|
} catch {}
|
|
661
1429
|
} catch {}
|
|
662
1430
|
return normalizeToolSummaries(rawItems, EXCLUDED_TOOLS);
|
|
@@ -664,9 +1432,9 @@ async function collectAllToolSchemas(ctx) {
|
|
|
664
1432
|
function installToolsPolicy(ctx, readState) {
|
|
665
1433
|
const disposers = [];
|
|
666
1434
|
if (typeof ctx.on === "function") try {
|
|
667
|
-
const offAssemble = ctx.on("system-prompt/assemble", async (_assembly,
|
|
1435
|
+
const offAssemble = ctx.on("system-prompt/assemble", async (_assembly, context, next) => {
|
|
668
1436
|
const result = await next();
|
|
669
|
-
const { enabled, disabled } = readState();
|
|
1437
|
+
const { enabled, disabled } = readState(resolveSessionIdFromScope(context, ctx));
|
|
670
1438
|
if (!enabled || disabled.size === 0 || !Array.isArray(result?.tools)) return result;
|
|
671
1439
|
const filtered = filterToolSchemas(result.tools, enabled, disabled);
|
|
672
1440
|
if (filtered.length === result.tools.length) return result;
|
|
@@ -681,10 +1449,13 @@ function installToolsPolicy(ctx, readState) {
|
|
|
681
1449
|
}
|
|
682
1450
|
const attachGuard = (targetCtx) => {
|
|
683
1451
|
const toolsService = targetCtx.get("tools");
|
|
684
|
-
if (toolsService === null || toolsService === void 0
|
|
1452
|
+
if (toolsService === null || toolsService === void 0) return;
|
|
1453
|
+
const offAttr = attachToolRegisterAttribution(targetCtx, toolsService);
|
|
1454
|
+
if (typeof offAttr === "function") disposers.push(offAttr);
|
|
1455
|
+
if (typeof toolsService.guard !== "function") return;
|
|
685
1456
|
try {
|
|
686
1457
|
const offGuard = toolsService.guard((exec) => {
|
|
687
|
-
const { enabled, disabled } = readState();
|
|
1458
|
+
const { enabled, disabled } = readState(resolveSessionIdFromScope(exec.agent, targetCtx));
|
|
688
1459
|
return disabledToolReason(exec.name, enabled, disabled);
|
|
689
1460
|
});
|
|
690
1461
|
if (typeof offGuard === "function") disposers.push(offGuard);
|
|
@@ -710,9 +1481,9 @@ function installToolsPolicy(ctx, readState) {
|
|
|
710
1481
|
}
|
|
711
1482
|
async function handleToolsCatalog(ctx) {
|
|
712
1483
|
try {
|
|
713
|
-
return
|
|
1484
|
+
return jsonResponse({ tools: await collectAllToolSchemas(ctx) });
|
|
714
1485
|
} catch {
|
|
715
|
-
return
|
|
1486
|
+
return jsonResponse({ tools: [] });
|
|
716
1487
|
}
|
|
717
1488
|
}
|
|
718
1489
|
function registerToolsRoute(ctx) {
|
|
@@ -730,6 +1501,417 @@ function registerToolsRoute(ctx) {
|
|
|
730
1501
|
};
|
|
731
1502
|
}
|
|
732
1503
|
//#endregion
|
|
1504
|
+
//#region src/session-info/host.ts
|
|
1505
|
+
const SESSION_INFO_PATH = SESSION_INFO_ROUTE;
|
|
1506
|
+
const EMPTY_PROJECTION = {
|
|
1507
|
+
skills: [],
|
|
1508
|
+
nodes: [],
|
|
1509
|
+
windowStartSeq: null,
|
|
1510
|
+
replacedRanges: [],
|
|
1511
|
+
shadowedSeqs: []
|
|
1512
|
+
};
|
|
1513
|
+
async function readAllSessionEvents(ctx, sessionId) {
|
|
1514
|
+
const sessions = ctx.get("sessions");
|
|
1515
|
+
if (sessions !== null && sessions !== void 0 && typeof sessions.get === "function") try {
|
|
1516
|
+
const live = sessions.get(sessionId);
|
|
1517
|
+
if (live !== void 0 && typeof live.snapshotEvents === "function") {
|
|
1518
|
+
const events = live.snapshotEvents();
|
|
1519
|
+
if (Array.isArray(events)) return events;
|
|
1520
|
+
}
|
|
1521
|
+
} catch {}
|
|
1522
|
+
const query = ctx.get("sessionQuery");
|
|
1523
|
+
if (query === null || query === void 0 || typeof query.observeSession !== "function") return null;
|
|
1524
|
+
let observation;
|
|
1525
|
+
try {
|
|
1526
|
+
observation = await query.observeSession(sessionId, { projectionMode: "none" });
|
|
1527
|
+
const events = observation?.events;
|
|
1528
|
+
return Array.isArray(events) ? events : null;
|
|
1529
|
+
} catch {
|
|
1530
|
+
return null;
|
|
1531
|
+
} finally {
|
|
1532
|
+
await disposeResource(observation);
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
async function handleSessionInfo(ctx, request) {
|
|
1536
|
+
let sessionId;
|
|
1537
|
+
try {
|
|
1538
|
+
sessionId = (await request.json())?.sessionId;
|
|
1539
|
+
} catch {
|
|
1540
|
+
return jsonResponse(EMPTY_PROJECTION, 400);
|
|
1541
|
+
}
|
|
1542
|
+
if (typeof sessionId !== "string" || sessionId === "") return jsonResponse(EMPTY_PROJECTION, 400);
|
|
1543
|
+
const events = await readAllSessionEvents(ctx, sessionId);
|
|
1544
|
+
if (events === null) return jsonResponse(EMPTY_PROJECTION);
|
|
1545
|
+
return jsonResponse(projectSkills(events));
|
|
1546
|
+
}
|
|
1547
|
+
function registerSessionInfoRoute(ctx) {
|
|
1548
|
+
const connection = ctx.get("connection");
|
|
1549
|
+
const register = connection?.fetch?.register;
|
|
1550
|
+
if (typeof register !== "function") return () => {};
|
|
1551
|
+
const dispose = register.call(connection?.fetch, {
|
|
1552
|
+
path: SESSION_INFO_PATH,
|
|
1553
|
+
methods: ["POST"],
|
|
1554
|
+
requestBody: "buffered",
|
|
1555
|
+
fetch: (request) => handleSessionInfo(ctx, request)
|
|
1556
|
+
});
|
|
1557
|
+
return () => {
|
|
1558
|
+
Promise.resolve().then(() => dispose()).catch(() => void 0);
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1561
|
+
//#endregion
|
|
1562
|
+
//#region src/shared/skills-manager.ts
|
|
1563
|
+
function extractPackageBadgeFromPath(rawPath) {
|
|
1564
|
+
const normalized = rawPath.replaceAll("\\", "/");
|
|
1565
|
+
const nmMatch = /\/node_modules\/((?:@[^/]+\/[^/]+)|(?:[^/]+))\//.exec(normalized);
|
|
1566
|
+
if (nmMatch?.[1] !== void 0) {
|
|
1567
|
+
const pkg = nmMatch[1];
|
|
1568
|
+
return pkg.startsWith("@deepseek-ai/") ? pkg.slice(13) : pkg;
|
|
1569
|
+
}
|
|
1570
|
+
if (normalized.includes("/app.asar/") || normalized.includes("/office-skills/")) return "bundled";
|
|
1571
|
+
}
|
|
1572
|
+
function classifySkillScope(rawSource, rawProvider, rawPath) {
|
|
1573
|
+
const source = typeof rawSource === "string" ? rawSource.trim() : "";
|
|
1574
|
+
const provider = typeof rawProvider === "string" ? rawProvider.trim() : "";
|
|
1575
|
+
const path = typeof rawPath === "string" ? rawPath.trim() : "";
|
|
1576
|
+
if (source === "project-dsh") return {
|
|
1577
|
+
scope: "project",
|
|
1578
|
+
sourceBadge: ".dsh/skills"
|
|
1579
|
+
};
|
|
1580
|
+
if (source === "project-agents") return {
|
|
1581
|
+
scope: "project",
|
|
1582
|
+
sourceBadge: ".agents/skills"
|
|
1583
|
+
};
|
|
1584
|
+
if (source.startsWith("project")) return {
|
|
1585
|
+
scope: "project",
|
|
1586
|
+
sourceBadge: source
|
|
1587
|
+
};
|
|
1588
|
+
if (source === "user-dsh") return {
|
|
1589
|
+
scope: "global",
|
|
1590
|
+
sourceBadge: "~/.dsh/skills"
|
|
1591
|
+
};
|
|
1592
|
+
if (source === "user-agents") return {
|
|
1593
|
+
scope: "global",
|
|
1594
|
+
sourceBadge: "~/.agents/skills"
|
|
1595
|
+
};
|
|
1596
|
+
if (source.startsWith("user")) return {
|
|
1597
|
+
scope: "global",
|
|
1598
|
+
sourceBadge: source
|
|
1599
|
+
};
|
|
1600
|
+
if (source === "custom") {
|
|
1601
|
+
const pkgBadge = path !== "" ? extractPackageBadgeFromPath(path) : void 0;
|
|
1602
|
+
if (pkgBadge !== void 0) return {
|
|
1603
|
+
scope: "plugin",
|
|
1604
|
+
sourceBadge: pkgBadge
|
|
1605
|
+
};
|
|
1606
|
+
return {
|
|
1607
|
+
scope: "global",
|
|
1608
|
+
sourceBadge: "custom"
|
|
1609
|
+
};
|
|
1610
|
+
}
|
|
1611
|
+
if (source === "bundled") return {
|
|
1612
|
+
scope: "plugin",
|
|
1613
|
+
sourceBadge: provider !== "" && provider !== "filesystem" ? provider : (path !== "" ? extractPackageBadgeFromPath(path) : void 0) ?? "bundled"
|
|
1614
|
+
};
|
|
1615
|
+
if (provider !== "" && provider !== "filesystem") return {
|
|
1616
|
+
scope: "plugin",
|
|
1617
|
+
sourceBadge: provider
|
|
1618
|
+
};
|
|
1619
|
+
if (provider === "filesystem") {
|
|
1620
|
+
const pkgBadge = path !== "" ? extractPackageBadgeFromPath(path) : void 0;
|
|
1621
|
+
if (pkgBadge !== void 0) return {
|
|
1622
|
+
scope: "plugin",
|
|
1623
|
+
sourceBadge: pkgBadge
|
|
1624
|
+
};
|
|
1625
|
+
return {
|
|
1626
|
+
scope: "global",
|
|
1627
|
+
sourceBadge: source !== "" ? source : "filesystem"
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1630
|
+
return {
|
|
1631
|
+
scope: "plugin",
|
|
1632
|
+
sourceBadge: provider || source || "plugin"
|
|
1633
|
+
};
|
|
1634
|
+
}
|
|
1635
|
+
function normalizeSkillCatalogItems(list, options) {
|
|
1636
|
+
const includeProject = options?.includeProject ?? true;
|
|
1637
|
+
const byName = new Map();
|
|
1638
|
+
for (const raw of list) {
|
|
1639
|
+
if (raw === null || raw === void 0 || typeof raw !== "object") continue;
|
|
1640
|
+
const row = raw;
|
|
1641
|
+
const name = typeof row.name === "string" ? row.name.trim() : "";
|
|
1642
|
+
if (name === "" || byName.has(name)) continue;
|
|
1643
|
+
const description = typeof row.description === "string" ? row.description.trim() : "";
|
|
1644
|
+
const source = typeof row.source === "string" ? row.source.trim() : "";
|
|
1645
|
+
const provider = typeof row.provider === "string" ? row.provider.trim() : "";
|
|
1646
|
+
const path = typeof row.path === "string" && row.path.trim() !== "" ? row.path.trim() : void 0;
|
|
1647
|
+
const { scope, sourceBadge } = classifySkillScope(source, provider, path);
|
|
1648
|
+
if (!includeProject && scope === "project") continue;
|
|
1649
|
+
const invocation = typeof row.invocation === "object" && row.invocation !== null ? row.invocation : null;
|
|
1650
|
+
const modelInvocable = typeof row.modelInvocable === "boolean" ? row.modelInvocable : typeof invocation?.modelInvocable === "boolean" ? invocation.modelInvocable : true;
|
|
1651
|
+
const userInvocable = typeof row.userInvocable === "boolean" ? row.userInvocable : typeof invocation?.userInvocable === "boolean" ? invocation.userInvocable : true;
|
|
1652
|
+
const whenToUse = typeof row.whenToUse === "string" && row.whenToUse.trim() !== "" ? row.whenToUse.trim() : void 0;
|
|
1653
|
+
byName.set(name, {
|
|
1654
|
+
name,
|
|
1655
|
+
description,
|
|
1656
|
+
source,
|
|
1657
|
+
provider,
|
|
1658
|
+
scope,
|
|
1659
|
+
sourceBadge,
|
|
1660
|
+
...path === void 0 ? {} : { path },
|
|
1661
|
+
...whenToUse === void 0 ? {} : { whenToUse },
|
|
1662
|
+
modelInvocable,
|
|
1663
|
+
userInvocable
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
return [...byName.values()].sort((a, b) => compareCodeUnits(a.name, b.name));
|
|
1667
|
+
}
|
|
1668
|
+
function isSkillDisabled(skillName, enabled, disabled) {
|
|
1669
|
+
if (!enabled || disabled.size === 0 || typeof skillName !== "string") return false;
|
|
1670
|
+
const trimmed = skillName.trim();
|
|
1671
|
+
return trimmed !== "" && disabled.has(trimmed);
|
|
1672
|
+
}
|
|
1673
|
+
function filterSkillsList(skills, enabled, disabled) {
|
|
1674
|
+
if (!enabled || disabled.size === 0) return [...skills];
|
|
1675
|
+
return skills.filter((skill) => !disabled.has(skill.name));
|
|
1676
|
+
}
|
|
1677
|
+
//#endregion
|
|
1678
|
+
//#region src/skills-manager/host.ts
|
|
1679
|
+
const SKILLS_PATH = SKILLS_ROUTE;
|
|
1680
|
+
const rawSkillListMap = new WeakMap();
|
|
1681
|
+
function getUnfilteredList(skillsService) {
|
|
1682
|
+
const raw = rawSkillListMap.get(skillsService);
|
|
1683
|
+
if (raw !== void 0) return raw;
|
|
1684
|
+
if (typeof skillsService.list === "function") return skillsService.list.bind(skillsService);
|
|
1685
|
+
}
|
|
1686
|
+
function readSkillsConfig(config, sessionId) {
|
|
1687
|
+
if (config === null || config === void 0 || typeof config !== "object") return {
|
|
1688
|
+
enabled: true,
|
|
1689
|
+
disabled: new Set()
|
|
1690
|
+
};
|
|
1691
|
+
const raw = config;
|
|
1692
|
+
const flag = unwrapVolatile(raw.skillsManager);
|
|
1693
|
+
const list = unwrapVolatile(raw.disabledSkills);
|
|
1694
|
+
const overrides = unwrapVolatile(raw.sessionSkillOverrides);
|
|
1695
|
+
return {
|
|
1696
|
+
enabled: typeof flag === "boolean" ? flag : true,
|
|
1697
|
+
disabled: resolveEffectiveDisabled(list, overrides, sessionId)
|
|
1698
|
+
};
|
|
1699
|
+
}
|
|
1700
|
+
async function resolveSessionLookupContext(ctx, sessionId) {
|
|
1701
|
+
let cwd;
|
|
1702
|
+
let agentPreset;
|
|
1703
|
+
const agents = ctx.get("agents");
|
|
1704
|
+
const live = typeof agents?.get === "function" ? agents.get(sessionId) : void 0;
|
|
1705
|
+
const workingDir = ctx.get("workingDirectory");
|
|
1706
|
+
if (live !== void 0 && typeof workingDir?.ensure === "function") try {
|
|
1707
|
+
const liveCwd = await workingDir.ensure(live);
|
|
1708
|
+
if (typeof liveCwd === "string" && liveCwd.trim() !== "") cwd = liveCwd.trim();
|
|
1709
|
+
} catch {}
|
|
1710
|
+
const sessionQuery = ctx.get("sessionQuery");
|
|
1711
|
+
if (typeof sessionQuery?.observeSession === "function") {
|
|
1712
|
+
let observation;
|
|
1713
|
+
try {
|
|
1714
|
+
observation = await sessionQuery.observeSession(sessionId);
|
|
1715
|
+
const projCwd = observation?.projections?.values?.workingDirectory ?? observation?.header?.cwd;
|
|
1716
|
+
if (cwd === void 0 && typeof projCwd === "string" && projCwd.trim() !== "") cwd = projCwd.trim();
|
|
1717
|
+
const preset = observation?.projections?.values?.agentPreset;
|
|
1718
|
+
if (typeof preset === "string" && preset.trim() !== "") agentPreset = preset.trim();
|
|
1719
|
+
} catch {} finally {
|
|
1720
|
+
await disposeResource(observation);
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
if (cwd === void 0 && typeof workingDir?.defaultDirectory === "string" && workingDir.defaultDirectory.trim() !== "") cwd = workingDir.defaultDirectory.trim();
|
|
1724
|
+
return {
|
|
1725
|
+
...cwd === void 0 ? {} : { cwd },
|
|
1726
|
+
...agentPreset === void 0 ? {} : { agentPreset },
|
|
1727
|
+
...live === void 0 ? {} : { live }
|
|
1728
|
+
};
|
|
1729
|
+
}
|
|
1730
|
+
async function appendSkillsFromList(target, listFn, options) {
|
|
1731
|
+
try {
|
|
1732
|
+
const rows = await listFn(options);
|
|
1733
|
+
if (Array.isArray(rows)) for (const item of rows) target.push(item);
|
|
1734
|
+
} catch {}
|
|
1735
|
+
}
|
|
1736
|
+
async function appendAllPresetAndScopedSkills(ctx, skillsService, listFn, rawItems, cwd) {
|
|
1737
|
+
const presetsService = ctx.get("agentPresets");
|
|
1738
|
+
if (presetsService !== null && presetsService !== void 0 && typeof presetsService.list === "function" && typeof presetsService.acquireScope === "function") {
|
|
1739
|
+
let presets = [];
|
|
1740
|
+
try {
|
|
1741
|
+
const rows = await presetsService.list();
|
|
1742
|
+
if (Array.isArray(rows)) presets = rows;
|
|
1743
|
+
} catch {}
|
|
1744
|
+
for (const row of presets) {
|
|
1745
|
+
if (row === null || row === void 0 || typeof row !== "object") continue;
|
|
1746
|
+
if (row.broken !== void 0 && row.broken !== null && row.broken !== "") continue;
|
|
1747
|
+
const id = typeof row.id === "string" ? row.id.trim() : "";
|
|
1748
|
+
if (id === "") continue;
|
|
1749
|
+
let lease;
|
|
1750
|
+
try {
|
|
1751
|
+
lease = await presetsService.acquireScope(id);
|
|
1752
|
+
if (lease?.key !== void 0) await appendSkillsFromList(rawItems, listFn, {
|
|
1753
|
+
...cwd === void 0 ? {} : { cwd },
|
|
1754
|
+
scope: lease.key
|
|
1755
|
+
});
|
|
1756
|
+
} catch {} finally {
|
|
1757
|
+
await disposeResource(lease);
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
try {
|
|
1762
|
+
const scopedMap = skillsService.layers?.scoped;
|
|
1763
|
+
if (scopedMap !== void 0 && typeof scopedMap.keys === "function") for (const scopeKey of scopedMap.keys()) await appendSkillsFromList(rawItems, listFn, {
|
|
1764
|
+
...cwd === void 0 ? {} : { cwd },
|
|
1765
|
+
scope: scopeKey
|
|
1766
|
+
});
|
|
1767
|
+
} catch {}
|
|
1768
|
+
}
|
|
1769
|
+
async function collectSkillCatalog(ctx, sessionId) {
|
|
1770
|
+
const skillsService = ctx.get("skills");
|
|
1771
|
+
if (skillsService === null || skillsService === void 0) return [];
|
|
1772
|
+
const listFn = getUnfilteredList(skillsService);
|
|
1773
|
+
if (listFn === void 0) return [];
|
|
1774
|
+
const sid = typeof sessionId === "string" ? sessionId.trim() : "";
|
|
1775
|
+
const rawItems = [];
|
|
1776
|
+
const presetsService = ctx.get("agentPresets");
|
|
1777
|
+
if (sid !== "") {
|
|
1778
|
+
const { cwd, agentPreset, live } = await resolveSessionLookupContext(ctx, sid);
|
|
1779
|
+
if (live !== void 0) await appendSkillsFromList(rawItems, listFn, {
|
|
1780
|
+
cwd,
|
|
1781
|
+
scope: live
|
|
1782
|
+
});
|
|
1783
|
+
else if (agentPreset !== void 0 && presetsService !== null && presetsService !== void 0 && typeof presetsService.acquireScope === "function") {
|
|
1784
|
+
let lease;
|
|
1785
|
+
try {
|
|
1786
|
+
lease = await presetsService.acquireScope(agentPreset);
|
|
1787
|
+
await appendSkillsFromList(rawItems, listFn, {
|
|
1788
|
+
cwd,
|
|
1789
|
+
scope: lease?.key
|
|
1790
|
+
});
|
|
1791
|
+
} catch {
|
|
1792
|
+
await appendSkillsFromList(rawItems, listFn, { cwd });
|
|
1793
|
+
} finally {
|
|
1794
|
+
await disposeResource(lease);
|
|
1795
|
+
}
|
|
1796
|
+
} else {
|
|
1797
|
+
await appendSkillsFromList(rawItems, listFn, { cwd });
|
|
1798
|
+
await appendAllPresetAndScopedSkills(ctx, skillsService, listFn, rawItems, cwd);
|
|
1799
|
+
}
|
|
1800
|
+
return normalizeSkillCatalogItems(rawItems, { includeProject: true });
|
|
1801
|
+
}
|
|
1802
|
+
await appendSkillsFromList(rawItems, listFn, {});
|
|
1803
|
+
await appendAllPresetAndScopedSkills(ctx, skillsService, listFn, rawItems, void 0);
|
|
1804
|
+
return normalizeSkillCatalogItems(rawItems, { includeProject: false });
|
|
1805
|
+
}
|
|
1806
|
+
function installSkillsPolicy(ctx, readState) {
|
|
1807
|
+
const disposers = [];
|
|
1808
|
+
const patchSkillsService = (targetCtx) => {
|
|
1809
|
+
const skillsService = targetCtx.get("skills");
|
|
1810
|
+
if (skillsService === null || skillsService === void 0 || typeof skillsService !== "object") return;
|
|
1811
|
+
const origList = typeof skillsService.list === "function" ? skillsService.list.bind(skillsService) : void 0;
|
|
1812
|
+
const origSnapshot = typeof skillsService.snapshot === "function" ? skillsService.snapshot.bind(skillsService) : void 0;
|
|
1813
|
+
const origGet = typeof skillsService.get === "function" ? skillsService.get.bind(skillsService) : void 0;
|
|
1814
|
+
if (origList !== void 0) {
|
|
1815
|
+
rawSkillListMap.set(skillsService, origList);
|
|
1816
|
+
skillsService.list = async (options) => {
|
|
1817
|
+
const items = await origList(options);
|
|
1818
|
+
const { enabled, disabled } = readState(resolveSessionIdFromScope(options?.scope, targetCtx));
|
|
1819
|
+
return filterSkillsList(items, enabled, disabled);
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1822
|
+
if (origSnapshot !== void 0) skillsService.snapshot = async (options) => {
|
|
1823
|
+
const snap = await origSnapshot(options);
|
|
1824
|
+
const { enabled, disabled } = readState(resolveSessionIdFromScope(options?.scope, targetCtx));
|
|
1825
|
+
if (!enabled || disabled.size === 0 || !Array.isArray(snap?.skills)) return snap;
|
|
1826
|
+
const filtered = filterSkillsList(snap.skills, enabled, disabled);
|
|
1827
|
+
if (filtered.length === snap.skills.length) return snap;
|
|
1828
|
+
return {
|
|
1829
|
+
...snap,
|
|
1830
|
+
skills: filtered
|
|
1831
|
+
};
|
|
1832
|
+
};
|
|
1833
|
+
if (origGet !== void 0) skillsService.get = async (name, options) => {
|
|
1834
|
+
const { enabled, disabled } = readState(resolveSessionIdFromScope(options?.scope, targetCtx));
|
|
1835
|
+
if (isSkillDisabled(name, enabled, disabled)) return void 0;
|
|
1836
|
+
return await origGet(name, options);
|
|
1837
|
+
};
|
|
1838
|
+
disposers.push(() => {
|
|
1839
|
+
rawSkillListMap.delete(skillsService);
|
|
1840
|
+
if (origList !== void 0) skillsService.list = origList;
|
|
1841
|
+
if (origSnapshot !== void 0) skillsService.snapshot = origSnapshot;
|
|
1842
|
+
if (origGet !== void 0) skillsService.get = origGet;
|
|
1843
|
+
});
|
|
1844
|
+
};
|
|
1845
|
+
const patchSessionCatalog = (targetCtx) => {
|
|
1846
|
+
const catalogService = targetCtx.get("sessionSkillCatalog");
|
|
1847
|
+
if (catalogService === null || catalogService === void 0 || typeof catalogService.list !== "function") return;
|
|
1848
|
+
const origCatalogList = catalogService.list.bind(catalogService);
|
|
1849
|
+
catalogService.list = async (request, signal) => {
|
|
1850
|
+
const res = await origCatalogList(request, signal);
|
|
1851
|
+
const { enabled, disabled } = readState(typeof request?.sessionId === "string" ? request.sessionId.trim() : void 0);
|
|
1852
|
+
if (!enabled || disabled.size === 0 || !Array.isArray(res?.skills)) return res;
|
|
1853
|
+
return {
|
|
1854
|
+
...res,
|
|
1855
|
+
skills: filterSkillsList(res.skills, enabled, disabled)
|
|
1856
|
+
};
|
|
1857
|
+
};
|
|
1858
|
+
disposers.push(() => {
|
|
1859
|
+
catalogService.list = origCatalogList;
|
|
1860
|
+
});
|
|
1861
|
+
};
|
|
1862
|
+
const skillsNow = ctx.get("skills");
|
|
1863
|
+
if (skillsNow !== null && skillsNow !== void 0) patchSkillsService(ctx);
|
|
1864
|
+
else if (typeof ctx.inject === "function") try {
|
|
1865
|
+
const offInject = ctx.inject(["skills"], (sctx) => {
|
|
1866
|
+
patchSkillsService(sctx);
|
|
1867
|
+
});
|
|
1868
|
+
if (typeof offInject === "function") disposers.push(() => {
|
|
1869
|
+
offInject();
|
|
1870
|
+
});
|
|
1871
|
+
} catch {}
|
|
1872
|
+
const catalogNow = ctx.get("sessionSkillCatalog");
|
|
1873
|
+
if (catalogNow !== null && catalogNow !== void 0) patchSessionCatalog(ctx);
|
|
1874
|
+
else if (typeof ctx.inject === "function") try {
|
|
1875
|
+
const offInject = ctx.inject(["sessionSkillCatalog"], (cctx) => {
|
|
1876
|
+
patchSessionCatalog(cctx);
|
|
1877
|
+
});
|
|
1878
|
+
if (typeof offInject === "function") disposers.push(() => {
|
|
1879
|
+
offInject();
|
|
1880
|
+
});
|
|
1881
|
+
} catch {}
|
|
1882
|
+
return () => {
|
|
1883
|
+
for (const dispose of disposers.splice(0)) try {
|
|
1884
|
+
dispose();
|
|
1885
|
+
} catch {}
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
async function handleSkillsCatalog(ctx, request) {
|
|
1889
|
+
let sessionId;
|
|
1890
|
+
if (request !== void 0 && typeof request.url === "string") try {
|
|
1891
|
+
const rawSid = new URL(request.url, "http://localhost").searchParams.get("sessionId");
|
|
1892
|
+
if (rawSid !== null && rawSid.trim() !== "") sessionId = rawSid.trim();
|
|
1893
|
+
} catch {}
|
|
1894
|
+
try {
|
|
1895
|
+
return jsonResponse({ skills: await collectSkillCatalog(ctx, sessionId) });
|
|
1896
|
+
} catch {
|
|
1897
|
+
return jsonResponse({ skills: [] });
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
function registerSkillsRoute(ctx) {
|
|
1901
|
+
const connection = ctx.get("connection");
|
|
1902
|
+
const register = connection?.fetch?.register;
|
|
1903
|
+
if (typeof register !== "function") return () => {};
|
|
1904
|
+
const dispose = register.call(connection?.fetch, {
|
|
1905
|
+
path: SKILLS_PATH,
|
|
1906
|
+
methods: ["GET"],
|
|
1907
|
+
requestBody: "buffered",
|
|
1908
|
+
fetch: (request) => handleSkillsCatalog(ctx, request)
|
|
1909
|
+
});
|
|
1910
|
+
return () => {
|
|
1911
|
+
Promise.resolve().then(() => dispose()).catch(() => void 0);
|
|
1912
|
+
};
|
|
1913
|
+
}
|
|
1914
|
+
//#endregion
|
|
733
1915
|
//#region src/index.ts
|
|
734
1916
|
const Config = Schema.object({
|
|
735
1917
|
findBar: Schema.boolean().default(true).volatile(),
|
|
@@ -739,10 +1921,14 @@ const Config = Schema.object({
|
|
|
739
1921
|
stepDuration: Schema.boolean().default(true).volatile(),
|
|
740
1922
|
sessionInfo: Schema.boolean().default(true).volatile(),
|
|
741
1923
|
toolsManager: Schema.boolean().default(true).volatile(),
|
|
1924
|
+
skillsManager: Schema.boolean().default(true).volatile(),
|
|
742
1925
|
suggestModel: Schema.string().default("").volatile(),
|
|
743
1926
|
suggestReasoning: Schema.string().default("").volatile(),
|
|
744
1927
|
suggestPrompt: Schema.string().default("").volatile(),
|
|
745
|
-
disabledTools: Schema.string().default("").volatile()
|
|
1928
|
+
disabledTools: Schema.string().default("").volatile(),
|
|
1929
|
+
sessionToolOverrides: Schema.string().default("").volatile(),
|
|
1930
|
+
disabledSkills: Schema.string().default("").volatile(),
|
|
1931
|
+
sessionSkillOverrides: Schema.string().default("").volatile()
|
|
746
1932
|
});
|
|
747
1933
|
function apply(ctx, config) {
|
|
748
1934
|
ctx.inject(["connection"], (serviceCtx) => {
|
|
@@ -762,10 +1948,20 @@ function apply(ctx, config) {
|
|
|
762
1948
|
serviceCtx.logger?.warn(`desktop-enhance: tools route not registered: ${String(error)}`);
|
|
763
1949
|
}
|
|
764
1950
|
try {
|
|
765
|
-
serviceCtx.effect(() =>
|
|
1951
|
+
serviceCtx.effect(() => registerSkillsRoute(serviceCtx), "desktop-enhance: skills route");
|
|
1952
|
+
} catch (error) {
|
|
1953
|
+
serviceCtx.logger?.warn(`desktop-enhance: skills route not registered: ${String(error)}`);
|
|
1954
|
+
}
|
|
1955
|
+
try {
|
|
1956
|
+
serviceCtx.effect(() => installToolsPolicy(serviceCtx, (sessionId) => readToolsConfig(config, sessionId)), "desktop-enhance: tools policy");
|
|
766
1957
|
} catch (error) {
|
|
767
1958
|
serviceCtx.logger?.warn(`desktop-enhance: tools policy not installed: ${String(error)}`);
|
|
768
1959
|
}
|
|
1960
|
+
try {
|
|
1961
|
+
serviceCtx.effect(() => installSkillsPolicy(serviceCtx, (sessionId) => readSkillsConfig(config, sessionId)), "desktop-enhance: skills policy");
|
|
1962
|
+
} catch (error) {
|
|
1963
|
+
serviceCtx.logger?.warn(`desktop-enhance: skills policy not installed: ${String(error)}`);
|
|
1964
|
+
}
|
|
769
1965
|
});
|
|
770
1966
|
}
|
|
771
1967
|
const __test = {
|
|
@@ -774,6 +1970,7 @@ const __test = {
|
|
|
774
1970
|
SUGGEST_EFFORTS_PATH,
|
|
775
1971
|
SESSION_INFO_PATH,
|
|
776
1972
|
TOOLS_PATH,
|
|
1973
|
+
SKILLS_PATH,
|
|
777
1974
|
MODEL_TIMEOUT_MS,
|
|
778
1975
|
MAX_OUTPUT_TOKENS,
|
|
779
1976
|
buildPrompt,
|
|
@@ -783,12 +1980,20 @@ const __test = {
|
|
|
783
1980
|
handleSuggest,
|
|
784
1981
|
handleSessionInfo,
|
|
785
1982
|
handleToolsCatalog,
|
|
1983
|
+
handleSkillsCatalog,
|
|
786
1984
|
collectAllToolSchemas,
|
|
1985
|
+
collectSkillCatalog,
|
|
787
1986
|
installToolsPolicy,
|
|
1987
|
+
installSkillsPolicy,
|
|
788
1988
|
readToolsConfig,
|
|
1989
|
+
readSkillsConfig,
|
|
1990
|
+
resolveFiberModuleName,
|
|
1991
|
+
resolveSessionIdFromScope,
|
|
1992
|
+
scanCordisFiberToolOwners,
|
|
789
1993
|
registerSuggestRoute,
|
|
790
1994
|
registerSessionInfoRoute,
|
|
791
1995
|
registerToolsRoute,
|
|
1996
|
+
registerSkillsRoute,
|
|
792
1997
|
routeOf,
|
|
793
1998
|
quietEffortFor,
|
|
794
1999
|
listModels,
|