@vtxmacro/cli 2026.8.59 → 2026.9.2

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/bin/vtx.js CHANGED
@@ -47,7 +47,7 @@ var init_agent_cli_release = __esm({
47
47
  "agent-cli-release.json"() {
48
48
  agent_cli_release_default = {
49
49
  package_name: "@vtxmacro/cli",
50
- package_version: "2026.8.59",
50
+ package_version: "2026.9.2",
51
51
  codex_package_name: "@openai/codex",
52
52
  codex_version: "0.147.0",
53
53
  copilot_sdk_package_name: "@github/copilot-sdk",
@@ -14827,6 +14827,7 @@ var init_external_inference_contract = __esm({
14827
14827
  authenticated_account_email: authenticatedAccountEmailSchema.nullable().optional(),
14828
14828
  authenticated_account_plan: safeCodeSchema.nullable().optional(),
14829
14829
  protocol_version: protocolVersionSchema,
14830
+ host_runtime_version: protocolVersionSchema.optional(),
14830
14831
  envelope_public_key: base64Url32BytesSchema,
14831
14832
  health: external_exports.enum(["healthy", "degraded", "draining"]),
14832
14833
  advertised_at: timestampSchema,
@@ -15500,6 +15501,7 @@ var init_external_inference_contract = __esm({
15500
15501
  outcome: adapterOutcomeEvidenceSchema,
15501
15502
  latency_ms: nonNegativeSafeIntegerSchema,
15502
15503
  time_to_first_token_ms: nonNegativeSafeIntegerSchema.nullable(),
15504
+ provider_dispatch_freshness_remaining_ms: nonNegativeSafeIntegerSchema.nullable().optional(),
15503
15505
  finish_reason: safeCodeSchema.nullable(),
15504
15506
  refusal_status: external_exports.enum(["none", "refused", "blocked", "unknown"]),
15505
15507
  completed_at: timestampSchema
@@ -15614,6 +15616,7 @@ var init_external_inference_contract = __esm({
15614
15616
  failure_category: safeCodeSchema,
15615
15617
  failure_code: safeCodeSchema,
15616
15618
  retryable: external_exports.boolean(),
15619
+ provider_dispatch_freshness_remaining_ms: nonNegativeSafeIntegerSchema.nullable().optional(),
15617
15620
  process_exit: codexProcessExitDiagnosticsSchema.nullable().optional(),
15618
15621
  membership_disposition: external_exports.enum([
15619
15622
  "retry_same_host",
@@ -18250,7 +18253,8 @@ var init_mcp_client = __esm({
18250
18253
  job_id: identifierSchema2,
18251
18254
  attempt_id: identifierSchema2,
18252
18255
  attempt_index: external_exports.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
18253
- state: safeCodeSchema2
18256
+ state: safeCodeSchema2,
18257
+ provider_dispatch_freshness_remaining_ms: external_exports.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).nullable().optional()
18254
18258
  });
18255
18259
  agentConnectResultSchema = external_exports.strictObject({
18256
18260
  host: hostStatusReadSchema,
@@ -21267,6 +21271,15 @@ child.once('close', async (code, signal) => {
21267
21271
  retryable: false
21268
21272
  });
21269
21273
  }
21274
+ if (options.notAfterMs !== void 0 && Date.now() > options.notAfterMs) {
21275
+ throw new CodexAppServerError({
21276
+ message: "Server account context expired before provider dispatch.",
21277
+ category: "adapter",
21278
+ code: "server_account_context_expired_before_provider_dispatch",
21279
+ retryable: false,
21280
+ dispatchOutcome: "not_dispatched"
21281
+ });
21282
+ }
21270
21283
  return await new Promise((resolve6, reject) => {
21271
21284
  const pending = { resolve: resolve6, reject, timer: null, abortCleanup: null };
21272
21285
  pending.timer = setTimeout(() => {
@@ -22182,6 +22195,7 @@ child.once('close', async (code, signal) => {
22182
22195
  }, {
22183
22196
  timeoutMs: remaining(),
22184
22197
  signal: request.signal,
22198
+ notAfterMs: "providerDispatchNotAfterMs" in request ? request.providerDispatchNotAfterMs : void 0,
22185
22199
  beforeWrite: async (id2) => {
22186
22200
  requestId = id2;
22187
22201
  try {
@@ -22204,6 +22218,7 @@ child.once('close', async (code, signal) => {
22204
22218
  onWritten: (id2) => {
22205
22219
  requestWritten = true;
22206
22220
  requestId = id2;
22221
+ if ("onProviderDispatch" in request) request.onProviderDispatch?.();
22207
22222
  }
22208
22223
  });
22209
22224
  } catch (error48) {
@@ -22994,6 +23009,14 @@ var init_codex_adapter = __esm({
22994
23009
  retryable: false
22995
23010
  });
22996
23011
  }
23012
+ if (input.providerDispatchNotAfterMs !== void 0 && !Number.isSafeInteger(input.providerDispatchNotAfterMs)) {
23013
+ throw new CodexAppServerError({
23014
+ message: "Codex provider-dispatch freshness deadline is invalid.",
23015
+ category: "adapter",
23016
+ code: "server_provider_dispatch_fence_invalid",
23017
+ retryable: false
23018
+ });
23019
+ }
22997
23020
  if (!CODEX_MODEL_NAME_PATTERN.test(input.requestedModel) || !CODEX_REASONING_EFFORT_PATTERN.test(input.requestedReasoningEffort)) {
22998
23021
  throw new CodexAppServerError({
22999
23022
  message: "Codex model selection is not a valid catalog identity.",
@@ -23781,6 +23804,8 @@ var init_codex_adapter = __esm({
23781
23804
  requestedModel: input.requestedModel,
23782
23805
  requestedReasoningEffort: input.requestedReasoningEffort,
23783
23806
  deadlineAtMs: input.deadlineAtMs,
23807
+ providerDispatchNotAfterMs: input.providerDispatchNotAfterMs,
23808
+ onProviderDispatch: input.onProviderDispatch,
23784
23809
  signal: input.signal,
23785
23810
  onDispatchState: async (state) => {
23786
23811
  currentDispatchOutcome = state.dispatchOutcome;
@@ -23823,7 +23848,7 @@ var init_codex_adapter = __esm({
23823
23848
  }
23824
23849
  }
23825
23850
  if (error48 instanceof CodexAppServerError) {
23826
- const dispatchOutcome = error48.dispatchOutcome === "not_dispatched" ? currentDispatchOutcome : error48.dispatchOutcome;
23851
+ const dispatchOutcome = error48.code === "server_account_context_expired_before_provider_dispatch" ? "not_dispatched" : error48.dispatchOutcome === "not_dispatched" ? currentDispatchOutcome : error48.dispatchOutcome;
23827
23852
  if (baseCheckpoint && !completedResult) {
23828
23853
  latestCheckpoint = {
23829
23854
  ...baseCheckpoint,
@@ -24531,6 +24556,16 @@ ${input.outputSchemaJson}`
24531
24556
  void session?.abort().catch(() => void 0);
24532
24557
  };
24533
24558
  input.signal?.addEventListener("abort", onAbort, { once: true });
24559
+ if (input.providerDispatchNotAfterMs !== void 0 && Date.now() > input.providerDispatchNotAfterMs) {
24560
+ throw new CodexAppServerError({
24561
+ message: "Server account context expired before provider dispatch.",
24562
+ category: "adapter",
24563
+ code: "server_account_context_expired_before_provider_dispatch",
24564
+ retryable: false,
24565
+ dispatchOutcome: "not_dispatched"
24566
+ });
24567
+ }
24568
+ input.onProviderDispatch?.();
24534
24569
  dispatchEntered = true;
24535
24570
  let response;
24536
24571
  try {
@@ -25345,6 +25380,14 @@ var init_deepseek_harness_adapter = __esm({
25345
25380
  const blocks = [];
25346
25381
  let usage = null;
25347
25382
  let finish = null;
25383
+ if (input.providerDispatchNotAfterMs !== void 0 && Date.now() > input.providerDispatchNotAfterMs) {
25384
+ throw nonDispatchedError(
25385
+ "Server account context expired before provider dispatch.",
25386
+ "transport",
25387
+ "server_account_context_expired_before_provider_dispatch"
25388
+ );
25389
+ }
25390
+ input.onProviderDispatch?.();
25348
25391
  for await (const chunk of adapter.stream({
25349
25392
  provider: "deepseek-official",
25350
25393
  model: input.requestedModel,
@@ -32458,7 +32501,7 @@ function createDefaultInferenceHostRunnerDependencies(options) {
32458
32501
  envelopePublicKey: options.envelopePublicKey
32459
32502
  };
32460
32503
  }
32461
- var import_ajv, RUNTIME_RECEIPT_SCHEMA_VERSION, ATTEMPT_RECEIPT_SCHEMA_VERSION, DEFAULT_ADVERTISEMENT_TTL_MS, DEFAULT_ADVERTISEMENT_REFRESH_LEAD_MS, DEFAULT_HOST_HEARTBEAT_MS, DEFAULT_PROVIDER_RATE_LIMIT_REFRESH_MS, DEFAULT_ATTEMPT_HEARTBEAT_MS, DEFAULT_DRAIN_TIMEOUT_MS, DEFAULT_REMOTE_RETRY_LIMIT, MIN_SLEEP_MS, MIN_HOST_HEARTBEAT_GAP_DIAGNOSTIC_MS, HOST_HEARTBEAT_GAP_DIAGNOSTIC_FACTOR, DEFAULT_CODEX_ACCOUNT_COOLDOWN_MS, DEFAULT_AGENT_RATE_LIMIT_COOLDOWN_MS, DEFAULT_AGENT_QUOTA_COOLDOWN_MS, DEFAULT_AGENT_TRANSIENT_COOLDOWN_MS, MIN_CLAIM_START_WINDOW_MS, MAX_ATTEMPT_START_RETRY_DELAY_MS, UNBOUNDED_AVAILABLE_SLOTS, buildInferenceAdvertisedModels, summarizeInferenceHostRuntimeRecovery, FileInferenceHostRuntimeReceiptStore, InferenceHostRecoveryRequiredError, InferenceHostRunnerError, defaultSleep, abortError, settlesWithin, defaultRegisterSignalHandlers, safeInteger, exactObjectKeys, validIso, validateAttemptReceipt, validateRuntimeReceipt, sha256, stableOperationId, buildAttemptStartRequest, isoAt, providerWeeklyQuotaFromRateLimits, finitePositiveOption, validateRunnerOptions, assertLocalCredentialIdentity, retryableRemoteError, remoteRetryAfterMs, controlPlaneFatal, defaultValidateOutput, objectRecord, positiveUtf8ByteLimit, assertCompilableOutputSchema, parseOutputContract, membershipFailureDisposition, safeFailureCode, publicServerFailureCode, attemptStartRetryFallbackMs, exactJson2, runnerIdentityMismatch, assertAdvertisementResult, assertHostHeartbeatResult, assertClaimResult, assertStartResult, assertJobHeartbeatResult, assertTerminalResult, isDefinitiveCompletionEvidenceExpiry, classifyFailure, ambiguousHeartbeatTransport, reportedTokenUsage, reportedUsage, InferenceHostRunner, createInferenceAgentControlClient, INFERENCE_AGENT_SYSTEM_PROMPT, INFERENCE_AGENT_WAKE_SCHEMA, parseInferenceAgentWake, InferenceAgentRuntime;
32504
+ var import_ajv, RUNTIME_RECEIPT_SCHEMA_VERSION, ATTEMPT_RECEIPT_SCHEMA_VERSION, DEFAULT_ADVERTISEMENT_TTL_MS, DEFAULT_ADVERTISEMENT_REFRESH_LEAD_MS, DEFAULT_HOST_HEARTBEAT_MS, DEFAULT_PROVIDER_RATE_LIMIT_REFRESH_MS, DEFAULT_ATTEMPT_HEARTBEAT_MS, DEFAULT_DRAIN_TIMEOUT_MS, DEFAULT_REMOTE_RETRY_LIMIT, MIN_SLEEP_MS, MIN_HOST_HEARTBEAT_GAP_DIAGNOSTIC_MS, HOST_HEARTBEAT_GAP_DIAGNOSTIC_FACTOR, DEFAULT_CODEX_ACCOUNT_COOLDOWN_MS, DEFAULT_AGENT_RATE_LIMIT_COOLDOWN_MS, DEFAULT_AGENT_QUOTA_COOLDOWN_MS, DEFAULT_AGENT_TRANSIENT_COOLDOWN_MS, MIN_CLAIM_START_WINDOW_MS, MAX_ATTEMPT_START_RETRY_DELAY_MS, UNBOUNDED_AVAILABLE_SLOTS, buildInferenceAdvertisedModels, summarizeInferenceHostRuntimeRecovery, FileInferenceHostRuntimeReceiptStore, InferenceHostRecoveryRequiredError, InferenceHostRunnerError, defaultSleep, abortError, settlesWithin, defaultRegisterSignalHandlers, safeInteger, exactObjectKeys, validIso, validateAttemptReceipt, validateRuntimeReceipt, sha256, stableOperationId, buildAttemptStartRequest, isoAt, providerWeeklyQuotaFromRateLimits, finitePositiveOption, validateRunnerOptions, assertLocalCredentialIdentity, retryableRemoteError, remoteRetryAfterMs, controlPlaneFatal, defaultValidateOutput, objectRecord, positiveUtf8ByteLimit, assertCompilableOutputSchema, parseOutputContract, serverProviderDispatchNotAfterMs, membershipFailureDisposition, safeFailureCode, publicServerFailureCode, attemptStartRetryFallbackMs, exactJson2, runnerIdentityMismatch, assertAdvertisementResult, assertHostHeartbeatResult, assertClaimResult, assertStartResult, assertJobHeartbeatResult, assertTerminalResult, isDefinitiveCompletionEvidenceExpiry, classifyFailure, ambiguousHeartbeatTransport, reportedTokenUsage, reportedUsage, InferenceHostRunner, createInferenceAgentControlClient, INFERENCE_AGENT_SYSTEM_PROMPT, INFERENCE_AGENT_WAKE_SCHEMA, parseInferenceAgentWake, InferenceAgentRuntime;
32462
32505
  var init_runner = __esm({
32463
32506
  "lib/inference-host/runner.ts"() {
32464
32507
  "use strict";
@@ -32815,7 +32858,7 @@ var init_runner = __esm({
32815
32858
  if (!options.displayName.trim() || options.displayName.length > 128) {
32816
32859
  throw new InferenceHostRunnerError("invalid_configuration", "Inference host display name is invalid.");
32817
32860
  }
32818
- if (!options.protocolVersion.trim() || !options.adapterRuntimeVersion.trim()) {
32861
+ if (!options.protocolVersion.trim() || !options.adapterRuntimeVersion.trim() || options.hostRuntimeVersion !== void 0 && !options.hostRuntimeVersion.trim()) {
32819
32862
  throw new InferenceHostRunnerError("invalid_configuration", "Inference host version metadata is required.");
32820
32863
  }
32821
32864
  const advertisementTtlMs = finitePositiveOption(
@@ -32836,6 +32879,7 @@ var init_runner = __esm({
32836
32879
  }
32837
32880
  return {
32838
32881
  adapterId,
32882
+ hostRuntimeVersion: options.hostRuntimeVersion ?? options.adapterRuntimeVersion,
32839
32883
  usageSource: options.usageSource ?? (adapterId === "codex" ? "codex_app_server" : adapterId),
32840
32884
  sameAttemptRecovery: options.sameAttemptRecovery ?? adapterId === "codex",
32841
32885
  agentRuntime: options.agentRuntime ?? null,
@@ -33023,10 +33067,37 @@ var init_runner = __esm({
33023
33067
  providerReasoningSummarySupported
33024
33068
  };
33025
33069
  };
33070
+ serverProviderDispatchNotAfterMs = (jobInput) => {
33071
+ if (jobInput.execution_mode !== "server") return void 0;
33072
+ let context;
33073
+ try {
33074
+ context = JSON.parse(jobInput.context_json);
33075
+ } catch {
33076
+ throw new InferenceHostRunnerError(
33077
+ "server_provider_dispatch_fence_invalid",
33078
+ "The Server provider-dispatch freshness fence is invalid."
33079
+ );
33080
+ }
33081
+ const contextObject = objectRecord(context);
33082
+ if (!contextObject || !("server_provider_dispatch_fence" in contextObject)) {
33083
+ return void 0;
33084
+ }
33085
+ const fence = objectRecord(contextObject.server_provider_dispatch_fence);
33086
+ const rawNotAfter = fence?.provider_dispatch_not_after;
33087
+ const notAfterMs = typeof rawNotAfter === "string" ? Date.parse(rawNotAfter) : NaN;
33088
+ if (!Number.isFinite(notAfterMs)) {
33089
+ throw new InferenceHostRunnerError(
33090
+ "server_provider_dispatch_fence_invalid",
33091
+ "The Server provider-dispatch freshness deadline is invalid."
33092
+ );
33093
+ }
33094
+ return notAfterMs;
33095
+ };
33026
33096
  membershipFailureDisposition = (failure) => {
33027
33097
  if (failure.dispatchOutcome === "outcome_unknown") return "quarantine_ambiguous";
33028
33098
  if (failure.category === "auth" || ["auth_expired", "managed_chatgpt_auth_required", "invalid_account_metadata"].includes(failure.code)) return "cascade_disable";
33029
33099
  if (failure.category === "quota" || ["quota_exceeded", "codex_rate_limited", "provider_rate_limited"].includes(failure.code)) return "cascade_cooldown";
33100
+ if (failure.code === "codex_server_overloaded") return "cascade_cooldown";
33030
33101
  if (failure.retryable && (["adapter", "network", "transport"].includes(failure.category) || failure.code === "rpc_timeout")) return "retry_same_host";
33031
33102
  if (["model_unavailable", "reasoning_effort_unavailable"].includes(failure.code)) return "cascade_cooldown";
33032
33103
  if ([
@@ -33534,6 +33605,7 @@ var init_runner = __esm({
33534
33605
  authenticated_account_email: this.options.authenticatedAccountEmail ?? null,
33535
33606
  authenticated_account_plan: this.options.authenticatedAccountPlan ?? null,
33536
33607
  protocol_version: this.options.protocolVersion,
33608
+ host_runtime_version: settings.hostRuntimeVersion,
33537
33609
  envelope_public_key: envelopePublicKey,
33538
33610
  health,
33539
33611
  advertised_at: isoAt(advertisedAt),
@@ -33724,13 +33796,14 @@ var init_runner = __esm({
33724
33796
  const heartbeatAttemptedAt = now();
33725
33797
  const attemptedAdvertisementGeneration = receipt.advertisement_generation;
33726
33798
  try {
33727
- const expiresAt = receipt.advertisement_expires_at ? Date.parse(receipt.advertisement_expires_at) : 0;
33728
- const refreshPendingAcrossExpiry = receipt.pending_advertisement !== null && expiresAt <= heartbeatAttemptedAt;
33729
33799
  await hostHeartbeat(
33730
33800
  "healthy",
33731
33801
  { signal: hostHeartbeatAbort.signal },
33732
33802
  false,
33733
- refreshPendingAcrossExpiry,
33803
+ // The server evaluates advertisement expiry when it receives
33804
+ // the heartbeat. A request sent just before expiry can therefore
33805
+ // truthfully return offline; the advertisement loop owns repair.
33806
+ true,
33734
33807
  0,
33735
33808
  attemptedAdvertisementGeneration
33736
33809
  );
@@ -33884,6 +33957,15 @@ var init_runner = __esm({
33884
33957
  active_attempts: active.size
33885
33958
  });
33886
33959
  },
33960
+ onProviderDispatch: (observation) => {
33961
+ emitDiagnostic("provider_dispatch_freshness_passed", {
33962
+ ...observation,
33963
+ job_id: claim.job_id,
33964
+ attempt_id: attemptId,
33965
+ requested_model: claim.requested_model,
33966
+ active_attempts: active.size
33967
+ });
33968
+ },
33887
33969
  startRetryCount: nextStartRetryCount,
33888
33970
  onAttemptStartRetry: (observation) => {
33889
33971
  attemptStartRetryCounts.set(attemptId, observation.retry_count);
@@ -34288,6 +34370,11 @@ var init_runner = __esm({
34288
34370
  credential.x25519_private_key,
34289
34371
  claim
34290
34372
  );
34373
+ const serverProviderDispatchDeadlineMs = serverProviderDispatchNotAfterMs(jobInput);
34374
+ let providerDispatchNotAfterMs = serverProviderDispatchDeadlineMs === void 0 ? void 0 : now() - 1;
34375
+ let serverReportedFreshnessRemainingMs = null;
34376
+ let startRoundTripMs = 0;
34377
+ let providerDispatchFreshnessRemainingMs = null;
34291
34378
  const startRequest = options.resumeReceipt?.start_request ?? buildAttemptStartRequest(claim, attemptId, isoAt(now()));
34292
34379
  let attemptReceipt = options.resumeReceipt ? validateAttemptReceipt(options.resumeReceipt) : {
34293
34380
  schema_version: ATTEMPT_RECEIPT_SCHEMA_VERSION,
@@ -34311,19 +34398,7 @@ var init_runner = __esm({
34311
34398
  "The persisted same-attempt recovery scope is invalid."
34312
34399
  );
34313
34400
  }
34314
- if (!options.resumeReceipt) {
34315
- await options.updateReceipt((current) => {
34316
- const pendingClaimRequest = options.claimRequest && current.pending_claim_request?.claim_request_id === options.claimRequest.claim_request_id ? null : current.pending_claim_request ?? null;
34317
- return {
34318
- ...current,
34319
- pending_claim_request: pendingClaimRequest,
34320
- attempts: { ...current.attempts, [attemptId]: attemptReceipt },
34321
- updated_at: isoAt(now())
34322
- };
34323
- });
34324
- options.onClaimPersisted?.();
34325
- }
34326
- const updateAttempt = async (changes) => {
34401
+ const persistAttempt = async (changes, clearPendingClaim = false) => {
34327
34402
  const nextAttemptReceipt = validateAttemptReceipt({
34328
34403
  ...attemptReceipt,
34329
34404
  ...changes,
@@ -34332,9 +34407,11 @@ var init_runner = __esm({
34332
34407
  attemptReceipt = nextAttemptReceipt;
34333
34408
  await options.updateReceipt((current) => ({
34334
34409
  ...current,
34410
+ pending_claim_request: clearPendingClaim && options.claimRequest && current.pending_claim_request?.claim_request_id === options.claimRequest.claim_request_id ? null : current.pending_claim_request ?? null,
34335
34411
  attempts: { ...current.attempts, [attemptId]: nextAttemptReceipt },
34336
34412
  updated_at: isoAt(now())
34337
34413
  }));
34414
+ if (clearPendingClaim) options.onClaimPersisted?.();
34338
34415
  };
34339
34416
  const removeAttempt = async () => {
34340
34417
  await options.updateReceipt((current) => {
@@ -34342,11 +34419,21 @@ var init_runner = __esm({
34342
34419
  delete attempts[attemptId];
34343
34420
  return {
34344
34421
  ...current,
34422
+ pending_claim_request: options.claimRequest && current.pending_claim_request?.claim_request_id === options.claimRequest.claim_request_id ? null : current.pending_claim_request ?? null,
34345
34423
  attempts,
34346
34424
  updated_at: isoAt(now())
34347
34425
  };
34348
34426
  });
34427
+ options.onClaimPersisted?.();
34349
34428
  };
34429
+ let outputContract = null;
34430
+ let inputValidationError;
34431
+ try {
34432
+ this.validateImmutableSelection(jobInput);
34433
+ outputContract = parseOutputContract(jobInput);
34434
+ } catch (error48) {
34435
+ inputValidationError = error48;
34436
+ }
34350
34437
  if (attemptReceipt.phase === "claimed") {
34351
34438
  const attemptDeadlineAtMs = Math.min(
34352
34439
  Date.parse(claim.deadline_at),
@@ -34357,6 +34444,7 @@ var init_runner = __esm({
34357
34444
  return "failed";
34358
34445
  }
34359
34446
  let startResult;
34447
+ const startCallStartedAtMs = now();
34360
34448
  try {
34361
34449
  startResult = await retryExact(() => mcp.callTool(
34362
34450
  "inference.job.start",
@@ -34364,6 +34452,16 @@ var init_runner = __esm({
34364
34452
  { signal, deadlineAtMs: attemptDeadlineAtMs }
34365
34453
  ), { signal, deadlineAtMs: attemptDeadlineAtMs });
34366
34454
  } catch (error48) {
34455
+ if (error48 instanceof ExternalInferenceMcpError && error48.serverFailureCode === "server_account_context_expired_before_provider_dispatch") {
34456
+ await removeAttempt();
34457
+ options.onAttemptOutcome?.({
34458
+ outcome: "freshness_rejected_before_provider_dispatch",
34459
+ failure_category: "freshness",
34460
+ failure_code: error48.serverFailureCode,
34461
+ dispatch_outcome: "not_dispatched"
34462
+ });
34463
+ return "failed";
34464
+ }
34367
34465
  if (attemptDeadlineAtMs <= now() + MIN_CLAIM_START_WINDOW_MS) {
34368
34466
  await removeAttempt();
34369
34467
  return "failed";
@@ -34395,11 +34493,37 @@ var init_runner = __esm({
34395
34493
  retry_count: retryCount,
34396
34494
  next_delay_ms: retryDelayMs
34397
34495
  });
34496
+ if (!options.resumeReceipt) {
34497
+ await persistAttempt({ phase: "claimed" }, true);
34498
+ }
34398
34499
  await options.sleep(retryDelayMs, signal);
34399
34500
  return "retry_claimed";
34400
34501
  }
34401
34502
  assertStartResult(startRequest, startResult);
34402
- await updateAttempt({ phase: "started" });
34503
+ if (serverProviderDispatchDeadlineMs !== void 0) {
34504
+ const serverRemaining = startResult.provider_dispatch_freshness_remaining_ms;
34505
+ if (!Number.isSafeInteger(serverRemaining) || Number(serverRemaining) < 0) {
34506
+ throw new InferenceHostRunnerError(
34507
+ "provider_dispatch_freshness_receipt_invalid",
34508
+ "The Server provider-dispatch freshness receipt is unavailable."
34509
+ );
34510
+ }
34511
+ const startCallCompletedAtMs = now();
34512
+ startRoundTripMs = Math.max(0, startCallCompletedAtMs - startCallStartedAtMs);
34513
+ serverReportedFreshnessRemainingMs = Number(serverRemaining);
34514
+ const conservativeRemainingMs = Math.max(
34515
+ 0,
34516
+ serverReportedFreshnessRemainingMs - startRoundTripMs
34517
+ );
34518
+ providerDispatchNotAfterMs = startCallCompletedAtMs + conservativeRemainingMs;
34519
+ }
34520
+ }
34521
+ if (attemptReceipt.phase !== "dispatched") {
34522
+ const providerDispatchable = inputValidationError === void 0 && outputContract !== null;
34523
+ await persistAttempt({
34524
+ phase: providerDispatchable ? "dispatched" : "started",
34525
+ dispatch_outcome: providerDispatchable ? "outcome_unknown" : "not_dispatched"
34526
+ }, !options.resumeReceipt);
34403
34527
  }
34404
34528
  let adapterResult;
34405
34529
  let heartbeatFailure;
@@ -34432,7 +34556,7 @@ var init_runner = __esm({
34432
34556
  sequence,
34433
34557
  observed_at: isoAt(now())
34434
34558
  };
34435
- await updateAttempt({ job_heartbeat_sequence: sequence });
34559
+ await persistAttempt({ job_heartbeat_sequence: sequence });
34436
34560
  const heartbeatDeadlineAtMs = Date.parse(claim.deadline_at);
34437
34561
  const directive = await retryExact(
34438
34562
  () => mcp.callTool(
@@ -34466,12 +34590,13 @@ var init_runner = __esm({
34466
34590
  await heartbeatLoop;
34467
34591
  };
34468
34592
  try {
34469
- this.validateImmutableSelection(jobInput);
34470
- const outputContract = parseOutputContract(jobInput);
34471
- await updateAttempt({
34472
- phase: "dispatched",
34473
- dispatch_outcome: "outcome_unknown"
34474
- });
34593
+ if (inputValidationError !== void 0) throw inputValidationError;
34594
+ if (outputContract === null) {
34595
+ throw new InferenceHostRunnerError(
34596
+ "invalid_output_schema",
34597
+ "The external inference output contract is unavailable."
34598
+ );
34599
+ }
34475
34600
  if (options.resumeReceipt?.phase === "dispatched" && !sameAttemptRecovery) {
34476
34601
  throw new CodexAppServerError({
34477
34602
  message: `${adapterId} cannot prove the exact result of the interrupted attempt.`,
@@ -34490,9 +34615,24 @@ var init_runner = __esm({
34490
34615
  requestedModel: jobInput.requested_model,
34491
34616
  requestedReasoningEffort: jobInput.requested_reasoning_effort,
34492
34617
  deadlineAtMs: Date.parse(jobInput.deadline_at),
34618
+ ...providerDispatchNotAfterMs === void 0 ? {} : { providerDispatchNotAfterMs },
34619
+ ...providerDispatchNotAfterMs === void 0 ? {} : {
34620
+ onProviderDispatch: () => {
34621
+ providerDispatchFreshnessRemainingMs = Math.max(
34622
+ 0,
34623
+ providerDispatchNotAfterMs - now()
34624
+ );
34625
+ options.onProviderDispatch?.({
34626
+ cycle_id: jobInput.runtime_binding?.cycle_id ?? "unavailable",
34627
+ freshness_remaining_ms: providerDispatchFreshnessRemainingMs,
34628
+ server_reported_remaining_ms: serverReportedFreshnessRemainingMs ?? 0,
34629
+ start_round_trip_ms: startRoundTripMs
34630
+ });
34631
+ }
34632
+ },
34493
34633
  signal: attemptAbort.signal
34494
34634
  });
34495
- await updateAttempt({
34635
+ await persistAttempt({
34496
34636
  phase: "dispatched",
34497
34637
  dispatch_outcome: "confirmed_dispatched"
34498
34638
  });
@@ -34598,6 +34738,7 @@ var init_runner = __esm({
34598
34738
  },
34599
34739
  latency_ms: adapterResult.latencyMs,
34600
34740
  time_to_first_token_ms: adapterResult.timeToFirstTokenMs,
34741
+ provider_dispatch_freshness_remaining_ms: providerDispatchFreshnessRemainingMs,
34601
34742
  finish_reason: finishReason,
34602
34743
  refusal_status: refusalStatus,
34603
34744
  completed_at: isoAt(now())
@@ -34611,7 +34752,7 @@ var init_runner = __esm({
34611
34752
  response_mode: "decision_candidate",
34612
34753
  decision_candidate_sha256: resultEnvelope.plaintext_sha256
34613
34754
  });
34614
- await updateAttempt({
34755
+ await persistAttempt({
34615
34756
  phase: "terminal_pending",
34616
34757
  terminal_operation_id: completionId,
34617
34758
  terminal_request: completion
@@ -34683,7 +34824,7 @@ var init_runner = __esm({
34683
34824
  effectiveEffort: adapterResult?.effectiveReasoningEffort ?? classified.effectiveEffort
34684
34825
  } : classified;
34685
34826
  const dispatchOutcome = heartbeatAmbiguous ? "outcome_unknown" : error48 instanceof CodexAppServerError ? error48.dispatchOutcome : failure.dispatchOutcome;
34686
- await updateAttempt({
34827
+ await persistAttempt({
34687
34828
  phase: dispatchOutcome === "not_dispatched" ? "started" : "dispatched",
34688
34829
  dispatch_outcome: dispatchOutcome
34689
34830
  });
@@ -34727,6 +34868,7 @@ var init_runner = __esm({
34727
34868
  failure_category: failure.category,
34728
34869
  failure_code: failure.code,
34729
34870
  retryable: failure.retryable,
34871
+ provider_dispatch_freshness_remaining_ms: providerDispatchFreshnessRemainingMs,
34730
34872
  ...processExit ? { process_exit: processExit } : {},
34731
34873
  membership_disposition: membershipFailureDisposition({
34732
34874
  ...failure,
@@ -34734,7 +34876,7 @@ var init_runner = __esm({
34734
34876
  }),
34735
34877
  failed_at: isoAt(now())
34736
34878
  });
34737
- await updateAttempt({
34879
+ await persistAttempt({
34738
34880
  phase: "terminal_pending",
34739
34881
  terminal_operation_id: failureId,
34740
34882
  terminal_request: failureRequest
@@ -37494,6 +37636,7 @@ Durable service:
37494
37636
  codexModelCapabilities: options.codexModelCapabilities,
37495
37637
  protocolVersion: EXTERNAL_INFERENCE_CONTRACT_VERSION,
37496
37638
  adapterRuntimeVersion: INFERENCE_HOST_CLI_VERSION,
37639
+ hostRuntimeVersion: INFERENCE_HOST_CLI_VERSION,
37497
37640
  maxConcurrency: options.maxConcurrency,
37498
37641
  once: options.once,
37499
37642
  emitDiagnosticEvent: options.emitDiagnosticEvent,
@@ -37549,6 +37692,7 @@ Durable service:
37549
37692
  codexModelCapabilities: options.preflight.modelCapabilities,
37550
37693
  protocolVersion: EXTERNAL_INFERENCE_CONTRACT_VERSION,
37551
37694
  adapterRuntimeVersion: options.preflight.runtimeVersion,
37695
+ hostRuntimeVersion: INFERENCE_HOST_CLI_VERSION,
37552
37696
  maxConcurrency: options.maxConcurrency,
37553
37697
  once: options.once,
37554
37698
  emitDiagnosticEvent: options.emitDiagnosticEvent,
@@ -43421,8 +43565,142 @@ var init_local_breadcrumbs = __esm({
43421
43565
  }
43422
43566
  });
43423
43567
 
43568
+ // lib/api/shared.ts
43569
+ function getProfileHeaders(baseHeaders = {}, explicitProfileId) {
43570
+ const headers = { ...baseHeaders };
43571
+ const profileId = explicitProfileId !== void 0 ? explicitProfileId : activeProfileId;
43572
+ if (profileId) headers["x-profile-id"] = profileId.toString();
43573
+ return headers;
43574
+ }
43575
+ var getApiUrl, API_URL, sleep2, isTransientNetworkFetchError, createIdempotencyKey, getErrorMessage, getErrorPayloadOrEmpty, getErrorPayloadOrFallbackDetail, getErrorMessageFromResponse, activeProfileId, PROFILE_STORAGE_KEY;
43576
+ var init_shared = __esm({
43577
+ "lib/api/shared.ts"() {
43578
+ "use strict";
43579
+ init_abort();
43580
+ getApiUrl = () => {
43581
+ if (typeof window === "undefined") {
43582
+ return process.env.API_URL_SERVER || process.env.NEXT_PUBLIC_API_URL || "http://api:8000";
43583
+ }
43584
+ if (process.env.NODE_ENV === "development") {
43585
+ const hostname3 = window.location.hostname;
43586
+ const isLocalNetworkIP = hostname3.startsWith("192.168.") || hostname3.startsWith("10.") || hostname3.startsWith("172.") && parseInt(hostname3.split(".")[1]) >= 16 && parseInt(hostname3.split(".")[1]) <= 31;
43587
+ if (isLocalNetworkIP) {
43588
+ return `http://${hostname3}:8000`;
43589
+ }
43590
+ if (hostname3 === "localhost" || hostname3 === "127.0.0.1") {
43591
+ return `http://${hostname3}:8000`;
43592
+ }
43593
+ }
43594
+ if (process.env.NEXT_PUBLIC_API_URL) {
43595
+ return process.env.NEXT_PUBLIC_API_URL;
43596
+ }
43597
+ try {
43598
+ const hostname3 = window.location.hostname;
43599
+ const protocol = window.location.protocol;
43600
+ const baseHost = hostname3.startsWith("www.") ? hostname3.slice(4) : hostname3;
43601
+ const apiHost = baseHost.startsWith("api.") ? baseHost : `api.${baseHost}`;
43602
+ return `${protocol}//${apiHost}`;
43603
+ } catch {
43604
+ return "http://localhost:8000";
43605
+ }
43606
+ };
43607
+ API_URL = getApiUrl();
43608
+ sleep2 = (ms) => new Promise((resolve6) => setTimeout(resolve6, ms));
43609
+ isTransientNetworkFetchError = (error48) => {
43610
+ const message = error48 instanceof Error ? error48.message : String(error48 || "");
43611
+ const normalized = message.toLowerCase();
43612
+ return message === "Failed to fetch" || message === "TypeError: Failed to fetch" || normalized.includes("network error") || normalized.includes("failed to fetch");
43613
+ };
43614
+ createIdempotencyKey = (action) => {
43615
+ const suffix = typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}`;
43616
+ return `web-${action}-${suffix}`;
43617
+ };
43618
+ getErrorMessage = (error48, defaultMessage) => {
43619
+ const extractRateLimitMessage = (raw) => {
43620
+ if (!/rate\s*limit|429|cooling\s*down/i.test(raw)) return null;
43621
+ const match = raw.match(/cooling\s*down\s*for\s*([0-9]+(?:\.[0-9]+)?)s/i);
43622
+ return match ? `Hyperliquid is rate-limited. Please retry in ~${match[1]}s.` : "Hyperliquid is rate-limited. Please wait a moment and retry.";
43623
+ };
43624
+ if (error48?.message === "Failed to fetch" || error48?.message === "TypeError: Failed to fetch" || error48?.message?.includes("network error")) {
43625
+ return "Network error. Please check your connection.";
43626
+ }
43627
+ const fromMessage = extractRateLimitMessage(String(error48?.message || ""));
43628
+ if (fromMessage) return fromMessage;
43629
+ if (error48?.detail) {
43630
+ const fromDetail = extractRateLimitMessage(String(error48.detail));
43631
+ if (fromDetail) return fromDetail;
43632
+ if (Array.isArray(error48.detail)) {
43633
+ return error48.detail.map((item) => `${item.loc ? item.loc.join(".") : "Field"}: ${item.msg}`).join(", ");
43634
+ }
43635
+ if (typeof error48.detail === "object") {
43636
+ const detailMessage = error48.detail.message;
43637
+ if (typeof detailMessage === "string" && detailMessage.trim()) return detailMessage;
43638
+ }
43639
+ return typeof error48.detail === "string" ? error48.detail : JSON.stringify(error48.detail);
43640
+ }
43641
+ return defaultMessage;
43642
+ };
43643
+ getErrorPayloadOrEmpty = async (response) => response.json().catch(() => ({}));
43644
+ getErrorPayloadOrFallbackDetail = async (response, fallbackDetail) => response.json().catch(() => ({ detail: fallbackDetail }));
43645
+ getErrorMessageFromResponse = async (response, defaultMessage, options) => {
43646
+ const error48 = options?.fallbackDetail ? await getErrorPayloadOrFallbackDetail(response, defaultMessage) : await getErrorPayloadOrEmpty(response);
43647
+ return getErrorMessage(error48, defaultMessage);
43648
+ };
43649
+ activeProfileId = null;
43650
+ PROFILE_STORAGE_KEY = "vtx_active_profile_id";
43651
+ if (typeof window !== "undefined") {
43652
+ const stored = sessionStorage.getItem(PROFILE_STORAGE_KEY);
43653
+ if (stored) {
43654
+ const parsed = parseInt(stored, 10);
43655
+ if (Number.isFinite(parsed) && parsed > 0) activeProfileId = parsed;
43656
+ }
43657
+ }
43658
+ }
43659
+ });
43660
+
43661
+ // lib/api/billing.ts
43662
+ var init_billing = __esm({
43663
+ "lib/api/billing.ts"() {
43664
+ "use strict";
43665
+ init_shared();
43666
+ }
43667
+ });
43668
+
43669
+ // lib/api/market-data.ts
43670
+ async function getExecutionAssetMetadata(exchange, symbol2, options) {
43671
+ const params = new URLSearchParams();
43672
+ if (options?.includePrivateContext) params.set("include_private_context", "true");
43673
+ const query = params.size > 0 ? `?${params.toString()}` : "";
43674
+ const url2 = `${API_URL}/trading/execution-metadata/${encodeURIComponent(exchange)}/${encodeURIComponent(symbol2)}${query}`;
43675
+ const response = await fetch(url2, {
43676
+ headers: getProfileHeaders({}, options?.profileId),
43677
+ credentials: "include",
43678
+ cache: "no-store"
43679
+ });
43680
+ if (!response.ok) {
43681
+ throw new Error(`Failed to fetch execution asset metadata: ${response.status} ${response.statusText}`);
43682
+ }
43683
+ return response.json();
43684
+ }
43685
+ var init_market_data = __esm({
43686
+ "lib/api/market-data.ts"() {
43687
+ "use strict";
43688
+ init_abort();
43689
+ init_network_debug();
43690
+ init_shared();
43691
+ }
43692
+ });
43693
+
43694
+ // lib/api/screener.ts
43695
+ var init_screener = __esm({
43696
+ "lib/api/screener.ts"() {
43697
+ "use strict";
43698
+ init_shared();
43699
+ }
43700
+ });
43701
+
43424
43702
  // lib/runtime/server-runtime-lease.ts
43425
- var CLIENT_RUNTIME_SERVER_LEASE_STORAGE_KEY, canUseStorage, normalizeProfileId, parseLeaseRecord, readPersistedLeaseMap, writePersistedLeaseMap, isLeaseExpired, getPersistedClientRuntimeServerLease, persistExistingClientRuntimeServerLease, persistClientRuntimeServerLease, clearPersistedClientRuntimeServerLease;
43703
+ var CLIENT_RUNTIME_SERVER_LEASE_STORAGE_KEY, canUseStorage, normalizeProfileId, normalizeLeaseGeneration, parseLeaseRecord, readPersistedLeaseMap, writePersistedLeaseMap, isLeaseExpired, getPersistedClientRuntimeServerLease, persistExistingClientRuntimeServerLease, persistClientRuntimeServerLease, clearPersistedClientRuntimeServerLease;
43426
43704
  var init_server_runtime_lease = __esm({
43427
43705
  "lib/runtime/server-runtime-lease.ts"() {
43428
43706
  "use strict";
@@ -43431,6 +43709,10 @@ var init_server_runtime_lease = __esm({
43431
43709
  normalizeProfileId = (profileId) => {
43432
43710
  return String(profileId ?? "").trim();
43433
43711
  };
43712
+ normalizeLeaseGeneration = (value) => {
43713
+ const generation = Number(value);
43714
+ return Number.isSafeInteger(generation) && generation > 0 ? generation : null;
43715
+ };
43434
43716
  parseLeaseRecord = (value, profileId) => {
43435
43717
  if (!value || typeof value !== "object" || Array.isArray(value)) {
43436
43718
  return null;
@@ -43475,8 +43757,10 @@ var init_server_runtime_lease = __esm({
43475
43757
  leaseId: String(record2.leaseId),
43476
43758
  runtimeSessionId: String(record2.runtimeSessionId),
43477
43759
  deviceId: String(record2.deviceId),
43760
+ schedulerInstanceId: String(record2.schedulerInstanceId ?? "").trim() || null,
43478
43761
  mode: record2.mode,
43479
43762
  scope: "trade-runtime",
43763
+ leaseGeneration: normalizeLeaseGeneration(record2.leaseGeneration),
43480
43764
  issuedAt: String(record2.issuedAt),
43481
43765
  expiresAt: String(record2.expiresAt),
43482
43766
  renewableUntil: String(record2.renewableUntil),
@@ -43579,8 +43863,10 @@ var init_server_runtime_lease = __esm({
43579
43863
  leaseId: String(lease.lease_id),
43580
43864
  runtimeSessionId: String(lease.runtime_session_id),
43581
43865
  deviceId: String(lease.device_id),
43866
+ schedulerInstanceId: String(lease.scheduler_instance_id ?? "").trim() || null,
43582
43867
  mode: lease.mode,
43583
43868
  scope: "trade-runtime",
43869
+ leaseGeneration: normalizeLeaseGeneration(lease.lease_generation),
43584
43870
  issuedAt: String(lease.issued_at),
43585
43871
  expiresAt: String(lease.expires_at),
43586
43872
  renewableUntil: String(lease.renewable_until),
@@ -43592,6 +43878,21 @@ var init_server_runtime_lease = __esm({
43592
43878
  savedAt: Date.now()
43593
43879
  };
43594
43880
  const leaseMap = readPersistedLeaseMap();
43881
+ const existingLease = leaseMap[profileId] ?? null;
43882
+ if (existingLease && record2.leaseId !== existingLease.leaseId) {
43883
+ const incomingGeneration = record2.leaseGeneration ?? null;
43884
+ const existingGeneration = existingLease.leaseGeneration ?? null;
43885
+ if (existingGeneration !== null && incomingGeneration === null || existingGeneration !== null && incomingGeneration !== null && incomingGeneration <= existingGeneration) {
43886
+ return existingLease;
43887
+ }
43888
+ if (existingGeneration === null && incomingGeneration === null) {
43889
+ const incomingIssuedAtMs = Date.parse(record2.issuedAt);
43890
+ const existingIssuedAtMs = Date.parse(existingLease.issuedAt);
43891
+ if (Number.isFinite(incomingIssuedAtMs) && Number.isFinite(existingIssuedAtMs) && incomingIssuedAtMs < existingIssuedAtMs) {
43892
+ return existingLease;
43893
+ }
43894
+ }
43895
+ }
43595
43896
  leaseMap[profileId] = record2;
43596
43897
  writePersistedLeaseMap(leaseMap);
43597
43898
  return record2;
@@ -43613,31 +43914,6 @@ var init_server_runtime_lease = __esm({
43613
43914
  });
43614
43915
 
43615
43916
  // lib/api.ts
43616
- async function getExecutionAssetMetadata(exchange, symbol2, options) {
43617
- const params = new URLSearchParams();
43618
- if (options?.includePrivateContext) {
43619
- params.set("include_private_context", "true");
43620
- }
43621
- const query = params.size > 0 ? `?${params.toString()}` : "";
43622
- const url2 = `${API_URL}/trading/execution-metadata/${encodeURIComponent(exchange)}/${encodeURIComponent(symbol2)}${query}`;
43623
- const response = await fetch(url2, {
43624
- headers: getProfileHeaders({}, options?.profileId),
43625
- credentials: "include",
43626
- cache: "no-store"
43627
- });
43628
- if (!response.ok) {
43629
- throw new Error(`Failed to fetch execution asset metadata: ${response.status} ${response.statusText}`);
43630
- }
43631
- return response.json();
43632
- }
43633
- function getProfileHeaders(baseHeaders = {}, explicitProfileId) {
43634
- const headers = { ...baseHeaders };
43635
- const pid = explicitProfileId !== void 0 ? explicitProfileId : _activeProfileId;
43636
- if (pid) {
43637
- headers["x-profile-id"] = pid.toString();
43638
- }
43639
- return headers;
43640
- }
43641
43917
  async function getClientRuntimeSecrets(profileId, options) {
43642
43918
  const params = new URLSearchParams();
43643
43919
  if (options?.activeProvider) {
@@ -43683,7 +43959,9 @@ async function postClientRuntime(path, profileId, body, options) {
43683
43959
  const signal = options?.signal;
43684
43960
  const parsedRequestTimeoutMs = Number(options?.requestTimeoutMs);
43685
43961
  const requestTimeoutMs = Number.isFinite(parsedRequestTimeoutMs) && parsedRequestTimeoutMs > 0 ? Math.round(parsedRequestTimeoutMs) : null;
43686
- const maxAttempts = keepalive ? 1 : 3;
43962
+ const parsedDeadlineAtMs = Number(options?.deadlineAtMs);
43963
+ const deadlineAtMs = path === "/runtime/decision" && Number.isFinite(parsedDeadlineAtMs) && parsedDeadlineAtMs > 0 ? Math.round(parsedDeadlineAtMs) : null;
43964
+ let maxAttempts = keepalive ? 1 : deadlineAtMs === null ? 3 : Math.max(3, Math.ceil(Math.max(0, deadlineAtMs - Date.now()) / 250) + 1);
43687
43965
  const requestContext = parseClientRuntimeRequestContext(body);
43688
43966
  const explicitIdempotencyKey = String(options?.idempotencyKey ?? "").trim();
43689
43967
  const idempotencyKey = shouldAttachRuntimeIdempotencyKey(path) ? explicitIdempotencyKey || createIdempotencyKey(`runtime-${path.replace(/\//g, "-")}`) : null;
@@ -43695,19 +43973,64 @@ async function postClientRuntime(path, profileId, body, options) {
43695
43973
  options?.runtimeLeaseToken,
43696
43974
  options?.omitRuntimeLeaseToken
43697
43975
  );
43976
+ const resolvedSchedulerInstanceId = String(
43977
+ options?.schedulerInstanceId ?? requestContext.schedulerInstanceId ?? ""
43978
+ ).trim() || null;
43979
+ const persistedRuntimeLease = getPersistedClientRuntimeServerLease(numericProfileId);
43980
+ if (resolvedRuntimeLeaseToken && persistedRuntimeLease?.schedulerInstanceId && !resolvedSchedulerInstanceId) {
43981
+ resolvedRuntimeLeaseToken = void 0;
43982
+ }
43698
43983
  attachRuntimeLeaseHeader(requestHeaders, resolvedRuntimeLeaseToken);
43984
+ attachRuntimeSchedulerInstanceHeader(
43985
+ requestHeaders,
43986
+ resolvedSchedulerInstanceId
43987
+ );
43699
43988
  if (idempotencyKey) {
43700
43989
  requestHeaders["X-Idempotency-Key"] = idempotencyKey;
43701
43990
  }
43702
43991
  let lastNetworkError = null;
43703
43992
  let missingRuntimeLeaseRecoveryAttempted = false;
43993
+ let replacementLeaseRetryUsed = false;
43994
+ const deadlineError = (attempt, cause) => annotateRuntimeRequestError(
43995
+ Object.assign(
43996
+ new Error("Client runtime decision persistence deadline exceeded after the AI run completed."),
43997
+ cause && (typeof cause === "object" || typeof cause === "function") ? { cause } : {}
43998
+ ),
43999
+ {
44000
+ path,
44001
+ method: "POST",
44002
+ attempt,
44003
+ maxAttempts: null,
44004
+ status: Number.isFinite(Number(cause?.status)) ? Number(cause.status) : null,
44005
+ keepalive,
44006
+ hadRuntimeLeaseToken: Boolean(resolvedRuntimeLeaseToken),
44007
+ deadlineAtMs,
44008
+ deadlineExceeded: true
44009
+ }
44010
+ );
44011
+ const waitBeforeRetry = async (delayMs, attempt, cause) => {
44012
+ if (deadlineAtMs === null) {
44013
+ await sleep2(delayMs);
44014
+ return;
44015
+ }
44016
+ const remainingMs = deadlineAtMs - Date.now();
44017
+ if (remainingMs <= delayMs) {
44018
+ throw deadlineError(attempt, cause);
44019
+ }
44020
+ await sleep2(delayMs);
44021
+ };
43704
44022
  for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
44023
+ const deadlineRemainingMs = deadlineAtMs === null ? null : deadlineAtMs - Date.now();
44024
+ if (deadlineRemainingMs !== null && deadlineRemainingMs <= 0) {
44025
+ throw deadlineError(Math.max(0, attempt - 1), lastNetworkError);
44026
+ }
43705
44027
  let response = null;
43706
44028
  let requestTimedOut = false;
43707
44029
  let timeoutId = null;
43708
44030
  let relayCallerAbort = null;
43709
44031
  let requestSignal = signal;
43710
- if (requestTimeoutMs !== null) {
44032
+ const attemptTimeoutMs = deadlineRemainingMs === null ? requestTimeoutMs : requestTimeoutMs === null ? deadlineRemainingMs : Math.min(requestTimeoutMs, deadlineRemainingMs);
44033
+ if (attemptTimeoutMs !== null) {
43711
44034
  const timeoutController = new AbortController();
43712
44035
  relayCallerAbort = () => timeoutController.abort(signal?.reason);
43713
44036
  if (signal?.aborted) {
@@ -43718,7 +44041,7 @@ async function postClientRuntime(path, profileId, body, options) {
43718
44041
  timeoutId = globalThis.setTimeout(() => {
43719
44042
  requestTimedOut = true;
43720
44043
  timeoutController.abort(new DOMException("Runtime request timeout reached.", "TimeoutError"));
43721
- }, requestTimeoutMs);
44044
+ }, Math.max(1, attemptTimeoutMs));
43722
44045
  requestSignal = timeoutController.signal;
43723
44046
  }
43724
44047
  const trace = startRuntimeNetworkDebugTrace({
@@ -43752,19 +44075,41 @@ async function postClientRuntime(path, profileId, body, options) {
43752
44075
  continue;
43753
44076
  }
43754
44077
  }
43755
- const shouldClearLease = Boolean(
44078
+ const leaseInvalidatingError = Boolean(
43756
44079
  resolvedRuntimeLeaseToken && shouldClearPersistedRuntimeLeaseOnError(response.status, error48.message)
43757
44080
  );
43758
- if (shouldClearLease) {
43759
- clearPersistedClientRuntimeServerLease(numericProfileId);
44081
+ let leaseCleared = false;
44082
+ if (leaseInvalidatingError) {
44083
+ const currentLease = getPersistedClientRuntimeServerLease(numericProfileId);
44084
+ const replacementLeaseToken = currentLease?.runtimeSessionId === requestContext.sessionId && currentLease.deviceId === requestContext.deviceId && currentLease.mode === (requestContext.mode ?? "trader") && currentLease.runtimeLeaseToken !== resolvedRuntimeLeaseToken ? currentLease.runtimeLeaseToken : null;
44085
+ if (replacementLeaseToken) {
44086
+ resolvedRuntimeLeaseToken = replacementLeaseToken;
44087
+ attachRuntimeLeaseHeader(requestHeaders, resolvedRuntimeLeaseToken);
44088
+ if (attempt >= maxAttempts && !replacementLeaseRetryUsed) {
44089
+ replacementLeaseRetryUsed = true;
44090
+ maxAttempts += 1;
44091
+ }
44092
+ if (attempt >= maxAttempts) {
44093
+ throw error48;
44094
+ }
44095
+ continue;
44096
+ }
44097
+ if (currentLease?.runtimeLeaseToken === resolvedRuntimeLeaseToken) {
44098
+ clearPersistedClientRuntimeServerLease(numericProfileId);
44099
+ leaseCleared = true;
44100
+ }
43760
44101
  }
43761
44102
  recordRuntimeAuthFailureBreadcrumb(path, numericProfileId, requestContext, response.status, error48.message, {
43762
44103
  keepalive,
43763
44104
  hadRuntimeLeaseToken: Boolean(resolvedRuntimeLeaseToken),
43764
- leaseCleared: shouldClearLease
44105
+ leaseCleared
43765
44106
  });
43766
- if (!keepalive && attempt < maxAttempts && !shouldClearLease && (shouldRetryClientRuntimeHttpStatus(path, response.status) || isRuntimeIdempotencyInProgressError(response.status, error48.message) || Boolean(idempotencyKey) && isRetryableRuntimeConflictError(response.status, error48))) {
43767
- await sleep2(resolveClientRuntimeRetryDelayMs(attempt, response.headers.get("Retry-After")));
44107
+ if (!keepalive && attempt < maxAttempts && !leaseInvalidatingError && (shouldRetryClientRuntimeHttpStatus(path, response.status) || isRuntimeIdempotencyInProgressError(response.status, error48.message) || Boolean(idempotencyKey) && isRetryableRuntimeConflictError(response.status, error48))) {
44108
+ await waitBeforeRetry(
44109
+ resolveClientRuntimeRetryDelayMs(attempt, response.headers.get("Retry-After")),
44110
+ attempt,
44111
+ error48
44112
+ );
43768
44113
  continue;
43769
44114
  }
43770
44115
  throw error48;
@@ -43781,18 +44126,26 @@ async function postClientRuntime(path, profileId, body, options) {
43781
44126
  const requestError = requestTimedOut && !signal?.aborted ? new TypeError("Runtime request timeout reached.") : error48;
43782
44127
  lastNetworkError = requestError;
43783
44128
  trace.completeError(requestError, response?.status ?? null);
44129
+ if (deadlineAtMs !== null && Date.now() >= deadlineAtMs) {
44130
+ throw deadlineError(attempt, requestError);
44131
+ }
43784
44132
  if (signal?.aborted || !requestTimedOut && !isTransientNetworkFetchError(requestError) || attempt >= maxAttempts) {
43785
44133
  throw annotateRuntimeRequestError(requestError, {
43786
44134
  path,
43787
44135
  method: "POST",
43788
44136
  attempt,
43789
- maxAttempts,
44137
+ maxAttempts: deadlineAtMs === null ? maxAttempts : null,
43790
44138
  status: response?.status ?? null,
43791
44139
  keepalive,
43792
- hadRuntimeLeaseToken: Boolean(resolvedRuntimeLeaseToken)
44140
+ hadRuntimeLeaseToken: Boolean(resolvedRuntimeLeaseToken),
44141
+ deadlineAtMs
43793
44142
  });
43794
44143
  }
43795
- await sleep2(resolveClientRuntimeRetryDelayMs(attempt, null));
44144
+ await waitBeforeRetry(
44145
+ resolveClientRuntimeRetryDelayMs(attempt, null),
44146
+ attempt,
44147
+ requestError
44148
+ );
43796
44149
  continue;
43797
44150
  } finally {
43798
44151
  if (timeoutId !== null) {
@@ -43808,20 +44161,22 @@ async function postClientRuntime(path, profileId, body, options) {
43808
44161
  path,
43809
44162
  method: "POST",
43810
44163
  attempt: maxAttempts,
43811
- maxAttempts,
44164
+ maxAttempts: deadlineAtMs === null ? maxAttempts : null,
43812
44165
  status: Number.isFinite(Number(lastNetworkError.status)) ? Number(lastNetworkError.status) : null,
43813
44166
  keepalive,
43814
- hadRuntimeLeaseToken: Boolean(resolvedRuntimeLeaseToken)
44167
+ hadRuntimeLeaseToken: Boolean(resolvedRuntimeLeaseToken),
44168
+ deadlineAtMs
43815
44169
  });
43816
44170
  }
43817
44171
  throw new Error("Client runtime request failed");
43818
44172
  }
43819
- async function beginClientRuntimeExchangeMutation(profileId, payload, requiredRuntimeSessionId, explicitRuntimeLeaseToken, explicitRuntimeDeviceId) {
44173
+ async function beginClientRuntimeExchangeMutation(profileId, payload, requiredRuntimeSessionId, explicitRuntimeLeaseToken, explicitRuntimeDeviceId, explicitSchedulerInstanceId) {
43820
44174
  const authority = resolveClientExchangeMutationAuthority(
43821
44175
  profileId,
43822
44176
  requiredRuntimeSessionId,
43823
44177
  explicitRuntimeLeaseToken,
43824
- explicitRuntimeDeviceId
44178
+ explicitRuntimeDeviceId,
44179
+ explicitSchedulerInstanceId
43825
44180
  );
43826
44181
  const requestBegin = () => postClientRuntime(
43827
44182
  "/runtime/exchange-mutations/begin",
@@ -43902,12 +44257,13 @@ async function beginClientRuntimeExchangeMutation(profileId, payload, requiredRu
43902
44257
  }
43903
44258
  return result2;
43904
44259
  }
43905
- async function reportClientRuntimeExchangeAttemptTransition(profileId, mutationId, payload, signal, requiredRuntimeSessionId, explicitRuntimeLeaseToken, explicitRuntimeDeviceId) {
44260
+ async function reportClientRuntimeExchangeAttemptTransition(profileId, mutationId, payload, signal, requiredRuntimeSessionId, explicitRuntimeLeaseToken, explicitRuntimeDeviceId, explicitSchedulerInstanceId) {
43906
44261
  const authority = resolveClientExchangeMutationAuthority(
43907
44262
  profileId,
43908
44263
  requiredRuntimeSessionId,
43909
44264
  explicitRuntimeLeaseToken,
43910
- explicitRuntimeDeviceId
44265
+ explicitRuntimeDeviceId,
44266
+ explicitSchedulerInstanceId
43911
44267
  );
43912
44268
  return postClientRuntime(
43913
44269
  `/runtime/exchange-mutations/${encodeURIComponent(mutationId)}/attempt`,
@@ -43923,12 +44279,13 @@ async function reportClientRuntimeExchangeAttemptTransition(profileId, mutationI
43923
44279
  }
43924
44280
  );
43925
44281
  }
43926
- async function settleClientRuntimeExchangeMutation(profileId, mutationId, payload, requiredRuntimeSessionId, explicitRuntimeLeaseToken, explicitRuntimeDeviceId) {
44282
+ async function settleClientRuntimeExchangeMutation(profileId, mutationId, payload, requiredRuntimeSessionId, explicitRuntimeLeaseToken, explicitRuntimeDeviceId, explicitSchedulerInstanceId) {
43927
44283
  const authority = resolveClientExchangeMutationAuthority(
43928
44284
  profileId,
43929
44285
  requiredRuntimeSessionId,
43930
44286
  explicitRuntimeLeaseToken,
43931
- explicitRuntimeDeviceId
44287
+ explicitRuntimeDeviceId,
44288
+ explicitSchedulerInstanceId
43932
44289
  );
43933
44290
  try {
43934
44291
  const result2 = await postClientRuntime(
@@ -44003,7 +44360,7 @@ async function reconcileActiveClientRuntimeExchangeMutation(profileId, requestOp
44003
44360
  }
44004
44361
  return rememberCompletedDeferredClientRuntimeStop(profileId, result2);
44005
44362
  }
44006
- var getApiUrl, API_URL, sleep2, isTransientNetworkFetchError, createIdempotencyKey, getErrorMessage, getErrorPayloadOrEmpty, getErrorPayloadOrFallbackDetail, getErrorMessageFromResponse, _activeProfileId, PROFILE_STORAGE_KEY, preferencesWriteQueue, CLIENT_SUPPORTED_PROMPT_CONTRACT_VERSION, completedDeferredClientRuntimeStops, rememberCompletedDeferredClientRuntimeStop, toNumericProfileId, shouldAttachRuntimeIdempotencyKey, attachRuntimeLeaseHeader, resolveRuntimeLeaseToken, persistRuntimeLeaseFromPayload, persistRuntimeLeaseStatusMetadata, shouldClearPersistedRuntimeLeaseOnError, isMissingRuntimeLeaseError, createRuntimeRequestError, parseClientRuntimeRequestContext, recordRuntimeAuthFailureBreadcrumb, classifyRuntimeRequestError, annotateRuntimeRequestError, parseRuntimeRetryAfterMs, shouldRecoverMissingRuntimeLease, recoverMissingRuntimeLease, isRetryableClientRuntimeStatus, shouldRetryClientRuntimeHttpStatus, isRuntimeIdempotencyInProgressError, isRetryableRuntimeConflictError, resolveClientRuntimeRetryDelayMs, CLIENT_EXCHANGE_AUTHORITY_DEVICE_KEY, CLIENT_EXCHANGE_AUTHORITY_SESSION_KEY, getOrCreateClientExchangeAuthorityIdentity, resolveClientExchangeMutationAuthority, clientExchangeMutationAuthorityBody, isPendingClientExchangeMutationError, clientExchangeMutationReconciliationTimers, MAX_CLIENT_EXCHANGE_RECONCILIATION_DELAY_MS, CLIENT_EXCHANGE_RECONCILIATION_CLOCK_SKEW_MS, ClientExchangeMutationRebuildRequiredError, isTerminalClientExchangeMutation, clientExchangeMutationReconciliationKey, clearScheduledClientExchangeMutationReconciliation, snapshotClientExchangeMutationReconciliationAuthority, postClientExchangeMutationReconciliation, scheduleClientExchangeMutationReconciliation;
44363
+ var preferencesWriteQueue, CLIENT_SUPPORTED_PROMPT_CONTRACT_VERSION, completedDeferredClientRuntimeStops, rememberCompletedDeferredClientRuntimeStop, toNumericProfileId, shouldAttachRuntimeIdempotencyKey, attachRuntimeLeaseHeader, attachRuntimeSchedulerInstanceHeader, resolveRuntimeLeaseToken, persistRuntimeLeaseFromPayload, persistRuntimeLeaseStatusMetadata, shouldClearPersistedRuntimeLeaseOnError, isMissingRuntimeLeaseError, createRuntimeRequestError, parseClientRuntimeRequestContext, recordRuntimeAuthFailureBreadcrumb, classifyRuntimeRequestError, annotateRuntimeRequestError, parseRuntimeRetryAfterMs, shouldRecoverMissingRuntimeLease, runtimeLeaseRecoveries, recoverMissingRuntimeLeaseDirect, recoverMissingRuntimeLease, isRetryableClientRuntimeStatus, shouldRetryClientRuntimeHttpStatus, isRuntimeIdempotencyInProgressError, isRetryableRuntimeConflictError, resolveClientRuntimeRetryDelayMs, CLIENT_EXCHANGE_AUTHORITY_DEVICE_KEY, CLIENT_EXCHANGE_AUTHORITY_SESSION_KEY, getOrCreateClientExchangeAuthorityIdentity, resolveClientExchangeMutationAuthority, clientExchangeMutationAuthorityBody, isPendingClientExchangeMutationError, clientExchangeMutationReconciliationTimers, MAX_CLIENT_EXCHANGE_RECONCILIATION_DELAY_MS, CLIENT_EXCHANGE_RECONCILIATION_CLOCK_SKEW_MS, ClientExchangeMutationRebuildRequiredError, isTerminalClientExchangeMutation, clientExchangeMutationReconciliationKey, clearScheduledClientExchangeMutationReconciliation, snapshotClientExchangeMutationReconciliationAuthority, postClientExchangeMutationReconciliation, scheduleClientExchangeMutationReconciliation;
44007
44364
  var init_api2 = __esm({
44008
44365
  "lib/api.ts"() {
44009
44366
  "use strict";
@@ -44019,99 +44376,12 @@ var init_api2 = __esm({
44019
44376
  init_network_debug();
44020
44377
  init_local_breadcrumbs();
44021
44378
  init_abort();
44379
+ init_shared();
44380
+ init_shared();
44381
+ init_billing();
44382
+ init_market_data();
44383
+ init_screener();
44022
44384
  init_server_runtime_lease();
44023
- getApiUrl = () => {
44024
- if (typeof window === "undefined") {
44025
- return process.env.API_URL_SERVER || process.env.NEXT_PUBLIC_API_URL || "http://api:8000";
44026
- }
44027
- if (process.env.NODE_ENV === "development") {
44028
- const hostname3 = window.location.hostname;
44029
- const isLocalNetworkIP = hostname3.startsWith("192.168.") || hostname3.startsWith("10.") || hostname3.startsWith("172.") && parseInt(hostname3.split(".")[1]) >= 16 && parseInt(hostname3.split(".")[1]) <= 31;
44030
- if (isLocalNetworkIP) {
44031
- return `http://${hostname3}:8000`;
44032
- }
44033
- if (hostname3 === "localhost" || hostname3 === "127.0.0.1") {
44034
- return `http://${hostname3}:8000`;
44035
- }
44036
- }
44037
- if (process.env.NEXT_PUBLIC_API_URL) {
44038
- return process.env.NEXT_PUBLIC_API_URL;
44039
- }
44040
- try {
44041
- const hostname3 = window.location.hostname;
44042
- const protocol = window.location.protocol;
44043
- const baseHost = hostname3.startsWith("www.") ? hostname3.slice(4) : hostname3;
44044
- const apiHost = baseHost.startsWith("api.") ? baseHost : `api.${baseHost}`;
44045
- return `${protocol}//${apiHost}`;
44046
- } catch {
44047
- return "http://localhost:8000";
44048
- }
44049
- };
44050
- API_URL = getApiUrl();
44051
- sleep2 = (ms) => new Promise((resolve6) => setTimeout(resolve6, ms));
44052
- isTransientNetworkFetchError = (error48) => {
44053
- const message = error48 instanceof Error ? error48.message : String(error48 || "");
44054
- const normalized = message.toLowerCase();
44055
- return message === "Failed to fetch" || message === "TypeError: Failed to fetch" || normalized.includes("network error") || normalized.includes("failed to fetch");
44056
- };
44057
- createIdempotencyKey = (action) => {
44058
- const suffix = typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}`;
44059
- return `web-${action}-${suffix}`;
44060
- };
44061
- getErrorMessage = (error48, defaultMessage) => {
44062
- const extractRateLimitMessage = (raw) => {
44063
- if (!/rate\s*limit|429|cooling\s*down/i.test(raw)) return null;
44064
- const cooldownMatch = raw.match(/cooling\s*down\s*for\s*([0-9]+(?:\.[0-9]+)?)s/i);
44065
- if (cooldownMatch) {
44066
- return `Hyperliquid is rate-limited. Please retry in ~${cooldownMatch[1]}s.`;
44067
- }
44068
- return "Hyperliquid is rate-limited. Please wait a moment and retry.";
44069
- };
44070
- if (error48?.message === "Failed to fetch" || error48?.message === "TypeError: Failed to fetch" || error48?.message?.includes("network error")) {
44071
- return "Network error. Please check your connection.";
44072
- }
44073
- const fromMessage = extractRateLimitMessage(String(error48?.message || ""));
44074
- if (fromMessage) return fromMessage;
44075
- if (error48?.detail) {
44076
- const fromDetail = extractRateLimitMessage(String(error48.detail));
44077
- if (fromDetail) return fromDetail;
44078
- if (Array.isArray(error48.detail)) {
44079
- return error48.detail.map((err) => {
44080
- const field = err.loc ? err.loc.join(".") : "Field";
44081
- return `${field}: ${err.msg}`;
44082
- }).join(", ");
44083
- }
44084
- if (typeof error48.detail === "object") {
44085
- const detailMessage = error48.detail.message;
44086
- if (typeof detailMessage === "string" && detailMessage.trim()) {
44087
- return detailMessage;
44088
- }
44089
- }
44090
- return typeof error48.detail === "string" ? error48.detail : JSON.stringify(error48.detail);
44091
- }
44092
- return defaultMessage;
44093
- };
44094
- getErrorPayloadOrEmpty = async (response) => {
44095
- return response.json().catch(() => ({}));
44096
- };
44097
- getErrorPayloadOrFallbackDetail = async (response, fallbackDetail) => {
44098
- return response.json().catch(() => ({ detail: fallbackDetail }));
44099
- };
44100
- getErrorMessageFromResponse = async (response, defaultMessage, options) => {
44101
- const error48 = options?.fallbackDetail ? await getErrorPayloadOrFallbackDetail(response, defaultMessage) : await getErrorPayloadOrEmpty(response);
44102
- return getErrorMessage(error48, defaultMessage);
44103
- };
44104
- _activeProfileId = null;
44105
- PROFILE_STORAGE_KEY = "vtx_active_profile_id";
44106
- if (typeof window !== "undefined") {
44107
- const stored = sessionStorage.getItem(PROFILE_STORAGE_KEY);
44108
- if (stored) {
44109
- const parsed = parseInt(stored, 10);
44110
- if (Number.isFinite(parsed) && parsed > 0) {
44111
- _activeProfileId = parsed;
44112
- }
44113
- }
44114
- }
44115
44385
  preferencesWriteQueue = Promise.resolve();
44116
44386
  CLIENT_SUPPORTED_PROMPT_CONTRACT_VERSION = String(
44117
44387
  process.env.NEXT_PUBLIC_CLIENT_RUNTIME_PROMPT_CONTRACT_VERSION || "2026-08-24.1"
@@ -44140,6 +44410,13 @@ var init_api2 = __esm({
44140
44410
  }
44141
44411
  requestHeaders["x-client-runtime-lease"] = normalized;
44142
44412
  };
44413
+ attachRuntimeSchedulerInstanceHeader = (requestHeaders, schedulerInstanceId) => {
44414
+ const normalized = String(schedulerInstanceId ?? "").trim();
44415
+ if (!normalized) {
44416
+ return;
44417
+ }
44418
+ requestHeaders["x-client-runtime-instance"] = normalized;
44419
+ };
44143
44420
  resolveRuntimeLeaseToken = (profileId, runtimeLeaseToken, omitRuntimeLeaseToken) => {
44144
44421
  if (omitRuntimeLeaseToken === true) {
44145
44422
  return void 0;
@@ -44229,11 +44506,13 @@ var init_api2 = __esm({
44229
44506
  const parsed = JSON.parse(body);
44230
44507
  const sessionId = typeof parsed.session_id === "string" && parsed.session_id.trim().length > 0 ? parsed.session_id.trim() : null;
44231
44508
  const deviceId = typeof parsed.device_id === "string" && parsed.device_id.trim().length > 0 ? parsed.device_id.trim() : null;
44509
+ const schedulerInstanceId = typeof parsed.scheduler_instance_id === "string" && parsed.scheduler_instance_id.trim().length > 0 ? parsed.scheduler_instance_id.trim() : null;
44232
44510
  const mode = parsed.mode === "assistant" ? "assistant" : parsed.mode === "trader" ? "trader" : null;
44233
44511
  const lastRunAt = typeof parsed.last_run_at === "string" && parsed.last_run_at.trim().length > 0 ? parsed.last_run_at.trim() : null;
44234
44512
  return {
44235
44513
  sessionId,
44236
44514
  deviceId,
44515
+ schedulerInstanceId,
44237
44516
  mode,
44238
44517
  lastRunAt
44239
44518
  };
@@ -44241,6 +44520,7 @@ var init_api2 = __esm({
44241
44520
  return {
44242
44521
  sessionId: null,
44243
44522
  deviceId: null,
44523
+ schedulerInstanceId: null,
44244
44524
  mode: null,
44245
44525
  lastRunAt: null
44246
44526
  };
@@ -44297,6 +44577,12 @@ var init_api2 = __esm({
44297
44577
  target.runtimeRequestTransientNetwork = isTransientNetworkFetchError(error48);
44298
44578
  target.runtimeRequestKeepalive = metadata.keepalive;
44299
44579
  target.runtimeRequestHadLeaseToken = metadata.hadRuntimeLeaseToken;
44580
+ if (metadata.deadlineAtMs !== void 0) {
44581
+ target.runtimeRequestDeadlineAtMs = metadata.deadlineAtMs;
44582
+ }
44583
+ if (metadata.deadlineExceeded !== void 0) {
44584
+ target.runtimeRequestDeadlineExceeded = metadata.deadlineExceeded;
44585
+ }
44300
44586
  return error48;
44301
44587
  };
44302
44588
  parseRuntimeRetryAfterMs = (value) => {
@@ -44322,7 +44608,8 @@ var init_api2 = __esm({
44322
44608
  }
44323
44609
  return path === "/runtime/heartbeat" || path === "/runtime/analyze" || path === "/runtime/prompt-contract/metadata" || path === "/runtime/prompt-contract/derived-context" || path === "/runtime/prompt" || path === "/runtime/decision" || path === "/runtime/error" || path === "/runtime/trade-sync";
44324
44610
  };
44325
- recoverMissingRuntimeLease = async (profileId, requestContext, signal) => {
44611
+ runtimeLeaseRecoveries = /* @__PURE__ */ new Map();
44612
+ recoverMissingRuntimeLeaseDirect = async (profileId, requestContext, signal) => {
44326
44613
  if (!requestContext.sessionId || !requestContext.deviceId) {
44327
44614
  return null;
44328
44615
  }
@@ -44330,6 +44617,7 @@ var init_api2 = __esm({
44330
44617
  "Content-Type": "application/json",
44331
44618
  "X-Idempotency-Key": createIdempotencyKey("runtime-lease-recovery")
44332
44619
  }, profileId);
44620
+ attachRuntimeSchedulerInstanceHeader(headers, requestContext.schedulerInstanceId);
44333
44621
  let payload;
44334
44622
  try {
44335
44623
  const response = await fetch(`${getApiUrl()}/trading/ai/runtime/session/start`, {
@@ -44341,6 +44629,7 @@ var init_api2 = __esm({
44341
44629
  body: JSON.stringify({
44342
44630
  session_id: requestContext.sessionId,
44343
44631
  device_id: requestContext.deviceId,
44632
+ ...requestContext.schedulerInstanceId ? { scheduler_instance_id: requestContext.schedulerInstanceId } : {},
44344
44633
  mode: requestContext.mode ?? null,
44345
44634
  last_run_at: requestContext.lastRunAt ?? null,
44346
44635
  force_takeover: false,
@@ -44357,14 +44646,100 @@ var init_api2 = __esm({
44357
44646
  }
44358
44647
  return null;
44359
44648
  }
44360
- persistRuntimeLeaseFromPayload(payload);
44649
+ const recoveredLease = payload?.lease;
44650
+ if (!recoveredLease || typeof recoveredLease !== "object" || Array.isArray(recoveredLease)) {
44651
+ return null;
44652
+ }
44653
+ const recoveredLeasePayload = recoveredLease;
44654
+ const expectedMode = requestContext.mode ?? "trader";
44655
+ const recoveredToken = String(recoveredLeasePayload.runtime_lease_token ?? "").trim();
44656
+ if (!recoveredToken || Number(recoveredLeasePayload.profile_id) !== profileId || String(recoveredLeasePayload.runtime_session_id ?? "").trim() !== requestContext.sessionId || String(recoveredLeasePayload.device_id ?? "").trim() !== requestContext.deviceId || String(recoveredLeasePayload.mode ?? "").trim().toLowerCase() !== expectedMode || requestContext.schedulerInstanceId != null && String(recoveredLeasePayload.scheduler_instance_id ?? "").trim() !== requestContext.schedulerInstanceId) {
44657
+ return null;
44658
+ }
44659
+ const currentLease = getPersistedClientRuntimeServerLease(profileId);
44660
+ if (currentLease && (currentLease.runtimeSessionId !== requestContext.sessionId || currentLease.deviceId !== requestContext.deviceId || currentLease.mode !== expectedMode || requestContext.schedulerInstanceId != null && currentLease.schedulerInstanceId !== requestContext.schedulerInstanceId)) {
44661
+ return null;
44662
+ }
44663
+ const selectedLease = persistClientRuntimeServerLease(
44664
+ recoveredLease
44665
+ );
44361
44666
  persistRuntimeLeaseStatusMetadata(profileId, payload);
44362
- const lease = getPersistedClientRuntimeServerLease(profileId);
44363
- if (lease?.runtimeSessionId === requestContext.sessionId && lease.deviceId === requestContext.deviceId && lease.runtimeLeaseToken) {
44364
- return lease.runtimeLeaseToken;
44667
+ if (selectedLease?.runtimeSessionId === requestContext.sessionId && selectedLease.deviceId === requestContext.deviceId && selectedLease.mode === expectedMode && (requestContext.schedulerInstanceId == null || selectedLease.schedulerInstanceId === requestContext.schedulerInstanceId) && selectedLease.runtimeLeaseToken) {
44668
+ return selectedLease.runtimeLeaseToken;
44365
44669
  }
44366
44670
  return null;
44367
44671
  };
44672
+ recoverMissingRuntimeLease = async (profileId, requestContext, signal) => {
44673
+ if (!requestContext.sessionId || !requestContext.deviceId) {
44674
+ return null;
44675
+ }
44676
+ const recoveryKey = JSON.stringify([
44677
+ profileId,
44678
+ requestContext.sessionId,
44679
+ requestContext.deviceId,
44680
+ requestContext.mode ?? "trader",
44681
+ requestContext.schedulerInstanceId
44682
+ ]);
44683
+ let recovery = runtimeLeaseRecoveries.get(recoveryKey);
44684
+ if (!recovery) {
44685
+ const controller = new AbortController();
44686
+ const created = {
44687
+ controller,
44688
+ promise: Promise.resolve(null),
44689
+ waiters: 0
44690
+ };
44691
+ created.promise = (async () => {
44692
+ try {
44693
+ return await recoverMissingRuntimeLeaseDirect(
44694
+ profileId,
44695
+ requestContext,
44696
+ controller.signal
44697
+ );
44698
+ } finally {
44699
+ if (runtimeLeaseRecoveries.get(recoveryKey) === created) {
44700
+ runtimeLeaseRecoveries.delete(recoveryKey);
44701
+ }
44702
+ }
44703
+ })();
44704
+ runtimeLeaseRecoveries.set(recoveryKey, created);
44705
+ recovery = created;
44706
+ }
44707
+ recovery.waiters += 1;
44708
+ try {
44709
+ if (!signal) {
44710
+ return await recovery.promise;
44711
+ }
44712
+ if (signal.aborted) {
44713
+ throw signal.reason ?? new DOMException("Runtime lease recovery aborted.", "AbortError");
44714
+ }
44715
+ return await new Promise((resolve6, reject) => {
44716
+ let settled = false;
44717
+ const finish = (callback) => {
44718
+ if (settled) {
44719
+ return;
44720
+ }
44721
+ settled = true;
44722
+ signal.removeEventListener("abort", onAbort);
44723
+ callback();
44724
+ };
44725
+ const onAbort = () => finish(() => reject(
44726
+ signal.reason ?? new DOMException("Runtime lease recovery aborted.", "AbortError")
44727
+ ));
44728
+ signal.addEventListener("abort", onAbort, { once: true });
44729
+ recovery.promise.then(
44730
+ (token) => finish(() => resolve6(token)),
44731
+ (error48) => finish(() => reject(error48))
44732
+ );
44733
+ });
44734
+ } finally {
44735
+ recovery.waiters = Math.max(0, recovery.waiters - 1);
44736
+ if (recovery.waiters === 0 && runtimeLeaseRecoveries.get(recoveryKey) === recovery && !recovery.controller.signal.aborted) {
44737
+ recovery.controller.abort(
44738
+ signal?.reason ?? new DOMException("Runtime lease recovery has no active waiters.", "AbortError")
44739
+ );
44740
+ }
44741
+ }
44742
+ };
44368
44743
  isRetryableClientRuntimeStatus = (status) => status === 408 || status === 429 || status === 500 || status === 502 || status === 503 || status === 504;
44369
44744
  shouldRetryClientRuntimeHttpStatus = (path, status) => {
44370
44745
  if (!isRetryableClientRuntimeStatus(status)) {
@@ -44376,7 +44751,7 @@ var init_api2 = __esm({
44376
44751
  return true;
44377
44752
  };
44378
44753
  isRuntimeIdempotencyInProgressError = (status, message) => status === 409 && (message.toLowerCase().includes("duplicate request already in progress") || message.toLowerCase().includes("duplicate request in-flight"));
44379
- isRetryableRuntimeConflictError = (status, error48) => status === 409 && error48.retryable === true && (error48.code === "profile_runtime_contract_busy" || error48.code === "runtime_trade_sync_finalizing");
44754
+ isRetryableRuntimeConflictError = (status, error48) => status === 409 && error48.retryable === true && (error48.code === "profile_runtime_contract_busy" || error48.code === "runtime_decision_finalizing" || error48.code === "runtime_trade_sync_finalizing");
44380
44755
  resolveClientRuntimeRetryDelayMs = (attempt, retryAfterHeader) => {
44381
44756
  const retryAfterMs = parseRuntimeRetryAfterMs(retryAfterHeader);
44382
44757
  if (retryAfterMs != null) {
@@ -44398,12 +44773,13 @@ var init_api2 = __esm({
44398
44773
  storage.setItem(key, generated);
44399
44774
  return generated;
44400
44775
  };
44401
- resolveClientExchangeMutationAuthority = (profileId, requiredRuntimeSessionId, explicitRuntimeLeaseToken, explicitRuntimeDeviceId) => {
44776
+ resolveClientExchangeMutationAuthority = (profileId, requiredRuntimeSessionId, explicitRuntimeLeaseToken, explicitRuntimeDeviceId, explicitSchedulerInstanceId) => {
44402
44777
  const numericProfileId = toNumericProfileId(profileId);
44403
44778
  const lease = getPersistedClientRuntimeServerLease(numericProfileId);
44404
44779
  const requiredSessionId = String(requiredRuntimeSessionId ?? "").trim();
44405
44780
  const explicitLeaseToken = String(explicitRuntimeLeaseToken ?? "").trim();
44406
44781
  const explicitDeviceId = String(explicitRuntimeDeviceId ?? "").trim();
44782
+ const schedulerInstanceId = String(explicitSchedulerInstanceId ?? "").trim();
44407
44783
  if (requiredSessionId && explicitLeaseToken && explicitDeviceId) {
44408
44784
  return {
44409
44785
  numericProfileId,
@@ -44411,18 +44787,20 @@ var init_api2 = __esm({
44411
44787
  deviceId: explicitDeviceId,
44412
44788
  mode: "trader",
44413
44789
  requestOptions: {
44414
- runtimeLeaseToken: explicitLeaseToken
44790
+ runtimeLeaseToken: explicitLeaseToken,
44791
+ schedulerInstanceId: schedulerInstanceId || void 0
44415
44792
  }
44416
44793
  };
44417
44794
  }
44418
- if (lease?.runtimeLeaseToken && lease.runtimeSessionId && lease.deviceId && lease.mode === "trader" && (!requiredSessionId || lease.runtimeSessionId === requiredSessionId)) {
44795
+ if (lease?.runtimeLeaseToken && lease.runtimeSessionId && lease.deviceId && lease.mode === "trader" && !lease.schedulerInstanceId && (!requiredSessionId || lease.runtimeSessionId === requiredSessionId)) {
44419
44796
  return {
44420
44797
  numericProfileId,
44421
44798
  sessionId: lease.runtimeSessionId,
44422
44799
  deviceId: lease.deviceId,
44423
44800
  mode: lease.mode,
44424
44801
  requestOptions: {
44425
- runtimeLeaseToken: lease.runtimeLeaseToken
44802
+ runtimeLeaseToken: lease.runtimeLeaseToken,
44803
+ schedulerInstanceId: schedulerInstanceId || void 0
44426
44804
  }
44427
44805
  };
44428
44806
  }
@@ -44454,11 +44832,15 @@ var init_api2 = __esm({
44454
44832
  }
44455
44833
  };
44456
44834
  };
44457
- clientExchangeMutationAuthorityBody = (authority) => ({
44458
- session_id: authority.sessionId,
44459
- device_id: authority.deviceId,
44460
- mode: authority.mode
44461
- });
44835
+ clientExchangeMutationAuthorityBody = (authority) => {
44836
+ const schedulerInstanceId = String(authority.requestOptions.schedulerInstanceId ?? "").trim();
44837
+ return {
44838
+ session_id: authority.sessionId,
44839
+ device_id: authority.deviceId,
44840
+ mode: authority.mode,
44841
+ ...schedulerInstanceId ? { scheduler_instance_id: schedulerInstanceId } : {}
44842
+ };
44843
+ };
44462
44844
  isPendingClientExchangeMutationError = (error48) => {
44463
44845
  const status = Number(error48?.status);
44464
44846
  const message = error48 instanceof Error ? error48.message : String(error48 ?? "");
@@ -44481,7 +44863,8 @@ var init_api2 = __esm({
44481
44863
  };
44482
44864
  snapshotClientExchangeMutationReconciliationAuthority = (requestOptions) => {
44483
44865
  const runtimeLeaseToken = String(requestOptions?.runtimeLeaseToken ?? "").trim();
44484
- return runtimeLeaseToken ? { runtimeLeaseToken } : { omitRuntimeLeaseToken: true };
44866
+ const schedulerInstanceId = String(requestOptions?.schedulerInstanceId ?? "").trim();
44867
+ return runtimeLeaseToken ? { runtimeLeaseToken, schedulerInstanceId: schedulerInstanceId || void 0 } : { omitRuntimeLeaseToken: true, schedulerInstanceId: schedulerInstanceId || void 0 };
44485
44868
  };
44486
44869
  postClientExchangeMutationReconciliation = async (profileId, mutationId, requestOptions) => {
44487
44870
  const result2 = await postClientRuntime(
@@ -54249,14 +54632,19 @@ var init_hyperliquid_client = __esm({
54249
54632
  const runtimeSessionId = String(durableMutation.requiredRuntimeSessionId ?? "").trim();
54250
54633
  const runtimeLeaseToken = String(durableMutation.runtimeLeaseToken ?? "").trim();
54251
54634
  const runtimeDeviceId = String(durableMutation.runtimeDeviceId ?? "").trim();
54252
- const presentCount = [runtimeSessionId, runtimeLeaseToken, runtimeDeviceId].filter(Boolean).length;
54253
- if (presentCount === 0) {
54635
+ const schedulerInstanceId = String(durableMutation.schedulerInstanceId ?? "").trim();
54636
+ const coreAuthority = [runtimeSessionId, runtimeLeaseToken, runtimeDeviceId];
54637
+ const corePresentCount = coreAuthority.filter(Boolean).length;
54638
+ if (corePresentCount === 0 && !schedulerInstanceId) {
54254
54639
  return [];
54255
54640
  }
54256
- if (presentCount !== 3) {
54641
+ if (corePresentCount !== 3) {
54257
54642
  throw new Error("Incomplete client runtime mutation authority.");
54258
54643
  }
54259
- return [runtimeSessionId, runtimeLeaseToken, runtimeDeviceId];
54644
+ if (!schedulerInstanceId) {
54645
+ return [runtimeSessionId, runtimeLeaseToken, runtimeDeviceId];
54646
+ }
54647
+ return [runtimeSessionId, runtimeLeaseToken, runtimeDeviceId, schedulerInstanceId];
54260
54648
  };
54261
54649
  assertFreshPreparedExecutionContext = (preparedContext) => {
54262
54650
  if (!preparedContext) {
@@ -57147,6 +57535,7 @@ var init_browser_trading = __esm({
57147
57535
  requiredRuntimeSessionId: input.runtimeSessionId,
57148
57536
  runtimeLeaseToken: input.runtimeLeaseToken,
57149
57537
  runtimeDeviceId: input.runtimeDeviceId,
57538
+ schedulerInstanceId: input.schedulerInstanceId,
57150
57539
  mutationId: mutation.mutationId,
57151
57540
  operationKind: "leverage",
57152
57541
  symbol: input.symbol
@@ -57185,6 +57574,7 @@ var init_browser_trading = __esm({
57185
57574
  requiredRuntimeSessionId: input.runtimeSessionId,
57186
57575
  runtimeLeaseToken: input.runtimeLeaseToken,
57187
57576
  runtimeDeviceId: input.runtimeDeviceId,
57577
+ schedulerInstanceId: input.schedulerInstanceId,
57188
57578
  mutationId: mutation.mutationId,
57189
57579
  operationKind: "order",
57190
57580
  symbol: input.symbol,
@@ -57221,6 +57611,7 @@ var init_browser_trading = __esm({
57221
57611
  requiredRuntimeSessionId: input.runtimeSessionId,
57222
57612
  runtimeLeaseToken: input.runtimeLeaseToken,
57223
57613
  runtimeDeviceId: input.runtimeDeviceId,
57614
+ schedulerInstanceId: input.schedulerInstanceId,
57224
57615
  mutationId: mutation.mutationId,
57225
57616
  operationKind: "order",
57226
57617
  symbol: input.symbol,
@@ -57251,6 +57642,7 @@ var init_browser_trading = __esm({
57251
57642
  requiredRuntimeSessionId: input.runtimeSessionId,
57252
57643
  runtimeLeaseToken: input.runtimeLeaseToken,
57253
57644
  runtimeDeviceId: input.runtimeDeviceId,
57645
+ schedulerInstanceId: input.schedulerInstanceId,
57254
57646
  mutationId: mutation.mutationId,
57255
57647
  operationKind: "order",
57256
57648
  symbol: input.symbol,
@@ -57291,6 +57683,7 @@ var init_browser_trading = __esm({
57291
57683
  requiredRuntimeSessionId: input.runtimeSessionId,
57292
57684
  runtimeLeaseToken: input.runtimeLeaseToken,
57293
57685
  runtimeDeviceId: input.runtimeDeviceId,
57686
+ schedulerInstanceId: input.schedulerInstanceId,
57294
57687
  mutationId: mutation.mutationId,
57295
57688
  operationKind: "order",
57296
57689
  symbol: input.symbol,
@@ -57320,6 +57713,7 @@ var init_browser_trading = __esm({
57320
57713
  requiredRuntimeSessionId: input.runtimeSessionId,
57321
57714
  runtimeLeaseToken: input.runtimeLeaseToken,
57322
57715
  runtimeDeviceId: input.runtimeDeviceId,
57716
+ schedulerInstanceId: input.schedulerInstanceId,
57323
57717
  mutationId: mutation.mutationId,
57324
57718
  operationKind: "cancel",
57325
57719
  symbol: input.symbol,
@@ -57349,6 +57743,7 @@ var init_browser_trading = __esm({
57349
57743
  runtimeSessionId: input.runtimeSessionId,
57350
57744
  runtimeLeaseToken: input.runtimeLeaseToken,
57351
57745
  runtimeDeviceId: input.runtimeDeviceId,
57746
+ schedulerInstanceId: input.schedulerInstanceId,
57352
57747
  walletAddress: input.walletAddress,
57353
57748
  config: input.config ?? null,
57354
57749
  signal: input.signal,
@@ -58610,6 +59005,7 @@ var init_runtime_execution = __esm({
58610
59005
  runtimeSessionId: request.sessionId || "__missing_runtime_session__",
58611
59006
  runtimeLeaseToken: request.runtimeLeaseToken,
58612
59007
  runtimeDeviceId: request.runtimeDeviceId,
59008
+ schedulerInstanceId: request.schedulerInstanceId,
58613
59009
  walletAddress: request.executionContext.walletAddress,
58614
59010
  config: request.config ?? null,
58615
59011
  signal: request.signal,
@@ -59005,6 +59401,7 @@ var init_runtime_execution = __esm({
59005
59401
  runtimeSessionId: request.sessionId || "__missing_runtime_session__",
59006
59402
  runtimeLeaseToken: request.runtimeLeaseToken,
59007
59403
  runtimeDeviceId: request.runtimeDeviceId,
59404
+ schedulerInstanceId: request.schedulerInstanceId,
59008
59405
  walletAddress: request.executionContext.walletAddress,
59009
59406
  config: request.config ?? null,
59010
59407
  signal: request.signal,
@@ -59037,6 +59434,7 @@ var init_runtime_execution = __esm({
59037
59434
  runtimeSessionId: request.sessionId || "__missing_runtime_session__",
59038
59435
  runtimeLeaseToken: request.runtimeLeaseToken,
59039
59436
  runtimeDeviceId: request.runtimeDeviceId,
59437
+ schedulerInstanceId: request.schedulerInstanceId,
59040
59438
  walletAddress: request.executionContext.walletAddress,
59041
59439
  config: request.config ?? null,
59042
59440
  signal: request.signal,
@@ -60042,6 +60440,7 @@ var init_runtime_execution = __esm({
60042
60440
  runtimeSessionId: request.sessionId || "__missing_runtime_session__",
60043
60441
  runtimeLeaseToken: request.runtimeLeaseToken,
60044
60442
  runtimeDeviceId: request.runtimeDeviceId,
60443
+ schedulerInstanceId: request.schedulerInstanceId,
60045
60444
  walletAddress: request.executionContext.walletAddress,
60046
60445
  config: request.config ?? null,
60047
60446
  signal: request.signal,
@@ -60740,6 +61139,7 @@ var init_runtime_execution = __esm({
60740
61139
  runtimeSessionId: request.sessionId || "__missing_runtime_session__",
60741
61140
  runtimeLeaseToken: request.runtimeLeaseToken,
60742
61141
  runtimeDeviceId: request.runtimeDeviceId,
61142
+ schedulerInstanceId: request.schedulerInstanceId,
60743
61143
  walletAddress: request.executionContext.walletAddress,
60744
61144
  config: request.config ?? null,
60745
61145
  signal: request.signal,
@@ -61179,6 +61579,7 @@ var init_runtime_execution = __esm({
61179
61579
  runtimeSessionId: request.sessionId || "__missing_runtime_session__",
61180
61580
  runtimeLeaseToken: request.runtimeLeaseToken,
61181
61581
  runtimeDeviceId: request.runtimeDeviceId,
61582
+ schedulerInstanceId: request.schedulerInstanceId,
61182
61583
  walletAddress: request.executionContext.walletAddress,
61183
61584
  config: request.config ?? null,
61184
61585
  signal: request.signal,
@@ -61705,6 +62106,7 @@ var init_runtime_execution = __esm({
61705
62106
  runtimeSessionId: input.sessionId || "__missing_runtime_session__",
61706
62107
  runtimeLeaseToken: input.runtimeLeaseToken,
61707
62108
  runtimeDeviceId: input.runtimeDeviceId,
62109
+ schedulerInstanceId: input.schedulerInstanceId,
61708
62110
  walletAddress: input.executionContext.walletAddress,
61709
62111
  config: input.config ?? null,
61710
62112
  signal: input.signal,
@@ -61722,6 +62124,7 @@ var init_runtime_execution = __esm({
61722
62124
  runtimeSessionId: input.sessionId || "__missing_runtime_session__",
61723
62125
  runtimeLeaseToken: input.runtimeLeaseToken,
61724
62126
  runtimeDeviceId: input.runtimeDeviceId,
62127
+ schedulerInstanceId: input.schedulerInstanceId,
61725
62128
  walletAddress: input.executionContext.walletAddress,
61726
62129
  config: input.config ?? null,
61727
62130
  signal: input.signal,
@@ -61793,6 +62196,7 @@ var init_runtime_execution = __esm({
61793
62196
  runtimeSessionId: input.sessionId || "__missing_runtime_session__",
61794
62197
  runtimeLeaseToken: input.runtimeLeaseToken,
61795
62198
  runtimeDeviceId: input.runtimeDeviceId,
62199
+ schedulerInstanceId: input.schedulerInstanceId,
61796
62200
  walletAddress: input.executionContext.walletAddress,
61797
62201
  config: input.config ?? null,
61798
62202
  signal: input.signal,
@@ -61911,6 +62315,7 @@ var init_runtime_execution = __esm({
61911
62315
  runtimeSessionId: input.sessionId || "__missing_runtime_session__",
61912
62316
  runtimeLeaseToken: input.runtimeLeaseToken,
61913
62317
  runtimeDeviceId: input.runtimeDeviceId,
62318
+ schedulerInstanceId: input.schedulerInstanceId,
61914
62319
  walletAddress: input.executionContext.walletAddress,
61915
62320
  config: input.config ?? null,
61916
62321
  signal: input.signal,
@@ -62069,6 +62474,7 @@ var init_runtime_execution = __esm({
62069
62474
  runtimeSessionId: input.sessionId || "__missing_runtime_session__",
62070
62475
  runtimeLeaseToken: input.runtimeLeaseToken,
62071
62476
  runtimeDeviceId: input.runtimeDeviceId,
62477
+ schedulerInstanceId: input.schedulerInstanceId,
62072
62478
  walletAddress: input.executionContext.walletAddress,
62073
62479
  config: input.config ?? null,
62074
62480
  signal: input.signal,
@@ -62392,6 +62798,7 @@ var init_runtime_execution = __esm({
62392
62798
  runtimeSessionId: input.sessionId || "__missing_runtime_session__",
62393
62799
  runtimeLeaseToken: input.runtimeLeaseToken,
62394
62800
  runtimeDeviceId: input.runtimeDeviceId,
62801
+ schedulerInstanceId: input.schedulerInstanceId,
62395
62802
  walletAddress: input.executionContext.walletAddress,
62396
62803
  config: input.config ?? null,
62397
62804
  signal: input.signal,