github-router 0.3.202 → 0.3.204

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.
@@ -1367,7 +1367,7 @@ var ArtifactClient = class {
1367
1367
  attempt += 1;
1368
1368
  if (!(err instanceof ArtifactError && err.retryable && retryableCodes.has(err.code)) || attempt > retries || signal?.aborted) throw err;
1369
1369
  const base = this.retryBaseMs;
1370
- await sleep$2(base <= 0 ? 0 : Math.round(base * 2 ** (attempt - 1) * (.5 + Math.random() * .5)), signal);
1370
+ await sleep$3(base <= 0 ? 0 : Math.round(base * 2 ** (attempt - 1) * (.5 + Math.random() * .5)), signal);
1371
1371
  }
1372
1372
  }
1373
1373
  async requestOnce(o) {
@@ -1431,7 +1431,7 @@ var ArtifactClient = class {
1431
1431
  }
1432
1432
  }
1433
1433
  };
1434
- function sleep$2(ms, signal) {
1434
+ function sleep$3(ms, signal) {
1435
1435
  if (ms <= 0) return Promise.resolve();
1436
1436
  return new Promise((resolve, reject) => {
1437
1437
  const onAbort = () => {
@@ -3133,7 +3133,7 @@ function isHardNotReady(reason) {
3133
3133
  */
3134
3134
  async function waitForMessageReady(client, localId, options = {}) {
3135
3135
  const now = options.now ?? Date.now;
3136
- const sleep$3 = options.sleep ?? realSleep;
3136
+ const sleep$4 = options.sleep ?? realSleep;
3137
3137
  const waitMs = Math.max(0, options.waitMs ?? 0);
3138
3138
  const pollMs = Math.max(1, options.pollMs ?? DEFAULT_READY_POLL_MS);
3139
3139
  const deadline = now() + waitMs;
@@ -3165,7 +3165,7 @@ async function waitForMessageReady(client, localId, options = {}) {
3165
3165
  ready: false,
3166
3166
  readiness: last
3167
3167
  };
3168
- await sleep$3(Math.min(pollMs, remaining));
3168
+ await sleep$4(Math.min(pollMs, remaining));
3169
3169
  }
3170
3170
  }
3171
3171
  /**
@@ -3243,7 +3243,7 @@ async function primeTurnCursor(client, localId, timeoutMs, signal) {
3243
3243
  */
3244
3244
  async function waitForTurnSettled(client, localId, options) {
3245
3245
  const now = options.now ?? Date.now;
3246
- const sleep$3 = options.sleep ?? realSleep;
3246
+ const sleep$4 = options.sleep ?? realSleep;
3247
3247
  const pollTimeoutMs = Math.max(1, options.pollTimeoutMs ?? DEFAULT_TURN_POLL_MS);
3248
3248
  const budget = Number.isFinite(options.timeoutMs) ? Math.max(0, options.timeoutMs) : 0;
3249
3249
  const deadline = now() + budget;
@@ -3275,7 +3275,7 @@ async function waitForTurnSettled(client, localId, options) {
3275
3275
  reason: "timeout",
3276
3276
  cursor
3277
3277
  };
3278
- await sleep$3(Math.min(TURN_POLL_ERROR_BACKOFF_MS, Math.max(0, deadline - now())));
3278
+ await sleep$4(Math.min(TURN_POLL_ERROR_BACKOFF_MS, Math.max(0, deadline - now())));
3279
3279
  continue;
3280
3280
  }
3281
3281
  cursor = response.cursor;
@@ -3392,13 +3392,13 @@ async function readTail(client, localId, lines, signal) {
3392
3392
  async function driveTask(deps) {
3393
3393
  const { client, localId, prompt, timeoutMs, expectReport, idempotencyKey, interruptKey, reportId, signal } = deps;
3394
3394
  const now = deps.now ?? Date.now;
3395
- const sleep$3 = deps.sleep ?? realSleep;
3395
+ const sleep$4 = deps.sleep ?? realSleep;
3396
3396
  const tailLines = deps.tailLines ?? DEFAULT_TAIL_LINES;
3397
3397
  const pollTimeoutMs = deps.pollTimeoutMs;
3398
3398
  const readyResult = await waitForMessageReady(client, localId, {
3399
3399
  waitMs: deps.idleWaitMs ?? DEFAULT_IDLE_WAIT_MS,
3400
3400
  now,
3401
- sleep: sleep$3,
3401
+ sleep: sleep$4,
3402
3402
  signal
3403
3403
  });
3404
3404
  if (!readyResult.ready && isHardNotReady(readyResult.readiness.reason)) return {
@@ -3441,7 +3441,7 @@ async function driveTask(deps) {
3441
3441
  pollTimeoutMs,
3442
3442
  cursor,
3443
3443
  now,
3444
- sleep: sleep$3,
3444
+ sleep: sleep$4,
3445
3445
  signal
3446
3446
  });
3447
3447
  cursor = settle.cursor;
@@ -3463,7 +3463,7 @@ async function driveTask(deps) {
3463
3463
  pollTimeoutMs,
3464
3464
  cursor,
3465
3465
  now,
3466
- sleep: sleep$3,
3466
+ sleep: sleep$4,
3467
3467
  signal
3468
3468
  });
3469
3469
  recovered = recovery.settled;
@@ -5732,7 +5732,7 @@ function runFenced(token, fn) {
5732
5732
  function currentFenceToken() {
5733
5733
  return fenceStore.getStore();
5734
5734
  }
5735
- function sleep$1(ms) {
5735
+ function sleep$2(ms) {
5736
5736
  return new Promise((resolve) => setTimeout(resolve, ms));
5737
5737
  }
5738
5738
  async function writeJsonSecure(target, value) {
@@ -5779,7 +5779,7 @@ async function withFileLock(target, fn) {
5779
5779
  }
5780
5780
  } catch {}
5781
5781
  if (Date.now() - start > LOCK_MAX_WAIT_MS) throw new Error(`first-mate durable-store lock timeout for ${target}`);
5782
- await sleep$1(LOCK_RETRY_MS);
5782
+ await sleep$2(LOCK_RETRY_MS);
5783
5783
  }
5784
5784
  const verifyOwner = async () => {
5785
5785
  try {
@@ -5858,7 +5858,7 @@ async function commitJsonCas(opts) {
5858
5858
  };
5859
5859
  if (explicit) throw new DurableConflictError(`durable store rev changed under CAS for ${opts.path} (expected ${base})`);
5860
5860
  lastConflict = new DurableConflictError(`durable store contention for ${opts.path} (attempt ${attempt + 1}/${OCC_MAX_ATTEMPTS})`);
5861
- await sleep$1(Math.floor(OCC_BACKOFF_MS * (attempt + 1) * (.5 + Math.random())));
5861
+ await sleep$2(Math.floor(OCC_BACKOFF_MS * (attempt + 1) * (.5 + Math.random())));
5862
5862
  }
5863
5863
  throw lastConflict ?? new DurableConflictError(`durable store failed to converge for ${opts.path}`);
5864
5864
  }
@@ -9956,6 +9956,40 @@ function segment(value) {
9956
9956
 
9957
9957
  //#endregion
9958
9958
  //#region src/lib/first-mate/scheduler/answer-inbox.ts
9959
+ const sleep$1 = (ms) => new Promise((r) => setTimeout(r, ms));
9960
+ /**
9961
+ * Windows sharing-violation codes. When two processes rename the SAME source
9962
+ * concurrently, POSIX gives the loser a clean `ENOENT` (source already gone),
9963
+ * but Windows can transiently surface `EPERM`/`EACCES`/`EBUSY` (the source is
9964
+ * momentarily locked by the peer's in-flight rename) before it resolves to
9965
+ * ENOENT. Treat these as retryable, not fatal.
9966
+ */
9967
+ const WIN_RENAME_TRANSIENT = new Set([
9968
+ "EPERM",
9969
+ "EACCES",
9970
+ "EBUSY"
9971
+ ]);
9972
+ /**
9973
+ * Atomically claim `from` by renaming it to the process-unique `to`.
9974
+ * Returns `true` if THIS caller won the claim, `false` if a peer already took it
9975
+ * (source gone). Retries transient Windows sharing violations so two concurrent
9976
+ * drainers converge to exactly one winner instead of one throwing. Non-transient
9977
+ * errors propagate.
9978
+ */
9979
+ async function claimByRename(from, to) {
9980
+ for (let attempt = 0;; attempt++) try {
9981
+ await fs.rename(from, to);
9982
+ return true;
9983
+ } catch (err) {
9984
+ const code = err.code;
9985
+ if (code === "ENOENT") return false;
9986
+ if (WIN_RENAME_TRANSIENT.has(code ?? "") && attempt < 25) {
9987
+ await sleep$1(4 + attempt);
9988
+ continue;
9989
+ }
9990
+ throw err;
9991
+ }
9992
+ }
9959
9993
  var AnswerInbox = class {
9960
9994
  file;
9961
9995
  chain = Promise.resolve();
@@ -10032,12 +10066,7 @@ var AnswerInbox = class {
10032
10066
  const orphan = nodePath.join(dir, name);
10033
10067
  if (this.inflight.has(orphan)) continue;
10034
10068
  const claim = `${orphan}.claim.${process.pid}.${randomBytes(4).toString("hex")}`;
10035
- try {
10036
- await fs.rename(orphan, claim);
10037
- } catch (err) {
10038
- if (err.code === "ENOENT") continue;
10039
- throw err;
10040
- }
10069
+ if (!await claimByRename(orphan, claim)) continue;
10041
10070
  try {
10042
10071
  this.mergeLines(await fs.readFile(claim, "utf8"), out);
10043
10072
  claimed.push(claim);
@@ -10046,12 +10075,11 @@ var AnswerInbox = class {
10046
10075
  }
10047
10076
  }
10048
10077
  const target = `${this.file}.draining.${process.pid}.${randomBytes(4).toString("hex")}`;
10049
- try {
10050
- await fs.rename(this.file, target);
10078
+ if (await claimByRename(this.file, target)) try {
10051
10079
  this.mergeLines(await fs.readFile(target, "utf8"), out);
10052
10080
  claimed.push(target);
10053
10081
  } catch (err) {
10054
- if (err.code !== "ENOENT") throw err;
10082
+ if (err.code !== "ENOENT") consola.warn(`first-mate: deferring unreadable inbox claim ${target} for retry:`, err);
10055
10083
  }
10056
10084
  for (const p of claimed) this.inflight.add(p);
10057
10085
  const ack = async () => {
@@ -31846,4 +31874,4 @@ function enumerateInjectedMcpToolNames(groupKeys, opts = {}) {
31846
31874
 
31847
31875
  //#endregion
31848
31876
  export { buildAdvisorStream as $, setupCopilotToken as $t, trustRepo as A, readResponseBodyCapped as At, runWorkerAgent as B, buildWorkspaceHeaderJson as Bt, fileLastPromptStore as C, getTokenCount as Ct, repoRoot as D, createResponses as Dt, repoFingerprint as E, pickEndpoint as Et, EXPLORE_DEFAULT_MODEL as F, extractTarGzMember as Ft, toolbeltEnabled as G, DEFAULT_CODEX_MODEL_FALLBACKS as Gt, buildEnv as H, toolbeltPathOverride as Ht, IMPLEMENT_DEFAULT_MODEL as I, extractZipMember as It, TOOLBELT_TOOLS$1 as J, UPSTREAM_INACTIVITY_TIMEOUT_MS as Jt, toolbeltSkipSet as K, DEFAULT_PORT as Kt, PLAN_DEFAULT_MODEL as L, shouldUseInsecureTls as Lt, resolveSealedGate as M, provisionBrowserAssets as Mt, BROWSE_DEFAULT_MODEL as N, hasSupportedBrowserInstalled as Nt, stopGateEnabledForRepo as O, createChatCompletions as Ot, DEFAULT_MODEL as P, provisionAndIndexColbert as Pt, ADVISOR_TOOL_INSTRUCTIONS as Q, withInstallLock as Qt, REVIEW_DEFAULT_MODEL as R, ArtifactClient as Rt, fileFindingsStore as S, createMessages as St, isSubagentContext as T, resolveMcpToolTimeoutMs as Tt, availableToolCommands as U, DEFAULT_CLAUDE_MODEL_FALLBACKS as Ut, withNoOutputRetry as V, collapsePathKeys as Vt, buildToolbeltAwareness as W, DEFAULT_CODEX_MODEL as Wt, searchWeb as X, pickClaudeDefault as Xt, assetFor as Y, generateRandomPort as Yt, ADVISOR_INTERNAL_TOOL_NAME as Z, getPackageVersion as Zt, stopGateDisabled as _, copilotBaseUrl as _n, nativeSubagentModel as _t, buildPeerAwarenessSnippet as a, cacheVSCodeVersion as an, logStreamError as at, stopReviewEnabled as b, state as bn, shimDefaultsToXhigh as bt, personasFor as c, resolveCodexModel as cn, handleMcpDelete as ct, buildStopHookCommand as d, getModels as dn, artifactToolsEnabled as dt, setupGitHubAgentToken as en, injectAdvisorTool as et, captureLaunchBaseline as f, getGitHubUser as fn, browseAgentEnabled as ft, launchBaselineKey as g, GITHUB_API_BASE_URL as gn, geminiAvailable as gt, injectStopHookIntoSettingsFile as h, forwardError as hn, fleetToolsEnabled as ht, buildAgentPrompt as i, cacheModels as in, isControllerClosedError as it, liveExec as j, parseJsonOrDiagnose as jt, stopReviewStateDir as k, MAX_RESPONSE_BODY_BYTES as kt, buildArtifactOpenHookCommand as l, resolveModel as ln, handleMcpPost as lt, fileBlockBudget as m, HTTPError as mn, browserToolsEnabled as mt, MCP_GROUPS as n, tryRefreshAndRetry as nn, buildAnthropicErrorEvent as nt, buildPeerAwarenessSummary as o, filterBetaHeader as on, readIteratorWithTimeout as ot, decideStopHook as p, fetchWithTransientRetry as pn, browserCompoundToolsEnabled as pt, vscodeRipgrepPath as q, UPSTREAM_FETCH_TIMEOUT_MS as qt, assertMcpToolSurfaceConsistent as r, cacheCopilotVersion as rn, buildOpenAIErrorEvent as rt, enumerateInjectedMcpToolNames as s, isNullish as sn, relayAnthropicStream as st, GROUP_META as t, setupGitHubToken as tn, isAdvisorRequested as tt, buildSessionBindHookCommand as u, sleep as un, agentToolsEnabled as ut, stopGateId as v, copilotHeaders as vn, standInToolEnabled as vt, fileReviewDebounce as w, assembleResponsesPayload as wt, fileBaselineStore as x, countTokens as xt, stopGatePlanMode as y, githubHeaders as yn, workerToolsEnabled as yt, appendPlanReminder as z, buildWorkspaceHeaderHelperCommand as zt };
31849
- //# sourceMappingURL=peer-mcp-personas-rik0SIrg.js.map
31877
+ //# sourceMappingURL=peer-mcp-personas-BekOx3Rp.js.map