@alan-ai-hq/agent-manager-darwin-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-agent.cjs CHANGED
@@ -20510,7 +20510,9 @@ var init_machine_identity = __esm({
20510
20510
  runCodexCredentialSchema = external_exports.object({
20511
20511
  accessToken: external_exports.string().min(1),
20512
20512
  chatgptAccountId: external_exports.string().min(1),
20513
- chatgptPlanType: external_exports.string().nullable()
20513
+ chatgptPlanType: external_exports.string().nullable(),
20514
+ credentialId: external_exports.uuid().optional(),
20515
+ providerUserId: external_exports.string().min(1).optional()
20514
20516
  });
20515
20517
  runCodexCredentialRefreshRequestSchema = external_exports.object({
20516
20518
  /** sha256 hex of the access token Codex was refused with; a newer stored token is returned instead of rotating. */
@@ -20519,7 +20521,7 @@ var init_machine_identity = __esm({
20519
20521
  runProviderCredentialSchema = external_exports.object({
20520
20522
  /** Environment variables for the agent CLI, e.g. ANTHROPIC_API_KEY; empty when the CLI's own login is used. */
20521
20523
  env: external_exports.record(external_exports.string(), external_exports.string()),
20522
- /** The team's Codex login for a cloud sandbox; absent where the CLI's own login is used. */
20524
+ /** The bound Codex login for a cloud sandbox; absent where the CLI's own login is used. */
20523
20525
  codex: runCodexCredentialSchema.optional()
20524
20526
  });
20525
20527
  }
@@ -20970,6 +20972,39 @@ var init_problem = __esm({
20970
20972
  }
20971
20973
  });
20972
20974
 
20975
+ // ../shared/dist/cli-usage.js
20976
+ var usagePercentSchema, usageTimestampSchema, cliUsageWindowPatchSchema, cliUsageWindowSchema, cliUsageBucketSchema, cliUsageSnapshotSchema;
20977
+ var init_cli_usage = __esm({
20978
+ "../shared/dist/cli-usage.js"() {
20979
+ "use strict";
20980
+ init_zod();
20981
+ usagePercentSchema = external_exports.number().min(0).max(100);
20982
+ usageTimestampSchema = external_exports.iso.datetime();
20983
+ cliUsageWindowPatchSchema = external_exports.object({
20984
+ usedPercent: usagePercentSchema.nullable().optional(),
20985
+ windowMinutes: external_exports.number().positive().nullable().optional(),
20986
+ resetsAt: usageTimestampSchema.nullable().optional()
20987
+ });
20988
+ cliUsageWindowSchema = external_exports.object({
20989
+ usedPercent: usagePercentSchema.optional(),
20990
+ windowMinutes: external_exports.number().positive().optional(),
20991
+ resetsAt: usageTimestampSchema.optional(),
20992
+ observedAt: usageTimestampSchema,
20993
+ receivedAt: usageTimestampSchema,
20994
+ sourceId: external_exports.string().min(1),
20995
+ sequence: external_exports.number().int().nonnegative()
20996
+ });
20997
+ cliUsageBucketSchema = external_exports.object({
20998
+ primary: cliUsageWindowSchema.optional(),
20999
+ secondary: cliUsageWindowSchema.optional(),
21000
+ planType: external_exports.string().min(1).nullable().optional()
21001
+ });
21002
+ cliUsageSnapshotSchema = external_exports.object({
21003
+ buckets: external_exports.record(external_exports.string().min(1), cliUsageBucketSchema)
21004
+ });
21005
+ }
21006
+ });
21007
+
20973
21008
  // ../shared/dist/runtime-v2/run-log.js
20974
21009
  function isRunLifecycleKind(sessionUpdate) {
20975
21010
  return RUN_LIFECYCLE_KINDS.has(sessionUpdate);
@@ -20977,12 +21012,13 @@ function isRunLifecycleKind(sessionUpdate) {
20977
21012
  function alignedLength(bytes) {
20978
21013
  return bytes.lastIndexOf(RUN_LOG_RECORD_SEPARATOR) + 1;
20979
21014
  }
20980
- var RUN_LOG_PROTOCOL, RUN_LOG_PROTOCOL_HEADER, RUN_LOG_RECORD_SEPARATOR, runAcceptedUpdateSchema, runStartedUpdateSchema, runWorkspaceRelocatedUpdateSchema, runOutcomeSchema, runRejectionCodeSchema, runEndedUpdateSchema, runLifecycleUpdateSchema, RUN_LIFECYCLE_KINDS, runLogRecordSchema;
21015
+ var RUN_LOG_PROTOCOL, RUN_LOG_PROTOCOL_HEADER, RUN_LOG_RECORD_SEPARATOR, runAcceptedUpdateSchema, runStartedUpdateSchema, runCodexRateLimitsUpdateSchema, runWorkspaceRelocatedUpdateSchema, runOutcomeSchema, runRejectionCodeSchema, runEndedUpdateSchema, runLifecycleUpdateSchema, RUN_LIFECYCLE_KINDS, runLogRecordSchema;
20981
21016
  var init_run_log = __esm({
20982
21017
  "../shared/dist/runtime-v2/run-log.js"() {
20983
21018
  "use strict";
20984
21019
  init_zod();
20985
21020
  init_problem();
21021
+ init_cli_usage();
20986
21022
  init_ids();
20987
21023
  RUN_LOG_PROTOCOL = 2;
20988
21024
  RUN_LOG_PROTOCOL_HEADER = "x-alan-log-protocol";
@@ -20997,6 +21033,16 @@ var init_run_log = __esm({
20997
21033
  providerSessionId: external_exports.string().min(1).optional(),
20998
21034
  pid: external_exports.number().int().positive().optional()
20999
21035
  });
21036
+ runCodexRateLimitsUpdateSchema = external_exports.object({
21037
+ sessionUpdate: external_exports.literal("_alan/codex.rate_limits"),
21038
+ limitId: external_exports.string().min(1),
21039
+ primary: cliUsageWindowPatchSchema.nullable().optional(),
21040
+ secondary: cliUsageWindowPatchSchema.nullable().optional(),
21041
+ planType: external_exports.string().min(1).nullable().optional(),
21042
+ observedAt: external_exports.iso.datetime(),
21043
+ sourceId: external_exports.string().min(1),
21044
+ sequence: external_exports.number().int().nonnegative()
21045
+ });
21000
21046
  runWorkspaceRelocatedUpdateSchema = external_exports.object({
21001
21047
  sessionUpdate: external_exports.literal("_alan/run.workspace_relocated"),
21002
21048
  previousPath: external_exports.string().min(1).max(4096),
@@ -21059,7 +21105,7 @@ var init_holder_protocol = __esm({
21059
21105
  init_ids();
21060
21106
  init_link();
21061
21107
  init_run_log();
21062
- HOLDER_PROTOCOL = 1;
21108
+ HOLDER_PROTOCOL = 2;
21063
21109
  holderAbortOutcomeSchema = external_exports.enum(["aborted", "interrupted"]);
21064
21110
  holderRequestSchema = external_exports.discriminatedUnion("type", [
21065
21111
  external_exports.object({ type: external_exports.literal("auth"), token: external_exports.string().min(1) }),
@@ -25885,7 +25931,18 @@ var init_chunk_SBT5W7L4 = __esm({
25885
25931
  }
25886
25932
  });
25887
25933
 
25888
- // ../agent-core/dist/chunk-54ZRJOQP.js
25934
+ // ../agent-core/dist/chunk-HBIPWAUI.js
25935
+ function readCapReset(text3) {
25936
+ const epoch = EPOCH_RESET.exec(text3);
25937
+ if (epoch) return { resetsAt: new Date(Number(epoch[1]) * 1e3).toISOString() };
25938
+ const codex = CODEX_RESET.exec(text3);
25939
+ if (codex) {
25940
+ const milliseconds = Date.parse(codex[1].replace(/(\d)(?:st|nd|rd|th)\b/gi, "$1"));
25941
+ if (Number.isFinite(milliseconds)) return { resetsAt: new Date(milliseconds).toISOString() };
25942
+ }
25943
+ const worded = WORDED_RESET.exec(text3);
25944
+ return worded ? { resetHint: worded[1].trim() } : {};
25945
+ }
25889
25946
  function specForErrorKind(errorKind) {
25890
25947
  const spec = ERROR_SPECS[errorKind];
25891
25948
  return { message: spec.message, errorKind, recoveryClass: spec.recoveryClass };
@@ -25946,15 +26003,6 @@ function normalizeCodexCliErrorMessage(message2) {
25946
26003
  }
25947
26004
  return message2;
25948
26005
  }
25949
- function readCapReset(text3) {
25950
- const epoch = EPOCH_RESET.exec(text3);
25951
- if (epoch) {
25952
- const seconds = Number(epoch[1]);
25953
- return { resetsAt: new Date(seconds * 1e3).toISOString() };
25954
- }
25955
- const worded = WORDED_RESET.exec(text3);
25956
- return worded ? { resetHint: worded[1].trim() } : {};
25957
- }
25958
26006
  function lineMatching(text3, pattern) {
25959
26007
  return text3.split("\n").map((line) => line.trim()).find((line) => pattern.test(line));
25960
26008
  }
@@ -25966,10 +26014,11 @@ function withCapReset(classified, text3) {
25966
26014
  if (classified.errorKind !== "usage_limit") return classified;
25967
26015
  const reset = readCapReset(text3);
25968
26016
  if (reset.resetsAt) {
26017
+ const own22 = lineMatching(text3, /\btry again at\b/i);
25969
26018
  return {
25970
26019
  ...classified,
25971
26020
  ...reset,
25972
- message: `Provider usage limit reached. It resets at ${reset.resetsAt}; switch model or wait, then retry.`
26021
+ message: own22 ?? `Provider usage limit reached. It resets at ${reset.resetsAt}; switch model or wait, then retry.`
25973
26022
  };
25974
26023
  }
25975
26024
  const own2 = lineMatching(text3, /usage limit/i);
@@ -26088,13 +26137,16 @@ function createCliProblem(observed, options) {
26088
26137
  ...classified.resetsAt ? { resetsAt: classified.resetsAt } : {}
26089
26138
  });
26090
26139
  }
26091
- 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;
26092
- var init_chunk_54ZRJOQP = __esm({
26093
- "../agent-core/dist/chunk-54ZRJOQP.js"() {
26140
+ 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;
26141
+ var init_chunk_HBIPWAUI = __esm({
26142
+ "../agent-core/dist/chunk-HBIPWAUI.js"() {
26094
26143
  "use strict";
26095
26144
  init_chunk_YXWJW7I5();
26096
26145
  import_crypto2 = require("crypto");
26097
26146
  init_agent2();
26147
+ EPOCH_RESET = /\|\s*(\d{10})\b/;
26148
+ WORDED_RESET = /\bresets?\s+(?:at\s+)?([^.\n]{1,60}?)\s*(?:$|[.\n])/i;
26149
+ 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;
26098
26150
  ERROR_SPECS = {
26099
26151
  model_mismatch: {
26100
26152
  message: "The selected model isn't available, or you don't have access to it. Pick a different model, then send your message again.",
@@ -26248,7 +26300,7 @@ var init_chunk_54ZRJOQP = __esm({
26248
26300
  // #44604), or a trailing assistant message (opencode #19517).
26249
26301
  {
26250
26302
  kind: "history_rejected",
26251
- 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/
26303
+ 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/
26252
26304
  },
26253
26305
  // Claude: "No conversation found with session ID"; Codex: "no rollout found for thread id";
26254
26306
  // Copilot: "No session, task, or name matched"; Kimi/Cursor ACP: `Session "<id>" not found`.
@@ -26297,8 +26349,6 @@ var init_chunk_54ZRJOQP = __esm({
26297
26349
  ];
26298
26350
  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.";
26299
26351
  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.";
26300
- EPOCH_RESET = /\|\s*(\d{10})\b/;
26301
- WORDED_RESET = /\bresets?\s+(?:at\s+)?([^.\n]{1,60}?)\s*(?:$|[.\n])/i;
26302
26352
  COMMAND_NOT_FOUND = /\bcommand not found\b|\bno such file or directory\b/i;
26303
26353
  CODE_RULES = [
26304
26354
  { pattern: /model_not_found|model_not_available/, kind: "model_mismatch" },
@@ -26353,7 +26403,7 @@ var init_chunk_54ZRJOQP = __esm({
26353
26403
  }
26354
26404
  });
26355
26405
 
26356
- // ../agent-core/dist/chunk-72NSEYHK.js
26406
+ // ../agent-core/dist/chunk-4G77APXN.js
26357
26407
  function detectImageMimeType(buffer) {
26358
26408
  if (buffer.length >= 8 && buffer.subarray(0, 8).equals(PNG_SIGNATURE)) return "image/png";
26359
26409
  if (buffer.length >= 3 && buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255) {
@@ -26737,11 +26787,11 @@ function silentStartError(name, timeoutMs) {
26737
26787
  };
26738
26788
  }
26739
26789
  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;
26740
- var init_chunk_72NSEYHK = __esm({
26741
- "../agent-core/dist/chunk-72NSEYHK.js"() {
26790
+ var init_chunk_4G77APXN = __esm({
26791
+ "../agent-core/dist/chunk-4G77APXN.js"() {
26742
26792
  "use strict";
26743
26793
  init_chunk_XC5676SG();
26744
- init_chunk_54ZRJOQP();
26794
+ init_chunk_HBIPWAUI();
26745
26795
  init_chunk_M6YHY2EZ();
26746
26796
  init_chunk_YXWJW7I5();
26747
26797
  import_crypto3 = require("crypto");
@@ -28842,9 +28892,9 @@ var init_claude = __esm({
28842
28892
  "../agent-core/dist/providers/claude.js"() {
28843
28893
  "use strict";
28844
28894
  init_chunk_SBT5W7L4();
28845
- init_chunk_72NSEYHK();
28895
+ init_chunk_4G77APXN();
28846
28896
  init_chunk_XC5676SG();
28847
- init_chunk_54ZRJOQP();
28897
+ init_chunk_HBIPWAUI();
28848
28898
  init_chunk_J2KTV5FP();
28849
28899
  init_chunk_M6YHY2EZ();
28850
28900
  init_chunk_FPGAN4XO();
@@ -30169,6 +30219,29 @@ function imageKey(update) {
30169
30219
  const image = asRecord(update.image);
30170
30220
  return asString(image?.sourceHash) || asString(image?.id) || void 0;
30171
30221
  }
30222
+ function windowPatch(value2) {
30223
+ if (value2 === null) return null;
30224
+ const record2 = asRecord(value2);
30225
+ if (!record2) return void 0;
30226
+ const patch = {};
30227
+ const usedPercent = asFiniteNumber(record2.usedPercent);
30228
+ if (usedPercent !== void 0 && usedPercent >= 0 && usedPercent <= 100) {
30229
+ patch.usedPercent = usedPercent;
30230
+ } else if (record2.usedPercent === null) {
30231
+ patch.usedPercent = null;
30232
+ }
30233
+ const duration3 = asFiniteNumber(record2.windowDurationMins);
30234
+ if (duration3 !== void 0 && duration3 > 0) patch.windowMinutes = duration3;
30235
+ else if (record2.windowDurationMins === null) patch.windowMinutes = null;
30236
+ const seconds = asFiniteNumber(record2.resetsAt);
30237
+ if (seconds !== void 0 && seconds >= 0) {
30238
+ const reset = new Date(seconds * 1e3);
30239
+ if (Number.isFinite(reset.getTime())) patch.resetsAt = reset.toISOString();
30240
+ } else if (record2.resetsAt === null) {
30241
+ patch.resetsAt = null;
30242
+ }
30243
+ return patch;
30244
+ }
30172
30245
  function isApprovalRequest(method) {
30173
30246
  return COMMAND_OR_FILE.has(method) || LEGACY.has(method);
30174
30247
  }
@@ -30580,7 +30653,10 @@ function classifyCodexError(error61) {
30580
30653
  const message2 = asString(error61?.message);
30581
30654
  const known = typeof info === "string" ? INFO_KINDS.get(info) : void 0;
30582
30655
  const own2 = normalizeCodexCliErrorMessage(message2.trim());
30583
- if (known) return own2 ? { ...specForErrorKind(known), message: own2 } : specForErrorKind(known);
30656
+ if (known) {
30657
+ const classified = own2 ? { ...specForErrorKind(known), message: own2 } : specForErrorKind(known);
30658
+ return known === "usage_limit" ? { ...classified, ...readCapReset(message2) } : classified;
30659
+ }
30584
30660
  const status = httpStatusOf(info);
30585
30661
  return classifyProviderError(message2, status === void 0 ? {} : { status });
30586
30662
  }
@@ -30664,7 +30740,7 @@ async function handshake(session, spec, log) {
30664
30740
  }
30665
30741
  await session.rpc.notify("initialized");
30666
30742
  }
30667
- async function preflight(session, spec) {
30743
+ async function preflight(session, spec, log) {
30668
30744
  if (spec.externalAuth) {
30669
30745
  const tokens2 = await spec.externalAuth.current();
30670
30746
  await session.rpc.request("account/login/start", {
@@ -30682,6 +30758,13 @@ async function preflight(session, spec) {
30682
30758
  specForErrorKind("not_logged_in")
30683
30759
  );
30684
30760
  }
30761
+ if (spec.externalAuth) {
30762
+ try {
30763
+ session.observeRateLimits(await session.rpc.request("account/rateLimits/read", {}));
30764
+ } catch {
30765
+ log.warn("codex.rate_limits_unavailable", {});
30766
+ }
30767
+ }
30685
30768
  }
30686
30769
  function threadOf(result) {
30687
30770
  const thread = asRecord(asRecord(result)?.thread);
@@ -30743,7 +30826,7 @@ function createCodexDriver(options = {}) {
30743
30826
  try {
30744
30827
  const opening = (async () => {
30745
30828
  await handshake(session, spec, resolved.log);
30746
- await preflight(session, spec);
30829
+ await preflight(session, spec, resolved.log);
30747
30830
  return openThread(session, spec, resolved.log);
30748
30831
  })();
30749
30832
  const thread = await withDeadline(
@@ -30894,7 +30977,7 @@ function createCodexExecDriver(options = {}) {
30894
30977
  };
30895
30978
  }
30896
30979
  function envDigest2(env) {
30897
- const hash2 = (0, import_crypto9.createHash)("sha256");
30980
+ const hash2 = (0, import_crypto10.createHash)("sha256");
30898
30981
  for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
30899
30982
  return hash2.digest("hex");
30900
30983
  }
@@ -31556,7 +31639,7 @@ function readCodexRolloutTurns(chunk, baseOffset, skipped) {
31556
31639
  return readTranscriptTurns(codexRolloutFile, chunk, baseOffset, skipped);
31557
31640
  }
31558
31641
  function envDigest22(env) {
31559
- const hash2 = (0, import_crypto10.createHash)("sha256");
31642
+ const hash2 = (0, import_crypto11.createHash)("sha256");
31560
31643
  for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
31561
31644
  return hash2.digest("hex");
31562
31645
  }
@@ -31625,14 +31708,14 @@ function codexTurnInput(run2, context) {
31625
31708
  ...images.length ? { imagePaths: images.map((image) => image.path) } : {}
31626
31709
  };
31627
31710
  }
31628
- 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, INJECTED_USER_PREFIXES, SHELL_TOOL_NAMES, ANNOUNCING_ITEM_TYPES, OUTPUT_MARKER, OPEN_PAGE_ACTIONS, FIND_IN_PAGE_ACTIONS, FILE_OPERATIONS, UNDERSTOOD_ITEM_TYPES, PRELUDE_TYPES2, PRELUDE_EVENTS, codexRolloutFile;
31711
+ 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, INJECTED_USER_PREFIXES, SHELL_TOOL_NAMES, ANNOUNCING_ITEM_TYPES, OUTPUT_MARKER, OPEN_PAGE_ACTIONS, FIND_IN_PAGE_ACTIONS, FILE_OPERATIONS, UNDERSTOOD_ITEM_TYPES, PRELUDE_TYPES2, PRELUDE_EVENTS, codexRolloutFile;
31629
31712
  var init_codex = __esm({
31630
31713
  "../agent-core/dist/providers/codex.js"() {
31631
31714
  "use strict";
31632
31715
  init_chunk_SBT5W7L4();
31633
- init_chunk_72NSEYHK();
31716
+ init_chunk_4G77APXN();
31634
31717
  init_chunk_XC5676SG();
31635
- init_chunk_54ZRJOQP();
31718
+ init_chunk_HBIPWAUI();
31636
31719
  init_chunk_J2KTV5FP();
31637
31720
  init_chunk_M6YHY2EZ();
31638
31721
  init_chunk_FPGAN4XO();
@@ -31641,10 +31724,12 @@ var init_codex = __esm({
31641
31724
  import_path6 = require("path");
31642
31725
  init_effort();
31643
31726
  import_crypto8 = require("crypto");
31644
- init_agent2();
31645
31727
  import_crypto9 = require("crypto");
31728
+ init_runtime_v2();
31646
31729
  init_agent2();
31647
31730
  import_crypto10 = require("crypto");
31731
+ init_agent2();
31732
+ import_crypto11 = require("crypto");
31648
31733
  init_effort();
31649
31734
  TokenRefresher = class {
31650
31735
  #auth;
@@ -31828,6 +31913,46 @@ var init_codex = __esm({
31828
31913
  return this.#cursor;
31829
31914
  }
31830
31915
  };
31916
+ CodexRateLimits = class {
31917
+ #clock;
31918
+ #sourceId;
31919
+ #sequence = 0;
31920
+ constructor(clock, sourceId = (0, import_crypto9.randomUUID)()) {
31921
+ this.#clock = clock;
31922
+ this.#sourceId = sourceId;
31923
+ }
31924
+ read(value2) {
31925
+ const response = asRecord(value2);
31926
+ const buckets = asRecord(response?.rateLimitsByLimitId);
31927
+ if (buckets) {
31928
+ return Object.entries(buckets).flatMap(
31929
+ ([limitId, snapshot2]) => this.#update(snapshot2, limitId)
31930
+ );
31931
+ }
31932
+ return this.#update(response?.rateLimits);
31933
+ }
31934
+ notification(params) {
31935
+ return this.#update(params.rateLimits);
31936
+ }
31937
+ #update(value2, bucketId) {
31938
+ const snapshot2 = asRecord(value2);
31939
+ if (!snapshot2) return [];
31940
+ const primary = windowPatch(snapshot2.primary);
31941
+ const secondary = windowPatch(snapshot2.secondary);
31942
+ const planType = snapshot2.planType === null ? null : asString(snapshot2.planType) || void 0;
31943
+ const parsed = runCodexRateLimitsUpdateSchema.safeParse({
31944
+ sessionUpdate: "_alan/codex.rate_limits",
31945
+ limitId: bucketId ?? (asString(snapshot2.limitId) || "codex"),
31946
+ ...primary === void 0 ? {} : { primary },
31947
+ ...secondary === void 0 ? {} : { secondary },
31948
+ ...planType === void 0 ? {} : { planType },
31949
+ observedAt: new Date(this.#clock.now()).toISOString(),
31950
+ sourceId: this.#sourceId,
31951
+ sequence: this.#sequence++
31952
+ });
31953
+ return parsed.success ? [parsed.data] : [];
31954
+ }
31955
+ };
31831
31956
  USER_INPUT_METHOD = "item/tool/requestUserInput";
31832
31957
  PERMISSIONS_METHOD = "item/permissions/requestApproval";
31833
31958
  ELICITATION_METHOD = "mcpServer/elicitation/request";
@@ -31897,7 +32022,6 @@ var init_codex = __esm({
31897
32022
  "thread/closed",
31898
32023
  "hook/started",
31899
32024
  "hook/completed",
31900
- "account/rateLimits/updated",
31901
32025
  "account/updated",
31902
32026
  "account/login/completed",
31903
32027
  "remoteControl/status/changed",
@@ -32092,6 +32216,7 @@ var init_codex = __esm({
32092
32216
  #listeners = createListeners();
32093
32217
  #options;
32094
32218
  #memory;
32219
+ #rateLimits;
32095
32220
  #stderr = [];
32096
32221
  #approvals = /* @__PURE__ */ new Map();
32097
32222
  /** Session-level updates (thread start warnings, MCP startup) that open the next turn's log. */
@@ -32108,6 +32233,7 @@ var init_codex = __esm({
32108
32233
  constructor(child, tree, memory, options) {
32109
32234
  this.#options = options;
32110
32235
  this.#memory = memory;
32236
+ this.#rateLimits = new CodexRateLimits(options.clock);
32111
32237
  this.#lastTurn = new CodexTurn(memory, options.clock);
32112
32238
  this.#host = hostProcess(
32113
32239
  child,
@@ -32142,6 +32268,9 @@ var init_codex = __esm({
32142
32268
  configure(config2) {
32143
32269
  this.#config = config2;
32144
32270
  }
32271
+ observeRateLimits(response) {
32272
+ this.#recordRateLimits(this.#rateLimits.read(response));
32273
+ }
32145
32274
  attachThread(threadId, rolloutPath) {
32146
32275
  if (threadId === this.#threadId) return;
32147
32276
  this.#threadId = threadId;
@@ -32308,6 +32437,10 @@ var init_codex = __esm({
32308
32437
  return known === void 0 || known === turnId ? active : void 0;
32309
32438
  }
32310
32439
  #onNotification(notification) {
32440
+ if (notification.method === "account/rateLimits/updated") {
32441
+ this.#recordRateLimits(this.#rateLimits.notification(notification.params));
32442
+ return;
32443
+ }
32311
32444
  if (notification.method === "serverRequest/resolved") this.#dropResolved(notification);
32312
32445
  const active = this.#ownerOf(notification);
32313
32446
  const reader = active?.turn ?? this.#lastTurn;
@@ -32334,6 +32467,14 @@ var init_codex = __esm({
32334
32467
  void this.#stopTurn(active);
32335
32468
  }
32336
32469
  }
32470
+ #recordRateLimits(updates) {
32471
+ const active = this.#current;
32472
+ if (active) this.#emitUpdates(active, updates);
32473
+ else {
32474
+ this.#between.push(...updates);
32475
+ this.#between.splice(0, Math.max(0, this.#between.length - MAX_BETWEEN_UPDATES));
32476
+ }
32477
+ }
32337
32478
  #emitUpdates(active, updates) {
32338
32479
  for (const update of updates) this.#emit({ type: "update", turnId: active.id, update });
32339
32480
  }
@@ -33052,9 +33193,9 @@ function alanCodeEngineEnv(input2) {
33052
33193
  };
33053
33194
  }
33054
33195
  async function writePlugin(directory, apiOrigin) {
33055
- const origin = (0, import_crypto11.createHash)("sha256").update(apiOrigin).digest("hex").slice(0, 12);
33196
+ const origin = (0, import_crypto12.createHash)("sha256").update(apiOrigin).digest("hex").slice(0, 12);
33056
33197
  const target = (0, import_path8.join)(directory, `engine-plugin-v${ALAN_CODE_ENGINE_PLUGIN_VERSION}-${origin}.mjs`);
33057
- const temporary = `${target}.${(0, import_crypto11.randomUUID)()}.tmp`;
33198
+ const temporary = `${target}.${(0, import_crypto12.randomUUID)()}.tmp`;
33058
33199
  await (0, import_promises34.mkdir)(directory, { recursive: true, mode: 448 });
33059
33200
  await (0, import_promises34.writeFile)(temporary, alanCodeEnginePluginSource(apiOrigin), { mode: 384 });
33060
33201
  await (0, import_promises34.rename)(temporary, target);
@@ -33086,7 +33227,7 @@ function alanCodeSystemPrompt(alanSystemPrompt) {
33086
33227
 
33087
33228
  ${instructions}` : ALAN_CODE_TOOL_NAMING_PROMPT;
33088
33229
  }
33089
- var import_http9, import_https, import_fs7, import_path7, import_crypto11, import_promises34, 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;
33230
+ var import_http9, import_https, import_fs7, import_path7, import_crypto12, import_promises34, 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;
33090
33231
  var init_alan_code = __esm({
33091
33232
  "../agent-core/dist/providers/alan-code.js"() {
33092
33233
  "use strict";
@@ -33099,7 +33240,7 @@ var init_alan_code = __esm({
33099
33240
  import_fs7 = require("fs");
33100
33241
  import_path7 = require("path");
33101
33242
  init_runtime_v2();
33102
- import_crypto11 = require("crypto");
33243
+ import_crypto12 = require("crypto");
33103
33244
  import_promises34 = require("fs/promises");
33104
33245
  import_path8 = require("path");
33105
33246
  import_url = require("url");
@@ -42905,9 +43046,9 @@ var require_tar_stream = __commonJS({
42905
43046
  var init_dist = __esm({
42906
43047
  "../agent-core/dist/index.js"() {
42907
43048
  "use strict";
42908
- init_chunk_72NSEYHK();
43049
+ init_chunk_4G77APXN();
42909
43050
  init_chunk_XC5676SG();
42910
- init_chunk_54ZRJOQP();
43051
+ init_chunk_HBIPWAUI();
42911
43052
  init_chunk_M6YHY2EZ();
42912
43053
  init_chunk_YXWJW7I5();
42913
43054
  }
@@ -43581,7 +43722,7 @@ function isAcpBackendKind(value2) {
43581
43722
  return Object.hasOwn(ACP_PROFILES, value2);
43582
43723
  }
43583
43724
  function envDigest3(env) {
43584
- const hash2 = (0, import_crypto12.createHash)("sha256");
43725
+ const hash2 = (0, import_crypto13.createHash)("sha256");
43585
43726
  for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
43586
43727
  return hash2.digest("hex");
43587
43728
  }
@@ -43648,13 +43789,13 @@ async function acpTurnInput(run2, context) {
43648
43789
  ...encoded.length ? { images: encoded, imagePaths: images.map((image) => image.path) } : {}
43649
43790
  };
43650
43791
  }
43651
- var import_promises49, import_path9, import_crypto12, import_promises50, CURSOR_ASK_QUESTION, copilotAcpProfile, cursorAcpProfile, MODEL_REJECTED, MAX_READ_BYTES, FsDenied, ENV_REFERENCE, AcpBackgroundTasks, CURSOR_CREATE_PLAN, STATUSES2, 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;
43792
+ var import_promises49, import_path9, import_crypto13, import_promises50, CURSOR_ASK_QUESTION, copilotAcpProfile, cursorAcpProfile, MODEL_REJECTED, MAX_READ_BYTES, FsDenied, ENV_REFERENCE, AcpBackgroundTasks, CURSOR_CREATE_PLAN, STATUSES2, 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;
43652
43793
  var init_acp3 = __esm({
43653
43794
  "../agent-core/dist/providers/acp.js"() {
43654
43795
  "use strict";
43655
- init_chunk_72NSEYHK();
43796
+ init_chunk_4G77APXN();
43656
43797
  init_chunk_XC5676SG();
43657
- init_chunk_54ZRJOQP();
43798
+ init_chunk_HBIPWAUI();
43658
43799
  init_chunk_J2KTV5FP();
43659
43800
  init_chunk_M6YHY2EZ();
43660
43801
  init_chunk_FPGAN4XO();
@@ -43663,7 +43804,7 @@ var init_acp3 = __esm({
43663
43804
  import_path9 = require("path");
43664
43805
  init_effort();
43665
43806
  init_acp();
43666
- import_crypto12 = require("crypto");
43807
+ import_crypto13 = require("crypto");
43667
43808
  import_promises50 = require("fs/promises");
43668
43809
  init_agent2();
43669
43810
  CURSOR_ASK_QUESTION = "cursor/ask_question";
@@ -44469,7 +44610,7 @@ var init_acp3 = __esm({
44469
44610
  var init_classify = __esm({
44470
44611
  "../agent-core/dist/classify.js"() {
44471
44612
  "use strict";
44472
- init_chunk_54ZRJOQP();
44613
+ init_chunk_HBIPWAUI();
44473
44614
  init_chunk_YXWJW7I5();
44474
44615
  }
44475
44616
  });
@@ -44679,7 +44820,10 @@ function createPersistentDriver(provider4, options) {
44679
44820
  return "delivered";
44680
44821
  };
44681
44822
  const openFailed = (error61, spec, sink, signal, inputs) => {
44682
- if (error61 instanceof SessionOpenRefusal && error61.reason === "unsupported_version" && options.fallback) {
44823
+ if (error61 instanceof SessionOpenRefusal && error61.reason === "unsupported_version" && inputs.codex !== void 0) {
44824
+ return { outcome: "failed", message: error61.message };
44825
+ }
44826
+ if (error61 instanceof SessionOpenRefusal && error61.reason === "unsupported_version" && options.fallback && inputs.codex === void 0) {
44683
44827
  log.warn("holder.persistent_unsupported", {
44684
44828
  harness: provider4.harness,
44685
44829
  message: error61.message
@@ -44696,7 +44840,7 @@ function createPersistentDriver(provider4, options) {
44696
44840
  };
44697
44841
  return {
44698
44842
  runTurn: async (spec, sink, signal, inputs) => {
44699
- if (live.fallbackOnly && options.fallback)
44843
+ if (live.fallbackOnly && options.fallback && inputs.codex === void 0)
44700
44844
  return options.fallback.runTurn(spec, sink, signal, inputs);
44701
44845
  if (signal.aborted) return { outcome: "aborted" };
44702
44846
  const managedMcp = await managedMcpAccess(signal);
@@ -45286,7 +45430,7 @@ function createOpenCodeDriver(options = {}) {
45286
45430
  await authorization?.remove();
45287
45431
  };
45288
45432
  const spec = { ...planned, env: launchEnv(planned, authorization) };
45289
- const password = options.password?.() ?? (0, import_crypto13.randomBytes)(24).toString("base64url");
45433
+ const password = options.password?.() ?? (0, import_crypto14.randomBytes)(24).toString("base64url");
45290
45434
  try {
45291
45435
  const session = await openWithRetries(spec, password, resolved);
45292
45436
  void session.exited.then(removeAuthorization).catch((error61) => {
@@ -45301,7 +45445,7 @@ function createOpenCodeDriver(options = {}) {
45301
45445
  };
45302
45446
  }
45303
45447
  function envDigest4(env) {
45304
- const hash2 = (0, import_crypto14.createHash)("sha256");
45448
+ const hash2 = (0, import_crypto15.createHash)("sha256");
45305
45449
  for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
45306
45450
  return hash2.digest("hex");
45307
45451
  }
@@ -45382,20 +45526,20 @@ function openCodeTurnInput(run2, context) {
45382
45526
  ...images.length ? { imagePaths: images.map((image) => image.path) } : {}
45383
45527
  };
45384
45528
  }
45385
- var import_http10, import_crypto13, import_promises51, import_path10, import_path11, import_url2, import_crypto14, IDLE_SOCKET_MS3, 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_OPERATIONS2, 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;
45529
+ var import_http10, import_crypto14, import_promises51, import_path10, import_path11, import_url2, import_crypto15, IDLE_SOCKET_MS3, 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_OPERATIONS2, 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;
45386
45530
  var init_opencode = __esm({
45387
45531
  "../agent-core/dist/providers/opencode.js"() {
45388
45532
  "use strict";
45389
- init_chunk_72NSEYHK();
45533
+ init_chunk_4G77APXN();
45390
45534
  init_chunk_XC5676SG();
45391
- init_chunk_54ZRJOQP();
45535
+ init_chunk_HBIPWAUI();
45392
45536
  init_chunk_J2KTV5FP();
45393
45537
  init_chunk_M6YHY2EZ();
45394
45538
  init_chunk_FPGAN4XO();
45395
45539
  init_chunk_YXWJW7I5();
45396
45540
  import_http10 = require("http");
45397
45541
  init_runtime_v2();
45398
- import_crypto13 = require("crypto");
45542
+ import_crypto14 = require("crypto");
45399
45543
  import_promises51 = require("fs/promises");
45400
45544
  import_path10 = require("path");
45401
45545
  init_agent2();
@@ -45403,7 +45547,7 @@ var init_opencode = __esm({
45403
45547
  import_url2 = require("url");
45404
45548
  init_acp();
45405
45549
  init_acp();
45406
- import_crypto14 = require("crypto");
45550
+ import_crypto15 = require("crypto");
45407
45551
  init_agent2();
45408
45552
  IDLE_SOCKET_MS3 = 4e3;
45409
45553
  OpenCodeHttpError = class extends Error {
@@ -46699,11 +46843,11 @@ function createCodexLogin(broker) {
46699
46843
  }
46700
46844
  };
46701
46845
  }
46702
- function withLogin(planned, externalAuth, accountId) {
46846
+ function withLogin(planned, externalAuth, credentialKey) {
46703
46847
  return {
46704
46848
  ...planned,
46705
46849
  spec: { ...planned.spec, externalAuth },
46706
- key: JSON.stringify([planned.key, accountId])
46850
+ key: JSON.stringify([planned.key, credentialKey])
46707
46851
  };
46708
46852
  }
46709
46853
  function createCodexHolderDriver(options) {
@@ -46725,7 +46869,11 @@ function createCodexHolderDriver(options) {
46725
46869
  });
46726
46870
  if (inputs.codex === void 0) return planned;
46727
46871
  login.forTurn(spec.runId, inputs.codex);
46728
- return withLogin(planned, login.externalAuth, inputs.codex.chatgptAccountId);
46872
+ return withLogin(
46873
+ planned,
46874
+ login.externalAuth,
46875
+ inputs.codex.credentialId ?? inputs.codex.chatgptAccountId
46876
+ );
46729
46877
  },
46730
46878
  canResume: () => true,
46731
46879
  open: async (spec) => {
@@ -47138,7 +47286,7 @@ function createDroidDriver(options = {}) {
47138
47286
  };
47139
47287
  }
47140
47288
  function envDigest5(env) {
47141
- const hash2 = (0, import_crypto15.createHash)("sha256");
47289
+ const hash2 = (0, import_crypto16.createHash)("sha256");
47142
47290
  for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
47143
47291
  return hash2.digest("hex");
47144
47292
  }
@@ -47198,19 +47346,19 @@ async function droidTurnInput(run2, context) {
47198
47346
  );
47199
47347
  return { turnId: run2.runId, text: text3, ...encoded.length ? { images: encoded } : {} };
47200
47348
  }
47201
- var import_crypto15, import_promises52, 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;
47349
+ var import_crypto16, import_promises52, 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;
47202
47350
  var init_droid = __esm({
47203
47351
  "../agent-core/dist/providers/droid.js"() {
47204
47352
  "use strict";
47205
- init_chunk_72NSEYHK();
47353
+ init_chunk_4G77APXN();
47206
47354
  init_chunk_XC5676SG();
47207
- init_chunk_54ZRJOQP();
47355
+ init_chunk_HBIPWAUI();
47208
47356
  init_chunk_J2KTV5FP();
47209
47357
  init_chunk_M6YHY2EZ();
47210
47358
  init_chunk_FPGAN4XO();
47211
47359
  init_chunk_YXWJW7I5();
47212
47360
  init_runtime_v2();
47213
- import_crypto15 = require("crypto");
47361
+ import_crypto16 = require("crypto");
47214
47362
  import_promises52 = require("fs/promises");
47215
47363
  init_agent2();
47216
47364
  FACTORY_API_VERSION = "1.0.0";
@@ -48258,7 +48406,7 @@ ${output2.stderr}`).join("\n")
48258
48406
  };
48259
48407
  }
48260
48408
  function envDigest6(env) {
48261
- const hash2 = (0, import_crypto16.createHash)("sha256");
48409
+ const hash2 = (0, import_crypto17.createHash)("sha256");
48262
48410
  for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
48263
48411
  return hash2.digest("hex");
48264
48412
  }
@@ -48304,14 +48452,14 @@ function antigravityTurnInput(run2, context) {
48304
48452
  });
48305
48453
  return { turnId: run2.runId, text: appendImagePathReferences(text3, images) };
48306
48454
  }
48307
- var import_promises53, 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;
48455
+ var import_promises53, 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;
48308
48456
  var init_antigravity = __esm({
48309
48457
  "../agent-core/dist/providers/antigravity.js"() {
48310
48458
  "use strict";
48311
48459
  init_chunk_SBT5W7L4();
48312
- init_chunk_72NSEYHK();
48460
+ init_chunk_4G77APXN();
48313
48461
  init_chunk_XC5676SG();
48314
- init_chunk_54ZRJOQP();
48462
+ init_chunk_HBIPWAUI();
48315
48463
  init_chunk_M6YHY2EZ();
48316
48464
  init_chunk_FPGAN4XO();
48317
48465
  init_chunk_YXWJW7I5();
@@ -48323,7 +48471,7 @@ var init_antigravity = __esm({
48323
48471
  init_effort();
48324
48472
  import_path14 = require("path");
48325
48473
  import_url3 = require("url");
48326
- import_crypto16 = require("crypto");
48474
+ import_crypto17 = require("crypto");
48327
48475
  init_agent2();
48328
48476
  NO_ANTIGRAVITY_CAPABILITIES = {
48329
48477
  structuredPrint: false,
@@ -48957,7 +49105,7 @@ function createCommandCodeDriver(options = {}) {
48957
49105
  };
48958
49106
  }
48959
49107
  function envDigest7(env) {
48960
- const hash2 = (0, import_crypto17.createHash)("sha256");
49108
+ const hash2 = (0, import_crypto18.createHash)("sha256");
48961
49109
  for (const key of Object.keys(env).sort()) hash2.update(`${key}\0${env[key]}\0`);
48962
49110
  return hash2.digest("hex");
48963
49111
  }
@@ -49009,13 +49157,13 @@ function commandCodeTurnInput(run2, context) {
49009
49157
  });
49010
49158
  return { turnId: run2.runId, text: appendImagePathReferences(text3, images) };
49011
49159
  }
49012
- var import_promises54, 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;
49160
+ var import_promises54, 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;
49013
49161
  var init_command_code = __esm({
49014
49162
  "../agent-core/dist/providers/command-code.js"() {
49015
49163
  "use strict";
49016
- init_chunk_72NSEYHK();
49164
+ init_chunk_4G77APXN();
49017
49165
  init_chunk_XC5676SG();
49018
- init_chunk_54ZRJOQP();
49166
+ init_chunk_HBIPWAUI();
49019
49167
  init_chunk_J2KTV5FP();
49020
49168
  init_chunk_M6YHY2EZ();
49021
49169
  init_chunk_FPGAN4XO();
@@ -49025,7 +49173,7 @@ var init_command_code = __esm({
49025
49173
  init_agent2();
49026
49174
  init_runtime_v2();
49027
49175
  init_acp();
49028
- import_crypto17 = require("crypto");
49176
+ import_crypto18 = require("crypto");
49029
49177
  init_agent2();
49030
49178
  COMMAND_CODE_GRAMMAR_NAME = "command_code_cli";
49031
49179
  SILENT3 = /* @__PURE__ */ new Set([
@@ -54416,7 +54564,7 @@ var require_websocket_server = __commonJS({
54416
54564
  // package.json
54417
54565
  var package_default = {
54418
54566
  name: "@alan-ai-hq/agent-manager",
54419
- version: "0.1.145",
54567
+ version: "0.1.146",
54420
54568
  private: true,
54421
54569
  type: "module",
54422
54570
  description: "Alan machine runtime (alan-agent): identity, link, reconciler, session holders, run log, uploader, local API",
@@ -55234,7 +55382,18 @@ function createGitHubProxyForwarder(options) {
55234
55382
 
55235
55383
  // src/api-client/holder-client.ts
55236
55384
  init_runtime_v2();
55385
+ init_zod();
55237
55386
  var REQUEST_TIMEOUT_MS3 = 3e4;
55387
+ var credentialRefusalSchema = external_exports.object({ message: external_exports.string().trim().min(1) });
55388
+ function credentialFailureMessage(response, fallback) {
55389
+ if (response.status !== 409) return fallback;
55390
+ try {
55391
+ const parsed = credentialRefusalSchema.safeParse(jsonBody(response));
55392
+ return parsed.success ? parsed.data.message : fallback;
55393
+ } catch {
55394
+ return fallback;
55395
+ }
55396
+ }
55238
55397
  function createHolderApiClient({
55239
55398
  apiUrl,
55240
55399
  accessToken,
@@ -55267,7 +55426,10 @@ function createHolderApiClient({
55267
55426
  if (!isOk(response)) {
55268
55427
  throw new RuntimeFault(
55269
55428
  "io_failed",
55270
- `Provider credential request failed: ${response.status}`
55429
+ credentialFailureMessage(
55430
+ response,
55431
+ `Provider credential request failed: ${response.status}`
55432
+ )
55271
55433
  );
55272
55434
  }
55273
55435
  return runProviderCredentialSchema.parse(jsonBody(response));
@@ -55275,7 +55437,10 @@ function createHolderApiClient({
55275
55437
  refreshCodexCredential: async (runId, body, signal) => {
55276
55438
  const response = await request2("POST", runCodexCredentialRefreshPath(runId), signal, body);
55277
55439
  if (!isOk(response)) {
55278
- throw new RuntimeFault("io_failed", `Codex sign-in refresh failed: ${response.status}`);
55440
+ throw new RuntimeFault(
55441
+ "io_failed",
55442
+ credentialFailureMessage(response, `Codex sign-in refresh failed: ${response.status}`)
55443
+ );
55279
55444
  }
55280
55445
  return runCodexCredentialSchema.parse(jsonBody(response));
55281
55446
  },