@dsh-workbench/core 0.1.10 → 0.1.11
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/bin/dsh-workbench +23 -0
- package/client.js +80 -23
- package/cordis.patch.yml +11 -3
- package/dist/client/client.body.js +80 -23
- package/dist/client/index.js +80 -23
- package/dist/host/index.js +194 -176
- package/dist/types/app/client.d.ts +9 -3
- package/dist/types/app/layouts/rightbar/BoardEmpty.d.ts +2 -1
- package/dist/types/app/layouts/rightbar/Rightbar.d.ts +1 -0
- package/dist/types/modules/panels/__tests__/approval.test.d.ts +1 -0
- package/dist/types/modules/panels/model/approval.d.ts +2 -0
- package/dist/types/shared/api/diy.d.ts +3 -0
- package/dist/types/shared/api/diy.test.d.ts +1 -0
- package/dist/types/shared/api/host/__tests__/approval-legacy.test.d.ts +1 -0
- package/dist/types/shared/api/host/approval-legacy.d.ts +2 -0
- package/dist/types/shared/api/host/diy.d.ts +3 -0
- package/dist/types/shared/api/host/diy.test.d.ts +1 -0
- package/package.json +13 -5
- package/preset/diy.patch.yml +156 -0
- package/scripts/seed-profile.sh +116 -0
- package/skills/workbench-module-diy/BUILD.md +179 -0
- package/skills/workbench-module-diy/DESIGN.md +81 -0
- package/skills/workbench-module-diy/LINKAGE.md +113 -0
- package/skills/workbench-module-diy/PANEL.md +124 -0
- package/skills/workbench-module-diy/REVIEW.md +31 -0
- package/skills/workbench-module-diy/SKILL.md +54 -0
- package/skills/workbench-module-diy/STEPS.md +93 -0
- package/skills/workbench-module-diy/TOOLS.md +112 -0
package/dist/host/index.js
CHANGED
|
@@ -892,171 +892,39 @@ function resolvePluginSource(source, env, options = {}) {
|
|
|
892
892
|
}
|
|
893
893
|
//#endregion
|
|
894
894
|
//#region ../shared/dist/host/tool-approval.js
|
|
895
|
-
function
|
|
896
|
-
|
|
897
|
-
return {
|
|
898
|
-
en: `${detail.en} — ${texts.question.en}`,
|
|
899
|
-
zh: `${detail.zh} —— ${texts.question.zh}`
|
|
900
|
-
};
|
|
901
|
-
}
|
|
902
|
-
function actionOf$1(call) {
|
|
903
|
-
const raw = call.arguments;
|
|
904
|
-
if (typeof raw !== "object" || raw === null) return {};
|
|
905
|
-
const value = raw;
|
|
906
|
-
return {
|
|
907
|
-
...typeof value.action === "string" ? { action: value.action } : {},
|
|
908
|
-
...typeof value.id === "string" ? { id: value.id } : typeof value.unit === "string" ? { id: value.unit } : {}
|
|
909
|
-
};
|
|
895
|
+
function messageOf(error) {
|
|
896
|
+
return error instanceof Error ? error.message : String(error);
|
|
910
897
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
var UNKNOWN = { kind: "unknown" };
|
|
914
|
-
function ask(spec) {
|
|
898
|
+
function compose(detail, verdict) {
|
|
899
|
+
if (detail === void 0 || typeof detail.zh !== "string" || detail.zh.trim() === "") return verdict.fallback;
|
|
915
900
|
return {
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
function confirmed(call) {
|
|
921
|
-
const raw = call.arguments;
|
|
922
|
-
if (typeof raw !== "object" || raw === null) return void 0;
|
|
923
|
-
const value = raw.confirm;
|
|
924
|
-
return typeof value === "boolean" ? value : void 0;
|
|
925
|
-
}
|
|
926
|
-
function effectOf(call, context) {
|
|
927
|
-
const name = call.name ?? "";
|
|
928
|
-
const { action, id } = actionOf$1(call);
|
|
929
|
-
const readAction = action !== void 0 && action !== "" && READ_ONLY_ACTIONS.has(action);
|
|
930
|
-
const what = () => {
|
|
931
|
-
if (id === void 0 || id === "") return "一个模块";
|
|
932
|
-
return `「${context.titleOf?.(id) ?? id}」`;
|
|
901
|
+
en: `${detail.en} — ${verdict.question.en}`,
|
|
902
|
+
zh: `${detail.zh} —— ${verdict.question.zh}`
|
|
933
903
|
};
|
|
934
|
-
if (name === "workbench_cmdb_release") {
|
|
935
|
-
if (confirmed(call) !== true) return READ;
|
|
936
|
-
return ask({
|
|
937
|
-
reason: "confirm=true releases a version to a real environment",
|
|
938
|
-
generic: {
|
|
939
|
-
en: "The agent wants to deploy a version for real (confirm: true) — it deploys on the platform (non-production). Allow?",
|
|
940
|
-
zh: "agent 想在非生产环境上**真的部署一个版本**(confirm: true)—— 会在平台上部署。允许吗?"
|
|
941
|
-
},
|
|
942
|
-
question: {
|
|
943
|
-
en: "it deploys on the platform for real (non-production). Allow?",
|
|
944
|
-
zh: "会在平台上真的部署一次(非生产环境)。允许吗?"
|
|
945
|
-
}
|
|
946
|
-
});
|
|
947
|
-
}
|
|
948
|
-
if (name === "workbench_coding_issue_comment" || name === "workbench_coding_issue_transfer") {
|
|
949
|
-
if (confirmed(call) !== true) return READ;
|
|
950
|
-
const comment = name === "workbench_coding_issue_comment";
|
|
951
|
-
return ask({
|
|
952
|
-
reason: comment ? "confirm=true posts a comment on the platform" : "confirm=true moves an issue to another status on the platform",
|
|
953
|
-
generic: comment ? {
|
|
954
|
-
en: "The agent wants to post a comment on the platform for real (confirm: true) — it writes on the platform. Allow?",
|
|
955
|
-
zh: "agent 想**真的给一条缺陷加评论**(confirm: true)—— 会写平台数据。允许吗?"
|
|
956
|
-
} : {
|
|
957
|
-
en: "The agent wants to move an issue to another status for real (confirm: true) — it writes on the platform. Allow?",
|
|
958
|
-
zh: "agent 想**真的把一条缺陷流转到别的状态**(confirm: true)—— 会写平台数据。允许吗?"
|
|
959
|
-
},
|
|
960
|
-
question: comment ? {
|
|
961
|
-
en: "it posts that comment on the platform for real. Allow?",
|
|
962
|
-
zh: "会在平台上真的发表这条评论。允许吗?"
|
|
963
|
-
} : {
|
|
964
|
-
en: "it changes that issue status on the platform for real. Allow?",
|
|
965
|
-
zh: "会在平台上真的改这条缺陷的状态。允许吗?"
|
|
966
|
-
}
|
|
967
|
-
});
|
|
968
|
-
}
|
|
969
|
-
if (name === "workbench_modules") {
|
|
970
|
-
if (readAction) return READ;
|
|
971
|
-
if (action === "update-dependency") return ask({
|
|
972
|
-
reason: `workbench_modules update-dependency ${id ?? ""} upgrades a shared dependency on this machine`,
|
|
973
|
-
generic: {
|
|
974
|
-
en: `The agent wants to upgrade the shared dependency ${what()} (it changes what is installed on this machine). Allow?`,
|
|
975
|
-
zh: `agent 想升级共用依赖 ${what()}(会改这台机器上装的东西)。允许吗?`
|
|
976
|
-
},
|
|
977
|
-
question: {
|
|
978
|
-
en: "it upgrades that shared dependency on this machine. Allow?",
|
|
979
|
-
zh: `会升级共用依赖 ${what()}。允许吗?`
|
|
980
|
-
}
|
|
981
|
-
});
|
|
982
|
-
const verb = action === "install" ? "装" : action === "uninstall" ? "卸载" : action === "update" ? "更新" : "装 / 更新 / 卸载";
|
|
983
|
-
return ask({
|
|
984
|
-
reason: `workbench_modules ${action ?? "(unknown action)"} ${id ?? ""} changes plugins on this machine`.trim(),
|
|
985
|
-
generic: {
|
|
986
|
-
en: `The agent wants to ${verb === "装" ? "install" : verb === "卸载" ? "remove" : verb === "更新" ? "update" : "install/update/remove"} the module ${what()} (it changes plugins on this machine). Allow?`,
|
|
987
|
-
zh: `agent 想${verb}模块 ${what()}(会改这台机器上的插件)。允许吗?`
|
|
988
|
-
},
|
|
989
|
-
question: {
|
|
990
|
-
en: "it changes plugins on this machine. Allow?",
|
|
991
|
-
zh: "会改这台机器上的插件。允许吗?"
|
|
992
|
-
}
|
|
993
|
-
});
|
|
994
|
-
}
|
|
995
|
-
if (name !== "workbench_panels") return UNKNOWN;
|
|
996
|
-
if (readAction) return READ;
|
|
997
|
-
if (action === "hide") return ask({
|
|
998
|
-
reason: "workbench_panels hide removes a module from the panel",
|
|
999
|
-
generic: {
|
|
1000
|
-
en: `The agent wants to remove ${what()} from this project's panel (its agent tools go offline here too). Allow?`,
|
|
1001
|
-
zh: `agent 想把 ${what()} 从这个项目的面板上收起来(这个项目里它的 agent 工具也一起下线)。允许吗?`
|
|
1002
|
-
},
|
|
1003
|
-
question: {
|
|
1004
|
-
en: "it takes that module off this panel (its agent tools go offline here too). Allow?",
|
|
1005
|
-
zh: `${what()}会从这个项目的面板上收起来(这个项目里它的 agent 工具也一起下线)。允许吗?`
|
|
1006
|
-
}
|
|
1007
|
-
});
|
|
1008
|
-
if (action === "move") return ask({
|
|
1009
|
-
reason: "workbench_panels move reorders the panel",
|
|
1010
|
-
generic: {
|
|
1011
|
-
en: `The agent wants to reorder this project's panel (put ${what()} first). Allow?`,
|
|
1012
|
-
zh: `agent 想调整这个项目面板的顺序(把 ${what()} 放前面)。允许吗?`
|
|
1013
|
-
},
|
|
1014
|
-
question: {
|
|
1015
|
-
en: `it reorders this panel (${what()} goes first). Allow?`,
|
|
1016
|
-
zh: `会调整这个项目面板的顺序(${what()}放前面)。允许吗?`
|
|
1017
|
-
}
|
|
1018
|
-
});
|
|
1019
|
-
if (action === "reset") return ask({
|
|
1020
|
-
reason: "workbench_panels reset clears the panel",
|
|
1021
|
-
generic: {
|
|
1022
|
-
en: "The agent wants to clear this project's panel (every module goes offline here). Allow?",
|
|
1023
|
-
zh: "agent 想清空这个项目的面板(所有模块在这个项目里都下线)。允许吗?"
|
|
1024
|
-
},
|
|
1025
|
-
question: {
|
|
1026
|
-
en: "it clears this panel (every module goes offline here). Allow?",
|
|
1027
|
-
zh: "会清空这个项目的面板(所有模块在这个项目里都下线)。允许吗?"
|
|
1028
|
-
}
|
|
1029
|
-
});
|
|
1030
|
-
return ask({
|
|
1031
|
-
reason: `workbench_panels ${action ?? "(unknown action)"} changes the user's panel`,
|
|
1032
|
-
generic: {
|
|
1033
|
-
en: `The agent wants to add ${what()} to this project's panel. Allow?`,
|
|
1034
|
-
zh: `agent 想把 ${what()} 加到**这个项目**的面板上。允许吗?`
|
|
1035
|
-
},
|
|
1036
|
-
question: {
|
|
1037
|
-
en: `it adds ${what()} to this project's panel. Allow?`,
|
|
1038
|
-
zh: `会把 ${what()} 加到**这个项目**的面板上。允许吗?`
|
|
1039
|
-
}
|
|
1040
|
-
});
|
|
1041
904
|
}
|
|
1042
905
|
async function approvalFor(call, context = {}) {
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
906
|
+
if (context.writes !== true) return void 0;
|
|
907
|
+
let verdict;
|
|
908
|
+
try {
|
|
909
|
+
verdict = context.policy?.(call);
|
|
910
|
+
} catch (error) {
|
|
1047
911
|
return {
|
|
1048
912
|
kind: "deny",
|
|
1049
|
-
reason:
|
|
913
|
+
reason: `问"要不要审批"的时候套件的策略抛了错,已经停下:${messageOf(error)}`
|
|
1050
914
|
};
|
|
1051
915
|
}
|
|
1052
|
-
|
|
916
|
+
if (verdict?.kind === "read") return void 0;
|
|
917
|
+
if (verdict?.kind !== "ask") return {
|
|
918
|
+
kind: "deny",
|
|
919
|
+
reason: `${call.name ?? "这把工具"} 在清单里声明会写东西,但它的套件没认领这次调用 —— 停下:在套件的 needsApproval 里补一条审批(含"这次会发生什么"),别让写静默过去`
|
|
920
|
+
};
|
|
1053
921
|
let facts;
|
|
1054
922
|
try {
|
|
1055
923
|
facts = await context.detailOf?.(call);
|
|
1056
924
|
} catch (error) {
|
|
1057
925
|
return {
|
|
1058
926
|
kind: "deny",
|
|
1059
|
-
reason: `拿不到"这次会发生什么",已经停下:${
|
|
927
|
+
reason: `拿不到"这次会发生什么",已经停下:${messageOf(error)}`
|
|
1060
928
|
};
|
|
1061
929
|
}
|
|
1062
930
|
if (facts !== void 0 && "blocked" in facts) return {
|
|
@@ -1065,8 +933,8 @@ async function approvalFor(call, context = {}) {
|
|
|
1065
933
|
};
|
|
1066
934
|
return {
|
|
1067
935
|
kind: "ask",
|
|
1068
|
-
reason:
|
|
1069
|
-
displayReason: compose(facts,
|
|
936
|
+
reason: verdict.reason,
|
|
937
|
+
displayReason: compose(facts, verdict)
|
|
1070
938
|
};
|
|
1071
939
|
}
|
|
1072
940
|
//#endregion
|
|
@@ -1588,6 +1456,101 @@ function createRegistryNotebook(dir) {
|
|
|
1588
1456
|
}
|
|
1589
1457
|
};
|
|
1590
1458
|
}
|
|
1459
|
+
var panelsUnit = {
|
|
1460
|
+
id: "panels",
|
|
1461
|
+
kind: "ui",
|
|
1462
|
+
card: null,
|
|
1463
|
+
tools: [{
|
|
1464
|
+
name: "workbench_panels",
|
|
1465
|
+
writes: true
|
|
1466
|
+
}, {
|
|
1467
|
+
name: "workbench_modules",
|
|
1468
|
+
writes: true
|
|
1469
|
+
}],
|
|
1470
|
+
host: {
|
|
1471
|
+
inject: [],
|
|
1472
|
+
optional: ["tools", "shell"]
|
|
1473
|
+
}
|
|
1474
|
+
};
|
|
1475
|
+
//#endregion
|
|
1476
|
+
//#region src/modules/panels/model/approval.ts
|
|
1477
|
+
var READ$1 = { kind: "read" };
|
|
1478
|
+
var READ_ONLY_ACTIONS = /* @__PURE__ */ new Set(["list", ""]);
|
|
1479
|
+
function actionOf$1(call) {
|
|
1480
|
+
const raw = call.arguments;
|
|
1481
|
+
if (typeof raw !== "object" || raw === null) return {};
|
|
1482
|
+
const value = raw;
|
|
1483
|
+
return {
|
|
1484
|
+
...typeof value.action === "string" ? { action: value.action } : {},
|
|
1485
|
+
...typeof value.id === "string" ? { id: value.id } : typeof value.unit === "string" ? { id: value.unit } : {}
|
|
1486
|
+
};
|
|
1487
|
+
}
|
|
1488
|
+
function whatOf(id) {
|
|
1489
|
+
if (id === void 0 || id === "") return "一个模块";
|
|
1490
|
+
return `「${id}」`;
|
|
1491
|
+
}
|
|
1492
|
+
function askOf(reason, question, fallback) {
|
|
1493
|
+
return {
|
|
1494
|
+
kind: "ask",
|
|
1495
|
+
reason,
|
|
1496
|
+
question,
|
|
1497
|
+
fallback
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
var panelsApproval = (call) => {
|
|
1501
|
+
const { action, id } = actionOf$1(call);
|
|
1502
|
+
const readAction = action !== void 0 && action !== "" && READ_ONLY_ACTIONS.has(action);
|
|
1503
|
+
const what = whatOf(id);
|
|
1504
|
+
if (call.name === "workbench_modules") {
|
|
1505
|
+
if (readAction) return READ$1;
|
|
1506
|
+
if (action === "update-dependency") return askOf(`workbench_modules update-dependency ${id ?? ""} upgrades a shared dependency on this machine`, {
|
|
1507
|
+
en: "it upgrades that shared dependency on this machine. Allow?",
|
|
1508
|
+
zh: `会升级共用依赖 ${what}。允许吗?`
|
|
1509
|
+
}, {
|
|
1510
|
+
en: `The agent wants to upgrade the shared dependency ${what} (it changes what is installed on this machine). Allow?`,
|
|
1511
|
+
zh: `agent 想升级共用依赖 ${what}(会改这台机器上装的东西)。允许吗?`
|
|
1512
|
+
});
|
|
1513
|
+
const verb = action === "install" ? "装" : action === "uninstall" ? "卸载" : action === "update" ? "更新" : "装 / 更新 / 卸载";
|
|
1514
|
+
const verbEn = verb === "装" ? "install" : verb === "卸载" ? "remove" : verb === "更新" ? "update" : "install/update/remove";
|
|
1515
|
+
return askOf(`workbench_modules ${action ?? "(unknown action)"} ${id ?? ""} changes plugins on this machine`.trim(), {
|
|
1516
|
+
en: "it changes plugins on this machine. Allow?",
|
|
1517
|
+
zh: "会改这台机器上的插件。允许吗?"
|
|
1518
|
+
}, {
|
|
1519
|
+
en: `The agent wants to ${verbEn} the module ${what} (it changes plugins on this machine). Allow?`,
|
|
1520
|
+
zh: `agent 想${verb}模块 ${what}(会改这台机器上的插件)。允许吗?`
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1523
|
+
if (call.name !== "workbench_panels") return void 0;
|
|
1524
|
+
if (readAction) return READ$1;
|
|
1525
|
+
if (action === "hide") return askOf("workbench_panels hide removes a module from the panel", {
|
|
1526
|
+
en: "it takes that module off this panel (its agent tools go offline here too). Allow?",
|
|
1527
|
+
zh: `${what}会从这个项目的面板上收起来(这个项目里它的 agent 工具也一起下线)。允许吗?`
|
|
1528
|
+
}, {
|
|
1529
|
+
en: `The agent wants to remove ${what} from this project's panel (its agent tools go offline here too). Allow?`,
|
|
1530
|
+
zh: `agent 想把 ${what} 从这个项目的面板上收起来(这个项目里它的 agent 工具也一起下线)。允许吗?`
|
|
1531
|
+
});
|
|
1532
|
+
if (action === "move") return askOf("workbench_panels move reorders the panel", {
|
|
1533
|
+
en: `it reorders this panel (${what} goes first). Allow?`,
|
|
1534
|
+
zh: `会调整这个项目面板的顺序(${what}放前面)。允许吗?`
|
|
1535
|
+
}, {
|
|
1536
|
+
en: `The agent wants to reorder this project's panel (put ${what} first). Allow?`,
|
|
1537
|
+
zh: `agent 想调整这个项目面板的顺序(把 ${what} 放前面)。允许吗?`
|
|
1538
|
+
});
|
|
1539
|
+
if (action === "reset") return askOf("workbench_panels reset clears the panel", {
|
|
1540
|
+
en: "it clears this panel (every module goes offline here). Allow?",
|
|
1541
|
+
zh: "会清空这个项目的面板(所有模块在这个项目里都下线)。允许吗?"
|
|
1542
|
+
}, {
|
|
1543
|
+
en: "The agent wants to clear this project's panel (every module goes offline here). Allow?",
|
|
1544
|
+
zh: "agent 想清空这个项目的面板(所有模块在这个项目里都下线)。允许吗?"
|
|
1545
|
+
});
|
|
1546
|
+
return askOf(`workbench_panels ${action ?? "(unknown action)"} changes the user's panel`, {
|
|
1547
|
+
en: `it adds ${what} to this project's panel. Allow?`,
|
|
1548
|
+
zh: `会把 ${what} 加到**这个项目**的面板上。允许吗?`
|
|
1549
|
+
}, {
|
|
1550
|
+
en: `The agent wants to add ${what} to this project's panel. Allow?`,
|
|
1551
|
+
zh: `agent 想把 ${what} 加到**这个项目**的面板上。允许吗?`
|
|
1552
|
+
});
|
|
1553
|
+
};
|
|
1591
1554
|
//#endregion
|
|
1592
1555
|
//#region src/shared/api/host/release.ts
|
|
1593
1556
|
function parseLedgerVersion(stdout, name) {
|
|
@@ -2432,22 +2395,6 @@ function applyPanelsPref(panels, payload) {
|
|
|
2432
2395
|
units: panels.move(action.id, action.index ?? 0, path)
|
|
2433
2396
|
};
|
|
2434
2397
|
}
|
|
2435
|
-
var panelsUnit = {
|
|
2436
|
-
id: "panels",
|
|
2437
|
-
kind: "ui",
|
|
2438
|
-
card: null,
|
|
2439
|
-
tools: [{
|
|
2440
|
-
name: "workbench_panels",
|
|
2441
|
-
writes: true
|
|
2442
|
-
}, {
|
|
2443
|
-
name: "workbench_modules",
|
|
2444
|
-
writes: true
|
|
2445
|
-
}],
|
|
2446
|
-
host: {
|
|
2447
|
-
inject: [],
|
|
2448
|
-
optional: ["tools", "shell"]
|
|
2449
|
-
}
|
|
2450
|
-
};
|
|
2451
2398
|
//#endregion
|
|
2452
2399
|
//#region src/modules/panels/model/handoff.ts
|
|
2453
2400
|
var PANELS_FACT = "panels";
|
|
@@ -2843,6 +2790,7 @@ var HOST_UNITS = [{
|
|
|
2843
2790
|
routes: panelRoutes(panels, values),
|
|
2844
2791
|
registerTools: () => [...registerPanelTools(ctx, panels, values), ...registerMarketTools(ctx, market)],
|
|
2845
2792
|
factsOf: (call) => panelsFactsOf(call, manifests()),
|
|
2793
|
+
needsApproval: panelsApproval,
|
|
2846
2794
|
gate: {
|
|
2847
2795
|
deniedTools: (workspace) => manifests().filter((manifest) => manifest.card !== null).filter((manifest) => !panels.isEnabled(manifest.id, workspace)).flatMap((manifest) => manifest.tools.map((tool) => tool.name)),
|
|
2848
2796
|
subscribe: (listener) => panels.subscribe(listener)
|
|
@@ -3094,6 +3042,21 @@ function bundleInspectHandler(ctx) {
|
|
|
3094
3042
|
};
|
|
3095
3043
|
}
|
|
3096
3044
|
//#endregion
|
|
3045
|
+
//#region src/shared/api/diy.ts
|
|
3046
|
+
var WORKSHOP_TITLE = "工作台DIY";
|
|
3047
|
+
//#endregion
|
|
3048
|
+
//#region src/shared/api/host/diy.ts
|
|
3049
|
+
var WORKSHOP_RELATIVE = "workbench/diy";
|
|
3050
|
+
function workshopPathOf(ctx) {
|
|
3051
|
+
const homePath = ctx.get("dshHomePath");
|
|
3052
|
+
if (typeof homePath !== "function") return null;
|
|
3053
|
+
try {
|
|
3054
|
+
return homePath(WORKSHOP_RELATIVE);
|
|
3055
|
+
} catch {
|
|
3056
|
+
return null;
|
|
3057
|
+
}
|
|
3058
|
+
}
|
|
3059
|
+
//#endregion
|
|
3097
3060
|
//#region src/shared/api/dsh-plugins.ts
|
|
3098
3061
|
var DSH_PLUGINS_ROUTE = "dsh-plugins";
|
|
3099
3062
|
//#endregion
|
|
@@ -4036,6 +3999,54 @@ function createUnitRegistry() {
|
|
|
4036
3999
|
};
|
|
4037
4000
|
}
|
|
4038
4001
|
//#endregion
|
|
4002
|
+
//#region src/shared/api/host/approval-legacy.ts
|
|
4003
|
+
var READ = { kind: "read" };
|
|
4004
|
+
function confirmed(call) {
|
|
4005
|
+
const raw = call.arguments;
|
|
4006
|
+
if (typeof raw !== "object" || raw === null) return void 0;
|
|
4007
|
+
const value = raw.confirm;
|
|
4008
|
+
return typeof value === "boolean" ? value : void 0;
|
|
4009
|
+
}
|
|
4010
|
+
var legacyApproval = (call) => {
|
|
4011
|
+
const name = call.name ?? "";
|
|
4012
|
+
if (name === "workbench_cmdb_release") {
|
|
4013
|
+
if (confirmed(call) !== true) return READ;
|
|
4014
|
+
return {
|
|
4015
|
+
kind: "ask",
|
|
4016
|
+
reason: "confirm=true releases a version to a real environment",
|
|
4017
|
+
question: {
|
|
4018
|
+
en: "it deploys on the platform for real (non-production). Allow?",
|
|
4019
|
+
zh: "会在平台上真的部署一次(非生产环境)。允许吗?"
|
|
4020
|
+
},
|
|
4021
|
+
fallback: {
|
|
4022
|
+
en: "The agent wants to deploy a version for real (confirm: true) — it deploys on the platform (non-production). Allow?",
|
|
4023
|
+
zh: "agent 想在非生产环境上**真的部署一个版本**(confirm: true)—— 会在平台上部署。允许吗?"
|
|
4024
|
+
}
|
|
4025
|
+
};
|
|
4026
|
+
}
|
|
4027
|
+
if (name !== "workbench_coding_issue_comment" && name !== "workbench_coding_issue_transfer") return void 0;
|
|
4028
|
+
if (confirmed(call) !== true) return READ;
|
|
4029
|
+
const comment = name === "workbench_coding_issue_comment";
|
|
4030
|
+
return {
|
|
4031
|
+
kind: "ask",
|
|
4032
|
+
reason: comment ? "confirm=true posts a comment on the platform" : "confirm=true moves an issue to another status on the platform",
|
|
4033
|
+
question: comment ? {
|
|
4034
|
+
en: "it posts that comment on the platform for real. Allow?",
|
|
4035
|
+
zh: "会在平台上真的发表这条评论。允许吗?"
|
|
4036
|
+
} : {
|
|
4037
|
+
en: "it changes that issue status on the platform for real. Allow?",
|
|
4038
|
+
zh: "会在平台上真的改这条缺陷的状态。允许吗?"
|
|
4039
|
+
},
|
|
4040
|
+
fallback: comment ? {
|
|
4041
|
+
en: "The agent wants to post a comment on the platform for real (confirm: true) — it writes on the platform. Allow?",
|
|
4042
|
+
zh: "agent 想**真的给一条缺陷加评论**(confirm: true)—— 会写平台数据。允许吗?"
|
|
4043
|
+
} : {
|
|
4044
|
+
en: "The agent wants to move an issue to another status for real (confirm: true) — it writes on the platform. Allow?",
|
|
4045
|
+
zh: "agent 想**真的把一条缺陷流转到别的状态**(confirm: true)—— 会写平台数据。允许吗?"
|
|
4046
|
+
}
|
|
4047
|
+
};
|
|
4048
|
+
};
|
|
4049
|
+
//#endregion
|
|
4039
4050
|
//#region src/shared/api/host/tool-scope.ts
|
|
4040
4051
|
function agentOf(value) {
|
|
4041
4052
|
return typeof value === "object" && value !== null ? value : void 0;
|
|
@@ -4140,6 +4151,14 @@ function apply(ctx) {
|
|
|
4140
4151
|
const units = createUnitRegistry();
|
|
4141
4152
|
ctx.provide(UNITS_SERVICE, units);
|
|
4142
4153
|
assembleHostUnits(units);
|
|
4154
|
+
ctx.inject(["workspaceRegistry"], (scoped) => {
|
|
4155
|
+
const registry = scoped.get("workspaceRegistry");
|
|
4156
|
+
const workshop = workshopPathOf(scoped);
|
|
4157
|
+
if (registry === void 0 || workshop === null) return;
|
|
4158
|
+
registry.create(workshop, WORKSHOP_TITLE).catch((error) => {
|
|
4159
|
+
ctx.logger?.warn?.(`dsh-workbench: 工坊没能登记成工作区 —— ${String(error)}`);
|
|
4160
|
+
});
|
|
4161
|
+
});
|
|
4143
4162
|
const opencliEnv = process.env.DSH_WORKBENCH_OPENCLI;
|
|
4144
4163
|
const installEnv = process.env.DSH_WORKBENCH_OPENCLI_INSTALL;
|
|
4145
4164
|
const liveManifests = () => units.manifests();
|
|
@@ -4365,20 +4384,19 @@ function apply(ctx) {
|
|
|
4365
4384
|
const off = ctx.on?.("tools/pre-execute", async (exec, next) => {
|
|
4366
4385
|
const decision = await next();
|
|
4367
4386
|
if (decision.kind !== "allow") return decision;
|
|
4368
|
-
const
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
}
|
|
4373
|
-
};
|
|
4387
|
+
const name = exec.name === void 0 ? void 0 : String(exec.name);
|
|
4388
|
+
const tool = name === void 0 ? void 0 : unitsOfTool().get(name);
|
|
4389
|
+
const owner = tool === void 0 ? void 0 : mounted.get(tool.unit)?.result;
|
|
4390
|
+
const detailOf = owner === void 0 ? void 0 : (call) => owner.approvalDetail?.(call);
|
|
4374
4391
|
const workspace = sessionWorkspace(exec) ?? void 0;
|
|
4375
4392
|
return await approvalFor({
|
|
4376
|
-
...
|
|
4393
|
+
...name === void 0 ? {} : { name },
|
|
4377
4394
|
arguments: exec.arguments,
|
|
4378
4395
|
...workspace === void 0 ? {} : { workspace }
|
|
4379
4396
|
}, {
|
|
4380
4397
|
detailOf,
|
|
4381
|
-
|
|
4398
|
+
policy: owner?.needsApproval ?? legacyApproval,
|
|
4399
|
+
writes: tool?.writes ?? false
|
|
4382
4400
|
}) ?? decision;
|
|
4383
4401
|
});
|
|
4384
4402
|
return () => off?.();
|