@aspectlylabs/mikka 0.0.715 → 0.0.716

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/mikka.js CHANGED
@@ -1148,16 +1148,16 @@ var require_range = __commonJS({
1148
1148
  };
1149
1149
  var replaceTilde = (comp, options) => {
1150
1150
  const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
1151
- const z38 = options.includePrerelease ? "-0" : "";
1151
+ const z39 = options.includePrerelease ? "-0" : "";
1152
1152
  return comp.replace(r, (_, M, m, p, pr) => {
1153
1153
  debug("tilde", comp, _, M, m, p, pr);
1154
1154
  let ret;
1155
1155
  if (isX(M)) {
1156
1156
  ret = "";
1157
1157
  } else if (isX(m)) {
1158
- ret = `>=${M}.0.0${z38} <${+M + 1}.0.0-0`;
1158
+ ret = `>=${M}.0.0${z39} <${+M + 1}.0.0-0`;
1159
1159
  } else if (isX(p)) {
1160
- ret = `>=${M}.${m}.0${z38} <${M}.${+m + 1}.0-0`;
1160
+ ret = `>=${M}.${m}.0${z39} <${M}.${+m + 1}.0-0`;
1161
1161
  } else if (pr) {
1162
1162
  debug("replaceTilde pr", pr);
1163
1163
  ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
@@ -1174,19 +1174,19 @@ var require_range = __commonJS({
1174
1174
  var replaceCaret = (comp, options) => {
1175
1175
  debug("caret", comp, options);
1176
1176
  const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
1177
- const z38 = options.includePrerelease ? "-0" : "";
1177
+ const z39 = options.includePrerelease ? "-0" : "";
1178
1178
  return comp.replace(r, (_, M, m, p, pr) => {
1179
1179
  debug("caret", comp, _, M, m, p, pr);
1180
1180
  let ret;
1181
1181
  if (isX(M)) {
1182
1182
  ret = "";
1183
1183
  } else if (isX(m)) {
1184
- ret = `>=${M}.0.0${z38} <${+M + 1}.0.0-0`;
1184
+ ret = `>=${M}.0.0${z39} <${+M + 1}.0.0-0`;
1185
1185
  } else if (isX(p)) {
1186
1186
  if (M === "0") {
1187
- ret = `>=${M}.${m}.0${z38} <${M}.${+m + 1}.0-0`;
1187
+ ret = `>=${M}.${m}.0${z39} <${M}.${+m + 1}.0-0`;
1188
1188
  } else {
1189
- ret = `>=${M}.${m}.0${z38} <${+M + 1}.0.0-0`;
1189
+ ret = `>=${M}.${m}.0${z39} <${+M + 1}.0.0-0`;
1190
1190
  }
1191
1191
  } else if (pr) {
1192
1192
  debug("replaceCaret pr", pr);
@@ -2103,11 +2103,11 @@ function daemonProcessAlive(dataDir) {
2103
2103
  return pid !== null && processAlive(pid);
2104
2104
  }
2105
2105
  function socketAnswers(socketPath) {
2106
- return new Promise((resolve19) => {
2106
+ return new Promise((resolve20) => {
2107
2107
  const socket = createConnection(socketPath);
2108
2108
  const done = (alive) => {
2109
2109
  socket.destroy();
2110
- resolve19(alive);
2110
+ resolve20(alive);
2111
2111
  };
2112
2112
  socket.once("connect", () => done(true));
2113
2113
  socket.once("error", () => done(false));
@@ -2216,7 +2216,7 @@ function closeLogger(logger) {
2216
2216
  const file = files.get(logger);
2217
2217
  if (!file) return Promise.resolve();
2218
2218
  files.delete(logger);
2219
- return new Promise((resolve19) => file.end(resolve19));
2219
+ return new Promise((resolve20) => file.end(resolve20));
2220
2220
  }
2221
2221
 
2222
2222
  // src/auto-update.ts
@@ -3505,6 +3505,14 @@ var USER_ERROR_CODES = {
3505
3505
  "adapter_start_failed",
3506
3506
  "cleanup_failed"
3507
3507
  ],
3508
+ /** Agent/Bot interop: reads, sends and Drive across threads and Bots (decision 2026-11-19-2200). */
3509
+ interop_not_found: [],
3510
+ interop_invalid_request: [],
3511
+ interop_scope_required: [],
3512
+ interop_send_unavailable: ["run_not_active", "thread_replaced", "thread_cannot_continue", "delivery_unavailable", "delivery_uncertain", "bot_unavailable", "continuation_requires_grant"],
3513
+ interop_diff_unavailable: ["no_checkpoint", "masked"],
3514
+ interop_drive_conflict: [],
3515
+ interop_drive_unavailable: ["file_too_large"],
3508
3516
  cloud_machine_unfunded: []
3509
3517
  };
3510
3518
 
@@ -3660,7 +3668,7 @@ function sensitiveTexts(errorNodes, context) {
3660
3668
  else incomplete = true;
3661
3669
  }
3662
3670
  }
3663
- const walk = (value, depth) => {
3671
+ const walk2 = (value, depth) => {
3664
3672
  if (++inspected > 8192 || depth > 8) {
3665
3673
  incomplete = true;
3666
3674
  return;
@@ -3668,7 +3676,7 @@ function sensitiveTexts(errorNodes, context) {
3668
3676
  if (typeof value === "string") {
3669
3677
  if (value.length <= MAX_INPUT && (value.trimStart().startsWith("[") || value.trimStart().startsWith("{"))) {
3670
3678
  try {
3671
- walk(JSON.parse(value), depth + 1);
3679
+ walk2(JSON.parse(value), depth + 1);
3672
3680
  return;
3673
3681
  } catch {
3674
3682
  }
@@ -3687,7 +3695,7 @@ function sensitiveTexts(errorNodes, context) {
3687
3695
  incomplete = true;
3688
3696
  continue;
3689
3697
  }
3690
- walk(descriptor.value, depth + 1);
3698
+ walk2(descriptor.value, depth + 1);
3691
3699
  }
3692
3700
  } catch {
3693
3701
  incomplete = true;
@@ -3697,7 +3705,7 @@ function sensitiveTexts(errorNodes, context) {
3697
3705
  try {
3698
3706
  const descriptor = Object.getOwnPropertyDescriptor(node, key2);
3699
3707
  if (descriptor && !("value" in descriptor)) incomplete = true;
3700
- else if (descriptor) walk(descriptor.value, 0);
3708
+ else if (descriptor) walk2(descriptor.value, 0);
3701
3709
  } catch {
3702
3710
  incomplete = true;
3703
3711
  }
@@ -6509,7 +6517,7 @@ function normalizeRepository(input, options = {}) {
6509
6517
 
6510
6518
  // src/login.ts
6511
6519
  import { arch, hostname, platform } from "node:os";
6512
- import { z as z36 } from "zod";
6520
+ import { z as z37 } from "zod";
6513
6521
 
6514
6522
  // src/errors.ts
6515
6523
  var DaemonError = class extends Error {
@@ -6597,7 +6605,7 @@ import { join as join4 } from "node:path";
6597
6605
  // package.json
6598
6606
  var package_default = {
6599
6607
  name: "@mikka/daemon",
6600
- version: "0.0.715",
6608
+ version: "0.0.716",
6601
6609
  description: "Local Mikka daemon: runs agents through the user's own CLIs",
6602
6610
  type: "module",
6603
6611
  private: true,
@@ -6665,7 +6673,7 @@ var package_default = {
6665
6673
  engines: {
6666
6674
  node: ">=22"
6667
6675
  },
6668
- gitHead: "edfb82d33849f2fa0deb42030db1f8eca68f1eb4"
6676
+ gitHead: "c0661a23ac7ffd231ef10ad15ce379b20991c120"
6669
6677
  };
6670
6678
 
6671
6679
  // src/paths.ts
@@ -6706,7 +6714,7 @@ function daemonPaths(dataDir) {
6706
6714
  }
6707
6715
 
6708
6716
  // src/server-link-http.ts
6709
- import { z as z35 } from "zod";
6717
+ import { z as z36 } from "zod";
6710
6718
 
6711
6719
  // ../protocol/src/chat-attachments.ts
6712
6720
  import { z as z32 } from "zod";
@@ -6819,7 +6827,7 @@ var ToolApprovalGate = class {
6819
6827
  /** Resolves on the next push or revocation. A paused run waits here instead
6820
6828
  * of asking the server on a timer. */
6821
6829
  changed(signal) {
6822
- return new Promise((resolve19, reject) => {
6830
+ return new Promise((resolve20, reject) => {
6823
6831
  if (signal.aborted || this.revoked) {
6824
6832
  reject(new Error("cancelled"));
6825
6833
  return;
@@ -6828,7 +6836,7 @@ var ToolApprovalGate = class {
6828
6836
  this.changes.delete(wake);
6829
6837
  signal.removeEventListener("abort", abort);
6830
6838
  if (error) reject(error);
6831
- else resolve19();
6839
+ else resolve20();
6832
6840
  };
6833
6841
  const wake = () => done(this.revoked ? new Error("cancelled") : void 0);
6834
6842
  const abort = () => done(new Error("cancelled"));
@@ -7264,9 +7272,250 @@ async function createRunMailbox(host) {
7264
7272
  return { tools, request: invoke, close };
7265
7273
  }
7266
7274
 
7275
+ // src/run-drive.ts
7276
+ import { createHash as createHash3 } from "node:crypto";
7277
+ import { lstat, mkdir as mkdir2, readFile as readFile2, readdir, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
7278
+ import { dirname as dirname4, extname, join as join5, relative, resolve as resolve3, sep } from "node:path";
7279
+ import { z as z35 } from "zod";
7280
+ var READ_LIMIT = 1024 * 1024;
7281
+ var WRITE_LIMIT = 4 * 1024 * 1024;
7282
+ var MAX_FILES = 2e3;
7283
+ var STATE_DIR = ".state";
7284
+ var scopeSchema = z35.object({ scope: z35.enum(["bot", "thread", "environment", "workspace"]), scopeId: z35.uuid(), write: z35.boolean() }).strict();
7285
+ var listingSchema = z35.object({
7286
+ volume: z35.object({ id: z35.string(), headDigest: z35.string(), entries: z35.array(z35.object({ path: z35.string(), sizeBytes: z35.number(), sha256: z35.string() })) }).nullable()
7287
+ }).passthrough();
7288
+ var stateSchema = z35.object({ volumeId: z35.string().nullable(), headDigest: z35.string().nullable(), files: z35.record(z35.string(), z35.string()) }).strict();
7289
+ var sha5 = (bytes) => createHash3("sha256").update(bytes).digest("hex");
7290
+ function localDrivePath(folder, path3) {
7291
+ if (!path3 || path3.startsWith("/") || path3.includes("\\") || path3.split("/").some((part) => !part || part === "." || part === "..")) return null;
7292
+ const target = resolve3(folder, ...path3.split("/"));
7293
+ return target.startsWith(resolve3(folder) + sep) ? target : null;
7294
+ }
7295
+ function conflictPath(path3, runId) {
7296
+ const ext = extname(path3);
7297
+ return `${ext ? path3.slice(0, -ext.length) : path3}.conflict-${runId.slice(0, 8)}${ext}`;
7298
+ }
7299
+ async function walk(folder) {
7300
+ const found = [];
7301
+ const visit = async (dir) => {
7302
+ for (const entry of await readdir(dir, { withFileTypes: true })) {
7303
+ if (found.length >= MAX_FILES) return;
7304
+ const full = join5(dir, entry.name);
7305
+ if (entry.isSymbolicLink()) continue;
7306
+ if (entry.isDirectory()) await visit(full);
7307
+ else if (entry.isFile()) found.push(relative(folder, full).split(sep).join("/"));
7308
+ }
7309
+ };
7310
+ await visit(folder).catch((error) => {
7311
+ if (error.code !== "ENOENT") throw error;
7312
+ });
7313
+ return found;
7314
+ }
7315
+ function createDriveMirror(options) {
7316
+ const { root, runId, call } = options;
7317
+ const warn = options.warn ?? (() => {
7318
+ });
7319
+ const folderOf = (scope) => join5(root, scope.scope, scope.scopeId);
7320
+ const stateFile = (scope) => join5(root, STATE_DIR, `${scope.scope}-${scope.scopeId}.json`);
7321
+ const target = (scope) => ({ scope: scope.scope, scopeId: scope.scopeId });
7322
+ const readState2 = async (scope) => {
7323
+ try {
7324
+ return stateSchema.parse(JSON.parse(await readFile2(stateFile(scope), "utf8")));
7325
+ } catch {
7326
+ return { volumeId: null, headDigest: null, files: {} };
7327
+ }
7328
+ };
7329
+ const saveState = async (scope, state2) => {
7330
+ await mkdir2(join5(root, STATE_DIR), { recursive: true, mode: 448 });
7331
+ await writeFile2(stateFile(scope), JSON.stringify(state2), { mode: 384 });
7332
+ };
7333
+ const list = async (scope, volumeId) => {
7334
+ const result = await call("drive_list", { ...target(scope), ...volumeId ? { volumeId } : {} });
7335
+ if (result.isError) throw new Error(`drive_list ${String(result.value.error ?? "failed")}`);
7336
+ return listingSchema.parse(result.value).volume;
7337
+ };
7338
+ const download2 = async (scope, volumeId, path3, file, expected2) => {
7339
+ const result = await call("drive_read", { ...target(scope), volumeId, path: path3, encoding: "base64" });
7340
+ if (result.isError || typeof result.value.content !== "string") throw new Error(`drive_read ${String(result.value.error ?? "failed")}`);
7341
+ const bytes = Buffer.from(result.value.content, "base64");
7342
+ if (sha5(bytes) !== expected2) throw new Error("drive_read digest mismatch");
7343
+ await mkdir2(dirname4(file), { recursive: true });
7344
+ await writeFile2(file, bytes);
7345
+ };
7346
+ async function pullScope(scope) {
7347
+ const folder = folderOf(scope);
7348
+ await mkdir2(folder, { recursive: true, mode: 448 });
7349
+ const previous = await readState2(scope);
7350
+ const volume = await list(scope);
7351
+ const state2 = { volumeId: volume?.id ?? null, headDigest: volume?.headDigest ?? null, files: {} };
7352
+ const remote = /* @__PURE__ */ new Set();
7353
+ for (const entry of volume?.entries ?? []) {
7354
+ const file = localDrivePath(folder, entry.path);
7355
+ if (!file) continue;
7356
+ remote.add(entry.path);
7357
+ if (entry.sizeBytes > READ_LIMIT) continue;
7358
+ let local = null;
7359
+ try {
7360
+ local = sha5(await readFile2(file));
7361
+ } catch {
7362
+ }
7363
+ if (local !== entry.sha256) await download2(scope, volume.id, entry.path, file, entry.sha256);
7364
+ state2.files[entry.path] = entry.sha256;
7365
+ }
7366
+ for (const path3 of Object.keys(previous.files)) {
7367
+ if (remote.has(path3)) continue;
7368
+ const file = localDrivePath(folder, path3);
7369
+ if (file) await rm2(file, { force: true });
7370
+ }
7371
+ await saveState(scope, state2);
7372
+ }
7373
+ async function write(scope, state2, path3, bytes) {
7374
+ const content = bytes === null ? {} : { content: bytes.toString("base64"), encoding: "base64" };
7375
+ const fingerprint2 = sha5(`${path3}\0${bytes === null ? "delete" : sha5(bytes)}`).slice(0, 32);
7376
+ for (let attempt = 0; attempt < 3; attempt++) {
7377
+ const result = await call("drive_write", {
7378
+ ...target(scope),
7379
+ ...state2.volumeId ? { volumeId: state2.volumeId } : {},
7380
+ path: path3,
7381
+ ...content,
7382
+ expectedDigest: state2.headDigest ?? "0".repeat(64),
7383
+ mutationId: `sync:${runId}:${fingerprint2}:${attempt}`
7384
+ });
7385
+ if (!result.isError) {
7386
+ state2.volumeId = String(result.value.volumeId);
7387
+ state2.headDigest = String(result.value.headDigest);
7388
+ return "ok";
7389
+ }
7390
+ if (result.value.error !== "interop_drive_conflict") throw new Error(`drive_write ${String(result.value.error ?? "failed")}`);
7391
+ const volume = await list(scope, state2.volumeId);
7392
+ state2.volumeId = volume?.id ?? state2.volumeId;
7393
+ state2.headDigest = volume?.headDigest ?? (typeof result.value.headDigest === "string" ? result.value.headDigest : state2.headDigest);
7394
+ const remoteSha = volume?.entries.find((entry) => entry.path === path3)?.sha256 ?? null;
7395
+ if (remoteSha !== (state2.files[path3] ?? null)) return "conflict";
7396
+ }
7397
+ return "conflict";
7398
+ }
7399
+ async function pushScope(scope) {
7400
+ if (!scope.write) return;
7401
+ const folder = folderOf(scope);
7402
+ const state2 = await readState2(scope);
7403
+ const local = /* @__PURE__ */ new Map();
7404
+ for (const path3 of await walk(folder)) {
7405
+ const file = localDrivePath(folder, path3);
7406
+ if (!file || (await lstat(file)).size > WRITE_LIMIT) continue;
7407
+ local.set(path3, await readFile2(file));
7408
+ }
7409
+ const changes = [];
7410
+ for (const [path3, bytes] of local) if (state2.files[path3] !== sha5(bytes)) changes.push({ path: path3, bytes });
7411
+ for (const path3 of Object.keys(state2.files)) if (!local.has(path3)) changes.push({ path: path3, bytes: null });
7412
+ if (!changes.length) return;
7413
+ let conflicted = false;
7414
+ for (const change of changes) {
7415
+ const outcome = await write(scope, state2, change.path, change.bytes);
7416
+ if (outcome === "ok") {
7417
+ if (change.bytes === null) delete state2.files[change.path];
7418
+ else state2.files[change.path] = sha5(change.bytes);
7419
+ continue;
7420
+ }
7421
+ conflicted = true;
7422
+ if (change.bytes !== null) {
7423
+ const copy = conflictPath(change.path, runId);
7424
+ if (await write(scope, state2, copy, change.bytes) === "ok") state2.files[copy] = sha5(change.bytes);
7425
+ warn("drive sync conflict kept as a copy", { scope: scope.scope, path: change.path });
7426
+ }
7427
+ }
7428
+ await saveState(scope, state2);
7429
+ if (conflicted) await pullScope(scope);
7430
+ }
7431
+ const each = async (work, label2) => {
7432
+ for (const scope of options.scopes) {
7433
+ try {
7434
+ await work(scope);
7435
+ } catch (error) {
7436
+ warn(`drive ${label2} failed`, { scope: scope.scope, error: error instanceof Error ? error.name : "Error" });
7437
+ }
7438
+ }
7439
+ };
7440
+ let pushing;
7441
+ return {
7442
+ folders: options.scopes.map((scope) => ({ scope: scope.scope, path: folderOf(scope), write: scope.write })),
7443
+ pull: () => each(pullScope, "pull"),
7444
+ // Pushes never overlap: a checkpoint and the terminal push run one after the other.
7445
+ push: () => pushing = (pushing ?? Promise.resolve()).then(() => each(pushScope, "push"))
7446
+ };
7447
+ }
7448
+ async function createRunDrive(host) {
7449
+ const assigned = host.assignment.mcp;
7450
+ if (!assigned) return void 0;
7451
+ let endpoint;
7452
+ try {
7453
+ endpoint = new URL(assigned.url);
7454
+ } catch {
7455
+ return void 0;
7456
+ }
7457
+ if (endpoint.href !== host.endpoint.href || !trustedServerEndpoint(endpoint) || !/^mkw_[A-Za-z0-9_-]{43}$/.test(assigned.token)) return void 0;
7458
+ let nextId = 0, session = null, version = "2025-03-26";
7459
+ const rpc = async (method, params, notification = false) => {
7460
+ const id5 = ++nextId;
7461
+ const response = await host.fetch(endpoint, {
7462
+ method: "POST",
7463
+ redirect: "error",
7464
+ headers: {
7465
+ ...host.headers,
7466
+ "content-type": "application/json",
7467
+ accept: "application/json, text/event-stream",
7468
+ authorization: `Bearer ${assigned.token}`,
7469
+ "MCP-Protocol-Version": version,
7470
+ ...session ? { "Mcp-Session-Id": session } : {}
7471
+ },
7472
+ signal: AbortSignal.any([host.signal, AbortSignal.timeout(3e4)]),
7473
+ body: JSON.stringify({ jsonrpc: "2.0", ...!notification ? { id: id5 } : {}, method, params })
7474
+ });
7475
+ if (!response.ok) {
7476
+ await response.body?.cancel();
7477
+ throw new Error(`drive rpc ${response.status}`);
7478
+ }
7479
+ const sid = response.headers.get("mcp-session-id");
7480
+ if (sid && sid.length <= 256 && !/[\r\n]/.test(sid)) session = sid;
7481
+ if (notification) {
7482
+ await response.body?.cancel();
7483
+ return null;
7484
+ }
7485
+ const text4 = await response.text();
7486
+ if (text4.length > 8 * 1024 * 1024) throw new Error("drive rpc too large");
7487
+ const packet = response.headers.get("content-type")?.split(";")[0] === "text/event-stream" ? JSON.parse(text4.split(/\r?\n/).find((line) => line.startsWith("data:"))?.slice(5) ?? "null") : JSON.parse(text4);
7488
+ if (packet?.jsonrpc !== "2.0" || packet.id !== id5 || packet.error || !packet.result) throw new Error("drive rpc failed");
7489
+ return packet.result;
7490
+ };
7491
+ const call = async (name, args) => {
7492
+ const result = await rpc("tools/call", { name, arguments: args });
7493
+ const text4 = result.content?.find((part) => part.type === "text")?.text;
7494
+ if (typeof text4 !== "string") throw new Error("drive tool result missing");
7495
+ return { isError: result.isError === true, value: JSON.parse(text4) };
7496
+ };
7497
+ try {
7498
+ const initialized = await rpc("initialize", { protocolVersion: version, capabilities: {}, clientInfo: { name: "mikka-run-drive", version: "1" } });
7499
+ if (["2025-03-26", "2025-06-18", "2025-11-25"].includes(initialized.protocolVersion)) version = initialized.protocolVersion;
7500
+ await rpc("notifications/initialized", {}, true);
7501
+ const plan = await call("drive_sync_scopes", {});
7502
+ if (plan.isError) return void 0;
7503
+ const scopes = z35.array(scopeSchema).max(8).parse(plan.value.scopes);
7504
+ if (!scopes.length) return void 0;
7505
+ return createDriveMirror({ root: host.root, runId: host.assignment.runId, scopes, call, warn: host.warn });
7506
+ } catch (error) {
7507
+ host.warn?.("drive mirror unavailable", { error: error instanceof Error ? error.name : "Error" });
7508
+ return void 0;
7509
+ }
7510
+ }
7511
+
7512
+ // src/server-link-http.ts
7513
+ import { homedir as homedir4 } from "node:os";
7514
+ import { join as joinPath } from "node:path";
7515
+
7267
7516
  // src/tracing.ts
7268
7517
  import { AsyncLocalStorage } from "node:async_hooks";
7269
- import { createHash as createHash3 } from "node:crypto";
7518
+ import { createHash as createHash4 } from "node:crypto";
7270
7519
  import { ROOT_CONTEXT as ROOT_CONTEXT2, SpanStatusCode as SpanStatusCode3, isSpanContextValid, trace as trace3 } from "@opentelemetry/api";
7271
7520
  import { ExportResultCode as ExportResultCode2, W3CTraceContextPropagator } from "@opentelemetry/core";
7272
7521
  import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
@@ -7702,7 +7951,7 @@ function daemonSampleRate(settings, env = process.env) {
7702
7951
  return Math.min(1, Math.max(0, rate));
7703
7952
  }
7704
7953
  function runIdHash(runId) {
7705
- return createHash3("sha256").update(runId).digest("hex").slice(0, 16);
7954
+ return createHash4("sha256").update(runId).digest("hex").slice(0, 16);
7706
7955
  }
7707
7956
  function routeTemplate(path3) {
7708
7957
  const clean = path3.split(/[?#]/, 1)[0];
@@ -8122,8 +8371,8 @@ var DaemonTracer = class {
8122
8371
  let timer;
8123
8372
  await Promise.race([
8124
8373
  work,
8125
- new Promise((resolve19) => {
8126
- timer = setTimeout(resolve19, timeoutMs);
8374
+ new Promise((resolve20) => {
8375
+ timer = setTimeout(resolve20, timeoutMs);
8127
8376
  timer.unref();
8128
8377
  })
8129
8378
  ]).finally(() => {
@@ -8434,7 +8683,7 @@ var RunRuntimeTimings = class {
8434
8683
  var runRuntimeTimings = new RunRuntimeTimings();
8435
8684
 
8436
8685
  // src/server-link-http.ts
8437
- var deviceSessionRejection = z35.object({ error: z35.enum(["Unauthorized", "authRequired"]) }).strict();
8686
+ var deviceSessionRejection = z36.object({ error: z36.enum(["Unauthorized", "authRequired"]) }).strict();
8438
8687
  var refusalCode = (body) => {
8439
8688
  if (typeof body !== "object" || body === null) return void 0;
8440
8689
  const { code, error } = body;
@@ -8542,12 +8791,12 @@ var HttpServerLink = class {
8542
8791
  }
8543
8792
  /** Asks the server's Decisions API for one run. Never throws; null on any failure. */
8544
8793
  decide = async (runId, request2, signal) => {
8545
- const answer = z35.discriminatedUnion("type", [
8546
- z35.object({ type: z35.literal("predicate"), name: z35.string(), probability: z35.number() }),
8547
- z35.object({ type: z35.literal("choice"), name: z35.string(), choice: z35.string() })
8794
+ const answer = z36.discriminatedUnion("type", [
8795
+ z36.object({ type: z36.literal("predicate"), name: z36.string(), probability: z36.number() }),
8796
+ z36.object({ type: z36.literal("choice"), name: z36.string(), choice: z36.string() })
8548
8797
  ]);
8549
8798
  try {
8550
- const { answers } = await this.call("POST", `/v1/runs/${seg2(runId)}/decision`, { body: request2, schema: z35.object({ answers: z35.array(answer).nullable() }), signal, timeoutMs: 6e3 });
8799
+ const { answers } = await this.call("POST", `/v1/runs/${seg2(runId)}/decision`, { body: request2, schema: z36.object({ answers: z36.array(answer).nullable() }), signal, timeoutMs: 6e3 });
8551
8800
  return answers ? new Map(answers.map((item) => [item.name, item])) : null;
8552
8801
  } catch {
8553
8802
  return null;
@@ -8586,6 +8835,16 @@ var HttpServerLink = class {
8586
8835
  headers: { [CLIENT_VERSION_HEADER]: this.clientVersion, ...deviceSessionHeaders, ...this.protectionBypass ? { "x-vercel-protection-bypass": this.protectionBypass } : {} }
8587
8836
  });
8588
8837
  }
8838
+ async prepareRunDrive(assignment, signal) {
8839
+ return createRunDrive({
8840
+ assignment,
8841
+ signal,
8842
+ endpoint: serverUrl(this.baseUrl, "/api/mcp"),
8843
+ root: joinPath(process.env.HOME || homedir4(), ".mikka", "drive"),
8844
+ fetch: (url, init) => this.taskFetch(assignment.runId, "task_data", url, init),
8845
+ headers: { [CLIENT_VERSION_HEADER]: this.clientVersion, ...deviceSessionHeaders, ...this.protectionBypass ? { "x-vercel-protection-bypass": this.protectionBypass } : {} }
8846
+ });
8847
+ }
8589
8848
  async claimCoordinator(deviceId, signal) {
8590
8849
  const response = await this.send("POST", `/v1/devices/${seg2(deviceId)}/coordinator`, { operation: "claim" }, this.credential, { signal });
8591
8850
  if (response.status === 404) return null;
@@ -8946,16 +9205,16 @@ var updateRequired = () => new LoginError("failed", "This daemon is too old for
8946
9205
  var DEVICE_CODE_PATH = `${AUTH_BASE_PATH}/device/code`;
8947
9206
  var DEVICE_TOKEN_PATH = `${AUTH_BASE_PATH}/device/token`;
8948
9207
  var DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
8949
- var deviceCodeResponse = z36.object({
8950
- device_code: z36.string().min(1),
8951
- user_code: z36.string().min(1),
8952
- verification_uri: z36.string(),
8953
- verification_uri_complete: z36.string().optional(),
8954
- expires_in: z36.number().positive(),
8955
- interval: z36.number().positive().default(5)
9208
+ var deviceCodeResponse = z37.object({
9209
+ device_code: z37.string().min(1),
9210
+ user_code: z37.string().min(1),
9211
+ verification_uri: z37.string(),
9212
+ verification_uri_complete: z37.string().optional(),
9213
+ expires_in: z37.number().positive(),
9214
+ interval: z37.number().positive().default(5)
8956
9215
  });
8957
- var tokenResponse = z36.object({ access_token: z36.string().regex(/^orv_[A-Za-z0-9_-]{43}$/) });
8958
- var errorResponse = z36.object({ error: z36.string() });
9216
+ var tokenResponse = z37.object({ access_token: z37.string().regex(/^orv_[A-Za-z0-9_-]{43}$/) });
9217
+ var errorResponse = z37.object({ error: z37.string() });
8959
9218
  var LoginError = class extends DaemonError {
8960
9219
  constructor(reason, message) {
8961
9220
  super(4003, message);
@@ -8987,7 +9246,7 @@ async function post(options, path3, body) {
8987
9246
  };
8988
9247
  }
8989
9248
  async function deviceLogin(options) {
8990
- const sleep3 = options.sleep ?? ((ms2) => new Promise((resolve19) => setTimeout(resolve19, ms2)));
9249
+ const sleep3 = options.sleep ?? ((ms2) => new Promise((resolve20) => setTimeout(resolve20, ms2)));
8991
9250
  const started = await post(options, DEVICE_CODE_PATH, {
8992
9251
  client_id: DAEMON_CLIENT_ID,
8993
9252
  device_name: options.deviceName ?? hostname(),
@@ -9061,7 +9320,7 @@ import {
9061
9320
  realpathSync as realpathSync15
9062
9321
  } from "node:fs";
9063
9322
  import { arch as arch3, hostname as hostname2, platform as platform3 } from "node:os";
9064
- import { join as join35 } from "node:path";
9323
+ import { join as join36 } from "node:path";
9065
9324
  import { fileURLToPath as fileURLToPath2 } from "node:url";
9066
9325
 
9067
9326
  // src/runs/quota-exhausted.ts
@@ -9145,7 +9404,7 @@ function quotaStopApplies(assignment) {
9145
9404
  import { spawn as spawn2 } from "node:child_process";
9146
9405
  import { randomUUID as randomUUID2 } from "node:crypto";
9147
9406
  import { realpathSync as realpathSync10 } from "node:fs";
9148
- import { join as join14 } from "node:path";
9407
+ import { join as join15 } from "node:path";
9149
9408
 
9150
9409
  // src/adapters/generation-metrics.ts
9151
9410
  var record2 = (value) => value && typeof value === "object" ? value : {};
@@ -9280,14 +9539,14 @@ import { realpathSync as realpathSync2 } from "node:fs";
9280
9539
  function prepareAgentStart(signal, open5, diagnostics) {
9281
9540
  const lifetime = new AbortController();
9282
9541
  let accept, refuse2;
9283
- const finalOptions = new Promise((resolve19, reject) => {
9284
- accept = resolve19;
9542
+ const finalOptions = new Promise((resolve20, reject) => {
9543
+ accept = resolve20;
9285
9544
  refuse2 = reject;
9286
9545
  });
9287
9546
  void finalOptions.catch(() => void 0);
9288
9547
  let parked, failed;
9289
- const ready = new Promise((resolve19, reject) => {
9290
- parked = resolve19;
9548
+ const ready = new Promise((resolve20, reject) => {
9549
+ parked = resolve20;
9291
9550
  failed = reject;
9292
9551
  });
9293
9552
  void ready.catch(() => void 0);
@@ -9370,8 +9629,8 @@ var ClaimedPromptQueue = class {
9370
9629
  while (!this.closed) {
9371
9630
  const item = this.items.shift();
9372
9631
  if (item) yield item;
9373
- else await new Promise((resolve19) => {
9374
- this.wake = resolve19;
9632
+ else await new Promise((resolve20) => {
9633
+ this.wake = resolve20;
9375
9634
  });
9376
9635
  }
9377
9636
  }
@@ -9507,7 +9766,7 @@ import {
9507
9766
  rmSync as rmSync3,
9508
9767
  writeFileSync as writeFileSync2
9509
9768
  } from "node:fs";
9510
- import { dirname as dirname4 } from "node:path";
9769
+ import { dirname as dirname5 } from "node:path";
9511
9770
  import { execa } from "execa";
9512
9771
 
9513
9772
  // src/agents/harness-home.ts
@@ -9519,7 +9778,7 @@ import {
9519
9778
  rmSync as rmSync2,
9520
9779
  writeFileSync
9521
9780
  } from "node:fs";
9522
- import { join as join5 } from "node:path";
9781
+ import { join as join6 } from "node:path";
9523
9782
 
9524
9783
  // src/credential-globs.ts
9525
9784
  var CLOUD_WORKER_STATE_DIR = "/home/user/.mikka/worker/adapters";
@@ -9574,25 +9833,25 @@ var CODEX_CONFIG = [
9574
9833
  ].join("\n");
9575
9834
  function prepareCodexHome(dir, log) {
9576
9835
  ownDir(dir);
9577
- writeOwnFile(join5(dir, "config.toml"), CODEX_CONFIG);
9578
- if (lstatSync(join5(dir, "auth.json"), { throwIfNoEntry: false })) {
9836
+ writeOwnFile(join6(dir, "config.toml"), CODEX_CONFIG);
9837
+ if (lstatSync(join6(dir, "auth.json"), { throwIfNoEntry: false })) {
9579
9838
  log.warn("removing a credential file left in the run's codex home");
9580
- rmSync2(join5(dir, "auth.json"), { force: true, recursive: true });
9839
+ rmSync2(join6(dir, "auth.json"), { force: true, recursive: true });
9581
9840
  }
9582
9841
  return { home: dir };
9583
9842
  }
9584
9843
  function wipeRunCredentials(runDir) {
9585
- for (const path3 of RUN_CREDENTIAL_PATHS) rmSync2(join5(runDir, path3), { force: true, recursive: true });
9844
+ for (const path3 of RUN_CREDENTIAL_PATHS) rmSync2(join6(runDir, path3), { force: true, recursive: true });
9586
9845
  }
9587
9846
  function sweepRunCredentials(stateDir) {
9588
- rmSync2(join5(stateDir, "github"), { recursive: true, force: true });
9847
+ rmSync2(join6(stateDir, "github"), { recursive: true, force: true });
9589
9848
  let runs;
9590
9849
  try {
9591
- runs = readdirSync(join5(stateDir, "runs"));
9850
+ runs = readdirSync(join6(stateDir, "runs"));
9592
9851
  } catch {
9593
9852
  return;
9594
9853
  }
9595
- for (const run3 of runs) wipeRunCredentials(join5(stateDir, "runs", run3));
9854
+ for (const run3 of runs) wipeRunCredentials(join6(stateDir, "runs", run3));
9596
9855
  }
9597
9856
  function writeOwnFile(file, content) {
9598
9857
  rmSync2(file, { force: true, recursive: true });
@@ -9607,9 +9866,9 @@ function carryHistory(from, to, entries) {
9607
9866
  if (!lstatSync(from, { throwIfNoEntry: false })?.isDirectory()) return;
9608
9867
  ownDir(to);
9609
9868
  for (const entry of entries) {
9610
- const source = join5(from, entry);
9869
+ const source = join6(from, entry);
9611
9870
  if (!lstatSync(source, { throwIfNoEntry: false })) continue;
9612
- cpSync(source, join5(to, entry), {
9871
+ cpSync(source, join6(to, entry), {
9613
9872
  recursive: true,
9614
9873
  force: true,
9615
9874
  filter: (path3) => !lstatSync(path3).isSymbolicLink()
@@ -9656,8 +9915,8 @@ var EventQueue = class {
9656
9915
  if (next.type === "exit") return;
9657
9916
  continue;
9658
9917
  }
9659
- await new Promise((resolve19) => {
9660
- this.waiter = resolve19;
9918
+ await new Promise((resolve20) => {
9919
+ this.waiter = resolve20;
9661
9920
  });
9662
9921
  }
9663
9922
  }
@@ -9724,7 +9983,7 @@ async function spawnCli(sandbox, argv, options) {
9724
9983
  });
9725
9984
  const pgid = child.pid;
9726
9985
  if (pgid !== void 0) {
9727
- mkdirSync4(dirname4(options.pidFile), { recursive: true, mode: 448 });
9986
+ mkdirSync4(dirname5(options.pidFile), { recursive: true, mode: 448 });
9728
9987
  rmSync3(options.pidFile, { force: true });
9729
9988
  writeFileSync2(options.pidFile, String(pgid), { flag: "wx", mode: 384 });
9730
9989
  }
@@ -9734,13 +9993,13 @@ async function spawnCli(sandbox, argv, options) {
9734
9993
  stderr = (stderr + data).slice(-STDERR_TAIL * 4);
9735
9994
  });
9736
9995
  const exited = new Promise(
9737
- (resolve19) => {
9996
+ (resolve20) => {
9738
9997
  child.once("error", (error) => {
9739
9998
  stderr += `
9740
9999
  ${error.message}`;
9741
- resolve19({ code: null, signal: null });
10000
+ resolve20({ code: null, signal: null });
9742
10001
  });
9743
- child.once("exit", (code, signal) => resolve19({ code, signal }));
10002
+ child.once("exit", (code, signal) => resolve20({ code, signal }));
9744
10003
  }
9745
10004
  ).finally(() => {
9746
10005
  signalGroup(pgid, "SIGKILL");
@@ -9757,8 +10016,8 @@ ${error.message}`;
9757
10016
  let timer;
9758
10017
  await Promise.race([
9759
10018
  exited,
9760
- new Promise((resolve19) => {
9761
- timer = setTimeout(resolve19, graceMs);
10019
+ new Promise((resolve20) => {
10020
+ timer = setTimeout(resolve20, graceMs);
9762
10021
  })
9763
10022
  ]);
9764
10023
  clearTimeout(timer);
@@ -9804,16 +10063,16 @@ function errorMessage(error) {
9804
10063
 
9805
10064
  // src/agents/github-runtime.ts
9806
10065
  import { existsSync as existsSync3, lstatSync as lstatSync4, mkdirSync as mkdirSync6, mkdtempSync as mkdtempSync2, realpathSync as realpathSync7, rmSync as rmSync6, writeFileSync as writeFileSync3 } from "node:fs";
9807
- import { delimiter as delimiter2, join as join9, resolve as resolve6 } from "node:path";
10066
+ import { delimiter as delimiter2, join as join10, resolve as resolve7 } from "node:path";
9808
10067
  import { execa as execa4 } from "execa";
9809
10068
 
9810
10069
  // src/path-search.ts
9811
10070
  import { accessSync, constants, statSync } from "node:fs";
9812
- import { delimiter, isAbsolute, join as join6 } from "node:path";
10071
+ import { delimiter, isAbsolute, join as join7 } from "node:path";
9813
10072
  function findOnPath(command, path3 = process.env.PATH ?? "") {
9814
10073
  for (const directory of path3.split(delimiter)) {
9815
10074
  if (!directory) continue;
9816
- const candidate = join6(directory, command);
10075
+ const candidate = join7(directory, command);
9817
10076
  try {
9818
10077
  accessSync(candidate, constants.X_OK);
9819
10078
  if (statSync(candidate).isFile()) return candidate;
@@ -9832,7 +10091,7 @@ import {
9832
10091
  rmSync as rmSync5
9833
10092
  } from "node:fs";
9834
10093
  import { tmpdir } from "node:os";
9835
- import { basename, dirname as dirname6, join as join8, resolve as resolve4 } from "node:path";
10094
+ import { basename, dirname as dirname7, join as join9, resolve as resolve5 } from "node:path";
9836
10095
 
9837
10096
  // src/ids.ts
9838
10097
  var SAFE_ID = /^[A-Za-z0-9_-]{1,64}$/;
@@ -9899,8 +10158,8 @@ import {
9899
10158
  readFileSync as readFileSync4,
9900
10159
  rmSync as rmSync4
9901
10160
  } from "node:fs";
9902
- import { lstat, readdir } from "node:fs/promises";
9903
- import { dirname as dirname5, isAbsolute as isAbsolute2, join as join7, relative, resolve as resolve3 } from "node:path";
10161
+ import { lstat as lstat2, readdir as readdir2 } from "node:fs/promises";
10162
+ import { dirname as dirname6, isAbsolute as isAbsolute2, join as join8, relative as relative2, resolve as resolve4 } from "node:path";
9904
10163
  import { execa as execa2 } from "execa";
9905
10164
  import { simpleGit } from "simple-git";
9906
10165
 
@@ -9981,12 +10240,12 @@ function runBranch(runId) {
9981
10240
  return `mikka/run-${assertSafeId("run id", runId)}`;
9982
10241
  }
9983
10242
  function isInside(parent, child) {
9984
- const rel = relative(parent, child);
10243
+ const rel = relative2(parent, child);
9985
10244
  return rel === "" || !rel.startsWith("..") && !isAbsolute2(rel);
9986
10245
  }
9987
10246
  var configWriters = /* @__PURE__ */ new Map();
9988
10247
  function withRepoConfig(repoPath, work) {
9989
- const key2 = resolve3(repoPath);
10248
+ const key2 = resolve4(repoPath);
9990
10249
  const result = (configWriters.get(key2) ?? Promise.resolve()).then(work, work);
9991
10250
  const settled = result.then(() => void 0, () => void 0);
9992
10251
  configWriters.set(key2, settled);
@@ -10007,9 +10266,9 @@ var WorktreeManager = class {
10007
10266
  usageRefresh = null;
10008
10267
  /** The run's worktree dir; never outside the worktree root. */
10009
10268
  pathFor(runId) {
10010
- const root = resolve3(this.root);
10011
- const path3 = resolve3(root, assertSafeId("run id", runId));
10012
- if (dirname5(path3) !== root) {
10269
+ const root = resolve4(this.root);
10270
+ const path3 = resolve4(root, assertSafeId("run id", runId));
10271
+ if (dirname6(path3) !== root) {
10013
10272
  throw new Error(`worktree path escapes ${root}: ${runId}`);
10014
10273
  }
10015
10274
  return path3;
@@ -10021,7 +10280,7 @@ var WorktreeManager = class {
10021
10280
  async create(runId, repoPath, baseBranch) {
10022
10281
  await excludeVerifyArtifacts(repoPath);
10023
10282
  const path3 = this.pathFor(runId);
10024
- if (existsSync2(join7(path3, ".git"))) return path3;
10283
+ if (existsSync2(join8(path3, ".git"))) return path3;
10025
10284
  mkdirSync5(this.root, { recursive: true });
10026
10285
  await withRepoConfig(
10027
10286
  repoPath,
@@ -10085,10 +10344,10 @@ var WorktreeManager = class {
10085
10344
  */
10086
10345
  async continueFrom(repoPath, previousWorktree, runId) {
10087
10346
  await excludeVerifyArtifacts(repoPath);
10088
- const root = resolve3(this.root);
10089
- const path3 = resolve3(previousWorktree);
10090
- if (dirname5(path3) !== root) return null;
10091
- if (!existsSync2(join7(path3, ".git"))) return null;
10347
+ const root = resolve4(this.root);
10348
+ const path3 = resolve4(previousWorktree);
10349
+ if (dirname6(path3) !== root) return null;
10350
+ if (!existsSync2(join8(path3, ".git"))) return null;
10092
10351
  let gitDir;
10093
10352
  try {
10094
10353
  gitDir = await worktreeGitDir(repoPath, path3);
@@ -10122,11 +10381,11 @@ var WorktreeManager = class {
10122
10381
  const repoReal = realpathSync4(repoPath);
10123
10382
  const worktreeReal = realpathSync4(worktree);
10124
10383
  for (const file of recipe.copyFiles) {
10125
- const rel = relative(repoPath, resolve3(repoPath, file));
10384
+ const rel = relative2(repoPath, resolve4(repoPath, file));
10126
10385
  if (rel === "" || rel.startsWith("..") || isAbsolute2(rel)) {
10127
10386
  throw new Error(`setup recipe copies a file outside the repo: ${file}`);
10128
10387
  }
10129
- const from = join7(repoPath, rel);
10388
+ const from = join8(repoPath, rel);
10130
10389
  const fromStat = lstatSync2(from, { throwIfNoEntry: false });
10131
10390
  if (!fromStat) continue;
10132
10391
  if (!fromStat.isFile() || !isInside(repoReal, realpathSync4(from))) {
@@ -10134,10 +10393,10 @@ var WorktreeManager = class {
10134
10393
  `setup recipe copies a symlink or non-file, or leaves the repo: ${file}`
10135
10394
  );
10136
10395
  }
10137
- const to = join7(worktree, rel);
10138
- mkdirSync5(dirname5(to), { recursive: true });
10396
+ const to = join8(worktree, rel);
10397
+ mkdirSync5(dirname6(to), { recursive: true });
10139
10398
  const toStat = lstatSync2(to, { throwIfNoEntry: false });
10140
- if (!isInside(worktreeReal, realpathSync4(dirname5(to))) || toStat && !toStat.isFile()) {
10399
+ if (!isInside(worktreeReal, realpathSync4(dirname6(to))) || toStat && !toStat.isFile()) {
10141
10400
  throw new Error(
10142
10401
  `setup recipe would write through a symlink or outside the worktree: ${file}`
10143
10402
  );
@@ -10179,11 +10438,11 @@ var WorktreeManager = class {
10179
10438
  */
10180
10439
  async discardIfEmpty(runIds, worktree, repoPath) {
10181
10440
  if (this.retainResources) return false;
10182
- const root = resolve3(this.root);
10183
- const path3 = worktree ? resolve3(worktree) : null;
10184
- if (path3 && dirname5(path3) !== root) return false;
10441
+ const root = resolve4(this.root);
10442
+ const path3 = worktree ? resolve4(worktree) : null;
10443
+ if (path3 && dirname6(path3) !== root) return false;
10185
10444
  const git3 = simpleGit(repoPath);
10186
- if (path3 && existsSync2(join7(path3, ".git"))) {
10445
+ if (path3 && existsSync2(join8(path3, ".git"))) {
10187
10446
  if ((await this.changedFiles(path3)).length > 0) return false;
10188
10447
  }
10189
10448
  const branches = [];
@@ -10222,15 +10481,15 @@ var WorktreeManager = class {
10222
10481
  "mikka/run-*",
10223
10482
  "--format=%(refname:short) %(worktreepath)"
10224
10483
  ]);
10225
- const root = resolve3(this.root);
10226
- const repo = resolve3(repoPath);
10484
+ const root = resolve4(this.root);
10485
+ const repo = resolve4(repoPath);
10227
10486
  const branches = [];
10228
10487
  for (const line of out.split("\n")) {
10229
10488
  const [name, where = ""] = line.split(" ");
10230
10489
  const runId = name?.startsWith("mikka/run-") ? name.slice("mikka/run-".length) : "";
10231
10490
  if (!runId) continue;
10232
- const worktree = where.trim() ? resolve3(where.trim()) : null;
10233
- if (worktree && (worktree === repo || dirname5(worktree) !== root))
10491
+ const worktree = where.trim() ? resolve4(where.trim()) : null;
10492
+ if (worktree && (worktree === repo || dirname6(worktree) !== root))
10234
10493
  continue;
10235
10494
  branches.push({ runId, worktree });
10236
10495
  }
@@ -10282,9 +10541,9 @@ var WorktreeManager = class {
10282
10541
  async function excludeVerifyArtifacts(repoPath) {
10283
10542
  await withRepoConfig(repoPath, async () => {
10284
10543
  const common2 = (await simpleGit(repoPath).raw(["rev-parse", "--path-format=absolute", "--git-common-dir"])).trim();
10285
- const info = join7(common2, "info");
10544
+ const info = join8(common2, "info");
10286
10545
  mkdirSync5(info, { recursive: true });
10287
- const file = join7(info, "exclude");
10546
+ const file = join8(info, "exclude");
10288
10547
  if (existsSync2(file) && !lstatSync2(file).isFile()) throw new Error("Invalid repository exclude file");
10289
10548
  const existing = existsSync2(file) ? readFileSync4(file, "utf8") : "";
10290
10549
  if (!existing.split(/\r?\n/).includes("/.verify/")) appendFileSync(file, "\n/.verify/\n");
@@ -10293,19 +10552,19 @@ async function excludeVerifyArtifacts(repoPath) {
10293
10552
  async function du(path3) {
10294
10553
  let stat3;
10295
10554
  try {
10296
- stat3 = await lstat(path3);
10555
+ stat3 = await lstat2(path3);
10297
10556
  } catch {
10298
10557
  return 0;
10299
10558
  }
10300
10559
  if (!stat3.isDirectory()) return stat3.size;
10301
10560
  let entries;
10302
10561
  try {
10303
- entries = await readdir(path3);
10562
+ entries = await readdir2(path3);
10304
10563
  } catch {
10305
10564
  return 0;
10306
10565
  }
10307
10566
  let total = 0;
10308
- for (const entry of entries) total += await du(join7(path3, entry));
10567
+ for (const entry of entries) total += await du(join8(path3, entry));
10309
10568
  return total;
10310
10569
  }
10311
10570
 
@@ -10345,10 +10604,10 @@ async function worktreeGitDir(repoPath, worktree, signal) {
10345
10604
  }
10346
10605
  )).stdout.trim()
10347
10606
  );
10348
- const dotGit = join8(realpathSync5(worktree), ".git");
10349
- const root = join8(common2, "worktrees");
10607
+ const dotGit = join9(realpathSync5(worktree), ".git");
10608
+ const root = join9(common2, "worktrees");
10350
10609
  for (const name of readdirSync3(root)) {
10351
- const gitdirFile = join8(root, name, "gitdir");
10610
+ const gitdirFile = join9(root, name, "gitdir");
10352
10611
  let target;
10353
10612
  try {
10354
10613
  target = readFileSync5(gitdirFile, "utf8").trim();
@@ -10356,16 +10615,16 @@ async function worktreeGitDir(repoPath, worktree, signal) {
10356
10615
  continue;
10357
10616
  }
10358
10617
  if (target === dotGit || safeRealpath(target) === dotGit) {
10359
- return join8(root, name);
10618
+ return join9(root, name);
10360
10619
  }
10361
10620
  }
10362
10621
  throw new Error(`${worktree} is not a worktree of ${repoPath}`);
10363
10622
  }
10364
10623
  async function worktreeGitWritePaths(repoPath, worktree, runId) {
10365
10624
  assertSafeId("run id", runId);
10366
- const common2 = resolve4(await worktreeGitDir(repoPath, worktree), "..", "..");
10625
+ const common2 = resolve5(await worktreeGitDir(repoPath, worktree), "..", "..");
10367
10626
  if (basename(common2) !== ".git") throw new Error(`${repoPath} is not a standard clone`);
10368
- return [dirname6(common2)];
10627
+ return [dirname7(common2)];
10369
10628
  }
10370
10629
  function safeRealpath(path3) {
10371
10630
  try {
@@ -10382,7 +10641,7 @@ async function pinnedGit(repoPath, worktree, env = process.env, signal) {
10382
10641
  signal?.throwIfAborted();
10383
10642
  return execa3("git", [...SAFE_GIT, ...args], {
10384
10643
  cwd: workTree,
10385
- env: { ...env, ...extra, GIT_DIR: gitDir, GIT_COMMON_DIR: resolve4(gitDir, "..", ".."), GIT_WORK_TREE: workTree },
10644
+ env: { ...env, ...extra, GIT_DIR: gitDir, GIT_COMMON_DIR: resolve5(gitDir, "..", ".."), GIT_WORK_TREE: workTree },
10386
10645
  extendEnv: false,
10387
10646
  stdin: "ignore",
10388
10647
  cancelSignal: signal,
@@ -10393,8 +10652,8 @@ async function pinnedGit(repoPath, worktree, env = process.env, signal) {
10393
10652
  }
10394
10653
  async function snapshotTree(repoPath, worktree, env, signal) {
10395
10654
  const git3 = await pinnedGit(repoPath, worktree, env, signal);
10396
- const dir = mkdtempSync(join8(tmpdir(), "mikka-index-"));
10397
- const index = { GIT_INDEX_FILE: join8(dir, "index") };
10655
+ const dir = mkdtempSync(join9(tmpdir(), "mikka-index-"));
10656
+ const index = { GIT_INDEX_FILE: join9(dir, "index") };
10398
10657
  try {
10399
10658
  await git3(["read-tree", "HEAD"], index);
10400
10659
  await git3(["add", "--all"], index);
@@ -10557,14 +10816,14 @@ function gitError(error) {
10557
10816
  // src/agents/local-git-origin.ts
10558
10817
  import { lstatSync as lstatSync3, realpathSync as realpathSync6 } from "node:fs";
10559
10818
  import { tmpdir as tmpdir2 } from "node:os";
10560
- import { basename as basename2, dirname as dirname7, resolve as resolve5, sep } from "node:path";
10819
+ import { basename as basename2, dirname as dirname8, resolve as resolve6, sep as sep2 } from "node:path";
10561
10820
  import { pathToFileURL } from "node:url";
10562
10821
  var repository = "https://github.com/mikka-e2e/core-loop.git";
10563
10822
  function localGitOrigin(env = process.env) {
10564
10823
  if (!localTestAccountsMode(env) || !env.MIKKA_DEV_GIT_ORIGIN) return void 0;
10565
- const path3 = resolve5(env.MIKKA_DEV_GIT_ORIGIN);
10824
+ const path3 = resolve6(env.MIKKA_DEV_GIT_ORIGIN);
10566
10825
  const temporary = realpathSync6(tmpdir2());
10567
- if (basename2(path3) !== "origin.git" || !/^mvp-[a-f0-9-]{36}$/.test(basename2(dirname7(path3))) || !basename2(dirname7(dirname7(path3))).startsWith("mikka-mvp-origin-") || dirname7(dirname7(dirname7(path3))) !== temporary || !path3.startsWith(`${temporary}${sep}`) || !lstatSync3(path3).isDirectory() || realpathSync6(path3) !== path3) {
10826
+ if (basename2(path3) !== "origin.git" || !/^mvp-[a-f0-9-]{36}$/.test(basename2(dirname8(path3))) || !basename2(dirname8(dirname8(path3))).startsWith("mikka-mvp-origin-") || dirname8(dirname8(dirname8(path3))) !== temporary || !path3.startsWith(`${temporary}${sep2}`) || !lstatSync3(path3).isDirectory() || realpathSync6(path3) !== path3) {
10568
10827
  throw new Error("Invalid local acceptance Git origin");
10569
10828
  }
10570
10829
  return path3;
@@ -10575,7 +10834,7 @@ function localGitConfig(env = process.env) {
10575
10834
  }
10576
10835
 
10577
10836
  // src/agents/github-runtime.ts
10578
- var GITHUB_CREDENTIAL_SCRIPT = resolve6(import.meta.dirname, "github-credentials.mjs");
10837
+ var GITHUB_CREDENTIAL_SCRIPT = resolve7(import.meta.dirname, "github-credentials.mjs");
10579
10838
  var helper = GITHUB_CREDENTIAL_SCRIPT;
10580
10839
  var quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
10581
10840
  function preparedTokenEnvironment(token) {
@@ -10620,19 +10879,19 @@ function githubReceiptEnvironment(host = process.env) {
10620
10879
  function prepareGitHubEnvironment(runDir, github, path3, runtime) {
10621
10880
  const endpoint = new URL(github.endpoint);
10622
10881
  if (!endpoint.pathname.endsWith("/api/runs/github-token") || !trustedServerEndpoint(endpoint)) throw new Error("Invalid run GitHub endpoint");
10623
- const gh = runtime?.ghBinary ?? path3.split(delimiter2).map((dir2) => join9(dir2, "gh")).find((file) => existsSync3(file));
10882
+ const gh = runtime?.ghBinary ?? path3.split(delimiter2).map((dir2) => join10(dir2, "gh")).find((file) => existsSync3(file));
10624
10883
  const node = runtime?.nodeBinary ?? process.execPath;
10625
10884
  if (!gh) throw new Error("Install GitHub CLI (gh) before running GitHub tasks");
10626
- const dir = join9(runDir, "github");
10885
+ const dir = join10(runDir, "github");
10627
10886
  mkdirSync6(dir, { recursive: true, mode: 448 });
10628
- if (!lstatSync4(dir).isDirectory() || realpathSync7(dir) !== join9(realpathSync7(runDir), "github")) throw new Error("Invalid run GitHub directory");
10629
- const config = join9(dir, "config.json");
10887
+ if (!lstatSync4(dir).isDirectory() || realpathSync7(dir) !== join10(realpathSync7(runDir), "github")) throw new Error("Invalid run GitHub directory");
10888
+ const config = join10(dir, "config.json");
10630
10889
  rmSync6(config, { force: true });
10631
10890
  writeFileSync3(config, JSON.stringify({ ...github, gh }), { mode: 384, flag: "wx" });
10632
- const bin = join9(dir, "bin");
10891
+ const bin = join10(dir, "bin");
10633
10892
  mkdirSync6(bin, { recursive: true, mode: 448 });
10634
- if (!lstatSync4(bin).isDirectory() || realpathSync7(bin) !== join9(realpathSync7(dir), "bin")) throw new Error("Invalid run GitHub executable directory");
10635
- const wrapper = join9(bin, "gh");
10893
+ if (!lstatSync4(bin).isDirectory() || realpathSync7(bin) !== join10(realpathSync7(dir), "bin")) throw new Error("Invalid run GitHub executable directory");
10894
+ const wrapper = join10(bin, "gh");
10636
10895
  rmSync6(wrapper, { force: true });
10637
10896
  const fixtureConfig = localGitConfig();
10638
10897
  const fixtureProxy = fixtureConfig.length ? 'case "${HTTP_PROXY:-${http_proxy:-}}" in http://*@localhost:*|http://*@127.0.0.1:*) unset NO_PROXY no_proxy ;; esac\n' : "";
@@ -10681,7 +10940,7 @@ async function withRunGitCredentials(assignment, privateDir, work, preparedEnvir
10681
10940
  } });
10682
10941
  }
10683
10942
  mkdirSync6(privateDir, { recursive: true, mode: 448 });
10684
- const dir = mkdtempSync2(join9(privateDir, "github-fetch-"));
10943
+ const dir = mkdtempSync2(join10(privateDir, "github-fetch-"));
10685
10944
  try {
10686
10945
  let env = {};
10687
10946
  try {
@@ -10705,7 +10964,7 @@ async function agentPublishedReceipt(input) {
10705
10964
  if (!input.github.branch) throw new Error("No task branch to read back");
10706
10965
  const branch = input.github.branch;
10707
10966
  mkdirSync6(input.privateDir, { recursive: true, mode: 448 });
10708
- const receiptDir = mkdtempSync2(join9(input.privateDir, "github-receipt-"));
10967
+ const receiptDir = mkdtempSync2(join10(input.privateDir, "github-receipt-"));
10709
10968
  const nativeGitHub = input.hosted || Boolean(input.githubEnvironment);
10710
10969
  try {
10711
10970
  const env = {
@@ -10735,7 +10994,7 @@ async function agentPublishedReceipt(input) {
10735
10994
  try {
10736
10995
  const gh = (args) => {
10737
10996
  input.signal?.throwIfAborted();
10738
- return execa4(nativeGitHub ? "gh" : join9(receiptDir, "github", "bin", "gh"), args, { cwd: input.worktree, env, extendEnv: false, stdin: "ignore", cancelSignal: input.signal, killDescendants: true });
10997
+ return execa4(nativeGitHub ? "gh" : join10(receiptDir, "github", "bin", "gh"), args, { cwd: input.worktree, env, extendEnv: false, stdin: "ignore", cancelSignal: input.signal, killDescendants: true });
10739
10998
  };
10740
10999
  const [owner, repository2] = input.github.repository.split("/");
10741
11000
  const query2 = "query($owner:String!,$repository:String!,$commit:GitObjectID!){repository(owner:$owner,name:$repository){object(oid:$commit){... on Commit {oid statusCheckRollup{state}}}}}";
@@ -10759,7 +11018,7 @@ async function agentPublishedReceipt(input) {
10759
11018
  }
10760
11019
 
10761
11020
  // src/agents/run-apps.ts
10762
- import { resolve as resolve7 } from "node:path";
11021
+ import { resolve as resolve8 } from "node:path";
10763
11022
  function runMcp(mcp, traceContext) {
10764
11023
  if (!mcp) return void 0;
10765
11024
  let url;
@@ -10811,12 +11070,12 @@ function codexMcpServer(server) {
10811
11070
  return { name: server.name, transport: "stdio", command: "npx", args: ["--yes", "mcp-remote@0.16.5", server.url, "--transport", "sse-only", ...headers], env };
10812
11071
  }
10813
11072
  function nativeMcpProcess(server) {
10814
- return server.cwd ? { command: process.execPath, args: [resolve7(import.meta.dirname, "mcp-stdio-launcher.mjs"), server.cwd, server.command, ...server.args], env: server.env } : { command: server.command, args: server.args, env: server.env };
11073
+ return server.cwd ? { command: process.execPath, args: [resolve8(import.meta.dirname, "mcp-stdio-launcher.mjs"), server.cwd, server.command, ...server.args], env: server.env } : { command: server.command, args: server.args, env: server.env };
10815
11074
  }
10816
11075
 
10817
11076
  // src/agents/run-context.ts
10818
11077
  import { execFileSync } from "node:child_process";
10819
- import { createHash as createHash7 } from "node:crypto";
11078
+ import { createHash as createHash8 } from "node:crypto";
10820
11079
  import {
10821
11080
  lstatSync as lstatSync8,
10822
11081
  mkdirSync as mkdirSync8,
@@ -10826,15 +11085,15 @@ import {
10826
11085
  rmSync as rmSync8,
10827
11086
  writeFileSync as writeFileSync4
10828
11087
  } from "node:fs";
10829
- import { homedir as homedir4 } from "node:os";
10830
- import { dirname as dirname10, join as join13, resolve as resolve10 } from "node:path";
11088
+ import { homedir as homedir5 } from "node:os";
11089
+ import { dirname as dirname11, join as join14, resolve as resolve11 } from "node:path";
10831
11090
 
10832
11091
  // src/agents/skill-artifact.ts
10833
- import { createHash as createHash4 } from "node:crypto";
11092
+ import { createHash as createHash5 } from "node:crypto";
10834
11093
  import { lstatSync as lstatSync5, readFileSync as readFileSync6 } from "node:fs";
10835
11094
  function verifyAssignedSkills(skills, receipt) {
10836
11095
  if (!receipt) return;
10837
- if (skills?.length !== 1 || skills[0].id !== receipt.artifact.skillId || skills[0].files.length !== 0 || createHash4("sha256").update(skillMarkdown(skills[0]), "utf8").digest("hex") !== receipt.artifact.sha256)
11096
+ if (skills?.length !== 1 || skills[0].id !== receipt.artifact.skillId || skills[0].files.length !== 0 || createHash5("sha256").update(skillMarkdown(skills[0]), "utf8").digest("hex") !== receipt.artifact.sha256)
10838
11097
  throw new Error("Assigned Skill artifact digest mismatch");
10839
11098
  }
10840
11099
  function verifySkillAssignment(assignment) {
@@ -10845,7 +11104,7 @@ function verifySkillAssignment(assignment) {
10845
11104
  verifyAssignedSkills(assignment.skills, receipt);
10846
11105
  }
10847
11106
  function verifyMountedSkill(file, receipt) {
10848
- if (!lstatSync5(file).isFile() || lstatSync5(file).isSymbolicLink() || lstatSync5(file).nlink !== 1 || createHash4("sha256").update(readFileSync6(file)).digest("hex") !== receipt.artifact.sha256)
11107
+ if (!lstatSync5(file).isFile() || lstatSync5(file).isSymbolicLink() || lstatSync5(file).nlink !== 1 || createHash5("sha256").update(readFileSync6(file)).digest("hex") !== receipt.artifact.sha256)
10849
11108
  throw new Error("Mounted Skill artifact digest mismatch");
10850
11109
  }
10851
11110
  function verifySkillResume(assignment, current) {
@@ -10858,11 +11117,11 @@ function verifySkillResume(assignment, current) {
10858
11117
  import { lstatSync as lstatSync6, readlinkSync, realpathSync as realpathSync8 } from "node:fs";
10859
11118
  import {
10860
11119
  basename as basename3,
10861
- dirname as dirname8,
11120
+ dirname as dirname9,
10862
11121
  isAbsolute as isAbsolute3,
10863
- join as join10,
10864
- relative as relative2,
10865
- resolve as resolve8
11122
+ join as join11,
11123
+ relative as relative3,
11124
+ resolve as resolve9
10866
11125
  } from "node:path";
10867
11126
  function decide(action, context = {}) {
10868
11127
  if (!Object.hasOwn(PERMISSION_DEFAULTS, action))
@@ -10951,14 +11210,14 @@ function realTarget(path3) {
10951
11210
  let current = path3;
10952
11211
  for (let hops = 0; ; ) {
10953
11212
  try {
10954
- return join10(realpathSync8(current), ...[...missing2].reverse());
11213
+ return join11(realpathSync8(current), ...[...missing2].reverse());
10955
11214
  } catch {
10956
11215
  if (lstatSync6(current, { throwIfNoEntry: false })?.isSymbolicLink()) {
10957
11216
  if (++hops > 40) return path3;
10958
- current = resolve8(dirname8(current), readlinkSync(current));
11217
+ current = resolve9(dirname9(current), readlinkSync(current));
10959
11218
  continue;
10960
11219
  }
10961
- const parent = dirname8(current);
11220
+ const parent = dirname9(current);
10962
11221
  if (parent === current) return path3;
10963
11222
  missing2.push(basename3(current));
10964
11223
  current = parent;
@@ -10966,28 +11225,28 @@ function realTarget(path3) {
10966
11225
  }
10967
11226
  }
10968
11227
  function inside(parent, child) {
10969
- const rel = relative2(parent, child);
11228
+ const rel = relative3(parent, child);
10970
11229
  return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
10971
11230
  }
10972
11231
  function classifyWrite(worktree, target) {
10973
- const root = resolve8(worktree);
10974
- const lexical = resolve8(root, target);
11232
+ const root = resolve9(worktree);
11233
+ const lexical = resolve9(root, target);
10975
11234
  const ok2 = inside(root, lexical) && inside(realTarget(root), realTarget(lexical));
10976
11235
  return ok2 ? "write_in_worktree" : "write_outside_repo";
10977
11236
  }
10978
11237
 
10979
11238
  // src/captures.ts
10980
- import { createHash as createHash6 } from "node:crypto";
11239
+ import { createHash as createHash7 } from "node:crypto";
10981
11240
  import { closeSync as closeSync2, constants as constants3, createReadStream, fstatSync, lstatSync as lstatSync7, mkdirSync as mkdirSync7, mkdtempSync as mkdtempSync3, openSync as openSync2, readFileSync as readFileSync7, readSync, readdirSync as readdirSync4, rmSync as rmSync7 } from "node:fs";
10982
- import { join as join12 } from "node:path";
11241
+ import { join as join13 } from "node:path";
10983
11242
  import { tmpdir as tmpdir3 } from "node:os";
10984
11243
 
10985
11244
  // src/agents/capture-video.mjs
10986
11245
  import { execFile as execFile3 } from "node:child_process";
10987
- import { createHash as createHash5 } from "node:crypto";
11246
+ import { createHash as createHash6 } from "node:crypto";
10988
11247
  import { constants as constants2, createWriteStream } from "node:fs";
10989
- import { chmod, lstat as lstat2, mkdir as mkdir2, mkdtemp, open, readFile as readFile2, rename, rm as rm2, stat } from "node:fs/promises";
10990
- import { dirname as dirname9, basename as basename4, join as join11, resolve as resolve9 } from "node:path";
11248
+ import { chmod, lstat as lstat3, mkdir as mkdir3, mkdtemp, open, readFile as readFile3, rename, rm as rm3, stat } from "node:fs/promises";
11249
+ import { dirname as dirname10, basename as basename4, join as join12, resolve as resolve10 } from "node:path";
10991
11250
  import { devNull } from "node:os";
10992
11251
  import { pipeline } from "node:stream/promises";
10993
11252
  import { pathToFileURL as pathToFileURL2 } from "node:url";
@@ -11048,16 +11307,16 @@ var CaptureVideoError = class extends Error {
11048
11307
  }
11049
11308
  };
11050
11309
  async function captureVideoBinaries({ directory = CAPTURE_TOOLS_DIRECTORY, ownerId = 0 } = {}) {
11051
- const info = await lstat2(directory).catch((error) => {
11310
+ const info = await lstat3(directory).catch((error) => {
11052
11311
  if (error.code === "ENOENT") return null;
11053
11312
  throw error;
11054
11313
  });
11055
11314
  if (!info) return { ffmpeg: "ffmpeg", ffprobe: "ffprobe" };
11056
11315
  try {
11057
11316
  if (!info.isDirectory() || info.uid !== ownerId || info.mode & 18) throw new Error("Private capture tools directory is unsafe");
11058
- const binaries = { ffmpeg: join11(directory, "ffmpeg"), ffprobe: join11(directory, "ffprobe") };
11317
+ const binaries = { ffmpeg: join12(directory, "ffmpeg"), ffprobe: join12(directory, "ffprobe") };
11059
11318
  for (const path3 of Object.values(binaries)) {
11060
- const binary = await lstat2(path3);
11319
+ const binary = await lstat3(path3);
11061
11320
  if (!binary.isFile() || binary.uid !== ownerId || binary.mode & 18 || !(binary.mode & 73)) throw new Error("Private capture tool is unsafe");
11062
11321
  }
11063
11322
  return binaries;
@@ -11123,7 +11382,7 @@ async function snapshot2(source, destination, signal) {
11123
11382
  const mp4 = bytesRead >= 12 && header.subarray(4, 8).toString() === "ftyp";
11124
11383
  const webm = bytesRead >= 4 && header.subarray(0, 4).equals(Buffer.from([26, 69, 223, 163])) && header.toString("latin1").includes("webm");
11125
11384
  if (!mp4 && !webm) throw new CaptureVideoError("captureVideoInputInvalid");
11126
- const hash2 = createHash5("sha256"), stream = handle.createReadStream({ autoClose: false, start: 0, end: info.size - 1 });
11385
+ const hash2 = createHash6("sha256"), stream = handle.createReadStream({ autoClose: false, start: 0, end: info.size - 1 });
11127
11386
  stream.on("data", (bytes) => hash2.update(bytes));
11128
11387
  await pipeline(stream, createWriteStream(destination, { flags: "wx", mode: 384 }), { signal });
11129
11388
  if ((await stat(destination)).size !== info.size) throw new CaptureVideoError("captureVideoInputChanged");
@@ -11140,13 +11399,13 @@ function videoFilter(windows, width, fps) {
11140
11399
  }
11141
11400
  async function processCaptureVideo(input, output, options = {}) {
11142
11401
  const maximum = options.maxBytes ?? CAPTURE_VIDEO_MAX_BYTES;
11143
- if (!Number.isSafeInteger(maximum) || maximum < 1 || maximum > CAPTURE_VIDEO_MAX_BYTES || resolve9(input) === resolve9(output))
11402
+ if (!Number.isSafeInteger(maximum) || maximum < 1 || maximum > CAPTURE_VIDEO_MAX_BYTES || resolve10(input) === resolve10(output))
11144
11403
  throw new CaptureVideoError("captureVideoOptionsInvalid");
11145
11404
  const steps = normalizeRecordingSteps(options.steps);
11146
11405
  const deadline = Date.now() + Math.min(options.timeoutMs ?? 9e4, 18e4);
11147
11406
  const binaries = await captureVideoBinaries();
11148
- await mkdir2(dirname9(output), { recursive: true, mode: 448 });
11149
- const temporary = await mkdtemp(join11(dirname9(output), ".capture-process-"));
11407
+ await mkdir3(dirname10(output), { recursive: true, mode: 448 });
11408
+ const temporary = await mkdtemp(join12(dirname10(output), ".capture-process-"));
11150
11409
  await chmod(temporary, 448);
11151
11410
  const run3 = async (binary, args) => {
11152
11411
  options.signal?.throwIfAborted();
@@ -11186,12 +11445,12 @@ async function processCaptureVideo(input, output, options = {}) {
11186
11445
  return { durationMs: Math.round(seconds * 1e3), width: stream.width, height: stream.height };
11187
11446
  };
11188
11447
  try {
11189
- const source = join11(temporary, "source.video");
11448
+ const source = join12(temporary, "source.video");
11190
11449
  const originalFile = await snapshot2(input, source, options.signal);
11191
11450
  const original = await probe(source);
11192
11451
  const windows = recordingWindows(original.durationMs, steps);
11193
11452
  const retainedMs = windows.reduce((total, window) => total + window.endMs - window.startMs, 0);
11194
- const result = join11(temporary, "final.mp4");
11453
+ const result = join12(temporary, "final.mp4");
11195
11454
  const base = [
11196
11455
  "-y",
11197
11456
  "-nostdin",
@@ -11231,7 +11490,7 @@ async function processCaptureVideo(input, output, options = {}) {
11231
11490
  "2",
11232
11491
  "-pix_fmt",
11233
11492
  "yuv420p",
11234
- ...rate ? ["-b:v", `${rate}k`, "-pass", String(pass), "-passlogfile", join11(temporary, "pass")] : ["-crf", "28"],
11493
+ ...rate ? ["-b:v", `${rate}k`, "-pass", String(pass), "-passlogfile", join12(temporary, "pass")] : ["-crf", "28"],
11235
11494
  ...pass === 1 ? ["-f", "null", devNull] : ["-movflags", "+faststart", result]
11236
11495
  ]);
11237
11496
  };
@@ -11252,7 +11511,7 @@ async function processCaptureVideo(input, output, options = {}) {
11252
11511
  if (Math.abs(measured.durationMs - retainedMs) > Math.max(250, windows.length * 100))
11253
11512
  throw new CaptureVideoError("captureVideoDurationMismatch");
11254
11513
  await chmod(result, 384);
11255
- if (await lstat2(output).catch(() => null)) throw new CaptureVideoError("captureVideoOutputExists");
11514
+ if (await lstat3(output).catch(() => null)) throw new CaptureVideoError("captureVideoOutputExists");
11256
11515
  options.signal?.throwIfAborted();
11257
11516
  await rename(result, output);
11258
11517
  return {
@@ -11272,14 +11531,14 @@ async function processCaptureVideo(input, output, options = {}) {
11272
11531
  }
11273
11532
  };
11274
11533
  } finally {
11275
- await rm2(temporary, { recursive: true, force: true });
11534
+ await rm3(temporary, { recursive: true, force: true });
11276
11535
  }
11277
11536
  }
11278
- if (process.argv[1] && basename4(process.argv[1]) === "capture-video.mjs" && pathToFileURL2(resolve9(process.argv[1])).href === import.meta.url) {
11537
+ if (process.argv[1] && basename4(process.argv[1]) === "capture-video.mjs" && pathToFileURL2(resolve10(process.argv[1])).href === import.meta.url) {
11279
11538
  try {
11280
11539
  const [, , input, output, metadata2] = process.argv;
11281
11540
  if (!input || !output || !metadata2 || process.argv.length !== 5) throw new CaptureVideoError("captureVideoOptionsInvalid");
11282
- const options = JSON.parse(await readFile2(metadata2, "utf8"));
11541
+ const options = JSON.parse(await readFile3(metadata2, "utf8"));
11283
11542
  const result = await processCaptureVideo(input, output, options);
11284
11543
  process.stdout.write(JSON.stringify(result) + "\n");
11285
11544
  } catch (error) {
@@ -11308,7 +11567,7 @@ function readPlain(path3, max) {
11308
11567
  }
11309
11568
  }
11310
11569
  var drop = (dir, id5) => {
11311
- for (const name of [`${id5}.json`, ...EXTENSIONS.map((ext) => `${id5}.${ext}`)]) rmSync7(join12(dir, name), { force: true });
11570
+ for (const name of [`${id5}.json`, ...EXTENSIONS.map((ext) => `${id5}.${ext}`)]) rmSync7(join13(dir, name), { force: true });
11312
11571
  };
11313
11572
  async function hashPlain(path3, signal) {
11314
11573
  signal?.throwIfAborted();
@@ -11316,7 +11575,7 @@ async function hashPlain(path3, signal) {
11316
11575
  try {
11317
11576
  const info = fstatSync(fd);
11318
11577
  if (!info.isFile() || info.size < 1 || info.size > CAPTURE_RAW_MAX_BYTES) throw new Error("Invalid capture video input");
11319
- const hash2 = createHash6("sha256");
11578
+ const hash2 = createHash7("sha256");
11320
11579
  for await (const chunk of createReadStream(path3, { fd, autoClose: false, start: 0, end: info.size - 1, signal })) hash2.update(chunk);
11321
11580
  signal?.throwIfAborted();
11322
11581
  return hash2.digest("hex");
@@ -11326,12 +11585,12 @@ async function hashPlain(path3, signal) {
11326
11585
  }
11327
11586
  async function prepareVideo(file, id5, steps, pendingDir, signal) {
11328
11587
  signal?.throwIfAborted();
11329
- const directory = pendingDir ?? mkdtempSync3(join12(tmpdir3(), "mikka-capture-pending-"));
11588
+ const directory = pendingDir ?? mkdtempSync3(join13(tmpdir3(), "mikka-capture-pending-"));
11330
11589
  mkdirSync7(directory, { recursive: true, mode: 448 });
11331
- const output = join12(directory, `${id5}.processed.mp4`), receipt = join12(directory, `${id5}.video.json`);
11590
+ const output = join13(directory, `${id5}.processed.mp4`), receipt = join13(directory, `${id5}.video.json`);
11332
11591
  try {
11333
11592
  const originalHash = await hashPlain(file, signal);
11334
- const stepHash = createHash6("sha256").update(JSON.stringify(steps)).digest("hex");
11593
+ const stepHash = createHash7("sha256").update(JSON.stringify(steps)).digest("hex");
11335
11594
  let result;
11336
11595
  const previous = readPlain(receipt, 128e3);
11337
11596
  if (previous) {
@@ -11359,7 +11618,7 @@ async function prepareVideo(file, id5, steps, pendingDir, signal) {
11359
11618
  }
11360
11619
  function dropPrepared(pendingDir, id5) {
11361
11620
  if (!pendingDir) return;
11362
- for (const name of [`${id5}.json`, `${id5}.processed.mp4`, `${id5}.video.json`]) rmSync7(join12(pendingDir, name), { force: true });
11621
+ for (const name of [`${id5}.json`, `${id5}.processed.mp4`, `${id5}.video.json`]) rmSync7(join13(pendingDir, name), { force: true });
11363
11622
  }
11364
11623
  function fileType(path3) {
11365
11624
  let fd;
@@ -11386,7 +11645,7 @@ async function uploadCaptures(dir, runId, link, log, pendingDir, existingOnly =
11386
11645
  signal?.throwIfAborted();
11387
11646
  const id5 = name.endsWith(".json") ? name.slice(0, -5) : "";
11388
11647
  if (!ID.test(id5)) continue;
11389
- const meta = readPlain(join12(dir, name), 128e3);
11648
+ const meta = readPlain(join13(dir, name), 128e3);
11390
11649
  let title2 = "";
11391
11650
  let steps = [];
11392
11651
  try {
@@ -11396,7 +11655,7 @@ async function uploadCaptures(dir, runId, link, log, pendingDir, existingOnly =
11396
11655
  } catch {
11397
11656
  title2 = "";
11398
11657
  }
11399
- const file = EXTENSIONS.map((ext) => join12(dir, `${id5}.${ext}`)).find((path3) => lstatSync7(path3, { throwIfNoEntry: false }));
11658
+ const file = EXTENSIONS.map((ext) => join13(dir, `${id5}.${ext}`)).find((path3) => lstatSync7(path3, { throwIfNoEntry: false }));
11400
11659
  const originalType = file ? fileType(file) : null;
11401
11660
  let video;
11402
11661
  if (file && title2 && originalType?.startsWith("video/")) {
@@ -11418,8 +11677,8 @@ async function uploadCaptures(dir, runId, link, log, pendingDir, existingOnly =
11418
11677
  continue;
11419
11678
  }
11420
11679
  try {
11421
- const sha2562 = createHash6("sha256").update(bytes).digest("hex");
11422
- const pendingPath = pendingDir ? join12(pendingDir, `${id5}.json`) : null;
11680
+ const sha2562 = createHash7("sha256").update(bytes).digest("hex");
11681
+ const pendingPath = pendingDir ? join13(pendingDir, `${id5}.json`) : null;
11423
11682
  let pending;
11424
11683
  if (pendingPath) {
11425
11684
  try {
@@ -11477,7 +11736,7 @@ async function uploadCaptures(dir, runId, link, log, pendingDir, existingOnly =
11477
11736
  log.warn({ run_id: runId, capture: id5, status: error.code }, "capture reservation unavailable; retry stopped");
11478
11737
  if (pendingDir) {
11479
11738
  mkdirSync7(pendingDir, { recursive: true, mode: 448 });
11480
- writeJsonAtomic(join12(pendingDir, "blocked.json"), { status: error.code });
11739
+ writeJsonAtomic(join13(pendingDir, "blocked.json"), { status: error.code });
11481
11740
  }
11482
11741
  return sent;
11483
11742
  }
@@ -11503,8 +11762,8 @@ var CaptureUploader = class {
11503
11762
  /** A final signal bounds both this pass and any earlier pass still in flight. */
11504
11763
  flush(runId, existingOnly = false, signal) {
11505
11764
  if (!/^[A-Za-z0-9_-]{1,64}$/.test(runId)) return Promise.resolve();
11506
- const pendingDir = this.pendingRoot ? join12(this.pendingRoot, runId) : void 0;
11507
- if (pendingDir && lstatSync7(join12(pendingDir, "blocked.json"), { throwIfNoEntry: false }))
11765
+ const pendingDir = this.pendingRoot ? join13(this.pendingRoot, runId) : void 0;
11766
+ if (pendingDir && lstatSync7(join13(pendingDir, "blocked.json"), { throwIfNoEntry: false }))
11508
11767
  return signal ? Promise.reject(new Error("Capture upload incomplete")) : Promise.resolve();
11509
11768
  const pass = this.passes.get(runId) ?? { tail: Promise.resolve(), abort: new AbortController() };
11510
11769
  const abort = () => pass.abort.abort(signal?.reason);
@@ -11549,7 +11808,7 @@ var HARNESS_DOMAINS = {
11549
11808
  "*.cursorapi.com"
11550
11809
  ]
11551
11810
  };
11552
- var MCP_SERVER_SCRIPT = resolve10(import.meta.dirname, "mikka-mcp.mjs");
11811
+ var MCP_SERVER_SCRIPT = resolve11(import.meta.dirname, "mikka-mcp.mjs");
11553
11812
  var MCP_SERVER_NAME = "mikka";
11554
11813
  var COMPUTER_MCP_SERVER_NAME = "mikka_computer";
11555
11814
  var RUN_GIT_CONFIG = [["maintenance.auto", "false"], ["gc.auto", "0"]];
@@ -11562,7 +11821,7 @@ function withGitConfig(env, entries) {
11562
11821
  });
11563
11822
  return out;
11564
11823
  }
11565
- function credentialDenyRead(harness, home = homedir4()) {
11824
+ function credentialDenyRead(harness, home = homedir5()) {
11566
11825
  return [
11567
11826
  ".ssh",
11568
11827
  ".aws",
@@ -11580,7 +11839,7 @@ function credentialDenyRead(harness, home = homedir4()) {
11580
11839
  // Other harnesses' logins; each harness still reads its own.
11581
11840
  ...harness === "codex" ? [] : [".codex/auth.json"],
11582
11841
  ...harness === "claude_code" ? [] : [".claude/.credentials.json"]
11583
- ].map((path3) => join13(home, path3));
11842
+ ].map((path3) => join14(home, path3));
11584
11843
  }
11585
11844
  function daemonSecrets(dataDir) {
11586
11845
  const paths = daemonPaths(realpathSync9(dataDir));
@@ -11591,18 +11850,18 @@ function daemonSecrets(dataDir) {
11591
11850
  paths.outbox,
11592
11851
  paths.logs,
11593
11852
  paths.devRepos,
11594
- join13(paths.adapterState, "pids")
11853
+ join14(paths.adapterState, "pids")
11595
11854
  ];
11596
11855
  }
11597
11856
  function runPaths(stateDir, runId) {
11598
11857
  const id5 = assertSafeId("run id", runId);
11599
11858
  return {
11600
11859
  /** The daemon's data dir (`stateDir` is `<dataDir>/adapters`). */
11601
- privateDir: resolve10(stateDir, ".."),
11860
+ privateDir: resolve11(stateDir, ".."),
11602
11861
  /** Writable from the sandbox. */
11603
- runDir: join13(stateDir, "runs", id5),
11862
+ runDir: join14(stateDir, "runs", id5),
11604
11863
  /** Daemon only. */
11605
- pidFile: join13(stateDir, "pids", `${id5}.pgid`)
11864
+ pidFile: join14(stateDir, "pids", `${id5}.pgid`)
11606
11865
  };
11607
11866
  }
11608
11867
  function repositorySkill(worktree, slug) {
@@ -11610,7 +11869,7 @@ function repositorySkill(worktree, slug) {
11610
11869
  const missing2 = (reason) => ({ id: id5, name: slug, description: "", source: "repository", digest: null, instructions: null, available: false, reason });
11611
11870
  if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(slug)) return missing2("invalid");
11612
11871
  for (const root of [".claude/skills", ".agents/skills"]) {
11613
- const file = join13(worktree, root, slug, SKILL_BODY_FILE);
11872
+ const file = join14(worktree, root, slug, SKILL_BODY_FILE);
11614
11873
  const meta = lstatSync8(file, { throwIfNoEntry: false });
11615
11874
  if (!meta) continue;
11616
11875
  if (!meta.isFile() || meta.isSymbolicLink() || meta.nlink !== 1 || meta.size < 1 || meta.size > MAX_PROFILE_SKILL_INSTRUCTIONS_LENGTH) return missing2("invalid");
@@ -11632,7 +11891,7 @@ function repositorySkill(worktree, slug) {
11632
11891
  name: (declaredName || slug).slice(0, 80),
11633
11892
  description: description.slice(0, 500),
11634
11893
  source: "repository",
11635
- digest: createHash7("sha256").update(body, "utf8").digest("hex"),
11894
+ digest: createHash8("sha256").update(body, "utf8").digest("hex"),
11636
11895
  instructions: body,
11637
11896
  available: true
11638
11897
  };
@@ -11646,16 +11905,16 @@ function writeProfileSkillManifest(options, runDir, worktree, includeRepository)
11646
11905
  if (assigned.length > MAX_PROFILE_SKILLS_PER_RUN || declared.length > MAX_PROFILE_SKILLS_PER_RUN) throw new Error("Profile Skill assignment limit");
11647
11906
  const entries = [];
11648
11907
  for (const skill of assigned) {
11649
- const digest9 = createHash7("sha256").update(skill.instructions, "utf8").digest("hex");
11908
+ const digest9 = createHash8("sha256").update(skill.instructions, "utf8").digest("hex");
11650
11909
  if (digest9 !== skill.digest) throw new Error("Profile Skill artifact digest mismatch");
11651
11910
  entries.push({ id: skill.id, name: skill.name, description: skill.description, source: skill.source, digest: digest9, instructions: skill.instructions, available: true });
11652
11911
  }
11653
11912
  for (const slug of declared) entries.push(includeRepository ? repositorySkill(worktree, slug) : { id: `repository:${slug}`, name: slug, description: "", source: "repository", digest: null, instructions: null, available: false, reason: "pending" });
11654
11913
  const unique = [...new Map(entries.map((entry) => [entry.id, entry])).values()];
11655
- const dir = join13(runDir, PROFILE_SKILLS_DIR);
11914
+ const dir = join14(runDir, PROFILE_SKILLS_DIR);
11656
11915
  ownDir(dir);
11657
11916
  const manifest = { version: 1, skills: unique };
11658
- const file = join13(dir, PROFILE_SKILL_MANIFEST_FILE);
11917
+ const file = join14(dir, PROFILE_SKILL_MANIFEST_FILE);
11659
11918
  const tmp = `${file}.${process.pid}.tmp`;
11660
11919
  writeFileSync4(tmp, `${JSON.stringify(manifest)}
11661
11920
  `, { encoding: "utf8", mode: 384 });
@@ -11666,11 +11925,11 @@ function prepareRunContextFiles(options) {
11666
11925
  ownDir(options.runDir);
11667
11926
  const runDir = realpathSync9(options.runDir);
11668
11927
  const files2 = {
11669
- worktree: resolve10(options.worktree),
11928
+ worktree: resolve11(options.worktree),
11670
11929
  runDir,
11671
- handoffFile: join13(runDir, "handoff.json"),
11672
- tmpDir: join13(runDir, "tmp"),
11673
- capturesDir: join13(runDir, CAPTURES_DIR)
11930
+ handoffFile: join14(runDir, "handoff.json"),
11931
+ tmpDir: join14(runDir, "tmp"),
11932
+ capturesDir: join14(runDir, CAPTURES_DIR)
11674
11933
  };
11675
11934
  ownDir(files2.tmpDir);
11676
11935
  ownDir(files2.capturesDir);
@@ -11704,7 +11963,7 @@ function runMcpServer(options, files2) {
11704
11963
  files2.worktree,
11705
11964
  "--capture-root",
11706
11965
  files2.tmpDir,
11707
- ...options.profileSkills?.length || options.repositorySkills?.length ? ["--profile-skills", join13(files2.runDir, PROFILE_SKILLS_DIR)] : [],
11966
+ ...options.profileSkills?.length || options.repositorySkills?.length ? ["--profile-skills", join14(files2.runDir, PROFILE_SKILLS_DIR)] : [],
11708
11967
  ...options.factoryCheck && (!options.factoryCheck.reportOnly || options.factoryCheck.inferCommand) ? ["--factory-verify", JSON.stringify({ cwd: files2.worktree, command: options.verifyCommand ?? null, infer: options.factoryCheck.inferCommand })] : [],
11709
11968
  ...options.factoryCheck?.reportOnly || readOnlyInspection ? ["--factory-artifacts", files2.worktree] : [],
11710
11969
  ...repositoryExecution ? ["--repository-selection", files2.worktree] : []
@@ -11752,13 +12011,13 @@ var RunContext = class {
11752
12011
  );
11753
12012
  ownDir(options.runDir);
11754
12013
  this.runDir = realpathSync9(options.runDir);
11755
- this.handoffFile = join13(this.runDir, "handoff.json");
11756
- this.skillsDir = join13(this.runDir, SKILLS_DIR);
11757
- this.tmpDir = join13(this.runDir, "tmp");
12014
+ this.handoffFile = join14(this.runDir, "handoff.json");
12015
+ this.skillsDir = join14(this.runDir, SKILLS_DIR);
12016
+ this.tmpDir = join14(this.runDir, "tmp");
11758
12017
  ownDir(this.tmpDir);
11759
- this.capturesDir = join13(this.runDir, CAPTURES_DIR);
12018
+ this.capturesDir = join14(this.runDir, CAPTURES_DIR);
11760
12019
  ownDir(this.capturesDir);
11761
- this.profileSkillsDir = join13(this.runDir, PROFILE_SKILLS_DIR);
12020
+ this.profileSkillsDir = join14(this.runDir, PROFILE_SKILLS_DIR);
11762
12021
  this.writeSkills();
11763
12022
  this.writeProfileSkills();
11764
12023
  if (options.github && !options.machineEnvironment) {
@@ -11801,23 +12060,23 @@ var RunContext = class {
11801
12060
  let slug = base;
11802
12061
  for (let n = 2; taken.has(slug); n += 1) slug = `${base}-${n}`;
11803
12062
  taken.add(slug);
11804
- const dir = join13(this.skillsDir, slug);
12063
+ const dir = join14(this.skillsDir, slug);
11805
12064
  if (this.options.skillReceipt) {
11806
12065
  const existing = lstatSync8(dir, { throwIfNoEntry: false });
11807
12066
  if (existing && (!existing.isDirectory() || existing.isSymbolicLink())) throw new Error("Unsafe Skill artifact directory");
11808
- const file = lstatSync8(join13(dir, SKILL_BODY_FILE), { throwIfNoEntry: false });
12067
+ const file = lstatSync8(join14(dir, SKILL_BODY_FILE), { throwIfNoEntry: false });
11809
12068
  if (file && (!file.isFile() || file.isSymbolicLink() || file.nlink !== 1)) throw new Error("Unsafe Skill artifact file");
11810
12069
  }
11811
12070
  mkdirSync8(dir, { recursive: true });
11812
- const bodyFile = join13(dir, SKILL_BODY_FILE);
12071
+ const bodyFile = join14(dir, SKILL_BODY_FILE);
11813
12072
  if (this.options.skillReceipt) {
11814
12073
  if (!lstatSync8(bodyFile, { throwIfNoEntry: false })) writeFileSync4(bodyFile, skillMarkdown(skill), { encoding: "utf8", flag: "wx", mode: 384 });
11815
12074
  } else writeFileSync4(bodyFile, skillMarkdown(skill), "utf8");
11816
- if (this.options.skillReceipt) verifyMountedSkill(join13(dir, SKILL_BODY_FILE), this.options.skillReceipt);
12075
+ if (this.options.skillReceipt) verifyMountedSkill(join14(dir, SKILL_BODY_FILE), this.options.skillReceipt);
11817
12076
  for (const file of skill.files) {
11818
- const target = resolve10(dir, file.path);
12077
+ const target = resolve11(dir, file.path);
11819
12078
  if (!target.startsWith(`${dir}/`)) continue;
11820
- mkdirSync8(dirname10(target), { recursive: true });
12079
+ mkdirSync8(dirname11(target), { recursive: true });
11821
12080
  writeFileSync4(target, file.content, "utf8");
11822
12081
  }
11823
12082
  }
@@ -11851,14 +12110,14 @@ var RunContext = class {
11851
12110
  denyWrite: [
11852
12111
  // The fixture's refs/objects are writable for push; its configuration
11853
12112
  // and hooks must remain host-owned because fixture verification runs Git.
11854
- ...fixtureOrigin ? [join13(fixtureOrigin, "config"), join13(fixtureOrigin, "hooks")] : [],
11855
- join13(this.worktree, ".git"),
11856
- join13(this.gitDir, "commondir"),
11857
- join13(this.gitDir, "gitdir"),
11858
- join13(this.gitDir, "config.worktree"),
12113
+ ...fixtureOrigin ? [join14(fixtureOrigin, "config"), join14(fixtureOrigin, "hooks")] : [],
12114
+ join14(this.worktree, ".git"),
12115
+ join14(this.gitDir, "commondir"),
12116
+ join14(this.gitDir, "gitdir"),
12117
+ join14(this.gitDir, "config.worktree"),
11859
12118
  // A repository's config and hooks in the shared clone, outside the
11860
12119
  // working directory, are declared read-only here too.
11861
- ...this.options.gitWritePaths?.length ? [join13(this.gitDir, "..", "..", "config"), join13(this.gitDir, "..", "..", "hooks")] : [],
12120
+ ...this.options.gitWritePaths?.length ? [join14(this.gitDir, "..", "..", "config"), join14(this.gitDir, "..", "..", "hooks")] : [],
11862
12121
  ...readOnly ? [this.worktree, ...this.options.gitWritePaths ?? []] : []
11863
12122
  ],
11864
12123
  denyRead: [
@@ -11912,7 +12171,7 @@ var RunContext = class {
11912
12171
  */
11913
12172
  tempEnv() {
11914
12173
  if (this.options.machineEnvironment) return this.options.policyHash ? { MIKKA_POLICY_HASH: this.options.policyHash } : {};
11915
- return { TMPDIR: this.tmpDir, TMPPREFIX: join13(this.tmpDir, "zsh"), ...withGitConfig(this.githubEnv, RUN_GIT_CONFIG), ...this.options.policyHash ? { MIKKA_POLICY_HASH: this.options.policyHash } : {} };
12174
+ return { TMPDIR: this.tmpDir, TMPPREFIX: join14(this.tmpDir, "zsh"), ...withGitConfig(this.githubEnv, RUN_GIT_CONFIG), ...this.options.policyHash ? { MIKKA_POLICY_HASH: this.options.policyHash } : {} };
11916
12175
  }
11917
12176
  /**
11918
12177
  * The agent delivers this run itself: it commits, pushes to the task
@@ -12393,8 +12652,8 @@ var PromptQueue = class {
12393
12652
  continue;
12394
12653
  }
12395
12654
  if (this.closed) return;
12396
- await new Promise((resolve19) => {
12397
- this.waiter = resolve19;
12655
+ await new Promise((resolve20) => {
12656
+ this.waiter = resolve20;
12398
12657
  });
12399
12658
  }
12400
12659
  }
@@ -12408,8 +12667,8 @@ async function untilSpoken(spoken) {
12408
12667
  try {
12409
12668
  return await Promise.race([
12410
12669
  spoken,
12411
- new Promise((resolve19) => {
12412
- timer = setTimeout(() => resolve19(true), CONTINUE_SILENCE_MS);
12670
+ new Promise((resolve20) => {
12671
+ timer = setTimeout(() => resolve20(true), CONTINUE_SILENCE_MS);
12413
12672
  })
12414
12673
  ]);
12415
12674
  } finally {
@@ -12552,15 +12811,15 @@ var ClaudeAdapter = class {
12552
12811
  throw new Error(SUBSCRIPTION_ERROR, { cause: error });
12553
12812
  }
12554
12813
  }
12555
- const nativeHome = options.machineEnvironment ? options.env.HOME : join14(runDir, "native-home");
12814
+ const nativeHome = options.machineEnvironment ? options.env.HOME : join15(runDir, "native-home");
12556
12815
  if (!nativeHome) throw new Error("Cloud machine HOME unavailable");
12557
- const configDir = options.machineEnvironment ? options.env.CLAUDE_CONFIG_DIR ?? join14(nativeHome, ".claude") : join14(nativeHome, ".claude");
12816
+ const configDir = options.machineEnvironment ? options.env.CLAUDE_CONFIG_DIR ?? join15(nativeHome, ".claude") : join15(nativeHome, ".claude");
12558
12817
  if (!options.machineEnvironment) {
12559
12818
  ownDir(nativeHome);
12560
12819
  ownDir(configDir);
12561
12820
  }
12562
12821
  if (!options.machineEnvironment && mode === "continue" && options.continueSession) {
12563
- carryHistory(join14(runPaths(this.options.stateDir, options.continueSession.runId).runDir, "native-home", ".claude"), configDir, ["projects"]);
12822
+ carryHistory(join15(runPaths(this.options.stateDir, options.continueSession.runId).runDir, "native-home", ".claude"), configDir, ["projects"]);
12564
12823
  }
12565
12824
  if (externalAuth && options.credential) throw new Error(SUBSCRIPTION_ERROR);
12566
12825
  const credentialEnv = claudeCredentialEnv(options.credential);
@@ -12595,8 +12854,8 @@ var ClaudeAdapter = class {
12595
12854
  privateDir: paths.privateDir,
12596
12855
  // Its session store, so `resume` works; keyed by the cwd it sees.
12597
12856
  extraWrite: preparing ? [] : [
12598
- join14(configDir, "projects", claudeProjectDirName(options.cwd)),
12599
- join14(
12857
+ join15(configDir, "projects", claudeProjectDirName(options.cwd)),
12858
+ join15(
12600
12859
  configDir,
12601
12860
  "projects",
12602
12861
  claudeProjectDirName(realpathSync10(options.cwd))
@@ -12630,15 +12889,15 @@ var ClaudeAdapter = class {
12630
12889
  let authTimer;
12631
12890
  let stderr = "";
12632
12891
  let stderrArrived = () => void 0;
12633
- const firstStderr = new Promise((resolve19) => {
12634
- stderrArrived = resolve19;
12892
+ const firstStderr = new Promise((resolve20) => {
12893
+ stderrArrived = resolve20;
12635
12894
  });
12636
12895
  const stderrTail = () => stderr.slice(-STDERR_TAIL2).trim() || "no output";
12637
12896
  let spoke = () => void 0;
12638
- const spoken = new Promise((resolve19) => spoke = resolve19);
12897
+ const spoken = new Promise((resolve20) => spoke = resolve20);
12639
12898
  let checkingContinuation = mode === "continue";
12640
12899
  let finished = () => void 0;
12641
- const gone = new Promise((resolve19) => finished = resolve19);
12900
+ const gone = new Promise((resolve20) => finished = resolve20);
12642
12901
  let nativeExit = Promise.resolve(false);
12643
12902
  if (externalAuth && this.options.onHostedSession) {
12644
12903
  try {
@@ -12677,10 +12936,10 @@ var ClaudeAdapter = class {
12677
12936
  stderr = previousStderr.slice(-STDERR_TAIL2 * 4);
12678
12937
  stderrArrived();
12679
12938
  }
12680
- nativeExit = new Promise((resolve19) => {
12681
- child.once("exit", () => resolve19(true));
12682
- child.once("error", () => resolve19(false));
12683
- if (child.exitCode !== null || child.signalCode) resolve19(true);
12939
+ nativeExit = new Promise((resolve20) => {
12940
+ child.once("exit", () => resolve20(true));
12941
+ child.once("error", () => resolve20(false));
12942
+ if (child.exitCode !== null || child.signalCode) resolve20(true);
12684
12943
  });
12685
12944
  child.stderr?.on("data", (data) => {
12686
12945
  stderr = (stderr + data.toString()).slice(-STDERR_TAIL2 * 4);
@@ -12739,7 +12998,7 @@ var ClaudeAdapter = class {
12739
12998
  if (preparation) {
12740
12999
  const { binding, control } = preparation;
12741
13000
  const fixed = claudePrewarmOptionsKey(options);
12742
- const parking = join14(runDir, "claude-parking");
13001
+ const parking = join15(runDir, "claude-parking");
12743
13002
  ownDir(parking);
12744
13003
  let anonymousAdopted = false;
12745
13004
  const prepared = prepareClaudeSession({
@@ -12906,8 +13165,8 @@ var ClaudeAdapter = class {
12906
13165
  if (!message.is_error) quota = void 0;
12907
13166
  if (message.is_error && externalAuth && !stderr) {
12908
13167
  let drainTimer;
12909
- await Promise.race([firstStderr, new Promise((resolve19) => {
12910
- drainTimer = setTimeout(resolve19, 100);
13168
+ await Promise.race([firstStderr, new Promise((resolve20) => {
13169
+ drainTimer = setTimeout(resolve20, 100);
12911
13170
  })]);
12912
13171
  clearTimeout(drainTimer);
12913
13172
  }
@@ -13095,7 +13354,7 @@ function codexFailureMessage(phase, info) {
13095
13354
  }
13096
13355
 
13097
13356
  // src/adapters/codex.ts
13098
- import { delimiter as delimiter3, dirname as dirname11, isAbsolute as isAbsolute5, join as join16, relative as relative4 } from "node:path";
13357
+ import { delimiter as delimiter3, dirname as dirname12, isAbsolute as isAbsolute5, join as join17, relative as relative5 } from "node:path";
13099
13358
  import { mkdirSync as mkdirSync10 } from "node:fs";
13100
13359
 
13101
13360
  // src/codex-generation-telemetry.ts
@@ -13515,11 +13774,11 @@ async function startCodexGenerationCollector(emit) {
13515
13774
  server.requestTimeout = 1e3;
13516
13775
  server.headersTimeout = 1e3;
13517
13776
  server.maxConnections = 4;
13518
- await new Promise((resolve19, reject) => {
13777
+ await new Promise((resolve20, reject) => {
13519
13778
  server.once("error", reject);
13520
13779
  server.listen(0, "127.0.0.1", () => {
13521
13780
  server.off("error", reject);
13522
- resolve19();
13781
+ resolve20();
13523
13782
  });
13524
13783
  });
13525
13784
  server.on("error", () => collector.reject());
@@ -13539,7 +13798,7 @@ async function startCodexGenerationCollector(emit) {
13539
13798
  "-c",
13540
13799
  "otel.log_guardian_assessments=false"
13541
13800
  ],
13542
- close: (cliExitObserved = false) => closed ??= new Promise((resolve19) => {
13801
+ close: (cliExitObserved = false) => closed ??= new Promise((resolve20) => {
13543
13802
  const timer = setTimeout(() => {
13544
13803
  collector.truncate();
13545
13804
  server.closeAllConnections();
@@ -13547,7 +13806,7 @@ async function startCodexGenerationCollector(emit) {
13547
13806
  timer.unref();
13548
13807
  server.close(() => {
13549
13808
  clearTimeout(timer);
13550
- resolve19(collector.finish(cliExitObserved));
13809
+ resolve20(collector.finish(cliExitObserved));
13551
13810
  });
13552
13811
  })
13553
13812
  };
@@ -13590,11 +13849,11 @@ var JsonlWriter = class extends AbstractMessageWriter {
13590
13849
  }
13591
13850
  stream;
13592
13851
  write(message) {
13593
- return new Promise((resolve19, reject) => {
13852
+ return new Promise((resolve20, reject) => {
13594
13853
  this.stream.write(
13595
13854
  `${JSON.stringify(message)}
13596
13855
  `,
13597
- (error) => error ? reject(error) : resolve19()
13856
+ (error) => error ? reject(error) : resolve20()
13598
13857
  );
13599
13858
  });
13600
13859
  }
@@ -13611,7 +13870,7 @@ function jsonlConnection(input, output) {
13611
13870
 
13612
13871
  // src/adapters/codex-mailbox.ts
13613
13872
  import { closeSync as closeSync3, constants as constants4, fstatSync as fstatSync2, lstatSync as lstatSync9, mkdirSync as mkdirSync9, openSync as openSync3, readSync as readSync2 } from "node:fs";
13614
- import { isAbsolute as isAbsolute4, join as join15, relative as relative3, sep as sep2 } from "node:path";
13873
+ import { isAbsolute as isAbsolute4, join as join16, relative as relative4, sep as sep3 } from "node:path";
13615
13874
  import { isDeepStrictEqual } from "node:util";
13616
13875
  var unavailable2 = () => new Error("Run mailbox requires a verified original Codex thread");
13617
13876
  function codexMailboxResumeVersion(userAgent) {
@@ -13628,7 +13887,7 @@ function historyParts(value) {
13628
13887
  return parts;
13629
13888
  }
13630
13889
  function receiptFile(stateDir, runId) {
13631
- return join15(stateDir, "codex-mailbox", assertSafeId("run id", runId) + ".json");
13890
+ return join16(stateDir, "codex-mailbox", assertSafeId("run id", runId) + ".json");
13632
13891
  }
13633
13892
  function readJson2(file, limit, firstLine = false) {
13634
13893
  const fd = openSync3(file, constants4.O_RDONLY | constants4.O_NOFOLLOW | constants4.O_NONBLOCK);
@@ -13648,16 +13907,16 @@ function verifyHistory(home, path3, threadId, catalogue) {
13648
13907
  const parts = historyParts(path3);
13649
13908
  let parent = home;
13650
13909
  for (const part of ["", ...parts.slice(0, -1)]) {
13651
- if (part) parent = join15(parent, part);
13910
+ if (part) parent = join16(parent, part);
13652
13911
  const stat3 = lstatSync9(parent);
13653
13912
  if (!stat3.isDirectory() || stat3.isSymbolicLink()) throw unavailable2();
13654
13913
  }
13655
- const header = readJson2(join15(home, ...parts), 1024 * 1024, true);
13914
+ const header = readJson2(join16(home, ...parts), 1024 * 1024, true);
13656
13915
  if (header?.type !== "session_meta" || header.payload?.id !== threadId || !isDeepStrictEqual(header.payload.dynamic_tools, catalogue)) throw unavailable2();
13657
13916
  }
13658
13917
  function verifyCodexMailboxResume(stateDir, sourceRunId, home, threadId, catalogue) {
13659
13918
  try {
13660
- const dir = lstatSync9(join15(stateDir, "codex-mailbox"));
13919
+ const dir = lstatSync9(join16(stateDir, "codex-mailbox"));
13661
13920
  if (!dir.isDirectory() || dir.isSymbolicLink()) throw unavailable2();
13662
13921
  const receipt = readJson2(receiptFile(stateDir, sourceRunId), 256 * 1024);
13663
13922
  if (receipt?.version !== 1 || receipt.nativeVersion !== "0.163.0" && receipt.nativeVersion !== "0.166.0" && receipt.nativeVersion !== "0.167.0" || receipt.runId !== sourceRunId || receipt.threadId !== threadId || !isDeepStrictEqual(receipt.catalogue, catalogue) || typeof receipt.historyPath !== "string") throw unavailable2();
@@ -13670,10 +13929,10 @@ function verifyCodexMailboxResume(stateDir, sourceRunId, home, threadId, catalog
13670
13929
  function recordCodexMailboxSession(stateDir, runId, home, thread, catalogue, resumed, nativeVersion) {
13671
13930
  try {
13672
13931
  if (!thread.id || typeof thread.path !== "string" || !isAbsolute4(thread.path)) throw unavailable2();
13673
- const historyPath = relative3(home, thread.path).split(sep2).join("/");
13932
+ const historyPath = relative4(home, thread.path).split(sep3).join("/");
13674
13933
  historyParts(historyPath);
13675
13934
  if (resumed) verifyHistory(home, historyPath, thread.id, catalogue);
13676
- const dir = join15(stateDir, "codex-mailbox");
13935
+ const dir = join16(stateDir, "codex-mailbox");
13677
13936
  mkdirSync9(dir, { recursive: true, mode: 448 });
13678
13937
  const stat3 = lstatSync9(dir);
13679
13938
  if (!stat3.isDirectory() || stat3.isSymbolicLink()) throw unavailable2();
@@ -13847,7 +14106,7 @@ function codexItemChunks(phase, item, streamed, worktree) {
13847
14106
  type: "data-file-change",
13848
14107
  data: {
13849
14108
  // Codex reports absolute paths; runs report worktree-relative ones.
13850
- path: isAbsolute5(c.path) ? relative4(worktree, c.path) : c.path,
14109
+ path: isAbsolute5(c.path) ? relative5(worktree, c.path) : c.path,
13851
14110
  change: c.kind.type === "add" ? "added" : c.kind.type === "delete" ? "deleted" : "modified"
13852
14111
  }
13853
14112
  }))
@@ -13937,8 +14196,8 @@ var CodexAdapter = class {
13937
14196
  options.continueSession.runId
13938
14197
  ).runDir;
13939
14198
  carryHistory(
13940
- join16(earlier2, "codex-home"),
13941
- join16(runDir, "codex-home"),
14199
+ join17(earlier2, "codex-home"),
14200
+ join17(runDir, "codex-home"),
13942
14201
  CODEX_HISTORY
13943
14202
  );
13944
14203
  } catch (error) {
@@ -13949,7 +14208,7 @@ var CodexAdapter = class {
13949
14208
  log.info({ err: error }, "could not copy the earlier codex threads");
13950
14209
  }
13951
14210
  }
13952
- const codexHome = options.machineEnvironment ? { home: options.env.CODEX_HOME ?? join16(options.env.HOME, ".codex") } : prepareCodexHome(join16(runDir, "codex-home"), log);
14211
+ const codexHome = options.machineEnvironment ? { home: options.env.CODEX_HOME ?? join17(options.env.HOME, ".codex") } : prepareCodexHome(join17(runDir, "codex-home"), log);
13953
14212
  if (options.machineEnvironment) mkdirSync10(codexHome.home, { recursive: true, mode: 448 });
13954
14213
  const mailboxResumeVersion = mailboxCatalogue && threadId ? verifyCodexMailboxResume(
13955
14214
  this.options.stateDir,
@@ -13960,7 +14219,7 @@ var CodexAdapter = class {
13960
14219
  ) : null;
13961
14220
  const computerMcp = this.options.computerMcp ?? this.options.computerProvider?.(options.runId, options.policy);
13962
14221
  const binary = this.options.binary ?? await this.options.ensureBinary?.() ?? "codex";
13963
- const childPath = isAbsolute5(binary) ? dirname11(binary) + delimiter3 + (options.env.PATH ?? "") : options.env.PATH;
14222
+ const childPath = isAbsolute5(binary) ? dirname12(binary) + delimiter3 + (options.env.PATH ?? "") : options.env.PATH;
13964
14223
  if (externalAuth && options.credential) throw new Error(SUBSCRIPTION_AUTH_ERROR);
13965
14224
  const credential = codexCredential(brokerAuth ? { kind: "provider", protocol: "openai", baseUrl: "https://mikka.invalid", key: NATIVE_AUTH_PLACEHOLDER } : options.credential);
13966
14225
  const providerDomain = credentialDomain(options.credential);
@@ -14593,7 +14852,7 @@ var CodexAdapter = class {
14593
14852
  // src/adapters/cursor.ts
14594
14853
  import { Readable, Writable } from "node:stream";
14595
14854
  import * as acp from "@agentclientprotocol/sdk";
14596
- import { join as join17 } from "node:path";
14855
+ import { join as join18 } from "node:path";
14597
14856
  function cursorAppServers(apps) {
14598
14857
  return [
14599
14858
  ...(apps?.apps ?? []).map((app) => ({ type: "http", name: app.name, url: app.url, headers: [{ name: "Authorization", value: `Bearer ${apps.token}` }] })),
@@ -14725,15 +14984,15 @@ var CursorAdapter = class {
14725
14984
  options.continueSession.runId
14726
14985
  ).runDir;
14727
14986
  carryHistory(
14728
- join17(earlier2, "cursor-home"),
14729
- join17(paths.runDir, "cursor-home"),
14987
+ join18(earlier2, "cursor-home"),
14988
+ join18(paths.runDir, "cursor-home"),
14730
14989
  CURSOR_HISTORY
14731
14990
  );
14732
14991
  } catch (error) {
14733
14992
  log.info({ err: error }, "could not copy the earlier cursor chats");
14734
14993
  }
14735
14994
  }
14736
- const configDir = prepareCursorHome(join17(paths.runDir, "cursor-home"));
14995
+ const configDir = prepareCursorHome(join18(paths.runDir, "cursor-home"));
14737
14996
  const ctx = new RunContext({
14738
14997
  github: options.github,
14739
14998
  githubEnvironment: options.githubEnvironment,
@@ -14968,7 +15227,7 @@ ${firstMessage}` : firstMessage
14968
15227
  // src/adapters/mock.ts
14969
15228
  import { randomUUID as randomUUID3 } from "node:crypto";
14970
15229
  import { mkdirSync as mkdirSync11, readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "node:fs";
14971
- import { dirname as dirname12, join as join18, resolve as resolve11 } from "node:path";
15230
+ import { dirname as dirname13, join as join19, resolve as resolve12 } from "node:path";
14972
15231
  import { setTimeout as sleep2 } from "node:timers/promises";
14973
15232
  import { execa as execa5 } from "execa";
14974
15233
 
@@ -15000,7 +15259,7 @@ function isRunChunk(value) {
15000
15259
  }
15001
15260
 
15002
15261
  // src/adapters/mock.ts
15003
- var DEFAULT_FIXTURES_DIR = resolve11(
15262
+ var DEFAULT_FIXTURES_DIR = resolve12(
15004
15263
  import.meta.dirname,
15005
15264
  true ? "./fixtures" : "../../fixtures"
15006
15265
  );
@@ -15034,7 +15293,7 @@ var MockAdapter = class {
15034
15293
  fixturesDir;
15035
15294
  speed;
15036
15295
  stateFile(sessionId) {
15037
- return join18(
15296
+ return join19(
15038
15297
  this.options.stateDir,
15039
15298
  `mock-${assertSafeId("session id", sessionId)}.json`
15040
15299
  );
@@ -15078,7 +15337,7 @@ var MockAdapter = class {
15078
15337
  open(sessionId, state2, options) {
15079
15338
  const name = assertSafeId("fixture", state2.fixture.replace(/\.jsonl$/, ""));
15080
15339
  const lines = parseFixture(
15081
- readFileSync9(join18(this.fixturesDir, `${name}.jsonl`), "utf8"),
15340
+ readFileSync9(join19(this.fixturesDir, `${name}.jsonl`), "utf8"),
15082
15341
  name
15083
15342
  );
15084
15343
  const abort = new AbortController();
@@ -15116,7 +15375,7 @@ var MockAdapter = class {
15116
15375
  if (line.hang) {
15117
15376
  if (!abort.signal.aborted) {
15118
15377
  await new Promise(
15119
- (resolve19) => abort.signal.addEventListener("abort", resolve19, { once: true })
15378
+ (resolve20) => abort.signal.addEventListener("abort", resolve20, { once: true })
15120
15379
  );
15121
15380
  }
15122
15381
  yield { type: "exit", outcome: "cancelled" };
@@ -15128,8 +15387,8 @@ var MockAdapter = class {
15128
15387
  `mock fixture writes outside the worktree: ${line.write.path}`
15129
15388
  );
15130
15389
  }
15131
- const target = resolve11(options.cwd, line.write.path);
15132
- mkdirSync11(dirname12(target), { recursive: true });
15390
+ const target = resolve12(options.cwd, line.write.path);
15391
+ mkdirSync11(dirname13(target), { recursive: true });
15133
15392
  writeFileSync5(target, line.write.content);
15134
15393
  }
15135
15394
  if (line.chunk) yield { type: "chunk", chunk: line.chunk };
@@ -15192,13 +15451,13 @@ var MockAdapter = class {
15192
15451
 
15193
15452
  // src/agents/local-github.ts
15194
15453
  import { mkdirSync as mkdirSync13, mkdtempSync as mkdtempSync4, rmSync as rmSync10, writeFileSync as writeFileSync7 } from "node:fs";
15195
- import { homedir as homedir5 } from "node:os";
15196
- import { delimiter as delimiter4, join as join20 } from "node:path";
15454
+ import { homedir as homedir6 } from "node:os";
15455
+ import { delimiter as delimiter4, join as join21 } from "node:path";
15197
15456
 
15198
15457
  // src/agents/machine-github.ts
15199
15458
  import { existsSync as existsSync4, mkdirSync as mkdirSync12, readFileSync as readFileSync10, renameSync as renameSync3, rmSync as rmSync9, writeFileSync as writeFileSync6 } from "node:fs";
15200
15459
  import { randomUUID as randomUUID4 } from "node:crypto";
15201
- import { dirname as dirname13, join as join19 } from "node:path";
15460
+ import { dirname as dirname14, join as join20 } from "node:path";
15202
15461
  function githubHosts(contents, token) {
15203
15462
  if (!token || /[\r\n\0]/.test(token) || token.length > 32768) throw Error("github_credential_invalid");
15204
15463
  const lines = contents.split(/\r?\n/);
@@ -15223,8 +15482,8 @@ function prepareMachineGitHub(github, host) {
15223
15482
  if (!github.token) throw Error("github_credential_missing");
15224
15483
  const home = host.env.HOME;
15225
15484
  if (!home) throw Error("github_home_missing");
15226
- const directory = host.env.GH_CONFIG_DIR ?? join19(host.env.XDG_CONFIG_HOME ?? join19(home, ".config"), "gh");
15227
- const file = join19(directory, "hosts.yml");
15485
+ const directory = host.env.GH_CONFIG_DIR ?? join20(host.env.XDG_CONFIG_HOME ?? join20(home, ".config"), "gh");
15486
+ const file = join20(directory, "hosts.yml");
15228
15487
  const original = existsSync4(file) ? readFileSync10(file, "utf8") : void 0;
15229
15488
  let written;
15230
15489
  let closed = false;
@@ -15238,7 +15497,7 @@ function prepareMachineGitHub(github, host) {
15238
15497
  host.onCredential?.("GITHUB_TOKEN", credential.token);
15239
15498
  const latest = existsSync4(file) ? readFileSync10(file, "utf8") : "";
15240
15499
  const next = githubHosts(latest, credential.token);
15241
- mkdirSync12(dirname13(file), { recursive: true, mode: 448 });
15500
+ mkdirSync12(dirname14(file), { recursive: true, mode: 448 });
15242
15501
  const temporary = `${file}.${randomUUID4()}`;
15243
15502
  writeFileSync6(temporary, next, { mode: 384, flag: "wx" });
15244
15503
  renameSync3(temporary, file);
@@ -15324,19 +15583,19 @@ async function prepareLocalGitHub(assignment, host) {
15324
15583
  const credential = assignment.github.token ? { token: assignment.github.token, expiresAt: assignment.github.expiresAt ?? null } : await lease();
15325
15584
  if (host.signal.aborted) throw Error("github_run_closed");
15326
15585
  mkdirSync13(host.stateDir, { recursive: true, mode: 448 });
15327
- const directory = mkdtempSync4(join20(host.stateDir, "github-"));
15586
+ const directory = mkdtempSync4(join21(host.stateDir, "github-"));
15328
15587
  try {
15329
- const bin = join20(directory, "bin");
15588
+ const bin = join21(directory, "bin");
15330
15589
  const quote2 = (value) => `'${value.replaceAll("'", "'\\''")}'`;
15331
15590
  const helper2 = `${process.versions.electron ? "env ELECTRON_RUN_AS_NODE=1 " : ""}${quote2(process.execPath)} ${quote2(GITHUB_CREDENTIAL_SCRIPT)}`;
15332
15591
  if (binary) {
15333
15592
  mkdirSync13(bin, { mode: 448 });
15334
- writeFileSync7(join20(bin, "gh"), `#!/bin/sh
15593
+ writeFileSync7(join21(bin, "gh"), `#!/bin/sh
15335
15594
  exec ${helper2} native-gh ${quote2(binary)} ${quote2(directory)} "$@"
15336
15595
  `, { mode: 448, flag: "wx" });
15337
15596
  }
15338
15597
  const prepared = prepareMachineGitHub({ ...assignment.github, ...credential, issueId: assignment.issueId }, {
15339
- env: { HOME: homedir5(), GH_CONFIG_DIR: directory },
15598
+ env: { HOME: homedir6(), GH_CONFIG_DIR: directory },
15340
15599
  signal: host.signal,
15341
15600
  refresh: () => runRuntimeTimings.backgroundCredentialRefresh(assignment.runId, lease),
15342
15601
  onCredential: host.onCredential,
@@ -15372,17 +15631,17 @@ exec ${helper2} native-gh ${quote2(binary)} ${quote2(directory)} "$@"
15372
15631
 
15373
15632
  // src/agents/verify.ts
15374
15633
  import { existsSync as existsSync5, mkdirSync as mkdirSync14, mkdtempSync as mkdtempSync5, realpathSync as realpathSync11, rmSync as rmSync11 } from "node:fs";
15375
- import { join as join21 } from "node:path";
15634
+ import { join as join22 } from "node:path";
15376
15635
  var OUTPUT_TAIL = 4e3;
15377
15636
  var SETUP_ATTEMPTS = 3;
15378
15637
  async function runVerify(sandbox, options) {
15379
15638
  options.signal?.throwIfAborted();
15380
15639
  mkdirSync14(options.tmpRoot, { recursive: true, mode: 448 });
15381
- const tmpDir = mkdtempSync5(join21(realpathSync11(options.tmpRoot), "verify-"));
15640
+ const tmpDir = mkdtempSync5(join22(realpathSync11(options.tmpRoot), "verify-"));
15382
15641
  const deadline = Date.now() + options.timeoutMs;
15383
15642
  try {
15384
15643
  for (let attempt = 1; ; attempt++) {
15385
- const started = join21(tmpDir, `.started-${attempt}`);
15644
+ const started = join22(tmpDir, `.started-${attempt}`);
15386
15645
  const result = await attemptVerify(sandbox, options, tmpDir, started, deadline - Date.now());
15387
15646
  if (result.exitCode === 0 || result.timedOut || options.signal?.aborted || existsSync5(started) || attempt >= SETUP_ATTEMPTS)
15388
15647
  return result;
@@ -15401,7 +15660,7 @@ async function attemptVerify(sandbox, options, tmpDir, started, timeoutMs) {
15401
15660
  policy: {
15402
15661
  allowWrite: options.readOnly ? [tmpDir] : [options.worktree, tmpDir],
15403
15662
  denyWrite: [
15404
- join21(options.worktree, ".git"),
15663
+ join22(options.worktree, ".git"),
15405
15664
  ...options.readOnly ? [options.worktree] : []
15406
15665
  ],
15407
15666
  denyRead: [
@@ -15472,7 +15731,7 @@ var NoSandbox = class {
15472
15731
 
15473
15732
  // src/fs-browse.ts
15474
15733
  import { execFile as execFile4 } from "node:child_process";
15475
- import { readdir as readdir2, realpath, stat as stat2 } from "node:fs/promises";
15734
+ import { readdir as readdir3, realpath, stat as stat2 } from "node:fs/promises";
15476
15735
  import { promisify as promisify4 } from "node:util";
15477
15736
  var run = promisify4(execFile4);
15478
15737
  async function git(cwd, args) {
@@ -15499,7 +15758,7 @@ async function verifyExpectedOrigin(path3, expected2) {
15499
15758
  }
15500
15759
 
15501
15760
  // src/device-type.ts
15502
- import { readdir as readdir3, readFile as readFile3 } from "node:fs/promises";
15761
+ import { readdir as readdir4, readFile as readFile4 } from "node:fs/promises";
15503
15762
  import { execa as execa6 } from "execa";
15504
15763
  async function detectDeviceType() {
15505
15764
  try {
@@ -15512,10 +15771,10 @@ async function detectDeviceType() {
15512
15771
  return /MacBook/i.test(stdout) ? "laptop" : "server";
15513
15772
  }
15514
15773
  if (process.platform === "linux") {
15515
- const entries = await readdir3("/sys/class/power_supply");
15774
+ const entries = await readdir4("/sys/class/power_supply");
15516
15775
  const types = await Promise.all(
15517
15776
  entries.map(
15518
- (entry) => readFile3(`/sys/class/power_supply/${entry}/type`, "utf8").catch(
15777
+ (entry) => readFile4(`/sys/class/power_supply/${entry}/type`, "utf8").catch(
15519
15778
  () => ""
15520
15779
  )
15521
15780
  )
@@ -15533,10 +15792,10 @@ import { arch as arch2, platform as platform2 } from "node:os";
15533
15792
  import { execa as execa7 } from "execa";
15534
15793
 
15535
15794
  // harness/install.mjs
15536
- import { createHash as createHash8, randomBytes as randomBytes2 } from "node:crypto";
15795
+ import { createHash as createHash9, randomBytes as randomBytes2 } from "node:crypto";
15537
15796
  import { execFile as execFile5 } from "node:child_process";
15538
15797
  import { createWriteStream as createWriteStream2, existsSync as existsSync6, mkdirSync as mkdirSync15, readdirSync as readdirSync5, readFileSync as readFileSync11, renameSync as renameSync4, rmSync as rmSync12, statSync as statSync2, symlinkSync, writeFileSync as writeFileSync8 } from "node:fs";
15539
- import { dirname as dirname14, join as join22, relative as relative5 } from "node:path";
15798
+ import { dirname as dirname15, join as join23, relative as relative6 } from "node:path";
15540
15799
  import { Readable as Readable2, Transform } from "node:stream";
15541
15800
  import { pipeline as pipeline2 } from "node:stream/promises";
15542
15801
  import { promisify as promisify5 } from "node:util";
@@ -15585,17 +15844,17 @@ function resolvePin(store, harness) {
15585
15844
  return { pin, artifact: pin.platforms[store.platform ?? platformKey()] };
15586
15845
  }
15587
15846
  function versionDir(store, harness) {
15588
- return join22(store.root, harness, resolvePin(store, harness).pin.version);
15847
+ return join23(store.root, harness, resolvePin(store, harness).pin.version);
15589
15848
  }
15590
15849
  function harnessBinaryPath(store, harness) {
15591
- return join22(versionDir(store, harness), "bin", resolvePin(store, harness).pin.command);
15850
+ return join23(versionDir(store, harness), "bin", resolvePin(store, harness).pin.command);
15592
15851
  }
15593
15852
  function harnessInstallState(store, harness) {
15594
15853
  const { pin, artifact } = resolvePin(store, harness);
15595
15854
  if (!artifact) return { state: "unsupported", version: pin.version };
15596
15855
  let installed = false;
15597
15856
  try {
15598
- installed = readFileSync11(join22(versionDir(store, harness), MARKER), "utf8") === installMarker(pin, artifact) && runtimeFiles(store, harness).every((path3) => {
15857
+ installed = readFileSync11(join23(versionDir(store, harness), MARKER), "utf8") === installMarker(pin, artifact) && runtimeFiles(store, harness).every((path3) => {
15599
15858
  const stat3 = statSync2(path3);
15600
15859
  return stat3.isFile() && (stat3.mode & 73) !== 0;
15601
15860
  });
@@ -15605,7 +15864,7 @@ function harnessInstallState(store, harness) {
15605
15864
  }
15606
15865
  function runtimeFiles(store, harness) {
15607
15866
  const binary = harnessBinaryPath(store, harness);
15608
- return harness === "codex" ? [binary, join22(dirname14(binary), "codex-code-mode-host")] : [binary];
15867
+ return harness === "codex" ? [binary, join23(dirname15(binary), "codex-code-mode-host")] : [binary];
15609
15868
  }
15610
15869
  function ensureHarness(store, harness) {
15611
15870
  const key2 = `${store.root}\0${harness}`;
@@ -15622,27 +15881,27 @@ async function install(store, harness) {
15622
15881
  if (state2 === "unsupported") throw new Error(`${harness} has no build for ${store.platform ?? platformKey()}`);
15623
15882
  if (state2 === "installed") return binary;
15624
15883
  const { pin, artifact } = resolvePin(store, harness);
15625
- const parent = join22(store.root, harness);
15884
+ const parent = join23(store.root, harness);
15626
15885
  mkdirSync15(parent, { recursive: true, mode: 448 });
15627
- const staging = join22(parent, `.staging-${randomBytes2(6).toString("hex")}`);
15886
+ const staging = join23(parent, `.staging-${randomBytes2(6).toString("hex")}`);
15628
15887
  mkdirSync15(staging, { recursive: true, mode: 448 });
15629
15888
  try {
15630
- const tarball = join22(staging, "package.tgz");
15889
+ const tarball = join23(staging, "package.tgz");
15631
15890
  await download(`${(store.pins ?? HARNESS_PINS).registry.replace(/\/$/, "")}/${artifact.tarball}`, tarball, artifact.integrity);
15632
15891
  await run2("tar", ["-xzf", tarball, "-C", staging]);
15633
15892
  if (harness === "codex") {
15634
15893
  if (!artifact.entry.endsWith("/bin/codex")) throw new Error("Invalid Codex bundle entry");
15635
- const bundle = dirname14(dirname14(artifact.entry));
15636
- for (const name of readdirSync5(join22(staging, bundle))) symlinkSync(relative5(staging, join22(staging, bundle, name)), join22(staging, name));
15894
+ const bundle = dirname15(dirname15(artifact.entry));
15895
+ for (const name of readdirSync5(join23(staging, bundle))) symlinkSync(relative6(staging, join23(staging, bundle, name)), join23(staging, name));
15637
15896
  for (const name of ["codex", "codex-code-mode-host"]) {
15638
- const stat3 = statSync2(join22(staging, "bin", name));
15897
+ const stat3 = statSync2(join23(staging, "bin", name));
15639
15898
  if (!stat3.isFile() || (stat3.mode & 73) === 0) throw new Error("Incomplete Codex runtime bundle");
15640
15899
  }
15641
15900
  } else {
15642
- mkdirSync15(join22(staging, "bin"), { mode: 448 });
15643
- symlinkSync(relative5(join22(staging, "bin"), join22(staging, artifact.entry)), join22(staging, "bin", pin.command));
15901
+ mkdirSync15(join23(staging, "bin"), { mode: 448 });
15902
+ symlinkSync(relative6(join23(staging, "bin"), join23(staging, artifact.entry)), join23(staging, "bin", pin.command));
15644
15903
  }
15645
- writeFileSync8(join22(staging, MARKER), installMarker(pin, artifact), { mode: 384 });
15904
+ writeFileSync8(join23(staging, MARKER), installMarker(pin, artifact), { mode: 384 });
15646
15905
  const target = versionDir(store, harness);
15647
15906
  const retained = existsSync6(target) ? `${target}.retained-${randomBytes2(6).toString("hex")}` : null;
15648
15907
  if (retained) renameSync4(target, retained);
@@ -15663,7 +15922,7 @@ async function download(url, file, integrity) {
15663
15922
  if (algorithm !== "sha512" || !expected2) throw new Error("Unsupported harness integrity");
15664
15923
  const response = await fetch(url, { redirect: "follow" });
15665
15924
  if (!response.ok || !response.body) throw new Error(`Harness download failed (${response.status})`);
15666
- const hash2 = createHash8("sha512");
15925
+ const hash2 = createHash9("sha512");
15667
15926
  const tap = new Transform({ transform(chunk, _encoding, done) {
15668
15927
  hash2.update(chunk);
15669
15928
  done(null, chunk);
@@ -15724,7 +15983,7 @@ function harnessFingerprint(store) {
15724
15983
  // src/model-probe.ts
15725
15984
  import { spawn as spawn3 } from "node:child_process";
15726
15985
  import { mkdtempSync as mkdtempSync6, readdirSync as readdirSync6, rmSync as rmSync13 } from "node:fs";
15727
- import { join as join23 } from "node:path";
15986
+ import { join as join24 } from "node:path";
15728
15987
 
15729
15988
  // src/process-group.ts
15730
15989
  async function stopGroup(child, graceMs = 3e3) {
@@ -15744,12 +16003,12 @@ async function stopGroup(child, graceMs = 3e3) {
15744
16003
  };
15745
16004
  if (child.exitCode === null && child.signalCode === null) {
15746
16005
  signal("SIGTERM");
15747
- await new Promise((resolve19) => {
15748
- if (child.exitCode !== null || child.signalCode !== null) return resolve19();
16006
+ await new Promise((resolve20) => {
16007
+ if (child.exitCode !== null || child.signalCode !== null) return resolve20();
15749
16008
  const done = () => {
15750
16009
  clearTimeout(timer);
15751
16010
  child.off("exit", done);
15752
- resolve19();
16011
+ resolve20();
15753
16012
  };
15754
16013
  const timer = setTimeout(done, graceMs);
15755
16014
  child.once("exit", done);
@@ -15804,10 +16063,10 @@ function sweepModelProbeHomes(scratchDir) {
15804
16063
  } catch {
15805
16064
  return;
15806
16065
  }
15807
- for (const name of names) if (name.startsWith(HOME_PREFIX)) rmSync13(join23(scratchDir, name), { recursive: true, force: true });
16066
+ for (const name of names) if (name.startsWith(HOME_PREFIX)) rmSync13(join24(scratchDir, name), { recursive: true, force: true });
15808
16067
  }
15809
16068
  async function probeHarnessModels(harness, binary, options) {
15810
- const home = mkdtempSync6(join23(options.scratchDir, HOME_PREFIX));
16069
+ const home = mkdtempSync6(join24(options.scratchDir, HOME_PREFIX));
15811
16070
  try {
15812
16071
  return await exchange(harness, binary, home, options);
15813
16072
  } finally {
@@ -15816,15 +16075,15 @@ async function probeHarnessModels(harness, binary, options) {
15816
16075
  }
15817
16076
  function exchange(harness, binary, home, options) {
15818
16077
  const args = harness === "codex" ? ["app-server"] : ["-p", "--input-format", "stream-json", "--output-format", "stream-json", "--verbose"];
15819
- const env = { PATH: process.env.PATH ?? "", HOME: home, CODEX_HOME: home, CLAUDE_CONFIG_DIR: join23(home, ".claude"), LANG: process.env.LANG ?? "C.UTF-8" };
15820
- return new Promise((resolve19) => {
16078
+ const env = { PATH: process.env.PATH ?? "", HOME: home, CODEX_HOME: home, CLAUDE_CONFIG_DIR: join24(home, ".claude"), LANG: process.env.LANG ?? "C.UTF-8" };
16079
+ return new Promise((resolve20) => {
15821
16080
  const child = (options.spawnImpl ?? spawn3)(binary, args, { env, cwd: home, detached: process.platform !== "win32", stdio: ["pipe", "pipe", "ignore"] });
15822
16081
  let result;
15823
16082
  let stopping;
15824
16083
  const stop = () => stopping ??= Promise.resolve().then(() => stopGroup(child, 0));
15825
16084
  const done = () => {
15826
16085
  clearTimeout(timer);
15827
- resolve19(result ?? null);
16086
+ resolve20(result ?? null);
15828
16087
  };
15829
16088
  const finish = (value) => {
15830
16089
  if (result !== void 0) return;
@@ -15886,14 +16145,14 @@ function exchange(harness, binary, home, options) {
15886
16145
  }
15887
16146
 
15888
16147
  // src/cloud-registration.ts
15889
- import { createHash as createHash9 } from "node:crypto";
15890
- import { join as join24 } from "node:path";
16148
+ import { createHash as createHash10 } from "node:crypto";
16149
+ import { join as join25 } from "node:path";
15891
16150
  function writeCloudRegistration(dataDir, deviceId, workspaceId, credential) {
15892
- writeJsonAtomic(join24(dataDir, "registration.json"), {
16151
+ writeJsonAtomic(join25(dataDir, "registration.json"), {
15893
16152
  version: 1,
15894
16153
  deviceId,
15895
16154
  workspaceId,
15896
- tokenSha256: createHash9("sha256").update(credential).digest("hex")
16155
+ tokenSha256: createHash10("sha256").update(credential).digest("hex")
15897
16156
  });
15898
16157
  }
15899
16158
 
@@ -15903,16 +16162,16 @@ import { mkdtempSync as mkdtempSync7, rmSync as rmSync14, statSync as statSync3
15903
16162
  // src/hosted-binaries.ts
15904
16163
  import { accessSync as accessSync2, constants as constants5, lstatSync as lstatSync10, readFileSync as readFileSync12, realpathSync as realpathSync12 } from "node:fs";
15905
16164
  import { delimiter as delimiter5, isAbsolute as isAbsolute6 } from "node:path";
15906
- import { z as z37 } from "zod";
16165
+ import { z as z38 } from "zod";
15907
16166
  var HOSTED_CLI_MANIFEST = "/opt/mikka/worker/.mikka-original-cli.json";
15908
16167
  var LEGACY_HOSTED_CLI_MANIFEST = "/opt/mikka/original-cli.json";
15909
16168
  var MANIFEST_PATHS = [HOSTED_CLI_MANIFEST, LEGACY_HOSTED_CLI_MANIFEST];
15910
- var binarySchema = z37.object({ path: z37.string().min(1), sha256: z37.string().regex(/^[a-f0-9]{64}$/) }).strict();
15911
- var manifestSchema = z37.object({
15912
- version: z37.literal(1),
15913
- kind: z37.enum(["claude", "codex", "desktop", "task"]),
15914
- original: z37.object({ claude_code: binarySchema.nullable(), codex: binarySchema.nullable() }).strict(),
15915
- added: z37.object({ claude_code: binarySchema.optional(), codex: binarySchema.optional() }).strict()
16169
+ var binarySchema = z38.object({ path: z38.string().min(1), sha256: z38.string().regex(/^[a-f0-9]{64}$/) }).strict();
16170
+ var manifestSchema = z38.object({
16171
+ version: z38.literal(1),
16172
+ kind: z38.enum(["claude", "codex", "desktop", "task"]),
16173
+ original: z38.object({ claude_code: binarySchema.nullable(), codex: binarySchema.nullable() }).strict(),
16174
+ added: z38.object({ claude_code: binarySchema.optional(), codex: binarySchema.optional() }).strict()
15916
16175
  }).strict();
15917
16176
  function readHostedCliManifest(paths = MANIFEST_PATHS) {
15918
16177
  for (const path3 of typeof paths === "string" ? [paths] : paths) {
@@ -16096,10 +16355,10 @@ async function prepareSubscriptionCredentials(assignment, host) {
16096
16355
 
16097
16356
  // src/run-scratch.ts
16098
16357
  import { rmSync as rmSync15 } from "node:fs";
16099
- import { join as join25 } from "node:path";
16358
+ import { join as join26 } from "node:path";
16100
16359
  function removeRunCredentials(stateDir, runId) {
16101
16360
  const { runDir } = runPaths(stateDir, runId);
16102
- for (const path3 of RUN_CREDENTIAL_PATHS) rmSync15(join25(runDir, path3), { recursive: true, force: true });
16361
+ for (const path3 of RUN_CREDENTIAL_PATHS) rmSync15(join26(runDir, path3), { recursive: true, force: true });
16103
16362
  }
16104
16363
 
16105
16364
  // src/subscription-local-runner.ts
@@ -16198,7 +16457,7 @@ function createLocalSubscriptionRunner(host) {
16198
16457
 
16199
16458
  // src/subscription-preflight.ts
16200
16459
  import { mkdtempSync as mkdtempSync8, rmSync as rmSync16 } from "node:fs";
16201
- import { join as join26 } from "node:path";
16460
+ import { join as join27 } from "node:path";
16202
16461
  import { execa as execa8 } from "execa";
16203
16462
  var refused = (detail, cause) => ({
16204
16463
  ready: false,
@@ -16217,7 +16476,7 @@ async function preflightLocalSubscription(harness, options) {
16217
16476
  const expected2 = (options.store.pins ?? HARNESS_PINS).harnesses[harness].version;
16218
16477
  let home;
16219
16478
  try {
16220
- home = mkdtempSync8(join26(options.scratchDir, "subscription-preflight-"));
16479
+ home = mkdtempSync8(join27(options.scratchDir, "subscription-preflight-"));
16221
16480
  const result = await execa8(binary, ["--version"], {
16222
16481
  env: { ...env, HOME: home },
16223
16482
  extendEnv: false,
@@ -16281,8 +16540,8 @@ async function acquireCloudWorkspaceControl(input, root = CLOUD_WORKSPACE_CONTRO
16281
16540
  });
16282
16541
  let acquired = false, releasing = false, settled = false, output = "";
16283
16542
  let finished;
16284
- const done = new Promise((resolve19) => {
16285
- finished = resolve19;
16543
+ const done = new Promise((resolve20) => {
16544
+ finished = resolve20;
16286
16545
  });
16287
16546
  child.stdin.on("error", () => {
16288
16547
  if (!settled && !releasing) child.kill("SIGTERM");
@@ -16295,7 +16554,7 @@ async function acquireCloudWorkspaceControl(input, root = CLOUD_WORKSPACE_CONTRO
16295
16554
  if (!acquired || settled || releasing || !child.stdin.writable) throw new CodedError("terminal_control_unavailable", { detail: "fence_lost" });
16296
16555
  child.stdin.write(JSON.stringify(value) + "\n");
16297
16556
  };
16298
- await new Promise((resolve19, reject) => {
16557
+ await new Promise((resolve20, reject) => {
16299
16558
  const fail = (cause) => reject(new CodedError("terminal_control_unavailable", { detail: "fence_unavailable", cause }));
16300
16559
  child.once("error", fail);
16301
16560
  child.stdout.on("data", (data) => {
@@ -16310,7 +16569,7 @@ async function acquireCloudWorkspaceControl(input, root = CLOUD_WORKSPACE_CONTRO
16310
16569
  fail(input.signal.reason);
16311
16570
  return;
16312
16571
  }
16313
- resolve19();
16572
+ resolve20();
16314
16573
  } else if (output.length > 32) {
16315
16574
  child.kill("SIGTERM");
16316
16575
  fail();
@@ -16350,7 +16609,7 @@ import {
16350
16609
  rmSync as rmSync17,
16351
16610
  truncateSync
16352
16611
  } from "node:fs";
16353
- import { join as join27 } from "node:path";
16612
+ import { join as join28 } from "node:path";
16354
16613
  var RETRY_MAX_MS = 3e4;
16355
16614
  var Outbox = class {
16356
16615
  constructor(dir, link, log, retryMs = 1e3, onUndeliverable = () => void 0, retainResources = false, traceContext = () => void 0) {
@@ -16378,10 +16637,10 @@ var Outbox = class {
16378
16637
  /** Runs whose file was checked for a torn tail since this process started. */
16379
16638
  repaired = /* @__PURE__ */ new Set();
16380
16639
  file(runId) {
16381
- return join27(this.dir, `${assertSafeId("run id", runId)}.jsonl`);
16640
+ return join28(this.dir, `${assertSafeId("run id", runId)}.jsonl`);
16382
16641
  }
16383
16642
  ackFile(runId) {
16384
- return join27(this.dir, `${assertSafeId("run id", runId)}.ack.json`);
16643
+ return join28(this.dir, `${assertSafeId("run id", runId)}.ack.json`);
16385
16644
  }
16386
16645
  parse(runId) {
16387
16646
  let data;
@@ -16736,9 +16995,9 @@ var RpcServer = class {
16736
16995
  const { socketPath } = this.options;
16737
16996
  rmSync18(socketPath, { force: true });
16738
16997
  const server = createServer2((socket) => this.accept(socket));
16739
- await new Promise((resolve19, reject) => {
16998
+ await new Promise((resolve20, reject) => {
16740
16999
  server.once("error", reject);
16741
- server.listen(socketPath, () => resolve19());
17000
+ server.listen(socketPath, () => resolve20());
16742
17001
  });
16743
17002
  chmodSync(socketPath, 384);
16744
17003
  this.server = server;
@@ -16802,9 +17061,9 @@ var RpcServer = class {
16802
17061
  }
16803
17062
  async close() {
16804
17063
  for (const socket of this.sockets) socket.destroy();
16805
- await new Promise((resolve19) => {
16806
- if (!this.server) return resolve19();
16807
- this.server.close(() => resolve19());
17064
+ await new Promise((resolve20) => {
17065
+ if (!this.server) return resolve20();
17066
+ this.server.close(() => resolve20());
16808
17067
  });
16809
17068
  this.server = null;
16810
17069
  rmSync18(this.options.socketPath, { force: true });
@@ -17032,7 +17291,7 @@ async function startTaskSecretBridge(options) {
17032
17291
  };
17033
17292
  options.signal.addEventListener("abort", close, { once: true });
17034
17293
  try {
17035
- await new Promise((resolve19, reject) => {
17294
+ await new Promise((resolve20, reject) => {
17036
17295
  const cleanup = () => {
17037
17296
  server.off("error", failed);
17038
17297
  options.signal.removeEventListener("abort", cancelled);
@@ -17053,7 +17312,7 @@ async function startTaskSecretBridge(options) {
17053
17312
  }
17054
17313
  server.listen(0, "127.0.0.1", () => {
17055
17314
  cleanup();
17056
- resolve19();
17315
+ resolve20();
17057
17316
  });
17058
17317
  });
17059
17318
  options.signal.throwIfAborted();
@@ -17082,37 +17341,37 @@ async function startTaskSecretBridge(options) {
17082
17341
  }
17083
17342
 
17084
17343
  // src/agents/chat-files.ts
17085
- import { createHash as createHash10 } from "node:crypto";
17086
- import { lstat as lstat3, mkdir as mkdir3, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
17087
- import { join as join28 } from "node:path";
17344
+ import { createHash as createHash11 } from "node:crypto";
17345
+ import { lstat as lstat4, mkdir as mkdir4, readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
17346
+ import { join as join29 } from "node:path";
17088
17347
  async function materializeChatFiles(text4, directory, download2) {
17089
17348
  const parsed = splitChatFiles(text4);
17090
17349
  if (!parsed.files.length) return text4;
17091
- await mkdir3(directory, { recursive: true, mode: 448 });
17092
- if (!(await lstat3(directory)).isDirectory() || (await lstat3(directory)).isSymbolicLink())
17350
+ await mkdir4(directory, { recursive: true, mode: 448 });
17351
+ if (!(await lstat4(directory)).isDirectory() || (await lstat4(directory)).isSymbolicLink())
17093
17352
  throw Error("Attachment directory unavailable");
17094
17353
  const entries = [];
17095
17354
  for (const ref of parsed.files) {
17096
17355
  const file = chatFileDownloadSchema.parse(await download2(ref.id));
17097
17356
  if (file.id !== ref.id) throw Error("Attachment identity mismatch");
17098
17357
  const bytes = Buffer.from(file.data, "base64");
17099
- if (bytes.length !== file.size || bytes.toString("base64") !== file.data || createHash10("sha256").update(bytes).digest("hex") !== file.sha256)
17358
+ if (bytes.length !== file.size || bytes.toString("base64") !== file.data || createHash11("sha256").update(bytes).digest("hex") !== file.sha256)
17100
17359
  throw Error("Attachment content mismatch");
17101
17360
  const ext = /\.([a-z0-9]{1,12})$/i.exec(file.name)?.[1]?.toLowerCase() ?? "bin";
17102
- const path3 = join28(directory, `${file.id}.${ext}`);
17361
+ const path3 = join29(directory, `${file.id}.${ext}`);
17103
17362
  try {
17104
- await writeFile2(path3, bytes, { flag: "wx", mode: 256 });
17363
+ await writeFile3(path3, bytes, { flag: "wx", mode: 256 });
17105
17364
  } catch (error) {
17106
- if (error.code !== "EEXIST" || (await lstat3(path3)).isSymbolicLink() || createHash10("sha256").update(await readFile4(path3)).digest("hex") !== file.sha256)
17365
+ if (error.code !== "EEXIST" || (await lstat4(path3)).isSymbolicLink() || createHash11("sha256").update(await readFile5(path3)).digest("hex") !== file.sha256)
17107
17366
  throw Error("Attachment file unavailable");
17108
17367
  }
17109
17368
  let textPath;
17110
17369
  if (file.text !== null) {
17111
- textPath = join28(directory, `${file.id}.extracted.txt`);
17370
+ textPath = join29(directory, `${file.id}.extracted.txt`);
17112
17371
  try {
17113
- await writeFile2(textPath, file.text, { flag: "wx", mode: 256 });
17372
+ await writeFile3(textPath, file.text, { flag: "wx", mode: 256 });
17114
17373
  } catch (error) {
17115
- if (error.code !== "EEXIST" || (await lstat3(textPath)).isSymbolicLink() || await readFile4(textPath, "utf8") !== file.text)
17374
+ if (error.code !== "EEXIST" || (await lstat4(textPath)).isSymbolicLink() || await readFile5(textPath, "utf8") !== file.text)
17116
17375
  throw Error("Attachment text unavailable");
17117
17376
  }
17118
17377
  }
@@ -17126,9 +17385,9 @@ ${JSON.stringify(entries)}`;
17126
17385
 
17127
17386
  // src/runs/check.ts
17128
17387
  import { execa as execa9 } from "execa";
17129
- async function fixedCheckSnapshot(repoPath, worktree, sha5, signal) {
17388
+ async function fixedCheckSnapshot(repoPath, worktree, sha6, signal) {
17130
17389
  signal?.throwIfAborted();
17131
- if (!/^[a-f0-9]{40}$/.test(sha5))
17390
+ if (!/^[a-f0-9]{40}$/.test(sha6))
17132
17391
  throw new Error("Check requires an exact candidate SHA");
17133
17392
  const gitDir = await worktreeGitDir(repoPath, worktree, signal);
17134
17393
  const git3 = async (...args) => (await execa9(
@@ -17148,13 +17407,13 @@ async function fixedCheckSnapshot(repoPath, worktree, sha5, signal) {
17148
17407
  killDescendants: true
17149
17408
  }
17150
17409
  )).stdout.trim();
17151
- if (await git3("rev-parse", "HEAD") !== sha5)
17410
+ if (await git3("rev-parse", "HEAD") !== sha6)
17152
17411
  throw new Error("Check worktree HEAD differs from the fixed candidate");
17153
17412
  if (await git3("status", "--porcelain"))
17154
17413
  throw new Error(
17155
17414
  "Check worktree contains changes outside the fixed candidate"
17156
17415
  );
17157
- return { sha: sha5, tree: await git3("rev-parse", `${sha5}^{tree}`) };
17416
+ return { sha: sha6, tree: await git3("rev-parse", `${sha6}^{tree}`) };
17158
17417
  }
17159
17418
 
17160
17419
  // src/runs/supervisor.ts
@@ -17229,21 +17488,21 @@ function createRunMasker(secrets) {
17229
17488
  return cut;
17230
17489
  };
17231
17490
  const deep = (value) => {
17232
- const walk = (input) => {
17491
+ const walk2 = (input) => {
17233
17492
  if (typeof input === "string") return text4(input);
17234
- if (Array.isArray(input)) return input.map(walk);
17493
+ if (Array.isArray(input)) return input.map(walk2);
17235
17494
  if (input && typeof input === "object" && Object.getPrototypeOf(input) === Object.prototype)
17236
- return Object.fromEntries(Object.entries(input).map(([k, v2]) => [text4(k), walk(v2)]));
17495
+ return Object.fromEntries(Object.entries(input).map(([k, v2]) => [text4(k), walk2(v2)]));
17237
17496
  return input;
17238
17497
  };
17239
- return walk(value);
17498
+ return walk2(value);
17240
17499
  };
17241
17500
  const tail = (key2) => {
17242
17501
  const held = pending.get(key2);
17243
17502
  pending.delete(key2);
17244
17503
  if (!held) return null;
17245
- const sep3 = key2.indexOf(":");
17246
- const prefix = key2.slice(0, sep3), id5 = key2.slice(sep3 + 1);
17504
+ const sep4 = key2.indexOf(":");
17505
+ const prefix = key2.slice(0, sep4), id5 = key2.slice(sep4 + 1);
17247
17506
  const masked = text4(held);
17248
17507
  return prefix === "tool" ? { type: "tool-input-delta", toolCallId: id5, inputTextDelta: masked } : { type: DELTA_FOR_PREFIX[prefix], id: id5, delta: masked };
17249
17508
  };
@@ -17302,23 +17561,23 @@ function createRunMasker(secrets) {
17302
17561
 
17303
17562
  // src/runs/supervisor.ts
17304
17563
  import { stdSerializers } from "pino";
17305
- import { createHash as createHash12, randomUUID as randomUUID6 } from "node:crypto";
17306
- import { join as join30, resolve as resolve13 } from "node:path";
17564
+ import { createHash as createHash13, randomUUID as randomUUID6 } from "node:crypto";
17565
+ import { join as join31, resolve as resolve14 } from "node:path";
17307
17566
  import { tmpdir as tmpdir5 } from "node:os";
17308
17567
  import { execa as execa12 } from "execa";
17309
17568
 
17310
17569
  // src/agents/checkpoint.ts
17311
17570
  import { mkdtempSync as mkdtempSync9, rmSync as rmSync19, writeFileSync as writeFileSync9 } from "node:fs";
17312
17571
  import { tmpdir as tmpdir4 } from "node:os";
17313
- import { join as join29 } from "node:path";
17572
+ import { join as join30 } from "node:path";
17314
17573
  import { gunzipSync as gunzipSync2, gzipSync as gzipSync2 } from "node:zlib";
17315
17574
  import { execa as execa11 } from "execa";
17316
17575
 
17317
17576
  // src/coding-workspace/checkpoint.ts
17318
- import { createHash as createHash11 } from "node:crypto";
17319
- import { resolve as resolve12 } from "node:path";
17577
+ import { createHash as createHash12 } from "node:crypto";
17578
+ import { resolve as resolve13 } from "node:path";
17320
17579
  import { execa as execa10 } from "execa";
17321
- var digest6 = (value) => createHash11("sha256").update(value).digest("hex");
17580
+ var digest6 = (value) => createHash12("sha256").update(value).digest("hex");
17322
17581
  var oid = /^[a-f0-9]{40}(?:[a-f0-9]{24})?$/;
17323
17582
  var MANIFEST_BYTES = 1536 * 1024;
17324
17583
  var regular = (mode) => mode === null || mode === "100644" || mode === "100755";
@@ -17350,7 +17609,7 @@ async function captureCheckpointReview(input) {
17350
17609
  const env = {
17351
17610
  ...buildChildEnv({}),
17352
17611
  GIT_DIR: gitDir,
17353
- GIT_COMMON_DIR: resolve12(gitDir, "..", ".."),
17612
+ GIT_COMMON_DIR: resolve13(gitDir, "..", ".."),
17354
17613
  GIT_WORK_TREE: input.worktree,
17355
17614
  GIT_CONFIG_NOSYSTEM: "1",
17356
17615
  GIT_CONFIG_GLOBAL: "/dev/null",
@@ -17455,20 +17714,20 @@ async function captureCheckpointReview(input) {
17455
17714
  return { ...file, binary: false, additions: 0, deletions: 0, fileVersion: digest6(diffFileVersionMaterial(input.repoId, revision2, file)) };
17456
17715
  });
17457
17716
  if (Buffer.byteLength(JSON.stringify(files2)) > MANIFEST_BYTES) return result([], [], "too_large");
17458
- const wanted = [...new Set(files2.filter((file) => regular(file.oldMode) && regular(file.newMode) && [file.oldSize, file.newSize].every((size) => size === null || size <= WORKSPACE_DIFF_MAX_BLOB_BYTES)).flatMap((file) => [file.oldBlob, file.newBlob].filter((sha5) => sha5 !== null)))];
17459
- if (wanted.reduce((total, sha5) => total + sizes.get(sha5), 0) > CHECKPOINT_REVIEW_MAX_PROOF_BYTES) return result([], [], "too_large");
17717
+ const wanted = [...new Set(files2.filter((file) => regular(file.oldMode) && regular(file.newMode) && [file.oldSize, file.newSize].every((size) => size === null || size <= WORKSPACE_DIFF_MAX_BLOB_BYTES)).flatMap((file) => [file.oldBlob, file.newBlob].filter((sha6) => sha6 !== null)))];
17718
+ if (wanted.reduce((total, sha6) => total + sizes.get(sha6), 0) > CHECKPOINT_REVIEW_MAX_PROOF_BYTES) return result([], [], "too_large");
17460
17719
  const blobs = [];
17461
17720
  if (wanted.length) {
17462
17721
  exceeded = true;
17463
17722
  const content = await git3(["cat-file", "--batch"], wanted.join("\n") + "\n", CHECKPOINT_REVIEW_MAX_PROOF_BYTES + wanted.length * 128);
17464
17723
  exceeded = false;
17465
17724
  let offset = 0;
17466
- for (const sha5 of wanted) {
17725
+ for (const sha6 of wanted) {
17467
17726
  signal.throwIfAborted();
17468
- const end = content.indexOf(10, offset), size = sizes.get(sha5);
17469
- if (end === -1 || content.subarray(offset, end).toString("ascii") !== `${sha5} blob ${size}` || end + 1 + size >= content.length || content[end + 1 + size] !== 10) return result([], [], "missing_evidence");
17727
+ const end = content.indexOf(10, offset), size = sizes.get(sha6);
17728
+ if (end === -1 || content.subarray(offset, end).toString("ascii") !== `${sha6} blob ${size}` || end + 1 + size >= content.length || content[end + 1 + size] !== 10) return result([], [], "missing_evidence");
17470
17729
  const bytes = content.subarray(end + 1, end + 1 + size);
17471
- blobs.push({ sha: sha5, base64: bytes.toString("base64") });
17730
+ blobs.push({ sha: sha6, base64: bytes.toString("base64") });
17472
17731
  offset = end + 2 + size;
17473
17732
  }
17474
17733
  if (offset !== content.length) return result([], [], "missing_evidence");
@@ -17537,8 +17796,8 @@ async function takeCheckpoint(options) {
17537
17796
  }
17538
17797
  async function applyCheckpoint(options) {
17539
17798
  const git3 = await pinnedGit(options.repoPath, options.worktree);
17540
- const dir = mkdtempSync9(join29(tmpdir4(), "mikka-checkpoint-"));
17541
- const file = join29(dir, "checkpoint.patch");
17799
+ const dir = mkdtempSync9(join30(tmpdir4(), "mikka-checkpoint-"));
17800
+ const file = join30(dir, "checkpoint.patch");
17542
17801
  try {
17543
17802
  const patch = gunzipSync2(Buffer.from(options.checkpoint.patch, "base64"));
17544
17803
  if (!patch.length && options.checkpoint.files === 0) return true;
@@ -17854,12 +18113,12 @@ var MemoryServer = class {
17854
18113
  this.check();
17855
18114
  let pending = this.pendingCommands(deviceId, skip);
17856
18115
  if (pending.length === 0 && waitSeconds > 0 && !signal?.aborted) {
17857
- await new Promise((resolve19) => {
17858
- const timer = setTimeout(resolve19, waitSeconds * 1e3);
17859
- signal?.addEventListener("abort", () => resolve19(), { once: true });
18116
+ await new Promise((resolve20) => {
18117
+ const timer = setTimeout(resolve20, waitSeconds * 1e3);
18118
+ signal?.addEventListener("abort", () => resolve20(), { once: true });
17860
18119
  this.wakeCommands.push(() => {
17861
18120
  clearTimeout(timer);
17862
- resolve19();
18121
+ resolve20();
17863
18122
  });
17864
18123
  });
17865
18124
  this.check();
@@ -17991,6 +18250,7 @@ var RunSupervisor = class {
17991
18250
  const masker = this.maskers.get(runId);
17992
18251
  const checkpoint = taken?.checkpoint ? masker ? masker.checkpoint(taken.checkpoint) : taken.checkpoint : void 0;
17993
18252
  if (checkpoint) await save(runId, checkpoint);
18253
+ if (checkpoint) await run3.drive?.push();
17994
18254
  if (taken) {
17995
18255
  run3.lastCheckpointTree = taken.tree;
17996
18256
  run3.lastCheckpointHead = taken.head;
@@ -18018,6 +18278,7 @@ var RunSupervisor = class {
18018
18278
  const accepted = runCheckpointReceiptSchema.safeParse(await save(id5, checkpoint2));
18019
18279
  if (accepted.success && accepted.data.runId === id5) receipt = accepted.data;
18020
18280
  }, Date.now(), true);
18281
+ if (!this.stopping) await run3.drive?.push();
18021
18282
  const checkpoint = ready && receipt ? { checkpoint: "ready", checkpointTakenAt: receipt.takenAt } : { checkpoint: "unavailable" };
18022
18283
  if (finishingComplete && run3.sessionExited && !this.stopping)
18023
18284
  run3.safePoint = { session: "exited", observedAt: receipt?.takenAt ?? (/* @__PURE__ */ new Date()).toISOString(), ...checkpoint };
@@ -18330,7 +18591,7 @@ var RunSupervisor = class {
18330
18591
  const entry = this.deps.journal.get(runId);
18331
18592
  if (splitChatFiles(text4).files.length) {
18332
18593
  if (!entry || !this.deps.downloadChatFile || !this.deps.adapterStateDir) throw Error("Run attachments unavailable");
18333
- text4 = await materializeChatFiles(text4, join30(this.deps.adapterStateDir, "inputs", runId), (id5) => this.deps.downloadChatFile(entry.assignment, id5, run3.abort.signal));
18594
+ text4 = await materializeChatFiles(text4, join31(this.deps.adapterStateDir, "inputs", runId), (id5) => this.deps.downloadChatFile(entry.assignment, id5, run3.abort.signal));
18334
18595
  }
18335
18596
  await run3.session.send(text4, mode);
18336
18597
  }
@@ -18360,9 +18621,9 @@ var RunSupervisor = class {
18360
18621
  run3.abort.abort();
18361
18622
  }
18362
18623
  let timer;
18363
- const grace = new Promise((resolve19) => {
18624
+ const grace = new Promise((resolve20) => {
18364
18625
  timer = setTimeout(
18365
- resolve19,
18626
+ resolve20,
18366
18627
  this.deps.stopGraceMs ?? DEFAULT_STOP_GRACE_MS
18367
18628
  );
18368
18629
  });
@@ -18689,11 +18950,11 @@ var RunSupervisor = class {
18689
18950
  if (configured.length === 0) return void 0;
18690
18951
  const loaded = [];
18691
18952
  if (this.deps.adapterStateDir) {
18692
- const dir = join30(runPaths(this.deps.adapterStateDir, runId).runDir, PROFILE_SKILLS_DIR, PROFILE_SKILL_LOADS_DIR);
18953
+ const dir = join31(runPaths(this.deps.adapterStateDir, runId).runDir, PROFILE_SKILLS_DIR, PROFILE_SKILL_LOADS_DIR);
18693
18954
  try {
18694
18955
  for (const name of readdirSync8(dir).sort()) {
18695
18956
  if (!name.endsWith(".json") || loaded.length >= configured.length) continue;
18696
- const file = join30(dir, name), meta = lstatSync11(file, { throwIfNoEntry: false });
18957
+ const file = join31(dir, name), meta = lstatSync11(file, { throwIfNoEntry: false });
18697
18958
  if (!meta?.isFile() || meta.isSymbolicLink() || meta.nlink !== 1 || meta.size < 2 || meta.size > 4096) continue;
18698
18959
  const receipt = profileSkillLoadReceiptSchema.safeParse(JSON.parse(readFileSync14(file, "utf8")));
18699
18960
  if (!receipt.success || loaded.some((item) => item.id === receipt.data.id)) continue;
@@ -18837,7 +19098,7 @@ var RunSupervisor = class {
18837
19098
  try {
18838
19099
  return await withRunGitCredentials(
18839
19100
  assignment,
18840
- runPaths(this.deps.adapterStateDir ?? join30(tmpdir5(), "mikka-run-state"), runId).privateDir,
19101
+ runPaths(this.deps.adapterStateDir ?? join31(tmpdir5(), "mikka-run-state"), runId).privateDir,
18841
19102
  (env) => this.deps.worktrees.fetchBranch(
18842
19103
  repo.path,
18843
19104
  repo.push?.remote ?? "origin",
@@ -18987,8 +19248,8 @@ var RunSupervisor = class {
18987
19248
  });
18988
19249
  if (readAbort) {
18989
19250
  let allowEffects, refuseEffects;
18990
- const entryReady = new Promise((resolve19, reject) => {
18991
- allowEffects = resolve19;
19251
+ const entryReady = new Promise((resolve20, reject) => {
19252
+ allowEffects = resolve20;
18992
19253
  refuseEffects = reject;
18993
19254
  });
18994
19255
  const authorized = Promise.all([policyReady, entryReady]);
@@ -19226,11 +19487,17 @@ var RunSupervisor = class {
19226
19487
  throw error;
19227
19488
  }
19228
19489
  }
19229
- let prompt = [assignment.prompt, run3.secretBridge?.instructions].filter(Boolean).join("\n\n");
19490
+ if (!run3.drive && this.deps.prepareRunDrive) {
19491
+ run3.drive = await this.deps.prepareRunDrive(assignment, run3.abort.signal).catch(() => void 0);
19492
+ await run3.drive?.pull();
19493
+ }
19494
+ const driveBrief = run3.drive?.folders.length ? `Shared Drive folders on this machine (synced at checkpoints and when you finish; a version conflict keeps your copy beside the newer one):
19495
+ ${run3.drive.folders.map((folder) => `- ${folder.scope}: ${folder.path}${folder.write ? "" : " (read-only)"}`).join("\n")}` : void 0;
19496
+ let prompt = [assignment.prompt, run3.secretBridge?.instructions, driveBrief].filter(Boolean).join("\n\n");
19230
19497
  let followUp = assignment.followUp;
19231
19498
  if (splitChatFiles(prompt).files.length || followUp && splitChatFiles(followUp).files.length) {
19232
19499
  if (!this.deps.downloadChatFile || !this.deps.adapterStateDir) throw Error("Run attachments unavailable");
19233
- const directory = join30(this.deps.adapterStateDir, "inputs", runId);
19500
+ const directory = join31(this.deps.adapterStateDir, "inputs", runId);
19234
19501
  const download2 = (id5) => this.deps.downloadChatFile(assignment, id5, run3.abort.signal);
19235
19502
  prompt = await materializeChatFiles(prompt, directory, download2);
19236
19503
  if (followUp) followUp = await materializeChatFiles(followUp, directory, download2);
@@ -19243,7 +19510,7 @@ var RunSupervisor = class {
19243
19510
  gitWritePaths: await worktreeGitWritePaths(repo.path, worktree, runId)
19244
19511
  };
19245
19512
  const resuming = entry.sessionId !== null && adapter.capabilities.supportsResume;
19246
- const inEarlierWorktree = continued !== null || entry.worktree !== null && resolve13(entry.worktree) !== resolve13(this.deps.worktrees.pathFor(runId));
19513
+ const inEarlierWorktree = continued !== null || entry.worktree !== null && resolve14(entry.worktree) !== resolve14(this.deps.worktrees.pathFor(runId));
19247
19514
  const continueSession = !resuming && assignment.resumeSessionId && assignment.continuesRunId && inEarlierWorktree && adapter.capabilities.supportsResume ? {
19248
19515
  sessionId: assignment.resumeSessionId,
19249
19516
  runId: assignment.continuesRunId,
@@ -19252,13 +19519,13 @@ var RunSupervisor = class {
19252
19519
  if (assignment.requireSessionResume && (!assignment.resumeSessionId || !assignment.continuesRunId || !adapter.capabilities.supportsResume || !resuming && !continueSession || resuming && entry.sessionId !== assignment.resumeSessionId))
19253
19520
  throw new Error("factory_question_session_resume_required");
19254
19521
  const benchmark = assignment.benchmark;
19255
- const policyDigest = assignment.skillReceipt ? createHash12("sha256").update(runPolicyDigestInput(assignment.policy)).digest("hex") : void 0;
19522
+ const policyDigest = assignment.skillReceipt ? createHash13("sha256").update(runPolicyDigestInput(assignment.policy)).digest("hex") : void 0;
19256
19523
  if (benchmark && (!assignment.skillReceipt || assignment.harness === "mock" || !assignment.verifyCommand || benchmark.sourceCommit !== this.deps.journal.get(runId)?.baseCommit || policyDigest !== benchmark.policyDigest)) throw new Error("Frozen benchmark execution configuration mismatch");
19257
19524
  let fixtureDigest;
19258
19525
  if (benchmark) {
19259
19526
  if (runPolicy(assignment.policy).readOnly !== true) throw new Error("Benchmark fixture must be read-only");
19260
19527
  const fixed = await fixedCheckSnapshot(repo.path, worktree, benchmark.sourceCommit);
19261
- fixtureDigest = createHash12("sha256").update(fixed.sha).digest("hex");
19528
+ fixtureDigest = createHash13("sha256").update(fixed.sha).digest("hex");
19262
19529
  if (fixtureDigest !== benchmark.fixtureDigest) throw new Error("Frozen benchmark fixture digest mismatch");
19263
19530
  }
19264
19531
  const previousMount = entry.skillMount;
@@ -19299,7 +19566,7 @@ var RunSupervisor = class {
19299
19566
  if (!this.deps.adapterStateDir || assignment.harness === "mock" || !session.sessionId || resuming && session.sessionId !== entry.sessionId || assignment.requireSessionResume && session.sessionId !== assignment.resumeSessionId)
19300
19567
  throw new Error("Skill mount requires the actual original harness session");
19301
19568
  verifySkillAssignment(assignment);
19302
- const file = join30(
19569
+ const file = join31(
19303
19570
  runPaths(this.deps.adapterStateDir, runId).runDir,
19304
19571
  SKILLS_DIR,
19305
19572
  skillSlug(assignment.skills[0].name),
@@ -19417,7 +19684,7 @@ var RunSupervisor = class {
19417
19684
  try {
19418
19685
  if (assignment.benchmark && !run3.cancelRequested) {
19419
19686
  const fixed = await fixedCheckSnapshot(repo.path, worktree, assignment.benchmark.sourceCommit, finishingSignal);
19420
- if (createHash12("sha256").update(fixed.sha).digest("hex") !== assignment.benchmark.fixtureDigest)
19687
+ if (createHash13("sha256").update(fixed.sha).digest("hex") !== assignment.benchmark.fixtureDigest)
19421
19688
  throw new Error("Benchmark fixture changed during model execution");
19422
19689
  }
19423
19690
  outcome = await this.report(runId, worktree, repo, assignment, stopReason, error, event.report, finishingSignal);
@@ -19501,10 +19768,10 @@ function trackParts(open5, chunk) {
19501
19768
  }
19502
19769
  var ABORTED = /* @__PURE__ */ Symbol("aborted");
19503
19770
  function abortPromise(signal) {
19504
- return new Promise((resolve19) => {
19505
- if (signal.aborted) resolve19(ABORTED);
19771
+ return new Promise((resolve20) => {
19772
+ if (signal.aborted) resolve20(ABORTED);
19506
19773
  else
19507
- signal.addEventListener("abort", () => resolve19(ABORTED), { once: true });
19774
+ signal.addEventListener("abort", () => resolve20(ABORTED), { once: true });
19508
19775
  });
19509
19776
  }
19510
19777
  function pickAgentReport(agent) {
@@ -19635,7 +19902,7 @@ var DeviceGatewayClosedError = class extends Error {
19635
19902
  function runDeviceGateway(socket, options) {
19636
19903
  const pingMs = options.pingMs ?? DEVICE_GATEWAY_PING_MS;
19637
19904
  const silenceMs = options.silenceMs ?? DEVICE_GATEWAY_SILENCE_MS;
19638
- return new Promise((resolve19, reject) => {
19905
+ return new Promise((resolve20, reject) => {
19639
19906
  let settled = false;
19640
19907
  let opened = false;
19641
19908
  let pulling = false;
@@ -19654,7 +19921,7 @@ function runDeviceGateway(socket, options) {
19654
19921
  } catch {
19655
19922
  }
19656
19923
  if (error && !options.signal.aborted) reject(error);
19657
- else resolve19();
19924
+ else resolve20();
19658
19925
  };
19659
19926
  const work = () => {
19660
19927
  if (settled) return;
@@ -19802,11 +20069,11 @@ var DeviceSession = class {
19802
20069
  }
19803
20070
  /** A redial backoff, not a poll: it ends early on `wake` or `stop`. */
19804
20071
  pause(ms2) {
19805
- return new Promise((resolve19) => {
20072
+ return new Promise((resolve20) => {
19806
20073
  const done = () => {
19807
20074
  clearTimeout(timer);
19808
20075
  this.wakeUp = null;
19809
- resolve19();
20076
+ resolve20();
19810
20077
  };
19811
20078
  const timer = setTimeout(done, ms2);
19812
20079
  this.wakeUp = done;
@@ -19817,20 +20084,20 @@ var DeviceSession = class {
19817
20084
 
19818
20085
  // src/coding-workspace/files.ts
19819
20086
  import { constants as constants7 } from "node:fs";
19820
- import { open as open2, readFile as readFile5, realpath as realpath2 } from "node:fs/promises";
20087
+ import { open as open2, readFile as readFile6, realpath as realpath2 } from "node:fs/promises";
19821
20088
  import { execFile as execFile7 } from "node:child_process";
19822
20089
  import { promisify as promisify7 } from "node:util";
19823
- import { createHash as createHash13 } from "node:crypto";
19824
- import { extname, resolve as resolve14 } from "node:path";
20090
+ import { createHash as createHash14 } from "node:crypto";
20091
+ import { extname as extname2, resolve as resolve15 } from "node:path";
19825
20092
  var execute2 = promisify7(execFile7);
19826
- var hash = (value) => createHash13("sha256").update(value).digest("hex");
20093
+ var hash = (value) => createHash14("sha256").update(value).digest("hex");
19827
20094
  var denied = () => new CodingWorkspaceError("workspace_path_unavailable");
19828
20095
  function isFileReadRequest(request2) {
19829
20096
  return request2.kind === "file" || request2.kind === "tree" || request2.kind === "search" || request2.kind === "context";
19830
20097
  }
19831
20098
  var safeDotfiles2 = /* @__PURE__ */ new Set([".gitignore", ".gitattributes", ".editorconfig", ".prettierignore", ".prettierrc", ".eslintrc", ".dockerignore"]);
19832
20099
  async function mountId(handle) {
19833
- const id5 = /^mnt_id:\s*(\d+)$/m.exec(await readFile5(`/proc/self/fdinfo/${handle.fd}`, "utf8"))?.[1];
20100
+ const id5 = /^mnt_id:\s*(\d+)$/m.exec(await readFile6(`/proc/self/fdinfo/${handle.fd}`, "utf8"))?.[1];
19834
20101
  if (!id5) throw new CodingWorkspaceError("workspace_unsupported");
19835
20102
  return id5;
19836
20103
  }
@@ -19870,9 +20137,9 @@ async function safeFile(root, path3, use) {
19870
20137
  parent = handle;
19871
20138
  }
19872
20139
  const selected = await realpath2(`/proc/self/fd/${parent.fd}`);
19873
- if (selected !== resolve14(root.path, path3) || await realpath2(root.gitPath) !== root.path) throw denied();
20140
+ if (selected !== resolve15(root.path, path3) || await realpath2(root.gitPath) !== root.path) throw denied();
19874
20141
  const result = await use(parent);
19875
- if (await realpath2(`/proc/self/fd/${parent.fd}`) !== selected || await realpath2(resolve14(root.path, path3)) !== selected || await realpath2(root.gitPath) !== root.path) throw new CodingWorkspaceError("workspace_version_conflict");
20142
+ if (await realpath2(`/proc/self/fd/${parent.fd}`) !== selected || await realpath2(resolve15(root.path, path3)) !== selected || await realpath2(root.gitPath) !== root.path) throw new CodingWorkspaceError("workspace_version_conflict");
19876
20143
  return result;
19877
20144
  } catch (cause) {
19878
20145
  if (cause instanceof CodingWorkspaceError) throw cause;
@@ -19884,7 +20151,7 @@ async function safeFile(root, path3, use) {
19884
20151
  var textExtensions = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".json", ".jsonc", ".md", ".mdx", ".txt", ".csv", ".tsv", ".yaml", ".yml", ".toml", ".xml", ".html", ".css", ".scss", ".sass", ".less", ".sql", ".py", ".pyi", ".go", ".mod", ".sum", ".rs", ".java", ".kt", ".kts", ".swift", ".c", ".h", ".cpp", ".hpp", ".cs", ".rb", ".php", ".sh", ".bash", ".zsh", ".fish", ".ps1", ".bat", ".cmd", ".vue", ".svelte", ".graphql", ".gql", ".proto", ".prisma", ".ex", ".exs", ".erl", ".hrl", ".clj", ".scala", ".r", ".rmd", ".jl", ".lua", ".pl", ".pm", ".dart", ".lock", ".ini", ".conf", ".cfg", ".rst", ".adoc", ".tex"]);
19885
20152
  var textNames = /^(?:Dockerfile(?:\..*)?|Containerfile|Makefile|CMakeLists\.txt|README(?:\..*)?|LICENSE(?:\..*)?|NOTICE|Procfile|Gemfile|Rakefile|Justfile)$/i;
19886
20153
  function isText(path3) {
19887
- return textExtensions.has(extname(path3).toLowerCase()) || textNames.test(path3.split("/").at(-1)) || safeDotfiles2.has(path3.split("/").at(-1));
20154
+ return textExtensions.has(extname2(path3).toLowerCase()) || textNames.test(path3.split("/").at(-1)) || safeDotfiles2.has(path3.split("/").at(-1));
19888
20155
  }
19889
20156
  function revision(headSha2, baseSha, content) {
19890
20157
  return { source: "working", headSha: headSha2, baseSha: baseSha && /^[a-f0-9]{40,64}$/.test(baseSha) ? baseSha : null, version: hash(content) };
@@ -19911,7 +20178,7 @@ async function readWorkspaceReceipt(command, entry) {
19911
20178
  const remote = entry.assignment.remoteUrl ?? entry.assignment.expectedRepoRemote;
19912
20179
  if (!remote || remoteKey(remote) !== identity.repositoryKey) throw new CodingWorkspaceError("workspace_checkout_unavailable");
19913
20180
  if (process.platform !== "linux") throw new CodingWorkspaceError("workspace_unsupported");
19914
- const path3 = resolve14(entry.worktree);
20181
+ const path3 = resolve15(entry.worktree);
19915
20182
  if (await realpath2(path3) !== path3) throw new CodingWorkspaceError("workspace_checkout_unavailable");
19916
20183
  directory = await open2(path3, constants7.O_RDONLY | constants7.O_DIRECTORY | constants7.O_NOFOLLOW);
19917
20184
  const root = {
@@ -19939,7 +20206,7 @@ async function readWorkspaceReceipt(command, entry) {
19939
20206
  kind: "file",
19940
20207
  path: request3.path,
19941
20208
  size,
19942
- language: extname(request3.path).slice(1) || null,
20209
+ language: extname2(request3.path).slice(1) || null,
19943
20210
  revision: revision(headSha2, entry.baseCommit, `${headSha2}:${request3.path}:${before.ino}:${before.mtimeNs}:${before.ctimeNs}:${before.size}`),
19944
20211
  content: null,
19945
20212
  contentSha256: null,
@@ -20071,9 +20338,9 @@ async function readWorkspaceReceipt(command, entry) {
20071
20338
 
20072
20339
  // src/coding-workspace/diff.ts
20073
20340
  import { constants as constants8 } from "node:fs";
20074
- import { open as open3, realpath as realpath3, mkdtemp as mkdtemp2, mkdir as mkdir4, writeFile as writeFile3, rm as rm3, lstat as lstat4 } from "node:fs/promises";
20075
- import { createHash as createHash14 } from "node:crypto";
20076
- import { resolve as resolve15, dirname as dirname15, join as join31, posix } from "node:path";
20341
+ import { open as open3, realpath as realpath3, mkdtemp as mkdtemp2, mkdir as mkdir5, writeFile as writeFile4, rm as rm4, lstat as lstat5 } from "node:fs/promises";
20342
+ import { createHash as createHash15 } from "node:crypto";
20343
+ import { resolve as resolve16, dirname as dirname16, join as join32, posix } from "node:path";
20077
20344
  import { tmpdir as tmpdir6 } from "node:os";
20078
20345
  import { execa as execa13 } from "execa";
20079
20346
 
@@ -20142,7 +20409,7 @@ var CRLFCleaner = class {
20142
20409
  };
20143
20410
 
20144
20411
  // src/coding-workspace/diff.ts
20145
- var digest7 = (value) => createHash14("sha256").update(value).digest("hex");
20412
+ var digest7 = (value) => createHash15("sha256").update(value).digest("hex");
20146
20413
  var fenceMode = (mode) => mode === "100644" || mode === "100755" || mode === "120000" || mode === "160000" ? mode : null;
20147
20414
  var oid2 = /^[a-f0-9]{40}(?:[a-f0-9]{24})?$/;
20148
20415
  var MAX_SCAN_BYTES = 64 * 1024 * 1024;
@@ -20167,7 +20434,7 @@ async function gitFor(repoPath, root, signal) {
20167
20434
  const env = {
20168
20435
  ...buildChildEnv({}),
20169
20436
  GIT_DIR: gitDir,
20170
- GIT_COMMON_DIR: resolve15(gitDir, "..", ".."),
20437
+ GIT_COMMON_DIR: resolve16(gitDir, "..", ".."),
20171
20438
  // cwd is resolved while the parent's FD is still open. The child does not
20172
20439
  // inherit that numeric descriptor, so its work tree must be relative to cwd.
20173
20440
  GIT_WORK_TREE: ".",
@@ -20232,7 +20499,7 @@ async function treeFiles(git3, commit) {
20232
20499
  }
20233
20500
  async function existsWithoutReading(path3) {
20234
20501
  try {
20235
- await lstat4(path3);
20502
+ await lstat5(path3);
20236
20503
  return true;
20237
20504
  } catch (error) {
20238
20505
  if (missing(error)) return false;
@@ -20251,12 +20518,12 @@ async function conversionSettings(git3) {
20251
20518
  const host = buildChildEnv({});
20252
20519
  const defaults = ["/etc/gitattributes", "/usr/etc/gitattributes", "/usr/local/etc/gitattributes"];
20253
20520
  if (!external) {
20254
- const configHome = host.XDG_CONFIG_HOME || (host.HOME ? join31(host.HOME, ".config") : void 0);
20255
- if (configHome) defaults.push(join31(configHome, "git", "attributes"));
20521
+ const configHome = host.XDG_CONFIG_HOME || (host.HOME ? join32(host.HOME, ".config") : void 0);
20522
+ if (configHome) defaults.push(join32(configHome, "git", "attributes"));
20256
20523
  }
20257
- const info = join31(git3.commonDir, "info");
20524
+ const info = join32(git3.commonDir, "info");
20258
20525
  if (await existsWithoutReading(info)) {
20259
- if (!(await lstat4(info)).isDirectory() || await existsWithoutReading(join31(info, "attributes")))
20526
+ if (!(await lstat5(info)).isDirectory() || await existsWithoutReading(join32(info, "attributes")))
20260
20527
  throw new CodingWorkspaceError("workspace_unsupported");
20261
20528
  }
20262
20529
  for (const path3 of defaults) if (await existsWithoutReading(path3)) throw new CodingWorkspaceError("workspace_unsupported");
@@ -20302,11 +20569,11 @@ async function workingConversion(git3, root, paths, head, signal, budget) {
20302
20569
  throw new CodingWorkspaceError("workspace_unsupported");
20303
20570
  attributeBytes.set(path3, bytes);
20304
20571
  }
20305
- const directory = await mkdtemp2(join31(tmpdir6(), "mikka-diff-attributes-"));
20572
+ const directory = await mkdtemp2(join32(tmpdir6(), "mikka-diff-attributes-"));
20306
20573
  const actions = /* @__PURE__ */ new Map();
20307
20574
  try {
20308
- const gitDir = join31(directory, "git"), worktree = join31(directory, "worktree");
20309
- await mkdir4(worktree, { mode: 448 });
20575
+ const gitDir = join32(directory, "git"), worktree = join32(directory, "worktree");
20576
+ await mkdir5(worktree, { mode: 448 });
20310
20577
  const env = {
20311
20578
  ...buildChildEnv({}),
20312
20579
  GIT_CONFIG_NOSYSTEM: "1",
@@ -20325,9 +20592,9 @@ async function workingConversion(git3, root, paths, head, signal, budget) {
20325
20592
  killDescendants: true
20326
20593
  });
20327
20594
  for (const [path3, bytes] of attributeBytes) {
20328
- const target = join31(worktree, path3);
20329
- await mkdir4(dirname15(target), { recursive: true, mode: 448 });
20330
- await writeFile3(target, bytes, { mode: 384, flag: "wx" });
20595
+ const target = join32(worktree, path3);
20596
+ await mkdir5(dirname16(target), { recursive: true, mode: 448 });
20597
+ await writeFile4(target, bytes, { mode: 384, flag: "wx" });
20331
20598
  }
20332
20599
  const attributes = ["text", "eol", "crlf", "filter", "working-tree-encoding", "ident"];
20333
20600
  const allowedPaths = new Set(paths);
@@ -20368,7 +20635,7 @@ async function workingConversion(git3, root, paths, head, signal, budget) {
20368
20635
  }
20369
20636
  for (const path3 of paths) actions.set(path3, cleanAction(values.get(path3), settings.autoCRLF));
20370
20637
  } finally {
20371
- await rm3(directory, { recursive: true, force: true });
20638
+ await rm4(directory, { recursive: true, force: true });
20372
20639
  }
20373
20640
  return {
20374
20641
  index,
@@ -20408,7 +20675,7 @@ async function currentFile(root, path3, head, budget, signal, conversion, git3)
20408
20675
  budget.bytes += size;
20409
20676
  if (budget.bytes > MAX_SCAN_BYTES) throw new CodingWorkspaceError("workspace_limit_exceeded");
20410
20677
  const algorithm = head.length === 64 ? "sha256" : "sha1";
20411
- const hasher = createHash14(algorithm).update(`blob ${size}\0`), stats = new GitTextStats();
20678
+ const hasher = createHash15(algorithm).update(`blob ${size}\0`), stats = new GitTextStats();
20412
20679
  const bytes = size <= WORKSPACE_DIFF_MAX_BLOB_BYTES ? Buffer.alloc(size) : null;
20413
20680
  const chunk = Buffer.alloc(64 * 1024);
20414
20681
  let offset = 0;
@@ -20448,7 +20715,7 @@ async function currentFile(root, path3, head, budget, signal, conversion, git3)
20448
20715
  let blob = rawBlob, cleanSize = size;
20449
20716
  if (normalize) {
20450
20717
  cleanSize -= stats.crlf;
20451
- const cleaned = createHash14(algorithm).update(`blob ${cleanSize}\0`), cleaner = new CRLFCleaner();
20718
+ const cleaned = createHash15(algorithm).update(`blob ${cleanSize}\0`), cleaner = new CRLFCleaner();
20452
20719
  if (bytes) cleaned.update(cleaner.push(bytes));
20453
20720
  else {
20454
20721
  budget.bytes += size;
@@ -20591,7 +20858,7 @@ async function readWorkspaceDiffReceipt(command, entry, repoPath) {
20591
20858
  if (!entry?.worktree || entry.assignment.runId !== identity.runId || entry.assignment.repoId !== identity.repoId || entry.assignment.deviceId !== identity.deviceId || remoteKey(entry.assignment.remoteUrl ?? entry.assignment.expectedRepoRemote ?? "") !== identity.repositoryKey)
20592
20859
  throw new CodingWorkspaceError("workspace_checkout_unavailable");
20593
20860
  if (process.platform !== "linux") throw new CodingWorkspaceError("workspace_unsupported");
20594
- const path3 = resolve15(entry.worktree);
20861
+ const path3 = resolve16(entry.worktree);
20595
20862
  if (await realpath3(path3) !== path3) throw new CodingWorkspaceError("workspace_checkout_unavailable");
20596
20863
  directory = await open3(path3, constants8.O_RDONLY | constants8.O_DIRECTORY | constants8.O_NOFOLLOW);
20597
20864
  const root = {
@@ -20638,8 +20905,8 @@ async function readWorkspaceDiffReceipt(command, entry, repoPath) {
20638
20905
  if (value.conversion) await verifyConversion(git3, root, value.conversion);
20639
20906
  if (Date.parse(expiresAt) <= Date.now()) throw new CodingWorkspaceError("workspace_request_expired");
20640
20907
  if (value.revision.source === "working" && (await git3(["rev-parse", "--verify", "HEAD"])).toString().trim() !== value.revision.headSha || await realpath3(root.gitPath) !== root.path) throw new CodingWorkspaceError("workspace_version_conflict");
20641
- return { result: { ...result, format: "text" }, files: [], blobs: [...blobs].map(([sha5, proof]) => ({
20642
- sha: sha5,
20908
+ return { result: { ...result, format: "text" }, files: [], blobs: [...blobs].map(([sha6, proof]) => ({
20909
+ sha: sha6,
20643
20910
  base64: proof.bytes.toString("base64"),
20644
20911
  ...proof.rawSha ? { clean: "crlf_to_lf", rawSha: proof.rawSha } : {}
20645
20912
  })) };
@@ -20661,7 +20928,7 @@ async function readWorkspaceRevertPreview(command, entry, repoPath) {
20661
20928
  if (!entry?.worktree || entry.assignment.runId !== identity.runId || entry.assignment.repoId !== identity.repoId || entry.assignment.deviceId !== identity.deviceId || remoteKey(entry.assignment.remoteUrl ?? entry.assignment.expectedRepoRemote ?? "") !== identity.repositoryKey)
20662
20929
  throw new CodingWorkspaceError("workspace_checkout_unavailable");
20663
20930
  if (process.platform !== "linux") throw new CodingWorkspaceError("workspace_unsupported");
20664
- const path3 = resolve15(entry.worktree);
20931
+ const path3 = resolve16(entry.worktree);
20665
20932
  if (await realpath3(path3) !== path3) throw new CodingWorkspaceError("workspace_checkout_unavailable");
20666
20933
  directory = await open3(path3, constants8.O_RDONLY | constants8.O_DIRECTORY | constants8.O_NOFOLLOW);
20667
20934
  const root = {
@@ -20731,9 +20998,9 @@ async function readWorkspaceRevertPreview(command, entry, repoPath) {
20731
20998
 
20732
20999
  // src/coding-workspace/git.ts
20733
21000
  import { constants as constants9 } from "node:fs";
20734
- import { lstat as lstat5, mkdtemp as mkdtemp3, open as open4, readFile as readFile6, realpath as realpath4, rm as rm4, unlink, writeFile as writeFile4 } from "node:fs/promises";
20735
- import { createHash as createHash15 } from "node:crypto";
20736
- import { join as join32, resolve as resolve16 } from "node:path";
21001
+ import { lstat as lstat6, mkdtemp as mkdtemp3, open as open4, readFile as readFile7, realpath as realpath4, rm as rm5, unlink, writeFile as writeFile5 } from "node:fs/promises";
21002
+ import { createHash as createHash16 } from "node:crypto";
21003
+ import { join as join33, resolve as resolve17 } from "node:path";
20737
21004
  import { tmpdir as tmpdir7 } from "node:os";
20738
21005
  import { execa as execa14 } from "execa";
20739
21006
 
@@ -20836,23 +21103,23 @@ function parseGitLog(output, options) {
20836
21103
  if (fields.length % 7 !== 0) throw new Error("log_parse");
20837
21104
  const commits = [];
20838
21105
  for (let offset = 0; offset < fields.length; offset += 7) {
20839
- const [sha5, parents, authorName, authorEmail, authoredAt, committedAt, subject] = fields.slice(offset, offset + 7);
20840
- if (!sha5 || !oid3.test(sha5)) throw new Error("log_parse");
21106
+ const [sha6, parents, authorName, authorEmail, authoredAt, committedAt, subject] = fields.slice(offset, offset + 7);
21107
+ if (!sha6 || !oid3.test(sha6)) throw new Error("log_parse");
20841
21108
  const time = (value) => {
20842
21109
  const parsed = new Date(value ?? "");
20843
21110
  if (!Number.isFinite(parsed.getTime())) throw new Error("log_parse");
20844
21111
  return parsed.toISOString();
20845
21112
  };
20846
21113
  commits.push({
20847
- sha: sha5,
21114
+ sha: sha6,
20848
21115
  parents: parents ? parents.split(" ").filter(Boolean) : [],
20849
21116
  authorName: (authorName ?? "").slice(0, 200),
20850
21117
  authorEmail: (authorEmail ?? "").slice(0, 320),
20851
21118
  authoredAt: time(authoredAt),
20852
21119
  committedAt: time(committedAt),
20853
21120
  subject: (subject ?? "").slice(0, 1e3),
20854
- head: sha5 === options.headSha,
20855
- base: options.baseSha !== null && sha5 === options.baseSha
21121
+ head: sha6 === options.headSha,
21122
+ base: options.baseSha !== null && sha6 === options.baseSha
20856
21123
  });
20857
21124
  }
20858
21125
  return commits;
@@ -20867,7 +21134,7 @@ function parseHistoryCursor(cursor, headSha2) {
20867
21134
  var historyCursor = (headSha2, offset) => `${headSha2}:${offset}`;
20868
21135
 
20869
21136
  // src/coding-workspace/git.ts
20870
- var digest8 = (value) => createHash15("sha256").update(value).digest("hex");
21137
+ var digest8 = (value) => createHash16("sha256").update(value).digest("hex");
20871
21138
  var oid4 = /^[a-f0-9]{40}(?:[a-f0-9]{24})?$/;
20872
21139
  var STATUS_BYTES = 8 * 1024 * 1024;
20873
21140
  var STATUS_SCAN_BYTES = 16 * 1024 * 1024;
@@ -20889,7 +21156,7 @@ async function openPinnedRoot(command, entry) {
20889
21156
  if (!entry?.worktree || entry.assignment.runId !== identity.runId || entry.assignment.repoId !== identity.repoId || entry.assignment.deviceId !== identity.deviceId || remoteKey(entry.assignment.remoteUrl ?? entry.assignment.expectedRepoRemote ?? "") !== identity.repositoryKey)
20890
21157
  throw unavailable4();
20891
21158
  if (process.platform !== "linux") throw new CodingWorkspaceError("workspace_unsupported");
20892
- const path3 = resolve16(entry.worktree);
21159
+ const path3 = resolve17(entry.worktree);
20893
21160
  if (await realpath4(path3) !== path3) throw unavailable4();
20894
21161
  const directory = await open4(path3, constants9.O_RDONLY | constants9.O_DIRECTORY | constants9.O_NOFOLLOW);
20895
21162
  try {
@@ -20994,7 +21261,7 @@ async function deletePinnedFile(root, path3, expectedFence) {
20994
21261
  const { parent, name, parents } = await openParent(root, path3);
20995
21262
  try {
20996
21263
  const targetPath = `/proc/self/fd/${parent.fd}/${name}`;
20997
- const stat3 = await lstat5(targetPath, { bigint: true }).catch((error) => {
21264
+ const stat3 = await lstat6(targetPath, { bigint: true }).catch((error) => {
20998
21265
  if (!missing(error)) throw error;
20999
21266
  return null;
21000
21267
  });
@@ -21329,15 +21596,15 @@ function runGit(cwd, args, env, signal, maximum = 8 * 1024 * 1024) {
21329
21596
  }
21330
21597
  async function readTempFile(worktree, path3) {
21331
21598
  if (!visibleWorkspacePath(path3)) throw new CodingWorkspaceError("workspace_path_unavailable");
21332
- const full = join32(worktree, ...path3.split("/"));
21599
+ const full = join33(worktree, ...path3.split("/"));
21333
21600
  if (!full.startsWith(`${worktree}/`)) throw new CodingWorkspaceError("workspace_path_unavailable");
21334
21601
  try {
21335
- const stat3 = await lstat5(full);
21602
+ const stat3 = await lstat6(full);
21336
21603
  if (stat3.isSymbolicLink()) return { exists: true, bytes: null, mode: null, reason: "unavailable" };
21337
21604
  if (stat3.isDirectory()) return { exists: true, bytes: null, mode: null, reason: "submodule" };
21338
21605
  if (!stat3.isFile()) return { exists: true, bytes: null, mode: null, reason: "unavailable" };
21339
21606
  if (stat3.size > RESTORE_FILE_BYTES) return { exists: true, bytes: null, mode: null, reason: "binary" };
21340
- return { exists: true, bytes: await readFile6(full), mode: stat3.mode & 73 ? "100755" : "100644", reason: null };
21607
+ return { exists: true, bytes: await readFile7(full), mode: stat3.mode & 73 ? "100755" : "100644", reason: null };
21341
21608
  } catch (error) {
21342
21609
  if (missing(error)) return { exists: false, bytes: null, mode: null, reason: null };
21343
21610
  throw error;
@@ -21350,10 +21617,10 @@ async function dryRunCheckpoint(git3, root, identity, statusBase, patchBase, pat
21350
21617
  } catch (error) {
21351
21618
  throw new CodingWorkspaceError("workspace_unsupported", { cause: error });
21352
21619
  }
21353
- const parent = await mkdtemp3(join32(tmpdir7(), "mikka-git-restore-"));
21354
- const worktree = join32(parent, "wt"), patchFile = join32(parent, "checkpoint.patch");
21620
+ const parent = await mkdtemp3(join33(tmpdir7(), "mikka-git-restore-"));
21621
+ const worktree = join33(parent, "wt"), patchFile = join33(parent, "checkpoint.patch");
21355
21622
  try {
21356
- await writeFile4(patchFile, patch, { mode: 384 });
21623
+ await writeFile5(patchFile, patch, { mode: 384 });
21357
21624
  await runGit(git3.commonDir, ["worktree", "add", "--detach", "--quiet", worktree, head], commonEnv(git3), signal);
21358
21625
  let applied = true;
21359
21626
  try {
@@ -21429,7 +21696,7 @@ async function dryRunCheckpoint(git3, root, identity, statusBase, patchBase, pat
21429
21696
  await runGit(git3.commonDir, ["worktree", "remove", "--force", worktree], commonEnv(git3), AbortSignal.timeout(5e3));
21430
21697
  } catch {
21431
21698
  }
21432
- await rm4(parent, { recursive: true, force: true });
21699
+ await rm5(parent, { recursive: true, force: true });
21433
21700
  }
21434
21701
  }
21435
21702
  function checkpointVersion(request2, plan) {
@@ -21631,9 +21898,9 @@ async function handleWorkspaceGitRequest(command, entry, repoPath) {
21631
21898
  }
21632
21899
 
21633
21900
  // src/repositories.ts
21634
- import { createHash as createHash16, randomUUID as randomUUID7 } from "node:crypto";
21901
+ import { createHash as createHash17, randomUUID as randomUUID7 } from "node:crypto";
21635
21902
  import { existsSync as existsSync7, lstatSync as lstatSync12, mkdirSync as mkdirSync17, readdirSync as readdirSync9, realpathSync as realpathSync13, renameSync as renameSync5, rmSync as rmSync20 } from "node:fs";
21636
- import { dirname as dirname16, join as join33, resolve as resolve17 } from "node:path";
21903
+ import { dirname as dirname17, join as join34, resolve as resolve18 } from "node:path";
21637
21904
  import { setTimeout as delay } from "node:timers/promises";
21638
21905
  import { execa as execa15 } from "execa";
21639
21906
  import lockfile2 from "proper-lockfile";
@@ -21657,8 +21924,8 @@ var RepositoryCache = class {
21657
21924
  retainResources;
21658
21925
  pathFor(remoteUrl) {
21659
21926
  const { key: key2 } = normalizeRepository(remoteUrl, { allowFile: this.allowFile });
21660
- const path3 = resolve17(this.root, "v2", createHash16("sha256").update(key2).digest("hex"));
21661
- if (!isInside(resolve17(this.root), path3) || path3 === resolve17(this.root)) throw new Error("Invalid repository cache path");
21927
+ const path3 = resolve18(this.root, "v2", createHash17("sha256").update(key2).digest("hex"));
21928
+ if (!isInside(resolve18(this.root), path3) || path3 === resolve18(this.root)) throw new Error("Invalid repository cache path");
21662
21929
  return path3;
21663
21930
  }
21664
21931
  /** Serialize clone/fetch against the same cache, including other processes. */
@@ -21666,7 +21933,7 @@ var RepositoryCache = class {
21666
21933
  signal?.throwIfAborted();
21667
21934
  const { remoteUrl: remote } = normalizeRepository(remoteUrl, { allowFile: this.allowFile });
21668
21935
  const path3 = this.pathFor(remote);
21669
- this.ensureParents(dirname16(path3));
21936
+ this.ensureParents(dirname17(path3));
21670
21937
  const release = await this.lock(path3, signal);
21671
21938
  try {
21672
21939
  return await withRepoConfig(path3, () => this.update(path3, remote, signal, env, diagnostics));
@@ -21705,7 +21972,7 @@ var RepositoryCache = class {
21705
21972
  } else {
21706
21973
  this.assertClone(path3);
21707
21974
  await git3(["remote", "set-url", "origin", remote], path3);
21708
- const depth = existsSync7(join33(path3, ".git", "shallow")) ? ["--depth=50"] : [];
21975
+ const depth = existsSync7(join34(path3, ".git", "shallow")) ? ["--depth=50"] : [];
21709
21976
  await git3(["fetch", ...depth, ...this.retainResources ? [] : ["--prune"], "--no-tags", "--no-recurse-submodules", "--no-write-fetch-head", "origin"], path3);
21710
21977
  }
21711
21978
  this.assertClone(path3);
@@ -21797,28 +22064,28 @@ var RepositoryCache = class {
21797
22064
  paths() {
21798
22065
  const visit = (path3) => {
21799
22066
  if (!existsSync7(path3) || lstatSync12(path3).isSymbolicLink()) return [];
21800
- if (existsSync7(join33(path3, ".git"))) {
22067
+ if (existsSync7(join34(path3, ".git"))) {
21801
22068
  this.assertClone(path3);
21802
22069
  return [path3];
21803
22070
  }
21804
- return readdirSync9(path3, { withFileTypes: true }).flatMap((entry) => entry.isDirectory() && !entry.name.endsWith(".lock") && !entry.name.includes(".clone-") ? visit(join33(path3, entry.name)) : []);
22071
+ return readdirSync9(path3, { withFileTypes: true }).flatMap((entry) => entry.isDirectory() && !entry.name.endsWith(".lock") && !entry.name.includes(".clone-") ? visit(join34(path3, entry.name)) : []);
21805
22072
  };
21806
- return visit(resolve17(this.root));
22073
+ return visit(resolve18(this.root));
21807
22074
  }
21808
22075
  ensureParents(path3) {
21809
22076
  mkdirSync17(this.root, { recursive: true, mode: 448 });
21810
22077
  if (lstatSync12(this.root).isSymbolicLink()) throw new Error("Repository cache contains a symlink");
21811
22078
  const root = realpathSync13(this.root);
21812
- let current = resolve17(this.root);
22079
+ let current = resolve18(this.root);
21813
22080
  for (const part of path3.slice(current.length + 1).split("/").filter(Boolean)) {
21814
- current = join33(current, part);
22081
+ current = join34(current, part);
21815
22082
  if (existsSync7(current) && lstatSync12(current).isSymbolicLink()) throw new Error("Repository cache contains a symlink");
21816
22083
  mkdirSync17(current, { recursive: true, mode: 448 });
21817
22084
  if (!isInside(root, realpathSync13(current))) throw new Error("Repository cache escapes its directory");
21818
22085
  }
21819
22086
  }
21820
22087
  assertClone(path3) {
21821
- if (lstatSync12(path3).isSymbolicLink() || !lstatSync12(join33(path3, ".git")).isDirectory() || lstatSync12(join33(path3, ".git")).isSymbolicLink()) throw new Error("Repository cache is not a standard clone");
22088
+ if (lstatSync12(path3).isSymbolicLink() || !lstatSync12(join34(path3, ".git")).isDirectory() || lstatSync12(join34(path3, ".git")).isSymbolicLink()) throw new Error("Repository cache is not a standard clone");
21822
22089
  if (!isInside(realpathSync13(this.root), realpathSync13(path3))) throw new Error("Repository cache escapes its directory");
21823
22090
  }
21824
22091
  async lock(path3, signal) {
@@ -21924,11 +22191,11 @@ async function prepareRunRepository(repositories, privateDir, assignment, signal
21924
22191
  import { randomUUID as randomUUID8 } from "node:crypto";
21925
22192
  import { spawn as spawn5 } from "node:child_process";
21926
22193
  import { existsSync as existsSync8, mkdirSync as mkdirSync18, realpathSync as realpathSync14 } from "node:fs";
21927
- import { dirname as dirname17, join as join34, resolve as resolve18 } from "node:path";
22194
+ import { dirname as dirname18, join as join35, resolve as resolve19 } from "node:path";
21928
22195
  import { fileURLToPath } from "node:url";
21929
22196
 
21930
22197
  // src/official-cli-timing.ts
21931
- import { createHash as createHash17, randomBytes as randomBytes4 } from "node:crypto";
22198
+ import { createHash as createHash18, randomBytes as randomBytes4 } from "node:crypto";
21932
22199
  import { createServer as createServer4 } from "node:http";
21933
22200
 
21934
22201
  // src/mcp-http-timing.ts
@@ -22252,7 +22519,7 @@ var OfficialCliTimingCollector = class {
22252
22519
  };
22253
22520
  async function startCliTimingCollector({ runId, harness, remoteMcpServerCount, decisionCatalogue }) {
22254
22521
  const collector = new OfficialCliTimingCollector(runId, harness);
22255
- const expectedCatalogueSha256 = decisionCatalogue ? createHash17("sha256").update(JSON.stringify(decisionCatalogue)).digest("hex") : null;
22522
+ const expectedCatalogueSha256 = decisionCatalogue ? createHash18("sha256").update(JSON.stringify(decisionCatalogue)).digest("hex") : null;
22256
22523
  const mcpCollector = new McpHttpTimingCollector(runId, harness, remoteMcpServerCount, Date.now, expectedCatalogueSha256);
22257
22524
  const path3 = `/v1/logs/${randomBytes4(16).toString("hex")}`;
22258
22525
  const mcpPath = `/v1/mcp-http/${randomBytes4(16).toString("hex")}`;
@@ -22293,11 +22560,11 @@ async function startCliTimingCollector({ runId, harness, remoteMcpServerCount, d
22293
22560
  server.requestTimeout = 5e3;
22294
22561
  server.headersTimeout = 5e3;
22295
22562
  server.maxConnections = 8;
22296
- await new Promise((resolve19, reject) => {
22563
+ await new Promise((resolve20, reject) => {
22297
22564
  server.once("error", reject);
22298
22565
  server.listen(0, "127.0.0.1", () => {
22299
22566
  server.off("error", reject);
22300
- resolve19();
22567
+ resolve20();
22301
22568
  });
22302
22569
  });
22303
22570
  server.on("error", () => {
@@ -22346,7 +22613,7 @@ async function startCliTimingCollector({ runId, harness, remoteMcpServerCount, d
22346
22613
  unsetEnv,
22347
22614
  mcpHttpObservationUrl: `${origin}${mcpPath}`,
22348
22615
  close: ({ cliExitObserved = false, publish = true } = {}) => closed ??= (async () => {
22349
- await new Promise((resolve19) => {
22616
+ await new Promise((resolve20) => {
22350
22617
  const timer = setTimeout(() => {
22351
22618
  collector.truncate();
22352
22619
  mcpCollector.truncate();
@@ -22354,7 +22621,7 @@ async function startCliTimingCollector({ runId, harness, remoteMcpServerCount, d
22354
22621
  }, 1e3);
22355
22622
  server.close(() => {
22356
22623
  clearTimeout(timer);
22357
- resolve19();
22624
+ resolve20();
22358
22625
  });
22359
22626
  });
22360
22627
  const official = collector.finish(cliExitObserved), mcp = mcpCollector.finish();
@@ -22392,7 +22659,7 @@ async function runHostedCommand(worktree, script, _readOnly, timeoutMs, signal)
22392
22659
  abort();
22393
22660
  } else chunks.push(chunk);
22394
22661
  };
22395
- const result = await new Promise((resolve19, reject) => {
22662
+ const result = await new Promise((resolve20, reject) => {
22396
22663
  child = spawn5("/bin/sh", ["-c", script], {
22397
22664
  cwd: realpathSync14(worktree),
22398
22665
  env: process.env,
@@ -22402,7 +22669,7 @@ async function runHostedCommand(worktree, script, _readOnly, timeoutMs, signal)
22402
22669
  child.stdout?.on("data", (chunk) => collect("stdout", stdout, chunk));
22403
22670
  child.stderr?.on("data", (chunk) => collect("stderr", stderr, chunk));
22404
22671
  child.once("error", reject);
22405
- child.once("close", (code, term) => resolve19({ code, signal: term }));
22672
+ child.once("close", (code, term) => resolve20({ code, signal: term }));
22406
22673
  child.once("exit", abort);
22407
22674
  signal?.addEventListener("abort", abort, { once: true });
22408
22675
  if (signal?.aborted) abort();
@@ -22528,7 +22795,7 @@ async function createHostedBotRunner(host) {
22528
22795
  if (selected && (!options.model || options.model !== subscription?.first.modelId)) throw Error("binding_mismatch");
22529
22796
  const paths = runPaths(host.stateDir, assignment.runId);
22530
22797
  mkdirSync18(paths.runDir, { recursive: true, mode: 448 });
22531
- const cwd = preparation ? resolve18(options.cwd) : realpathSync14(options.cwd);
22798
+ const cwd = preparation ? resolve19(options.cwd) : realpathSync14(options.cwd);
22532
22799
  const env = Object.fromEntries(Object.entries({ ...process.env, ...options.env, ...assignment.taskEnv }).filter((entry) => typeof entry[1] === "string"));
22533
22800
  if (runDiagnosticsEnabled(assignment.taskEnv, host.collectCliTiming)) env.CLOUD_STARTUP_TIMING = "1";
22534
22801
  const selectedGithub = options.github ?? (assignment.github ? { ...assignment.github, issueId: assignment.issueId, runToken: assignment.mcp?.token } : void 0);
@@ -22559,7 +22826,7 @@ async function createHostedBotRunner(host) {
22559
22826
  });
22560
22827
  Object.assign(env, github.env);
22561
22828
  }
22562
- const ledger = join34(host.stateDir, "native-ledgers", assignment.runId + ".json");
22829
+ const ledger = join35(host.stateDir, "native-ledgers", assignment.runId + ".json");
22563
22830
  const scope = selected && subscription ? {
22564
22831
  runId: assignment.runId,
22565
22832
  bindingId: selected.bindingId,
@@ -22572,12 +22839,12 @@ async function createHostedBotRunner(host) {
22572
22839
  modelId: subscription.first.modelId
22573
22840
  } : void 0;
22574
22841
  if (continuation && existsSync8(ledger)) throw unavailable5("ledger_mismatch");
22575
- const previousLedger = continuation ? join34(host.stateDir, "native-ledgers", continuation.runId + ".json") : ledger;
22842
+ const previousLedger = continuation ? join35(host.stateDir, "native-ledgers", continuation.runId + ".json") : ledger;
22576
22843
  const previous = scope ? readJson(previousLedger) : void 0;
22577
22844
  if (preparation && previous) throw unavailable5("ledger_mismatch");
22578
22845
  const expectedScope = scope && continuation ? { ...scope, runId: continuation.runId } : scope;
22579
22846
  if (scope && (existsSync8(previousLedger) && (!previous || JSON.stringify(previous.scope) !== JSON.stringify(expectedScope) || typeof previous.sessionId !== "string") || assignment.requireSessionResume && (!previous || previous.sessionId !== assignment.resumeSessionId))) throw unavailable5("ledger_mismatch");
22580
- if (scope) mkdirSync18(dirname17(ledger), { recursive: true, mode: 448 });
22847
+ if (scope) mkdirSync18(dirname18(ledger), { recursive: true, mode: 448 });
22581
22848
  const record3 = async (sessionId) => {
22582
22849
  assertOpen();
22583
22850
  if (scope) writeJsonAtomic(ledger, { scope, sessionId });
@@ -22649,9 +22916,9 @@ async function createHostedBotRunner(host) {
22649
22916
  signal: lifetime.signal
22650
22917
  });
22651
22918
  child.stderr?.resume();
22652
- const exited = new Promise((resolve19) => {
22653
- child.once("exit", (code, signal) => resolve19({ code, signal }));
22654
- child.once("error", () => resolve19({ code: null, signal: null }));
22919
+ const exited = new Promise((resolve20) => {
22920
+ child.once("exit", (code, signal) => resolve20({ code, signal }));
22921
+ child.once("error", () => resolve20({ code: null, signal: null }));
22655
22922
  });
22656
22923
  return {
22657
22924
  process: child,
@@ -22838,7 +23105,7 @@ async function createHostedBotRunner(host) {
22838
23105
  import {
22839
23106
  randomBytes as randomBytes5,
22840
23107
  randomUUID as randomUUID9,
22841
- createHash as createHash19,
23108
+ createHash as createHash20,
22842
23109
  timingSafeEqual as timingSafeEqual2
22843
23110
  } from "node:crypto";
22844
23111
  import { chmodSync as chmodSync2 } from "node:fs";
@@ -22848,8 +23115,8 @@ import { createServer as createServer5 } from "node:net";
22848
23115
  import { spawn as spawn6 } from "node:child_process";
22849
23116
  import { execFile as execFile8 } from "node:child_process";
22850
23117
  import { promisify as promisify8 } from "node:util";
22851
- import { createHash as createHash18 } from "node:crypto";
22852
- import { readFile as readFile7, realpath as realpath5 } from "node:fs/promises";
23118
+ import { createHash as createHash19 } from "node:crypto";
23119
+ import { readFile as readFile8, realpath as realpath5 } from "node:fs/promises";
22853
23120
  import { createInterface } from "node:readline";
22854
23121
  var exec3 = promisify8(execFile8);
22855
23122
  async function detectComputerDriver(binary = "cua-driver") {
@@ -22865,7 +23132,7 @@ async function detectComputerDriver(binary = "cua-driver") {
22865
23132
  installed: true,
22866
23133
  version,
22867
23134
  path: path3,
22868
- fingerprint: createHash18("sha256").update(await readFile7(path3)).digest("hex")
23135
+ fingerprint: createHash19("sha256").update(await readFile8(path3)).digest("hex")
22869
23136
  };
22870
23137
  } catch {
22871
23138
  return null;
@@ -22932,7 +23199,7 @@ async function executeDriver(driver, input, display, leaseGuard, assertLive = ()
22932
23199
  if (display !== void 0 && !/^:[1-9][0-9]{0,3}$/.test(display))
22933
23200
  throw new Error("Invalid desktop display");
22934
23201
  const call = normalizeCall(input);
22935
- const fingerprint2 = createHash18("sha256").update(await readFile7(driver.path)).digest("hex");
23202
+ const fingerprint2 = createHash19("sha256").update(await readFile8(driver.path)).digest("hex");
22936
23203
  if (fingerprint2 !== driver.fingerprint)
22937
23204
  throw new Error("Driver changed; restart and approve a new request");
22938
23205
  const args = driverArguments(call);
@@ -22995,9 +23262,9 @@ async function executeDriver(driver, input, display, leaseGuard, assertLive = ()
22995
23262
  )
22996
23263
  )
22997
23264
  );
22998
- const request2 = (method, params) => new Promise((resolve19, reject) => {
23265
+ const request2 = (method, params) => new Promise((resolve20, reject) => {
22999
23266
  const n = ++id5;
23000
- pending.set(n, { resolve: resolve19, reject });
23267
+ pending.set(n, { resolve: resolve20, reject });
23001
23268
  child.stdin.write(
23002
23269
  JSON.stringify({ jsonrpc: "2.0", id: n, method, params }) + "\n"
23003
23270
  );
@@ -23139,10 +23406,10 @@ var ComputerBroker = class {
23139
23406
  })();
23140
23407
  });
23141
23408
  });
23142
- await new Promise((resolve19, reject) => {
23409
+ await new Promise((resolve20, reject) => {
23143
23410
  this.server.once("error", reject);
23144
- if (this.transport === "tcp") this.server.listen({ host: "127.0.0.1", port: 0 }, resolve19);
23145
- else this.server.listen(this.socketPath, resolve19);
23411
+ if (this.transport === "tcp") this.server.listen({ host: "127.0.0.1", port: 0 }, resolve20);
23412
+ else this.server.listen(this.socketPath, resolve20);
23146
23413
  });
23147
23414
  if (this.transport === "tcp") this.socketPath = `tcp://127.0.0.1:${this.server.address().port}`;
23148
23415
  else chmodSync2(this.socketPath, 384);
@@ -23227,8 +23494,8 @@ var ComputerBroker = class {
23227
23494
  call,
23228
23495
  expiresAt: this.now() + this.ttl
23229
23496
  };
23230
- const digest9 = createHash19("sha256").update(JSON.stringify(request2)).digest("hex");
23231
- return new Promise((resolve19, reject) => {
23497
+ const digest9 = createHash20("sha256").update(JSON.stringify(request2)).digest("hex");
23498
+ return new Promise((resolve20, reject) => {
23232
23499
  const timer = setTimeout(() => {
23233
23500
  this.pending.delete(request2.id);
23234
23501
  signal?.removeEventListener("abort", cancel);
@@ -23246,7 +23513,7 @@ var ComputerBroker = class {
23246
23513
  assertLive,
23247
23514
  cleanup: () => signal?.removeEventListener("abort", cancel),
23248
23515
  request: { ...request2, digest: digest9 },
23249
- resolve: resolve19,
23516
+ resolve: resolve20,
23250
23517
  reject,
23251
23518
  timer
23252
23519
  });
@@ -23339,15 +23606,15 @@ var ComputerBroker = class {
23339
23606
  async close() {
23340
23607
  this.suspend();
23341
23608
  for (const socket of this.sockets) socket.destroy();
23342
- if (this.server?.listening) await new Promise((resolve19) => this.server.close(resolve19));
23609
+ if (this.server?.listening) await new Promise((resolve20) => this.server.close(resolve20));
23343
23610
  }
23344
23611
  };
23345
23612
 
23346
23613
  // src/computer/credential-executor.ts
23347
- import { createHash as createHash20 } from "node:crypto";
23614
+ import { createHash as createHash21 } from "node:crypto";
23348
23615
  function credentialAwareExecutor(deps) {
23349
23616
  return async (driver, call, display, runId, context) => {
23350
- const digest9 = createHash20("sha256").update(JSON.stringify(call)).digest("hex");
23617
+ const digest9 = createHash21("sha256").update(JSON.stringify(call)).digest("hex");
23351
23618
  const resolved = await deps.consumeMatchingIntent(runId, context.actionId, digest9);
23352
23619
  context.assertLive();
23353
23620
  if (resolved.kind === "ordinary") return deps.executeOrdinary(driver, call, display, runId, context.assertLive);
@@ -23444,8 +23711,8 @@ async function followWebComputerReviews(broker, deviceId, link, signal, pushes,
23444
23711
  changed = false;
23445
23712
  }
23446
23713
  if (signal.aborted) break;
23447
- await new Promise((resolve19) => {
23448
- wake = resolve19;
23714
+ await new Promise((resolve20) => {
23715
+ wake = resolve20;
23449
23716
  if (signal.aborted) nudge();
23450
23717
  });
23451
23718
  }
@@ -23629,7 +23896,7 @@ var Daemon = class {
23629
23896
  if (this.options.credential)
23630
23897
  this.saveDevice({ credential: this.options.credential });
23631
23898
  this.journal = new RunJournal(paths.journal);
23632
- this.captureUploader = new CaptureUploader((runId) => join35(runPaths(paths.adapterState, runId).runDir, CAPTURES_DIR), this.options.link, this.log, join35(paths.dataDir, "capture-pending"));
23899
+ this.captureUploader = new CaptureUploader((runId) => join36(runPaths(paths.adapterState, runId).runDir, CAPTURES_DIR), this.options.link, this.log, join36(paths.dataDir, "capture-pending"));
23633
23900
  this.outbox = new Outbox(
23634
23901
  paths.outbox,
23635
23902
  this.options.link,
@@ -23648,7 +23915,7 @@ var Daemon = class {
23648
23915
  if (this.localComputerDriver && this.options.link.syncComputerReviews) {
23649
23916
  this.localComputerBroker = new ComputerBroker({
23650
23917
  driver: this.localComputerDriver,
23651
- socketPath: join35(paths.dataDir, "local-computer.sock"),
23918
+ socketPath: join36(paths.dataDir, "local-computer.sock"),
23652
23919
  transport: "tcp",
23653
23920
  needsPerson: this.computerNeedsPerson(),
23654
23921
  permitted: (runId) => {
@@ -23691,7 +23958,7 @@ var Daemon = class {
23691
23958
  };
23692
23959
  this.cloudComputerBroker = new ComputerBroker({
23693
23960
  driver,
23694
- socketPath: join35(paths.dataDir, "computer.sock"),
23961
+ socketPath: join36(paths.dataDir, "computer.sock"),
23695
23962
  needsPerson: this.computerNeedsPerson(),
23696
23963
  permitted: (runId) => {
23697
23964
  const entry = this.journal.get(runId);
@@ -23783,9 +24050,10 @@ var Daemon = class {
23783
24050
  startCredential: hosted?.start,
23784
24051
  prepareSubscription: hosted?.prepare,
23785
24052
  prepareRunMailbox: this.options.link.prepareRunMailbox?.bind(this.options.link),
24053
+ prepareRunDrive: this.options.link.prepareRunDrive?.bind(this.options.link),
23786
24054
  prepareRunToolApproval: this.options.link.prepareRunToolApproval?.bind(this.options.link),
23787
24055
  prepareRunGitHub: hosted ? void 0 : (assignment, signal, onCredential) => prepareLocalGitHub(assignment, {
23788
- stateDir: join35(this.paths.adapterState, "github"),
24056
+ stateDir: join36(this.paths.adapterState, "github"),
23789
24057
  link: this.options.link,
23790
24058
  signal,
23791
24059
  onCredential,
@@ -23855,7 +24123,7 @@ var Daemon = class {
23855
24123
  worktree,
23856
24124
  tree,
23857
24125
  github: { ...assignment.github, runToken: assignment.mcp?.token, issueId: assignment.issueId },
23858
- privateDir: join35(paths.adapterState, "pids"),
24126
+ privateDir: join36(paths.adapterState, "pids"),
23859
24127
  ...hosted ? { hosted: true } : {},
23860
24128
  env: hosted ? process.env : githubReceiptEnvironment(),
23861
24129
  githubEnvironment,
@@ -23968,11 +24236,11 @@ var Daemon = class {
23968
24236
  async sessionTicket(signal) {
23969
24237
  while (!this.device.credential) {
23970
24238
  this.server = "unregistered";
23971
- await new Promise((resolve19) => {
24239
+ await new Promise((resolve20) => {
23972
24240
  const done = () => {
23973
24241
  this.credentialArrived.delete(done);
23974
24242
  signal.removeEventListener("abort", done);
23975
- resolve19();
24243
+ resolve20();
23976
24244
  };
23977
24245
  this.credentialArrived.add(done);
23978
24246
  signal.addEventListener("abort", done, { once: true });
@@ -24570,11 +24838,11 @@ var Daemon = class {
24570
24838
  return runVerify(sandbox, {
24571
24839
  command,
24572
24840
  worktree: realpathSync15(worktree),
24573
- tmpRoot: join35(this.paths.adapterState, "verify", runId),
24841
+ tmpRoot: join36(this.paths.adapterState, "verify", runId),
24574
24842
  privateDir: paths.privateDir,
24575
24843
  pidFile: paths.pidFile.replace(/\.pgid$/, ".verify.pgid"),
24576
24844
  networkAllow: repo.networkAllow,
24577
- env: { ...buildChildEnv(), ...githubEnvironment, MIKKA_HANDOFF_FILE: join35(paths.runDir, "handoff.json") },
24845
+ env: { ...buildChildEnv(), ...githubEnvironment, MIKKA_HANDOFF_FILE: join36(paths.runDir, "handoff.json") },
24578
24846
  timeoutMs,
24579
24847
  signal,
24580
24848
  readOnly
@@ -24726,14 +24994,14 @@ var Daemon = class {
24726
24994
  }
24727
24995
  const initialRunId = this.initialRunHint;
24728
24996
  let resolveRepositories, rejectRepositories;
24729
- const repositoriesReady = initialRunId ? new Promise((resolve19, reject) => {
24730
- resolveRepositories = resolve19;
24997
+ const repositoriesReady = initialRunId ? new Promise((resolve20, reject) => {
24998
+ resolveRepositories = resolve20;
24731
24999
  rejectRepositories = reject;
24732
25000
  }) : void 0;
24733
25001
  if (initialRunId && repositoriesReady) {
24734
25002
  let received;
24735
- const repository2 = this.options.hostedSubscriptions && this.options.e2bContainerRuntime && this.journal.all().length === 0 ? new Promise((resolve19) => {
24736
- received = resolve19;
25003
+ const repository2 = this.options.hostedSubscriptions && this.options.e2bContainerRuntime && this.journal.all().length === 0 ? new Promise((resolve20) => {
25004
+ received = resolve20;
24737
25005
  }) : void 0;
24738
25006
  this.initialRepositorySync = { runId: initialRunId, ready: repositoriesReady, repository: repository2, received };
24739
25007
  void repositoriesReady.catch(() => void 0);
@@ -25129,7 +25397,7 @@ var Daemon = class {
25129
25397
  });
25130
25398
  }
25131
25399
  get updateStateFile() {
25132
- return join35(this.paths.dataDir, "auto-update.json");
25400
+ return join36(this.paths.dataDir, "auto-update.json");
25133
25401
  }
25134
25402
  /** A server named this release (a report answer, a commands read, a 426), or npm did for a refused daemon. */
25135
25403
  learnRelease(latest) {
@@ -25234,7 +25502,7 @@ function isNoDaemon(error) {
25234
25502
  }
25235
25503
  async function connectDaemon(options) {
25236
25504
  const socket = connect(options.socketPath);
25237
- await new Promise((resolve19, reject) => {
25505
+ await new Promise((resolve20, reject) => {
25238
25506
  const timer = setTimeout(() => {
25239
25507
  socket.destroy();
25240
25508
  reject(
@@ -25245,7 +25513,7 @@ async function connectDaemon(options) {
25245
25513
  }, options.timeoutMs ?? 3e3);
25246
25514
  socket.once("connect", () => {
25247
25515
  clearTimeout(timer);
25248
- resolve19();
25516
+ resolve20();
25249
25517
  });
25250
25518
  socket.once("error", (error) => {
25251
25519
  clearTimeout(timer);
@@ -25282,9 +25550,9 @@ async function connectDaemon(options) {
25282
25550
  if (isProtocolMismatch(error) && options.drainOnMismatch) {
25283
25551
  await Promise.race([
25284
25552
  connection.sendRequest("daemon.drain", {}).catch(() => void 0),
25285
- new Promise((resolve19) => {
25286
- connection.onClose(resolve19);
25287
- setTimeout(resolve19, 2e3).unref();
25553
+ new Promise((resolve20) => {
25554
+ connection.onClose(resolve20);
25555
+ setTimeout(resolve20, 2e3).unref();
25288
25556
  })
25289
25557
  ]);
25290
25558
  }
@@ -25343,8 +25611,8 @@ async function connectStartingDaemon(dataDir) {
25343
25611
  }
25344
25612
  if (!daemonProcessAlive(dataDir)) return void 0;
25345
25613
  if (revision2 !== before) continue;
25346
- await new Promise((resolve19) => {
25347
- wake = resolve19;
25614
+ await new Promise((resolve20) => {
25615
+ wake = resolve20;
25348
25616
  });
25349
25617
  wake = void 0;
25350
25618
  }