@aspectlylabs/mikka 0.0.648 → 0.0.652

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/main.js CHANGED
@@ -878,10 +878,10 @@ var require_truncate = __commonJS({
878
878
  "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/truncate.js"(exports, module) {
879
879
  "use strict";
880
880
  var parse2 = require_parse();
881
- var constants9 = require_constants();
881
+ var constants10 = require_constants();
882
882
  var SemVer = require_semver();
883
883
  var truncate = (version, truncation, options) => {
884
- if (!constants9.RELEASE_TYPES.includes(truncation)) {
884
+ if (!constants10.RELEASE_TYPES.includes(truncation)) {
885
885
  return null;
886
886
  }
887
887
  const clonedVersion = cloneInputVersion(version, options);
@@ -1930,7 +1930,7 @@ var require_semver2 = __commonJS({
1930
1930
  "../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/index.js"(exports, module) {
1931
1931
  "use strict";
1932
1932
  var internalRe = require_re();
1933
- var constants9 = require_constants();
1933
+ var constants10 = require_constants();
1934
1934
  var SemVer = require_semver();
1935
1935
  var identifiers = require_identifiers();
1936
1936
  var parse2 = require_parse();
@@ -2014,8 +2014,8 @@ var require_semver2 = __commonJS({
2014
2014
  re: internalRe.re,
2015
2015
  src: internalRe.src,
2016
2016
  tokens: internalRe.t,
2017
- SEMVER_SPEC_VERSION: constants9.SEMVER_SPEC_VERSION,
2018
- RELEASE_TYPES: constants9.RELEASE_TYPES,
2017
+ SEMVER_SPEC_VERSION: constants10.SEMVER_SPEC_VERSION,
2018
+ RELEASE_TYPES: constants10.RELEASE_TYPES,
2019
2019
  compareIdentifiers: identifiers.compareIdentifiers,
2020
2020
  rcompareIdentifiers: identifiers.rcompareIdentifiers
2021
2021
  };
@@ -2077,6 +2077,24 @@ function logCodedError(error, fields = {}, log = consoleCodedErrorLog) {
2077
2077
 
2078
2078
  // ../protocol/src/user-error-codes.ts
2079
2079
  var USER_ERROR_CODES = {
2080
+ review_auth_required: [],
2081
+ review_not_found: [],
2082
+ not_owner_terminal: [],
2083
+ review_machine_gone: [],
2084
+ review_binding_changed: [],
2085
+ review_checkout_unavailable: [],
2086
+ review_preview_unavailable: ["configuration", "runtime", "protocol", "scope_changed", "limit"],
2087
+ terminal_unsupported: ["local_device", "runtime_version"],
2088
+ terminal_already_controlled: [],
2089
+ terminal_binding_changed: [],
2090
+ terminal_ended: [],
2091
+ terminal_input_too_large: [],
2092
+ terminal_invalid_request: [],
2093
+ terminal_request_conflict: [],
2094
+ terminal_input_uncertain: [],
2095
+ terminal_limit: [],
2096
+ terminal_unavailable: ["configuration", "runtime", "protocol", "installation", "lease"],
2097
+ terminal_control_unavailable: ["fence_unavailable", "fence_lost"],
2080
2098
  review_scope_denied: ["sponsored_placement"],
2081
2099
  workspace_not_found: [],
2082
2100
  workspace_snapshot_unavailable: [],
@@ -2160,6 +2178,8 @@ var USER_ERROR_CODES = {
2160
2178
  web_auth_exchange_rejected: [],
2161
2179
  web_auth_session_expired: [],
2162
2180
  factory_spec_approval_required: [],
2181
+ factory_visual_evidence_required: [],
2182
+ factory_public_evidence_required: [],
2163
2183
  map_invalid_request: ["invalid_query", "invalid_token"],
2164
2184
  map_not_found: [],
2165
2185
  map_snapshot_changed: ["source_changed"],
@@ -2632,7 +2652,7 @@ import {
2632
2652
  realpathSync as realpathSync15
2633
2653
  } from "node:fs";
2634
2654
  import { arch as arch2, hostname, platform as platform3 } from "node:os";
2635
- import { join as join35 } from "node:path";
2655
+ import { join as join36 } from "node:path";
2636
2656
  import { fileURLToPath as fileURLToPath2 } from "node:url";
2637
2657
 
2638
2658
  // ../protocol/src/accounts.ts
@@ -3157,6 +3177,7 @@ var harnessInfoSchema = z8.object({
3157
3177
  computerBroker: z8.literal(true).optional(),
3158
3178
  /** Run-scoped CLI approvals and policy-version checks are supported. */
3159
3179
  toolApproval: z8.literal(true).optional(),
3180
+ activeTurnSteer: z8.literal(true).optional(),
3160
3181
  /**
3161
3182
  * The CLI exists but `installed` stays false because the daemon cannot run it
3162
3183
  * in a sandbox. `missing` names the absent packages; empty means the machine
@@ -3728,6 +3749,7 @@ var runSafePoint = z14.object({
3728
3749
  checkpoint: z14.enum(["ready", "unavailable"]),
3729
3750
  checkpointTakenAt: z14.iso.datetime({ offset: true }).optional()
3730
3751
  }).strict().refine((value) => value.checkpoint === "ready" ? value.checkpointTakenAt !== void 0 && Date.parse(value.observedAt) >= Date.parse(value.checkpointTakenAt) : value.checkpointTakenAt === void 0, { message: "A ready final checkpoint requires its acknowledged snapshot time" });
3752
+ var runVisualEvidence = z14.array(z14.object({ captureId: z14.uuid(), publicSafe: z14.literal(true) }).strict()).max(40);
3731
3753
  var runReport = z14.object({
3732
3754
  repositorySelection: runRepositorySelection.optional(),
3733
3755
  /** Worktree base journaled before the adapter started; never agent-supplied. */
@@ -3796,6 +3818,10 @@ var runReport = z14.object({
3796
3818
  previewDatabaseBranch: z14.string().trim().min(1).max(500).optional(),
3797
3819
  /** Acceptance criteria the agent checked, with evidence. */
3798
3820
  criteria: z14.array(runCriterion).max(200).optional(),
3821
+ /** Captures from this run whose full visible content was checked for public sharing.
3822
+ * This is an explicit content review, not an automatic pixel-redaction claim.
3823
+ * The server resolves capture ownership and creates the existing share URL. */
3824
+ visualEvidence: runVisualEvidence.optional(),
3799
3825
  /** A review completes once; this verdict never changes daemon-owned verification. */
3800
3826
  reviewVerdict: reviewVerdict.optional(),
3801
3827
  /**
@@ -5411,6 +5437,7 @@ var runCommandSchema = z24.discriminatedUnion("kind", [
5411
5437
  messageId: z24.uuid(),
5412
5438
  text: z24.string().min(1).max(1e5)
5413
5439
  }),
5440
+ z24.object({ kind: z24.literal("steer"), runId: id3, messageId: z24.uuid(), text: z24.string().min(1).max(1e5) }),
5414
5441
  z24.object({ kind: z24.literal("stop"), runId: id3 }),
5415
5442
  // A host notification carries addresses only; peer content remains behind
5416
5443
  // the authenticated mailbox read and retains its original provenance.
@@ -5432,7 +5459,8 @@ var runCommandsResponse = z24.object({
5432
5459
  deviceCommands: z24.array(deviceManagementCommand).max(1).optional().catch(void 0)
5433
5460
  });
5434
5461
  var runCommandsAck = z24.object({
5435
- delivered: z24.array(z24.uuid()).max(500)
5462
+ delivered: z24.array(z24.uuid()).max(500),
5463
+ refusedSteers: z24.array(z24.uuid()).max(500).optional()
5436
5464
  });
5437
5465
  var FS_REQUESTS_MAX_WAIT_SECONDS = 25;
5438
5466
  var FS_MAX_ENTRIES = 500;
@@ -6032,7 +6060,7 @@ import { join } from "node:path";
6032
6060
  // package.json
6033
6061
  var package_default = {
6034
6062
  name: "@mikka/daemon",
6035
- version: "0.0.648",
6063
+ version: "0.0.652",
6036
6064
  description: "Local Mikka daemon: runs agents through the user's own CLIs",
6037
6065
  type: "module",
6038
6066
  private: true,
@@ -6100,7 +6128,7 @@ var package_default = {
6100
6128
  engines: {
6101
6129
  node: ">=22"
6102
6130
  },
6103
- gitHead: "2e9c04daba44caec091c927f23b3cb825d9c4e23"
6131
+ gitHead: "69f071e0b39bad61cb617f495e04e7328cdd749e"
6104
6132
  };
6105
6133
 
6106
6134
  // src/paths.ts
@@ -6221,7 +6249,7 @@ function quotaStopApplies(assignment) {
6221
6249
  import { spawn as spawn2 } from "node:child_process";
6222
6250
  import { randomUUID as randomUUID2 } from "node:crypto";
6223
6251
  import { realpathSync as realpathSync9 } from "node:fs";
6224
- import { join as join10 } from "node:path";
6252
+ import { join as join11 } from "node:path";
6225
6253
 
6226
6254
  // src/tracing.ts
6227
6255
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -7076,8 +7104,8 @@ var DaemonTracer = class {
7076
7104
  let timer;
7077
7105
  await Promise.race([
7078
7106
  work,
7079
- new Promise((resolve19) => {
7080
- timer = setTimeout(resolve19, timeoutMs);
7107
+ new Promise((resolve20) => {
7108
+ timer = setTimeout(resolve20, timeoutMs);
7081
7109
  timer.unref();
7082
7110
  })
7083
7111
  ]).finally(() => {
@@ -7255,17 +7283,17 @@ var CodexGenerationMetrics = class {
7255
7283
  // src/adapters/claude-prewarm.ts
7256
7284
  import { randomUUID } from "node:crypto";
7257
7285
  import { realpathSync } from "node:fs";
7258
- function prepareAgentStart(signal, open4, diagnostics) {
7286
+ function prepareAgentStart(signal, open5, diagnostics) {
7259
7287
  const lifetime = new AbortController();
7260
7288
  let accept, refuse2;
7261
- const finalOptions = new Promise((resolve19, reject) => {
7262
- accept = resolve19;
7289
+ const finalOptions = new Promise((resolve20, reject) => {
7290
+ accept = resolve20;
7263
7291
  refuse2 = reject;
7264
7292
  });
7265
7293
  void finalOptions.catch(() => void 0);
7266
7294
  let parked, failed;
7267
- const ready = new Promise((resolve19, reject) => {
7268
- parked = resolve19;
7295
+ const ready = new Promise((resolve20, reject) => {
7296
+ parked = resolve20;
7269
7297
  failed = reject;
7270
7298
  });
7271
7299
  void ready.catch(() => void 0);
@@ -7274,7 +7302,7 @@ function prepareAgentStart(signal, open4, diagnostics) {
7274
7302
  const starting = Promise.resolve().then(() => {
7275
7303
  const work = () => {
7276
7304
  lifetime.signal.throwIfAborted();
7277
- return open4({ signal: lifetime.signal, finalOptions, parked });
7305
+ return open5({ signal: lifetime.signal, finalOptions, parked });
7278
7306
  };
7279
7307
  return diagnostics ? daemonTracer.preparation(
7280
7308
  { runIdHash: runIdHash(diagnostics.runId), harness: diagnostics.harness },
@@ -7348,8 +7376,8 @@ var ClaimedPromptQueue = class {
7348
7376
  while (!this.closed) {
7349
7377
  const item = this.items.shift();
7350
7378
  if (item) yield item;
7351
- else await new Promise((resolve19) => {
7352
- this.wake = resolve19;
7379
+ else await new Promise((resolve20) => {
7380
+ this.wake = resolve20;
7353
7381
  });
7354
7382
  }
7355
7383
  }
@@ -7793,6 +7821,14 @@ var SNAPSHOT_CREDENTIAL_GLOBS = [
7793
7821
  "/root/.git-credentials",
7794
7822
  // A Bot desktop's cached GitHub credential (lib/computer/desktop-github.ts).
7795
7823
  "/home/*/.mikka/github/token.json",
7824
+ // One-use bootstrap handoffs carry the same device credential. The worker
7825
+ // unlinks them after reading, but a pause may race an unconsumed handoff.
7826
+ // The daemon's own `device.json`/`daemon.secret` stay: they are the local
7827
+ // identity over a device token this machine revokes when it pauses, and
7828
+ // removing them would break a same-VM resume before that revocation.
7829
+ "/home/user/.mikka/bootstrap.json",
7830
+ "/home/user/.mikka/anonymous-claude.json",
7831
+ "/home/user/.mikka/anonymous-codex.json",
7796
7832
  ...runCredentialGlobs(CLOUD_WORKER_STATE_DIR)
7797
7833
  ];
7798
7834
 
@@ -7831,8 +7867,8 @@ function writeOwnFile(file, content) {
7831
7867
  writeFileSync(file, content, { flag: "wx", mode: 384 });
7832
7868
  }
7833
7869
  function ownDir(dir) {
7834
- const stat2 = lstatSync(dir, { throwIfNoEntry: false });
7835
- if (stat2 && !stat2.isDirectory()) rmSync(dir, { force: true });
7870
+ const stat3 = lstatSync(dir, { throwIfNoEntry: false });
7871
+ if (stat3 && !stat3.isDirectory()) rmSync(dir, { force: true });
7836
7872
  mkdirSync(dir, { recursive: true, mode: 448 });
7837
7873
  }
7838
7874
  function carryHistory(from, to, entries) {
@@ -7888,8 +7924,8 @@ var EventQueue = class {
7888
7924
  if (next.type === "exit") return;
7889
7925
  continue;
7890
7926
  }
7891
- await new Promise((resolve19) => {
7892
- this.waiter = resolve19;
7927
+ await new Promise((resolve20) => {
7928
+ this.waiter = resolve20;
7893
7929
  });
7894
7930
  }
7895
7931
  }
@@ -7966,13 +8002,13 @@ async function spawnCli(sandbox, argv, options) {
7966
8002
  stderr = (stderr + data).slice(-STDERR_TAIL * 4);
7967
8003
  });
7968
8004
  const exited = new Promise(
7969
- (resolve19) => {
8005
+ (resolve20) => {
7970
8006
  child.once("error", (error) => {
7971
8007
  stderr += `
7972
8008
  ${error.message}`;
7973
- resolve19({ code: null, signal: null });
8009
+ resolve20({ code: null, signal: null });
7974
8010
  });
7975
- child.once("exit", (code, signal) => resolve19({ code, signal }));
8011
+ child.once("exit", (code, signal) => resolve20({ code, signal }));
7976
8012
  }
7977
8013
  ).finally(() => {
7978
8014
  signalGroup(pgid, "SIGKILL");
@@ -7989,8 +8025,8 @@ ${error.message}`;
7989
8025
  let timer;
7990
8026
  await Promise.race([
7991
8027
  exited,
7992
- new Promise((resolve19) => {
7993
- timer = setTimeout(resolve19, graceMs);
8028
+ new Promise((resolve20) => {
8029
+ timer = setTimeout(resolve20, graceMs);
7994
8030
  })
7995
8031
  ]);
7996
8032
  clearTimeout(timer);
@@ -8566,13 +8602,13 @@ async function excludeVerifyArtifacts(repoPath) {
8566
8602
  });
8567
8603
  }
8568
8604
  async function du(path3) {
8569
- let stat2;
8605
+ let stat3;
8570
8606
  try {
8571
- stat2 = await lstat(path3);
8607
+ stat3 = await lstat(path3);
8572
8608
  } catch {
8573
8609
  return 0;
8574
8610
  }
8575
- if (!stat2.isDirectory()) return stat2.size;
8611
+ if (!stat3.isDirectory()) return stat3.size;
8576
8612
  let entries;
8577
8613
  try {
8578
8614
  entries = await readdir(path3);
@@ -9098,7 +9134,7 @@ function nativeMcpProcess(server) {
9098
9134
 
9099
9135
  // src/agents/run-context.ts
9100
9136
  import { execFileSync } from "node:child_process";
9101
- import { createHash as createHash6 } from "node:crypto";
9137
+ import { createHash as createHash7 } from "node:crypto";
9102
9138
  import {
9103
9139
  lstatSync as lstatSync8,
9104
9140
  mkdirSync as mkdirSync7,
@@ -9109,7 +9145,7 @@ import {
9109
9145
  writeFileSync as writeFileSync4
9110
9146
  } from "node:fs";
9111
9147
  import { homedir as homedir2 } from "node:os";
9112
- import { dirname as dirname7, join as join9, resolve as resolve7 } from "node:path";
9148
+ import { dirname as dirname8, join as join10, resolve as resolve8 } from "node:path";
9113
9149
 
9114
9150
  // src/agents/skill-artifact.ts
9115
9151
  import { createHash as createHash4 } from "node:crypto";
@@ -9259,9 +9295,10 @@ function classifyWrite(worktree, target) {
9259
9295
  }
9260
9296
 
9261
9297
  // src/captures.ts
9262
- import { createHash as createHash5 } from "node:crypto";
9263
- import { closeSync as closeSync2, constants as constants2, fstatSync, lstatSync as lstatSync7, mkdirSync as mkdirSync6, openSync as openSync2, readFileSync as readFileSync6, readdirSync as readdirSync4, rmSync as rmSync6 } from "node:fs";
9264
- import { join as join8 } from "node:path";
9298
+ import { createHash as createHash6 } from "node:crypto";
9299
+ import { closeSync as closeSync2, constants as constants3, createReadStream, fstatSync, lstatSync as lstatSync7, mkdirSync as mkdirSync6, mkdtempSync as mkdtempSync3, openSync as openSync2, readFileSync as readFileSync6, readSync, readdirSync as readdirSync4, rmSync as rmSync6 } from "node:fs";
9300
+ import { join as join9 } from "node:path";
9301
+ import { tmpdir as tmpdir3 } from "node:os";
9265
9302
 
9266
9303
  // ../protocol/src/capture.ts
9267
9304
  import { z as z32 } from "zod";
@@ -9279,6 +9316,7 @@ var CAPTURE_MAX_BYTES = {
9279
9316
  video: 1e8
9280
9317
  };
9281
9318
  var RECORDING_MAX_SECONDS = 300;
9319
+ var CAPTURE_MAX_DURATION_MS = 36e5;
9282
9320
  var CAPTURE_TITLE_MAX = 200;
9283
9321
  function captureKind(contentType) {
9284
9322
  return contentType.startsWith("video/") ? "video" : "image";
@@ -9309,14 +9347,31 @@ function cleanCaptureTitle(title2) {
9309
9347
  }
9310
9348
  var sha256 = z32.string().regex(/^[a-f0-9]{64}$/);
9311
9349
  var title = z32.string().trim().min(1).max(CAPTURE_TITLE_MAX);
9350
+ var recordingStep = z32.object({
9351
+ atMs: z32.number().int().min(0).max(CAPTURE_MAX_DURATION_MS),
9352
+ label: title,
9353
+ source: z32.enum(["action", "mark"]),
9354
+ durationMs: z32.number().int().min(0).max(CAPTURE_MAX_DURATION_MS).nullable().optional()
9355
+ }).strict().refine((step) => step.durationMs == null || step.source === "action" && step.durationMs <= step.atMs, {
9356
+ message: "An action duration must fit its recorded end offset."
9357
+ });
9312
9358
  var captureUploadRequest = z32.object({
9313
9359
  /** Stable client id, persisted before the first network attempt. */
9314
9360
  captureId: z32.uuid().optional(),
9315
9361
  title,
9316
9362
  contentType: z32.enum(CAPTURE_CONTENT_TYPES),
9317
9363
  size: z32.number().int().min(1).max(CAPTURE_MAX_BYTES.video),
9318
- sha256
9319
- }).strict();
9364
+ sha256,
9365
+ /** Final, processed video duration and its remapped timeline. */
9366
+ durationMs: z32.number().int().min(1).max(CAPTURE_MAX_DURATION_MS).optional(),
9367
+ steps: z32.array(recordingStep).max(200).optional()
9368
+ }).strict().superRefine((value, ctx) => {
9369
+ if (value.durationMs !== void 0 || value.steps !== void 0) {
9370
+ if (!value.contentType.startsWith("video/")) ctx.addIssue({ code: "custom", message: "Only videos carry a recording timeline." });
9371
+ if (value.steps?.some((step) => value.durationMs === void 0 || step.atMs > value.durationMs))
9372
+ ctx.addIssue({ code: "custom", message: "Recording steps must fit the final video duration." });
9373
+ }
9374
+ });
9320
9375
  var captureUploadTarget = z32.discriminatedUnion("target", [
9321
9376
  z32.object({ target: z32.literal("storage"), url: z32.url({ protocol: /^https$/ }), headers: z32.record(z32.string(), z32.string()) }),
9322
9377
  z32.object({ target: z32.literal("server") })
@@ -9341,7 +9396,12 @@ var screenCaptureRequest = z32.discriminatedUnion("action", [
9341
9396
  z32.object({ action: z32.literal("start_recording"), title, maxSeconds: z32.number().int().min(5).max(RECORDING_MAX_SECONDS).optional() }).strict(),
9342
9397
  z32.object({ action: z32.literal("stop_recording") }).strict(),
9343
9398
  // A step on the recording's timeline: an action's own description, or a moment the agent marks.
9344
- z32.object({ action: z32.literal("step"), label: title, source: z32.enum(["action", "mark"]) }).strict()
9399
+ z32.object({
9400
+ action: z32.literal("step"),
9401
+ label: title,
9402
+ source: z32.enum(["action", "mark"]),
9403
+ durationMs: z32.number().int().min(0).max(RECORDING_MAX_SECONDS * 1e3).optional()
9404
+ }).strict().refine((step) => step.durationMs === void 0 || step.source === "action", { message: "Only actions have a duration." })
9345
9405
  ]);
9346
9406
  var screenCaptureResponse = z32.discriminatedUnion("action", [
9347
9407
  z32.object({ action: z32.literal("screenshot"), capture: captureView }),
@@ -9448,6 +9508,312 @@ function readJson(file) {
9448
9508
  }
9449
9509
  }
9450
9510
 
9511
+ // src/agents/capture-video.mjs
9512
+ import { execFile } from "node:child_process";
9513
+ import { createHash as createHash5 } from "node:crypto";
9514
+ import { constants as constants2, createWriteStream } from "node:fs";
9515
+ import { chmod, lstat as lstat2, mkdir, mkdtemp, open, readFile, rename, rm, stat } from "node:fs/promises";
9516
+ import { dirname as dirname7, basename as basename4, join as join8, resolve as resolve7 } from "node:path";
9517
+ import { devNull } from "node:os";
9518
+ import { pipeline } from "node:stream/promises";
9519
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
9520
+ import { promisify } from "node:util";
9521
+ var execute = promisify(execFile);
9522
+ var CAPTURE_RAW_MAX_BYTES = 1e9;
9523
+ var CAPTURE_VIDEO_MAX_BYTES = 1e8;
9524
+ var CAPTURE_TOOLCHAIN = {
9525
+ id: "ffmpeg-static-b6.1.1-linux-x64-e7e7fb30477f-4f231a1960d8",
9526
+ release: "https://github.com/eugeneware/ffmpeg-static/releases/tag/b6.1.1",
9527
+ version: "7.0.2-static",
9528
+ assets: {
9529
+ ffmpeg: {
9530
+ assetId: 316528626,
9531
+ gzip: true,
9532
+ downloadBytes: 29354986,
9533
+ downloadSha256: "bfe8a8fc511530457b528c48d77b5737527b504a3797a9bc4866aeca69c2dffa",
9534
+ bytes: 79826272,
9535
+ sha256: "e7e7fb30477f717e6f55f9180a70386c62677ef8a4d4d1a5d948f4098aa3eb99"
9536
+ },
9537
+ ffprobe: {
9538
+ assetId: 316529539,
9539
+ gzip: true,
9540
+ downloadBytes: 29276839,
9541
+ downloadSha256: "25d9b6ccb05e3d9de9e04e31e2506d8dd7f9f0418981965ac6df12e8d3afd067",
9542
+ bytes: 79665792,
9543
+ sha256: "4f231a1960d83e403d08f7971e271707bec278a9ae18e21b8b5b03186668450d"
9544
+ },
9545
+ LICENSE: {
9546
+ assetId: 316529924,
9547
+ gzip: false,
9548
+ downloadBytes: 35147,
9549
+ downloadSha256: "8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903",
9550
+ bytes: 35147,
9551
+ sha256: "8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903"
9552
+ },
9553
+ README: {
9554
+ assetId: 316529927,
9555
+ gzip: false,
9556
+ downloadBytes: 2235,
9557
+ downloadSha256: "72f4b1b06d419d22ace6e7cc75f06826f90737345aa0b1736158929f4aacc537",
9558
+ bytes: 2235,
9559
+ sha256: "72f4b1b06d419d22ace6e7cc75f06826f90737345aa0b1736158929f4aacc537"
9560
+ }
9561
+ }
9562
+ };
9563
+ var CAPTURE_TOOLS_ROOT = "/opt/mikka/runtime/capture-tools";
9564
+ var CAPTURE_TOOLS_DIRECTORY = `${CAPTURE_TOOLS_ROOT}/${CAPTURE_TOOLCHAIN.id}`;
9565
+ var MAX_STEPS = 200;
9566
+ var MAX_DURATION_MS = 36e5;
9567
+ var PADDING_BEFORE_MS = 1e3;
9568
+ var PADDING_AFTER_MS = 1500;
9569
+ var CaptureVideoError = class extends Error {
9570
+ constructor(code, options) {
9571
+ super(code, options);
9572
+ this.name = "CaptureVideoError";
9573
+ this.code = code;
9574
+ }
9575
+ };
9576
+ async function captureVideoBinaries({ directory = CAPTURE_TOOLS_DIRECTORY, ownerId = 0 } = {}) {
9577
+ const info = await lstat2(directory).catch((error) => {
9578
+ if (error.code === "ENOENT") return null;
9579
+ throw error;
9580
+ });
9581
+ if (!info) return { ffmpeg: "ffmpeg", ffprobe: "ffprobe" };
9582
+ try {
9583
+ if (!info.isDirectory() || info.uid !== ownerId || info.mode & 18) throw new Error("Private capture tools directory is unsafe");
9584
+ const binaries = { ffmpeg: join8(directory, "ffmpeg"), ffprobe: join8(directory, "ffprobe") };
9585
+ for (const path3 of Object.values(binaries)) {
9586
+ const binary = await lstat2(path3);
9587
+ if (!binary.isFile() || binary.uid !== ownerId || binary.mode & 18 || !(binary.mode & 73)) throw new Error("Private capture tool is unsafe");
9588
+ }
9589
+ return binaries;
9590
+ } catch (error) {
9591
+ throw new CaptureVideoError("captureVideoDependencyUnavailable", { cause: error });
9592
+ }
9593
+ }
9594
+ function normalizeRecordingSteps(input = []) {
9595
+ if (!Array.isArray(input) || input.length > MAX_STEPS) throw new CaptureVideoError("captureVideoStepsInvalid");
9596
+ return input.map((step) => {
9597
+ if (!step || typeof step !== "object" || Array.isArray(step) || !Number.isSafeInteger(step.atMs) || step.atMs < 0 || step.atMs > MAX_DURATION_MS || !["action", "mark"].includes(step.source) || typeof step.label !== "string" || !step.label.trim() || step.label.length > 200 || step.durationMs != null && (step.source !== "action" || !Number.isSafeInteger(step.durationMs) || step.durationMs < 0 || step.durationMs > MAX_DURATION_MS))
9598
+ throw new CaptureVideoError("captureVideoStepsInvalid");
9599
+ return {
9600
+ atMs: step.atMs,
9601
+ label: step.label.replace(/\s+/g, " ").trim(),
9602
+ source: step.source,
9603
+ ...step.durationMs == null ? {} : { durationMs: step.durationMs }
9604
+ };
9605
+ }).sort((left, right) => left.atMs - right.atMs);
9606
+ }
9607
+ function recordingWindows(durationMs, rawSteps = []) {
9608
+ if (!Number.isSafeInteger(durationMs) || durationMs <= 0 || durationMs > MAX_DURATION_MS)
9609
+ throw new CaptureVideoError("captureVideoDurationInvalid");
9610
+ const steps = normalizeRecordingSteps(rawSteps);
9611
+ const actions = steps.filter((step) => step.source === "action");
9612
+ if (!actions.length || actions.some((step) => step.durationMs == null) || steps.some((step) => step.atMs > durationMs + PADDING_AFTER_MS))
9613
+ return [{ startMs: 0, endMs: durationMs }];
9614
+ const windows = [
9615
+ { startMs: 0, endMs: Math.min(actions[0].atMs + PADDING_AFTER_MS, durationMs) },
9616
+ ...steps.map((step) => ({
9617
+ startMs: Math.max(0, step.atMs - (step.durationMs ?? 0) - PADDING_BEFORE_MS),
9618
+ endMs: Math.min(durationMs, step.atMs + PADDING_AFTER_MS)
9619
+ })),
9620
+ { startMs: Math.max(0, actions.at(-1).atMs - actions.at(-1).durationMs - PADDING_BEFORE_MS), endMs: durationMs }
9621
+ ].filter((window) => window.endMs > window.startMs).sort((a, b) => a.startMs - b.startMs);
9622
+ const merged = [];
9623
+ for (const window of windows) {
9624
+ const previous = merged.at(-1);
9625
+ if (previous && window.startMs <= previous.endMs + 500) previous.endMs = Math.max(previous.endMs, window.endMs);
9626
+ else merged.push({ ...window });
9627
+ }
9628
+ return merged;
9629
+ }
9630
+ function remapRecordingSteps(rawSteps, windows, durationMs) {
9631
+ const point = (atMs) => {
9632
+ let kept = 0;
9633
+ for (const window of windows) {
9634
+ if (atMs <= window.endMs) return Math.min(durationMs, Math.max(0, Math.round(kept + Math.max(0, atMs - window.startMs))));
9635
+ kept += window.endMs - window.startMs;
9636
+ }
9637
+ return Math.min(durationMs, Math.round(kept));
9638
+ };
9639
+ return normalizeRecordingSteps(rawSteps).map((step) => ({ ...step, atMs: point(step.atMs) }));
9640
+ }
9641
+ async function snapshot2(source, destination, signal) {
9642
+ signal?.throwIfAborted();
9643
+ const handle = await open(source, constants2.O_RDONLY | (constants2.O_NOFOLLOW ?? 0));
9644
+ try {
9645
+ const info = await handle.stat();
9646
+ if (!info.isFile() || info.size < 1 || info.size > CAPTURE_RAW_MAX_BYTES) throw new CaptureVideoError("captureVideoInputInvalid");
9647
+ const header = Buffer.alloc(64);
9648
+ const { bytesRead } = await handle.read(header, 0, header.length, 0);
9649
+ const mp4 = bytesRead >= 12 && header.subarray(4, 8).toString() === "ftyp";
9650
+ const webm = bytesRead >= 4 && header.subarray(0, 4).equals(Buffer.from([26, 69, 223, 163])) && header.toString("latin1").includes("webm");
9651
+ if (!mp4 && !webm) throw new CaptureVideoError("captureVideoInputInvalid");
9652
+ const hash2 = createHash5("sha256"), stream = handle.createReadStream({ autoClose: false, start: 0, end: info.size - 1 });
9653
+ stream.on("data", (bytes) => hash2.update(bytes));
9654
+ await pipeline(stream, createWriteStream(destination, { flags: "wx", mode: 384 }), { signal });
9655
+ if ((await stat(destination)).size !== info.size) throw new CaptureVideoError("captureVideoInputChanged");
9656
+ return { size: info.size, sha256: hash2.digest("hex") };
9657
+ } finally {
9658
+ await handle.close();
9659
+ }
9660
+ }
9661
+ function videoFilter(windows, width, fps) {
9662
+ const seconds = (milliseconds2) => (milliseconds2 / 1e3).toFixed(3);
9663
+ const parts = windows.map((window, i) => `[0:v:0]trim=start=${seconds(window.startMs)}:end=${seconds(window.endMs)},setpts=PTS-STARTPTS[v${i}]`);
9664
+ const combined = windows.length === 1 ? "[v0]" : windows.map((_, i) => `[v${i}]`).join("") + `concat=n=${windows.length}:v=1:a=0,`;
9665
+ return `${parts.join(";")};${combined}scale=w='min(${width},iw)':h=-2:force_divisible_by=2,fps=${fps},format=yuv420p[out]`;
9666
+ }
9667
+ async function processCaptureVideo(input, output, options = {}) {
9668
+ const maximum = options.maxBytes ?? CAPTURE_VIDEO_MAX_BYTES;
9669
+ if (!Number.isSafeInteger(maximum) || maximum < 1 || maximum > CAPTURE_VIDEO_MAX_BYTES || resolve7(input) === resolve7(output))
9670
+ throw new CaptureVideoError("captureVideoOptionsInvalid");
9671
+ const steps = normalizeRecordingSteps(options.steps);
9672
+ const deadline = Date.now() + Math.min(options.timeoutMs ?? 9e4, 18e4);
9673
+ const binaries = await captureVideoBinaries();
9674
+ await mkdir(dirname7(output), { recursive: true, mode: 448 });
9675
+ const temporary = await mkdtemp(join8(dirname7(output), ".capture-process-"));
9676
+ await chmod(temporary, 448);
9677
+ const run3 = async (binary, args) => {
9678
+ options.signal?.throwIfAborted();
9679
+ const remaining = deadline - Date.now();
9680
+ if (remaining <= 0) throw new CaptureVideoError("captureVideoProcessingTimeout");
9681
+ try {
9682
+ return await execute(binary, args, { timeout: remaining, maxBuffer: 256 * 1024, signal: options.signal, windowsHide: true });
9683
+ } catch (error) {
9684
+ throw new CaptureVideoError(["ENOENT", "EACCES", "ENOEXEC"].includes(error.code) ? "captureVideoDependencyUnavailable" : "captureVideoProcessingFailed", { cause: error });
9685
+ }
9686
+ };
9687
+ const probe = async (path3) => {
9688
+ const { stdout } = await run3(binaries.ffprobe, [
9689
+ "-v",
9690
+ "error",
9691
+ "-protocol_whitelist",
9692
+ "file,pipe",
9693
+ "-format_whitelist",
9694
+ "mov,matroska,webm",
9695
+ "-select_streams",
9696
+ "v:0",
9697
+ "-show_entries",
9698
+ "format=duration:stream=width,height,duration,nb_frames",
9699
+ "-of",
9700
+ "json",
9701
+ path3
9702
+ ]);
9703
+ let value;
9704
+ try {
9705
+ value = JSON.parse(stdout);
9706
+ } catch (error) {
9707
+ throw new CaptureVideoError("captureVideoProbeInvalid", { cause: error });
9708
+ }
9709
+ const stream = value.streams?.[0], seconds = Number(value.format?.duration ?? stream?.duration);
9710
+ if (!stream || !Number.isFinite(seconds) || seconds <= 0 || seconds * 1e3 > MAX_DURATION_MS || !Number.isSafeInteger(stream.width) || stream.width < 1 || !Number.isSafeInteger(stream.height) || stream.height < 1)
9711
+ throw new CaptureVideoError("captureVideoProbeInvalid");
9712
+ return { durationMs: Math.round(seconds * 1e3), width: stream.width, height: stream.height };
9713
+ };
9714
+ try {
9715
+ const source = join8(temporary, "source.video");
9716
+ const originalFile = await snapshot2(input, source, options.signal);
9717
+ const original = await probe(source);
9718
+ const windows = recordingWindows(original.durationMs, steps);
9719
+ const retainedMs = windows.reduce((total, window) => total + window.endMs - window.startMs, 0);
9720
+ const result = join8(temporary, "final.mp4");
9721
+ const base = [
9722
+ "-y",
9723
+ "-nostdin",
9724
+ "-hide_banner",
9725
+ "-loglevel",
9726
+ "error",
9727
+ "-threads",
9728
+ "2",
9729
+ "-filter_complex_threads",
9730
+ "1",
9731
+ "-protocol_whitelist",
9732
+ "file,pipe",
9733
+ "-format_whitelist",
9734
+ "mov,matroska,webm",
9735
+ "-i",
9736
+ source
9737
+ ];
9738
+ const encode2 = async (width, fps, rate, pass) => {
9739
+ await run3(binaries.ffmpeg, [
9740
+ ...base,
9741
+ "-filter_complex",
9742
+ videoFilter(windows, width, fps),
9743
+ "-map",
9744
+ "[out]",
9745
+ "-map_metadata",
9746
+ "-1",
9747
+ "-map_chapters",
9748
+ "-1",
9749
+ "-an",
9750
+ "-sn",
9751
+ "-dn",
9752
+ "-c:v",
9753
+ "libx264",
9754
+ "-preset",
9755
+ "veryfast",
9756
+ "-threads",
9757
+ "2",
9758
+ "-pix_fmt",
9759
+ "yuv420p",
9760
+ ...rate ? ["-b:v", `${rate}k`, "-pass", String(pass), "-passlogfile", join8(temporary, "pass")] : ["-crf", "28"],
9761
+ ...pass === 1 ? ["-f", "null", devNull] : ["-movflags", "+faststart", result]
9762
+ ]);
9763
+ };
9764
+ await encode2(1280, 15);
9765
+ if ((await stat(result)).size > maximum) {
9766
+ const rate = Math.floor(maximum * 0.82 * 8 / (retainedMs / 1e3) / 1e3);
9767
+ if (rate < 8) throw new CaptureVideoError("captureVideoTooLarge");
9768
+ for (const [width, fps, fraction] of [[960, 12, 1], [640, 10, 0.8]]) {
9769
+ await encode2(width, fps, Math.max(8, Math.floor(rate * fraction)), 1);
9770
+ await encode2(width, fps, Math.max(8, Math.floor(rate * fraction)), 2);
9771
+ if ((await stat(result)).size <= maximum) break;
9772
+ }
9773
+ }
9774
+ const size = (await stat(result)).size;
9775
+ if (size > maximum || size === 0) throw new CaptureVideoError("captureVideoTooLarge");
9776
+ const measured = await probe(result);
9777
+ if (measured.durationMs > MAX_DURATION_MS) throw new CaptureVideoError("captureVideoDurationInvalid");
9778
+ if (Math.abs(measured.durationMs - retainedMs) > Math.max(250, windows.length * 100))
9779
+ throw new CaptureVideoError("captureVideoDurationMismatch");
9780
+ await chmod(result, 384);
9781
+ if (await lstat2(output).catch(() => null)) throw new CaptureVideoError("captureVideoOutputExists");
9782
+ options.signal?.throwIfAborted();
9783
+ await rename(result, output);
9784
+ return {
9785
+ durationMs: measured.durationMs,
9786
+ size,
9787
+ steps: remapRecordingSteps(steps, windows, measured.durationMs),
9788
+ processing: {
9789
+ version: 1,
9790
+ originalDurationMs: original.durationMs,
9791
+ originalSize: originalFile.size,
9792
+ originalSha256: originalFile.sha256,
9793
+ trimmedMs: original.durationMs - retainedMs,
9794
+ retainedMs,
9795
+ windows,
9796
+ width: measured.width,
9797
+ height: measured.height
9798
+ }
9799
+ };
9800
+ } finally {
9801
+ await rm(temporary, { recursive: true, force: true });
9802
+ }
9803
+ }
9804
+ if (process.argv[1] && basename4(process.argv[1]) === "capture-video.mjs" && pathToFileURL2(resolve7(process.argv[1])).href === import.meta.url) {
9805
+ try {
9806
+ const [, , input, output, metadata2] = process.argv;
9807
+ if (!input || !output || !metadata2 || process.argv.length !== 5) throw new CaptureVideoError("captureVideoOptionsInvalid");
9808
+ const options = JSON.parse(await readFile(metadata2, "utf8"));
9809
+ const result = await processCaptureVideo(input, output, options);
9810
+ process.stdout.write(JSON.stringify(result) + "\n");
9811
+ } catch (error) {
9812
+ process.stderr.write((error instanceof CaptureVideoError ? error.code : "captureVideoProcessingFailed") + "\n");
9813
+ process.exitCode = 1;
9814
+ }
9815
+ }
9816
+
9451
9817
  // src/captures.ts
9452
9818
  var CAPTURES_DIR = "captures";
9453
9819
  var ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
@@ -9455,36 +9821,121 @@ var EXTENSIONS = ["png", "jpg", "webp", "mp4", "webm"];
9455
9821
  function readPlain(path3, max) {
9456
9822
  let fd;
9457
9823
  try {
9458
- fd = openSync2(path3, constants2.O_RDONLY | (constants2.O_NOFOLLOW ?? 0));
9824
+ fd = openSync2(path3, constants3.O_RDONLY | (constants3.O_NOFOLLOW ?? 0));
9459
9825
  } catch {
9460
9826
  return null;
9461
9827
  }
9462
9828
  try {
9463
- const stat2 = fstatSync(fd);
9464
- if (!stat2.isFile() || stat2.size > max) return null;
9829
+ const stat3 = fstatSync(fd);
9830
+ if (!stat3.isFile() || stat3.size > max) return null;
9465
9831
  return new Uint8Array(readFileSync6(fd));
9466
9832
  } finally {
9467
9833
  closeSync2(fd);
9468
9834
  }
9469
9835
  }
9470
9836
  var drop = (dir, id5) => {
9471
- for (const name of [`${id5}.json`, ...EXTENSIONS.map((ext) => `${id5}.${ext}`)]) rmSync6(join8(dir, name), { force: true });
9837
+ for (const name of [`${id5}.json`, ...EXTENSIONS.map((ext) => `${id5}.${ext}`)]) rmSync6(join9(dir, name), { force: true });
9472
9838
  };
9473
- async function uploadCaptures(dir, runId, link, log, pendingDir, existingOnly = false) {
9839
+ async function hashPlain(path3, signal) {
9840
+ signal?.throwIfAborted();
9841
+ const fd = openSync2(path3, constants3.O_RDONLY | (constants3.O_NOFOLLOW ?? 0));
9842
+ try {
9843
+ const info = fstatSync(fd);
9844
+ if (!info.isFile() || info.size < 1 || info.size > CAPTURE_RAW_MAX_BYTES) throw new Error("Invalid capture video input");
9845
+ const hash2 = createHash6("sha256");
9846
+ for await (const chunk of createReadStream(path3, { fd, autoClose: false, start: 0, end: info.size - 1, signal })) hash2.update(chunk);
9847
+ signal?.throwIfAborted();
9848
+ return hash2.digest("hex");
9849
+ } finally {
9850
+ closeSync2(fd);
9851
+ }
9852
+ }
9853
+ async function prepareVideo(file, id5, steps, pendingDir, signal) {
9854
+ signal?.throwIfAborted();
9855
+ const directory = pendingDir ?? mkdtempSync3(join9(tmpdir3(), "mikka-capture-pending-"));
9856
+ mkdirSync6(directory, { recursive: true, mode: 448 });
9857
+ const output = join9(directory, `${id5}.processed.mp4`), receipt = join9(directory, `${id5}.video.json`);
9858
+ try {
9859
+ const originalHash = await hashPlain(file, signal);
9860
+ const stepHash = createHash6("sha256").update(JSON.stringify(steps)).digest("hex");
9861
+ let result;
9862
+ const previous = readPlain(receipt, 128e3);
9863
+ if (previous) {
9864
+ try {
9865
+ const cached = JSON.parse(new TextDecoder().decode(previous));
9866
+ if (cached.originalHash === originalHash && cached.stepHash === stepHash && cached.result?.processing?.version === 1 && cached.result?.durationMs > 0 && cached.result.durationMs <= CAPTURE_MAX_DURATION_MS && await hashPlain(output, signal) === cached.sha256) result = cached.result;
9867
+ } catch {
9868
+ }
9869
+ }
9870
+ signal?.throwIfAborted();
9871
+ if (!result) {
9872
+ rmSync6(output, { force: true });
9873
+ rmSync6(receipt, { force: true });
9874
+ result = await processCaptureVideo(file, output, { steps, maxBytes: CAPTURE_MAX_BYTES.video, signal });
9875
+ if (result.processing.originalSha256 !== originalHash) throw new Error("Capture changed during video processing");
9876
+ writeJsonAtomic(receipt, { originalHash, stepHash, sha256: await hashPlain(output, signal), result });
9877
+ }
9878
+ signal?.throwIfAborted();
9879
+ const bytes = readPlain(output, CAPTURE_MAX_BYTES.video);
9880
+ if (!bytes || captureProblem(bytes, "video/mp4")) throw new Error("Processed capture video is invalid");
9881
+ return { bytes, durationMs: result.durationMs, steps: normalizeRecordingSteps(result.steps) };
9882
+ } finally {
9883
+ if (!pendingDir) rmSync6(directory, { recursive: true, force: true });
9884
+ }
9885
+ }
9886
+ function dropPrepared(pendingDir, id5) {
9887
+ if (!pendingDir) return;
9888
+ for (const name of [`${id5}.json`, `${id5}.processed.mp4`, `${id5}.video.json`]) rmSync6(join9(pendingDir, name), { force: true });
9889
+ }
9890
+ function fileType(path3) {
9891
+ let fd;
9892
+ try {
9893
+ fd = openSync2(path3, constants3.O_RDONLY | (constants3.O_NOFOLLOW ?? 0));
9894
+ } catch {
9895
+ return null;
9896
+ }
9897
+ try {
9898
+ const info = fstatSync(fd);
9899
+ if (!info.isFile() || info.size < 1 || info.size > CAPTURE_RAW_MAX_BYTES) return null;
9900
+ const head = Buffer.alloc(64);
9901
+ return sniffCaptureType(head.subarray(0, readSync(fd, head, 0, head.length, 0)));
9902
+ } finally {
9903
+ closeSync2(fd);
9904
+ }
9905
+ }
9906
+ async function uploadCaptures(dir, runId, link, log, pendingDir, existingOnly = false, signal) {
9907
+ signal?.throwIfAborted();
9474
9908
  if (!link.beginCapture || !link.sendCapture || !link.completeCapture) return 0;
9475
9909
  if (!lstatSync7(dir, { throwIfNoEntry: false })?.isDirectory()) return 0;
9476
9910
  let sent = 0;
9477
9911
  for (const name of readdirSync4(dir).sort()) {
9912
+ signal?.throwIfAborted();
9478
9913
  const id5 = name.endsWith(".json") ? name.slice(0, -5) : "";
9479
9914
  if (!ID.test(id5)) continue;
9480
- const meta = readPlain(join8(dir, name), 4096);
9915
+ const meta = readPlain(join9(dir, name), 128e3);
9481
9916
  let title2 = "";
9917
+ let steps = [];
9482
9918
  try {
9483
- title2 = cleanCaptureTitle(String(JSON.parse(new TextDecoder().decode(meta ?? new Uint8Array())).title ?? ""));
9919
+ const data = JSON.parse(new TextDecoder().decode(meta ?? new Uint8Array()));
9920
+ title2 = cleanCaptureTitle(String(data.title ?? ""));
9921
+ steps = normalizeRecordingSteps(data.steps);
9484
9922
  } catch {
9923
+ title2 = "";
9485
9924
  }
9486
- const file = EXTENSIONS.map((ext) => join8(dir, `${id5}.${ext}`)).find((path3) => lstatSync7(path3, { throwIfNoEntry: false }));
9487
- const bytes = file ? readPlain(file, CAPTURE_MAX_BYTES.video) : null;
9925
+ const file = EXTENSIONS.map((ext) => join9(dir, `${id5}.${ext}`)).find((path3) => lstatSync7(path3, { throwIfNoEntry: false }));
9926
+ const originalType = file ? fileType(file) : null;
9927
+ let video;
9928
+ if (file && title2 && originalType?.startsWith("video/")) {
9929
+ try {
9930
+ video = await prepareVideo(file, id5, steps, pendingDir, signal);
9931
+ } catch {
9932
+ signal?.throwIfAborted();
9933
+ log.warn({ run_id: runId, capture: id5 }, "capture video processing failed");
9934
+ continue;
9935
+ }
9936
+ }
9937
+ signal?.throwIfAborted();
9938
+ const bytes = video?.bytes ?? (file && originalType?.startsWith("image/") ? readPlain(file, CAPTURE_MAX_BYTES.image) : null);
9488
9939
  const problem = !title2 ? "no title" : !bytes ? "no regular file" : captureProblem(bytes);
9489
9940
  const contentType = bytes && sniffCaptureType(bytes);
9490
9941
  if (problem || !bytes || !contentType) {
@@ -9493,8 +9944,8 @@ async function uploadCaptures(dir, runId, link, log, pendingDir, existingOnly =
9493
9944
  continue;
9494
9945
  }
9495
9946
  try {
9496
- const sha2562 = createHash5("sha256").update(bytes).digest("hex");
9497
- const pendingPath = pendingDir ? join8(pendingDir, `${id5}.json`) : null;
9947
+ const sha2562 = createHash6("sha256").update(bytes).digest("hex");
9948
+ const pendingPath = pendingDir ? join9(pendingDir, `${id5}.json`) : null;
9498
9949
  let pending;
9499
9950
  if (pendingPath) {
9500
9951
  try {
@@ -9507,36 +9958,43 @@ async function uploadCaptures(dir, runId, link, log, pendingDir, existingOnly =
9507
9958
  let target;
9508
9959
  if (pending) {
9509
9960
  try {
9510
- await link.completeCapture(runId, pending.captureId);
9961
+ await link.completeCapture(runId, pending.captureId, signal);
9962
+ signal?.throwIfAborted();
9511
9963
  drop(dir, id5);
9512
- if (pendingPath) rmSync6(pendingPath, { force: true });
9964
+ dropPrepared(pendingDir, id5);
9513
9965
  sent += 1;
9514
9966
  continue;
9515
9967
  } catch (error) {
9968
+ signal?.throwIfAborted();
9516
9969
  if (!(error instanceof DaemonError) || error instanceof ServerUnreachableError || error.code !== 404) throw error;
9517
9970
  }
9518
9971
  if (!link.resumeCapture) return sent;
9519
9972
  try {
9520
- target = await link.resumeCapture(runId, pending.captureId);
9973
+ target = await link.resumeCapture(runId, pending.captureId, signal);
9521
9974
  } catch (error) {
9975
+ signal?.throwIfAborted();
9522
9976
  if (existingOnly || !(error instanceof DaemonError) || error instanceof ServerUnreachableError || error.code !== 404) throw error;
9523
- target = await link.beginCapture(runId, { captureId: pending.captureId, title: title2, contentType, size: bytes.length, sha256: sha2562 });
9977
+ target = await link.beginCapture(runId, { captureId: pending.captureId, title: title2, contentType, size: bytes.length, sha256: sha2562, ...video ? { durationMs: video.durationMs, steps: video.steps } : {} }, signal);
9524
9978
  }
9525
9979
  } else {
9526
9980
  if (pendingPath) {
9527
9981
  mkdirSync6(pendingDir, { recursive: true, mode: 448 });
9528
9982
  writeJsonAtomic(pendingPath, { captureId: id5, sha256: sha2562 });
9529
9983
  }
9530
- target = await link.beginCapture(runId, { ...pendingPath ? { captureId: id5 } : {}, title: title2, contentType, size: bytes.length, sha256: sha2562 });
9531
- if (pendingPath && target.captureId !== id5) throw new Error("Capture reservation id changed");
9984
+ target = await link.beginCapture(runId, { captureId: id5, title: title2, contentType, size: bytes.length, sha256: sha2562, ...video ? { durationMs: video.durationMs, steps: video.steps } : {} }, signal);
9985
+ if (target.captureId !== id5) throw new Error("Capture reservation id changed");
9532
9986
  }
9987
+ signal?.throwIfAborted();
9533
9988
  const { captureId, upload } = target;
9534
- await link.sendCapture(runId, captureId, upload, bytes, contentType);
9535
- await link.completeCapture(runId, captureId);
9989
+ await link.sendCapture(runId, captureId, upload, bytes, contentType, signal);
9990
+ signal?.throwIfAborted();
9991
+ await link.completeCapture(runId, captureId, signal);
9992
+ signal?.throwIfAborted();
9536
9993
  drop(dir, id5);
9537
- if (pendingPath) rmSync6(pendingPath, { force: true });
9994
+ dropPrepared(pendingDir, id5);
9538
9995
  sent += 1;
9539
9996
  } catch (error) {
9997
+ signal?.throwIfAborted();
9540
9998
  if (error instanceof ServerUnreachableError) {
9541
9999
  log.warn({ run_id: runId, capture: id5 }, "capture upload deferred");
9542
10000
  return sent;
@@ -9545,13 +10003,13 @@ async function uploadCaptures(dir, runId, link, log, pendingDir, existingOnly =
9545
10003
  log.warn({ run_id: runId, capture: id5, status: error.code }, "capture reservation unavailable; retry stopped");
9546
10004
  if (pendingDir) {
9547
10005
  mkdirSync6(pendingDir, { recursive: true, mode: 448 });
9548
- writeJsonAtomic(join8(pendingDir, "blocked.json"), { status: error.code });
10006
+ writeJsonAtomic(join9(pendingDir, "blocked.json"), { status: error.code });
9549
10007
  }
9550
10008
  return sent;
9551
10009
  }
9552
10010
  log.warn({ run_id: runId, capture: id5, status: error instanceof DaemonError ? error.code : void 0 }, "capture refused");
9553
10011
  drop(dir, id5);
9554
- if (pendingDir) rmSync6(join8(pendingDir, `${id5}.json`), { force: true });
10012
+ dropPrepared(pendingDir, id5);
9555
10013
  }
9556
10014
  }
9557
10015
  return sent;
@@ -9568,15 +10026,31 @@ var CaptureUploader = class {
9568
10026
  log;
9569
10027
  pendingRoot;
9570
10028
  passes = /* @__PURE__ */ new Map();
9571
- flush(runId, existingOnly = false) {
10029
+ /** A final signal bounds both this pass and any earlier pass still in flight. */
10030
+ flush(runId, existingOnly = false, signal) {
9572
10031
  if (!/^[A-Za-z0-9_-]{1,64}$/.test(runId)) return Promise.resolve();
9573
- const pendingDir = this.pendingRoot ? join8(this.pendingRoot, runId) : void 0;
9574
- if (pendingDir && lstatSync7(join8(pendingDir, "blocked.json"), { throwIfNoEntry: false })) return Promise.resolve();
9575
- const previous = this.passes.get(runId) ?? Promise.resolve();
9576
- const next = previous.then(() => uploadCaptures(this.dirFor(runId), runId, this.link, this.log, pendingDir, existingOnly)).then(() => void 0, (error) => this.log.warn({ run_id: runId, err: error instanceof Error ? error.message : String(error) }, "capture upload failed")).finally(() => {
9577
- if (this.passes.get(runId) === next) this.passes.delete(runId);
10032
+ const pendingDir = this.pendingRoot ? join9(this.pendingRoot, runId) : void 0;
10033
+ if (pendingDir && lstatSync7(join9(pendingDir, "blocked.json"), { throwIfNoEntry: false }))
10034
+ return signal ? Promise.reject(new Error("Capture upload incomplete")) : Promise.resolve();
10035
+ const pass = this.passes.get(runId) ?? { tail: Promise.resolve(), abort: new AbortController() };
10036
+ const abort = () => pass.abort.abort(signal?.reason);
10037
+ signal?.addEventListener("abort", abort, { once: true });
10038
+ if (signal?.aborted) abort();
10039
+ const next = pass.tail.catch(() => void 0).then(async () => {
10040
+ const dir = this.dirFor(runId);
10041
+ await uploadCaptures(dir, runId, this.link, this.log, pendingDir, existingOnly, pass.abort.signal);
10042
+ pass.abort.signal.throwIfAborted();
10043
+ if (signal && lstatSync7(dir, { throwIfNoEntry: false })?.isDirectory() && readdirSync4(dir).some((name) => name.endsWith(".json") && ID.test(name.slice(0, -5))))
10044
+ throw new Error("Capture upload incomplete");
10045
+ }).catch((error) => {
10046
+ if (signal) throw error;
10047
+ this.log.warn({ run_id: runId, reason: pass.abort.signal.aborted ? "cancelled" : "failed" }, "capture upload failed");
10048
+ }).finally(() => {
10049
+ signal?.removeEventListener("abort", abort);
10050
+ if (this.passes.get(runId)?.tail === next) this.passes.delete(runId);
9578
10051
  });
9579
- this.passes.set(runId, next);
10052
+ pass.tail = next;
10053
+ this.passes.set(runId, pass);
9580
10054
  return next;
9581
10055
  }
9582
10056
  };
@@ -9601,7 +10075,7 @@ var HARNESS_DOMAINS = {
9601
10075
  "*.cursorapi.com"
9602
10076
  ]
9603
10077
  };
9604
- var MCP_SERVER_SCRIPT = resolve7(import.meta.dirname, "mikka-mcp.mjs");
10078
+ var MCP_SERVER_SCRIPT = resolve8(import.meta.dirname, "mikka-mcp.mjs");
9605
10079
  var MCP_SERVER_NAME = "mikka";
9606
10080
  var COMPUTER_MCP_SERVER_NAME = "mikka_computer";
9607
10081
  var RUN_GIT_CONFIG = [["maintenance.auto", "false"], ["gc.auto", "0"]];
@@ -9632,7 +10106,7 @@ function credentialDenyRead(harness, home = homedir2()) {
9632
10106
  // Other harnesses' logins; each harness still reads its own.
9633
10107
  ...harness === "codex" ? [] : [".codex/auth.json"],
9634
10108
  ...harness === "claude_code" ? [] : [".claude/.credentials.json"]
9635
- ].map((path3) => join9(home, path3));
10109
+ ].map((path3) => join10(home, path3));
9636
10110
  }
9637
10111
  function daemonSecrets(dataDir) {
9638
10112
  const paths = daemonPaths(realpathSync8(dataDir));
@@ -9643,18 +10117,18 @@ function daemonSecrets(dataDir) {
9643
10117
  paths.outbox,
9644
10118
  paths.logs,
9645
10119
  paths.devRepos,
9646
- join9(paths.adapterState, "pids")
10120
+ join10(paths.adapterState, "pids")
9647
10121
  ];
9648
10122
  }
9649
10123
  function runPaths(stateDir, runId) {
9650
10124
  const id5 = assertSafeId("run id", runId);
9651
10125
  return {
9652
10126
  /** The daemon's data dir (`stateDir` is `<dataDir>/adapters`). */
9653
- privateDir: resolve7(stateDir, ".."),
10127
+ privateDir: resolve8(stateDir, ".."),
9654
10128
  /** Writable from the sandbox. */
9655
- runDir: join9(stateDir, "runs", id5),
10129
+ runDir: join10(stateDir, "runs", id5),
9656
10130
  /** Daemon only. */
9657
- pidFile: join9(stateDir, "pids", `${id5}.pgid`)
10131
+ pidFile: join10(stateDir, "pids", `${id5}.pgid`)
9658
10132
  };
9659
10133
  }
9660
10134
  function repositorySkill(worktree, slug) {
@@ -9662,7 +10136,7 @@ function repositorySkill(worktree, slug) {
9662
10136
  const missing2 = (reason) => ({ id: id5, name: slug, description: "", source: "repository", digest: null, instructions: null, available: false, reason });
9663
10137
  if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(slug)) return missing2("invalid");
9664
10138
  for (const root of [".claude/skills", ".agents/skills"]) {
9665
- const file = join9(worktree, root, slug, SKILL_BODY_FILE);
10139
+ const file = join10(worktree, root, slug, SKILL_BODY_FILE);
9666
10140
  const meta = lstatSync8(file, { throwIfNoEntry: false });
9667
10141
  if (!meta) continue;
9668
10142
  if (!meta.isFile() || meta.isSymbolicLink() || meta.nlink !== 1 || meta.size < 1 || meta.size > MAX_PROFILE_SKILL_INSTRUCTIONS_LENGTH) return missing2("invalid");
@@ -9684,7 +10158,7 @@ function repositorySkill(worktree, slug) {
9684
10158
  name: (declaredName || slug).slice(0, 80),
9685
10159
  description: description.slice(0, 500),
9686
10160
  source: "repository",
9687
- digest: createHash6("sha256").update(body, "utf8").digest("hex"),
10161
+ digest: createHash7("sha256").update(body, "utf8").digest("hex"),
9688
10162
  instructions: body,
9689
10163
  available: true
9690
10164
  };
@@ -9698,16 +10172,16 @@ function writeProfileSkillManifest(options, runDir, worktree, includeRepository)
9698
10172
  if (assigned.length > MAX_PROFILE_SKILLS_PER_RUN || declared.length > MAX_PROFILE_SKILLS_PER_RUN) throw new Error("Profile Skill assignment limit");
9699
10173
  const entries = [];
9700
10174
  for (const skill of assigned) {
9701
- const digest9 = createHash6("sha256").update(skill.instructions, "utf8").digest("hex");
10175
+ const digest9 = createHash7("sha256").update(skill.instructions, "utf8").digest("hex");
9702
10176
  if (digest9 !== skill.digest) throw new Error("Profile Skill artifact digest mismatch");
9703
10177
  entries.push({ id: skill.id, name: skill.name, description: skill.description, source: skill.source, digest: digest9, instructions: skill.instructions, available: true });
9704
10178
  }
9705
10179
  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" });
9706
10180
  const unique = [...new Map(entries.map((entry) => [entry.id, entry])).values()];
9707
- const dir = join9(runDir, PROFILE_SKILLS_DIR);
10181
+ const dir = join10(runDir, PROFILE_SKILLS_DIR);
9708
10182
  ownDir(dir);
9709
10183
  const manifest = { version: 1, skills: unique };
9710
- const file = join9(dir, PROFILE_SKILL_MANIFEST_FILE);
10184
+ const file = join10(dir, PROFILE_SKILL_MANIFEST_FILE);
9711
10185
  const tmp = `${file}.${process.pid}.tmp`;
9712
10186
  writeFileSync4(tmp, `${JSON.stringify(manifest)}
9713
10187
  `, { encoding: "utf8", mode: 384 });
@@ -9718,11 +10192,11 @@ function prepareRunContextFiles(options) {
9718
10192
  ownDir(options.runDir);
9719
10193
  const runDir = realpathSync8(options.runDir);
9720
10194
  const files2 = {
9721
- worktree: resolve7(options.worktree),
10195
+ worktree: resolve8(options.worktree),
9722
10196
  runDir,
9723
- handoffFile: join9(runDir, "handoff.json"),
9724
- tmpDir: join9(runDir, "tmp"),
9725
- capturesDir: join9(runDir, CAPTURES_DIR)
10197
+ handoffFile: join10(runDir, "handoff.json"),
10198
+ tmpDir: join10(runDir, "tmp"),
10199
+ capturesDir: join10(runDir, CAPTURES_DIR)
9726
10200
  };
9727
10201
  ownDir(files2.tmpDir);
9728
10202
  ownDir(files2.capturesDir);
@@ -9756,7 +10230,7 @@ function runMcpServer(options, files2) {
9756
10230
  files2.worktree,
9757
10231
  "--capture-root",
9758
10232
  files2.tmpDir,
9759
- ...options.profileSkills?.length || options.repositorySkills?.length ? ["--profile-skills", join9(files2.runDir, PROFILE_SKILLS_DIR)] : [],
10233
+ ...options.profileSkills?.length || options.repositorySkills?.length ? ["--profile-skills", join10(files2.runDir, PROFILE_SKILLS_DIR)] : [],
9760
10234
  ...options.factoryCheck && (!options.factoryCheck.reportOnly || options.factoryCheck.inferCommand) ? ["--factory-verify", JSON.stringify({ cwd: files2.worktree, command: options.verifyCommand ?? null, infer: options.factoryCheck.inferCommand })] : [],
9761
10235
  ...options.factoryCheck?.reportOnly || readOnlyInspection ? ["--factory-artifacts", files2.worktree] : [],
9762
10236
  ...repositoryExecution ? ["--repository-selection", files2.worktree] : []
@@ -9804,13 +10278,13 @@ var RunContext = class {
9804
10278
  );
9805
10279
  ownDir(options.runDir);
9806
10280
  this.runDir = realpathSync8(options.runDir);
9807
- this.handoffFile = join9(this.runDir, "handoff.json");
9808
- this.skillsDir = join9(this.runDir, SKILLS_DIR);
9809
- this.tmpDir = join9(this.runDir, "tmp");
10281
+ this.handoffFile = join10(this.runDir, "handoff.json");
10282
+ this.skillsDir = join10(this.runDir, SKILLS_DIR);
10283
+ this.tmpDir = join10(this.runDir, "tmp");
9810
10284
  ownDir(this.tmpDir);
9811
- this.capturesDir = join9(this.runDir, CAPTURES_DIR);
10285
+ this.capturesDir = join10(this.runDir, CAPTURES_DIR);
9812
10286
  ownDir(this.capturesDir);
9813
- this.profileSkillsDir = join9(this.runDir, PROFILE_SKILLS_DIR);
10287
+ this.profileSkillsDir = join10(this.runDir, PROFILE_SKILLS_DIR);
9814
10288
  this.writeSkills();
9815
10289
  this.writeProfileSkills();
9816
10290
  if (options.github && !options.machineEnvironment) {
@@ -9853,23 +10327,23 @@ var RunContext = class {
9853
10327
  let slug = base;
9854
10328
  for (let n = 2; taken.has(slug); n += 1) slug = `${base}-${n}`;
9855
10329
  taken.add(slug);
9856
- const dir = join9(this.skillsDir, slug);
10330
+ const dir = join10(this.skillsDir, slug);
9857
10331
  if (this.options.skillReceipt) {
9858
10332
  const existing = lstatSync8(dir, { throwIfNoEntry: false });
9859
10333
  if (existing && (!existing.isDirectory() || existing.isSymbolicLink())) throw new Error("Unsafe Skill artifact directory");
9860
- const file = lstatSync8(join9(dir, SKILL_BODY_FILE), { throwIfNoEntry: false });
10334
+ const file = lstatSync8(join10(dir, SKILL_BODY_FILE), { throwIfNoEntry: false });
9861
10335
  if (file && (!file.isFile() || file.isSymbolicLink() || file.nlink !== 1)) throw new Error("Unsafe Skill artifact file");
9862
10336
  }
9863
10337
  mkdirSync7(dir, { recursive: true });
9864
- const bodyFile = join9(dir, SKILL_BODY_FILE);
10338
+ const bodyFile = join10(dir, SKILL_BODY_FILE);
9865
10339
  if (this.options.skillReceipt) {
9866
10340
  if (!lstatSync8(bodyFile, { throwIfNoEntry: false })) writeFileSync4(bodyFile, skillMarkdown(skill), { encoding: "utf8", flag: "wx", mode: 384 });
9867
10341
  } else writeFileSync4(bodyFile, skillMarkdown(skill), "utf8");
9868
- if (this.options.skillReceipt) verifyMountedSkill(join9(dir, SKILL_BODY_FILE), this.options.skillReceipt);
10342
+ if (this.options.skillReceipt) verifyMountedSkill(join10(dir, SKILL_BODY_FILE), this.options.skillReceipt);
9869
10343
  for (const file of skill.files) {
9870
- const target = resolve7(dir, file.path);
10344
+ const target = resolve8(dir, file.path);
9871
10345
  if (!target.startsWith(`${dir}/`)) continue;
9872
- mkdirSync7(dirname7(target), { recursive: true });
10346
+ mkdirSync7(dirname8(target), { recursive: true });
9873
10347
  writeFileSync4(target, file.content, "utf8");
9874
10348
  }
9875
10349
  }
@@ -9903,14 +10377,14 @@ var RunContext = class {
9903
10377
  denyWrite: [
9904
10378
  // The fixture's refs/objects are writable for push; its configuration
9905
10379
  // and hooks must remain host-owned because fixture verification runs Git.
9906
- ...fixtureOrigin ? [join9(fixtureOrigin, "config"), join9(fixtureOrigin, "hooks")] : [],
9907
- join9(this.worktree, ".git"),
9908
- join9(this.gitDir, "commondir"),
9909
- join9(this.gitDir, "gitdir"),
9910
- join9(this.gitDir, "config.worktree"),
10380
+ ...fixtureOrigin ? [join10(fixtureOrigin, "config"), join10(fixtureOrigin, "hooks")] : [],
10381
+ join10(this.worktree, ".git"),
10382
+ join10(this.gitDir, "commondir"),
10383
+ join10(this.gitDir, "gitdir"),
10384
+ join10(this.gitDir, "config.worktree"),
9911
10385
  // A repository's config and hooks in the shared clone, outside the
9912
10386
  // working directory, are declared read-only here too.
9913
- ...this.options.gitWritePaths?.length ? [join9(this.gitDir, "..", "..", "config"), join9(this.gitDir, "..", "..", "hooks")] : [],
10387
+ ...this.options.gitWritePaths?.length ? [join10(this.gitDir, "..", "..", "config"), join10(this.gitDir, "..", "..", "hooks")] : [],
9914
10388
  ...readOnly ? [this.worktree, ...this.options.gitWritePaths ?? []] : []
9915
10389
  ],
9916
10390
  denyRead: [
@@ -9964,7 +10438,7 @@ var RunContext = class {
9964
10438
  */
9965
10439
  tempEnv() {
9966
10440
  if (this.options.machineEnvironment) return this.options.policyHash ? { MIKKA_POLICY_HASH: this.options.policyHash } : {};
9967
- return { TMPDIR: this.tmpDir, TMPPREFIX: join9(this.tmpDir, "zsh"), ...withGitConfig(this.githubEnv, RUN_GIT_CONFIG), ...this.options.policyHash ? { MIKKA_POLICY_HASH: this.options.policyHash } : {} };
10441
+ return { TMPDIR: this.tmpDir, TMPPREFIX: join10(this.tmpDir, "zsh"), ...withGitConfig(this.githubEnv, RUN_GIT_CONFIG), ...this.options.policyHash ? { MIKKA_POLICY_HASH: this.options.policyHash } : {} };
9968
10442
  }
9969
10443
  /**
9970
10444
  * The agent delivers this run itself: it commits, pushes to the task
@@ -9980,17 +10454,18 @@ var RunContext = class {
9980
10454
  }
9981
10455
  /** The agent's hand-in as the session's exit, or null if it made none. */
9982
10456
  readHandoff(log) {
9983
- const stat2 = lstatSync8(this.handoffFile, { throwIfNoEntry: false });
9984
- if (!stat2) return null;
10457
+ const stat3 = lstatSync8(this.handoffFile, { throwIfNoEntry: false });
10458
+ if (!stat3) return null;
9985
10459
  let file;
9986
10460
  try {
9987
- if (!stat2.isFile()) throw new Error("not a regular file");
10461
+ if (!stat3.isFile()) throw new Error("not a regular file");
9988
10462
  file = JSON.parse(readFileSync7(this.handoffFile, "utf8"));
9989
10463
  } catch (error) {
9990
10464
  log?.warn({ err: error }, "unreadable handoff file; ignoring it");
9991
10465
  return null;
9992
10466
  }
9993
10467
  const plan = this.options.kind === "plan" ? planFromHandoff(file.plan, log) : null;
10468
+ const visualEvidence = runVisualEvidence.safeParse(file.visualEvidence);
9994
10469
  const question = runQuestion.safeParse(file.question);
9995
10470
  const repositorySelection = !this.options.factoryCheck && ["implement", "fix"].includes(this.options.kind ?? "") ? runRepositorySelection.safeParse(file.repositorySelection) : null;
9996
10471
  const report2 = {
@@ -10003,6 +10478,7 @@ var RunContext = class {
10003
10478
  ...plan ? { plan } : {},
10004
10479
  ...typeof file.previewDatabaseBranch === "string" ? { previewDatabaseBranch: file.previewDatabaseBranch } : {},
10005
10480
  ...Array.isArray(file.criteria) ? { criteria: file.criteria } : {},
10481
+ ...visualEvidence.success ? { visualEvidence: visualEvidence.data } : {},
10006
10482
  ...file.reviewVerdict ? { reviewVerdict: file.reviewVerdict } : {},
10007
10483
  ...file.verificationCommand ? { verificationCommand: file.verificationCommand } : {},
10008
10484
  ...runQuestion.safeParse(file.question).success ? { question: runQuestion.parse(file.question) } : {}
@@ -10493,8 +10969,8 @@ var PromptQueue = class {
10493
10969
  continue;
10494
10970
  }
10495
10971
  if (this.closed) return;
10496
- await new Promise((resolve19) => {
10497
- this.waiter = resolve19;
10972
+ await new Promise((resolve20) => {
10973
+ this.waiter = resolve20;
10498
10974
  });
10499
10975
  }
10500
10976
  }
@@ -10508,8 +10984,8 @@ async function untilSpoken(spoken) {
10508
10984
  try {
10509
10985
  return await Promise.race([
10510
10986
  spoken,
10511
- new Promise((resolve19) => {
10512
- timer = setTimeout(() => resolve19(true), CONTINUE_SILENCE_MS);
10987
+ new Promise((resolve20) => {
10988
+ timer = setTimeout(() => resolve20(true), CONTINUE_SILENCE_MS);
10513
10989
  })
10514
10990
  ]);
10515
10991
  } finally {
@@ -10652,15 +11128,15 @@ var ClaudeAdapter = class {
10652
11128
  throw new Error(SUBSCRIPTION_ERROR, { cause: error });
10653
11129
  }
10654
11130
  }
10655
- const nativeHome = options.machineEnvironment ? options.env.HOME : join10(runDir, "native-home");
11131
+ const nativeHome = options.machineEnvironment ? options.env.HOME : join11(runDir, "native-home");
10656
11132
  if (!nativeHome) throw new Error("Cloud machine HOME unavailable");
10657
- const configDir = options.machineEnvironment ? options.env.CLAUDE_CONFIG_DIR ?? join10(nativeHome, ".claude") : join10(nativeHome, ".claude");
11133
+ const configDir = options.machineEnvironment ? options.env.CLAUDE_CONFIG_DIR ?? join11(nativeHome, ".claude") : join11(nativeHome, ".claude");
10658
11134
  if (!options.machineEnvironment) {
10659
11135
  ownDir(nativeHome);
10660
11136
  ownDir(configDir);
10661
11137
  }
10662
11138
  if (!options.machineEnvironment && mode === "continue" && options.continueSession) {
10663
- carryHistory(join10(runPaths(this.options.stateDir, options.continueSession.runId).runDir, "native-home", ".claude"), configDir, ["projects"]);
11139
+ carryHistory(join11(runPaths(this.options.stateDir, options.continueSession.runId).runDir, "native-home", ".claude"), configDir, ["projects"]);
10664
11140
  }
10665
11141
  if (externalAuth && options.credential) throw new Error(SUBSCRIPTION_ERROR);
10666
11142
  const credentialEnv = claudeCredentialEnv(options.credential);
@@ -10695,8 +11171,8 @@ var ClaudeAdapter = class {
10695
11171
  privateDir: paths.privateDir,
10696
11172
  // Its session store, so `resume` works; keyed by the cwd it sees.
10697
11173
  extraWrite: preparing ? [] : [
10698
- join10(configDir, "projects", claudeProjectDirName(options.cwd)),
10699
- join10(
11174
+ join11(configDir, "projects", claudeProjectDirName(options.cwd)),
11175
+ join11(
10700
11176
  configDir,
10701
11177
  "projects",
10702
11178
  claudeProjectDirName(realpathSync9(options.cwd))
@@ -10730,15 +11206,15 @@ var ClaudeAdapter = class {
10730
11206
  let authTimer;
10731
11207
  let stderr = "";
10732
11208
  let stderrArrived = () => void 0;
10733
- const firstStderr = new Promise((resolve19) => {
10734
- stderrArrived = resolve19;
11209
+ const firstStderr = new Promise((resolve20) => {
11210
+ stderrArrived = resolve20;
10735
11211
  });
10736
11212
  const stderrTail = () => stderr.slice(-STDERR_TAIL2).trim() || "no output";
10737
11213
  let spoke = () => void 0;
10738
- const spoken = new Promise((resolve19) => spoke = resolve19);
11214
+ const spoken = new Promise((resolve20) => spoke = resolve20);
10739
11215
  let checkingContinuation = mode === "continue";
10740
11216
  let finished = () => void 0;
10741
- const gone = new Promise((resolve19) => finished = resolve19);
11217
+ const gone = new Promise((resolve20) => finished = resolve20);
10742
11218
  let nativeExit = Promise.resolve(false);
10743
11219
  if (externalAuth && this.options.onHostedSession) {
10744
11220
  try {
@@ -10777,10 +11253,10 @@ var ClaudeAdapter = class {
10777
11253
  stderr = previousStderr.slice(-STDERR_TAIL2 * 4);
10778
11254
  stderrArrived();
10779
11255
  }
10780
- nativeExit = new Promise((resolve19) => {
10781
- child.once("exit", () => resolve19(true));
10782
- child.once("error", () => resolve19(false));
10783
- if (child.exitCode !== null || child.signalCode) resolve19(true);
11256
+ nativeExit = new Promise((resolve20) => {
11257
+ child.once("exit", () => resolve20(true));
11258
+ child.once("error", () => resolve20(false));
11259
+ if (child.exitCode !== null || child.signalCode) resolve20(true);
10784
11260
  });
10785
11261
  child.stderr?.on("data", (data) => {
10786
11262
  stderr = (stderr + data.toString()).slice(-STDERR_TAIL2 * 4);
@@ -10839,7 +11315,7 @@ var ClaudeAdapter = class {
10839
11315
  if (preparation) {
10840
11316
  const { binding, control } = preparation;
10841
11317
  const fixed = claudePrewarmOptionsKey(options);
10842
- const parking = join10(runDir, "claude-parking");
11318
+ const parking = join11(runDir, "claude-parking");
10843
11319
  ownDir(parking);
10844
11320
  let anonymousAdopted = false;
10845
11321
  const prepared = prepareClaudeSession({
@@ -11006,8 +11482,8 @@ var ClaudeAdapter = class {
11006
11482
  if (!message.is_error) quota = void 0;
11007
11483
  if (message.is_error && externalAuth && !stderr) {
11008
11484
  let drainTimer;
11009
- await Promise.race([firstStderr, new Promise((resolve19) => {
11010
- drainTimer = setTimeout(resolve19, 100);
11485
+ await Promise.race([firstStderr, new Promise((resolve20) => {
11486
+ drainTimer = setTimeout(resolve20, 100);
11011
11487
  })]);
11012
11488
  clearTimeout(drainTimer);
11013
11489
  }
@@ -11195,7 +11671,7 @@ function codexFailureMessage(phase, info) {
11195
11671
  }
11196
11672
 
11197
11673
  // src/adapters/codex.ts
11198
- import { delimiter as delimiter3, dirname as dirname8, isAbsolute as isAbsolute5, join as join12, relative as relative4 } from "node:path";
11674
+ import { delimiter as delimiter3, dirname as dirname9, isAbsolute as isAbsolute5, join as join13, relative as relative4 } from "node:path";
11199
11675
  import { mkdirSync as mkdirSync9 } from "node:fs";
11200
11676
 
11201
11677
  // src/codex-generation-telemetry.ts
@@ -11615,11 +12091,11 @@ async function startCodexGenerationCollector(emit) {
11615
12091
  server.requestTimeout = 1e3;
11616
12092
  server.headersTimeout = 1e3;
11617
12093
  server.maxConnections = 4;
11618
- await new Promise((resolve19, reject) => {
12094
+ await new Promise((resolve20, reject) => {
11619
12095
  server.once("error", reject);
11620
12096
  server.listen(0, "127.0.0.1", () => {
11621
12097
  server.off("error", reject);
11622
- resolve19();
12098
+ resolve20();
11623
12099
  });
11624
12100
  });
11625
12101
  server.on("error", () => collector.reject());
@@ -11639,7 +12115,7 @@ async function startCodexGenerationCollector(emit) {
11639
12115
  "-c",
11640
12116
  "otel.log_guardian_assessments=false"
11641
12117
  ],
11642
- close: (cliExitObserved = false) => closed ??= new Promise((resolve19) => {
12118
+ close: (cliExitObserved = false) => closed ??= new Promise((resolve20) => {
11643
12119
  const timer = setTimeout(() => {
11644
12120
  collector.truncate();
11645
12121
  server.closeAllConnections();
@@ -11647,7 +12123,7 @@ async function startCodexGenerationCollector(emit) {
11647
12123
  timer.unref();
11648
12124
  server.close(() => {
11649
12125
  clearTimeout(timer);
11650
- resolve19(collector.finish(cliExitObserved));
12126
+ resolve20(collector.finish(cliExitObserved));
11651
12127
  });
11652
12128
  })
11653
12129
  };
@@ -11690,11 +12166,11 @@ var JsonlWriter = class extends AbstractMessageWriter {
11690
12166
  }
11691
12167
  stream;
11692
12168
  write(message) {
11693
- return new Promise((resolve19, reject) => {
12169
+ return new Promise((resolve20, reject) => {
11694
12170
  this.stream.write(
11695
12171
  `${JSON.stringify(message)}
11696
12172
  `,
11697
- (error) => error ? reject(error) : resolve19()
12173
+ (error) => error ? reject(error) : resolve20()
11698
12174
  );
11699
12175
  });
11700
12176
  }
@@ -11710,8 +12186,8 @@ function jsonlConnection(input, output) {
11710
12186
  }
11711
12187
 
11712
12188
  // src/adapters/codex-mailbox.ts
11713
- import { closeSync as closeSync3, constants as constants3, fstatSync as fstatSync2, lstatSync as lstatSync9, mkdirSync as mkdirSync8, openSync as openSync3, readSync } from "node:fs";
11714
- import { isAbsolute as isAbsolute4, join as join11, relative as relative3, sep as sep2 } from "node:path";
12189
+ import { closeSync as closeSync3, constants as constants4, fstatSync as fstatSync2, lstatSync as lstatSync9, mkdirSync as mkdirSync8, openSync as openSync3, readSync as readSync2 } from "node:fs";
12190
+ import { isAbsolute as isAbsolute4, join as join12, relative as relative3, sep as sep2 } from "node:path";
11715
12191
  import { isDeepStrictEqual } from "node:util";
11716
12192
  var unavailable2 = () => new Error("Run mailbox requires a verified original Codex thread");
11717
12193
  function codexMailboxResumeVersion(userAgent) {
@@ -11728,15 +12204,15 @@ function historyParts(value) {
11728
12204
  return parts;
11729
12205
  }
11730
12206
  function receiptFile(stateDir, runId) {
11731
- return join11(stateDir, "codex-mailbox", assertSafeId("run id", runId) + ".json");
12207
+ return join12(stateDir, "codex-mailbox", assertSafeId("run id", runId) + ".json");
11732
12208
  }
11733
12209
  function readJson2(file, limit, firstLine = false) {
11734
- const fd = openSync3(file, constants3.O_RDONLY | constants3.O_NOFOLLOW | constants3.O_NONBLOCK);
12210
+ const fd = openSync3(file, constants4.O_RDONLY | constants4.O_NOFOLLOW | constants4.O_NONBLOCK);
11735
12211
  try {
11736
- const stat2 = fstatSync2(fd);
11737
- if (!stat2.isFile() || stat2.nlink !== 1 || !firstLine && stat2.size > limit) throw unavailable2();
11738
- const buffer = Buffer.alloc(Math.min(stat2.size, limit + 1));
11739
- const length = readSync(fd, buffer, 0, buffer.length, 0);
12212
+ const stat3 = fstatSync2(fd);
12213
+ if (!stat3.isFile() || stat3.nlink !== 1 || !firstLine && stat3.size > limit) throw unavailable2();
12214
+ const buffer = Buffer.alloc(Math.min(stat3.size, limit + 1));
12215
+ const length = readSync2(fd, buffer, 0, buffer.length, 0);
11740
12216
  const end = firstLine ? buffer.subarray(0, length).indexOf(10) : length;
11741
12217
  if (end < 0 || end > limit) throw unavailable2();
11742
12218
  return JSON.parse(buffer.subarray(0, end).toString("utf8"));
@@ -11748,16 +12224,16 @@ function verifyHistory(home, path3, threadId, catalogue) {
11748
12224
  const parts = historyParts(path3);
11749
12225
  let parent = home;
11750
12226
  for (const part of ["", ...parts.slice(0, -1)]) {
11751
- if (part) parent = join11(parent, part);
11752
- const stat2 = lstatSync9(parent);
11753
- if (!stat2.isDirectory() || stat2.isSymbolicLink()) throw unavailable2();
12227
+ if (part) parent = join12(parent, part);
12228
+ const stat3 = lstatSync9(parent);
12229
+ if (!stat3.isDirectory() || stat3.isSymbolicLink()) throw unavailable2();
11754
12230
  }
11755
- const header = readJson2(join11(home, ...parts), 1024 * 1024, true);
12231
+ const header = readJson2(join12(home, ...parts), 1024 * 1024, true);
11756
12232
  if (header?.type !== "session_meta" || header.payload?.id !== threadId || !isDeepStrictEqual(header.payload.dynamic_tools, catalogue)) throw unavailable2();
11757
12233
  }
11758
12234
  function verifyCodexMailboxResume(stateDir, sourceRunId, home, threadId, catalogue) {
11759
12235
  try {
11760
- const dir = lstatSync9(join11(stateDir, "codex-mailbox"));
12236
+ const dir = lstatSync9(join12(stateDir, "codex-mailbox"));
11761
12237
  if (!dir.isDirectory() || dir.isSymbolicLink()) throw unavailable2();
11762
12238
  const receipt = readJson2(receiptFile(stateDir, sourceRunId), 256 * 1024);
11763
12239
  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();
@@ -11773,10 +12249,10 @@ function recordCodexMailboxSession(stateDir, runId, home, thread, catalogue, res
11773
12249
  const historyPath = relative3(home, thread.path).split(sep2).join("/");
11774
12250
  historyParts(historyPath);
11775
12251
  if (resumed) verifyHistory(home, historyPath, thread.id, catalogue);
11776
- const dir = join11(stateDir, "codex-mailbox");
12252
+ const dir = join12(stateDir, "codex-mailbox");
11777
12253
  mkdirSync8(dir, { recursive: true, mode: 448 });
11778
- const stat2 = lstatSync9(dir);
11779
- if (!stat2.isDirectory() || stat2.isSymbolicLink()) throw unavailable2();
12254
+ const stat3 = lstatSync9(dir);
12255
+ if (!stat3.isDirectory() || stat3.isSymbolicLink()) throw unavailable2();
11780
12256
  writeJsonAtomic(receiptFile(stateDir, runId), { version: 1, nativeVersion, runId, threadId: thread.id, historyPath, catalogue });
11781
12257
  } catch {
11782
12258
  if (resumed) throw unavailable2();
@@ -12037,8 +12513,8 @@ var CodexAdapter = class {
12037
12513
  options.continueSession.runId
12038
12514
  ).runDir;
12039
12515
  carryHistory(
12040
- join12(earlier2, "codex-home"),
12041
- join12(runDir, "codex-home"),
12516
+ join13(earlier2, "codex-home"),
12517
+ join13(runDir, "codex-home"),
12042
12518
  CODEX_HISTORY
12043
12519
  );
12044
12520
  } catch (error) {
@@ -12049,7 +12525,7 @@ var CodexAdapter = class {
12049
12525
  log.info({ err: error }, "could not copy the earlier codex threads");
12050
12526
  }
12051
12527
  }
12052
- const codexHome = options.machineEnvironment ? { home: options.env.CODEX_HOME ?? join12(options.env.HOME, ".codex") } : prepareCodexHome(join12(runDir, "codex-home"), log);
12528
+ const codexHome = options.machineEnvironment ? { home: options.env.CODEX_HOME ?? join13(options.env.HOME, ".codex") } : prepareCodexHome(join13(runDir, "codex-home"), log);
12053
12529
  if (options.machineEnvironment) mkdirSync9(codexHome.home, { recursive: true, mode: 448 });
12054
12530
  const mailboxResumeVersion = mailboxCatalogue && threadId ? verifyCodexMailboxResume(
12055
12531
  this.options.stateDir,
@@ -12060,7 +12536,7 @@ var CodexAdapter = class {
12060
12536
  ) : null;
12061
12537
  const computerMcp = this.options.computerMcp ?? this.options.computerProvider?.(options.runId, options.policy);
12062
12538
  const binary = this.options.binary ?? await this.options.ensureBinary?.() ?? "codex";
12063
- const childPath = isAbsolute5(binary) ? dirname8(binary) + delimiter3 + (options.env.PATH ?? "") : options.env.PATH;
12539
+ const childPath = isAbsolute5(binary) ? dirname9(binary) + delimiter3 + (options.env.PATH ?? "") : options.env.PATH;
12064
12540
  if (externalAuth && options.credential) throw new Error(SUBSCRIPTION_AUTH_ERROR);
12065
12541
  const credential = codexCredential(brokerAuth ? { kind: "provider", protocol: "openai", baseUrl: "https://mikka.invalid", key: NATIVE_AUTH_PLACEHOLDER } : options.credential);
12066
12542
  const providerDomain = credentialDomain(options.credential);
@@ -12236,7 +12712,6 @@ var CodexAdapter = class {
12236
12712
  );
12237
12713
  const queue = new EventQueue();
12238
12714
  const streamed = /* @__PURE__ */ new Set();
12239
- const pending = [];
12240
12715
  let activeTurn = null;
12241
12716
  let pendingTurnStart = null;
12242
12717
  let ending = false;
@@ -12282,11 +12757,6 @@ var CodexAdapter = class {
12282
12757
  ending = true;
12283
12758
  pendingMcp.clear();
12284
12759
  options.toolApproval?.revoke();
12285
- if (pending.length > 0)
12286
- log.warn(
12287
- { dropped: pending.length },
12288
- "session ended with unsent messages"
12289
- );
12290
12760
  rpc.dispose();
12291
12761
  await child.kill();
12292
12762
  if (event) {
@@ -12469,17 +12939,6 @@ var CodexAdapter = class {
12469
12939
  });
12470
12940
  }
12471
12941
  }
12472
- const next = pending.shift();
12473
- if (next) {
12474
- await startTurn(next).catch(
12475
- (error) => finish({
12476
- outcome: "failed",
12477
- error: managedAuth ? turnStartFailure ?? subscriptionFailure("turn_start", codexFailureInfo(error)) : error instanceof ProviderFailureError ? error.message : `Codex: ${errorMessage(error)}`,
12478
- ...error instanceof ProviderFailureError ? { providerFailure: error.providerFailure } : {}
12479
- })
12480
- );
12481
- return;
12482
- }
12483
12942
  if (turn.status === "failed" || lastError) {
12484
12943
  quota = mergeQuota(quota, codexQuotaSignal(turn.error, rateLimits));
12485
12944
  const failure2 = codexFailureInfo(turn.error);
@@ -12666,7 +13125,7 @@ var CodexAdapter = class {
12666
13125
  sessionId,
12667
13126
  runtimeModel,
12668
13127
  events: () => queue.drain(),
12669
- async send(message) {
13128
+ async send(message, mode2) {
12670
13129
  sensitiveText.push(message);
12671
13130
  if (ending) throw new Error("The Codex session already ended");
12672
13131
  if (activeTurn) {
@@ -12677,11 +13136,16 @@ var CodexAdapter = class {
12677
13136
  expectedTurnId: activeTurn
12678
13137
  });
12679
13138
  return;
12680
- } catch {
13139
+ } catch (error) {
13140
+ const failure2 = codexFailureInfo(error);
13141
+ const { category, rpcCode } = failure2;
13142
+ const code = rpcCode === void 0 ? "" : `, RPC ${rpcCode}`;
13143
+ throw new Error(`Codex could not steer the active turn (${category}${code})`, { cause: failure2 });
12681
13144
  }
12682
13145
  }
12683
- if (activeTurn) pending.push(message);
12684
- else await startTurn(message);
13146
+ if (ending) throw new Error("The Codex session already ended");
13147
+ if (mode2 === "steer") throw new Error("The Codex turn is no longer active");
13148
+ await startTurn(message);
12685
13149
  },
12686
13150
  async cancel() {
12687
13151
  cancelling = true;
@@ -12705,7 +13169,7 @@ var CodexAdapter = class {
12705
13169
  // src/adapters/cursor.ts
12706
13170
  import { Readable, Writable } from "node:stream";
12707
13171
  import * as acp from "@agentclientprotocol/sdk";
12708
- import { join as join13 } from "node:path";
13172
+ import { join as join14 } from "node:path";
12709
13173
  function cursorAppServers(apps) {
12710
13174
  return [
12711
13175
  ...(apps?.apps ?? []).map((app) => ({ type: "http", name: app.name, url: app.url, headers: [{ name: "Authorization", value: `Bearer ${apps.token}` }] })),
@@ -12837,15 +13301,15 @@ var CursorAdapter = class {
12837
13301
  options.continueSession.runId
12838
13302
  ).runDir;
12839
13303
  carryHistory(
12840
- join13(earlier2, "cursor-home"),
12841
- join13(paths.runDir, "cursor-home"),
13304
+ join14(earlier2, "cursor-home"),
13305
+ join14(paths.runDir, "cursor-home"),
12842
13306
  CURSOR_HISTORY
12843
13307
  );
12844
13308
  } catch (error) {
12845
13309
  log.info({ err: error }, "could not copy the earlier cursor chats");
12846
13310
  }
12847
13311
  }
12848
- const configDir = prepareCursorHome(join13(paths.runDir, "cursor-home"));
13312
+ const configDir = prepareCursorHome(join14(paths.runDir, "cursor-home"));
12849
13313
  const ctx = new RunContext({
12850
13314
  github: options.github,
12851
13315
  githubEnvironment: options.githubEnvironment,
@@ -13080,7 +13544,7 @@ ${firstMessage}` : firstMessage
13080
13544
  // src/adapters/mock.ts
13081
13545
  import { randomUUID as randomUUID3 } from "node:crypto";
13082
13546
  import { mkdirSync as mkdirSync10, readFileSync as readFileSync8, writeFileSync as writeFileSync5 } from "node:fs";
13083
- import { dirname as dirname9, join as join14, resolve as resolve8 } from "node:path";
13547
+ import { dirname as dirname10, join as join15, resolve as resolve9 } from "node:path";
13084
13548
  import { setTimeout as sleep } from "node:timers/promises";
13085
13549
  import { execa as execa5 } from "execa";
13086
13550
 
@@ -13112,7 +13576,7 @@ function isRunChunk(value) {
13112
13576
  }
13113
13577
 
13114
13578
  // src/adapters/mock.ts
13115
- var DEFAULT_FIXTURES_DIR = resolve8(
13579
+ var DEFAULT_FIXTURES_DIR = resolve9(
13116
13580
  import.meta.dirname,
13117
13581
  true ? "./fixtures" : "../../fixtures"
13118
13582
  );
@@ -13146,7 +13610,7 @@ var MockAdapter = class {
13146
13610
  fixturesDir;
13147
13611
  speed;
13148
13612
  stateFile(sessionId) {
13149
- return join14(
13613
+ return join15(
13150
13614
  this.options.stateDir,
13151
13615
  `mock-${assertSafeId("session id", sessionId)}.json`
13152
13616
  );
@@ -13190,7 +13654,7 @@ var MockAdapter = class {
13190
13654
  open(sessionId, state2, options) {
13191
13655
  const name = assertSafeId("fixture", state2.fixture.replace(/\.jsonl$/, ""));
13192
13656
  const lines = parseFixture(
13193
- readFileSync8(join14(this.fixturesDir, `${name}.jsonl`), "utf8"),
13657
+ readFileSync8(join15(this.fixturesDir, `${name}.jsonl`), "utf8"),
13194
13658
  name
13195
13659
  );
13196
13660
  const abort = new AbortController();
@@ -13228,7 +13692,7 @@ var MockAdapter = class {
13228
13692
  if (line.hang) {
13229
13693
  if (!abort.signal.aborted) {
13230
13694
  await new Promise(
13231
- (resolve19) => abort.signal.addEventListener("abort", resolve19, { once: true })
13695
+ (resolve20) => abort.signal.addEventListener("abort", resolve20, { once: true })
13232
13696
  );
13233
13697
  }
13234
13698
  yield { type: "exit", outcome: "cancelled" };
@@ -13240,8 +13704,8 @@ var MockAdapter = class {
13240
13704
  `mock fixture writes outside the worktree: ${line.write.path}`
13241
13705
  );
13242
13706
  }
13243
- const target = resolve8(options.cwd, line.write.path);
13244
- mkdirSync10(dirname9(target), { recursive: true });
13707
+ const target = resolve9(options.cwd, line.write.path);
13708
+ mkdirSync10(dirname10(target), { recursive: true });
13245
13709
  writeFileSync5(target, line.write.content);
13246
13710
  }
13247
13711
  if (line.chunk) yield { type: "chunk", chunk: line.chunk };
@@ -13303,14 +13767,14 @@ var MockAdapter = class {
13303
13767
  };
13304
13768
 
13305
13769
  // src/agents/local-github.ts
13306
- import { mkdirSync as mkdirSync12, mkdtempSync as mkdtempSync3, rmSync as rmSync9, writeFileSync as writeFileSync7 } from "node:fs";
13770
+ import { mkdirSync as mkdirSync12, mkdtempSync as mkdtempSync4, rmSync as rmSync9, writeFileSync as writeFileSync7 } from "node:fs";
13307
13771
  import { homedir as homedir3 } from "node:os";
13308
- import { delimiter as delimiter4, join as join16 } from "node:path";
13772
+ import { delimiter as delimiter4, join as join17 } from "node:path";
13309
13773
 
13310
13774
  // src/agents/machine-github.ts
13311
13775
  import { existsSync as existsSync4, mkdirSync as mkdirSync11, readFileSync as readFileSync9, renameSync as renameSync3, rmSync as rmSync8, writeFileSync as writeFileSync6 } from "node:fs";
13312
13776
  import { randomUUID as randomUUID4 } from "node:crypto";
13313
- import { dirname as dirname10, join as join15 } from "node:path";
13777
+ import { dirname as dirname11, join as join16 } from "node:path";
13314
13778
  function githubHosts(contents, token) {
13315
13779
  if (!token || /[\r\n\0]/.test(token) || token.length > 32768) throw Error("github_credential_invalid");
13316
13780
  const lines = contents.split(/\r?\n/);
@@ -13335,8 +13799,8 @@ function prepareMachineGitHub(github, host) {
13335
13799
  if (!github.token) throw Error("github_credential_missing");
13336
13800
  const home = host.env.HOME;
13337
13801
  if (!home) throw Error("github_home_missing");
13338
- const directory = host.env.GH_CONFIG_DIR ?? join15(host.env.XDG_CONFIG_HOME ?? join15(home, ".config"), "gh");
13339
- const file = join15(directory, "hosts.yml");
13802
+ const directory = host.env.GH_CONFIG_DIR ?? join16(host.env.XDG_CONFIG_HOME ?? join16(home, ".config"), "gh");
13803
+ const file = join16(directory, "hosts.yml");
13340
13804
  const original = existsSync4(file) ? readFileSync9(file, "utf8") : void 0;
13341
13805
  let written;
13342
13806
  let closed = false;
@@ -13350,7 +13814,7 @@ function prepareMachineGitHub(github, host) {
13350
13814
  host.onCredential?.("GITHUB_TOKEN", credential.token);
13351
13815
  const latest = existsSync4(file) ? readFileSync9(file, "utf8") : "";
13352
13816
  const next = githubHosts(latest, credential.token);
13353
- mkdirSync11(dirname10(file), { recursive: true, mode: 448 });
13817
+ mkdirSync11(dirname11(file), { recursive: true, mode: 448 });
13354
13818
  const temporary = `${file}.${randomUUID4()}`;
13355
13819
  writeFileSync6(temporary, next, { mode: 384, flag: "wx" });
13356
13820
  renameSync3(temporary, file);
@@ -13436,14 +13900,14 @@ async function prepareLocalGitHub(assignment, host) {
13436
13900
  const credential = assignment.github.token ? { token: assignment.github.token, expiresAt: assignment.github.expiresAt ?? null } : await lease();
13437
13901
  if (host.signal.aborted) throw Error("github_run_closed");
13438
13902
  mkdirSync12(host.stateDir, { recursive: true, mode: 448 });
13439
- const directory = mkdtempSync3(join16(host.stateDir, "github-"));
13903
+ const directory = mkdtempSync4(join17(host.stateDir, "github-"));
13440
13904
  try {
13441
- const bin = join16(directory, "bin");
13905
+ const bin = join17(directory, "bin");
13442
13906
  const quote2 = (value) => `'${value.replaceAll("'", "'\\''")}'`;
13443
13907
  const helper2 = `${process.versions.electron ? "env ELECTRON_RUN_AS_NODE=1 " : ""}${quote2(process.execPath)} ${quote2(GITHUB_CREDENTIAL_SCRIPT)}`;
13444
13908
  if (binary) {
13445
13909
  mkdirSync12(bin, { mode: 448 });
13446
- writeFileSync7(join16(bin, "gh"), `#!/bin/sh
13910
+ writeFileSync7(join17(bin, "gh"), `#!/bin/sh
13447
13911
  exec ${helper2} native-gh ${quote2(binary)} ${quote2(directory)} "$@"
13448
13912
  `, { mode: 448, flag: "wx" });
13449
13913
  }
@@ -13483,18 +13947,18 @@ exec ${helper2} native-gh ${quote2(binary)} ${quote2(directory)} "$@"
13483
13947
  }
13484
13948
 
13485
13949
  // src/agents/verify.ts
13486
- import { existsSync as existsSync5, mkdirSync as mkdirSync13, mkdtempSync as mkdtempSync4, realpathSync as realpathSync10, rmSync as rmSync10 } from "node:fs";
13487
- import { join as join17 } from "node:path";
13950
+ import { existsSync as existsSync5, mkdirSync as mkdirSync13, mkdtempSync as mkdtempSync5, realpathSync as realpathSync10, rmSync as rmSync10 } from "node:fs";
13951
+ import { join as join18 } from "node:path";
13488
13952
  var OUTPUT_TAIL = 4e3;
13489
13953
  var SETUP_ATTEMPTS = 3;
13490
13954
  async function runVerify(sandbox, options) {
13491
13955
  options.signal?.throwIfAborted();
13492
13956
  mkdirSync13(options.tmpRoot, { recursive: true, mode: 448 });
13493
- const tmpDir = mkdtempSync4(join17(realpathSync10(options.tmpRoot), "verify-"));
13957
+ const tmpDir = mkdtempSync5(join18(realpathSync10(options.tmpRoot), "verify-"));
13494
13958
  const deadline = Date.now() + options.timeoutMs;
13495
13959
  try {
13496
13960
  for (let attempt = 1; ; attempt++) {
13497
- const started = join17(tmpDir, `.started-${attempt}`);
13961
+ const started = join18(tmpDir, `.started-${attempt}`);
13498
13962
  const result = await attemptVerify(sandbox, options, tmpDir, started, deadline - Date.now());
13499
13963
  if (result.exitCode === 0 || result.timedOut || options.signal?.aborted || existsSync5(started) || attempt >= SETUP_ATTEMPTS)
13500
13964
  return result;
@@ -13513,7 +13977,7 @@ async function attemptVerify(sandbox, options, tmpDir, started, timeoutMs) {
13513
13977
  policy: {
13514
13978
  allowWrite: options.readOnly ? [tmpDir] : [options.worktree, tmpDir],
13515
13979
  denyWrite: [
13516
- join17(options.worktree, ".git"),
13980
+ join18(options.worktree, ".git"),
13517
13981
  ...options.readOnly ? [options.worktree] : []
13518
13982
  ],
13519
13983
  denyRead: [
@@ -13583,12 +14047,12 @@ var NoSandbox = class {
13583
14047
  };
13584
14048
 
13585
14049
  // src/fs-browse.ts
13586
- import { execFile } from "node:child_process";
13587
- import { readdir as readdir2, realpath, stat } from "node:fs/promises";
14050
+ import { execFile as execFile2 } from "node:child_process";
14051
+ import { readdir as readdir2, realpath, stat as stat2 } from "node:fs/promises";
13588
14052
  import { homedir as homedir4, platform } from "node:os";
13589
- import { basename as basename4, dirname as dirname11, isAbsolute as isAbsolute6, join as join18, resolve as resolve9 } from "node:path";
13590
- import { promisify } from "node:util";
13591
- var run = promisify(execFile);
14053
+ import { basename as basename5, dirname as dirname12, isAbsolute as isAbsolute6, join as join19, resolve as resolve10 } from "node:path";
14054
+ import { promisify as promisify2 } from "node:util";
14055
+ var run = promisify2(execFile2);
13592
14056
  async function git(cwd, args) {
13593
14057
  try {
13594
14058
  const { stdout } = await run("git", ["-C", cwd, ...args], {
@@ -13602,14 +14066,14 @@ async function git(cwd, args) {
13602
14066
  }
13603
14067
  async function isDir(path3) {
13604
14068
  try {
13605
- return (await stat(path3)).isDirectory();
14069
+ return (await stat2(path3)).isDirectory();
13606
14070
  } catch {
13607
14071
  return false;
13608
14072
  }
13609
14073
  }
13610
14074
  async function exists(path3) {
13611
14075
  try {
13612
- await stat(path3);
14076
+ await stat2(path3);
13613
14077
  return true;
13614
14078
  } catch {
13615
14079
  return false;
@@ -13632,7 +14096,7 @@ async function browseFolder(request2) {
13632
14096
  code: "not_found",
13633
14097
  message: "Expected an absolute path."
13634
14098
  };
13635
- const path3 = resolve9(wanted);
14099
+ const path3 = resolve10(wanted);
13636
14100
  if (!await exists(path3))
13637
14101
  return { ok: false, code: "not_found", message: `${path3} does not exist.` };
13638
14102
  if (!await isDir(path3))
@@ -13656,7 +14120,7 @@ async function browseFolder(request2) {
13656
14120
  let truncated = false;
13657
14121
  const dirs = names.filter((e) => e.isDirectory() || e.isSymbolicLink()).filter((e) => request2.showHidden || !e.name.startsWith(".")).sort((a, b) => a.name.localeCompare(b.name));
13658
14122
  for (const entry of dirs) {
13659
- const full = join18(path3, entry.name);
14123
+ const full = join19(path3, entry.name);
13660
14124
  if (entry.isSymbolicLink() && !await isDir(full)) continue;
13661
14125
  if (folders.length >= FS_MAX_ENTRIES) {
13662
14126
  truncated = true;
@@ -13665,14 +14129,14 @@ async function browseFolder(request2) {
13665
14129
  folders.push({
13666
14130
  name: entry.name,
13667
14131
  path: full,
13668
- isRepo: await exists(join18(full, ".git"))
14132
+ isRepo: await exists(join19(full, ".git"))
13669
14133
  });
13670
14134
  }
13671
- const parent = dirname11(path3);
14135
+ const parent = dirname12(path3);
13672
14136
  return {
13673
14137
  ok: true,
13674
14138
  path: path3,
13675
- parent: parent === path3 || basename4(path3) === "" ? null : parent,
14139
+ parent: parent === path3 || basename5(path3) === "" ? null : parent,
13676
14140
  home,
13677
14141
  platform: platform(),
13678
14142
  entries: folders,
@@ -13693,12 +14157,12 @@ async function verifyExpectedOrigin(path3, expected2) {
13693
14157
  }
13694
14158
 
13695
14159
  // src/auto-update.ts
13696
- import { execFile as execFile2 } from "node:child_process";
14160
+ import { execFile as execFile3 } from "node:child_process";
13697
14161
  import { realpathSync as realpathSync11 } from "node:fs";
13698
14162
  import { homedir as homedir5 } from "node:os";
13699
- import { dirname as dirname12, join as join19, resolve as resolve10 } from "node:path";
13700
- import { promisify as promisify2 } from "node:util";
13701
- var exec = promisify2(execFile2);
14163
+ import { dirname as dirname13, join as join20, resolve as resolve11 } from "node:path";
14164
+ import { promisify as promisify3 } from "node:util";
14165
+ var exec = promisify3(execFile3);
13702
14166
  function newerStableVersion(candidate, current) {
13703
14167
  const stable = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
13704
14168
  if (typeof candidate !== "string" || !stable.test(candidate) || !stable.test(current)) return false;
@@ -13707,16 +14171,16 @@ function newerStableVersion(candidate, current) {
13707
14171
  return false;
13708
14172
  }
13709
14173
  function serviceNpmEnvironment(entry, home, env) {
13710
- const prefix = join19(home, ".mikka/npm");
13711
- return resolve10(entry) === join19(prefix, "lib/node_modules/@aspectlylabs/mikka/mikka.js") ? { ...env, npm_config_prefix: prefix, npm_config_cache: join19(home, ".mikka/npm-cache") } : env;
14174
+ const prefix = join20(home, ".mikka/npm");
14175
+ return resolve11(entry) === join20(prefix, "lib/node_modules/@aspectlylabs/mikka/mikka.js") ? { ...env, npm_config_prefix: prefix, npm_config_cache: join20(home, ".mikka/npm-cache") } : env;
13712
14176
  }
13713
14177
  async function runServiceNpm(args) {
13714
- const npm = realpathSync11(join19(dirname12(process.execPath), "npm"));
14178
+ const npm = realpathSync11(join20(dirname13(process.execPath), "npm"));
13715
14179
  const { stdout } = await exec(process.execPath, [npm, ...args], {
13716
14180
  cwd: homedir5(),
13717
14181
  timeout: 3e5,
13718
14182
  maxBuffer: 1024 * 1024,
13719
- env: { ...serviceNpmEnvironment(realpathSync11(process.argv[1]), homedir5(), process.env), PATH: `${dirname12(process.execPath)}:${process.env.PATH ?? ""}` }
14183
+ env: { ...serviceNpmEnvironment(realpathSync11(process.argv[1]), homedir5(), process.env), PATH: `${dirname13(process.execPath)}:${process.env.PATH ?? ""}` }
13720
14184
  });
13721
14185
  return stdout.trim();
13722
14186
  }
@@ -13738,12 +14202,12 @@ function reportedUpdateFailure(file, current) {
13738
14202
  }
13739
14203
 
13740
14204
  // src/service.ts
13741
- import { execFile as execFile3 } from "node:child_process";
13742
- import { promisify as promisify3 } from "node:util";
13743
- import { mkdir, readFile, writeFile, rm } from "node:fs/promises";
14205
+ import { execFile as execFile4 } from "node:child_process";
14206
+ import { promisify as promisify4 } from "node:util";
14207
+ import { mkdir as mkdir2, readFile as readFile2, writeFile, rm as rm2 } from "node:fs/promises";
13744
14208
  import { homedir as homedir6 } from "node:os";
13745
- import { dirname as dirname13, join as join20, resolve as resolve11 } from "node:path";
13746
- var exec2 = promisify3(execFile3);
14209
+ import { dirname as dirname14, join as join21, resolve as resolve12 } from "node:path";
14210
+ var exec2 = promisify4(execFile4);
13747
14211
  var label = "com.aspectlylabs.mikka.daemon";
13748
14212
  async function restartService(update, beforeRestart, dependencies = {
13749
14213
  manager: process.env.MIKKA_SERVICE,
@@ -13777,10 +14241,10 @@ async function uninstallService(clearCredential, dependencies = {
13777
14241
  try {
13778
14242
  if (dependencies.manager === "systemd") {
13779
14243
  await dependencies.run("systemctl", ["--user", "disable", "mikka-daemon.service"]);
13780
- await rm(join20(dependencies.home, ".config/systemd/user/mikka-daemon.service"), { force: true });
14244
+ await rm2(join21(dependencies.home, ".config/systemd/user/mikka-daemon.service"), { force: true });
13781
14245
  await dependencies.run("systemctl", ["--user", "daemon-reload"]);
13782
14246
  } else if (dependencies.manager === "launchd") {
13783
- await rm(join20(dependencies.home, "Library/LaunchAgents", `${label}.plist`), { force: true });
14247
+ await rm2(join21(dependencies.home, "Library/LaunchAgents", `${label}.plist`), { force: true });
13784
14248
  }
13785
14249
  } finally {
13786
14250
  clearCredential();
@@ -13793,7 +14257,7 @@ async function uninstallService(clearCredential, dependencies = {
13793
14257
  }
13794
14258
 
13795
14259
  // src/device-type.ts
13796
- import { readdir as readdir3, readFile as readFile2 } from "node:fs/promises";
14260
+ import { readdir as readdir3, readFile as readFile3 } from "node:fs/promises";
13797
14261
  import { execa as execa6 } from "execa";
13798
14262
  async function detectDeviceType() {
13799
14263
  try {
@@ -13809,7 +14273,7 @@ async function detectDeviceType() {
13809
14273
  const entries = await readdir3("/sys/class/power_supply");
13810
14274
  const types = await Promise.all(
13811
14275
  entries.map(
13812
- (entry) => readFile2(`/sys/class/power_supply/${entry}/type`, "utf8").catch(
14276
+ (entry) => readFile3(`/sys/class/power_supply/${entry}/type`, "utf8").catch(
13813
14277
  () => ""
13814
14278
  )
13815
14279
  )
@@ -13827,13 +14291,13 @@ import { arch, platform as platform2 } from "node:os";
13827
14291
  import { execa as execa7 } from "execa";
13828
14292
 
13829
14293
  // harness/install.mjs
13830
- import { createHash as createHash7, randomBytes as randomBytes2 } from "node:crypto";
13831
- import { execFile as execFile4 } from "node:child_process";
13832
- import { createWriteStream, existsSync as existsSync6, mkdirSync as mkdirSync14, readdirSync as readdirSync5, readFileSync as readFileSync10, renameSync as renameSync4, rmSync as rmSync11, statSync as statSync2, symlinkSync, writeFileSync as writeFileSync8 } from "node:fs";
13833
- import { dirname as dirname14, join as join21, relative as relative5 } from "node:path";
14294
+ import { createHash as createHash8, randomBytes as randomBytes2 } from "node:crypto";
14295
+ import { execFile as execFile5 } from "node:child_process";
14296
+ import { createWriteStream as createWriteStream2, existsSync as existsSync6, mkdirSync as mkdirSync14, readdirSync as readdirSync5, readFileSync as readFileSync10, renameSync as renameSync4, rmSync as rmSync11, statSync as statSync2, symlinkSync, writeFileSync as writeFileSync8 } from "node:fs";
14297
+ import { dirname as dirname15, join as join22, relative as relative5 } from "node:path";
13834
14298
  import { Readable as Readable2, Transform } from "node:stream";
13835
- import { pipeline } from "node:stream/promises";
13836
- import { promisify as promisify4 } from "node:util";
14299
+ import { pipeline as pipeline2 } from "node:stream/promises";
14300
+ import { promisify as promisify5 } from "node:util";
13837
14301
 
13838
14302
  // harness/pins.json
13839
14303
  var pins_default = {
@@ -13869,7 +14333,7 @@ var HARNESS_PINS = pins_default;
13869
14333
  var MARKER = ".mikka-installed";
13870
14334
  var INSTALL_FORMAT = "complete-package-v1\n";
13871
14335
  var installMarker = (pin, artifact) => INSTALL_FORMAT + artifact.integrity + (pin.companions?.length ? "\n" + pin.companions.join("\n") : "");
13872
- var run2 = promisify4(execFile4);
14336
+ var run2 = promisify5(execFile5);
13873
14337
  var inflight = /* @__PURE__ */ new Map();
13874
14338
  function platformKey(platform4 = process.platform, arch3 = process.arch) {
13875
14339
  return `${platform4}-${arch3}`;
@@ -13879,19 +14343,19 @@ function resolvePin(store, harness) {
13879
14343
  return { pin, artifact: pin.platforms[store.platform ?? platformKey()] };
13880
14344
  }
13881
14345
  function versionDir(store, harness) {
13882
- return join21(store.root, harness, resolvePin(store, harness).pin.version);
14346
+ return join22(store.root, harness, resolvePin(store, harness).pin.version);
13883
14347
  }
13884
14348
  function harnessBinaryPath(store, harness) {
13885
- return join21(versionDir(store, harness), "bin", resolvePin(store, harness).pin.command);
14349
+ return join22(versionDir(store, harness), "bin", resolvePin(store, harness).pin.command);
13886
14350
  }
13887
14351
  function harnessInstallState(store, harness) {
13888
14352
  const { pin, artifact } = resolvePin(store, harness);
13889
14353
  if (!artifact) return { state: "unsupported", version: pin.version };
13890
14354
  let installed = false;
13891
14355
  try {
13892
- installed = readFileSync10(join21(versionDir(store, harness), MARKER), "utf8") === installMarker(pin, artifact) && runtimeFiles(store, harness).every((path3) => {
13893
- const stat2 = statSync2(path3);
13894
- return stat2.isFile() && (stat2.mode & 73) !== 0;
14356
+ installed = readFileSync10(join22(versionDir(store, harness), MARKER), "utf8") === installMarker(pin, artifact) && runtimeFiles(store, harness).every((path3) => {
14357
+ const stat3 = statSync2(path3);
14358
+ return stat3.isFile() && (stat3.mode & 73) !== 0;
13895
14359
  });
13896
14360
  } catch {
13897
14361
  }
@@ -13899,7 +14363,7 @@ function harnessInstallState(store, harness) {
13899
14363
  }
13900
14364
  function runtimeFiles(store, harness) {
13901
14365
  const binary = harnessBinaryPath(store, harness);
13902
- return harness === "codex" ? [binary, join21(dirname14(binary), "codex-code-mode-host")] : [binary];
14366
+ return harness === "codex" ? [binary, join22(dirname15(binary), "codex-code-mode-host")] : [binary];
13903
14367
  }
13904
14368
  function ensureHarness(store, harness) {
13905
14369
  const key2 = `${store.root}\0${harness}`;
@@ -13916,27 +14380,27 @@ async function install(store, harness) {
13916
14380
  if (state2 === "unsupported") throw new Error(`${harness} has no build for ${store.platform ?? platformKey()}`);
13917
14381
  if (state2 === "installed") return binary;
13918
14382
  const { pin, artifact } = resolvePin(store, harness);
13919
- const parent = join21(store.root, harness);
14383
+ const parent = join22(store.root, harness);
13920
14384
  mkdirSync14(parent, { recursive: true, mode: 448 });
13921
- const staging = join21(parent, `.staging-${randomBytes2(6).toString("hex")}`);
14385
+ const staging = join22(parent, `.staging-${randomBytes2(6).toString("hex")}`);
13922
14386
  mkdirSync14(staging, { recursive: true, mode: 448 });
13923
14387
  try {
13924
- const tarball = join21(staging, "package.tgz");
14388
+ const tarball = join22(staging, "package.tgz");
13925
14389
  await download(`${(store.pins ?? HARNESS_PINS).registry.replace(/\/$/, "")}/${artifact.tarball}`, tarball, artifact.integrity);
13926
14390
  await run2("tar", ["-xzf", tarball, "-C", staging]);
13927
14391
  if (harness === "codex") {
13928
14392
  if (!artifact.entry.endsWith("/bin/codex")) throw new Error("Invalid Codex bundle entry");
13929
- const bundle = dirname14(dirname14(artifact.entry));
13930
- for (const name of readdirSync5(join21(staging, bundle))) symlinkSync(relative5(staging, join21(staging, bundle, name)), join21(staging, name));
14393
+ const bundle = dirname15(dirname15(artifact.entry));
14394
+ for (const name of readdirSync5(join22(staging, bundle))) symlinkSync(relative5(staging, join22(staging, bundle, name)), join22(staging, name));
13931
14395
  for (const name of ["codex", "codex-code-mode-host"]) {
13932
- const stat2 = statSync2(join21(staging, "bin", name));
13933
- if (!stat2.isFile() || (stat2.mode & 73) === 0) throw new Error("Incomplete Codex runtime bundle");
14396
+ const stat3 = statSync2(join22(staging, "bin", name));
14397
+ if (!stat3.isFile() || (stat3.mode & 73) === 0) throw new Error("Incomplete Codex runtime bundle");
13934
14398
  }
13935
14399
  } else {
13936
- mkdirSync14(join21(staging, "bin"), { mode: 448 });
13937
- symlinkSync(relative5(join21(staging, "bin"), join21(staging, artifact.entry)), join21(staging, "bin", pin.command));
14400
+ mkdirSync14(join22(staging, "bin"), { mode: 448 });
14401
+ symlinkSync(relative5(join22(staging, "bin"), join22(staging, artifact.entry)), join22(staging, "bin", pin.command));
13938
14402
  }
13939
- writeFileSync8(join21(staging, MARKER), installMarker(pin, artifact), { mode: 384 });
14403
+ writeFileSync8(join22(staging, MARKER), installMarker(pin, artifact), { mode: 384 });
13940
14404
  const target = versionDir(store, harness);
13941
14405
  const retained = existsSync6(target) ? `${target}.retained-${randomBytes2(6).toString("hex")}` : null;
13942
14406
  if (retained) renameSync4(target, retained);
@@ -13957,12 +14421,12 @@ async function download(url, file, integrity) {
13957
14421
  if (algorithm !== "sha512" || !expected2) throw new Error("Unsupported harness integrity");
13958
14422
  const response = await fetch(url, { redirect: "follow" });
13959
14423
  if (!response.ok || !response.body) throw new Error(`Harness download failed (${response.status})`);
13960
- const hash2 = createHash7("sha512");
14424
+ const hash2 = createHash8("sha512");
13961
14425
  const tap = new Transform({ transform(chunk, _encoding, done) {
13962
14426
  hash2.update(chunk);
13963
14427
  done(null, chunk);
13964
14428
  } });
13965
- await pipeline(Readable2.fromWeb(response.body), tap, createWriteStream(file, { mode: 384 }));
14429
+ await pipeline2(Readable2.fromWeb(response.body), tap, createWriteStream2(file, { mode: 384 }));
13966
14430
  if (hash2.digest("base64") !== expected2) throw new Error("Harness download failed its integrity check");
13967
14431
  }
13968
14432
  function managedHarnessReport(store) {
@@ -14017,8 +14481,8 @@ function harnessFingerprint(store) {
14017
14481
 
14018
14482
  // src/model-probe.ts
14019
14483
  import { spawn as spawn3 } from "node:child_process";
14020
- import { mkdtempSync as mkdtempSync5, readdirSync as readdirSync6, rmSync as rmSync12 } from "node:fs";
14021
- import { join as join22 } from "node:path";
14484
+ import { mkdtempSync as mkdtempSync6, readdirSync as readdirSync6, rmSync as rmSync12 } from "node:fs";
14485
+ import { join as join23 } from "node:path";
14022
14486
 
14023
14487
  // src/process-group.ts
14024
14488
  async function stopGroup(child, graceMs = 3e3) {
@@ -14038,12 +14502,12 @@ async function stopGroup(child, graceMs = 3e3) {
14038
14502
  };
14039
14503
  if (child.exitCode === null && child.signalCode === null) {
14040
14504
  signal("SIGTERM");
14041
- await new Promise((resolve19) => {
14042
- if (child.exitCode !== null || child.signalCode !== null) return resolve19();
14505
+ await new Promise((resolve20) => {
14506
+ if (child.exitCode !== null || child.signalCode !== null) return resolve20();
14043
14507
  const done = () => {
14044
14508
  clearTimeout(timer);
14045
14509
  child.off("exit", done);
14046
- resolve19();
14510
+ resolve20();
14047
14511
  };
14048
14512
  const timer = setTimeout(done, graceMs);
14049
14513
  child.once("exit", done);
@@ -14098,10 +14562,10 @@ function sweepModelProbeHomes(scratchDir) {
14098
14562
  } catch {
14099
14563
  return;
14100
14564
  }
14101
- for (const name of names) if (name.startsWith(HOME_PREFIX)) rmSync12(join22(scratchDir, name), { recursive: true, force: true });
14565
+ for (const name of names) if (name.startsWith(HOME_PREFIX)) rmSync12(join23(scratchDir, name), { recursive: true, force: true });
14102
14566
  }
14103
14567
  async function probeHarnessModels(harness, binary, options) {
14104
- const home = mkdtempSync5(join22(options.scratchDir, HOME_PREFIX));
14568
+ const home = mkdtempSync6(join23(options.scratchDir, HOME_PREFIX));
14105
14569
  try {
14106
14570
  return await exchange(harness, binary, home, options);
14107
14571
  } finally {
@@ -14110,15 +14574,15 @@ async function probeHarnessModels(harness, binary, options) {
14110
14574
  }
14111
14575
  function exchange(harness, binary, home, options) {
14112
14576
  const args = harness === "codex" ? ["app-server"] : ["-p", "--input-format", "stream-json", "--output-format", "stream-json", "--verbose"];
14113
- const env = { PATH: process.env.PATH ?? "", HOME: home, CODEX_HOME: home, CLAUDE_CONFIG_DIR: join22(home, ".claude"), LANG: process.env.LANG ?? "C.UTF-8" };
14114
- return new Promise((resolve19) => {
14577
+ const env = { PATH: process.env.PATH ?? "", HOME: home, CODEX_HOME: home, CLAUDE_CONFIG_DIR: join23(home, ".claude"), LANG: process.env.LANG ?? "C.UTF-8" };
14578
+ return new Promise((resolve20) => {
14115
14579
  const child = (options.spawnImpl ?? spawn3)(binary, args, { env, cwd: home, detached: process.platform !== "win32", stdio: ["pipe", "pipe", "ignore"] });
14116
14580
  let result;
14117
14581
  let stopping;
14118
14582
  const stop = () => stopping ??= Promise.resolve().then(() => stopGroup(child, 0));
14119
14583
  const done = () => {
14120
14584
  clearTimeout(timer);
14121
- resolve19(result ?? null);
14585
+ resolve20(result ?? null);
14122
14586
  };
14123
14587
  const finish = (value) => {
14124
14588
  if (result !== void 0) return;
@@ -14180,22 +14644,22 @@ function exchange(harness, binary, home, options) {
14180
14644
  }
14181
14645
 
14182
14646
  // src/cloud-registration.ts
14183
- import { createHash as createHash8 } from "node:crypto";
14184
- import { join as join23 } from "node:path";
14647
+ import { createHash as createHash9 } from "node:crypto";
14648
+ import { join as join24 } from "node:path";
14185
14649
  function writeCloudRegistration(dataDir, deviceId, workspaceId, credential) {
14186
- writeJsonAtomic(join23(dataDir, "registration.json"), {
14650
+ writeJsonAtomic(join24(dataDir, "registration.json"), {
14187
14651
  version: 1,
14188
14652
  deviceId,
14189
14653
  workspaceId,
14190
- tokenSha256: createHash8("sha256").update(credential).digest("hex")
14654
+ tokenSha256: createHash9("sha256").update(credential).digest("hex")
14191
14655
  });
14192
14656
  }
14193
14657
 
14194
14658
  // src/cloud-model-probe.ts
14195
- import { mkdtempSync as mkdtempSync6, rmSync as rmSync13, statSync as statSync3 } from "node:fs";
14659
+ import { mkdtempSync as mkdtempSync7, rmSync as rmSync13, statSync as statSync3 } from "node:fs";
14196
14660
 
14197
14661
  // src/hosted-binaries.ts
14198
- import { accessSync as accessSync2, constants as constants4, lstatSync as lstatSync10, readFileSync as readFileSync11, realpathSync as realpathSync12 } from "node:fs";
14662
+ import { accessSync as accessSync2, constants as constants5, lstatSync as lstatSync10, readFileSync as readFileSync11, realpathSync as realpathSync12 } from "node:fs";
14199
14663
  import { delimiter as delimiter5, isAbsolute as isAbsolute7 } from "node:path";
14200
14664
  import { z as z34 } from "zod";
14201
14665
  var HOSTED_CLI_MANIFEST = "/opt/mikka/worker/.mikka-original-cli.json";
@@ -14237,7 +14701,7 @@ function executable(path3) {
14237
14701
  if (!path3) return void 0;
14238
14702
  try {
14239
14703
  const resolved = realpathSync12(path3);
14240
- accessSync2(resolved, constants4.X_OK);
14704
+ accessSync2(resolved, constants5.X_OK);
14241
14705
  return lstatSync10(resolved).isFile() ? resolved : void 0;
14242
14706
  } catch {
14243
14707
  return void 0;
@@ -14390,10 +14854,10 @@ async function prepareSubscriptionCredentials(assignment, host) {
14390
14854
 
14391
14855
  // src/run-scratch.ts
14392
14856
  import { rmSync as rmSync14 } from "node:fs";
14393
- import { join as join24 } from "node:path";
14857
+ import { join as join25 } from "node:path";
14394
14858
  function removeRunCredentials(stateDir, runId) {
14395
14859
  const { runDir } = runPaths(stateDir, runId);
14396
- for (const path3 of RUN_CREDENTIAL_PATHS) rmSync14(join24(runDir, path3), { recursive: true, force: true });
14860
+ for (const path3 of RUN_CREDENTIAL_PATHS) rmSync14(join25(runDir, path3), { recursive: true, force: true });
14397
14861
  }
14398
14862
 
14399
14863
  // src/subscription-local-runner.ts
@@ -14469,7 +14933,7 @@ function createLocalSubscriptionRunner(host) {
14469
14933
  finish();
14470
14934
  }
14471
14935
  },
14472
- send: (text4) => session.send(text4),
14936
+ send: (text4, mode) => session.send(text4, mode),
14473
14937
  cancel: async () => {
14474
14938
  try {
14475
14939
  await session.cancel();
@@ -14491,8 +14955,8 @@ function createLocalSubscriptionRunner(host) {
14491
14955
  }
14492
14956
 
14493
14957
  // src/subscription-preflight.ts
14494
- import { mkdtempSync as mkdtempSync7, rmSync as rmSync15 } from "node:fs";
14495
- import { join as join25 } from "node:path";
14958
+ import { mkdtempSync as mkdtempSync8, rmSync as rmSync15 } from "node:fs";
14959
+ import { join as join26 } from "node:path";
14496
14960
  import { execa as execa8 } from "execa";
14497
14961
  var refused = (detail, cause) => ({
14498
14962
  ready: false,
@@ -14511,7 +14975,7 @@ async function preflightLocalSubscription(harness, options) {
14511
14975
  const expected2 = (options.store.pins ?? HARNESS_PINS).harnesses[harness].version;
14512
14976
  let home;
14513
14977
  try {
14514
- home = mkdtempSync7(join25(options.scratchDir, "subscription-preflight-"));
14978
+ home = mkdtempSync8(join26(options.scratchDir, "subscription-preflight-"));
14515
14979
  const result = await execa8(binary, ["--version"], {
14516
14980
  env: { ...env, HOME: home },
14517
14981
  extendEnv: false,
@@ -14575,8 +15039,8 @@ async function acquireCloudWorkspaceControl(input, root = CLOUD_WORKSPACE_CONTRO
14575
15039
  });
14576
15040
  let acquired = false, releasing = false, settled = false, output = "";
14577
15041
  let finished;
14578
- const done = new Promise((resolve19) => {
14579
- finished = resolve19;
15042
+ const done = new Promise((resolve20) => {
15043
+ finished = resolve20;
14580
15044
  });
14581
15045
  child.stdin.on("error", () => {
14582
15046
  if (!settled && !releasing) child.kill("SIGTERM");
@@ -14589,7 +15053,7 @@ async function acquireCloudWorkspaceControl(input, root = CLOUD_WORKSPACE_CONTRO
14589
15053
  if (!acquired || settled || releasing || !child.stdin.writable) throw new CodedError("terminal_control_unavailable", { detail: "fence_lost" });
14590
15054
  child.stdin.write(JSON.stringify(value) + "\n");
14591
15055
  };
14592
- await new Promise((resolve19, reject) => {
15056
+ await new Promise((resolve20, reject) => {
14593
15057
  const fail = (cause) => reject(new CodedError("terminal_control_unavailable", { detail: "fence_unavailable", cause }));
14594
15058
  child.once("error", fail);
14595
15059
  child.stdout.on("data", (data) => {
@@ -14604,7 +15068,7 @@ async function acquireCloudWorkspaceControl(input, root = CLOUD_WORKSPACE_CONTRO
14604
15068
  fail(input.signal.reason);
14605
15069
  return;
14606
15070
  }
14607
- resolve19();
15071
+ resolve20();
14608
15072
  } else if (output.length > 32) {
14609
15073
  child.kill("SIGTERM");
14610
15074
  fail();
@@ -14638,7 +15102,7 @@ async function acquireCloudWorkspaceControl(input, root = CLOUD_WORKSPACE_CONTRO
14638
15102
  // src/lock.ts
14639
15103
  import { mkdirSync as mkdirSync15, readFileSync as readFileSync12, rmSync as rmSync16 } from "node:fs";
14640
15104
  import { createConnection } from "node:net";
14641
- import { join as join26 } from "node:path";
15105
+ import { join as join27 } from "node:path";
14642
15106
  import { setTimeout as sleep2 } from "node:timers/promises";
14643
15107
  import lockfile from "proper-lockfile";
14644
15108
  var DaemonAlreadyRunningError = class extends Error {
@@ -14653,7 +15117,7 @@ var LOCK_STALE_MS = 5 * 6e4;
14653
15117
  var LOCK_UPDATE_MS = 3e4;
14654
15118
  var LOCK_TAKEOVER_MS = 6e3;
14655
15119
  function pidFile(dataDir) {
14656
- return join26(dataDir, "daemon.pid");
15120
+ return join27(dataDir, "daemon.pid");
14657
15121
  }
14658
15122
  function holderPid(dataDir) {
14659
15123
  try {
@@ -14672,11 +15136,11 @@ function processAlive(pid) {
14672
15136
  }
14673
15137
  }
14674
15138
  function socketAnswers(socketPath) {
14675
- return new Promise((resolve19) => {
15139
+ return new Promise((resolve20) => {
14676
15140
  const socket = createConnection(socketPath);
14677
15141
  const done = (alive) => {
14678
15142
  socket.destroy();
14679
- resolve19(alive);
15143
+ resolve20(alive);
14680
15144
  };
14681
15145
  socket.once("connect", () => done(true));
14682
15146
  socket.once("error", () => done(false));
@@ -14785,7 +15249,7 @@ function closeLogger(logger) {
14785
15249
  const file = files.get(logger);
14786
15250
  if (!file) return Promise.resolve();
14787
15251
  files.delete(logger);
14788
- return new Promise((resolve19) => file.end(resolve19));
15252
+ return new Promise((resolve20) => file.end(resolve20));
14789
15253
  }
14790
15254
 
14791
15255
  // src/outbox.ts
@@ -14797,7 +15261,7 @@ import {
14797
15261
  rmSync as rmSync17,
14798
15262
  truncateSync
14799
15263
  } from "node:fs";
14800
- import { join as join27 } from "node:path";
15264
+ import { join as join28 } from "node:path";
14801
15265
  var Outbox = class {
14802
15266
  constructor(dir, link, log, retryMs = 1e3, onUndeliverable = () => void 0, retainResources = false, traceContext = () => void 0) {
14803
15267
  this.dir = dir;
@@ -14822,10 +15286,10 @@ var Outbox = class {
14822
15286
  /** Runs whose file was checked for a torn tail since this process started. */
14823
15287
  repaired = /* @__PURE__ */ new Set();
14824
15288
  file(runId) {
14825
- return join27(this.dir, `${assertSafeId("run id", runId)}.jsonl`);
15289
+ return join28(this.dir, `${assertSafeId("run id", runId)}.jsonl`);
14826
15290
  }
14827
15291
  ackFile(runId) {
14828
- return join27(this.dir, `${assertSafeId("run id", runId)}.ack.json`);
15292
+ return join28(this.dir, `${assertSafeId("run id", runId)}.ack.json`);
14829
15293
  }
14830
15294
  parse(runId) {
14831
15295
  let data;
@@ -15011,11 +15475,11 @@ var Outbox = class {
15011
15475
  };
15012
15476
 
15013
15477
  // src/quota/files.ts
15014
- import { execFile as execFile5 } from "node:child_process";
15015
- import { constants as constants5 } from "node:fs";
15016
- import { promisify as promisify5 } from "node:util";
15017
- var NOFOLLOW = constants5.O_NOFOLLOW ?? 0;
15018
- var execFileAsync = promisify5(execFile5);
15478
+ import { execFile as execFile6 } from "node:child_process";
15479
+ import { constants as constants6 } from "node:fs";
15480
+ import { promisify as promisify6 } from "node:util";
15481
+ var NOFOLLOW = constants6.O_NOFOLLOW ?? 0;
15482
+ var execFileAsync = promisify6(execFile6);
15019
15483
  var MAX_CREDENTIAL_BYTES = 64 * 1024;
15020
15484
  function sanitizeError(error) {
15021
15485
  const raw = error instanceof Error ? error.message : String(error);
@@ -15175,9 +15639,9 @@ var RpcServer = class {
15175
15639
  const { socketPath } = this.options;
15176
15640
  rmSync18(socketPath, { force: true });
15177
15641
  const server = createServer2((socket) => this.accept(socket));
15178
- await new Promise((resolve19, reject) => {
15642
+ await new Promise((resolve20, reject) => {
15179
15643
  server.once("error", reject);
15180
- server.listen(socketPath, () => resolve19());
15644
+ server.listen(socketPath, () => resolve20());
15181
15645
  });
15182
15646
  chmodSync(socketPath, 384);
15183
15647
  this.server = server;
@@ -15241,9 +15705,9 @@ var RpcServer = class {
15241
15705
  }
15242
15706
  async close() {
15243
15707
  for (const socket of this.sockets) socket.destroy();
15244
- await new Promise((resolve19) => {
15245
- if (!this.server) return resolve19();
15246
- this.server.close(() => resolve19());
15708
+ await new Promise((resolve20) => {
15709
+ if (!this.server) return resolve20();
15710
+ this.server.close(() => resolve20());
15247
15711
  });
15248
15712
  this.server = null;
15249
15713
  rmSync18(this.options.socketPath, { force: true });
@@ -15471,7 +15935,7 @@ async function startTaskSecretBridge(options) {
15471
15935
  };
15472
15936
  options.signal.addEventListener("abort", close, { once: true });
15473
15937
  try {
15474
- await new Promise((resolve19, reject) => {
15938
+ await new Promise((resolve20, reject) => {
15475
15939
  const cleanup = () => {
15476
15940
  server.off("error", failed);
15477
15941
  options.signal.removeEventListener("abort", cancelled);
@@ -15492,7 +15956,7 @@ async function startTaskSecretBridge(options) {
15492
15956
  }
15493
15957
  server.listen(0, "127.0.0.1", () => {
15494
15958
  cleanup();
15495
- resolve19();
15959
+ resolve20();
15496
15960
  });
15497
15961
  });
15498
15962
  options.signal.throwIfAborted();
@@ -15521,9 +15985,9 @@ async function startTaskSecretBridge(options) {
15521
15985
  }
15522
15986
 
15523
15987
  // src/agents/chat-files.ts
15524
- import { createHash as createHash9 } from "node:crypto";
15525
- import { lstat as lstat2, mkdir as mkdir2, readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
15526
- import { join as join28 } from "node:path";
15988
+ import { createHash as createHash10 } from "node:crypto";
15989
+ import { lstat as lstat3, mkdir as mkdir3, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
15990
+ import { join as join29 } from "node:path";
15527
15991
 
15528
15992
  // ../protocol/src/chat-attachments.ts
15529
15993
  import { z as z35 } from "zod";
@@ -15575,31 +16039,31 @@ function splitChatFiles(text4) {
15575
16039
  async function materializeChatFiles(text4, directory, download2) {
15576
16040
  const parsed = splitChatFiles(text4);
15577
16041
  if (!parsed.files.length) return text4;
15578
- await mkdir2(directory, { recursive: true, mode: 448 });
15579
- if (!(await lstat2(directory)).isDirectory() || (await lstat2(directory)).isSymbolicLink())
16042
+ await mkdir3(directory, { recursive: true, mode: 448 });
16043
+ if (!(await lstat3(directory)).isDirectory() || (await lstat3(directory)).isSymbolicLink())
15580
16044
  throw Error("Attachment directory unavailable");
15581
16045
  const entries = [];
15582
16046
  for (const ref of parsed.files) {
15583
16047
  const file = chatFileDownloadSchema.parse(await download2(ref.id));
15584
16048
  if (file.id !== ref.id) throw Error("Attachment identity mismatch");
15585
16049
  const bytes = Buffer.from(file.data, "base64");
15586
- if (bytes.length !== file.size || bytes.toString("base64") !== file.data || createHash9("sha256").update(bytes).digest("hex") !== file.sha256)
16050
+ if (bytes.length !== file.size || bytes.toString("base64") !== file.data || createHash10("sha256").update(bytes).digest("hex") !== file.sha256)
15587
16051
  throw Error("Attachment content mismatch");
15588
16052
  const ext = /\.([a-z0-9]{1,12})$/i.exec(file.name)?.[1]?.toLowerCase() ?? "bin";
15589
- const path3 = join28(directory, `${file.id}.${ext}`);
16053
+ const path3 = join29(directory, `${file.id}.${ext}`);
15590
16054
  try {
15591
16055
  await writeFile2(path3, bytes, { flag: "wx", mode: 256 });
15592
16056
  } catch (error) {
15593
- if (error.code !== "EEXIST" || (await lstat2(path3)).isSymbolicLink() || createHash9("sha256").update(await readFile3(path3)).digest("hex") !== file.sha256)
16057
+ if (error.code !== "EEXIST" || (await lstat3(path3)).isSymbolicLink() || createHash10("sha256").update(await readFile4(path3)).digest("hex") !== file.sha256)
15594
16058
  throw Error("Attachment file unavailable");
15595
16059
  }
15596
16060
  let textPath;
15597
16061
  if (file.text !== null) {
15598
- textPath = join28(directory, `${file.id}.extracted.txt`);
16062
+ textPath = join29(directory, `${file.id}.extracted.txt`);
15599
16063
  try {
15600
16064
  await writeFile2(textPath, file.text, { flag: "wx", mode: 256 });
15601
16065
  } catch (error) {
15602
- if (error.code !== "EEXIST" || (await lstat2(textPath)).isSymbolicLink() || await readFile3(textPath, "utf8") !== file.text)
16066
+ if (error.code !== "EEXIST" || (await lstat3(textPath)).isSymbolicLink() || await readFile4(textPath, "utf8") !== file.text)
15603
16067
  throw Error("Attachment text unavailable");
15604
16068
  }
15605
16069
  }
@@ -15789,23 +16253,23 @@ function createRunMasker(secrets) {
15789
16253
 
15790
16254
  // src/runs/supervisor.ts
15791
16255
  import { stdSerializers } from "pino";
15792
- import { createHash as createHash11, randomUUID as randomUUID6 } from "node:crypto";
15793
- import { join as join30, resolve as resolve13 } from "node:path";
15794
- import { tmpdir as tmpdir4 } from "node:os";
16256
+ import { createHash as createHash12, randomUUID as randomUUID6 } from "node:crypto";
16257
+ import { join as join31, resolve as resolve14 } from "node:path";
16258
+ import { tmpdir as tmpdir5 } from "node:os";
15795
16259
  import { execa as execa12 } from "execa";
15796
16260
 
15797
16261
  // src/agents/checkpoint.ts
15798
- import { mkdtempSync as mkdtempSync8, rmSync as rmSync19, writeFileSync as writeFileSync9 } from "node:fs";
15799
- import { tmpdir as tmpdir3 } from "node:os";
15800
- import { join as join29 } from "node:path";
16262
+ import { mkdtempSync as mkdtempSync9, rmSync as rmSync19, writeFileSync as writeFileSync9 } from "node:fs";
16263
+ import { tmpdir as tmpdir4 } from "node:os";
16264
+ import { join as join30 } from "node:path";
15801
16265
  import { gunzipSync as gunzipSync2, gzipSync as gzipSync2 } from "node:zlib";
15802
16266
  import { execa as execa11 } from "execa";
15803
16267
 
15804
16268
  // src/coding-workspace/checkpoint.ts
15805
- import { createHash as createHash10 } from "node:crypto";
15806
- import { resolve as resolve12 } from "node:path";
16269
+ import { createHash as createHash11 } from "node:crypto";
16270
+ import { resolve as resolve13 } from "node:path";
15807
16271
  import { execa as execa10 } from "execa";
15808
- var digest6 = (value) => createHash10("sha256").update(value).digest("hex");
16272
+ var digest6 = (value) => createHash11("sha256").update(value).digest("hex");
15809
16273
  var oid = /^[a-f0-9]{40}(?:[a-f0-9]{24})?$/;
15810
16274
  var MANIFEST_BYTES = 1536 * 1024;
15811
16275
  var regular = (mode) => mode === null || mode === "100644" || mode === "100755";
@@ -15837,7 +16301,7 @@ async function captureCheckpointReview(input) {
15837
16301
  const env = {
15838
16302
  ...buildChildEnv({}),
15839
16303
  GIT_DIR: gitDir,
15840
- GIT_COMMON_DIR: resolve12(gitDir, "..", ".."),
16304
+ GIT_COMMON_DIR: resolve13(gitDir, "..", ".."),
15841
16305
  GIT_WORK_TREE: input.worktree,
15842
16306
  GIT_CONFIG_NOSYSTEM: "1",
15843
16307
  GIT_CONFIG_GLOBAL: "/dev/null",
@@ -16024,8 +16488,8 @@ async function takeCheckpoint(options) {
16024
16488
  }
16025
16489
  async function applyCheckpoint(options) {
16026
16490
  const git3 = await pinnedGit(options.repoPath, options.worktree);
16027
- const dir = mkdtempSync8(join29(tmpdir3(), "mikka-checkpoint-"));
16028
- const file = join29(dir, "checkpoint.patch");
16491
+ const dir = mkdtempSync9(join30(tmpdir4(), "mikka-checkpoint-"));
16492
+ const file = join30(dir, "checkpoint.patch");
16029
16493
  try {
16030
16494
  const patch = gunzipSync2(Buffer.from(options.checkpoint.patch, "base64"));
16031
16495
  if (!patch.length && options.checkpoint.files === 0) return true;
@@ -16058,7 +16522,7 @@ async function hasCommit(repoPath, commit) {
16058
16522
 
16059
16523
  // src/server-link.ts
16060
16524
  import { randomUUID as randomUUID5 } from "node:crypto";
16061
- import { pathToFileURL as pathToFileURL2 } from "node:url";
16525
+ import { pathToFileURL as pathToFileURL3 } from "node:url";
16062
16526
  var MAX_CONTINUES = 3;
16063
16527
  var MAX_CRASH_RETRIES = 3;
16064
16528
  var MAX_FIX_ROUNDS = 3;
@@ -16142,7 +16606,7 @@ var MemoryServer = class {
16142
16606
  const runId = run3.runId ?? randomUUID5();
16143
16607
  const fixturePath = this.repos.get(deviceId)?.find((repo) => repo.repoId === run3.repoId)?.path;
16144
16608
  this.runs.set(runId, {
16145
- assignment: { ...run3, runId, remoteUrl: run3.remoteUrl ?? (fixturePath ? pathToFileURL2(fixturePath).href : void 0) },
16609
+ assignment: { ...run3, runId, remoteUrl: run3.remoteUrl ?? (fixturePath ? pathToFileURL3(fixturePath).href : void 0) },
16146
16610
  deviceId,
16147
16611
  state: "queued",
16148
16612
  patches: []
@@ -16280,12 +16744,12 @@ var MemoryServer = class {
16280
16744
  this.check();
16281
16745
  let pending = this.pendingCommands(deviceId, skip);
16282
16746
  if (pending.length === 0 && waitSeconds > 0 && !signal?.aborted) {
16283
- await new Promise((resolve19) => {
16284
- const timer = setTimeout(resolve19, waitSeconds * 1e3);
16285
- signal?.addEventListener("abort", () => resolve19(), { once: true });
16747
+ await new Promise((resolve20) => {
16748
+ const timer = setTimeout(resolve20, waitSeconds * 1e3);
16749
+ signal?.addEventListener("abort", () => resolve20(), { once: true });
16286
16750
  this.wakeCommands.push(() => {
16287
16751
  clearTimeout(timer);
16288
- resolve19();
16752
+ resolve20();
16289
16753
  });
16290
16754
  });
16291
16755
  this.check();
@@ -16753,10 +17217,11 @@ var RunSupervisor = class {
16753
17217
  check();
16754
17218
  await this.send(runId, mailboxNoticeText(runId, messageIds));
16755
17219
  }
16756
- async send(runId, text4) {
17220
+ async send(runId, text4, mode) {
16757
17221
  const run3 = this.active.get(runId);
16758
17222
  const adapter = this.adapterFor(runId);
16759
17223
  if (!run3?.session) throw new RunNotFoundError(runId);
17224
+ if (mode === "steer" && adapter.harness !== "codex") throw new Error("Active turn steering unavailable");
16760
17225
  if (!adapter.capabilities.supportsInterject) {
16761
17226
  throw new Error(
16762
17227
  `Harness "${adapter.harness}" cannot take messages mid-run`
@@ -16766,9 +17231,9 @@ var RunSupervisor = class {
16766
17231
  const entry = this.deps.journal.get(runId);
16767
17232
  if (splitChatFiles(text4).files.length) {
16768
17233
  if (!entry || !this.deps.downloadChatFile || !this.deps.adapterStateDir) throw Error("Run attachments unavailable");
16769
- text4 = await materializeChatFiles(text4, join30(this.deps.adapterStateDir, "inputs", runId), (id5) => this.deps.downloadChatFile(entry.assignment, id5, run3.abort.signal));
17234
+ text4 = await materializeChatFiles(text4, join31(this.deps.adapterStateDir, "inputs", runId), (id5) => this.deps.downloadChatFile(entry.assignment, id5, run3.abort.signal));
16770
17235
  }
16771
- await run3.session.send(text4);
17236
+ await run3.session.send(text4, mode);
16772
17237
  }
16773
17238
  async cancel(runId) {
16774
17239
  const entry = this.deps.journal.get(runId);
@@ -16796,9 +17261,9 @@ var RunSupervisor = class {
16796
17261
  run3.abort.abort();
16797
17262
  }
16798
17263
  let timer;
16799
- const grace = new Promise((resolve19) => {
17264
+ const grace = new Promise((resolve20) => {
16800
17265
  timer = setTimeout(
16801
- resolve19,
17266
+ resolve20,
16802
17267
  this.deps.stopGraceMs ?? DEFAULT_STOP_GRACE_MS
16803
17268
  );
16804
17269
  });
@@ -16824,10 +17289,10 @@ var RunSupervisor = class {
16824
17289
  this.active.get(runId)?.runtimeTiming?.chunk(chunk);
16825
17290
  if (chunk.type.startsWith("data-") && "transient" in chunk && chunk.transient)
16826
17291
  return this.append(runId, chunk);
16827
- const open4 = this.openParts.get(runId) ?? /* @__PURE__ */ new Set();
16828
- this.openParts.set(runId, open4);
16829
- if (this.cutMessages.has(runId) && open4.size === 0) this.endMessage(runId);
16830
- trackParts(open4, chunk);
17292
+ const open5 = this.openParts.get(runId) ?? /* @__PURE__ */ new Set();
17293
+ this.openParts.set(runId, open5);
17294
+ if (this.cutMessages.has(runId) && open5.size === 0) this.endMessage(runId);
17295
+ trackParts(open5, chunk);
16831
17296
  if (chunk.type === "start") {
16832
17297
  this.endMessage(runId);
16833
17298
  this.openMessages.add(runId);
@@ -16835,7 +17300,7 @@ var RunSupervisor = class {
16835
17300
  if (!this.openMessages.has(runId)) return;
16836
17301
  this.openMessages.delete(runId);
16837
17302
  this.cutMessages.delete(runId);
16838
- open4.clear();
17303
+ open5.clear();
16839
17304
  } else if (!this.openMessages.has(runId)) {
16840
17305
  this.append(runId, { type: "start", messageId: randomUUID6() });
16841
17306
  this.openMessages.add(runId);
@@ -17086,16 +17551,22 @@ var RunSupervisor = class {
17086
17551
  }
17087
17552
  });
17088
17553
  }
17089
- /** Waits for the run's capture uploads, but never longer than a minute. */
17090
- async flushCaptures(runId) {
17554
+ /** One minute for preparation and upload; cancellation drains before the terminal event. */
17555
+ async flushCaptures(runId, signal) {
17091
17556
  if (!this.deps.captures) return true;
17092
- let timer;
17093
- return Promise.race([
17094
- this.deps.captures.flush(runId).then(() => true),
17095
- new Promise((resolve19) => {
17096
- timer = setTimeout(() => resolve19(false), 6e4);
17097
- })
17098
- ]).finally(() => clearTimeout(timer));
17557
+ const deadline = new AbortController();
17558
+ const finishing = AbortSignal.any([signal, deadline.signal]);
17559
+ const timer = setTimeout(() => deadline.abort(new Error("Capture finalization deadline exceeded")), 6e4);
17560
+ try {
17561
+ await this.deps.captures.flush(runId, false, finishing);
17562
+ finishing.throwIfAborted();
17563
+ return true;
17564
+ } catch (error) {
17565
+ if (signal.aborted) return false;
17566
+ throw error;
17567
+ } finally {
17568
+ clearTimeout(timer);
17569
+ }
17099
17570
  }
17100
17571
  /** Only the local lease and pushed stop state govern host finishing work. */
17101
17572
  assertFinishingRunLive(runId, signal) {
@@ -17119,11 +17590,11 @@ var RunSupervisor = class {
17119
17590
  if (configured.length === 0) return void 0;
17120
17591
  const loaded = [];
17121
17592
  if (this.deps.adapterStateDir) {
17122
- const dir = join30(runPaths(this.deps.adapterStateDir, runId).runDir, PROFILE_SKILLS_DIR, PROFILE_SKILL_LOADS_DIR);
17593
+ const dir = join31(runPaths(this.deps.adapterStateDir, runId).runDir, PROFILE_SKILLS_DIR, PROFILE_SKILL_LOADS_DIR);
17123
17594
  try {
17124
17595
  for (const name of readdirSync8(dir).sort()) {
17125
17596
  if (!name.endsWith(".json") || loaded.length >= configured.length) continue;
17126
- const file = join30(dir, name), meta = lstatSync11(file, { throwIfNoEntry: false });
17597
+ const file = join31(dir, name), meta = lstatSync11(file, { throwIfNoEntry: false });
17127
17598
  if (!meta?.isFile() || meta.isSymbolicLink() || meta.nlink !== 1 || meta.size < 2 || meta.size > 4096) continue;
17128
17599
  const receipt = profileSkillLoadReceiptSchema.safeParse(JSON.parse(readFileSync14(file, "utf8")));
17129
17600
  if (!receipt.success || loaded.some((item) => item.id === receipt.data.id)) continue;
@@ -17267,7 +17738,7 @@ var RunSupervisor = class {
17267
17738
  try {
17268
17739
  return await withRunGitCredentials(
17269
17740
  assignment,
17270
- runPaths(this.deps.adapterStateDir ?? join30(tmpdir4(), "mikka-run-state"), runId).privateDir,
17741
+ runPaths(this.deps.adapterStateDir ?? join31(tmpdir5(), "mikka-run-state"), runId).privateDir,
17271
17742
  (env) => this.deps.worktrees.fetchBranch(
17272
17743
  repo.path,
17273
17744
  repo.push?.remote ?? "origin",
@@ -17338,7 +17809,15 @@ var RunSupervisor = class {
17338
17809
  }, { root: true, traceContext: assignment?.traceContext }).catch(async (error) => {
17339
17810
  run3.repositoryPreparing?.refuseEffects(error);
17340
17811
  run3.repositoryPreparing?.abort.abort();
17341
- await Promise.all([run3.repositoryPreparing?.done.catch(() => void 0), this.closePrepared(run3)]);
17812
+ await Promise.all([
17813
+ run3.repositoryPreparing?.done.catch(() => void 0),
17814
+ this.closePrepared(run3),
17815
+ Promise.resolve().then(() => this.deps.captures?.flush(
17816
+ runId,
17817
+ false,
17818
+ AbortSignal.abort(new Error("Capture finalization cancelled"))
17819
+ )).catch(() => void 0)
17820
+ ]);
17342
17821
  run3.runtimeTiming?.finishing();
17343
17822
  const message = error instanceof Error ? error.message : String(error);
17344
17823
  this.deps.log.error({ run_id: runId, err: this.logError(runId, error) }, "run failed");
@@ -17409,8 +17888,8 @@ var RunSupervisor = class {
17409
17888
  });
17410
17889
  if (readAbort) {
17411
17890
  let allowEffects, refuseEffects;
17412
- const entryReady = new Promise((resolve19, reject) => {
17413
- allowEffects = resolve19;
17891
+ const entryReady = new Promise((resolve20, reject) => {
17892
+ allowEffects = resolve20;
17414
17893
  refuseEffects = reject;
17415
17894
  });
17416
17895
  const authorized = Promise.all([policyReady, entryReady]);
@@ -17644,7 +18123,7 @@ var RunSupervisor = class {
17644
18123
  let followUp = assignment.followUp;
17645
18124
  if (splitChatFiles(prompt).files.length || followUp && splitChatFiles(followUp).files.length) {
17646
18125
  if (!this.deps.downloadChatFile || !this.deps.adapterStateDir) throw Error("Run attachments unavailable");
17647
- const directory = join30(this.deps.adapterStateDir, "inputs", runId);
18126
+ const directory = join31(this.deps.adapterStateDir, "inputs", runId);
17648
18127
  const download2 = (id5) => this.deps.downloadChatFile(assignment, id5, run3.abort.signal);
17649
18128
  prompt = await materializeChatFiles(prompt, directory, download2);
17650
18129
  if (followUp) followUp = await materializeChatFiles(followUp, directory, download2);
@@ -17657,7 +18136,7 @@ var RunSupervisor = class {
17657
18136
  gitWritePaths: await worktreeGitWritePaths(repo.path, worktree, runId)
17658
18137
  };
17659
18138
  const resuming = entry.sessionId !== null && adapter.capabilities.supportsResume;
17660
- const inEarlierWorktree = continued !== null || entry.worktree !== null && resolve13(entry.worktree) !== resolve13(this.deps.worktrees.pathFor(runId));
18139
+ const inEarlierWorktree = continued !== null || entry.worktree !== null && resolve14(entry.worktree) !== resolve14(this.deps.worktrees.pathFor(runId));
17661
18140
  const continueSession = !resuming && assignment.resumeSessionId && assignment.continuesRunId && inEarlierWorktree && adapter.capabilities.supportsResume ? {
17662
18141
  sessionId: assignment.resumeSessionId,
17663
18142
  runId: assignment.continuesRunId,
@@ -17666,13 +18145,13 @@ var RunSupervisor = class {
17666
18145
  if (assignment.requireSessionResume && (!assignment.resumeSessionId || !assignment.continuesRunId || !adapter.capabilities.supportsResume || !resuming && !continueSession || resuming && entry.sessionId !== assignment.resumeSessionId))
17667
18146
  throw new Error("factory_question_session_resume_required");
17668
18147
  const benchmark = assignment.benchmark;
17669
- const policyDigest = assignment.skillReceipt ? createHash11("sha256").update(runPolicyDigestInput(assignment.policy)).digest("hex") : void 0;
18148
+ const policyDigest = assignment.skillReceipt ? createHash12("sha256").update(runPolicyDigestInput(assignment.policy)).digest("hex") : void 0;
17670
18149
  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");
17671
18150
  let fixtureDigest;
17672
18151
  if (benchmark) {
17673
18152
  if (runPolicy(assignment.policy).readOnly !== true) throw new Error("Benchmark fixture must be read-only");
17674
18153
  const fixed = await fixedCheckSnapshot(repo.path, worktree, benchmark.sourceCommit);
17675
- fixtureDigest = createHash11("sha256").update(fixed.sha).digest("hex");
18154
+ fixtureDigest = createHash12("sha256").update(fixed.sha).digest("hex");
17676
18155
  if (fixtureDigest !== benchmark.fixtureDigest) throw new Error("Frozen benchmark fixture digest mismatch");
17677
18156
  }
17678
18157
  const previousMount = entry.skillMount;
@@ -17713,7 +18192,7 @@ var RunSupervisor = class {
17713
18192
  if (!this.deps.adapterStateDir || assignment.harness === "mock" || !session.sessionId || resuming && session.sessionId !== entry.sessionId || assignment.requireSessionResume && session.sessionId !== assignment.resumeSessionId)
17714
18193
  throw new Error("Skill mount requires the actual original harness session");
17715
18194
  verifySkillAssignment(assignment);
17716
- const file = join30(
18195
+ const file = join31(
17717
18196
  runPaths(this.deps.adapterStateDir, runId).runDir,
17718
18197
  SKILLS_DIR,
17719
18198
  skillSlug(assignment.skills[0].name),
@@ -17830,7 +18309,7 @@ var RunSupervisor = class {
17830
18309
  try {
17831
18310
  if (assignment.benchmark && !run3.cancelRequested) {
17832
18311
  const fixed = await fixedCheckSnapshot(repo.path, worktree, assignment.benchmark.sourceCommit, finishingSignal);
17833
- if (createHash11("sha256").update(fixed.sha).digest("hex") !== assignment.benchmark.fixtureDigest)
18312
+ if (createHash12("sha256").update(fixed.sha).digest("hex") !== assignment.benchmark.fixtureDigest)
17834
18313
  throw new Error("Benchmark fixture changed during model execution");
17835
18314
  }
17836
18315
  outcome = await this.report(runId, worktree, repo, assignment, stopReason, error, event.report, finishingSignal);
@@ -17867,7 +18346,7 @@ var RunSupervisor = class {
17867
18346
  report2 = { ...report2, publish };
17868
18347
  stopReason = stopReasonOf(event, run3, assignment);
17869
18348
  }
17870
- const capturesSaved = !this.stopping && await this.flushCaptures(runId);
18349
+ const capturesSaved = !this.stopping && await this.flushCaptures(runId, finishingSignal);
17871
18350
  stopReason = stopReasonOf(event, run3, assignment);
17872
18351
  const checkpoint = await this.saveTerminalCheckpoint(runId, run3, capturesSaved);
17873
18352
  if (stopReason === "provider_failure" || stopReason === "quota_exhausted") report2 = { ...report2, providerCheckpoint: checkpoint.checkpoint };
@@ -17891,33 +18370,33 @@ var RunSupervisor = class {
17891
18370
  }
17892
18371
  }
17893
18372
  };
17894
- function trackParts(open4, chunk) {
18373
+ function trackParts(open5, chunk) {
17895
18374
  switch (chunk.type) {
17896
18375
  case "text-start":
17897
18376
  case "reasoning-start":
17898
- open4.add(`${chunk.type.split("-")[0]}:${chunk.id}`);
18377
+ open5.add(`${chunk.type.split("-")[0]}:${chunk.id}`);
17899
18378
  break;
17900
18379
  case "text-end":
17901
18380
  case "reasoning-end":
17902
- open4.delete(`${chunk.type.split("-")[0]}:${chunk.id}`);
18381
+ open5.delete(`${chunk.type.split("-")[0]}:${chunk.id}`);
17903
18382
  break;
17904
18383
  case "tool-input-start":
17905
18384
  case "tool-input-available":
17906
- open4.add(`tool:${chunk.toolCallId}`);
18385
+ open5.add(`tool:${chunk.toolCallId}`);
17907
18386
  break;
17908
18387
  case "tool-output-available":
17909
18388
  case "tool-output-error":
17910
18389
  case "tool-output-denied":
17911
- open4.delete(`tool:${chunk.toolCallId}`);
18390
+ open5.delete(`tool:${chunk.toolCallId}`);
17912
18391
  break;
17913
18392
  }
17914
18393
  }
17915
18394
  var ABORTED = /* @__PURE__ */ Symbol("aborted");
17916
18395
  function abortPromise(signal) {
17917
- return new Promise((resolve19) => {
17918
- if (signal.aborted) resolve19(ABORTED);
18396
+ return new Promise((resolve20) => {
18397
+ if (signal.aborted) resolve20(ABORTED);
17919
18398
  else
17920
- signal.addEventListener("abort", () => resolve19(ABORTED), { once: true });
18399
+ signal.addEventListener("abort", () => resolve20(ABORTED), { once: true });
17921
18400
  });
17922
18401
  }
17923
18402
  function pickAgentReport(agent) {
@@ -17926,6 +18405,8 @@ function pickAgentReport(agent) {
17926
18405
  if (agent.repositorySelection) picked.repositorySelection = agent.repositorySelection;
17927
18406
  if (agent.verificationCommand && typeof agent.verificationCommand.command === "string" && agent.verificationCommand.command.trim() && typeof agent.verificationCommand.basis === "string" && agent.verificationCommand.basis.trim())
17928
18407
  picked.verificationCommand = { command: agent.verificationCommand.command.trim().slice(0, 2e3), basis: agent.verificationCommand.basis.trim().slice(0, 2e3) };
18408
+ const visualEvidence = runVisualEvidence.safeParse(agent.visualEvidence);
18409
+ if (visualEvidence.success) picked.visualEvidence = visualEvidence.data;
17929
18410
  const verdict = reviewVerdict.safeParse(agent.reviewVerdict);
17930
18411
  if (verdict.success) picked.reviewVerdict = verdict.data;
17931
18412
  if (typeof agent.summary === "string")
@@ -18041,7 +18522,7 @@ var DeviceGatewayClosedError = class extends Error {
18041
18522
  };
18042
18523
  function runDeviceGateway(socket, options) {
18043
18524
  const pingMs = options.pingMs ?? DEVICE_GATEWAY_PING_MS;
18044
- return new Promise((resolve19, reject) => {
18525
+ return new Promise((resolve20, reject) => {
18045
18526
  let settled = false;
18046
18527
  let opened = false;
18047
18528
  let pulling = false;
@@ -18060,7 +18541,7 @@ function runDeviceGateway(socket, options) {
18060
18541
  } catch {
18061
18542
  }
18062
18543
  if (error && !options.signal.aborted) reject(error);
18063
- else resolve19();
18544
+ else resolve20();
18064
18545
  };
18065
18546
  const work = () => {
18066
18547
  if (settled) return;
@@ -18139,27 +18620,27 @@ var SessionRejectedError = class extends DaemonError {
18139
18620
  };
18140
18621
 
18141
18622
  // src/coding-workspace/files.ts
18142
- import { constants as constants6 } from "node:fs";
18143
- import { open, readFile as readFile4, realpath as realpath2 } from "node:fs/promises";
18144
- import { execFile as execFile6 } from "node:child_process";
18145
- import { promisify as promisify6 } from "node:util";
18146
- import { createHash as createHash12 } from "node:crypto";
18147
- import { extname, resolve as resolve14 } from "node:path";
18148
- var execute = promisify6(execFile6);
18149
- var hash = (value) => createHash12("sha256").update(value).digest("hex");
18623
+ import { constants as constants7 } from "node:fs";
18624
+ import { open as open2, readFile as readFile5, realpath as realpath2 } from "node:fs/promises";
18625
+ import { execFile as execFile7 } from "node:child_process";
18626
+ import { promisify as promisify7 } from "node:util";
18627
+ import { createHash as createHash13 } from "node:crypto";
18628
+ import { extname, resolve as resolve15 } from "node:path";
18629
+ var execute2 = promisify7(execFile7);
18630
+ var hash = (value) => createHash13("sha256").update(value).digest("hex");
18150
18631
  var denied = () => new CodingWorkspaceError("workspace_path_unavailable");
18151
18632
  function isFileReadRequest(request2) {
18152
18633
  return request2.kind === "file" || request2.kind === "tree" || request2.kind === "search" || request2.kind === "context";
18153
18634
  }
18154
18635
  var safeDotfiles2 = /* @__PURE__ */ new Set([".gitignore", ".gitattributes", ".editorconfig", ".prettierignore", ".prettierrc", ".eslintrc", ".dockerignore"]);
18155
18636
  async function mountId(handle) {
18156
- const id5 = /^mnt_id:\s*(\d+)$/m.exec(await readFile4(`/proc/self/fdinfo/${handle.fd}`, "utf8"))?.[1];
18637
+ const id5 = /^mnt_id:\s*(\d+)$/m.exec(await readFile5(`/proc/self/fdinfo/${handle.fd}`, "utf8"))?.[1];
18157
18638
  if (!id5) throw new CodingWorkspaceError("workspace_unsupported");
18158
18639
  return id5;
18159
18640
  }
18160
18641
  async function git2(root, args, maxBuffer = 2 * 1024 * 1024) {
18161
18642
  try {
18162
- const { stdout } = await execute("git", ["--no-optional-locks", "-c", "core.fsmonitor=false", "-c", "core.hooksPath=/dev/null", ...args], {
18643
+ const { stdout } = await execute2("git", ["--no-optional-locks", "-c", "core.fsmonitor=false", "-c", "core.hooksPath=/dev/null", ...args], {
18163
18644
  // chdir resolves the parent's open directory before exec closes FDs.
18164
18645
  // /proc/self works even when the visible procfs uses another PID namespace.
18165
18646
  cwd: root.gitPath,
@@ -18186,16 +18667,16 @@ async function safeFile(root, path3, use) {
18186
18667
  const parts = path3.split("/");
18187
18668
  for (let index = 0; index < parts.length; index++) {
18188
18669
  const directory = index < parts.length - 1;
18189
- const handle = await open(`/proc/self/fd/${parent.fd}/${parts[index]}`, constants6.O_RDONLY | constants6.O_NOFOLLOW | constants6.O_NONBLOCK | (directory ? constants6.O_DIRECTORY : 0));
18670
+ const handle = await open2(`/proc/self/fd/${parent.fd}/${parts[index]}`, constants7.O_RDONLY | constants7.O_NOFOLLOW | constants7.O_NONBLOCK | (directory ? constants7.O_DIRECTORY : 0));
18190
18671
  handles.push(handle);
18191
- const stat2 = await handle.stat({ bigint: true });
18192
- if (stat2.dev !== root.device || await mountId(handle) !== root.mountId || !directory && (!stat2.isFile() || stat2.nlink !== 1n)) throw denied();
18672
+ const stat3 = await handle.stat({ bigint: true });
18673
+ if (stat3.dev !== root.device || await mountId(handle) !== root.mountId || !directory && (!stat3.isFile() || stat3.nlink !== 1n)) throw denied();
18193
18674
  parent = handle;
18194
18675
  }
18195
18676
  const selected = await realpath2(`/proc/self/fd/${parent.fd}`);
18196
- if (selected !== resolve14(root.path, path3) || await realpath2(root.gitPath) !== root.path) throw denied();
18677
+ if (selected !== resolve15(root.path, path3) || await realpath2(root.gitPath) !== root.path) throw denied();
18197
18678
  const result = await use(parent);
18198
- 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");
18679
+ 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");
18199
18680
  return result;
18200
18681
  } catch (cause) {
18201
18682
  if (cause instanceof CodingWorkspaceError) throw cause;
@@ -18234,9 +18715,9 @@ async function readWorkspaceReceipt(command, entry) {
18234
18715
  const remote = entry.assignment.remoteUrl ?? entry.assignment.expectedRepoRemote;
18235
18716
  if (!remote || remoteKey(remote) !== identity.repositoryKey) throw new CodingWorkspaceError("workspace_checkout_unavailable");
18236
18717
  if (process.platform !== "linux") throw new CodingWorkspaceError("workspace_unsupported");
18237
- const path3 = resolve14(entry.worktree);
18718
+ const path3 = resolve15(entry.worktree);
18238
18719
  if (await realpath2(path3) !== path3) throw new CodingWorkspaceError("workspace_checkout_unavailable");
18239
- directory = await open(path3, constants6.O_RDONLY | constants6.O_DIRECTORY | constants6.O_NOFOLLOW);
18720
+ directory = await open2(path3, constants7.O_RDONLY | constants7.O_DIRECTORY | constants7.O_NOFOLLOW);
18240
18721
  const root = {
18241
18722
  path: path3,
18242
18723
  handle: directory,
@@ -18393,11 +18874,11 @@ async function readWorkspaceReceipt(command, entry) {
18393
18874
  }
18394
18875
 
18395
18876
  // src/coding-workspace/diff.ts
18396
- import { constants as constants7 } from "node:fs";
18397
- import { open as open2, realpath as realpath3, mkdtemp, mkdir as mkdir3, writeFile as writeFile3, rm as rm2, lstat as lstat3 } from "node:fs/promises";
18398
- import { createHash as createHash13 } from "node:crypto";
18399
- import { resolve as resolve15, dirname as dirname15, join as join31, posix } from "node:path";
18400
- import { tmpdir as tmpdir5 } from "node:os";
18877
+ import { constants as constants8 } from "node:fs";
18878
+ 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";
18879
+ import { createHash as createHash14 } from "node:crypto";
18880
+ import { resolve as resolve16, dirname as dirname16, join as join32, posix } from "node:path";
18881
+ import { tmpdir as tmpdir6 } from "node:os";
18401
18882
  import { execa as execa13 } from "execa";
18402
18883
 
18403
18884
  // src/coding-workspace/eol.ts
@@ -18465,12 +18946,12 @@ var CRLFCleaner = class {
18465
18946
  };
18466
18947
 
18467
18948
  // src/coding-workspace/diff.ts
18468
- var digest7 = (value) => createHash13("sha256").update(value).digest("hex");
18949
+ var digest7 = (value) => createHash14("sha256").update(value).digest("hex");
18469
18950
  var fenceMode = (mode) => mode === "100644" || mode === "100755" || mode === "120000" || mode === "160000" ? mode : null;
18470
18951
  var oid2 = /^[a-f0-9]{40}(?:[a-f0-9]{24})?$/;
18471
18952
  var MAX_SCAN_BYTES = 64 * 1024 * 1024;
18472
18953
  var MAX_MANIFEST_BYTES = 1536 * 1024;
18473
- var statFence = (stat2) => digest7(`${stat2.dev}:${stat2.ino}:${stat2.mtimeNs}:${stat2.ctimeNs}:${stat2.size}:${stat2.mode}`);
18954
+ var statFence = (stat3) => digest7(`${stat3.dev}:${stat3.ino}:${stat3.mtimeNs}:${stat3.ctimeNs}:${stat3.size}:${stat3.mode}`);
18474
18955
  function pathsText(bytes) {
18475
18956
  try {
18476
18957
  return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
@@ -18490,7 +18971,7 @@ async function gitFor(repoPath, root, signal) {
18490
18971
  const env = {
18491
18972
  ...buildChildEnv({}),
18492
18973
  GIT_DIR: gitDir,
18493
- GIT_COMMON_DIR: resolve15(gitDir, "..", ".."),
18974
+ GIT_COMMON_DIR: resolve16(gitDir, "..", ".."),
18494
18975
  // cwd is resolved while the parent's FD is still open. The child does not
18495
18976
  // inherit that numeric descriptor, so its work tree must be relative to cwd.
18496
18977
  GIT_WORK_TREE: ".",
@@ -18555,7 +19036,7 @@ async function treeFiles(git3, commit) {
18555
19036
  }
18556
19037
  async function existsWithoutReading(path3) {
18557
19038
  try {
18558
- await lstat3(path3);
19039
+ await lstat4(path3);
18559
19040
  return true;
18560
19041
  } catch (error) {
18561
19042
  if (missing(error)) return false;
@@ -18574,12 +19055,12 @@ async function conversionSettings(git3) {
18574
19055
  const host = buildChildEnv({});
18575
19056
  const defaults = ["/etc/gitattributes", "/usr/etc/gitattributes", "/usr/local/etc/gitattributes"];
18576
19057
  if (!external) {
18577
- const configHome = host.XDG_CONFIG_HOME || (host.HOME ? join31(host.HOME, ".config") : void 0);
18578
- if (configHome) defaults.push(join31(configHome, "git", "attributes"));
19058
+ const configHome = host.XDG_CONFIG_HOME || (host.HOME ? join32(host.HOME, ".config") : void 0);
19059
+ if (configHome) defaults.push(join32(configHome, "git", "attributes"));
18579
19060
  }
18580
- const info = join31(git3.commonDir, "info");
19061
+ const info = join32(git3.commonDir, "info");
18581
19062
  if (await existsWithoutReading(info)) {
18582
- if (!(await lstat3(info)).isDirectory() || await existsWithoutReading(join31(info, "attributes")))
19063
+ if (!(await lstat4(info)).isDirectory() || await existsWithoutReading(join32(info, "attributes")))
18583
19064
  throw new CodingWorkspaceError("workspace_unsupported");
18584
19065
  }
18585
19066
  for (const path3 of defaults) if (await existsWithoutReading(path3)) throw new CodingWorkspaceError("workspace_unsupported");
@@ -18625,11 +19106,11 @@ async function workingConversion(git3, root, paths, head, signal, budget) {
18625
19106
  throw new CodingWorkspaceError("workspace_unsupported");
18626
19107
  attributeBytes.set(path3, bytes);
18627
19108
  }
18628
- const directory = await mkdtemp(join31(tmpdir5(), "mikka-diff-attributes-"));
19109
+ const directory = await mkdtemp2(join32(tmpdir6(), "mikka-diff-attributes-"));
18629
19110
  const actions = /* @__PURE__ */ new Map();
18630
19111
  try {
18631
- const gitDir = join31(directory, "git"), worktree = join31(directory, "worktree");
18632
- await mkdir3(worktree, { mode: 448 });
19112
+ const gitDir = join32(directory, "git"), worktree = join32(directory, "worktree");
19113
+ await mkdir4(worktree, { mode: 448 });
18633
19114
  const env = {
18634
19115
  ...buildChildEnv({}),
18635
19116
  GIT_CONFIG_NOSYSTEM: "1",
@@ -18648,8 +19129,8 @@ async function workingConversion(git3, root, paths, head, signal, budget) {
18648
19129
  killDescendants: true
18649
19130
  });
18650
19131
  for (const [path3, bytes] of attributeBytes) {
18651
- const target = join31(worktree, path3);
18652
- await mkdir3(dirname15(target), { recursive: true, mode: 448 });
19132
+ const target = join32(worktree, path3);
19133
+ await mkdir4(dirname16(target), { recursive: true, mode: 448 });
18653
19134
  await writeFile3(target, bytes, { mode: 384, flag: "wx" });
18654
19135
  }
18655
19136
  const attributes = ["text", "eol", "crlf", "filter", "working-tree-encoding", "ident"];
@@ -18691,7 +19172,7 @@ async function workingConversion(git3, root, paths, head, signal, budget) {
18691
19172
  }
18692
19173
  for (const path3 of paths) actions.set(path3, cleanAction(values.get(path3), settings.autoCRLF));
18693
19174
  } finally {
18694
- await rm2(directory, { recursive: true, force: true });
19175
+ await rm3(directory, { recursive: true, force: true });
18695
19176
  }
18696
19177
  return {
18697
19178
  index,
@@ -18731,7 +19212,7 @@ async function currentFile(root, path3, head, budget, signal, conversion, git3)
18731
19212
  budget.bytes += size;
18732
19213
  if (budget.bytes > MAX_SCAN_BYTES) throw new CodingWorkspaceError("workspace_limit_exceeded");
18733
19214
  const algorithm = head.length === 64 ? "sha256" : "sha1";
18734
- const hasher = createHash13(algorithm).update(`blob ${size}\0`), stats = new GitTextStats();
19215
+ const hasher = createHash14(algorithm).update(`blob ${size}\0`), stats = new GitTextStats();
18735
19216
  const bytes = size <= WORKSPACE_DIFF_MAX_BLOB_BYTES ? Buffer.alloc(size) : null;
18736
19217
  const chunk = Buffer.alloc(64 * 1024);
18737
19218
  let offset = 0;
@@ -18771,7 +19252,7 @@ async function currentFile(root, path3, head, budget, signal, conversion, git3)
18771
19252
  let blob = rawBlob, cleanSize = size;
18772
19253
  if (normalize) {
18773
19254
  cleanSize -= stats.crlf;
18774
- const cleaned = createHash13(algorithm).update(`blob ${cleanSize}\0`), cleaner = new CRLFCleaner();
19255
+ const cleaned = createHash14(algorithm).update(`blob ${cleanSize}\0`), cleaner = new CRLFCleaner();
18775
19256
  if (bytes) cleaned.update(cleaner.push(bytes));
18776
19257
  else {
18777
19258
  budget.bytes += size;
@@ -18841,7 +19322,7 @@ function metadata(repoId, revision2, old, next) {
18841
19322
  fileVersion: digest7(diffFileVersionMaterial(repoId, revision2, file))
18842
19323
  };
18843
19324
  }
18844
- async function snapshot2(git3, root, entry, request2, signal) {
19325
+ async function snapshot3(git3, root, entry, request2, signal) {
18845
19326
  const currentHead = (await git3(["rev-parse", "--verify", "HEAD"])).toString().trim();
18846
19327
  if (!oid2.test(currentHead)) throw new CodingWorkspaceError("workspace_checkout_unavailable");
18847
19328
  const headSha2 = request2.source === "commit" ? request2.headSha : currentHead;
@@ -18914,9 +19395,9 @@ async function readWorkspaceDiffReceipt(command, entry, repoPath) {
18914
19395
  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)
18915
19396
  throw new CodingWorkspaceError("workspace_checkout_unavailable");
18916
19397
  if (process.platform !== "linux") throw new CodingWorkspaceError("workspace_unsupported");
18917
- const path3 = resolve15(entry.worktree);
19398
+ const path3 = resolve16(entry.worktree);
18918
19399
  if (await realpath3(path3) !== path3) throw new CodingWorkspaceError("workspace_checkout_unavailable");
18919
- directory = await open2(path3, constants7.O_RDONLY | constants7.O_DIRECTORY | constants7.O_NOFOLLOW);
19400
+ directory = await open3(path3, constants8.O_RDONLY | constants8.O_DIRECTORY | constants8.O_NOFOLLOW);
18920
19401
  const root = {
18921
19402
  path: path3,
18922
19403
  handle: directory,
@@ -18928,7 +19409,7 @@ async function readWorkspaceDiffReceipt(command, entry, repoPath) {
18928
19409
  if (remoteKey((await git3(["config", "--get", "remote.origin.url"])).toString().trim()) !== identity.repositoryKey)
18929
19410
  throw new CodingWorkspaceError("workspace_checkout_unavailable");
18930
19411
  const selection = request2.kind === "diff_snapshot" ? request2 : request2.revision.source === "working" ? { kind: "diff_snapshot", source: "working" } : { kind: "diff_snapshot", source: "commit", headSha: request2.revision.headSha, baseSha: request2.revision.baseSha };
18931
- const value = await snapshot2(git3, root, entry, selection, signal);
19412
+ const value = await snapshot3(git3, root, entry, selection, signal);
18932
19413
  if (Date.parse(expiresAt) <= Date.now()) throw new CodingWorkspaceError("workspace_request_expired");
18933
19414
  const observation2 = { ok: true, identity, revision: value.revision, availability: "online", observedAt: (/* @__PURE__ */ new Date()).toISOString() };
18934
19415
  signal.throwIfAborted();
@@ -18984,9 +19465,9 @@ async function readWorkspaceRevertPreview(command, entry, repoPath) {
18984
19465
  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)
18985
19466
  throw new CodingWorkspaceError("workspace_checkout_unavailable");
18986
19467
  if (process.platform !== "linux") throw new CodingWorkspaceError("workspace_unsupported");
18987
- const path3 = resolve15(entry.worktree);
19468
+ const path3 = resolve16(entry.worktree);
18988
19469
  if (await realpath3(path3) !== path3) throw new CodingWorkspaceError("workspace_checkout_unavailable");
18989
- directory = await open2(path3, constants7.O_RDONLY | constants7.O_DIRECTORY | constants7.O_NOFOLLOW);
19470
+ directory = await open3(path3, constants8.O_RDONLY | constants8.O_DIRECTORY | constants8.O_NOFOLLOW);
18990
19471
  const root = {
18991
19472
  path: path3,
18992
19473
  handle: directory,
@@ -18997,7 +19478,7 @@ async function readWorkspaceRevertPreview(command, entry, repoPath) {
18997
19478
  const signal = AbortSignal.timeout(remaining), git3 = await gitFor(repoPath, root, signal);
18998
19479
  if (remoteKey((await git3(["config", "--get", "remote.origin.url"])).toString().trim()) !== identity.repositoryKey)
18999
19480
  throw new CodingWorkspaceError("workspace_checkout_unavailable");
19000
- const value = await snapshot2(git3, root, entry, { kind: "diff_snapshot", source: "working" }, signal);
19481
+ const value = await snapshot3(git3, root, entry, { kind: "diff_snapshot", source: "working" }, signal);
19001
19482
  if (value.revision.version !== request2.revision.version) throw new CodingWorkspaceError("workspace_version_conflict");
19002
19483
  const file = value.files.find((candidate) => candidate.path === request2.file.path);
19003
19484
  if (!file || file.fileVersion !== request2.file.fileVersion || file.path !== request2.file.path || file.previousPath !== request2.file.previousPath || file.status !== request2.file.status || file.oldBlob !== request2.file.oldBlob || file.newBlob !== request2.file.newBlob || file.oldMode !== request2.file.oldMode || file.newMode !== request2.file.newMode) throw new CodingWorkspaceError("workspace_version_conflict");
@@ -19053,11 +19534,11 @@ async function readWorkspaceRevertPreview(command, entry, repoPath) {
19053
19534
  }
19054
19535
 
19055
19536
  // src/coding-workspace/git.ts
19056
- import { constants as constants8 } from "node:fs";
19057
- import { lstat as lstat4, mkdtemp as mkdtemp2, open as open3, readFile as readFile5, realpath as realpath4, rm as rm3, unlink, writeFile as writeFile4 } from "node:fs/promises";
19058
- import { createHash as createHash14 } from "node:crypto";
19059
- import { join as join32, resolve as resolve16 } from "node:path";
19060
- import { tmpdir as tmpdir6 } from "node:os";
19537
+ import { constants as constants9 } from "node:fs";
19538
+ 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";
19539
+ import { createHash as createHash15 } from "node:crypto";
19540
+ import { join as join33, resolve as resolve17 } from "node:path";
19541
+ import { tmpdir as tmpdir7 } from "node:os";
19061
19542
  import { execa as execa14 } from "execa";
19062
19543
 
19063
19544
  // src/coding-workspace/git-parse.ts
@@ -19190,7 +19671,7 @@ function parseHistoryCursor(cursor, headSha2) {
19190
19671
  var historyCursor = (headSha2, offset) => `${headSha2}:${offset}`;
19191
19672
 
19192
19673
  // src/coding-workspace/git.ts
19193
- var digest8 = (value) => createHash14("sha256").update(value).digest("hex");
19674
+ var digest8 = (value) => createHash15("sha256").update(value).digest("hex");
19194
19675
  var oid4 = /^[a-f0-9]{40}(?:[a-f0-9]{24})?$/;
19195
19676
  var STATUS_BYTES = 8 * 1024 * 1024;
19196
19677
  var STATUS_SCAN_BYTES = 16 * 1024 * 1024;
@@ -19212,9 +19693,9 @@ async function openPinnedRoot(command, entry) {
19212
19693
  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)
19213
19694
  throw unavailable4();
19214
19695
  if (process.platform !== "linux") throw new CodingWorkspaceError("workspace_unsupported");
19215
- const path3 = resolve16(entry.worktree);
19696
+ const path3 = resolve17(entry.worktree);
19216
19697
  if (await realpath4(path3) !== path3) throw unavailable4();
19217
- const directory = await open3(path3, constants8.O_RDONLY | constants8.O_DIRECTORY | constants8.O_NOFOLLOW);
19698
+ const directory = await open4(path3, constants9.O_RDONLY | constants9.O_DIRECTORY | constants9.O_NOFOLLOW);
19218
19699
  try {
19219
19700
  const root = {
19220
19701
  path: path3,
@@ -19262,13 +19743,13 @@ async function openParent(root, path3) {
19262
19743
  let parent = root.handle;
19263
19744
  try {
19264
19745
  for (let index = 0; index < parts.length - 1; index++) {
19265
- const handle = await open3(
19746
+ const handle = await open4(
19266
19747
  `/proc/self/fd/${parent.fd}/${parts[index]}`,
19267
- constants8.O_RDONLY | constants8.O_DIRECTORY | constants8.O_NOFOLLOW
19748
+ constants9.O_RDONLY | constants9.O_DIRECTORY | constants9.O_NOFOLLOW
19268
19749
  );
19269
19750
  parents.push(handle);
19270
- const stat2 = await handle.stat({ bigint: true });
19271
- if (stat2.dev !== root.device || await mountId(handle) !== root.mountId) throw new CodingWorkspaceError("workspace_path_unavailable");
19751
+ const stat3 = await handle.stat({ bigint: true });
19752
+ if (stat3.dev !== root.device || await mountId(handle) !== root.mountId) throw new CodingWorkspaceError("workspace_path_unavailable");
19272
19753
  parent = handle;
19273
19754
  }
19274
19755
  return { parent, name: parts.at(-1), parents };
@@ -19294,8 +19775,8 @@ async function writePinnedFile(root, path3, bytes, executable2, expectation) {
19294
19775
  let target;
19295
19776
  try {
19296
19777
  const targetPath = `/proc/self/fd/${parent.fd}/${name}`;
19297
- const flags = constants8.O_WRONLY | constants8.O_NOFOLLOW | (expectation.createOnly ? constants8.O_CREAT | constants8.O_EXCL : 0);
19298
- target = await open3(targetPath, flags, executable2 ? 493 : 420);
19778
+ const flags = constants9.O_WRONLY | constants9.O_NOFOLLOW | (expectation.createOnly ? constants9.O_CREAT | constants9.O_EXCL : 0);
19779
+ target = await open4(targetPath, flags, executable2 ? 493 : 420);
19299
19780
  const before = await target.stat({ bigint: true });
19300
19781
  if (!before.isFile() || before.nlink !== 1n) throw new CodingWorkspaceError("workspace_path_unavailable");
19301
19782
  if (expectation.fence && statFence(before) !== expectation.fence) throw conflict();
@@ -19317,16 +19798,16 @@ async function deletePinnedFile(root, path3, expectedFence) {
19317
19798
  const { parent, name, parents } = await openParent(root, path3);
19318
19799
  try {
19319
19800
  const targetPath = `/proc/self/fd/${parent.fd}/${name}`;
19320
- const stat2 = await lstat4(targetPath, { bigint: true }).catch((error) => {
19801
+ const stat3 = await lstat5(targetPath, { bigint: true }).catch((error) => {
19321
19802
  if (!missing(error)) throw error;
19322
19803
  return null;
19323
19804
  });
19324
- if (!stat2) {
19805
+ if (!stat3) {
19325
19806
  if (expectedFence !== void 0) throw conflict();
19326
19807
  return;
19327
19808
  }
19328
- if (stat2.isSymbolicLink() || !stat2.isFile() || stat2.nlink !== 1n) throw new CodingWorkspaceError("workspace_path_unavailable");
19329
- if (expectedFence === void 0 || statFence(stat2) !== expectedFence) throw conflict();
19809
+ if (stat3.isSymbolicLink() || !stat3.isFile() || stat3.nlink !== 1n) throw new CodingWorkspaceError("workspace_path_unavailable");
19810
+ if (expectedFence === void 0 || statFence(stat3) !== expectedFence) throw conflict();
19330
19811
  await unlink(targetPath);
19331
19812
  } catch (error) {
19332
19813
  if (error instanceof CodingWorkspaceError) throw error;
@@ -19652,15 +20133,15 @@ function runGit(cwd, args, env, signal, maximum = 8 * 1024 * 1024) {
19652
20133
  }
19653
20134
  async function readTempFile(worktree, path3) {
19654
20135
  if (!visibleWorkspacePath(path3)) throw new CodingWorkspaceError("workspace_path_unavailable");
19655
- const full = join32(worktree, ...path3.split("/"));
20136
+ const full = join33(worktree, ...path3.split("/"));
19656
20137
  if (!full.startsWith(`${worktree}/`)) throw new CodingWorkspaceError("workspace_path_unavailable");
19657
20138
  try {
19658
- const stat2 = await lstat4(full);
19659
- if (stat2.isSymbolicLink()) return { exists: true, bytes: null, mode: null, reason: "unavailable" };
19660
- if (stat2.isDirectory()) return { exists: true, bytes: null, mode: null, reason: "submodule" };
19661
- if (!stat2.isFile()) return { exists: true, bytes: null, mode: null, reason: "unavailable" };
19662
- if (stat2.size > RESTORE_FILE_BYTES) return { exists: true, bytes: null, mode: null, reason: "binary" };
19663
- return { exists: true, bytes: await readFile5(full), mode: stat2.mode & 73 ? "100755" : "100644", reason: null };
20139
+ const stat3 = await lstat5(full);
20140
+ if (stat3.isSymbolicLink()) return { exists: true, bytes: null, mode: null, reason: "unavailable" };
20141
+ if (stat3.isDirectory()) return { exists: true, bytes: null, mode: null, reason: "submodule" };
20142
+ if (!stat3.isFile()) return { exists: true, bytes: null, mode: null, reason: "unavailable" };
20143
+ if (stat3.size > RESTORE_FILE_BYTES) return { exists: true, bytes: null, mode: null, reason: "binary" };
20144
+ return { exists: true, bytes: await readFile6(full), mode: stat3.mode & 73 ? "100755" : "100644", reason: null };
19664
20145
  } catch (error) {
19665
20146
  if (missing(error)) return { exists: false, bytes: null, mode: null, reason: null };
19666
20147
  throw error;
@@ -19673,8 +20154,8 @@ async function dryRunCheckpoint(git3, root, identity, statusBase, patchBase, pat
19673
20154
  } catch (error) {
19674
20155
  throw new CodingWorkspaceError("workspace_unsupported", { cause: error });
19675
20156
  }
19676
- const parent = await mkdtemp2(join32(tmpdir6(), "mikka-git-restore-"));
19677
- const worktree = join32(parent, "wt"), patchFile = join32(parent, "checkpoint.patch");
20157
+ const parent = await mkdtemp3(join33(tmpdir7(), "mikka-git-restore-"));
20158
+ const worktree = join33(parent, "wt"), patchFile = join33(parent, "checkpoint.patch");
19678
20159
  try {
19679
20160
  await writeFile4(patchFile, patch, { mode: 384 });
19680
20161
  await runGit(git3.commonDir, ["worktree", "add", "--detach", "--quiet", worktree, head], commonEnv(git3), signal);
@@ -19752,7 +20233,7 @@ async function dryRunCheckpoint(git3, root, identity, statusBase, patchBase, pat
19752
20233
  await runGit(git3.commonDir, ["worktree", "remove", "--force", worktree], commonEnv(git3), AbortSignal.timeout(5e3));
19753
20234
  } catch {
19754
20235
  }
19755
- await rm3(parent, { recursive: true, force: true });
20236
+ await rm4(parent, { recursive: true, force: true });
19756
20237
  }
19757
20238
  }
19758
20239
  function checkpointVersion(request2, plan) {
@@ -19954,9 +20435,9 @@ async function handleWorkspaceGitRequest(command, entry, repoPath) {
19954
20435
  }
19955
20436
 
19956
20437
  // src/repositories.ts
19957
- import { createHash as createHash15, randomUUID as randomUUID7 } from "node:crypto";
20438
+ import { createHash as createHash16, randomUUID as randomUUID7 } from "node:crypto";
19958
20439
  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";
19959
- import { dirname as dirname16, join as join33, resolve as resolve17 } from "node:path";
20440
+ import { dirname as dirname17, join as join34, resolve as resolve18 } from "node:path";
19960
20441
  import { setTimeout as delay } from "node:timers/promises";
19961
20442
  import { execa as execa15 } from "execa";
19962
20443
  import lockfile2 from "proper-lockfile";
@@ -19980,8 +20461,8 @@ var RepositoryCache = class {
19980
20461
  retainResources;
19981
20462
  pathFor(remoteUrl) {
19982
20463
  const { key: key2 } = normalizeRepository(remoteUrl, { allowFile: this.allowFile });
19983
- const path3 = resolve17(this.root, "v2", createHash15("sha256").update(key2).digest("hex"));
19984
- if (!isInside(resolve17(this.root), path3) || path3 === resolve17(this.root)) throw new Error("Invalid repository cache path");
20464
+ const path3 = resolve18(this.root, "v2", createHash16("sha256").update(key2).digest("hex"));
20465
+ if (!isInside(resolve18(this.root), path3) || path3 === resolve18(this.root)) throw new Error("Invalid repository cache path");
19985
20466
  return path3;
19986
20467
  }
19987
20468
  /** Serialize clone/fetch against the same cache, including other processes. */
@@ -19989,7 +20470,7 @@ var RepositoryCache = class {
19989
20470
  signal?.throwIfAborted();
19990
20471
  const { remoteUrl: remote } = normalizeRepository(remoteUrl, { allowFile: this.allowFile });
19991
20472
  const path3 = this.pathFor(remote);
19992
- this.ensureParents(dirname16(path3));
20473
+ this.ensureParents(dirname17(path3));
19993
20474
  const release = await this.lock(path3, signal);
19994
20475
  try {
19995
20476
  return await withRepoConfig(path3, () => this.update(path3, remote, signal, env, diagnostics));
@@ -20000,18 +20481,18 @@ var RepositoryCache = class {
20000
20481
  async update(path3, remote, signal, env = {}, diagnostics) {
20001
20482
  signal?.throwIfAborted();
20002
20483
  const git3 = (args, cwd) => {
20003
- const execute2 = () => execa15("git", [
20484
+ const execute3 = () => execa15("git", [
20004
20485
  ...FETCH_GIT,
20005
20486
  "-c",
20006
20487
  `protocol.file.allow=${this.allowFile ? "always" : "never"}`,
20007
20488
  ...args
20008
20489
  ], { cwd, env: { ...process.env, ...env, GIT_TERMINAL_PROMPT: "0" }, stdin: "ignore", timeout: FETCH_TIMEOUT_MS, cancelSignal: signal, killDescendants: true });
20009
- if (!diagnostics) return execute2();
20490
+ if (!diagnostics) return execute3();
20010
20491
  const phase = args[0] === "clone" ? "clone" : args[0] === "fetch" ? "fetch" : args[0] === "remote" && args[1] === "set-head" ? "remote_head" : args[0] === "ls-remote" ? "remote_refs" : "local";
20011
20492
  const traced = () => daemonTracer.span(
20012
20493
  `daemon.repository.git.${phase}`,
20013
20494
  { "mikka.run.id_hash": diagnostics.runIdHash, "mikka.harness": diagnostics.harness },
20014
- execute2
20495
+ execute3
20015
20496
  );
20016
20497
  return diagnostics.timer ? diagnostics.timer.measure(phase, traced) : traced();
20017
20498
  };
@@ -20028,7 +20509,7 @@ var RepositoryCache = class {
20028
20509
  } else {
20029
20510
  this.assertClone(path3);
20030
20511
  await git3(["remote", "set-url", "origin", remote], path3);
20031
- const depth = existsSync7(join33(path3, ".git", "shallow")) ? ["--depth=50"] : [];
20512
+ const depth = existsSync7(join34(path3, ".git", "shallow")) ? ["--depth=50"] : [];
20032
20513
  await git3(["fetch", ...depth, ...this.retainResources ? [] : ["--prune"], "--no-tags", "--no-recurse-submodules", "--no-write-fetch-head", "origin"], path3);
20033
20514
  }
20034
20515
  this.assertClone(path3);
@@ -20120,28 +20601,28 @@ var RepositoryCache = class {
20120
20601
  paths() {
20121
20602
  const visit = (path3) => {
20122
20603
  if (!existsSync7(path3) || lstatSync12(path3).isSymbolicLink()) return [];
20123
- if (existsSync7(join33(path3, ".git"))) {
20604
+ if (existsSync7(join34(path3, ".git"))) {
20124
20605
  this.assertClone(path3);
20125
20606
  return [path3];
20126
20607
  }
20127
- return readdirSync9(path3, { withFileTypes: true }).flatMap((entry) => entry.isDirectory() && !entry.name.endsWith(".lock") && !entry.name.includes(".clone-") ? visit(join33(path3, entry.name)) : []);
20608
+ return readdirSync9(path3, { withFileTypes: true }).flatMap((entry) => entry.isDirectory() && !entry.name.endsWith(".lock") && !entry.name.includes(".clone-") ? visit(join34(path3, entry.name)) : []);
20128
20609
  };
20129
- return visit(resolve17(this.root));
20610
+ return visit(resolve18(this.root));
20130
20611
  }
20131
20612
  ensureParents(path3) {
20132
20613
  mkdirSync17(this.root, { recursive: true, mode: 448 });
20133
20614
  if (lstatSync12(this.root).isSymbolicLink()) throw new Error("Repository cache contains a symlink");
20134
20615
  const root = realpathSync13(this.root);
20135
- let current = resolve17(this.root);
20616
+ let current = resolve18(this.root);
20136
20617
  for (const part of path3.slice(current.length + 1).split("/").filter(Boolean)) {
20137
- current = join33(current, part);
20618
+ current = join34(current, part);
20138
20619
  if (existsSync7(current) && lstatSync12(current).isSymbolicLink()) throw new Error("Repository cache contains a symlink");
20139
20620
  mkdirSync17(current, { recursive: true, mode: 448 });
20140
20621
  if (!isInside(root, realpathSync13(current))) throw new Error("Repository cache escapes its directory");
20141
20622
  }
20142
20623
  }
20143
20624
  assertClone(path3) {
20144
- if (lstatSync12(path3).isSymbolicLink() || !lstatSync12(join33(path3, ".git")).isDirectory() || lstatSync12(join33(path3, ".git")).isSymbolicLink()) throw new Error("Repository cache is not a standard clone");
20625
+ if (lstatSync12(path3).isSymbolicLink() || !lstatSync12(join34(path3, ".git")).isDirectory() || lstatSync12(join34(path3, ".git")).isSymbolicLink()) throw new Error("Repository cache is not a standard clone");
20145
20626
  if (!isInside(realpathSync13(this.root), realpathSync13(path3))) throw new Error("Repository cache escapes its directory");
20146
20627
  }
20147
20628
  async lock(path3, signal) {
@@ -20247,11 +20728,11 @@ async function prepareRunRepository(repositories, privateDir, assignment, signal
20247
20728
  import { randomUUID as randomUUID8 } from "node:crypto";
20248
20729
  import { spawn as spawn5 } from "node:child_process";
20249
20730
  import { existsSync as existsSync8, mkdirSync as mkdirSync18, realpathSync as realpathSync14 } from "node:fs";
20250
- import { dirname as dirname17, join as join34, resolve as resolve18 } from "node:path";
20731
+ import { dirname as dirname18, join as join35, resolve as resolve19 } from "node:path";
20251
20732
  import { fileURLToPath } from "node:url";
20252
20733
 
20253
20734
  // src/official-cli-timing.ts
20254
- import { createHash as createHash16, randomBytes as randomBytes4 } from "node:crypto";
20735
+ import { createHash as createHash17, randomBytes as randomBytes4 } from "node:crypto";
20255
20736
  import { createServer as createServer4 } from "node:http";
20256
20737
 
20257
20738
  // src/mcp-http-timing.ts
@@ -20575,7 +21056,7 @@ var OfficialCliTimingCollector = class {
20575
21056
  };
20576
21057
  async function startCliTimingCollector({ runId, harness, remoteMcpServerCount, decisionCatalogue }) {
20577
21058
  const collector = new OfficialCliTimingCollector(runId, harness);
20578
- const expectedCatalogueSha256 = decisionCatalogue ? createHash16("sha256").update(JSON.stringify(decisionCatalogue)).digest("hex") : null;
21059
+ const expectedCatalogueSha256 = decisionCatalogue ? createHash17("sha256").update(JSON.stringify(decisionCatalogue)).digest("hex") : null;
20579
21060
  const mcpCollector = new McpHttpTimingCollector(runId, harness, remoteMcpServerCount, Date.now, expectedCatalogueSha256);
20580
21061
  const path3 = `/v1/logs/${randomBytes4(16).toString("hex")}`;
20581
21062
  const mcpPath = `/v1/mcp-http/${randomBytes4(16).toString("hex")}`;
@@ -20616,11 +21097,11 @@ async function startCliTimingCollector({ runId, harness, remoteMcpServerCount, d
20616
21097
  server.requestTimeout = 5e3;
20617
21098
  server.headersTimeout = 5e3;
20618
21099
  server.maxConnections = 8;
20619
- await new Promise((resolve19, reject) => {
21100
+ await new Promise((resolve20, reject) => {
20620
21101
  server.once("error", reject);
20621
21102
  server.listen(0, "127.0.0.1", () => {
20622
21103
  server.off("error", reject);
20623
- resolve19();
21104
+ resolve20();
20624
21105
  });
20625
21106
  });
20626
21107
  server.on("error", () => {
@@ -20669,7 +21150,7 @@ async function startCliTimingCollector({ runId, harness, remoteMcpServerCount, d
20669
21150
  unsetEnv,
20670
21151
  mcpHttpObservationUrl: `${origin}${mcpPath}`,
20671
21152
  close: ({ cliExitObserved = false, publish = true } = {}) => closed ??= (async () => {
20672
- await new Promise((resolve19) => {
21153
+ await new Promise((resolve20) => {
20673
21154
  const timer = setTimeout(() => {
20674
21155
  collector.truncate();
20675
21156
  mcpCollector.truncate();
@@ -20677,7 +21158,7 @@ async function startCliTimingCollector({ runId, harness, remoteMcpServerCount, d
20677
21158
  }, 1e3);
20678
21159
  server.close(() => {
20679
21160
  clearTimeout(timer);
20680
- resolve19();
21161
+ resolve20();
20681
21162
  });
20682
21163
  });
20683
21164
  const official = collector.finish(cliExitObserved), mcp = mcpCollector.finish();
@@ -20715,7 +21196,7 @@ async function runHostedCommand(worktree, script, _readOnly, timeoutMs, signal)
20715
21196
  abort();
20716
21197
  } else chunks.push(chunk);
20717
21198
  };
20718
- const result = await new Promise((resolve19, reject) => {
21199
+ const result = await new Promise((resolve20, reject) => {
20719
21200
  child = spawn5("/bin/sh", ["-c", script], {
20720
21201
  cwd: realpathSync14(worktree),
20721
21202
  env: process.env,
@@ -20725,7 +21206,7 @@ async function runHostedCommand(worktree, script, _readOnly, timeoutMs, signal)
20725
21206
  child.stdout?.on("data", (chunk) => collect("stdout", stdout, chunk));
20726
21207
  child.stderr?.on("data", (chunk) => collect("stderr", stderr, chunk));
20727
21208
  child.once("error", reject);
20728
- child.once("close", (code, term) => resolve19({ code, signal: term }));
21209
+ child.once("close", (code, term) => resolve20({ code, signal: term }));
20729
21210
  child.once("exit", abort);
20730
21211
  signal?.addEventListener("abort", abort, { once: true });
20731
21212
  if (signal?.aborted) abort();
@@ -20851,7 +21332,7 @@ async function createHostedBotRunner(host) {
20851
21332
  if (selected && (!options.model || options.model !== subscription?.first.modelId)) throw Error("binding_mismatch");
20852
21333
  const paths = runPaths(host.stateDir, assignment.runId);
20853
21334
  mkdirSync18(paths.runDir, { recursive: true, mode: 448 });
20854
- const cwd = preparation ? resolve18(options.cwd) : realpathSync14(options.cwd);
21335
+ const cwd = preparation ? resolve19(options.cwd) : realpathSync14(options.cwd);
20855
21336
  const env = Object.fromEntries(Object.entries({ ...process.env, ...options.env, ...assignment.taskEnv }).filter((entry) => typeof entry[1] === "string"));
20856
21337
  if (runDiagnosticsEnabled(assignment.taskEnv, host.collectCliTiming)) env.CLOUD_STARTUP_TIMING = "1";
20857
21338
  const selectedGithub = options.github ?? (assignment.github ? { ...assignment.github, issueId: assignment.issueId, runToken: assignment.mcp?.token } : void 0);
@@ -20882,7 +21363,7 @@ async function createHostedBotRunner(host) {
20882
21363
  });
20883
21364
  Object.assign(env, github.env);
20884
21365
  }
20885
- const ledger = join34(host.stateDir, "native-ledgers", assignment.runId + ".json");
21366
+ const ledger = join35(host.stateDir, "native-ledgers", assignment.runId + ".json");
20886
21367
  const scope = selected && subscription ? {
20887
21368
  runId: assignment.runId,
20888
21369
  bindingId: selected.bindingId,
@@ -20895,12 +21376,12 @@ async function createHostedBotRunner(host) {
20895
21376
  modelId: subscription.first.modelId
20896
21377
  } : void 0;
20897
21378
  if (continuation && existsSync8(ledger)) throw unavailable5("ledger_mismatch");
20898
- const previousLedger = continuation ? join34(host.stateDir, "native-ledgers", continuation.runId + ".json") : ledger;
21379
+ const previousLedger = continuation ? join35(host.stateDir, "native-ledgers", continuation.runId + ".json") : ledger;
20899
21380
  const previous = scope ? readJson(previousLedger) : void 0;
20900
21381
  if (preparation && previous) throw unavailable5("ledger_mismatch");
20901
21382
  const expectedScope = scope && continuation ? { ...scope, runId: continuation.runId } : scope;
20902
21383
  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");
20903
- if (scope) mkdirSync18(dirname17(ledger), { recursive: true, mode: 448 });
21384
+ if (scope) mkdirSync18(dirname18(ledger), { recursive: true, mode: 448 });
20904
21385
  const record3 = async (sessionId) => {
20905
21386
  assertOpen();
20906
21387
  if (scope) writeJsonAtomic(ledger, { scope, sessionId });
@@ -20972,9 +21453,9 @@ async function createHostedBotRunner(host) {
20972
21453
  signal: lifetime.signal
20973
21454
  });
20974
21455
  child.stderr?.resume();
20975
- const exited = new Promise((resolve19) => {
20976
- child.once("exit", (code, signal) => resolve19({ code, signal }));
20977
- child.once("error", () => resolve19({ code: null, signal: null }));
21456
+ const exited = new Promise((resolve20) => {
21457
+ child.once("exit", (code, signal) => resolve20({ code, signal }));
21458
+ child.once("error", () => resolve20({ code: null, signal: null }));
20978
21459
  });
20979
21460
  return {
20980
21461
  process: child,
@@ -21078,9 +21559,9 @@ async function createHostedBotRunner(host) {
21078
21559
  await close();
21079
21560
  }
21080
21561
  },
21081
- send: async (text4) => {
21562
+ send: async (text4, mode) => {
21082
21563
  assertOpen();
21083
- await session.send(text4);
21564
+ await session.send(text4, mode);
21084
21565
  },
21085
21566
  cancel: async () => {
21086
21567
  try {
@@ -21161,7 +21642,7 @@ async function createHostedBotRunner(host) {
21161
21642
  import {
21162
21643
  randomBytes as randomBytes5,
21163
21644
  randomUUID as randomUUID9,
21164
- createHash as createHash18,
21645
+ createHash as createHash19,
21165
21646
  timingSafeEqual as timingSafeEqual2
21166
21647
  } from "node:crypto";
21167
21648
  import { chmodSync as chmodSync2 } from "node:fs";
@@ -21169,12 +21650,12 @@ import { createServer as createServer5 } from "node:net";
21169
21650
 
21170
21651
  // src/computer/driver.mjs
21171
21652
  import { spawn as spawn6 } from "node:child_process";
21172
- import { execFile as execFile7 } from "node:child_process";
21173
- import { promisify as promisify7 } from "node:util";
21174
- import { createHash as createHash17 } from "node:crypto";
21175
- import { readFile as readFile6, realpath as realpath5 } from "node:fs/promises";
21653
+ import { execFile as execFile8 } from "node:child_process";
21654
+ import { promisify as promisify8 } from "node:util";
21655
+ import { createHash as createHash18 } from "node:crypto";
21656
+ import { readFile as readFile7, realpath as realpath5 } from "node:fs/promises";
21176
21657
  import { createInterface } from "node:readline";
21177
- var exec3 = promisify7(execFile7);
21658
+ var exec3 = promisify8(execFile8);
21178
21659
  async function detectComputerDriver(binary = "cua-driver") {
21179
21660
  try {
21180
21661
  const { stdout: located } = await exec3("which", [binary], {
@@ -21188,7 +21669,7 @@ async function detectComputerDriver(binary = "cua-driver") {
21188
21669
  installed: true,
21189
21670
  version,
21190
21671
  path: path3,
21191
- fingerprint: createHash17("sha256").update(await readFile6(path3)).digest("hex")
21672
+ fingerprint: createHash18("sha256").update(await readFile7(path3)).digest("hex")
21192
21673
  };
21193
21674
  } catch {
21194
21675
  return null;
@@ -21255,7 +21736,7 @@ async function executeDriver(driver, input, display, leaseGuard, assertLive = ()
21255
21736
  if (display !== void 0 && !/^:[1-9][0-9]{0,3}$/.test(display))
21256
21737
  throw new Error("Invalid desktop display");
21257
21738
  const call = normalizeCall(input);
21258
- const fingerprint2 = createHash17("sha256").update(await readFile6(driver.path)).digest("hex");
21739
+ const fingerprint2 = createHash18("sha256").update(await readFile7(driver.path)).digest("hex");
21259
21740
  if (fingerprint2 !== driver.fingerprint)
21260
21741
  throw new Error("Driver changed; restart and approve a new request");
21261
21742
  const args = driverArguments(call);
@@ -21318,9 +21799,9 @@ async function executeDriver(driver, input, display, leaseGuard, assertLive = ()
21318
21799
  )
21319
21800
  )
21320
21801
  );
21321
- const request2 = (method, params) => new Promise((resolve19, reject) => {
21802
+ const request2 = (method, params) => new Promise((resolve20, reject) => {
21322
21803
  const n = ++id5;
21323
- pending.set(n, { resolve: resolve19, reject });
21804
+ pending.set(n, { resolve: resolve20, reject });
21324
21805
  child.stdin.write(
21325
21806
  JSON.stringify({ jsonrpc: "2.0", id: n, method, params }) + "\n"
21326
21807
  );
@@ -21358,6 +21839,8 @@ var ComputerBroker = class {
21358
21839
  grants = /* @__PURE__ */ new Map();
21359
21840
  // runId → when its screen recording stops by itself; only set while one runs.
21360
21841
  recordingUntil = /* @__PURE__ */ new Map();
21842
+ recordingSteps = /* @__PURE__ */ new Map();
21843
+ recordingTimingFailed = /* @__PURE__ */ new Set();
21361
21844
  pending = /* @__PURE__ */ new Map();
21362
21845
  sockets = /* @__PURE__ */ new Set();
21363
21846
  suspended = false;
@@ -21366,13 +21849,13 @@ var ComputerBroker = class {
21366
21849
  socketPath,
21367
21850
  transport = "unix",
21368
21851
  permitted,
21369
- execute: execute2 = (driver2, call, display, _runId, context) => executeDriver(driver2, call, display, void 0, context.assertLive),
21852
+ execute: execute3 = (driver2, call, display, _runId, context) => executeDriver(driver2, call, display, void 0, context.assertLive),
21370
21853
  capture,
21371
21854
  now = Date.now,
21372
21855
  ttl = 3e5,
21373
21856
  needsPerson
21374
21857
  }) {
21375
- Object.assign(this, { driver, socketPath, permitted, execute: execute2, capture, now, ttl, transport, needsPerson });
21858
+ Object.assign(this, { driver, socketPath, permitted, execute: execute3, capture, now, ttl, transport, needsPerson });
21376
21859
  }
21377
21860
  // runId → the last few action kinds, evidence for the Decisions API.
21378
21861
  recent = /* @__PURE__ */ new Map();
@@ -21434,10 +21917,10 @@ var ComputerBroker = class {
21434
21917
  })();
21435
21918
  });
21436
21919
  });
21437
- await new Promise((resolve19, reject) => {
21920
+ await new Promise((resolve20, reject) => {
21438
21921
  this.server.once("error", reject);
21439
- if (this.transport === "tcp") this.server.listen({ host: "127.0.0.1", port: 0 }, resolve19);
21440
- else this.server.listen(this.socketPath, resolve19);
21922
+ if (this.transport === "tcp") this.server.listen({ host: "127.0.0.1", port: 0 }, resolve20);
21923
+ else this.server.listen(this.socketPath, resolve20);
21441
21924
  });
21442
21925
  if (this.transport === "tcp") this.socketPath = `tcp://127.0.0.1:${this.server.address().port}`;
21443
21926
  else chmodSync2(this.socketPath, 384);
@@ -21448,23 +21931,39 @@ var ComputerBroker = class {
21448
21931
  return Promise.reject(new Error("Not permitted"));
21449
21932
  const call = normalizeCall(value);
21450
21933
  const step = actionStep(value);
21451
- return this.requestCall(token, grant, call, signal).then((result) => {
21452
- this.markStep(grant.runId, step);
21453
- return result;
21454
- });
21934
+ return this.requestCall(token, grant, call, signal, step);
21455
21935
  }
21456
- /** While this run records, a done action's description becomes a step on the recording (best effort; never fails the action). */
21457
- markStep(runId, label2) {
21936
+ /** Timings cover execution itself, excluding decision and human-approval waits. */
21937
+ async executeRecorded(driver, call, display, runId, context, step) {
21938
+ const started = this.now();
21939
+ try {
21940
+ return await this.execute(driver, call, display, runId, context);
21941
+ } finally {
21942
+ const label2 = step ?? { get_desktop_state: "Read the screen", click: "Click", type_text: "Type text", press_key: "Press a key", scroll: "Scroll" }[call.name];
21943
+ this.markStep(runId, label2, Math.max(0, Math.round(this.now() - started)));
21944
+ }
21945
+ }
21946
+ /** Pending timing writes drain before stop, so the last action cannot disappear. */
21947
+ markStep(runId, label2, durationMs) {
21458
21948
  const until = this.recordingUntil.get(runId);
21459
21949
  if (!label2 || !this.capture || until === void 0) return;
21460
- if (this.now() > until) {
21950
+ if (this.now() > until + 3e4) {
21461
21951
  this.recordingUntil.delete(runId);
21462
21952
  return;
21463
21953
  }
21464
- void Promise.resolve().then(() => this.capture(runId, { action: "step", label: label2, source: "action" })).catch(() => {
21954
+ const pending = this.recordingSteps.get(runId) ?? /* @__PURE__ */ new Set();
21955
+ const write = Promise.resolve().then(() => this.capture(runId, { action: "step", label: label2, source: "action", durationMs: Math.min(durationMs, 3e5) }, AbortSignal.timeout(5e3))).then((result) => {
21956
+ if (result?.recorded === false) this.recordingTimingFailed.add(runId);
21957
+ }).catch(() => {
21958
+ this.recordingTimingFailed.add(runId);
21959
+ }).finally(() => {
21960
+ pending.delete(write);
21961
+ if (!pending.size) this.recordingSteps.delete(runId);
21465
21962
  });
21963
+ pending.add(write);
21964
+ this.recordingSteps.set(runId, pending);
21466
21965
  }
21467
- requestCall(token, grant, call, signal) {
21966
+ requestCall(token, grant, call, signal, step) {
21468
21967
  const actionId = randomUUID9();
21469
21968
  const assertLive = () => {
21470
21969
  if (this.suspended || signal?.aborted || this.grants.get(token) !== grant || this.driver?.fingerprint !== grant.fingerprint || !this.permitted(grant.runId))
@@ -21473,7 +21972,7 @@ var ComputerBroker = class {
21473
21972
  if (grant.permission === "allow") {
21474
21973
  return Promise.resolve().then(() => {
21475
21974
  assertLive();
21476
- return this.execute(this.driver, call, grant.display, grant.runId, { actionId, assertLive });
21975
+ return this.executeRecorded(this.driver, call, grant.display, grant.runId, { actionId, assertLive }, step);
21477
21976
  });
21478
21977
  }
21479
21978
  if (this.needsPerson) {
@@ -21488,15 +21987,15 @@ var ComputerBroker = class {
21488
21987
  }).then((needsPerson) => {
21489
21988
  if (needsPerson !== false) {
21490
21989
  if (needsPerson !== true) console.warn(`Decision fallback: computer action ${call.name} reviewed as before without a judgment`);
21491
- return this.review(token, grant, call, actionId, assertLive, signal);
21990
+ return this.review(token, grant, call, actionId, assertLive, signal, step);
21492
21991
  }
21493
21992
  assertLive();
21494
- return this.execute(this.driver, call, grant.display, grant.runId, { actionId, assertLive });
21993
+ return this.executeRecorded(this.driver, call, grant.display, grant.runId, { actionId, assertLive }, step);
21495
21994
  });
21496
21995
  }
21497
- return this.review(token, grant, call, actionId, assertLive, signal);
21996
+ return this.review(token, grant, call, actionId, assertLive, signal, step);
21498
21997
  }
21499
- review(token, grant, call, actionId, assertLive, signal) {
21998
+ review(token, grant, call, actionId, assertLive, signal, step) {
21500
21999
  if (this.pending.size >= 20) return Promise.reject(new Error("Not permitted"));
21501
22000
  const request2 = {
21502
22001
  id: actionId,
@@ -21506,8 +22005,8 @@ var ComputerBroker = class {
21506
22005
  call,
21507
22006
  expiresAt: this.now() + this.ttl
21508
22007
  };
21509
- const digest9 = createHash18("sha256").update(JSON.stringify(request2)).digest("hex");
21510
- return new Promise((resolve19, reject) => {
22008
+ const digest9 = createHash19("sha256").update(JSON.stringify(request2)).digest("hex");
22009
+ return new Promise((resolve20, reject) => {
21511
22010
  const timer = setTimeout(() => {
21512
22011
  this.pending.delete(request2.id);
21513
22012
  signal?.removeEventListener("abort", cancel);
@@ -21521,10 +22020,11 @@ var ComputerBroker = class {
21521
22020
  signal?.addEventListener("abort", cancel, { once: true });
21522
22021
  this.pending.set(request2.id, {
21523
22022
  token,
22023
+ step,
21524
22024
  assertLive,
21525
22025
  cleanup: () => signal?.removeEventListener("abort", cancel),
21526
22026
  request: { ...request2, digest: digest9 },
21527
- resolve: resolve19,
22027
+ resolve: resolve20,
21528
22028
  reject,
21529
22029
  timer
21530
22030
  });
@@ -21538,9 +22038,20 @@ var ComputerBroker = class {
21538
22038
  return { error: "Not permitted" };
21539
22039
  const call = normalizeCaptureCall(value);
21540
22040
  try {
22041
+ if (call.action === "stop_recording") {
22042
+ await Promise.all(this.recordingSteps.get(grant.runId) ?? []);
22043
+ if (this.recordingTimingFailed.has(grant.runId))
22044
+ await this.capture(grant.runId, { action: "step", label: "Recording timing incomplete", source: "action" }, signal);
22045
+ }
21541
22046
  const result = await this.capture(grant.runId, call, signal);
21542
- if (call.action === "start_recording" && typeof result?.stopsAt === "string") this.recordingUntil.set(grant.runId, Date.parse(result.stopsAt));
21543
- if (call.action === "stop_recording") this.recordingUntil.delete(grant.runId);
22047
+ if (call.action === "start_recording" && typeof result?.stopsAt === "string") {
22048
+ this.recordingUntil.set(grant.runId, Date.parse(result.stopsAt));
22049
+ this.recordingTimingFailed.delete(grant.runId);
22050
+ }
22051
+ if (call.action === "stop_recording") {
22052
+ this.recordingUntil.delete(grant.runId);
22053
+ this.recordingTimingFailed.delete(grant.runId);
22054
+ }
21544
22055
  return { result };
21545
22056
  } catch (error) {
21546
22057
  const detail = typeof error?.safeMessage === "string" ? error.safeMessage.slice(0, 300) : void 0;
@@ -21585,7 +22096,7 @@ var ComputerBroker = class {
21585
22096
  throw new Error("Not permitted");
21586
22097
  };
21587
22098
  assertLive();
21588
- row.resolve(await this.execute(this.driver, call, display, runId, { actionId: id5, assertLive }));
22099
+ row.resolve(await this.executeRecorded(this.driver, call, display, runId, { actionId: id5, assertLive }, row.step));
21589
22100
  } catch (error) {
21590
22101
  row.reject(error);
21591
22102
  }
@@ -21606,15 +22117,15 @@ var ComputerBroker = class {
21606
22117
  async close() {
21607
22118
  this.suspend();
21608
22119
  for (const socket of this.sockets) socket.destroy();
21609
- if (this.server?.listening) await new Promise((resolve19) => this.server.close(resolve19));
22120
+ if (this.server?.listening) await new Promise((resolve20) => this.server.close(resolve20));
21610
22121
  }
21611
22122
  };
21612
22123
 
21613
22124
  // src/computer/credential-executor.ts
21614
- import { createHash as createHash19 } from "node:crypto";
22125
+ import { createHash as createHash20 } from "node:crypto";
21615
22126
  function credentialAwareExecutor(deps) {
21616
22127
  return async (driver, call, display, runId, context) => {
21617
- const digest9 = createHash19("sha256").update(JSON.stringify(call)).digest("hex");
22128
+ const digest9 = createHash20("sha256").update(JSON.stringify(call)).digest("hex");
21618
22129
  const resolved = await deps.consumeMatchingIntent(runId, context.actionId, digest9);
21619
22130
  context.assertLive();
21620
22131
  if (resolved.kind === "ordinary") return deps.executeOrdinary(driver, call, display, runId, context.assertLive);
@@ -21653,8 +22164,8 @@ function createHostedComputerExecutor(deps) {
21653
22164
  // src/computer/web-review.ts
21654
22165
  async function applyWebComputerDecisions(broker, decisions) {
21655
22166
  for (const decision of decisions) {
21656
- const snapshot3 = broker.list().find((row) => row.id === decision.id);
21657
- if (!snapshot3 || snapshot3.digest !== decision.digest) continue;
22167
+ const snapshot4 = broker.list().find((row) => row.id === decision.id);
22168
+ if (!snapshot4 || snapshot4.digest !== decision.digest) continue;
21658
22169
  await broker.decide(decision.id, decision.digest, decision.approve).catch(() => void 0);
21659
22170
  }
21660
22171
  }
@@ -21681,9 +22192,9 @@ async function pollWebComputerReviews(broker, deviceId, link, signal, intervalMs
21681
22192
  });
21682
22193
  try {
21683
22194
  while (!signal.aborted) {
21684
- const snapshot3 = broker.list();
21685
- const pending = snapshot3.length > 0;
21686
- const key2 = snapshotKey(snapshot3);
22195
+ const snapshot4 = broker.list();
22196
+ const pending = snapshot4.length > 0;
22197
+ const key2 = snapshotKey(snapshot4);
21687
22198
  const everyCheck = (pushes?.mode("computerReviews") ?? "legacy") !== "push";
21688
22199
  if (key2 !== synced || pending && (pushed || everyCheck || Date.now() - syncedAt >= presenceMs)) {
21689
22200
  pushed = false;
@@ -21696,11 +22207,11 @@ async function pollWebComputerReviews(broker, deviceId, link, signal, intervalMs
21696
22207
  }
21697
22208
  if (signal.aborted) break;
21698
22209
  if (pushes) await pushes.next(intervalMs, signal);
21699
- else await new Promise((resolve19) => {
22210
+ else await new Promise((resolve20) => {
21700
22211
  const done = () => {
21701
22212
  clearTimeout(timer);
21702
22213
  signal.removeEventListener("abort", done);
21703
- resolve19();
22214
+ resolve20();
21704
22215
  };
21705
22216
  const timer = setTimeout(done, intervalMs);
21706
22217
  signal.addEventListener("abort", done, { once: true });
@@ -21745,16 +22256,16 @@ var DeviceWorkSignal = class {
21745
22256
  }
21746
22257
  /** Resolves on the next push or mode change, after `ms`, or on abort. */
21747
22258
  next(ms2, signal) {
21748
- return new Promise((resolve19) => {
22259
+ return new Promise((resolve20) => {
21749
22260
  if (signal?.aborted) {
21750
- resolve19();
22261
+ resolve20();
21751
22262
  return;
21752
22263
  }
21753
22264
  const done = () => {
21754
22265
  clearTimeout(timer);
21755
22266
  off();
21756
22267
  signal?.removeEventListener("abort", done);
21757
- resolve19();
22268
+ resolve20();
21758
22269
  };
21759
22270
  const timer = setTimeout(done, Math.max(0, ms2));
21760
22271
  const off = this.subscribe(done);
@@ -21787,8 +22298,8 @@ var HARNESS_RESCAN_MS = 5 * 6e4;
21787
22298
  var MODEL_PROBE_MS = 6 * 60 * 6e4;
21788
22299
  function cloudComputerGrantMatches(assignment, runId, deviceId) {
21789
22300
  if (!assignment?.computer || !deviceId || assignment.runId !== runId || assignment.deviceId !== deviceId) return false;
21790
- const snapshot3 = assignment.policySnapshot?.payload;
21791
- return !snapshot3 || snapshot3.runId === runId && snapshot3.deviceId === deviceId && snapshot3.ownerId === assignment.computer.ownerId;
22301
+ const snapshot4 = assignment.policySnapshot?.payload;
22302
+ return !snapshot4 || snapshot4.runId === runId && snapshot4.deviceId === deviceId && snapshot4.ownerId === assignment.computer.ownerId;
21792
22303
  }
21793
22304
  var Daemon = class {
21794
22305
  constructor(options) {
@@ -21861,6 +22372,7 @@ var Daemon = class {
21861
22372
  localComputerBroker = null;
21862
22373
  /** Messages handed to an agent whose delivery the server has not taken yet. */
21863
22374
  unacked = /* @__PURE__ */ new Set();
22375
+ refusedSteers = /* @__PURE__ */ new Set();
21864
22376
  /** Runs this daemon already started cancelling for a stop request. */
21865
22377
  stopping = /* @__PURE__ */ new Set();
21866
22378
  /** Runs this daemon has ended, whose end the server may not have yet. */
@@ -21899,7 +22411,7 @@ var Daemon = class {
21899
22411
  if (this.options.credential)
21900
22412
  this.saveDevice({ credential: this.options.credential });
21901
22413
  this.journal = new RunJournal(paths.journal);
21902
- this.captureUploader = new CaptureUploader((runId) => join35(runPaths(paths.adapterState, runId).runDir, CAPTURES_DIR), this.options.link, this.log, join35(paths.dataDir, "capture-pending"));
22414
+ this.captureUploader = new CaptureUploader((runId) => join36(runPaths(paths.adapterState, runId).runDir, CAPTURES_DIR), this.options.link, this.log, join36(paths.dataDir, "capture-pending"));
21903
22415
  this.outbox = new Outbox(
21904
22416
  paths.outbox,
21905
22417
  this.options.link,
@@ -21918,7 +22430,7 @@ var Daemon = class {
21918
22430
  if (this.localComputerDriver && this.options.link.syncComputerReviews) {
21919
22431
  this.localComputerBroker = new ComputerBroker({
21920
22432
  driver: this.localComputerDriver,
21921
- socketPath: join35(paths.dataDir, "local-computer.sock"),
22433
+ socketPath: join36(paths.dataDir, "local-computer.sock"),
21922
22434
  transport: "tcp",
21923
22435
  needsPerson: this.computerNeedsPerson(),
21924
22436
  permitted: (runId) => {
@@ -21961,7 +22473,7 @@ var Daemon = class {
21961
22473
  };
21962
22474
  this.cloudComputerBroker = new ComputerBroker({
21963
22475
  driver,
21964
- socketPath: join35(paths.dataDir, "computer.sock"),
22476
+ socketPath: join36(paths.dataDir, "computer.sock"),
21965
22477
  needsPerson: this.computerNeedsPerson(),
21966
22478
  permitted: (runId) => {
21967
22479
  const entry = this.journal.get(runId);
@@ -22040,7 +22552,7 @@ var Daemon = class {
22040
22552
  ) : this.realAdapters()
22041
22553
  ]);
22042
22554
  this.supervisor = new RunSupervisor({
22043
- acquireWorkspaceControl: this.options.taskRegistered ? (assignment, signal, onLost) => acquireCloudWorkspaceControl({ runId: assignment.runId, deviceId: assignment.deviceId, signal, onLost }) : void 0,
22555
+ acquireWorkspaceControl: this.options.e2bContainerRuntime || this.options.taskRegistered ? (assignment, signal, onLost) => acquireCloudWorkspaceControl({ runId: assignment.runId, deviceId: assignment.deviceId, signal, onLost }) : void 0,
22044
22556
  collectCliTiming: this.options.collectCliTiming,
22045
22557
  journal: this.journal,
22046
22558
  adapterStateDir: this.paths.adapterState,
@@ -22055,7 +22567,7 @@ var Daemon = class {
22055
22567
  prepareRunMailbox: this.options.link.prepareRunMailbox?.bind(this.options.link),
22056
22568
  prepareRunToolApproval: this.options.link.prepareRunToolApproval?.bind(this.options.link),
22057
22569
  prepareRunGitHub: hosted ? void 0 : (assignment, signal, onCredential) => prepareLocalGitHub(assignment, {
22058
- stateDir: join35(this.paths.adapterState, "github"),
22570
+ stateDir: join36(this.paths.adapterState, "github"),
22059
22571
  link: this.options.link,
22060
22572
  signal,
22061
22573
  onCredential,
@@ -22125,7 +22637,7 @@ var Daemon = class {
22125
22637
  worktree,
22126
22638
  tree,
22127
22639
  github: { ...assignment.github, runToken: assignment.mcp?.token, issueId: assignment.issueId },
22128
- privateDir: join35(paths.adapterState, "pids"),
22640
+ privateDir: join36(paths.adapterState, "pids"),
22129
22641
  ...hosted ? { hosted: true } : {},
22130
22642
  env: hosted ? process.env : githubReceiptEnvironment(),
22131
22643
  githubEnvironment,
@@ -22172,6 +22684,7 @@ var Daemon = class {
22172
22684
  ...this.modelReports.get(info.harness),
22173
22685
  // The run's live gate stops a revoked run; Codex also verifies its
22174
22686
  // pinned interface at initialize.
22687
+ ...info.harness === "codex" && info.installed ? { activeTurnSteer: true } : {},
22175
22688
  toolApproval: this.supportsToolApproval(info),
22176
22689
  coordinator: false
22177
22690
  })) : await Promise.all(supported.map((info) => this.localHarnessReport(info)));
@@ -22222,10 +22735,13 @@ var Daemon = class {
22222
22735
  await this.pauseCommands(1e3, signal);
22223
22736
  continue;
22224
22737
  }
22225
- if (this.unacked.size > 0) {
22738
+ if (this.unacked.size > 0 || this.refusedSteers.size > 0) {
22226
22739
  const ids = [...this.unacked].slice(0, 500);
22227
- await link.ackCommands(deviceId, ids);
22740
+ const refused2 = [...this.refusedSteers].slice(0, 500);
22741
+ if (refused2.length) await link.ackCommands(deviceId, ids, refused2);
22742
+ else await link.ackCommands(deviceId, ids);
22228
22743
  for (const id5 of ids) this.unacked.delete(id5);
22744
+ for (const id5 of refused2) this.refusedSteers.delete(id5);
22229
22745
  }
22230
22746
  if (await this.holdGateway(deviceId, signal)) {
22231
22747
  backoff = 1e3;
@@ -22273,7 +22789,7 @@ var Daemon = class {
22273
22789
  await this.pauseCommands(500, signal);
22274
22790
  continue;
22275
22791
  }
22276
- if (this.unacked.size > 0) continue;
22792
+ if (this.unacked.size > 0 || this.refusedSteers.size > 0) continue;
22277
22793
  if (news) continue;
22278
22794
  if (commands.length === 0 && !signal.aborted) {
22279
22795
  const remaining = Math.max(1e3, wait * 1e3) - (performance.now() - started);
@@ -22316,10 +22832,13 @@ var Daemon = class {
22316
22832
  if (this.stopped || signal.aborted) return;
22317
22833
  await this.applyCommands(commands);
22318
22834
  if (queued.length > 0) this.claimQueued(queued);
22319
- while (this.unacked.size > 0 && !signal.aborted) {
22835
+ while ((this.unacked.size > 0 || this.refusedSteers.size > 0) && !signal.aborted) {
22320
22836
  const ids = [...this.unacked].slice(0, 500);
22321
- await this.options.link.ackCommands(deviceId, ids);
22837
+ const refused2 = [...this.refusedSteers].slice(0, 500);
22838
+ if (refused2.length) await this.options.link.ackCommands(deviceId, ids, refused2);
22839
+ else await this.options.link.ackCommands(deviceId, ids);
22322
22840
  for (const id5 of ids) this.unacked.delete(id5);
22841
+ for (const id5 of refused2) this.refusedSteers.delete(id5);
22323
22842
  }
22324
22843
  }
22325
22844
  /**
@@ -22348,8 +22867,8 @@ var Daemon = class {
22348
22867
  }
22349
22868
  if (signal.aborted) return false;
22350
22869
  const socket = openDeviceGateway(ticket.url, ticket.protocol);
22351
- void daemonTracer.span("daemon.gateway.connect", { "mikka.gateway.mode": this.runControlPush ? "push" : "legacy" }, () => new Promise((resolve19, reject) => {
22352
- gatewayOpened = resolve19;
22870
+ void daemonTracer.span("daemon.gateway.connect", { "mikka.gateway.mode": this.runControlPush ? "push" : "legacy" }, () => new Promise((resolve20, reject) => {
22871
+ gatewayOpened = resolve20;
22353
22872
  gatewayFailed = reject;
22354
22873
  }), { root: true }).catch(() => void 0);
22355
22874
  await runDeviceGateway(socket, {
@@ -22474,12 +22993,12 @@ var Daemon = class {
22474
22993
  /** Waits `ms`, or less if the daemon stops or the device registers. */
22475
22994
  pauseCommands(ms2, signal) {
22476
22995
  if (signal.aborted) return Promise.resolve();
22477
- return new Promise((resolve19) => {
22996
+ return new Promise((resolve20) => {
22478
22997
  const done = () => {
22479
22998
  clearTimeout(timer);
22480
22999
  signal.removeEventListener("abort", done);
22481
23000
  this.wakeCommands = null;
22482
- resolve19();
23001
+ resolve20();
22483
23002
  };
22484
23003
  const timer = setTimeout(done, ms2);
22485
23004
  signal.addEventListener("abort", done, { once: true });
@@ -22515,6 +23034,33 @@ var Daemon = class {
22515
23034
  for (const command of commands) {
22516
23035
  const entry = this.journal.get(command.runId);
22517
23036
  if (!entry) continue;
23037
+ if (command.kind === "steer") {
23038
+ const id5 = command.messageId;
23039
+ const prior = entry.steerReceipts?.[id5];
23040
+ if (prior === "accepted") {
23041
+ this.unacked.add(id5);
23042
+ continue;
23043
+ }
23044
+ if (prior || isTerminalRunState(entry.state)) {
23045
+ this.refusedSteers.add(id5);
23046
+ continue;
23047
+ }
23048
+ const record3 = (outcome) => this.journal.update(
23049
+ command.runId,
23050
+ { steerReceipts: { ...this.journal.get(command.runId)?.steerReceipts, [id5]: outcome } }
23051
+ );
23052
+ record3("starting");
23053
+ try {
23054
+ await this.supervisor.send(command.runId, command.text, "steer");
23055
+ record3("accepted");
23056
+ this.unacked.add(id5);
23057
+ } catch {
23058
+ record3("refused");
23059
+ this.refusedSteers.add(id5);
23060
+ }
23061
+ acted = true;
23062
+ continue;
23063
+ }
22518
23064
  if (isTerminalRunState(entry.state)) {
22519
23065
  if (command.kind === "stop")
22520
23066
  void this.supervisor.discardIfEmpty(command.runId, command.runId);
@@ -22583,6 +23129,7 @@ var Daemon = class {
22583
23129
  const report2 = {
22584
23130
  ...info,
22585
23131
  ...this.modelReports.get(info.harness),
23132
+ ...info.harness === "codex" && info.installed ? { activeTurnSteer: true } : {},
22586
23133
  toolApproval: this.supportsToolApproval(info),
22587
23134
  coordinator: false
22588
23135
  };
@@ -22723,11 +23270,11 @@ var Daemon = class {
22723
23270
  return runVerify(sandbox, {
22724
23271
  command,
22725
23272
  worktree: realpathSync15(worktree),
22726
- tmpRoot: join35(this.paths.adapterState, "verify", runId),
23273
+ tmpRoot: join36(this.paths.adapterState, "verify", runId),
22727
23274
  privateDir: paths.privateDir,
22728
23275
  pidFile: paths.pidFile.replace(/\.pgid$/, ".verify.pgid"),
22729
23276
  networkAllow: repo.networkAllow,
22730
- env: { ...buildChildEnv(), ...githubEnvironment, MIKKA_HANDOFF_FILE: join35(paths.runDir, "handoff.json") },
23277
+ env: { ...buildChildEnv(), ...githubEnvironment, MIKKA_HANDOFF_FILE: join36(paths.runDir, "handoff.json") },
22731
23278
  timeoutMs,
22732
23279
  signal,
22733
23280
  readOnly
@@ -22817,7 +23364,7 @@ var Daemon = class {
22817
23364
  }
22818
23365
  /** Idle on the push socket: no runs, nothing waiting to upload. The database can sleep. */
22819
23366
  gatewayIdle() {
22820
- return this.gatewayLive && this.server === "online" && this.supervisor.heartbeatRuns().length === 0 && this.queuedClaims.size === 0 && this.unacked.size === 0 && this.outbox.pending() === 0 && !this.draining && !this.updating && this.deviceReceiptsVersion === this.deviceReceiptsAcknowledged;
23367
+ return this.gatewayLive && this.server === "online" && this.supervisor.heartbeatRuns().length === 0 && this.queuedClaims.size === 0 && this.unacked.size === 0 && this.refusedSteers.size === 0 && this.outbox.pending() === 0 && !this.draining && !this.updating && this.deviceReceiptsVersion === this.deviceReceiptsAcknowledged;
22821
23368
  }
22822
23369
  schedule(delay2) {
22823
23370
  if (this.stopped) return;
@@ -22899,14 +23446,14 @@ var Daemon = class {
22899
23446
  }
22900
23447
  const initialRunId = this.initialRunHint;
22901
23448
  let resolveRepositories, rejectRepositories;
22902
- const repositoriesReady = initialRunId ? new Promise((resolve19, reject) => {
22903
- resolveRepositories = resolve19;
23449
+ const repositoriesReady = initialRunId ? new Promise((resolve20, reject) => {
23450
+ resolveRepositories = resolve20;
22904
23451
  rejectRepositories = reject;
22905
23452
  }) : void 0;
22906
23453
  if (initialRunId && repositoriesReady) {
22907
23454
  let received;
22908
- const repository2 = this.options.hostedSubscriptions && this.options.e2bContainerRuntime && this.journal.all().length === 0 ? new Promise((resolve19) => {
22909
- received = resolve19;
23455
+ const repository2 = this.options.hostedSubscriptions && this.options.e2bContainerRuntime && this.journal.all().length === 0 ? new Promise((resolve20) => {
23456
+ received = resolve20;
22910
23457
  }) : void 0;
22911
23458
  this.initialRepositorySync = { runId: initialRunId, ready: repositoriesReady, repository: repository2, received };
22912
23459
  void repositoriesReady.catch(() => void 0);
@@ -23335,7 +23882,7 @@ var Daemon = class {
23335
23882
  });
23336
23883
  }
23337
23884
  get updateStateFile() {
23338
- return join35(this.paths.dataDir, "auto-update.json");
23885
+ return join36(this.paths.dataDir, "auto-update.json");
23339
23886
  }
23340
23887
  /** A server named this release (heartbeat, commands poll or refused claim); older servers name none. */
23341
23888
  learnRelease(latest) {