@ai-development-environment/control-agent 0.0.141 → 0.0.142
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/control-agent.js +783 -242
- package/package.json +1 -1
package/dist/control-agent.js
CHANGED
|
@@ -11683,7 +11683,7 @@ function tailscaleServeRemovePayload(value) {
|
|
|
11683
11683
|
// package.json
|
|
11684
11684
|
var package_default = {
|
|
11685
11685
|
name: "@ai-development-environment/control-agent",
|
|
11686
|
-
version: "0.0.
|
|
11686
|
+
version: "0.0.142",
|
|
11687
11687
|
description: "Control agent for the AI Development Environment",
|
|
11688
11688
|
license: "MIT",
|
|
11689
11689
|
repository: {
|
|
@@ -11810,7 +11810,7 @@ import { randomUUID as randomUUID10 } from "node:crypto";
|
|
|
11810
11810
|
// src/runs/branch-naming.ts
|
|
11811
11811
|
import { mkdtemp as mkdtemp2, rm as rm7 } from "node:fs/promises";
|
|
11812
11812
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
11813
|
-
import { join as
|
|
11813
|
+
import { join as join10 } from "node:path";
|
|
11814
11814
|
|
|
11815
11815
|
// src/runs/codex-adapter.ts
|
|
11816
11816
|
import {
|
|
@@ -13166,7 +13166,9 @@ var CodexAdapter = class {
|
|
|
13166
13166
|
|
|
13167
13167
|
// src/runs/claude-adapter.ts
|
|
13168
13168
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
13169
|
+
import { stat as stat3 } from "node:fs/promises";
|
|
13169
13170
|
import { homedir as homedir5 } from "node:os";
|
|
13171
|
+
import { dirname as dirname5, join as join7 } from "node:path";
|
|
13170
13172
|
|
|
13171
13173
|
// src/runs/claude-import.ts
|
|
13172
13174
|
import { createReadStream as createReadStream3 } from "node:fs";
|
|
@@ -13194,6 +13196,83 @@ function timestamp2(value) {
|
|
|
13194
13196
|
const date = typeof value === "string" || typeof value === "number" ? new Date(value) : void 0;
|
|
13195
13197
|
return date && Number.isFinite(date.getTime()) ? date.toISOString() : void 0;
|
|
13196
13198
|
}
|
|
13199
|
+
function claudeSubagentSnapshot(nativeId, values, metadataValues = [], options = { transcriptStatus: "AVAILABLE" }) {
|
|
13200
|
+
const messages = /* @__PURE__ */ new Map();
|
|
13201
|
+
for (const value of values) {
|
|
13202
|
+
const record = asRecord(value);
|
|
13203
|
+
if ((record.type === "user" || record.type === "assistant") && typeof record.uuid === "string")
|
|
13204
|
+
messages.set(record.uuid, { ...record, agent_id: nativeId });
|
|
13205
|
+
}
|
|
13206
|
+
const records = [...messages.values()];
|
|
13207
|
+
const toolUseId = records.map((record) => record.parent_tool_use_id).find((value) => typeof value === "string" && !!value);
|
|
13208
|
+
const parentNativeId = records.map((record) => record.parent_agent_id).find((value) => typeof value === "string" && !!value);
|
|
13209
|
+
let label;
|
|
13210
|
+
let agentType;
|
|
13211
|
+
let status2;
|
|
13212
|
+
let nativeRunId;
|
|
13213
|
+
for (const value of metadataValues) {
|
|
13214
|
+
const envelope = asRecord(value);
|
|
13215
|
+
const record = envelope.raw ? asRecord(envelope.raw) : envelope;
|
|
13216
|
+
const content = asRecord(record.message).content;
|
|
13217
|
+
for (const candidate of Array.isArray(content) ? content : []) {
|
|
13218
|
+
const block = asRecord(candidate);
|
|
13219
|
+
if (block.type === "tool_use" && block.id === toolUseId && (block.name === "Agent" || block.name === "Task")) {
|
|
13220
|
+
const input = asRecord(block.input);
|
|
13221
|
+
if (typeof input.description === "string") label = input.description;
|
|
13222
|
+
if (typeof input.subagent_type === "string")
|
|
13223
|
+
agentType = input.subagent_type;
|
|
13224
|
+
}
|
|
13225
|
+
}
|
|
13226
|
+
if (record.task_id !== nativeId) continue;
|
|
13227
|
+
if (typeof record.description === "string") label ??= record.description;
|
|
13228
|
+
if (typeof record.subagent_type === "string")
|
|
13229
|
+
agentType = record.subagent_type;
|
|
13230
|
+
const runId = typeof record.run_id === "string" ? record.run_id : void 0;
|
|
13231
|
+
if (nativeRunId && (!runId || runId < nativeRunId)) continue;
|
|
13232
|
+
if (runId && runId !== nativeRunId) {
|
|
13233
|
+
nativeRunId = runId;
|
|
13234
|
+
status2 = void 0;
|
|
13235
|
+
}
|
|
13236
|
+
const state = record.status ?? asRecord(record.patch).status ?? (record.subtype === "task_started" || record.subtype === "task_progress" ? "RUNNING" : void 0);
|
|
13237
|
+
if (typeof state === "string") status2 = state.toUpperCase();
|
|
13238
|
+
}
|
|
13239
|
+
const prompt = records.filter((record) => record.type === "user").map((record) => textBlocks(asRecord(record.message).content)).find(Boolean);
|
|
13240
|
+
const replies = /* @__PURE__ */ new Map();
|
|
13241
|
+
let finalReplyId;
|
|
13242
|
+
for (const record of records) {
|
|
13243
|
+
if (record.type !== "assistant") continue;
|
|
13244
|
+
const message2 = asRecord(record.message);
|
|
13245
|
+
const reply = textBlocks(message2.content);
|
|
13246
|
+
if (reply) {
|
|
13247
|
+
const replyId = String(message2.id ?? record.uuid);
|
|
13248
|
+
const parts = replies.get(replyId) ?? /* @__PURE__ */ new Map();
|
|
13249
|
+
parts.set(String(record.uuid), reply);
|
|
13250
|
+
replies.set(replyId, parts);
|
|
13251
|
+
finalReplyId = replyId;
|
|
13252
|
+
}
|
|
13253
|
+
}
|
|
13254
|
+
const last = records.at(-1);
|
|
13255
|
+
const finished = options.transcriptStatus === "AVAILABLE" && status2 !== "RUNNING" && status2 !== "PAUSED" && last?.type === "assistant" && asRecord(last.message).stop_reason === "end_turn";
|
|
13256
|
+
return {
|
|
13257
|
+
nativeId,
|
|
13258
|
+
...nativeRunId ? { nativeRunId } : {},
|
|
13259
|
+
...parentNativeId ? { parentNativeId } : {},
|
|
13260
|
+
...toolUseId ? { toolUseId } : {},
|
|
13261
|
+
...label ? { label } : {},
|
|
13262
|
+
...agentType ? { agentType } : {},
|
|
13263
|
+
...status2 || finished ? { status: status2 ?? "COMPLETED" } : {},
|
|
13264
|
+
...prompt ? { prompt } : {},
|
|
13265
|
+
...finalReplyId && status2 !== "RUNNING" && status2 !== "PAUSED" ? { finalOutput: [...replies.get(finalReplyId).values()].join("\n\n") } : {},
|
|
13266
|
+
startedAt: timestamp2(records[0]?.timestamp),
|
|
13267
|
+
...finished ? { finishedAt: timestamp2(last?.timestamp) } : {},
|
|
13268
|
+
...options,
|
|
13269
|
+
messages: records.map((record) => ({
|
|
13270
|
+
nativeId: String(record.uuid),
|
|
13271
|
+
raw: record,
|
|
13272
|
+
createdAt: timestamp2(record.timestamp)
|
|
13273
|
+
}))
|
|
13274
|
+
};
|
|
13275
|
+
}
|
|
13197
13276
|
function claudeTranscriptMetadata(values) {
|
|
13198
13277
|
const records = values.map(asRecord);
|
|
13199
13278
|
const requests = /* @__PURE__ */ new Map();
|
|
@@ -13422,6 +13501,8 @@ import { randomBytes as Wwe } from "crypto";
|
|
|
13422
13501
|
import { closeSync as nct, constants as Gt, fchmodSync as rct, fstatSync as oct, ftruncateSync as sct, lstatSync as ict, openSync as act, readFileSync as lct, renameSync as cct, unlinkSync as uct, writeFileSync as dct } from "fs";
|
|
13423
13502
|
import { lstat as cg, open as Rd, rename as rF, stat as Vwe, unlink as Ad, writeFile as qwe } from "fs/promises";
|
|
13424
13503
|
import { basename as Ywe, join as Zwe } from "path";
|
|
13504
|
+
import { readdir as zxe, readFile as EF } from "fs/promises";
|
|
13505
|
+
import { isAbsolute as bF, join as ug, relative as CF, sep as dg } from "path";
|
|
13425
13506
|
import { randomUUID as A$e } from "crypto";
|
|
13426
13507
|
import { join as j1 } from "path";
|
|
13427
13508
|
import { lstat as s6e } from "fs/promises";
|
|
@@ -17312,6 +17393,10 @@ function Ef(e10) {
|
|
|
17312
17393
|
}
|
|
17313
17394
|
var ak = "[\\w-]{1,63}";
|
|
17314
17395
|
var AJ = new RegExp(`^${ak}$`);
|
|
17396
|
+
var RJ = /^[\w-]{1,128}$/;
|
|
17397
|
+
function eS(e10) {
|
|
17398
|
+
return RJ.test(e10);
|
|
17399
|
+
}
|
|
17315
17400
|
var DJe = new RegExp(`^a(?:${ak}-)?[0-9a-f]{16}$`);
|
|
17316
17401
|
function tS(e10, t) {
|
|
17317
17402
|
let n = Buffer.from(t.replace(/-/g, ""), "hex"), r = ik("sha1").update(n).update(Buffer.from(e10, "utf8")).digest();
|
|
@@ -30304,6 +30389,12 @@ function R0(e10, t) {
|
|
|
30304
30389
|
function DR(e10, t) {
|
|
30305
30390
|
return typeof t === "string" && e10.test(t);
|
|
30306
30391
|
}
|
|
30392
|
+
function VTe(e10) {
|
|
30393
|
+
if (e10.year !== void 0 && e10.projectKey === void 0) return Y("scope.projectKey", "required when year is given");
|
|
30394
|
+
if (e10.month !== void 0 && e10.year === void 0) return Y("scope.year", "required when month is given");
|
|
30395
|
+
if (e10.day !== void 0 && e10.month === void 0) return Y("scope.month", "required when day is given");
|
|
30396
|
+
return R0("scope", e10);
|
|
30397
|
+
}
|
|
30307
30398
|
var qTe = /^[0-9a-f]{8}$/;
|
|
30308
30399
|
function YTe(e10) {
|
|
30309
30400
|
switch (e10.namespace) {
|
|
@@ -30376,6 +30467,97 @@ function YTe(e10) {
|
|
|
30376
30467
|
}
|
|
30377
30468
|
return;
|
|
30378
30469
|
}
|
|
30470
|
+
function LR(e10) {
|
|
30471
|
+
if (typeof e10 !== "object" || e10 === null) return Y("scope", "expected a scope object");
|
|
30472
|
+
let t = QTe(e10);
|
|
30473
|
+
if (t === void 0) return Y("scope", `${String(e10.namespace)} is not a listable namespace`);
|
|
30474
|
+
return JTe(e10) ?? n0("scope", t);
|
|
30475
|
+
}
|
|
30476
|
+
var ZTe = { transcript: [["agentId", "names one agent transcript, a stream key, not a scope: narrow a scope with agentRelPath"], ["journal", "names a run journal, a stream key, not a scope: narrow a scope with agentRelPath"], ["sessionJournal", "names a session's own journal, a stream key, not a scope: the session scope lists it"]], log: [["agentId", "names one log stream, a stream key, not a scope"], ["runId", "names one log stream, a stream key, not a scope"]], sessionLog: [["logName", "names one session's log, a stream key, not a scope: a day scope lists its logs"]], task: [["taskId", "names one task value, a key, not a scope: a list scope narrows with listId only"], ["meta", "names one task value, a key, not a scope: a list scope narrows with listId only"], ["highWaterMark", "names one task value, a key, not a scope: a list scope narrows with listId only"]], mailbox: [["teammate", "names one inbox, a key, not a scope"]], cache: [["id", "names one cached value, a key, not a scope: a cache scope narrows with store only"]], pluginAssetCache: [["digest", "names one cached asset, a key, not a scope"]], fileHistory: [["backupFileName", "names one backup, a key, not a scope: a file-history scope narrows with sessionId only"]], state: [["id", "names one value, a key, not a scope"]], feedbackDraft: [["draftId", "names one draft, a key, not a scope"]], jobsRoot: [["file", "names one value, a key, not a scope"], ["draftKey", "names one value, a key, not a scope"]], plan: [["name", "names one plan, a key, not a scope"]], paste: [["id", "names one paste, a key, not a scope"]], session: [["file", "names one value, a key, not a scope"]], globalConfig: [["stamp", "names one recovery copy, a key, not a scope: the scope narrows with kind only"]], marketplaceCache: [["form", "names one of the marketplace's two engine-written files, a key, not a scope: the tree narrows with relPath only"]], memory: [], pluginCache: [], daemon: [], sidecar: [], agentMemory: [], scratch: [], userConfigDir: [], job: [], bridgeSpawn: [] };
|
|
30477
|
+
function JTe(e10) {
|
|
30478
|
+
let t = e10.namespace === "agentMemory" ? XTe(e10) : void 0;
|
|
30479
|
+
if (t !== void 0) return t;
|
|
30480
|
+
if (e10.namespace === "transcript" || e10.namespace === "sidecar") {
|
|
30481
|
+
let r = ng("scope.sessionId", e10.sessionId);
|
|
30482
|
+
if (r !== void 0) return r;
|
|
30483
|
+
}
|
|
30484
|
+
for (let [r, o] of ZTe[e10.namespace]) if (r in e10 && e10[r] !== void 0) return Y(`scope.${r}`, o);
|
|
30485
|
+
if (e10.namespace === "sidecar" && rg(e10.relPath)) return Y("scope.relPath", _d);
|
|
30486
|
+
if (e10.namespace === "sidecar" && h0(e10.relPath)) return Y("scope.relPath", m0);
|
|
30487
|
+
if (e10.namespace === "log" && e10.channel !== void 0 && !E0(e10.channel)) return Y("scope.channel", S0);
|
|
30488
|
+
if (e10.namespace === "job" && A0(e10.relPath)) return Y("scope.relPath", C0);
|
|
30489
|
+
let n = e10.namespace === "sessionLog" ? VTe(e10) : void 0;
|
|
30490
|
+
if (n !== void 0) return n;
|
|
30491
|
+
if (e10.namespace === "scratch" && e10.sessionId === void 0 && e10.relPath !== void 0) return Y("scope.relPath", "requires scope.sessionId: a scratch relPath narrows one session directory, and no cross-session prefix filter exists");
|
|
30492
|
+
if (e10.namespace === "userConfigDir" && !o0.has(e10.dir)) return Y("scope.dir", s0);
|
|
30493
|
+
if (e10.namespace === "transcript" && e10.agentRelPath !== void 0 && (e10.projectKey === void 0 || e10.sessionId === void 0)) return Y("scope.agentRelPath", "requires scope.projectKey and scope.sessionId: an agentRelPath narrows the subagents/ tree of one session directory");
|
|
30494
|
+
if (e10.namespace === "transcript" && rg(e10.agentRelPath)) return Y("scope.agentRelPath", _d);
|
|
30495
|
+
if (e10.namespace === "pluginCache") {
|
|
30496
|
+
if (e10.marketplace === void 0 && e10.plugin !== void 0) return Y("scope.plugin", "requires scope.marketplace: a plugin narrows one marketplace folder");
|
|
30497
|
+
if (e10.plugin === void 0 && e10.version !== void 0) return Y("scope.version", "requires scope.plugin: a version narrows one plugin folder");
|
|
30498
|
+
if (e10.version === void 0 && e10.relPath !== void 0) return Y("scope.relPath", "requires scope.version: a relPath narrows one version folder");
|
|
30499
|
+
}
|
|
30500
|
+
if (e10.namespace === "job" && e10.jobId === void 0 && e10.relPath !== void 0) return Y("scope.relPath", "requires scope.jobId: a job relPath narrows one job directory, and no cross-job prefix filter exists");
|
|
30501
|
+
if (e10.namespace === "transcript" && e10.projectKey === void 0 && e10.sessionId !== void 0) return Y("scope.sessionId", "requires scope.projectKey: a session narrows one project folder, and no cross-project session filter exists");
|
|
30502
|
+
if (e10.namespace === "globalConfig" && e10.kind !== void 0 && !p0(e10.kind)) return Y("scope.kind", d0);
|
|
30503
|
+
return;
|
|
30504
|
+
}
|
|
30505
|
+
function XTe(e10) {
|
|
30506
|
+
if (!c0(e10.layer)) return Y("scope.layer", "must be user, project or local");
|
|
30507
|
+
if (e10.layer === "user" && "projectKey" in e10) return Y("scope.projectKey", "the user layer is not keyed by project");
|
|
30508
|
+
if (e10.layer !== "user" && typeof e10.projectKey !== "string") return Y("scope.projectKey", "required for the project and local layers");
|
|
30509
|
+
return e10.agentType === void 0 && e10.relPath !== void 0 ? Y("scope.relPath", "requires scope.agentType: an agent-memory relPath narrows one agent directory") : void 0;
|
|
30510
|
+
}
|
|
30511
|
+
function QTe(e10) {
|
|
30512
|
+
switch (e10.namespace) {
|
|
30513
|
+
case "transcript":
|
|
30514
|
+
return [["projectKey", e10.projectKey, "optional"], ["sessionId", e10.sessionId, "optional"], ["agentRelPath", e10.agentRelPath, "optional"]];
|
|
30515
|
+
case "task":
|
|
30516
|
+
return [["listId", e10.listId, "optional"]];
|
|
30517
|
+
case "mailbox":
|
|
30518
|
+
return [["team", e10.team, "optional"]];
|
|
30519
|
+
case "memory":
|
|
30520
|
+
return [["projectKey", e10.projectKey], ["relPath", e10.relPath, "optional"]];
|
|
30521
|
+
case "pluginCache":
|
|
30522
|
+
return [["marketplace", e10.marketplace, "optional"], ["plugin", e10.plugin, "optional"], ["version", e10.version, "optional"], ["relPath", e10.relPath, "optional"]];
|
|
30523
|
+
case "marketplaceCache":
|
|
30524
|
+
return [["marketplace", e10.marketplace], ["relPath", e10.relPath, "optional"]];
|
|
30525
|
+
case "cache":
|
|
30526
|
+
return [["store", e10.store]];
|
|
30527
|
+
case "state":
|
|
30528
|
+
case "plan":
|
|
30529
|
+
case "paste":
|
|
30530
|
+
case "pluginAssetCache":
|
|
30531
|
+
case "feedbackDraft":
|
|
30532
|
+
return [];
|
|
30533
|
+
case "sidecar":
|
|
30534
|
+
return [["projectKey", e10.projectKey], ["sessionId", e10.sessionId], ["relPath", e10.relPath, "optional"]];
|
|
30535
|
+
case "agentMemory":
|
|
30536
|
+
return [["projectKey", e10.layer === "user" ? void 0 : e10.projectKey, "optional"], ["agentType", e10.agentType, "optional"], ["relPath", e10.relPath, "optional"]];
|
|
30537
|
+
case "scratch":
|
|
30538
|
+
return [["sessionId", e10.sessionId, "optional"], ["relPath", e10.relPath, "optional"]];
|
|
30539
|
+
case "userConfigDir":
|
|
30540
|
+
return [["relPath", e10.relPath, "optional"]];
|
|
30541
|
+
case "fileHistory":
|
|
30542
|
+
return [["sessionId", e10.sessionId, "optional"]];
|
|
30543
|
+
case "job":
|
|
30544
|
+
return [["jobId", e10.jobId, "optional"], ["relPath", e10.relPath, "optional"]];
|
|
30545
|
+
case "daemon":
|
|
30546
|
+
return [["relPath", e10.relPath, "optional"]];
|
|
30547
|
+
case "jobsRoot":
|
|
30548
|
+
case "session":
|
|
30549
|
+
return [];
|
|
30550
|
+
case "bridgeSpawn":
|
|
30551
|
+
return [["dir", e10.dir, "optional"]];
|
|
30552
|
+
case "globalConfig":
|
|
30553
|
+
return [["kind", e10.kind, "optional"]];
|
|
30554
|
+
case "log":
|
|
30555
|
+
return [["sessionId", e10.sessionId, "optional"]];
|
|
30556
|
+
case "sessionLog":
|
|
30557
|
+
return [["projectKey", e10.projectKey, "optional"], ["year", e10.year, "optional"], ["month", e10.month, "optional"], ["day", e10.day, "optional"]];
|
|
30558
|
+
}
|
|
30559
|
+
return;
|
|
30560
|
+
}
|
|
30379
30561
|
function twe(e10) {
|
|
30380
30562
|
let t = process.cwd();
|
|
30381
30563
|
return t.endsWith(O0) ? t + e10 : t + O0 + e10;
|
|
@@ -31553,6 +31735,158 @@ var xxe = new Exe();
|
|
|
31553
31735
|
function gl() {
|
|
31554
31736
|
return xxe.getStore() ?? new fF();
|
|
31555
31737
|
}
|
|
31738
|
+
async function AF(e10, t, n, r, o) {
|
|
31739
|
+
let s = await ws(e10, t, Hn(n), r, o);
|
|
31740
|
+
if (!s) return null;
|
|
31741
|
+
let i = s.filePath.replace(/\.jsonl$/, "");
|
|
31742
|
+
return ug(i, "subagents");
|
|
31743
|
+
}
|
|
31744
|
+
function RF(e10) {
|
|
31745
|
+
let t = CF(Et(), e10);
|
|
31746
|
+
if (t === "" || t.startsWith(`..${dg}`) || t === ".." || bF(t)) return null;
|
|
31747
|
+
let n = t.split(dg);
|
|
31748
|
+
return n.length < 4 || n[2] !== "subagents" ? null : n;
|
|
31749
|
+
}
|
|
31750
|
+
function jxe(e10) {
|
|
31751
|
+
let t = RF(e10), n = t?.at(-1);
|
|
31752
|
+
if (!t || !n?.startsWith("agent-") || !n.endsWith(".jsonl")) return null;
|
|
31753
|
+
let r = n.slice(6, -6), o = t.slice(3, -1);
|
|
31754
|
+
if (!$n([t[0], t[1], r]) || o.length > 0 && !$n(o)) return null;
|
|
31755
|
+
let s = Ut.transcript(t[0], t[1], r, o.length > 0 ? o : void 0);
|
|
31756
|
+
return zo(s) === void 0 ? s : null;
|
|
31757
|
+
}
|
|
31758
|
+
function Bxe(e10) {
|
|
31759
|
+
let t = RF(e10);
|
|
31760
|
+
if (!t) return null;
|
|
31761
|
+
let n = t.slice(2);
|
|
31762
|
+
if (!$n([t[0], t[1]]) || !$n(n)) return null;
|
|
31763
|
+
let r = Ut.sidecar(t[0], t[1], n);
|
|
31764
|
+
return zo(r) === void 0 ? r : null;
|
|
31765
|
+
}
|
|
31766
|
+
async function OF(e10, t, { rejectUnlistable: n = false } = {}) {
|
|
31767
|
+
let r = be() && t !== void 0 ? Kxe(e10) : null;
|
|
31768
|
+
if (t !== void 0 && r !== null) return Wxe(t, r, e10, Gxe, n);
|
|
31769
|
+
let o = [];
|
|
31770
|
+
async function s(i) {
|
|
31771
|
+
let a;
|
|
31772
|
+
try {
|
|
31773
|
+
a = await zxe(i, { withFileTypes: true });
|
|
31774
|
+
} catch (l) {
|
|
31775
|
+
if (n && !at(l)) throw l;
|
|
31776
|
+
return;
|
|
31777
|
+
}
|
|
31778
|
+
for (let l of a) if (l.isFile() && l.name.startsWith("agent-") && l.name.endsWith(".jsonl")) {
|
|
31779
|
+
let c = l.name.slice(6, -6);
|
|
31780
|
+
o.push({ agentId: c, filePath: ug(i, l.name) });
|
|
31781
|
+
} else if (l.isDirectory()) await s(ug(i, l.name));
|
|
31782
|
+
}
|
|
31783
|
+
return await s(e10), o;
|
|
31784
|
+
}
|
|
31785
|
+
function Kxe(e10) {
|
|
31786
|
+
let t = CF(Et(), e10);
|
|
31787
|
+
if (t === "" || t.startsWith(`..${dg}`) || bF(t)) return null;
|
|
31788
|
+
let n = t.split(dg);
|
|
31789
|
+
if (n.length !== 3 || n[2] !== "subagents" || !$n([n[0], n[1]])) return null;
|
|
31790
|
+
let r = { namespace: "transcript", projectKey: n[0], sessionId: n[1] };
|
|
31791
|
+
return LR(r) === void 0 ? r : null;
|
|
31792
|
+
}
|
|
31793
|
+
var Gxe = 1e4;
|
|
31794
|
+
async function Wxe(e10, t, n, r, o) {
|
|
31795
|
+
let s = [], i = [t], a = /* @__PURE__ */ new Set([""]), l = 0;
|
|
31796
|
+
try {
|
|
31797
|
+
while (i.length > 0) {
|
|
31798
|
+
if (++l > r) throw Error("sub-agent listing incomplete");
|
|
31799
|
+
let c = i.shift(), d = [];
|
|
31800
|
+
if ((await kr((f) => e10.listEntries(c, { skipKeyStats: true, skipScopeStats: true, ...f !== void 0 && { cursor: f } }), (f) => {
|
|
31801
|
+
for (let m of f) if (m.kind === "key" && m.key.namespace === "transcript" && m.key.agentId !== void 0 && en(m.key.agentId) && (m.key.agentRelPath === void 0 || $n(m.key.agentRelPath))) s.push({ agentId: m.key.agentId, filePath: ug(n, ...m.key.agentRelPath ?? [], `agent-${m.key.agentId}.jsonl`) });
|
|
31802
|
+
else if (m.kind === "scope" && m.scope.namespace === "transcript" && m.scope.agentRelPath !== void 0 && $n(m.scope.agentRelPath) && !a.has(m.scope.agentRelPath.join("/"))) {
|
|
31803
|
+
let g = { ...t, agentRelPath: m.scope.agentRelPath };
|
|
31804
|
+
if (LR(g) === void 0) a.add(m.scope.agentRelPath.join("/")), d.push(g);
|
|
31805
|
+
}
|
|
31806
|
+
})).status !== "done") throw Error("sub-agent listing incomplete");
|
|
31807
|
+
i.unshift(...d);
|
|
31808
|
+
}
|
|
31809
|
+
} catch (c) {
|
|
31810
|
+
if (o) throw c;
|
|
31811
|
+
return [];
|
|
31812
|
+
}
|
|
31813
|
+
return s;
|
|
31814
|
+
}
|
|
31815
|
+
function Vxe(e10) {
|
|
31816
|
+
let t = [], n = 10, r = e10.length, o = 0;
|
|
31817
|
+
while (o < r) {
|
|
31818
|
+
let s = e10.indexOf(10, o);
|
|
31819
|
+
if (s === -1) s = r;
|
|
31820
|
+
let i = o;
|
|
31821
|
+
while (i < s && e10[i] <= 32) i++;
|
|
31822
|
+
if (o = s + 1, i >= s) continue;
|
|
31823
|
+
let a = e10.toString("utf-8", i, s);
|
|
31824
|
+
try {
|
|
31825
|
+
let l = je(a), c = l.type;
|
|
31826
|
+
if ((c === "user" || c === "assistant" || c === "attachment") && typeof l.uuid === "string") t.push(l);
|
|
31827
|
+
} catch {
|
|
31828
|
+
}
|
|
31829
|
+
}
|
|
31830
|
+
return t;
|
|
31831
|
+
}
|
|
31832
|
+
function qxe(e10) {
|
|
31833
|
+
if (e10.length === 0) return [];
|
|
31834
|
+
let t = /* @__PURE__ */ new Map();
|
|
31835
|
+
for (let i of e10) t.set(i.uuid, i);
|
|
31836
|
+
let n = e10.findLast((i) => i.type === "user" || i.type === "assistant");
|
|
31837
|
+
if (!n) return [];
|
|
31838
|
+
let r = [], o = /* @__PURE__ */ new Set(), s = n;
|
|
31839
|
+
while (s) {
|
|
31840
|
+
if (o.has(s.uuid)) break;
|
|
31841
|
+
o.add(s.uuid), r.push(s), s = s.parentUuid ? t.get(s.parentUuid) : void 0;
|
|
31842
|
+
}
|
|
31843
|
+
return r.reverse(), r;
|
|
31844
|
+
}
|
|
31845
|
+
async function TF(e10, t, n, r) {
|
|
31846
|
+
if (!Ve(e10)) return [];
|
|
31847
|
+
let o = be(), s = o ? n : void 0, i = await AF(e10, t?.dir, s, o, r);
|
|
31848
|
+
if (!i) return [];
|
|
31849
|
+
return (await OF(i, s)).map((l) => l.agentId);
|
|
31850
|
+
}
|
|
31851
|
+
async function wF(e10, t, n, r, o) {
|
|
31852
|
+
if (!Ve(e10)) return [];
|
|
31853
|
+
if (!t) return [];
|
|
31854
|
+
let s = be(), i = s ? r : void 0, a = await AF(e10, n?.dir, i, s, o);
|
|
31855
|
+
if (!a) return [];
|
|
31856
|
+
let c = (await OF(a, i)).find((g) => g.agentId === t);
|
|
31857
|
+
if (!c) return [];
|
|
31858
|
+
let d, p = i !== void 0 ? jxe(c.filePath) : null;
|
|
31859
|
+
if (i !== void 0 && p !== null) try {
|
|
31860
|
+
let g = await i.read([p]), _ = g.ok ? g.value.items[0] : void 0;
|
|
31861
|
+
if (!_?.found) return [];
|
|
31862
|
+
d = Buffer.from(_.value);
|
|
31863
|
+
} catch {
|
|
31864
|
+
return [];
|
|
31865
|
+
}
|
|
31866
|
+
else try {
|
|
31867
|
+
d = await EF(c.filePath);
|
|
31868
|
+
} catch {
|
|
31869
|
+
return [];
|
|
31870
|
+
}
|
|
31871
|
+
let f, m;
|
|
31872
|
+
try {
|
|
31873
|
+
let g = c.filePath.replace(/\.jsonl$/, ".meta.json"), _ = i !== void 0 ? Bxe(g) : null, y;
|
|
31874
|
+
if (i !== void 0 && _ !== null) {
|
|
31875
|
+
let E = await i.read([_]);
|
|
31876
|
+
if (!E.ok || !E.value.items[0]?.found) throw Error("sidecar absent");
|
|
31877
|
+
y = Buffer.from(E.value.items[0].value).toString("utf-8");
|
|
31878
|
+
} else y = await EF(g, "utf-8");
|
|
31879
|
+
let S = je(y);
|
|
31880
|
+
f = S.toolUseId, m = S.parentAgentId;
|
|
31881
|
+
} catch {
|
|
31882
|
+
}
|
|
31883
|
+
return YR(d, n, f, m);
|
|
31884
|
+
}
|
|
31885
|
+
function YR(e10, t, n, r) {
|
|
31886
|
+
if (e10.length === 0) return [];
|
|
31887
|
+
let o = Vxe(e10), s = qxe(o), i = Du(n), a = typeof r === "string" && eS(r) ? r : void 0, l = FR(s, { keepMeta: true }).filter((c) => c.type === "user" || c.type === "assistant").map((c) => $R(c, i, a));
|
|
31888
|
+
return HR(l, t);
|
|
31889
|
+
}
|
|
31556
31890
|
function IF(e10, t) {
|
|
31557
31891
|
let n = e10.data;
|
|
31558
31892
|
if (n.isSidechain === true) return null;
|
|
@@ -43065,6 +43399,14 @@ async function jWt(e10) {
|
|
|
43065
43399
|
if (e10?.sessionStore) return bJe(e10.sessionStore, e10);
|
|
43066
43400
|
return X0(e10);
|
|
43067
43401
|
}
|
|
43402
|
+
async function WWt(e10, t) {
|
|
43403
|
+
if (t?.sessionStore) return wJe(t.sessionStore, e10, t.dir);
|
|
43404
|
+
return TF(e10, t);
|
|
43405
|
+
}
|
|
43406
|
+
async function VWt(e10, t, n) {
|
|
43407
|
+
if (n?.sessionStore) return xJe(n.sessionStore, e10, t, n);
|
|
43408
|
+
return wF(e10, t, n);
|
|
43409
|
+
}
|
|
43068
43410
|
function tJ(e10) {
|
|
43069
43411
|
return e10.map((t) => ae(t)).join(`
|
|
43070
43412
|
`) + `
|
|
@@ -43129,8 +43471,46 @@ async function RJe(e10, t, n) {
|
|
|
43129
43471
|
if (!o || o.length === 0) return [];
|
|
43130
43472
|
return M0(o, { limit: n.limit, offset: n.offset, includeSystemMessages: n.includeSystemMessages });
|
|
43131
43473
|
}
|
|
43474
|
+
async function wJe(e10, t, n) {
|
|
43475
|
+
if (!Ve(t)) return [];
|
|
43476
|
+
if (!e10.listSubkeys) throw Error("sessionStore.listSubkeys is not implemented -- cannot list subagents. Provide a store with a listSubkeys() method.");
|
|
43477
|
+
let r = Pn(n), o = await e10.listSubkeys({ projectKey: r, sessionId: t }), s = /* @__PURE__ */ new Set();
|
|
43478
|
+
for (let i of o) {
|
|
43479
|
+
if (!i.startsWith("subagents/")) continue;
|
|
43480
|
+
let a = i.split("/").at(-1);
|
|
43481
|
+
if (a.startsWith("agent-")) s.add(a.slice(6));
|
|
43482
|
+
}
|
|
43483
|
+
return [...s];
|
|
43484
|
+
}
|
|
43485
|
+
async function xJe(e10, t, n, r) {
|
|
43486
|
+
if (!Ve(t)) return [];
|
|
43487
|
+
if (!n) return [];
|
|
43488
|
+
let o = Pn(r.dir), s = `subagents/agent-${n}`;
|
|
43489
|
+
if (e10.listSubkeys) {
|
|
43490
|
+
let p = await e10.listSubkeys({ projectKey: o, sessionId: t }), f = `agent-${n}`, m = p.find((g) => g.startsWith("subagents/") && g.split("/").at(-1) === f);
|
|
43491
|
+
if (!m) return [];
|
|
43492
|
+
s = m;
|
|
43493
|
+
}
|
|
43494
|
+
let i = await e10.load({ projectKey: o, sessionId: t, subpath: s });
|
|
43495
|
+
if (!i || i.length === 0) return [];
|
|
43496
|
+
let a = i.findLast(df), l = typeof a?.toolUseId === "string" ? a.toolUseId : void 0, c = typeof a?.parentAgentId === "string" ? a.parentAgentId : void 0, d = i.filter((p) => !df(p));
|
|
43497
|
+
if (d.length === 0) return [];
|
|
43498
|
+
return YR(Buffer.from(tJ(d)), { limit: r.limit, offset: r.offset }, l, c);
|
|
43499
|
+
}
|
|
43132
43500
|
|
|
43133
43501
|
// src/runs/claude-adapter.ts
|
|
43502
|
+
var SUBAGENT_PAGE_SIZE = 500;
|
|
43503
|
+
var MAX_SUBAGENT_MESSAGES = 1e4;
|
|
43504
|
+
var MAX_SUBAGENT_BYTES = 8 * 1024 * 1024;
|
|
43505
|
+
var MAX_SESSION_SUBAGENT_BYTES = 32 * 1024 * 1024;
|
|
43506
|
+
var MAX_SUBAGENT_CACHE_BYTES = 64 * 1024 * 1024;
|
|
43507
|
+
function claudeMessageSummary(record) {
|
|
43508
|
+
const message2 = asRecord(record.message);
|
|
43509
|
+
const content = Array.isArray(message2.content) ? message2.content : [];
|
|
43510
|
+
return content.map(asRecord).map(
|
|
43511
|
+
(block) => block.type === "tool_use" ? String(block.name ?? "Tool call") : block.type === "tool_result" ? "Tool result" : block.type === "thinking" || block.type === "redacted_thinking" ? "Thinking" : String(block.type ?? "Claude message")
|
|
43512
|
+
).join(", ") || `Claude ${String(record.type)}`;
|
|
43513
|
+
}
|
|
43134
43514
|
function findClaudeCodeExecutable(options = {}) {
|
|
43135
43515
|
return findExecutable("claude", {
|
|
43136
43516
|
...options,
|
|
@@ -43276,6 +43656,23 @@ var ClaudeAdapter = class {
|
|
|
43276
43656
|
};
|
|
43277
43657
|
catalogPromise;
|
|
43278
43658
|
hydrationCache = /* @__PURE__ */ new Map();
|
|
43659
|
+
subagentHistoryCache = /* @__PURE__ */ new Map();
|
|
43660
|
+
subagentHistoryCacheBytes = 0;
|
|
43661
|
+
cacheSubagentHistory(key, entry) {
|
|
43662
|
+
const previous = this.subagentHistoryCache.get(key);
|
|
43663
|
+
if (previous) this.subagentHistoryCacheBytes -= previous.bytes;
|
|
43664
|
+
this.subagentHistoryCache.delete(key);
|
|
43665
|
+
if (entry) {
|
|
43666
|
+
this.subagentHistoryCache.set(key, entry);
|
|
43667
|
+
this.subagentHistoryCacheBytes += entry.bytes;
|
|
43668
|
+
}
|
|
43669
|
+
while (this.subagentHistoryCacheBytes > MAX_SUBAGENT_CACHE_BYTES) {
|
|
43670
|
+
const oldest = this.subagentHistoryCache.keys().next().value;
|
|
43671
|
+
if (oldest === void 0) break;
|
|
43672
|
+
this.subagentHistoryCacheBytes -= this.subagentHistoryCache.get(oldest).bytes;
|
|
43673
|
+
this.subagentHistoryCache.delete(oldest);
|
|
43674
|
+
}
|
|
43675
|
+
}
|
|
43279
43676
|
catalog() {
|
|
43280
43677
|
this.catalogPromise ??= (async () => {
|
|
43281
43678
|
const messages = new MessageQueue();
|
|
@@ -43337,6 +43734,7 @@ var ClaudeAdapter = class {
|
|
|
43337
43734
|
permissionMode: input.run.kind === "PLAN" ? "plan" : "bypassPermissions",
|
|
43338
43735
|
allowDangerouslySkipPermissions: input.run.kind === "SESSION",
|
|
43339
43736
|
includePartialMessages: true,
|
|
43737
|
+
forwardSubagentText: true,
|
|
43340
43738
|
env: { ...claudeEnvironment(), ...executionEnvironment() },
|
|
43341
43739
|
spawnClaudeCodeProcess: ({ command: command3, args, cwd, env, signal: signal2 }) => spawnExecutionProcess(command3, args, {
|
|
43342
43740
|
cwd,
|
|
@@ -43376,8 +43774,9 @@ var ClaudeAdapter = class {
|
|
|
43376
43774
|
try {
|
|
43377
43775
|
for await (const message2 of activeQuery) {
|
|
43378
43776
|
const record = asRecord(message2);
|
|
43777
|
+
const childMessage = typeof record.agent_id === "string" || typeof record.parent_tool_use_id === "string";
|
|
43379
43778
|
const sessionId = typeof record.session_id === "string" ? record.session_id : void 0;
|
|
43380
|
-
if (sessionId && sessionId !== nativeId) {
|
|
43779
|
+
if (sessionId && sessionId !== nativeId && !childMessage) {
|
|
43381
43780
|
nativeId = sessionId;
|
|
43382
43781
|
const version = record.subtype === "init" && typeof record.claude_code_version === "string" ? record.claude_code_version : void 0;
|
|
43383
43782
|
const path = await findClaudeSessionFile(
|
|
@@ -43394,11 +43793,14 @@ var ClaudeAdapter = class {
|
|
|
43394
43793
|
record.message ?? record.result ?? record.summary
|
|
43395
43794
|
);
|
|
43396
43795
|
const type = String(record.type ?? "message").toUpperCase();
|
|
43397
|
-
if (messageText) {
|
|
43796
|
+
if (messageText || record.type === "assistant" || record.type === "user") {
|
|
43398
43797
|
await callbacks.onEvent({
|
|
43399
43798
|
type: type === "ASSISTANT" ? "ASSISTANT" : type,
|
|
43400
|
-
summary: messageText.slice(
|
|
43401
|
-
|
|
43799
|
+
summary: (messageText || claudeMessageSummary(record)).slice(
|
|
43800
|
+
0,
|
|
43801
|
+
2e3
|
|
43802
|
+
),
|
|
43803
|
+
detailMarkdown: messageText || void 0,
|
|
43402
43804
|
raw: message2
|
|
43403
43805
|
});
|
|
43404
43806
|
} else if (record.type === "system" && record.subtype) {
|
|
@@ -43408,7 +43810,7 @@ var ClaudeAdapter = class {
|
|
|
43408
43810
|
raw: message2
|
|
43409
43811
|
});
|
|
43410
43812
|
}
|
|
43411
|
-
if (record.type === "result") {
|
|
43813
|
+
if (record.type === "result" && !childMessage) {
|
|
43412
43814
|
finalOutput = typeof record.result === "string" ? record.result : finalOutput;
|
|
43413
43815
|
for (const usage2 of claudeModelUsages(record, input.run.model)) {
|
|
43414
43816
|
await callbacks.onUsage(usage2);
|
|
@@ -43459,6 +43861,118 @@ var ClaudeAdapter = class {
|
|
|
43459
43861
|
delete(nativeId, cwd) {
|
|
43460
43862
|
return dJe(nativeId, { dir: cwd });
|
|
43461
43863
|
}
|
|
43864
|
+
async discoverSubagents(sessionId, folder, history, transcriptPath) {
|
|
43865
|
+
let ids;
|
|
43866
|
+
try {
|
|
43867
|
+
ids = await WWt(sessionId, { dir: folder });
|
|
43868
|
+
} catch {
|
|
43869
|
+
return void 0;
|
|
43870
|
+
}
|
|
43871
|
+
const children = [];
|
|
43872
|
+
let sessionBytes = 0;
|
|
43873
|
+
for (const nativeId of [...new Set(ids)]) {
|
|
43874
|
+
const cacheKey = JSON.stringify([sessionId, folder, nativeId]);
|
|
43875
|
+
let fingerprint;
|
|
43876
|
+
if (transcriptPath && !/[/\\]/.test(nativeId)) {
|
|
43877
|
+
try {
|
|
43878
|
+
const childPath = join7(
|
|
43879
|
+
dirname5(transcriptPath),
|
|
43880
|
+
sessionId,
|
|
43881
|
+
"subagents",
|
|
43882
|
+
`agent-${nativeId}`
|
|
43883
|
+
);
|
|
43884
|
+
const file = await stat3(`${childPath}.jsonl`);
|
|
43885
|
+
const metadata2 = await stat3(`${childPath}.meta.json`).catch(
|
|
43886
|
+
(error) => {
|
|
43887
|
+
if (error.code === "ENOENT")
|
|
43888
|
+
return null;
|
|
43889
|
+
throw error;
|
|
43890
|
+
}
|
|
43891
|
+
);
|
|
43892
|
+
if (file.isFile())
|
|
43893
|
+
fingerprint = `${file.size}:${file.mtimeMs}:${metadata2?.size ?? "missing"}:${metadata2?.mtimeMs ?? "missing"}`;
|
|
43894
|
+
} catch {
|
|
43895
|
+
}
|
|
43896
|
+
}
|
|
43897
|
+
const cached = this.subagentHistoryCache.get(cacheKey);
|
|
43898
|
+
if (cached && cached.fingerprint === fingerprint && sessionBytes + cached.bytes <= MAX_SESSION_SUBAGENT_BYTES) {
|
|
43899
|
+
this.cacheSubagentHistory(cacheKey, cached);
|
|
43900
|
+
children.push({
|
|
43901
|
+
nativeId,
|
|
43902
|
+
messages: cached.messages,
|
|
43903
|
+
transcriptStatus: "AVAILABLE"
|
|
43904
|
+
});
|
|
43905
|
+
sessionBytes += cached.bytes;
|
|
43906
|
+
continue;
|
|
43907
|
+
}
|
|
43908
|
+
this.cacheSubagentHistory(cacheKey);
|
|
43909
|
+
const messages = [];
|
|
43910
|
+
let transcriptStatus = "AVAILABLE";
|
|
43911
|
+
let transcriptError;
|
|
43912
|
+
let offset = 0;
|
|
43913
|
+
let childBytes = 0;
|
|
43914
|
+
try {
|
|
43915
|
+
while (offset < MAX_SUBAGENT_MESSAGES) {
|
|
43916
|
+
if (sessionBytes >= MAX_SESSION_SUBAGENT_BYTES) {
|
|
43917
|
+
transcriptStatus = messages.length ? "PARTIAL" : "UNAVAILABLE";
|
|
43918
|
+
transcriptError = "Session subagent transcript size limit reached.";
|
|
43919
|
+
break;
|
|
43920
|
+
}
|
|
43921
|
+
const limit = Math.min(
|
|
43922
|
+
SUBAGENT_PAGE_SIZE,
|
|
43923
|
+
MAX_SUBAGENT_MESSAGES - offset
|
|
43924
|
+
);
|
|
43925
|
+
const page = await VWt(sessionId, nativeId, {
|
|
43926
|
+
dir: folder,
|
|
43927
|
+
limit,
|
|
43928
|
+
offset
|
|
43929
|
+
});
|
|
43930
|
+
for (const message2 of page) {
|
|
43931
|
+
const bytes = Buffer.byteLength(JSON.stringify(message2));
|
|
43932
|
+
if (childBytes + bytes > MAX_SUBAGENT_BYTES || sessionBytes + bytes > MAX_SESSION_SUBAGENT_BYTES) {
|
|
43933
|
+
transcriptStatus = messages.length ? "PARTIAL" : "UNAVAILABLE";
|
|
43934
|
+
transcriptError = "Subagent transcript size limit reached.";
|
|
43935
|
+
break;
|
|
43936
|
+
}
|
|
43937
|
+
messages.push(message2);
|
|
43938
|
+
childBytes += bytes;
|
|
43939
|
+
sessionBytes += bytes;
|
|
43940
|
+
}
|
|
43941
|
+
if (transcriptError || page.length < limit) break;
|
|
43942
|
+
offset += page.length;
|
|
43943
|
+
if (offset >= MAX_SUBAGENT_MESSAGES) {
|
|
43944
|
+
transcriptStatus = "PARTIAL";
|
|
43945
|
+
transcriptError = "Subagent transcript message limit reached.";
|
|
43946
|
+
}
|
|
43947
|
+
}
|
|
43948
|
+
if (!messages.length && !transcriptError) {
|
|
43949
|
+
transcriptStatus = "UNAVAILABLE";
|
|
43950
|
+
transcriptError = "Subagent transcript was not found.";
|
|
43951
|
+
}
|
|
43952
|
+
} catch (error) {
|
|
43953
|
+
transcriptStatus = messages.length ? "PARTIAL" : "UNAVAILABLE";
|
|
43954
|
+
transcriptError = error instanceof Error ? error.message : "Subagent transcript failed.";
|
|
43955
|
+
}
|
|
43956
|
+
children.push({ nativeId, messages, transcriptStatus, transcriptError });
|
|
43957
|
+
if (transcriptStatus === "AVAILABLE" && fingerprint) {
|
|
43958
|
+
this.cacheSubagentHistory(cacheKey, {
|
|
43959
|
+
fingerprint,
|
|
43960
|
+
messages,
|
|
43961
|
+
bytes: childBytes
|
|
43962
|
+
});
|
|
43963
|
+
}
|
|
43964
|
+
}
|
|
43965
|
+
const metadata = [
|
|
43966
|
+
...history.events ?? [],
|
|
43967
|
+
...children.flatMap((child) => child.messages)
|
|
43968
|
+
];
|
|
43969
|
+
return children.map(
|
|
43970
|
+
(child) => claudeSubagentSnapshot(child.nativeId, child.messages, metadata, {
|
|
43971
|
+
transcriptStatus: child.transcriptStatus,
|
|
43972
|
+
transcriptError: child.transcriptError
|
|
43973
|
+
})
|
|
43974
|
+
);
|
|
43975
|
+
}
|
|
43462
43976
|
async discover(worktrees) {
|
|
43463
43977
|
const results = [];
|
|
43464
43978
|
for (const worktree of worktrees) {
|
|
@@ -43505,6 +44019,12 @@ var ClaudeAdapter = class {
|
|
|
43505
44019
|
} catch {
|
|
43506
44020
|
}
|
|
43507
44021
|
}
|
|
44022
|
+
const subagents = await this.discoverSubagents(
|
|
44023
|
+
session.sessionId,
|
|
44024
|
+
worktree.folder,
|
|
44025
|
+
history,
|
|
44026
|
+
sessionInfo.nativeTranscriptPath
|
|
44027
|
+
);
|
|
43508
44028
|
results.push({
|
|
43509
44029
|
nativeId: session.sessionId,
|
|
43510
44030
|
worktreeId: worktree.id,
|
|
@@ -43515,7 +44035,8 @@ var ClaudeAdapter = class {
|
|
|
43515
44035
|
createdAt: session.createdAt ? new Date(session.createdAt).toISOString() : void 0,
|
|
43516
44036
|
updatedAt: new Date(session.lastModified).toISOString(),
|
|
43517
44037
|
rawMetadata: session,
|
|
43518
|
-
sessionInfo
|
|
44038
|
+
sessionInfo,
|
|
44039
|
+
...subagents === void 0 ? {} : { subagents }
|
|
43519
44040
|
});
|
|
43520
44041
|
}
|
|
43521
44042
|
}
|
|
@@ -43528,7 +44049,7 @@ init_promise();
|
|
|
43528
44049
|
import { execFile as execFile2 } from "node:child_process";
|
|
43529
44050
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
43530
44051
|
import { mkdir as mkdir2, rm as rm6 } from "node:fs/promises";
|
|
43531
|
-
import { dirname as
|
|
44052
|
+
import { dirname as dirname6, join as join9 } from "node:path";
|
|
43532
44053
|
import { promisify as promisify2 } from "node:util";
|
|
43533
44054
|
|
|
43534
44055
|
// ../../node_modules/@opencode/client/dist/chunks/rpc-runtime-ve4aws36.js
|
|
@@ -43661,7 +44182,7 @@ function matchesVersion2(version, options) {
|
|
|
43661
44182
|
|
|
43662
44183
|
// ../../node_modules/@opencode/client/dist/chunks/rpc-runtime-8ye1ye6f.js
|
|
43663
44184
|
import { homedir as homedir6 } from "node:os";
|
|
43664
|
-
import { join as
|
|
44185
|
+
import { join as join8 } from "node:path";
|
|
43665
44186
|
function decide2(service, options) {
|
|
43666
44187
|
if (!matchesVersion2(service.version, options))
|
|
43667
44188
|
return { _tag: "replace", pty: service.state === "ready" ? "handoff" : "clear" };
|
|
@@ -43677,7 +44198,7 @@ function fail(message2) {
|
|
|
43677
44198
|
return { _tag: "fail", error: new Error(message2) };
|
|
43678
44199
|
}
|
|
43679
44200
|
function fallback2() {
|
|
43680
|
-
return
|
|
44201
|
+
return join8(process.env["XDG_STATE_HOME"] ?? join8(homedir6(), ".local", "state"), "opencode", "service.json");
|
|
43681
44202
|
}
|
|
43682
44203
|
function same2(left, right) {
|
|
43683
44204
|
return left.id === right.id && left.version === right.version && left.url === right.url && left.pid === right.pid;
|
|
@@ -44013,12 +44534,12 @@ var supportedOpenCodeVersion = (version) => {
|
|
|
44013
44534
|
var OpenCodeRuntime = class {
|
|
44014
44535
|
constructor(isolated = false) {
|
|
44015
44536
|
this.isolated = isolated;
|
|
44016
|
-
this.stateDirectory =
|
|
44017
|
-
|
|
44537
|
+
this.stateDirectory = join9(
|
|
44538
|
+
dirname6(configPath()),
|
|
44018
44539
|
"opencode",
|
|
44019
44540
|
isolated ? `run-${randomUUID3()}` : "agent"
|
|
44020
44541
|
);
|
|
44021
|
-
this.file =
|
|
44542
|
+
this.file = join9(this.stateDirectory, "opencode", "service.json");
|
|
44022
44543
|
}
|
|
44023
44544
|
isolated;
|
|
44024
44545
|
starting;
|
|
@@ -44064,7 +44585,7 @@ var OpenCodeRuntime = class {
|
|
|
44064
44585
|
`OpenCode >=2.1.1 <3 is required; found ${stdout.trim()}`
|
|
44065
44586
|
);
|
|
44066
44587
|
const version = stdout.trim().replace(/^(?:opencode\s+)?v?/, "");
|
|
44067
|
-
await mkdir2(
|
|
44588
|
+
await mkdir2(dirname6(this.file), { recursive: true, mode: 448 });
|
|
44068
44589
|
try {
|
|
44069
44590
|
const endpoint = await Service.ensure({
|
|
44070
44591
|
file: this.file,
|
|
@@ -44135,7 +44656,7 @@ async function generateBranchName(naming, parentSignal) {
|
|
|
44135
44656
|
),
|
|
44136
44657
|
12e4
|
|
44137
44658
|
);
|
|
44138
|
-
const directory = await mkdtemp2(
|
|
44659
|
+
const directory = await mkdtemp2(join10(tmpdir2(), "aide-branch-"));
|
|
44139
44660
|
const signal2 = controller.signal;
|
|
44140
44661
|
const adapter = naming.provider === "CODEX" ? new CodexAdapter() : naming.provider === "CLAUDE" ? new ClaudeAdapter() : null;
|
|
44141
44662
|
const runtime = naming.provider === "OPENCODE" ? new OpenCodeRuntime(true) : null;
|
|
@@ -44256,7 +44777,7 @@ var generateTicketBranch = async (payload, _timeout, signal2) => {
|
|
|
44256
44777
|
// src/handlers/commands.ts
|
|
44257
44778
|
import { chmod as chmod2, mkdtemp as mkdtemp3, realpath, rm as rm8, writeFile as writeFile4 } from "node:fs/promises";
|
|
44258
44779
|
import { homedir as homedir7, tmpdir as tmpdir3 } from "node:os";
|
|
44259
|
-
import { join as
|
|
44780
|
+
import { join as join11 } from "node:path";
|
|
44260
44781
|
|
|
44261
44782
|
// src/command-processes.ts
|
|
44262
44783
|
import { createHash as createHash4 } from "node:crypto";
|
|
@@ -44403,9 +44924,9 @@ var runCommand = async (rawPayload, _timeoutMs, signal2, _onLog, context) => {
|
|
|
44403
44924
|
throw new Error("Command output uploader is unavailable");
|
|
44404
44925
|
}
|
|
44405
44926
|
const directory = await mkdtemp3(
|
|
44406
|
-
|
|
44927
|
+
join11(tmpdir3(), commandScriptPrefix(context.agentId))
|
|
44407
44928
|
);
|
|
44408
|
-
const scriptPath =
|
|
44929
|
+
const scriptPath = join11(directory, "command.sh");
|
|
44409
44930
|
await writeFile4(scriptPath, payload.script, {
|
|
44410
44931
|
encoding: "utf8",
|
|
44411
44932
|
mode: 384
|
|
@@ -44649,9 +45170,9 @@ async function localBranchReport(folder, timeoutMs, signal2, unavailable) {
|
|
|
44649
45170
|
}
|
|
44650
45171
|
|
|
44651
45172
|
// src/handlers/codebases.ts
|
|
44652
|
-
import { readdir as readdir2, realpath as realpath3, stat as
|
|
45173
|
+
import { readdir as readdir2, realpath as realpath3, stat as stat4 } from "node:fs/promises";
|
|
44653
45174
|
import { homedir as homedir8 } from "node:os";
|
|
44654
|
-
import { dirname as
|
|
45175
|
+
import { dirname as dirname7, join as join13, resolve as resolve4 } from "node:path";
|
|
44655
45176
|
|
|
44656
45177
|
// src/repository-metadata.ts
|
|
44657
45178
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
@@ -44721,7 +45242,7 @@ async function withMetadataKey(key, task, signal2) {
|
|
|
44721
45242
|
// src/git-sync-snapshot.ts
|
|
44722
45243
|
import { readFile as readFile5, rename as rename3, rm as rm9, writeFile as writeFile5 } from "node:fs/promises";
|
|
44723
45244
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
44724
|
-
import { join as
|
|
45245
|
+
import { join as join12 } from "node:path";
|
|
44725
45246
|
async function git(folder, args, timeoutMs, signal2, allowMissing = false) {
|
|
44726
45247
|
const result = await captureCommand({
|
|
44727
45248
|
command: "git",
|
|
@@ -44851,7 +45372,7 @@ async function fetchPinnedRef(folder, remote, ref, timeoutMs, signal2) {
|
|
|
44851
45372
|
signal2
|
|
44852
45373
|
);
|
|
44853
45374
|
}
|
|
44854
|
-
var leaseFile = (gitDirectory2) =>
|
|
45375
|
+
var leaseFile = (gitDirectory2) => join12(gitDirectory2, "aide-sync-push-lease.json");
|
|
44855
45376
|
async function saveSyncPushLease(gitDirectory2, lease) {
|
|
44856
45377
|
const destination = leaseFile(gitDirectory2);
|
|
44857
45378
|
const temporary = `${destination}.${randomUUID4()}.tmp`;
|
|
@@ -44964,7 +45485,7 @@ function baseSnapshot(folder) {
|
|
|
44964
45485
|
}
|
|
44965
45486
|
async function fetchedAt(commonDirectory) {
|
|
44966
45487
|
try {
|
|
44967
|
-
return (await
|
|
45488
|
+
return (await stat4(join13(commonDirectory, "FETCH_HEAD"))).mtime.toISOString();
|
|
44968
45489
|
} catch {
|
|
44969
45490
|
return null;
|
|
44970
45491
|
}
|
|
@@ -44975,7 +45496,7 @@ async function inspectCodebaseProcess(selectedFolder, timeoutMs, signal2, expect
|
|
|
44975
45496
|
let selected;
|
|
44976
45497
|
try {
|
|
44977
45498
|
selected = await realpath3(fallbackFolder);
|
|
44978
|
-
if (!(await
|
|
45499
|
+
if (!(await stat4(selected)).isDirectory())
|
|
44979
45500
|
throw new Error("Folder is not a directory");
|
|
44980
45501
|
} catch (error) {
|
|
44981
45502
|
return {
|
|
@@ -45145,7 +45666,7 @@ var browseCodebaseDirectories = async (payload) => {
|
|
|
45145
45666
|
const input = codebaseBrowsePayload(payload);
|
|
45146
45667
|
const homePath = await realpath3(homedir8());
|
|
45147
45668
|
const path = await realpath3(input.path ? resolve4(input.path) : homePath);
|
|
45148
|
-
if (!(await
|
|
45669
|
+
if (!(await stat4(path)).isDirectory())
|
|
45149
45670
|
throw new Error("Path is not a directory");
|
|
45150
45671
|
const candidates = await readdir2(path, { withFileTypes: true });
|
|
45151
45672
|
const entries = [];
|
|
@@ -45153,13 +45674,13 @@ var browseCodebaseDirectories = async (payload) => {
|
|
|
45153
45674
|
if (candidate.isDirectory()) {
|
|
45154
45675
|
entries.push({
|
|
45155
45676
|
name: candidate.name,
|
|
45156
|
-
path:
|
|
45677
|
+
path: join13(path, candidate.name),
|
|
45157
45678
|
hidden: candidate.name.startsWith(".")
|
|
45158
45679
|
});
|
|
45159
45680
|
} else if (candidate.isSymbolicLink()) {
|
|
45160
45681
|
try {
|
|
45161
|
-
const target2 =
|
|
45162
|
-
if ((await
|
|
45682
|
+
const target2 = join13(path, candidate.name);
|
|
45683
|
+
if ((await stat4(target2)).isDirectory()) {
|
|
45163
45684
|
entries.push({
|
|
45164
45685
|
name: candidate.name,
|
|
45165
45686
|
path: target2,
|
|
@@ -45173,7 +45694,7 @@ var browseCodebaseDirectories = async (payload) => {
|
|
|
45173
45694
|
entries.sort((first, second) => first.name.localeCompare(second.name));
|
|
45174
45695
|
const listing = {
|
|
45175
45696
|
path,
|
|
45176
|
-
parentPath:
|
|
45697
|
+
parentPath: dirname7(path) === path ? null : dirname7(path),
|
|
45177
45698
|
homePath,
|
|
45178
45699
|
entries: entries.slice(0, 1e3),
|
|
45179
45700
|
truncated: entries.length > 1e3
|
|
@@ -45986,9 +46507,9 @@ import {
|
|
|
45986
46507
|
rmdir
|
|
45987
46508
|
} from "node:fs/promises";
|
|
45988
46509
|
import {
|
|
45989
|
-
dirname as
|
|
46510
|
+
dirname as dirname9,
|
|
45990
46511
|
isAbsolute as isAbsolute4,
|
|
45991
|
-
join as
|
|
46512
|
+
join as join15,
|
|
45992
46513
|
parse as parse3,
|
|
45993
46514
|
relative as relative2,
|
|
45994
46515
|
resolve as resolve6,
|
|
@@ -45998,7 +46519,7 @@ import {
|
|
|
45998
46519
|
// src/repository-coordinator.ts
|
|
45999
46520
|
import { AsyncLocalStorage as AsyncLocalStorage3 } from "node:async_hooks";
|
|
46000
46521
|
import { lstat, readlink, realpath as realpath4 } from "node:fs/promises";
|
|
46001
|
-
import { basename as basename2, dirname as
|
|
46522
|
+
import { basename as basename2, dirname as dirname8, join as join14, resolve as resolve5 } from "node:path";
|
|
46002
46523
|
async function canonicalResourcePath(path) {
|
|
46003
46524
|
const absolute = resolve5(path);
|
|
46004
46525
|
try {
|
|
@@ -46008,15 +46529,15 @@ async function canonicalResourcePath(path) {
|
|
|
46008
46529
|
try {
|
|
46009
46530
|
if ((await lstat(absolute)).isSymbolicLink())
|
|
46010
46531
|
return canonicalResourcePath(
|
|
46011
|
-
resolve5(
|
|
46532
|
+
resolve5(dirname8(absolute), await readlink(absolute))
|
|
46012
46533
|
);
|
|
46013
46534
|
} catch (linkError) {
|
|
46014
46535
|
if (linkError.code !== "ENOENT")
|
|
46015
46536
|
throw linkError;
|
|
46016
46537
|
}
|
|
46017
|
-
const parent =
|
|
46538
|
+
const parent = dirname8(absolute);
|
|
46018
46539
|
if (parent === absolute) throw error;
|
|
46019
|
-
return
|
|
46540
|
+
return join14(await canonicalResourcePath(parent), basename2(absolute));
|
|
46020
46541
|
}
|
|
46021
46542
|
}
|
|
46022
46543
|
var RepositoryCoordinator = class {
|
|
@@ -46342,7 +46863,7 @@ async function safeDirectory(path, create) {
|
|
|
46342
46863
|
const absolute = resolve6(path);
|
|
46343
46864
|
let current = parse3(absolute).root;
|
|
46344
46865
|
for (const component of absolute.slice(current.length).split(sep3).filter(Boolean)) {
|
|
46345
|
-
current =
|
|
46866
|
+
current = join15(current, component);
|
|
46346
46867
|
let info;
|
|
46347
46868
|
try {
|
|
46348
46869
|
info = await lstat2(current);
|
|
@@ -46377,7 +46898,7 @@ var inspectCloneDestination = async (value, timeoutMs, signal2) => {
|
|
|
46377
46898
|
throw new Error("Clone base directory must be absolute on this agent");
|
|
46378
46899
|
const destination = resolve6(payload.baseDirectory, payload.relativePath);
|
|
46379
46900
|
try {
|
|
46380
|
-
await safeDirectory(
|
|
46901
|
+
await safeDirectory(dirname9(destination), false);
|
|
46381
46902
|
const info = await lstat2(destination);
|
|
46382
46903
|
if (info.isSymbolicLink() || !info.isDirectory())
|
|
46383
46904
|
throw new Error(
|
|
@@ -46431,7 +46952,7 @@ var cloneCodebase = async (value, timeoutMs, signal2) => {
|
|
|
46431
46952
|
const deadline = Date.now() + timeoutMs;
|
|
46432
46953
|
const remaining = () => Math.max(0, deadline - Date.now());
|
|
46433
46954
|
await safeDirectory(payload.baseDirectory, true);
|
|
46434
|
-
const parent = await safeDirectory(
|
|
46955
|
+
const parent = await safeDirectory(dirname9(destination), true);
|
|
46435
46956
|
const parentIdentity = await lstat2(parent);
|
|
46436
46957
|
const existing = await lstat2(destination).catch((error) => {
|
|
46437
46958
|
if (missing(error)) return null;
|
|
@@ -46456,9 +46977,9 @@ var cloneCodebase = async (value, timeoutMs, signal2) => {
|
|
|
46456
46977
|
}
|
|
46457
46978
|
return { ...success, snapshot, reused: true };
|
|
46458
46979
|
}
|
|
46459
|
-
const staging = await mkdtemp4(
|
|
46980
|
+
const staging = await mkdtemp4(join15(parent, ".aide-clone-"));
|
|
46460
46981
|
const stagingIdentity = await lstat2(staging);
|
|
46461
|
-
const checkout =
|
|
46982
|
+
const checkout = join15(staging, "checkout");
|
|
46462
46983
|
const verifyStaging = async () => {
|
|
46463
46984
|
if (!await ownsDirectory(parent, parentIdentity, staging, stagingIdentity)) {
|
|
46464
46985
|
throw new Error(
|
|
@@ -46538,8 +47059,8 @@ var cloneCodebase = async (value, timeoutMs, signal2) => {
|
|
|
46538
47059
|
};
|
|
46539
47060
|
|
|
46540
47061
|
// src/handlers/coverage.ts
|
|
46541
|
-
import { readFile as readFile7, realpath as realpath7, stat as
|
|
46542
|
-
import { join as
|
|
47062
|
+
import { readFile as readFile7, realpath as realpath7, stat as stat6 } from "node:fs/promises";
|
|
47063
|
+
import { join as join17, relative as relative5, sep as sep6 } from "node:path";
|
|
46543
47064
|
|
|
46544
47065
|
// src/handlers/builds.ts
|
|
46545
47066
|
import { createHash as createHash6, randomUUID as randomUUID5 } from "node:crypto";
|
|
@@ -46553,7 +47074,7 @@ import {
|
|
|
46553
47074
|
realpath as realpath6,
|
|
46554
47075
|
rename as rename5,
|
|
46555
47076
|
rm as rm11,
|
|
46556
|
-
stat as
|
|
47077
|
+
stat as stat5,
|
|
46557
47078
|
writeFile as writeFile6
|
|
46558
47079
|
} from "node:fs/promises";
|
|
46559
47080
|
import { createReadStream as createReadStream5, createWriteStream as createWriteStream2 } from "node:fs";
|
|
@@ -46562,9 +47083,9 @@ import { pipeline } from "node:stream/promises";
|
|
|
46562
47083
|
import { StringDecoder } from "node:string_decoder";
|
|
46563
47084
|
import {
|
|
46564
47085
|
basename as basename3,
|
|
46565
|
-
dirname as
|
|
47086
|
+
dirname as dirname10,
|
|
46566
47087
|
isAbsolute as isAbsolute6,
|
|
46567
|
-
join as
|
|
47088
|
+
join as join16,
|
|
46568
47089
|
relative as relative4,
|
|
46569
47090
|
resolve as resolve8,
|
|
46570
47091
|
sep as sep5
|
|
@@ -46965,7 +47486,7 @@ function requireSuccess2(result, fallback) {
|
|
|
46965
47486
|
}
|
|
46966
47487
|
async function validateWorktree(input, timeoutMs, signal2) {
|
|
46967
47488
|
const folder = await realpath6(input.folder);
|
|
46968
|
-
if (!(await
|
|
47489
|
+
if (!(await stat5(folder)).isDirectory())
|
|
46969
47490
|
throw new Error("Worktree is missing");
|
|
46970
47491
|
const gitDirectory2 = requireSuccess2(
|
|
46971
47492
|
await command(
|
|
@@ -47012,7 +47533,7 @@ async function validateSource(root, source) {
|
|
|
47012
47533
|
if (difference === ".." || difference.startsWith(`..${sep5}`) || isAbsolute6(difference)) {
|
|
47013
47534
|
throw new Error("Build source resolves outside the worktree");
|
|
47014
47535
|
}
|
|
47015
|
-
const information = await
|
|
47536
|
+
const information = await stat5(resolved);
|
|
47016
47537
|
if (source.kind === "PACKAGE" && !information.isFile()) {
|
|
47017
47538
|
throw new Error("Package.swift is missing");
|
|
47018
47539
|
}
|
|
@@ -47028,7 +47549,7 @@ async function discoverSourcesInFolder(folder) {
|
|
|
47028
47549
|
const current = queue.shift();
|
|
47029
47550
|
for (const entry of await readdir3(current, { withFileTypes: true })) {
|
|
47030
47551
|
if (entry.isSymbolicLink()) continue;
|
|
47031
|
-
const absolute =
|
|
47552
|
+
const absolute = join16(current, entry.name);
|
|
47032
47553
|
const path = relative4(folder, absolute).split(sep5).join("/");
|
|
47033
47554
|
if (entry.isDirectory()) {
|
|
47034
47555
|
if (entry.name.endsWith(".xcodeproj")) {
|
|
@@ -47099,7 +47620,7 @@ function metadataFromList(value) {
|
|
|
47099
47620
|
};
|
|
47100
47621
|
}
|
|
47101
47622
|
async function workspaceProjectPaths(workspacePath2, folder) {
|
|
47102
|
-
const contentsPath =
|
|
47623
|
+
const contentsPath = join16(workspacePath2, "contents.xcworkspacedata");
|
|
47103
47624
|
let contents;
|
|
47104
47625
|
try {
|
|
47105
47626
|
contents = await readFile6(contentsPath, "utf8");
|
|
@@ -47120,7 +47641,7 @@ async function workspaceProjectPaths(workspacePath2, folder) {
|
|
|
47120
47641
|
}).filter((path) => path.endsWith(".xcodeproj"));
|
|
47121
47642
|
const projects = [];
|
|
47122
47643
|
for (const location of locations) {
|
|
47123
|
-
const candidate = resolve8(
|
|
47644
|
+
const candidate = resolve8(dirname10(workspacePath2), location);
|
|
47124
47645
|
const difference = relative4(folder, candidate);
|
|
47125
47646
|
if (difference === ".." || difference.startsWith(`..${sep5}`) || isAbsolute6(difference)) {
|
|
47126
47647
|
continue;
|
|
@@ -47128,7 +47649,7 @@ async function workspaceProjectPaths(workspacePath2, folder) {
|
|
|
47128
47649
|
try {
|
|
47129
47650
|
const resolved = await realpath6(candidate);
|
|
47130
47651
|
const resolvedDifference = relative4(folder, resolved);
|
|
47131
|
-
if (resolvedDifference === ".." || resolvedDifference.startsWith(`..${sep5}`) || isAbsolute6(resolvedDifference) || !(await
|
|
47652
|
+
if (resolvedDifference === ".." || resolvedDifference.startsWith(`..${sep5}`) || isAbsolute6(resolvedDifference) || !(await stat5(resolved)).isDirectory()) {
|
|
47132
47653
|
continue;
|
|
47133
47654
|
}
|
|
47134
47655
|
projects.push(resolved);
|
|
@@ -47319,7 +47840,7 @@ async function dependentSigningRequirements(source, absolutePath, folder, rootTa
|
|
|
47319
47840
|
for (const project of projects.slice(0, 50)) {
|
|
47320
47841
|
const converted = await command(
|
|
47321
47842
|
"plutil",
|
|
47322
|
-
["-convert", "json", "-o", "-",
|
|
47843
|
+
["-convert", "json", "-o", "-", join16(project, "project.pbxproj")],
|
|
47323
47844
|
Math.min(timeoutMs, 15e3),
|
|
47324
47845
|
signal2,
|
|
47325
47846
|
folder
|
|
@@ -47580,8 +48101,8 @@ function physicalDestinations(value, includeUnavailable = false) {
|
|
|
47580
48101
|
});
|
|
47581
48102
|
}
|
|
47582
48103
|
async function listPhysicalDevices(timeoutMs, signal2, includeUnavailable = false) {
|
|
47583
|
-
const directory = await mkdtemp5(
|
|
47584
|
-
const output =
|
|
48104
|
+
const directory = await mkdtemp5(join16(tmpdir4(), "ade-devices-"));
|
|
48105
|
+
const output = join16(directory, "devices.json");
|
|
47585
48106
|
try {
|
|
47586
48107
|
const result = await command(
|
|
47587
48108
|
"xcrun",
|
|
@@ -48033,7 +48554,7 @@ function actionArgument(action) {
|
|
|
48033
48554
|
}[action];
|
|
48034
48555
|
}
|
|
48035
48556
|
function xcodeBuildArguments(input) {
|
|
48036
|
-
const resultBundle =
|
|
48557
|
+
const resultBundle = join16(input.artifactDirectory, "result.xcresult");
|
|
48037
48558
|
const sourcePath = containedPath2(input.folder, input.source.relativePath);
|
|
48038
48559
|
const usesCapturedTestProducts = input.action === "TEST_WITHOUT_BUILDING";
|
|
48039
48560
|
const args = [
|
|
@@ -48056,13 +48577,13 @@ function xcodeBuildArguments(input) {
|
|
|
48056
48577
|
if (input.action === "ARCHIVE") {
|
|
48057
48578
|
args.push(
|
|
48058
48579
|
"-archivePath",
|
|
48059
|
-
|
|
48580
|
+
join16(input.artifactDirectory, "archive.xcarchive")
|
|
48060
48581
|
);
|
|
48061
48582
|
}
|
|
48062
48583
|
if (input.action === "BUILD_FOR_TESTING") {
|
|
48063
48584
|
args.push(
|
|
48064
48585
|
"-testProductsPath",
|
|
48065
|
-
|
|
48586
|
+
join16(input.artifactDirectory, "test-products.xctestproducts")
|
|
48066
48587
|
);
|
|
48067
48588
|
}
|
|
48068
48589
|
if (input.action === "TEST_WITHOUT_BUILDING" && input.advancedSettings.priorTestProductsPath) {
|
|
@@ -48126,15 +48647,15 @@ function classifyFailure(output) {
|
|
|
48126
48647
|
}
|
|
48127
48648
|
async function runHook(options) {
|
|
48128
48649
|
const phaseDirectory = options.phase === "PRE_BUILD" ? "pre" : "post";
|
|
48129
|
-
const directory =
|
|
48650
|
+
const directory = join16(
|
|
48130
48651
|
options.input.artifactDirectory,
|
|
48131
48652
|
"hooks",
|
|
48132
48653
|
phaseDirectory
|
|
48133
48654
|
);
|
|
48134
48655
|
const prefix = `${String(options.script.position).padStart(3, "0")}-${options.script.id}`;
|
|
48135
|
-
const file =
|
|
48136
|
-
const runner =
|
|
48137
|
-
const log2 =
|
|
48656
|
+
const file = join16(directory, `${prefix}.mjs`);
|
|
48657
|
+
const runner = join16(directory, `${prefix}.runner.mjs`);
|
|
48658
|
+
const log2 = join16(directory, `${prefix}.log`);
|
|
48138
48659
|
const started = Date.now();
|
|
48139
48660
|
try {
|
|
48140
48661
|
await mkdir4(directory, { recursive: true, mode: 448 });
|
|
@@ -48229,26 +48750,26 @@ if (typeof hookModule.default === "function") {
|
|
|
48229
48750
|
}
|
|
48230
48751
|
async function pathExists(path) {
|
|
48231
48752
|
try {
|
|
48232
|
-
await
|
|
48753
|
+
await stat5(path);
|
|
48233
48754
|
return true;
|
|
48234
48755
|
} catch {
|
|
48235
48756
|
return false;
|
|
48236
48757
|
}
|
|
48237
48758
|
}
|
|
48238
48759
|
async function pathSize(path) {
|
|
48239
|
-
const information = await
|
|
48760
|
+
const information = await stat5(path);
|
|
48240
48761
|
if (information.isFile()) return information.size;
|
|
48241
48762
|
if (!information.isDirectory()) return 0;
|
|
48242
48763
|
let size = 0;
|
|
48243
48764
|
for (const entry of await readdir3(path, { withFileTypes: true })) {
|
|
48244
48765
|
if (entry.isSymbolicLink()) continue;
|
|
48245
|
-
size += await pathSize(
|
|
48766
|
+
size += await pathSize(join16(path, entry.name));
|
|
48246
48767
|
}
|
|
48247
48768
|
return size;
|
|
48248
48769
|
}
|
|
48249
48770
|
async function fileChecksum(path) {
|
|
48250
48771
|
try {
|
|
48251
|
-
const information = await
|
|
48772
|
+
const information = await stat5(path);
|
|
48252
48773
|
if (!information.isFile()) return null;
|
|
48253
48774
|
const hash = createHash6("sha256");
|
|
48254
48775
|
await pipeline(createReadStream5(path), hash);
|
|
@@ -48272,7 +48793,7 @@ async function plistString(plistPath, keyPath, timeoutMs, signal2) {
|
|
|
48272
48793
|
}
|
|
48273
48794
|
}
|
|
48274
48795
|
async function archiveApplicationProperties(archivePath, timeoutMs, signal2) {
|
|
48275
|
-
const plistPath =
|
|
48796
|
+
const plistPath = join16(archivePath, "Info.plist");
|
|
48276
48797
|
const read3 = (key) => plistString(plistPath, `ApplicationProperties.${key}`, timeoutMs, signal2);
|
|
48277
48798
|
const [bundleIdentifier2, bundleShortVersion, bundleVersion, applicationPath] = await Promise.all([
|
|
48278
48799
|
read3("CFBundleIdentifier"),
|
|
@@ -48431,9 +48952,9 @@ function normalizeCoverage(value) {
|
|
|
48431
48952
|
};
|
|
48432
48953
|
}
|
|
48433
48954
|
async function writeJsonReport(input, kind, timeoutMs, signal2) {
|
|
48434
|
-
const resultBundle =
|
|
48955
|
+
const resultBundle = join16(input.artifactDirectory, "result.xcresult");
|
|
48435
48956
|
const filename = kind === "TEST_RESULTS" ? "test-results.json" : "code-coverage.json";
|
|
48436
|
-
const destination =
|
|
48957
|
+
const destination = join16(input.artifactDirectory, filename);
|
|
48437
48958
|
const temporary = `${destination}.tmp-${randomUUID5()}`;
|
|
48438
48959
|
try {
|
|
48439
48960
|
if (!await pathExists(resultBundle)) {
|
|
@@ -48575,7 +49096,7 @@ async function snapshotCoverageChangesLocked(baseBranch, folder, timeoutMs, sign
|
|
|
48575
49096
|
const types = changeTypesFromStatus(status2.stdout);
|
|
48576
49097
|
for (const path of untracked.stdout.split("\0").filter(Boolean)) {
|
|
48577
49098
|
try {
|
|
48578
|
-
const contents = await readFile6(
|
|
49099
|
+
const contents = await readFile6(join16(folder, path));
|
|
48579
49100
|
if (contents.includes(0)) continue;
|
|
48580
49101
|
const lineCount = contents.length ? contents.toString("utf8").split("\n").length - (contents.toString("utf8").endsWith("\n") ? 1 : 0) : 0;
|
|
48581
49102
|
lines.set(
|
|
@@ -48638,7 +49159,7 @@ async function addChangedCoverage(report, changes, input, folder, timeoutMs, sig
|
|
|
48638
49159
|
);
|
|
48639
49160
|
let lines = EMPTY_COVERAGE_LINES;
|
|
48640
49161
|
if (coveragePath && change.lines.length) {
|
|
48641
|
-
const temporary2 =
|
|
49162
|
+
const temporary2 = join16(
|
|
48642
49163
|
input.artifactDirectory,
|
|
48643
49164
|
`.changed-coverage-${randomUUID5()}.json`
|
|
48644
49165
|
);
|
|
@@ -48689,7 +49210,7 @@ async function addChangedCoverage(report, changes, input, folder, timeoutMs, sig
|
|
|
48689
49210
|
changedLineCoverage: changedExecutableLines ? changedCoveredLines / changedExecutableLines : null
|
|
48690
49211
|
};
|
|
48691
49212
|
const data = { ...report.data, changedFiles };
|
|
48692
|
-
const destination =
|
|
49213
|
+
const destination = join16(input.artifactDirectory, "worktree-coverage.json");
|
|
48693
49214
|
const temporary = `${destination}.tmp-${randomUUID5()}`;
|
|
48694
49215
|
await writeFile6(temporary, JSON.stringify({ summary, data }, null, 2), {
|
|
48695
49216
|
mode: 384
|
|
@@ -48743,7 +49264,7 @@ async function findFiles(root, predicate, limit = 20) {
|
|
|
48743
49264
|
}
|
|
48744
49265
|
for (const entry of entries) {
|
|
48745
49266
|
if (entry.isSymbolicLink()) continue;
|
|
48746
|
-
const path =
|
|
49267
|
+
const path = join16(current, entry.name);
|
|
48747
49268
|
if (entry.isDirectory()) queue.push(path);
|
|
48748
49269
|
else if (entry.isFile() && predicate(entry.name)) results.push(path);
|
|
48749
49270
|
if (results.length >= limit) break;
|
|
@@ -48781,18 +49302,18 @@ async function dwarfdumpUuids(paths, signal2) {
|
|
|
48781
49302
|
}
|
|
48782
49303
|
async function captureDsyms(input, entries, signal2) {
|
|
48783
49304
|
const sources = [];
|
|
48784
|
-
const archiveDsyms =
|
|
49305
|
+
const archiveDsyms = join16(
|
|
48785
49306
|
input.artifactDirectory,
|
|
48786
49307
|
"archive.xcarchive",
|
|
48787
49308
|
"dSYMs"
|
|
48788
49309
|
);
|
|
48789
49310
|
if (input.action === "ARCHIVE" && await pathExists(archiveDsyms)) {
|
|
48790
49311
|
for (const name of await readdir3(archiveDsyms)) {
|
|
48791
|
-
if (name.endsWith(".dSYM")) sources.push(
|
|
49312
|
+
if (name.endsWith(".dSYM")) sources.push(join16(archiveDsyms, name));
|
|
48792
49313
|
}
|
|
48793
49314
|
} else {
|
|
48794
49315
|
const binaries = entries.map(
|
|
48795
|
-
({ buildSettings: settings }) => settings.TARGET_BUILD_DIR && settings.EXECUTABLE_PATH ?
|
|
49316
|
+
({ buildSettings: settings }) => settings.TARGET_BUILD_DIR && settings.EXECUTABLE_PATH ? join16(settings.TARGET_BUILD_DIR, settings.EXECUTABLE_PATH) : null
|
|
48796
49317
|
).filter((path) => Boolean(path));
|
|
48797
49318
|
const existing = [];
|
|
48798
49319
|
for (const binary of new Set(binaries)) {
|
|
@@ -48808,21 +49329,21 @@ async function captureDsyms(input, entries, signal2) {
|
|
|
48808
49329
|
if (!await pathExists(folder)) continue;
|
|
48809
49330
|
for (const name of await readdir3(folder)) {
|
|
48810
49331
|
if (!name.endsWith(".dSYM")) continue;
|
|
48811
|
-
const bundle =
|
|
49332
|
+
const bundle = join16(folder, name);
|
|
48812
49333
|
const uuids = await dwarfdumpUuids([bundle], signal2);
|
|
48813
49334
|
if (uuids.some((entry) => built.has(entry.uuid))) sources.push(bundle);
|
|
48814
49335
|
}
|
|
48815
49336
|
}
|
|
48816
49337
|
}
|
|
48817
49338
|
if (!sources.length) return null;
|
|
48818
|
-
const staging =
|
|
48819
|
-
const zipPath =
|
|
49339
|
+
const staging = join16(input.artifactDirectory, "dSYMs");
|
|
49340
|
+
const zipPath = join16(input.artifactDirectory, DSYMS_ARTIFACT_FILENAME);
|
|
48820
49341
|
await rm11(staging, { recursive: true, force: true });
|
|
48821
49342
|
await rm11(zipPath, { force: true });
|
|
48822
49343
|
await mkdir4(staging, { recursive: true, mode: 448 });
|
|
48823
49344
|
try {
|
|
48824
49345
|
for (const source of sources) {
|
|
48825
|
-
await cp(source,
|
|
49346
|
+
await cp(source, join16(staging, basename3(source)), {
|
|
48826
49347
|
recursive: true,
|
|
48827
49348
|
preserveTimestamps: true
|
|
48828
49349
|
});
|
|
@@ -48839,7 +49360,7 @@ async function captureDsyms(input, entries, signal2) {
|
|
|
48839
49360
|
);
|
|
48840
49361
|
}
|
|
48841
49362
|
const uuids = await dwarfdumpUuids(
|
|
48842
|
-
sources.map((source) =>
|
|
49363
|
+
sources.map((source) => join16(staging, basename3(source))),
|
|
48843
49364
|
signal2
|
|
48844
49365
|
);
|
|
48845
49366
|
return await artifact(
|
|
@@ -48857,7 +49378,7 @@ async function captureDsyms(input, entries, signal2) {
|
|
|
48857
49378
|
}
|
|
48858
49379
|
async function captureArtifacts(input, folder, signal2, includeProducts = true) {
|
|
48859
49380
|
const artifacts = [];
|
|
48860
|
-
const resultBundle =
|
|
49381
|
+
const resultBundle = join16(input.artifactDirectory, "result.xcresult");
|
|
48861
49382
|
if (await pathExists(resultBundle)) {
|
|
48862
49383
|
const coverageProbe = await command(
|
|
48863
49384
|
"xcrun",
|
|
@@ -48884,7 +49405,7 @@ async function captureArtifacts(input, folder, signal2, includeProducts = true)
|
|
|
48884
49405
|
);
|
|
48885
49406
|
}
|
|
48886
49407
|
if (!includeProducts) return artifacts;
|
|
48887
|
-
const archivePath =
|
|
49408
|
+
const archivePath = join16(input.artifactDirectory, "archive.xcarchive");
|
|
48888
49409
|
if (await pathExists(archivePath)) {
|
|
48889
49410
|
artifacts.push(
|
|
48890
49411
|
await artifact(input.artifactDirectory, "ARCHIVE", archivePath)
|
|
@@ -48921,10 +49442,10 @@ async function captureArtifacts(input, folder, signal2, includeProducts = true)
|
|
|
48921
49442
|
if (apps.length === 1) {
|
|
48922
49443
|
const settings = apps[0].buildSettings;
|
|
48923
49444
|
const productName = settings.FULL_PRODUCT_NAME ?? settings.WRAPPER_NAME;
|
|
48924
|
-
const source = settings.TARGET_BUILD_DIR && productName ?
|
|
49445
|
+
const source = settings.TARGET_BUILD_DIR && productName ? join16(settings.TARGET_BUILD_DIR, productName) : null;
|
|
48925
49446
|
if (source && await pathExists(source)) {
|
|
48926
|
-
const productDirectory =
|
|
48927
|
-
const destination =
|
|
49447
|
+
const productDirectory = join16(input.artifactDirectory, "products");
|
|
49448
|
+
const destination = join16(productDirectory, basename3(source));
|
|
48928
49449
|
await mkdir4(productDirectory, { recursive: true, mode: 448 });
|
|
48929
49450
|
await rm11(destination, { recursive: true, force: true });
|
|
48930
49451
|
await cp(source, destination, {
|
|
@@ -48944,7 +49465,7 @@ async function captureArtifacts(input, folder, signal2, includeProducts = true)
|
|
|
48944
49465
|
}
|
|
48945
49466
|
}
|
|
48946
49467
|
if (input.action === "BUILD_FOR_TESTING") {
|
|
48947
|
-
const testDirectory =
|
|
49468
|
+
const testDirectory = join16(
|
|
48948
49469
|
input.artifactDirectory,
|
|
48949
49470
|
"test-products.xctestproducts"
|
|
48950
49471
|
);
|
|
@@ -48971,8 +49492,8 @@ var runIosBuild = async (payload, timeoutMs, signal2, onLog, context) => {
|
|
|
48971
49492
|
const input = parseBuildJobPayload(payload);
|
|
48972
49493
|
if (!input.worktreeId || /[\\/\0]/.test(input.worktreeId) || input.worktreeId === "." || input.worktreeId === "..")
|
|
48973
49494
|
throw new Error("Invalid build worktree identifier");
|
|
48974
|
-
const derivedDataPath = input.derivedDataPath ??
|
|
48975
|
-
|
|
49495
|
+
const derivedDataPath = input.derivedDataPath ?? join16(
|
|
49496
|
+
dirname10(input.artifactDirectory),
|
|
48976
49497
|
".worktree-derived-data",
|
|
48977
49498
|
input.worktreeId
|
|
48978
49499
|
);
|
|
@@ -49068,7 +49589,7 @@ var runIosBuildWithPaths = async (payload, timeoutMs, signal2, onLog, context) =
|
|
|
49068
49589
|
if (input.derivedDataPath) {
|
|
49069
49590
|
await mkdir4(input.derivedDataPath, { recursive: true, mode: 448 });
|
|
49070
49591
|
await writeFile6(
|
|
49071
|
-
|
|
49592
|
+
join16(input.derivedDataPath, ".aide-worktree.json"),
|
|
49072
49593
|
`${JSON.stringify({ version: 1, worktreeId: input.worktreeId, folder })}
|
|
49073
49594
|
`,
|
|
49074
49595
|
{ mode: 384 }
|
|
@@ -49078,10 +49599,10 @@ var runIosBuildWithPaths = async (payload, timeoutMs, signal2, onLog, context) =
|
|
|
49078
49599
|
const testProductsPath = input.advancedSettings.priorTestProductsPath;
|
|
49079
49600
|
const xctestrunPath = input.advancedSettings.priorXctestrunPath;
|
|
49080
49601
|
if (testProductsPath) {
|
|
49081
|
-
if (!testProductsPath.endsWith(".xctestproducts") || !await pathExists(testProductsPath) || !(await
|
|
49602
|
+
if (!testProductsPath.endsWith(".xctestproducts") || !await pathExists(testProductsPath) || !(await stat5(testProductsPath)).isDirectory()) {
|
|
49082
49603
|
throw new Error("The captured test-products artifact is unavailable");
|
|
49083
49604
|
}
|
|
49084
|
-
} else if (!xctestrunPath?.endsWith(".xctestrun") || !await pathExists(xctestrunPath) || !(await
|
|
49605
|
+
} else if (!xctestrunPath?.endsWith(".xctestrun") || !await pathExists(xctestrunPath) || !(await stat5(xctestrunPath)).isFile()) {
|
|
49085
49606
|
throw new Error("The captured .xctestrun artifact is unavailable");
|
|
49086
49607
|
}
|
|
49087
49608
|
}
|
|
@@ -49094,11 +49615,11 @@ var runIosBuildWithPaths = async (payload, timeoutMs, signal2, onLog, context) =
|
|
|
49094
49615
|
signal2
|
|
49095
49616
|
);
|
|
49096
49617
|
await mkdir4(input.artifactDirectory, { recursive: true, mode: 448 });
|
|
49097
|
-
const rawLog =
|
|
49618
|
+
const rawLog = join16(input.artifactDirectory, "build.log");
|
|
49098
49619
|
const logger = new BuildLogger(input.buildId, context, rawLog, process.env);
|
|
49099
49620
|
try {
|
|
49100
49621
|
const scriptExecutions = [];
|
|
49101
|
-
const contextPath =
|
|
49622
|
+
const contextPath = join16(input.artifactDirectory, "context.json");
|
|
49102
49623
|
const baseHookContext = {
|
|
49103
49624
|
buildId: input.buildId,
|
|
49104
49625
|
branch: input.branch ?? null,
|
|
@@ -49123,15 +49644,40 @@ var runIosBuildWithPaths = async (payload, timeoutMs, signal2, onLog, context) =
|
|
|
49123
49644
|
let errorCode = null;
|
|
49124
49645
|
let error = null;
|
|
49125
49646
|
let failBuild = false;
|
|
49126
|
-
|
|
49127
|
-
|
|
49128
|
-
|
|
49129
|
-
|
|
49130
|
-
|
|
49647
|
+
let progressStatus = "PREPARING";
|
|
49648
|
+
const reportProgress = async (progress) => {
|
|
49649
|
+
try {
|
|
49650
|
+
await context?.reportBuildProgress?.({
|
|
49651
|
+
...progress,
|
|
49652
|
+
buildId: input.buildId
|
|
49653
|
+
});
|
|
49654
|
+
} catch (progressError) {
|
|
49655
|
+
logger.emit(progress.status, "SYSTEM", cleanError2(progressError));
|
|
49656
|
+
}
|
|
49657
|
+
};
|
|
49658
|
+
const runReportedHook = async (options) => {
|
|
49659
|
+
await reportProgress({
|
|
49660
|
+
status: progressStatus,
|
|
49661
|
+
scriptExecutions: [
|
|
49662
|
+
{
|
|
49663
|
+
phase: options.phase,
|
|
49664
|
+
position: options.script.position,
|
|
49665
|
+
status: "RUNNING"
|
|
49666
|
+
}
|
|
49667
|
+
]
|
|
49131
49668
|
});
|
|
49132
|
-
|
|
49133
|
-
|
|
49134
|
-
|
|
49669
|
+
const execution = await runHook(options);
|
|
49670
|
+
scriptExecutions.push(execution);
|
|
49671
|
+
await reportProgress({
|
|
49672
|
+
status: progressStatus,
|
|
49673
|
+
scriptExecutions: [execution]
|
|
49674
|
+
});
|
|
49675
|
+
return execution;
|
|
49676
|
+
};
|
|
49677
|
+
await reportProgress({
|
|
49678
|
+
status: "PREPARING",
|
|
49679
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
49680
|
+
});
|
|
49135
49681
|
logger.emit("PREPARING", "SYSTEM", `Preparing build in ${folder}`);
|
|
49136
49682
|
try {
|
|
49137
49683
|
await onLog({
|
|
@@ -49167,7 +49713,7 @@ var runIosBuildWithPaths = async (payload, timeoutMs, signal2, onLog, context) =
|
|
|
49167
49713
|
(a, b) => a.position - b.position
|
|
49168
49714
|
)) {
|
|
49169
49715
|
if (!script.preBuildScript) continue;
|
|
49170
|
-
const execution = await
|
|
49716
|
+
const execution = await runReportedHook({
|
|
49171
49717
|
input,
|
|
49172
49718
|
folder,
|
|
49173
49719
|
script,
|
|
@@ -49178,7 +49724,6 @@ var runIosBuildWithPaths = async (payload, timeoutMs, signal2, onLog, context) =
|
|
|
49178
49724
|
logger,
|
|
49179
49725
|
signal: signal2
|
|
49180
49726
|
});
|
|
49181
|
-
scriptExecutions.push(execution);
|
|
49182
49727
|
if (execution.causedBuildFailure) {
|
|
49183
49728
|
failBuild = true;
|
|
49184
49729
|
errorCode = "SCRIPT_FAILED";
|
|
@@ -49210,14 +49755,11 @@ var runIosBuildWithPaths = async (payload, timeoutMs, signal2, onLog, context) =
|
|
|
49210
49755
|
const finishBuild = async () => {
|
|
49211
49756
|
try {
|
|
49212
49757
|
if (!failBuild && !signal2.aborted) {
|
|
49213
|
-
|
|
49214
|
-
|
|
49215
|
-
|
|
49216
|
-
|
|
49217
|
-
|
|
49218
|
-
} catch (progressError) {
|
|
49219
|
-
logger.emit("RUNNING", "SYSTEM", cleanError2(progressError));
|
|
49220
|
-
}
|
|
49758
|
+
progressStatus = "RUNNING";
|
|
49759
|
+
await reportProgress({
|
|
49760
|
+
status: progressStatus,
|
|
49761
|
+
scriptExecutions: [...scriptExecutions]
|
|
49762
|
+
});
|
|
49221
49763
|
if (input.worktreeCoverage) {
|
|
49222
49764
|
try {
|
|
49223
49765
|
coverageChanges = await snapshotCoverageChanges(
|
|
@@ -49254,7 +49796,7 @@ var runIosBuildWithPaths = async (payload, timeoutMs, signal2, onLog, context) =
|
|
|
49254
49796
|
)) {
|
|
49255
49797
|
if (!script.postBuildScript) continue;
|
|
49256
49798
|
try {
|
|
49257
|
-
const execution = await
|
|
49799
|
+
const execution = await runReportedHook({
|
|
49258
49800
|
input,
|
|
49259
49801
|
folder,
|
|
49260
49802
|
script,
|
|
@@ -49272,7 +49814,6 @@ var runIosBuildWithPaths = async (payload, timeoutMs, signal2, onLog, context) =
|
|
|
49272
49814
|
logger,
|
|
49273
49815
|
signal: postSignal
|
|
49274
49816
|
});
|
|
49275
|
-
scriptExecutions.push(execution);
|
|
49276
49817
|
if (execution.causedBuildFailure && !signal2.aborted) {
|
|
49277
49818
|
failBuild = true;
|
|
49278
49819
|
errorCode ??= "SCRIPT_FAILED";
|
|
@@ -49461,21 +50002,21 @@ var downloadIosBuildArtifact = async (payload, timeoutMs, signal2, onLog, contex
|
|
|
49461
50002
|
if (!difference || difference === ".." || difference.startsWith(`..${sep5}`) || isAbsolute6(difference)) {
|
|
49462
50003
|
throw new Error("Build artifact resolves outside the build folder");
|
|
49463
50004
|
}
|
|
49464
|
-
const information = await
|
|
50005
|
+
const information = await stat5(target2);
|
|
49465
50006
|
let uploadPath = target2;
|
|
49466
50007
|
let filename = basename3(target2);
|
|
49467
50008
|
let contentType = "application/octet-stream";
|
|
49468
50009
|
let temporaryArchive = null;
|
|
49469
50010
|
try {
|
|
49470
50011
|
if (information.isDirectory()) {
|
|
49471
|
-
temporaryArchive =
|
|
50012
|
+
temporaryArchive = join16(
|
|
49472
50013
|
tmpdir4(),
|
|
49473
50014
|
`ade-build-artifact-${randomUUID5()}.tar.gz`
|
|
49474
50015
|
);
|
|
49475
50016
|
requireSuccess2(
|
|
49476
50017
|
await command(
|
|
49477
50018
|
"tar",
|
|
49478
|
-
["-czf", temporaryArchive, "-C",
|
|
50019
|
+
["-czf", temporaryArchive, "-C", dirname10(target2), basename3(target2)],
|
|
49479
50020
|
timeoutMs,
|
|
49480
50021
|
signal2
|
|
49481
50022
|
),
|
|
@@ -49521,21 +50062,21 @@ var uploadTransferredIosBuildArtifact = async (payload, timeoutMs, signal2, onLo
|
|
|
49521
50062
|
if (!difference || difference === ".." || difference.startsWith(`..${sep5}`) || isAbsolute6(difference)) {
|
|
49522
50063
|
throw new Error("Build artifact resolves outside the build folder");
|
|
49523
50064
|
}
|
|
49524
|
-
const information = await
|
|
50065
|
+
const information = await stat5(target2);
|
|
49525
50066
|
let uploadPath = target2;
|
|
49526
50067
|
let filename = basename3(target2);
|
|
49527
50068
|
let contentType = "application/octet-stream";
|
|
49528
50069
|
let temporaryArchive = null;
|
|
49529
50070
|
try {
|
|
49530
50071
|
if (information.isDirectory()) {
|
|
49531
|
-
temporaryArchive =
|
|
50072
|
+
temporaryArchive = join16(
|
|
49532
50073
|
tmpdir4(),
|
|
49533
50074
|
`ade-build-transfer-${input.transferId}-${randomUUID5()}.tar.gz`
|
|
49534
50075
|
);
|
|
49535
50076
|
requireSuccess2(
|
|
49536
50077
|
await command(
|
|
49537
50078
|
"tar",
|
|
49538
|
-
["-czf", temporaryArchive, "-C",
|
|
50079
|
+
["-czf", temporaryArchive, "-C", dirname10(target2), basename3(target2)],
|
|
49539
50080
|
timeoutMs,
|
|
49540
50081
|
signal2
|
|
49541
50082
|
),
|
|
@@ -49591,24 +50132,24 @@ async function deployPreparedIosBuild(input, folder, appPath, timeoutMs, signal2
|
|
|
49591
50132
|
if (!await pathExists(appPath) || !appPath.endsWith(".app")) {
|
|
49592
50133
|
throw new Error("Runnable app artifact is missing");
|
|
49593
50134
|
}
|
|
49594
|
-
const deploymentsDirectory =
|
|
50135
|
+
const deploymentsDirectory = join16(input.artifactDirectory, "deployments");
|
|
49595
50136
|
await mkdir4(deploymentsDirectory, { recursive: true, mode: 448 });
|
|
49596
50137
|
const logger = new BuildLogger(
|
|
49597
50138
|
input.buildId,
|
|
49598
50139
|
context,
|
|
49599
|
-
|
|
50140
|
+
join16(deploymentsDirectory, "deployments.log"),
|
|
49600
50141
|
process.env
|
|
49601
50142
|
);
|
|
49602
50143
|
try {
|
|
49603
50144
|
const outcomes = [];
|
|
49604
50145
|
for (const deployment of input.deployments) {
|
|
49605
|
-
const directory =
|
|
50146
|
+
const directory = join16(
|
|
49606
50147
|
input.artifactDirectory,
|
|
49607
50148
|
"deployments",
|
|
49608
50149
|
deployment.id
|
|
49609
50150
|
);
|
|
49610
50151
|
await mkdir4(directory, { recursive: true, mode: 448 });
|
|
49611
|
-
const logPath =
|
|
50152
|
+
const logPath = join16(directory, "deployment.log");
|
|
49612
50153
|
const started = Date.now();
|
|
49613
50154
|
let failure = null;
|
|
49614
50155
|
let launchedAt = null;
|
|
@@ -49830,7 +50371,7 @@ var deployIosBuild = async (payload, timeoutMs, signal2, _onLog, context) => {
|
|
|
49830
50371
|
};
|
|
49831
50372
|
async function createRemoteBuildStagingDirectory(buildId) {
|
|
49832
50373
|
return realpath6(
|
|
49833
|
-
await mkdtemp5(
|
|
50374
|
+
await mkdtemp5(join16(tmpdir4(), `ade-remote-build-${buildId}-`))
|
|
49834
50375
|
);
|
|
49835
50376
|
}
|
|
49836
50377
|
var deployTransferredIosBuild = async (payload, timeoutMs, signal2, onLog, context) => {
|
|
@@ -49839,7 +50380,7 @@ var deployTransferredIosBuild = async (payload, timeoutMs, signal2, onLog, conte
|
|
|
49839
50380
|
throw new Error("This agent cannot download transferred build artifacts");
|
|
49840
50381
|
}
|
|
49841
50382
|
const staging = await createRemoteBuildStagingDirectory(input.buildId);
|
|
49842
|
-
const archive =
|
|
50383
|
+
const archive = join16(staging, "artifact.tar.gz");
|
|
49843
50384
|
try {
|
|
49844
50385
|
await onLog({
|
|
49845
50386
|
sequence: 0,
|
|
@@ -49881,7 +50422,7 @@ var deployTransferredIosBuild = async (payload, timeoutMs, signal2, onLog, conte
|
|
|
49881
50422
|
),
|
|
49882
50423
|
"Could not extract the transferred app"
|
|
49883
50424
|
);
|
|
49884
|
-
const appPath = await realpath6(
|
|
50425
|
+
const appPath = await realpath6(join16(staging, root));
|
|
49885
50426
|
const pathDifference = relative4(staging, appPath);
|
|
49886
50427
|
if (pathDifference === ".." || pathDifference.startsWith(`..${sep5}`) || isAbsolute6(pathDifference)) {
|
|
49887
50428
|
throw new Error("Transferred app resolves outside its staging directory");
|
|
@@ -49946,14 +50487,14 @@ var exportIosArchive = async (payload, timeoutMs, signal2, _onLog, context) => {
|
|
|
49946
50487
|
if (!await pathExists(archivePath) || !archivePath.endsWith(".xcarchive")) {
|
|
49947
50488
|
throw new Error("Archive artifact is missing");
|
|
49948
50489
|
}
|
|
49949
|
-
const exportDirectory =
|
|
50490
|
+
const exportDirectory = join16(
|
|
49950
50491
|
input.artifactDirectory,
|
|
49951
50492
|
"exports",
|
|
49952
50493
|
input.exportId
|
|
49953
50494
|
);
|
|
49954
50495
|
await mkdir4(exportDirectory, { recursive: true, mode: 448 });
|
|
49955
|
-
const plistPath =
|
|
49956
|
-
const logPath =
|
|
50496
|
+
const plistPath = join16(exportDirectory, "ExportOptions.plist");
|
|
50497
|
+
const logPath = join16(exportDirectory, "export.log");
|
|
49957
50498
|
await writeFile6(plistPath, exportPlist(input.settings), { mode: 384 });
|
|
49958
50499
|
const logger = new BuildLogger(input.buildId, context, logPath, process.env);
|
|
49959
50500
|
try {
|
|
@@ -50022,7 +50563,7 @@ var importCoverageReport = async (payloadValue, timeoutMs, signal2, onLog) => {
|
|
|
50022
50563
|
const payload = parseCoverageImportPayload(payloadValue);
|
|
50023
50564
|
if (signal2.aborted) return { ...successfulProcess4, cancelled: true };
|
|
50024
50565
|
const folder = await realpath7(payload.folder);
|
|
50025
|
-
const reportPath = await realpath7(
|
|
50566
|
+
const reportPath = await realpath7(join17(folder, payload.reportPath)).catch(
|
|
50026
50567
|
() => {
|
|
50027
50568
|
throw new Error(`Coverage file ${payload.reportPath} does not exist`);
|
|
50028
50569
|
}
|
|
@@ -50031,7 +50572,7 @@ var importCoverageReport = async (payloadValue, timeoutMs, signal2, onLog) => {
|
|
|
50031
50572
|
if (!difference || difference === ".." || difference.startsWith("../")) {
|
|
50032
50573
|
throw new Error("Coverage file resolves outside the worktree");
|
|
50033
50574
|
}
|
|
50034
|
-
const information = await
|
|
50575
|
+
const information = await stat6(reportPath);
|
|
50035
50576
|
if (!information.isFile()) throw new Error("Coverage file is not a file");
|
|
50036
50577
|
if (information.size > MAX_REPORT_BYTES) {
|
|
50037
50578
|
throw new Error("Coverage file exceeds the 64 MiB limit");
|
|
@@ -50095,12 +50636,12 @@ import {
|
|
|
50095
50636
|
readdir as readdir4,
|
|
50096
50637
|
rename as rename6,
|
|
50097
50638
|
rm as rm12,
|
|
50098
|
-
stat as
|
|
50639
|
+
stat as stat7,
|
|
50099
50640
|
utimes,
|
|
50100
50641
|
writeFile as writeFile7
|
|
50101
50642
|
} from "node:fs/promises";
|
|
50102
50643
|
import { homedir as homedir9, tmpdir as tmpdir5 } from "node:os";
|
|
50103
|
-
import { join as
|
|
50644
|
+
import { join as join18 } from "node:path";
|
|
50104
50645
|
var CACHE_LIMIT_BYTES = 10 * 1024 ** 3;
|
|
50105
50646
|
var ATOS_OUTPUT_LIMIT_BYTES = 16 * 1024 * 1024;
|
|
50106
50647
|
var successfulProcess5 = {
|
|
@@ -50113,7 +50654,7 @@ function dsymCacheDirectory() {
|
|
|
50113
50654
|
if (process.env.CONTROL_AGENT_DSYM_CACHE) {
|
|
50114
50655
|
return process.env.CONTROL_AGENT_DSYM_CACHE;
|
|
50115
50656
|
}
|
|
50116
|
-
return process.platform === "darwin" ?
|
|
50657
|
+
return process.platform === "darwin" ? join18(homedir9(), "Library", "Caches", "control-agent", "dsym-cache") : join18(homedir9(), ".cache", "control-agent", "dsym-cache");
|
|
50117
50658
|
}
|
|
50118
50659
|
async function log(onLog, sequence, message2, stream = "SYSTEM") {
|
|
50119
50660
|
await onLog({
|
|
@@ -50124,10 +50665,10 @@ async function log(onLog, sequence, message2, stream = "SYSTEM") {
|
|
|
50124
50665
|
});
|
|
50125
50666
|
}
|
|
50126
50667
|
async function cachedDwarf(dsym, cache, download, signal2) {
|
|
50127
|
-
const folder =
|
|
50128
|
-
const path =
|
|
50668
|
+
const folder = join18(cache, dsym.sha256);
|
|
50669
|
+
const path = join18(folder, dsym.binaryName);
|
|
50129
50670
|
try {
|
|
50130
|
-
const existing = await
|
|
50671
|
+
const existing = await stat7(path);
|
|
50131
50672
|
if (existing.size === dsym.sizeBytes) {
|
|
50132
50673
|
const now = /* @__PURE__ */ new Date();
|
|
50133
50674
|
await utimes(folder, now, now).catch(() => void 0);
|
|
@@ -50136,7 +50677,7 @@ async function cachedDwarf(dsym, cache, download, signal2) {
|
|
|
50136
50677
|
} catch {
|
|
50137
50678
|
}
|
|
50138
50679
|
await mkdir5(folder, { recursive: true, mode: 448 });
|
|
50139
|
-
const partial =
|
|
50680
|
+
const partial = join18(folder, `.${dsym.binaryName}.${randomUUID6()}.partial`);
|
|
50140
50681
|
try {
|
|
50141
50682
|
await download({
|
|
50142
50683
|
downloadPath: dsym.downloadPath,
|
|
@@ -50160,13 +50701,13 @@ async function trimDsymCache(cache, keep, limit = CACHE_LIMIT_BYTES) {
|
|
|
50160
50701
|
}
|
|
50161
50702
|
const folders = [];
|
|
50162
50703
|
for (const name of entries) {
|
|
50163
|
-
const folder =
|
|
50704
|
+
const folder = join18(cache, name);
|
|
50164
50705
|
try {
|
|
50165
|
-
const information = await
|
|
50706
|
+
const information = await stat7(folder);
|
|
50166
50707
|
if (!information.isDirectory()) continue;
|
|
50167
50708
|
let size = 0;
|
|
50168
50709
|
for (const file of await readdir4(folder)) {
|
|
50169
|
-
size += (await
|
|
50710
|
+
size += (await stat7(join18(folder, file))).size;
|
|
50170
50711
|
}
|
|
50171
50712
|
folders.push({ name, size, used: information.mtimeMs });
|
|
50172
50713
|
} catch {
|
|
@@ -50176,7 +50717,7 @@ async function trimDsymCache(cache, keep, limit = CACHE_LIMIT_BYTES) {
|
|
|
50176
50717
|
for (const folder of folders.sort((left, right) => left.used - right.used)) {
|
|
50177
50718
|
if (total <= limit) break;
|
|
50178
50719
|
if (keep.has(folder.name)) continue;
|
|
50179
|
-
await rm12(
|
|
50720
|
+
await rm12(join18(cache, folder.name), { recursive: true, force: true });
|
|
50180
50721
|
total -= folder.size;
|
|
50181
50722
|
}
|
|
50182
50723
|
}
|
|
@@ -50228,7 +50769,7 @@ var symbolicateCrash = async (payloadValue, timeoutMs, signal2, onLog, context)
|
|
|
50228
50769
|
);
|
|
50229
50770
|
}
|
|
50230
50771
|
}
|
|
50231
|
-
const workFolder =
|
|
50772
|
+
const workFolder = join18(tmpdir5(), `control-agent-atos-${randomUUID6()}`);
|
|
50232
50773
|
await mkdir5(workFolder, { recursive: true, mode: 448 });
|
|
50233
50774
|
const lookups = [];
|
|
50234
50775
|
try {
|
|
@@ -50244,7 +50785,7 @@ var symbolicateCrash = async (payloadValue, timeoutMs, signal2, onLog, context)
|
|
|
50244
50785
|
if (!dwarfPath) continue;
|
|
50245
50786
|
for (let start = 0; start < lookup.offsets.length; start += ATOS_BATCH_SIZE) {
|
|
50246
50787
|
const batch = lookup.offsets.slice(start, start + ATOS_BATCH_SIZE);
|
|
50247
|
-
const offsetsFile =
|
|
50788
|
+
const offsetsFile = join18(workFolder, `${lookup.uuid}-${start}.txt`);
|
|
50248
50789
|
await writeFile7(offsetsFile, `${batch.join("\n")}
|
|
50249
50790
|
`, { mode: 384 });
|
|
50250
50791
|
const run = await captureCommand({
|
|
@@ -50465,13 +51006,13 @@ import {
|
|
|
50465
51006
|
readFile as readFile8,
|
|
50466
51007
|
readdir as readdir5,
|
|
50467
51008
|
rm as rm13,
|
|
50468
|
-
stat as
|
|
51009
|
+
stat as stat8,
|
|
50469
51010
|
writeFile as writeFile8
|
|
50470
51011
|
} from "node:fs/promises";
|
|
50471
51012
|
import { homedir as homedir11, tmpdir as tmpdir6 } from "node:os";
|
|
50472
|
-
import { basename as basename4, join as
|
|
51013
|
+
import { basename as basename4, join as join19, relative as relative6, sep as sep7 } from "node:path";
|
|
50473
51014
|
var PROFILE_DIRECTORIES = [
|
|
50474
|
-
|
|
51015
|
+
join19(
|
|
50475
51016
|
homedir11(),
|
|
50476
51017
|
"Library",
|
|
50477
51018
|
"Developer",
|
|
@@ -50479,7 +51020,7 @@ var PROFILE_DIRECTORIES = [
|
|
|
50479
51020
|
"UserData",
|
|
50480
51021
|
"Provisioning Profiles"
|
|
50481
51022
|
),
|
|
50482
|
-
|
|
51023
|
+
join19(homedir11(), "Library", "MobileDevice", "Provisioning Profiles")
|
|
50483
51024
|
];
|
|
50484
51025
|
var PROFILE_EXTENSIONS = [".mobileprovision", ".provisionprofile"];
|
|
50485
51026
|
function text(value) {
|
|
@@ -50572,7 +51113,7 @@ async function readProfiles(timeoutMs, signal2) {
|
|
|
50572
51113
|
continue;
|
|
50573
51114
|
signal2.throwIfAborted();
|
|
50574
51115
|
const raw = await decodeProfile(
|
|
50575
|
-
|
|
51116
|
+
join19(directory, entry),
|
|
50576
51117
|
timeoutMs,
|
|
50577
51118
|
signal2
|
|
50578
51119
|
);
|
|
@@ -50606,7 +51147,7 @@ async function decodedProfiles(timeoutMs, signal2, strict = false) {
|
|
|
50606
51147
|
continue;
|
|
50607
51148
|
}
|
|
50608
51149
|
signal2.throwIfAborted();
|
|
50609
|
-
const path =
|
|
51150
|
+
const path = join19(directory, entry);
|
|
50610
51151
|
const raw = await decodeProfile(path, timeoutMs, signal2, strict);
|
|
50611
51152
|
if (!raw) continue;
|
|
50612
51153
|
let content;
|
|
@@ -50762,7 +51303,7 @@ async function readCertificates(timeoutMs, signal2, strict = false) {
|
|
|
50762
51303
|
);
|
|
50763
51304
|
}
|
|
50764
51305
|
async function readArchiveBundles(archivePath, timeoutMs, signal2) {
|
|
50765
|
-
const products =
|
|
51306
|
+
const products = join19(archivePath, "Products");
|
|
50766
51307
|
const bundles = [];
|
|
50767
51308
|
const queue = [products];
|
|
50768
51309
|
while (queue.length) {
|
|
@@ -50776,7 +51317,7 @@ async function readArchiveBundles(archivePath, timeoutMs, signal2) {
|
|
|
50776
51317
|
}
|
|
50777
51318
|
for (const entry of entries) {
|
|
50778
51319
|
if (entry.isSymbolicLink() || !entry.isDirectory()) continue;
|
|
50779
|
-
const path =
|
|
51320
|
+
const path = join19(current, entry.name);
|
|
50780
51321
|
const signable = /\.(app|appex)$/.test(entry.name);
|
|
50781
51322
|
if (!signable) {
|
|
50782
51323
|
if (!/\.[A-Za-z0-9]+$/.test(entry.name)) queue.push(path);
|
|
@@ -50808,7 +51349,7 @@ async function bundleIdentifier(bundlePath, timeoutMs, signal2) {
|
|
|
50808
51349
|
"raw",
|
|
50809
51350
|
"-o",
|
|
50810
51351
|
"-",
|
|
50811
|
-
|
|
51352
|
+
join19(bundlePath, "Info.plist")
|
|
50812
51353
|
],
|
|
50813
51354
|
timeoutMs: Math.min(timeoutMs, 5e3),
|
|
50814
51355
|
signal: signal2
|
|
@@ -50824,9 +51365,9 @@ async function embeddedProfile(bundlePath, timeoutMs, signal2) {
|
|
|
50824
51365
|
"embedded.mobileprovision",
|
|
50825
51366
|
"embedded.provisionprofile"
|
|
50826
51367
|
]) {
|
|
50827
|
-
const path =
|
|
51368
|
+
const path = join19(bundlePath, name);
|
|
50828
51369
|
try {
|
|
50829
|
-
await
|
|
51370
|
+
await stat8(path);
|
|
50830
51371
|
} catch {
|
|
50831
51372
|
continue;
|
|
50832
51373
|
}
|
|
@@ -50871,7 +51412,7 @@ async function inspectSigningAssets(archivePath, timeoutMs, signal2) {
|
|
|
50871
51412
|
}
|
|
50872
51413
|
var inspectIosSigning = async (payload, timeoutMs, signal2) => {
|
|
50873
51414
|
const input = parseBuildSigningInspectPayload(payload);
|
|
50874
|
-
const archivePath =
|
|
51415
|
+
const archivePath = join19(input.artifactDirectory, input.archiveRelativePath);
|
|
50875
51416
|
const inspection = await inspectSigningAssets(archivePath, timeoutMs, signal2);
|
|
50876
51417
|
return {
|
|
50877
51418
|
exitCode: 0,
|
|
@@ -50933,8 +51474,8 @@ var installSigningProfile = async (payload, timeoutMs, signal2) => {
|
|
|
50933
51474
|
const { contentBase64 } = signingProfileInstallPayload(payload);
|
|
50934
51475
|
const content = Buffer.from(contentBase64, "base64");
|
|
50935
51476
|
if (!content.length) throw new Error("Provisioning profile is empty");
|
|
50936
|
-
const temporaryRoot = await mkdtemp6(
|
|
50937
|
-
const temporaryPath =
|
|
51477
|
+
const temporaryRoot = await mkdtemp6(join19(tmpdir6(), "ade-profile-"));
|
|
51478
|
+
const temporaryPath = join19(temporaryRoot, `${randomUUID7()}.mobileprovision`);
|
|
50938
51479
|
try {
|
|
50939
51480
|
await writeFile8(temporaryPath, content, { mode: 384 });
|
|
50940
51481
|
const raw = await decodeProfile(temporaryPath, timeoutMs, signal2);
|
|
@@ -50943,7 +51484,7 @@ var installSigningProfile = async (payload, timeoutMs, signal2) => {
|
|
|
50943
51484
|
if (!uuid) throw new Error("Provisioning profile UUID is missing");
|
|
50944
51485
|
const directory = PROFILE_DIRECTORIES[0];
|
|
50945
51486
|
await mkdir6(directory, { recursive: true, mode: 448 });
|
|
50946
|
-
const destination =
|
|
51487
|
+
const destination = join19(directory, `${uuid}.mobileprovision`);
|
|
50947
51488
|
await writeFile8(destination, content, { mode: 384 });
|
|
50948
51489
|
return { ...successfulProcess6, uuid };
|
|
50949
51490
|
} finally {
|
|
@@ -50971,8 +51512,8 @@ var importSigningIdentity = async (payload, timeoutMs, signal2, _onLog, context)
|
|
|
50971
51512
|
const hash = createHash7("sha256").update(p12).digest("hex").toUpperCase();
|
|
50972
51513
|
if (hash !== input.sha256)
|
|
50973
51514
|
throw new Error("Signing identity transfer changed");
|
|
50974
|
-
const temporaryRoot = await mkdtemp6(
|
|
50975
|
-
const path =
|
|
51515
|
+
const temporaryRoot = await mkdtemp6(join19(tmpdir6(), "ade-identity-"));
|
|
51516
|
+
const path = join19(temporaryRoot, "identity.p12");
|
|
50976
51517
|
try {
|
|
50977
51518
|
await writeFile8(path, p12, { mode: 384 });
|
|
50978
51519
|
const result = await captureCommand({
|
|
@@ -51191,15 +51732,15 @@ import {
|
|
|
51191
51732
|
realpath as realpath8,
|
|
51192
51733
|
readFile as readFile9,
|
|
51193
51734
|
rm as rm14,
|
|
51194
|
-
stat as
|
|
51735
|
+
stat as stat9,
|
|
51195
51736
|
statfs
|
|
51196
51737
|
} from "node:fs/promises";
|
|
51197
51738
|
import { homedir as homedir12 } from "node:os";
|
|
51198
51739
|
import {
|
|
51199
51740
|
basename as basename5,
|
|
51200
|
-
dirname as
|
|
51741
|
+
dirname as dirname11,
|
|
51201
51742
|
isAbsolute as isAbsolute7,
|
|
51202
|
-
join as
|
|
51743
|
+
join as join20,
|
|
51203
51744
|
relative as relative7,
|
|
51204
51745
|
resolve as resolve9
|
|
51205
51746
|
} from "node:path";
|
|
@@ -51228,7 +51769,7 @@ async function configuredRoots(payload) {
|
|
|
51228
51769
|
}
|
|
51229
51770
|
async function legacyConfiguredRoots(payload) {
|
|
51230
51771
|
if (payload.mode === "DEFAULT") {
|
|
51231
|
-
return [
|
|
51772
|
+
return [join20(homedir12(), "Library", "Developer", "Xcode", "DerivedData")];
|
|
51232
51773
|
}
|
|
51233
51774
|
if (payload.mode === "ABSOLUTE") {
|
|
51234
51775
|
if (!payload.path || !isAbsolute7(payload.path)) {
|
|
@@ -51285,21 +51826,21 @@ async function scanRoot(configuredRoot, timeoutMs, signal2) {
|
|
|
51285
51826
|
};
|
|
51286
51827
|
}
|
|
51287
51828
|
const entries = [];
|
|
51288
|
-
const rootStats = await
|
|
51829
|
+
const rootStats = await stat9(rootPath2);
|
|
51289
51830
|
const volumeId = String(rootStats.dev);
|
|
51290
51831
|
for (const child of children) {
|
|
51291
51832
|
signal2.throwIfAborted();
|
|
51292
51833
|
if (!child.isDirectory()) continue;
|
|
51293
|
-
const path =
|
|
51834
|
+
const path = join20(rootPath2, child.name);
|
|
51294
51835
|
const information = await lstat4(path);
|
|
51295
51836
|
let projectPath = await workspacePath(
|
|
51296
|
-
|
|
51837
|
+
join20(path, "info.plist"),
|
|
51297
51838
|
timeoutMs,
|
|
51298
51839
|
signal2
|
|
51299
51840
|
);
|
|
51300
51841
|
try {
|
|
51301
51842
|
const ownership = JSON.parse(
|
|
51302
|
-
await readFile9(
|
|
51843
|
+
await readFile9(join20(path, ".aide-worktree.json"), "utf8")
|
|
51303
51844
|
);
|
|
51304
51845
|
if (ownership.version === 1 && ownership.worktreeId === child.name && typeof ownership.folder === "string" && isAbsolute7(ownership.folder))
|
|
51305
51846
|
projectPath = ownership.folder;
|
|
@@ -51319,7 +51860,7 @@ async function scanRoot(configuredRoot, timeoutMs, signal2) {
|
|
|
51319
51860
|
return { entries, warning: null };
|
|
51320
51861
|
}
|
|
51321
51862
|
async function scanDeviceSupport(signal2) {
|
|
51322
|
-
const configuredRoot =
|
|
51863
|
+
const configuredRoot = join20(
|
|
51323
51864
|
process.env.ADE_IOS_DEVICE_SUPPORT_DIRECTORY ?? homedir12(),
|
|
51324
51865
|
...process.env.ADE_IOS_DEVICE_SUPPORT_DIRECTORY ? [] : ["Library", "Developer", "Xcode", "iOS DeviceSupport"]
|
|
51325
51866
|
);
|
|
@@ -51340,7 +51881,7 @@ async function scanDeviceSupport(signal2) {
|
|
|
51340
51881
|
const children = await readdir6(rootPath2, { withFileTypes: true });
|
|
51341
51882
|
return {
|
|
51342
51883
|
entries: children.filter((child) => child.isDirectory() && !child.isSymbolicLink()).map((child) => ({
|
|
51343
|
-
path:
|
|
51884
|
+
path: join20(rootPath2, child.name),
|
|
51344
51885
|
rootPath: rootPath2,
|
|
51345
51886
|
name: child.name,
|
|
51346
51887
|
kind: "DEVICE_SUPPORT",
|
|
@@ -51408,7 +51949,7 @@ async function ownedWorktreeBuildData(folder, configuration, timeoutMs, signal2)
|
|
|
51408
51949
|
warnings.push(`${entry.path}: ${errorMessage(error)}`);
|
|
51409
51950
|
continue;
|
|
51410
51951
|
}
|
|
51411
|
-
let ancestor =
|
|
51952
|
+
let ancestor = dirname11(entry.workspacePath);
|
|
51412
51953
|
while (within(folder, ancestor) && ancestor !== folder) {
|
|
51413
51954
|
try {
|
|
51414
51955
|
if (!within(folder, await realpath8(ancestor))) ancestor = "";
|
|
@@ -51418,7 +51959,7 @@ async function ownedWorktreeBuildData(folder, configuration, timeoutMs, signal2)
|
|
|
51418
51959
|
ancestor = "";
|
|
51419
51960
|
break;
|
|
51420
51961
|
}
|
|
51421
|
-
ancestor =
|
|
51962
|
+
ancestor = dirname11(ancestor);
|
|
51422
51963
|
}
|
|
51423
51964
|
}
|
|
51424
51965
|
if (!ancestor) continue;
|
|
@@ -51434,7 +51975,7 @@ function assertDirectChild(rootPath2, path) {
|
|
|
51434
51975
|
}
|
|
51435
51976
|
const root = resolve9(rootPath2);
|
|
51436
51977
|
const target2 = resolve9(path);
|
|
51437
|
-
if (target2 === root ||
|
|
51978
|
+
if (target2 === root || dirname11(target2) !== root || basename5(target2) !== basename5(path)) {
|
|
51438
51979
|
throw new Error("Build Data target must be a direct child of its root");
|
|
51439
51980
|
}
|
|
51440
51981
|
}
|
|
@@ -51448,7 +51989,7 @@ async function allocatedBytes(path, signal2) {
|
|
|
51448
51989
|
try {
|
|
51449
51990
|
for await (const entry of directory) {
|
|
51450
51991
|
signal2.throwIfAborted();
|
|
51451
|
-
total += await allocatedBytes(
|
|
51992
|
+
total += await allocatedBytes(join20(path, entry.name), signal2);
|
|
51452
51993
|
}
|
|
51453
51994
|
} finally {
|
|
51454
51995
|
await directory.close().catch(() => void 0);
|
|
@@ -51463,7 +52004,7 @@ var sizeBuildData = async (rawPayload, _timeoutMs, signal2) => {
|
|
|
51463
52004
|
try {
|
|
51464
52005
|
assertDirectChild(target2.rootPath, target2.path);
|
|
51465
52006
|
const rootPath2 = await realpath8(target2.rootPath);
|
|
51466
|
-
if (rootPath2 !== resolve9(target2.rootPath) ||
|
|
52007
|
+
if (rootPath2 !== resolve9(target2.rootPath) || dirname11(resolve9(target2.path)) !== rootPath2) {
|
|
51467
52008
|
throw new Error("Build Data root changed since the scan");
|
|
51468
52009
|
}
|
|
51469
52010
|
const stats = await lstat4(target2.path);
|
|
@@ -51495,7 +52036,7 @@ var deleteBuildData = async (rawPayload, _timeoutMs, signal2, _onLog, context) =
|
|
|
51495
52036
|
const removeTarget2 = async () => {
|
|
51496
52037
|
assertDirectChild(target2.rootPath, target2.path);
|
|
51497
52038
|
const rootPath2 = await realpath8(target2.rootPath);
|
|
51498
|
-
if (rootPath2 !== resolve9(target2.rootPath) ||
|
|
52039
|
+
if (rootPath2 !== resolve9(target2.rootPath) || dirname11(resolve9(target2.path)) !== rootPath2) {
|
|
51499
52040
|
throw new Error("Build Data root changed since the scan");
|
|
51500
52041
|
}
|
|
51501
52042
|
const stats = await lstat4(target2.path);
|
|
@@ -51564,13 +52105,13 @@ async function inspectVolume(configuredPath, role, signal2, allowMissing) {
|
|
|
51564
52105
|
let candidate = resolve9(configuredPath);
|
|
51565
52106
|
for (; ; ) {
|
|
51566
52107
|
signal2.throwIfAborted();
|
|
51567
|
-
const parent =
|
|
52108
|
+
const parent = dirname11(candidate);
|
|
51568
52109
|
if (parent === candidate) throw error;
|
|
51569
52110
|
missingSegments.unshift(basename5(candidate));
|
|
51570
52111
|
candidate = parent;
|
|
51571
52112
|
try {
|
|
51572
52113
|
inspectionPath = await realpath8(candidate);
|
|
51573
|
-
canonicalPath =
|
|
52114
|
+
canonicalPath = join20(inspectionPath, ...missingSegments);
|
|
51574
52115
|
break;
|
|
51575
52116
|
} catch (parentError) {
|
|
51576
52117
|
if (parentError.code !== "ENOENT") {
|
|
@@ -51580,7 +52121,7 @@ async function inspectVolume(configuredPath, role, signal2, allowMissing) {
|
|
|
51580
52121
|
}
|
|
51581
52122
|
}
|
|
51582
52123
|
const [information, filesystem] = await Promise.all([
|
|
51583
|
-
|
|
52124
|
+
stat9(inspectionPath),
|
|
51584
52125
|
statfs(inspectionPath, { bigint: true })
|
|
51585
52126
|
]);
|
|
51586
52127
|
const id2 = String(information.dev);
|
|
@@ -51689,11 +52230,11 @@ import {
|
|
|
51689
52230
|
readdir as readdir7,
|
|
51690
52231
|
rename as rename7,
|
|
51691
52232
|
rm as rm15,
|
|
51692
|
-
stat as
|
|
52233
|
+
stat as stat10,
|
|
51693
52234
|
writeFile as writeFile9
|
|
51694
52235
|
} from "node:fs/promises";
|
|
51695
52236
|
import { homedir as homedir13 } from "node:os";
|
|
51696
|
-
import { dirname as
|
|
52237
|
+
import { dirname as dirname12, isAbsolute as isAbsolute8, join as join21, relative as relative8, resolve as resolve10, sep as sep8 } from "node:path";
|
|
51697
52238
|
import { promisify as promisify3 } from "node:util";
|
|
51698
52239
|
var executeFile = promisify3(execFile3);
|
|
51699
52240
|
var successfulProcess8 = {
|
|
@@ -51748,7 +52289,7 @@ var PROJECT_ROOTS = {
|
|
|
51748
52289
|
};
|
|
51749
52290
|
async function directoryExists(path) {
|
|
51750
52291
|
try {
|
|
51751
|
-
return (await
|
|
52292
|
+
return (await stat10(path)).isDirectory();
|
|
51752
52293
|
} catch {
|
|
51753
52294
|
return false;
|
|
51754
52295
|
}
|
|
@@ -51758,7 +52299,7 @@ async function configuredTools(tools) {
|
|
|
51758
52299
|
return Promise.all(
|
|
51759
52300
|
AI_TOOLS.filter((tool) => tools.includes(tool)).map(async (tool) => ({
|
|
51760
52301
|
tool,
|
|
51761
|
-
configured: await directoryExists(
|
|
52302
|
+
configured: await directoryExists(join21(homePath, ...CONFIG_PATHS[tool])),
|
|
51762
52303
|
homePath
|
|
51763
52304
|
}))
|
|
51764
52305
|
);
|
|
@@ -51795,7 +52336,7 @@ async function listPackageFiles(skillDirectory) {
|
|
|
51795
52336
|
let totalBytes = 0;
|
|
51796
52337
|
const visit = async (directory) => {
|
|
51797
52338
|
for (const entry of await readdir7(directory, { withFileTypes: true })) {
|
|
51798
|
-
const path =
|
|
52339
|
+
const path = join21(directory, entry.name);
|
|
51799
52340
|
const metadata = await lstat5(path);
|
|
51800
52341
|
if (metadata.isSymbolicLink()) {
|
|
51801
52342
|
throw new Error(
|
|
@@ -51894,7 +52435,7 @@ async function scanRoot2(location, configured, targets, warnings) {
|
|
|
51894
52435
|
const installations = [];
|
|
51895
52436
|
for (const entry of await readdir7(root, { withFileTypes: true })) {
|
|
51896
52437
|
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
51897
|
-
const directory =
|
|
52438
|
+
const directory = join21(root, entry.name);
|
|
51898
52439
|
try {
|
|
51899
52440
|
const skillPackage = await readPackage(directory, resolvedRoot);
|
|
51900
52441
|
const relativeDirectory = location.folder ? relative8(location.folder, directory).split(sep8).join("/") : "";
|
|
@@ -51974,7 +52515,7 @@ var readSkills = async (payload) => {
|
|
|
51974
52515
|
const { resolvedRoot } = await resolvedSkillRoot(request);
|
|
51975
52516
|
packages.push({
|
|
51976
52517
|
...request,
|
|
51977
|
-
package: await readPackage(
|
|
52518
|
+
package: await readPackage(join21(root, request.skillName), resolvedRoot)
|
|
51978
52519
|
});
|
|
51979
52520
|
}
|
|
51980
52521
|
return { ...successfulProcess8, packages };
|
|
@@ -51992,7 +52533,7 @@ async function gitExcludePath(folder) {
|
|
|
51992
52533
|
}
|
|
51993
52534
|
async function updateManagedExclude(folder, relativeSkillPath, present) {
|
|
51994
52535
|
const excludePath = await gitExcludePath(folder);
|
|
51995
|
-
await mkdir7(
|
|
52536
|
+
await mkdir7(dirname12(excludePath), { recursive: true });
|
|
51996
52537
|
let existing = "";
|
|
51997
52538
|
try {
|
|
51998
52539
|
existing = await readFile10(excludePath, "utf8");
|
|
@@ -52036,18 +52577,18 @@ async function writePackage(location, skillPackage) {
|
|
|
52036
52577
|
throw new Error("New skill copies may only be written to shared roots");
|
|
52037
52578
|
}
|
|
52038
52579
|
const root = rootPath(location);
|
|
52039
|
-
const destination =
|
|
52580
|
+
const destination = join21(root, skillPackage.name);
|
|
52040
52581
|
await assertUntracked(location, destination);
|
|
52041
52582
|
await mkdir7(root, { recursive: true });
|
|
52042
|
-
const temporary =
|
|
52043
|
-
const backup =
|
|
52583
|
+
const temporary = join21(root, `.${skillPackage.name}.${randomUUID8()}.tmp`);
|
|
52584
|
+
const backup = join21(root, `.${skillPackage.name}.${randomUUID8()}.bak`);
|
|
52044
52585
|
await mkdir7(temporary, { recursive: true });
|
|
52045
52586
|
try {
|
|
52046
52587
|
for (const file of skillPackage.files) {
|
|
52047
52588
|
const path = resolve10(temporary, ...file.path.split("/"));
|
|
52048
52589
|
if (!path.startsWith(`${temporary}${sep8}`))
|
|
52049
52590
|
throw new Error("Skill file escaped temporary directory");
|
|
52050
|
-
await mkdir7(
|
|
52591
|
+
await mkdir7(dirname12(path), { recursive: true });
|
|
52051
52592
|
await writeFile9(path, Buffer.from(file.contentsBase64, "base64"));
|
|
52052
52593
|
await chmod3(path, file.executable ? 493 : 420);
|
|
52053
52594
|
}
|
|
@@ -52078,7 +52619,7 @@ var applySkills = async (payload) => {
|
|
|
52078
52619
|
for (const operation of operations) {
|
|
52079
52620
|
const root = rootPath(operation);
|
|
52080
52621
|
const skillName = operation.kind === "WRITE" ? operation.package.name : operation.skillName;
|
|
52081
|
-
const destination =
|
|
52622
|
+
const destination = join21(root, skillName);
|
|
52082
52623
|
await assertUntracked(operation, destination);
|
|
52083
52624
|
if (operation.kind === "WRITE") {
|
|
52084
52625
|
await writePackage(operation, operation.package);
|
|
@@ -52112,16 +52653,16 @@ import {
|
|
|
52112
52653
|
readFile as readFile11,
|
|
52113
52654
|
realpath as realpath10,
|
|
52114
52655
|
rm as rm17,
|
|
52115
|
-
stat as
|
|
52656
|
+
stat as stat11,
|
|
52116
52657
|
writeFile as writeFile10
|
|
52117
52658
|
} from "node:fs/promises";
|
|
52118
52659
|
import { tmpdir as tmpdir8 } from "node:os";
|
|
52119
|
-
import { join as
|
|
52660
|
+
import { join as join23 } from "node:path";
|
|
52120
52661
|
|
|
52121
52662
|
// src/runs/git-checkpoint.ts
|
|
52122
52663
|
import { copyFile, mkdtemp as mkdtemp7, rm as rm16 } from "node:fs/promises";
|
|
52123
52664
|
import { tmpdir as tmpdir7 } from "node:os";
|
|
52124
|
-
import { join as
|
|
52665
|
+
import { join as join22 } from "node:path";
|
|
52125
52666
|
var PATCH_LIMIT = 2e6;
|
|
52126
52667
|
var SUMMARY_LIMIT = 24e4;
|
|
52127
52668
|
var MANIFEST_LIMIT = 2e6;
|
|
@@ -52355,12 +52896,12 @@ async function captureGitCheckpoint(cwd, runId, kind) {
|
|
|
52355
52896
|
["diff", "--stat", "HEAD"],
|
|
52356
52897
|
SUMMARY_LIMIT
|
|
52357
52898
|
);
|
|
52358
|
-
const directory = await mkdtemp7(
|
|
52899
|
+
const directory = await mkdtemp7(join22(tmpdir7(), "aide-run-index-"));
|
|
52359
52900
|
let worktreeTree = null;
|
|
52360
52901
|
let refName = null;
|
|
52361
52902
|
try {
|
|
52362
52903
|
const actualIndex = await git3(cwd, ["rev-parse", "--git-path", "index"]);
|
|
52363
|
-
const temporaryIndex =
|
|
52904
|
+
const temporaryIndex = join22(directory, "index");
|
|
52364
52905
|
try {
|
|
52365
52906
|
await copyFile(actualIndex, temporaryIndex);
|
|
52366
52907
|
} catch {
|
|
@@ -52425,13 +52966,13 @@ var success2 = {
|
|
|
52425
52966
|
var runWorkflowTerminal = async (payloadValue, timeoutMs, signal2, onLog, context) => {
|
|
52426
52967
|
const payload = parseWorkflowTerminalPayload(payloadValue);
|
|
52427
52968
|
const cwd = await realpath10(payload.cwd);
|
|
52428
|
-
const information = await
|
|
52969
|
+
const information = await stat11(cwd);
|
|
52429
52970
|
if (!information.isDirectory())
|
|
52430
52971
|
throw new Error("Workflow working directory is not a directory");
|
|
52431
|
-
const directory = await mkdtemp8(
|
|
52972
|
+
const directory = await mkdtemp8(join23(tmpdir8(), "aide-workflow-"));
|
|
52432
52973
|
const extension2 = payload.interpreter === "NODE" ? "mjs" : "sh";
|
|
52433
|
-
const scriptPath =
|
|
52434
|
-
const sessionPath =
|
|
52974
|
+
const scriptPath = join23(directory, `step.${extension2}`);
|
|
52975
|
+
const sessionPath = join23(directory, "session.json");
|
|
52435
52976
|
try {
|
|
52436
52977
|
await writeFile10(scriptPath, `${payload.script}
|
|
52437
52978
|
`, { mode: 384 });
|
|
@@ -52522,9 +53063,9 @@ var runWorkflowGitCheckpoint = async (payloadValue, _timeoutMs, signal2) => {
|
|
|
52522
53063
|
|
|
52523
53064
|
// src/handlers/worktrees.ts
|
|
52524
53065
|
import { createWriteStream as createWriteStream3, watch } from "node:fs";
|
|
52525
|
-
import { mkdtemp as mkdtemp9, open as open3, readFile as readFile13, realpath as realpath12, rm as rm19, stat as
|
|
53066
|
+
import { mkdtemp as mkdtemp9, open as open3, readFile as readFile13, realpath as realpath12, rm as rm19, stat as stat12 } from "node:fs/promises";
|
|
52526
53067
|
import { tmpdir as tmpdir9 } from "node:os";
|
|
52527
|
-
import { basename as basename6, dirname as
|
|
53068
|
+
import { basename as basename6, dirname as dirname14, isAbsolute as isAbsolute10, join as join25, relative as relative10 } from "node:path";
|
|
52528
53069
|
|
|
52529
53070
|
// src/handlers/worktree-preparations.ts
|
|
52530
53071
|
import { createHash as createHash8 } from "node:crypto";
|
|
@@ -52538,7 +53079,7 @@ import {
|
|
|
52538
53079
|
rm as rm18,
|
|
52539
53080
|
writeFile as writeFile11
|
|
52540
53081
|
} from "node:fs/promises";
|
|
52541
|
-
import { dirname as
|
|
53082
|
+
import { dirname as dirname13, isAbsolute as isAbsolute9, join as join24, relative as relative9, resolve as resolve11 } from "node:path";
|
|
52542
53083
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
52543
53084
|
var EXCLUDE_BEGIN = "# BEGIN AIDE PREPARATIONS";
|
|
52544
53085
|
var EXCLUDE_END = "# END AIDE PREPARATIONS";
|
|
@@ -52590,7 +53131,7 @@ async function safeTarget(folder, path) {
|
|
|
52590
53131
|
let current = root;
|
|
52591
53132
|
const segments = fromRoot.split(/[\\/]/);
|
|
52592
53133
|
for (const segment of segments.slice(0, -1)) {
|
|
52593
|
-
current =
|
|
53134
|
+
current = join24(current, segment);
|
|
52594
53135
|
try {
|
|
52595
53136
|
const info = await lstat6(current);
|
|
52596
53137
|
if (info.isSymbolicLink()) {
|
|
@@ -52713,7 +53254,7 @@ async function writeExcludeFile(folder, definitions, timeoutMs, signal2) {
|
|
|
52713
53254
|
const entries = definitions.filter((definition) => definition.kind === "WRITE").map((definition) => excludeEntry(definition.path)).sort((left, right) => left.localeCompare(right));
|
|
52714
53255
|
const block = entries.length ? [EXCLUDE_BEGIN, ...entries, EXCLUDE_END].join("\n") : "";
|
|
52715
53256
|
const next = [base, block].filter(Boolean).join("\n\n");
|
|
52716
|
-
await mkdir8(
|
|
53257
|
+
await mkdir8(dirname13(path), { recursive: true });
|
|
52717
53258
|
const temporary = `${path}.${randomUUID9()}.tmp`;
|
|
52718
53259
|
try {
|
|
52719
53260
|
await writeFile11(temporary, next ? `${next}
|
|
@@ -52803,7 +53344,7 @@ async function applyOne(folder, definition, timeoutMs, signal2) {
|
|
|
52803
53344
|
throw error;
|
|
52804
53345
|
}
|
|
52805
53346
|
}
|
|
52806
|
-
await mkdir8(
|
|
53347
|
+
await mkdir8(dirname13(target2), { recursive: true, mode: 493 });
|
|
52807
53348
|
await safeTarget(folder, definition.path);
|
|
52808
53349
|
await writeFile11(target2, contents, { mode: executable ? 493 : 420 });
|
|
52809
53350
|
if (executable) await chmod4(target2, 493);
|
|
@@ -53077,7 +53618,7 @@ async function rebaseInProgress(folder, timeoutMs, signal2) {
|
|
|
53077
53618
|
const candidate = pathResult.stdout.trim();
|
|
53078
53619
|
if (!candidate) continue;
|
|
53079
53620
|
try {
|
|
53080
|
-
await
|
|
53621
|
+
await stat12(isAbsolute10(candidate) ? candidate : join25(folder, candidate));
|
|
53081
53622
|
return true;
|
|
53082
53623
|
} catch {
|
|
53083
53624
|
}
|
|
@@ -53099,7 +53640,7 @@ async function gitStatePathExists(folder, name, timeoutMs, signal2) {
|
|
|
53099
53640
|
throw new Error(`Could not resolve Git state path ${name}`);
|
|
53100
53641
|
}
|
|
53101
53642
|
try {
|
|
53102
|
-
await
|
|
53643
|
+
await stat12(candidate);
|
|
53103
53644
|
return true;
|
|
53104
53645
|
} catch (error) {
|
|
53105
53646
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -53153,7 +53694,7 @@ async function rebaseBranch(folder, timeoutMs, signal2) {
|
|
|
53153
53694
|
if (!candidate) continue;
|
|
53154
53695
|
try {
|
|
53155
53696
|
const headName = (await readFile13(
|
|
53156
|
-
isAbsolute10(candidate) ? candidate :
|
|
53697
|
+
isAbsolute10(candidate) ? candidate : join25(folder, candidate),
|
|
53157
53698
|
"utf8"
|
|
53158
53699
|
)).trim();
|
|
53159
53700
|
if (headName.startsWith("refs/heads/")) {
|
|
@@ -53348,7 +53889,7 @@ async function origin(folder, timeoutMs, signal2) {
|
|
|
53348
53889
|
}
|
|
53349
53890
|
async function validateWorktree2(input, timeoutMs, signal2) {
|
|
53350
53891
|
const folder = await realpath12(input.folder);
|
|
53351
|
-
if (!(await
|
|
53892
|
+
if (!(await stat12(folder)).isDirectory())
|
|
53352
53893
|
throw new Error("Worktree is missing");
|
|
53353
53894
|
const observedGitDirectory = await gitDirectory(folder, timeoutMs, signal2);
|
|
53354
53895
|
if (observedGitDirectory !== input.gitDirectory) {
|
|
@@ -53590,7 +54131,7 @@ function parseNumstat(value) {
|
|
|
53590
54131
|
}
|
|
53591
54132
|
async function untrackedLines(folder, path) {
|
|
53592
54133
|
try {
|
|
53593
|
-
const file = await
|
|
54134
|
+
const file = await stat12(`${folder}/${path}`);
|
|
53594
54135
|
if (!file.isFile() || file.size > 1024 * 1024) return null;
|
|
53595
54136
|
const contents = await readFile13(`${folder}/${path}`);
|
|
53596
54137
|
if (contents.includes(0)) return null;
|
|
@@ -53823,7 +54364,7 @@ async function comparisonSides(input, folder, timeoutMs, signal2) {
|
|
|
53823
54364
|
if (!input.path) return { before: null, after: null };
|
|
53824
54365
|
const path = input.path;
|
|
53825
54366
|
const previousPath = input.previousPath ?? path;
|
|
53826
|
-
const currentPath =
|
|
54367
|
+
const currentPath = join25(folder, path);
|
|
53827
54368
|
if (input.scope === "UNTRACKED") {
|
|
53828
54369
|
return { before: null, after: { kind: "FILE", path: currentPath } };
|
|
53829
54370
|
}
|
|
@@ -53927,7 +54468,7 @@ async function availableSide(side, folder, timeoutMs, signal2) {
|
|
|
53927
54468
|
try {
|
|
53928
54469
|
const resolved = await realpath12(side.path);
|
|
53929
54470
|
const difference = relative10(folder, resolved);
|
|
53930
|
-
return difference !== ".." && !difference.startsWith("../") && (await
|
|
54471
|
+
return difference !== ".." && !difference.startsWith("../") && (await stat12(resolved)).isFile();
|
|
53931
54472
|
} catch {
|
|
53932
54473
|
return false;
|
|
53933
54474
|
}
|
|
@@ -53998,7 +54539,7 @@ async function inspectRequestedDiff(input, folder, timeoutMs, signal2) {
|
|
|
53998
54539
|
let patch;
|
|
53999
54540
|
if (input.scope === "UNTRACKED") {
|
|
54000
54541
|
const bounded = await readBoundedFile(
|
|
54001
|
-
|
|
54542
|
+
join25(folder, input.path),
|
|
54002
54543
|
MAX_DIFF_BYTES
|
|
54003
54544
|
);
|
|
54004
54545
|
const contents = bounded.contents;
|
|
@@ -54180,8 +54721,8 @@ var downloadWorktreeDiffAsset = async (payload, timeoutMs, signal2, _onLog, cont
|
|
|
54180
54721
|
if (!/^\d+$/.test(size) || Number(size) > 20 * 1024 * 1024) {
|
|
54181
54722
|
throw new Error("Diff image exceeds the 20 MiB limit");
|
|
54182
54723
|
}
|
|
54183
|
-
temporaryDirectory = await mkdtemp9(
|
|
54184
|
-
uploadPath =
|
|
54724
|
+
temporaryDirectory = await mkdtemp9(join25(tmpdir9(), "ade-diff-image-"));
|
|
54725
|
+
uploadPath = join25(temporaryDirectory, basename6(input.path));
|
|
54185
54726
|
await writeGitObject(
|
|
54186
54727
|
folder,
|
|
54187
54728
|
selected.specification,
|
|
@@ -54190,7 +54731,7 @@ var downloadWorktreeDiffAsset = async (payload, timeoutMs, signal2, _onLog, cont
|
|
|
54190
54731
|
signal2
|
|
54191
54732
|
);
|
|
54192
54733
|
}
|
|
54193
|
-
const information = await
|
|
54734
|
+
const information = await stat12(uploadPath);
|
|
54194
54735
|
if (!information.isFile() || information.size > 20 * 1024 * 1024) {
|
|
54195
54736
|
throw new Error("Diff image exceeds the 20 MiB limit");
|
|
54196
54737
|
}
|
|
@@ -54474,7 +55015,7 @@ async function chooseNewBranch(folder, candidates, allowedCurrentBranch, timeout
|
|
|
54474
55015
|
}
|
|
54475
55016
|
async function validateBranchRoot(input, timeoutMs, signal2) {
|
|
54476
55017
|
const rootFolder = await realpath12(input.rootFolder);
|
|
54477
|
-
if (!(await
|
|
55018
|
+
if (!(await stat12(rootFolder)).isDirectory()) {
|
|
54478
55019
|
throw new Error("Base repository is missing");
|
|
54479
55020
|
}
|
|
54480
55021
|
if (await origin(rootFolder, timeoutMs, signal2) !== input.expectedOrigin) {
|
|
@@ -54545,8 +55086,8 @@ var branchWorktree = async (payload, timeoutMs, signal2, _onLog, context) => {
|
|
|
54545
55086
|
timeoutMs,
|
|
54546
55087
|
signal2
|
|
54547
55088
|
) : input.candidates[0];
|
|
54548
|
-
const targetFolder = input.action === "CREATE" ?
|
|
54549
|
-
|
|
55089
|
+
const targetFolder = input.action === "CREATE" ? join25(
|
|
55090
|
+
dirname14(rootFolder),
|
|
54550
55091
|
`${basename6(rootFolder)}-${branch.replaceAll("/", "-")}`
|
|
54551
55092
|
) : changeFolder;
|
|
54552
55093
|
const execute2 = () => finishBranchWorktree(
|
|
@@ -54575,7 +55116,7 @@ var branchWorktree = async (payload, timeoutMs, signal2, _onLog, context) => {
|
|
|
54575
55116
|
async function finishBranchWorktree(input, rootFolder, targetFolder, branch, beforeBranch, timeoutMs, signal2) {
|
|
54576
55117
|
if (input.action === "CREATE") {
|
|
54577
55118
|
try {
|
|
54578
|
-
await
|
|
55119
|
+
await stat12(targetFolder);
|
|
54579
55120
|
throw new Error(`Worktree folder already exists: ${targetFolder}`);
|
|
54580
55121
|
} catch (error) {
|
|
54581
55122
|
if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT") {
|
|
@@ -54820,8 +55361,8 @@ async function checkedOutBranchFolder(rootFolder, branch, timeoutMs, signal2) {
|
|
|
54820
55361
|
var checkoutMovedWorktree = async (payload, timeoutMs, signal2, _onLog, context) => {
|
|
54821
55362
|
const input = worktreeMoveCheckoutJobPayload(payload);
|
|
54822
55363
|
const rootFolder = await validateBranchRoot(input, timeoutMs, signal2);
|
|
54823
|
-
const targetFolder = input.mode === "NEW" ?
|
|
54824
|
-
|
|
55364
|
+
const targetFolder = input.mode === "NEW" ? join25(
|
|
55365
|
+
dirname14(rootFolder),
|
|
54825
55366
|
`${basename6(rootFolder)}-${input.branch.replaceAll("/", "-")}`
|
|
54826
55367
|
) : input.folder;
|
|
54827
55368
|
const execute2 = () => finishMovedWorktree(input, rootFolder, timeoutMs, signal2);
|
|
@@ -54881,12 +55422,12 @@ async function finishMovedWorktree(input, rootFolder, timeoutMs, signal2) {
|
|
|
54881
55422
|
`Branch ${input.branch} is already checked out in ${occupiedFolder}`
|
|
54882
55423
|
);
|
|
54883
55424
|
}
|
|
54884
|
-
targetFolder =
|
|
54885
|
-
|
|
55425
|
+
targetFolder = join25(
|
|
55426
|
+
dirname14(rootFolder),
|
|
54886
55427
|
`${basename6(rootFolder)}-${input.branch.replaceAll("/", "-")}`
|
|
54887
55428
|
);
|
|
54888
55429
|
try {
|
|
54889
|
-
await
|
|
55430
|
+
await stat12(targetFolder);
|
|
54890
55431
|
throw new Error(`Worktree folder already exists: ${targetFolder}`);
|
|
54891
55432
|
} catch (error) {
|
|
54892
55433
|
if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT") {
|
|
@@ -55132,7 +55673,7 @@ var prepareWorktree = async (payload, timeoutMs, signal2) => {
|
|
|
55132
55673
|
var deleteWorktree = async (payload, timeoutMs, signal2, _onLog, context) => {
|
|
55133
55674
|
const input = worktreeDeleteJobPayload(payload);
|
|
55134
55675
|
const rootFolder = await realpath12(input.rootFolder);
|
|
55135
|
-
if (!(await
|
|
55676
|
+
if (!(await stat12(rootFolder)).isDirectory()) {
|
|
55136
55677
|
throw new Error("Base repository is missing");
|
|
55137
55678
|
}
|
|
55138
55679
|
if (await origin(rootFolder, timeoutMs, signal2) !== input.expectedOrigin) {
|
|
@@ -55605,7 +56146,7 @@ var operateWorktree = async (payload, timeoutMs, signal2) => {
|
|
|
55605
56146
|
break;
|
|
55606
56147
|
}
|
|
55607
56148
|
case "CLEAR_LOCK":
|
|
55608
|
-
await rm19(
|
|
56149
|
+
await rm19(join25(input.gitDirectory, "index.lock"), { force: true });
|
|
55609
56150
|
break;
|
|
55610
56151
|
case "STASH_ALL":
|
|
55611
56152
|
await runGit(["stash", "push", "--include-untracked"], "Stash failed");
|
|
@@ -57042,7 +57583,7 @@ var CodebaseMonitor = class {
|
|
|
57042
57583
|
import { execFile as execFile4 } from "node:child_process";
|
|
57043
57584
|
import { createHash as createHash9, randomUUID as randomUUID12 } from "node:crypto";
|
|
57044
57585
|
import { mkdir as mkdir10, rm as rm21, realpath as realpath13 } from "node:fs/promises";
|
|
57045
|
-
import { dirname as
|
|
57586
|
+
import { dirname as dirname16, join as join27 } from "node:path";
|
|
57046
57587
|
import { promisify as promisify4 } from "node:util";
|
|
57047
57588
|
|
|
57048
57589
|
// src/runs/journal.ts
|
|
@@ -57054,11 +57595,11 @@ import {
|
|
|
57054
57595
|
readFile as readFile14,
|
|
57055
57596
|
rename as rename9,
|
|
57056
57597
|
rm as rm20,
|
|
57057
|
-
stat as
|
|
57598
|
+
stat as stat13,
|
|
57058
57599
|
truncate,
|
|
57059
57600
|
writeFile as writeFile12
|
|
57060
57601
|
} from "node:fs/promises";
|
|
57061
|
-
import { dirname as
|
|
57602
|
+
import { dirname as dirname15, join as join26 } from "node:path";
|
|
57062
57603
|
var RunJournal = class {
|
|
57063
57604
|
constructor(runId, attemptId) {
|
|
57064
57605
|
this.runId = runId;
|
|
@@ -57078,13 +57619,13 @@ var RunJournal = class {
|
|
|
57078
57619
|
this.attemptId = attemptId;
|
|
57079
57620
|
}
|
|
57080
57621
|
get directory() {
|
|
57081
|
-
return
|
|
57622
|
+
return join26(dirname15(configPath()), "runs", this.runId);
|
|
57082
57623
|
}
|
|
57083
57624
|
get eventsPath() {
|
|
57084
|
-
return
|
|
57625
|
+
return join26(this.directory, "events.jsonl");
|
|
57085
57626
|
}
|
|
57086
57627
|
get statePath() {
|
|
57087
|
-
return
|
|
57628
|
+
return join26(this.directory, "state.json");
|
|
57088
57629
|
}
|
|
57089
57630
|
async load() {
|
|
57090
57631
|
if (this.loaded) return;
|
|
@@ -57106,7 +57647,7 @@ var RunJournal = class {
|
|
|
57106
57647
|
if (!(error instanceof SyntaxError) && error.code !== "ENOENT")
|
|
57107
57648
|
throw error;
|
|
57108
57649
|
}
|
|
57109
|
-
const size = await
|
|
57650
|
+
const size = await stat13(this.eventsPath).then(
|
|
57110
57651
|
({ size: size2 }) => size2,
|
|
57111
57652
|
(error) => {
|
|
57112
57653
|
if (error.code === "ENOENT") return 0;
|
|
@@ -58781,7 +59322,7 @@ var RunManager = class {
|
|
|
58781
59322
|
5
|
|
58782
59323
|
);
|
|
58783
59324
|
await this.completeCommand(command3.id, "SUCCEEDED");
|
|
58784
|
-
await rm21(
|
|
59325
|
+
await rm21(join27(dirname16(configPath()), "runs", run.id, "attachments"), {
|
|
58785
59326
|
recursive: true,
|
|
58786
59327
|
force: true
|
|
58787
59328
|
}).catch(() => void 0);
|
|
@@ -58994,7 +59535,7 @@ var RunManager = class {
|
|
|
58994
59535
|
this.active.delete(run.id);
|
|
58995
59536
|
this.interruptionRequests.delete(run.id);
|
|
58996
59537
|
this.executingCommands.delete(command3.id);
|
|
58997
|
-
await rm21(
|
|
59538
|
+
await rm21(join27(dirname16(configPath()), "runs", run.id, "attachments"), {
|
|
58998
59539
|
recursive: true,
|
|
58999
59540
|
force: true
|
|
59000
59541
|
}).catch(() => void 0);
|
|
@@ -59232,11 +59773,11 @@ var RunManager = class {
|
|
|
59232
59773
|
}
|
|
59233
59774
|
async stageAttachments(runId, attachments) {
|
|
59234
59775
|
if (!attachments.length) return [];
|
|
59235
|
-
const directory =
|
|
59776
|
+
const directory = join27(dirname16(configPath()), "runs", runId, "attachments");
|
|
59236
59777
|
await mkdir10(directory, { recursive: true, mode: 448 });
|
|
59237
59778
|
return Promise.all(
|
|
59238
59779
|
attachments.map(async (attachment) => {
|
|
59239
|
-
const path =
|
|
59780
|
+
const path = join27(
|
|
59240
59781
|
directory,
|
|
59241
59782
|
`${attachment.id}-${safeFilename(attachment.filename)}`
|
|
59242
59783
|
);
|