@tekmidian/pai 0.66.3 → 0.66.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/dist/{chain-Fz4NLm4D.mjs → chain-BhPwBDXB.mjs} +2 -2
- package/dist/{chain-Fz4NLm4D.mjs.map → chain-BhPwBDXB.mjs.map} +1 -1
- package/dist/cli/index.mjs +8 -8
- package/dist/cli/program.mjs +8 -8
- package/dist/{context-handover-cache-DcPEW6vf.mjs → context-handover-cache-BbCYQUGo.mjs} +3 -3
- package/dist/{context-handover-cache-DcPEW6vf.mjs.map → context-handover-cache-BbCYQUGo.mjs.map} +1 -1
- package/dist/daemon/index.mjs +5 -5
- package/dist/{daemon-Bl8TpHdM.mjs → daemon-DzXOfieK.mjs} +5 -5
- package/dist/{daemon-Bl8TpHdM.mjs.map → daemon-DzXOfieK.mjs.map} +1 -1
- package/dist/{daemon-ZhHU6D0i.mjs → daemon-UJtRscyO.mjs} +5 -5
- package/dist/daemon-mcp/index.mjs +5 -5
- package/dist/{factory-BUnZgnKW.mjs → factory-CXFHwvcv.mjs} +2 -2
- package/dist/{factory-BUnZgnKW.mjs.map → factory-CXFHwvcv.mjs.map} +1 -1
- package/dist/{factory-CrVlo2hY.mjs → factory-CnKsU6zX.mjs} +2 -2
- package/dist/{fallback-awOmq_9A.mjs → fallback-CoooFqyA.mjs} +2 -2
- package/dist/{fallback-awOmq_9A.mjs.map → fallback-CoooFqyA.mjs.map} +1 -1
- package/dist/hooks/load-project-context.mjs.map +2 -2
- package/dist/hooks/security-validator.mjs.map +2 -2
- package/dist/hooks/worker-status-line.mjs.map +2 -2
- package/dist/{main-resolver-DDShdDBm.mjs → main-resolver-DrHtx8iW.mjs} +1 -1
- package/dist/{main-resolver-CVGPICy-.mjs → main-resolver-SfGGg1DB.mjs} +3 -3
- package/dist/{main-resolver-CVGPICy-.mjs.map → main-resolver-SfGGg1DB.mjs.map} +1 -1
- package/dist/{planner-GdiYe2FO.mjs → planner-C43lzcw5.mjs} +5 -5
- package/dist/{planner-GdiYe2FO.mjs.map → planner-C43lzcw5.mjs.map} +1 -1
- package/dist/postgres-B2BEBT-J.mjs +5 -0
- package/dist/{postgres-H85VSYHI.mjs → postgres-BxmyQHoA.mjs} +52 -4
- package/dist/postgres-BxmyQHoA.mjs.map +1 -0
- package/dist/{program-D3MSfx86.mjs → program-DB-hoyfW.mjs} +38 -121
- package/dist/program-DB-hoyfW.mjs.map +1 -0
- package/dist/{run-D9YbWsnL.mjs → run-wi5NEkJd.mjs} +116 -7
- package/dist/run-wi5NEkJd.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/postgres-DKyiCA5V.mjs +0 -5
- package/dist/postgres-H85VSYHI.mjs.map +0 -1
- package/dist/program-D3MSfx86.mjs.map +0 -1
- package/dist/run-D9YbWsnL.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as getRegistryBackend } from "./factory-
|
|
1
|
+
import { i as getRegistryBackend } from "./factory-CXFHwvcv.mjs";
|
|
2
2
|
import { a as paiHomePath, o as resolvePaiFile } from "./pai-home-UncxWxlX.mjs";
|
|
3
3
|
import { A as resolveProviderKey, D as readWorkersSection, E as providerKeyPath, O as resolveCapability, T as providerCostTier, _ as classModelCapability, b as getProviderOrNative, f as NATIVE_ANTHROPIC_MODELS, g as assertProviderRunnable, h as WorkersConfigError, k as resolveModelCapability, m as WORKER_CLASSES, n as claudeCommand, o as DEFAULT_LOG_DIR, r as ANTHROPIC_NATIVE, t as buildRunEnv, x as isModelCapability, y as expandHome } from "./run-env-CQRnxNht.mjs";
|
|
4
4
|
import { appendFileSync, closeSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
@@ -1046,6 +1046,109 @@ function ledgerSummary(path, scope, lastN = 15, now = /* @__PURE__ */ new Date()
|
|
|
1046
1046
|
};
|
|
1047
1047
|
}
|
|
1048
1048
|
|
|
1049
|
+
//#endregion
|
|
1050
|
+
//#region src/workers/pending.ts
|
|
1051
|
+
/**
|
|
1052
|
+
* Pending worker results: finished workers whose worktree branch still holds
|
|
1053
|
+
* work that never reached the repo (commits not in HEAD, or uncommitted
|
|
1054
|
+
* files). Surfaced by `pai worker ps/pending`, the SessionStart hook, the
|
|
1055
|
+
* status line and the prepublish gate so an unmerged fix cannot be forgotten.
|
|
1056
|
+
*/
|
|
1057
|
+
/** Stale after this long: `pai worker gc` (archive) instead of merge. */
|
|
1058
|
+
const STALE_HOURS = 24;
|
|
1059
|
+
function toplevel(dir) {
|
|
1060
|
+
try {
|
|
1061
|
+
return git(dir, ["rev-parse", "--show-toplevel"]);
|
|
1062
|
+
} catch {
|
|
1063
|
+
return null;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
function fmtAge(ms) {
|
|
1067
|
+
const h = Math.floor(ms / 36e5);
|
|
1068
|
+
return h >= 48 ? `${Math.floor(h / 24)}d` : h >= 1 ? `${h}h` : `${Math.floor(ms / 6e4)}m`;
|
|
1069
|
+
}
|
|
1070
|
+
/** Finished workers with unmerged work; `repoRoot` limits to one repo, else every repo. */
|
|
1071
|
+
function pendingResults(logDir, repoRoot, now = Date.now()) {
|
|
1072
|
+
const want = repoRoot ? toplevel(repoRoot) : null;
|
|
1073
|
+
if (repoRoot && !want) return [];
|
|
1074
|
+
const out = [];
|
|
1075
|
+
for (const st of loadStatuses(logDir)) {
|
|
1076
|
+
if (st.archived || st.merged || isLive(st)) continue;
|
|
1077
|
+
if (!st.worktreeDir || !existsSync(st.worktreeDir)) continue;
|
|
1078
|
+
const repo = toplevel(st.cwd);
|
|
1079
|
+
if (!repo || want && repo !== want) continue;
|
|
1080
|
+
let commits = 0;
|
|
1081
|
+
let dirty = 0;
|
|
1082
|
+
try {
|
|
1083
|
+
if (st.branch) commits = git(repo, [
|
|
1084
|
+
"cherry",
|
|
1085
|
+
"HEAD",
|
|
1086
|
+
`refs/heads/${st.branch}`
|
|
1087
|
+
]).split("\n").filter((l) => l.startsWith("+")).length;
|
|
1088
|
+
dirty = uncommittedPaths(st.worktreeDir).filter((p) => !/(^|\/)node_modules(\/|$)/.test(p)).length;
|
|
1089
|
+
} catch {
|
|
1090
|
+
continue;
|
|
1091
|
+
}
|
|
1092
|
+
if (!commits && !dirty) continue;
|
|
1093
|
+
let ageMs = 0;
|
|
1094
|
+
try {
|
|
1095
|
+
ageMs = Math.max(0, now - statSync(statusPath(logDir, st.id)).mtimeMs);
|
|
1096
|
+
} catch {}
|
|
1097
|
+
out.push({
|
|
1098
|
+
id: st.id,
|
|
1099
|
+
label: st.label,
|
|
1100
|
+
repo,
|
|
1101
|
+
ageMs,
|
|
1102
|
+
age: fmtAge(ageMs),
|
|
1103
|
+
commits,
|
|
1104
|
+
dirty
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
return out;
|
|
1108
|
+
}
|
|
1109
|
+
/** One human line per result, with the exact next command. */
|
|
1110
|
+
function formatPending(results, showRepo = false) {
|
|
1111
|
+
return results.map((r) => {
|
|
1112
|
+
const next = r.ageMs > STALE_HOURS * 36e5 ? "pai worker gc" : `pai worker merge ${r.id}`;
|
|
1113
|
+
const repo = showRepo ? ` ${r.repo}` : "";
|
|
1114
|
+
return `${r.id} ${r.age} ${r.commits} commit(s), ${r.dirty} dirty ${r.label}${repo} -> ${next}`;
|
|
1115
|
+
}).join("\n");
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Release gate: exit code and message for `pai worker pending --gate`.
|
|
1119
|
+
* PAI_ALLOW_PENDING=1 overrides.
|
|
1120
|
+
*/
|
|
1121
|
+
function pendingGate(results, env = process.env) {
|
|
1122
|
+
if (!results.length || env.PAI_ALLOW_PENDING === "1") return {
|
|
1123
|
+
code: 0,
|
|
1124
|
+
message: ""
|
|
1125
|
+
};
|
|
1126
|
+
return {
|
|
1127
|
+
code: 1,
|
|
1128
|
+
message: `${results.length} unmerged worker result(s) in this repo — merge or discard before publishing:\n${formatPending(results)}\nOverride deliberately with PAI_ALLOW_PENDING=1.`
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
/** Invalidate pending cache entries for a repo and its subdirectories. */
|
|
1132
|
+
function invalidatePendingCache(logDir, repoRoot) {
|
|
1133
|
+
const file = join(logDir, "pending-cache.json");
|
|
1134
|
+
let cache = {};
|
|
1135
|
+
try {
|
|
1136
|
+
cache = JSON.parse(readFileSync(file, "utf8"));
|
|
1137
|
+
} catch {
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
const resolved = repoRoot.endsWith("/") ? repoRoot : `${repoRoot}/`;
|
|
1141
|
+
let changed = false;
|
|
1142
|
+
for (const key of Object.keys(cache)) if (key === repoRoot || key.startsWith(resolved)) {
|
|
1143
|
+
delete cache[key];
|
|
1144
|
+
changed = true;
|
|
1145
|
+
}
|
|
1146
|
+
if (!changed) return;
|
|
1147
|
+
try {
|
|
1148
|
+
writeFileSync(file, JSON.stringify(cache));
|
|
1149
|
+
} catch {}
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1049
1152
|
//#endregion
|
|
1050
1153
|
//#region src/workers/worktree.ts
|
|
1051
1154
|
/**
|
|
@@ -1290,6 +1393,7 @@ function recordWorktree(logDir, status, info, ok) {
|
|
|
1290
1393
|
s.worktreeSnapshot = null;
|
|
1291
1394
|
}
|
|
1292
1395
|
saveStatus(logDir, s);
|
|
1396
|
+
invalidatePendingCache(logDir, s.cwd);
|
|
1293
1397
|
return s;
|
|
1294
1398
|
}
|
|
1295
1399
|
function safeCommitsSince(dir, base) {
|
|
@@ -1824,6 +1928,7 @@ function mergeWorker(logDir, id, opts = {}) {
|
|
|
1824
1928
|
...st,
|
|
1825
1929
|
merged: true
|
|
1826
1930
|
});
|
|
1931
|
+
invalidatePendingCache(logDir, st.cwd);
|
|
1827
1932
|
const base = `merged ${st.branch} into ${st.cwd} (worktree removed${branchGone ? ", branch deleted" : "; branch kept: git refused -d"})`;
|
|
1828
1933
|
const notes = [];
|
|
1829
1934
|
if (salvage.committed.length) notes.push(`salvaged ${salvage.committed.length} uncommitted change(s): ${salvage.committed.join(", ")}`);
|
|
@@ -1854,6 +1959,7 @@ function discardWorker(logDir, id) {
|
|
|
1854
1959
|
commits: null,
|
|
1855
1960
|
merged: false
|
|
1856
1961
|
});
|
|
1962
|
+
invalidatePendingCache(logDir, st.cwd);
|
|
1857
1963
|
return `discarded worker ${id}: worktree removed${branchGone ? `, branch ${st.branch} deleted` : ""}`;
|
|
1858
1964
|
}
|
|
1859
1965
|
function mustHaveBranch(logDir, id) {
|
|
@@ -2008,9 +2114,12 @@ function gcWorktrees(logDir, olderThanHours = 24, dryRun = false, now = Date.now
|
|
|
2008
2114
|
}
|
|
2009
2115
|
archive(ent.name, dir, null);
|
|
2010
2116
|
}
|
|
2011
|
-
if (!dryRun) for (const repo of new Set(loadStatuses(logDir).map((s) => s.cwd)))
|
|
2012
|
-
|
|
2013
|
-
|
|
2117
|
+
if (!dryRun) for (const repo of new Set(loadStatuses(logDir).map((s) => s.cwd))) {
|
|
2118
|
+
try {
|
|
2119
|
+
git(repo, ["worktree", "prune"]);
|
|
2120
|
+
} catch {}
|
|
2121
|
+
invalidatePendingCache(logDir, repo);
|
|
2122
|
+
}
|
|
2014
2123
|
return out;
|
|
2015
2124
|
}
|
|
2016
2125
|
/** Run `gcWorktrees` at most once per `everyMin` minutes (stamp file in the logDir). */
|
|
@@ -4472,7 +4581,7 @@ async function runWorker(opts) {
|
|
|
4472
4581
|
if (gc?.length) process.stderr.write(`pai worker: archived ${gc.length} leftover worktree(s) (pai worker gc)\n`);
|
|
4473
4582
|
} catch {}
|
|
4474
4583
|
if (opts.className === "plan" && !opts._planner) {
|
|
4475
|
-
const { runPlanner } = await import("./planner-
|
|
4584
|
+
const { runPlanner } = await import("./planner-C43lzcw5.mjs");
|
|
4476
4585
|
return runPlanner(opts);
|
|
4477
4586
|
}
|
|
4478
4587
|
const parent = launchParent(opts.parent);
|
|
@@ -5731,5 +5840,5 @@ function resultFromOutput(out) {
|
|
|
5731
5840
|
}
|
|
5732
5841
|
|
|
5733
5842
|
//#endregion
|
|
5734
|
-
export {
|
|
5735
|
-
//# sourceMappingURL=run-
|
|
5843
|
+
export { setWorkerLabel as $, git as A, ageOf as B, itermUuid as C, workerInScope as D, sessionTag as E, pendingGate as F, isChatPane as G, contextLabel as H, pendingResults as I, loadStatuses as J, isLive as K, appendLedger as L, verifyWorker as M, worktreesDir as N, discardWorker as O, formatPending as P, saveStatus as Q, ledgerSummary as R, itermForClaudeSession as S, sessionMapPath as T, contextPercent as U, alive as V, elapsedOf as W, nowStamp as X, newWorkerId as Y, ownsPid as Z, markControlsHeld as _, describeMcp as _t, deadlineLabel as a, ensureProxyRunning as at, requestKill as b, handoffFromInside as c, probeQuota as ct, workerDepth as d, ensureNoMcpConfig as dt, waitForTerminalStatus as et, checkPaneForWorker as f, eventsPath as ft, clickrControlsArgv as g, projectLaunchConfig as gt, openPaneForWorker as h, pinNotices as ht, usageContextTokens as i, DEFAULT_PROXY_PORT as it, mergeWorker as j, gcWorktrees as k, readInbox as l, quotaSkipThreshold as lt, openFollowPane as m, workersLogDir as mt, runWorker as n, parseRunnerArgs as nt, parseWorkerReport as o, stopProxy as ot, closeEndedPanes as p, ledgerPath as pt, loadStatus as q, testProvider as r, shortText as rt, renderReport as s, clearCooldown as st, printResult as t, longInlinePromptHint as tt, sayToWorker as u, resolveTarget as ut, callerDescription as v, expandMcpNames as vt, resolveSession as w, currentTabKey as x, endLabel as y, UNLABELED as z };
|
|
5844
|
+
//# sourceMappingURL=run-wi5NEkJd.mjs.map
|