tianshu-harness 3.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +189 -0
- package/README.en.md +1066 -0
- package/README.ja.md +1214 -0
- package/README.ko.md +1216 -0
- package/README.md +309 -0
- package/completions/rivet.bash +118 -0
- package/completions/rivet.fish +110 -0
- package/completions/rivet.ps1 +230 -0
- package/completions/rivet.zsh +187 -0
- package/dist/account-OAEKORZE.js +47 -0
- package/dist/account-login-V6FOLHJR.js +65 -0
- package/dist/account-status-KHNPPAFL.js +23 -0
- package/dist/agent/worker-process/child.js +407 -0
- package/dist/browser-cli-FLNY5ZHI.js +19 -0
- package/dist/browser-readiness-LWVGSBD5.js +12 -0
- package/dist/build-backends-5KXKR2S4.js +13 -0
- package/dist/build-options-66Y4ZE7C.js +9 -0
- package/dist/bundled-skills/brainstorming/SKILL.md +139 -0
- package/dist/bundled-skills/visual-acceptance/SKILL.md +64 -0
- package/dist/chain-7MAMFXZ3.js +10 -0
- package/dist/checkpoint-MND4DUIX.js +33 -0
- package/dist/chunk-2E6CK2RC.js +392 -0
- package/dist/chunk-2EBWGAXD.js +51 -0
- package/dist/chunk-2HDP7RMR.js +119 -0
- package/dist/chunk-2HKD2UFM.js +1000 -0
- package/dist/chunk-2VYRLULP.js +51 -0
- package/dist/chunk-2XN7PM4N.js +125 -0
- package/dist/chunk-35H7GVNR.js +66 -0
- package/dist/chunk-3C3R7JXY.js +77 -0
- package/dist/chunk-3VGD2FXB.js +118 -0
- package/dist/chunk-424AP7FM.js +534 -0
- package/dist/chunk-4J5TZGOE.js +3707 -0
- package/dist/chunk-4QJ3Y5JM.js +898 -0
- package/dist/chunk-4U2ET7ZY.js +1326 -0
- package/dist/chunk-4XPFLICE.js +876 -0
- package/dist/chunk-5B2OCU5P.js +31707 -0
- package/dist/chunk-5GGOGLSN.js +73 -0
- package/dist/chunk-5JRZPLI6.js +251 -0
- package/dist/chunk-5TQ3JYBU.js +397 -0
- package/dist/chunk-66JPZSGX.js +55 -0
- package/dist/chunk-6HSVXHCZ.js +764 -0
- package/dist/chunk-6S5FPUS7.js +21 -0
- package/dist/chunk-722LQO64.js +131 -0
- package/dist/chunk-73NJ7IT7.js +354 -0
- package/dist/chunk-7FW3I7WC.js +95 -0
- package/dist/chunk-7KUCBNLB.js +173 -0
- package/dist/chunk-7RDOV3DF.js +201 -0
- package/dist/chunk-A5MNH4ER.js +79 -0
- package/dist/chunk-ADIVZ2D5.js +15 -0
- package/dist/chunk-AE3P3F6W.js +366 -0
- package/dist/chunk-AERM3VGP.js +280 -0
- package/dist/chunk-AEWHC4WM.js +246 -0
- package/dist/chunk-AOVQ7VIF.js +169 -0
- package/dist/chunk-AOYHP3WI.js +12411 -0
- package/dist/chunk-B3YEBABJ.js +7160 -0
- package/dist/chunk-BCQXEZPJ.js +154 -0
- package/dist/chunk-BKTQAYO2.js +418 -0
- package/dist/chunk-BSECIPAQ.js +80 -0
- package/dist/chunk-BUIMGNDD.js +52 -0
- package/dist/chunk-BXHV3GSB.js +10320 -0
- package/dist/chunk-C6ZVZCPP.js +139 -0
- package/dist/chunk-CEZNQVWM.js +82 -0
- package/dist/chunk-CGFZGR7G.js +1492 -0
- package/dist/chunk-CGOADM2X.js +337 -0
- package/dist/chunk-CI4R6P2B.js +24 -0
- package/dist/chunk-D2TCGRSX.js +73 -0
- package/dist/chunk-D4PTYFOG.js +154 -0
- package/dist/chunk-D54ZWG4T.js +717 -0
- package/dist/chunk-DEBI37QB.js +145 -0
- package/dist/chunk-DWROHPXP.js +1051 -0
- package/dist/chunk-DZ6UOJ5D.js +92 -0
- package/dist/chunk-EBJTVRQN.js +81 -0
- package/dist/chunk-EGEI2RQA.js +1167 -0
- package/dist/chunk-EHHUASO5.js +1305 -0
- package/dist/chunk-EPKTIOED.js +41 -0
- package/dist/chunk-ER5JW2QZ.js +5681 -0
- package/dist/chunk-ETHFACAB.js +315 -0
- package/dist/chunk-EXUE5W2F.js +112 -0
- package/dist/chunk-EXXICUIW.js +73 -0
- package/dist/chunk-FFQSZJOO.js +169 -0
- package/dist/chunk-FHFKPGDO.js +85 -0
- package/dist/chunk-FW3QKMFX.js +158 -0
- package/dist/chunk-GD4ZNZ7W.js +30 -0
- package/dist/chunk-GHVMWF2I.js +581 -0
- package/dist/chunk-GMKAXSYQ.js +297 -0
- package/dist/chunk-HBVF6BWO.js +325 -0
- package/dist/chunk-HV4YGVMS.js +379 -0
- package/dist/chunk-ILBCKAV6.js +89 -0
- package/dist/chunk-J4U4AW46.js +440 -0
- package/dist/chunk-J6ESSM47.js +1791 -0
- package/dist/chunk-JBZHIC6T.js +2309 -0
- package/dist/chunk-JCFWOULR.js +245 -0
- package/dist/chunk-JRF5L6OD.js +131 -0
- package/dist/chunk-JSS75KCG.js +2014 -0
- package/dist/chunk-JSXWIWWJ.js +225 -0
- package/dist/chunk-JYV7I2QH.js +98 -0
- package/dist/chunk-KIOXTQQL.js +1596 -0
- package/dist/chunk-KWVTXT5B.js +89 -0
- package/dist/chunk-KX22RD6R.js +33 -0
- package/dist/chunk-LA6IPTGH.js +709 -0
- package/dist/chunk-LH5VCGLB.js +1796 -0
- package/dist/chunk-LQQ6XJ2Y.js +269 -0
- package/dist/chunk-MJQ55WZZ.js +65 -0
- package/dist/chunk-ML3UKMH3.js +40 -0
- package/dist/chunk-MOZPLHSU.js +5526 -0
- package/dist/chunk-NGEWJ4DF.js +89 -0
- package/dist/chunk-NH6VIOAR.js +211 -0
- package/dist/chunk-O5VZQKCB.js +26106 -0
- package/dist/chunk-OHSV42QB.js +748 -0
- package/dist/chunk-OO3TAHO5.js +4070 -0
- package/dist/chunk-OTNHSAGN.js +38282 -0
- package/dist/chunk-OUWAC7AQ.js +442 -0
- package/dist/chunk-OXMIV4WE.js +270 -0
- package/dist/chunk-P5KJURUR.js +229 -0
- package/dist/chunk-P6GJOVO6.js +307 -0
- package/dist/chunk-QARAGUXX.js +23 -0
- package/dist/chunk-R43HJCDX.js +2711 -0
- package/dist/chunk-RAXBAWRN.js +210 -0
- package/dist/chunk-RK3JHWPT.js +39 -0
- package/dist/chunk-RWA23GMM.js +24 -0
- package/dist/chunk-S4K4L6IM.js +179 -0
- package/dist/chunk-SAXK6LVF.js +124 -0
- package/dist/chunk-SEPGEJNK.js +1607 -0
- package/dist/chunk-SUJERP5I.js +285 -0
- package/dist/chunk-T3ED6BY2.js +913 -0
- package/dist/chunk-THKDVSEC.js +90 -0
- package/dist/chunk-TI4GSEL5.js +52 -0
- package/dist/chunk-TPI73L57.js +164 -0
- package/dist/chunk-TVHW77C7.js +338 -0
- package/dist/chunk-TWNHOSDT.js +1073 -0
- package/dist/chunk-UFMN76QD.js +347 -0
- package/dist/chunk-UHGLFRZE.js +205 -0
- package/dist/chunk-UTZYPKBF.js +15231 -0
- package/dist/chunk-UXNLELW6.js +25 -0
- package/dist/chunk-UXXS53EA.js +166 -0
- package/dist/chunk-V5DHFGI7.js +171 -0
- package/dist/chunk-V5YIPMHV.js +2353 -0
- package/dist/chunk-WMUWEO2C.js +754 -0
- package/dist/chunk-WOE3D7JM.js +945 -0
- package/dist/chunk-X2IK5LVR.js +2592 -0
- package/dist/chunk-XU2YXCDL.js +459 -0
- package/dist/chunk-YJG5HIX5.js +203 -0
- package/dist/chunk-Z3QE7TZM.js +72 -0
- package/dist/chunk-Z5Z3JHJY.js +64 -0
- package/dist/chunk-ZDIFBJFT.js +168 -0
- package/dist/chunk-ZGGCEXDC.js +176 -0
- package/dist/chunk-ZMZCZNKU.js +263 -0
- package/dist/chunk-ZNC5T65N.js +17 -0
- package/dist/chunk-ZO3I3A7O.js +308 -0
- package/dist/chunk-ZQKXBUB7.js +217 -0
- package/dist/chunk-ZTRINFM2.js +78 -0
- package/dist/chunk-ZU7JZCVP.js +193 -0
- package/dist/chunk-ZZAWNALS.js +350 -0
- package/dist/cli/entry.js +54 -0
- package/dist/connector-L5QQTR6Y.js +26 -0
- package/dist/context-62DC6EC3.js +31 -0
- package/dist/council-convene-NJWPNBDU.js +46 -0
- package/dist/create-agent-config-ODSQWNVC.js +55 -0
- package/dist/default-registry-2PU3BTAU.js +68 -0
- package/dist/deliver-task-KONV4C4M.js +57 -0
- package/dist/delivery-gate-v2-F2YVMVGK.js +27 -0
- package/dist/domain-knowledge-store-DDZ3F4J7.js +11 -0
- package/dist/fetch-core-ZPPYDSZH.js +14 -0
- package/dist/galaxy-K72BBDQN.js +91 -0
- package/dist/goal-criteria-SCALAU2D.js +141 -0
- package/dist/goal-persist-XWY2GDQX.js +19 -0
- package/dist/goal-tracker-FXMJ2GVK.js +11 -0
- package/dist/headless-LSB6I7PT.js +162 -0
- package/dist/headless-coordinator-VDPDMVUT.js +90 -0
- package/dist/inject-U55SMB6A.js +39 -0
- package/dist/login-flow-CD4ZGXOC.js +59 -0
- package/dist/logs-cli-SQVYFMMN.js +283 -0
- package/dist/loop-ULZYBDA3.js +76 -0
- package/dist/main.js +4064 -0
- package/dist/manager-ROZBCWPA.js +171 -0
- package/dist/manager-Z7XFFUOM.js +10670 -0
- package/dist/meridian-indexer-ZIW363L7.js +21 -0
- package/dist/native-resolver-PN34UIVV.js +13 -0
- package/dist/node_modules/better-sqlite3/lib/database.js +90 -0
- package/dist/node_modules/better-sqlite3/lib/index.js +3 -0
- package/dist/node_modules/better-sqlite3/lib/methods/aggregate.js +43 -0
- package/dist/node_modules/better-sqlite3/lib/methods/backup.js +67 -0
- package/dist/node_modules/better-sqlite3/lib/methods/function.js +31 -0
- package/dist/node_modules/better-sqlite3/lib/methods/inspect.js +7 -0
- package/dist/node_modules/better-sqlite3/lib/methods/pragma.js +12 -0
- package/dist/node_modules/better-sqlite3/lib/methods/serialize.js +16 -0
- package/dist/node_modules/better-sqlite3/lib/methods/table.js +189 -0
- package/dist/node_modules/better-sqlite3/lib/methods/transaction.js +78 -0
- package/dist/node_modules/better-sqlite3/lib/methods/wrappers.js +54 -0
- package/dist/node_modules/better-sqlite3/lib/sqlite-error.js +20 -0
- package/dist/node_modules/better-sqlite3/lib/util.js +12 -0
- package/dist/node_modules/better-sqlite3/package.json +59 -0
- package/dist/ownership-ledger-E3WIEKPL.js +9 -0
- package/dist/package.json +3 -0
- package/dist/path-grants-XRRXHXG7.js +40 -0
- package/dist/paths-LVV5IMQN.js +49 -0
- package/dist/plan-fact-anchors-LMVQZCW5.js +13 -0
- package/dist/plan-store-ODLTTPFB.js +17 -0
- package/dist/plan-templates-5FPFBOL6.js +109 -0
- package/dist/plugin-loader-ZZKX7ZE6.js +22 -0
- package/dist/prefix-budget-62OV5HQC.js +13 -0
- package/dist/project-trust-5WS5MOMU.js +31 -0
- package/dist/provider-cli-ALDQXIT7.js +37 -0
- package/dist/providers-XQYTAVPK.js +11 -0
- package/dist/proxy-resolver-V2Y6534D.js +15 -0
- package/dist/recovery-cli-KPGY6FY3.js +106 -0
- package/dist/review-discipline-MNSYCST5.js +55 -0
- package/dist/review-router-BVQZW3MX.js +18 -0
- package/dist/seed-capsules/seed-capsule-attack-methodology.md +62 -0
- package/dist/seed-capsules/seed-capsule-changgeng.md +31 -0
- package/dist/seed-capsules/seed-capsule-design-aesthetics.md +38 -0
- package/dist/seed-capsules/seed-capsule-diagnostic-ladder.md +54 -0
- package/dist/seed-capsules/seed-capsule-fu.md +39 -0
- package/dist/seed-capsules/seed-capsule-huagai.md +73 -0
- package/dist/seed-capsules/seed-capsule-kaiyang.md +65 -0
- package/dist/seed-capsules/seed-capsule-knowledge-work.md +40 -0
- package/dist/seed-capsules/seed-capsule-tanlang.md +47 -0
- package/dist/seed-capsules/seed-capsule-tianfu.md +23 -0
- package/dist/seed-capsules/seed-capsule-tianliang.md +63 -0
- package/dist/seed-capsules/seed-capsule-tianquan.md +32 -0
- package/dist/seed-capsules/seed-capsule-tianxuan-ccr.md +22 -0
- package/dist/seed-capsules/seed-capsule-tianxuan.md +64 -0
- package/dist/seed-capsules/seed-capsule-yaoguang.md +87 -0
- package/dist/serve-X2R2UTLF.js +170 -0
- package/dist/serve-agent-KHSU6RVV.js +965 -0
- package/dist/session-persist-HUUC772H.js +37 -0
- package/dist/session-registry-6XUD5C4Y.js +15 -0
- package/dist/skill-loader-CK3RMO47.js +48 -0
- package/dist/skills/cli-harness-sop.md +207 -0
- package/dist/spawn-git-4HFU65AH.js +29 -0
- package/dist/sse-EYUTBWUK.js +512 -0
- package/dist/starflow-NOFBMPFU.js +30 -0
- package/dist/streamableHttp-V67CNJMO.js +447 -0
- package/dist/task-contract-6XHBNJQK.js +32 -0
- package/dist/task-ledger-3K4TJIER.js +9 -0
- package/dist/team-orchestrate-S6NHZP7X.js +64 -0
- package/dist/title-extract-QX4XGCYN.js +50 -0
- package/dist/todo-QDXGRZZP.js +31 -0
- package/dist/todo-store-V3TTO5AH.js +12 -0
- package/dist/tool-preset-LU5BYEDZ.js +23 -0
- package/dist/tool-tiers-GD742YBN.js +23 -0
- package/dist/turndown.es-OI55K6C3.js +17373 -0
- package/dist/verification-attribution-EKG4CNUV.js +13 -0
- package/dist/volatile-git-MBTST7RA.js +15 -0
- package/dist/wave-checkpoint-XLIIHXQA.js +30 -0
- package/dist/web-cli-DUG4I35O.js +233 -0
- package/dist/web-search-3IK542AA.js +34 -0
- package/dist/workers/cpu-worker.js +45 -0
- package/dist/workflow-runner-HX7UBAYG.js +297 -0
- package/dist/worktree-baseline-O5NCU6M2.js +9 -0
- package/package.json +122 -0
- package/scripts/check-mobile-env.mjs +76 -0
- package/scripts/fetch-native-sqlite.js +392 -0
- package/scripts/prune-installed-wasms.js +45 -0
- package/scripts/tree-sitter-wasm-keep.js +40 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --expose-gc --max-old-space-size=4096
|
|
2
|
+
import { createRequire as __rivetCreateRequire } from 'node:module'; const require = __rivetCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
init_esm_shims
|
|
5
|
+
} from "./chunk-5GGOGLSN.js";
|
|
6
|
+
|
|
7
|
+
// src/utils/safe-path.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
var ANSI_SEQ_RE = /\x1B(?:\[[0-9;?]*[ -/]*[@-~]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[@-Z\\-_])/g;
|
|
10
|
+
function stripTerminalEscapes(text) {
|
|
11
|
+
return text.replace(ANSI_SEQ_RE, "").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, " ");
|
|
12
|
+
}
|
|
13
|
+
var MAX_NAME_LENGTH = 200;
|
|
14
|
+
function isSafeFileName(name) {
|
|
15
|
+
if (!name || name.length > MAX_NAME_LENGTH) return false;
|
|
16
|
+
if (name.includes("/") || name.includes("\\") || name.includes("\0")) return false;
|
|
17
|
+
if (name.startsWith(".")) return false;
|
|
18
|
+
if (name.includes("..")) return false;
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
stripTerminalEscapes,
|
|
24
|
+
isSafeFileName
|
|
25
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --expose-gc --max-old-space-size=4096
|
|
2
|
+
import { createRequire as __rivetCreateRequire } from 'node:module'; const require = __rivetCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
init_esm_shims
|
|
5
|
+
} from "./chunk-5GGOGLSN.js";
|
|
6
|
+
|
|
7
|
+
// src/tools/registry.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
|
|
10
|
+
// src/tools/did-you-mean.ts
|
|
11
|
+
init_esm_shims();
|
|
12
|
+
function levenshtein(a, b) {
|
|
13
|
+
if (a === b) return 0;
|
|
14
|
+
const aLen = a.length;
|
|
15
|
+
const bLen = b.length;
|
|
16
|
+
if (aLen === 0) return bLen;
|
|
17
|
+
if (bLen === 0) return aLen;
|
|
18
|
+
let prev = new Array(bLen + 1);
|
|
19
|
+
let curr = new Array(bLen + 1);
|
|
20
|
+
for (let j = 0; j <= bLen; j++) prev[j] = j;
|
|
21
|
+
for (let i = 1; i <= aLen; i++) {
|
|
22
|
+
curr[0] = i;
|
|
23
|
+
const aCharCode = a.charCodeAt(i - 1);
|
|
24
|
+
for (let j = 1; j <= bLen; j++) {
|
|
25
|
+
const cost = aCharCode === b.charCodeAt(j - 1) ? 0 : 1;
|
|
26
|
+
const insert = (curr[j - 1] ?? 0) + 1;
|
|
27
|
+
const del = (prev[j] ?? 0) + 1;
|
|
28
|
+
const sub = (prev[j - 1] ?? 0) + cost;
|
|
29
|
+
const m1 = insert < del ? insert : del;
|
|
30
|
+
curr[j] = m1 < sub ? m1 : sub;
|
|
31
|
+
}
|
|
32
|
+
const tmp = prev;
|
|
33
|
+
prev = curr;
|
|
34
|
+
curr = tmp;
|
|
35
|
+
}
|
|
36
|
+
return prev[bLen] ?? 0;
|
|
37
|
+
}
|
|
38
|
+
function didYouMean(input, candidates, options = {}) {
|
|
39
|
+
if (candidates.length === 0 || input.length === 0) return [];
|
|
40
|
+
const topK = options.topK ?? 3;
|
|
41
|
+
const inputLen = input.length;
|
|
42
|
+
const maxDistance = options.maxDistance ?? Math.max(2, Math.floor(inputLen / 4));
|
|
43
|
+
const scored = [];
|
|
44
|
+
for (const candidate of candidates) {
|
|
45
|
+
if (candidate.length === 0) continue;
|
|
46
|
+
const d = levenshtein(input, candidate);
|
|
47
|
+
if (d <= maxDistance) scored.push({ name: candidate, distance: d });
|
|
48
|
+
}
|
|
49
|
+
if (scored.length > 0) {
|
|
50
|
+
scored.sort((a, b) => a.distance - b.distance || a.name.localeCompare(b.name));
|
|
51
|
+
return scored.slice(0, topK).map((s) => s.name);
|
|
52
|
+
}
|
|
53
|
+
const substringHits = [];
|
|
54
|
+
for (const candidate of candidates) {
|
|
55
|
+
if (candidate.length === 0) continue;
|
|
56
|
+
if (candidate.includes(input) || input.includes(candidate)) {
|
|
57
|
+
substringHits.push(candidate);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
substringHits.sort((a, b) => a.localeCompare(b));
|
|
61
|
+
return substringHits.slice(0, topK);
|
|
62
|
+
}
|
|
63
|
+
function didYouMeanHint(input, allToolNames) {
|
|
64
|
+
if (allToolNames.length === 0) {
|
|
65
|
+
return "No tools are registered.";
|
|
66
|
+
}
|
|
67
|
+
const suggestions = didYouMean(input, allToolNames);
|
|
68
|
+
const parts = [];
|
|
69
|
+
if (suggestions.length > 0) {
|
|
70
|
+
parts.push(`Did you mean: ${suggestions.join(", ")}?`);
|
|
71
|
+
}
|
|
72
|
+
const sorted = allToolNames.slice().sort();
|
|
73
|
+
parts.push(`Available tools: ${sorted.join(", ")}`);
|
|
74
|
+
return parts.join(" ");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/tools/registry.ts
|
|
78
|
+
var FOREIGN_ALIASES = {
|
|
79
|
+
todowrite: "todo",
|
|
80
|
+
task: "delegate_task",
|
|
81
|
+
agent: "delegate_task"
|
|
82
|
+
};
|
|
83
|
+
var ToolRegistry = class {
|
|
84
|
+
tools = /* @__PURE__ */ new Map();
|
|
85
|
+
register(tool) {
|
|
86
|
+
this.tools.set(tool.definition.name, tool);
|
|
87
|
+
}
|
|
88
|
+
/** Remove a tool by name. No-op if not registered. Returns true if removed. */
|
|
89
|
+
remove(name) {
|
|
90
|
+
return this.tools.delete(name);
|
|
91
|
+
}
|
|
92
|
+
get(name) {
|
|
93
|
+
return this.tools.get(name);
|
|
94
|
+
}
|
|
95
|
+
has(name) {
|
|
96
|
+
return this.tools.has(name);
|
|
97
|
+
}
|
|
98
|
+
getAll() {
|
|
99
|
+
return Array.from(this.tools.values());
|
|
100
|
+
}
|
|
101
|
+
/** Names of every registered tool, sorted for stable did-you-mean hints. */
|
|
102
|
+
getAllNames() {
|
|
103
|
+
return Array.from(this.tools.keys()).sort();
|
|
104
|
+
}
|
|
105
|
+
getDefinitions() {
|
|
106
|
+
return this.getAll().filter((t) => t.isEnabled()).map((t) => t.definition).sort((a, b) => a.name.localeCompare(b.name));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Resolve a possibly-foreign tool name to its canonical registered name.
|
|
110
|
+
* Returns the input unchanged when it is already registered or no alias
|
|
111
|
+
* matches. The tool pipeline calls this BEFORE its permission gates
|
|
112
|
+
* (plan-mode, deny rules, approval, risk) so aliases cannot slip past
|
|
113
|
+
* policies keyed on the canonical name.
|
|
114
|
+
*/
|
|
115
|
+
resolveName(name) {
|
|
116
|
+
if (this.tools.has(name)) return name;
|
|
117
|
+
const aliasKey = FOREIGN_ALIASES[name.toLowerCase()];
|
|
118
|
+
if (aliasKey && this.tools.has(aliasKey)) return aliasKey;
|
|
119
|
+
return name;
|
|
120
|
+
}
|
|
121
|
+
async execute(name, params) {
|
|
122
|
+
let tool = this.tools.get(name);
|
|
123
|
+
let resolvedName = name;
|
|
124
|
+
let aliasNote;
|
|
125
|
+
if (!tool) {
|
|
126
|
+
const aliasKey = FOREIGN_ALIASES[name.toLowerCase()];
|
|
127
|
+
if (aliasKey) {
|
|
128
|
+
tool = this.tools.get(aliasKey);
|
|
129
|
+
if (tool) {
|
|
130
|
+
resolvedName = aliasKey;
|
|
131
|
+
aliasNote = `[NOTE: "${name}" \u81EA\u52A8\u6620\u5C04\u4E3A "${aliasKey}" \u2014 \u4E0B\u6B21\u8BF7\u76F4\u63A5\u8C03 ${aliasKey}]`;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (!tool) {
|
|
136
|
+
const hint = didYouMeanHint(name, this.getAllNames());
|
|
137
|
+
throw new Error(`Unknown tool: ${name}. If this is an EXTENDED-layer tool, use delegate_task to dispatch a worker, or /tools enable <name> to mount it on the primary agent. ${hint}`);
|
|
138
|
+
}
|
|
139
|
+
if (!tool.isEnabled()) throw new Error(`Tool ${resolvedName} is disabled`);
|
|
140
|
+
const result = await tool.execute(params);
|
|
141
|
+
if (aliasNote) {
|
|
142
|
+
result.content = `${aliasNote}
|
|
143
|
+
${result.content}`;
|
|
144
|
+
}
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
needsApproval(name, params) {
|
|
148
|
+
const tool = this.tools.get(name);
|
|
149
|
+
if (!tool) return false;
|
|
150
|
+
return tool.requiresApproval(params);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
function filterToolRegistry(source, allowedNames) {
|
|
154
|
+
const filtered = new ToolRegistry();
|
|
155
|
+
for (const name of allowedNames) {
|
|
156
|
+
const tool = source.get(name);
|
|
157
|
+
if (!tool) throw new Error(`Cannot allowlist unknown tool: ${name}`);
|
|
158
|
+
filtered.register(tool);
|
|
159
|
+
}
|
|
160
|
+
return filtered;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export {
|
|
164
|
+
ToolRegistry,
|
|
165
|
+
filterToolRegistry
|
|
166
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --expose-gc --max-old-space-size=4096
|
|
2
|
+
import { createRequire as __rivetCreateRequire } from 'node:module'; const require = __rivetCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
redactText,
|
|
5
|
+
redactValue,
|
|
6
|
+
truncateUtf16Safe
|
|
7
|
+
} from "./chunk-ML3UKMH3.js";
|
|
8
|
+
import {
|
|
9
|
+
init_esm_shims
|
|
10
|
+
} from "./chunk-5GGOGLSN.js";
|
|
11
|
+
|
|
12
|
+
// src/agent/event-tap.ts
|
|
13
|
+
init_esm_shims();
|
|
14
|
+
var RESULT_CAP = 2e3;
|
|
15
|
+
var DELTA_FLUSH_CHARS = 4e3;
|
|
16
|
+
function tapAgentCallbacks(inner, sink) {
|
|
17
|
+
let seq = 0;
|
|
18
|
+
let pending = null;
|
|
19
|
+
const write = (type, data) => {
|
|
20
|
+
seq += 1;
|
|
21
|
+
try {
|
|
22
|
+
sink({ seq, ts: Date.now(), type, data });
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const flush = () => {
|
|
27
|
+
if (!pending) return;
|
|
28
|
+
const buf = pending;
|
|
29
|
+
pending = null;
|
|
30
|
+
write(buf.type, { text: buf.text });
|
|
31
|
+
};
|
|
32
|
+
const emit = (type, data) => {
|
|
33
|
+
flush();
|
|
34
|
+
write(type, data);
|
|
35
|
+
};
|
|
36
|
+
const delta = (type, text) => {
|
|
37
|
+
if (!text) return;
|
|
38
|
+
if (pending && pending.type !== type) flush();
|
|
39
|
+
pending = { type, text: (pending?.text ?? "") + text };
|
|
40
|
+
if (pending.text.length >= DELTA_FLUSH_CHARS) flush();
|
|
41
|
+
};
|
|
42
|
+
const tapped = {
|
|
43
|
+
...inner,
|
|
44
|
+
flush,
|
|
45
|
+
onTextDelta: (text) => {
|
|
46
|
+
delta("text_delta", redactText(text));
|
|
47
|
+
inner.onTextDelta(text);
|
|
48
|
+
},
|
|
49
|
+
onThinkingDelta: (thinking) => {
|
|
50
|
+
delta("thinking_delta", redactText(thinking));
|
|
51
|
+
inner.onThinkingDelta(thinking);
|
|
52
|
+
},
|
|
53
|
+
onToolUse: (id, name, input) => {
|
|
54
|
+
emit("tool_use", { id, name, input: redactValue(input) });
|
|
55
|
+
inner.onToolUse(id, name, input);
|
|
56
|
+
},
|
|
57
|
+
onToolResult: (id, name, result, isError, rawPath, uiContent) => {
|
|
58
|
+
if (isError !== void 0) {
|
|
59
|
+
emit("tool_result", {
|
|
60
|
+
id,
|
|
61
|
+
name,
|
|
62
|
+
isError: !!isError,
|
|
63
|
+
result: truncateUtf16Safe(redactText(result), RESULT_CAP)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
inner.onToolResult(id, name, result, isError, rawPath, uiContent);
|
|
67
|
+
},
|
|
68
|
+
onTurnComplete: (usage, turnNumber, isFinal, evidenceSummary) => {
|
|
69
|
+
emit("turn_complete", { usage, turnNumber, isFinal: !!isFinal });
|
|
70
|
+
inner.onTurnComplete(usage, turnNumber, isFinal, evidenceSummary);
|
|
71
|
+
},
|
|
72
|
+
onError: (error) => {
|
|
73
|
+
emit("error", { error: redactText(error.message) });
|
|
74
|
+
inner.onError(error);
|
|
75
|
+
},
|
|
76
|
+
onAbort: (reason) => {
|
|
77
|
+
emit("status", { status: "aborted", ...reason ? { reason } : {} });
|
|
78
|
+
inner.onAbort(reason);
|
|
79
|
+
},
|
|
80
|
+
onApprovalRequired: async (id, name, input) => {
|
|
81
|
+
emit("approval_required", { requestId: id, toolName: name, input: redactValue(input) });
|
|
82
|
+
const result = await inner.onApprovalRequired(id, name, input);
|
|
83
|
+
const approved = typeof result === "boolean" ? result : result.approved;
|
|
84
|
+
emit("approval_resolved", { requestId: id, decision: approved ? "approve" : "reject" });
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
if (inner.onCheckpoint) {
|
|
89
|
+
const fn = inner.onCheckpoint.bind(inner);
|
|
90
|
+
tapped.onCheckpoint = (hash) => {
|
|
91
|
+
emit("checkpoint", { hash });
|
|
92
|
+
fn(hash);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (inner.onPhaseChange) {
|
|
96
|
+
const fn = inner.onPhaseChange.bind(inner);
|
|
97
|
+
tapped.onPhaseChange = (phase, detail) => {
|
|
98
|
+
emit("phase", { phase, ...detail });
|
|
99
|
+
fn(phase, detail);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (inner.onIntentNote) {
|
|
103
|
+
const fn = inner.onIntentNote.bind(inner);
|
|
104
|
+
tapped.onIntentNote = (intent) => {
|
|
105
|
+
emit("intent_note", redactValue(intent));
|
|
106
|
+
fn(intent);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (inner.onDecisionShift) {
|
|
110
|
+
const fn = inner.onDecisionShift.bind(inner);
|
|
111
|
+
tapped.onDecisionShift = (shift) => {
|
|
112
|
+
emit("decision_shift", redactValue(shift));
|
|
113
|
+
fn(shift);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (inner.onDomainDrift) {
|
|
117
|
+
const fn = inner.onDomainDrift.bind(inner);
|
|
118
|
+
tapped.onDomainDrift = (drift) => {
|
|
119
|
+
emit("domain_drift", redactValue(drift));
|
|
120
|
+
fn(drift);
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
if (inner.onDelegationActivity) {
|
|
124
|
+
const fn = inner.onDelegationActivity.bind(inner);
|
|
125
|
+
const delegationStartedAt = /* @__PURE__ */ new Map();
|
|
126
|
+
tapped.onDelegationActivity = (a) => {
|
|
127
|
+
let started = delegationStartedAt.get(a.workOrderId);
|
|
128
|
+
if (started === void 0) {
|
|
129
|
+
started = Date.now();
|
|
130
|
+
delegationStartedAt.set(a.workOrderId, started);
|
|
131
|
+
}
|
|
132
|
+
emit("delegation", {
|
|
133
|
+
workerId: a.workOrderId,
|
|
134
|
+
parentId: a.parentToolId,
|
|
135
|
+
// 嵌套委派的父 worker order id(与 sidecar emitDelegationActivity 对齐)。
|
|
136
|
+
parentWorkerId: a.parentWorkerId,
|
|
137
|
+
profile: a.profile,
|
|
138
|
+
authority: a.authority,
|
|
139
|
+
authorityReason: a.authorityReason,
|
|
140
|
+
objective: a.objective,
|
|
141
|
+
status: a.status,
|
|
142
|
+
phase: a.status === "running" ? "running" : a.status,
|
|
143
|
+
progressLine: a.progressLine ? redactText(a.progressLine) : void 0,
|
|
144
|
+
elapsedMs: Date.now() - started,
|
|
145
|
+
toolUseCount: a.toolUseCount,
|
|
146
|
+
tokenCount: a.tokenCount,
|
|
147
|
+
eventKind: a.eventKind,
|
|
148
|
+
eventDetail: a.eventDetail ? redactText(a.eventDetail) : void 0,
|
|
149
|
+
failureReason: a.failureReason,
|
|
150
|
+
model: a.model,
|
|
151
|
+
provider: a.provider,
|
|
152
|
+
usage: a.usage,
|
|
153
|
+
artifactId: a.artifactId,
|
|
154
|
+
changedFiles: a.changedFiles,
|
|
155
|
+
summary: a.summary ? redactText(a.summary) : void 0,
|
|
156
|
+
origin: a.origin,
|
|
157
|
+
contract: a.contract,
|
|
158
|
+
findingsCount: a.findingsCount,
|
|
159
|
+
topFinding: a.topFinding ? redactText(a.topFinding) : void 0,
|
|
160
|
+
verificationBrief: a.verificationBrief,
|
|
161
|
+
evidenceStatus: a.evidenceStatus
|
|
162
|
+
});
|
|
163
|
+
fn(a);
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
return tapped;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export {
|
|
170
|
+
tapAgentCallbacks
|
|
171
|
+
};
|