@quantiya/codevibe-core 2.0.80 → 2.0.81

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.
@@ -149,7 +149,7 @@ async function fireBeacon(name, params, clientId = getClientId()) {
149
149
  client_id: clientId,
150
150
  events: [{ name, params }]
151
151
  });
152
- await new Promise((resolve28) => {
152
+ await new Promise((resolve29) => {
153
153
  let req = https.request(
154
154
  {
155
155
  hostname: GA4_HOSTNAME,
@@ -157,9 +157,9 @@ async function fireBeacon(name, params, clientId = getClientId()) {
157
157
  method: "POST",
158
158
  headers: { "Content-Type": "application/json" }
159
159
  },
160
- () => resolve28()
160
+ () => resolve29()
161
161
  );
162
- req.on("error", () => resolve28()), req.write(payload), req.end(), setTimeout(resolve28, 2e3);
162
+ req.on("error", () => resolve29()), req.write(payload), req.end(), setTimeout(resolve29, 2e3);
163
163
  });
164
164
  } catch {
165
165
  }
@@ -641,7 +641,7 @@ var import_node_child_process8, path66, GIT_TIMEOUT_MS, SCRUBBED_ENV, defaultGit
641
641
  import_node_child_process8 = require("node:child_process"), path66 = __toESM(require("node:path")), GIT_TIMEOUT_MS = 5e3, SCRUBBED_ENV = (() => {
642
642
  let out = {};
643
643
  return process.env.PATH && (out.PATH = process.env.PATH), process.env.LANG && (out.LANG = process.env.LANG), process.env.LC_ALL && (out.LC_ALL = process.env.LC_ALL), out;
644
- })(), defaultGitExec = (args, options) => new Promise((resolve28, reject) => {
644
+ })(), defaultGitExec = (args, options) => new Promise((resolve29, reject) => {
645
645
  (0, import_node_child_process8.execFile)(
646
646
  "git",
647
647
  args,
@@ -658,7 +658,7 @@ var import_node_child_process8, path66, GIT_TIMEOUT_MS, SCRUBBED_ENV, defaultGit
658
658
  return;
659
659
  }
660
660
  let out = stdout;
661
- resolve28(typeof out == "string" ? out : out.toString("utf8"));
661
+ resolve29(typeof out == "string" ? out : out.toString("utf8"));
662
662
  }
663
663
  ).on("error", reject);
664
664
  });
@@ -887,8 +887,8 @@ var import_node_fs28, path67, os39, crypto26, import_json_freeze15, import_yaml,
887
887
  this.locked = !0;
888
888
  return;
889
889
  }
