@tekmidian/pai 1.0.2 → 1.0.3
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-B7Yu6Uam.mjs} +2 -2
- package/dist/auto-route-CjjQqU1o.mjs +11 -0
- package/dist/{chain-D-yvET_y.mjs → chain-7n9Gx56r.mjs} +2 -2
- package/dist/cli/index.mjs +29 -35
- package/dist/{cockpit-actions-C8GlTzts.mjs → cockpit-actions-BBHeyEZI.mjs} +8 -8
- package/dist/{cockpit-actions-BWunx3rY.mjs → cockpit-actions-DR9X514g.mjs} +1 -1
- package/dist/{cockpit-memory-vTlFWV7F.mjs → cockpit-memory--dnShXBA.mjs} +1 -1
- package/dist/{controls-BcKFHeG1.mjs → controls-CPoeudou.mjs} +4 -4
- package/dist/daemon/index.mjs +13 -13
- package/dist/{daemon-N7WhYi6I.mjs → daemon-DKdBNKfa.mjs} +13 -13
- package/dist/{daemon-ColVHwGZ.mjs → daemon-DPAo6WTa.mjs} +9 -9
- package/dist/daemon-mcp/index.mjs +10 -10
- package/dist/hooks/worker-pool-host.mjs +115 -115
- package/dist/index.mjs +4 -4
- package/dist/{indexer-backend-_a6UNhXJ.mjs → indexer-backend-Cll7le4P.mjs} +4 -4
- package/dist/{models-add-BtB3Se6f.mjs → models-add-C1QIc1DA.mjs} +10 -10
- package/dist/{pai-marker-DurzIbw8.mjs → pai-marker-BcZyJguM.mjs} +2 -2
- package/dist/{pane-audit-BQytYa60.mjs → pane-audit-DKQt71s4.mjs} +2 -2
- package/dist/{planner-BM27GBfC.mjs → planner-BmFACdLa.mjs} +8 -8
- 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/{project-setup-CfpApz5o.mjs → project-setup-jvfONJTQ.mjs} +8 -8
- package/dist/{registrable-C7b6givx.mjs → registrable-BzH4TObg.mjs} +3 -3
- package/dist/{registrable-Uzgmfyhz.mjs → registrable-DpyTtajg.mjs} +2 -2
- package/dist/{render-CwIrgxLi.mjs → render-BYmQkuLd.mjs} +2 -2
- package/dist/{render-Cc2j5QG9.mjs → render-CoMvwMPs.mjs} +3 -3
- package/dist/{root-wC_6Fx0B.mjs → root-FtJsxYnm.mjs} +7 -7
- package/dist/{root-BWy0c2Lq.mjs → root-Xglu0OPD.mjs} +3 -3
- package/dist/{run-6Q9kCPem.mjs → run-CSC7mgPf.mjs} +7 -7
- package/dist/{scan-ZQWm-_se.mjs → scan-C_Y5W9py.mjs} +3 -3
- package/dist/{session-DVUExUnX.mjs → session-8iqQDkqb.mjs} +7 -7
- package/dist/{session-Bok2PqRS.mjs → session-BeqAbNPd.mjs} +6 -6
- package/dist/{viewer-MWBVJP3u.mjs → viewer-CqozWW39.mjs} +6 -6
- package/dist/{viewer-DcpJwGKE.mjs → viewer-mDXUNHNy.mjs} +5 -5
- package/dist/{worker-config-BDYNxbYz.mjs → worker-config-CJhEMk19.mjs} +10 -10
- package/dist/{worker-config-gmAq_-rI.mjs → worker-config-DESkIjMF.mjs} +9 -9
- package/dist/{worktree-CrnOqTBW.mjs → worktree-CRs2gyg0.mjs} +2 -2
- 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/dist/auto-route-BjoMHKyI.mjs +0 -11
|
@@ -9985,7 +9985,7 @@ var init_paths = __esm({
|
|
|
9985
9985
|
|
|
9986
9986
|
// src/config/claude-json.ts
|
|
9987
9987
|
import { homedir as homedir3 } from "node:os";
|
|
9988
|
-
import { join as join8 } from "node:path";
|
|
9988
|
+
import { join as join8, resolve as resolve3 } from "node:path";
|
|
9989
9989
|
function claudeJsonPath() {
|
|
9990
9990
|
return join8(homedir3(), ".claude.json");
|
|
9991
9991
|
}
|
|
@@ -10260,9 +10260,9 @@ function poolPort(config) {
|
|
|
10260
10260
|
return config.pool?.port ?? DEFAULT_POOL_PORT;
|
|
10261
10261
|
}
|
|
10262
10262
|
function postTaskToPool(port2, task, timeoutMs, path = "/task", handover, handoverWaitMs = 2e4) {
|
|
10263
|
-
return new Promise((
|
|
10263
|
+
return new Promise((resolve12) => {
|
|
10264
10264
|
let connected = false;
|
|
10265
|
-
const fail = (detail) =>
|
|
10265
|
+
const fail = (detail) => resolve12({ error: connected ? "claim-error" : "unreachable", detail });
|
|
10266
10266
|
const body = JSON.stringify(task);
|
|
10267
10267
|
const req = httpRequest(
|
|
10268
10268
|
{
|
|
@@ -10279,7 +10279,7 @@ function postTaskToPool(port2, task, timeoutMs, path = "/task", handover, handov
|
|
|
10279
10279
|
res.on("end", () => {
|
|
10280
10280
|
try {
|
|
10281
10281
|
const resp = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
10282
|
-
|
|
10282
|
+
resolve12(resp.pooled ? { ok: resp } : { miss: resp.reason ?? "refused" });
|
|
10283
10283
|
} catch (e) {
|
|
10284
10284
|
fail(`unreadable answer: ${e instanceof Error ? e.message : String(e)}`);
|
|
10285
10285
|
}
|
|
@@ -10289,12 +10289,12 @@ function postTaskToPool(port2, task, timeoutMs, path = "/task", handover, handov
|
|
|
10289
10289
|
);
|
|
10290
10290
|
req.setTimeout(timeoutMs, () => {
|
|
10291
10291
|
req.destroy();
|
|
10292
|
-
|
|
10292
|
+
resolve12({ error: "timeout", detail: `no answer within ${timeoutMs} ms` });
|
|
10293
10293
|
});
|
|
10294
10294
|
req.on("socket", (s) => s.on("connect", () => connected = true));
|
|
10295
10295
|
req.on("error", (e) => {
|
|
10296
10296
|
if (e.code === "ECONNREFUSED" && handover?.() && handoverWaitMs > 0) {
|
|
10297
|
-
setTimeout(() => void postTaskToPool(port2, task, timeoutMs, path, handover, handoverWaitMs - 300).then(
|
|
10297
|
+
setTimeout(() => void postTaskToPool(port2, task, timeoutMs, path, handover, handoverWaitMs - 300).then(resolve12), 300);
|
|
10298
10298
|
return;
|
|
10299
10299
|
}
|
|
10300
10300
|
fail(e.message);
|
|
@@ -10303,33 +10303,33 @@ function postTaskToPool(port2, task, timeoutMs, path = "/task", handover, handov
|
|
|
10303
10303
|
});
|
|
10304
10304
|
}
|
|
10305
10305
|
function poolHostProbe(port2, timeoutMs = 500) {
|
|
10306
|
-
return new Promise((
|
|
10306
|
+
return new Promise((resolve12) => {
|
|
10307
10307
|
const req = httpRequest({ host: LOOPBACK_HOST, port: port2, path: "/healthz", method: "GET", timeout: timeoutMs }, (res) => {
|
|
10308
10308
|
res.resume();
|
|
10309
|
-
res.on("end", () =>
|
|
10310
|
-
res.on("error", () =>
|
|
10309
|
+
res.on("end", () => resolve12(res.statusCode === 200 ? "up" : "down"));
|
|
10310
|
+
res.on("error", () => resolve12("down"));
|
|
10311
10311
|
});
|
|
10312
10312
|
req.on("timeout", () => {
|
|
10313
10313
|
req.destroy();
|
|
10314
|
-
|
|
10314
|
+
resolve12("timeout");
|
|
10315
10315
|
});
|
|
10316
|
-
req.on("error", () =>
|
|
10316
|
+
req.on("error", () => resolve12("down"));
|
|
10317
10317
|
req.end();
|
|
10318
10318
|
});
|
|
10319
10319
|
}
|
|
10320
10320
|
function poolHostPid(port2, timeoutMs = 500) {
|
|
10321
|
-
return new Promise((
|
|
10321
|
+
return new Promise((resolve12) => {
|
|
10322
10322
|
const req = httpRequest({ host: LOOPBACK_HOST, port: port2, path: "/healthz", method: "GET", timeout: timeoutMs }, (res) => {
|
|
10323
10323
|
res.resume();
|
|
10324
10324
|
const pid = parseInt(String(res.headers["x-pool-host-pid"] ?? ""), 10);
|
|
10325
|
-
res.on("end", () =>
|
|
10326
|
-
res.on("error", () =>
|
|
10325
|
+
res.on("end", () => resolve12(res.statusCode === 200 ? Number.isFinite(pid) ? pid : 0 : null));
|
|
10326
|
+
res.on("error", () => resolve12(null));
|
|
10327
10327
|
});
|
|
10328
10328
|
req.on("timeout", () => {
|
|
10329
10329
|
req.destroy();
|
|
10330
|
-
|
|
10330
|
+
resolve12(null);
|
|
10331
10331
|
});
|
|
10332
|
-
req.on("error", () =>
|
|
10332
|
+
req.on("error", () => resolve12(null));
|
|
10333
10333
|
req.end();
|
|
10334
10334
|
});
|
|
10335
10335
|
}
|
|
@@ -11283,7 +11283,7 @@ var init_wait_on = __esm({
|
|
|
11283
11283
|
// src/workers/report.ts
|
|
11284
11284
|
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
11285
11285
|
import { statSync as statSync5 } from "node:fs";
|
|
11286
|
-
import { isAbsolute, relative, resolve as
|
|
11286
|
+
import { isAbsolute, relative, resolve as resolve4 } from "node:path";
|
|
11287
11287
|
function ag2ReportBlock() {
|
|
11288
11288
|
const spec = ag2Spec();
|
|
11289
11289
|
return [
|
|
@@ -11446,7 +11446,7 @@ function verifyReportChanges(changed, cwd, startMs) {
|
|
|
11446
11446
|
const raw = (ch.path ?? "").trim();
|
|
11447
11447
|
if (!raw) continue;
|
|
11448
11448
|
if (/^delete:/i.test(raw)) continue;
|
|
11449
|
-
const abs = isAbsolute(raw) ? raw :
|
|
11449
|
+
const abs = isAbsolute(raw) ? raw : resolve4(cwd, raw);
|
|
11450
11450
|
let mtimeMs;
|
|
11451
11451
|
try {
|
|
11452
11452
|
mtimeMs = statSync5(abs).mtimeMs;
|
|
@@ -12867,14 +12867,14 @@ function anthropicUsageUrl() {
|
|
|
12867
12867
|
return new URL("/api/oauth/usage", loadConfig().router.claudeUpstream);
|
|
12868
12868
|
}
|
|
12869
12869
|
function getJson(url, headers, timeoutMs = 5e3) {
|
|
12870
|
-
return new Promise((
|
|
12870
|
+
return new Promise((resolve12, reject) => {
|
|
12871
12871
|
const mod = url.protocol === "https:" ? https : http;
|
|
12872
12872
|
const rq = mod.get(url, { headers, timeout: timeoutMs }, (res) => {
|
|
12873
12873
|
let t = "";
|
|
12874
12874
|
res.on("data", (c) => t += c);
|
|
12875
12875
|
res.on(
|
|
12876
12876
|
"end",
|
|
12877
|
-
() => res.statusCode === 200 ?
|
|
12877
|
+
() => res.statusCode === 200 ? resolve12(t) : reject(new HttpError(res.statusCode ?? 0, res.statusCode === 429 ? parseRetryAfter(res.headers["retry-after"]) : void 0))
|
|
12878
12878
|
);
|
|
12879
12879
|
});
|
|
12880
12880
|
rq.on("timeout", () => rq.destroy(new Error("timeout")));
|
|
@@ -12882,7 +12882,7 @@ function getJson(url, headers, timeoutMs = 5e3) {
|
|
|
12882
12882
|
});
|
|
12883
12883
|
}
|
|
12884
12884
|
function sh(cmd, args) {
|
|
12885
|
-
return new Promise((
|
|
12885
|
+
return new Promise((resolve12) => execFile(cmd, args, { timeout: 4e3 }, (_e, out) => resolve12(String(out ?? "").trim())));
|
|
12886
12886
|
}
|
|
12887
12887
|
async function anthropicToken() {
|
|
12888
12888
|
for (const args of [["-a", process.env.USER ?? ""], []]) {
|
|
@@ -16965,7 +16965,7 @@ var require_dist2 = __commonJS({
|
|
|
16965
16965
|
function parse4(stream, callback) {
|
|
16966
16966
|
const parser = new parser_1.Parser();
|
|
16967
16967
|
stream.on("data", (buffer) => parser.parse(buffer, callback));
|
|
16968
|
-
return new Promise((
|
|
16968
|
+
return new Promise((resolve12) => stream.on("end", () => resolve12()));
|
|
16969
16969
|
}
|
|
16970
16970
|
exports.parse = parse4;
|
|
16971
16971
|
}
|
|
@@ -17692,12 +17692,12 @@ var require_client = __commonJS({
|
|
|
17692
17692
|
this._connect(callback);
|
|
17693
17693
|
return;
|
|
17694
17694
|
}
|
|
17695
|
-
return new this._Promise((
|
|
17695
|
+
return new this._Promise((resolve12, reject) => {
|
|
17696
17696
|
this._connect((error) => {
|
|
17697
17697
|
if (error) {
|
|
17698
17698
|
reject(error);
|
|
17699
17699
|
} else {
|
|
17700
|
-
|
|
17700
|
+
resolve12(this);
|
|
17701
17701
|
}
|
|
17702
17702
|
});
|
|
17703
17703
|
});
|
|
@@ -18039,8 +18039,8 @@ var require_client = __commonJS({
|
|
|
18039
18039
|
readTimeout = config.query_timeout || this.connectionParameters.query_timeout;
|
|
18040
18040
|
query = new Query2(config, values, callback);
|
|
18041
18041
|
if (!query.callback) {
|
|
18042
|
-
result = new this._Promise((
|
|
18043
|
-
query.callback = (err, res) => err ? reject(err) :
|
|
18042
|
+
result = new this._Promise((resolve12, reject) => {
|
|
18043
|
+
query.callback = (err, res) => err ? reject(err) : resolve12(res);
|
|
18044
18044
|
}).catch((err) => {
|
|
18045
18045
|
Error.captureStackTrace(err);
|
|
18046
18046
|
throw err;
|
|
@@ -18113,8 +18113,8 @@ var require_client = __commonJS({
|
|
|
18113
18113
|
if (cb) {
|
|
18114
18114
|
this.connection.once("end", cb);
|
|
18115
18115
|
} else {
|
|
18116
|
-
return new this._Promise((
|
|
18117
|
-
this.connection.once("end",
|
|
18116
|
+
return new this._Promise((resolve12) => {
|
|
18117
|
+
this.connection.once("end", resolve12);
|
|
18118
18118
|
});
|
|
18119
18119
|
}
|
|
18120
18120
|
}
|
|
@@ -18163,8 +18163,8 @@ var require_pg_pool = __commonJS({
|
|
|
18163
18163
|
const cb = function(err, client) {
|
|
18164
18164
|
err ? rej(err) : res(client);
|
|
18165
18165
|
};
|
|
18166
|
-
const result = new Promise2(function(
|
|
18167
|
-
res =
|
|
18166
|
+
const result = new Promise2(function(resolve12, reject) {
|
|
18167
|
+
res = resolve12;
|
|
18168
18168
|
rej = reject;
|
|
18169
18169
|
}).catch((err) => {
|
|
18170
18170
|
Error.captureStackTrace(err);
|
|
@@ -18585,8 +18585,8 @@ var require_query2 = __commonJS({
|
|
|
18585
18585
|
NativeQuery.prototype._getPromise = function() {
|
|
18586
18586
|
if (this._promise) return this._promise;
|
|
18587
18587
|
this._promise = new Promise(
|
|
18588
|
-
function(
|
|
18589
|
-
this._once("end",
|
|
18588
|
+
function(resolve12, reject) {
|
|
18589
|
+
this._once("end", resolve12);
|
|
18590
18590
|
this._once("error", reject);
|
|
18591
18591
|
}.bind(this)
|
|
18592
18592
|
);
|
|
@@ -18758,12 +18758,12 @@ var require_client2 = __commonJS({
|
|
|
18758
18758
|
this._connect(callback);
|
|
18759
18759
|
return;
|
|
18760
18760
|
}
|
|
18761
|
-
return new this._Promise((
|
|
18761
|
+
return new this._Promise((resolve12, reject) => {
|
|
18762
18762
|
this._connect((error) => {
|
|
18763
18763
|
if (error) {
|
|
18764
18764
|
reject(error);
|
|
18765
18765
|
} else {
|
|
18766
|
-
|
|
18766
|
+
resolve12(this);
|
|
18767
18767
|
}
|
|
18768
18768
|
});
|
|
18769
18769
|
});
|
|
@@ -18787,8 +18787,8 @@ var require_client2 = __commonJS({
|
|
|
18787
18787
|
query = new NativeQuery(config, values, callback);
|
|
18788
18788
|
if (!query.callback) {
|
|
18789
18789
|
let resolveOut, rejectOut;
|
|
18790
|
-
result = new this._Promise((
|
|
18791
|
-
resolveOut =
|
|
18790
|
+
result = new this._Promise((resolve12, reject) => {
|
|
18791
|
+
resolveOut = resolve12;
|
|
18792
18792
|
rejectOut = reject;
|
|
18793
18793
|
}).catch((err) => {
|
|
18794
18794
|
Error.captureStackTrace(err);
|
|
@@ -18844,8 +18844,8 @@ var require_client2 = __commonJS({
|
|
|
18844
18844
|
}
|
|
18845
18845
|
let result;
|
|
18846
18846
|
if (!cb) {
|
|
18847
|
-
result = new this._Promise(function(
|
|
18848
|
-
cb = (err) => err ? reject(err) :
|
|
18847
|
+
result = new this._Promise(function(resolve12, reject) {
|
|
18848
|
+
cb = (err) => err ? reject(err) : resolve12();
|
|
18849
18849
|
});
|
|
18850
18850
|
}
|
|
18851
18851
|
this.native.end(function() {
|
|
@@ -20294,7 +20294,7 @@ function chunkId(projectId, path, chunkIndex, startLine, endLine) {
|
|
|
20294
20294
|
return createHash4("sha256").update(`${projectId}:${path}:${chunkIndex}:${startLine}:${endLine}`).digest("hex");
|
|
20295
20295
|
}
|
|
20296
20296
|
function yieldToEventLoop() {
|
|
20297
|
-
return new Promise((
|
|
20297
|
+
return new Promise((resolve12) => setTimeout(resolve12, 10));
|
|
20298
20298
|
}
|
|
20299
20299
|
function walkMdFiles(dir, acc, cap = MAX_FILES_PER_PROJECT, depth = 0) {
|
|
20300
20300
|
const results = acc ?? [];
|
|
@@ -22182,7 +22182,7 @@ var init_ntfy = __esm({
|
|
|
22182
22182
|
import { connect } from "node:net";
|
|
22183
22183
|
import { randomUUID } from "node:crypto";
|
|
22184
22184
|
function callHub(method, params) {
|
|
22185
|
-
return new Promise((
|
|
22185
|
+
return new Promise((resolve12) => {
|
|
22186
22186
|
let done = false;
|
|
22187
22187
|
let buffer = "";
|
|
22188
22188
|
let timer = null;
|
|
@@ -22197,7 +22197,7 @@ function callHub(method, params) {
|
|
|
22197
22197
|
socket?.destroy();
|
|
22198
22198
|
} catch {
|
|
22199
22199
|
}
|
|
22200
|
-
|
|
22200
|
+
resolve12(ok);
|
|
22201
22201
|
}
|
|
22202
22202
|
const socket = connect(hubSocket(), () => {
|
|
22203
22203
|
const request = {
|
|
@@ -22277,14 +22277,14 @@ var init_macos = __esm({
|
|
|
22277
22277
|
payload.message,
|
|
22278
22278
|
title
|
|
22279
22279
|
];
|
|
22280
|
-
return new Promise((
|
|
22280
|
+
return new Promise((resolve12) => {
|
|
22281
22281
|
const child = spawn("osascript", args, {
|
|
22282
22282
|
detached: true,
|
|
22283
22283
|
stdio: "ignore"
|
|
22284
22284
|
});
|
|
22285
22285
|
child.unref();
|
|
22286
|
-
child.on("error", () =>
|
|
22287
|
-
setTimeout(() =>
|
|
22286
|
+
child.on("error", () => resolve12(false));
|
|
22287
|
+
setTimeout(() => resolve12(true), 200);
|
|
22288
22288
|
});
|
|
22289
22289
|
} catch {
|
|
22290
22290
|
return false;
|
|
@@ -22802,13 +22802,13 @@ var require_backup = __commonJS({
|
|
|
22802
22802
|
var runBackup = (backup, handler) => {
|
|
22803
22803
|
let rate = 0;
|
|
22804
22804
|
let useDefault = true;
|
|
22805
|
-
return new Promise((
|
|
22805
|
+
return new Promise((resolve12, reject) => {
|
|
22806
22806
|
setImmediate(function step() {
|
|
22807
22807
|
try {
|
|
22808
22808
|
const progress = backup.transfer(rate);
|
|
22809
22809
|
if (!progress.remainingPages) {
|
|
22810
22810
|
backup.close();
|
|
22811
|
-
|
|
22811
|
+
resolve12(progress);
|
|
22812
22812
|
return;
|
|
22813
22813
|
}
|
|
22814
22814
|
if (useDefault) {
|
|
@@ -26553,15 +26553,15 @@ __export(detect_exports, {
|
|
|
26553
26553
|
formatDetection: () => formatDetection,
|
|
26554
26554
|
formatDetectionJson: () => formatDetectionJson
|
|
26555
26555
|
});
|
|
26556
|
-
import { resolve as
|
|
26556
|
+
import { resolve as resolve5 } from "node:path";
|
|
26557
26557
|
async function detectProject(cwd) {
|
|
26558
|
-
const target =
|
|
26558
|
+
const target = resolve5(cwd ?? process.cwd());
|
|
26559
26559
|
const backend = await getRegistryBackend();
|
|
26560
26560
|
const projects = await backend.listProjectsByPathLengthDesc({ excludeArchived: true });
|
|
26561
26561
|
let matched = null;
|
|
26562
26562
|
let matchType = "exact";
|
|
26563
26563
|
for (const p of projects) {
|
|
26564
|
-
const root =
|
|
26564
|
+
const root = resolve5(p.root_path);
|
|
26565
26565
|
if (target === root) {
|
|
26566
26566
|
matched = p;
|
|
26567
26567
|
matchType = "exact";
|
|
@@ -26576,7 +26576,7 @@ async function detectProject(cwd) {
|
|
|
26576
26576
|
if (!matched) return null;
|
|
26577
26577
|
const sessionCount = await backend.countSessionsForProject(matched.id);
|
|
26578
26578
|
const lastDate = await backend.getMostRecentSessionDate(matched.id);
|
|
26579
|
-
const relative4 = matchType === "parent" ? target.slice(
|
|
26579
|
+
const relative4 = matchType === "parent" ? target.slice(resolve5(matched.root_path).length + 1) : null;
|
|
26580
26580
|
return {
|
|
26581
26581
|
id: matched.id,
|
|
26582
26582
|
slug: matched.slug,
|
|
@@ -26632,7 +26632,7 @@ var init_detect = __esm({
|
|
|
26632
26632
|
});
|
|
26633
26633
|
|
|
26634
26634
|
// src/cli/lib/utils.ts
|
|
26635
|
-
import { resolve as
|
|
26635
|
+
import { resolve as resolve6, basename as basename6, join as join30 } from "node:path";
|
|
26636
26636
|
import { mkdirSync as mkdirSync21, existsSync as existsSync31, writeFileSync as writeFileSync18, readdirSync as readdirSync8, statSync as statSync10 } from "node:fs";
|
|
26637
26637
|
function encIndex(entries) {
|
|
26638
26638
|
let idx = indexes.get(entries);
|
|
@@ -27968,11 +27968,11 @@ var init_run_env = __esm({
|
|
|
27968
27968
|
// src/router/supervisor.ts
|
|
27969
27969
|
import { connect as connect2 } from "node:net";
|
|
27970
27970
|
function probeRouter(port2 = routerPort(), timeoutMs = LOCAL_PROBE_TIMEOUT_MS) {
|
|
27971
|
-
return new Promise((
|
|
27971
|
+
return new Promise((resolve12) => {
|
|
27972
27972
|
const sock = connect2({ host: LOOPBACK_HOST, port: port2 });
|
|
27973
27973
|
const done = (up) => {
|
|
27974
27974
|
sock.destroy();
|
|
27975
|
-
|
|
27975
|
+
resolve12(up);
|
|
27976
27976
|
};
|
|
27977
27977
|
sock.setTimeout(timeoutMs, () => done(false));
|
|
27978
27978
|
sock.once("connect", () => done(true));
|
|
@@ -28525,7 +28525,7 @@ function sayToWorker(logDir2, id, text, timeoutMs = 4e3) {
|
|
|
28525
28525
|
new Error(`worker ${id} has no operator socket (${path}) \u2014 it may predate this PAI version`)
|
|
28526
28526
|
);
|
|
28527
28527
|
}
|
|
28528
|
-
return new Promise((
|
|
28528
|
+
return new Promise((resolve12, reject) => {
|
|
28529
28529
|
const sock = connect3(path);
|
|
28530
28530
|
const fail = (e) => {
|
|
28531
28531
|
sock.destroy();
|
|
@@ -28539,7 +28539,7 @@ function sayToWorker(logDir2, id, text, timeoutMs = 4e3) {
|
|
|
28539
28539
|
sock.once("data", (d) => {
|
|
28540
28540
|
sock.end();
|
|
28541
28541
|
const reply = d.toString("utf8").trim();
|
|
28542
|
-
if (reply === "ok")
|
|
28542
|
+
if (reply === "ok") resolve12("ok");
|
|
28543
28543
|
else reject(new Error(`worker ${id} did not take the message: ${reply.replace(/^err /, "") || "no acknowledgement"}`));
|
|
28544
28544
|
});
|
|
28545
28545
|
sock.once("close", () => fail(new Error("connection closed before the worker acknowledged")));
|
|
@@ -28657,10 +28657,10 @@ var init_pending = __esm({
|
|
|
28657
28657
|
// src/workers/worktree.ts
|
|
28658
28658
|
import { execFile as execFile2, execFileSync as execFileSync11, spawnSync as spawnSync3 } from "node:child_process";
|
|
28659
28659
|
import { existsSync as existsSync44, lstatSync, mkdirSync as mkdirSync28, readFileSync as readFileSync43, mkdtempSync as mkdtempSync2, writeFileSync as writeFileSync23, readdirSync as readdirSync13, readlinkSync, realpathSync as realpathSync2, rmSync as rmSync9, statSync as statSync15 } from "node:fs";
|
|
28660
|
-
import { basename as basename8, dirname as dirname22, isAbsolute as isAbsolute2, join as join43, resolve as
|
|
28660
|
+
import { basename as basename8, dirname as dirname22, isAbsolute as isAbsolute2, join as join43, resolve as resolve7, sep as sep2 } from "node:path";
|
|
28661
28661
|
import { tmpdir as tmpdir3, platform } from "node:os";
|
|
28662
28662
|
function isSlotWorktree(dir) {
|
|
28663
|
-
return basename8(dirname22(
|
|
28663
|
+
return basename8(dirname22(resolve7(dir))) === "slots";
|
|
28664
28664
|
}
|
|
28665
28665
|
function worktreesDir(logDir2) {
|
|
28666
28666
|
return join43(logDir2, "worktrees");
|
|
@@ -28783,7 +28783,7 @@ function isPaiBookkeepingPath(path) {
|
|
|
28783
28783
|
function ensureScratchExcluded(cwd) {
|
|
28784
28784
|
try {
|
|
28785
28785
|
const rel = git(cwd, ["rev-parse", "--git-path", "info/exclude"]);
|
|
28786
|
-
const file = isAbsolute2(rel) ? rel :
|
|
28786
|
+
const file = isAbsolute2(rel) ? rel : resolve7(cwd, rel);
|
|
28787
28787
|
const cur = existsSync44(file) ? readFileSync43(file, "utf8") : "";
|
|
28788
28788
|
if (cur.split("\n").some((l) => l.trim() === ".pai-scratch/")) return;
|
|
28789
28789
|
mkdirSync28(dirname22(file), { recursive: true });
|
|
@@ -28981,7 +28981,7 @@ function transcriptWrites(logDir2, id, dir) {
|
|
|
28981
28981
|
} catch {
|
|
28982
28982
|
return [];
|
|
28983
28983
|
}
|
|
28984
|
-
const roots = [
|
|
28984
|
+
const roots = [resolve7(dir)];
|
|
28985
28985
|
try {
|
|
28986
28986
|
roots.push(realpathSync2(dir));
|
|
28987
28987
|
} catch {
|
|
@@ -28996,7 +28996,7 @@ function transcriptWrites(logDir2, id, dir) {
|
|
|
28996
28996
|
if (b?.type !== "tool_use" || !["Write", "Edit", "MultiEdit", "NotebookEdit"].includes(b.name ?? "")) continue;
|
|
28997
28997
|
const fp = b.input?.file_path;
|
|
28998
28998
|
if (typeof fp !== "string") continue;
|
|
28999
|
-
const abs =
|
|
28999
|
+
const abs = resolve7(fp);
|
|
29000
29000
|
if (roots.some((r) => abs.startsWith(r + sep2))) out.add(abs);
|
|
29001
29001
|
}
|
|
29002
29002
|
} catch {
|
|
@@ -29025,7 +29025,7 @@ function worktreeKnowledge(logDir2, id, dir, base) {
|
|
|
29025
29025
|
} catch {
|
|
29026
29026
|
}
|
|
29027
29027
|
k.ignored = ignoredKnowledge(dir);
|
|
29028
|
-
const root =
|
|
29028
|
+
const root = resolve7(dir);
|
|
29029
29029
|
for (const abs of transcriptWrites(logDir2, id, dir)) {
|
|
29030
29030
|
if (existsSync44(abs)) continue;
|
|
29031
29031
|
const rel = abs.startsWith(root + sep2) ? abs.slice(root.length + 1) : abs;
|
|
@@ -29066,7 +29066,7 @@ function symlinkEscapesWorktree(wtDir, relPath) {
|
|
|
29066
29066
|
}
|
|
29067
29067
|
if (!stat.isSymbolicLink()) return false;
|
|
29068
29068
|
const target = readlinkSync(full);
|
|
29069
|
-
const resolvedTarget = isAbsolute2(target) ? target :
|
|
29069
|
+
const resolvedTarget = isAbsolute2(target) ? target : resolve7(dirname22(full), target);
|
|
29070
29070
|
const realTarget = existsSync44(resolvedTarget) ? realpathSync2(resolvedTarget) : resolvedTarget;
|
|
29071
29071
|
const realWtDir = realpathSync2(wtDir);
|
|
29072
29072
|
return realTarget !== realWtDir && !realTarget.startsWith(realWtDir + sep2);
|
|
@@ -29321,7 +29321,7 @@ function mergeWorker(logDir2, id, opts = {}) {
|
|
|
29321
29321
|
let files = [];
|
|
29322
29322
|
let inProgress = false;
|
|
29323
29323
|
try {
|
|
29324
|
-
inProgress = existsSync44(
|
|
29324
|
+
inProgress = existsSync44(resolve7(st.cwd, git(st.cwd, ["rev-parse", "--git-path", "MERGE_HEAD"])));
|
|
29325
29325
|
if (inProgress) files = git(st.cwd, ["diff", "--name-only", "--diff-filter=U"]).split("\n").filter(Boolean);
|
|
29326
29326
|
} catch {
|
|
29327
29327
|
}
|
|
@@ -29521,7 +29521,7 @@ function branchArchived(repo, branchRef, refs) {
|
|
|
29521
29521
|
function commonDir(dir) {
|
|
29522
29522
|
try {
|
|
29523
29523
|
const raw = git(dir, ["rev-parse", "--git-common-dir"]);
|
|
29524
|
-
return isAbsolute2(raw) ? raw :
|
|
29524
|
+
return isAbsolute2(raw) ? raw : resolve7(dir, raw);
|
|
29525
29525
|
} catch {
|
|
29526
29526
|
return null;
|
|
29527
29527
|
}
|
|
@@ -29613,7 +29613,7 @@ function archiveWorktree(logDir2, id, dir, branch) {
|
|
|
29613
29613
|
let repo;
|
|
29614
29614
|
try {
|
|
29615
29615
|
const raw = git(dir, ["rev-parse", "--git-common-dir"]);
|
|
29616
|
-
repo = isAbsolute2(raw) ? raw :
|
|
29616
|
+
repo = isAbsolute2(raw) ? raw : resolve7(dir, raw);
|
|
29617
29617
|
} catch {
|
|
29618
29618
|
throw new Error("not a git worktree");
|
|
29619
29619
|
}
|
|
@@ -29713,7 +29713,7 @@ function archiveSlotBranch(logDir2, st, tree, dryRun, report, out) {
|
|
|
29713
29713
|
let repo;
|
|
29714
29714
|
try {
|
|
29715
29715
|
const raw = git(st.cwd, ["rev-parse", "--git-common-dir"]);
|
|
29716
|
-
repo = isAbsolute2(raw) ? raw :
|
|
29716
|
+
repo = isAbsolute2(raw) ? raw : resolve7(st.cwd, raw);
|
|
29717
29717
|
git(repo, ["rev-parse", "--verify", "-q", `refs/heads/${tree.branch}`]);
|
|
29718
29718
|
} catch {
|
|
29719
29719
|
return;
|
|
@@ -29762,13 +29762,13 @@ function gcForeign(logDir2, repo, owned, dryRun, report, out, archive) {
|
|
|
29762
29762
|
} catch {
|
|
29763
29763
|
return;
|
|
29764
29764
|
}
|
|
29765
|
-
const pai2 =
|
|
29765
|
+
const pai2 = resolve7(logDir2);
|
|
29766
29766
|
const blocks = raw.split("\n\n").map((b) => b.trim()).filter(Boolean);
|
|
29767
29767
|
blocks.slice(1).forEach((block) => {
|
|
29768
29768
|
const field = (k) => block.split("\n").find((l) => l.startsWith(k + " "))?.slice(k.length + 1);
|
|
29769
29769
|
const dir = field("worktree");
|
|
29770
29770
|
if (!dir || !existsSync44(dir) || block.includes("\nprunable")) return;
|
|
29771
|
-
const real =
|
|
29771
|
+
const real = resolve7(dir);
|
|
29772
29772
|
if (owned.has(real) || real === pai2 || real.startsWith(pai2 + sep2) || isSlotWorktree(real)) return;
|
|
29773
29773
|
const ref = field("branch");
|
|
29774
29774
|
const branch = ref?.replace(/^refs\/heads\//, "");
|
|
@@ -29788,7 +29788,7 @@ function realpathOr(p) {
|
|
|
29788
29788
|
try {
|
|
29789
29789
|
return realpathSync2(p);
|
|
29790
29790
|
} catch {
|
|
29791
|
-
return
|
|
29791
|
+
return resolve7(p);
|
|
29792
29792
|
}
|
|
29793
29793
|
}
|
|
29794
29794
|
function gcScratchTrees(statuses, owned, extraRepos, out, archive) {
|
|
@@ -29894,7 +29894,7 @@ function gcWorktrees(logDir2, olderThanHours = 24, dryRun = false, now = Date.no
|
|
|
29894
29894
|
const out = [];
|
|
29895
29895
|
const root = worktreesDir(logDir2);
|
|
29896
29896
|
const statuses = loadStatuses(logDir2);
|
|
29897
|
-
const owned = new Set(statuses.map((s) => ownedTree(s)?.dir).filter((d) => !!d).map((d) =>
|
|
29897
|
+
const owned = new Set(statuses.map((s) => ownedTree(s)?.dir).filter((d) => !!d).map((d) => resolve7(d)));
|
|
29898
29898
|
const archive = (id, dir, branch, st) => {
|
|
29899
29899
|
const target = `refs/pai-archive/${id}`;
|
|
29900
29900
|
if (!isRealWorktree(dir)) return void out.push({ id, skipped: "not a worktree" });
|
|
@@ -29968,7 +29968,7 @@ function gcWorktrees(logDir2, olderThanHours = 24, dryRun = false, now = Date.no
|
|
|
29968
29968
|
if (existsSync44(root)) {
|
|
29969
29969
|
for (const ent of readdirSync13(root, { withFileTypes: true })) {
|
|
29970
29970
|
const dir = join43(root, ent.name);
|
|
29971
|
-
if (!ent.isDirectory() || owned.has(
|
|
29971
|
+
if (!ent.isDirectory() || owned.has(resolve7(dir)) || isSlotWorktree(dir) || ent.name.startsWith("spare-") || landed.has(realpathOr(dir))) continue;
|
|
29972
29972
|
try {
|
|
29973
29973
|
if (Math.floor(statSync15(dir).mtimeMs) > cutoff) continue;
|
|
29974
29974
|
} catch {
|
|
@@ -30050,7 +30050,7 @@ __export(aibroker_client_exports, {
|
|
|
30050
30050
|
import { connect as connect4 } from "node:net";
|
|
30051
30051
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
30052
30052
|
function callAiBroker(method, params = {}, timeoutMs = 8e3, caller = {}) {
|
|
30053
|
-
return new Promise((
|
|
30053
|
+
return new Promise((resolve12, reject) => {
|
|
30054
30054
|
const socketPath = brokerSocket();
|
|
30055
30055
|
let done = false;
|
|
30056
30056
|
let buffer = "";
|
|
@@ -30067,7 +30067,7 @@ function callAiBroker(method, params = {}, timeoutMs = 8e3, caller = {}) {
|
|
|
30067
30067
|
} catch {
|
|
30068
30068
|
}
|
|
30069
30069
|
if (err) reject(err);
|
|
30070
|
-
else
|
|
30070
|
+
else resolve12(value);
|
|
30071
30071
|
}
|
|
30072
30072
|
const socket = connect4(socketPath, () => {
|
|
30073
30073
|
const request = {
|
|
@@ -30443,7 +30443,7 @@ var init_kill_tree = __esm({
|
|
|
30443
30443
|
// src/workers/reap.ts
|
|
30444
30444
|
import { execFileSync as execFileSync13 } from "node:child_process";
|
|
30445
30445
|
import { existsSync as existsSync45, readdirSync as readdirSync14, realpathSync as realpathSync3 } from "node:fs";
|
|
30446
|
-
import { join as join45, resolve as
|
|
30446
|
+
import { join as join45, resolve as resolve8, sep as sep3 } from "node:path";
|
|
30447
30447
|
function commandOf(pid) {
|
|
30448
30448
|
try {
|
|
30449
30449
|
return execFileSync13("ps", ["-o", "command=", "-p", String(pid)], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
@@ -30775,12 +30775,12 @@ function proxyPidPath(logDir2) {
|
|
|
30775
30775
|
return join47(logDir2, "proxy.pid");
|
|
30776
30776
|
}
|
|
30777
30777
|
function proxyListening(port2 = proxyPort(), timeoutMs = 400) {
|
|
30778
|
-
return new Promise((
|
|
30778
|
+
return new Promise((resolve12) => {
|
|
30779
30779
|
const sock = connect5({ port: port2, host: HOST });
|
|
30780
30780
|
const done = (ok) => {
|
|
30781
30781
|
sock.removeAllListeners();
|
|
30782
30782
|
sock.destroy();
|
|
30783
|
-
|
|
30783
|
+
resolve12(ok);
|
|
30784
30784
|
};
|
|
30785
30785
|
sock.setTimeout(timeoutMs, () => done(false));
|
|
30786
30786
|
sock.once("connect", () => done(true));
|
|
@@ -31092,9 +31092,9 @@ async function reaskAg2Report(a) {
|
|
|
31092
31092
|
proc.stdout.on("data", (chunk) => {
|
|
31093
31093
|
out += chunk.toString("utf8");
|
|
31094
31094
|
});
|
|
31095
|
-
await new Promise((
|
|
31096
|
-
proc.on("error", () =>
|
|
31097
|
-
proc.on("close", () =>
|
|
31095
|
+
await new Promise((resolve12) => {
|
|
31096
|
+
proc.on("error", () => resolve12());
|
|
31097
|
+
proc.on("close", () => resolve12());
|
|
31098
31098
|
});
|
|
31099
31099
|
clearTimeout(timer);
|
|
31100
31100
|
return resultFromOutput(out);
|
|
@@ -31623,16 +31623,16 @@ async function openOwnedPane(o) {
|
|
|
31623
31623
|
let session;
|
|
31624
31624
|
let sock = null;
|
|
31625
31625
|
let server;
|
|
31626
|
-
const connected = new Promise((
|
|
31626
|
+
const connected = new Promise((resolve12) => {
|
|
31627
31627
|
server = createServer2((s2) => {
|
|
31628
31628
|
sock = s2;
|
|
31629
31629
|
server.close();
|
|
31630
|
-
|
|
31630
|
+
resolve12(s2);
|
|
31631
31631
|
});
|
|
31632
31632
|
});
|
|
31633
|
-
await new Promise((
|
|
31633
|
+
await new Promise((resolve12, reject) => {
|
|
31634
31634
|
server.once("error", reject);
|
|
31635
|
-
server.listen(sockPath(o.id),
|
|
31635
|
+
server.listen(sockPath(o.id), resolve12);
|
|
31636
31636
|
});
|
|
31637
31637
|
const fail = async (e) => {
|
|
31638
31638
|
server.close();
|
|
@@ -31911,14 +31911,14 @@ function pickSplit(panes, hostId) {
|
|
|
31911
31911
|
return best ? { id: best.id, dir: best.dir, cols: best.cols, rows: best.rows, small: true } : null;
|
|
31912
31912
|
}
|
|
31913
31913
|
function osascript(script, args) {
|
|
31914
|
-
return new Promise((
|
|
31914
|
+
return new Promise((resolve12, reject) => {
|
|
31915
31915
|
const proc = spawn4("osascript", ["-l", "JavaScript", "-", ...args], { stdio: ["pipe", "pipe", "pipe"] });
|
|
31916
31916
|
let out = "";
|
|
31917
31917
|
let err = "";
|
|
31918
31918
|
proc.stdout.on("data", (c) => out += c.toString("utf8"));
|
|
31919
31919
|
proc.stderr.on("data", (c) => err += c.toString("utf8"));
|
|
31920
31920
|
proc.on("error", reject);
|
|
31921
|
-
proc.on("close", () =>
|
|
31921
|
+
proc.on("close", () => resolve12({ stdout: out, stderr: err }));
|
|
31922
31922
|
proc.stdin.write(script);
|
|
31923
31923
|
proc.stdin.end();
|
|
31924
31924
|
});
|
|
@@ -33155,18 +33155,18 @@ var init_browser_tools = __esm({
|
|
|
33155
33155
|
});
|
|
33156
33156
|
|
|
33157
33157
|
// src/workers/project-config.ts
|
|
33158
|
-
import { resolve as
|
|
33158
|
+
import { resolve as resolve9 } from "node:path";
|
|
33159
33159
|
function asStringArray(v) {
|
|
33160
33160
|
if (!Array.isArray(v)) return void 0;
|
|
33161
33161
|
const out = v.filter((x) => typeof x === "string");
|
|
33162
33162
|
return out.length ? out : void 0;
|
|
33163
33163
|
}
|
|
33164
33164
|
async function projectLaunchConfig(cwd, registry) {
|
|
33165
|
-
const target =
|
|
33165
|
+
const target = resolve9(cwd);
|
|
33166
33166
|
const backend = registry ?? await getRegistryBackend();
|
|
33167
33167
|
const rows = await backend.listProjectsByPathLengthDesc({ excludeArchived: true });
|
|
33168
33168
|
for (const row of rows) {
|
|
33169
|
-
const root =
|
|
33169
|
+
const root = resolve9(row.root_path);
|
|
33170
33170
|
if (target !== root && !target.startsWith(root + "/")) continue;
|
|
33171
33171
|
if (!row.session_config) return null;
|
|
33172
33172
|
let parsed;
|
|
@@ -33441,7 +33441,7 @@ var init_execute_prepare = __esm({
|
|
|
33441
33441
|
|
|
33442
33442
|
// src/workers/edit-assist.ts
|
|
33443
33443
|
import { readFileSync as readFileSync49 } from "node:fs";
|
|
33444
|
-
import { resolve as
|
|
33444
|
+
import { resolve as resolve10 } from "node:path";
|
|
33445
33445
|
function editAssist(i) {
|
|
33446
33446
|
if (i.errorText.includes("No changes to make: old_string and new_string are exactly the same")) {
|
|
33447
33447
|
return "old_string and new_string are identical: the file already contains your intended text; check whether this step is done (grep for it) before editing again.";
|
|
@@ -33549,7 +33549,7 @@ function editHintFor(input, errorText, cwd) {
|
|
|
33549
33549
|
let fileText = null;
|
|
33550
33550
|
if (typeof i.file_path === "string") {
|
|
33551
33551
|
try {
|
|
33552
|
-
fileText = readFileSync49(
|
|
33552
|
+
fileText = readFileSync49(resolve10(cwd, i.file_path), "utf8");
|
|
33553
33553
|
} catch {
|
|
33554
33554
|
fileText = null;
|
|
33555
33555
|
}
|
|
@@ -34811,14 +34811,14 @@ async function foldRun(a, p) {
|
|
|
34811
34811
|
state.closeTimer = null;
|
|
34812
34812
|
}
|
|
34813
34813
|
writeEvent({ type: "operator", text, handoff: isHandoffMessage(text) });
|
|
34814
|
-
return new Promise((
|
|
34814
|
+
return new Promise((resolve12) => {
|
|
34815
34815
|
try {
|
|
34816
34816
|
stdin.write(
|
|
34817
34817
|
stdinUserMessage(operatorUserText(text)) + "\n",
|
|
34818
|
-
(e) =>
|
|
34818
|
+
(e) => resolve12(e ? `write to the worker failed: ${e.message}` : void 0)
|
|
34819
34819
|
);
|
|
34820
34820
|
} catch (e) {
|
|
34821
|
-
|
|
34821
|
+
resolve12(`write to the worker failed: ${e.message}`);
|
|
34822
34822
|
}
|
|
34823
34823
|
});
|
|
34824
34824
|
}) : null;
|
|
@@ -34942,11 +34942,11 @@ async function foldRun(a, p) {
|
|
|
34942
34942
|
}
|
|
34943
34943
|
});
|
|
34944
34944
|
}
|
|
34945
|
-
let rc = await new Promise((
|
|
34945
|
+
let rc = await new Promise((resolve12, reject) => {
|
|
34946
34946
|
const onError = (e) => void failRun(e).then(() => reject(e), () => reject(e));
|
|
34947
34947
|
if (earlyError) onError(earlyError);
|
|
34948
34948
|
else proc.on("error", onError);
|
|
34949
|
-
proc.on("close", (code) =>
|
|
34949
|
+
proc.on("close", (code) => resolve12(code ?? (state.killed ? 143 : 1)));
|
|
34950
34950
|
});
|
|
34951
34951
|
if (state.troubleTimer) clearInterval(state.troubleTimer);
|
|
34952
34952
|
if (state.trouble) {
|
|
@@ -35475,11 +35475,11 @@ async function executeCodexRun(a) {
|
|
|
35475
35475
|
saveStatus(logDir2, status);
|
|
35476
35476
|
for (const ev of fold.events.splice(0)) writeEvent(ev);
|
|
35477
35477
|
});
|
|
35478
|
-
const rc = await new Promise((
|
|
35478
|
+
const rc = await new Promise((resolve12, reject) => {
|
|
35479
35479
|
const onError = (e) => void failRun(e).then(() => reject(e), () => reject(e));
|
|
35480
35480
|
if (earlyError) onError(earlyError);
|
|
35481
35481
|
else proc.on("error", onError);
|
|
35482
|
-
proc.on("close", (code) =>
|
|
35482
|
+
proc.on("close", (code) => resolve12(code ?? (killed ? 143 : 1)));
|
|
35483
35483
|
});
|
|
35484
35484
|
const secs = Math.floor((Date.now() - t0) / 1e3);
|
|
35485
35485
|
const finalText = fold.finalText ?? "";
|
|
@@ -35577,12 +35577,12 @@ async function returnControlsIfHeld(logDir2, id) {
|
|
|
35577
35577
|
if (!id) return;
|
|
35578
35578
|
const status = loadStatus(logDir2, id);
|
|
35579
35579
|
if (!status?.controlsHeld) return;
|
|
35580
|
-
await new Promise((
|
|
35580
|
+
await new Promise((resolve12) => {
|
|
35581
35581
|
let done = false;
|
|
35582
35582
|
const finish = () => {
|
|
35583
35583
|
if (done) return;
|
|
35584
35584
|
done = true;
|
|
35585
|
-
|
|
35585
|
+
resolve12();
|
|
35586
35586
|
};
|
|
35587
35587
|
try {
|
|
35588
35588
|
const proc = spawn8("clickr", clickrControlsReturnArgv(id), { stdio: "ignore" });
|
|
@@ -36283,7 +36283,7 @@ import { openSync as openSync8, closeSync as closeSync7, writeSync as writeSync3
|
|
|
36283
36283
|
init_pai_home();
|
|
36284
36284
|
init_worktree();
|
|
36285
36285
|
import { existsSync as existsSync55, mkdirSync as mkdirSync40, writeFileSync as writeFileSync32, realpathSync as realpathSync4 } from "node:fs";
|
|
36286
|
-
import { dirname as dirname27, join as join56, resolve as
|
|
36286
|
+
import { dirname as dirname27, join as join56, resolve as resolve11, isAbsolute as isAbsolute3 } from "node:path";
|
|
36287
36287
|
function slotsDir(logDir2) {
|
|
36288
36288
|
return join56(logDir2, "slots");
|
|
36289
36289
|
}
|
|
@@ -36293,7 +36293,7 @@ function slotPath(logDir2, provider, n) {
|
|
|
36293
36293
|
function slotRepo(dir) {
|
|
36294
36294
|
try {
|
|
36295
36295
|
const raw = git(dir, ["rev-parse", "--git-common-dir"]);
|
|
36296
|
-
const resolved = isAbsolute3(raw) ? raw :
|
|
36296
|
+
const resolved = isAbsolute3(raw) ? raw : resolve11(dir, raw);
|
|
36297
36297
|
return realpathSync4(resolved);
|
|
36298
36298
|
} catch {
|
|
36299
36299
|
return null;
|
|
@@ -36306,7 +36306,7 @@ function slotServesRepo(logDir2, provider, n, repo) {
|
|
|
36306
36306
|
if (!slotRepoPath) return false;
|
|
36307
36307
|
try {
|
|
36308
36308
|
const repoCommon = git(repo, ["rev-parse", "--git-common-dir"]);
|
|
36309
|
-
const resolvedRepo = isAbsolute3(repoCommon) ? repoCommon :
|
|
36309
|
+
const resolvedRepo = isAbsolute3(repoCommon) ? repoCommon : resolve11(repo, repoCommon);
|
|
36310
36310
|
return slotRepoPath === realpathSync4(resolvedRepo);
|
|
36311
36311
|
} catch {
|
|
36312
36312
|
return false;
|
|
@@ -36477,8 +36477,8 @@ var PoolSlotSession = class {
|
|
|
36477
36477
|
this.feeding = true;
|
|
36478
36478
|
let result = null;
|
|
36479
36479
|
let resolveFeed = null;
|
|
36480
|
-
const done = new Promise((
|
|
36481
|
-
resolveFeed = () =>
|
|
36480
|
+
const done = new Promise((resolve12) => {
|
|
36481
|
+
resolveFeed = () => resolve12(result);
|
|
36482
36482
|
});
|
|
36483
36483
|
const listener = (e) => {
|
|
36484
36484
|
if (e.type === "slot-exit") {
|
|
@@ -36513,7 +36513,7 @@ var PoolSlotSession = class {
|
|
|
36513
36513
|
/** Resolves when the process exits (immediately when it already has). */
|
|
36514
36514
|
waitExit() {
|
|
36515
36515
|
if (this.exited) return Promise.resolve(this.exitCode);
|
|
36516
|
-
return new Promise((
|
|
36516
|
+
return new Promise((resolve12) => this.exitWaiters.push(resolve12));
|
|
36517
36517
|
}
|
|
36518
36518
|
/**
|
|
36519
36519
|
* Resolves on the slot's init event (or its exit, or the timeout). The
|
|
@@ -36522,7 +36522,7 @@ var PoolSlotSession = class {
|
|
|
36522
36522
|
*/
|
|
36523
36523
|
waitInit(timeoutMs) {
|
|
36524
36524
|
if (this.exited) return Promise.resolve(null);
|
|
36525
|
-
return new Promise((
|
|
36525
|
+
return new Promise((resolve12) => {
|
|
36526
36526
|
let timer = setTimeout(done, timeoutMs);
|
|
36527
36527
|
const listener = (e) => {
|
|
36528
36528
|
if (e.type === "system" && e.subtype === "init") {
|
|
@@ -36536,7 +36536,7 @@ var PoolSlotSession = class {
|
|
|
36536
36536
|
if (!timer) return;
|
|
36537
36537
|
clearTimeout(timer);
|
|
36538
36538
|
timer = null;
|
|
36539
|
-
|
|
36539
|
+
resolve12(e ?? null);
|
|
36540
36540
|
}
|
|
36541
36541
|
this.listeners.add(listener);
|
|
36542
36542
|
});
|
|
@@ -36565,20 +36565,20 @@ function routerUsageTail(file) {
|
|
|
36565
36565
|
}
|
|
36566
36566
|
}
|
|
36567
36567
|
function readBody(req, max = 8 * 1024 * 1024) {
|
|
36568
|
-
return new Promise((
|
|
36568
|
+
return new Promise((resolve12) => {
|
|
36569
36569
|
const chunks = [];
|
|
36570
36570
|
let size = 0;
|
|
36571
36571
|
req.on("data", (c) => {
|
|
36572
36572
|
size += c.length;
|
|
36573
36573
|
if (size > max) {
|
|
36574
|
-
|
|
36574
|
+
resolve12(null);
|
|
36575
36575
|
req.destroy();
|
|
36576
36576
|
return;
|
|
36577
36577
|
}
|
|
36578
36578
|
chunks.push(c);
|
|
36579
36579
|
});
|
|
36580
|
-
req.on("end", () =>
|
|
36581
|
-
req.on("error", () =>
|
|
36580
|
+
req.on("end", () => resolve12(Buffer.concat(chunks).toString("utf8")));
|
|
36581
|
+
req.on("error", () => resolve12(null));
|
|
36582
36582
|
});
|
|
36583
36583
|
}
|
|
36584
36584
|
function sendJson(res, status, body) {
|
|
@@ -37347,7 +37347,7 @@ function createPoolHost(opts = {}) {
|
|
|
37347
37347
|
}
|
|
37348
37348
|
for (const list of [...spares.values()]) for (const e of [...list]) discardSpare(e, "host shutdown");
|
|
37349
37349
|
persist();
|
|
37350
|
-
await new Promise((
|
|
37350
|
+
await new Promise((resolve12) => server.close(() => resolve12()));
|
|
37351
37351
|
};
|
|
37352
37352
|
const reapSlots = () => {
|
|
37353
37353
|
let n = 0;
|
|
@@ -37411,9 +37411,9 @@ function createPoolHost(opts = {}) {
|
|
|
37411
37411
|
return true;
|
|
37412
37412
|
}
|
|
37413
37413
|
clearReloadMarker(logDir2);
|
|
37414
|
-
await new Promise((
|
|
37415
|
-
server.once("error", () =>
|
|
37416
|
-
server.listen(port2, LOOPBACK_HOST, () =>
|
|
37414
|
+
await new Promise((resolve12) => {
|
|
37415
|
+
server.once("error", () => resolve12());
|
|
37416
|
+
server.listen(port2, LOOPBACK_HOST, () => resolve12());
|
|
37417
37417
|
});
|
|
37418
37418
|
appendLedger(ledger, "POOL-HOST-RELOAD-FAILED", { pid: process.pid, bundle: opts.bundlePath, note: why });
|
|
37419
37419
|
reloading = false;
|