@vtxmacro/cli 2026.9.66 → 2026.9.68

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/README.md CHANGED
@@ -305,6 +305,7 @@ agent chooses its own cadence and may request zero, one, or many data calls:
305
305
 
306
306
  ```bash
307
307
  vtx inference-host agent-assignment-next --wait-seconds 50 --json
308
+ vtx inference-host agent-review-begin --json
308
309
  vtx inference-host agent-data-call --json
309
310
  vtx inference-host agent-decision-submit --json
310
311
  vtx inference-host agent-decision-status --json
@@ -16,7 +16,7 @@ import { fileURLToPath } from "node:url";
16
16
  // agent-cli-release.json
17
17
  var agent_cli_release_default = {
18
18
  package_name: "@vtxmacro/cli",
19
- package_version: "2026.9.66",
19
+ package_version: "2026.9.68",
20
20
  codex_package_name: "@openai/codex",
21
21
  codex_version: "0.155.0",
22
22
  copilot_sdk_package_name: "@github/copilot-sdk",
@@ -133,6 +133,14 @@ var runtime_policy_generated_default = {
133
133
  min_delay_milliseconds: 250,
134
134
  max_delay_milliseconds: 1e4
135
135
  },
136
+ trade_refresh_policy: {
137
+ server_config_stream_timeout_ms: 1e4,
138
+ config_retry_interval_ms: 5e3,
139
+ copy_trading_status_poll_ms: 5e3,
140
+ post_execution_refresh_delay_ms: 3e3,
141
+ account_read_backoff_min_ms: 2e3,
142
+ account_read_backoff_max_ms: 6e4
143
+ },
136
144
  deployment_reload_observability: {
137
145
  bootstrap_max_error_events_per_page: 4,
138
146
  bootstrap_max_profiles: 10
@@ -210,10 +218,12 @@ var runtime_policy_generated_default = {
210
218
  },
211
219
  server_runtime: {
212
220
  prompt_rescue: {
221
+ request_ttl_seconds: 20,
213
222
  snapshot_max_age_seconds: 5,
214
223
  snapshot_component_max_skew_seconds: 2,
215
- client_long_poll_seconds: 20,
216
- client_claim_http_timeout_milliseconds: 25e3,
224
+ client_claim_http_timeout_milliseconds: 5e3,
225
+ client_claim_retry_delay_milliseconds: 1e3,
226
+ client_failure_report_timeout_milliseconds: 2e3,
217
227
  client_presence_heartbeat_interval_milliseconds: 3e4,
218
228
  client_presence_http_timeout_milliseconds: 5e3
219
229
  }
@@ -16,6 +16,14 @@ var runtime_policy_generated_default = {
16
16
  min_delay_milliseconds: 250,
17
17
  max_delay_milliseconds: 1e4
18
18
  },
19
+ trade_refresh_policy: {
20
+ server_config_stream_timeout_ms: 1e4,
21
+ config_retry_interval_ms: 5e3,
22
+ copy_trading_status_poll_ms: 5e3,
23
+ post_execution_refresh_delay_ms: 3e3,
24
+ account_read_backoff_min_ms: 2e3,
25
+ account_read_backoff_max_ms: 6e4
26
+ },
19
27
  deployment_reload_observability: {
20
28
  bootstrap_max_error_events_per_page: 4,
21
29
  bootstrap_max_profiles: 10
@@ -93,10 +101,12 @@ var runtime_policy_generated_default = {
93
101
  },
94
102
  server_runtime: {
95
103
  prompt_rescue: {
104
+ request_ttl_seconds: 20,
96
105
  snapshot_max_age_seconds: 5,
97
106
  snapshot_component_max_skew_seconds: 2,
98
- client_long_poll_seconds: 20,
99
- client_claim_http_timeout_milliseconds: 25e3,
107
+ client_claim_http_timeout_milliseconds: 5e3,
108
+ client_claim_retry_delay_milliseconds: 1e3,
109
+ client_failure_report_timeout_milliseconds: 2e3,
100
110
  client_presence_heartbeat_interval_milliseconds: 3e4,
101
111
  client_presence_http_timeout_milliseconds: 5e3
102
112
  }
package/bin/vtx.js CHANGED
@@ -77,7 +77,7 @@ var init_agent_cli_release = __esm({
77
77
  "agent-cli-release.json"() {
78
78
  agent_cli_release_default = {
79
79
  package_name: "@vtxmacro/cli",
80
- package_version: "2026.9.66",
80
+ package_version: "2026.9.68",
81
81
  codex_package_name: "@openai/codex",
82
82
  codex_version: "0.155.0",
83
83
  copilot_sdk_package_name: "@github/copilot-sdk",
@@ -15727,6 +15727,8 @@ var init_external_inference_contract = __esm({
15727
15727
  }
15728
15728
  });
15729
15729
  providerWeeklyQuotaReadSchema = external_exports.strictObject({
15730
+ credits_available: external_exports.boolean().nullable().optional(),
15731
+ rate_limit_reached: external_exports.boolean().nullable().optional(),
15730
15732
  source: external_exports.literal("codex_app_server"),
15731
15733
  used_percent: external_exports.number().finite().min(0).max(1e6),
15732
15734
  resets_at: timestampSchema,
@@ -20516,6 +20518,14 @@ var init_runtime_policy_generated = __esm({
20516
20518
  min_delay_milliseconds: 250,
20517
20519
  max_delay_milliseconds: 1e4
20518
20520
  },
20521
+ trade_refresh_policy: {
20522
+ server_config_stream_timeout_ms: 1e4,
20523
+ config_retry_interval_ms: 5e3,
20524
+ copy_trading_status_poll_ms: 5e3,
20525
+ post_execution_refresh_delay_ms: 3e3,
20526
+ account_read_backoff_min_ms: 2e3,
20527
+ account_read_backoff_max_ms: 6e4
20528
+ },
20519
20529
  deployment_reload_observability: {
20520
20530
  bootstrap_max_error_events_per_page: 4,
20521
20531
  bootstrap_max_profiles: 10
@@ -20593,10 +20603,12 @@ var init_runtime_policy_generated = __esm({
20593
20603
  },
20594
20604
  server_runtime: {
20595
20605
  prompt_rescue: {
20606
+ request_ttl_seconds: 20,
20596
20607
  snapshot_max_age_seconds: 5,
20597
20608
  snapshot_component_max_skew_seconds: 2,
20598
- client_long_poll_seconds: 20,
20599
- client_claim_http_timeout_milliseconds: 25e3,
20609
+ client_claim_http_timeout_milliseconds: 5e3,
20610
+ client_claim_retry_delay_milliseconds: 1e3,
20611
+ client_failure_report_timeout_milliseconds: 2e3,
20600
20612
  client_presence_heartbeat_interval_milliseconds: 3e4,
20601
20613
  client_presence_http_timeout_milliseconds: 5e3
20602
20614
  }
@@ -20773,7 +20785,7 @@ var init_mcp_transport = __esm({
20773
20785
  });
20774
20786
 
20775
20787
  // lib/inference-host/mcp-client.ts
20776
- var EXTERNAL_INFERENCE_MCP_PROTOCOL_VERSION, EXTERNAL_INFERENCE_AUTOMATED_HOST_TOOLS, EXTERNAL_INFERENCE_OPERATIONAL_TOOLS, ClaimTiming, ExternalInferenceMcpError, DEFAULT_REQUEST_TIMEOUT_MS, MAX_RETRY_AFTER_MS, PUBLIC_TOOL_ERROR_PREFIX, parseRetryAfterMs, identifierSchema2, safeCodeSchema2, publicFailureCodeSchema, publicToolErrorSchema, structuredPublicToolErrorSchema, parsePublicToolError, hostMutationResultSchema, attemptStartResultSchema, agentConnectResultSchema, agentHeartbeatResultSchema, timestampSchema2, positiveGenerationSchema, jsonObjectSchema, agentAssignmentNextArgumentsSchema, agentDataCapabilityDescriptorSchema, agentAssignmentNextResultSchema, agentAssignmentHeartbeatArgumentsSchema, agentAssignmentHeartbeatResultSchema, agentDataCallArgumentsSchema, agentDataCallResultSchema, agentDecisionSubmitArgumentsSchema, agentDecisionSubmitResultSchema, agentDecisionStatusArgumentsSchema, agentDecisionStatusResultSchema, agentAssignmentReleaseArgumentsSchema, agentAssignmentReleaseResultSchema, jobCompletionResultSchema, jobFailureResultSchema, toolContracts, discoveryResultSchema, toolListResultSchema, inlineStructuredContentSchema, protocolMeta, parseJsonDocument, parseSseDocuments, parseResponseDocuments, exactOperationalInventory, exactJson, invalidBoundResult, verifyToolResult, ExternalInferenceMcpClient;
20788
+ var EXTERNAL_INFERENCE_MCP_PROTOCOL_VERSION, EXTERNAL_INFERENCE_AUTOMATED_HOST_TOOLS, EXTERNAL_INFERENCE_OPERATIONAL_TOOLS, ClaimTiming, ExternalInferenceMcpError, DEFAULT_REQUEST_TIMEOUT_MS, MAX_RETRY_AFTER_MS, PUBLIC_TOOL_ERROR_PREFIX, parseRetryAfterMs, identifierSchema2, safeCodeSchema2, publicFailureCodeSchema, publicToolErrorSchema, structuredPublicToolErrorSchema, parsePublicToolError, hostMutationResultSchema, attemptStartResultSchema, agentConnectResultSchema, agentHeartbeatResultSchema, timestampSchema2, positiveGenerationSchema, jsonObjectSchema, agentAssignmentNextArgumentsSchema, agentDataCapabilityDescriptorSchema, agentAssignmentNextResultSchema, agentAssignmentHeartbeatArgumentsSchema, agentAssignmentHeartbeatResultSchema, agentDataCallArgumentsSchema, agentDataCallResultSchema, agentDecisionTimingSchema, agentDecisionSubmitArgumentsSchema, agentDecisionSubmitResultSchema, agentDecisionStatusArgumentsSchema, agentDecisionStatusResultSchema, agentAssignmentReleaseArgumentsSchema, agentAssignmentReleaseResultSchema, jobCompletionResultSchema, jobFailureResultSchema, toolContracts, discoveryResultSchema, toolListResultSchema, inlineStructuredContentSchema, protocolMeta, parseJsonDocument, parseSseDocuments, parseResponseDocuments, exactOperationalInventory, exactJson, invalidBoundResult, verifyToolResult, ExternalInferenceMcpClient;
20777
20789
  var init_mcp_client = __esm({
20778
20790
  "lib/inference-host/mcp-client.ts"() {
20779
20791
  "use strict";
@@ -21096,13 +21108,23 @@ var init_mcp_client = __esm({
21096
21108
  warnings: external_exports.array(external_exports.unknown()),
21097
21109
  sources: external_exports.array(external_exports.unknown())
21098
21110
  });
21111
+ agentDecisionTimingSchema = external_exports.strictObject({
21112
+ analysis_started_at: timestampSchema2,
21113
+ model_latency_ms: external_exports.number().int().nonnegative().nullable(),
21114
+ model_latency_source: external_exports.literal("harness_invocation").nullable()
21115
+ }).refine((timing) => timing.model_latency_ms === null === (timing.model_latency_source === null), {
21116
+ message: "Model latency and its measurement source must be supplied together."
21117
+ });
21099
21118
  agentDecisionSubmitArgumentsSchema = external_exports.strictObject({
21100
21119
  assignment_id: identifierSchema2,
21101
21120
  assignment_generation: positiveGenerationSchema,
21102
21121
  operation_id: identifierSchema2,
21103
21122
  candidate: jsonObjectSchema,
21104
21123
  observed_at: timestampSchema2,
21124
+ timing: agentDecisionTimingSchema.optional(),
21105
21125
  provenance: jsonObjectSchema.nullable().optional()
21126
+ }).refine((request) => !request.timing || Date.parse(request.timing.analysis_started_at) <= Date.parse(request.observed_at), {
21127
+ message: "Analysis start must precede decision observation."
21106
21128
  });
21107
21129
  agentDecisionSubmitResultSchema = external_exports.strictObject({
21108
21130
  assignment_id: identifierSchema2,
@@ -21454,6 +21476,7 @@ var init_mcp_client = __esm({
21454
21476
  #requestId = 0;
21455
21477
  #initialized = false;
21456
21478
  #providerQuotaRecoverySupported = false;
21479
+ #providerCreditsSupported = false;
21457
21480
  #runtimeRecoveryDiagnosticsSupported = false;
21458
21481
  #providerHttpStatusTools = /* @__PURE__ */ new Set();
21459
21482
  #grokToolValidationTools = /* @__PURE__ */ new Set();
@@ -21500,6 +21523,9 @@ var init_mcp_client = __esm({
21500
21523
  supportsRuntimeRecoveryDiagnostics() {
21501
21524
  return this.#runtimeRecoveryDiagnosticsSupported;
21502
21525
  }
21526
+ supportsProviderCredits() {
21527
+ return this.#providerCreditsSupported;
21528
+ }
21503
21529
  supportsProviderQuotaRecovery() {
21504
21530
  return this.#providerQuotaRecoverySupported;
21505
21531
  }
@@ -21562,6 +21588,21 @@ var init_mcp_client = __esm({
21562
21588
  "inference.host.heartbeat",
21563
21589
  ["provider_quota_recovery"]
21564
21590
  ) && advertisesFields("inference.job.fail", ["provider_retry_at", "provider_retry_source"]);
21591
+ const hostHeartbeatSchema = listed.tools.find(
21592
+ (tool) => tool.name === "inference.host.heartbeat"
21593
+ )?.inputSchema;
21594
+ const advertisesCredits = (value, depth = 0) => {
21595
+ if (depth > 4 || !value || typeof value !== "object" || Array.isArray(value)) return false;
21596
+ const node = value;
21597
+ const properties = node.properties;
21598
+ if (properties && typeof properties === "object" && Object.hasOwn(properties, "credits_available") && Object.hasOwn(properties, "rate_limit_reached")) return true;
21599
+ if (typeof node.$ref === "string" && /^#\/\$defs\/[^/]+$/u.test(node.$ref)) {
21600
+ const definition = node.$ref.slice("#/$defs/".length).replace(/~1/gu, "/").replace(/~0/gu, "~");
21601
+ return advertisesCredits(hostHeartbeatSchema?.$defs?.[definition], depth + 1);
21602
+ }
21603
+ return Array.isArray(node.anyOf) && node.anyOf.some((branch) => advertisesCredits(branch, depth + 1));
21604
+ };
21605
+ this.#providerCreditsSupported = advertisesCredits(hostHeartbeatSchema?.properties?.provider_weekly_quota);
21565
21606
  this.#grokToolValidationTools.clear();
21566
21607
  if (advertisesFields("inference.job.fail", ["grok_tool_validation"])) {
21567
21608
  this.#grokToolValidationTools.add("inference.job.fail");
@@ -28345,7 +28386,7 @@ async function logoutCodexSubscription(options) {
28345
28386
  await session.close();
28346
28387
  }
28347
28388
  }
28348
- var CODEX_INFERENCE_PERMISSION_PROFILE, CODEX_AGENT_PERMISSION_PROFILE, CODEX_REASONING_CONTENT_MAX_UTF8_BYTES, CODEX_REASONING_SUMMARY_MAX_UTF8_BYTES, CODEX_ACCOUNT_PLAN_TYPES, CODEX_AGENT_DYNAMIC_TOOLS, CodexAppServerError, objectOrNull, finiteToken, tokenUsageFromBreakdown, usageFromNotification, validPlanType, nonnegativeSafeIntegerOrNull, nonnegativeFiniteNumberOrNull, parseRateLimitWindow, RATE_LIMIT_REACHED_TYPES, DEFAULT_CODEX_QUOTA_COOLDOWN_MS, MAX_CODEX_QUOTA_COOLDOWN_MS, CODEX_TRANSIENT_RATE_LIMIT_COOLDOWN_MS, parseRateLimitSnapshot, codexRateLimitRetryAtMs, codexAccountRateLimitReached, forbiddenMethod, forbiddenTerminalItem, forbiddenAgentMethod, forbiddenAgentTerminalItem, createCodexAgentToolSpecs, classifyCodexTurnFailure, scrubbedCodexEnvironment, killWindowsProcessTree, appServerArgs, GUARDIAN_SCRIPT, WINDOWS_RECEIPT_REPLACE_ERROR_CODES, MAX_RETIRED_RESPONSE_IDS, LATE_RESPONSE_SAFE_METHODS, replaceCodexGuardianReceiptFile, writeCodexGuardianSpawnIntent, parseGuardianReceipt, readCodexGuardianReceipt, waitForCodexGuardianState, defaultSpawn, CodexAppServerSession;
28389
+ var CODEX_INFERENCE_PERMISSION_PROFILE, CODEX_AGENT_PERMISSION_PROFILE, CODEX_REASONING_CONTENT_MAX_UTF8_BYTES, CODEX_REASONING_SUMMARY_MAX_UTF8_BYTES, CODEX_ACCOUNT_PLAN_TYPES, CODEX_AGENT_DYNAMIC_TOOLS, CodexAppServerError, objectOrNull, finiteToken, tokenUsageFromBreakdown, usageFromNotification, validPlanType, nonnegativeSafeIntegerOrNull, nonnegativeFiniteNumberOrNull, parseRateLimitWindow, RATE_LIMIT_REACHED_TYPES, DEFAULT_CODEX_QUOTA_COOLDOWN_MS, MAX_CODEX_QUOTA_COOLDOWN_MS, CODEX_TRANSIENT_RATE_LIMIT_COOLDOWN_MS, parseCreditsSnapshot, codexCreditsAvailable, parseRateLimitSnapshot, codexRateLimitRetryAtMs, codexAccountRateLimitReached, forbiddenMethod, forbiddenTerminalItem, forbiddenAgentMethod, forbiddenAgentTerminalItem, createCodexAgentToolSpecs, classifyCodexTurnFailure, scrubbedCodexEnvironment, killWindowsProcessTree, appServerArgs, GUARDIAN_SCRIPT, WINDOWS_RECEIPT_REPLACE_ERROR_CODES, MAX_RETIRED_RESPONSE_IDS, LATE_RESPONSE_SAFE_METHODS, replaceCodexGuardianReceiptFile, writeCodexGuardianSpawnIntent, parseGuardianReceipt, readCodexGuardianReceipt, waitForCodexGuardianState, defaultSpawn, CodexAppServerSession;
28349
28390
  var init_codex_app_server = __esm({
28350
28391
  "lib/inference-host/codex-app-server.ts"() {
28351
28392
  "use strict";
@@ -28460,6 +28501,19 @@ var init_codex_app_server = __esm({
28460
28501
  DEFAULT_CODEX_QUOTA_COOLDOWN_MS = 5 * 60 * 1e3;
28461
28502
  MAX_CODEX_QUOTA_COOLDOWN_MS = 8 * 24 * 60 * 60 * 1e3;
28462
28503
  CODEX_TRANSIENT_RATE_LIMIT_COOLDOWN_MS = 30 * 1e3;
28504
+ parseCreditsSnapshot = (value) => {
28505
+ const candidate = objectOrNull(value);
28506
+ if (!candidate || typeof candidate.hasCredits !== "boolean" || typeof candidate.unlimited !== "boolean" || candidate.balance != null && typeof candidate.balance !== "string") return null;
28507
+ return {
28508
+ hasCredits: candidate.hasCredits,
28509
+ unlimited: candidate.unlimited,
28510
+ balance: candidate.balance ?? null
28511
+ };
28512
+ };
28513
+ codexCreditsAvailable = (snapshot) => {
28514
+ const credits = parseCreditsSnapshot(snapshot.credits);
28515
+ return credits !== null && (credits.hasCredits || credits.unlimited);
28516
+ };
28463
28517
  parseRateLimitSnapshot = (value) => {
28464
28518
  const candidate = objectOrNull(value);
28465
28519
  if (!candidate) throw new Error("invalid rate-limit snapshot");
@@ -28473,6 +28527,7 @@ var init_codex_app_server = __esm({
28473
28527
  limitId,
28474
28528
  limitName,
28475
28529
  planType,
28530
+ credits: parseCreditsSnapshot(candidate.credits),
28476
28531
  primary: parseRateLimitWindow(candidate.primary ?? null),
28477
28532
  secondary: parseRateLimitWindow(candidate.secondary ?? null),
28478
28533
  rateLimitReachedType: reached,
@@ -28480,6 +28535,7 @@ var init_codex_app_server = __esm({
28480
28535
  };
28481
28536
  };
28482
28537
  codexRateLimitRetryAtMs = (accountRateLimits) => {
28538
+ if (!codexAccountRateLimitReached(accountRateLimits)) return null;
28483
28539
  const snapshots = [accountRateLimits.rateLimits];
28484
28540
  const exhaustedResets = [];
28485
28541
  const reachedResets = [];
@@ -28500,7 +28556,12 @@ var init_codex_app_server = __esm({
28500
28556
  const candidates = exhaustedResets.length > 0 ? exhaustedResets : reachedResets.length > 0 ? reachedResets : [];
28501
28557
  return candidates.length > 0 ? Math.max(...candidates) : null;
28502
28558
  };
28503
- codexAccountRateLimitReached = (accountRateLimits) => [accountRateLimits.rateLimits].some((snapshot) => snapshot.rateLimitReachedType !== null || snapshot.spendControlReached === true || snapshot.primary?.usedPercent !== void 0 && snapshot.primary.usedPercent >= 100 || snapshot.secondary?.usedPercent !== void 0 && snapshot.secondary.usedPercent >= 100);
28559
+ codexAccountRateLimitReached = (accountRateLimits) => [accountRateLimits.rateLimits].some((snapshot) => (
28560
+ // The account snapshot reports generic included-usage exhaustion even when
28561
+ // purchased credits remain. Workspace restrictions are distinct hard stops;
28562
+ // actual turn failures remain authoritative in classifyCodexTurnFailure.
28563
+ snapshot.rateLimitReachedType !== null && (snapshot.rateLimitReachedType !== "rate_limit_reached" || !codexCreditsAvailable(snapshot)) || snapshot.spendControlReached === true || !codexCreditsAvailable(snapshot) && (snapshot.primary?.usedPercent !== void 0 && snapshot.primary.usedPercent >= 100 || snapshot.secondary?.usedPercent !== void 0 && snapshot.secondary.usedPercent >= 100)
28564
+ ));
28504
28565
  forbiddenMethod = (method) => method.startsWith("mcpServer/") || method.startsWith("serverRequest/") || method.startsWith("item/mcpToolCall") || method.startsWith("item/commandExecution") || method.startsWith("item/fileChange") || method.startsWith("item/dynamicToolCall") || method.startsWith("item/collabAgentToolCall");
28505
28566
  forbiddenTerminalItem = (item) => ![
28506
28567
  "userMessage",
@@ -30840,7 +30901,7 @@ async function clearInferenceAgentNextState(statePath) {
30840
30901
  "Agent-driven inference next recovery state"
30841
30902
  );
30842
30903
  }
30843
- var inferenceAgentAttemptStatePath, inferenceAgentNextStatePath, inferenceAgentRuntimeStatePath, inferenceAgentFailureFencePath, isIsoTimestamp, assertPlainObject, hasExactKeys, assertInferenceAgentFailureFence, assertInferenceAgentRuntimeState, readCodexAgentRuntimeState, clearCodexAgentRuntimeState, foregroundAgentControlStatePath, assertRuntimeAssignment, assertForegroundAgentControlState, assertNextState, assertAttemptState;
30904
+ var inferenceAgentAttemptStatePath, inferenceAgentNextStatePath, assertDecisionTiming, inferenceAgentRuntimeStatePath, inferenceAgentFailureFencePath, isIsoTimestamp, assertPlainObject, hasExactKeys, assertInferenceAgentFailureFence, assertInferenceAgentRuntimeState, readCodexAgentRuntimeState, clearCodexAgentRuntimeState, foregroundAgentControlStatePath, assertRuntimeAssignment, assertForegroundAgentControlState, assertNextState, assertAttemptState;
30844
30905
  var init_agent_state = __esm({
30845
30906
  "lib/inference-host/agent-state.ts"() {
30846
30907
  "use strict";
@@ -30851,6 +30912,10 @@ var init_agent_state = __esm({
30851
30912
  init_external_inference_contract();
30852
30913
  inferenceAgentAttemptStatePath = (statePath) => `${statePath}.agent-attempt.json`;
30853
30914
  inferenceAgentNextStatePath = (statePath) => `${statePath}.agent-next.json`;
30915
+ assertDecisionTiming = (value, observedAt, message) => {
30916
+ const timing = assertPlainObject(value, message);
30917
+ if (!hasExactKeys(timing, ["analysis_started_at", "model_latency_ms", "model_latency_source"]) || !isIsoTimestamp(timing.analysis_started_at) || Date.parse(timing.analysis_started_at) > Date.parse(String(observedAt)) || (timing.model_latency_ms === null ? timing.model_latency_source !== null : !Number.isSafeInteger(timing.model_latency_ms) || Number(timing.model_latency_ms) < 0 || timing.model_latency_source !== "harness_invocation")) throw new Error(message);
30918
+ };
30854
30919
  inferenceAgentRuntimeStatePath = (statePath) => `${statePath}.codex-agent-runtime.json`;
30855
30920
  inferenceAgentFailureFencePath = (statePath) => `${statePath}.agent-failure-fence.json`;
30856
30921
  isIsoTimestamp = (value) => typeof value === "string" && Number.isFinite(Date.parse(value));
@@ -30962,9 +31027,14 @@ var init_agent_state = __esm({
30962
31027
  "observed_at",
30963
31028
  "provenance",
30964
31029
  "first_transmit_at",
30965
- "last_status_check_at"
31030
+ "last_status_check_at",
31031
+ ..."timing" in pending3 ? ["timing"] : []
30966
31032
  ]) || typeof pending3.operation_id !== "string" || !pending3.operation_id || !pending3.candidate || typeof pending3.candidate !== "object" || Array.isArray(pending3.candidate) || !isIsoTimestamp(pending3.observed_at) || pending3.provenance !== null && (typeof pending3.provenance !== "object" || Array.isArray(pending3.provenance)) || pending3.first_transmit_at !== null && !isIsoTimestamp(pending3.first_transmit_at) || pending3.last_status_check_at !== null && !isIsoTimestamp(pending3.last_status_check_at)) throw new Error(message);
30967
31033
  }
31034
+ if (state.pending_decision && "timing" in state.pending_decision) {
31035
+ const pending3 = state.pending_decision;
31036
+ assertDecisionTiming(pending3.timing, pending3.observed_at, message);
31037
+ }
30968
31038
  return state;
30969
31039
  };
30970
31040
  readCodexAgentRuntimeState = readInferenceAgentRuntimeState;
@@ -31012,9 +31082,15 @@ var init_agent_state = __esm({
31012
31082
  "pending_next",
31013
31083
  "pending_decision",
31014
31084
  "next_wake_at",
31015
- "updated_at"
31085
+ "updated_at",
31086
+ ..."review" in state ? ["review"] : []
31016
31087
  ]) || state.schema_version !== "vtx_foreground_agent_control_v1" || typeof state.host_id !== "string" || !state.host_id || state.next_wake_at !== null && !isIsoTimestamp(state.next_wake_at) || !isIsoTimestamp(state.updated_at)) throw new Error(message);
31017
31088
  if (state.assignment !== null) assertRuntimeAssignment(state.assignment, message);
31089
+ if (state.review !== void 0 && state.review !== null) {
31090
+ const review = assertPlainObject(state.review, message);
31091
+ const assignment = state.assignment;
31092
+ if (!hasExactKeys(review, ["assignment_id", "assignment_generation", "analysis_started_at"]) || !assignment || review.assignment_id !== assignment.assignment_id || review.assignment_generation !== assignment.assignment_generation || !isIsoTimestamp(review.analysis_started_at)) throw new Error(message);
31093
+ }
31018
31094
  if (state.pending_next !== null) {
31019
31095
  const pending3 = assertPlainObject(state.pending_next, message);
31020
31096
  if (!hasExactKeys(pending3, ["operation_id", "requested_at"]) || typeof pending3.operation_id !== "string" || !pending3.operation_id || !isIsoTimestamp(pending3.requested_at)) throw new Error(message);
@@ -31028,13 +31104,15 @@ var init_agent_state = __esm({
31028
31104
  "last_status_check_at"
31029
31105
  ])) throw new Error(message);
31030
31106
  const request = assertPlainObject(pending3.request, message);
31107
+ if ("timing" in request) assertDecisionTiming(request.timing, request.observed_at, message);
31031
31108
  if (!hasExactKeys(request, [
31032
31109
  "assignment_id",
31033
31110
  "assignment_generation",
31034
31111
  "operation_id",
31035
31112
  "candidate",
31036
31113
  "observed_at",
31037
- "provenance"
31114
+ "provenance",
31115
+ ..."timing" in request ? ["timing"] : []
31038
31116
  ]) || request.assignment_id !== state.assignment.assignment_id || request.assignment_generation !== state.assignment.assignment_generation || typeof request.operation_id !== "string" || !request.operation_id || !request.candidate || typeof request.candidate !== "object" || Array.isArray(request.candidate) || !isIsoTimestamp(request.observed_at) || !request.provenance || typeof request.provenance !== "object" || Array.isArray(request.provenance) || pending3.first_transmit_at !== null && !isIsoTimestamp(pending3.first_transmit_at) || pending3.last_status_check_at !== null && !isIsoTimestamp(pending3.last_status_check_at)) throw new Error(message);
31039
31117
  }
31040
31118
  return state;
@@ -31487,12 +31565,16 @@ var init_runner = __esm({
31487
31565
  started_at: startedAt
31488
31566
  });
31489
31567
  isoAt = (milliseconds) => new Date(milliseconds).toISOString();
31490
- providerWeeklyQuotaFromRateLimits = (rateLimits, observedAtMs, currentTimeMs = observedAtMs) => {
31568
+ providerWeeklyQuotaFromRateLimits = (rateLimits, observedAtMs, currentTimeMs = observedAtMs, includeCredits = true) => {
31491
31569
  if (!rateLimits) return null;
31492
31570
  for (const window2 of [rateLimits.rateLimits.primary, rateLimits.rateLimits.secondary]) {
31493
31571
  if (window2?.windowDurationMins !== 7 * 24 * 60 || window2.resetsAt === null || window2.resetsAt * 1e3 <= currentTimeMs) continue;
31494
31572
  return {
31495
31573
  source: "codex_app_server",
31574
+ ...includeCredits ? {
31575
+ credits_available: codexCreditsAvailable(rateLimits.rateLimits),
31576
+ rate_limit_reached: codexAccountRateLimitReached(rateLimits)
31577
+ } : {},
31496
31578
  used_percent: window2.usedPercent,
31497
31579
  resets_at: isoAt(window2.resetsAt * 1e3),
31498
31580
  observed_at: isoAt(observedAtMs)
@@ -31504,7 +31586,7 @@ var init_runner = __esm({
31504
31586
  const window2 = rateLimits.rateLimits[key];
31505
31587
  const known = previous?.[key];
31506
31588
  if (known && (!window2 || window2.windowDurationMins !== known.windowDurationMins)) return false;
31507
- return window2 === null || window2.resetsAt !== null && window2.resetsAt * 1e3 > nowMs && window2.usedPercent < 100;
31589
+ return window2 === null || window2.resetsAt !== null && window2.resetsAt * 1e3 > nowMs && (window2.usedPercent < 100 || codexCreditsAvailable(rateLimits.rateLimits));
31508
31590
  });
31509
31591
  finitePositiveOption = (value, fallback, label) => {
31510
31592
  const result2 = value ?? fallback;
@@ -32536,7 +32618,8 @@ var init_runner = __esm({
32536
32618
  provider_weekly_quota: providerWeeklyQuotaFromRateLimits(
32537
32619
  providerRateLimits,
32538
32620
  providerRateLimitsObservedAtMs,
32539
- now()
32621
+ now(),
32622
+ mcp.supportsProviderCredits?.() === true
32540
32623
  ),
32541
32624
  ...mcp.supportsProviderQuotaRecovery?.() === true && providerQuotaRecoveryObservedAtMs !== null && status === "healthy" && active.size === 0 && (providerRetryAtMs ?? 0) <= now() && providerFailureRetryAtMs <= now() && now() - providerQuotaRecoveryObservedAtMs <= 2 * settings.providerRateLimitRefreshMs && providerRateLimits !== null && usableProviderQuotaSnapshot(providerRateLimits, knownProviderQuotaSnapshot, now()) ? { provider_quota_recovery: {
32542
32625
  source: "codex_app_server",
@@ -33154,14 +33237,7 @@ var init_runner = __esm({
33154
33237
  providerRetryAtMs = Math.max(providerRetryAtMs ?? 0, refreshedRetryAt);
33155
33238
  providerCooldownReason = "provider_limit_snapshot";
33156
33239
  retainQuotaSnapshot(providerRateLimits);
33157
- } else if (providerRetryAtMs !== null && !codexAccountRateLimitReached(providerRateLimits) && providerRateLimits.rateLimits.limitId === providerQuotaSnapshot?.limitId && [providerRateLimits.rateLimits.primary, providerRateLimits.rateLimits.secondary].some((window2) => window2 !== null) && ["primary", "secondary"].every((key) => {
33158
- const window2 = refreshedRateLimits.rateLimits[key];
33159
- const previous = providerQuotaSnapshot?.[key];
33160
- if (previous && (!window2 || window2.windowDurationMins !== previous.windowDurationMins)) {
33161
- return false;
33162
- }
33163
- return window2 === null || window2.resetsAt !== null && window2.resetsAt * 1e3 > refreshedAt && window2.usedPercent < 100;
33164
- })) {
33240
+ } else if (providerRetryAtMs !== null && usableProviderQuotaSnapshot(providerRateLimits, providerQuotaSnapshot, refreshedAt)) {
33165
33241
  emitDiagnostic("provider_cooldown_cleared", {
33166
33242
  reason: providerCooldownReason,
33167
33243
  recovery: "provider_quota_restored",
@@ -34956,6 +35032,11 @@ var init_runner = __esm({
34956
35032
  operation_id: randomUUID(),
34957
35033
  candidate,
34958
35034
  observed_at: nowIso(),
35035
+ timing: {
35036
+ analysis_started_at: state.pending_turn.started_at,
35037
+ model_latency_ms: null,
35038
+ model_latency_source: null
35039
+ },
34959
35040
  provenance: {
34960
35041
  source: "external_agent",
34961
35042
  agent_run_id: liveThread.threadId,
@@ -34993,6 +35074,7 @@ var init_runner = __esm({
34993
35074
  operation_id: pending3.operation_id,
34994
35075
  candidate: pending3.candidate,
34995
35076
  observed_at: pending3.observed_at,
35077
+ ...pending3.timing ? { timing: pending3.timing } : {},
34996
35078
  provenance: pending3.provenance
34997
35079
  }, { signal: turnAbort.signal });
34998
35080
  } catch {
@@ -42609,6 +42691,14 @@ var init_runtime_policy_generated2 = __esm({
42609
42691
  min_delay_milliseconds: 250,
42610
42692
  max_delay_milliseconds: 1e4
42611
42693
  },
42694
+ trade_refresh_policy: {
42695
+ server_config_stream_timeout_ms: 1e4,
42696
+ config_retry_interval_ms: 5e3,
42697
+ copy_trading_status_poll_ms: 5e3,
42698
+ post_execution_refresh_delay_ms: 3e3,
42699
+ account_read_backoff_min_ms: 2e3,
42700
+ account_read_backoff_max_ms: 6e4
42701
+ },
42612
42702
  deployment_reload_observability: {
42613
42703
  bootstrap_max_error_events_per_page: 4,
42614
42704
  bootstrap_max_profiles: 10
@@ -42686,10 +42776,12 @@ var init_runtime_policy_generated2 = __esm({
42686
42776
  },
42687
42777
  server_runtime: {
42688
42778
  prompt_rescue: {
42779
+ request_ttl_seconds: 20,
42689
42780
  snapshot_max_age_seconds: 5,
42690
42781
  snapshot_component_max_skew_seconds: 2,
42691
- client_long_poll_seconds: 20,
42692
- client_claim_http_timeout_milliseconds: 25e3,
42782
+ client_claim_http_timeout_milliseconds: 5e3,
42783
+ client_claim_retry_delay_milliseconds: 1e3,
42784
+ client_failure_report_timeout_milliseconds: 2e3,
42693
42785
  client_presence_heartbeat_interval_milliseconds: 3e4,
42694
42786
  client_presence_http_timeout_milliseconds: 5e3
42695
42787
  }
@@ -44537,6 +44629,13 @@ async function runInferenceHostCli(argv2, env = process.env, dependencies = {})
44537
44629
  dependencies
44538
44630
  );
44539
44631
  }
44632
+ if (parsed.command === "agent-review-begin") {
44633
+ return await withAgentCommandLock(
44634
+ config2,
44635
+ async () => await foregroundReviewBegin(config2, parsed, dependencies, warnings),
44636
+ dependencies
44637
+ );
44638
+ }
44540
44639
  if (parsed.command === "agent-data-call") {
44541
44640
  return await foregroundDataCall(config2, parsed, dependencies, warnings);
44542
44641
  }
@@ -44597,7 +44696,7 @@ async function runInferenceHostCli(argv2, env = process.env, dependencies = {})
44597
44696
  return await cleanupLogin(config2, parsed, dependencies, warnings, true);
44598
44697
  }
44599
44698
  throw new Error(
44600
- "Usage: vtx inference-host <login|codex-login|grok-login|deepseek-login|pi-login|exo-login|run|agent-connect|agent-run|agent-next|agent-complete|agent-fail|agent-assignment-next|agent-assignment-heartbeat|agent-data-call|agent-decision-submit|agent-decision-status|agent-assignment-release|service|status|doctor|logout|codex-logout|grok-logout|deepseek-logout|pi-logout|exo-logout|revoke> [--json]"
44699
+ "Usage: vtx inference-host <login|codex-login|grok-login|deepseek-login|pi-login|exo-login|run|agent-connect|agent-run|agent-next|agent-complete|agent-fail|agent-assignment-next|agent-assignment-heartbeat|agent-review-begin|agent-data-call|agent-decision-submit|agent-decision-status|agent-assignment-release|service|status|doctor|logout|codex-logout|grok-logout|deepseek-logout|pi-logout|exo-logout|revoke> [--json]"
44601
44700
  );
44602
44701
  } catch (error48) {
44603
44702
  return {
@@ -44608,7 +44707,7 @@ async function runInferenceHostCli(argv2, env = process.env, dependencies = {})
44608
44707
  };
44609
44708
  }
44610
44709
  }
44611
- var INFERENCE_HOST_CLI_VERSION, runtimeReceiptPath, codexRecoveryPath, codexGuardianReceiptRoot, revocationCheckpointPath, foregroundHostLockPath, credentialLifecycleLockPath, serviceRecoveryCommandLockPath, AGENT_HEARTBEAT_INTERVAL_MS, AGENT_HEARTBEAT_MAX_RETRY_DELAY_MS, retryableAgentHeartbeatError, assertRevocationCheckpoint, readRevocationCheckpoint, writeRevocationCheckpoint, clearRevocationCheckpoint, render, INFERENCE_HOST_HELP, parseHostConcurrency, parseInferenceHostArgs, resolveDurableServiceDisplayName, defaultOpenBrowser, registerInferenceHostServiceControlInput, defaultRegisterLifecycleSignalHandlers, lifecycleCancellation, configuredCredentialStore, restoreInferenceHostCredentialContext, recoverInferenceHostCredentialContextTransition, accountKeyForState, assertCredentialMatchesState2, revocationCheckpointForCredential, assertRevocationCheckpointMatchesLocalIdentity, fileExistsPrivately, inspectCodexAuthentication, clearLocalRuntimeArtifacts, assertDurableServiceUninstalled, assertLocalRuntimeArtifactsMayBeDiscarded, defaultRunForeground, preparePortableDurableAdapter, prepareExoAdapter, defaultRunPortableDurableAdapter, login, codexLogin, codexLogout, grokAuthentication, deepSeekCredentialStore, deepSeekLogin, deepSeekLogout, piLogin, piLogout, exoLogin, exoLogout, localStatus, doctor, cleanupLogin, runHost, defaultReadStdin, parseAgentStdin, parseOptionalAgentStdin, agentOperationId, agentSession, agentConnect, foregroundAgentControlState, requireForegroundAgentState, assignmentFromClaim, foregroundAssignmentNext, foregroundAssignmentHeartbeat, foregroundDataCall, foregroundDecisionStatusRequest, foregroundAssignmentLeaseEnded, handleForegroundCancelledAssignment, foregroundDecisionFollowup, foregroundDecisionStatus, foregroundDecisionSubmit, foregroundAssignmentRelease, agentRun, agentNext, agentComplete, agentFail, withAgentCommandLock, recoveryBackupPath, serviceRecoveryTransactionPath, readServiceRecoveryTransaction, assertResumableCodexRecoveryEvidence, recoverInstalledCodexService, serviceCommand, hasExplicitCredentialStoreConfiguration, credentialEnvironmentForIdentity, commandRequiresRetainedCredentialStore, commandUsesInstalledServiceCredentials, resolveInferenceHostCommandConfig;
44710
+ var INFERENCE_HOST_CLI_VERSION, runtimeReceiptPath, codexRecoveryPath, codexGuardianReceiptRoot, revocationCheckpointPath, foregroundHostLockPath, credentialLifecycleLockPath, serviceRecoveryCommandLockPath, AGENT_HEARTBEAT_INTERVAL_MS, AGENT_HEARTBEAT_MAX_RETRY_DELAY_MS, retryableAgentHeartbeatError, assertRevocationCheckpoint, readRevocationCheckpoint, writeRevocationCheckpoint, clearRevocationCheckpoint, render, INFERENCE_HOST_HELP, parseHostConcurrency, parseInferenceHostArgs, resolveDurableServiceDisplayName, defaultOpenBrowser, registerInferenceHostServiceControlInput, defaultRegisterLifecycleSignalHandlers, lifecycleCancellation, configuredCredentialStore, restoreInferenceHostCredentialContext, recoverInferenceHostCredentialContextTransition, accountKeyForState, assertCredentialMatchesState2, revocationCheckpointForCredential, assertRevocationCheckpointMatchesLocalIdentity, fileExistsPrivately, inspectCodexAuthentication, clearLocalRuntimeArtifacts, assertDurableServiceUninstalled, assertLocalRuntimeArtifactsMayBeDiscarded, defaultRunForeground, preparePortableDurableAdapter, prepareExoAdapter, defaultRunPortableDurableAdapter, login, codexLogin, codexLogout, grokAuthentication, deepSeekCredentialStore, deepSeekLogin, deepSeekLogout, piLogin, piLogout, exoLogin, exoLogout, localStatus, doctor, cleanupLogin, runHost, defaultReadStdin, parseAgentStdin, parseOptionalAgentStdin, agentOperationId, agentSession, agentConnect, foregroundAgentControlState, requireForegroundAgentState, assignmentFromClaim, foregroundAssignmentNext, foregroundAssignmentHeartbeat, foregroundReviewBegin, foregroundDataCall, foregroundDecisionStatusRequest, foregroundAssignmentLeaseEnded, handleForegroundCancelledAssignment, foregroundDecisionFollowup, foregroundDecisionStatus, foregroundDecisionSubmit, foregroundAssignmentRelease, agentRun, agentNext, agentComplete, agentFail, withAgentCommandLock, recoveryBackupPath, serviceRecoveryTransactionPath, readServiceRecoveryTransaction, assertResumableCodexRecoveryEvidence, recoverInstalledCodexService, serviceCommand, hasExplicitCredentialStoreConfiguration, credentialEnvironmentForIdentity, commandRequiresRetainedCredentialStore, commandUsesInstalledServiceCredentials, resolveInferenceHostCommandConfig;
44612
44711
  var init_cli = __esm({
44613
44712
  "lib/inference-host/cli.ts"() {
44614
44713
  "use strict";
@@ -44729,6 +44828,7 @@ Commands:
44729
44828
  agent-fail Submit one truthful agent failure from stdin
44730
44829
  agent-assignment-next Claim the assigned Main bot for Agent control
44731
44830
  agent-assignment-heartbeat Renew the current Agent assignment
44831
+ agent-review-begin Record review start before reading decision context
44732
44832
  agent-data-call Request allowed assignment-scoped VTX data
44733
44833
  agent-decision-submit Submit the normal structured trading decision
44734
44834
  agent-decision-status Read a submitted decision outcome or recover uncertain submission
@@ -46446,6 +46546,7 @@ Waiting for approval...
46446
46546
  state = {
46447
46547
  ...state,
46448
46548
  assignment,
46549
+ review: state.assignment?.assignment_id === assignment.assignment_id && state.assignment?.assignment_generation === assignment.assignment_generation ? state.review ?? null : null,
46449
46550
  pending_next: null,
46450
46551
  next_wake_at: null,
46451
46552
  updated_at: now().toISOString()
@@ -46462,7 +46563,8 @@ Waiting for approval...
46462
46563
  exitCode: 0,
46463
46564
  stdout: render({
46464
46565
  ...result2,
46465
- instructions: "Use your harness scheduler for the requested cadence and keep agent-run open for liveness. Use agent-data-call for canonical VTX data and your authorized native Insights/external tools. Trading JSON is optional; submit a decision only when you choose, using the exact output_schema. The keeper does not schedule or restart your harness.",
46566
+ instructions: "Use your harness scheduler for the requested cadence and keep agent-run open for liveness. Call agent-review-begin before each review to record its actual analysis start. Use agent-data-call for canonical VTX data and your authorized native Insights/external tools. Trading JSON is optional; submit a decision only when you choose, using the exact output_schema. The keeper does not schedule or restart your harness.",
46567
+ review_begin_command: "vtx inference-host agent-review-begin --json",
46466
46568
  data_command: "vtx inference-host agent-data-call --json",
46467
46569
  decision_command: "vtx inference-host agent-decision-submit --json",
46468
46570
  decision_input: {
@@ -46532,6 +46634,31 @@ Waiting for approval...
46532
46634
  ` : ""