890
- return new Promise((resolve28) => {
891
- this.waiters.push(resolve28);
890
+ return new Promise((resolve29) => {
891
+ this.waiters.push(resolve29);
892
892
  });
893
893
  }
894
894
  release() {
@@ -1018,8 +1018,8 @@ CodeVibe \u2014 choose an agent:
1018
1018
  out.write(` ${marker} [${i + 1}] ${a.kind.padEnd(8)} ${a.binPath}
1019
1019
  `);
1020
1020
  }); ; ) {
1021
- let trimmed = (await new Promise((resolve28) => {
1022
- rl.question(`Agent [1-${args.healthy.length}] (default ${args.defaultIndex + 1}): `, resolve28);
1021
+ let trimmed = (await new Promise((resolve29) => {
1022
+ rl.question(`Agent [1-${args.healthy.length}] (default ${args.defaultIndex + 1}): `, resolve29);
1023
1023
  })).trim();
1024
1024
  if (trimmed === "") return args.healthy[args.defaultIndex];
1025
1025
  let n = Number.parseInt(trimmed, 10);
@@ -1702,7 +1702,14 @@ function getConfig() {
1702
1702
  // src/credential-broker/oauth-account-lock.ts
1703
1703
  var import_node_fs = require("node:fs"), os4 = __toESM(require("node:os")), path3 = __toESM(require("node:path")), import_node_crypto = require("node:crypto");
1704
1704
  init_logger2();
1705
- var DEFAULT_TTL_MS = 3e4, DEFAULT_HEARTBEAT_MS = 5e3, DEFAULT_MAX_WAIT_MS = 6e4, DEFAULT_BACKOFF_MS = 25;
1705
+ var LocalLockBusyError = class extends Error {
1706
+ constructor(diagnostic) {
1707
+ super(`[oauth-account-lock] timed out acquiring OAuth-account lock after ${diagnostic.waitMs}ms (holder not reclaimable) ${JSON.stringify(diagnostic)}`);
1708
+ this.diagnostic = diagnostic;
1709
+ this.code = "LOCAL_LOCK_BUSY";
1710
+ this.name = "LocalLockBusyError";
1711
+ }
1712
+ }, DEFAULT_TTL_MS = 3e4, DEFAULT_HEARTBEAT_MS = 5e3, DEFAULT_MAX_WAIT_MS = 6e4, DEFAULT_BACKOFF_MS = 25;
1706
1713
  function errCode(err) {
1707
1714
  return err?.code;
1708
1715
  }
@@ -1719,7 +1726,7 @@ function defaultIsProcessAlive(selfHost) {
1719
1726
  }
1720
1727
  var OAuthAccountLock = class {
1721
1728
  constructor(opts) {
1722
- this.lockDir = opts.lockDir, this.requireRemovalOnRelease = opts.requireRemovalOnRelease === !0, this.ownerFile = path3.join(this.lockDir, "owner.json"), this.reclaimGuardDir = `${this.lockDir}.reclaim`, this.ttlMs = opts.ttlMs ?? DEFAULT_TTL_MS, this.heartbeatMs = opts.heartbeatMs ?? DEFAULT_HEARTBEAT_MS, this.maxWaitMs = opts.maxWaitMs ?? DEFAULT_MAX_WAIT_MS, this.ownerlessGraceMs = opts.ownerlessGraceMs ?? this.ttlMs * 2, this.backoffMs = opts.backoffMs ?? DEFAULT_BACKOFF_MS, this.now = opts.now ?? Date.now, this.delayFn = opts.delay ?? ((ms) => new Promise((r) => setTimeout(r, ms))), this.pid = opts.pid ?? process.pid, this.hostId = opts.hostId ?? os4.hostname(), this.isProcessAlive = opts.isProcessAlive ?? defaultIsProcessAlive(this.hostId), this.randomId = opts.randomId ?? (() => (0, import_node_crypto.randomUUID)()), this.utimesFn = opts.utimesFn ?? ((dir) => import_node_fs.promises.utimes(dir, /* @__PURE__ */ new Date(), /* @__PURE__ */ new Date())), this.disableAutoHeartbeat = opts.disableAutoHeartbeat ?? !1;
1729
+ this.lockDir = opts.lockDir, this.role = opts.role ?? "oauth-account", this.requireRemovalOnRelease = opts.requireRemovalOnRelease === !0, this.ownerFile = path3.join(this.lockDir, "owner.json"), this.reclaimGuardDir = `${this.lockDir}.reclaim`, this.ttlMs = opts.ttlMs ?? DEFAULT_TTL_MS, this.heartbeatMs = opts.heartbeatMs ?? DEFAULT_HEARTBEAT_MS, this.maxWaitMs = opts.maxWaitMs ?? DEFAULT_MAX_WAIT_MS, this.ownerlessGraceMs = opts.ownerlessGraceMs ?? this.ttlMs * 2, this.backoffMs = opts.backoffMs ?? DEFAULT_BACKOFF_MS, this.now = opts.now ?? Date.now, this.delayFn = opts.delay ?? ((ms) => new Promise((r) => setTimeout(r, ms))), this.pid = opts.pid ?? process.pid, this.hostId = opts.hostId ?? os4.hostname(), this.isProcessAlive = opts.isProcessAlive ?? defaultIsProcessAlive(this.hostId), this.randomId = opts.randomId ?? (() => (0, import_node_crypto.randomUUID)()), this.utimesFn = opts.utimesFn ?? ((dir) => import_node_fs.promises.utimes(dir, /* @__PURE__ */ new Date(), /* @__PURE__ */ new Date())), this.disableAutoHeartbeat = opts.disableAutoHeartbeat ?? !1;
1723
1730
  }
1724
1731
  /**
1725
1732
  * Acquire the lock (bounded by `maxWaitMs`). Resolves a {@link LockHandle} on
@@ -1746,12 +1753,21 @@ var OAuthAccountLock = class {
1746
1753
  if (handle) return handle;
1747
1754
  }
1748
1755
  if (this.now() - start >= this.maxWaitMs)
1749
- throw new Error(
1750
- `[oauth-account-lock] timed out acquiring OAuth-account lock after ${this.maxWaitMs}ms (holder not reclaimable)`
1751
- );
1756
+ throw await this.contentionError();
1752
1757
  await this.backoff(attempt);
1753
1758
  }
1754
1759
  }
1760
+ async contentionError() {
1761
+ let snapshot2 = await this.readOwnerState(this.lockDir), owner = snapshot2.kind === "owner" ? snapshot2.owner : null, startedAt = owner ? Date.parse(owner.startedAt) : NaN;
1762
+ return new LocalLockBusyError({
1763
+ role: this.role,
1764
+ lockId: (0, import_node_crypto.createHash)("sha256").update(path3.resolve(this.lockDir)).digest("hex"),
1765
+ holderPid: owner?.pid ?? null,
1766
+ holderState: owner ? this.isProcessAlive(owner.pid, owner.host) : snapshot2.kind,
1767
+ heldMs: Number.isFinite(startedAt) ? Math.max(0, this.now() - startedAt) : null,
1768
+ waitMs: this.maxWaitMs
1769
+ });
1770
+ }
1755
1771
  /** Whether the EXISTING lockdir holder is reclaimable (dead), an ownerless strand
1756
1772
  * (F6), or must be waited on. */
1757
1773
  async classifyExistingHolder() {
@@ -4362,8 +4378,8 @@ async function settleWithin(p, ms) {
4362
4378
  try {
4363
4379
  return await Promise.race([
4364
4380
  p,
4365
- new Promise((resolve28) => {
4366
- timer = setTimeout(() => resolve28(void 0), Math.max(0, ms));
4381
+ new Promise((resolve29) => {
4382
+ timer = setTimeout(() => resolve29(void 0), Math.max(0, ms));
4367
4383
  })
4368
4384
  ]);
4369
4385
  } finally {
@@ -4432,9 +4448,9 @@ async function classifyGitWorkspace(workspaceRoot, timeoutMs) {
4432
4448
  }
4433
4449
  }
4434
4450
  async function probeAdvisoryWorkspaceFingerprint(workspaceRoot, options = {}) {
4435
- let started = Date.now(), timeoutMs = options.timeoutMs ?? ADVISORY_WALK_FINGERPRINT_TIMEOUT_MS, state = { method: "marker", expired: !1 }, timer, deadlineHit = new Promise((resolve28) => {
4451
+ let started = Date.now(), timeoutMs = options.timeoutMs ?? ADVISORY_WALK_FINGERPRINT_TIMEOUT_MS, state = { method: "marker", expired: !1 }, timer, deadlineHit = new Promise((resolve29) => {
4436
4452
  timer = setTimeout(() => {
4437
- state.expired = !0, resolve28({ kind: "probe-failed", method: state.method, reason: "timeout", durationMs: Date.now() - started });
4453
+ state.expired = !0, resolve29({ kind: "probe-failed", method: state.method, reason: "timeout", durationMs: Date.now() - started });
4438
4454
  }, Math.max(0, timeoutMs));
4439
4455
  });
4440
4456
  try {
@@ -6096,8 +6112,8 @@ async function cleanExitFieldsAfterPrime(sessionId, maxWaitMs = PRIME_WAIT_MAX_M
6096
6112
  let pending2 = pendingPrimes.get(sessionId);
6097
6113
  if (pending2) {
6098
6114
  let timer;
6099
- await Promise.race([pending2, new Promise((resolve28) => {
6100
- timer = setTimeout(resolve28, maxWaitMs), timer.unref?.();
6115
+ await Promise.race([pending2, new Promise((resolve29) => {
6116
+ timer = setTimeout(resolve29, maxWaitMs), timer.unref?.();
6101
6117
  })]), timer && clearTimeout(timer);
6102
6118
  }
6103
6119
  return buildCleanExitFields(sessionId);
@@ -6134,7 +6150,7 @@ async function holdAfterResumeLock(predecessorSessionId, opts = {}) {
6134
6150
  let write = opts.write ?? ((text2) => process.stdout.write(text2));
6135
6151
  write(`CODEVIBE_E2E_HOLD ${predecessorSessionId}
6136
6152
  `);
6137
- let exists = opts.exists ?? import_node_fs2.existsSync, sleep2 = opts.sleep ?? ((ms) => new Promise((resolve28) => setTimeout(resolve28, ms))), now = opts.now ?? Date.now, started = now();
6153
+ let exists = opts.exists ?? import_node_fs2.existsSync, sleep2 = opts.sleep ?? ((ms) => new Promise((resolve29) => setTimeout(resolve29, ms))), now = opts.now ?? Date.now, started = now();
6138
6154
  for (; !exists(releaseFile); ) {
6139
6155
  if (now() - started >= E2E_HOLD_MAX_MS) {
6140
6156
  write(`CODEVIBE_E2E_HOLD_TIMEOUT ${predecessorSessionId}
@@ -6304,7 +6320,7 @@ function validPid(pid) {
6304
6320
  return Number.isSafeInteger(pid) && pid > 0;
6305
6321
  }
6306
6322
  async function boundedExec(command, args) {
6307
- return new Promise((resolve28) => {
6323
+ return new Promise((resolve29) => {
6308
6324
  let child;
6309
6325
  try {
6310
6326
  child = (0, import_node_child_process2.spawn)(command, args, {
@@ -6313,11 +6329,11 @@ async function boundedExec(command, args) {
6313
6329
  env: scrubSearchApiKeys({ ...process.env })
6314
6330
  });
6315
6331
  } catch {
6316
- resolve28(null);
6332
+ resolve29(null);
6317
6333
  return;
6318
6334
  }
6319
6335
  let chunks = [], bytes = 0, settled = !1, finish = (value) => {
6320
- settled || (settled = !0, clearTimeout(timer), resolve28(value));
6336
+ settled || (settled = !0, clearTimeout(timer), resolve29(value));
6321
6337
  }, timer = setTimeout(() => {
6322
6338
  try {
6323
6339
  child.kill("SIGKILL");
@@ -11000,8 +11016,8 @@ var sourceCursorId = (scope, stream) => stableUuid("codevibe-sync-source-cursor-
11000
11016
  * serializes original callers and restarted owners without holding the
11001
11017
  * account store lock across network awaits. Only an exact ACK permits removal.
11002
11018
  * Admission closure/PAUSED does not authorize dropping pending control work. */
11003
- async runPromptResolution(value, resolve28, options = {}) {
11004
- if (typeof resolve28 != "function") return invalid7();
11019
+ async runPromptResolution(value, resolve29, options = {}) {
11020
+ if (typeof resolve29 != "function") return invalid7();
11005
11021
  let input = snapshotSyncPromptResolution(value), id5 = input.clientOperationId, expected = decodePromptResolution({ schemaVersion: 1, kind: "PROMPT_RESOLUTION", operationId: id5, input }, this.options.userId, invalid7);
11006
11022
  if (!this.matchesPromptResolutionScope(input)) return invalid7();
11007
11023
  this.options.assertAccount(), await this.ensureDirectory();
@@ -11021,7 +11037,7 @@ var sourceCursorId = (scope, stream) => stableUuid("codevibe-sync-source-cursor-
11021
11037
  let sealed = this.seal(expected, key);
11022
11038
  return await this.checkCapacity(Buffer.byteLength(sealed), id5 + ".resolution"), await this.write(id5, sealed, ".resolution"), expected;
11023
11039
  });
11024
- return await fence(), row3 ? await resolve28(row3.input, fence) !== !0 ? (await fence(), !1) : (await fence(), await this.withStore(async (key) => {
11040
+ return await fence(), row3 ? await resolve29(row3.input, fence) !== !0 ? (await fence(), !1) : (await fence(), await this.withStore(async (key) => {
11025
11041
  await this.readValue(id5, key, ".resolution", validate) && (await fence(), await import_node_fs5.promises.unlink(this.file(id5, ".resolution")), await this.syncDirectory(this.directory));
11026
11042
  }), await fence(), !0) : !0;
11027
11043
  } finally {
@@ -11749,6 +11765,7 @@ var sourceCursorId = (scope, stream) => stableUuid("codevibe-sync-source-cursor-
11749
11765
  lockDir: path19.join(this.directory, name),
11750
11766
  ownerlessGraceMs: 1 / 0,
11751
11767
  maxWaitMs: 2e3,
11768
+ role: name === "store.lockdir" ? "sync-journal-store" : "sync-journal",
11752
11769
  requireRemovalOnRelease
11753
11770
  });
11754
11771
  }
@@ -11967,8 +11984,8 @@ var count3 = import_zod9.z.string().regex(/^(0|[1-9][0-9]{0,18})$/).refine((s) =
11967
11984
  if (this.starting) return this.starting;
11968
11985
  if (this.phase !== "new") return Promise.reject(failure());
11969
11986
  this.phase = "opening";
11970
- let ready = new Promise((resolve28, reject) => {
11971
- this.resolveReady = resolve28, this.rejectReady = reject;
11987
+ let ready = new Promise((resolve29, reject) => {
11988
+ this.resolveReady = resolve29, this.rejectReady = reject;
11972
11989
  });
11973
11990
  return ready.catch(() => {
11974
11991
  }), this.starting = Promise.resolve().then(async () => {
@@ -12226,9 +12243,9 @@ var count3 = import_zod9.z.string().regex(/^(0|[1-9][0-9]{0,18})$/).refine((s) =
12226
12243
  this.phase = "closed", this.abort.abort(failure()), this.rejectReady?.(failure()), clearTimeout(this.controlTimer), clearTimeout(this.pongTimer), clearTimeout(this.heartbeatTimer), clearTimeout(this.recoveryTimer), clearInterval(this.pingTimer);
12227
12244
  let ws = this.ws;
12228
12245
  this.ws = void 0;
12229
- let socketClosed = new Promise((resolve28) => {
12246
+ let socketClosed = new Promise((resolve29) => {
12230
12247
  if (!ws || ws.readyState === import_ws.default.CLOSED) {
12231
- resolve28();
12248
+ resolve29();
12232
12249
  return;
12233
12250
  }
12234
12251
  ws.removeAllListeners(), ws.on("error", () => {
@@ -12237,7 +12254,7 @@ var count3 = import_zod9.z.string().regex(/^(0|[1-9][0-9]{0,18})$/).refine((s) =
12237
12254
  ws.terminate();
12238
12255
  }, 5e3);
12239
12256
  timer.unref?.(), ws.once("close", () => {
12240
- clearTimeout(timer), resolve28();
12257
+ clearTimeout(timer), resolve29();
12241
12258
  });
12242
12259
  try {
12243
12260
  ws.close(1e3);
@@ -12992,6 +13009,7 @@ var RESERVED_STATE_FILES = /* @__PURE__ */ new Set(["ledger.json", "legacy-owned
12992
13009
  if (!identity.isDirectory() || identity.isSymbolicLink() || typeof process.getuid == "function" && identity.uid !== process.getuid()) throw new Error("Tool sync directory invalid");
12993
13010
  let owner = await createOAuthAccountLock({
12994
13011
  lockDir: path22.join(dir, ".sync-recovery.lockdir"),
13012
+ role: "tool-sync-recovery",
12995
13013
  ownerlessGraceMs: 1 / 0,
12996
13014
  maxWaitMs: 2e3,
12997
13015
  requireRemovalOnRelease: !0
@@ -13453,8 +13471,8 @@ var DecisionAttemptReceiptStore = class _DecisionAttemptReceiptStore {
13453
13471
  return path23.join(path23.resolve(this.rootDir), opaqueSegment(sessionId));
13454
13472
  }
13455
13473
  async withSessionLock(sessionId, operation) {
13456
- let key = this.sessionQueueKey(sessionId), prior = _DecisionAttemptReceiptStore.sessionQueues.get(key) ?? Promise.resolve(), release, gate = new Promise((resolve28) => {
13457
- release = resolve28;
13474
+ let key = this.sessionQueueKey(sessionId), prior = _DecisionAttemptReceiptStore.sessionQueues.get(key) ?? Promise.resolve(), release, gate = new Promise((resolve29) => {
13475
+ release = resolve29;
13458
13476
  }), tail = prior.then(() => gate);
13459
13477
  _DecisionAttemptReceiptStore.sessionQueues.set(key, tail), await prior;
13460
13478
  try {
@@ -14206,9 +14224,9 @@ var AppSyncClient = class _AppSyncClient {
14206
14224
  if (signal?.aborted) throw _AppSyncClient.abortReason(signal);
14207
14225
  }
14208
14226
  static async waitForSyncStateRetry(delayMs, signal) {
14209
- _AppSyncClient.throwIfAborted(signal), await new Promise((resolve28, reject) => {
14227
+ _AppSyncClient.throwIfAborted(signal), await new Promise((resolve29, reject) => {
14210
14228
  let timer = setTimeout(() => {
14211
- signal?.removeEventListener("abort", onAbort), resolve28();
14229
+ signal?.removeEventListener("abort", onAbort), resolve29();
14212
14230
  }, delayMs), onAbort = () => {
14213
14231
  clearTimeout(timer), signal?.removeEventListener("abort", onAbort), reject(_AppSyncClient.abortReason(signal));
14214
14232
  };
@@ -14256,7 +14274,7 @@ var AppSyncClient = class _AppSyncClient {
14256
14274
  * the operation itself settles.
14257
14275
  */
14258
14276
  static awaitSharedFlightForCaller(flight, signal) {
14259
- return signal ? (_AppSyncClient.throwIfAborted(signal), new Promise((resolve28, reject) => {
14277
+ return signal ? (_AppSyncClient.throwIfAborted(signal), new Promise((resolve29, reject) => {
14260
14278
  let settled = !1, finish = (operation) => {
14261
14279
  settled || (settled = !0, signal.removeEventListener("abort", onAbort), operation());
14262
14280
  }, onAbort = () => {
@@ -14267,7 +14285,7 @@ var AppSyncClient = class _AppSyncClient {
14267
14285
  return;
14268
14286
  }
14269
14287
  flight.then(
14270
- (value) => finish(() => resolve28(value)),
14288
+ (value) => finish(() => resolve29(value)),
14271
14289
  (error) => finish(() => reject(error))
14272
14290
  );
14273
14291
  })) : flight;
@@ -14605,7 +14623,7 @@ var AppSyncClient = class _AppSyncClient {
14605
14623
  owned2.promise.then(settled, settled);
14606
14624
  }
14607
14625
  let owned = flight;
14608
- return owned.waiters++, new Promise((resolve28, reject) => {
14626
+ return owned.waiters++, new Promise((resolve29, reject) => {
14609
14627
  let finished = !1, finish = (error) => {
14610
14628
  if (!finished) {
14611
14629
  finished = !0, signal?.removeEventListener("abort", onAbort), --owned.waiters === 0 && !owned.settled && (this.syncStateRead === owned && (this.syncStateRead = null), owned.controller.abort(new Error("Sync state read has no callers")));
@@ -14613,7 +14631,7 @@ var AppSyncClient = class _AppSyncClient {
14613
14631
  if (check(), error !== void 0) throw error;
14614
14632
  let state = this.companionSyncStatusSnapshot(userId);
14615
14633
  if (!state) throw new SyncEventClientError("INVALID_SYNC_STATE");
14616
- resolve28(state);
14634
+ resolve29(state);
14617
14635
  } catch (failure2) {
14618
14636
  reject(failure2);
14619
14637
  }
@@ -15310,8 +15328,8 @@ var AppSyncClient = class _AppSyncClient {
15310
15328
  * its existing domain authority to obtain a validated resolution ACK. This
15311
15329
  * method grants no backend authority and creates no new visible occurrence.
15312
15330
  * False, thrown or account-switched acknowledgements retain the source. */
15313
- resolvePromptPublication(value, resolve28, options = {}) {
15314
- if (!value || typeof value != "object" || Array.isArray(value) || typeof resolve28 != "function" || Object.keys(value).some((field2) => !["sessionId", "promptId"].includes(field2)) || typeof value.sessionId != "string" || !/^[A-Za-z0-9_-]{1,256}$/.test(value.sessionId) || typeof value.promptId != "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(value.promptId))
15331
+ resolvePromptPublication(value, resolve29, options = {}) {
15332
+ if (!value || typeof value != "object" || Array.isArray(value) || typeof resolve29 != "function" || Object.keys(value).some((field2) => !["sessionId", "promptId"].includes(field2)) || typeof value.sessionId != "string" || !/^[A-Za-z0-9_-]{1,256}$/.test(value.sessionId) || typeof value.promptId != "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(value.promptId))
15315
15333
  return Promise.reject(new SyncEventClientError("INVALID_SYNC_INPUT"));
15316
15334
  let input = { ...value }, { root, signal } = options, userId = this.getCurrentUserId(), check = () => {
15317
15335
  this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal);
@@ -15322,7 +15340,7 @@ var AppSyncClient = class _AppSyncClient {
15322
15340
  let journals = records.map((scope) => this.desktopSyncWriter({ root, sessionScope: scope }).promptPublication(input.promptId));
15323
15341
  for (let journal of journals)
15324
15342
  await journal.settle(signal), check();
15325
- let acknowledged = await resolve28(records.length > 0);
15343
+ let acknowledged = await resolve29(records.length > 0);
15326
15344
  if (check(), acknowledged !== !0) return !1;
15327
15345
  for (let journal of journals)
15328
15346
  await journal.close(), check();
@@ -15742,16 +15760,16 @@ var AppSyncClient = class _AppSyncClient {
15742
15760
  /**
15743
15761
  * Update a session
15744
15762
  */
15745
- async updateSession(input) {
15763
+ async updateSession(input, options = {}) {
15746
15764
  if (input.status === void 0)
15747
- return this.doUpdateSession(input);
15748
- let next = (this.statusWriteChains.get(input.sessionId) ?? Promise.resolve()).catch(() => {
15749
- }).then(() => this.doUpdateSession(input));
15765
+ return this.doUpdateSession(input, options.expectedUserId);
15766
+ let prior = this.statusWriteChains.get(input.sessionId) ?? Promise.resolve(), expectedUserId = options.expectedUserId, next = prior.catch(() => {
15767
+ }).then(() => this.doUpdateSession(input, expectedUserId));
15750
15768
  return this.statusWriteChains.set(input.sessionId, next.catch(() => {
15751
15769
  })), next;
15752
15770
  }
15753
- async doUpdateSession(input) {
15754
- input.status === "INACTIVE" /* INACTIVE */ && (this.syncRetiringSessions.add(input.sessionId), this.cleanupSubscription(input.sessionId), await Promise.all([
15771
+ async doUpdateSession(input, expectedUserId) {
15772
+ expectedUserId !== void 0 && this.assertSyncAccount(expectedUserId), input.status === "INACTIVE" /* INACTIVE */ && (this.syncRetiringSessions.add(input.sessionId), this.cleanupSubscription(input.sessionId), await Promise.all([
15755
15773
  this.joinSyncSubscriptionClosures(input.sessionId),
15756
15774
  ...[...this.syncReadOwners.get(input.sessionId) ?? []].map((reader) => reader.close())
15757
15775
  ]));
@@ -15760,12 +15778,12 @@ var AppSyncClient = class _AppSyncClient {
15760
15778
  metadata: input.metadata ? JSON.stringify(input.metadata) : void 0
15761
15779
  }, response;
15762
15780
  try {
15763
- response = await this.graphqlRequest(mutations.updateSession, { input: preparedInput });
15781
+ response = await this.graphqlRequest(mutations.updateSession, { input: preparedInput }, !1, void 0, expectedUserId);
15764
15782
  } catch (error) {
15765
15783
  if (!hasCleanExitFields(preparedInput) || !isUnknownCleanExitFieldError(error)) throw error;
15766
15784
  logger.warn("[AppSyncClient] Server rejected the P61 clean-exit fields; retrying without them", {
15767
15785
  sessionId: input.sessionId
15768
- }), response = await this.graphqlRequest(mutations.updateSession, { input: withoutCleanExitFields(preparedInput) });
15786
+ }), response = await this.graphqlRequest(mutations.updateSession, { input: withoutCleanExitFields(preparedInput) }, !1, void 0, expectedUserId);
15769
15787
  }
15770
15788
  logger.debug("[AppSyncClient] Session updated", { sessionId: response.data.updateSession.sessionId });
15771
15789
  let session2 = response.data.updateSession;
@@ -19326,7 +19344,7 @@ async function prepareSessionEncryption(sessionId, appSyncClient, logger2) {
19326
19344
  sessionId,
19327
19345
  attempt: attempt + 1,
19328
19346
  delayMs
19329
- }), await new Promise((resolve28) => setTimeout(resolve28, delayMs));
19347
+ }), await new Promise((resolve29) => setTimeout(resolve29, delayMs));
19330
19348
  }
19331
19349
  }
19332
19350
  if (serviceDeviceKeys.length === 0)
@@ -20988,8 +21006,8 @@ function finishedResumeMessage(predecessorSessionId, successorSessionId) {
20988
21006
  async function publishThenRetire(args) {
20989
21007
  let { deps } = args, preview = args.encryptedLastPrompt ? { encryptedLastPrompt: args.encryptedLastPrompt } : {}, note = { successorSessionId: args.successorSessionId, predecessorSessionId: args.predecessorSessionId, marker: args.marker, ...preview };
20990
21008
  try {
20991
- let timer, drained = deps.drain(args.successorSessionId).then(() => !0, () => !1), timedOut = new Promise((resolve28) => {
20992
- timer = setTimeout(() => resolve28(!1), deps.timeoutMs ?? PUBLISH_DRAIN_TIMEOUT_MS), timer.unref?.();
21009
+ let timer, drained = deps.drain(args.successorSessionId).then(() => !0, () => !1), timedOut = new Promise((resolve29) => {
21010
+ timer = setTimeout(() => resolve29(!1), deps.timeoutMs ?? PUBLISH_DRAIN_TIMEOUT_MS), timer.unref?.();
20993
21011
  }), ok = await Promise.race([drained, timedOut]);
20994
21012
  return timer && clearTimeout(timer), ok ? (await deps.updateSession({
20995
21013
  sessionId: args.successorSessionId,
@@ -21500,22 +21518,22 @@ function ResumeChoice(props) {
21500
21518
  }
21501
21519
  async function runResumePicker(rows) {
21502
21520
  let { ink } = getInkRuntime();
21503
- return new Promise((resolve28) => {
21521
+ return new Promise((resolve29) => {
21504
21522
  let instance = null, done = (value) => {
21505
- instance?.unmount(), resolve28(value);
21523
+ instance?.unmount(), resolve29(value);
21506
21524
  };
21507
21525
  instance = ink.render(React.createElement(ResumePicker, { rows, onSelect: (id5) => done(id5), onCancel: () => done(null) }));
21508
21526
  });
21509
21527
  }
21510
21528
  async function runResumeChoice(prompt, continueLabel) {
21511
21529
  let { ink } = getInkRuntime();
21512
- return new Promise((resolve28) => {
21530
+ return new Promise((resolve29) => {
21513
21531
  let instance = null;
21514
21532
  instance = ink.render(React.createElement(ResumeChoice, {
21515
21533
  prompt,
21516
21534
  ...continueLabel ? { continueLabel } : {},
21517
21535
  onChoose: (value) => {
21518
- instance?.unmount(), resolve28(value);
21536
+ instance?.unmount(), resolve29(value);
21519
21537
  }
21520
21538
  }));
21521
21539
  });
@@ -21626,8 +21644,8 @@ CodeVibe \u2014 choose mode (${tier} tier):
21626
21644
  `), process.stdout.write(` \x1B[36m[1]\x1B[0m \x1B[1mCompanion\x1B[0m \x1B[2m(route to local agent wrapper)\x1B[0m
21627
21645
  `), process.stdout.write(` \x1B[35m[2]\x1B[0m \x1B[1mOrchestration\x1B[0m \x1B[2m(CodeVibe-owned shell)\x1B[0m
21628
21646
  `)); ; ) {
21629
- let promptStr = plain6 ? "Mode [1/2]: " : "\x1B[36mMode [1/2]: \x1B[0m", trimmed = (await new Promise((resolve28) => {
21630
- rl.question(promptStr, resolve28);
21647
+ let promptStr = plain6 ? "Mode [1/2]: " : "\x1B[36mMode [1/2]: \x1B[0m", trimmed = (await new Promise((resolve29) => {
21648
+ rl.question(promptStr, resolve29);
21631
21649
  })).trim();
21632
21650
  if (trimmed === "1" || trimmed.toLowerCase() === "companion") return "companion";
21633
21651
  if (trimmed === "2" || trimmed.toLowerCase() === "orchestration") return "orchestration";
@@ -22505,7 +22523,7 @@ function requestOllamaJson(config, pathname, body, opts) {
22505
22523
  let err = new Error("Ollama request aborted by signal");
22506
22524
  return err.name = "AbortError", Promise.reject(err);
22507
22525
  }
22508
- return new Promise((resolve28, reject) => {
22526
+ return new Promise((resolve29, reject) => {
22509
22527
  let settled = !1, responseBytes = 0, responseBody = "", finish = (fn) => {
22510
22528
  settled || (settled = !0, clearTimeout(timeout), fn());
22511
22529
  }, req = chooseHttpClient(url).request(
@@ -22532,7 +22550,7 @@ function requestOllamaJson(config, pathname, body, opts) {
22532
22550
  }
22533
22551
  responseBody += decoder.write(chunk);
22534
22552
  }), res.on("end", () => {
22535
- responseBody += decoder.end(), finish(() => resolve28(responseBody));
22553
+ responseBody += decoder.end(), finish(() => resolve29(responseBody));
22536
22554
  });
22537
22555
  }
22538
22556
  ), timeout = setTimeout(() => {
@@ -22672,7 +22690,7 @@ function requestOllamaGenerateStream(config, promptText, opts) {
22672
22690
  num_ctx: numCtx
22673
22691
  }
22674
22692
  }), url = new URL("/api/generate", config.host), timeoutMs = opts?.timeoutMs ?? config.timeoutMs;
22675
- return opts?.signal?.aborted ? Promise.reject(new Error("Ollama generation aborted by signal")) : new Promise((resolve28, reject) => {
22693
+ return opts?.signal?.aborted ? Promise.reject(new Error("Ollama generation aborted by signal")) : new Promise((resolve29, reject) => {
22676
22694
  let settled = !1, responseBytes = 0, buffer = "", decoder = new import_string_decoder.StringDecoder("utf8"), out = { text: "" }, emptyRun = 0, chunks = 0, sawDone = !1, lastDone, ndjson = !1, timeout = null, idleTimer = null, activeRes = null, clearIdle = () => {
22677
22695
  idleTimer && (clearTimeout(idleTimer), idleTimer = null);
22678
22696
  }, finish = (fn) => {
@@ -22696,7 +22714,7 @@ function requestOllamaGenerateStream(config, promptText, opts) {
22696
22714
  visibleChars: out.text.length,
22697
22715
  idleMs: streamIdleCutoffMs,
22698
22716
  chunks
22699
- }), finish(() => resolve28(out)), activeRes?.destroy());
22717
+ }), finish(() => resolve29(out)), activeRes?.destroy());
22700
22718
  }, streamIdleCutoffMs);
22701
22719
  }, handleLine = (line, res) => {
22702
22720
  if (settled) return;
@@ -22729,14 +22747,14 @@ function requestOllamaGenerateStream(config, promptText, opts) {
22729
22747
  return;
22730
22748
  }
22731
22749
  if (lastDone = chunk.done, chunk.done === !0) {
22732
- sawDone = !0, finish(() => resolve28(out));
22750
+ sawDone = !0, finish(() => resolve29(out));
22733
22751
  return;
22734
22752
  }
22735
22753
  out.text.length > 0 && armIdle(), emptyRun = piece.length === 0 ? emptyRun + 1 : 0, emptyRun >= EMPTY_TOKEN_WATCHDOG && (out.cutOff = "empty-token-loop", logger.warn("[ollama] generation cut off \u2014 empty-token loop", {
22736
22754
  visibleChars: out.text.length,
22737
22755
  emptyRun,
22738
22756
  chunks
22739
- }), finish(() => resolve28(out)), res.destroy());
22757
+ }), finish(() => resolve29(out)), res.destroy());
22740
22758
  }, req = chooseHttpClient(url).request(
22741
22759
  url,
22742
22760
  {
@@ -22778,7 +22796,7 @@ function requestOllamaGenerateStream(config, promptText, opts) {
22778
22796
  );
22779
22797
  return;
22780
22798
  }
22781
- finish(() => resolve28(out));
22799
+ finish(() => resolve29(out));
22782
22800
  }
22783
22801
  }));
22784
22802
  }
@@ -22808,7 +22826,7 @@ function describeRecordError(value) {
22808
22826
  function requestOllamaPull(config, onProgress = () => {
22809
22827
  }, options) {
22810
22828
  let url = new URL("/api/pull", config.host), body = JSON.stringify({ name: config.model, stream: !0 }), stallTimeoutMs = typeof options?.stallTimeoutMs == "number" && options.stallTimeoutMs > 0 ? options.stallTimeoutMs : PULL_STALL_TIMEOUT_MS;
22811
- return new Promise((resolve28, reject) => {
22829
+ return new Promise((resolve29, reject) => {
22812
22830
  let settled = !1, buffer = "", pullDecoder = new import_string_decoder.StringDecoder("utf8"), stallTimer = null, clearStall = () => {
22813
22831
  stallTimer && (clearTimeout(stallTimer), stallTimer = null);
22814
22832
  }, finish = (fn) => {
@@ -22850,7 +22868,7 @@ function requestOllamaPull(config, onProgress = () => {
22850
22868
  status,
22851
22869
  completed: typeof parsed.completed == "number" ? parsed.completed : void 0,
22852
22870
  total: typeof parsed.total == "number" ? parsed.total : void 0
22853
- }), status === "success" && finish(() => resolve28()));
22871
+ }), status === "success" && finish(() => resolve29()));
22854
22872
  }, req = chooseHttpClient(url).request(
22855
22873
  url,
22856
22874
  {
@@ -22887,7 +22905,7 @@ function requestOllamaPull(config, onProgress = () => {
22887
22905
  }
22888
22906
  buffer.length > MAX_PULL_LINE_BYTES && (finish(() => reject(new Error("Ollama pull response line exceeded the size limit"))), res.destroy());
22889
22907
  })), res.on("end", () => guarded(() => {
22890
- settled || (buffer += pullDecoder.end(), handleLine(buffer), buffer = "", finish(() => resolve28()));
22908
+ settled || (buffer += pullDecoder.end(), handleLine(buffer), buffer = "", finish(() => resolve29()));
22891
22909
  }));
22892
22910
  }
22893
22911
  );
@@ -24156,8 +24174,8 @@ function createBoundedSharedShutdownOperation(options) {
24156
24174
  let operation = null, normalWait = null, signalWait = null, getOperation = () => {
24157
24175
  if (!operation) {
24158
24176
  let resolveOperation, rejectOperation;
24159
- operation = new Promise((resolve28, reject) => {
24160
- resolveOperation = resolve28, rejectOperation = reject;
24177
+ operation = new Promise((resolve29, reject) => {
24178
+ resolveOperation = resolve29, rejectOperation = reject;
24161
24179
  });
24162
24180
  try {
24163
24181
  Promise.resolve(options.start()).then(resolveOperation, rejectOperation);
@@ -24171,8 +24189,8 @@ function createBoundedSharedShutdownOperation(options) {
24171
24189
  try {
24172
24190
  if (await Promise.race([
24173
24191
  getOperation().then(() => "settled"),
24174
- new Promise((resolve28) => {
24175
- timer = setTimeout(() => resolve28("timeout"), timeoutMs), timer.unref?.();
24192
+ new Promise((resolve29) => {
24193
+ timer = setTimeout(() => resolve29("timeout"), timeoutMs), timer.unref?.();
24176
24194
  })
24177
24195
  ]) === "timeout") {
24178
24196
  options.onTimeout?.(deadlineClass, timeoutMs);
@@ -24286,8 +24304,8 @@ function createExplicitTtyExitCoordinator(deps) {
24286
24304
  let started = !1, resolveCompletion = () => {
24287
24305
  };
24288
24306
  return {
24289
- completion: new Promise((resolve28) => {
24290
- resolveCompletion = resolve28;
24307
+ completion: new Promise((resolve29) => {
24308
+ resolveCompletion = resolve29;
24291
24309
  }),
24292
24310
  start: () => {
24293
24311
  started || (started = !0, Promise.resolve().then(deps.runTeardown).catch(() => {
@@ -28703,8 +28721,8 @@ function spawnIsolatedHelper(command, args, options) {
28703
28721
  }), child;
28704
28722
  }
28705
28723
  function observeChildClose(child) {
28706
- return new Promise((resolve28, reject) => {
28707
- child.once("error", reject), child.once("close", resolve28);
28724
+ return new Promise((resolve29, reject) => {
28725
+ child.once("error", reject), child.once("close", resolve29);
28708
28726
  });
28709
28727
  }
28710
28728
  async function withHelperDeadline(work, timeoutMs, label, signal) {
@@ -28735,8 +28753,8 @@ async function waitBounded(work, timeoutMs) {
28735
28753
  work.then(() => {
28736
28754
  }, () => {
28737
28755
  }),
28738
- new Promise((resolve28) => {
28739
- timer = setTimeout(resolve28, timeoutMs), timer.unref?.();
28756
+ new Promise((resolve29) => {
28757
+ timer = setTimeout(resolve29, timeoutMs), timer.unref?.();
28740
28758
  })
28741
28759
  ]);
28742
28760
  } finally {
@@ -28975,7 +28993,7 @@ async function ensureDurableDirectoryTree(target2, opts = {}) {
28975
28993
  process.env[key] !== void 0 && (env[key] = process.env[key]);
28976
28994
  let child, closed4;
28977
28995
  try {
28978
- let resultPromise = new Promise((resolve28, reject) => {
28996
+ let resultPromise = new Promise((resolve29, reject) => {
28979
28997
  try {
28980
28998
  child = spawnIsolatedHelper(process.execPath, ["-e", DURABLE_DIRECTORY_BOOTSTRAP], {
28981
28999
  env,
@@ -29002,7 +29020,7 @@ async function ensureDurableDirectoryTree(target2, opts = {}) {
29002
29020
  try {
29003
29021
  let value = JSON.parse(Buffer.concat(chunks, bytes).toString("utf8"));
29004
29022
  if (typeof value.canonicalPath != "string" || typeof value.dev != "string" || typeof value.ino != "string" || typeof value.birthtimeNs != "string" || !/^\d+$/.test(value.birthtimeNs) || typeof value.mtimeMs != "number" || typeof value.created != "boolean") throw new Error("invalid durable-directory result");
29005
- resolve28(value);
29023
+ resolve29(value);
29006
29024
  } catch (err) {
29007
29025
  reject(err);
29008
29026
  }
@@ -29126,13 +29144,13 @@ async function acquireWorkspaceRootLease(authority, opts = {}) {
29126
29144
  }), closed4 = observeChildClose(child);
29127
29145
  let stderr = new BoundedOutputBuffer(4096);
29128
29146
  child.stderr?.on("data", (chunk) => stderr.push(chunk));
29129
- let ready = await withHelperDeadline(new Promise((resolve28, reject) => {
29147
+ let ready = await withHelperDeadline(new Promise((resolve29, reject) => {
29130
29148
  let value = "";
29131
29149
  child.stdout?.on("data", (chunk) => {
29132
29150
  value += chunk.toString("utf8"), value.length > 4096 && reject(new Error("workspace-lease helper exceeded output limit"));
29133
29151
  let at = value.indexOf(`
29134
29152
  `);
29135
- at >= 0 && resolve28(value.slice(0, at));
29153
+ at >= 0 && resolve29(value.slice(0, at));
29136
29154
  }), child.once("error", reject), closed4.then((code) => {
29137
29155
  code !== null && code !== 0 && reject(new Error(`workspace-lease helper failed (${code}): ${stderr.toString()}`));
29138
29156
  });
@@ -29192,7 +29210,7 @@ async function captureWorkspaceRootAuthority(workingDir, opts = {}) {
29192
29210
  process.env[key] !== void 0 && (env[key] = process.env[key]);
29193
29211
  let child, closed4;
29194
29212
  try {
29195
- let resultPromise = new Promise((resolve28, reject) => {
29213
+ let resultPromise = new Promise((resolve29, reject) => {
29196
29214
  try {
29197
29215
  child = spawnIsolatedHelper(process.execPath, ["-e", WORKSPACE_AUTHORITY_BOOTSTRAP], {
29198
29216
  env,
@@ -29227,7 +29245,7 @@ async function captureWorkspaceRootAuthority(workingDir, opts = {}) {
29227
29245
  }
29228
29246
  try {
29229
29247
  let value = JSON.parse(Buffer.concat(chunks, bytes).toString("utf8"));
29230
- assertWorkspaceRootAuthoritySchema(value), resolve28(value);
29248
+ assertWorkspaceRootAuthoritySchema(value), resolve29(value);
29231
29249
  } catch (err) {
29232
29250
  reject(err);
29233
29251
  }
@@ -32345,8 +32363,8 @@ async function runAnchoredReadWithinRoot(root, relativePath, opts) {
32345
32363
  let nextMessage = () => {
32346
32364
  let queued = messages.shift();
32347
32365
  return queued ? Promise.resolve(queued) : protocolError ? Promise.reject(protocolError) : withHelperDeadline(Promise.race([
32348
- new Promise((resolve28, reject) => {
32349
- waiter = { resolve: resolve28, reject };
32366
+ new Promise((resolve29, reject) => {
32367
+ waiter = { resolve: resolve29, reject };
32350
32368
  }),
32351
32369
  childClosed.then((code) => {
32352
32370
  throw new Error(`anchored read helper closed before result (${code}): ${stderr.toString()}`);
@@ -32824,8 +32842,8 @@ var writeChains = /* @__PURE__ */ new Map();
32824
32842
  function withWriteLock(filePath, operation, opts) {
32825
32843
  if (opts?.signal?.aborted)
32826
32844
  return Promise.reject(new Error("anchored operation aborted by signal"));
32827
- let prior = writeChains.get(filePath) ?? Promise.resolve(), isCancelled = !1, timer, abortListener, rejectCaller, resolveCaller, callerPromise = new Promise((resolve28, reject) => {
32828
- resolveCaller = resolve28, rejectCaller = reject;
32845
+ let prior = writeChains.get(filePath) ?? Promise.resolve(), isCancelled = !1, timer, abortListener, rejectCaller, resolveCaller, callerPromise = new Promise((resolve29, reject) => {
32846
+ resolveCaller = resolve29, rejectCaller = reject;
32829
32847
  }), cleanupWait = () => {
32830
32848
  timer !== void 0 && (clearTimeout(timer), timer = void 0), abortListener !== void 0 && opts?.signal && (opts.signal.removeEventListener("abort", abortListener), abortListener = void 0);
32831
32849
  };
@@ -32904,8 +32922,8 @@ async function runAnchored(parent, request3, beforeCommit, afterRename, afterWri
32904
32922
  let nextLine = async () => {
32905
32923
  let line = lines.shift();
32906
32924
  return line !== void 0 ? (backlog.onLineConsumed(utf8Bytes(line)), line) : withHelperDeadline(Promise.race([
32907
- new Promise((resolve28) => {
32908
- waiter = resolve28;
32925
+ new Promise((resolve29) => {
32926
+ waiter = resolve29;
32909
32927
  }),
32910
32928
  childClosed.then((code2) => {
32911
32929
  throw new Error(`anchored-fs helper closed before replying (${code2}): ${stderr.toString()}`);
@@ -34656,8 +34674,8 @@ function ReviewerSetupWizard(props) {
34656
34674
  // src/orchestration-shell/resume-modal.ts
34657
34675
  var pending = /* @__PURE__ */ new WeakMap();
34658
34676
  function open9(store, modal) {
34659
- return pending.get(store)?.(modal.kind === "picker" ? null : !1), new Promise((resolve28) => {
34660
- pending.set(store, resolve28), store.dispatch({ type: "RESUME_MODAL_OPEN", modal });
34677
+ return pending.get(store)?.(modal.kind === "picker" ? null : !1), new Promise((resolve29) => {
34678
+ pending.set(store, resolve29), store.dispatch({ type: "RESUME_MODAL_OPEN", modal });
34661
34679
  });
34662
34680
  }
34663
34681
  async function pickInShell(store, rows) {
@@ -34668,8 +34686,8 @@ async function chooseInShell(store, prompt, continueLabel) {
34668
34686
  return await open9(store, { kind: "choice", prompt, continueLabel }) === !0;
34669
34687
  }
34670
34688
  function settleResumeModal(store, value) {
34671
- let resolve28 = pending.get(store);
34672
- pending.delete(store), store.dispatch({ type: "RESUME_MODAL_CLOSE" }), resolve28?.(value);
34689
+ let resolve29 = pending.get(store);
34690
+ pending.delete(store), store.dispatch({ type: "RESUME_MODAL_CLOSE" }), resolve29?.(value);
34673
34691
  }
34674
34692
 
34675
34693
  // src/orchestration-shell/task-lifecycle-lines.ts
@@ -35154,7 +35172,7 @@ async function htmlToTextWorker(html, options) {
35154
35172
  if (signal?.aborted)
35155
35173
  throw new WebExtractAbortError();
35156
35174
  let workerPath = resolveExtractWorkerPath();
35157
- return new Promise((resolve28, reject) => {
35175
+ return new Promise((resolve29, reject) => {
35158
35176
  let settled = !1, timer = null, worker = null, cleanup = () => {
35159
35177
  timer && (clearTimeout(timer), timer = null), signal && signal.removeEventListener("abort", onAbort);
35160
35178
  }, onAbort = () => {
@@ -35175,7 +35193,7 @@ async function htmlToTextWorker(html, options) {
35175
35193
  }), reject(new WebExtractTimeoutError(timeoutMs)));
35176
35194
  }, timeoutMs), worker.on("message", (msg) => {
35177
35195
  settled || (settled = !0, cleanup(), worker?.terminate().catch(() => {
35178
- }), msg.success && msg.result ? resolve28(msg.result) : reject(new Error(msg.error || "HTML extraction failed in worker")));
35196
+ }), msg.success && msg.result ? resolve29(msg.result) : reject(new Error(msg.error || "HTML extraction failed in worker")));
35179
35197
  }), worker.on("error", (err) => {
35180
35198
  settled || (settled = !0, cleanup(), worker?.terminate().catch(() => {
35181
35199
  }), reject(err));
@@ -35839,14 +35857,14 @@ async function resolveValidatedIps(host, signal, customLookup = dns2.lookup) {
35839
35857
  }
35840
35858
  let records;
35841
35859
  try {
35842
- records = await new Promise((resolve28, reject) => {
35860
+ records = await new Promise((resolve29, reject) => {
35843
35861
  if (signal?.aborted) {
35844
35862
  reject(new FetchError("timeout", "aborted before DNS"));
35845
35863
  return;
35846
35864
  }
35847
35865
  let onAbort = () => reject(new FetchError("timeout", "DNS aborted"));
35848
35866
  signal?.addEventListener("abort", onAbort, { once: !0 }), customLookup(host, { all: !0 }, (err, addrs) => {
35849
- signal?.removeEventListener("abort", onAbort), err ? reject(err) : resolve28(addrs);
35867
+ signal?.removeEventListener("abort", onAbort), err ? reject(err) : resolve29(addrs);
35850
35868
  });
35851
35869
  });
35852
35870
  } catch (e) {
@@ -35898,7 +35916,7 @@ function decodeBody(buf, contentType) {
35898
35916
  return buf.toString("utf-8");
35899
35917
  }
35900
35918
  function getOnce(url, frozen, signal, options) {
35901
- return new Promise((resolve28, reject) => {
35919
+ return new Promise((resolve29, reject) => {
35902
35920
  let req = (url.protocol === "https:" ? https3 : http2).request(
35903
35921
  url,
35904
35922
  {
@@ -35918,7 +35936,7 @@ function getOnce(url, frozen, signal, options) {
35918
35936
  (res) => {
35919
35937
  let status = res.statusCode ?? 0, contentType = String(res.headers["content-type"] ?? "");
35920
35938
  if (status >= 300 && status < 400 && res.headers.location) {
35921
- res.resume(), resolve28({ status, location: res.headers.location, contentType });
35939
+ res.resume(), resolve29({ status, location: res.headers.location, contentType });
35922
35940
  return;
35923
35941
  }
35924
35942
  if (status >= 400) {
@@ -35949,7 +35967,7 @@ function getOnce(url, frozen, signal, options) {
35949
35967
  return;
35950
35968
  }
35951
35969
  chunks.push(c);
35952
- }), stream.on("end", () => resolve28({ status, contentType, body: Buffer.concat(chunks) })), stream.on("error", (e) => reject(new FetchError("network", e?.code ?? "stream error")));
35970
+ }), stream.on("end", () => resolve29({ status, contentType, body: Buffer.concat(chunks) })), stream.on("error", (e) => reject(new FetchError("network", e?.code ?? "stream error")));
35953
35971
  }
35954
35972
  );
35955
35973
  req.setTimeout(TIMEOUT_MS, () => {
@@ -36611,10 +36629,10 @@ async function startAgentWebTurn(options) {
36611
36629
  });
36612
36630
  });
36613
36631
  try {
36614
- await new Promise((resolve28, reject) => {
36632
+ await new Promise((resolve29, reject) => {
36615
36633
  server.listen(socketPath, () => {
36616
36634
  try {
36617
- fs33.chmodSync(socketPath, 384), resolve28();
36635
+ fs33.chmodSync(socketPath, 384), resolve29();
36618
36636
  } catch (err) {
36619
36637
  reject(err);
36620
36638
  }
@@ -37509,7 +37527,7 @@ function isTransientDirectoryEnumeration(error) {
37509
37527
  return error instanceof Error && error.message.includes(TRANSIENT_DIRECTORY_ENUMERATION);
37510
37528
  }
37511
37529
  function sleep(ms) {
37512
- return new Promise((resolve28) => setTimeout(resolve28, ms));
37530
+ return new Promise((resolve29) => setTimeout(resolve29, ms));
37513
37531
  }
37514
37532
  async function withTransientDirectoryEnumerationRetry(operation, opts = {}) {
37515
37533
  let maxAttempts = opts.maxAttempts ?? 4, retryDelaysMs = opts.retryDelaysMs ?? [10, 25, 50], sleepFn = opts.sleep ?? sleep;
@@ -37649,8 +37667,8 @@ function nextDirectoryWorkerMessage(worker, deadlineAt, label, signal) {
37649
37667
  if (worker.protocolError) return Promise.reject(worker.protocolError);
37650
37668
  let remaining = deadlineAt - Date.now();
37651
37669
  return remaining <= 0 ? Promise.reject(new Error(`${label} helper timed out`)) : withHelperDeadline(Promise.race([
37652
- new Promise((resolve28, reject) => {
37653
- worker.waiter = { resolve: resolve28, reject };
37670
+ new Promise((resolve29, reject) => {
37671
+ worker.waiter = { resolve: resolve29, reject };
37654
37672
  }),
37655
37673
  worker.closed.then((code) => {
37656
37674
  throw new Error(
@@ -38179,10 +38197,10 @@ function readPosixHostProtocol(child, persistOwner, syncOwnerDirectory) {
38179
38197
  let status = child.stdio?.[3];
38180
38198
  if (!status || typeof status.on != "function")
38181
38199
  return { cleanupSafe: Promise.resolve(!1), owner: Promise.resolve(void 0) };
38182
- let resolveCleanup, resolveOwner, cleanupSafe = new Promise((resolve28) => {
38183
- resolveCleanup = resolve28;
38184
- }), owner = new Promise((resolve28) => {
38185
- resolveOwner = resolve28;
38200
+ let resolveCleanup, resolveOwner, cleanupSafe = new Promise((resolve29) => {
38201
+ resolveCleanup = resolve29;
38202
+ }), owner = new Promise((resolve29) => {
38203
+ resolveOwner = resolve29;
38186
38204
  }), pending2 = "", bytes = 0, ownerSettled = !1, cleanupSettled = !1, finish = () => {
38187
38205
  ownerSettled || (ownerSettled = !0, resolveOwner(void 0)), cleanupSettled || (cleanupSettled = !0, resolveCleanup(!1));
38188
38206
  }, consume = (line) => {
@@ -38545,11 +38563,11 @@ async function spawnWindowsJobProcess(command, args, options, seams = {}) {
38545
38563
  throw await anchoredRemoveTree(hostDir, hostIdentity).catch(() => {
38546
38564
  }), err;
38547
38565
  }
38548
- let cleanupStarted = !1, cleanupPromise = new Promise((resolve28) => {
38566
+ let cleanupStarted = !1, cleanupPromise = new Promise((resolve29) => {
38549
38567
  let cleanup = () => {
38550
38568
  cleanupStarted || (cleanupStarted = !0, anchoredRemoveTree(hostDir, hostIdentity).then(
38551
- () => resolve28(!0),
38552
- () => resolve28(!1)
38569
+ () => resolve29(!0),
38570
+ () => resolve29(!1)
38553
38571
  ));
38554
38572
  };
38555
38573
  child.once("close", cleanup), child.once("error", cleanup);
@@ -38584,7 +38602,7 @@ async function waitForProcessIdentity(pid) {
38584
38602
  for (let attempt = 0; attempt < 100; attempt++) {
38585
38603
  let identity = await readProcessIdentity(pid);
38586
38604
  if (identity) return identity;
38587
- await new Promise((resolve28) => setTimeout(resolve28, 10));
38605
+ await new Promise((resolve29) => setTimeout(resolve29, 10));
38588
38606
  }
38589
38607
  return null;
38590
38608
  }
@@ -38803,7 +38821,7 @@ async function terminateOwnedProcessTree(args) {
38803
38821
  } catch (err) {
38804
38822
  err.code !== "ESRCH" && directKill();
38805
38823
  }
38806
- let timeoutMs = args.timeoutMs ?? 1e4, deadline = Date.now() + timeoutMs, sleep2 = args.sleep ?? ((ms) => new Promise((resolve28) => setTimeout(resolve28, ms)));
38824
+ let timeoutMs = args.timeoutMs ?? 1e4, deadline = Date.now() + timeoutMs, sleep2 = args.sleep ?? ((ms) => new Promise((resolve29) => setTimeout(resolve29, ms)));
38807
38825
  for (; ; ) {
38808
38826
  try {
38809
38827
  kill(-pid, 0);
@@ -38944,17 +38962,17 @@ function isInsideDir(candidate, dir) {
38944
38962
  return root.startsWith("/") ? candidate === root || candidate.startsWith(`${root}/`) : !1;
38945
38963
  }
38946
38964
  function run(command, args, okExitCodes = []) {
38947
- return new Promise((resolve28, reject) => {
38965
+ return new Promise((resolve29, reject) => {
38948
38966
  (0, import_node_child_process5.execFile)(
38949
38967
  command,
38950
38968
  args,
38951
38969
  // `LC_ALL=C` pins the `lstart` column format the parser reads.
38952
38970
  { timeout: 5e3, maxBuffer: 64 * 1024 * 1024, windowsHide: !0, env: { ...process.env, LC_ALL: "C" } },
38953
38971
  (err, stdout) => {
38954
- if (!err) return resolve28(stdout);
38972
+ if (!err) return resolve29(stdout);
38955
38973
  let code = err.code;
38956
38974
  if (typeof code == "number" && okExitCodes.includes(code) && !err.killed)
38957
- return resolve28(stdout);
38975
+ return resolve29(stdout);
38958
38976
  reject(err);
38959
38977
  }
38960
38978
  );
@@ -39218,8 +39236,8 @@ function wireLifecycle(internal, args) {
39218
39236
  }
39219
39237
  return descendantReap;
39220
39238
  }, resolveDone = () => {
39221
- }, done = new Promise((resolve28) => {
39222
- resolveDone = resolve28;
39239
+ }, done = new Promise((resolve29) => {
39240
+ resolveDone = resolve29;
39223
39241
  }), cleanupAbort = () => {
39224
39242
  }, cleanupTimeout = () => {
39225
39243
  }, settling = !1, forcedExit = null, settle = async (failureClass, exitCode, workspaceCleanupSafe = !0) => {
@@ -41674,8 +41692,8 @@ async function runShellCommand(args) {
41674
41692
  }, aborted = args.signal?.aborted === !0, onAbort = () => {
41675
41693
  aborted = !0, killProcessTree();
41676
41694
  }, resolveResult = () => {
41677
- }, settled = new Promise((resolve28) => {
41678
- resolveResult = resolve28;
41695
+ }, settled = new Promise((resolve29) => {
41696
+ resolveResult = resolve29;
41679
41697
  }), settle = (result) => {
41680
41698
  alreadySettled || (alreadySettled = !0, timer !== void 0 && clearTimeout(timer), args.signal?.removeEventListener("abort", onAbort), resolveResult(result));
41681
41699
  }, finalize = async (exitCode, workspaceCleanupSafe = !0) => {
@@ -42385,8 +42403,8 @@ function createWorkspaceMaterializerSession(opts) {
42385
42403
  if (queued) return Promise.resolve(queued);
42386
42404
  if (protocolError) return Promise.reject(protocolError);
42387
42405
  let remaining = deadlineAt - Date.now();
42388
- return remaining <= 0 ? Promise.reject(new Error("workspace-materializer helper timed out")) : withHelperDeadline(new Promise((resolve28, reject) => {
42389
- waiter = { resolve: resolve28, reject };
42406
+ return remaining <= 0 ? Promise.reject(new Error("workspace-materializer helper timed out")) : withHelperDeadline(new Promise((resolve29, reject) => {
42407
+ waiter = { resolve: resolve29, reject };
42390
42408
  }), remaining, "workspace-materializer helper");
42391
42409
  }
42392
42410
  function serialize(operation) {
@@ -43663,8 +43681,8 @@ async function runAnchoredCasHelper(workingDir, relativePath, expectedRoot, requ
43663
43681
  "anchored CAS helper exit"
43664
43682
  ), nextMessageRaw = () => {
43665
43683
  let queued = messages.shift();
43666
- return queued !== void 0 && backlog.onLineConsumed(messageSizes.shift() ?? 0), queued ? Promise.resolve(queued) : closed4 ? Promise.reject(new Error(`anchored CAS helper exited ${closeCode}: ${stderr.toString()}`)) : new Promise((resolve28, reject) => {
43667
- lineWaiter = { resolve: resolve28, reject };
43684
+ return queued !== void 0 && backlog.onLineConsumed(messageSizes.shift() ?? 0), queued ? Promise.resolve(queued) : closed4 ? Promise.reject(new Error(`anchored CAS helper exited ${closeCode}: ${stderr.toString()}`)) : new Promise((resolve29, reject) => {
43685
+ lineWaiter = { resolve: resolve29, reject };
43668
43686
  });
43669
43687
  }, nextMessage = () => withHelperDeadline(
43670
43688
  nextMessageRaw(),
@@ -46059,8 +46077,8 @@ async function readSnapshotOwnerAnchor(shadowDir, opts) {
46059
46077
  });
46060
46078
  !hasError && !opts?.signal?.aborted ? await closePromise : await Promise.race([
46061
46079
  closePromise,
46062
- new Promise((resolve28) => {
46063
- let t = setTimeout(resolve28, 0);
46080
+ new Promise((resolve29) => {
46081
+ let t = setTimeout(resolve29, 0);
46064
46082
  typeof t.unref == "function" && t.unref();
46065
46083
  })
46066
46084
  ]);
@@ -47945,8 +47963,8 @@ var WorkspaceShadow = class _WorkspaceShadow {
47945
47963
  this.exposureFileAuthority = { ...fileAuthority };
47946
47964
  }
47947
47965
  async runOwnedStateFileWrite(write) {
47948
- let settle, admission = new Promise((resolve28) => {
47949
- settle = resolve28;
47966
+ let settle, admission = new Promise((resolve29) => {
47967
+ settle = resolve29;
47950
47968
  });
47951
47969
  this.stateFileWriteAdmissions.add(admission);
47952
47970
  try {
@@ -49376,7 +49394,7 @@ var DEFAULT_MERGE_PLAN_MAX_WORK = 16e6, DEFAULT_MERGE_PLAN_TIMEOUT_MS = 5e3, MER
49376
49394
  this.used += units, this.workSinceYield += units, this.assertActive();
49377
49395
  }
49378
49396
  async cooperate(force = !1) {
49379
- this.assertActive(), !(!force && this.workSinceYield < MERGE_PLAN_YIELD_INTERVAL) && (this.workSinceYield = 0, await new Promise((resolve28) => setImmediate(resolve28)), this.assertActive());
49397
+ this.assertActive(), !(!force && this.workSinceYield < MERGE_PLAN_YIELD_INTERVAL) && (this.workSinceYield = 0, await new Promise((resolve29) => setImmediate(resolve29)), this.assertActive());
49380
49398
  }
49381
49399
  };
49382
49400
  function assertSnapshotBundleFileOccurrenceBounds(bundles, budget = createMetadataBudget(), label = "snapshot bundle file-occurrence aggregate") {
@@ -50732,7 +50750,7 @@ init_logger2();
50732
50750
  var import_node_child_process7 = require("node:child_process"), crypto20 = __toESM(require("node:crypto")), fs44 = __toESM(require("node:fs/promises")), os32 = __toESM(require("node:os")), path56 = __toESM(require("node:path")), import_node_util = require("node:util");
50733
50751
 
50734
50752
  // src/local-executor/git-lock-retry.ts
50735
- var realSleep = (ms) => new Promise((resolve28) => setTimeout(resolve28, ms));
50753
+ var realSleep = (ms) => new Promise((resolve29) => setTimeout(resolve29, ms));
50736
50754
  function isGitLockContention(msg) {
50737
50755
  let m = msg.toLowerCase();
50738
50756
  return (
@@ -51020,7 +51038,7 @@ async function pinnedGit(repoDir, args, opts = {}) {
51020
51038
  }
51021
51039
  async function pinnedGitWithInput(repoDir, args, input, opts = {}) {
51022
51040
  let configPrefix = [...W2_HERMETIC_CONFIG, ...PINNED_GIT_CONFIG];
51023
- return await new Promise((resolve28, reject) => {
51041
+ return await new Promise((resolve29, reject) => {
51024
51042
  let child = (0, import_node_child_process7.spawn)("git", ["-C", repoDir, ...configPrefix, ...args], {
51025
51043
  env: sanitizeGitEnv(),
51026
51044
  stdio: ["pipe", "pipe", "pipe"]
@@ -51030,7 +51048,7 @@ async function pinnedGitWithInput(repoDir, args, input, opts = {}) {
51030
51048
  }), child.stderr.on("data", (c) => {
51031
51049
  stderr += c.toString("utf8");
51032
51050
  }), child.on("error", (err) => reject(err)), child.on("close", (code) => {
51033
- code === 0 || opts.allowFail ? resolve28({ stdout, stderr, code: code ?? -1 }) : reject(new Error(`git ${args[0] ?? ""} exited ${code}: ${stderr.slice(0, 400)}`));
51051
+ code === 0 || opts.allowFail ? resolve29({ stdout, stderr, code: code ?? -1 }) : reject(new Error(`git ${args[0] ?? ""} exited ${code}: ${stderr.slice(0, 400)}`));
51034
51052
  }), child.stdin.on("error", () => {
51035
51053
  }), child.stdin.end(input);
51036
51054
  });
@@ -56795,8 +56813,8 @@ var LocalExecutorImpl = class {
56795
56813
  throw new Error("LocalExecutor session shutdown has fenced new advisory spawns");
56796
56814
  let resolveSettled, admission = {
56797
56815
  controller: new AbortController(),
56798
- settled: new Promise((resolve28) => {
56799
- resolveSettled = resolve28;
56816
+ settled: new Promise((resolve29) => {
56817
+ resolveSettled = resolve29;
56800
56818
  }),
56801
56819
  resolveSettled: () => resolveSettled(),
56802
56820
  handle: null,
@@ -57884,7 +57902,7 @@ var LocalExecutorImpl = class {
57884
57902
  this.integrationAbort.signal
57885
57903
  ), ranGate || this.workspaceShutdown) return;
57886
57904
  let remaining = deadline - Date.now();
57887
- !retryMissing || remaining <= 0 || await new Promise((resolve28) => setTimeout(resolve28, Math.min(TRACK_TIP_POLL_MS, remaining)));
57905
+ !retryMissing || remaining <= 0 || await new Promise((resolve29) => setTimeout(resolve29, Math.min(TRACK_TIP_POLL_MS, remaining)));
57888
57906
  }
57889
57907
  }
57890
57908
  /** True only for a missing exact current-generation bundle; malformed input is classified inside the gate. */
@@ -59568,8 +59586,8 @@ var RevertManifestStore = class {
59568
59586
  let nextLine = async () => {
59569
59587
  let line = lines.shift();
59570
59588
  return line !== void 0 ? (backlog.onLineConsumed(utf8Bytes(line)), line) : withHelperDeadline(Promise.race([
59571
- new Promise((resolve28) => {
59572
- waiter = resolve28;
59589
+ new Promise((resolve29) => {
59590
+ waiter = resolve29;
59573
59591
  }),
59574
59592
  childClosed.then((code2) => {
59575
59593
  throw new Error(`store helper closed before replying (${code2}): ${stderr.toString()}`);
@@ -62492,7 +62510,7 @@ var import_node_child_process9 = require("node:child_process");
62492
62510
  init_env_scrub();
62493
62511
  var ChildProcessCommandRunner = class {
62494
62512
  run(argv, opts = {}) {
62495
- return new Promise((resolve28, reject) => {
62513
+ return new Promise((resolve29, reject) => {
62496
62514
  let child = (0, import_node_child_process9.spawn)(argv[0], argv.slice(1), {
62497
62515
  stdio: ["pipe", "pipe", "pipe"],
62498
62516
  windowsHide: !0,
@@ -62508,7 +62526,7 @@ var ChildProcessCommandRunner = class {
62508
62526
  }, opts.timeoutMs)), child.on("error", (err) => {
62509
62527
  timer && clearTimeout(timer), reject(err);
62510
62528
  }), child.on("close", (code) => {
62511
- timer && clearTimeout(timer), resolve28({
62529
+ timer && clearTimeout(timer), resolve29({
62512
62530
  exitCode: code,
62513
62531
  stdout: Buffer.concat(stdoutChunks).toString("utf8"),
62514
62532
  stderr: Buffer.concat(stderrChunks).toString("utf8")
@@ -62595,12 +62613,12 @@ var denialCounter = 0, HostEgressForwarder = class {
62595
62613
  */
62596
62614
  async start() {
62597
62615
  return await import_node_fs29.promises.rm(this.udsPath, { force: !0 }).catch(() => {
62598
- }), new Promise((resolve28, reject) => {
62616
+ }), new Promise((resolve29, reject) => {
62599
62617
  let onError = (err) => {
62600
62618
  this.server.removeListener("error", onError), reject(err);
62601
62619
  };
62602
62620
  this.server.once("error", onError), this.server.listen(this.udsPath, () => {
62603
- this.server.removeListener("error", onError), this.listening = !0, resolve28({ udsPath: this.udsPath });
62621
+ this.server.removeListener("error", onError), this.listening = !0, resolve29({ udsPath: this.udsPath });
62604
62622
  });
62605
62623
  });
62606
62624
  }
@@ -62618,8 +62636,8 @@ var denialCounter = 0, HostEgressForwarder = class {
62618
62636
  });
62619
62637
  return;
62620
62638
  }
62621
- this.listening = !1, await new Promise((resolve28) => {
62622
- this.server.close(() => resolve28());
62639
+ this.listening = !1, await new Promise((resolve29) => {
62640
+ this.server.close(() => resolve29());
62623
62641
  }), await import_node_fs29.promises.rm(this.udsPath, { force: !0 }).catch(() => {
62624
62642
  });
62625
62643
  }
@@ -63713,7 +63731,7 @@ async function runReviewer(opts) {
63713
63731
  });
63714
63732
  }
63715
63733
  let acquiredChild = child;
63716
- return new Promise((resolve28, reject) => {
63734
+ return new Promise((resolve29, reject) => {
63717
63735
  let child2 = acquiredChild, settled = !1, stdoutChunks = [], stderrChunks = [], cleanupStreams = () => {
63718
63736
  try {
63719
63737
  child2.stdin && !child2.stdin.destroyed && child2.stdin.destroy();
@@ -63735,7 +63753,7 @@ async function runReviewer(opts) {
63735
63753
  }, cleanupAbortListener = () => {
63736
63754
  }, cleanupTimeoutTimer = () => {
63737
63755
  }, settleSuccess = (outcome2) => {
63738
- settled || (settled = !0, cleanupAbortListener(), cleanupTimeoutTimer(), resolve28(outcome2));
63756
+ settled || (settled = !0, cleanupAbortListener(), cleanupTimeoutTimer(), resolve29(outcome2));
63739
63757
  }, settleError = (err) => {
63740
63758
  settled || (settled = !0, cleanupAbortListener(), cleanupTimeoutTimer(), cleanupStreams(), killChild(), reject(err));
63741
63759
  };
@@ -66533,8 +66551,8 @@ var QuorumLoop = class _QuorumLoop {
66533
66551
  return this.trackExistingSessionWork(recovery);
66534
66552
  }
66535
66553
  acquireRecoveryRelaunchPermit() {
66536
- return this.shuttingDown ? Promise.resolve(!1) : this.activeRecoveryRelaunches < TEAM_RECOVERY_RELAUNCH_CONCURRENCY ? (this.activeRecoveryRelaunches++, Promise.resolve(!0)) : new Promise((resolve28) => {
66537
- this.recoveryRelaunchWaiters.push(resolve28);
66554
+ return this.shuttingDown ? Promise.resolve(!1) : this.activeRecoveryRelaunches < TEAM_RECOVERY_RELAUNCH_CONCURRENCY ? (this.activeRecoveryRelaunches++, Promise.resolve(!0)) : new Promise((resolve29) => {
66555
+ this.recoveryRelaunchWaiters.push(resolve29);
66538
66556
  });
66539
66557
  }
66540
66558
  releaseRecoveryRelaunchPermit() {
@@ -66565,12 +66583,12 @@ var QuorumLoop = class _QuorumLoop {
66565
66583
  }
66566
66584
  }
66567
66585
  awaitBackgroundRecoveryStep(work, signal) {
66568
- return signal ? signal.aborted ? Promise.reject(BACKGROUND_RECOVERY_ABORTED) : new Promise((resolve28, reject) => {
66586
+ return signal ? signal.aborted ? Promise.reject(BACKGROUND_RECOVERY_ABORTED) : new Promise((resolve29, reject) => {
66569
66587
  let settled = !1, finish = (complete) => {
66570
66588
  settled || (settled = !0, signal.removeEventListener("abort", onAbort), complete());
66571
66589
  }, onAbort = () => finish(() => reject(BACKGROUND_RECOVERY_ABORTED));
66572
66590
  signal.addEventListener("abort", onAbort, { once: !0 }), work.then(
66573
- (value) => finish(() => resolve28(value)),
66591
+ (value) => finish(() => resolve29(value)),
66574
66592
  (err) => finish(() => reject(err))
66575
66593
  );
66576
66594
  }) : work;
@@ -66699,8 +66717,8 @@ var QuorumLoop = class _QuorumLoop {
66699
66717
  gateId,
66700
66718
  entry: entry5,
66701
66719
  authority,
66702
- settled: new Promise((resolve28) => {
66703
- settle = resolve28;
66720
+ settled: new Promise((resolve29) => {
66721
+ settle = resolve29;
66704
66722
  })
66705
66723
  }, admissions = this.teamDispatchAdmissionsByTask.get(taskId) ?? /* @__PURE__ */ new Set();
66706
66724
  admissions.add(admission), this.teamDispatchAdmissionsByTask.set(taskId, admissions);
@@ -67981,8 +67999,8 @@ ${section}`);
67981
67999
  taskId: args.taskId,
67982
68000
  gateId,
67983
68001
  abortController,
67984
- settled: new Promise((resolve28) => {
67985
- settlePending = resolve28;
68002
+ settled: new Promise((resolve29) => {
68003
+ settlePending = resolve29;
67986
68004
  }),
67987
68005
  ...args.teamAuthority ? { teamAuthority: args.teamAuthority } : {}
67988
68006
  }, needsWeb = this.webAccessByTask.get(args.taskId);
@@ -70187,8 +70205,8 @@ ${section}`);
70187
70205
  () => {
70188
70206
  }
70189
70207
  ));
70190
- let displayTimeout = new Promise((resolve28) => {
70191
- timeout = setTimeout(() => resolve28(void 0), TICK_SCAN_TIMEOUT_MS);
70208
+ let displayTimeout = new Promise((resolve29) => {
70209
+ timeout = setTimeout(() => resolve29(void 0), TICK_SCAN_TIMEOUT_MS);
70192
70210
  });
70193
70211
  return await Promise.race([scan, displayTimeout]);
70194
70212
  } catch {
@@ -76328,7 +76346,7 @@ var AdvisoryAttachmentJournal = class {
76328
76346
  artifactTargets.add(target2);
76329
76347
  }
76330
76348
  if (retirementNames.length > 0 && Date.now() < retirementDeadlineMs)
76331
- return await new Promise((resolve28) => setTimeout(resolve28, 20)), this.listRecords(root, retirementDeadlineMs, artifactRetry);
76349
+ return await new Promise((resolve29) => setTimeout(resolve29, 20)), this.listRecords(root, retirementDeadlineMs, artifactRetry);
76332
76350
  for (let name of retirementNames.sort()) {
76333
76351
  let retired = await this.readRetirementRecord(root, name), currentOwner = await this.currentOwner(), ownedHere = sameProcessIdentity(retired.value.owner, currentOwner) && this.activeBatchIds.has(retired.value.batchId), ownerDead = !await this.ownerIsAlive(retired.value.owner);
76334
76352
  if (!ownedHere && !ownerDead)
@@ -80552,8 +80570,8 @@ var PromptPublicationTracker = class {
80552
80570
  return this.active.has(promptId2);
80553
80571
  }
80554
80572
  async run(promptId2, publish) {
80555
- let settle, settled = new Promise((resolve28) => {
80556
- settle = resolve28;
80573
+ let settle, settled = new Promise((resolve29) => {
80574
+ settle = resolve29;
80557
80575
  }), writes = this.active.get(promptId2) ?? /* @__PURE__ */ new Set();
80558
80576
  writes.add(settled), this.active.set(promptId2, writes);
80559
80577
  try {
@@ -82926,9 +82944,9 @@ async function runOrchestrationShellSession(args) {
82926
82944
  await durableDecisionEffectDispatcher.dispatch(resolution);
82927
82945
  }, settleInitialSubscription = () => {
82928
82946
  }, rejectInitialSubscription = () => {
82929
- }, initialSubscriptionSettled = !startupReadinessRequired, initialCatchUpStarted = !1, initialSubscriptionTimer = null, initialSubscriptionReady = startupReadinessRequired ? new Promise((resolve28, reject) => {
82947
+ }, initialSubscriptionSettled = !startupReadinessRequired, initialCatchUpStarted = !1, initialSubscriptionTimer = null, initialSubscriptionReady = startupReadinessRequired ? new Promise((resolve29, reject) => {
82930
82948
  settleInitialSubscription = () => {
82931
- initialSubscriptionSettled || (initialSubscriptionSettled = !0, resolve28());
82949
+ initialSubscriptionSettled || (initialSubscriptionSettled = !0, resolve29());
82932
82950
  }, rejectInitialSubscription = (error) => {
82933
82951
  initialSubscriptionSettled || (initialSubscriptionSettled = !0, reject(error));
82934
82952
  }, initialSubscriptionTimer = setTimeout(() => {
@@ -83111,9 +83129,9 @@ async function runOrchestrationShellSession(args) {
83111
83129
  }
83112
83130
  let unsubscribePromptActions = null, promptActionStartupSettled = !startupReadinessRequired, settlePromptActionStartup = () => {
83113
83131
  }, rejectPromptActionStartup = () => {
83114
- }, promptActionStartupTimer = null, promptActionStartupReady = startupReadinessRequired ? new Promise((resolve28, reject) => {
83132
+ }, promptActionStartupTimer = null, promptActionStartupReady = startupReadinessRequired ? new Promise((resolve29, reject) => {
83115
83133
  settlePromptActionStartup = () => {
83116
- promptActionStartupSettled || (promptActionStartupSettled = !0, resolve28());
83134
+ promptActionStartupSettled || (promptActionStartupSettled = !0, resolve29());
83117
83135
  }, rejectPromptActionStartup = (error) => {
83118
83136
  promptActionStartupSettled || (promptActionStartupSettled = !0, reject(error));
83119
83137
  }, promptActionStartupTimer = setTimeout(() => {
@@ -83428,9 +83446,9 @@ async function runOrchestrationShellSession(args) {
83428
83446
  try {
83429
83447
  let released = await Promise.race([
83430
83448
  args.appsyncClient.releaseSessionWork(args.session.sessionId, { signal: controller.signal }),
83431
- new Promise((resolve28) => {
83449
+ new Promise((resolve29) => {
83432
83450
  timer = setTimeout(() => {
83433
- controller.abort(), resolve28(null);
83451
+ controller.abort(), resolve29(null);
83434
83452
  }, SESSION_WORK_RELEASE_TIMEOUT_MS), timer.unref?.();
83435
83453
  })
83436
83454
  ]);
@@ -83611,8 +83629,8 @@ async function runOrchestrationShellSession(args) {
83611
83629
  errorName: reason?.name ?? "Error"
83612
83630
  });
83613
83631
  }),
83614
- new Promise((resolve28) => {
83615
- timer = setTimeout(resolve28, SESSION_RETIRE_TIMEOUT_MS2), timer.unref?.();
83632
+ new Promise((resolve29) => {
83633
+ timer = setTimeout(resolve29, SESSION_RETIRE_TIMEOUT_MS2), timer.unref?.();
83616
83634
  })
83617
83635
  ]);
83618
83636
  } finally {
@@ -83658,8 +83676,8 @@ async function runOrchestrationShellSession(args) {
83658
83676
  disableBracketedPaste();
83659
83677
  let teardownSweepAbort = new AbortController(), TEARDOWN_SWEEP_TIMEOUT_MS = 2e3, teardownSweepTimer = setTimeout(() => teardownSweepAbort.abort(), TEARDOWN_SWEEP_TIMEOUT_MS);
83660
83678
  teardownSweepTimer.unref?.();
83661
- let hardDeadline = new Promise((resolve28) => {
83662
- setTimeout(resolve28, SIGNAL_SHUTDOWN_TIMEOUT_MS + SESSION_RETIRE_TIMEOUT_MS2 + 500).unref?.();
83679
+ let hardDeadline = new Promise((resolve29) => {
83680
+ setTimeout(resolve29, SIGNAL_SHUTDOWN_TIMEOUT_MS + SESSION_RETIRE_TIMEOUT_MS2 + 500).unref?.();
83663
83681
  }), teardownOperations = Promise.allSettled([
83664
83682
  runPlannerTeardown("signal"),
83665
83683
  reapOrphanShadows(/* @__PURE__ */ new Set(), {
@@ -84324,9 +84342,9 @@ function maybeFetchAndDispatchReviewSummary(event, envelope, store, reviewSummar
84324
84342
  }
84325
84343
  async function fetchAndDispatchReviewSummary(event, envelope, store, reviewSummaryFetcher) {
84326
84344
  try {
84327
- let abandoned = !1, timer, timeout = new Promise((resolve28) => {
84345
+ let abandoned = !1, timer, timeout = new Promise((resolve29) => {
84328
84346
  timer = setTimeout(() => {
84329
- abandoned = !0, resolve28(null);
84347
+ abandoned = !0, resolve29(null);
84330
84348
  }, TASK_REVIEW_SUMMARY_FETCH_TIMEOUT_MS);
84331
84349
  }), summary;
84332
84350
  try {
@@ -88879,8 +88897,8 @@ async function loadTrackBudgetForStatus(args) {
88879
88897
  try {
88880
88898
  let budget = await Promise.race([
88881
88899
  args.appsyncClient.getTrackBudgetStatus(args.session.sessionId),
88882
- new Promise((resolve28) => {
88883
- timer = setTimeout(() => resolve28(null), TRACK_BUDGET_STATUS_TIMEOUT_MS), timer.unref?.();
88900
+ new Promise((resolve29) => {
88901
+ timer = setTimeout(() => resolve29(null), TRACK_BUDGET_STATUS_TIMEOUT_MS), timer.unref?.();
88884
88902
  })
88885
88903
  ]);
88886
88904
  if (budget && typeof args.quorumLoop.markQueuedTaskCancelled == "function")
@@ -89299,7 +89317,7 @@ async function bindOAuthServer(handler) {
89299
89317
  for (let i = 0; i < PORT_RANGE_SIZE; i++) {
89300
89318
  let port = PRIMARY_PORT + i;
89301
89319
  try {
89302
- let server = await new Promise((resolve28, reject) => {
89320
+ let server = await new Promise((resolve29, reject) => {
89303
89321
  let s = http3.createServer(handler), onError = (err) => {
89304
89322
  s.removeListener("listening", onListening), reject(err);
89305
89323
  }, onListening = () => {
@@ -89309,7 +89327,7 @@ async function bindOAuthServer(handler) {
89309
89327
  code: postErr?.code,
89310
89328
  message: postErr?.message
89311
89329
  });
89312
- }), resolve28(s);
89330
+ }), resolve29(s);
89313
89331
  };
89314
89332
  s.once("error", onError), s.once("listening", onListening), s.listen(port, "localhost");
89315
89333
  });
@@ -89532,14 +89550,14 @@ var AuthService = class _AuthService {
89532
89550
  if (existing && !keychainManager.isTokenExpired(existing))
89533
89551
  return existing;
89534
89552
  let state = this.generateState();
89535
- return new Promise((resolve28, reject) => {
89553
+ return new Promise((resolve29, reject) => {
89536
89554
  let serverRef = {}, timeoutHandle = null, isResolved = !1, callbackInFlight = !1, forceCloseSockets = (srv) => {
89537
89555
  srv.closeAllConnections?.();
89538
89556
  }, cleanupAndResolve = (tokens) => {
89539
89557
  if (isResolved) return;
89540
89558
  isResolved = !0, timeoutHandle && (clearTimeout(timeoutHandle), timeoutHandle = null);
89541
89559
  let srv = serverRef.server;
89542
- srv ? (forceCloseSockets(srv), srv.close(() => resolve28(tokens))) : resolve28(tokens);
89560
+ srv ? (forceCloseSockets(srv), srv.close(() => resolve29(tokens))) : resolve29(tokens);
89543
89561
  }, cleanupAndReject = (err) => {
89544
89562
  if (isResolved) return;
89545
89563
  isResolved = !0, timeoutHandle && (clearTimeout(timeoutHandle), timeoutHandle = null);
@@ -89600,7 +89618,7 @@ var AuthService = class _AuthService {
89600
89618
  </html>
89601
89619
  `), isResolved = !0, timeoutHandle && (clearTimeout(timeoutHandle), timeoutHandle = null), setTimeout(() => {
89602
89620
  let srv = serverRef.server;
89603
- srv ? (forceCloseSockets(srv), srv.close(() => resolve28(tokenData))) : resolve28(tokenData);
89621
+ srv ? (forceCloseSockets(srv), srv.close(() => resolve29(tokenData))) : resolve29(tokenData);
89604
89622
  }, 500);
89605
89623
  } catch (err) {
89606
89624
  let safeMessage = String(err?.message || err).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
@@ -89640,12 +89658,12 @@ var AuthService = class _AuthService {
89640
89658
  */
89641
89659
  async logout() {
89642
89660
  let config = getConfig(), deleted = await keychainManager.deleteTokens(getEnvironment());
89643
- return deleted && new Promise((resolve28) => {
89661
+ return deleted && new Promise((resolve29) => {
89644
89662
  let serverRef = {}, timeoutHandle = null, isCleanedUp = !1, cleanupAndResolve = (value) => {
89645
89663
  if (isCleanedUp) return;
89646
89664
  isCleanedUp = !0, timeoutHandle && (clearTimeout(timeoutHandle), timeoutHandle = null);
89647
89665
  let srv = serverRef.server;
89648
- srv ? (srv.closeAllConnections?.(), srv.close(() => resolve28(value))) : resolve28(value);
89666
+ srv ? (srv.closeAllConnections?.(), srv.close(() => resolve29(value))) : resolve29(value);
89649
89667
  };
89650
89668
  (async () => {
89651
89669
  try {
@@ -91714,9 +91732,9 @@ var LocalModelGatewayBroker = class {
91714
91732
  let server = http4.createServer((req, res) => {
91715
91733
  this.handleHttp(req, res);
91716
91734
  });
91717
- await new Promise((resolve28, reject) => {
91735
+ await new Promise((resolve29, reject) => {
91718
91736
  server.once("error", reject), server.listen(0, "127.0.0.1", () => {
91719
- server.removeListener("error", reject), resolve28();
91737
+ server.removeListener("error", reject), resolve29();
91720
91738
  });
91721
91739
  });
91722
91740
  let addr = server.address();
@@ -91760,7 +91778,7 @@ var LocalModelGatewayBroker = class {
91760
91778
  }
91761
91779
  if (await Promise.allSettled(survivors.map((r) => r.done)), this.upstreamKeys.clear(), this.credentialGeneration.clear(), this.inflightRefresh.clear(), this.tokenMinter.clear(), this.server) {
91762
91780
  let server = this.server;
91763
- this.server = null, this.boundAddr = null, await new Promise((resolve28) => server.close(() => resolve28()));
91781
+ this.server = null, this.boundAddr = null, await new Promise((resolve29) => server.close(() => resolve29()));
91764
91782
  }
91765
91783
  logger.info("[Broker] Stopped + zeroized upstream credentials", {
91766
91784
  taskId: this.taskId
@@ -92329,9 +92347,9 @@ var LocalModelGatewayBroker = class {
92329
92347
  return auth.slice(7).trim();
92330
92348
  }
92331
92349
  readBody(req) {
92332
- return new Promise((resolve28, reject) => {
92350
+ return new Promise((resolve29, reject) => {
92333
92351
  let chunks = [];
92334
- req.on("data", (c) => chunks.push(c)), req.on("end", () => resolve28(Buffer.concat(chunks).toString("utf8"))), req.on("error", reject);
92352
+ req.on("data", (c) => chunks.push(c)), req.on("end", () => resolve29(Buffer.concat(chunks).toString("utf8"))), req.on("error", reject);
92335
92353
  });
92336
92354
  }
92337
92355
  writeJson(res, status, body) {
@@ -93370,7 +93388,7 @@ var LocalGemmaProcessRunner = class {
93370
93388
  }
93371
93389
  invoke(promptText, purpose, options) {
93372
93390
  let responseFormat = options?.responseFormat ?? "json";
93373
- return new Promise((resolve28, reject) => {
93391
+ return new Promise((resolve29, reject) => {
93374
93392
  let stdout = "", stderr = "", settled = !1, terminalError = null, timeoutTimer, killTimer = null, child = (0, import_child_process8.spawn)(this.config.command, this.config.args, {
93375
93393
  env: scrubSearchApiKeys({
93376
93394
  ...this.config.env,
@@ -93430,11 +93448,11 @@ var LocalGemmaProcessRunner = class {
93430
93448
  return;
93431
93449
  }
93432
93450
  if (responseFormat === "text") {
93433
- resolve28(trimmed);
93451
+ resolve29(trimmed);
93434
93452
  return;
93435
93453
  }
93436
93454
  try {
93437
- resolve28(enforceStrictJsonStdout(trimmed));
93455
+ resolve29(enforceStrictJsonStdout(trimmed));
93438
93456
  } catch (err) {
93439
93457
  reject(err);
93440
93458
  }
@@ -93535,12 +93553,12 @@ var FileSystemLocalModelStore = class {
93535
93553
  }, defaultLocalModelStore = new FileSystemLocalModelStore();
93536
93554
  async function fileDigest(pathname) {
93537
93555
  let hash3 = (0, import_crypto19.createHash)("sha256"), bytes = 0;
93538
- return await new Promise((resolve28, reject) => {
93556
+ return await new Promise((resolve29, reject) => {
93539
93557
  let stream = (0, import_fs4.createReadStream)(pathname);
93540
93558
  stream.on("data", (chunk) => {
93541
93559
  let buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
93542
93560
  bytes += buffer.byteLength, hash3.update(buffer);
93543
- }), stream.on("error", reject), stream.on("end", resolve28);
93561
+ }), stream.on("error", reject), stream.on("end", resolve29);
93544
93562
  }), { sha256: hash3.digest("hex"), bytes };
93545
93563
  }
93546
93564
  function resolveRedirectUrl(currentUrl, location) {
@@ -93553,7 +93571,7 @@ function resolveRedirectUrl(currentUrl, location) {
93553
93571
  }
93554
93572
  }
93555
93573
  async function downloadHttpsToFile(url, destinationPath, expectedBytes, redirectBudget = 3) {
93556
- await new Promise((resolve28, reject) => {
93574
+ await new Promise((resolve29, reject) => {
93557
93575
  let req = import_https2.default.get(url, (res) => {
93558
93576
  let status = res.statusCode ?? 0;
93559
93577
  if ([301, 302, 303, 307, 308].includes(status)) {
@@ -93563,7 +93581,7 @@ async function downloadHttpsToFile(url, destinationPath, expectedBytes, redirect
93563
93581
  reject(new Error("local Gemma download redirect was invalid or exceeded the limit"));
93564
93582
  return;
93565
93583
  }
93566
- downloadHttpsToFile(redirected, destinationPath, expectedBytes, redirectBudget - 1).then(resolve28).catch(reject);
93584
+ downloadHttpsToFile(redirected, destinationPath, expectedBytes, redirectBudget - 1).then(resolve29).catch(reject);
93567
93585
  return;
93568
93586
  }
93569
93587
  if (status !== 200) {
@@ -93591,7 +93609,7 @@ async function downloadHttpsToFile(url, destinationPath, expectedBytes, redirect
93591
93609
  `local Gemma download exceeded pinned bytes ${expectedBytes}`
93592
93610
  )
93593
93611
  );
93594
- }), (0, import_promises3.pipeline)(res, file).then(() => resolve28()).catch(reject);
93612
+ }), (0, import_promises3.pipeline)(res, file).then(() => resolve29()).catch(reject);
93595
93613
  });
93596
93614
  req.on("error", reject), req.setTimeout(3e4, () => {
93597
93615
  req.destroy(new Error("local Gemma download timed out"));
@@ -93609,7 +93627,7 @@ var defaultLocalModelDownloadTransport = {
93609
93627
  this.stallTimeoutMs = stallTimeoutMs;
93610
93628
  }
93611
93629
  pull(model, localOllamaHost, onProgress) {
93612
- return new Promise((resolve28, reject) => {
93630
+ return new Promise((resolve29, reject) => {
93613
93631
  let env = scrubSearchApiKeys({ ...process.env });
93614
93632
  localOllamaHost ? env.OLLAMA_HOST = localOllamaHost : delete env.OLLAMA_HOST;
93615
93633
  let resolvedCommand = this.command || process.env.CODEVIBE_OLLAMA_COMMAND || DEFAULT_OLLAMA_COMMAND, child = this.spawnPull(resolvedCommand, ["pull", model], {
@@ -93645,7 +93663,7 @@ var defaultLocalModelDownloadTransport = {
93645
93663
  }), child.on("close", (code, signal) => {
93646
93664
  if (timer && clearTimeout(timer), !stalled) {
93647
93665
  if (code === 0) {
93648
- resolve28();
93666
+ resolve29();
93649
93667
  return;
93650
93668
  }
93651
93669
  reject(
@@ -94340,8 +94358,8 @@ async function retireUnownedAdmittedSession(appsyncClient, sessionId) {
94340
94358
  try {
94341
94359
  await Promise.race([
94342
94360
  appsyncClient.updateSession({ sessionId, status: "INACTIVE" /* INACTIVE */, ...cleanExit }),
94343
- new Promise((resolve28) => {
94344
- timer = setTimeout(resolve28, SESSION_RETIRE_TIMEOUT_MS), timer.unref?.();
94361
+ new Promise((resolve29) => {
94362
+ timer = setTimeout(resolve29, SESSION_RETIRE_TIMEOUT_MS), timer.unref?.();
94345
94363
  })
94346
94364
  ]);
94347
94365
  } catch (err) {
@@ -94636,10 +94654,10 @@ Run \`codevibe vendor-key setup\`` + (checksCodex ? " (or `codevibe vendor-key i
94636
94654
  async function promptInstallLocalModel() {
94637
94655
  let rl = require("readline").createInterface({ input: process.stdin, output: process.stdout });
94638
94656
  try {
94639
- let trimmed = (await new Promise((resolve28) => {
94657
+ let trimmed = (await new Promise((resolve29) => {
94640
94658
  rl.question(
94641
94659
  "Orchestration Mode needs the local model (~7GB), which isn't installed. Install it now? [Y/n]: ",
94642
- resolve28
94660
+ resolve29
94643
94661
  );
94644
94662
  })).trim().toLowerCase();
94645
94663
  return trimmed === "" || trimmed.startsWith("y");