@tekmidian/pai 1.0.2 → 1.0.4
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/.claude-plugin/plugin.json +1 -1
- package/dist/{auto-route-B4azPk4l.mjs → auto-route-21GdHL70.mjs} +2 -2
- package/dist/auto-route-C3S2W3Bc.mjs +11 -0
- package/dist/{budget-Dod6rnA9.mjs → budget-BrloTOZW.mjs} +1 -1
- package/dist/{chain-D-yvET_y.mjs → chain-D7PFur8Y.mjs} +2 -2
- package/dist/cli/index.mjs +82 -198
- package/dist/{cockpit-actions-BWunx3rY.mjs → cockpit-actions-BfRMr2sm.mjs} +6 -6
- package/dist/{cockpit-actions-C8GlTzts.mjs → cockpit-actions-OodH_vx_.mjs} +20 -18
- package/dist/{cockpit-memory-vTlFWV7F.mjs → cockpit-memory-teG9M8bG.mjs} +6 -6
- package/dist/config/defaults/config.yaml +6 -0
- package/dist/{controls-BcKFHeG1.mjs → controls-JLm6g0yP.mjs} +7 -5
- package/dist/daemon/index.mjs +23 -23
- package/dist/daemon-DeYImF1F.mjs +45 -0
- package/dist/daemon-mcp/index.mjs +21 -21
- package/dist/{daemon-ColVHwGZ.mjs → daemon-nXanenDM.mjs} +23 -19
- package/dist/{detect-9CZNO0yf.mjs → detect-BLKsUOgG.mjs} +2 -2
- package/dist/{detect-D1ziFFfA.mjs → detect-Rrimh0xc.mjs} +3 -3
- package/dist/{embed-pass-DIWjA68P.mjs → embed-pass-e64AwDCa.mjs} +1 -1
- package/dist/{endreason-C577xIQz.mjs → endreason-BC-v05H_.mjs} +17 -3
- package/dist/{factory-DjAAsqr_.mjs → factory-B7nv75rC.mjs} +2 -2
- package/dist/{factory-Bsib-qDG.mjs → factory-Bs9imVMq.mjs} +2 -2
- package/dist/{fallback-DFlItw1Z.mjs → fallback-CBWpp2F2.mjs} +227 -5
- package/dist/{health-Dnym-qcT.mjs → health-C4FQmkJn.mjs} +2 -2
- package/dist/{helpers-BD6V-p9w.mjs → helpers-DSNK_1KP.mjs} +2 -2
- package/dist/{helpers-CMGjy_0N.mjs → helpers-Dz7mjTSw.mjs} +3 -3
- package/dist/hooks/capture-all-events.mjs +21 -2
- package/dist/hooks/capture-tool-output.mjs +21 -2
- package/dist/hooks/worker-pool-host.mjs +167 -124
- package/dist/hooks/worker-status-line.mjs +34 -6
- package/dist/index.mjs +4 -4
- package/dist/{indexer-backend-_a6UNhXJ.mjs → indexer-backend-BdjeL4P8.mjs} +32 -229
- package/dist/{ipc-client-CaiGJnSM.mjs → ipc-client-CnYEF31R.mjs} +1 -1
- package/dist/{ipc-client-ZRmDKd5Z.mjs → ipc-client-DN7EvoVo.mjs} +1 -1
- package/dist/{kill-tree-EWYaEk5v.mjs → kill-tree-DleMNZX3.mjs} +2 -2
- package/dist/{kill-tree-BG7dRVtp.mjs → kill-tree-SV6hrIa3.mjs} +2 -2
- package/dist/{launch-Jh5NVeNe.mjs → launch-Di7N-J5X.mjs} +2 -2
- package/dist/{launch-CXVlZjHt.mjs → launch-DlZTKE3u.mjs} +2 -2
- package/dist/{main-config-ops-BEMpuhDz.mjs → main-config-ops-kTXR8Pyv.mjs} +1 -1
- package/dist/{main-resolver-3Ns1HPmS.mjs → main-resolver-yp_puSSb.mjs} +5 -5
- package/dist/{model-inventory-BFVSNFT3.mjs → model-inventory-h6Z9fN_o.mjs} +1 -1
- package/dist/{models-add-BtB3Se6f.mjs → models-add-TVni3A7V.mjs} +22 -22
- package/dist/{pai-marker-DurzIbw8.mjs → pai-marker-BcZyJguM.mjs} +2 -2
- package/dist/{pane-audit-BQytYa60.mjs → pane-audit-Lqy9N_Ki.mjs} +23 -5
- package/dist/{planner-BM27GBfC.mjs → planner-j77ndkBf.mjs} +14 -14
- package/dist/{pool-BRvoOkv6.mjs → pool-Dh-q3iJi.mjs} +43 -4
- package/dist/{pool-cli-B_YR8_Gl.mjs → pool-cli-BggU8GRp.mjs} +2 -2
- package/dist/{pool-cli-DkZTAlSW.mjs → pool-cli-DQ6OzRy2.mjs} +2 -2
- package/dist/{postgres-BdBNkL_l.mjs → postgres-BK4FP9Zg.mjs} +1 -1
- package/dist/{postgres-C6ti4haA.mjs → postgres-DNIOQijl.mjs} +17 -7
- package/dist/{project-setup-CfpApz5o.mjs → project-setup-CBRtFFh0.mjs} +16 -236
- package/dist/{providers-CblTFrhz.mjs → providers-C9QC0TtO.mjs} +2 -2
- package/dist/{providers-BeDiVEb-.mjs → providers-FvCLzFge.mjs} +2 -2
- package/dist/{query-feedback-BRfPtqki.mjs → query-feedback-DN52N9C5.mjs} +1 -1
- package/dist/{registrable-C7b6givx.mjs → registrable-BzH4TObg.mjs} +3 -3
- package/dist/{registrable-Uzgmfyhz.mjs → registrable-DpyTtajg.mjs} +2 -2
- package/dist/{render-Cc2j5QG9.mjs → render-B35bQTE-.mjs} +4 -4
- package/dist/{render-CwIrgxLi.mjs → render-C84BqQRC.mjs} +3 -3
- package/dist/{root-BWy0c2Lq.mjs → root-C4oXlXS_.mjs} +7 -7
- package/dist/{root-wC_6Fx0B.mjs → root-DD1xx_Vu.mjs} +16 -16
- package/dist/route-table-FEfDuhIV.mjs +15 -0
- package/dist/{routing-BAAST9vT.mjs → routing-DmkheCRH.mjs} +126 -8
- package/dist/{routing-CENt4HH1.mjs → routing-f2zulGwD.mjs} +1 -1
- package/dist/{run-6Q9kCPem.mjs → run-BwZKBJZZ.mjs} +28 -14
- package/dist/{scan-ZQWm-_se.mjs → scan-BBGvU5EB.mjs} +4 -4
- package/dist/{session-Bok2PqRS.mjs → session-BAhtXdxj.mjs} +15 -15
- package/dist/{session-DVUExUnX.mjs → session-Dn5OJXlg.mjs} +23 -23
- package/dist/{session-scan-BJI_ZO8M.mjs → session-scan-B57dNuA4.mjs} +1 -1
- package/dist/{session-scan-W-gbwJHM.mjs → session-scan-DUn10MBd.mjs} +2 -2
- package/dist/session-usage-CPvXvSkw.mjs +222 -0
- package/dist/{sources-ESUkZaWv.mjs → sources-CiE3rZek.mjs} +1 -1
- package/dist/{viewer-MWBVJP3u.mjs → viewer-DEySE4c_.mjs} +8 -8
- package/dist/{viewer-DcpJwGKE.mjs → viewer-wfKnvnrI.mjs} +6 -6
- package/dist/{worker-config-gmAq_-rI.mjs → worker-config-CO5FXLAT.mjs} +21 -21
- package/dist/{worker-config-BDYNxbYz.mjs → worker-config-eY5Qy4vl.mjs} +322 -25
- package/dist/{worktree-CrnOqTBW.mjs → worktree-CRs2gyg0.mjs} +2 -2
- package/dist/{zettelkasten-BzMm8REH.mjs → zettelkasten-_h_tUm2T.mjs} +1 -1
- package/dist/{zettelkasten-B_rRRRvD.mjs → zettelkasten-tpCRBYvH.mjs} +2 -2
- package/docs/cockpit.md +1 -0
- package/docs/images/architecture.png +0 -0
- package/gemini-extension.json +1 -1
- package/package.json +1 -1
- package/pai-plugin.json +1 -1
- package/plugins/context-preservation/plugin.json +1 -1
- package/plugins/core/plugin.json +1 -1
- package/plugins/creative/plugin.json +1 -1
- package/plugins/observability/plugin.json +1 -1
- package/plugins/productivity/plugin.json +1 -1
- package/plugins/semantic-search/plugin.json +1 -1
- package/plugins/ui/plugin.json +1 -1
- package/plugins/zettelkasten/plugin.json +1 -1
- package/src/hooks/ts/capture-all-events.ts +15 -3
- package/src/hooks/ts/lib/raw-capture.ts +7 -0
- package/src/hooks/ts/post-tool-use/capture-tool-output.ts +13 -3
- package/dist/auto-route-BjoMHKyI.mjs +0 -11
- package/dist/daemon-N7WhYi6I.mjs +0 -45
- package/dist/route-table-B7zpoypi.mjs +0 -15
|
@@ -3,8 +3,9 @@ import { wt as appendLedger } from "./config-XpZWOYOG.mjs";
|
|
|
3
3
|
import { i as ledgerPath } from "./paths-CHifubDh.mjs";
|
|
4
4
|
import { C as nowStamp, M as spawnTimeOf, T as ownsPidCached, b as loadStatusesCached, g as isLive, h as isChatPane, v as loadStatus, w as ownsPid } from "./status-ggJ7lgVg.mjs";
|
|
5
5
|
import { i as itermUuid } from "./scope-D-h6F6DN.mjs";
|
|
6
|
-
import { At as recordPath, Ct as PANE_EXEC_PID_ENV, Dt as pidAlive, L as fmtElapsed, Mt as panePolicy, Ot as readExit, St as PANE_EXEC_ENV, Tt as listRecords, V as loadPlanStatuses, _t as paneTitle, dt as osascript, kt as readRecord, mt as realPaneOps, nt as closePaneForWorker, st as loadRegistry, tt as closeOwnPane, vt as writePaneTitle, wt as exitFilePath } from "./controls-
|
|
7
|
-
import {
|
|
6
|
+
import { At as recordPath, Ct as PANE_EXEC_PID_ENV, Dt as pidAlive, L as fmtElapsed, Mt as panePolicy, Ot as readExit, St as PANE_EXEC_ENV, Tt as listRecords, V as loadPlanStatuses, _t as paneTitle, dt as osascript, kt as readRecord, mt as realPaneOps, nt as closePaneForWorker, st as loadRegistry, tt as closeOwnPane, vt as writePaneTitle, wt as exitFilePath } from "./controls-JLm6g0yP.mjs";
|
|
7
|
+
import { s as requestKill, t as appendStopEvent } from "./endreason-BC-v05H_.mjs";
|
|
8
|
+
import { i as killTree } from "./kill-tree-DleMNZX3.mjs";
|
|
8
9
|
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
9
10
|
import { join } from "node:path";
|
|
10
11
|
import { execFileSync, spawn } from "node:child_process";
|
|
@@ -532,7 +533,17 @@ async function stopUnpaned(logDir, id, why, stop, now) {
|
|
|
532
533
|
reason
|
|
533
534
|
})))(id, why).catch(() => void 0);
|
|
534
535
|
}
|
|
535
|
-
|
|
536
|
+
const LAUNCH_PID_SLACK_MS = 12e4;
|
|
537
|
+
/**
|
|
538
|
+
* Whether a process started at `startMs` fits the launch. The wrapper starts when the pane opens (`openedMs`), the child when
|
|
539
|
+
* the command starts (`startedMs`); a run that queued for a provider slot between the two has them minutes apart, so each side
|
|
540
|
+
* is measured against its own stamp.
|
|
541
|
+
*/
|
|
542
|
+
function launchPidFresh(startMs, r, side) {
|
|
543
|
+
const at = side === "wrapper" ? r.openedMs ?? r.startedMs : r.startedMs;
|
|
544
|
+
return Math.abs(startMs - at) <= LAUNCH_PID_SLACK_MS;
|
|
545
|
+
}
|
|
546
|
+
/** A pid is the launch's own only when it started within two minutes of its side's launch and, for the wrapper, runs `pane exec <id>`. */
|
|
536
547
|
function ownsLaunchPid(pid, r, side) {
|
|
537
548
|
try {
|
|
538
549
|
const env = {
|
|
@@ -548,7 +559,7 @@ function ownsLaunchPid(pid, r, side) {
|
|
|
548
559
|
encoding: "utf8",
|
|
549
560
|
env
|
|
550
561
|
}).trim());
|
|
551
|
-
if (Number.isNaN(start) ||
|
|
562
|
+
if (Number.isNaN(start) || !launchPidFresh(start, r, side)) return false;
|
|
552
563
|
if (side === "wrapper") return execFileSync("ps", [
|
|
553
564
|
"-o",
|
|
554
565
|
"command=",
|
|
@@ -617,6 +628,13 @@ async function auditLaunches(logDir, d = {}, now = /* @__PURE__ */ new Date()) {
|
|
|
617
628
|
action: "wrapper killed, pane closed"
|
|
618
629
|
});
|
|
619
630
|
} else if (!ex && r.wrapper && !wrapperUp && childUp) {
|
|
631
|
+
const why = "pane audit: wrapper (the pane) is gone, child killed";
|
|
632
|
+
requestKill(logDir, ledger, r.id, "pane audit", true, why);
|
|
633
|
+
appendStopEvent(logDir, r.id, {
|
|
634
|
+
killed_by: "pane audit",
|
|
635
|
+
forced: true,
|
|
636
|
+
reason: why
|
|
637
|
+
});
|
|
620
638
|
kill(r.child, "SIGKILL", true);
|
|
621
639
|
appendLedger(ledger, "PANE-ORPHAN", {
|
|
622
640
|
id: r.id,
|
|
@@ -743,4 +761,4 @@ function renderPaneAudit(verdicts) {
|
|
|
743
761
|
|
|
744
762
|
//#endregion
|
|
745
763
|
export { readAudit as a, followPaneRun as c, loadPaneRunStatuses as d, paneRunRows as f, listItermTabs as i, isPaneRunId as l, runInPane as m, auditTick as n, renderPaneAudit as o, renderPaneRunLines as p, closeFinishedPanes as r, runningProcs as s, auditPanes as t, loadPaneRunStatus as u };
|
|
746
|
-
//# sourceMappingURL=pane-audit-
|
|
764
|
+
//# sourceMappingURL=pane-audit-Lqy9N_Ki.mjs.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { j as readWorkersSection, wt as appendLedger } from "./config-XpZWOYOG.mjs";
|
|
2
2
|
import "./config-Bu1_vbY8.mjs";
|
|
3
3
|
import { i as ledgerPath, u as workersLogDir } from "./paths-CHifubDh.mjs";
|
|
4
|
-
import { g as mergeWorker, n as MergeConflictError } from "./worktree-
|
|
4
|
+
import { g as mergeWorker, n as MergeConflictError } from "./worktree-CRs2gyg0.mjs";
|
|
5
5
|
import { S as newWorkerId, nt as shortText, tt as parseRunnerArgs, v as loadStatus } from "./status-ggJ7lgVg.mjs";
|
|
6
|
-
import "./pool-
|
|
6
|
+
import "./pool-Dh-q3iJi.mjs";
|
|
7
7
|
import "./helpers-CRuBUas3.mjs";
|
|
8
8
|
import "./scope-D-h6F6DN.mjs";
|
|
9
|
-
import "./routing-
|
|
9
|
+
import "./routing-DmkheCRH.mjs";
|
|
10
10
|
import "./tool-errors-7E13StWd.mjs";
|
|
11
11
|
import "./wait-ByV0OyMZ.mjs";
|
|
12
12
|
import "./local-tiers-BE4jGaMa.mjs";
|
|
@@ -14,20 +14,20 @@ import "./caller-identity-yLFb7CKq.mjs";
|
|
|
14
14
|
import "./capacity-DEveQdFV.mjs";
|
|
15
15
|
import "./local-instances-DOxSgT_L.mjs";
|
|
16
16
|
import "./local-candidate-DLdwQt0s.mjs";
|
|
17
|
-
import "./factory-
|
|
18
|
-
import "./postgres-
|
|
17
|
+
import "./factory-B7nv75rC.mjs";
|
|
18
|
+
import "./postgres-DNIOQijl.mjs";
|
|
19
19
|
import "./embedding-gate-6rZrWRXa.mjs";
|
|
20
20
|
import "./embeddings-BVq3esBF.mjs";
|
|
21
21
|
import "./router-CQSc3lk3.mjs";
|
|
22
|
-
import "./launch-
|
|
23
|
-
import { V as printResult, t as runWorker } from "./run-
|
|
24
|
-
import "./controls-
|
|
25
|
-
import "./endreason-
|
|
26
|
-
import "./render-
|
|
22
|
+
import "./launch-Di7N-J5X.mjs";
|
|
23
|
+
import { V as printResult, t as runWorker } from "./run-BwZKBJZZ.mjs";
|
|
24
|
+
import "./controls-JLm6g0yP.mjs";
|
|
25
|
+
import "./endreason-BC-v05H_.mjs";
|
|
26
|
+
import "./render-C84BqQRC.mjs";
|
|
27
27
|
import "./operator-CyuB3aVw.mjs";
|
|
28
|
-
import "./kill-tree-
|
|
29
|
-
import "./pool-cli-
|
|
30
|
-
import { n as swapPromptArg } from "./chain-
|
|
28
|
+
import "./kill-tree-DleMNZX3.mjs";
|
|
29
|
+
import "./pool-cli-BggU8GRp.mjs";
|
|
30
|
+
import { n as swapPromptArg } from "./chain-D7PFur8Y.mjs";
|
|
31
31
|
import { existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
32
32
|
import { join } from "node:path";
|
|
33
33
|
|
|
@@ -307,4 +307,4 @@ function printPlannerSummary(logDir, plannerId, results, merged, conflicted, fmt
|
|
|
307
307
|
|
|
308
308
|
//#endregion
|
|
309
309
|
export { runPlanner };
|
|
310
|
-
//# sourceMappingURL=planner-
|
|
310
|
+
//# sourceMappingURL=planner-j77ndkBf.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Et as parseLedger, I as LOOPBACK_HOST, c as WorkersConfigError, d as defaultWorkersConfig, i as DEFAULT_POOL_PORT, t as ANTHROPIC_NATIVE } from "./config-XpZWOYOG.mjs";
|
|
2
2
|
import { t as assertTestWriteAllowed } from "./test-isolation-lqSmYxr0.mjs";
|
|
3
|
-
import { appendFileSync, copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
3
|
+
import { appendFileSync, copyFileSync, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
5
|
import { homedir } from "node:os";
|
|
6
6
|
import { request } from "node:http";
|
|
7
7
|
|
|
@@ -105,6 +105,45 @@ function trustProjectPath(absPath) {
|
|
|
105
105
|
});
|
|
106
106
|
return true;
|
|
107
107
|
}
|
|
108
|
+
/** Canonical form of a script path: realpath when it exists, else the resolved text. */
|
|
109
|
+
function canonicalScript(p) {
|
|
110
|
+
try {
|
|
111
|
+
return realpathSync(p);
|
|
112
|
+
} catch {
|
|
113
|
+
return resolve(p);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/** True when an mcpServers entry runs `script`, comparing by realpath (symlinked repo paths match). */
|
|
117
|
+
function mcpEntryRunsScript(entry, script) {
|
|
118
|
+
const args = entry?.args;
|
|
119
|
+
if (!Array.isArray(args)) return false;
|
|
120
|
+
const want = canonicalScript(script);
|
|
121
|
+
return args.some((a) => typeof a === "string" && canonicalScript(a) === want);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Point `servers[name]` at `script`. An existing entry running the same file
|
|
125
|
+
* (by realpath) is updated in place; a genuinely different one is kept as
|
|
126
|
+
* `<name>-legacy`.
|
|
127
|
+
*/
|
|
128
|
+
function registerMcpScript(servers, name, script) {
|
|
129
|
+
const existing = servers[name];
|
|
130
|
+
const entry = {
|
|
131
|
+
command: "node",
|
|
132
|
+
args: [script]
|
|
133
|
+
};
|
|
134
|
+
if (!existing) {
|
|
135
|
+
servers[name] = entry;
|
|
136
|
+
return "added";
|
|
137
|
+
}
|
|
138
|
+
if (mcpEntryRunsScript(existing, script)) {
|
|
139
|
+
const same = JSON.stringify(existing) === JSON.stringify(entry);
|
|
140
|
+
servers[name] = entry;
|
|
141
|
+
return same ? "unchanged" : "updated";
|
|
142
|
+
}
|
|
143
|
+
servers[`${name}-legacy`] = existing;
|
|
144
|
+
servers[name] = entry;
|
|
145
|
+
return "legacy-kept";
|
|
146
|
+
}
|
|
108
147
|
|
|
109
148
|
//#endregion
|
|
110
149
|
//#region src/workers/mcp.ts
|
|
@@ -589,5 +628,5 @@ function spareStats(ledgerText) {
|
|
|
589
628
|
}
|
|
590
629
|
|
|
591
630
|
//#endregion
|
|
592
|
-
export {
|
|
593
|
-
//# sourceMappingURL=pool-
|
|
631
|
+
export { readClaudeJson as A, describeMcp as C, readMcpServers as D, mcpServersFromToolGrants as E, trustProjectPath as M, writeClaudeJson as N, writeMcpConfig as O, inputSideTokens as S, grantsChrome as T, readPoolMetrics as _, formatCarryByProvider as a, spareStats as b, poolHostAlive as c, poolIneligibleReason as d, poolMetricsPath as f, postTaskToPool as g, poolSettings as h, bundleBuildStamp as i, registerMcpScript as j, mcpEntryRunsScript as k, poolHostProbe as l, poolPort as m, SLOT_TOOLS as n, poolCarry as o, poolPidPath as p, UNIT_MARKER as r, poolDir as s, SHARED_MARKER as t, poolHostStale as u, readPoolState as v, expandMcpNames as w, warmOrCold as x, reloadInProgress as y };
|
|
632
|
+
//# sourceMappingURL=pool-Dh-q3iJi.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Et as parseLedger, F as writeWorkersSection, I as LOOPBACK_HOST, j as readWorkersSection, wt as appendLedger } from "./config-XpZWOYOG.mjs";
|
|
2
2
|
import { i as ledgerPath } from "./paths-CHifubDh.mjs";
|
|
3
3
|
import { m as fmtTokens } from "./status-ggJ7lgVg.mjs";
|
|
4
|
-
import { _ as readPoolMetrics, a as formatCarryByProvider, b as spareStats, c as poolHostAlive, f as poolMetricsPath, h as poolSettings, i as bundleBuildStamp, l as poolHostProbe, m as poolPort, o as poolCarry, p as poolPidPath, s as poolDir, u as poolHostStale, v as readPoolState, y as reloadInProgress } from "./pool-
|
|
4
|
+
import { _ as readPoolMetrics, a as formatCarryByProvider, b as spareStats, c as poolHostAlive, f as poolMetricsPath, h as poolSettings, i as bundleBuildStamp, l as poolHostProbe, m as poolPort, o as poolCarry, p as poolPidPath, s as poolDir, u as poolHostStale, v as readPoolState, y as reloadInProgress } from "./pool-Dh-q3iJi.mjs";
|
|
5
5
|
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { dirname, join } from "node:path";
|
|
7
7
|
import { spawn } from "node:child_process";
|
|
@@ -313,4 +313,4 @@ function spareStatusLines(state, logDir) {
|
|
|
313
313
|
|
|
314
314
|
//#endregion
|
|
315
315
|
export { poolOff as a, poolStatusText as c, spareStatusLines as d, standalonePoolHostPath as f, hostBuildText as i, reloadPoolHost as l, diskBundleMtime as n, poolOn as o, ensurePoolHost as r, poolReloadLive as s, POOL_HEAL_GAP_MS as t, skipReasonLine as u };
|
|
316
|
-
//# sourceMappingURL=pool-cli-
|
|
316
|
+
//# sourceMappingURL=pool-cli-BggU8GRp.mjs.map
|
|
@@ -2,7 +2,7 @@ import "./config-XpZWOYOG.mjs";
|
|
|
2
2
|
import "./config-Bu1_vbY8.mjs";
|
|
3
3
|
import "./paths-CHifubDh.mjs";
|
|
4
4
|
import "./status-ggJ7lgVg.mjs";
|
|
5
|
-
import "./pool-
|
|
6
|
-
import { a as poolOff, c as poolStatusText, d as spareStatusLines, f as standalonePoolHostPath, i as hostBuildText, l as reloadPoolHost, n as diskBundleMtime, o as poolOn, r as ensurePoolHost, s as poolReloadLive, t as POOL_HEAL_GAP_MS, u as skipReasonLine } from "./pool-cli-
|
|
5
|
+
import "./pool-Dh-q3iJi.mjs";
|
|
6
|
+
import { a as poolOff, c as poolStatusText, d as spareStatusLines, f as standalonePoolHostPath, i as hostBuildText, l as reloadPoolHost, n as diskBundleMtime, o as poolOn, r as ensurePoolHost, s as poolReloadLive, t as POOL_HEAL_GAP_MS, u as skipReasonLine } from "./pool-cli-BggU8GRp.mjs";
|
|
7
7
|
|
|
8
8
|
export { poolOff, poolOn, poolStatusText };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./config-Bu1_vbY8.mjs";
|
|
2
2
|
import "./helpers-CRuBUas3.mjs";
|
|
3
|
-
import { o as buildPgTsQuery, t as PostgresBackend } from "./postgres-
|
|
3
|
+
import { o as buildPgTsQuery, t as PostgresBackend } from "./postgres-DNIOQijl.mjs";
|
|
4
4
|
import "./embedding-gate-6rZrWRXa.mjs";
|
|
5
5
|
import "./embeddings-BVq3esBF.mjs";
|
|
6
6
|
|
|
@@ -1257,6 +1257,8 @@ CREATE TABLE IF NOT EXISTS pai_observations (
|
|
|
1257
1257
|
files_modified JSONB DEFAULT '[]'::jsonb,
|
|
1258
1258
|
concepts JSONB DEFAULT '[]'::jsonb,
|
|
1259
1259
|
content_hash TEXT,
|
|
1260
|
+
source TEXT,
|
|
1261
|
+
fidelity TEXT,
|
|
1260
1262
|
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
1261
1263
|
);
|
|
1262
1264
|
|
|
@@ -1292,6 +1294,11 @@ let _tablesEnsured = false;
|
|
|
1292
1294
|
async function ensureObservationTables(pool) {
|
|
1293
1295
|
if (_tablesEnsured) return;
|
|
1294
1296
|
await pool.query(SCHEMA_SQL);
|
|
1297
|
+
const colCheck = await pool.query(`SELECT column_name FROM information_schema.columns
|
|
1298
|
+
WHERE table_name = 'pai_observations' AND column_name IN ('source', 'fidelity')`);
|
|
1299
|
+
const existing = new Set(colCheck.rows.map((r) => r.column_name));
|
|
1300
|
+
if (!existing.has("source")) await pool.query("ALTER TABLE pai_observations ADD COLUMN IF NOT EXISTS source TEXT");
|
|
1301
|
+
if (!existing.has("fidelity")) await pool.query("ALTER TABLE pai_observations ADD COLUMN IF NOT EXISTS fidelity TEXT");
|
|
1295
1302
|
_tablesEnsured = true;
|
|
1296
1303
|
}
|
|
1297
1304
|
const SKILL_TELEMETRY_SCHEMA_SQL = `
|
|
@@ -1341,8 +1348,9 @@ async function storeObservation(pool, obs) {
|
|
|
1341
1348
|
if (dupCheck.rowCount && dupCheck.rowCount > 0) return null;
|
|
1342
1349
|
return (await pool.query(`INSERT INTO pai_observations
|
|
1343
1350
|
(session_id, project_id, project_slug, type, title, narrative,
|
|
1344
|
-
tool_name, tool_input_summary, files_read, files_modified, concepts, content_hash
|
|
1345
|
-
|
|
1351
|
+
tool_name, tool_input_summary, files_read, files_modified, concepts, content_hash,
|
|
1352
|
+
source, fidelity)
|
|
1353
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9::jsonb, $10::jsonb, $11::jsonb, $12, $13, $14)
|
|
1346
1354
|
RETURNING id`, [
|
|
1347
1355
|
obs.session_id,
|
|
1348
1356
|
obs.project_id ?? null,
|
|
@@ -1355,7 +1363,9 @@ async function storeObservation(pool, obs) {
|
|
|
1355
1363
|
JSON.stringify(obs.files_read),
|
|
1356
1364
|
JSON.stringify(obs.files_modified),
|
|
1357
1365
|
JSON.stringify(obs.concepts),
|
|
1358
|
-
hash
|
|
1366
|
+
hash,
|
|
1367
|
+
obs.source ?? null,
|
|
1368
|
+
obs.fidelity ?? null
|
|
1359
1369
|
])).rows[0]?.id ?? null;
|
|
1360
1370
|
}
|
|
1361
1371
|
/**
|
|
@@ -1403,7 +1413,7 @@ async function queryObservations(pool, opts = {}) {
|
|
|
1403
1413
|
return (await pool.query(`SELECT id, session_id, project_id, project_slug, type, title, narrative,
|
|
1404
1414
|
tool_name, tool_input_summary,
|
|
1405
1415
|
files_read, files_modified, concepts,
|
|
1406
|
-
content_hash, created_at
|
|
1416
|
+
content_hash, source, fidelity, created_at
|
|
1407
1417
|
FROM pai_observations
|
|
1408
1418
|
${where}
|
|
1409
1419
|
ORDER BY created_at DESC
|
|
@@ -1414,7 +1424,7 @@ async function queryRecentObservations(pool, projectId, limit) {
|
|
|
1414
1424
|
return (await pool.query(`SELECT id, session_id, project_id, project_slug, type, title, narrative,
|
|
1415
1425
|
tool_name, tool_input_summary,
|
|
1416
1426
|
files_read, files_modified, concepts,
|
|
1417
|
-
content_hash, created_at
|
|
1427
|
+
content_hash, source, fidelity, created_at
|
|
1418
1428
|
FROM pai_observations
|
|
1419
1429
|
WHERE project_id = $1
|
|
1420
1430
|
ORDER BY created_at DESC
|
|
@@ -1425,7 +1435,7 @@ async function querySessionObservations(pool, sessionId) {
|
|
|
1425
1435
|
return (await pool.query(`SELECT id, session_id, project_id, project_slug, type, title, narrative,
|
|
1426
1436
|
tool_name, tool_input_summary,
|
|
1427
1437
|
files_read, files_modified, concepts,
|
|
1428
|
-
content_hash, created_at
|
|
1438
|
+
content_hash, source, fidelity, created_at
|
|
1429
1439
|
FROM pai_observations
|
|
1430
1440
|
WHERE session_id = $1
|
|
1431
1441
|
ORDER BY created_at ASC`, [sessionId])).rows;
|
|
@@ -2309,4 +2319,4 @@ function rowToKgEntity(row) {
|
|
|
2309
2319
|
|
|
2310
2320
|
//#endregion
|
|
2311
2321
|
export { entityContentId as a, resolveFromModule as c, retryTransient as i, embedChunksWithBackend as n, buildPgTsQuery as o, indexProjectWithBackend as r, packageRoot as s, PostgresBackend as t };
|
|
2312
|
-
//# sourceMappingURL=postgres-
|
|
2322
|
+
//# sourceMappingURL=postgres-DNIOQijl.mjs.map
|
|
@@ -2,31 +2,31 @@ import { c as ok, i as err, n as dim } from "./utils-J2b9y8PC.mjs";
|
|
|
2
2
|
import { g as paiHomePath, l as claudeHomeDir } from "./runtime-paths-WsO9sJFc.mjs";
|
|
3
3
|
import { X as readMergeVerify, c as WorkersConfigError, f as escalationCloud, h as isModelCapability, j as readWorkersSection, m as isLocalProvider, p as getProviderOrNative, t as ANTHROPIC_NATIVE } from "./config-XpZWOYOG.mjs";
|
|
4
4
|
import { i as ledgerPath, r as eventsPath, u as workersLogDir } from "./paths-CHifubDh.mjs";
|
|
5
|
-
import { D as formatPending, O as pendingGate, b as verifyWorker, c as formatKnowledge, d as gcWorktrees, g as mergeWorker, k as pendingResults, m as leftoverWorktrees, s as discardWorker, u as gcPoolWorktrees } from "./worktree-
|
|
5
|
+
import { D as formatPending, O as pendingGate, b as verifyWorker, c as formatKnowledge, d as gcWorktrees, g as mergeWorker, k as pendingResults, m as leftoverWorktrees, s as discardWorker, u as gcPoolWorktrees } from "./worktree-CRs2gyg0.mjs";
|
|
6
6
|
import { B as loadStatusConfig, C as nowStamp, F as ForgeError, H as setClaim, I as PROJECT_CONFIG_REL, K as PREAMBLE_MAX_BYTES, R as listClaims, V as parseStatusConfig, W as writeContinueToForge, Z as projectRoot, a as UNLABELED, et as longInlinePromptHint, g as isLive, j as setWorkerNote, k as saveStatus, o as ageOf, q as PREAMBLE_REL, s as alive, tt as parseRunnerArgs, v as loadStatus, w as ownsPid, y as loadStatuses, z as listStale } from "./status-ggJ7lgVg.mjs";
|
|
7
7
|
import { p as currentWorkerId } from "./scope-D-h6F6DN.mjs";
|
|
8
|
-
import { C as detectSessionProvider,
|
|
8
|
+
import { C as detectSessionProvider, Sn as probeLoopback, St as gcSettingsFiles, Tn as resolveRunnerProvider, gn as LOCAL_MECHANISM_LINE, ln as detectSessionName, pt as isLoopbackProvider, un as BATCH_ENV, wn as resolveLocalProvider } from "./routing-DmkheCRH.mjs";
|
|
9
9
|
import { C as statusMarker, S as realDeps, T as waitOn, a as runWait, w as statusQueue } from "./wait-ByV0OyMZ.mjs";
|
|
10
10
|
import { n as breakStaleMutex } from "./caller-identity-yLFb7CKq.mjs";
|
|
11
11
|
import { a as liveQueue, f as sessionOf, l as reorderQueue, o as providerCap, s as queueRows, t as admitCap } from "./capacity-DEveQdFV.mjs";
|
|
12
12
|
import { n as tierProviderNames, t as isLocalCandidate } from "./local-candidate-DLdwQt0s.mjs";
|
|
13
13
|
import { n as OPT, t as CliError } from "./define-CjJsmq-6.mjs";
|
|
14
|
-
import { c as resolveFromModule } from "./postgres-
|
|
15
|
-
import { C as workerUsage, S as usageJson, U as endProcesses, W as findWorktreeOrphans, _ as stopLaunchedWorkers, a as resolveWorkers, b as renderUsage, d as capture, h as realCommitsAhead, i as liveResolveCtx, m as mergeBranch, n as LocalProviderRefusedError, p as launchWorker, r as PoolRefusedError, t as runWorker, v as parseWhen } from "./run-
|
|
16
|
-
import { $ as checkPaneForWorker, A as tail, Gt as handoffFromInside, H as planLogTail, J as queueLockPath, Jt as LOCAL_FAILURE_LIMIT, N as filesOverlap, R as followPlanLog, W as planRunEnded, Xt as localFailures, Yt as classifyRoute, Z as withRunLock, Zt as routeLine, c as setMuted, ct as openFollowPane, et as closeEndedPanes, ft as paneBackend, gt as workerEnded, ht as resolveHostSession, lt as openPaneForWorker, pt as paneMayClose, st as loadRegistry
|
|
17
|
-
import { R as parentFromEnv } from "./render-
|
|
14
|
+
import { c as resolveFromModule } from "./postgres-DNIOQijl.mjs";
|
|
15
|
+
import { C as workerUsage, S as usageJson, U as endProcesses, W as findWorktreeOrphans, _ as stopLaunchedWorkers, a as resolveWorkers, b as renderUsage, d as capture, h as realCommitsAhead, i as liveResolveCtx, m as mergeBranch, n as LocalProviderRefusedError, p as launchWorker, r as PoolRefusedError, t as runWorker, v as parseWhen } from "./run-BwZKBJZZ.mjs";
|
|
16
|
+
import { $ as checkPaneForWorker, A as tail, Gt as handoffFromInside, H as planLogTail, J as queueLockPath, Jt as LOCAL_FAILURE_LIMIT, N as filesOverlap, R as followPlanLog, W as planRunEnded, Xt as localFailures, Yt as classifyRoute, Z as withRunLock, Zt as routeLine, c as setMuted, ct as openFollowPane, et as closeEndedPanes, ft as paneBackend, gt as workerEnded, ht as resolveHostSession, lt as openPaneForWorker, pt as paneMayClose, st as loadRegistry } from "./controls-JLm6g0yP.mjs";
|
|
17
|
+
import { R as parentFromEnv } from "./render-C84BqQRC.mjs";
|
|
18
18
|
import { r as sayToWorker } from "./operator-CyuB3aVw.mjs";
|
|
19
|
-
import { i as killTree } from "./kill-tree-
|
|
20
|
-
import { t as runChain } from "./chain-
|
|
21
|
-
import { c as followPaneRun, i as listItermTabs, l as isPaneRunId, o as renderPaneAudit, s as runningProcs, t as auditPanes, u as loadPaneRunStatus } from "./pane-audit-
|
|
22
|
-
import { a as followTailOutput, d as psOutput, f as replayOutput, m as statusLineOutput, o as followWorkers } from "./viewer-
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
19
|
+
import { i as killTree } from "./kill-tree-DleMNZX3.mjs";
|
|
20
|
+
import { t as runChain } from "./chain-D7PFur8Y.mjs";
|
|
21
|
+
import { c as followPaneRun, i as listItermTabs, l as isPaneRunId, o as renderPaneAudit, s as runningProcs, t as auditPanes, u as loadPaneRunStatus } from "./pane-audit-Lqy9N_Ki.mjs";
|
|
22
|
+
import { a as followTailOutput, d as psOutput, f as replayOutput, m as statusLineOutput, o as followWorkers } from "./viewer-wfKnvnrI.mjs";
|
|
23
|
+
import { a as DEFAULT_IDLE_SECS, o as commandToRun, s as runProbed } from "./fallback-CBWpp2F2.mjs";
|
|
24
|
+
import { _ as unsetCapabilityPreference, a as describeCapabilities, c as modelPrefsText, d as setCapabilityPreference, h as setProviderModel, o as describeModels, u as resolveProviderName } from "./providers-C9QC0TtO.mjs";
|
|
25
|
+
import { appendFileSync, copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, rmdirSync, statSync, writeFileSync } from "node:fs";
|
|
25
26
|
import { createHash, randomBytes } from "node:crypto";
|
|
26
|
-
import { basename, dirname,
|
|
27
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
27
28
|
import { tmpdir } from "node:os";
|
|
28
29
|
import { execFileSync, spawn } from "node:child_process";
|
|
29
|
-
import { fileURLToPath } from "node:url";
|
|
30
30
|
import { parse } from "yaml";
|
|
31
31
|
|
|
32
32
|
//#region src/workers/specfile.ts
|
|
@@ -467,226 +467,6 @@ function spawnPaiWorker(argv, cwd) {
|
|
|
467
467
|
});
|
|
468
468
|
}
|
|
469
469
|
|
|
470
|
-
//#endregion
|
|
471
|
-
//#region src/workers/hang-probe.ts
|
|
472
|
-
/**
|
|
473
|
-
* hang-probe.ts — `pai worker test-run -- <command>`: runs a test command and, when it goes silent,
|
|
474
|
-
* tells the model WHERE it is stuck.
|
|
475
|
-
*
|
|
476
|
-
* A synchronous infinite loop blocks Node's event loop, so the test runner cannot even report its own
|
|
477
|
-
* timeout and the model sees nothing. Node's `--report-on-signal` does not help: it is serviced by the
|
|
478
|
-
* event loop (measured: a `while(true){}` process never writes the report). The child therefore runs with a
|
|
479
|
-
* preloaded watchdog (NODE_OPTIONS --require): a worker thread per process that, when a trigger file appears,
|
|
480
|
-
* attaches the inspector to the main thread, pauses it (V8 interrupts a running loop) and writes the call
|
|
481
|
-
* frames. After the command was silent for the idle threshold the wrapper triggers every node process under
|
|
482
|
-
* it and maps the frames to the worktree's files. The worker guard rewrites test commands into this wrapper
|
|
483
|
-
* (see wrapTestCommand).
|
|
484
|
-
*/
|
|
485
|
-
/** Marker line every diagnosis carries; the loop guard keys on it. */
|
|
486
|
-
const HANG_MARKER = "[pai hang probe]";
|
|
487
|
-
const DEFAULT_IDLE_SECS = 60;
|
|
488
|
-
/** Seconds of the first `timeout N` in the command, else null. */
|
|
489
|
-
function timeoutSecs(command) {
|
|
490
|
-
const m = /\b(?:g?timeout)\s+(?:-[ks]\s+\S+\s+|-\S+\s+)*(\d+(?:\.\d+)?)([smhd]?)\b/.exec(command);
|
|
491
|
-
if (!m) return null;
|
|
492
|
-
return Number(m[1]) * {
|
|
493
|
-
"": 1,
|
|
494
|
-
s: 1,
|
|
495
|
-
m: 60,
|
|
496
|
-
h: 3600,
|
|
497
|
-
d: 86400
|
|
498
|
-
}[m[2]];
|
|
499
|
-
}
|
|
500
|
-
function killQuiet(pid, sig) {
|
|
501
|
-
try {
|
|
502
|
-
process.kill(pid, sig);
|
|
503
|
-
} catch {}
|
|
504
|
-
}
|
|
505
|
-
function rmQuiet(f) {
|
|
506
|
-
try {
|
|
507
|
-
unlinkSync(f);
|
|
508
|
-
} catch {}
|
|
509
|
-
}
|
|
510
|
-
const shq = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
|
|
511
|
-
/** The command line test-run executes: the decoded --cmd-b64 payload, else the words after `--`, each shell-quoted. */
|
|
512
|
-
function commandToRun(cmdB64, words) {
|
|
513
|
-
if (cmdB64) return Buffer.from(cmdB64, "base64").toString("utf8");
|
|
514
|
-
return words.map(shq).join(" ");
|
|
515
|
-
}
|
|
516
|
-
/** Call frames of one probed process, user code only, files relative to cwd. */
|
|
517
|
-
function userFrames(frames, cwd) {
|
|
518
|
-
const out = [];
|
|
519
|
-
for (const f of frames) {
|
|
520
|
-
let file = f.url;
|
|
521
|
-
if (file.startsWith("file://")) try {
|
|
522
|
-
file = fileURLToPath(file);
|
|
523
|
-
} catch {
|
|
524
|
-
continue;
|
|
525
|
-
}
|
|
526
|
-
if (!file || file.startsWith("node:") || file.includes("node_modules") || !isAbsolute(file)) continue;
|
|
527
|
-
const rel = relative(cwd, file);
|
|
528
|
-
if (rel.startsWith("..")) continue;
|
|
529
|
-
out.push({
|
|
530
|
-
fn: f.functionName || "(anonymous)",
|
|
531
|
-
file: rel,
|
|
532
|
-
line: f.lineNumber + 1
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
return out;
|
|
536
|
-
}
|
|
537
|
-
/** The model-facing diagnosis for the reports taken after `idleSecs` of silence. */
|
|
538
|
-
function diagnose(probed, cwd, idleSecs) {
|
|
539
|
-
const stuck = probed.map((r) => userFrames(r, cwd)).find((f) => f.length > 0);
|
|
540
|
-
if (stuck) {
|
|
541
|
-
const [top, ...rest] = stuck;
|
|
542
|
-
const via = rest[0] ? ` (called from ${rest[0].file}:${rest[0].line} ${rest[0].fn}())` : "";
|
|
543
|
-
return `${HANG_MARKER} test run hung with no output for ${idleSecs} s; the main thread is stuck in ${top.file}:${top.line} ${top.fn}()${via}. A synchronous loop that never ends blocks the runner's own timeout. Fix that loop; rerunning unchanged will hang again.\n` + stuck.slice(0, 6).map((f) => ` at ${f.fn} (${f.file}:${f.line})`).join("\n");
|
|
544
|
-
}
|
|
545
|
-
return `${HANG_MARKER} test run printed nothing for ${idleSecs} s and the main thread is idle in the event loop: it is waiting (async), not spinning. A test awaits a promise, timer, process or socket that never completes (vitest's own per-test timeout ends it unless the test raised it). Find the await and give it an end; rerunning unchanged will wait again.`;
|
|
546
|
-
}
|
|
547
|
-
function listProcs() {
|
|
548
|
-
try {
|
|
549
|
-
return psTable("pid=,ppid=,command=").split("\n").flatMap((l) => {
|
|
550
|
-
const m = /^\s*(\d+)\s+(\d+)\s+(.*)$/.exec(l);
|
|
551
|
-
return m ? [{
|
|
552
|
-
pid: Number(m[1]),
|
|
553
|
-
ppid: Number(m[2]),
|
|
554
|
-
cmd: m[3]
|
|
555
|
-
}] : [];
|
|
556
|
-
});
|
|
557
|
-
} catch {
|
|
558
|
-
return [];
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
/** Pids of node processes below `root`. */
|
|
562
|
-
function nodeDescendants(root, procs = listProcs()) {
|
|
563
|
-
const seen = new Set([root]);
|
|
564
|
-
for (let grew = true; grew;) {
|
|
565
|
-
grew = false;
|
|
566
|
-
for (const p of procs) if (!seen.has(p.pid) && seen.has(p.ppid)) seen.add(p.pid), grew = true;
|
|
567
|
-
}
|
|
568
|
-
return procs.filter((p) => p.pid !== root && seen.has(p.pid) && /(?:^|\/)node(?:\s|$)/.test(p.cmd)).map((p) => p.pid);
|
|
569
|
-
}
|
|
570
|
-
/** Runs the command, passes its output through, probes once when it goes silent. Resolves to the exit code. */
|
|
571
|
-
async function runProbed(o) {
|
|
572
|
-
const out = o.out ?? ((s) => process.stdout.write(s));
|
|
573
|
-
const err = o.err ?? ((s) => process.stderr.write(s));
|
|
574
|
-
mkdirSync(o.reportDir, { recursive: true });
|
|
575
|
-
const t = timeoutSecs(o.command);
|
|
576
|
-
const idle = Math.max(2, Math.min(o.idleSecs ?? DEFAULT_IDLE_SECS, t !== null ? t - 8 : Infinity));
|
|
577
|
-
const preload = join(o.reportDir, "preload.cjs");
|
|
578
|
-
writeFileSync(preload, PRELOAD_SOURCE);
|
|
579
|
-
const env = {
|
|
580
|
-
...process.env,
|
|
581
|
-
PAI_HANG_PROBE_DIR: o.reportDir,
|
|
582
|
-
NODE_OPTIONS: `${process.env.NODE_OPTIONS ?? ""} --require=${preload}`.trim()
|
|
583
|
-
};
|
|
584
|
-
const child = spawn("bash", ["-c", o.command], {
|
|
585
|
-
cwd: o.cwd,
|
|
586
|
-
env,
|
|
587
|
-
stdio: [
|
|
588
|
-
"ignore",
|
|
589
|
-
"pipe",
|
|
590
|
-
"pipe"
|
|
591
|
-
]
|
|
592
|
-
});
|
|
593
|
-
let last = Date.now();
|
|
594
|
-
let probing = false;
|
|
595
|
-
let announcedIdle = false;
|
|
596
|
-
let spun = false;
|
|
597
|
-
let pending = Promise.resolve();
|
|
598
|
-
child.stdout.on("data", (d) => (last = Date.now(), out(d.toString())));
|
|
599
|
-
child.stderr.on("data", (d) => (last = Date.now(), err(d.toString())));
|
|
600
|
-
const timer = setInterval(() => {
|
|
601
|
-
if (probing || spun || Date.now() - last < idle * 1e3 || !child.pid) return;
|
|
602
|
-
probing = true;
|
|
603
|
-
const pids = nodeDescendants(child.pid);
|
|
604
|
-
for (const p of pids) writeFileSync(join(o.reportDir, `probe-${p}`), "");
|
|
605
|
-
pending = collectFrames(o.reportDir, pids, 3e3).then((frames) => {
|
|
606
|
-
for (const p of pids) rmQuiet(join(o.reportDir, `probe-${p}`));
|
|
607
|
-
const stuck = frames.some((f) => userFrames(f, o.cwd).length > 0);
|
|
608
|
-
if (stuck || !announcedIdle) err(`\n${diagnose(frames, o.cwd, idle)}\n`);
|
|
609
|
-
announcedIdle = true;
|
|
610
|
-
probing = false;
|
|
611
|
-
if (stuck) {
|
|
612
|
-
spun = true;
|
|
613
|
-
for (const p of [...pids, child.pid]) killQuiet(p, "SIGTERM");
|
|
614
|
-
setTimeout(() => pids.forEach((p) => killQuiet(p, "SIGKILL")), 2e3).unref();
|
|
615
|
-
}
|
|
616
|
-
});
|
|
617
|
-
}, 1e3);
|
|
618
|
-
return await new Promise((resolve) => {
|
|
619
|
-
child.on("close", (code, sig) => {
|
|
620
|
-
clearInterval(timer);
|
|
621
|
-
pending.then(() => resolve(spun ? 124 : code ?? (sig ? 128 + (sig === "SIGKILL" ? 9 : 15) : 1)));
|
|
622
|
-
});
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
/** Frames each probed pid reported (empty list: its main thread was idle); pids that never answered are left out. */
|
|
626
|
-
async function collectFrames(dir, pids, waitMs) {
|
|
627
|
-
const got = /* @__PURE__ */ new Map();
|
|
628
|
-
for (const end = Date.now() + waitMs; Date.now() < end && got.size < pids.length;) {
|
|
629
|
-
for (const p of pids) {
|
|
630
|
-
const f = join(dir, `frames-${p}.json`);
|
|
631
|
-
if (got.has(p) || !existsSync(f)) continue;
|
|
632
|
-
try {
|
|
633
|
-
got.set(p, JSON.parse(readFileSync(f, "utf8")).frames);
|
|
634
|
-
unlinkSync(f);
|
|
635
|
-
} catch {}
|
|
636
|
-
}
|
|
637
|
-
await new Promise((r) => setTimeout(r, 100));
|
|
638
|
-
}
|
|
639
|
-
return [...got.values()];
|
|
640
|
-
}
|
|
641
|
-
/** Preloaded into every node process of the test run (CommonJS, so it also loads under --require). */
|
|
642
|
-
const PRELOAD_SOURCE = `"use strict";
|
|
643
|
-
const { Worker, isMainThread } = require("node:worker_threads");
|
|
644
|
-
if (isMainThread) {
|
|
645
|
-
const code = \`
|
|
646
|
-
const { existsSync, unlinkSync, writeFileSync, renameSync } = require("node:fs");
|
|
647
|
-
const { Session } = require("node:inspector");
|
|
648
|
-
const { workerData } = require("node:worker_threads");
|
|
649
|
-
const trigger = workerData.dir + "/probe-" + workerData.pid;
|
|
650
|
-
const done = (frames) => {
|
|
651
|
-
const tmp = workerData.dir + "/tmp-" + workerData.pid;
|
|
652
|
-
writeFileSync(tmp, JSON.stringify({ frames }));
|
|
653
|
-
renameSync(tmp, workerData.dir + "/frames-" + workerData.pid + ".json");
|
|
654
|
-
};
|
|
655
|
-
setInterval(() => {
|
|
656
|
-
if (!existsSync(trigger)) return;
|
|
657
|
-
try { unlinkSync(trigger); } catch {}
|
|
658
|
-
const s = new Session();
|
|
659
|
-
s.connectToMainThread();
|
|
660
|
-
let answered = false;
|
|
661
|
-
const urls = {}, maps = {};
|
|
662
|
-
s.on("Debugger.scriptParsed", (m) => { urls[m.params.scriptId] = m.params.url; maps[m.params.scriptId] = m.params.sourceMapURL; });
|
|
663
|
-
// transformed code (vite-node, tsx) has shifted lines: map back through its inline source map
|
|
664
|
-
const where = (f) => {
|
|
665
|
-
const id = f.location.scriptId;
|
|
666
|
-
let url = urls[id] || f.url, line = f.location.lineNumber;
|
|
667
|
-
const m = /^data:[^,]*;base64,(.*)$/.exec(maps[id] || "");
|
|
668
|
-
if (m) try {
|
|
669
|
-
const e = new (require("node:module").SourceMap)(JSON.parse(Buffer.from(m[1], "base64").toString())).findEntry(line, f.location.columnNumber || 0);
|
|
670
|
-
if (e && e.originalSource) { url = new URL(e.originalSource, url).href; line = e.originalLine; }
|
|
671
|
-
} catch {}
|
|
672
|
-
return { functionName: f.functionName, url, lineNumber: line };
|
|
673
|
-
};
|
|
674
|
-
s.on("Debugger.paused", (m) => {
|
|
675
|
-
answered = true;
|
|
676
|
-
done(m.params.callFrames.map(where));
|
|
677
|
-
s.post("Debugger.resume", () => s.post("Debugger.disable", () => s.disconnect()));
|
|
678
|
-
});
|
|
679
|
-
s.post("Debugger.enable", () => s.post("Debugger.pause"));
|
|
680
|
-
// an idle event loop runs no JS to pause in
|
|
681
|
-
setTimeout(() => { if (!answered) { done([]); s.post("Debugger.disable", () => s.disconnect()); } }, 800);
|
|
682
|
-
}, 200);
|
|
683
|
-
\`;
|
|
684
|
-
try {
|
|
685
|
-
new Worker(code, { eval: true, workerData: { dir: process.env.PAI_HANG_PROBE_DIR, pid: process.pid } }).unref();
|
|
686
|
-
} catch {}
|
|
687
|
-
}
|
|
688
|
-
`;
|
|
689
|
-
|
|
690
470
|
//#endregion
|
|
691
471
|
//#region src/workers/wait-probes.ts
|
|
692
472
|
/**
|
|
@@ -3232,7 +3012,7 @@ async function projectChecks(cwd, d = {}) {
|
|
|
3232
3012
|
}
|
|
3233
3013
|
async function realDaemonStart() {
|
|
3234
3014
|
try {
|
|
3235
|
-
const [{ PaiClient }, { loadConfig }] = await Promise.all([import("./ipc-client-
|
|
3015
|
+
const [{ PaiClient }, { loadConfig }] = await Promise.all([import("./ipc-client-DN7EvoVo.mjs"), import("./config-DtENJ6cL.mjs")]);
|
|
3236
3016
|
const s = await new PaiClient(loadConfig().socketPath).status();
|
|
3237
3017
|
return Date.now() - Number(s.uptime) * 1e3;
|
|
3238
3018
|
} catch {
|
|
@@ -3249,4 +3029,4 @@ function realBuildTime() {
|
|
|
3249
3029
|
|
|
3250
3030
|
//#endregion
|
|
3251
3031
|
export { schedulerLines as C, resolveSpecPath as E, withTarget as S, readSpecPrompt as T, issueClaims as _, branchDiff as a, workerCommand as b, runQueue as c, loadSettings as d, move as f, issueClaim as g, renderReview as h, projectChecks as i, QueueStore as l, renderList as m, initProject as n, realQueueDeps as o, queueStatePath as p, isGitProject as r, acceptItems as s, formatCheck as t, again as u, issueStale as v, schedulerView as w, resolveTarget as x, providerCaps as y };
|
|
3252
|
-
//# sourceMappingURL=project-setup-
|
|
3032
|
+
//# sourceMappingURL=project-setup-CBRtFFh0.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { F as writeWorkersSection, M as resolveCapability, O as providerCostTier, _ as maskKey, a as MODEL_CAPABILITIES, c as WorkersConfigError, d as defaultWorkersConfig, g as keysDir, h as isModelCapability, j as readWorkersSection, o as PROVIDER_TAGS, p as getProviderOrNative, t as ANTHROPIC_NATIVE, tt as workersYamlPath, y as nativeAnthropicProvider } from "./config-XpZWOYOG.mjs";
|
|
2
2
|
import { n as CONFIG_FILE, o as expandHome, s as homeRel } from "./config-Bu1_vbY8.mjs";
|
|
3
3
|
import { u as workersLogDir } from "./paths-CHifubDh.mjs";
|
|
4
|
-
import { a as clearCooldown, d as probeQuota,
|
|
4
|
+
import { a as clearCooldown, d as probeQuota, gn as LOCAL_MECHANISM_LINE, p as quotaSkipThreshold, pt as isLoopbackProvider } from "./routing-DmkheCRH.mjs";
|
|
5
5
|
import { d as resolveCap, t as admitCap } from "./capacity-DEveQdFV.mjs";
|
|
6
6
|
import { chmodSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
7
7
|
|
|
@@ -387,4 +387,4 @@ function describeCapabilities(workers) {
|
|
|
387
387
|
|
|
388
388
|
//#endregion
|
|
389
389
|
export { unsetCapabilityPreference as _, describeCapabilities as a, useProvider as b, modelPrefsText as c, setCapabilityPreference as d, setClass as f, setWorkersEnabled as g, setProviderModel as h, describeCap as i, removeProvider as l, setProviderEnabled as m, capText as n, describeModels as o, setProviderCap as p, classTargetText as r, describeProviders as s, addProvider as t, resolveProviderName as u, unsetClass as v, updateProvider as y };
|
|
390
|
-
//# sourceMappingURL=providers-
|
|
390
|
+
//# sourceMappingURL=providers-C9QC0TtO.mjs.map
|
|
@@ -3,7 +3,7 @@ import "./config-Bu1_vbY8.mjs";
|
|
|
3
3
|
import "./paths-CHifubDh.mjs";
|
|
4
4
|
import "./status-ggJ7lgVg.mjs";
|
|
5
5
|
import "./scope-D-h6F6DN.mjs";
|
|
6
|
-
import "./routing-
|
|
6
|
+
import "./routing-DmkheCRH.mjs";
|
|
7
7
|
import "./tool-errors-7E13StWd.mjs";
|
|
8
8
|
import "./wait-ByV0OyMZ.mjs";
|
|
9
9
|
import "./local-tiers-BE4jGaMa.mjs";
|
|
@@ -11,6 +11,6 @@ import "./caller-identity-yLFb7CKq.mjs";
|
|
|
11
11
|
import "./capacity-DEveQdFV.mjs";
|
|
12
12
|
import "./local-instances-DOxSgT_L.mjs";
|
|
13
13
|
import "./local-candidate-DLdwQt0s.mjs";
|
|
14
|
-
import { _ as unsetCapabilityPreference, a as describeCapabilities, b as useProvider, c as modelPrefsText, d as setCapabilityPreference, f as setClass, g as setWorkersEnabled, h as setProviderModel, i as describeCap, l as removeProvider, m as setProviderEnabled, n as capText, o as describeModels, p as setProviderCap, r as classTargetText, s as describeProviders, t as addProvider, u as resolveProviderName, v as unsetClass, y as updateProvider } from "./providers-
|
|
14
|
+
import { _ as unsetCapabilityPreference, a as describeCapabilities, b as useProvider, c as modelPrefsText, d as setCapabilityPreference, f as setClass, g as setWorkersEnabled, h as setProviderModel, i as describeCap, l as removeProvider, m as setProviderEnabled, n as capText, o as describeModels, p as setProviderCap, r as classTargetText, s as describeProviders, t as addProvider, u as resolveProviderName, v as unsetClass, y as updateProvider } from "./providers-C9QC0TtO.mjs";
|
|
15
15
|
|
|
16
16
|
export { setProviderEnabled, useProvider };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./config-XpZWOYOG.mjs";
|
|
2
2
|
import "./config-Bu1_vbY8.mjs";
|
|
3
3
|
import "./paths-CHifubDh.mjs";
|
|
4
|
-
import "./worktree-
|
|
4
|
+
import "./worktree-CRs2gyg0.mjs";
|
|
5
5
|
import "./status-ggJ7lgVg.mjs";
|
|
6
|
-
import "./pool-
|
|
7
|
-
import { a as unregistrableReason, i as reportUnregistrable, n as mainRepoOf, o as workerWorktreesRoot, r as pruneWorktreeProjects, s as worktreeReason, t as isLinkedWorktree } from "./registrable-
|
|
6
|
+
import "./pool-Dh-q3iJi.mjs";
|
|
7
|
+
import { a as unregistrableReason, i as reportUnregistrable, n as mainRepoOf, o as workerWorktreesRoot, r as pruneWorktreeProjects, s as worktreeReason, t as isLinkedWorktree } from "./registrable-DpyTtajg.mjs";
|
|
8
8
|
|
|
9
9
|
export { reportUnregistrable };
|