@ai-development-environment/control-agent 0.0.106 → 0.0.108

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.
Files changed (2) hide show
  1. package/dist/control-agent.js +957 -339
  2. package/package.json +1 -1
@@ -3730,15 +3730,15 @@ var require_windows = __commonJS({
3730
3730
  }
3731
3731
  return false;
3732
3732
  }
3733
- function checkStat(stat12, path, options) {
3734
- if (!stat12.isSymbolicLink() && !stat12.isFile()) {
3733
+ function checkStat(stat13, path, options) {
3734
+ if (!stat13.isSymbolicLink() && !stat13.isFile()) {
3735
3735
  return false;
3736
3736
  }
3737
3737
  return checkPathExt(path, options);
3738
3738
  }
3739
3739
  function isexe(path, options, cb) {
3740
- fs2.stat(path, function(er2, stat12) {
3741
- cb(er2, er2 ? false : checkStat(stat12, path, options));
3740
+ fs2.stat(path, function(er2, stat13) {
3741
+ cb(er2, er2 ? false : checkStat(stat13, path, options));
3742
3742
  });
3743
3743
  }
3744
3744
  function sync(path, options) {
@@ -3754,20 +3754,20 @@ var require_mode = __commonJS({
3754
3754
  isexe.sync = sync;
3755
3755
  var fs2 = __require("fs");
3756
3756
  function isexe(path, options, cb) {
3757
- fs2.stat(path, function(er2, stat12) {
3758
- cb(er2, er2 ? false : checkStat(stat12, options));
3757
+ fs2.stat(path, function(er2, stat13) {
3758
+ cb(er2, er2 ? false : checkStat(stat13, options));
3759
3759
  });
3760
3760
  }
3761
3761
  function sync(path, options) {
3762
3762
  return checkStat(fs2.statSync(path), options);
3763
3763
  }
3764
- function checkStat(stat12, options) {
3765
- return stat12.isFile() && checkMode(stat12, options);
3764
+ function checkStat(stat13, options) {
3765
+ return stat13.isFile() && checkMode(stat13, options);
3766
3766
  }
3767
- function checkMode(stat12, options) {
3768
- var mod = stat12.mode;
3769
- var uid = stat12.uid;
3770
- var gid = stat12.gid;
3767
+ function checkMode(stat13, options) {
3768
+ var mod = stat13.mode;
3769
+ var uid = stat13.uid;
3770
+ var gid = stat13.gid;
3771
3771
  var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
3772
3772
  var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
3773
3773
  var u = parseInt("100", 8);
@@ -4205,7 +4205,7 @@ var require_cross_spawn = __commonJS({
4205
4205
  });
4206
4206
 
4207
4207
  // src/index.ts
4208
- import { rm as rm16 } from "node:fs/promises";
4208
+ import { rm as rm17 } from "node:fs/promises";
4209
4209
 
4210
4210
  // src/config.ts
4211
4211
  import { chmod, mkdir, readFile, rename, writeFile } from "node:fs/promises";
@@ -5236,12 +5236,12 @@ var AgentGraphQLClient = class {
5236
5236
  );
5237
5237
  return data.workflowJobSecrets;
5238
5238
  }
5239
- appendLog(jobId, log) {
5239
+ appendLog(jobId, log2) {
5240
5240
  return this.request(
5241
5241
  `mutation AppendLog($jobId: ID!, $logs: [AgentJobLogInput!]!) {
5242
5242
  appendAgentJobLogs(jobId: $jobId, logs: $logs) { id }
5243
5243
  }`,
5244
- { jobId, logs: [log] }
5244
+ { jobId, logs: [log2] }
5245
5245
  );
5246
5246
  }
5247
5247
  appendCommandOutput(jobId, attemptId, chunks) {
@@ -5489,6 +5489,85 @@ var AgentGraphQLClient = class {
5489
5489
  checksum: metadata.checksum
5490
5490
  };
5491
5491
  }
5492
+ /**
5493
+ * Downloads a dSYM's DWARF file for crash symbolication in 16 MiB ranges,
5494
+ * resuming a partial file and retrying each range, then checks the sha256
5495
+ * the job payload promised.
5496
+ */
5497
+ async downloadDsymDwarf(input) {
5498
+ if (!input.downloadPath.startsWith("/api/agent/dsyms/")) {
5499
+ throw new Error("dSYM download path is not an agent route");
5500
+ }
5501
+ const url = `${this.server}${input.downloadPath}`;
5502
+ let offset = 0;
5503
+ try {
5504
+ offset = (await stat(input.path)).size;
5505
+ } catch {
5506
+ }
5507
+ if (offset > input.sizeBytes) {
5508
+ await rm(input.path, { force: true });
5509
+ offset = 0;
5510
+ }
5511
+ const handle = await open(input.path, offset === 0 ? "w" : "r+");
5512
+ try {
5513
+ while (offset < input.sizeBytes) {
5514
+ const end = Math.min(
5515
+ input.sizeBytes - 1,
5516
+ offset + 16 * 1024 * 1024 - 1
5517
+ );
5518
+ let bytes = null;
5519
+ let attempt = 0;
5520
+ while (!bytes) {
5521
+ let failure = new Error("dSYM range download failed");
5522
+ try {
5523
+ const response = await fetch(url, {
5524
+ headers: this.artifactTransferHeaders({
5525
+ range: `bytes=${offset}-${end}`
5526
+ }),
5527
+ signal: input.signal
5528
+ });
5529
+ if (response.status !== 206 && response.status !== 200) {
5530
+ failure = new Error(
5531
+ `dSYM download failed: HTTP ${response.status} ${await response.text()}`
5532
+ );
5533
+ if (response.status === 401 || response.status === 403) {
5534
+ throw failure;
5535
+ }
5536
+ } else {
5537
+ const received = Buffer.from(await response.arrayBuffer());
5538
+ const expected = end - offset + 1;
5539
+ if (response.status === 200 && offset === 0) {
5540
+ bytes = received.subarray(0, expected);
5541
+ } else if (received.length === expected) {
5542
+ bytes = received;
5543
+ } else {
5544
+ failure = new Error("dSYM range length did not match");
5545
+ }
5546
+ }
5547
+ } catch (error) {
5548
+ if (input.signal.aborted) throw error;
5549
+ if (error === failure) throw error;
5550
+ failure = error instanceof Error ? error : new Error(String(error));
5551
+ }
5552
+ if (bytes) break;
5553
+ if (++attempt >= 5) throw failure;
5554
+ await artifactTransferRetryDelay(attempt, input.signal);
5555
+ }
5556
+ await writeArtifactTransferBytes(handle, bytes, offset);
5557
+ offset += bytes.length;
5558
+ }
5559
+ await handle.sync();
5560
+ } finally {
5561
+ await handle.close();
5562
+ }
5563
+ const digest = createHash("sha256");
5564
+ for await (const chunk of createReadStream(input.path))
5565
+ digest.update(chunk);
5566
+ if (digest.digest("hex") !== input.sha256) {
5567
+ await rm(input.path, { force: true });
5568
+ throw new Error("Downloaded dSYM checksum did not match");
5569
+ }
5570
+ }
5492
5571
  completeJob(jobId, status2, result, error) {
5493
5572
  return this.request(
5494
5573
  `mutation CompleteJob($jobId: ID!, $status: AgentJobStatus!, $result: JSON, $error: String) {
@@ -7754,6 +7833,7 @@ var DEFAULT_BUILD_ADVANCED_SETTINGS = {
7754
7833
  parseTestResults: true,
7755
7834
  parallelTesting: null,
7756
7835
  parallelTestingWorkers: null,
7836
+ collectDsyms: null,
7757
7837
  onlyTesting: [],
7758
7838
  skipTesting: [],
7759
7839
  buildSettingOverrides: {},
@@ -7761,6 +7841,11 @@ var DEFAULT_BUILD_ADVANCED_SETTINGS = {
7761
7841
  priorTestProductsPath: null,
7762
7842
  priorXctestrunPath: null
7763
7843
  };
7844
+ var DSYMS_ARTIFACT_KIND = "DSYMS";
7845
+ var DSYMS_ARTIFACT_FILENAME = "dSYMs.zip";
7846
+ function resolveCollectDsyms(settings, action) {
7847
+ return settings.collectDsyms ?? action === "ARCHIVE";
7848
+ }
7764
7849
  var BUILD_REPORT_KINDS = ["TEST_RESULTS", "CODE_COVERAGE"];
7765
7850
  function objectValue7(value, name) {
7766
7851
  if (!value || typeof value !== "object" || Array.isArray(value)) {
@@ -7895,6 +7980,10 @@ function parseBuildAdvancedSettings(value) {
7895
7980
  if (parallel !== null && typeof parallel !== "boolean") {
7896
7981
  throw new Error("parallelTesting must be a boolean or null");
7897
7982
  }
7983
+ const collectDsyms = input.collectDsyms ?? null;
7984
+ if (collectDsyms !== null && typeof collectDsyms !== "boolean") {
7985
+ throw new Error("collectDsyms must be a boolean or null");
7986
+ }
7898
7987
  return {
7899
7988
  packageResolution: enumValue3(
7900
7989
  input.packageResolution,
@@ -7950,6 +8039,7 @@ function parseBuildAdvancedSettings(value) {
7950
8039
  ),
7951
8040
  parallelTesting: parallel,
7952
8041
  parallelTestingWorkers: workers ?? null,
8042
+ collectDsyms,
7953
8043
  onlyTesting: stringArray2(
7954
8044
  input.onlyTesting,
7955
8045
  "advanced settings.onlyTesting"
@@ -8851,12 +8941,189 @@ function buildCoverageReportPayload(input) {
8851
8941
  };
8852
8942
  }
8853
8943
 
8944
+ // ../agent-contract/src/crashes.ts
8945
+ var CRASH_SYMBOLICATE_JOB_KIND = "ios.crash.symbolicate";
8946
+ var CRASH_JOB_KINDS = [CRASH_SYMBOLICATE_JOB_KIND];
8947
+ var ATOS_BATCH_SIZE = 500;
8948
+ var ATOS_GROUP_DELIMITER = "<|aide-atos|>";
8949
+ var MAX_LOOKUPS = 200;
8950
+ var MAX_OFFSETS = 1e4;
8951
+ function objectValue12(value, name) {
8952
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
8953
+ throw new Error(`${name} must be an object`);
8954
+ }
8955
+ return value;
8956
+ }
8957
+ function stringValue12(value, name, maximum = 4e3) {
8958
+ if (typeof value !== "string" || !value.trim() || value.length > maximum) {
8959
+ throw new Error(
8960
+ `${name} must be a non-empty string of at most ${maximum} characters`
8961
+ );
8962
+ }
8963
+ return value;
8964
+ }
8965
+ function arrayValue(value, name, maximum) {
8966
+ if (!Array.isArray(value)) throw new Error(`${name} must be an array`);
8967
+ if (value.length > maximum) {
8968
+ throw new Error(`${name} may hold at most ${maximum} entries`);
8969
+ }
8970
+ return value;
8971
+ }
8972
+ function hexOffset(value, name) {
8973
+ const text2 = stringValue12(value, name, 32);
8974
+ if (!/^0x[0-9a-f]+$/i.test(text2)) {
8975
+ throw new Error(`${name} must be a 0x hexadecimal offset`);
8976
+ }
8977
+ return `0x${text2.slice(2).toLowerCase()}`;
8978
+ }
8979
+ function normalizeUuid(value) {
8980
+ const compact = value.replaceAll("-", "").replace(/^<|>$/g, "").trim();
8981
+ if (!/^[0-9a-f]{32}$/i.test(compact)) {
8982
+ throw new Error(`${value} is not a binary image UUID`);
8983
+ }
8984
+ return compact.toUpperCase();
8985
+ }
8986
+ function safeFileName(value, name) {
8987
+ const text2 = stringValue12(value, name, 255);
8988
+ if (text2.includes("/") || text2.includes("\\") || text2 === "..") {
8989
+ throw new Error(`${name} must be a plain file name`);
8990
+ }
8991
+ return text2;
8992
+ }
8993
+ function parseCrashSymbolicationPayload(value) {
8994
+ const payload = objectValue12(value, "crash symbolication payload");
8995
+ const dsyms = arrayValue(payload.dsyms, "dsyms", MAX_LOOKUPS).map(
8996
+ (entry, index) => {
8997
+ const dsym = objectValue12(entry, `dsyms[${index}]`);
8998
+ const sha256 = stringValue12(dsym.sha256, `dsyms[${index}].sha256`, 64);
8999
+ if (!/^[0-9a-f]{64}$/.test(sha256)) {
9000
+ throw new Error(`dsyms[${index}].sha256 must be a sha256 digest`);
9001
+ }
9002
+ const size = dsym.sizeBytes;
9003
+ if (typeof size !== "number" || !Number.isSafeInteger(size) || size < 1) {
9004
+ throw new Error(`dsyms[${index}].sizeBytes must be a positive integer`);
9005
+ }
9006
+ const downloadPath = stringValue12(
9007
+ dsym.downloadPath,
9008
+ `dsyms[${index}].downloadPath`
9009
+ );
9010
+ if (!downloadPath.startsWith("/api/agent/dsyms/")) {
9011
+ throw new Error(`dsyms[${index}].downloadPath is not an agent route`);
9012
+ }
9013
+ return {
9014
+ dsymId: stringValue12(dsym.dsymId, `dsyms[${index}].dsymId`, 200),
9015
+ sha256,
9016
+ sizeBytes: size,
9017
+ binaryName: safeFileName(dsym.binaryName, `dsyms[${index}].binaryName`),
9018
+ downloadPath
9019
+ };
9020
+ }
9021
+ );
9022
+ const known = new Set(dsyms.map((dsym) => dsym.dsymId));
9023
+ let offsetCount = 0;
9024
+ const lookups = arrayValue(payload.lookups, "lookups", MAX_LOOKUPS).map(
9025
+ (entry, index) => {
9026
+ const lookup = objectValue12(entry, `lookups[${index}]`);
9027
+ const dsymId = stringValue12(lookup.dsymId, `lookups[${index}].dsymId`);
9028
+ if (!known.has(dsymId)) {
9029
+ throw new Error(`lookups[${index}].dsymId is not listed in dsyms`);
9030
+ }
9031
+ const arch2 = stringValue12(lookup.arch, `lookups[${index}].arch`, 32);
9032
+ if (!/^[a-z0-9_]+$/i.test(arch2)) {
9033
+ throw new Error(`lookups[${index}].arch is invalid`);
9034
+ }
9035
+ const offsets = arrayValue(
9036
+ lookup.offsets,
9037
+ `lookups[${index}].offsets`,
9038
+ MAX_OFFSETS
9039
+ ).map(
9040
+ (offset, position) => hexOffset(offset, `lookups[${index}].offsets[${position}]`)
9041
+ );
9042
+ offsetCount += offsets.length;
9043
+ if (offsetCount > MAX_OFFSETS) {
9044
+ throw new Error(`A crash may request at most ${MAX_OFFSETS} offsets`);
9045
+ }
9046
+ return {
9047
+ dsymId,
9048
+ uuid: normalizeUuid(
9049
+ stringValue12(lookup.uuid, `lookups[${index}].uuid`, 64)
9050
+ ),
9051
+ arch: arch2,
9052
+ offsets
9053
+ };
9054
+ }
9055
+ );
9056
+ return {
9057
+ crashId: stringValue12(payload.crashId, "crashId", 200),
9058
+ dsyms,
9059
+ lookups
9060
+ };
9061
+ }
9062
+ function atosArguments(input) {
9063
+ return [
9064
+ "atos",
9065
+ "-arch",
9066
+ input.arch,
9067
+ "-o",
9068
+ input.dwarfPath,
9069
+ "--offset",
9070
+ "-i",
9071
+ "--fullPath",
9072
+ "-d",
9073
+ ATOS_GROUP_DELIMITER,
9074
+ "-f",
9075
+ input.offsetsFile
9076
+ ];
9077
+ }
9078
+ var ATOS_LINE = /^(.+?) \(in ([^)]+)\)(?: \((.+):(\d+)\))?(?: \+ (\d+))?$/;
9079
+ function parseAtosLine(line) {
9080
+ const text2 = line.trim();
9081
+ if (!text2 || /^0x[0-9a-f]+$/i.test(text2)) return null;
9082
+ const match = ATOS_LINE.exec(text2);
9083
+ if (!match) {
9084
+ return {
9085
+ symbol: text2,
9086
+ image: null,
9087
+ file: null,
9088
+ line: null,
9089
+ symbolOffset: null
9090
+ };
9091
+ }
9092
+ const [, symbol, image, file, lineNumber, offset] = match;
9093
+ return {
9094
+ symbol,
9095
+ image: image ?? null,
9096
+ file: file ?? null,
9097
+ line: lineNumber ? Number(lineNumber) : null,
9098
+ symbolOffset: offset ? Number(offset) : null
9099
+ };
9100
+ }
9101
+ function parseAtosOutput(stdout, offsets) {
9102
+ const groups = [[]];
9103
+ for (const line of stdout.split(/\r?\n/)) {
9104
+ if (line.trim() === ATOS_GROUP_DELIMITER) groups.push([]);
9105
+ else if (line.trim()) groups[groups.length - 1].push(line);
9106
+ }
9107
+ if (!groups[groups.length - 1].length) groups.pop();
9108
+ if (groups.length !== offsets.length) {
9109
+ throw new Error(
9110
+ `atos answered ${groups.length} addresses but ${offsets.length} were requested`
9111
+ );
9112
+ }
9113
+ return offsets.map((offset, index) => ({
9114
+ offset,
9115
+ frames: groups[index].map(parseAtosLine).filter(
9116
+ (frame) => frame !== null
9117
+ )
9118
+ }));
9119
+ }
9120
+
8854
9121
  // ../agent-contract/src/cli-health.ts
8855
9122
  var CLI_HEALTH_JOB_KIND = "cli.health";
8856
9123
  var CLI_HEALTH_MAX_CHECKS = 27;
8857
9124
  var CLI_HEALTH_MAX_OUTPUT_BYTES = 32 * 1024;
8858
9125
  var CLI_HEALTH_CHECK_TIMEOUT_MS = 15e3;
8859
- function objectValue12(value, name) {
9126
+ function objectValue13(value, name) {
8860
9127
  if (!value || typeof value !== "object" || Array.isArray(value)) {
8861
9128
  throw new Error(`${name} must be an object`);
8862
9129
  }
@@ -8864,7 +9131,7 @@ function objectValue12(value, name) {
8864
9131
  }
8865
9132
  function checkDefinition(value, index) {
8866
9133
  const name = `cli.health checks[${index}]`;
8867
- const check = objectValue12(value, name);
9134
+ const check = objectValue13(value, name);
8868
9135
  const allowed = /* @__PURE__ */ new Set(["id", "name", "command", "builtIn"]);
8869
9136
  const unexpected = Object.keys(check).find((key) => !allowed.has(key));
8870
9137
  if (unexpected) throw new Error(`Unexpected ${name} field: ${unexpected}`);
@@ -8886,7 +9153,7 @@ function checkDefinition(value, index) {
8886
9153
  return check;
8887
9154
  }
8888
9155
  function parseCliHealthJobPayload(value) {
8889
- const payload = objectValue12(value, "cli.health payload");
9156
+ const payload = objectValue13(value, "cli.health payload");
8890
9157
  const unexpected = Object.keys(payload).find((key) => key !== "checks");
8891
9158
  if (unexpected)
8892
9159
  throw new Error(`Unexpected cli.health payload field: ${unexpected}`);
@@ -8927,7 +9194,7 @@ var TAILSCALE_DESTINATION_PROTOCOLS = [
8927
9194
  "TCP"
8928
9195
  ];
8929
9196
  var TAILSCALE_PROXY_PROTOCOLS = ["NONE", "V1", "V2"];
8930
- function objectValue13(value, name) {
9197
+ function objectValue14(value, name) {
8931
9198
  if (!value || typeof value !== "object" || Array.isArray(value)) {
8932
9199
  throw new Error(`${name} must be an object`);
8933
9200
  }
@@ -8994,7 +9261,7 @@ function appCapabilities(value) {
8994
9261
  ].sort();
8995
9262
  }
8996
9263
  function parseTailscaleServeRoute(value) {
8997
- const route = objectValue13(value, "Tailscale Serve route");
9264
+ const route = objectValue14(value, "Tailscale Serve route");
8998
9265
  exactKeys3(
8999
9266
  route,
9000
9267
  [
@@ -9014,7 +9281,7 @@ function parseTailscaleServeRoute(value) {
9014
9281
  "Tailscale Serve protocol"
9015
9282
  );
9016
9283
  const listenPort = integerPort(route.listenPort, "Tailscale listen port");
9017
- const destination = objectValue13(
9284
+ const destination = objectValue14(
9018
9285
  route.destination,
9019
9286
  "Tailscale Serve destination"
9020
9287
  );
@@ -9075,12 +9342,12 @@ function parseTailscaleServeRoute(value) {
9075
9342
  };
9076
9343
  }
9077
9344
  function tailscaleServeInspectPayload(value) {
9078
- const payload = objectValue13(value, "Tailscale Serve inspect payload");
9345
+ const payload = objectValue14(value, "Tailscale Serve inspect payload");
9079
9346
  exactKeys3(payload, ["operationId"], "Tailscale Serve inspect payload");
9080
9347
  return { operationId: requiredString(payload.operationId, "operationId") };
9081
9348
  }
9082
9349
  function mutationPayload(value, allowPrevious) {
9083
- const payload = objectValue13(value, "Tailscale Serve mutation payload");
9350
+ const payload = objectValue14(value, "Tailscale Serve mutation payload");
9084
9351
  exactKeys3(
9085
9352
  payload,
9086
9353
  [
@@ -9135,7 +9402,9 @@ var PORTABLE_AGENT_CAPABILITIES = [
9135
9402
  var MACOS_AGENT_CAPABILITIES = [
9136
9403
  ...BUILD_DATA_JOB_KINDS,
9137
9404
  ...IOS_BUILD_JOB_KINDS,
9138
- ...SIGNING_ASSET_JOB_KINDS
9405
+ ...SIGNING_ASSET_JOB_KINDS,
9406
+ // `atos` ships with Xcode, so only a Mac can name crash frames.
9407
+ ...CRASH_JOB_KINDS
9139
9408
  ];
9140
9409
  var UNIX_AGENT_CAPABILITIES = [...TAILSCALE_SERVE_JOB_KINDS];
9141
9410
  function capabilitiesForPlatform(targetPlatform) {
@@ -10951,7 +11220,7 @@ function testArguments(settings) {
10951
11220
  for (const test of settings.skipTesting) args.push(`-skip-testing:${test}`);
10952
11221
  return args;
10953
11222
  }
10954
- function advancedArguments(settings) {
11223
+ function advancedArguments(settings, action) {
10955
11224
  const args = [];
10956
11225
  if (settings.packageResolution === "RESOLVED_ONLY") {
10957
11226
  args.push("-onlyUsePackageVersionsFromResolvedFile");
@@ -10985,6 +11254,9 @@ function advancedArguments(settings) {
10985
11254
  args.push("-allowProvisioningDeviceRegistration");
10986
11255
  }
10987
11256
  args.push(...testArguments(settings));
11257
+ if (resolveCollectDsyms(settings, action) && !settings.buildSettingOverrides.DEBUG_INFORMATION_FORMAT) {
11258
+ args.push("DEBUG_INFORMATION_FORMAT=dwarf-with-dsym");
11259
+ }
10988
11260
  for (const [key, value] of Object.entries(settings.buildSettingOverrides)) {
10989
11261
  args.push(`${key}=${value}`);
10990
11262
  }
@@ -11024,7 +11296,7 @@ function xcodeBuildArguments(input) {
11024
11296
  "-hideShellScriptEnvironment",
11025
11297
  "-resultBundlePath",
11026
11298
  resultBundle,
11027
- ...usesCapturedTestProducts ? testArguments(input.advancedSettings) : advancedArguments(input.advancedSettings)
11299
+ ...usesCapturedTestProducts ? testArguments(input.advancedSettings) : advancedArguments(input.advancedSettings, input.action)
11028
11300
  ];
11029
11301
  if (input.action === "ARCHIVE") {
11030
11302
  args.push(
@@ -11063,7 +11335,7 @@ function xcodeBuildSettingsArguments(input, folder = input.folder) {
11063
11335
  input.configuration,
11064
11336
  "-destination",
11065
11337
  destinationArgument(input.destination),
11066
- ...advancedArguments(input.advancedSettings),
11338
+ ...advancedArguments(input.advancedSettings, input.action),
11067
11339
  "-showBuildSettings",
11068
11340
  "-json"
11069
11341
  ];
@@ -11106,7 +11378,7 @@ async function runHook(options) {
11106
11378
  const prefix = `${String(options.script.position).padStart(3, "0")}-${options.script.id}`;
11107
11379
  const file = join3(directory, `${prefix}.mjs`);
11108
11380
  const runner = join3(directory, `${prefix}.runner.mjs`);
11109
- const log = join3(directory, `${prefix}.log`);
11381
+ const log2 = join3(directory, `${prefix}.log`);
11110
11382
  const started = Date.now();
11111
11383
  try {
11112
11384
  await mkdir2(directory, { recursive: true, mode: 448 });
@@ -11161,7 +11433,7 @@ if (typeof hookModule.default === "function") {
11161
11433
  phase: options.phase,
11162
11434
  scope: "BUILD",
11163
11435
  scopeId: options.input.buildId,
11164
- additionalLogPath: log
11436
+ additionalLogPath: log2
11165
11437
  });
11166
11438
  const failed = result.exitCode !== 0 || result.timedOut;
11167
11439
  return {
@@ -11171,7 +11443,7 @@ if (typeof hookModule.default === "function") {
11171
11443
  exitCode: result.exitCode,
11172
11444
  durationMs: Date.now() - started,
11173
11445
  causedBuildFailure: failed && options.script.failureBehavior === "FAIL_BUILD",
11174
- outputRelativePath: relative3(options.input.artifactDirectory, log),
11446
+ outputRelativePath: relative3(options.input.artifactDirectory, log2),
11175
11447
  error: failed ? cleanError(result.output || "Build hook failed") : null
11176
11448
  };
11177
11449
  } catch (hookError) {
@@ -11184,7 +11456,7 @@ if (typeof hookModule.default === "function") {
11184
11456
  exitCode: null,
11185
11457
  durationMs: Date.now() - started,
11186
11458
  causedBuildFailure: !options.signal.aborted && options.script.failureBehavior === "FAIL_BUILD",
11187
- outputRelativePath: relative3(options.input.artifactDirectory, log),
11459
+ outputRelativePath: relative3(options.input.artifactDirectory, log2),
11188
11460
  error
11189
11461
  };
11190
11462
  }
@@ -11706,6 +11978,110 @@ async function findFiles(root, predicate, limit = 20) {
11706
11978
  }
11707
11979
  return results;
11708
11980
  }
11981
+ function parseDwarfdumpUuids(output) {
11982
+ const found = [];
11983
+ for (const line of output.split(/\r?\n/)) {
11984
+ const match = /^UUID:\s+([0-9A-Fa-f-]{36})\s+\(([^)]+)\)\s+(.+)$/.exec(
11985
+ line.trim()
11986
+ );
11987
+ if (match) {
11988
+ found.push({
11989
+ uuid: match[1].toUpperCase(),
11990
+ arch: match[2],
11991
+ name: basename2(match[3])
11992
+ });
11993
+ }
11994
+ }
11995
+ return found;
11996
+ }
11997
+ async function dwarfdumpUuids(paths, signal) {
11998
+ if (!paths.length) return [];
11999
+ const result = await command(
12000
+ "xcrun",
12001
+ ["dwarfdump", "--uuid", ...paths],
12002
+ 6e4,
12003
+ signal,
12004
+ void 0,
12005
+ xcodeEnvironment()
12006
+ );
12007
+ return parseDwarfdumpUuids(result.stdout);
12008
+ }
12009
+ async function captureDsyms(input, entries, signal) {
12010
+ const sources = [];
12011
+ const archiveDsyms = join3(
12012
+ input.artifactDirectory,
12013
+ "archive.xcarchive",
12014
+ "dSYMs"
12015
+ );
12016
+ if (input.action === "ARCHIVE" && await pathExists(archiveDsyms)) {
12017
+ for (const name of await readdir(archiveDsyms)) {
12018
+ if (name.endsWith(".dSYM")) sources.push(join3(archiveDsyms, name));
12019
+ }
12020
+ } else {
12021
+ const binaries = entries.map(
12022
+ ({ buildSettings: settings }) => settings.TARGET_BUILD_DIR && settings.EXECUTABLE_PATH ? join3(settings.TARGET_BUILD_DIR, settings.EXECUTABLE_PATH) : null
12023
+ ).filter((path) => Boolean(path));
12024
+ const existing = [];
12025
+ for (const binary of new Set(binaries)) {
12026
+ if (await pathExists(binary)) existing.push(binary);
12027
+ }
12028
+ const built = new Set(
12029
+ (await dwarfdumpUuids(existing, signal)).map((entry) => entry.uuid)
12030
+ );
12031
+ const folders = new Set(
12032
+ entries.map(({ buildSettings: settings }) => settings.DWARF_DSYM_FOLDER_PATH).filter((path) => Boolean(path))
12033
+ );
12034
+ for (const folder of folders) {
12035
+ if (!await pathExists(folder)) continue;
12036
+ for (const name of await readdir(folder)) {
12037
+ if (!name.endsWith(".dSYM")) continue;
12038
+ const bundle = join3(folder, name);
12039
+ const uuids = await dwarfdumpUuids([bundle], signal);
12040
+ if (uuids.some((entry) => built.has(entry.uuid))) sources.push(bundle);
12041
+ }
12042
+ }
12043
+ }
12044
+ if (!sources.length) return null;
12045
+ const staging = join3(input.artifactDirectory, "dSYMs");
12046
+ const zipPath = join3(input.artifactDirectory, DSYMS_ARTIFACT_FILENAME);
12047
+ await rm3(staging, { recursive: true, force: true });
12048
+ await rm3(zipPath, { force: true });
12049
+ await mkdir2(staging, { recursive: true, mode: 448 });
12050
+ try {
12051
+ for (const source of sources) {
12052
+ await cp(source, join3(staging, basename2(source)), {
12053
+ recursive: true,
12054
+ preserveTimestamps: true
12055
+ });
12056
+ }
12057
+ const zipped = await command(
12058
+ "/usr/bin/ditto",
12059
+ ["-c", "-k", "--norsrc", "--noextattr", "--keepParent", staging, zipPath],
12060
+ 10 * 6e4,
12061
+ signal
12062
+ );
12063
+ if (zipped.exitCode !== 0) {
12064
+ throw new Error(
12065
+ `Could not zip dSYMs: ${zipped.stderr.trim() || `ditto exited with ${zipped.exitCode}`}`
12066
+ );
12067
+ }
12068
+ const uuids = await dwarfdumpUuids(
12069
+ sources.map((source) => join3(staging, basename2(source))),
12070
+ signal
12071
+ );
12072
+ return await artifact(
12073
+ input.artifactDirectory,
12074
+ DSYMS_ARTIFACT_KIND,
12075
+ zipPath,
12076
+ {
12077
+ count: sources.length,
12078
+ uuids
12079
+ }
12080
+ );
12081
+ } finally {
12082
+ await rm3(staging, { recursive: true, force: true });
12083
+ }
12084
+ }
11709
12085
  async function captureArtifacts(input, folder, signal, includeProducts = true) {
11710
12086
  const artifacts = [];
11711
12087
  const resultBundle = join3(input.artifactDirectory, "result.xcresult");
@@ -11749,8 +12125,22 @@ async function captureArtifacts(input, folder, signal, includeProducts = true) {
11749
12125
  folder,
11750
12126
  xcodeEnvironment()
11751
12127
  );
11752
- if (settingsResult.exitCode !== 0) return artifacts;
12128
+ const collectDsyms = resolveCollectDsyms(
12129
+ input.advancedSettings,
12130
+ input.action
12131
+ );
12132
+ if (settingsResult.exitCode !== 0) {
12133
+ if (collectDsyms) {
12134
+ const dsyms = await captureDsyms(input, [], signal);
12135
+ if (dsyms) artifacts.push(dsyms);
12136
+ }
12137
+ return artifacts;
12138
+ }
11753
12139
  const entries = parseBuildSettings(settingsResult.stdout);
12140
+ if (collectDsyms) {
12141
+ const dsyms = await captureDsyms(input, entries, signal);
12142
+ if (dsyms) artifacts.push(dsyms);
12143
+ }
11754
12144
  const apps = entries.filter((entry) => {
11755
12145
  const settings = entry.buildSettings;
11756
12146
  return settings.WRAPPER_EXTENSION === "app" || settings.FULL_PRODUCT_NAME?.endsWith(".app");
@@ -12734,9 +13124,220 @@ var importCoverageReport = async (payloadValue, timeoutMs, signal, onLog) => {
12734
13124
  };
12735
13125
  };
12736
13126
 
13127
+ // src/handlers/crashes.ts
13128
+ import { randomUUID as randomUUID2 } from "node:crypto";
13129
+ import {
13130
+ mkdir as mkdir3,
13131
+ readdir as readdir2,
13132
+ rename as rename3,
13133
+ rm as rm4,
13134
+ stat as stat4,
13135
+ utimes,
13136
+ writeFile as writeFile4
13137
+ } from "node:fs/promises";
13138
+ import { homedir as homedir3, tmpdir as tmpdir3 } from "node:os";
13139
+ import { join as join5 } from "node:path";
13140
+ var CACHE_LIMIT_BYTES = 10 * 1024 ** 3;
13141
+ var ATOS_OUTPUT_LIMIT_BYTES = 16 * 1024 * 1024;
13142
+ var successfulProcess3 = {
13143
+ exitCode: 0,
13144
+ signal: null,
13145
+ timedOut: false,
13146
+ cancelled: false
13147
+ };
13148
+ function dsymCacheDirectory() {
13149
+ if (process.env.CONTROL_AGENT_DSYM_CACHE) {
13150
+ return process.env.CONTROL_AGENT_DSYM_CACHE;
13151
+ }
13152
+ return process.platform === "darwin" ? join5(homedir3(), "Library", "Caches", "control-agent", "dsym-cache") : join5(homedir3(), ".cache", "control-agent", "dsym-cache");
13153
+ }
13154
+ async function log(onLog, sequence, message, stream = "SYSTEM") {
13155
+ await onLog({
13156
+ sequence,
13157
+ stream,
13158
+ message,
13159
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
13160
+ });
13161
+ }
13162
+ async function cachedDwarf(dsym, cache, download, signal) {
13163
+ const folder = join5(cache, dsym.sha256);
13164
+ const path = join5(folder, dsym.binaryName);
13165
+ try {
13166
+ const existing = await stat4(path);
13167
+ if (existing.size === dsym.sizeBytes) {
13168
+ const now = /* @__PURE__ */ new Date();
13169
+ await utimes(folder, now, now).catch(() => void 0);
13170
+ return { path, downloaded: false };
13171
+ }
13172
+ } catch {
13173
+ }
13174
+ await mkdir3(folder, { recursive: true, mode: 448 });
13175
+ const partial = join5(folder, `.${dsym.binaryName}.${randomUUID2()}.partial`);
13176
+ try {
13177
+ await download({
13178
+ downloadPath: dsym.downloadPath,
13179
+ path: partial,
13180
+ sizeBytes: dsym.sizeBytes,
13181
+ sha256: dsym.sha256,
13182
+ signal
13183
+ });
13184
+ await rename3(partial, path);
13185
+ } finally {
13186
+ await rm4(partial, { force: true });
13187
+ }
13188
+ return { path, downloaded: true };
13189
+ }
13190
+ async function trimDsymCache(cache, keep, limit = CACHE_LIMIT_BYTES) {
13191
+ let entries;
13192
+ try {
13193
+ entries = await readdir2(cache);
13194
+ } catch {
13195
+ return;
13196
+ }
13197
+ const folders = [];
13198
+ for (const name of entries) {
13199
+ const folder = join5(cache, name);
13200
+ try {
13201
+ const information = await stat4(folder);
13202
+ if (!information.isDirectory()) continue;
13203
+ let size = 0;
13204
+ for (const file of await readdir2(folder)) {
13205
+ size += (await stat4(join5(folder, file))).size;
13206
+ }
13207
+ folders.push({ name, size, used: information.mtimeMs });
13208
+ } catch {
13209
+ }
13210
+ }
13211
+ let total = folders.reduce((sum, folder) => sum + folder.size, 0);
13212
+ for (const folder of folders.sort((left, right) => left.used - right.used)) {
13213
+ if (total <= limit) break;
13214
+ if (keep.has(folder.name)) continue;
13215
+ await rm4(join5(cache, folder.name), { recursive: true, force: true });
13216
+ total -= folder.size;
13217
+ }
13218
+ }
13219
+ async function xcodeVersion(signal) {
13220
+ const result = await captureCommand({
13221
+ command: "xcrun",
13222
+ args: ["xcodebuild", "-version"],
13223
+ timeoutMs: 3e4,
13224
+ signal
13225
+ }).catch(() => null);
13226
+ if (!result || result.exitCode !== 0) return null;
13227
+ return result.stdout.trim().split(/\r?\n/).join(" ") || null;
13228
+ }
13229
+ var symbolicateCrash = async (payloadValue, timeoutMs, signal, onLog, context) => {
13230
+ const payload = parseCrashSymbolicationPayload(payloadValue);
13231
+ if (!context?.downloadDsymDwarf) {
13232
+ throw new Error("This agent cannot download dSYMs");
13233
+ }
13234
+ const deadline = Date.now() + timeoutMs;
13235
+ const remaining = () => Math.max(0, deadline - Date.now());
13236
+ const cache = dsymCacheDirectory();
13237
+ let sequence = 0;
13238
+ const dwarfPaths = /* @__PURE__ */ new Map();
13239
+ const downloadErrors = /* @__PURE__ */ new Map();
13240
+ for (const dsym of payload.dsyms) {
13241
+ if (signal.aborted) return { ...successfulProcess3, cancelled: true };
13242
+ try {
13243
+ const { path, downloaded } = await cachedDwarf(
13244
+ dsym,
13245
+ cache,
13246
+ context.downloadDsymDwarf,
13247
+ signal
13248
+ );
13249
+ dwarfPaths.set(dsym.dsymId, path);
13250
+ await log(
13251
+ onLog,
13252
+ sequence++,
13253
+ `${downloaded ? "Downloaded" : "Using cached"} ${dsym.binaryName} (${dsym.sha256.slice(0, 12)})`
13254
+ );
13255
+ } catch (error) {
13256
+ if (signal.aborted) return { ...successfulProcess3, cancelled: true };
13257
+ const message = error instanceof Error ? error.message : String(error);
13258
+ downloadErrors.set(dsym.dsymId, message);
13259
+ await log(
13260
+ onLog,
13261
+ sequence++,
13262
+ `Could not download ${dsym.binaryName}: ${message}`,
13263
+ "STDERR"
13264
+ );
13265
+ }
13266
+ }
13267
+ const workFolder = join5(tmpdir3(), `control-agent-atos-${randomUUID2()}`);
13268
+ await mkdir3(workFolder, { recursive: true, mode: 448 });
13269
+ const lookups = [];
13270
+ try {
13271
+ for (const lookup of payload.lookups) {
13272
+ const dwarfPath = dwarfPaths.get(lookup.dsymId);
13273
+ const result = {
13274
+ dsymId: lookup.dsymId,
13275
+ uuid: lookup.uuid,
13276
+ results: [],
13277
+ error: dwarfPath ? null : downloadErrors.get(lookup.dsymId) ?? "The dSYM is unavailable"
13278
+ };
13279
+ lookups.push(result);
13280
+ if (!dwarfPath) continue;
13281
+ for (let start = 0; start < lookup.offsets.length; start += ATOS_BATCH_SIZE) {
13282
+ const batch = lookup.offsets.slice(start, start + ATOS_BATCH_SIZE);
13283
+ const offsetsFile = join5(workFolder, `${lookup.uuid}-${start}.txt`);
13284
+ await writeFile4(offsetsFile, `${batch.join("\n")}
13285
+ `, { mode: 384 });
13286
+ const run = await captureCommand({
13287
+ command: "xcrun",
13288
+ args: atosArguments({ arch: lookup.arch, dwarfPath, offsetsFile }),
13289
+ timeoutMs: remaining(),
13290
+ signal,
13291
+ maxOutputBytes: ATOS_OUTPUT_LIMIT_BYTES
13292
+ });
13293
+ if (run.cancelled || run.timedOut) {
13294
+ return {
13295
+ exitCode: run.exitCode,
13296
+ signal: run.signal,
13297
+ timedOut: run.timedOut,
13298
+ cancelled: run.cancelled
13299
+ };
13300
+ }
13301
+ if (run.exitCode !== 0) {
13302
+ result.error = run.stderr.trim().slice(0, 1e3) || `atos exited with code ${run.exitCode}`;
13303
+ break;
13304
+ }
13305
+ if (run.outputTruncated) {
13306
+ result.error = "atos printed more output than the agent keeps";
13307
+ break;
13308
+ }
13309
+ try {
13310
+ result.results.push(...parseAtosOutput(run.stdout, batch));
13311
+ } catch (error) {
13312
+ result.error = error instanceof Error ? error.message : String(error);
13313
+ break;
13314
+ }
13315
+ }
13316
+ const named = result.results.filter((entry) => entry.frames.length);
13317
+ await log(
13318
+ onLog,
13319
+ sequence++,
13320
+ `${lookup.uuid} (${lookup.arch}): named ${named.length} of ${lookup.offsets.length} addresses${result.error ? `; ${result.error}` : ""}`,
13321
+ result.error ? "STDERR" : "SYSTEM"
13322
+ );
13323
+ }
13324
+ } finally {
13325
+ await rm4(workFolder, { recursive: true, force: true });
13326
+ }
13327
+ await trimDsymCache(
13328
+ cache,
13329
+ new Set(payload.dsyms.map((dsym) => dsym.sha256))
13330
+ ).catch(() => void 0);
13331
+ return {
13332
+ ...successfulProcess3,
13333
+ lookups,
13334
+ xcodeVersion: await xcodeVersion(signal)
13335
+ };
13336
+ };
13337
+
12737
13338
  // src/handlers/cli-health.ts
12738
13339
  import { Buffer as Buffer2 } from "node:buffer";
12739
- import { homedir as homedir3 } from "node:os";
13340
+ import { homedir as homedir4 } from "node:os";
12740
13341
  var CONCURRENCY = 4;
12741
13342
  var ANSI_PATTERN = /\u001B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g;
12742
13343
  var CONTROL_PATTERN = /[\u0000-\u0008\u000B\u000C\u000E-\u001A\u001C-\u001F\u007F]/g;
@@ -12807,7 +13408,7 @@ async function runCliHealthCheck(check, signal, onLog, options = {}) {
12807
13408
  const result = await captureCommand({
12808
13409
  command: shell,
12809
13410
  args: ["-lc", check.command],
12810
- cwd: options.cwd || homedir3(),
13411
+ cwd: options.cwd || homedir4(),
12811
13412
  timeoutMs,
12812
13413
  signal,
12813
13414
  maxOutputBytes: CLI_HEALTH_MAX_OUTPUT_BYTES
@@ -12862,8 +13463,8 @@ async function runCliHealth(payload, _timeoutMs, signal, onLog) {
12862
13463
  let next = 0;
12863
13464
  let logSequence = 0;
12864
13465
  let logChain = Promise.resolve();
12865
- const appendSweepLog = (log) => {
12866
- const sequenced = { ...log, sequence: logSequence++ };
13466
+ const appendSweepLog = (log2) => {
13467
+ const sequenced = { ...log2, sequence: logSequence++ };
12867
13468
  const task = logChain.then(() => onLog(sequenced));
12868
13469
  logChain = task.catch(() => void 0);
12869
13470
  return task;
@@ -12893,28 +13494,28 @@ async function runCliHealth(payload, _timeoutMs, signal, onLog) {
12893
13494
  }
12894
13495
 
12895
13496
  // src/handlers/signing.ts
12896
- import { createHash as createHash6, randomUUID as randomUUID2, X509Certificate } from "node:crypto";
13497
+ import { createHash as createHash6, randomUUID as randomUUID3, X509Certificate } from "node:crypto";
12897
13498
  import {
12898
- mkdir as mkdir3,
13499
+ mkdir as mkdir4,
12899
13500
  mkdtemp as mkdtemp3,
12900
13501
  readFile as readFile4,
12901
- readdir as readdir2,
12902
- rm as rm4,
12903
- stat as stat4,
12904
- writeFile as writeFile4
13502
+ readdir as readdir3,
13503
+ rm as rm5,
13504
+ stat as stat5,
13505
+ writeFile as writeFile5
12905
13506
  } from "node:fs/promises";
12906
- import { homedir as homedir4, tmpdir as tmpdir3 } from "node:os";
12907
- import { basename as basename3, join as join5, relative as relative5, sep as sep5 } from "node:path";
13507
+ import { homedir as homedir5, tmpdir as tmpdir4 } from "node:os";
13508
+ import { basename as basename3, join as join6, relative as relative5, sep as sep5 } from "node:path";
12908
13509
  var PROFILE_DIRECTORIES = [
12909
- join5(
12910
- homedir4(),
13510
+ join6(
13511
+ homedir5(),
12911
13512
  "Library",
12912
13513
  "Developer",
12913
13514
  "Xcode",
12914
13515
  "UserData",
12915
13516
  "Provisioning Profiles"
12916
13517
  ),
12917
- join5(homedir4(), "Library", "MobileDevice", "Provisioning Profiles")
13518
+ join6(homedir5(), "Library", "MobileDevice", "Provisioning Profiles")
12918
13519
  ];
12919
13520
  var PROFILE_EXTENSIONS = [".mobileprovision", ".provisionprofile"];
12920
13521
  function text(value) {
@@ -12998,7 +13599,7 @@ async function readProfiles(timeoutMs, signal) {
12998
13599
  for (const directory of PROFILE_DIRECTORIES) {
12999
13600
  let entries;
13000
13601
  try {
13001
- entries = await readdir2(directory);
13602
+ entries = await readdir3(directory);
13002
13603
  } catch {
13003
13604
  continue;
13004
13605
  }
@@ -13007,7 +13608,7 @@ async function readProfiles(timeoutMs, signal) {
13007
13608
  continue;
13008
13609
  signal.throwIfAborted();
13009
13610
  const raw = await decodeProfile(
13010
- join5(directory, entry),
13611
+ join6(directory, entry),
13011
13612
  timeoutMs,
13012
13613
  signal
13013
13614
  );
@@ -13029,7 +13630,7 @@ async function decodedProfiles(timeoutMs, signal, strict = false) {
13029
13630
  for (const directory of PROFILE_DIRECTORIES) {
13030
13631
  let entries;
13031
13632
  try {
13032
- entries = await readdir2(directory);
13633
+ entries = await readdir3(directory);
13033
13634
  } catch (error) {
13034
13635
  if (strict && error.code !== "ENOENT") {
13035
13636
  throw error;
@@ -13041,7 +13642,7 @@ async function decodedProfiles(timeoutMs, signal, strict = false) {
13041
13642
  continue;
13042
13643
  }
13043
13644
  signal.throwIfAborted();
13044
- const path = join5(directory, entry);
13645
+ const path = join6(directory, entry);
13045
13646
  const raw = await decodeProfile(path, timeoutMs, signal, strict);
13046
13647
  if (!raw) continue;
13047
13648
  let content;
@@ -13197,7 +13798,7 @@ async function readCertificates(timeoutMs, signal, strict = false) {
13197
13798
  );
13198
13799
  }
13199
13800
  async function readArchiveBundles(archivePath, timeoutMs, signal) {
13200
- const products = join5(archivePath, "Products");
13801
+ const products = join6(archivePath, "Products");
13201
13802
  const bundles = [];
13202
13803
  const queue = [products];
13203
13804
  while (queue.length) {
@@ -13205,13 +13806,13 @@ async function readArchiveBundles(archivePath, timeoutMs, signal) {
13205
13806
  const current = queue.shift();
13206
13807
  let entries;
13207
13808
  try {
13208
- entries = await readdir2(current, { withFileTypes: true });
13809
+ entries = await readdir3(current, { withFileTypes: true });
13209
13810
  } catch {
13210
13811
  continue;
13211
13812
  }
13212
13813
  for (const entry of entries) {
13213
13814
  if (entry.isSymbolicLink() || !entry.isDirectory()) continue;
13214
- const path = join5(current, entry.name);
13815
+ const path = join6(current, entry.name);
13215
13816
  const signable = /\.(app|appex)$/.test(entry.name);
13216
13817
  if (!signable) {
13217
13818
  if (!/\.[A-Za-z0-9]+$/.test(entry.name)) queue.push(path);
@@ -13243,7 +13844,7 @@ async function bundleIdentifier(bundlePath, timeoutMs, signal) {
13243
13844
  "raw",
13244
13845
  "-o",
13245
13846
  "-",
13246
- join5(bundlePath, "Info.plist")
13847
+ join6(bundlePath, "Info.plist")
13247
13848
  ],
13248
13849
  timeoutMs: Math.min(timeoutMs, 5e3),
13249
13850
  signal
@@ -13259,9 +13860,9 @@ async function embeddedProfile(bundlePath, timeoutMs, signal) {
13259
13860
  "embedded.mobileprovision",
13260
13861
  "embedded.provisionprofile"
13261
13862
  ]) {
13262
- const path = join5(bundlePath, name);
13863
+ const path = join6(bundlePath, name);
13263
13864
  try {
13264
- await stat4(path);
13865
+ await stat5(path);
13265
13866
  } catch {
13266
13867
  continue;
13267
13868
  }
@@ -13306,7 +13907,7 @@ async function inspectSigningAssets(archivePath, timeoutMs, signal) {
13306
13907
  }
13307
13908
  var inspectIosSigning = async (payload, timeoutMs, signal) => {
13308
13909
  const input = parseBuildSigningInspectPayload(payload);
13309
- const archivePath = join5(input.artifactDirectory, input.archiveRelativePath);
13910
+ const archivePath = join6(input.artifactDirectory, input.archiveRelativePath);
13310
13911
  const inspection = await inspectSigningAssets(archivePath, timeoutMs, signal);
13311
13912
  return {
13312
13913
  exitCode: 0,
@@ -13316,7 +13917,7 @@ var inspectIosSigning = async (payload, timeoutMs, signal) => {
13316
13917
  ...inspection
13317
13918
  };
13318
13919
  };
13319
- var successfulProcess3 = {
13920
+ var successfulProcess4 = {
13320
13921
  exitCode: 0,
13321
13922
  signal: null,
13322
13923
  timedOut: false,
@@ -13339,7 +13940,7 @@ var scanSigningAssets = async (payload, timeoutMs, signal) => {
13339
13940
  }
13340
13941
  }
13341
13942
  return {
13342
- ...successfulProcess3,
13943
+ ...successfulProcess4,
13343
13944
  profiles: [...byUuid.values()].sort(
13344
13945
  (left, right) => left.name.localeCompare(right.name)
13345
13946
  ),
@@ -13358,7 +13959,7 @@ var readSigningProfile = async (payload, timeoutMs, signal) => {
13358
13959
  const { uuid } = signingProfileKeyPayload(payload);
13359
13960
  const profile = await findDecodedProfile(uuid, timeoutMs, signal);
13360
13961
  return {
13361
- ...successfulProcess3,
13962
+ ...successfulProcess4,
13362
13963
  uuid,
13363
13964
  contentBase64: profile.content.toString("base64"),
13364
13965
  sha256: createHash6("sha256").update(profile.content).digest("hex").toUpperCase()
@@ -13368,21 +13969,21 @@ var installSigningProfile = async (payload, timeoutMs, signal) => {
13368
13969
  const { contentBase64 } = signingProfileInstallPayload(payload);
13369
13970
  const content = Buffer.from(contentBase64, "base64");
13370
13971
  if (!content.length) throw new Error("Provisioning profile is empty");
13371
- const temporaryRoot = await mkdtemp3(join5(tmpdir3(), "ade-profile-"));
13372
- const temporaryPath = join5(temporaryRoot, `${randomUUID2()}.mobileprovision`);
13972
+ const temporaryRoot = await mkdtemp3(join6(tmpdir4(), "ade-profile-"));
13973
+ const temporaryPath = join6(temporaryRoot, `${randomUUID3()}.mobileprovision`);
13373
13974
  try {
13374
- await writeFile4(temporaryPath, content, { mode: 384 });
13975
+ await writeFile5(temporaryPath, content, { mode: 384 });
13375
13976
  const raw = await decodeProfile(temporaryPath, timeoutMs, signal);
13376
13977
  if (!raw) throw new Error("Provisioning profile is invalid or unsigned");
13377
13978
  const uuid = text(raw.UUID);
13378
13979
  if (!uuid) throw new Error("Provisioning profile UUID is missing");
13379
13980
  const directory = PROFILE_DIRECTORIES[0];
13380
- await mkdir3(directory, { recursive: true, mode: 448 });
13381
- const destination = join5(directory, `${uuid}.mobileprovision`);
13382
- await writeFile4(destination, content, { mode: 384 });
13383
- return { ...successfulProcess3, uuid };
13981
+ await mkdir4(directory, { recursive: true, mode: 448 });
13982
+ const destination = join6(directory, `${uuid}.mobileprovision`);
13983
+ await writeFile5(destination, content, { mode: 384 });
13984
+ return { ...successfulProcess4, uuid };
13384
13985
  } finally {
13385
- await rm4(temporaryRoot, { recursive: true, force: true });
13986
+ await rm5(temporaryRoot, { recursive: true, force: true });
13386
13987
  }
13387
13988
  };
13388
13989
  var deleteSigningProfile = async (payload, timeoutMs, signal) => {
@@ -13392,9 +13993,9 @@ var deleteSigningProfile = async (payload, timeoutMs, signal) => {
13392
13993
  );
13393
13994
  for (const profile of matches) {
13394
13995
  signal.throwIfAborted();
13395
- await rm4(profile.path, { force: false });
13996
+ await rm5(profile.path, { force: false });
13396
13997
  }
13397
- return { ...successfulProcess3, uuid, deleted: matches.length };
13998
+ return { ...successfulProcess4, uuid, deleted: matches.length };
13398
13999
  };
13399
14000
  var importSigningIdentity = async (payload, timeoutMs, signal, _onLog, context) => {
13400
14001
  const input = signingIdentityImportPayload(payload);
@@ -13406,10 +14007,10 @@ var importSigningIdentity = async (payload, timeoutMs, signal, _onLog, context)
13406
14007
  const hash = createHash6("sha256").update(p12).digest("hex").toUpperCase();
13407
14008
  if (hash !== input.sha256)
13408
14009
  throw new Error("Signing identity transfer changed");
13409
- const temporaryRoot = await mkdtemp3(join5(tmpdir3(), "ade-identity-"));
13410
- const path = join5(temporaryRoot, "identity.p12");
14010
+ const temporaryRoot = await mkdtemp3(join6(tmpdir4(), "ade-identity-"));
14011
+ const path = join6(temporaryRoot, "identity.p12");
13411
14012
  try {
13412
- await writeFile4(path, p12, { mode: 384 });
14013
+ await writeFile5(path, p12, { mode: 384 });
13413
14014
  const result = await captureCommand({
13414
14015
  command: "/usr/bin/security",
13415
14016
  args: [
@@ -13430,9 +14031,9 @@ var importSigningIdentity = async (payload, timeoutMs, signal, _onLog, context)
13430
14031
  result.stderr.trim() || "Could not import signing identity"
13431
14032
  );
13432
14033
  }
13433
- return { ...successfulProcess3, sha256: input.sha256 };
14034
+ return { ...successfulProcess4, sha256: input.sha256 };
13434
14035
  } finally {
13435
- await rm4(temporaryRoot, { recursive: true, force: true });
14036
+ await rm5(temporaryRoot, { recursive: true, force: true });
13436
14037
  }
13437
14038
  };
13438
14039
  var deleteSigningIdentity = async (payload, timeoutMs, signal) => {
@@ -13448,7 +14049,7 @@ var deleteSigningIdentity = async (payload, timeoutMs, signal) => {
13448
14049
  result.stderr.trim() || "Could not delete signing identity"
13449
14050
  );
13450
14051
  }
13451
- return { ...successfulProcess3, sha1 };
14052
+ return { ...successfulProcess4, sha1 };
13452
14053
  };
13453
14054
 
13454
14055
  // src/handlers/ccusage.ts
@@ -13456,8 +14057,8 @@ import { Buffer as Buffer3 } from "node:buffer";
13456
14057
 
13457
14058
  // src/executable-lookup.ts
13458
14059
  import { accessSync, constants } from "node:fs";
13459
- import { homedir as homedir5 } from "node:os";
13460
- import { delimiter, dirname as dirname3, join as join6 } from "node:path";
14060
+ import { homedir as homedir6 } from "node:os";
14061
+ import { delimiter, dirname as dirname3, join as join7 } from "node:path";
13461
14062
  function isExecutable(path) {
13462
14063
  try {
13463
14064
  accessSync(path, constants.X_OK);
@@ -13467,14 +14068,14 @@ function isExecutable(path) {
13467
14068
  }
13468
14069
  }
13469
14070
  function toolDirectories(options = {}) {
13470
- const home = options.home ?? homedir5();
14071
+ const home = options.home ?? homedir6();
13471
14072
  const platform2 = options.platform ?? process.platform;
13472
14073
  return [
13473
- join6(home, ".local", "bin"),
13474
- join6(home, ".bun", "bin"),
13475
- join6(home, ".npm-global", "bin"),
14074
+ join7(home, ".local", "bin"),
14075
+ join7(home, ".bun", "bin"),
14076
+ join7(home, ".npm-global", "bin"),
13476
14077
  // Where the opencode.ai install script puts its binary.
13477
- join6(home, ".opencode", "bin"),
14078
+ join7(home, ".opencode", "bin"),
13478
14079
  // Global npm installs land next to the node binary running this agent.
13479
14080
  options.nodeDirectory ?? dirname3(process.execPath),
13480
14081
  ...platform2 === "darwin" ? ["/opt/homebrew/bin", "/usr/local/bin"] : []
@@ -13491,7 +14092,7 @@ function findExecutable(name, options = {}) {
13491
14092
  const override = options.overrideVariable ? env[options.overrideVariable]?.trim() : void 0;
13492
14093
  const candidates = [
13493
14094
  ...override ? [override] : [],
13494
- ...directories.map((directory) => join6(directory, executable))
14095
+ ...directories.map((directory) => join7(directory, executable))
13495
14096
  ];
13496
14097
  const canExecute = options.isExecutable ?? isExecutable;
13497
14098
  return [...new Set(candidates)].find(canExecute);
@@ -13537,7 +14138,7 @@ async function runProcess(options) {
13537
14138
  detached
13538
14139
  });
13539
14140
  const emit = (stream, message) => {
13540
- const log = {
14141
+ const log2 = {
13541
14142
  sequence: sequence++,
13542
14143
  stream,
13543
14144
  message,
@@ -13545,10 +14146,10 @@ async function runProcess(options) {
13545
14146
  };
13546
14147
  logChain = logChain.then(async () => {
13547
14148
  try {
13548
- await options.onLog(log);
14149
+ await options.onLog(log2);
13549
14150
  } catch (error) {
13550
14151
  console.error(
13551
- `Could not append process log ${log.sequence}:`,
14152
+ `Could not append process log ${log2.sequence}:`,
13552
14153
  error instanceof Error ? error.message : error
13553
14154
  );
13554
14155
  }
@@ -13651,18 +14252,18 @@ async function runCcusage(payload, timeoutMs, signal, onLog) {
13651
14252
  args: ["--json"],
13652
14253
  timeoutMs,
13653
14254
  signal,
13654
- onLog: async (log) => {
13655
- if (log.stream !== "STDOUT") {
13656
- await onLog(log);
14255
+ onLog: async (log2) => {
14256
+ if (log2.stream !== "STDOUT") {
14257
+ await onLog(log2);
13657
14258
  return;
13658
14259
  }
13659
- const lineBytes = Buffer3.byteLength(log.message, "utf8") + 1;
14260
+ const lineBytes = Buffer3.byteLength(log2.message, "utf8") + 1;
13660
14261
  if (stdoutBytes + lineBytes > MAX_CCUSAGE_STDOUT_BYTES) {
13661
14262
  exceededLimit = true;
13662
14263
  return;
13663
14264
  }
13664
14265
  stdoutBytes += lineBytes;
13665
- stdout.push(log.message);
14266
+ stdout.push(log2.message);
13666
14267
  }
13667
14268
  });
13668
14269
  if (result.exitCode !== 0 || result.cancelled || result.timedOut || result.signal !== null) {
@@ -13686,15 +14287,15 @@ async function runCcusage(payload, timeoutMs, signal, onLog) {
13686
14287
  import {
13687
14288
  lstat as lstat2,
13688
14289
  opendir,
13689
- readdir as readdir3,
14290
+ readdir as readdir4,
13690
14291
  realpath as realpath4,
13691
- rm as rm5,
13692
- stat as stat5,
14292
+ rm as rm6,
14293
+ stat as stat6,
13693
14294
  statfs
13694
14295
  } from "node:fs/promises";
13695
- import { homedir as homedir6 } from "node:os";
13696
- import { basename as basename4, dirname as dirname4, isAbsolute as isAbsolute4, join as join7, resolve as resolve4 } from "node:path";
13697
- var successfulProcess4 = {
14296
+ import { homedir as homedir7 } from "node:os";
14297
+ import { basename as basename4, dirname as dirname4, isAbsolute as isAbsolute4, join as join8, resolve as resolve4 } from "node:path";
14298
+ var successfulProcess5 = {
13698
14299
  exitCode: 0,
13699
14300
  signal: null,
13700
14301
  timedOut: false,
@@ -13710,7 +14311,7 @@ function safeRelativePath3(value) {
13710
14311
  }
13711
14312
  async function configuredRoots(payload) {
13712
14313
  if (payload.mode === "DEFAULT") {
13713
- return [join7(homedir6(), "Library", "Developer", "Xcode", "DerivedData")];
14314
+ return [join8(homedir7(), "Library", "Developer", "Xcode", "DerivedData")];
13714
14315
  }
13715
14316
  if (payload.mode === "ABSOLUTE") {
13716
14317
  if (!payload.path || !isAbsolute4(payload.path)) {
@@ -13759,7 +14360,7 @@ async function scanRoot(configuredRoot, timeoutMs, signal) {
13759
14360
  }
13760
14361
  let children;
13761
14362
  try {
13762
- children = await readdir3(rootPath2, { withFileTypes: true });
14363
+ children = await readdir4(rootPath2, { withFileTypes: true });
13763
14364
  } catch (error) {
13764
14365
  return {
13765
14366
  entries: [],
@@ -13767,15 +14368,15 @@ async function scanRoot(configuredRoot, timeoutMs, signal) {
13767
14368
  };
13768
14369
  }
13769
14370
  const entries = [];
13770
- const rootStats = await stat5(rootPath2);
14371
+ const rootStats = await stat6(rootPath2);
13771
14372
  const volumeId = String(rootStats.dev);
13772
14373
  for (const child of children) {
13773
14374
  signal.throwIfAborted();
13774
14375
  if (!child.isDirectory()) continue;
13775
- const path = join7(rootPath2, child.name);
14376
+ const path = join8(rootPath2, child.name);
13776
14377
  const information = await lstat2(path);
13777
14378
  const projectPath = await workspacePath(
13778
- join7(path, "info.plist"),
14379
+ join8(path, "info.plist"),
13779
14380
  timeoutMs,
13780
14381
  signal
13781
14382
  );
@@ -13793,8 +14394,8 @@ async function scanRoot(configuredRoot, timeoutMs, signal) {
13793
14394
  return { entries, warning: null };
13794
14395
  }
13795
14396
  async function scanDeviceSupport(signal) {
13796
- const configuredRoot = join7(
13797
- process.env.ADE_IOS_DEVICE_SUPPORT_DIRECTORY ?? homedir6(),
14397
+ const configuredRoot = join8(
14398
+ process.env.ADE_IOS_DEVICE_SUPPORT_DIRECTORY ?? homedir7(),
13798
14399
  ...process.env.ADE_IOS_DEVICE_SUPPORT_DIRECTORY ? [] : ["Library", "Developer", "Xcode", "iOS DeviceSupport"]
13799
14400
  );
13800
14401
  signal.throwIfAborted();
@@ -13811,10 +14412,10 @@ async function scanDeviceSupport(signal) {
13811
14412
  };
13812
14413
  }
13813
14414
  try {
13814
- const children = await readdir3(rootPath2, { withFileTypes: true });
14415
+ const children = await readdir4(rootPath2, { withFileTypes: true });
13815
14416
  return {
13816
14417
  entries: children.filter((child) => child.isDirectory() && !child.isSymbolicLink()).map((child) => ({
13817
- path: join7(rootPath2, child.name),
14418
+ path: join8(rootPath2, child.name),
13818
14419
  rootPath: rootPath2,
13819
14420
  name: child.name,
13820
14421
  kind: "DEVICE_SUPPORT",
@@ -13853,7 +14454,7 @@ var scanBuildData = async (rawPayload, timeoutMs, signal) => {
13853
14454
  const deviceSupport = await scanDeviceSupport(signal);
13854
14455
  entries.push(...deviceSupport.entries);
13855
14456
  if (deviceSupport.warning) warnings.push(deviceSupport.warning);
13856
- return { ...successfulProcess4, entries, warnings };
14457
+ return { ...successfulProcess5, entries, warnings };
13857
14458
  };
13858
14459
  function assertDirectChild(rootPath2, path) {
13859
14460
  if (!isAbsolute4(rootPath2) || !isAbsolute4(path)) {
@@ -13875,7 +14476,7 @@ async function allocatedBytes(path, signal) {
13875
14476
  try {
13876
14477
  for await (const entry of directory) {
13877
14478
  signal.throwIfAborted();
13878
- total += await allocatedBytes(join7(path, entry.name), signal);
14479
+ total += await allocatedBytes(join8(path, entry.name), signal);
13879
14480
  }
13880
14481
  } finally {
13881
14482
  await directory.close().catch(() => void 0);
@@ -13911,7 +14512,7 @@ var sizeBuildData = async (rawPayload, _timeoutMs, signal) => {
13911
14512
  });
13912
14513
  }
13913
14514
  }
13914
- return { ...successfulProcess4, sizes };
14515
+ return { ...successfulProcess5, sizes };
13915
14516
  };
13916
14517
  var deleteBuildData = async (rawPayload, _timeoutMs, signal) => {
13917
14518
  const payload = buildDataDeletePayload(rawPayload);
@@ -13928,7 +14529,7 @@ var deleteBuildData = async (rawPayload, _timeoutMs, signal) => {
13928
14529
  if (!stats.isDirectory() || stats.isSymbolicLink()) {
13929
14530
  throw new Error("Build Data target is not a directory");
13930
14531
  }
13931
- await rm5(target2.path, { recursive: true, force: false, maxRetries: 3 });
14532
+ await rm6(target2.path, { recursive: true, force: false, maxRetries: 3 });
13932
14533
  deleted.push({ path: target2.path, deleted: true, error: null });
13933
14534
  } catch (error) {
13934
14535
  signal.throwIfAborted();
@@ -13939,7 +14540,7 @@ var deleteBuildData = async (rawPayload, _timeoutMs, signal) => {
13939
14540
  });
13940
14541
  }
13941
14542
  }
13942
- return { ...successfulProcess4, deleted };
14543
+ return { ...successfulProcess5, deleted };
13943
14544
  };
13944
14545
  async function sharedCapacityId(canonicalPath, volumeId, signal) {
13945
14546
  try {
@@ -13981,7 +14582,7 @@ async function inspectVolume(configuredPath, role, signal, allowMissing) {
13981
14582
  candidate = parent;
13982
14583
  try {
13983
14584
  inspectionPath = await realpath4(candidate);
13984
- canonicalPath = join7(inspectionPath, ...missingSegments);
14585
+ canonicalPath = join8(inspectionPath, ...missingSegments);
13985
14586
  break;
13986
14587
  } catch (parentError) {
13987
14588
  if (parentError.code !== "ENOENT") {
@@ -13991,7 +14592,7 @@ async function inspectVolume(configuredPath, role, signal, allowMissing) {
13991
14592
  }
13992
14593
  }
13993
14594
  const [information, filesystem] = await Promise.all([
13994
- stat5(inspectionPath),
14595
+ stat6(inspectionPath),
13995
14596
  statfs(inspectionPath, { bigint: true })
13996
14597
  ]);
13997
14598
  const id = String(information.dev);
@@ -14087,10 +14688,10 @@ async function collectAgentDiskSpace(configuration, signal) {
14087
14688
  }
14088
14689
 
14089
14690
  // src/handlers/codebases.ts
14090
- import { readdir as readdir4, realpath as realpath5, stat as stat6 } from "node:fs/promises";
14091
- import { homedir as homedir7 } from "node:os";
14092
- import { dirname as dirname5, join as join8, resolve as resolve5 } from "node:path";
14093
- var successfulProcess5 = {
14691
+ import { readdir as readdir5, realpath as realpath5, stat as stat7 } from "node:fs/promises";
14692
+ import { homedir as homedir8 } from "node:os";
14693
+ import { dirname as dirname5, join as join9, resolve as resolve5 } from "node:path";
14694
+ var successfulProcess6 = {
14094
14695
  exitCode: 0,
14095
14696
  signal: null,
14096
14697
  timedOut: false,
@@ -14166,7 +14767,7 @@ function baseSnapshot(folder) {
14166
14767
  }
14167
14768
  async function fetchedAt(commonDirectory) {
14168
14769
  try {
14169
- return (await stat6(join8(commonDirectory, "FETCH_HEAD"))).mtime.toISOString();
14770
+ return (await stat7(join9(commonDirectory, "FETCH_HEAD"))).mtime.toISOString();
14170
14771
  } catch {
14171
14772
  return null;
14172
14773
  }
@@ -14177,11 +14778,11 @@ async function inspectCodebaseProcess(selectedFolder, timeoutMs, signal, expecte
14177
14778
  let selected;
14178
14779
  try {
14179
14780
  selected = await realpath5(fallbackFolder);
14180
- if (!(await stat6(selected)).isDirectory())
14781
+ if (!(await stat7(selected)).isDirectory())
14181
14782
  throw new Error("Folder is not a directory");
14182
14783
  } catch (error) {
14183
14784
  return {
14184
- ...successfulProcess5,
14785
+ ...successfulProcess6,
14185
14786
  snapshot: {
14186
14787
  ...base,
14187
14788
  availability: "MISSING",
@@ -14198,7 +14799,7 @@ async function inspectCodebaseProcess(selectedFolder, timeoutMs, signal, expecte
14198
14799
  );
14199
14800
  if (rootResult.exitCode !== 0) {
14200
14801
  return {
14201
- ...successfulProcess5,
14802
+ ...successfulProcess6,
14202
14803
  snapshot: {
14203
14804
  ...base,
14204
14805
  folder: selected,
@@ -14218,7 +14819,7 @@ async function inspectCodebaseProcess(selectedFolder, timeoutMs, signal, expecte
14218
14819
  );
14219
14820
  if (bare.stdout.trim() === "true") {
14220
14821
  return {
14221
- ...successfulProcess5,
14822
+ ...successfulProcess6,
14222
14823
  snapshot: {
14223
14824
  ...base,
14224
14825
  folder,
@@ -14250,7 +14851,7 @@ async function inspectCodebaseProcess(selectedFolder, timeoutMs, signal, expecte
14250
14851
  ]);
14251
14852
  if (originResult.exitCode !== 0) {
14252
14853
  return {
14253
- ...successfulProcess5,
14854
+ ...successfulProcess6,
14254
14855
  snapshot: {
14255
14856
  ...base,
14256
14857
  folder,
@@ -14297,7 +14898,7 @@ async function inspectCodebaseProcess(selectedFolder, timeoutMs, signal, expecte
14297
14898
  const syncState = !branch ? "DETACHED" : !upstream ? "NO_UPSTREAM" : ahead === null || behind === null ? "UNKNOWN" : ahead > 0 && behind > 0 ? "DIVERGED" : ahead > 0 ? "AHEAD" : behind > 0 ? "BEHIND" : "IN_SYNC";
14298
14899
  const mismatch = expectedOrigin !== void 0 && origin2.canonicalOrigin !== expectedOrigin;
14299
14900
  return {
14300
- ...successfulProcess5,
14901
+ ...successfulProcess6,
14301
14902
  snapshot: {
14302
14903
  folder,
14303
14904
  observedOrigin: origin2.sanitizedOrigin,
@@ -14319,7 +14920,7 @@ async function inspectCodebaseProcess(selectedFolder, timeoutMs, signal, expecte
14319
14920
  } catch (error) {
14320
14921
  if (error instanceof InterruptedGitInspection) return error.result;
14321
14922
  return {
14322
- ...successfulProcess5,
14923
+ ...successfulProcess6,
14323
14924
  snapshot: {
14324
14925
  ...base,
14325
14926
  folder: selected,
@@ -14345,23 +14946,23 @@ async function inspectCodebase(selectedFolder, timeoutMs, signal, expectedOrigin
14345
14946
  }
14346
14947
  var browseCodebaseDirectories = async (payload) => {
14347
14948
  const input = codebaseBrowsePayload(payload);
14348
- const homePath = await realpath5(homedir7());
14949
+ const homePath = await realpath5(homedir8());
14349
14950
  const path = await realpath5(input.path ? resolve5(input.path) : homePath);
14350
- if (!(await stat6(path)).isDirectory())
14951
+ if (!(await stat7(path)).isDirectory())
14351
14952
  throw new Error("Path is not a directory");
14352
- const candidates = await readdir4(path, { withFileTypes: true });
14953
+ const candidates = await readdir5(path, { withFileTypes: true });
14353
14954
  const entries = [];
14354
14955
  for (const candidate of candidates) {
14355
14956
  if (candidate.isDirectory()) {
14356
14957
  entries.push({
14357
14958
  name: candidate.name,
14358
- path: join8(path, candidate.name),
14959
+ path: join9(path, candidate.name),
14359
14960
  hidden: candidate.name.startsWith(".")
14360
14961
  });
14361
14962
  } else if (candidate.isSymbolicLink()) {
14362
14963
  try {
14363
- const target2 = join8(path, candidate.name);
14364
- if ((await stat6(target2)).isDirectory()) {
14964
+ const target2 = join9(path, candidate.name);
14965
+ if ((await stat7(target2)).isDirectory()) {
14365
14966
  entries.push({
14366
14967
  name: candidate.name,
14367
14968
  path: target2,
@@ -14380,7 +14981,7 @@ var browseCodebaseDirectories = async (payload) => {
14380
14981
  entries: entries.slice(0, 1e3),
14381
14982
  truncated: entries.length > 1e3
14382
14983
  };
14383
- return { ...successfulProcess5, listing };
14984
+ return { ...successfulProcess6, listing };
14384
14985
  };
14385
14986
  var inspectCodebaseFolder = async (payload, timeoutMs, signal) => {
14386
14987
  const input = codebaseJobPayload(payload);
@@ -14458,7 +15059,7 @@ async function updateBaseBranchAfterFetch(folder, baseBranch, timeoutMs, signal)
14458
15059
  var fetchCodebase = async (payload, timeoutMs, signal, onLog, context) => {
14459
15060
  const input = codebaseJobPayload(payload);
14460
15061
  let sequence = 0;
14461
- const log = async (message) => {
15062
+ const log2 = async (message) => {
14462
15063
  try {
14463
15064
  await onLog({
14464
15065
  sequence: sequence++,
@@ -14470,7 +15071,7 @@ var fetchCodebase = async (payload, timeoutMs, signal, onLog, context) => {
14470
15071
  console.error("Could not report fetch progress:", cleanError2(error));
14471
15072
  }
14472
15073
  };
14473
- await log("Checking repository before fetching");
15074
+ await log2("Checking repository before fetching");
14474
15075
  const beforeResult = await inspectCodebaseProcess(
14475
15076
  input.folder,
14476
15077
  Math.min(timeoutMs, 3e4),
@@ -14480,11 +15081,11 @@ var fetchCodebase = async (payload, timeoutMs, signal, onLog, context) => {
14480
15081
  if (!("snapshot" in beforeResult)) return beforeResult;
14481
15082
  const before = beforeResult.snapshot;
14482
15083
  if (before.availability !== "AVAILABLE") {
14483
- return { ...successfulProcess5, exitCode: 1, snapshot: before };
15084
+ return { ...successfulProcess6, exitCode: 1, snapshot: before };
14484
15085
  }
14485
15086
  let result;
14486
15087
  const fetchAttemptedAt = (/* @__PURE__ */ new Date()).toISOString();
14487
- await log("Fetching remote branches from origin");
15088
+ await log2("Fetching remote branches from origin");
14488
15089
  try {
14489
15090
  result = await git(input.folder, ["fetch", "origin"], timeoutMs, signal);
14490
15091
  } catch (error) {
@@ -14492,14 +15093,14 @@ var fetchCodebase = async (payload, timeoutMs, signal, onLog, context) => {
14492
15093
  throw error;
14493
15094
  }
14494
15095
  if (result.exitCode === 0 && input.keepBaseBranchUpToDate && input.baseBranch) {
14495
- await log("Updating the base branch where it can be fast-forwarded");
15096
+ await log2("Updating the base branch where it can be fast-forwarded");
14496
15097
  const updated = await updateBaseBranchAfterFetch(
14497
15098
  input.folder,
14498
15099
  input.baseBranch,
14499
15100
  timeoutMs,
14500
15101
  signal
14501
15102
  );
14502
- await log(
15103
+ await log2(
14503
15104
  updated ? "Base branch updated" : "Base branch left unchanged because it could not be safely fast-forwarded"
14504
15105
  );
14505
15106
  }
@@ -14517,12 +15118,12 @@ var fetchCodebase = async (payload, timeoutMs, signal, onLog, context) => {
14517
15118
  snapshot.fetchedAt = (/* @__PURE__ */ new Date()).toISOString();
14518
15119
  }
14519
15120
  if (result.exitCode !== 0) {
14520
- await log(snapshot.error || "Git fetch failed");
15121
+ await log2(snapshot.error || "Git fetch failed");
14521
15122
  }
14522
15123
  let worktreesRefreshedAt;
14523
15124
  let worktreeRefreshError;
14524
15125
  if (input.codebaseId && context?.refreshFetchedCodebase) {
14525
- await log("Refreshing worktree branches and status");
15126
+ await log2("Refreshing worktree branches and status");
14526
15127
  try {
14527
15128
  worktreesRefreshedAt = await context.refreshFetchedCodebase({
14528
15129
  codebaseId: input.codebaseId,
@@ -14530,10 +15131,10 @@ var fetchCodebase = async (payload, timeoutMs, signal, onLog, context) => {
14530
15131
  fetchAttemptedAt,
14531
15132
  fetchError: result.exitCode === 0 ? null : snapshot.error
14532
15133
  });
14533
- await log("Worktree branches and status refreshed");
15134
+ await log2("Worktree branches and status refreshed");
14534
15135
  } catch (error) {
14535
15136
  worktreeRefreshError = cleanError2(error);
14536
- await log(`Could not refresh worktrees: ${worktreeRefreshError}`);
15137
+ await log2(`Could not refresh worktrees: ${worktreeRefreshError}`);
14537
15138
  }
14538
15139
  }
14539
15140
  return {
@@ -14756,12 +15357,12 @@ var inspectCodebaseGit = async (payload, timeoutMs, signal) => {
14756
15357
  );
14757
15358
  if (input.action === "STATE") {
14758
15359
  return {
14759
- ...successfulProcess5,
15360
+ ...successfulProcess6,
14760
15361
  state: await inspectCodebaseGitState(folder, timeoutMs, signal)
14761
15362
  };
14762
15363
  }
14763
15364
  return {
14764
- ...successfulProcess5,
15365
+ ...successfulProcess6,
14765
15366
  diff: await inspectCodebaseStashDiff(
14766
15367
  folder,
14767
15368
  input.stashOid,
@@ -14984,7 +15585,7 @@ var operateCodebaseGit = async (payload, timeoutMs, signal) => {
14984
15585
  );
14985
15586
  await runCodebaseGitOperation(folder, input, timeoutMs, signal);
14986
15587
  return {
14987
- ...successfulProcess5,
15588
+ ...successfulProcess6,
14988
15589
  snapshot: await inspectCodebase(
14989
15590
  folder,
14990
15591
  Math.min(timeoutMs, 3e4),
@@ -15001,25 +15602,25 @@ var operateCodebaseGit = async (payload, timeoutMs, signal) => {
15001
15602
 
15002
15603
  // src/handlers/skills.ts
15003
15604
  import { execFile } from "node:child_process";
15004
- import { randomUUID as randomUUID3 } from "node:crypto";
15605
+ import { randomUUID as randomUUID4 } from "node:crypto";
15005
15606
  import {
15006
15607
  access,
15007
15608
  chmod as chmod3,
15008
15609
  lstat as lstat3,
15009
- mkdir as mkdir4,
15610
+ mkdir as mkdir5,
15010
15611
  readFile as readFile5,
15011
15612
  realpath as realpath6,
15012
- readdir as readdir5,
15013
- rename as rename3,
15014
- rm as rm6,
15015
- stat as stat7,
15016
- writeFile as writeFile5
15613
+ readdir as readdir6,
15614
+ rename as rename4,
15615
+ rm as rm7,
15616
+ stat as stat8,
15617
+ writeFile as writeFile6
15017
15618
  } from "node:fs/promises";
15018
- import { homedir as homedir8 } from "node:os";
15019
- import { dirname as dirname6, isAbsolute as isAbsolute5, join as join9, relative as relative6, resolve as resolve6, sep as sep6 } from "node:path";
15619
+ import { homedir as homedir9 } from "node:os";
15620
+ import { dirname as dirname6, isAbsolute as isAbsolute5, join as join10, relative as relative6, resolve as resolve6, sep as sep6 } from "node:path";
15020
15621
  import { promisify } from "node:util";
15021
15622
  var executeFile = promisify(execFile);
15022
- var successfulProcess6 = {
15623
+ var successfulProcess7 = {
15023
15624
  exitCode: 0,
15024
15625
  signal: null,
15025
15626
  timedOut: false,
@@ -15071,23 +15672,23 @@ var PROJECT_ROOTS = {
15071
15672
  };
15072
15673
  async function directoryExists(path) {
15073
15674
  try {
15074
- return (await stat7(path)).isDirectory();
15675
+ return (await stat8(path)).isDirectory();
15075
15676
  } catch {
15076
15677
  return false;
15077
15678
  }
15078
15679
  }
15079
15680
  async function configuredTools(tools) {
15080
- const homePath = homedir8();
15681
+ const homePath = homedir9();
15081
15682
  return Promise.all(
15082
15683
  AI_TOOLS.filter((tool) => tools.includes(tool)).map(async (tool) => ({
15083
15684
  tool,
15084
- configured: await directoryExists(join9(homePath, ...CONFIG_PATHS[tool])),
15685
+ configured: await directoryExists(join10(homePath, ...CONFIG_PATHS[tool])),
15085
15686
  homePath
15086
15687
  }))
15087
15688
  );
15088
15689
  }
15089
15690
  function rootPath(location) {
15090
- const base = location.scope === "GLOBAL" ? homedir8() : location.folder;
15691
+ const base = location.scope === "GLOBAL" ? homedir9() : location.folder;
15091
15692
  const parts = location.scope === "GLOBAL" ? GLOBAL_ROOTS[location.rootKind] : PROJECT_ROOTS[location.rootKind];
15092
15693
  const path = resolve6(base, ...parts);
15093
15694
  const normalizedBase = resolve6(base);
@@ -15117,8 +15718,8 @@ async function listPackageFiles(skillDirectory) {
15117
15718
  const files = [];
15118
15719
  let totalBytes = 0;
15119
15720
  const visit = async (directory) => {
15120
- for (const entry of await readdir5(directory, { withFileTypes: true })) {
15121
- const path = join9(directory, entry.name);
15721
+ for (const entry of await readdir6(directory, { withFileTypes: true })) {
15722
+ const path = join10(directory, entry.name);
15122
15723
  const metadata = await lstat3(path);
15123
15724
  if (metadata.isSymbolicLink()) {
15124
15725
  throw new Error(
@@ -15215,9 +15816,9 @@ async function scanRoot2(location, configured, targets, warnings) {
15215
15816
  if (!consumers.length) return [];
15216
15817
  const target2 = targetForFolder(targets, location.folder);
15217
15818
  const installations = [];
15218
- for (const entry of await readdir5(root, { withFileTypes: true })) {
15819
+ for (const entry of await readdir6(root, { withFileTypes: true })) {
15219
15820
  if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
15220
- const directory = join9(root, entry.name);
15821
+ const directory = join10(root, entry.name);
15221
15822
  try {
15222
15823
  const skillPackage = await readPackage(directory, resolvedRoot);
15223
15824
  const relativeDirectory = location.folder ? relative6(location.folder, directory).split(sep6).join("/") : "";
@@ -15274,7 +15875,7 @@ var scanSkills = async (payload) => {
15274
15875
  )
15275
15876
  )).flat();
15276
15877
  return {
15277
- ...successfulProcess6,
15878
+ ...successfulProcess7,
15278
15879
  configuredTools: observations,
15279
15880
  installations,
15280
15881
  warnings: warnings.slice(0, 500)
@@ -15297,10 +15898,10 @@ var readSkills = async (payload) => {
15297
15898
  const { resolvedRoot } = await resolvedSkillRoot(request);
15298
15899
  packages.push({
15299
15900
  ...request,
15300
- package: await readPackage(join9(root, request.skillName), resolvedRoot)
15901
+ package: await readPackage(join10(root, request.skillName), resolvedRoot)
15301
15902
  });
15302
15903
  }
15303
- return { ...successfulProcess6, packages };
15904
+ return { ...successfulProcess7, packages };
15304
15905
  };
15305
15906
  async function gitExcludePath(folder) {
15306
15907
  const result = await executeFile("git", [
@@ -15315,7 +15916,7 @@ async function gitExcludePath(folder) {
15315
15916
  }
15316
15917
  async function updateManagedExclude(folder, relativeSkillPath, present) {
15317
15918
  const excludePath = await gitExcludePath(folder);
15318
- await mkdir4(dirname6(excludePath), { recursive: true });
15919
+ await mkdir5(dirname6(excludePath), { recursive: true });
15319
15920
  let existing = "";
15320
15921
  try {
15321
15922
  existing = await readFile5(excludePath, "utf8");
@@ -15338,7 +15939,7 @@ async function updateManagedExclude(folder, relativeSkillPath, present) {
15338
15939
  const block = managed.size ? `${MANAGED_EXCLUDE_START}
15339
15940
  ${[...managed].sort().join("\n")}
15340
15941
  ${MANAGED_EXCLUDE_END}` : "";
15341
- await writeFile5(
15942
+ await writeFile6(
15342
15943
  excludePath,
15343
15944
  `${[before, block, after].filter(Boolean).join("\n\n")}
15344
15945
  `,
@@ -15359,39 +15960,39 @@ async function writePackage(location, skillPackage) {
15359
15960
  throw new Error("New skill copies may only be written to shared roots");
15360
15961
  }
15361
15962
  const root = rootPath(location);
15362
- const destination = join9(root, skillPackage.name);
15963
+ const destination = join10(root, skillPackage.name);
15363
15964
  await assertUntracked(location, destination);
15364
- await mkdir4(root, { recursive: true });
15365
- const temporary = join9(root, `.${skillPackage.name}.${randomUUID3()}.tmp`);
15366
- const backup = join9(root, `.${skillPackage.name}.${randomUUID3()}.bak`);
15367
- await mkdir4(temporary, { recursive: true });
15965
+ await mkdir5(root, { recursive: true });
15966
+ const temporary = join10(root, `.${skillPackage.name}.${randomUUID4()}.tmp`);
15967
+ const backup = join10(root, `.${skillPackage.name}.${randomUUID4()}.bak`);
15968
+ await mkdir5(temporary, { recursive: true });
15368
15969
  try {
15369
15970
  for (const file of skillPackage.files) {
15370
15971
  const path = resolve6(temporary, ...file.path.split("/"));
15371
15972
  if (!path.startsWith(`${temporary}${sep6}`))
15372
15973
  throw new Error("Skill file escaped temporary directory");
15373
- await mkdir4(dirname6(path), { recursive: true });
15374
- await writeFile5(path, Buffer.from(file.contentsBase64, "base64"));
15974
+ await mkdir5(dirname6(path), { recursive: true });
15975
+ await writeFile6(path, Buffer.from(file.contentsBase64, "base64"));
15375
15976
  await chmod3(path, file.executable ? 493 : 420);
15376
15977
  }
15377
15978
  let hadDestination = false;
15378
15979
  try {
15379
15980
  await access(destination);
15380
15981
  hadDestination = true;
15381
- await rename3(destination, backup);
15982
+ await rename4(destination, backup);
15382
15983
  } catch {
15383
15984
  hadDestination = false;
15384
15985
  }
15385
15986
  try {
15386
- await rename3(temporary, destination);
15387
- if (hadDestination) await rm6(backup, { recursive: true, force: true });
15987
+ await rename4(temporary, destination);
15988
+ if (hadDestination) await rm7(backup, { recursive: true, force: true });
15388
15989
  } catch (error) {
15389
- if (hadDestination) await rename3(backup, destination);
15990
+ if (hadDestination) await rename4(backup, destination);
15390
15991
  throw error;
15391
15992
  }
15392
15993
  } finally {
15393
- await rm6(temporary, { recursive: true, force: true });
15394
- await rm6(backup, { recursive: true, force: true });
15994
+ await rm7(temporary, { recursive: true, force: true });
15995
+ await rm7(backup, { recursive: true, force: true });
15395
15996
  }
15396
15997
  return destination;
15397
15998
  }
@@ -15401,7 +16002,7 @@ var applySkills = async (payload) => {
15401
16002
  for (const operation of operations) {
15402
16003
  const root = rootPath(operation);
15403
16004
  const skillName = operation.kind === "WRITE" ? operation.package.name : operation.skillName;
15404
- const destination = join9(root, skillName);
16005
+ const destination = join10(root, skillName);
15405
16006
  await assertUntracked(operation, destination);
15406
16007
  if (operation.kind === "WRITE") {
15407
16008
  await writePackage(operation, operation.package);
@@ -15411,7 +16012,7 @@ var applySkills = async (payload) => {
15411
16012
  packageHash: operation.package.packageHash
15412
16013
  });
15413
16014
  } else {
15414
- await rm6(destination, { recursive: true, force: true });
16015
+ await rm7(destination, { recursive: true, force: true });
15415
16016
  results.push({
15416
16017
  kind: operation.kind,
15417
16018
  path: destination,
@@ -15426,14 +16027,14 @@ var applySkills = async (payload) => {
15426
16027
  );
15427
16028
  }
15428
16029
  }
15429
- return { ...successfulProcess6, results };
16030
+ return { ...successfulProcess7, results };
15430
16031
  };
15431
16032
 
15432
16033
  // src/handlers/runs.ts
15433
- import { readFile as readFile6, readdir as readdir6, stat as stat8 } from "node:fs/promises";
15434
- import { homedir as homedir9 } from "node:os";
15435
- import { join as join10 } from "node:path";
15436
- var successfulProcess7 = {
16034
+ import { readFile as readFile6, readdir as readdir7, stat as stat9 } from "node:fs/promises";
16035
+ import { homedir as homedir10 } from "node:os";
16036
+ import { join as join11 } from "node:path";
16037
+ var successfulProcess8 = {
15437
16038
  exitCode: 0,
15438
16039
  signal: null,
15439
16040
  timedOut: false,
@@ -15441,39 +16042,39 @@ var successfulProcess7 = {
15441
16042
  };
15442
16043
  async function fileExists(path) {
15443
16044
  try {
15444
- return (await stat8(path)).isFile();
16045
+ return (await stat9(path)).isFile();
15445
16046
  } catch {
15446
16047
  return false;
15447
16048
  }
15448
16049
  }
15449
16050
  async function findClaudeSessionFile(nativeId, home) {
15450
- const projectsDir = join10(home, ".claude", "projects");
16051
+ const projectsDir = join11(home, ".claude", "projects");
15451
16052
  let entries;
15452
16053
  try {
15453
- entries = await readdir6(projectsDir, { withFileTypes: true });
16054
+ entries = await readdir7(projectsDir, { withFileTypes: true });
15454
16055
  } catch {
15455
16056
  return null;
15456
16057
  }
15457
16058
  const target2 = `${nativeId}.jsonl`;
15458
16059
  for (const entry of entries) {
15459
16060
  if (!entry.isDirectory()) continue;
15460
- const candidate = join10(projectsDir, entry.name, target2);
16061
+ const candidate = join11(projectsDir, entry.name, target2);
15461
16062
  if (await fileExists(candidate)) return candidate;
15462
16063
  }
15463
16064
  return null;
15464
16065
  }
15465
16066
  async function findCodexSessionFile(nativeId, home) {
15466
- const sessionsDir = join10(home, ".codex", "sessions");
16067
+ const sessionsDir = join11(home, ".codex", "sessions");
15467
16068
  const suffix = `-${nativeId}.jsonl`;
15468
16069
  const walk = async (dir) => {
15469
16070
  let entries;
15470
16071
  try {
15471
- entries = await readdir6(dir, { withFileTypes: true });
16072
+ entries = await readdir7(dir, { withFileTypes: true });
15472
16073
  } catch {
15473
16074
  return null;
15474
16075
  }
15475
16076
  for (const entry of entries) {
15476
- const path = join10(dir, entry.name);
16077
+ const path = join11(dir, entry.name);
15477
16078
  if (entry.isDirectory()) {
15478
16079
  const found = await walk(path);
15479
16080
  if (found) return found;
@@ -15490,13 +16091,13 @@ async function locateSessionFile(payload, home) {
15490
16091
  }
15491
16092
  var readRunSession = async (payload) => {
15492
16093
  const input = parseRunSessionReadPayload(payload);
15493
- const path = await locateSessionFile(input, homedir9());
16094
+ const path = await locateSessionFile(input, homedir10());
15494
16095
  if (!path) {
15495
16096
  throw new Error(
15496
16097
  `No ${input.provider === "CLAUDE" ? "Claude" : "Codex"} session file found for this run on this agent`
15497
16098
  );
15498
16099
  }
15499
- const { size } = await stat8(path);
16100
+ const { size } = await stat9(path);
15500
16101
  if (size > MAX_RUN_SESSION_FILE_BYTES) {
15501
16102
  throw new Error(
15502
16103
  `Session file is too large to export (${size} bytes exceeds the ${MAX_RUN_SESSION_FILE_BYTES} byte limit)`
@@ -15504,7 +16105,7 @@ var readRunSession = async (payload) => {
15504
16105
  }
15505
16106
  const contents = await readFile6(path);
15506
16107
  return {
15507
- ...successfulProcess7,
16108
+ ...successfulProcess8,
15508
16109
  filename: path.split("/").at(-1) ?? `${input.nativeId}.jsonl`,
15509
16110
  contentBase64: contents.toString("base64")
15510
16111
  };
@@ -15515,18 +16116,18 @@ import {
15515
16116
  mkdtemp as mkdtemp5,
15516
16117
  readFile as readFile7,
15517
16118
  realpath as realpath7,
15518
- rm as rm8,
15519
- stat as stat9,
15520
- writeFile as writeFile6
16119
+ rm as rm9,
16120
+ stat as stat10,
16121
+ writeFile as writeFile7
15521
16122
  } from "node:fs/promises";
15522
- import { tmpdir as tmpdir5 } from "node:os";
15523
- import { join as join12 } from "node:path";
16123
+ import { tmpdir as tmpdir6 } from "node:os";
16124
+ import { join as join13 } from "node:path";
15524
16125
 
15525
16126
  // src/runs/git-checkpoint.ts
15526
16127
  import { execFile as execFile2, spawn as spawn6 } from "node:child_process";
15527
- import { copyFile, mkdtemp as mkdtemp4, rm as rm7 } from "node:fs/promises";
15528
- import { tmpdir as tmpdir4 } from "node:os";
15529
- import { join as join11 } from "node:path";
16128
+ import { copyFile, mkdtemp as mkdtemp4, rm as rm8 } from "node:fs/promises";
16129
+ import { tmpdir as tmpdir5 } from "node:os";
16130
+ import { join as join12 } from "node:path";
15530
16131
  import { promisify as promisify2 } from "node:util";
15531
16132
  var execFileAsync = promisify2(execFile2);
15532
16133
  var PATCH_LIMIT = 2e6;
@@ -15744,12 +16345,12 @@ async function captureGitCheckpoint(cwd, runId, kind) {
15744
16345
  ["diff", "--stat", "HEAD"],
15745
16346
  SUMMARY_LIMIT
15746
16347
  );
15747
- const directory = await mkdtemp4(join11(tmpdir4(), "aide-run-index-"));
16348
+ const directory = await mkdtemp4(join12(tmpdir5(), "aide-run-index-"));
15748
16349
  let worktreeTree = null;
15749
16350
  let refName = null;
15750
16351
  try {
15751
16352
  const actualIndex = await git2(cwd, ["rev-parse", "--git-path", "index"]);
15752
- const temporaryIndex = join11(directory, "index");
16353
+ const temporaryIndex = join12(directory, "index");
15753
16354
  try {
15754
16355
  await copyFile(actualIndex, temporaryIndex);
15755
16356
  } catch {
@@ -15781,7 +16382,7 @@ async function captureGitCheckpoint(cwd, runId, kind) {
15781
16382
  refName = `refs/aide/runs/${runId}/${Date.now()}-${kind.toLowerCase()}`;
15782
16383
  await git2(cwd, ["update-ref", refName, checkpointCommit]);
15783
16384
  } finally {
15784
- await rm7(directory, { recursive: true, force: true });
16385
+ await rm8(directory, { recursive: true, force: true });
15785
16386
  }
15786
16387
  return {
15787
16388
  kind,
@@ -15814,17 +16415,17 @@ var success = {
15814
16415
  var runWorkflowTerminal = async (payloadValue, timeoutMs, signal, onLog, context) => {
15815
16416
  const payload = parseWorkflowTerminalPayload(payloadValue);
15816
16417
  const cwd = await realpath7(payload.cwd);
15817
- const information = await stat9(cwd);
16418
+ const information = await stat10(cwd);
15818
16419
  if (!information.isDirectory())
15819
16420
  throw new Error("Workflow working directory is not a directory");
15820
- const directory = await mkdtemp5(join12(tmpdir5(), "aide-workflow-"));
16421
+ const directory = await mkdtemp5(join13(tmpdir6(), "aide-workflow-"));
15821
16422
  const extension2 = payload.interpreter === "NODE" ? "mjs" : "sh";
15822
- const scriptPath = join12(directory, `step.${extension2}`);
15823
- const sessionPath = join12(directory, "session.json");
16423
+ const scriptPath = join13(directory, `step.${extension2}`);
16424
+ const sessionPath = join13(directory, "session.json");
15824
16425
  try {
15825
- await writeFile6(scriptPath, `${payload.script}
16426
+ await writeFile7(scriptPath, `${payload.script}
15826
16427
  `, { mode: 384 });
15827
- await writeFile6(
16428
+ await writeFile7(
15828
16429
  sessionPath,
15829
16430
  `${JSON.stringify(payload.sessionData, null, 2)}
15830
16431
  `,
@@ -15854,7 +16455,7 @@ var runWorkflowTerminal = async (payloadValue, timeoutMs, signal, onLog, context
15854
16455
  env,
15855
16456
  timeoutMs,
15856
16457
  signal,
15857
- onLog: (log) => onLog({ ...log, message: redact(log.message) })
16458
+ onLog: (log2) => onLog({ ...log2, message: redact(log2.message) })
15858
16459
  });
15859
16460
  const sessionFile = await readFile7(sessionPath);
15860
16461
  if (sessionFile.byteLength > MAX_SESSION_BYTES) {
@@ -15868,7 +16469,7 @@ var runWorkflowTerminal = async (payloadValue, timeoutMs, signal, onLog, context
15868
16469
  }
15869
16470
  return { ...result, sessionData };
15870
16471
  } finally {
15871
- await rm8(directory, { recursive: true, force: true });
16472
+ await rm9(directory, { recursive: true, force: true });
15872
16473
  }
15873
16474
  };
15874
16475
  var runWorkflowGitCheckpoint = async (payloadValue, _timeoutMs, signal) => {
@@ -15911,9 +16512,9 @@ var runWorkflowGitCheckpoint = async (payloadValue, _timeoutMs, signal) => {
15911
16512
 
15912
16513
  // src/handlers/worktrees.ts
15913
16514
  import { createWriteStream as createWriteStream2, watch } from "node:fs";
15914
- import { mkdtemp as mkdtemp6, open as open3, readFile as readFile9, realpath as realpath9, rm as rm10, stat as stat10 } from "node:fs/promises";
15915
- import { tmpdir as tmpdir6 } from "node:os";
15916
- import { basename as basename5, dirname as dirname8, isAbsolute as isAbsolute7, join as join14, relative as relative8 } from "node:path";
16515
+ import { mkdtemp as mkdtemp6, open as open3, readFile as readFile9, realpath as realpath9, rm as rm11, stat as stat11 } from "node:fs/promises";
16516
+ import { tmpdir as tmpdir7 } from "node:os";
16517
+ import { basename as basename5, dirname as dirname8, isAbsolute as isAbsolute7, join as join15, relative as relative8 } from "node:path";
15917
16518
  import { spawn as spawn7 } from "node:child_process";
15918
16519
 
15919
16520
  // src/handlers/worktree-preparations.ts
@@ -15921,13 +16522,13 @@ import { createHash as createHash7 } from "node:crypto";
15921
16522
  import {
15922
16523
  chmod as chmod4,
15923
16524
  lstat as lstat4,
15924
- mkdir as mkdir5,
16525
+ mkdir as mkdir6,
15925
16526
  readFile as readFile8,
15926
16527
  realpath as realpath8,
15927
- rm as rm9,
15928
- writeFile as writeFile7
16528
+ rm as rm10,
16529
+ writeFile as writeFile8
15929
16530
  } from "node:fs/promises";
15930
- import { dirname as dirname7, isAbsolute as isAbsolute6, join as join13, relative as relative7, resolve as resolve7 } from "node:path";
16531
+ import { dirname as dirname7, isAbsolute as isAbsolute6, join as join14, relative as relative7, resolve as resolve7 } from "node:path";
15931
16532
  var EXCLUDE_BEGIN = "# BEGIN AIDE PREPARATIONS";
15932
16533
  var EXCLUDE_END = "# END AIDE PREPARATIONS";
15933
16534
  function cleanError3(value) {
@@ -15978,7 +16579,7 @@ async function safeTarget(folder, path) {
15978
16579
  let current = root;
15979
16580
  const segments = fromRoot.split(/[\\/]/);
15980
16581
  for (const segment of segments.slice(0, -1)) {
15981
- current = join13(current, segment);
16582
+ current = join14(current, segment);
15982
16583
  try {
15983
16584
  const info = await lstat4(current);
15984
16585
  if (info.isSymbolicLink()) {
@@ -16094,8 +16695,8 @@ async function reconcileExcludeFile(folder, definitions, timeoutMs, signal) {
16094
16695
  const entries = definitions.filter((definition) => definition.kind === "WRITE").map((definition) => excludeEntry(definition.path)).sort((left, right) => left.localeCompare(right));
16095
16696
  const block = entries.length ? [EXCLUDE_BEGIN, ...entries, EXCLUDE_END].join("\n") : "";
16096
16697
  const next = [base, block].filter(Boolean).join("\n\n");
16097
- await mkdir5(dirname7(path), { recursive: true });
16098
- await writeFile7(path, next ? `${next}
16698
+ await mkdir6(dirname7(path), { recursive: true });
16699
+ await writeFile8(path, next ? `${next}
16099
16700
  ` : "", "utf8");
16100
16701
  }
16101
16702
  function decodeContents(definition) {
@@ -16117,7 +16718,7 @@ async function removeTarget(target2, path) {
16117
16718
  if (info.isDirectory() && !info.isSymbolicLink()) {
16118
16719
  throw new Error(`Preparation path is a directory: ${path}`);
16119
16720
  }
16120
- await rm9(target2, { force: true });
16721
+ await rm10(target2, { force: true });
16121
16722
  } catch (error) {
16122
16723
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
16123
16724
  return;
@@ -16172,15 +16773,15 @@ async function applyOne(folder, definition, timeoutMs, signal) {
16172
16773
  throw new Error(`Preparation path is a directory: ${definition.path}`);
16173
16774
  }
16174
16775
  executable = info.isFile() && (info.mode & 73) !== 0;
16175
- if (info.isSymbolicLink()) await rm9(target2, { force: true });
16776
+ if (info.isSymbolicLink()) await rm10(target2, { force: true });
16176
16777
  } catch (error) {
16177
16778
  if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT") {
16178
16779
  throw error;
16179
16780
  }
16180
16781
  }
16181
- await mkdir5(dirname7(target2), { recursive: true, mode: 493 });
16782
+ await mkdir6(dirname7(target2), { recursive: true, mode: 493 });
16182
16783
  await safeTarget(folder, definition.path);
16183
- await writeFile7(target2, contents, { mode: executable ? 493 : 420 });
16784
+ await writeFile8(target2, contents, { mode: executable ? 493 : 420 });
16184
16785
  if (executable) await chmod4(target2, 493);
16185
16786
  }
16186
16787
  if (tracked) {
@@ -16399,7 +17000,7 @@ async function preparationConflictPaths(folder, definitions, remoteBase, timeout
16399
17000
  }
16400
17001
 
16401
17002
  // src/handlers/worktrees.ts
16402
- var successfulProcess8 = {
17003
+ var successfulProcess9 = {
16403
17004
  exitCode: 0,
16404
17005
  signal: null,
16405
17006
  timedOut: false,
@@ -16452,7 +17053,7 @@ async function rebaseInProgress(folder, timeoutMs, signal) {
16452
17053
  const candidate = pathResult.stdout.trim();
16453
17054
  if (!candidate) continue;
16454
17055
  try {
16455
- await stat10(isAbsolute7(candidate) ? candidate : join14(folder, candidate));
17056
+ await stat11(isAbsolute7(candidate) ? candidate : join15(folder, candidate));
16456
17057
  return true;
16457
17058
  } catch {
16458
17059
  }
@@ -16472,7 +17073,7 @@ async function rebaseBranch(folder, timeoutMs, signal) {
16472
17073
  if (!candidate) continue;
16473
17074
  try {
16474
17075
  const headName = (await readFile9(
16475
- isAbsolute7(candidate) ? candidate : join14(folder, candidate),
17076
+ isAbsolute7(candidate) ? candidate : join15(folder, candidate),
16476
17077
  "utf8"
16477
17078
  )).trim();
16478
17079
  if (headName.startsWith("refs/heads/")) {
@@ -16666,7 +17267,7 @@ async function origin(folder, timeoutMs, signal) {
16666
17267
  }
16667
17268
  async function validateWorktree2(input, timeoutMs, signal) {
16668
17269
  const folder = await realpath9(input.folder);
16669
- if (!(await stat10(folder)).isDirectory())
17270
+ if (!(await stat11(folder)).isDirectory())
16670
17271
  throw new Error("Worktree is missing");
16671
17272
  const observedGitDirectory = await gitDirectory(folder, timeoutMs, signal);
16672
17273
  if (observedGitDirectory !== input.gitDirectory) {
@@ -16907,7 +17508,7 @@ function parseNumstat(value) {
16907
17508
  }
16908
17509
  async function untrackedLines(folder, path) {
16909
17510
  try {
16910
- const file = await stat10(`${folder}/${path}`);
17511
+ const file = await stat11(`${folder}/${path}`);
16911
17512
  if (!file.isFile() || file.size > 1024 * 1024) return null;
16912
17513
  const contents = await readFile9(`${folder}/${path}`);
16913
17514
  if (contents.includes(0)) return null;
@@ -17030,7 +17631,7 @@ async function inspectCommits(folder, baseBranch, timeoutMs, signal) {
17030
17631
  [
17031
17632
  "log",
17032
17633
  "--max-count=101",
17033
- "--format=%x1e%H%x1f%s%x1f%an%x1f%aI",
17634
+ "--format=%x1e%H%x1f%s%x1f%an%x1f%aI%x1f%B%x00",
17034
17635
  "--numstat",
17035
17636
  `refs/remotes/origin/${baseBranch}..HEAD`
17036
17637
  ],
@@ -17040,16 +17641,31 @@ async function inspectCommits(folder, baseBranch, timeoutMs, signal) {
17040
17641
  "Could not inspect base-relative commits"
17041
17642
  );
17042
17643
  const commits = result.stdout.split("").filter(Boolean).map((block) => {
17043
- const lines = block.trim().split("\n");
17044
- const [sha = "", subject = "", authorName = "", authoredAt = ""] = (lines.shift() ?? "").split("");
17644
+ const [header = "", stats = ""] = block.split("\0");
17645
+ const [
17646
+ sha = "",
17647
+ subject = "",
17648
+ authorName = "",
17649
+ authoredAt = "",
17650
+ ...messageParts
17651
+ ] = header.split("");
17652
+ const message = messageParts.join("").replace(/\n$/, "");
17045
17653
  let additions = 0;
17046
17654
  let deletions = 0;
17047
- for (const line of lines) {
17655
+ for (const line of stats.trim().split("\n")) {
17048
17656
  const [added, deleted] = line.split(" ");
17049
17657
  if (/^\d+$/.test(added ?? "")) additions += Number(added);
17050
17658
  if (/^\d+$/.test(deleted ?? "")) deletions += Number(deleted);
17051
17659
  }
17052
- return { sha, subject, authorName, authoredAt, additions, deletions };
17660
+ return {
17661
+ sha,
17662
+ subject,
17663
+ message,
17664
+ authorName,
17665
+ authoredAt,
17666
+ additions,
17667
+ deletions
17668
+ };
17053
17669
  });
17054
17670
  return { commits: commits.slice(0, 100), truncated: commits.length > 100 };
17055
17671
  }
@@ -17125,7 +17741,7 @@ async function comparisonSides(input, folder, timeoutMs, signal) {
17125
17741
  if (!input.path) return { before: null, after: null };
17126
17742
  const path = input.path;
17127
17743
  const previousPath = input.previousPath ?? path;
17128
- const currentPath = join14(folder, path);
17744
+ const currentPath = join15(folder, path);
17129
17745
  if (input.scope === "UNTRACKED") {
17130
17746
  return { before: null, after: { kind: "FILE", path: currentPath } };
17131
17747
  }
@@ -17229,7 +17845,7 @@ async function availableSide(side, folder, timeoutMs, signal) {
17229
17845
  try {
17230
17846
  const resolved = await realpath9(side.path);
17231
17847
  const difference = relative8(folder, resolved);
17232
- return difference !== ".." && !difference.startsWith("../") && (await stat10(resolved)).isFile();
17848
+ return difference !== ".." && !difference.startsWith("../") && (await stat11(resolved)).isFile();
17233
17849
  } catch {
17234
17850
  return false;
17235
17851
  }
@@ -17300,7 +17916,7 @@ async function inspectRequestedDiff(input, folder, timeoutMs, signal) {
17300
17916
  let patch;
17301
17917
  if (input.scope === "UNTRACKED") {
17302
17918
  const bounded = await readBoundedFile(
17303
- join14(folder, input.path),
17919
+ join15(folder, input.path),
17304
17920
  MAX_DIFF_BYTES
17305
17921
  );
17306
17922
  const contents = bounded.contents;
@@ -17380,7 +17996,7 @@ var inspectWorktreeDiff = async (payload, timeoutMs, signal) => {
17380
17996
  const input = worktreeDiffPayload(payload);
17381
17997
  const folder = await validateWorktree2(input, timeoutMs, signal);
17382
17998
  return {
17383
- ...successfulProcess8,
17999
+ ...successfulProcess9,
17384
18000
  diff: await inspectRequestedDiff(input, folder, timeoutMs, signal)
17385
18001
  };
17386
18002
  };
@@ -17482,8 +18098,8 @@ var downloadWorktreeDiffAsset = async (payload, timeoutMs, signal, _onLog, conte
17482
18098
  if (!/^\d+$/.test(size) || Number(size) > 20 * 1024 * 1024) {
17483
18099
  throw new Error("Diff image exceeds the 20 MiB limit");
17484
18100
  }
17485
- temporaryDirectory = await mkdtemp6(join14(tmpdir6(), "ade-diff-image-"));
17486
- uploadPath = join14(temporaryDirectory, basename5(input.path));
18101
+ temporaryDirectory = await mkdtemp6(join15(tmpdir7(), "ade-diff-image-"));
18102
+ uploadPath = join15(temporaryDirectory, basename5(input.path));
17487
18103
  await writeGitObject(
17488
18104
  folder,
17489
18105
  selected.specification,
@@ -17492,7 +18108,7 @@ var downloadWorktreeDiffAsset = async (payload, timeoutMs, signal, _onLog, conte
17492
18108
  signal
17493
18109
  );
17494
18110
  }
17495
- const information = await stat10(uploadPath);
18111
+ const information = await stat11(uploadPath);
17496
18112
  if (!information.isFile() || information.size > 20 * 1024 * 1024) {
17497
18113
  throw new Error("Diff image exceeds the 20 MiB limit");
17498
18114
  }
@@ -17502,10 +18118,10 @@ var downloadWorktreeDiffAsset = async (payload, timeoutMs, signal, _onLog, conte
17502
18118
  filename: basename5(input.path),
17503
18119
  contentType: imageContentType(input.path)
17504
18120
  });
17505
- return successfulProcess8;
18121
+ return successfulProcess9;
17506
18122
  } finally {
17507
18123
  if (temporaryDirectory) {
17508
- await rm10(temporaryDirectory, { recursive: true, force: true });
18124
+ await rm11(temporaryDirectory, { recursive: true, force: true });
17509
18125
  }
17510
18126
  }
17511
18127
  };
@@ -17517,11 +18133,11 @@ var watchWorktree = async (payload, timeoutMs, signal, _onLog, context) => {
17517
18133
  closeWorktreeWatch(current);
17518
18134
  activeWorktreeWatches.delete(input.gitDirectory);
17519
18135
  }
17520
- return successfulProcess8;
18136
+ return successfulProcess9;
17521
18137
  }
17522
18138
  if (!context) throw new Error("Worktree activity reporting is unavailable");
17523
18139
  const folder = await validateWorktree2(input, timeoutMs, signal);
17524
- if (current?.watchId === input.watchId) return successfulProcess8;
18140
+ if (current?.watchId === input.watchId) return successfulProcess9;
17525
18141
  if (current) {
17526
18142
  closeWorktreeWatch(current);
17527
18143
  activeWorktreeWatches.delete(input.gitDirectory);
@@ -17563,14 +18179,14 @@ var watchWorktree = async (payload, timeoutMs, signal, _onLog, context) => {
17563
18179
  activeWorktreeWatches.delete(input.gitDirectory);
17564
18180
  throw error;
17565
18181
  }
17566
- return successfulProcess8;
18182
+ return successfulProcess9;
17567
18183
  };
17568
18184
  var inspectWorktree = async (payload, timeoutMs, signal) => {
17569
18185
  const input = worktreeJobPayload(payload);
17570
18186
  const folder = await validateWorktree2(input, timeoutMs, signal);
17571
18187
  if (!input.baseBranch) throw new Error("A base branch is required");
17572
18188
  return {
17573
- ...successfulProcess8,
18189
+ ...successfulProcess9,
17574
18190
  detail: await inspectWorktreeDetail(
17575
18191
  folder,
17576
18192
  input.baseBranch,
@@ -17584,12 +18200,12 @@ var inspectWorktreeGit = async (payload, timeoutMs, signal) => {
17584
18200
  const folder = await validateWorktree2(input, timeoutMs, signal);
17585
18201
  if (input.action === "STATE") {
17586
18202
  return {
17587
- ...successfulProcess8,
18203
+ ...successfulProcess9,
17588
18204
  state: await inspectCodebaseGitState(folder, timeoutMs, signal)
17589
18205
  };
17590
18206
  }
17591
18207
  return {
17592
- ...successfulProcess8,
18208
+ ...successfulProcess9,
17593
18209
  diff: await inspectCodebaseStashDiff(
17594
18210
  folder,
17595
18211
  input.stashOid,
@@ -17673,7 +18289,7 @@ var commitWorktree = async (payload, timeoutMs, signal) => {
17673
18289
  );
17674
18290
  const [shaResult, subjectResult] = await Promise.all([sha, subject]);
17675
18291
  return {
17676
- ...successfulProcess8,
18292
+ ...successfulProcess9,
17677
18293
  commit: {
17678
18294
  sha: shaResult.stdout.trim(),
17679
18295
  subject: subjectResult.stdout.trim(),
@@ -17694,7 +18310,7 @@ var operateWorktreeGit = async (payload, timeoutMs, signal) => {
17694
18310
  const folder = await validateWorktree2(input, timeoutMs, signal);
17695
18311
  await runCodebaseGitOperation(folder, input, timeoutMs, signal);
17696
18312
  return {
17697
- ...successfulProcess8,
18313
+ ...successfulProcess9,
17698
18314
  worktree: await inspectWorktreeItem(
17699
18315
  folder,
17700
18316
  folder,
@@ -17774,7 +18390,7 @@ async function chooseNewBranch(folder, candidates, allowedCurrentBranch, timeout
17774
18390
  }
17775
18391
  async function validateBranchRoot(input, timeoutMs, signal) {
17776
18392
  const rootFolder = await realpath9(input.rootFolder);
17777
- if (!(await stat10(rootFolder)).isDirectory()) {
18393
+ if (!(await stat11(rootFolder)).isDirectory()) {
17778
18394
  throw new Error("Base repository is missing");
17779
18395
  }
17780
18396
  if (await origin(rootFolder, timeoutMs, signal) !== input.expectedOrigin) {
@@ -17837,13 +18453,13 @@ var branchWorktree = async (payload, timeoutMs, signal) => {
17837
18453
  timeoutMs,
17838
18454
  signal
17839
18455
  ) : input.candidates[0];
17840
- const targetFolder = input.action === "CREATE" ? join14(
18456
+ const targetFolder = input.action === "CREATE" ? join15(
17841
18457
  dirname8(rootFolder),
17842
18458
  `${basename5(rootFolder)}-${branch.replaceAll("/", "-")}`
17843
18459
  ) : changeFolder;
17844
18460
  if (input.action === "CREATE") {
17845
18461
  try {
17846
- await stat10(targetFolder);
18462
+ await stat11(targetFolder);
17847
18463
  throw new Error(`Worktree folder already exists: ${targetFolder}`);
17848
18464
  } catch (error) {
17849
18465
  if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT") {
@@ -17981,7 +18597,7 @@ var branchWorktree = async (payload, timeoutMs, signal) => {
17981
18597
  throw new Error(worktree.error || "Could not inspect the updated worktree");
17982
18598
  }
17983
18599
  return {
17984
- ...successfulProcess8,
18600
+ ...successfulProcess9,
17985
18601
  worktree,
17986
18602
  branch,
17987
18603
  baseBranch: input.baseBranch,
@@ -18038,7 +18654,7 @@ var pushMovedWorktree = async (payload, timeoutMs, signal) => {
18038
18654
  throw new Error("The source branch changed while it was being pushed");
18039
18655
  }
18040
18656
  return {
18041
- ...successfulProcess8,
18657
+ ...successfulProcess9,
18042
18658
  moveId: input.moveId,
18043
18659
  branch,
18044
18660
  headSha: pushedHeadSha
@@ -18129,12 +18745,12 @@ var checkoutMovedWorktree = async (payload, timeoutMs, signal) => {
18129
18745
  `Branch ${input.branch} is already checked out in ${occupiedFolder}`
18130
18746
  );
18131
18747
  }
18132
- targetFolder = join14(
18748
+ targetFolder = join15(
18133
18749
  dirname8(rootFolder),
18134
18750
  `${basename5(rootFolder)}-${input.branch.replaceAll("/", "-")}`
18135
18751
  );
18136
18752
  try {
18137
- await stat10(targetFolder);
18753
+ await stat11(targetFolder);
18138
18754
  throw new Error(`Worktree folder already exists: ${targetFolder}`);
18139
18755
  } catch (error) {
18140
18756
  if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT") {
@@ -18240,7 +18856,7 @@ var checkoutMovedWorktree = async (payload, timeoutMs, signal) => {
18240
18856
  if (switched.exitCode !== 0) {
18241
18857
  if (!input.stashOnFailure && hasChanges(targetChanges)) {
18242
18858
  return {
18243
- ...successfulProcess8,
18859
+ ...successfulProcess9,
18244
18860
  moveId: input.moveId,
18245
18861
  outcome: "NEEDS_STASH",
18246
18862
  message: cleanError4(
@@ -18309,7 +18925,7 @@ var checkoutMovedWorktree = async (payload, timeoutMs, signal) => {
18309
18925
  );
18310
18926
  }
18311
18927
  return {
18312
- ...successfulProcess8,
18928
+ ...successfulProcess9,
18313
18929
  moveId: input.moveId,
18314
18930
  outcome: "CHECKED_OUT",
18315
18931
  worktree,
@@ -18361,7 +18977,7 @@ var prepareWorktree = async (payload, timeoutMs, signal) => {
18361
18977
  });
18362
18978
  }
18363
18979
  }
18364
- return { ...successfulProcess8, worktrees };
18980
+ return { ...successfulProcess9, worktrees };
18365
18981
  }
18366
18982
  const folder = await validateWorktree2(input, timeoutMs, signal);
18367
18983
  const preparations = await executeWorktreePreparations(
@@ -18372,7 +18988,7 @@ var prepareWorktree = async (payload, timeoutMs, signal) => {
18372
18988
  signal
18373
18989
  );
18374
18990
  return {
18375
- ...successfulProcess8,
18991
+ ...successfulProcess9,
18376
18992
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
18377
18993
  preparations
18378
18994
  };
@@ -18380,7 +18996,7 @@ var prepareWorktree = async (payload, timeoutMs, signal) => {
18380
18996
  var deleteWorktree = async (payload, timeoutMs, signal) => {
18381
18997
  const input = worktreeDeleteJobPayload(payload);
18382
18998
  const rootFolder = await realpath9(input.rootFolder);
18383
- if (!(await stat10(rootFolder)).isDirectory()) {
18999
+ if (!(await stat11(rootFolder)).isDirectory()) {
18384
19000
  throw new Error("Base repository is missing");
18385
19001
  }
18386
19002
  if (await origin(rootFolder, timeoutMs, signal) !== input.expectedOrigin) {
@@ -18467,7 +19083,7 @@ var deleteWorktree = async (payload, timeoutMs, signal) => {
18467
19083
  );
18468
19084
  }
18469
19085
  return {
18470
- ...successfulProcess8,
19086
+ ...successfulProcess9,
18471
19087
  moveId: input.moveId,
18472
19088
  deleted: true,
18473
19089
  branch,
@@ -18568,7 +19184,7 @@ var operateWorktree = async (payload, timeoutMs, signal) => {
18568
19184
  operationOutcome = "PREPARATION_CONFLICT";
18569
19185
  preparationResults = await inspectPreparations();
18570
19186
  return {
18571
- ...successfulProcess8,
19187
+ ...successfulProcess9,
18572
19188
  outcome: operationOutcome,
18573
19189
  preparationConflictPaths: preparationConflictPathList,
18574
19190
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -18585,7 +19201,7 @@ var operateWorktree = async (payload, timeoutMs, signal) => {
18585
19201
  );
18586
19202
  if (preparationResults.some((item) => item.state === "ERROR")) {
18587
19203
  return {
18588
- ...successfulProcess8,
19204
+ ...successfulProcess9,
18589
19205
  exitCode: 1,
18590
19206
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
18591
19207
  preparations: preparationResults
@@ -18617,7 +19233,7 @@ var operateWorktree = async (payload, timeoutMs, signal) => {
18617
19233
  state: "SUSPENDED"
18618
19234
  }));
18619
19235
  return {
18620
- ...successfulProcess8,
19236
+ ...successfulProcess9,
18621
19237
  outcome: operationOutcome,
18622
19238
  preparationConflictPaths: preparationConflictPathList,
18623
19239
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -18679,7 +19295,7 @@ var operateWorktree = async (payload, timeoutMs, signal) => {
18679
19295
  operationOutcome = "PREPARATION_CONFLICT";
18680
19296
  preparationResults = await inspectPreparations();
18681
19297
  return {
18682
- ...successfulProcess8,
19298
+ ...successfulProcess9,
18683
19299
  outcome: operationOutcome,
18684
19300
  preparationConflictPaths: preparationConflictPathList,
18685
19301
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -18696,7 +19312,7 @@ var operateWorktree = async (payload, timeoutMs, signal) => {
18696
19312
  );
18697
19313
  if (preparationResults.some((item) => item.state === "ERROR")) {
18698
19314
  return {
18699
- ...successfulProcess8,
19315
+ ...successfulProcess9,
18700
19316
  exitCode: 1,
18701
19317
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
18702
19318
  preparations: preparationResults
@@ -18728,7 +19344,7 @@ var operateWorktree = async (payload, timeoutMs, signal) => {
18728
19344
  state: "SUSPENDED"
18729
19345
  }));
18730
19346
  return {
18731
- ...successfulProcess8,
19347
+ ...successfulProcess9,
18732
19348
  outcome: operationOutcome,
18733
19349
  preparationConflictPaths: preparationConflictPathList,
18734
19350
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -18779,7 +19395,7 @@ var operateWorktree = async (payload, timeoutMs, signal) => {
18779
19395
  break;
18780
19396
  }
18781
19397
  case "CLEAR_LOCK":
18782
- await rm10(join14(input.gitDirectory, "index.lock"), { force: true });
19398
+ await rm11(join15(input.gitDirectory, "index.lock"), { force: true });
18783
19399
  break;
18784
19400
  case "STASH_ALL":
18785
19401
  await runGit(["stash", "push", "--include-untracked"], "Stash failed");
@@ -18792,7 +19408,7 @@ var operateWorktree = async (payload, timeoutMs, signal) => {
18792
19408
  break;
18793
19409
  }
18794
19410
  return {
18795
- ...successfulProcess8,
19411
+ ...successfulProcess9,
18796
19412
  outcome: operationOutcome,
18797
19413
  preparationConflictPaths: preparationConflictPathList,
18798
19414
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -18855,7 +19471,7 @@ var autoSyncWorktree = async (payload, timeoutMs, signal) => {
18855
19471
  const continuingRebase = await rebaseInProgress(folder, timeoutMs, signal);
18856
19472
  if (changes.hasConflicts && !continuingRebase) {
18857
19473
  return {
18858
- ...successfulProcess8,
19474
+ ...successfulProcess9,
18859
19475
  outcome: "UNRESOLVED",
18860
19476
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
18861
19477
  preparations: suspendedPreparations(),
@@ -18885,7 +19501,7 @@ var autoSyncWorktree = async (payload, timeoutMs, signal) => {
18885
19501
  );
18886
19502
  if (continued.exitCode !== 0) {
18887
19503
  return {
18888
- ...successfulProcess8,
19504
+ ...successfulProcess9,
18889
19505
  outcome: "UNRESOLVED",
18890
19506
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
18891
19507
  preparations: suspendedPreparations(),
@@ -18907,7 +19523,7 @@ var autoSyncWorktree = async (payload, timeoutMs, signal) => {
18907
19523
  }
18908
19524
  if (changes.hasConflicts || changes.hasStagedChanges || changes.hasUnstagedChanges || await rebaseInProgress(folder, timeoutMs, signal)) {
18909
19525
  return {
18910
- ...successfulProcess8,
19526
+ ...successfulProcess9,
18911
19527
  outcome: "UNRESOLVED",
18912
19528
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
18913
19529
  preparations: suspendedPreparations(),
@@ -18950,7 +19566,7 @@ var autoSyncWorktree = async (payload, timeoutMs, signal) => {
18950
19566
  }
18951
19567
  const preparations = await reapplyPreparations();
18952
19568
  return {
18953
- ...successfulProcess8,
19569
+ ...successfulProcess9,
18954
19570
  outcome: "SYNCED",
18955
19571
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
18956
19572
  preparations,
@@ -18996,7 +19612,7 @@ var autoSyncWorktree = async (payload, timeoutMs, signal) => {
18996
19612
  if (upstreamContainsHead.exitCode !== 0) {
18997
19613
  await runGit(["push", "--force-with-lease"], "Auto Sync push failed");
18998
19614
  return {
18999
- ...successfulProcess8,
19615
+ ...successfulProcess9,
19000
19616
  outcome: "SYNCED",
19001
19617
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
19002
19618
  preparations: await inspectPreparations(),
@@ -19011,7 +19627,7 @@ var autoSyncWorktree = async (payload, timeoutMs, signal) => {
19011
19627
  };
19012
19628
  }
19013
19629
  return {
19014
- ...successfulProcess8,
19630
+ ...successfulProcess9,
19015
19631
  outcome: "NO_CHANGE",
19016
19632
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
19017
19633
  preparations: await inspectPreparations(),
@@ -19034,7 +19650,7 @@ var autoSyncWorktree = async (payload, timeoutMs, signal) => {
19034
19650
  );
19035
19651
  if (preparationConflictPathList.length > 0 && !input.forcePreparations) {
19036
19652
  return {
19037
- ...successfulProcess8,
19653
+ ...successfulProcess9,
19038
19654
  outcome: "PREPARATION_CONFLICT",
19039
19655
  preparationConflictPaths: preparationConflictPathList,
19040
19656
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -19059,7 +19675,7 @@ var autoSyncWorktree = async (payload, timeoutMs, signal) => {
19059
19675
  );
19060
19676
  if (preparationResults.some((item) => item.state === "ERROR")) {
19061
19677
  return {
19062
- ...successfulProcess8,
19678
+ ...successfulProcess9,
19063
19679
  exitCode: 1,
19064
19680
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
19065
19681
  preparations: preparationResults
@@ -19077,7 +19693,7 @@ var autoSyncWorktree = async (payload, timeoutMs, signal) => {
19077
19693
  const conflicts = conflictStatus.exitCode === 0 && statusChangeState(conflictStatus.stdout).hasConflicts;
19078
19694
  if (conflicts && await rebaseInProgress(folder, timeoutMs, signal)) {
19079
19695
  return {
19080
- ...successfulProcess8,
19696
+ ...successfulProcess9,
19081
19697
  outcome: "CONFLICT",
19082
19698
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
19083
19699
  preparations: suspendedPreparations(),
@@ -19107,7 +19723,7 @@ var autoSyncWorktree = async (payload, timeoutMs, signal) => {
19107
19723
  }
19108
19724
  preparationResults = input.forcePreparations ? await reapplyPreparations() : await inspectPreparations();
19109
19725
  return {
19110
- ...successfulProcess8,
19726
+ ...successfulProcess9,
19111
19727
  outcome: "SYNCED",
19112
19728
  checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
19113
19729
  preparations: preparationResults,
@@ -19126,7 +19742,7 @@ var autoSyncWorktree = async (payload, timeoutMs, signal) => {
19126
19742
  import { accessSync as accessSync2, constants as constants2 } from "node:fs";
19127
19743
  var MAX_OUTPUT_BYTES2 = 2 * 1024 * 1024;
19128
19744
  var mutationQueues = /* @__PURE__ */ new Map();
19129
- function objectValue14(value) {
19745
+ function objectValue15(value) {
19130
19746
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
19131
19747
  }
19132
19748
  function resolveTailscaleExecutable(platform2 = process.platform, resolve12 = findExecutable, isExecutable2 = (path) => {
@@ -19155,7 +19771,7 @@ function resolveTailscaleExecutable(platform2 = process.platform, resolve12 = fi
19155
19771
  function parseTailscaleJson(value, label) {
19156
19772
  try {
19157
19773
  const parsed = JSON.parse(value);
19158
- const object = objectValue14(parsed);
19774
+ const object = objectValue15(parsed);
19159
19775
  if (!object) throw new Error("expected an object");
19160
19776
  return object;
19161
19777
  } catch (error) {
@@ -19185,7 +19801,7 @@ async function captureTailscale(executable, args, timeoutMs, signal) {
19185
19801
  return result;
19186
19802
  }
19187
19803
  function backendIdentity(status2) {
19188
- const self2 = objectValue14(status2.Self);
19804
+ const self2 = objectValue15(status2.Self);
19189
19805
  const rawAddresses = Array.isArray(self2?.TailscaleIPs) ? self2.TailscaleIPs : status2.TailscaleIPs;
19190
19806
  const addresses = Array.isArray(rawAddresses) ? rawAddresses.filter((value) => typeof value === "string") : [];
19191
19807
  const dnsName = typeof self2?.DNSName === "string" ? self2.DNSName : null;
@@ -19215,21 +19831,21 @@ function portFromListener(value) {
19215
19831
  }
19216
19832
  function normalizeTailscaleServeSnapshot(status2, serve, inspectedAt = (/* @__PURE__ */ new Date()).toISOString()) {
19217
19833
  const routes = [];
19218
- const tcp = objectValue14(serve.TCP) ?? {};
19219
- const web = objectValue14(serve.Web) ?? {};
19220
- const funnel = objectValue14(serve.AllowFunnel) ?? {};
19834
+ const tcp = objectValue15(serve.TCP) ?? {};
19835
+ const web = objectValue15(serve.Web) ?? {};
19836
+ const funnel = objectValue15(serve.AllowFunnel) ?? {};
19221
19837
  for (const [listener, rawWeb] of Object.entries(web)) {
19222
19838
  const listenPort = portFromListener(listener);
19223
- const webConfig = objectValue14(rawWeb);
19224
- const handlers2 = objectValue14(webConfig?.Handlers);
19839
+ const webConfig = objectValue15(rawWeb);
19840
+ const handlers2 = objectValue15(webConfig?.Handlers);
19225
19841
  if (!listenPort || !handlers2) continue;
19226
- const tcpConfig = objectValue14(tcp[String(listenPort)]);
19842
+ const tcpConfig = objectValue15(tcp[String(listenPort)]);
19227
19843
  const protocol = tcpConfig?.HTTPS === true ? "HTTPS" : "HTTP";
19228
19844
  const isFunnel = Object.entries(funnel).some(
19229
19845
  ([key, enabled]) => enabled === true && portFromListener(key) === listenPort
19230
19846
  );
19231
19847
  for (const [mountPath, rawHandler] of Object.entries(handlers2)) {
19232
- const handler = objectValue14(rawHandler);
19848
+ const handler = objectValue15(rawHandler);
19233
19849
  if (!handler || typeof handler.Proxy !== "string") continue;
19234
19850
  const capabilities = Array.isArray(handler.AcceptAppCaps) ? handler.AcceptAppCaps.filter(
19235
19851
  (value) => typeof value === "string"
@@ -19252,7 +19868,7 @@ function normalizeTailscaleServeSnapshot(status2, serve, inspectedAt = (/* @__PU
19252
19868
  }
19253
19869
  for (const [listener, rawTcp] of Object.entries(tcp)) {
19254
19870
  const listenPort = portFromListener(listener);
19255
- const config = objectValue14(rawTcp);
19871
+ const config = objectValue15(rawTcp);
19256
19872
  if (!listenPort || !config || typeof config.TCPForward !== "string")
19257
19873
  continue;
19258
19874
  const destination = config.TCPForward.startsWith("tcp://") ? config.TCPForward : `tcp://${config.TCPForward}`;
@@ -19446,6 +20062,7 @@ var handlers = {
19446
20062
  [IOS_COVERAGE_REPORT_JOB_KIND]: generateIosBuildReport,
19447
20063
  [IOS_SIGNING_INSPECT_JOB_KIND]: inspectIosSigning,
19448
20064
  [COVERAGE_IMPORT_JOB_KIND]: importCoverageReport,
20065
+ [CRASH_SYMBOLICATE_JOB_KIND]: symbolicateCrash,
19449
20066
  [SIGNING_ASSETS_SCAN_JOB_KIND]: scanSigningAssets,
19450
20067
  [SIGNING_PROFILE_READ_JOB_KIND]: readSigningProfile,
19451
20068
  [SIGNING_PROFILE_INSTALL_JOB_KIND]: installSigningProfile,
@@ -19574,7 +20191,7 @@ var JobExecutor = class {
19574
20191
  claimed.payload,
19575
20192
  claimed.timeoutSeconds * 1e3,
19576
20193
  controller.signal,
19577
- (log) => this.client.appendLog(claimed.id, log).then(() => void 0),
20194
+ (log2) => this.client.appendLog(claimed.id, log2).then(() => void 0),
19578
20195
  {
19579
20196
  agentId: claimed.agentId,
19580
20197
  reportWorktreeActivity: (input) => this.client.reportWorktreeActivity(input),
@@ -19589,6 +20206,7 @@ var JobExecutor = class {
19589
20206
  uploadBuildArtifact: (input) => this.client.uploadBuildArtifact(input),
19590
20207
  uploadBuildArtifactTransfer: (input) => this.client.uploadBuildArtifactTransfer(input),
19591
20208
  downloadBuildArtifactTransfer: (input) => this.client.downloadBuildArtifactTransfer(input),
20209
+ downloadDsymDwarf: (input) => this.client.downloadDsymDwarf(input),
19592
20210
  claimSigningSecretTransfer: (transferId) => this.client.claimSigningSecretTransfer(transferId),
19593
20211
  claimWorkflowJobSecrets: () => this.client.claimWorkflowJobSecrets(claimed.id),
19594
20212
  appendCommandOutput: (attemptId, chunks) => this.client.appendCommandOutput(claimed.id, attemptId, chunks)
@@ -19755,21 +20373,21 @@ var CodebaseMonitor = class {
19755
20373
 
19756
20374
  // src/runs/run-manager.ts
19757
20375
  import { execFile as execFile4 } from "node:child_process";
19758
- import { mkdir as mkdir9, rm as rm15 } from "node:fs/promises";
19759
- import { dirname as dirname14, join as join21 } from "node:path";
20376
+ import { mkdir as mkdir10, rm as rm16 } from "node:fs/promises";
20377
+ import { dirname as dirname14, join as join22 } from "node:path";
19760
20378
  import { promisify as promisify4 } from "node:util";
19761
20379
 
19762
20380
  // src/runs/journal.ts
19763
- import { randomUUID as randomUUID4 } from "node:crypto";
20381
+ import { randomUUID as randomUUID5 } from "node:crypto";
19764
20382
  import {
19765
20383
  appendFile,
19766
- mkdir as mkdir6,
20384
+ mkdir as mkdir7,
19767
20385
  readFile as readFile10,
19768
- rename as rename4,
19769
- rm as rm11,
19770
- writeFile as writeFile8
20386
+ rename as rename5,
20387
+ rm as rm12,
20388
+ writeFile as writeFile9
19771
20389
  } from "node:fs/promises";
19772
- import { dirname as dirname9, join as join15 } from "node:path";
20390
+ import { dirname as dirname9, join as join16 } from "node:path";
19773
20391
  var RunJournal = class {
19774
20392
  constructor(runId, attemptId) {
19775
20393
  this.runId = runId;
@@ -19788,13 +20406,13 @@ var RunJournal = class {
19788
20406
  this.attemptId = attemptId;
19789
20407
  }
19790
20408
  get directory() {
19791
- return join15(dirname9(configPath()), "runs", this.runId);
20409
+ return join16(dirname9(configPath()), "runs", this.runId);
19792
20410
  }
19793
20411
  get eventsPath() {
19794
- return join15(this.directory, "events.jsonl");
20412
+ return join16(this.directory, "events.jsonl");
19795
20413
  }
19796
20414
  get statePath() {
19797
- return join15(this.directory, "state.json");
20415
+ return join16(this.directory, "state.json");
19798
20416
  }
19799
20417
  async load() {
19800
20418
  if (this.loaded) return;
@@ -19806,7 +20424,7 @@ var RunJournal = class {
19806
20424
  await this.loading;
19807
20425
  }
19808
20426
  async loadState() {
19809
- await mkdir6(this.directory, { recursive: true, mode: 448 });
20427
+ await mkdir7(this.directory, { recursive: true, mode: 448 });
19810
20428
  try {
19811
20429
  const state = JSON.parse(await readFile10(this.statePath, "utf8"));
19812
20430
  this.acknowledged = state.acknowledged ?? -1;
@@ -19826,7 +20444,7 @@ var RunJournal = class {
19826
20444
  await this.load();
19827
20445
  const value = {
19828
20446
  ...event,
19829
- id: randomUUID4(),
20447
+ id: randomUUID5(),
19830
20448
  sequence: this.nextSequence++,
19831
20449
  attemptId: this.attemptId
19832
20450
  };
@@ -19893,12 +20511,12 @@ var RunJournal = class {
19893
20511
  const contents = `${JSON.stringify({ acknowledged: this.acknowledged, nextSequence: this.nextSequence })}
19894
20512
  `;
19895
20513
  const operation = this.saving.then(async () => {
19896
- const temporary = `${this.statePath}.${process.pid}.${randomUUID4()}.tmp`;
20514
+ const temporary = `${this.statePath}.${process.pid}.${randomUUID5()}.tmp`;
19897
20515
  try {
19898
- await writeFile8(temporary, contents, { mode: 384 });
19899
- await rename4(temporary, this.statePath);
20516
+ await writeFile9(temporary, contents, { mode: 384 });
20517
+ await rename5(temporary, this.statePath);
19900
20518
  } catch (error) {
19901
- await rm11(temporary, { force: true }).catch(() => void 0);
20519
+ await rm12(temporary, { force: true }).catch(() => void 0);
19902
20520
  throw error;
19903
20521
  }
19904
20522
  });
@@ -19908,7 +20526,7 @@ var RunJournal = class {
19908
20526
  };
19909
20527
 
19910
20528
  // src/runs/claude-adapter.ts
19911
- import { randomUUID as randomUUID6 } from "node:crypto";
20529
+ import { randomUUID as randomUUID7 } from "node:crypto";
19912
20530
 
19913
20531
  // ../../node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
19914
20532
  import { createRequire as ose } from "node:module";
@@ -46483,7 +47101,7 @@ var HR = class {
46483
47101
  this.isClosed = true, this.onclose?.();
46484
47102
  }
46485
47103
  };
46486
- function rm13(e) {
47104
+ function rm14(e) {
46487
47105
  return typeof e === "number" && Number.isInteger(e) && e > 0 ? e : void 0;
46488
47106
  }
46489
47107
  var om = /* @__PURE__ */ Symbol("suppressControlResponse");
@@ -47030,7 +47648,7 @@ var sS = class _sS {
47030
47648
  for (let [a, c] of Object.entries(t)) {
47031
47649
  let l = this.sdkMcpServers.get(a);
47032
47650
  if (!l) this.connectSdkMcpServer(a, c);
47033
- else if (rm13(c.timeout) !== l.timeout) ie(`[Query.setMcpServers] MCP server '${a}' is already registered; its timeout change is ignored until the server is removed and re-added`);
47651
+ else if (rm14(c.timeout) !== l.timeout) ie(`[Query.setMcpServers] MCP server '${a}' is already registered; its timeout change is ignored until the server is removed and re-added`);
47034
47652
  }
47035
47653
  let s = {};
47036
47654
  for (let a of Object.keys(t)) {
@@ -47081,7 +47699,7 @@ var sS = class _sS {
47081
47699
  }
47082
47700
  connectSdkMcpServer(e, t) {
47083
47701
  let n = new HR((r) => this.sendMcpServerMessageToCli(e, r));
47084
- this.sdkMcpServers.set(e, { transport: n, timeout: rm13(t.timeout) }), t.instance.connect(n).catch((r) => {
47702
+ this.sdkMcpServers.set(e, { transport: n, timeout: rm14(t.timeout) }), t.instance.connect(n).catch((r) => {
47085
47703
  if (this.sdkMcpServers.get(e)?.transport === n) this.sdkMcpServers.delete(e);
47086
47704
  ie(`[Query.connectSdkMcpServer] Failed to connect MCP server '${e}': ${r}`, { level: "error" });
47087
47705
  });
@@ -56532,7 +57150,7 @@ var ClaudeAdapter = class {
56532
57150
  if (toolName !== "AskUserQuestion") {
56533
57151
  return { behavior: "allow", updatedInput: toolInput };
56534
57152
  }
56535
- const requestId = options.toolUseID || randomUUID6();
57153
+ const requestId = options.toolUseID || randomUUID7();
56536
57154
  const questions = questionsFromInput(toolInput);
56537
57155
  await callbacks.onQuestion(requestId, questions);
56538
57156
  const answers = await new Promise((resolve12) => {
@@ -56679,9 +57297,9 @@ import {
56679
57297
  execFile as execFile3,
56680
57298
  spawn as spawn9
56681
57299
  } from "node:child_process";
56682
- import { mkdtemp as mkdtemp7, rm as rm14, writeFile as writeFile9 } from "node:fs/promises";
56683
- import { tmpdir as tmpdir7 } from "node:os";
56684
- import { join as join20 } from "node:path";
57300
+ import { mkdtemp as mkdtemp7, rm as rm15, writeFile as writeFile10 } from "node:fs/promises";
57301
+ import { tmpdir as tmpdir8 } from "node:os";
57302
+ import { join as join21 } from "node:path";
56685
57303
  import { createInterface as createInterface2 } from "node:readline";
56686
57304
  import { promisify as promisify3 } from "node:util";
56687
57305
  var execFileAsync2 = promisify3(execFile3);
@@ -56814,7 +57432,7 @@ var CodexAppServer = class {
56814
57432
  }
56815
57433
  }
56816
57434
  async createBundledModelCatalog(executable) {
56817
- const directory = await mkdtemp7(join20(tmpdir7(), "aide-codex-models-"));
57435
+ const directory = await mkdtemp7(join21(tmpdir8(), "aide-codex-models-"));
56818
57436
  try {
56819
57437
  const { stdout } = await execFileAsync2(
56820
57438
  executable,
@@ -56824,12 +57442,12 @@ var CodexAppServer = class {
56824
57442
  maxBuffer: 16 * 1024 * 1024
56825
57443
  }
56826
57444
  );
56827
- const catalogPath = join20(directory, "models.json");
56828
- await writeFile9(catalogPath, stdout, "utf8");
57445
+ const catalogPath = join21(directory, "models.json");
57446
+ await writeFile10(catalogPath, stdout, "utf8");
56829
57447
  this.modelCatalogDirectory = directory;
56830
57448
  return catalogPath;
56831
57449
  } catch (error) {
56832
- await rm14(directory, { recursive: true, force: true }).catch(
57450
+ await rm15(directory, { recursive: true, force: true }).catch(
56833
57451
  () => void 0
56834
57452
  );
56835
57453
  throw error;
@@ -56840,7 +57458,7 @@ var CodexAppServer = class {
56840
57458
  if (this.modelCatalogDirectory === directory) {
56841
57459
  this.modelCatalogDirectory = void 0;
56842
57460
  }
56843
- await rm14(directory, { recursive: true, force: true }).catch(
57461
+ await rm15(directory, { recursive: true, force: true }).catch(
56844
57462
  () => void 0
56845
57463
  );
56846
57464
  }
@@ -63709,7 +64327,7 @@ var RunManager = class {
63709
64327
  5
63710
64328
  );
63711
64329
  await this.completeCommand(command3.id, "SUCCEEDED");
63712
- await rm15(join21(dirname14(configPath()), "runs", run.id, "attachments"), {
64330
+ await rm16(join22(dirname14(configPath()), "runs", run.id, "attachments"), {
63713
64331
  recursive: true,
63714
64332
  force: true
63715
64333
  }).catch(() => void 0);
@@ -63891,7 +64509,7 @@ var RunManager = class {
63891
64509
  this.active.delete(run.id);
63892
64510
  this.interruptionRequests.delete(run.id);
63893
64511
  this.executingCommands.delete(command3.id);
63894
- await rm15(join21(dirname14(configPath()), "runs", run.id, "attachments"), {
64512
+ await rm16(join22(dirname14(configPath()), "runs", run.id, "attachments"), {
63895
64513
  recursive: true,
63896
64514
  force: true
63897
64515
  }).catch(() => void 0);
@@ -64119,11 +64737,11 @@ var RunManager = class {
64119
64737
  }
64120
64738
  async stageAttachments(runId, attachments) {
64121
64739
  if (!attachments.length) return [];
64122
- const directory = join21(dirname14(configPath()), "runs", runId, "attachments");
64123
- await mkdir9(directory, { recursive: true, mode: 448 });
64740
+ const directory = join22(dirname14(configPath()), "runs", runId, "attachments");
64741
+ await mkdir10(directory, { recursive: true, mode: 448 });
64124
64742
  return Promise.all(
64125
64743
  attachments.map(async (attachment) => {
64126
- const path = join21(
64744
+ const path = join22(
64127
64745
  directory,
64128
64746
  `${attachment.id}-${safeFilename(attachment.filename)}`
64129
64747
  );
@@ -64811,7 +65429,7 @@ async function unenroll() {
64811
65429
  config = await loadConfig(path);
64812
65430
  } catch {
64813
65431
  }
64814
- await rm16(path, { force: true });
65432
+ await rm17(path, { force: true });
64815
65433
  console.log(
64816
65434
  config ? `Removed the enrollment for ${config.name} (${config.agentId}) from ${path}` : `Removed ${path}`
64817
65435
  );