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,72 @@
|
|
|
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/net/playwright-driver.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
import { createRequire } from "module";
|
|
10
|
+
var PLAYWRIGHT_CORE_INSTALL_HINT = [
|
|
11
|
+
"CLI \u5B89\u88C5\u7528\u6237\uFF1Anpm install -g tianshu-harness\uFF08\u91CD\u65B0\u5B89\u88C5\u4EE5\u8865\u9F50\u4F9D\u8D56\uFF09\uFF0C",
|
|
12
|
+
" \u6216\u5F53\u524D\u9879\u76EE\u5185\uFF1Anpm i playwright-core",
|
|
13
|
+
" \u4ED3\u5E93\u5185\u5F00\u53D1\uFF1Anpm i playwright-core",
|
|
14
|
+
" \u684C\u9762\u7AEF\uFF1A\u68C0\u67E5 dist/node_modules/playwright-core \u662F\u5426\u5B8C\u6574"
|
|
15
|
+
].join("\n");
|
|
16
|
+
function resolvePlaywrightCoreVersion() {
|
|
17
|
+
try {
|
|
18
|
+
const pkg = createRequire(import.meta.url)("playwright-core/package.json");
|
|
19
|
+
return typeof pkg.version === "string" && pkg.version ? pkg.version : void 0;
|
|
20
|
+
} catch {
|
|
21
|
+
return void 0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function playwrightInstallSpec(version = resolvePlaywrightCoreVersion()) {
|
|
25
|
+
return version ? `playwright@${version}` : "playwright";
|
|
26
|
+
}
|
|
27
|
+
var PLAYWRIGHT_MANUAL_INSTALL_HINT = `npx ${playwrightInstallSpec()} install chromium\uFF08\u56FD\u5185\u7F51\u7EDC\uFF1APLAYWRIGHT_DOWNLOAD_HOST=https://registry.npmmirror.com/-/binary/playwright npx ${playwrightInstallSpec()} install chromium\uFF09`;
|
|
28
|
+
var PLAYWRIGHT_INSTALL_HINT = `chromium \u672A\u5B89\u88C5\u3002\u4E00\u952E\u5B89\u88C5\uFF1A\u7EC8\u7AEF \`rivet browser install\`\uFF08\u81EA\u52A8\u5E26\u56FD\u5185\u955C\u50CF\uFF09\uFF0C\u6216\u684C\u9762\u7AEF \u8BBE\u7F6E \u2192 \u96C6\u6210 \u2192 \u6D4F\u89C8\u5668\uFF08\u622A\u56FE\uFF09\u91CC\u70B9\u5B89\u88C5\u3002\u624B\u52A8\uFF1A${PLAYWRIGHT_MANUAL_INSTALL_HINT}`;
|
|
29
|
+
async function loadPlaywrightCore() {
|
|
30
|
+
const specifier = "playwright-core";
|
|
31
|
+
try {
|
|
32
|
+
return await import(specifier);
|
|
33
|
+
} catch (err) {
|
|
34
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
35
|
+
throw new Error(
|
|
36
|
+
`\u65E0\u6CD5\u52A0\u8F7D playwright-core \u6A21\u5757\uFF08\u4E0D\u662F\u6D4F\u89C8\u5668\u7F3A\u5931\uFF09\u3002
|
|
37
|
+
\uFF08\u539F\u59CB\u9519\u8BEF\uFF1A${msg.split("\n")[0]}\uFF09`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function isBrowserMissingError(err) {
|
|
42
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
43
|
+
return msg.includes("Executable") && msg.includes("doesn't exist");
|
|
44
|
+
}
|
|
45
|
+
async function launchHeadlessChromium(opts = {}) {
|
|
46
|
+
const mod = await loadPlaywrightCore();
|
|
47
|
+
try {
|
|
48
|
+
return await mod.chromium.launch({
|
|
49
|
+
headless: true,
|
|
50
|
+
...opts.timeoutMs ? { timeout: opts.timeoutMs } : {},
|
|
51
|
+
...opts.proxy ? { proxy: opts.proxy } : {}
|
|
52
|
+
});
|
|
53
|
+
} catch (err) {
|
|
54
|
+
if (isBrowserMissingError(err)) {
|
|
55
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
56
|
+
throw new Error(`${PLAYWRIGHT_INSTALL_HINT}
|
|
57
|
+
\uFF08\u539F\u59CB\u9519\u8BEF\uFF1A${msg.split("\n")[0]}\uFF09`);
|
|
58
|
+
}
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
PLAYWRIGHT_CORE_INSTALL_HINT,
|
|
65
|
+
resolvePlaywrightCoreVersion,
|
|
66
|
+
playwrightInstallSpec,
|
|
67
|
+
PLAYWRIGHT_MANUAL_INSTALL_HINT,
|
|
68
|
+
PLAYWRIGHT_INSTALL_HINT,
|
|
69
|
+
loadPlaywrightCore,
|
|
70
|
+
isBrowserMissingError,
|
|
71
|
+
launchHeadlessChromium
|
|
72
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
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/api/json-escape-repair.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
var VALID_SINGLE_ESCAPES = /* @__PURE__ */ new Set(['"', "\\", "/", "b", "f", "n", "r", "t"]);
|
|
10
|
+
var HEX4_RE = /^[0-9a-fA-F]{4}/;
|
|
11
|
+
function repairInvalidJsonEscapes(raw) {
|
|
12
|
+
let out = "";
|
|
13
|
+
let inString = false;
|
|
14
|
+
let changed = false;
|
|
15
|
+
for (let i = 0; i < raw.length; i++) {
|
|
16
|
+
const ch = raw[i];
|
|
17
|
+
if (!inString) {
|
|
18
|
+
if (ch === '"') inString = true;
|
|
19
|
+
out += ch;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (ch === '"') {
|
|
23
|
+
inString = false;
|
|
24
|
+
out += ch;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (ch !== "\\") {
|
|
28
|
+
out += ch;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const next = raw[i + 1];
|
|
32
|
+
if (next !== void 0 && VALID_SINGLE_ESCAPES.has(next)) {
|
|
33
|
+
out += ch + next;
|
|
34
|
+
i++;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (next === "u" && HEX4_RE.test(raw.slice(i + 2, i + 6))) {
|
|
38
|
+
out += ch;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
out += "\\\\";
|
|
42
|
+
changed = true;
|
|
43
|
+
}
|
|
44
|
+
return changed ? out : null;
|
|
45
|
+
}
|
|
46
|
+
function parseJsonObjectWithEscapeRepair(raw) {
|
|
47
|
+
for (const candidate of [raw, repairInvalidJsonEscapes(raw)]) {
|
|
48
|
+
if (candidate === null) continue;
|
|
49
|
+
try {
|
|
50
|
+
const parsed = JSON.parse(candidate);
|
|
51
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
52
|
+
return parsed;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
repairInvalidJsonEscapes,
|
|
63
|
+
parseJsonObjectWithEscapeRepair
|
|
64
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
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/agent/galaxy-contract.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
function normalizeGalaxyLabel(value) {
|
|
10
|
+
return value.trim().toLocaleLowerCase().replace(/[\s_-]+/g, "-");
|
|
11
|
+
}
|
|
12
|
+
function validateGalaxyDimensionContract(dimensions) {
|
|
13
|
+
const issues = [];
|
|
14
|
+
const dimensionNames = /* @__PURE__ */ new Map();
|
|
15
|
+
for (let index = 0; index < dimensions.length; index++) {
|
|
16
|
+
const dimension = dimensions[index];
|
|
17
|
+
const name = normalizeGalaxyLabel(dimension.name);
|
|
18
|
+
const previous = dimensionNames.get(name);
|
|
19
|
+
if (previous !== void 0) {
|
|
20
|
+
issues.push({
|
|
21
|
+
dimensionIndex: index,
|
|
22
|
+
code: "duplicate-dimension",
|
|
23
|
+
message: `dimension "${dimension.name}" duplicates dimension #${previous + 1}; use unique names so task identity remains stable`
|
|
24
|
+
});
|
|
25
|
+
} else {
|
|
26
|
+
dimensionNames.set(name, index);
|
|
27
|
+
}
|
|
28
|
+
const hasAuthorityField = dimension.authority !== void 0;
|
|
29
|
+
const hasAuthoritiesField = dimension.authorities !== void 0;
|
|
30
|
+
if (hasAuthorityField && hasAuthoritiesField) {
|
|
31
|
+
issues.push({
|
|
32
|
+
dimensionIndex: index,
|
|
33
|
+
code: "ambiguous-authority",
|
|
34
|
+
message: `dimension "${dimension.name}" must set either authority or authorities, not both`
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const authority = dimension.authority?.trim() ?? "";
|
|
38
|
+
const authorities = (dimension.authorities ?? []).map((value) => value.trim());
|
|
39
|
+
if (!authority && authorities.length === 0) {
|
|
40
|
+
issues.push({
|
|
41
|
+
dimensionIndex: index,
|
|
42
|
+
code: "missing-authority",
|
|
43
|
+
message: `dimension "${dimension.name}" must select at least one star-domain authority`
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const seenAuthorities = /* @__PURE__ */ new Set();
|
|
47
|
+
for (const candidate of authorities) {
|
|
48
|
+
const key = normalizeGalaxyLabel(candidate);
|
|
49
|
+
if (seenAuthorities.has(key)) {
|
|
50
|
+
issues.push({
|
|
51
|
+
dimensionIndex: index,
|
|
52
|
+
code: "duplicate-authority",
|
|
53
|
+
message: `dimension "${dimension.name}" repeats authority "${candidate}"; each EP perspective must be unique`
|
|
54
|
+
});
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
seenAuthorities.add(key);
|
|
58
|
+
}
|
|
59
|
+
if (dimension.parallelism === "data") {
|
|
60
|
+
if (hasAuthoritiesField || authorities.length > 0) {
|
|
61
|
+
issues.push({
|
|
62
|
+
dimensionIndex: index,
|
|
63
|
+
code: "data-authority-list",
|
|
64
|
+
message: `data-parallel dimension "${dimension.name}" accepts one authority; use expert mode for multiple perspectives`
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (dimension.replicas === void 0 || dimension.replicas < 2) {
|
|
68
|
+
issues.push({
|
|
69
|
+
dimensionIndex: index,
|
|
70
|
+
code: "data-replicas",
|
|
71
|
+
message: `data-parallel dimension "${dimension.name}" requires replicas >= 2`
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
} else if (dimension.replicas !== void 0) {
|
|
75
|
+
issues.push({
|
|
76
|
+
dimensionIndex: index,
|
|
77
|
+
code: "expert-replicas",
|
|
78
|
+
message: `expert dimension "${dimension.name}" cannot set replicas; use parallelism: data for independent copies`
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return issues;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/agent/galaxy-budget.ts
|
|
86
|
+
init_esm_shims();
|
|
87
|
+
var SEMANTIC_PATTERNS = [
|
|
88
|
+
["review", ["review", "\u5BA1\u67E5", "\u8BC4\u5BA1", "\u590D\u5BA1", "\u5BA1\u9605"]],
|
|
89
|
+
["verify", ["verify", "test", "\u9A8C\u8BC1", "\u56DE\u5F52", "\u6D4B\u8BD5", "\u81EA\u6D4B"]],
|
|
90
|
+
["docs", ["docs", "doc", "research", "\u6587\u6863", "\u8C03\u7814", "\u7814\u7A76", "\u8D44\u6599"]],
|
|
91
|
+
["plan", ["plan", "design", "\u89C4\u5212", "\u8BA1\u5212", "\u8BBE\u8BA1", "\u65B9\u6848"]],
|
|
92
|
+
["search", ["search", "scout", "explore", "\u68C0\u7D22", "\u641C\u7D22", "\u63A2\u67E5", "\u4FA6\u5BDF", "\u63A2\u7D22", "\u8C03\u67E5"]],
|
|
93
|
+
["impl", ["impl", "patch", "fix", "frontend", "backend", "feature", "\u5B9E\u73B0", "\u524D\u7AEF", "\u540E\u7AEF", "\u4FEE\u590D", "\u8865\u4E01", "\u5F00\u53D1", "\u91CD\u6784"]]
|
|
94
|
+
];
|
|
95
|
+
function classifyGalaxyDimension(name) {
|
|
96
|
+
const key = (name ?? "").toLowerCase().replace(/[\s_-]/g, "");
|
|
97
|
+
if (key.length === 0) return "impl";
|
|
98
|
+
for (const [semantic, patterns] of SEMANTIC_PATTERNS) {
|
|
99
|
+
for (const pattern of patterns) {
|
|
100
|
+
if (key.includes(pattern)) return semantic;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return "impl";
|
|
104
|
+
}
|
|
105
|
+
var PROFILE_BY_SEMANTIC = {
|
|
106
|
+
review: "reviewer",
|
|
107
|
+
verify: "verify_scout",
|
|
108
|
+
plan: "planner",
|
|
109
|
+
docs: "doc_scout",
|
|
110
|
+
search: "code_scout",
|
|
111
|
+
impl: "patcher"
|
|
112
|
+
};
|
|
113
|
+
var KIND_BY_SEMANTIC = {
|
|
114
|
+
review: "review",
|
|
115
|
+
verify: "verify",
|
|
116
|
+
plan: "plan",
|
|
117
|
+
docs: "doc_research",
|
|
118
|
+
search: "code_search",
|
|
119
|
+
impl: "patch_proposal"
|
|
120
|
+
};
|
|
121
|
+
var TASK_SHAPE_BY_SEMANTIC = {
|
|
122
|
+
review: "review",
|
|
123
|
+
verify: "review",
|
|
124
|
+
plan: "plan",
|
|
125
|
+
docs: "docs",
|
|
126
|
+
search: "explore",
|
|
127
|
+
impl: "impl"
|
|
128
|
+
};
|
|
129
|
+
function mapGalaxyDimensionToProfile(name) {
|
|
130
|
+
return PROFILE_BY_SEMANTIC[classifyGalaxyDimension(name)];
|
|
131
|
+
}
|
|
132
|
+
function mapGalaxyDimensionToKind(name) {
|
|
133
|
+
return KIND_BY_SEMANTIC[classifyGalaxyDimension(name)];
|
|
134
|
+
}
|
|
135
|
+
function mapGalaxyDimensionToTaskShape(name) {
|
|
136
|
+
return TASK_SHAPE_BY_SEMANTIC[classifyGalaxyDimension(name)];
|
|
137
|
+
}
|
|
138
|
+
function isReviewGalaxyDimension(name) {
|
|
139
|
+
const semantic = classifyGalaxyDimension(name);
|
|
140
|
+
return semantic === "review" || semantic === "verify";
|
|
141
|
+
}
|
|
142
|
+
function buildGalaxyBudgetInputs(dimensions) {
|
|
143
|
+
const profiles = [];
|
|
144
|
+
const tierFloors = [];
|
|
145
|
+
const requestedTimeoutMs = [];
|
|
146
|
+
for (const rawDimension of dimensions) {
|
|
147
|
+
if (!rawDimension || typeof rawDimension !== "object") continue;
|
|
148
|
+
const dimension = rawDimension;
|
|
149
|
+
const authorities = Array.isArray(dimension.authorities) ? dimension.authorities : typeof dimension.authority === "string" && dimension.authority.length > 0 ? [dimension.authority] : [];
|
|
150
|
+
const replicas = dimension.parallelism === "data" && typeof dimension.replicas === "number" && Number.isFinite(dimension.replicas) ? Math.max(1, Math.trunc(dimension.replicas)) : 1;
|
|
151
|
+
const profile = typeof dimension.profile === "string" ? dimension.profile : typeof dimension.name === "string" && dimension.name.length > 0 ? mapGalaxyDimensionToProfile(dimension.name) : void 0;
|
|
152
|
+
for (let i = 0; i < authorities.length * replicas; i++) {
|
|
153
|
+
profiles.push(profile);
|
|
154
|
+
tierFloors.push(dimension.tierFloor);
|
|
155
|
+
requestedTimeoutMs.push(dimension.timeoutMs);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return { profiles, tierFloors, requestedTimeoutMs };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export {
|
|
162
|
+
validateGalaxyDimensionContract,
|
|
163
|
+
mapGalaxyDimensionToProfile,
|
|
164
|
+
mapGalaxyDimensionToKind,
|
|
165
|
+
mapGalaxyDimensionToTaskShape,
|
|
166
|
+
isReviewGalaxyDimension,
|
|
167
|
+
buildGalaxyBudgetInputs
|
|
168
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
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/agent/tool-arg-post-processor.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
var ToolArgPostProcessorRegistry = class {
|
|
10
|
+
processors = /* @__PURE__ */ new Map();
|
|
11
|
+
register(processor) {
|
|
12
|
+
this.processors.set(processor.toolName, processor);
|
|
13
|
+
}
|
|
14
|
+
has(name) {
|
|
15
|
+
return this.processors.has(name);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Process an array of OaiToolCalls in-place-safe manner.
|
|
19
|
+
* Returns the same array if nothing changed, or a new array with
|
|
20
|
+
* replaced arguments. Never mutates the original OaiToolCall objects —
|
|
21
|
+
* creates shallow copies with replaced `function.arguments`.
|
|
22
|
+
*/
|
|
23
|
+
processToolCalls(calls) {
|
|
24
|
+
if (calls.length === 0) return calls;
|
|
25
|
+
let changed = false;
|
|
26
|
+
const result = calls.map((tc) => {
|
|
27
|
+
const processor = this.processors.get(tc.function.name);
|
|
28
|
+
if (!processor) return tc;
|
|
29
|
+
try {
|
|
30
|
+
const newArgs = processor.process(tc.function.arguments);
|
|
31
|
+
if (newArgs !== null && newArgs !== tc.function.arguments) {
|
|
32
|
+
changed = true;
|
|
33
|
+
return {
|
|
34
|
+
...tc,
|
|
35
|
+
function: { ...tc.function, arguments: newArgs }
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
return tc;
|
|
41
|
+
});
|
|
42
|
+
return changed ? result : calls;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
function createFileContentArgProcessor(opts) {
|
|
46
|
+
return {
|
|
47
|
+
toolName: opts.toolName,
|
|
48
|
+
process(args) {
|
|
49
|
+
let parsed;
|
|
50
|
+
try {
|
|
51
|
+
parsed = JSON.parse(args);
|
|
52
|
+
} catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const content = parsed[opts.contentField];
|
|
56
|
+
if (typeof content !== "string" || content.length === 0) return null;
|
|
57
|
+
if (content.startsWith(opts.pointerPrefix)) return null;
|
|
58
|
+
if (opts.threshold > 0 && content.length < opts.threshold) return null;
|
|
59
|
+
const path = opts.resolvePath(parsed);
|
|
60
|
+
if (typeof path !== "string" || path.length === 0) return null;
|
|
61
|
+
const chars = content.length;
|
|
62
|
+
const lines = content.split("\n").length;
|
|
63
|
+
return JSON.stringify({
|
|
64
|
+
...parsed,
|
|
65
|
+
[opts.contentField]: opts.render({ path, lines, chars })
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/tools/edit-file-arg-processor.ts
|
|
72
|
+
init_esm_shims();
|
|
73
|
+
|
|
74
|
+
// src/tools/pointer-tag.ts
|
|
75
|
+
init_esm_shims();
|
|
76
|
+
var POINTER_INTERNAL_TAG = "#RIVET-POINTER-DISPLAY-ONLY#";
|
|
77
|
+
|
|
78
|
+
// src/tools/edit-file-arg-processor.ts
|
|
79
|
+
var EDIT_FILE_POINTER_PREFIX = "[edit on";
|
|
80
|
+
var EDIT_FILE_THRESHOLD = 8e3;
|
|
81
|
+
var editFileArgProcessor = {
|
|
82
|
+
toolName: "edit_file",
|
|
83
|
+
process(args) {
|
|
84
|
+
let parsed;
|
|
85
|
+
try {
|
|
86
|
+
parsed = JSON.parse(args);
|
|
87
|
+
} catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const oldStr = parsed.old_string;
|
|
91
|
+
const newStr = parsed.new_string;
|
|
92
|
+
const filePath = parsed.file_path;
|
|
93
|
+
if (typeof oldStr !== "string" || typeof newStr !== "string") return null;
|
|
94
|
+
if (typeof filePath !== "string" || filePath.length === 0) return null;
|
|
95
|
+
if (oldStr.startsWith(EDIT_FILE_POINTER_PREFIX)) return null;
|
|
96
|
+
if (oldStr.length + newStr.length < EDIT_FILE_THRESHOLD) return null;
|
|
97
|
+
const preview = oldStr.slice(0, 80).replace(/\s+/g, " ").trim();
|
|
98
|
+
return JSON.stringify({
|
|
99
|
+
...parsed,
|
|
100
|
+
old_string: `${EDIT_FILE_POINTER_PREFIX} ${filePath}: replaced ${oldStr.length}-char block, preview: "${preview}". \u5DF2\u6210\u529F\u843D\u76D8\uFF0C\u52FF\u91CD\u505A\u2014\u2014\u5386\u53F2\u6B63\u5E38\u622A\u65AD\uFF0C\u67E5\u770B\u7528 read_file\u3002${POINTER_INTERNAL_TAG} display-only pointer]`,
|
|
101
|
+
new_string: `[new block ${filePath}: ${newStr.length} chars \u2014 \u5DF2\u843D\u76D8\uFF0C\u52FF\u91CD\u505A\u3002${POINTER_INTERNAL_TAG} display-only pointer]`
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// src/tools/hash-edit-arg-processor.ts
|
|
107
|
+
init_esm_shims();
|
|
108
|
+
var HASH_EDIT_POINTER_PREFIX = "[hash_edit applied to";
|
|
109
|
+
var HASH_EDIT_THRESHOLD = 8e3;
|
|
110
|
+
var hashEditArgProcessor = createFileContentArgProcessor({
|
|
111
|
+
toolName: "hash_edit",
|
|
112
|
+
contentField: "new_string",
|
|
113
|
+
pointerPrefix: HASH_EDIT_POINTER_PREFIX,
|
|
114
|
+
threshold: HASH_EDIT_THRESHOLD,
|
|
115
|
+
resolvePath: (parsed) => {
|
|
116
|
+
const fp = parsed.file_path;
|
|
117
|
+
return typeof fp === "string" && fp.length > 0 ? fp : null;
|
|
118
|
+
},
|
|
119
|
+
render: ({ path, lines, chars }) => `${HASH_EDIT_POINTER_PREFIX} ${path} \u2014 new block ${lines} lines, ${chars} chars. \u5DF2\u6210\u529F\u843D\u76D8\uFF0C\u52FF\u91CD\u505A\u2014\u2014\u5386\u53F2\u6B63\u5E38\u622A\u65AD\uFF0C\u67E5\u770B\u7528 read_file\u3002${POINTER_INTERNAL_TAG} display-only pointer]`
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// src/tools/apply-patch-arg-processor.ts
|
|
123
|
+
init_esm_shims();
|
|
124
|
+
var APPLY_PATCH_POINTER_PREFIX = "[patch applied to";
|
|
125
|
+
var APPLY_PATCH_THRESHOLD = 4e3;
|
|
126
|
+
var MAX_LISTED_FILES = 5;
|
|
127
|
+
function parsePatchedFiles(diff) {
|
|
128
|
+
const files = [];
|
|
129
|
+
for (const line of diff.split("\n")) {
|
|
130
|
+
if (!line.startsWith("+++ ")) continue;
|
|
131
|
+
let path = line.slice(4).trim();
|
|
132
|
+
const tabIdx = path.indexOf(" ");
|
|
133
|
+
if (tabIdx !== -1) path = path.slice(0, tabIdx);
|
|
134
|
+
if (path === "/dev/null") continue;
|
|
135
|
+
if (path.startsWith("b/")) path = path.slice(2);
|
|
136
|
+
if (path.length > 0) files.push(path);
|
|
137
|
+
}
|
|
138
|
+
return files;
|
|
139
|
+
}
|
|
140
|
+
var applyPatchArgProcessor = {
|
|
141
|
+
toolName: "apply_patch",
|
|
142
|
+
process(args) {
|
|
143
|
+
let parsed;
|
|
144
|
+
try {
|
|
145
|
+
parsed = JSON.parse(args);
|
|
146
|
+
} catch {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
const diff = parsed.diff;
|
|
150
|
+
if (typeof diff !== "string" || diff.length === 0) return null;
|
|
151
|
+
if (diff.startsWith(APPLY_PATCH_POINTER_PREFIX)) return null;
|
|
152
|
+
if (parsed.check_only === true) return null;
|
|
153
|
+
if (diff.length < APPLY_PATCH_THRESHOLD) return null;
|
|
154
|
+
const files = parsePatchedFiles(diff);
|
|
155
|
+
if (files.length === 0) return null;
|
|
156
|
+
const hunks = (diff.match(/^@@ /gm) ?? []).length;
|
|
157
|
+
const shown = files.slice(0, MAX_LISTED_FILES).join(", ");
|
|
158
|
+
const more = files.length > MAX_LISTED_FILES ? `, \u2026(+${files.length - MAX_LISTED_FILES})` : "";
|
|
159
|
+
return JSON.stringify({
|
|
160
|
+
...parsed,
|
|
161
|
+
diff: `${APPLY_PATCH_POINTER_PREFIX} ${files.length} file(s): ${shown}${more} \u2014 ${hunks} hunks, ${diff.length} chars. \u5DF2\u6210\u529F\u5E94\u7528\uFF0C\u52FF\u91CD\u653E\u2014\u2014\u5386\u53F2\u6B63\u5E38\u622A\u65AD\uFF0C\u67E5\u770B\u7528 read_file / git diff\u3002${POINTER_INTERNAL_TAG} display-only pointer]`
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export {
|
|
167
|
+
ToolArgPostProcessorRegistry,
|
|
168
|
+
createFileContentArgProcessor,
|
|
169
|
+
POINTER_INTERNAL_TAG,
|
|
170
|
+
EDIT_FILE_POINTER_PREFIX,
|
|
171
|
+
editFileArgProcessor,
|
|
172
|
+
HASH_EDIT_POINTER_PREFIX,
|
|
173
|
+
hashEditArgProcessor,
|
|
174
|
+
APPLY_PATCH_POINTER_PREFIX,
|
|
175
|
+
applyPatchArgProcessor
|
|
176
|
+
};
|