@vtxmacro/cli 2026.9.24 → 2026.9.26

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.
@@ -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.24",
19
+ package_version: "2026.9.26",
20
20
  codex_package_name: "@openai/codex",
21
21
  codex_version: "0.153.3",
22
22
  copilot_sdk_package_name: "@github/copilot-sdk",
package/bin/vtx.js CHANGED
@@ -69,7 +69,7 @@ var init_agent_cli_release = __esm({
69
69
  "agent-cli-release.json"() {
70
70
  agent_cli_release_default = {
71
71
  package_name: "@vtxmacro/cli",
72
- package_version: "2026.9.24",
72
+ package_version: "2026.9.26",
73
73
  codex_package_name: "@openai/codex",
74
74
  codex_version: "0.153.3",
75
75
  copilot_sdk_package_name: "@github/copilot-sdk",
@@ -19221,7 +19221,7 @@ ${body}`;
19221
19221
  });
19222
19222
 
19223
19223
  // lib/inference-host/mcp-client.ts
19224
- var EXTERNAL_INFERENCE_MCP_PROTOCOL_VERSION, EXTERNAL_INFERENCE_AUTOMATED_HOST_TOOLS, EXTERNAL_INFERENCE_OPERATIONAL_TOOLS, 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;
19224
+ 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;
19225
19225
  var init_mcp_client = __esm({
19226
19226
  "lib/inference-host/mcp-client.ts"() {
19227
19227
  "use strict";
@@ -19254,6 +19254,42 @@ var init_mcp_client = __esm({
19254
19254
  "inference.agent.complete",
19255
19255
  "inference.agent.fail"
19256
19256
  ];
19257
+ ClaimTiming = class {
19258
+ constructor() {
19259
+ this.startedAt = performance.now();
19260
+ this.changedAt = this.startedAt;
19261
+ this.phase = "other_ms";
19262
+ this.finished = false;
19263
+ this.elapsed = {
19264
+ token_lookup_ms: 0,
19265
+ fetch_headers_ms: 0,
19266
+ body_reception_ms: 0,
19267
+ response_parse_ms: 0,
19268
+ response_validation_ms: 0,
19269
+ other_ms: 0
19270
+ };
19271
+ this.transportAttempts = 0;
19272
+ this.tokenRefreshes = 0;
19273
+ }
19274
+ enter(phase) {
19275
+ if (this.finished) return;
19276
+ const at = performance.now();
19277
+ this.elapsed[this.phase] += Math.max(0, at - this.changedAt);
19278
+ this.changedAt = at;
19279
+ this.phase = phase;
19280
+ }
19281
+ finish(outcome) {
19282
+ this.enter("other_ms");
19283
+ this.finished = true;
19284
+ return Object.freeze({
19285
+ ...this.elapsed,
19286
+ total_ms: Math.max(0, this.changedAt - this.startedAt),
19287
+ transport_attempts: this.transportAttempts,
19288
+ token_refreshes: this.tokenRefreshes,
19289
+ outcome
19290
+ });
19291
+ }
19292
+ };
19257
19293
  ExternalInferenceMcpError = class extends Error {
19258
19294
  constructor(code, message, options = {}) {
19259
19295
  super(message, { cause: options.cause });
@@ -19662,9 +19698,11 @@ var init_mcp_client = __esm({
19662
19698
  }
19663
19699
  return documents;
19664
19700
  };
19665
- parseResponseDocuments = async (response) => {
19701
+ parseResponseDocuments = async (response, timing) => {
19666
19702
  const contentType = String(response.headers.get("content-type") || "").split(";", 1)[0].trim().toLowerCase();
19703
+ timing?.enter("body_reception_ms");
19667
19704
  const body = await response.text();
19705
+ timing?.enter("response_parse_ms");
19668
19706
  if (contentType === "application/json") return [parseJsonDocument(body)];
19669
19707
  if (contentType === "text/event-stream") return parseSseDocuments(body);
19670
19708
  throw new ExternalInferenceMcpError(
@@ -19852,75 +19890,90 @@ var init_mcp_client = __esm({
19852
19890
  this.#initialized = true;
19853
19891
  }
19854
19892
  async callTool(name, argumentsValue, options = {}) {
19855
- if (!this.#initialized) {
19856
- throw new ExternalInferenceMcpError(
19857
- "not_initialized",
19858
- "Insights MCP inventory must be verified before calling an inference operation."
19859
- );
19860
- }
19861
- const contract = toolContracts[name];
19862
- const argumentsDocument = contract.arguments.parse(argumentsValue);
19863
- const rawResult = await this.#request(
19864
- "tools/call",
19865
- { name, arguments: argumentsDocument },
19866
- name,
19867
- options
19868
- );
19869
- const callResult = external_exports.object({
19870
- isError: external_exports.boolean().optional(),
19871
- content: external_exports.array(external_exports.object({
19872
- type: external_exports.string(),
19873
- text: external_exports.string().optional()
19874
- }).passthrough()).optional(),
19875
- structuredContent: external_exports.unknown()
19876
- }).passthrough().parse(rawResult);
19877
- if (callResult.isError === true) {
19878
- const errorText = (callResult.content ?? []).filter((block) => block.type === "text").map((block) => block.text ?? "").join("\n");
19879
- const structuredPublicToolError = structuredPublicToolErrorSchema.safeParse(
19880
- callResult.structuredContent
19881
- );
19882
- const structuredDocument = callResult.structuredContent !== null && typeof callResult.structuredContent === "object" && !Array.isArray(callResult.structuredContent) ? callResult.structuredContent : null;
19883
- const hasStructuredPublicToolErrorMarker = structuredDocument?.schema_version === "vtx_insights_tool_error_v1";
19884
- const publicToolError = structuredPublicToolError.success ? structuredPublicToolError.data : hasStructuredPublicToolErrorMarker ? null : parsePublicToolError(errorText);
19885
- const hasPublicToolErrorMarker = hasStructuredPublicToolErrorMarker || errorText.includes(PUBLIC_TOOL_ERROR_PREFIX);
19886
- const completionEvidenceExpired = name === "inference.job.complete" && (publicToolError ? publicToolError.failure_code === "completion_evidence_expired" && publicToolError.phase === "validation" && publicToolError.retryable === false && publicToolError.terminal_before_execution === true : !hasPublicToolErrorMarker && errorText.includes("External inference completion evidence window expired"));
19887
- const hostNotClaimable = name === "inference.job.claim" && publicToolError?.failure_code === "host_not_claimable" && publicToolError.phase === "admission" && publicToolError.retryable === true && publicToolError.terminal_before_execution === true;
19888
- const definitivelyNotApplied = name === "inference.agent.decision.submit" && publicToolError?.phase === "validation" && publicToolError.retryable === false && publicToolError.terminal_before_execution === true && (publicToolError.failure_code === "agent_decision_schema_invalid" || publicToolError.failure_code === "invalid_arguments" && publicToolError.reason_code === "schema_validation") || (name === "inference.host.register" || name === "inference.host.advertise") && (errorText.includes("Advertisement time is outside the allowed clock skew.") || errorText.includes("Advertisement is already expired.")) || (name === "inference.agent.next" || name === "inference.agent.heartbeat") && (errorText.includes("Advertisement time is outside the allowed clock skew.") || errorText.includes("Advertisement is already expired.") || errorText.includes("Heartbeat time is outside the allowed clock skew.")) || name === "inference.host.heartbeat" && errorText.includes("Heartbeat time is outside the allowed clock skew.") || name === "inference.job.claim" && (errorText.includes(
19889
- "External inference claim request was not applied before its generation became stale"
19890
- ) || errorText.includes("External inference host advertisement is expired or superseded")) || name === "inference.job.complete" && completionEvidenceExpired;
19891
- const retryableInfrastructureRejection = EXTERNAL_INFERENCE_AUTOMATED_HOST_TOOLS.includes(name) && (errorText.includes("External inference polling is at its configured concurrency limit") || errorText.includes("The Insights action reached the response timeout") || errorText.includes("Insights capability failed without exposing private runtime details"));
19892
- const retryableClaimRejection = name === "inference.job.claim" && !definitivelyNotApplied && (retryableInfrastructureRejection || hostNotClaimable || errorText.includes("External inference host is not live enough to claim work") || errorText.includes("External inference host request generation is stale") || errorText.includes("External inference claim runtime fence is stale"));
19893
- const retryableHeartbeatClockSkew = name === "inference.host.heartbeat" && definitivelyNotApplied;
19894
- const retryableAdvertisementClockSkew = (name === "inference.host.register" || name === "inference.host.advertise") && definitivelyNotApplied;
19895
- const staleHostHeartbeatGeneration = name === "inference.host.heartbeat" && errorText.includes("Heartbeat generations do not match the current host authority.");
19896
- const obsoleteClaimReplay = name === "inference.job.claim" && errorText.includes(
19897
- "External inference claim replay is no longer dispatchable"
19893
+ const timing = name === "inference.job.claim" && options.onClaimTiming ? new ClaimTiming() : void 0;
19894
+ let outcome = "failure";
19895
+ try {
19896
+ if (!this.#initialized) {
19897
+ throw new ExternalInferenceMcpError(
19898
+ "not_initialized",
19899
+ "Insights MCP inventory must be verified before calling an inference operation."
19900
+ );
19901
+ }
19902
+ const contract = toolContracts[name];
19903
+ const argumentsDocument = contract.arguments.parse(argumentsValue);
19904
+ const rawResult = await this.#request(
19905
+ "tools/call",
19906
+ { name, arguments: argumentsDocument },
19907
+ name,
19908
+ options,
19909
+ timing
19898
19910
  );
19899
- throw new ExternalInferenceMcpError(
19900
- completionEvidenceExpired ? "completion_evidence_expired" : staleHostHeartbeatGeneration ? "generation_stale" : obsoleteClaimReplay ? "claim_replay_obsolete" : "tool_rejected",
19901
- `Insights MCP rejected ${name}.`,
19902
- {
19903
- definitivelyNotApplied: definitivelyNotApplied || staleHostHeartbeatGeneration,
19904
- // Claim polling is an idempotent control-plane operation. During an
19905
- // API rotation the MCP server can return a tool error after the
19906
- // request reached the application boundary, so retain and replay
19907
- // the exact request unless the server proves it was not applied.
19908
- retryable: retryableInfrastructureRejection || retryableClaimRejection || retryableHeartbeatClockSkew || retryableAdvertisementClockSkew,
19909
- serverFailureCode: publicToolError?.failure_code ?? null,
19910
- retryAfterMs: hostNotClaimable ? publicToolError?.retry_after_ms ?? null : null
19911
+ timing?.enter("response_validation_ms");
19912
+ const callResult = external_exports.object({
19913
+ isError: external_exports.boolean().optional(),
19914
+ content: external_exports.array(external_exports.object({
19915
+ type: external_exports.string(),
19916
+ text: external_exports.string().optional()
19917
+ }).passthrough()).optional(),
19918
+ structuredContent: external_exports.unknown()
19919
+ }).passthrough().parse(rawResult);
19920
+ if (callResult.isError === true) {
19921
+ const errorText = (callResult.content ?? []).filter((block) => block.type === "text").map((block) => block.text ?? "").join("\n");
19922
+ const structuredPublicToolError = structuredPublicToolErrorSchema.safeParse(
19923
+ callResult.structuredContent
19924
+ );
19925
+ const structuredDocument = callResult.structuredContent !== null && typeof callResult.structuredContent === "object" && !Array.isArray(callResult.structuredContent) ? callResult.structuredContent : null;
19926
+ const hasStructuredPublicToolErrorMarker = structuredDocument?.schema_version === "vtx_insights_tool_error_v1";
19927
+ const publicToolError = structuredPublicToolError.success ? structuredPublicToolError.data : hasStructuredPublicToolErrorMarker ? null : parsePublicToolError(errorText);
19928
+ const hasPublicToolErrorMarker = hasStructuredPublicToolErrorMarker || errorText.includes(PUBLIC_TOOL_ERROR_PREFIX);
19929
+ const completionEvidenceExpired = name === "inference.job.complete" && (publicToolError ? publicToolError.failure_code === "completion_evidence_expired" && publicToolError.phase === "validation" && publicToolError.retryable === false && publicToolError.terminal_before_execution === true : !hasPublicToolErrorMarker && errorText.includes("External inference completion evidence window expired"));
19930
+ const hostNotClaimable = name === "inference.job.claim" && publicToolError?.failure_code === "host_not_claimable" && publicToolError.phase === "admission" && publicToolError.retryable === true && publicToolError.terminal_before_execution === true;
19931
+ const definitivelyNotApplied = name === "inference.agent.decision.submit" && publicToolError?.phase === "validation" && publicToolError.retryable === false && publicToolError.terminal_before_execution === true && (publicToolError.failure_code === "agent_decision_schema_invalid" || publicToolError.failure_code === "invalid_arguments" && publicToolError.reason_code === "schema_validation") || (name === "inference.host.register" || name === "inference.host.advertise") && (errorText.includes("Advertisement time is outside the allowed clock skew.") || errorText.includes("Advertisement is already expired.")) || (name === "inference.agent.next" || name === "inference.agent.heartbeat") && (errorText.includes("Advertisement time is outside the allowed clock skew.") || errorText.includes("Advertisement is already expired.") || errorText.includes("Heartbeat time is outside the allowed clock skew.")) || name === "inference.host.heartbeat" && errorText.includes("Heartbeat time is outside the allowed clock skew.") || name === "inference.job.claim" && (errorText.includes(
19932
+ "External inference claim request was not applied before its generation became stale"
19933
+ ) || errorText.includes("External inference host advertisement is expired or superseded")) || name === "inference.job.complete" && completionEvidenceExpired;
19934
+ const retryableInfrastructureRejection = EXTERNAL_INFERENCE_AUTOMATED_HOST_TOOLS.includes(name) && (errorText.includes("External inference polling is at its configured concurrency limit") || errorText.includes("The Insights action reached the response timeout") || errorText.includes("Insights capability failed without exposing private runtime details"));
19935
+ const retryableClaimRejection = name === "inference.job.claim" && !definitivelyNotApplied && (retryableInfrastructureRejection || hostNotClaimable || errorText.includes("External inference host is not live enough to claim work") || errorText.includes("External inference host request generation is stale") || errorText.includes("External inference claim runtime fence is stale"));
19936
+ const retryableHeartbeatClockSkew = name === "inference.host.heartbeat" && definitivelyNotApplied;
19937
+ const retryableAdvertisementClockSkew = (name === "inference.host.register" || name === "inference.host.advertise") && definitivelyNotApplied;
19938
+ const staleHostHeartbeatGeneration = name === "inference.host.heartbeat" && errorText.includes("Heartbeat generations do not match the current host authority.");
19939
+ const obsoleteClaimReplay = name === "inference.job.claim" && errorText.includes(
19940
+ "External inference claim replay is no longer dispatchable"
19941
+ );
19942
+ throw new ExternalInferenceMcpError(
19943
+ completionEvidenceExpired ? "completion_evidence_expired" : staleHostHeartbeatGeneration ? "generation_stale" : obsoleteClaimReplay ? "claim_replay_obsolete" : "tool_rejected",
19944
+ `Insights MCP rejected ${name}.`,
19945
+ {
19946
+ definitivelyNotApplied: definitivelyNotApplied || staleHostHeartbeatGeneration,
19947
+ // Claim polling is an idempotent control-plane operation. During an
19948
+ // API rotation the MCP server can return a tool error after the
19949
+ // request reached the application boundary, so retain and replay
19950
+ // the exact request unless the server proves it was not applied.
19951
+ retryable: retryableInfrastructureRejection || retryableClaimRejection || retryableHeartbeatClockSkew || retryableAdvertisementClockSkew,
19952
+ serverFailureCode: publicToolError?.failure_code ?? null,
19953
+ retryAfterMs: hostNotClaimable ? publicToolError?.retry_after_ms ?? null : null
19954
+ }
19955
+ );
19956
+ }
19957
+ const structured = inlineStructuredContentSchema.parse(callResult.structuredContent);
19958
+ if (structured.capability !== name) {
19959
+ throw new ExternalInferenceMcpError(
19960
+ "invalid_response",
19961
+ "Insights MCP returned a result for a different capability."
19962
+ );
19963
+ }
19964
+ const result2 = contract.result.parse(structured.result);
19965
+ verifyToolResult(name, argumentsDocument, result2);
19966
+ outcome = "success";
19967
+ return result2;
19968
+ } finally {
19969
+ if (timing) {
19970
+ const receipt = timing.finish(outcome);
19971
+ try {
19972
+ void Promise.resolve(options.onClaimTiming?.(receipt)).catch(() => void 0);
19973
+ } catch {
19911
19974
  }
19912
- );
19913
- }
19914
- const structured = inlineStructuredContentSchema.parse(callResult.structuredContent);
19915
- if (structured.capability !== name) {
19916
- throw new ExternalInferenceMcpError(
19917
- "invalid_response",
19918
- "Insights MCP returned a result for a different capability."
19919
- );
19975
+ }
19920
19976
  }
19921
- const result2 = contract.result.parse(structured.result);
19922
- verifyToolResult(name, argumentsDocument, result2);
19923
- return result2;
19924
19977
  }
19925
19978
  async #token(refresh, options) {
19926
19979
  try {
@@ -19944,7 +19997,7 @@ var init_mcp_client = __esm({
19944
19997
  );
19945
19998
  }
19946
19999
  }
19947
- async #request(method, params, name, options = {}) {
20000
+ async #request(method, params, name, options = {}, timing) {
19948
20001
  const timeoutMs = options.timeoutMs ?? this.#requestTimeoutMs;
19949
20002
  if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1) {
19950
20003
  throw new ExternalInferenceMcpError(
@@ -19968,22 +20021,32 @@ var init_mcp_client = __esm({
19968
20021
  _meta: protocolMeta(this.#clientName, this.#clientVersion)
19969
20022
  }
19970
20023
  };
20024
+ timing?.enter("token_lookup_ms");
20025
+ const token = await this.#token(false, boundedOptions);
20026
+ timing?.enter("fetch_headers_ms");
20027
+ if (timing) timing.transportAttempts += 1;
19971
20028
  let response = await this.#send(
19972
20029
  method,
19973
20030
  name,
19974
20031
  body,
19975
- await this.#token(false, boundedOptions),
20032
+ token,
19976
20033
  boundedOptions
19977
20034
  );
19978
20035
  if (response.status === 401 && this.#tokenSource.refreshAccessToken) {
20036
+ timing?.enter("token_lookup_ms");
20037
+ if (timing) timing.tokenRefreshes += 1;
20038
+ const refreshedToken = await this.#token(true, boundedOptions);
20039
+ timing?.enter("fetch_headers_ms");
20040
+ if (timing) timing.transportAttempts += 1;
19979
20041
  response = await this.#send(
19980
20042
  method,
19981
20043
  name,
19982
20044
  body,
19983
- await this.#token(true, boundedOptions),
20045
+ refreshedToken,
19984
20046
  boundedOptions
19985
20047
  );
19986
20048
  }
20049
+ timing?.enter("other_ms");
19987
20050
  if (!response.ok) {
19988
20051
  const httpStatusCode = response.status;
19989
20052
  const retryAfterMs = parseRetryAfterMs(response);
@@ -19998,7 +20061,7 @@ var init_mcp_client = __esm({
19998
20061
  let documents;
19999
20062
  try {
20000
20063
  documents = await this.#bounded(
20001
- parseResponseDocuments(response),
20064
+ parseResponseDocuments(response, timing),
20002
20065
  boundedOptions,
20003
20066
  "request_timeout"
20004
20067
  );
@@ -20006,6 +20069,7 @@ var init_mcp_client = __esm({
20006
20069
  await response.body?.cancel().catch(() => void 0);
20007
20070
  throw error48;
20008
20071
  }
20072
+ timing?.enter("response_validation_ms");
20009
20073
  const document2 = documents.find((candidate) => candidate.id === requestId);
20010
20074
  if (!document2 || document2.jsonrpc !== "2.0") {
20011
20075
  throw new ExternalInferenceMcpError(
@@ -37396,6 +37460,7 @@ var init_runner = __esm({
37396
37460
  const request = receipt.pending_claim_request;
37397
37461
  if (request === claimPreparation.unsent && Date.parse(receipt.advertisement_expires_at ?? "") <= now()) break;
37398
37462
  let claim;
37463
+ let claimTiming;
37399
37464
  const claimCallStartedAtMs = now();
37400
37465
  try {
37401
37466
  claimOpportunities += 1;
@@ -37405,6 +37470,9 @@ var init_runner = __esm({
37405
37470
  request,
37406
37471
  {
37407
37472
  signal: this.options.signal,
37473
+ onClaimTiming: (timing) => {
37474
+ claimTiming = timing;
37475
+ },
37408
37476
  ...yieldRenewalToClaim ? { deadlineAtMs: expiresAt } : {}
37409
37477
  }
37410
37478
  );
@@ -37506,6 +37574,7 @@ var init_runner = __esm({
37506
37574
  claimCallRoundTripMs - (claim.schema_version === "external_inference_job_claim_result_v3" ? claim.server_processing_ms : 0)
37507
37575
  );
37508
37576
  emitDiagnostic("claim_batch_received", {
37577
+ ...claimTiming ? { client_timing: claimTiming } : {},
37509
37578
  claim_count: claim.claims.length,
37510
37579
  round_trip_ms: claimCallRoundTripMs,
37511
37580
  server_processing_ms: claim.schema_version === "external_inference_job_claim_result_v3" ? claim.server_processing_ms : null,
@@ -39382,6 +39451,124 @@ var init_runner = __esm({
39382
39451
  }
39383
39452
  });
39384
39453
 
39454
+ // lib/runtime-policy.generated.json with { type: 'json' }
39455
+ var runtime_policy_generated_default;
39456
+ var init_runtime_policy_generated = __esm({
39457
+ "lib/runtime-policy.generated.json with { type: 'json' }"() {
39458
+ runtime_policy_generated_default = {
39459
+ ui: {
39460
+ auth_bootstrap_retry: {
39461
+ max_attempts: 3,
39462
+ jitter_milliseconds: 750,
39463
+ base_delay_milliseconds: 500,
39464
+ min_delay_milliseconds: 250,
39465
+ max_delay_milliseconds: 1e4
39466
+ }
39467
+ },
39468
+ ai_dashboard: {
39469
+ market_news_bounds: {
39470
+ max_items_min: 1,
39471
+ max_items_max: 100,
39472
+ lookback_hours_min: 1,
39473
+ lookback_hours_max: 168,
39474
+ max_items_steps: [
39475
+ 1,
39476
+ 2,
39477
+ 3,
39478
+ 4,
39479
+ 5,
39480
+ 6,
39481
+ 7,
39482
+ 8,
39483
+ 9,
39484
+ 10,
39485
+ 15,
39486
+ 20,
39487
+ 25,
39488
+ 30,
39489
+ 40,
39490
+ 50,
39491
+ 60,
39492
+ 75,
39493
+ 90,
39494
+ 100
39495
+ ],
39496
+ lookback_hours_steps: [
39497
+ 1,
39498
+ 2,
39499
+ 4,
39500
+ 8,
39501
+ 12,
39502
+ 24,
39503
+ 48,
39504
+ 72,
39505
+ 168
39506
+ ]
39507
+ }
39508
+ },
39509
+ trading: {
39510
+ engine: {
39511
+ client_runtime: {
39512
+ recovery: {
39513
+ resume_retry_base_delay_ms: 1e3,
39514
+ resume_retry_max_delay_ms: 3e4,
39515
+ transient_load_min_delay_ms: 3e4,
39516
+ transient_load_max_delay_ms: 12e4,
39517
+ rate_limit_buffer_ms: 1e3,
39518
+ rate_limit_max_delay_ms: 3e5,
39519
+ engine_stop_settle_retry_delay_ms: 250,
39520
+ recoverable_reset_settle_retry_delay_ms: 1500,
39521
+ local_ai_preflight_timeout_ms: 3e3,
39522
+ surge_stagger_max_ms: 6e4,
39523
+ surge_stagger_min_ms: 2e3,
39524
+ surge_stagger_min_candidates: 4,
39525
+ stagger_deadline_ttl_ms: 3e5,
39526
+ server_active_reprobe_delay_ms: 6e4,
39527
+ transient_load_jitter_ms: 1e4,
39528
+ cross_host_completed_ttl_ms: 15e3,
39529
+ telemetry_dedupe_ttl_ms: 5e3,
39530
+ browser_presence_heartbeat_interval_ms: 3e4,
39531
+ host_liveness_heartbeat_interval_ms: 3e4,
39532
+ host_liveness_recovery_nudge_ttl_ms: 1e4
39533
+ }
39534
+ }
39535
+ }
39536
+ },
39537
+ external_inference: {
39538
+ service: {
39539
+ startup_max_attempts: 40,
39540
+ startup_poll_interval_ms: 250,
39541
+ restart_stable_uptime_ms: 6e4,
39542
+ restart_backoff_base_ms: 1e3,
39543
+ restart_backoff_max_ms: 3e4,
39544
+ restart_exponent_max: 5
39545
+ }
39546
+ },
39547
+ desktop: {
39548
+ runtime_watchdog: {
39549
+ ping_interval_milliseconds: 15e3,
39550
+ telemetry_interval_milliseconds: 3e5
39551
+ }
39552
+ },
39553
+ screener: {
39554
+ resource_scheduler: {
39555
+ client_lock_ttl_milliseconds: 12e4,
39556
+ client_poll_interval_milliseconds: 250
39557
+ }
39558
+ },
39559
+ deployment: {
39560
+ cutover_buffer: {
39561
+ target_timeout_ms: 3e3,
39562
+ retired_timeout_ms: 45e3,
39563
+ max_body_bytes: 33554432,
39564
+ max_inflight: 16,
39565
+ max_queue: 64
39566
+ }
39567
+ }
39568
+ };
39569
+ }
39570
+ });
39571
+
39385
39572
  // lib/inference-host/service.ts
39386
39573
  import { spawn as spawn7 } from "node:child_process";
39387
39574
  import { randomUUID as randomUUID6 } from "node:crypto";
@@ -39395,6 +39582,7 @@ var init_service = __esm({
39395
39582
  "use strict";
39396
39583
  init_define_VTX_EXO_POLICY();
39397
39584
  init_define_VTX_PI_MODEL_POLICY();
39585
+ init_runtime_policy_generated();
39398
39586
  init_durable_adapter();
39399
39587
  init_config();
39400
39588
  SERVICE_NAME = "VTX Macro Inference Host";
@@ -39801,7 +39989,7 @@ WantedBy=default.target
39801
39989
  await new Promise((resolvePromise) => setTimeout(resolvePromise, milliseconds));
39802
39990
  });
39803
39991
  this.stopWaitAttempts = dependencies.stopWaitAttempts ?? SERVICE_COOPERATIVE_STOP_SECONDS * 4;
39804
- this.startWaitAttempts = dependencies.startWaitAttempts ?? 40;
39992
+ this.startWaitAttempts = dependencies.startWaitAttempts ?? runtime_policy_generated_default.external_inference.service.startup_max_attempts;
39805
39993
  this.reconcileWaitAttempts = dependencies.reconcileWaitAttempts ?? SERVICE_COOPERATIVE_STOP_SECONDS * 4;
39806
39994
  this.confirmInitialReadiness = dependencies.confirmInitialReadiness ?? true;
39807
39995
  this.acquireProcessLock = dependencies.acquireProcessLock ?? acquireInferenceHostProcessLock;
@@ -39932,9 +40120,9 @@ WantedBy=default.target
39932
40120
  for (let attempt = 0; attempt < this.startWaitAttempts; attempt += 1) {
39933
40121
  const status = await this.status();
39934
40122
  if (status.manager_active) return status;
39935
- await this.sleep(250);
40123
+ await this.sleep(runtime_policy_generated_default.external_inference.service.startup_poll_interval_ms);
39936
40124
  }
39937
- throw new Error("Background service did not reach an active state within 10 seconds.");
40125
+ throw new Error(`Background service did not reach an active state within ${this.startWaitAttempts * runtime_policy_generated_default.external_inference.service.startup_poll_interval_ms / 1e3} seconds.`);
39938
40126
  }
39939
40127
  async restoreRunningSupervisor(manifest, preserveGeneration = false, targetInstanceName) {
39940
40128
  const previousRuntime = await readRuntimeAcrossAtomicReplacement(this.runtimePath()).catch(() => null);
@@ -40735,8 +40923,8 @@ ${result2.stderr}`)) {
40735
40923
  throw new Error("worker_cooperative_stop_timeout");
40736
40924
  }
40737
40925
  if (signal.aborted || record3.controller.signal.aborted || !await readDesiredAcrossAtomicReplacement(desiredPath)) break;
40738
- failures = result2.uptimeMs >= 6e4 ? 0 : failures + 1;
40739
- const retryAfterMs = Math.min(1e3 * 2 ** Math.min(failures, 5), 3e4);
40926
+ failures = result2.uptimeMs >= runtime_policy_generated_default.external_inference.service.restart_stable_uptime_ms ? 0 : failures + 1;
40927
+ const retryAfterMs = Math.min(runtime_policy_generated_default.external_inference.service.restart_backoff_base_ms * 2 ** Math.min(failures, runtime_policy_generated_default.external_inference.service.restart_exponent_max), runtime_policy_generated_default.external_inference.service.restart_backoff_max_ms);
40740
40928
  await updateRecord(record3, "failed", "worker_exited");
40741
40929
  await appendServiceLog(serviceManifest.log_path, "worker_exited", {
40742
40930
  instance_name: record3.worker.instance_name,
@@ -40750,7 +40938,7 @@ ${result2.stderr}`)) {
40750
40938
  if (error48 instanceof Error && error48.message === "worker_cooperative_stop_timeout") throw error48;
40751
40939
  if (signal.aborted || record3.controller.signal.aborted) break;
40752
40940
  failures += 1;
40753
- const retryAfterMs = Math.min(1e3 * 2 ** Math.min(failures, 5), 3e4);
40941
+ const retryAfterMs = Math.min(runtime_policy_generated_default.external_inference.service.restart_backoff_base_ms * 2 ** Math.min(failures, runtime_policy_generated_default.external_inference.service.restart_exponent_max), runtime_policy_generated_default.external_inference.service.restart_backoff_max_ms);
40754
40942
  await updateRecord(record3, "failed", "worker_launch_failed");
40755
40943
  await appendServiceLog(serviceManifest.log_path, "worker_launch_failed", {
40756
40944
  instance_name: record3.worker.instance_name,
@@ -47717,6 +47905,124 @@ var init_local_breadcrumbs = __esm({
47717
47905
  }
47718
47906
  });
47719
47907
 
47908
+ // lib/runtime-policy.generated.json
47909
+ var runtime_policy_generated_default2;
47910
+ var init_runtime_policy_generated2 = __esm({
47911
+ "lib/runtime-policy.generated.json"() {
47912
+ runtime_policy_generated_default2 = {
47913
+ ui: {
47914
+ auth_bootstrap_retry: {
47915
+ max_attempts: 3,
47916
+ jitter_milliseconds: 750,
47917
+ base_delay_milliseconds: 500,
47918
+ min_delay_milliseconds: 250,
47919
+ max_delay_milliseconds: 1e4
47920
+ }
47921
+ },
47922
+ ai_dashboard: {
47923
+ market_news_bounds: {
47924
+ max_items_min: 1,
47925
+ max_items_max: 100,
47926
+ lookback_hours_min: 1,
47927
+ lookback_hours_max: 168,
47928
+ max_items_steps: [
47929
+ 1,
47930
+ 2,
47931
+ 3,
47932
+ 4,
47933
+ 5,
47934
+ 6,
47935
+ 7,
47936
+ 8,
47937
+ 9,
47938
+ 10,
47939
+ 15,
47940
+ 20,
47941
+ 25,
47942
+ 30,
47943
+ 40,
47944
+ 50,
47945
+ 60,
47946
+ 75,
47947
+ 90,
47948
+ 100
47949
+ ],
47950
+ lookback_hours_steps: [
47951
+ 1,
47952
+ 2,
47953
+ 4,
47954
+ 8,
47955
+ 12,
47956
+ 24,
47957
+ 48,
47958
+ 72,
47959
+ 168
47960
+ ]
47961
+ }
47962
+ },
47963
+ trading: {
47964
+ engine: {
47965
+ client_runtime: {
47966
+ recovery: {
47967
+ resume_retry_base_delay_ms: 1e3,
47968
+ resume_retry_max_delay_ms: 3e4,
47969
+ transient_load_min_delay_ms: 3e4,
47970
+ transient_load_max_delay_ms: 12e4,
47971
+ rate_limit_buffer_ms: 1e3,
47972
+ rate_limit_max_delay_ms: 3e5,
47973
+ engine_stop_settle_retry_delay_ms: 250,
47974
+ recoverable_reset_settle_retry_delay_ms: 1500,
47975
+ local_ai_preflight_timeout_ms: 3e3,
47976
+ surge_stagger_max_ms: 6e4,
47977
+ surge_stagger_min_ms: 2e3,
47978
+ surge_stagger_min_candidates: 4,
47979
+ stagger_deadline_ttl_ms: 3e5,
47980
+ server_active_reprobe_delay_ms: 6e4,
47981
+ transient_load_jitter_ms: 1e4,
47982
+ cross_host_completed_ttl_ms: 15e3,
47983
+ telemetry_dedupe_ttl_ms: 5e3,
47984
+ browser_presence_heartbeat_interval_ms: 3e4,
47985
+ host_liveness_heartbeat_interval_ms: 3e4,
47986
+ host_liveness_recovery_nudge_ttl_ms: 1e4
47987
+ }
47988
+ }
47989
+ }
47990
+ },
47991
+ external_inference: {
47992
+ service: {
47993
+ startup_max_attempts: 40,
47994
+ startup_poll_interval_ms: 250,
47995
+ restart_stable_uptime_ms: 6e4,
47996
+ restart_backoff_base_ms: 1e3,
47997
+ restart_backoff_max_ms: 3e4,
47998
+ restart_exponent_max: 5
47999
+ }
48000
+ },
48001
+ desktop: {
48002
+ runtime_watchdog: {
48003
+ ping_interval_milliseconds: 15e3,
48004
+ telemetry_interval_milliseconds: 3e5
48005
+ }
48006
+ },
48007
+ screener: {
48008
+ resource_scheduler: {
48009
+ client_lock_ttl_milliseconds: 12e4,
48010
+ client_poll_interval_milliseconds: 250
48011
+ }
48012
+ },
48013
+ deployment: {
48014
+ cutover_buffer: {
48015
+ target_timeout_ms: 3e3,
48016
+ retired_timeout_ms: 45e3,
48017
+ max_body_bytes: 33554432,
48018
+ max_inflight: 16,
48019
+ max_queue: 64
48020
+ }
48021
+ }
48022
+ };
48023
+ }
48024
+ });
48025
+
47720
48026
  // lib/api/shared.ts
47721
48027
  function getProfileHeaders(baseHeaders = {}, explicitProfileId) {
47722
48028
  const headers = { ...baseHeaders };
@@ -47724,12 +48030,13 @@ function getProfileHeaders(baseHeaders = {}, explicitProfileId) {
47724
48030
  if (profileId) headers["x-profile-id"] = profileId.toString();
47725
48031
  return headers;
47726
48032
  }
47727
- var getApiUrl, API_URL, sleep2, isTransientNetworkFetchError, createIdempotencyKey, getErrorMessage, getErrorPayloadOrEmpty, getErrorPayloadOrFallbackDetail, getErrorMessageFromResponse, activeProfileId, PROFILE_STORAGE_KEY;
48033
+ var getApiUrl, API_URL, sleep2, AUTH_BOOTSTRAP_GET_MAX_ATTEMPTS, AUTH_BOOTSTRAP_RETRY_JITTER_MS, isTransientNetworkFetchError, createIdempotencyKey, getErrorMessage, getErrorPayloadOrEmpty, getErrorPayloadOrFallbackDetail, getErrorMessageFromResponse, activeProfileId, PROFILE_STORAGE_KEY;
47728
48034
  var init_shared = __esm({
47729
48035
  "lib/api/shared.ts"() {
47730
48036
  "use strict";
47731
48037
  init_define_VTX_EXO_POLICY();
47732
48038
  init_define_VTX_PI_MODEL_POLICY();
48039
+ init_runtime_policy_generated2();
47733
48040
  init_abort();
47734
48041
  getApiUrl = () => {
47735
48042
  if (typeof window === "undefined") {
@@ -47760,6 +48067,8 @@ var init_shared = __esm({
47760
48067
  };
47761
48068
  API_URL = getApiUrl();
47762
48069
  sleep2 = (ms) => new Promise((resolve10) => setTimeout(resolve10, ms));
48070
+ AUTH_BOOTSTRAP_GET_MAX_ATTEMPTS = runtime_policy_generated_default2.ui.auth_bootstrap_retry.max_attempts;
48071
+ AUTH_BOOTSTRAP_RETRY_JITTER_MS = runtime_policy_generated_default2.ui.auth_bootstrap_retry.jitter_milliseconds;
47763
48072
  isTransientNetworkFetchError = (error48) => {
47764
48073
  const message = error48 instanceof Error ? error48.message : String(error48 || "");
47765
48074
  const normalized = message.toLowerCase();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtxmacro/cli",
3
- "version": "2026.9.24",
3
+ "version": "2026.9.26",
4
4
  "description": "VTX Macro CLI, MCP server, and durable external inference host.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",