@alan-ai-hq/agent-manager-linux-arm64 0.1.145 → 0.1.146

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/alan-holder.cjs CHANGED
@@ -20506,7 +20506,9 @@ var init_machine_identity = __esm({
20506
20506
  runCodexCredentialSchema = external_exports.object({
20507
20507
  accessToken: external_exports.string().min(1),
20508
20508
  chatgptAccountId: external_exports.string().min(1),
20509
- chatgptPlanType: external_exports.string().nullable()
20509
+ chatgptPlanType: external_exports.string().nullable(),
20510
+ credentialId: external_exports.uuid().optional(),
20511
+ providerUserId: external_exports.string().min(1).optional()
20510
20512
  });
20511
20513
  runCodexCredentialRefreshRequestSchema = external_exports.object({
20512
20514
  /** sha256 hex of the access token Codex was refused with; a newer stored token is returned instead of rotating. */
@@ -20515,7 +20517,7 @@ var init_machine_identity = __esm({
20515
20517
  runProviderCredentialSchema = external_exports.object({
20516
20518
  /** Environment variables for the agent CLI, e.g. ANTHROPIC_API_KEY; empty when the CLI's own login is used. */
20517
20519
  env: external_exports.record(external_exports.string(), external_exports.string()),
20518
- /** The team's Codex login for a cloud sandbox; absent where the CLI's own login is used. */
20520
+ /** The bound Codex login for a cloud sandbox; absent where the CLI's own login is used. */
20519
20521
  codex: runCodexCredentialSchema.optional()
20520
20522
  });
20521
20523
  }
@@ -20930,16 +20932,50 @@ var init_problem = __esm({
20930
20932
  }
20931
20933
  });
20932
20934
 
20935
+ // ../shared/dist/cli-usage.js
20936
+ var usagePercentSchema, usageTimestampSchema, cliUsageWindowPatchSchema, cliUsageWindowSchema, cliUsageBucketSchema, cliUsageSnapshotSchema;
20937
+ var init_cli_usage = __esm({
20938
+ "../shared/dist/cli-usage.js"() {
20939
+ "use strict";
20940
+ init_zod();
20941
+ usagePercentSchema = external_exports.number().min(0).max(100);
20942
+ usageTimestampSchema = external_exports.iso.datetime();
20943
+ cliUsageWindowPatchSchema = external_exports.object({
20944
+ usedPercent: usagePercentSchema.nullable().optional(),
20945
+ windowMinutes: external_exports.number().positive().nullable().optional(),
20946
+ resetsAt: usageTimestampSchema.nullable().optional()
20947
+ });
20948
+ cliUsageWindowSchema = external_exports.object({
20949
+ usedPercent: usagePercentSchema.optional(),
20950
+ windowMinutes: external_exports.number().positive().optional(),
20951
+ resetsAt: usageTimestampSchema.optional(),
20952
+ observedAt: usageTimestampSchema,
20953
+ receivedAt: usageTimestampSchema,
20954
+ sourceId: external_exports.string().min(1),
20955
+ sequence: external_exports.number().int().nonnegative()
20956
+ });
20957
+ cliUsageBucketSchema = external_exports.object({
20958
+ primary: cliUsageWindowSchema.optional(),
20959
+ secondary: cliUsageWindowSchema.optional(),
20960
+ planType: external_exports.string().min(1).nullable().optional()
20961
+ });
20962
+ cliUsageSnapshotSchema = external_exports.object({
20963
+ buckets: external_exports.record(external_exports.string().min(1), cliUsageBucketSchema)
20964
+ });
20965
+ }
20966
+ });
20967
+
20933
20968
  // ../shared/dist/runtime-v2/run-log.js
20934
20969
  function isRunLifecycleKind(sessionUpdate) {
20935
20970
  return RUN_LIFECYCLE_KINDS.has(sessionUpdate);
20936
20971
  }
20937
- var runAcceptedUpdateSchema, runStartedUpdateSchema, runWorkspaceRelocatedUpdateSchema, runOutcomeSchema, runRejectionCodeSchema, runEndedUpdateSchema, runLifecycleUpdateSchema, RUN_LIFECYCLE_KINDS, runLogRecordSchema;
20972
+ var runAcceptedUpdateSchema, runStartedUpdateSchema, runCodexRateLimitsUpdateSchema, runWorkspaceRelocatedUpdateSchema, runOutcomeSchema, runRejectionCodeSchema, runEndedUpdateSchema, runLifecycleUpdateSchema, RUN_LIFECYCLE_KINDS, runLogRecordSchema;
20938
20973
  var init_run_log = __esm({
20939
20974
  "../shared/dist/runtime-v2/run-log.js"() {
20940
20975
  "use strict";
20941
20976
  init_zod();
20942
20977
  init_problem();
20978
+ init_cli_usage();
20943
20979
  init_ids();
20944
20980
  runAcceptedUpdateSchema = external_exports.object({
20945
20981
  sessionUpdate: external_exports.literal("_alan/run.accepted"),
@@ -20951,6 +20987,16 @@ var init_run_log = __esm({
20951
20987
  providerSessionId: external_exports.string().min(1).optional(),
20952
20988
  pid: external_exports.number().int().positive().optional()
20953
20989
  });
20990
+ runCodexRateLimitsUpdateSchema = external_exports.object({
20991
+ sessionUpdate: external_exports.literal("_alan/codex.rate_limits"),
20992
+ limitId: external_exports.string().min(1),
20993
+ primary: cliUsageWindowPatchSchema.nullable().optional(),
20994
+ secondary: cliUsageWindowPatchSchema.nullable().optional(),
20995
+ planType: external_exports.string().min(1).nullable().optional(),
20996
+ observedAt: external_exports.iso.datetime(),
20997
+ sourceId: external_exports.string().min(1),
20998
+ sequence: external_exports.number().int().nonnegative()
20999
+ });
20954
21000
  runWorkspaceRelocatedUpdateSchema = external_exports.object({
20955
21001
  sessionUpdate: external_exports.literal("_alan/run.workspace_relocated"),
20956
21002
  previousPath: external_exports.string().min(1).max(4096),
@@ -21013,7 +21059,7 @@ var init_holder_protocol = __esm({
21013
21059
  init_ids();
21014
21060
  init_link();
21015
21061
  init_run_log();
21016
- HOLDER_PROTOCOL = 1;
21062
+ HOLDER_PROTOCOL = 2;
21017
21063
  holderAbortOutcomeSchema = external_exports.enum(["aborted", "interrupted"]);
21018
21064
  holderRequestSchema = external_exports.discriminatedUnion("type", [
21019
21065
  external_exports.object({ type: external_exports.literal("auth"), token: external_exports.string().min(1) }),
@@ -24141,7 +24187,18 @@ var init_chunk_SBT5W7L4 = __esm({
24141
24187
  }
24142
24188
  });
24143
24189
 
24144
- // ../agent-core/dist/chunk-54ZRJOQP.js
24190
+ // ../agent-core/dist/chunk-HBIPWAUI.js
24191
+ function readCapReset(text2) {
24192
+ const epoch = EPOCH_RESET.exec(text2);
24193
+ if (epoch) return { resetsAt: new Date(Number(epoch[1]) * 1e3).toISOString() };
24194
+ const codex = CODEX_RESET.exec(text2);
24195
+ if (codex) {
24196
+ const milliseconds = Date.parse(codex[1].replace(/(\d)(?:st|nd|rd|th)\b/gi, "$1"));
24197
+ if (Number.isFinite(milliseconds)) return { resetsAt: new Date(milliseconds).toISOString() };
24198
+ }
24199
+ const worded = WORDED_RESET.exec(text2);
24200
+ return worded ? { resetHint: worded[1].trim() } : {};
24201
+ }
24145
24202
  function specForErrorKind(errorKind) {
24146
24203
  const spec = ERROR_SPECS[errorKind];
24147
24204
  return { message: spec.message, errorKind, recoveryClass: spec.recoveryClass };
@@ -24202,15 +24259,6 @@ function normalizeCodexCliErrorMessage(message) {
24202
24259
  }
24203
24260
  return message;
24204
24261
  }
24205
- function readCapReset(text2) {
24206
- const epoch = EPOCH_RESET.exec(text2);
24207
- if (epoch) {
24208
- const seconds = Number(epoch[1]);
24209
- return { resetsAt: new Date(seconds * 1e3).toISOString() };
24210
- }
24211
- const worded = WORDED_RESET.exec(text2);
24212
- return worded ? { resetHint: worded[1].trim() } : {};
24213
- }
24214
24262
  function lineMatching(text2, pattern) {
24215
24263
  return text2.split("\n").map((line) => line.trim()).find((line) => pattern.test(line));
24216
24264
  }
@@ -24222,10 +24270,11 @@ function withCapReset(classified, text2) {
24222
24270
  if (classified.errorKind !== "usage_limit") return classified;
24223
24271
  const reset = readCapReset(text2);
24224
24272
  if (reset.resetsAt) {
24273
+ const own22 = lineMatching(text2, /\btry again at\b/i);
24225
24274
  return {
24226
24275
  ...classified,
24227
24276
  ...reset,
24228
- message: `Provider usage limit reached. It resets at ${reset.resetsAt}; switch model or wait, then retry.`
24277
+ message: own22 ?? `Provider usage limit reached. It resets at ${reset.resetsAt}; switch model or wait, then retry.`
24229
24278
  };
24230
24279
  }
24231
24280
  const own2 = lineMatching(text2, /usage limit/i);
@@ -24344,13 +24393,16 @@ function createCliProblem(observed, options) {
24344
24393
  ...classified.resetsAt ? { resetsAt: classified.resetsAt } : {}
24345
24394
  });
24346
24395
  }
24347
- var import_crypto2, ERROR_SPECS, AGENT_ERROR_KINDS, AGENT_SIGN_IN_BY_HARNESS, STATUS_PREFIX, TEXT_RULES, CODEX_TIMEOUT_MESSAGE, CODEX_EXPIRED_MESSAGE, EPOCH_RESET, WORDED_RESET, COMMAND_NOT_FOUND, CODE_RULES, TEXT_REFINES, STATUS_LEAD, CLI_PROBLEM_CODE_BY_ERROR_KIND, KEY_REJECTION_KINDS;
24348
- var init_chunk_54ZRJOQP = __esm({
24349
- "../agent-core/dist/chunk-54ZRJOQP.js"() {
24396
+ var import_crypto2, EPOCH_RESET, WORDED_RESET, CODEX_RESET, ERROR_SPECS, AGENT_ERROR_KINDS, AGENT_SIGN_IN_BY_HARNESS, STATUS_PREFIX, TEXT_RULES, CODEX_TIMEOUT_MESSAGE, CODEX_EXPIRED_MESSAGE, COMMAND_NOT_FOUND, CODE_RULES, TEXT_REFINES, STATUS_LEAD, CLI_PROBLEM_CODE_BY_ERROR_KIND, KEY_REJECTION_KINDS;
24397
+ var init_chunk_HBIPWAUI = __esm({
24398
+ "../agent-core/dist/chunk-HBIPWAUI.js"() {
24350
24399
  "use strict";
24351
24400
  init_chunk_YXWJW7I5();
24352
24401
  import_crypto2 = require("crypto");
24353
24402
  init_agent2();
24403
+ EPOCH_RESET = /\|\s*(\d{10})\b/;
24404
+ WORDED_RESET = /\bresets?\s+(?:at\s+)?([^.\n]{1,60}?)\s*(?:$|[.\n])/i;
24405
+ CODEX_RESET = /\btry again at\s+([A-Za-z]{3,9}\s+\d{1,2}(?:st|nd|rd|th)?,?\s+\d{4}\s+\d{1,2}:\d{2}\s*[AP]M(?:\s+(?:UTC|GMT)(?:[+-]\d{1,2}(?::?\d{2})?)?)?)/i;
24354
24406
  ERROR_SPECS = {
24355
24407
  model_mismatch: {
24356
24408
  message: "The selected model isn't available, or you don't have access to it. Pick a different model, then send your message again.",
@@ -24504,7 +24556,7 @@ var init_chunk_54ZRJOQP = __esm({
24504
24556
  // #44604), or a trailing assistant message (opencode #19517).
24505
24557
  {
24506
24558
  kind: "history_rejected",
24507
- pattern: /\btext content blocks must be non-empty\b|\bcontent field in the message object\b|\bids were found without `?tool_result`? blocks\b|\bunexpected `?tool_use_id`?|\btool use concurrency issues\b|\bno tool output found for\b|\bdoes not support assistant message prefill\b/
24559
+ pattern: /\btext content blocks must be non-empty\b|\bcontent field in the message object\b|\bids were found without `?tool_result`? blocks\b|\bunexpected `?tool_use_id`?|\btool use concurrency issues\b|\bno tool output found for\b|\bdoes not support assistant message prefill\b|\binvalid_encrypted_content\b|organization_id did not match the target organization/
24508
24560
  },
24509
24561
  // Claude: "No conversation found with session ID"; Codex: "no rollout found for thread id";
24510
24562
  // Copilot: "No session, task, or name matched"; Kimi/Cursor ACP: `Session "<id>" not found`.
@@ -24553,8 +24605,6 @@ var init_chunk_54ZRJOQP = __esm({
24553
24605
  ];
24554
24606
  CODEX_TIMEOUT_MESSAGE = "Codex connection to OpenAI timed out while waiting for the turn to continue. Retry the message; if it repeats, check network/API latency or reduce slow MCP/tool calls in the turn.";
24555
24607
  CODEX_EXPIRED_MESSAGE = "Codex CLI connection expired. Re-authenticate the Codex CLI on this computer (run `codex login`) or reconnect it in Cloud settings, then retry.";
24556
- EPOCH_RESET = /\|\s*(\d{10})\b/;
24557
- WORDED_RESET = /\bresets?\s+(?:at\s+)?([^.\n]{1,60}?)\s*(?:$|[.\n])/i;
24558
24608
  COMMAND_NOT_FOUND = /\bcommand not found\b|\bno such file or directory\b/i;
24559
24609
  CODE_RULES = [
24560
24610
  { pattern: /model_not_found|model_not_available/, kind: "model_mismatch" },
@@ -24609,7 +24659,7 @@ var init_chunk_54ZRJOQP = __esm({
24609
24659
  }
24610
24660
  });
24611
24661
 
24612
- // ../agent-core/dist/chunk-72NSEYHK.js
24662
+ // ../agent-core/dist/chunk-4G77APXN.js
24613
24663
  function detectImageMimeType(buffer) {
24614
24664
  if (buffer.length >= 8 && buffer.subarray(0, 8).equals(PNG_SIGNATURE)) return "image/png";
24615
24665
  if (buffer.length >= 3 && buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255) {
@@ -24993,11 +25043,11 @@ function silentStartError(name, timeoutMs) {
24993
25043
  };
24994
25044
  }
24995
25045
  var import_crypto3, import_fs4, import_path3, PNG_SIGNATURE, IMAGE_MIME_BY_EXT, VIDEO_MIME_BY_EXT, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, MAX_IMAGE_BYTES, MAX_VIDEO_BYTES, AGENT_BROWSER_MENTION, LocalMediaReader, SessionOpenRefusal, JsonRpcError, ACP_PROTOCOL_VERSION, ACP_ERROR, STDERR_TAIL_LINES, RESULT_EXIT_GRACE_MS, PerTurnSession;
24996
- var init_chunk_72NSEYHK = __esm({
24997
- "../agent-core/dist/chunk-72NSEYHK.js"() {
25046
+ var init_chunk_4G77APXN = __esm({
25047
+ "../agent-core/dist/chunk-4G77APXN.js"() {
24998
25048
  "use strict";
24999
25049
  init_chunk_XC5676SG();
25000
- init_chunk_54ZRJOQP();
25050
+ init_chunk_HBIPWAUI();
25001
25051
  init_chunk_M6YHY2EZ();
25002
25052
  init_chunk_YXWJW7I5();
25003
25053
  import_crypto3 = require("crypto");
@@ -26904,9 +26954,9 @@ var init_claude = __esm({
26904
26954
  "../agent-core/dist/providers/claude.js"() {
26905
26955
  "use strict";
26906
26956
  init_chunk_SBT5W7L4();
26907
- init_chunk_72NSEYHK();
26957
+ init_chunk_4G77APXN();
26908
26958
  init_chunk_XC5676SG();
26909
- init_chunk_54ZRJOQP();
26959
+ init_chunk_HBIPWAUI();
26910
26960
  init_chunk_J2KTV5FP();
26911
26961
  init_chunk_M6YHY2EZ();
26912
26962
  init_chunk_FPGAN4XO();
@@ -28208,6 +28258,29 @@ function imageKey(update) {
28208
28258
  const image = asRecord(update.image);
28209
28259
  return asString(image?.sourceHash) || asString(image?.id) || void 0;
28210
28260
  }
28261
+ function windowPatch(value) {
28262
+ if (value === null) return null;
28263
+ const record2 = asRecord(value);
28264
+ if (!record2) return void 0;
28265
+ const patch = {};
28266
+ const usedPercent = asFiniteNumber(record2.usedPercent);
28267
+ if (usedPercent !== void 0 && usedPercent >= 0 && usedPercent <= 100) {
28268
+ patch.usedPercent = usedPercent;
28269
+ } else if (record2.usedPercent === null) {
28270
+ patch.usedPercent = null;
28271
+ }
28272
+ const duration3 = asFiniteNumber(record2.windowDurationMins);
28273
+ if (duration3 !== void 0 && duration3 > 0) patch.windowMinutes = duration3;
28274
+ else if (record2.windowDurationMins === null) patch.windowMinutes = null;
28275
+ const seconds = asFiniteNumber(record2.resetsAt);
28276
+ if (seconds !== void 0 && seconds >= 0) {
28277
+ const reset = new Date(seconds * 1e3);
28278
+ if (Number.isFinite(reset.getTime())) patch.resetsAt = reset.toISOString();
28279
+ } else if (record2.resetsAt === null) {
28280
+ patch.resetsAt = null;
28281
+ }
28282
+ return patch;
28283
+ }
28211
28284
  function isApprovalRequest(method) {
28212
28285
  return COMMAND_OR_FILE.has(method) || LEGACY.has(method);
28213
28286
  }
@@ -28619,7 +28692,10 @@ function classifyCodexError(error61) {
28619
28692
  const message = asString(error61?.message);
28620
28693
  const known = typeof info === "string" ? INFO_KINDS.get(info) : void 0;
28621
28694
  const own2 = normalizeCodexCliErrorMessage(message.trim());
28622
- if (known) return own2 ? { ...specForErrorKind(known), message: own2 } : specForErrorKind(known);
28695
+ if (known) {
28696
+ const classified = own2 ? { ...specForErrorKind(known), message: own2 } : specForErrorKind(known);
28697
+ return known === "usage_limit" ? { ...classified, ...readCapReset(message) } : classified;
28698
+ }
28623
28699
  const status = httpStatusOf(info);
28624
28700
  return classifyProviderError(message, status === void 0 ? {} : { status });
28625
28701
  }
@@ -28703,7 +28779,7 @@ async function handshake(session, spec, log) {
28703
28779
  }
28704
28780
  await session.rpc.notify("initialized");
28705
28781
  }
28706
- async function preflight(session, spec) {
28782
+ async function preflight(session, spec, log) {
28707
28783
  if (spec.externalAuth) {
28708
28784
  const tokens2 = await spec.externalAuth.current();
28709
28785
  await session.rpc.request("account/login/start", {
@@ -28721,6 +28797,13 @@ async function preflight(session, spec) {
28721
28797
  specForErrorKind("not_logged_in")
28722
28798
  );
28723
28799
  }
28800
+ if (spec.externalAuth) {
28801
+ try {
28802
+ session.observeRateLimits(await session.rpc.request("account/rateLimits/read", {}));
28803
+ } catch {
28804
+ log.warn("codex.rate_limits_unavailable", {});
28805
+ }
28806
+ }
28724
28807
  }
28725
28808
  function threadOf(result) {
28726
28809
  const thread = asRecord(asRecord(result)?.thread);
@@ -28782,7 +28865,7 @@ function createCodexDriver(options = {}) {
28782
28865
  try {
28783
28866
  const opening = (async () => {
28784
28867
  await handshake(session, spec, resolved.log);
28785
- await preflight(session, spec);
28868
+ await preflight(session, spec, resolved.log);
28786
28869
  return openThread(session, spec, resolved.log);
28787
28870
  })();
28788
28871
  const thread = await withDeadline(
@@ -28933,7 +29016,7 @@ function createCodexExecDriver(options = {}) {
28933
29016
  };
28934
29017
  }
28935
29018
  function envDigest2(env) {
28936
- const hash2 = (0, import_crypto9.createHash)("sha256");
29019
+ const hash2 = (0, import_crypto10.createHash)("sha256");
28937
29020
  for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
28938
29021
  return hash2.digest("hex");
28939
29022
  }
@@ -28974,7 +29057,7 @@ function planCodexExecSession(run, context) {
28974
29057
  };
28975
29058
  }
28976
29059
  function envDigest22(env) {
28977
- const hash2 = (0, import_crypto10.createHash)("sha256");
29060
+ const hash2 = (0, import_crypto11.createHash)("sha256");
28978
29061
  for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
28979
29062
  return hash2.digest("hex");
28980
29063
  }
@@ -29043,14 +29126,14 @@ function codexTurnInput(run, context) {
29043
29126
  ...images.length ? { imagePaths: images.map((image) => image.path) } : {}
29044
29127
  };
29045
29128
  }
29046
- var import_fs6, import_path6, import_crypto8, import_crypto9, import_crypto10, TokenRefresher, MCP_STARTUP_TIMEOUT_SEC, FIELD_TYPES, YES_NO, ACCEPT_DECLINE, MAX_INLINE_GENERATED_IMAGE_BYTES, PNG_SIGNATURE2, JPEG_NON_FRAME_MARKERS, IMAGE_GEN_CALL, PROMPT_LITERAL, RELOCATE_EVERY_MS, CodexImageGenerationFold, CodexRolloutImages, USER_INPUT_METHOD, PERMISSIONS_METHOD, ELICITATION_METHOD, COMMAND_OR_FILE, LEGACY, DECISIONS, COORDINATION_TOOLS, SETTLED_AGENT, STATUS, CHANGE_OPERATIONS, SILENT_ON_START, IGNORED_ITEMS, PLAN_STATUS, WORKER_LIFECYCLE, INFO_KINDS, SILENT, CodexTurn, STDERR_TAIL_LINES3, MAX_BETWEEN_UPDATES, UNSUPPORTED_REQUEST, DECLINED_ELICITATION, IMAGE_CATCH_UP_MS, IMAGE_POLL_MS, CodexSession, CODEX_MIN_VERSION, CODEX_REQUIREMENT, CODEX_TESTED_LINE, DEFAULTS2, CLIENT_INFO, STATUS2, EXITED_WITHOUT_RESPONSE, CodexExecTurn, DEFAULTS22, CodexExecSession;
29129
+ var import_fs6, import_path6, import_crypto8, import_crypto9, import_crypto10, import_crypto11, TokenRefresher, MCP_STARTUP_TIMEOUT_SEC, FIELD_TYPES, YES_NO, ACCEPT_DECLINE, MAX_INLINE_GENERATED_IMAGE_BYTES, PNG_SIGNATURE2, JPEG_NON_FRAME_MARKERS, IMAGE_GEN_CALL, PROMPT_LITERAL, RELOCATE_EVERY_MS, CodexImageGenerationFold, CodexRolloutImages, CodexRateLimits, USER_INPUT_METHOD, PERMISSIONS_METHOD, ELICITATION_METHOD, COMMAND_OR_FILE, LEGACY, DECISIONS, COORDINATION_TOOLS, SETTLED_AGENT, STATUS, CHANGE_OPERATIONS, SILENT_ON_START, IGNORED_ITEMS, PLAN_STATUS, WORKER_LIFECYCLE, INFO_KINDS, SILENT, CodexTurn, STDERR_TAIL_LINES3, MAX_BETWEEN_UPDATES, UNSUPPORTED_REQUEST, DECLINED_ELICITATION, IMAGE_CATCH_UP_MS, IMAGE_POLL_MS, CodexSession, CODEX_MIN_VERSION, CODEX_REQUIREMENT, CODEX_TESTED_LINE, DEFAULTS2, CLIENT_INFO, STATUS2, EXITED_WITHOUT_RESPONSE, CodexExecTurn, DEFAULTS22, CodexExecSession;
29047
29130
  var init_codex = __esm({
29048
29131
  "../agent-core/dist/providers/codex.js"() {
29049
29132
  "use strict";
29050
29133
  init_chunk_SBT5W7L4();
29051
- init_chunk_72NSEYHK();
29134
+ init_chunk_4G77APXN();
29052
29135
  init_chunk_XC5676SG();
29053
- init_chunk_54ZRJOQP();
29136
+ init_chunk_HBIPWAUI();
29054
29137
  init_chunk_J2KTV5FP();
29055
29138
  init_chunk_M6YHY2EZ();
29056
29139
  init_chunk_FPGAN4XO();
@@ -29059,10 +29142,12 @@ var init_codex = __esm({
29059
29142
  import_path6 = require("path");
29060
29143
  init_effort();
29061
29144
  import_crypto8 = require("crypto");
29062
- init_agent2();
29063
29145
  import_crypto9 = require("crypto");
29146
+ init_runtime_v2();
29064
29147
  init_agent2();
29065
29148
  import_crypto10 = require("crypto");
29149
+ init_agent2();
29150
+ import_crypto11 = require("crypto");
29066
29151
  init_effort();
29067
29152
  TokenRefresher = class {
29068
29153
  #auth;
@@ -29246,6 +29331,46 @@ var init_codex = __esm({
29246
29331
  return this.#cursor;
29247
29332
  }
29248
29333
  };
29334
+ CodexRateLimits = class {
29335
+ #clock;
29336
+ #sourceId;
29337
+ #sequence = 0;
29338
+ constructor(clock, sourceId = (0, import_crypto9.randomUUID)()) {
29339
+ this.#clock = clock;
29340
+ this.#sourceId = sourceId;
29341
+ }
29342
+ read(value) {
29343
+ const response = asRecord(value);
29344
+ const buckets = asRecord(response?.rateLimitsByLimitId);
29345
+ if (buckets) {
29346
+ return Object.entries(buckets).flatMap(
29347
+ ([limitId, snapshot2]) => this.#update(snapshot2, limitId)
29348
+ );
29349
+ }
29350
+ return this.#update(response?.rateLimits);
29351
+ }
29352
+ notification(params) {
29353
+ return this.#update(params.rateLimits);
29354
+ }
29355
+ #update(value, bucketId) {
29356
+ const snapshot2 = asRecord(value);
29357
+ if (!snapshot2) return [];
29358
+ const primary = windowPatch(snapshot2.primary);
29359
+ const secondary = windowPatch(snapshot2.secondary);
29360
+ const planType = snapshot2.planType === null ? null : asString(snapshot2.planType) || void 0;
29361
+ const parsed = runCodexRateLimitsUpdateSchema.safeParse({
29362
+ sessionUpdate: "_alan/codex.rate_limits",
29363
+ limitId: bucketId ?? (asString(snapshot2.limitId) || "codex"),
29364
+ ...primary === void 0 ? {} : { primary },
29365
+ ...secondary === void 0 ? {} : { secondary },
29366
+ ...planType === void 0 ? {} : { planType },
29367
+ observedAt: new Date(this.#clock.now()).toISOString(),
29368
+ sourceId: this.#sourceId,
29369
+ sequence: this.#sequence++
29370
+ });
29371
+ return parsed.success ? [parsed.data] : [];
29372
+ }
29373
+ };
29249
29374
  USER_INPUT_METHOD = "item/tool/requestUserInput";
29250
29375
  PERMISSIONS_METHOD = "item/permissions/requestApproval";
29251
29376
  ELICITATION_METHOD = "mcpServer/elicitation/request";
@@ -29315,7 +29440,6 @@ var init_codex = __esm({
29315
29440
  "thread/closed",
29316
29441
  "hook/started",
29317
29442
  "hook/completed",
29318
- "account/rateLimits/updated",
29319
29443
  "account/updated",
29320
29444
  "account/login/completed",
29321
29445
  "remoteControl/status/changed",
@@ -29510,6 +29634,7 @@ var init_codex = __esm({
29510
29634
  #listeners = createListeners();
29511
29635
  #options;
29512
29636
  #memory;
29637
+ #rateLimits;
29513
29638
  #stderr = [];
29514
29639
  #approvals = /* @__PURE__ */ new Map();
29515
29640
  /** Session-level updates (thread start warnings, MCP startup) that open the next turn's log. */
@@ -29526,6 +29651,7 @@ var init_codex = __esm({
29526
29651
  constructor(child, tree, memory, options) {
29527
29652
  this.#options = options;
29528
29653
  this.#memory = memory;
29654
+ this.#rateLimits = new CodexRateLimits(options.clock);
29529
29655
  this.#lastTurn = new CodexTurn(memory, options.clock);
29530
29656
  this.#host = hostProcess(
29531
29657
  child,
@@ -29560,6 +29686,9 @@ var init_codex = __esm({
29560
29686
  configure(config2) {
29561
29687
  this.#config = config2;
29562
29688
  }
29689
+ observeRateLimits(response) {
29690
+ this.#recordRateLimits(this.#rateLimits.read(response));
29691
+ }
29563
29692
  attachThread(threadId, rolloutPath) {
29564
29693
  if (threadId === this.#threadId) return;
29565
29694
  this.#threadId = threadId;
@@ -29726,6 +29855,10 @@ var init_codex = __esm({
29726
29855
  return known === void 0 || known === turnId ? active : void 0;
29727
29856
  }
29728
29857
  #onNotification(notification) {
29858
+ if (notification.method === "account/rateLimits/updated") {
29859
+ this.#recordRateLimits(this.#rateLimits.notification(notification.params));
29860
+ return;
29861
+ }
29729
29862
  if (notification.method === "serverRequest/resolved") this.#dropResolved(notification);
29730
29863
  const active = this.#ownerOf(notification);
29731
29864
  const reader = active?.turn ?? this.#lastTurn;
@@ -29752,6 +29885,14 @@ var init_codex = __esm({
29752
29885
  void this.#stopTurn(active);
29753
29886
  }
29754
29887
  }
29888
+ #recordRateLimits(updates) {
29889
+ const active = this.#current;
29890
+ if (active) this.#emitUpdates(active, updates);
29891
+ else {
29892
+ this.#between.push(...updates);
29893
+ this.#between.splice(0, Math.max(0, this.#between.length - MAX_BETWEEN_UPDATES));
29894
+ }
29895
+ }
29755
29896
  #emitUpdates(active, updates) {
29756
29897
  for (const update of updates) this.#emit({ type: "update", turnId: active.id, update });
29757
29898
  }
@@ -30405,9 +30546,9 @@ function alanCodeEngineEnv(input2) {
30405
30546
  };
30406
30547
  }
30407
30548
  async function writePlugin(directory, apiOrigin) {
30408
- const origin = (0, import_crypto11.createHash)("sha256").update(apiOrigin).digest("hex").slice(0, 12);
30549
+ const origin = (0, import_crypto12.createHash)("sha256").update(apiOrigin).digest("hex").slice(0, 12);
30409
30550
  const target = (0, import_path8.join)(directory, `engine-plugin-v${ALAN_CODE_ENGINE_PLUGIN_VERSION}-${origin}.mjs`);
30410
- const temporary = `${target}.${(0, import_crypto11.randomUUID)()}.tmp`;
30551
+ const temporary = `${target}.${(0, import_crypto12.randomUUID)()}.tmp`;
30411
30552
  await (0, import_promises15.mkdir)(directory, { recursive: true, mode: 448 });
30412
30553
  await (0, import_promises15.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
30413
30554
  await (0, import_promises15.rename)(temporary, target);
@@ -30439,7 +30580,7 @@ function alanCodeSystemPrompt(alanSystemPrompt) {
30439
30580
 
30440
30581
  ${instructions}` : ALAN_CODE_TOOL_NAMING_PROMPT;
30441
30582
  }
30442
- var import_http3, import_https, import_fs7, import_path7, import_crypto11, import_promises15, import_path8, import_url, ALAN_CODE_BASELINE_PROMPT, ALAN_CODE_ENGINE_PROVIDER_ID, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT_TOKENS, ALAN_CODE_API_KEY_ENV, ALAN_CODE_CONVERSATION_ID_ENV, ALAN_CODE_PROXY_PATH, ALAN_CODE_WEBSEARCH_PATH, ALAN_CODE_CATALOG_PATH, CATALOG_TIMEOUT_MS, MAX_CATALOG_BYTES, ACTIVATION_WAIT_MS, ACTIVATION_POLL_MS, CatalogResponseError, ALAN_CODE_ENGINE_PATH_ENV, ALAN_CODE_ENGINE_COMMAND, ALAN_CODE_ENGINE_NAME, WINDOWS_RUNNABLE_EXTENSION, ALAN_CODE_ENGINE_PLUGIN_VERSION, ALAN_CODE_TOOL_NAMING_PROMPT;
30583
+ var import_http3, import_https, import_fs7, import_path7, import_crypto12, import_promises15, import_path8, import_url, ALAN_CODE_BASELINE_PROMPT, ALAN_CODE_ENGINE_PROVIDER_ID, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT_TOKENS, ALAN_CODE_API_KEY_ENV, ALAN_CODE_CONVERSATION_ID_ENV, ALAN_CODE_PROXY_PATH, ALAN_CODE_WEBSEARCH_PATH, ALAN_CODE_CATALOG_PATH, CATALOG_TIMEOUT_MS, MAX_CATALOG_BYTES, ACTIVATION_WAIT_MS, ACTIVATION_POLL_MS, CatalogResponseError, ALAN_CODE_ENGINE_PATH_ENV, ALAN_CODE_ENGINE_COMMAND, ALAN_CODE_ENGINE_NAME, WINDOWS_RUNNABLE_EXTENSION, ALAN_CODE_ENGINE_PLUGIN_VERSION, ALAN_CODE_TOOL_NAMING_PROMPT;
30443
30584
  var init_alan_code = __esm({
30444
30585
  "../agent-core/dist/providers/alan-code.js"() {
30445
30586
  "use strict";
@@ -30452,7 +30593,7 @@ var init_alan_code = __esm({
30452
30593
  import_fs7 = require("fs");
30453
30594
  import_path7 = require("path");
30454
30595
  init_runtime_v2();
30455
- import_crypto11 = require("crypto");
30596
+ import_crypto12 = require("crypto");
30456
30597
  import_promises15 = require("fs/promises");
30457
30598
  import_path8 = require("path");
30458
30599
  import_url = require("url");
@@ -37822,9 +37963,9 @@ var require_dist = __commonJS({
37822
37963
  var init_dist = __esm({
37823
37964
  "../agent-core/dist/index.js"() {
37824
37965
  "use strict";
37825
- init_chunk_72NSEYHK();
37966
+ init_chunk_4G77APXN();
37826
37967
  init_chunk_XC5676SG();
37827
- init_chunk_54ZRJOQP();
37968
+ init_chunk_HBIPWAUI();
37828
37969
  init_chunk_M6YHY2EZ();
37829
37970
  init_chunk_YXWJW7I5();
37830
37971
  }
@@ -38498,7 +38639,7 @@ function isAcpBackendKind(value) {
38498
38639
  return Object.hasOwn(ACP_PROFILES, value);
38499
38640
  }
38500
38641
  function envDigest3(env) {
38501
- const hash2 = (0, import_crypto12.createHash)("sha256");
38642
+ const hash2 = (0, import_crypto13.createHash)("sha256");
38502
38643
  for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
38503
38644
  return hash2.digest("hex");
38504
38645
  }
@@ -38565,13 +38706,13 @@ async function acpTurnInput(run, context) {
38565
38706
  ...encoded.length ? { images: encoded, imagePaths: images.map((image) => image.path) } : {}
38566
38707
  };
38567
38708
  }
38568
- var import_promises23, import_path9, import_crypto12, import_promises24, CURSOR_ASK_QUESTION, copilotAcpProfile, cursorAcpProfile, MODEL_REJECTED, MAX_READ_BYTES, FsDenied, ENV_REFERENCE, AcpBackgroundTasks, CURSOR_CREATE_PLAN, STATUSES, READ_KINDS, ALLOW_KINDS, REJECT_KINDS, CANCELLED_PERMISSION, STOP_REASONS, CHUNKS, ECHOES, AcpTurn, STDERR_TAIL_LINES4, MAX_BETWEEN_UPDATES2, AcpSession, DEFAULTS3, CLIENT_INFO2, TASK_BACKGROUNDED, TASK_COMPLETED, SESSION_NOTIFICATION, KILLED_STATUSES, SUCCESS_STATUSES, SUBAGENT_ID, grokTaskDialect, grokAcpProfile, kimiAcpProfile, ACP_PROFILES, ACP_MODES;
38709
+ var import_promises23, import_path9, import_crypto13, import_promises24, CURSOR_ASK_QUESTION, copilotAcpProfile, cursorAcpProfile, MODEL_REJECTED, MAX_READ_BYTES, FsDenied, ENV_REFERENCE, AcpBackgroundTasks, CURSOR_CREATE_PLAN, STATUSES, READ_KINDS, ALLOW_KINDS, REJECT_KINDS, CANCELLED_PERMISSION, STOP_REASONS, CHUNKS, ECHOES, AcpTurn, STDERR_TAIL_LINES4, MAX_BETWEEN_UPDATES2, AcpSession, DEFAULTS3, CLIENT_INFO2, TASK_BACKGROUNDED, TASK_COMPLETED, SESSION_NOTIFICATION, KILLED_STATUSES, SUCCESS_STATUSES, SUBAGENT_ID, grokTaskDialect, grokAcpProfile, kimiAcpProfile, ACP_PROFILES, ACP_MODES;
38569
38710
  var init_acp3 = __esm({
38570
38711
  "../agent-core/dist/providers/acp.js"() {
38571
38712
  "use strict";
38572
- init_chunk_72NSEYHK();
38713
+ init_chunk_4G77APXN();
38573
38714
  init_chunk_XC5676SG();
38574
- init_chunk_54ZRJOQP();
38715
+ init_chunk_HBIPWAUI();
38575
38716
  init_chunk_J2KTV5FP();
38576
38717
  init_chunk_M6YHY2EZ();
38577
38718
  init_chunk_FPGAN4XO();
@@ -38580,7 +38721,7 @@ var init_acp3 = __esm({
38580
38721
  import_path9 = require("path");
38581
38722
  init_effort();
38582
38723
  init_acp();
38583
- import_crypto12 = require("crypto");
38724
+ import_crypto13 = require("crypto");
38584
38725
  import_promises24 = require("fs/promises");
38585
38726
  init_agent2();
38586
38727
  CURSOR_ASK_QUESTION = "cursor/ask_question";
@@ -39386,7 +39527,7 @@ var init_acp3 = __esm({
39386
39527
  var init_classify = __esm({
39387
39528
  "../agent-core/dist/classify.js"() {
39388
39529
  "use strict";
39389
- init_chunk_54ZRJOQP();
39530
+ init_chunk_HBIPWAUI();
39390
39531
  init_chunk_YXWJW7I5();
39391
39532
  }
39392
39533
  });
@@ -39596,7 +39737,10 @@ function createPersistentDriver(provider4, options) {
39596
39737
  return "delivered";
39597
39738
  };
39598
39739
  const openFailed = (error61, spec, sink, signal, inputs) => {
39599
- if (error61 instanceof SessionOpenRefusal && error61.reason === "unsupported_version" && options.fallback) {
39740
+ if (error61 instanceof SessionOpenRefusal && error61.reason === "unsupported_version" && inputs.codex !== void 0) {
39741
+ return { outcome: "failed", message: error61.message };
39742
+ }
39743
+ if (error61 instanceof SessionOpenRefusal && error61.reason === "unsupported_version" && options.fallback && inputs.codex === void 0) {
39600
39744
  log.warn("holder.persistent_unsupported", {
39601
39745
  harness: provider4.harness,
39602
39746
  message: error61.message
@@ -39613,7 +39757,7 @@ function createPersistentDriver(provider4, options) {
39613
39757
  };
39614
39758
  return {
39615
39759
  runTurn: async (spec, sink, signal, inputs) => {
39616
- if (live.fallbackOnly && options.fallback)
39760
+ if (live.fallbackOnly && options.fallback && inputs.codex === void 0)
39617
39761
  return options.fallback.runTurn(spec, sink, signal, inputs);
39618
39762
  if (signal.aborted) return { outcome: "aborted" };
39619
39763
  const managedMcp = await managedMcpAccess(signal);
@@ -40203,7 +40347,7 @@ function createOpenCodeDriver(options = {}) {
40203
40347
  await authorization?.remove();
40204
40348
  };
40205
40349
  const spec = { ...planned, env: launchEnv(planned, authorization) };
40206
- const password = options.password?.() ?? (0, import_crypto13.randomBytes)(24).toString("base64url");
40350
+ const password = options.password?.() ?? (0, import_crypto14.randomBytes)(24).toString("base64url");
40207
40351
  try {
40208
40352
  const session = await openWithRetries(spec, password, resolved);
40209
40353
  void session.exited.then(removeAuthorization).catch((error61) => {
@@ -40218,7 +40362,7 @@ function createOpenCodeDriver(options = {}) {
40218
40362
  };
40219
40363
  }
40220
40364
  function envDigest4(env) {
40221
- const hash2 = (0, import_crypto14.createHash)("sha256");
40365
+ const hash2 = (0, import_crypto15.createHash)("sha256");
40222
40366
  for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
40223
40367
  return hash2.digest("hex");
40224
40368
  }
@@ -40299,20 +40443,20 @@ function openCodeTurnInput(run, context) {
40299
40443
  ...images.length ? { imagePaths: images.map((image) => image.path) } : {}
40300
40444
  };
40301
40445
  }
40302
- var import_http4, import_crypto13, import_promises25, import_path10, import_path11, import_url2, import_crypto14, IDLE_SOCKET_MS2, OpenCodeHttpError, OpenCodeClient, OPENCODE_CONFIG_ENV, OPENCODE_ENGINE, TEXT_PARTS, STEP_PARTS, STOPPED_BY_USER, OpenCodeSubagents, NAMED_KINDS, OPENCODE_ABORTED_ERROR, PROVIDER_EVENT_META, TASK_TOOL_NAME, TASK_RESULT_TAG, TASK_ERROR_TAG, PERMISSION_DENIED, FILE_OPERATIONS, PartReader, NOTHING, NON_INTERACTIVE_PERMISSIONS, CONTENT_FILTER_FINISHES, OUTPUT_PARTS, OpenCodeTurn, LISTENING, OUTPUT_TAIL_LINES, IMAGE_TYPES, OpenCodeSession, OPENCODE_MIN_VERSION, OPENCODE_REQUIREMENT, OPENCODE_TESTED_LINE, OPENCODE_SUPPORTED_MAJOR, DEFAULTS4, STORE_LOCKED, NON_INTERACTIVE_RULES, TITLE_LENGTH, MAX_VARIANT_LENGTH;
40446
+ var import_http4, import_crypto14, import_promises25, import_path10, import_path11, import_url2, import_crypto15, IDLE_SOCKET_MS2, OpenCodeHttpError, OpenCodeClient, OPENCODE_CONFIG_ENV, OPENCODE_ENGINE, TEXT_PARTS, STEP_PARTS, STOPPED_BY_USER, OpenCodeSubagents, NAMED_KINDS, OPENCODE_ABORTED_ERROR, PROVIDER_EVENT_META, TASK_TOOL_NAME, TASK_RESULT_TAG, TASK_ERROR_TAG, PERMISSION_DENIED, FILE_OPERATIONS, PartReader, NOTHING, NON_INTERACTIVE_PERMISSIONS, CONTENT_FILTER_FINISHES, OUTPUT_PARTS, OpenCodeTurn, LISTENING, OUTPUT_TAIL_LINES, IMAGE_TYPES, OpenCodeSession, OPENCODE_MIN_VERSION, OPENCODE_REQUIREMENT, OPENCODE_TESTED_LINE, OPENCODE_SUPPORTED_MAJOR, DEFAULTS4, STORE_LOCKED, NON_INTERACTIVE_RULES, TITLE_LENGTH, MAX_VARIANT_LENGTH;
40303
40447
  var init_opencode = __esm({
40304
40448
  "../agent-core/dist/providers/opencode.js"() {
40305
40449
  "use strict";
40306
- init_chunk_72NSEYHK();
40450
+ init_chunk_4G77APXN();
40307
40451
  init_chunk_XC5676SG();
40308
- init_chunk_54ZRJOQP();
40452
+ init_chunk_HBIPWAUI();
40309
40453
  init_chunk_J2KTV5FP();
40310
40454
  init_chunk_M6YHY2EZ();
40311
40455
  init_chunk_FPGAN4XO();
40312
40456
  init_chunk_YXWJW7I5();
40313
40457
  import_http4 = require("http");
40314
40458
  init_runtime_v2();
40315
- import_crypto13 = require("crypto");
40459
+ import_crypto14 = require("crypto");
40316
40460
  import_promises25 = require("fs/promises");
40317
40461
  import_path10 = require("path");
40318
40462
  init_agent2();
@@ -40320,7 +40464,7 @@ var init_opencode = __esm({
40320
40464
  import_url2 = require("url");
40321
40465
  init_acp();
40322
40466
  init_acp();
40323
- import_crypto14 = require("crypto");
40467
+ import_crypto15 = require("crypto");
40324
40468
  init_agent2();
40325
40469
  IDLE_SOCKET_MS2 = 4e3;
40326
40470
  OpenCodeHttpError = class extends Error {
@@ -41616,11 +41760,11 @@ function createCodexLogin(broker) {
41616
41760
  }
41617
41761
  };
41618
41762
  }
41619
- function withLogin(planned, externalAuth, accountId) {
41763
+ function withLogin(planned, externalAuth, credentialKey) {
41620
41764
  return {
41621
41765
  ...planned,
41622
41766
  spec: { ...planned.spec, externalAuth },
41623
- key: JSON.stringify([planned.key, accountId])
41767
+ key: JSON.stringify([planned.key, credentialKey])
41624
41768
  };
41625
41769
  }
41626
41770
  function createCodexHolderDriver(options) {
@@ -41642,7 +41786,11 @@ function createCodexHolderDriver(options) {
41642
41786
  });
41643
41787
  if (inputs.codex === void 0) return planned;
41644
41788
  login.forTurn(spec.runId, inputs.codex);
41645
- return withLogin(planned, login.externalAuth, inputs.codex.chatgptAccountId);
41789
+ return withLogin(
41790
+ planned,
41791
+ login.externalAuth,
41792
+ inputs.codex.credentialId ?? inputs.codex.chatgptAccountId
41793
+ );
41646
41794
  },
41647
41795
  canResume: () => true,
41648
41796
  open: async (spec) => {
@@ -42055,7 +42203,7 @@ function createDroidDriver(options = {}) {
42055
42203
  };
42056
42204
  }
42057
42205
  function envDigest5(env) {
42058
- const hash2 = (0, import_crypto15.createHash)("sha256");
42206
+ const hash2 = (0, import_crypto16.createHash)("sha256");
42059
42207
  for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
42060
42208
  return hash2.digest("hex");
42061
42209
  }
@@ -42115,19 +42263,19 @@ async function droidTurnInput(run, context) {
42115
42263
  );
42116
42264
  return { turnId: run.runId, text: text2, ...encoded.length ? { images: encoded } : {} };
42117
42265
  }
42118
- var import_crypto15, import_promises26, FACTORY_API_VERSION, FACTORY_PROTOCOL_VERSION, SUBAGENT_TOOLS, TASK_OUTPUT_TOOLS, TASK_STOP_TOOLS, SILENT2, DroidTurn, STDERR_TAIL_LINES5, UNSUPPORTED_REQUEST2, DroidSession, DEFAULTS5, DROID_REQUIREMENT, DROID_JSONRPC_ARGS;
42266
+ var import_crypto16, import_promises26, FACTORY_API_VERSION, FACTORY_PROTOCOL_VERSION, SUBAGENT_TOOLS, TASK_OUTPUT_TOOLS, TASK_STOP_TOOLS, SILENT2, DroidTurn, STDERR_TAIL_LINES5, UNSUPPORTED_REQUEST2, DroidSession, DEFAULTS5, DROID_REQUIREMENT, DROID_JSONRPC_ARGS;
42119
42267
  var init_droid = __esm({
42120
42268
  "../agent-core/dist/providers/droid.js"() {
42121
42269
  "use strict";
42122
- init_chunk_72NSEYHK();
42270
+ init_chunk_4G77APXN();
42123
42271
  init_chunk_XC5676SG();
42124
- init_chunk_54ZRJOQP();
42272
+ init_chunk_HBIPWAUI();
42125
42273
  init_chunk_J2KTV5FP();
42126
42274
  init_chunk_M6YHY2EZ();
42127
42275
  init_chunk_FPGAN4XO();
42128
42276
  init_chunk_YXWJW7I5();
42129
42277
  init_runtime_v2();
42130
- import_crypto15 = require("crypto");
42278
+ import_crypto16 = require("crypto");
42131
42279
  import_promises26 = require("fs/promises");
42132
42280
  init_agent2();
42133
42281
  FACTORY_API_VERSION = "1.0.0";
@@ -43175,7 +43323,7 @@ ${output2.stderr}`).join("\n")
43175
43323
  };
43176
43324
  }
43177
43325
  function envDigest6(env) {
43178
- const hash2 = (0, import_crypto16.createHash)("sha256");
43326
+ const hash2 = (0, import_crypto17.createHash)("sha256");
43179
43327
  for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
43180
43328
  return hash2.digest("hex");
43181
43329
  }
@@ -43221,14 +43369,14 @@ function antigravityTurnInput(run, context) {
43221
43369
  });
43222
43370
  return { turnId: run.runId, text: appendImagePathReferences(text2, images) };
43223
43371
  }
43224
- var import_promises27, import_path12, import_fs8, import_path13, import_path14, import_url3, import_crypto16, NO_ANTIGRAVITY_CAPABILITIES, INSTRUCTIONS_FILE, MAX_INSTRUCTION_CHARS, SHORTENED_NOTE, DIFF_BLOCK_START, DIFF_BLOCK_END, HUNK_HEADER, TRANSCRIPT_FILE, FULL_TRANSCRIPT_FILE, LOG_DIRS, TOOL_RESULT_TYPES, BrainTranscript, AntigravityTranscripts, ANTIGRAVITY_GRAMMAR_NAME, AntigravityGrammar, ignored, HANDLERS, SUCCESSFUL_STATUSES, SESSION_START_TYPES, RESULT_TYPES, SUBAGENT_START_TYPES, RESUME_FORKED, EXITED_WITHOUT_RESULT, AntigravityTurn, DEFAULTS6, AntigravitySession, WINDOWS_LINE_MARGIN;
43372
+ var import_promises27, import_path12, import_fs8, import_path13, import_path14, import_url3, import_crypto17, NO_ANTIGRAVITY_CAPABILITIES, INSTRUCTIONS_FILE, MAX_INSTRUCTION_CHARS, SHORTENED_NOTE, DIFF_BLOCK_START, DIFF_BLOCK_END, HUNK_HEADER, TRANSCRIPT_FILE, FULL_TRANSCRIPT_FILE, LOG_DIRS, TOOL_RESULT_TYPES, BrainTranscript, AntigravityTranscripts, ANTIGRAVITY_GRAMMAR_NAME, AntigravityGrammar, ignored, HANDLERS, SUCCESSFUL_STATUSES, SESSION_START_TYPES, RESULT_TYPES, SUBAGENT_START_TYPES, RESUME_FORKED, EXITED_WITHOUT_RESULT, AntigravityTurn, DEFAULTS6, AntigravitySession, WINDOWS_LINE_MARGIN;
43225
43373
  var init_antigravity = __esm({
43226
43374
  "../agent-core/dist/providers/antigravity.js"() {
43227
43375
  "use strict";
43228
43376
  init_chunk_SBT5W7L4();
43229
- init_chunk_72NSEYHK();
43377
+ init_chunk_4G77APXN();
43230
43378
  init_chunk_XC5676SG();
43231
- init_chunk_54ZRJOQP();
43379
+ init_chunk_HBIPWAUI();
43232
43380
  init_chunk_M6YHY2EZ();
43233
43381
  init_chunk_FPGAN4XO();
43234
43382
  init_chunk_YXWJW7I5();
@@ -43240,7 +43388,7 @@ var init_antigravity = __esm({
43240
43388
  init_effort();
43241
43389
  import_path14 = require("path");
43242
43390
  import_url3 = require("url");
43243
- import_crypto16 = require("crypto");
43391
+ import_crypto17 = require("crypto");
43244
43392
  init_agent2();
43245
43393
  NO_ANTIGRAVITY_CAPABILITIES = {
43246
43394
  structuredPrint: false,
@@ -43874,7 +44022,7 @@ function createCommandCodeDriver(options = {}) {
43874
44022
  };
43875
44023
  }
43876
44024
  function envDigest7(env) {
43877
- const hash2 = (0, import_crypto17.createHash)("sha256");
44025
+ const hash2 = (0, import_crypto18.createHash)("sha256");
43878
44026
  for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
43879
44027
  return hash2.digest("hex");
43880
44028
  }
@@ -43926,13 +44074,13 @@ function commandCodeTurnInput(run, context) {
43926
44074
  });
43927
44075
  return { turnId: run.runId, text: appendImagePathReferences(text2, images) };
43928
44076
  }
43929
- var import_promises28, import_path15, import_crypto17, COMMAND_CODE_GRAMMAR_NAME, SILENT3, CommandCodeGrammar, SHELL_TOOL, STOP_TOOLS, REPORTED_STATUS, SHELL_STATUS, SWEEP_INTERVAL_MS, CommandCodeBackgroundTasks, EXITED_WITHOUT_RESULT2, CommandCodeTurn, COMMAND_CODE_MAX_TURNS, DEFAULTS7, CommandCodeSession;
44077
+ var import_promises28, import_path15, import_crypto18, COMMAND_CODE_GRAMMAR_NAME, SILENT3, CommandCodeGrammar, SHELL_TOOL, STOP_TOOLS, REPORTED_STATUS, SHELL_STATUS, SWEEP_INTERVAL_MS, CommandCodeBackgroundTasks, EXITED_WITHOUT_RESULT2, CommandCodeTurn, COMMAND_CODE_MAX_TURNS, DEFAULTS7, CommandCodeSession;
43930
44078
  var init_command_code = __esm({
43931
44079
  "../agent-core/dist/providers/command-code.js"() {
43932
44080
  "use strict";
43933
- init_chunk_72NSEYHK();
44081
+ init_chunk_4G77APXN();
43934
44082
  init_chunk_XC5676SG();
43935
- init_chunk_54ZRJOQP();
44083
+ init_chunk_HBIPWAUI();
43936
44084
  init_chunk_J2KTV5FP();
43937
44085
  init_chunk_M6YHY2EZ();
43938
44086
  init_chunk_FPGAN4XO();
@@ -43942,7 +44090,7 @@ var init_command_code = __esm({
43942
44090
  init_agent2();
43943
44091
  init_runtime_v2();
43944
44092
  init_acp();
43945
- import_crypto17 = require("crypto");
44093
+ import_crypto18 = require("crypto");
43946
44094
  init_agent2();
43947
44095
  COMMAND_CODE_GRAMMAR_NAME = "command_code_cli";
43948
44096
  SILENT3 = /* @__PURE__ */ new Set([
@@ -44933,7 +45081,18 @@ function createHttpTransport() {
44933
45081
 
44934
45082
  // src/api-client/holder-client.ts
44935
45083
  init_runtime_v2();
45084
+ init_zod();
44936
45085
  var REQUEST_TIMEOUT_MS = 3e4;
45086
+ var credentialRefusalSchema = external_exports.object({ message: external_exports.string().trim().min(1) });
45087
+ function credentialFailureMessage(response, fallback) {
45088
+ if (response.status !== 409) return fallback;
45089
+ try {
45090
+ const parsed = credentialRefusalSchema.safeParse(jsonBody(response));
45091
+ return parsed.success ? parsed.data.message : fallback;
45092
+ } catch {
45093
+ return fallback;
45094
+ }
45095
+ }
44937
45096
  function createHolderApiClient({
44938
45097
  apiUrl,
44939
45098
  accessToken,
@@ -44966,7 +45125,10 @@ function createHolderApiClient({
44966
45125
  if (!isOk(response)) {
44967
45126
  throw new RuntimeFault(
44968
45127
  "io_failed",
44969
- `Provider credential request failed: ${response.status}`
45128
+ credentialFailureMessage(
45129
+ response,
45130
+ `Provider credential request failed: ${response.status}`
45131
+ )
44970
45132
  );
44971
45133
  }
44972
45134
  return runProviderCredentialSchema.parse(jsonBody(response));
@@ -44974,7 +45136,10 @@ function createHolderApiClient({
44974
45136
  refreshCodexCredential: async (runId, body, signal) => {
44975
45137
  const response = await request2("POST", runCodexCredentialRefreshPath(runId), signal, body);
44976
45138
  if (!isOk(response)) {
44977
- throw new RuntimeFault("io_failed", `Codex sign-in refresh failed: ${response.status}`);
45139
+ throw new RuntimeFault(
45140
+ "io_failed",
45141
+ credentialFailureMessage(response, `Codex sign-in refresh failed: ${response.status}`)
45142
+ );
44978
45143
  }
44979
45144
  return runCodexCredentialSchema.parse(jsonBody(response));
44980
45145
  },