46533
46635
  };
46534
46636
  };
46637
+ foregroundReviewBegin = async (config2, parsed, dependencies, warnings) => {
46638
+ const session = await agentSession(config2, dependencies, warnings);
46639
+ const state = await requireForegroundAgentState(config2, session.localState.host_id);
46640
+ if (state.pending_decision || state.pending_next) {
46641
+ throw new Error("Resolve the pending Agent operation before beginning a review.");
46642
+ }
46643
+ await parseOptionalAgentStdin(dependencies, []);
46644
+ const startedAt = (dependencies.now ?? (() => /* @__PURE__ */ new Date()))().toISOString();
46645
+ const review = {
46646
+ assignment_id: state.assignment.assignment_id,
46647
+ assignment_generation: state.assignment.assignment_generation,
46648
+ analysis_started_at: startedAt
46649
+ };
46650
+ await writeInferenceForegroundAgentControlState(config2.statePath, {
46651
+ ...state,
46652
+ review,
46653
+ updated_at: startedAt
46654
+ });
46655
+ return { exitCode: 0, stdout: render({
46656
+ ...review,
46657
+ model_latency_ms: null,
46658
+ model_latency_source: null
46659
+ }, parsed.json), stderr: warnings.length ? `${warnings.join("\n")}
46660
+ ` : "" };
46661
+ };
46535
46662
  foregroundDataCall = async (config2, parsed, dependencies, warnings) => {
46536
46663
  const session = await agentSession(config2, dependencies, warnings);
46537
46664
  const state = await withAgentCommandLock(
@@ -46671,6 +46798,7 @@ Waiting for approval...
46671
46798
  const observedAt = now().toISOString();
46672
46799
  state = {
46673
46800
  ...state,
46801
+ review: null,
46674
46802
  pending_decision: {
46675
46803
  request: {
46676
46804
  assignment_id: state.assignment.assignment_id,
@@ -46678,6 +46806,11 @@ Waiting for approval...
46678
46806
  operation_id: agentOperationId("agent-decision-submit"),
46679
46807
  candidate: input.candidate,
46680
46808
  observed_at: observedAt,
46809
+ ...state.review ? { timing: {
46810
+ analysis_started_at: state.review.analysis_started_at,
46811
+ model_latency_ms: null,
46812
+ model_latency_source: null
46813
+ } } : {},
46681
46814
  provenance: input.provenance
46682
46815
  },
46683
46816
  first_transmit_at: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtxmacro/cli",
3
- "version": "2026.9.66",
3
+ "version": "2026.9.68",
4
4
  "description": "VTX Macro CLI, MCP server, and durable external inference host.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",