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,315 @@
|
|
|
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/platform.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
import { homedir } from "os";
|
|
10
|
+
import { execFile, spawnSync } from "child_process";
|
|
11
|
+
import { existsSync } from "fs";
|
|
12
|
+
import { win32 as winPath } from "path";
|
|
13
|
+
import { TextDecoder } from "util";
|
|
14
|
+
var isWin = process.platform === "win32";
|
|
15
|
+
function resolveTargetPlatform(platform) {
|
|
16
|
+
switch (platform) {
|
|
17
|
+
case "windows":
|
|
18
|
+
return "win32";
|
|
19
|
+
case "macos":
|
|
20
|
+
return "darwin";
|
|
21
|
+
case "linux":
|
|
22
|
+
return "linux";
|
|
23
|
+
case "auto":
|
|
24
|
+
default:
|
|
25
|
+
return process.platform;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
var _targetPlatform = process.platform;
|
|
29
|
+
var _targetEol = process.platform === "win32" ? "crlf" : "lf";
|
|
30
|
+
function setTargetConventions(platform, eol) {
|
|
31
|
+
_targetPlatform = resolveTargetPlatform(platform);
|
|
32
|
+
_targetEol = eol === "auto" ? _targetPlatform === "win32" ? "crlf" : "lf" : eol;
|
|
33
|
+
}
|
|
34
|
+
function getTargetPlatform() {
|
|
35
|
+
return _targetPlatform;
|
|
36
|
+
}
|
|
37
|
+
function getTargetEol() {
|
|
38
|
+
return _targetEol;
|
|
39
|
+
}
|
|
40
|
+
var _cachedShell = null;
|
|
41
|
+
var _cachedGitBash;
|
|
42
|
+
function resolveGitBashPath(deps) {
|
|
43
|
+
if (!deps.isWindows) return null;
|
|
44
|
+
const override = deps.env["RIVET_GIT_BASH_PATH"];
|
|
45
|
+
if (override && deps.exists(override)) return override;
|
|
46
|
+
const gitPath = deps.whichGit();
|
|
47
|
+
if (gitPath) {
|
|
48
|
+
const gitRoot = winPath.dirname(winPath.dirname(gitPath));
|
|
49
|
+
const bashPath = winPath.join(gitRoot, "bin", "bash.exe");
|
|
50
|
+
if (deps.exists(bashPath)) return bashPath;
|
|
51
|
+
}
|
|
52
|
+
const bashOnPath = deps.whichBash?.();
|
|
53
|
+
if (bashOnPath && !/^[A-Za-z]:\\Windows\\(System32|SysWOW64)\\bash\.exe$/i.test(bashOnPath) && deps.exists(bashOnPath)) {
|
|
54
|
+
return bashOnPath;
|
|
55
|
+
}
|
|
56
|
+
const candidates = [
|
|
57
|
+
"C:\\Program Files\\Git\\bin\\bash.exe",
|
|
58
|
+
"C:\\Program Files (x86)\\Git\\bin\\bash.exe"
|
|
59
|
+
];
|
|
60
|
+
const localApp = deps.env["LOCALAPPDATA"];
|
|
61
|
+
if (localApp) candidates.push(winPath.join(localApp, "Programs", "Git", "bin", "bash.exe"));
|
|
62
|
+
const scoopRoot = deps.env["SCOOP"];
|
|
63
|
+
if (scoopRoot) candidates.push(winPath.join(scoopRoot, "apps", "git", "current", "bin", "bash.exe"));
|
|
64
|
+
const userProfile = deps.env["USERPROFILE"];
|
|
65
|
+
if (userProfile) candidates.push(winPath.join(userProfile, "scoop", "apps", "git", "current", "bin", "bash.exe"));
|
|
66
|
+
for (const c of candidates) {
|
|
67
|
+
if (deps.exists(c)) return c;
|
|
68
|
+
}
|
|
69
|
+
const bundledGitDir = deps.env["RIVET_BUNDLED_GIT_DIR"];
|
|
70
|
+
if (bundledGitDir) {
|
|
71
|
+
const bundledBash = winPath.join(bundledGitDir, "bin", "bash.exe");
|
|
72
|
+
if (deps.exists(bundledBash)) return bundledBash;
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
function whichGitWindows() {
|
|
77
|
+
try {
|
|
78
|
+
const result = spawnSync("where", ["git"], { stdio: ["ignore", "pipe", "ignore"], timeout: 3e3, windowsHide: true });
|
|
79
|
+
if (result.status === 0) {
|
|
80
|
+
const first = result.stdout.toString().split("\n")[0]?.trim();
|
|
81
|
+
return first && first.length > 0 ? first : void 0;
|
|
82
|
+
}
|
|
83
|
+
} catch {
|
|
84
|
+
}
|
|
85
|
+
return void 0;
|
|
86
|
+
}
|
|
87
|
+
function whichBashWindows() {
|
|
88
|
+
try {
|
|
89
|
+
const result = spawnSync("where", ["bash"], { stdio: ["ignore", "pipe", "ignore"], timeout: 3e3, windowsHide: true });
|
|
90
|
+
if (result.status === 0) {
|
|
91
|
+
const first = result.stdout.toString().split("\n")[0]?.trim();
|
|
92
|
+
return first && first.length > 0 ? first : void 0;
|
|
93
|
+
}
|
|
94
|
+
} catch {
|
|
95
|
+
}
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
function applyConfiguredGitBashPath(gitBashPath) {
|
|
99
|
+
const trimmed = gitBashPath?.trim();
|
|
100
|
+
if (!trimmed) return;
|
|
101
|
+
if (process.env["RIVET_GIT_BASH_PATH"]) return;
|
|
102
|
+
process.env["RIVET_GIT_BASH_PATH"] = trimmed;
|
|
103
|
+
_cachedGitBash = void 0;
|
|
104
|
+
_cachedShell = null;
|
|
105
|
+
_shellProbeGen++;
|
|
106
|
+
}
|
|
107
|
+
function whereAsync(cmd) {
|
|
108
|
+
return new Promise((resolve) => {
|
|
109
|
+
try {
|
|
110
|
+
execFile("where", [cmd], { timeout: 3e3, windowsHide: true, encoding: "utf8" }, (err, stdout) => {
|
|
111
|
+
if (err || typeof stdout !== "string") return resolve(void 0);
|
|
112
|
+
const first = stdout.split("\n")[0]?.trim();
|
|
113
|
+
resolve(first && first.length > 0 ? first : void 0);
|
|
114
|
+
});
|
|
115
|
+
} catch {
|
|
116
|
+
resolve(void 0);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
var _shellPrewarm = null;
|
|
121
|
+
var _shellProbeGen = 0;
|
|
122
|
+
function prewarmShellProbes() {
|
|
123
|
+
if (_cachedShell && _cachedGitBash !== void 0) return Promise.resolve();
|
|
124
|
+
if (_shellPrewarm) return _shellPrewarm;
|
|
125
|
+
_shellPrewarm = (async () => {
|
|
126
|
+
if (!isWin) {
|
|
127
|
+
if (_cachedGitBash === void 0) _cachedGitBash = null;
|
|
128
|
+
if (!_cachedShell) _cachedShell = resolveShellCommand({ isWindows: false, env: process.env, gitBashPath: null, hasPwsh: () => false });
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const gen = _shellProbeGen;
|
|
132
|
+
const [git, bash, pwsh, powershell] = await Promise.all([
|
|
133
|
+
whereAsync("git"),
|
|
134
|
+
whereAsync("bash"),
|
|
135
|
+
whereAsync("pwsh.exe"),
|
|
136
|
+
whereAsync("powershell.exe")
|
|
137
|
+
]);
|
|
138
|
+
if (gen !== _shellProbeGen) return;
|
|
139
|
+
if (_cachedGitBash === void 0) {
|
|
140
|
+
_cachedGitBash = resolveGitBashPath({
|
|
141
|
+
isWindows: true,
|
|
142
|
+
env: process.env,
|
|
143
|
+
whichGit: () => git,
|
|
144
|
+
whichBash: () => bash,
|
|
145
|
+
exists: existsSync
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (!_cachedShell) {
|
|
149
|
+
const hits = { "pwsh.exe": !!pwsh, "powershell.exe": !!powershell };
|
|
150
|
+
_cachedShell = resolveShellCommand({
|
|
151
|
+
isWindows: true,
|
|
152
|
+
env: process.env,
|
|
153
|
+
gitBashPath: _cachedGitBash,
|
|
154
|
+
hasPwsh: (cmd) => hits[cmd] ?? false
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
})().catch(() => {
|
|
158
|
+
}).finally(() => {
|
|
159
|
+
_shellPrewarm = null;
|
|
160
|
+
});
|
|
161
|
+
return _shellPrewarm;
|
|
162
|
+
}
|
|
163
|
+
function findGitBashPath() {
|
|
164
|
+
if (_cachedGitBash !== void 0) return _cachedGitBash;
|
|
165
|
+
_cachedGitBash = resolveGitBashPath({
|
|
166
|
+
isWindows: isWin,
|
|
167
|
+
env: process.env,
|
|
168
|
+
whichGit: whichGitWindows,
|
|
169
|
+
whichBash: whichBashWindows,
|
|
170
|
+
exists: existsSync
|
|
171
|
+
});
|
|
172
|
+
return _cachedGitBash;
|
|
173
|
+
}
|
|
174
|
+
function resolveShellCommand(deps) {
|
|
175
|
+
if (deps.isWindows) {
|
|
176
|
+
const forcePwsh = /^(1|true|yes)$/i.test(deps.env["RIVET_USE_POWERSHELL"] ?? "");
|
|
177
|
+
if (!forcePwsh && deps.gitBashPath) {
|
|
178
|
+
return { cmd: deps.gitBashPath, args: ["-c"], kind: "bash" };
|
|
179
|
+
}
|
|
180
|
+
for (const cmd of ["pwsh.exe", "powershell.exe"]) {
|
|
181
|
+
if (deps.hasPwsh(cmd)) {
|
|
182
|
+
return { cmd, args: ["-NoProfile", "-NonInteractive", "-Command"], kind: "powershell" };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const comSpec = deps.env["ComSpec"] || "cmd.exe";
|
|
186
|
+
return { cmd: comSpec, args: ["/c"], kind: "cmd" };
|
|
187
|
+
}
|
|
188
|
+
return { cmd: "sh", args: ["-c"], kind: "sh" };
|
|
189
|
+
}
|
|
190
|
+
function hasPwshWindows(cmd) {
|
|
191
|
+
try {
|
|
192
|
+
const result = spawnSync("where", [cmd], { stdio: ["ignore", "pipe", "ignore"], timeout: 3e3, windowsHide: true });
|
|
193
|
+
return result.status === 0 && result.stdout.toString().trim().length > 0;
|
|
194
|
+
} catch {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function getShellCommand() {
|
|
199
|
+
if (_cachedShell) return _cachedShell;
|
|
200
|
+
_cachedShell = resolveShellCommand({
|
|
201
|
+
isWindows: isWin,
|
|
202
|
+
env: process.env,
|
|
203
|
+
gitBashPath: findGitBashPath(),
|
|
204
|
+
hasPwsh: hasPwshWindows
|
|
205
|
+
});
|
|
206
|
+
return _cachedShell;
|
|
207
|
+
}
|
|
208
|
+
function getShellDiagnostics() {
|
|
209
|
+
const shell = getShellCommand();
|
|
210
|
+
const gitBash = findGitBashPath();
|
|
211
|
+
const diag = { kind: shell.kind, cmd: shell.cmd, gitBashPath: gitBash };
|
|
212
|
+
if (isWin && shell.kind !== "bash") {
|
|
213
|
+
const bundledNote = process.env["RIVET_BUNDLED_GIT_DIR"] ? `, \u5185\u7F6E Git\uFF08${process.env["RIVET_BUNDLED_GIT_DIR"]}\u2014\u2014\u53EF\u80FD\u4ECD\u5728\u9996\u6B21\u89E3\u538B\u4E2D\uFF0C\u7A0D\u540E\u91CD\u8BD5\u6216\u91CD\u542F\uFF09` : "";
|
|
214
|
+
diag.fallbackReason = gitBash ? `Git Bash found at ${gitBash} but not selected (RIVET_USE_POWERSHELL set?)` : `Git Bash not found \u2014 probed RIVET_GIT_BASH_PATH, \`where git\` \u2192 \u2026\\Git\\bin\\bash.exe, C:\\Program Files\\Git, %LOCALAPPDATA%\\Programs\\Git${bundledNote}`;
|
|
215
|
+
}
|
|
216
|
+
return diag;
|
|
217
|
+
}
|
|
218
|
+
function rewriteWindowsNullRedirect(command) {
|
|
219
|
+
return command.replace(
|
|
220
|
+
/(^|\s)(\d?)>\s*nul(?=\s|$|;|&|\|)/gi,
|
|
221
|
+
(_m, pre, fd) => `${pre}${fd}>/dev/null`
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
function rewritePowershellNullRedirect(command) {
|
|
225
|
+
return command.replace(
|
|
226
|
+
/(^|\s)(\d?)>\s*(?:nul|\/dev\/null)(?=\s|$|;|&|\|)/gi,
|
|
227
|
+
(_m, pre, fd) => `${pre}${fd}>$null`
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
function gracefulKill(child) {
|
|
231
|
+
if (!child.pid) return;
|
|
232
|
+
try {
|
|
233
|
+
if (isWin) {
|
|
234
|
+
spawnSync("taskkill", ["/PID", String(child.pid)], {
|
|
235
|
+
stdio: ["ignore", "ignore", "ignore"],
|
|
236
|
+
timeout: 5e3,
|
|
237
|
+
windowsHide: true
|
|
238
|
+
});
|
|
239
|
+
} else {
|
|
240
|
+
child.kill("SIGTERM");
|
|
241
|
+
}
|
|
242
|
+
} catch {
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function forceKill(child) {
|
|
246
|
+
if (!child.pid) return;
|
|
247
|
+
try {
|
|
248
|
+
if (isWin) {
|
|
249
|
+
spawnSync("taskkill", ["/F", "/PID", String(child.pid)], {
|
|
250
|
+
stdio: ["ignore", "ignore", "ignore"],
|
|
251
|
+
timeout: 5e3,
|
|
252
|
+
windowsHide: true
|
|
253
|
+
});
|
|
254
|
+
} else {
|
|
255
|
+
child.kill("SIGKILL");
|
|
256
|
+
}
|
|
257
|
+
} catch {
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function expandHome(path) {
|
|
261
|
+
if (path.startsWith("~")) {
|
|
262
|
+
return homedir() + path.slice(1);
|
|
263
|
+
}
|
|
264
|
+
return path;
|
|
265
|
+
}
|
|
266
|
+
var isUtf8Buffer = typeof Buffer.isUtf8 === "function" ? Buffer.isUtf8 : (buf) => {
|
|
267
|
+
try {
|
|
268
|
+
new TextDecoder("utf-8", { fatal: true }).decode(buf);
|
|
269
|
+
return true;
|
|
270
|
+
} catch {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
var WinStreamDecoder = class {
|
|
275
|
+
decoder = null;
|
|
276
|
+
isUtf8 = true;
|
|
277
|
+
first = true;
|
|
278
|
+
write(chunk) {
|
|
279
|
+
if (!isWin) {
|
|
280
|
+
return chunk.toString("utf8");
|
|
281
|
+
}
|
|
282
|
+
if (this.first) {
|
|
283
|
+
this.first = false;
|
|
284
|
+
this.isUtf8 = isUtf8Buffer(chunk);
|
|
285
|
+
const encoding = this.isUtf8 ? "utf-8" : "gbk";
|
|
286
|
+
this.decoder = new TextDecoder(encoding, { fatal: false });
|
|
287
|
+
}
|
|
288
|
+
if (this.decoder) {
|
|
289
|
+
return this.decoder.decode(chunk, { stream: true });
|
|
290
|
+
}
|
|
291
|
+
return chunk.toString("utf8");
|
|
292
|
+
}
|
|
293
|
+
end() {
|
|
294
|
+
if (this.decoder) {
|
|
295
|
+
return this.decoder.decode();
|
|
296
|
+
}
|
|
297
|
+
return "";
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
export {
|
|
302
|
+
setTargetConventions,
|
|
303
|
+
getTargetPlatform,
|
|
304
|
+
getTargetEol,
|
|
305
|
+
applyConfiguredGitBashPath,
|
|
306
|
+
prewarmShellProbes,
|
|
307
|
+
getShellCommand,
|
|
308
|
+
getShellDiagnostics,
|
|
309
|
+
rewriteWindowsNullRedirect,
|
|
310
|
+
rewritePowershellNullRedirect,
|
|
311
|
+
gracefulKill,
|
|
312
|
+
forceKill,
|
|
313
|
+
expandHome,
|
|
314
|
+
WinStreamDecoder
|
|
315
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
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/prompt/volatile-git.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
import { execFile } from "child_process";
|
|
10
|
+
import { promisify } from "util";
|
|
11
|
+
var execFileP = promisify(execFile);
|
|
12
|
+
function formatGitStatus(branch, status) {
|
|
13
|
+
if (!branch && !status) return void 0;
|
|
14
|
+
return `Current branch: ${branch}
|
|
15
|
+
Status:
|
|
16
|
+
${status || "(clean)"}`;
|
|
17
|
+
}
|
|
18
|
+
async function loadGitStatus(cwd) {
|
|
19
|
+
try {
|
|
20
|
+
const [branchResult, statusResult, logResult] = await Promise.all([
|
|
21
|
+
execFileP("git", ["branch", "--show-current"], { cwd, timeout: 5e3, windowsHide: true }),
|
|
22
|
+
execFileP("git", ["status", "--short"], { cwd, timeout: 5e3, windowsHide: true }),
|
|
23
|
+
execFileP("git", ["log", "--oneline", "-5"], { cwd, timeout: 5e3, windowsHide: true }).catch(() => ({ stdout: "" }))
|
|
24
|
+
]);
|
|
25
|
+
const base = formatGitStatus(branchResult.stdout.trim(), statusResult.stdout.trim());
|
|
26
|
+
const log = logResult.stdout.trim();
|
|
27
|
+
if (!base && !log) return void 0;
|
|
28
|
+
return log ? `${base ?? ""}
|
|
29
|
+
Recent commits:
|
|
30
|
+
${log}` : base;
|
|
31
|
+
} catch {
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
var MAX_CACHED_CWDS = 50;
|
|
36
|
+
function trimCache(map, ttlMs) {
|
|
37
|
+
if (map.size <= MAX_CACHED_CWDS) return;
|
|
38
|
+
const now = Date.now();
|
|
39
|
+
for (const [key, val] of map) {
|
|
40
|
+
if (now - val.timestamp > ttlMs) map.delete(key);
|
|
41
|
+
}
|
|
42
|
+
while (map.size > MAX_CACHED_CWDS) {
|
|
43
|
+
const [key] = map.keys();
|
|
44
|
+
map.delete(key);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function createGitStatusCache(options) {
|
|
48
|
+
const values = /* @__PURE__ */ new Map();
|
|
49
|
+
const refreshing = /* @__PURE__ */ new Map();
|
|
50
|
+
const isFresh = (cwd) => {
|
|
51
|
+
const entry = values.get(cwd);
|
|
52
|
+
return !!entry && options.now() - entry.timestamp < options.ttlMs;
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
get(cwd) {
|
|
56
|
+
trimCache(values, options.ttlMs);
|
|
57
|
+
return values.get(cwd)?.value;
|
|
58
|
+
},
|
|
59
|
+
prime(cwd, nextValue) {
|
|
60
|
+
values.set(cwd, { value: nextValue, timestamp: options.now() });
|
|
61
|
+
trimCache(values, options.ttlMs);
|
|
62
|
+
},
|
|
63
|
+
async refresh(cwd) {
|
|
64
|
+
const existing = refreshing.get(cwd);
|
|
65
|
+
if (existing) return existing;
|
|
66
|
+
const work = options.load(cwd).then((nextValue) => {
|
|
67
|
+
values.set(cwd, { value: nextValue, timestamp: options.now() });
|
|
68
|
+
trimCache(values, options.ttlMs);
|
|
69
|
+
}).finally(() => {
|
|
70
|
+
refreshing.delete(cwd);
|
|
71
|
+
});
|
|
72
|
+
refreshing.set(cwd, work);
|
|
73
|
+
return work;
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
* Awaitable variant: triggers refresh only if the cache is stale.
|
|
77
|
+
* Call this before building a prompt to eliminate the 30s staleness blind spot
|
|
78
|
+
* while keeping the synchronous get() path side-effect free.
|
|
79
|
+
*/
|
|
80
|
+
async refreshIfStale(cwd) {
|
|
81
|
+
if (!isFresh(cwd)) {
|
|
82
|
+
await this.refresh(cwd);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
var gitStatusCache = createGitStatusCache({
|
|
88
|
+
ttlMs: 3e4,
|
|
89
|
+
now: () => Date.now(),
|
|
90
|
+
load: loadGitStatus
|
|
91
|
+
});
|
|
92
|
+
async function getGitInjectedContext(cwd) {
|
|
93
|
+
try {
|
|
94
|
+
const [branchResult, headResult] = await Promise.all([
|
|
95
|
+
execFileP("git", ["branch", "--show-current"], { cwd, timeout: 5e3, windowsHide: true }),
|
|
96
|
+
execFileP("git", ["rev-parse", "HEAD"], { cwd, timeout: 5e3, windowsHide: true })
|
|
97
|
+
]);
|
|
98
|
+
const branch = branchResult.stdout.trim() || void 0;
|
|
99
|
+
const head = headResult.stdout.trim() || void 0;
|
|
100
|
+
if (!branch && !head) return void 0;
|
|
101
|
+
return { branch, head };
|
|
102
|
+
} catch {
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
formatGitStatus,
|
|
109
|
+
createGitStatusCache,
|
|
110
|
+
gitStatusCache,
|
|
111
|
+
getGitInjectedContext
|
|
112
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
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/oai-types.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
function isToolMessage(msg) {
|
|
10
|
+
return msg.role === "tool";
|
|
11
|
+
}
|
|
12
|
+
function isAssistantWithTools(msg) {
|
|
13
|
+
return msg.role === "assistant" && Array.isArray(msg.tool_calls) && msg.tool_calls.length > 0;
|
|
14
|
+
}
|
|
15
|
+
function normalizeOaiMessage(message) {
|
|
16
|
+
if (message.role !== "assistant" || !Array.isArray(message.tool_calls) || message.tool_calls.length > 0) {
|
|
17
|
+
return message;
|
|
18
|
+
}
|
|
19
|
+
const { tool_calls: _, ...rest } = message;
|
|
20
|
+
return { ...rest, content: rest.content ?? "" };
|
|
21
|
+
}
|
|
22
|
+
function normalizeOaiMessages(messages) {
|
|
23
|
+
let normalized;
|
|
24
|
+
for (let i = 0; i < messages.length; i++) {
|
|
25
|
+
const message = normalizeOaiMessage(messages[i]);
|
|
26
|
+
if (message !== messages[i]) {
|
|
27
|
+
normalized ??= messages.slice();
|
|
28
|
+
normalized[i] = message;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return normalized ?? messages;
|
|
32
|
+
}
|
|
33
|
+
var STRIPPED_IMAGE_PLACEHOLDER = "[image removed to reduce payload size]";
|
|
34
|
+
function oaiMessagesHaveImageParts(messages) {
|
|
35
|
+
return messages.some(
|
|
36
|
+
(m) => m.role === "user" && Array.isArray(m.content) && m.content.some((p) => p.type === "image_url")
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function stripOaiImageParts(messages, placeholder = STRIPPED_IMAGE_PLACEHOLDER) {
|
|
40
|
+
let removedCount = 0;
|
|
41
|
+
let next;
|
|
42
|
+
for (let i = 0; i < messages.length; i++) {
|
|
43
|
+
const msg = messages[i];
|
|
44
|
+
if (msg.role !== "user" || !Array.isArray(msg.content)) continue;
|
|
45
|
+
const imageCount = msg.content.reduce(
|
|
46
|
+
(n, p) => p.type === "image_url" ? n + 1 : n,
|
|
47
|
+
0
|
|
48
|
+
);
|
|
49
|
+
if (imageCount === 0) continue;
|
|
50
|
+
removedCount += imageCount;
|
|
51
|
+
next ??= messages.slice();
|
|
52
|
+
const kept = msg.content.filter((p) => p.type !== "image_url");
|
|
53
|
+
const content = kept.length > 0 ? kept : [{ type: "text", text: placeholder }];
|
|
54
|
+
next[i] = { ...msg, content };
|
|
55
|
+
}
|
|
56
|
+
return { messages: next ?? messages, removedCount };
|
|
57
|
+
}
|
|
58
|
+
function oaiMessageText(msg) {
|
|
59
|
+
if (msg.role === "user" && Array.isArray(msg.content)) {
|
|
60
|
+
return msg.content.filter((p) => p.type === "text").map((p) => p.text).join("");
|
|
61
|
+
}
|
|
62
|
+
return msg.content;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
isToolMessage,
|
|
67
|
+
isAssistantWithTools,
|
|
68
|
+
normalizeOaiMessage,
|
|
69
|
+
normalizeOaiMessages,
|
|
70
|
+
oaiMessagesHaveImageParts,
|
|
71
|
+
stripOaiImageParts,
|
|
72
|
+
oaiMessageText
|
|
73
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
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
|
+
buildDeliveryGate,
|
|
5
|
+
emptyPhysarumShadowStats
|
|
6
|
+
} from "./chunk-OTNHSAGN.js";
|
|
7
|
+
import {
|
|
8
|
+
STAR_DOMAINS
|
|
9
|
+
} from "./chunk-WMUWEO2C.js";
|
|
10
|
+
import {
|
|
11
|
+
init_esm_shims
|
|
12
|
+
} from "./chunk-5GGOGLSN.js";
|
|
13
|
+
|
|
14
|
+
// src/tui/cockpit/state.ts
|
|
15
|
+
init_esm_shims();
|
|
16
|
+
function describeStarDomain(domain) {
|
|
17
|
+
if (domain) return domain.name;
|
|
18
|
+
if (domain === null) return "\u5173\u95ED(\u73AF\u5883)";
|
|
19
|
+
const fallback = STAR_DOMAINS.tianshu?.name ?? "\u5929\u67A2";
|
|
20
|
+
return `Auto(${fallback})`;
|
|
21
|
+
}
|
|
22
|
+
function computePanelStatuses(snapshot) {
|
|
23
|
+
const safety = snapshot.safety.riskLevel === "high" || snapshot.safety.doomLoopLevel === "blocked" ? "error" : snapshot.safety.riskLevel === "medium" || snapshot.safety.doomLoopLevel === "warn" ? "warn" : "ok";
|
|
24
|
+
const verify = snapshot.verification.deliveryStatus === "failed" || snapshot.verification.deliveryStatus === "blocked" ? "error" : snapshot.verification.deliveryStatus === "unverified" && snapshot.verification.filesModified > 0 ? "warn" : "ok";
|
|
25
|
+
const context = snapshot.context ? snapshot.context.brokenRounds > 0 ? "error" : snapshot.context.compactionState === "critical" ? "error" : snapshot.context.compactionState === "warning" ? "warn" : "ok" : "idle";
|
|
26
|
+
const model = "ok";
|
|
27
|
+
const trace = snapshot.trace.events.some((e) => e.status === "failed") ? "error" : "ok";
|
|
28
|
+
const summary = safety === "error" || verify === "error" ? "error" : safety === "warn" || verify === "warn" ? "warn" : "ok";
|
|
29
|
+
const mcp = snapshot.mcp.servers.some((s) => s.status === "error") ? "error" : snapshot.mcp.servers.some((s) => s.status === "connecting") ? "warn" : "ok";
|
|
30
|
+
const advisory = snapshot.advisory.silenced.length > 0 ? "warn" : "ok";
|
|
31
|
+
return { summary, trace, verify, context, safety, model, mcp, advisory };
|
|
32
|
+
}
|
|
33
|
+
var ADVISORY_PANEL_MAX_KEYS = 8;
|
|
34
|
+
function buildAdvisorySection(agent, statusNotices) {
|
|
35
|
+
const ga = agent.guardianActivity;
|
|
36
|
+
const readback = agent.advisoryReadback;
|
|
37
|
+
const bus = agent.advisoryBus;
|
|
38
|
+
const keys = readback ? [...readback.getStats()].filter(([, s]) => s.delivered > 0 || s.shadowHeld > 0).sort((a, b) => b[1].delivered - a[1].delivered).slice(0, ADVISORY_PANEL_MAX_KEYS).map(([key, s]) => ({
|
|
39
|
+
key,
|
|
40
|
+
delivered: s.delivered,
|
|
41
|
+
adopted: s.adopted,
|
|
42
|
+
ignored: s.ignored,
|
|
43
|
+
ignoredStreak: s.ignoredStreak,
|
|
44
|
+
adoptionRate: readback.getAdoptionRate(key),
|
|
45
|
+
lift: readback.getMatureLift(key)
|
|
46
|
+
})) : [];
|
|
47
|
+
return {
|
|
48
|
+
rendered: ga?.advisoriesRendered ?? 0,
|
|
49
|
+
dropped: ga?.advisoriesDropped ?? 0,
|
|
50
|
+
adopted: ga?.advisoriesAdopted ?? 0,
|
|
51
|
+
ignored: ga?.advisoriesIgnored ?? 0,
|
|
52
|
+
heldOut: ga?.advisoriesHeldOut ?? 0,
|
|
53
|
+
silenced: bus?.getSilencedKeys() ?? [],
|
|
54
|
+
pendingWatch: bus?.getPendingWatchCount() ?? 0,
|
|
55
|
+
keys,
|
|
56
|
+
statusNotices
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function buildCockpitSnapshot(sources) {
|
|
60
|
+
const { agent, session, claimCounts, reasoningEffort } = sources;
|
|
61
|
+
const model = sources.model ?? "unknown";
|
|
62
|
+
const cacheHitRate = sources.cacheHitRate ?? session.getCacheHitRate();
|
|
63
|
+
const cost = sources.cost ?? 0;
|
|
64
|
+
const mcpManager = sources.mcpManager ?? null;
|
|
65
|
+
const agentWithCache = agent;
|
|
66
|
+
const prewarmStats = agentWithCache.getPrewarmStats?.() ?? { hits: 0, misses: 0, hitRate: 0 };
|
|
67
|
+
const physarumShadowStats = agentWithCache.getPhysarumShadowStats?.() ?? emptyPhysarumShadowStats();
|
|
68
|
+
const cacheDiagnostic = agentWithCache.getCacheDiagnostic?.() ?? null;
|
|
69
|
+
const speculationStats = agent.p3?.queue.statsBySource() ?? null;
|
|
70
|
+
const traceStore = agent.getTraceStore();
|
|
71
|
+
const evidence = agent.getEvidenceState();
|
|
72
|
+
const doomLevel = agent.getDoomLoopLevel();
|
|
73
|
+
const usage = session.getTotalUsage();
|
|
74
|
+
const risk = agent.getLatestRisk();
|
|
75
|
+
const contextReport = agent.getContextLayerReport();
|
|
76
|
+
const mcpStates = mcpManager?.getStates() ?? [];
|
|
77
|
+
const deliveryGate = buildDeliveryGate(evidence);
|
|
78
|
+
const snapshot = {
|
|
79
|
+
intent: null,
|
|
80
|
+
blockingReason: deliveryGate.blockingReason ?? null,
|
|
81
|
+
nextAction: deliveryGate.nextAction ?? null,
|
|
82
|
+
safety: {
|
|
83
|
+
doomLoopLevel: doomLevel,
|
|
84
|
+
riskLevel: risk.level,
|
|
85
|
+
riskReasons: risk.reasons,
|
|
86
|
+
suggestedAction: risk.suggestedAction,
|
|
87
|
+
recentFingerprints: new Set(traceStore.toolFingerprints).size
|
|
88
|
+
},
|
|
89
|
+
verification: {
|
|
90
|
+
filesRead: evidence.filesRead.size,
|
|
91
|
+
filesModified: evidence.filesModified.size,
|
|
92
|
+
runs: evidence.verifications.map((v) => ({
|
|
93
|
+
tool: v.command,
|
|
94
|
+
status: v.status,
|
|
95
|
+
summary: `${v.passed}\u2713 ${v.failed}\u2717 ${v.skipped}skip`
|
|
96
|
+
})),
|
|
97
|
+
deliveryStatus: evidence.deliveryStatus,
|
|
98
|
+
impactedFiles: evidence.impactedFiles.size,
|
|
99
|
+
impactedTests: evidence.impactedTests.size
|
|
100
|
+
},
|
|
101
|
+
trace: {
|
|
102
|
+
events: traceStore.events.map((e) => ({
|
|
103
|
+
id: e.id,
|
|
104
|
+
turn: e.turn,
|
|
105
|
+
kind: e.kind,
|
|
106
|
+
name: e.name,
|
|
107
|
+
status: e.status,
|
|
108
|
+
durationMs: e.durationMs,
|
|
109
|
+
summary: e.summary
|
|
110
|
+
})),
|
|
111
|
+
totalEvents: traceStore.events.length
|
|
112
|
+
},
|
|
113
|
+
context: session.getContextLedger() ? {
|
|
114
|
+
estimatedTokens: session.getContextLedger().tokenBudget.estimatedTokens,
|
|
115
|
+
maxTokens: session.getContextLedger().tokenBudget.maxTokens,
|
|
116
|
+
rounds: session.getContextLedger().rounds.length,
|
|
117
|
+
compactionState: session.getContextLedger().tokenBudget.compactionState,
|
|
118
|
+
brokenRounds: session.getContextLedger().apiInvariantStatus.brokenRounds,
|
|
119
|
+
layers: contextReport.layers.map((l) => ({
|
|
120
|
+
id: l.id,
|
|
121
|
+
label: l.label,
|
|
122
|
+
stability: l.stability,
|
|
123
|
+
channel: l.channel,
|
|
124
|
+
fingerprint: l.fingerprint,
|
|
125
|
+
digest: l.digest,
|
|
126
|
+
tokenEstimate: l.tokenEstimate
|
|
127
|
+
})),
|
|
128
|
+
claimCounts: claimCounts ?? { active: 0, stale: 0, conflicted: 0, durable: 0, durableCandidate: 0, quarantined: 0, recallBlocked: 0 }
|
|
129
|
+
} : null,
|
|
130
|
+
model: {
|
|
131
|
+
name: model,
|
|
132
|
+
cacheHitRate,
|
|
133
|
+
inputTokens: usage.input_tokens,
|
|
134
|
+
outputTokens: usage.output_tokens,
|
|
135
|
+
cacheReadTokens: usage.cache_read_input_tokens,
|
|
136
|
+
cacheWriteTokens: usage.cache_creation_input_tokens,
|
|
137
|
+
cost,
|
|
138
|
+
perTurnHitRate: session.getLatestTurnHitRate(),
|
|
139
|
+
recentTurnHitRate: session.getRecentTurnHitRate(3),
|
|
140
|
+
prewarmHits: prewarmStats.hits,
|
|
141
|
+
prewarmMisses: prewarmStats.misses,
|
|
142
|
+
prewarmHitRate: prewarmStats.hitRate,
|
|
143
|
+
physarumShadow: physarumShadowStats,
|
|
144
|
+
speculation: speculationStats,
|
|
145
|
+
cacheDiagnostic,
|
|
146
|
+
reasoningEffort: agent.getReasoningEffort() || reasoningEffort || "medium",
|
|
147
|
+
starDomain: describeStarDomain(agent.getSessionDomain())
|
|
148
|
+
},
|
|
149
|
+
mcp: {
|
|
150
|
+
servers: mcpStates.map((s) => ({
|
|
151
|
+
serverId: s.serverId,
|
|
152
|
+
status: s.status,
|
|
153
|
+
toolCount: s.toolCount,
|
|
154
|
+
lastErrorClass: s.lastErrorClass
|
|
155
|
+
})),
|
|
156
|
+
totalTools: mcpManager?.getAllTools().length ?? 0,
|
|
157
|
+
connectedServers: mcpStates.filter((s) => s.status === "connected").length
|
|
158
|
+
},
|
|
159
|
+
advisory: buildAdvisorySection(agent, sources.advisoryStatusNotices ?? [])
|
|
160
|
+
};
|
|
161
|
+
return {
|
|
162
|
+
...snapshot,
|
|
163
|
+
panelStatuses: computePanelStatuses(snapshot)
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export {
|
|
168
|
+
buildCockpitSnapshot
|
|
169
|
+
};
|