@vtxmacro/cli 2026.9.30 → 2026.9.32

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.30",
19
+ package_version: "2026.9.32",
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
@@ -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.30",
80
+ package_version: "2026.9.32",
81
81
  codex_package_name: "@openai/codex",
82
82
  codex_version: "0.153.3",
83
83
  copilot_sdk_package_name: "@github/copilot-sdk",
@@ -14722,7 +14722,7 @@ var init_zod = __esm({
14722
14722
  });
14723
14723
 
14724
14724
  // lib/external-inference-contract.ts
14725
- var EXTERNAL_INFERENCE_CONTRACT_VERSION, EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION, EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION_V2, EXTERNAL_INFERENCE_ADVERTISEMENT_SCHEMA_VERSION, EXTERNAL_INFERENCE_ENVELOPE_SCHEMA_VERSION, EXTERNAL_INFERENCE_COMPRESSED_INPUT_ENVELOPE_SCHEMA_VERSION, EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION, LEGACY_EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION, EXTERNAL_INFERENCE_USAGE_SCHEMA_VERSION, EXTERNAL_INFERENCE_INPUT_HASH_DOMAIN, MAX_EXTERNAL_INFERENCE_STATUS_HOSTS, MAX_PROFILE_EXTERNAL_INFERENCE_FALLBACKS_PER_LANE, MAX_GENERATION, MAX_SAFE_INTEGER, MAX_PROMPT_BYTES, MAX_IMMUTABLE_JOB_INPUT_BYTES, MAX_CANDIDATE_PLAINTEXT_BYTES, MAX_CIPHERTEXT_CHARS, SHA256_INITIAL_STATE, SHA256_ROUND_CONSTANTS, rotateRight, sha256BytesHex, sha256Utf8Hex, computeImmutableJobInputSha256, identifierSchema, operationIdentifierSchema, sha256HexSchema, generationSchema, zeroBasedGenerationSchema, nonNegativeSafeIntegerSchema, positiveSafeIntegerSchema, sqlIntegerTokenCountSchema, timestampSchema, safeCodeSchema, processExitCodeSchema, externalInferenceAdapterIdSchema, reasoningEffortSchema, modelNameSchema, displayNameSchema, authenticatedAccountEmailSchema, protocolVersionSchema, base64UrlAlphabet, isCanonicalBase64Url, base64Url32BytesSchema, base64UrlNonceSchema, base64UrlCiphertextSchema, claimHandleSchema, boundedJsonTextSchema, boundedPromptTextSchema, laneSchema, botModeSchema, executionModeSchema, responseModeSchema, controlModeSchema, dispatchOutcomeSchema, responseOutcomeSchema, nativeModelControllerSchema, legacyExternalAgentModelControllerSchema, externalAgentModelControllerSchema, boundExternalAgentModelControllerSchema, externalAgentUnboundControllerSchema, externalAgentUnboundControllerV2Schema, orderedFallbackHostIdsSchema, externalInferenceFallbackHostIdsSchema, liveModelControllerSchema, snapshotModelControllerSchema, modelIdentityMappingSchema, advertisedModelSchema, hostAdvertisementSchema, envelopeAadSchema, validateEnvelopeAad, commonEnvelopeShape, sealedKeyWrapEnvelopeSchema, sealedInputEnvelopeSchema, sealedCandidateEnvelopeSchema, sealedEnvelopeSchema, screenerCandidateRuntimeBindingSchema, screenerClientLeaseBindingSchema, screenerRuntimeBindingSchema, serverRuntimeBindingSchema, clientRuntimeBindingSchema, runtimeBindingSchema, immutableJobInputSchema, canonicalizeJsonValue, serializeImmutableJobInput, reportedTokenUsageSchema, unavailableTokenUsageSchema, tokenUsageSchema, agentTurnReceiptSchema, agentConnectRequestSchema, agentNextRequestSchema, agentHeartbeatRequestSchema, emptyAgentNextResultSchema, claimedAgentNextResultSchema, agentNextResultSchema, agentCompleteRequestSchema, agentFailRequestSchema, requestedModelSelectionSchema, completedModelProvenanceSchema, attemptModelProvenanceSchema, providerWeeklyQuotaReadSchema, hostHeartbeatRequestSchema, jobClaimRequestBaseShape, jobClaimRequestSchema, emptyJobClaimSchema, claimedJobSchema, claimedDispatchIntentSchema, batchedJobClaimSchema, timedBatchedJobClaimSchema, jobClaimResultSchema, attemptStartRequestSchema, jobHeartbeatRequestSchema, continueHeartbeatDirectiveSchema, cancelHeartbeatDirectiveSchema, jobHeartbeatResultSchema, adapterOutcomeEvidenceSchema, completionBaseShape, validateCompletion, providerResponseCompletionSchema, decisionCandidateCompletionSchema, jobCompleteRequestSchema, codexProcessExitDiagnosticsSchema, jobFailRequestSchema, jobCancelRequestSchema, jobCancellationReceiptSchema, jobDeliveryRequestSchema, deliveryBaseShape, validateDeliveryCandidate, providerResponseDeliverySchema, decisionCandidateDeliverySchema, jobDeliveryResultSchema, jobConsumptionRequestSchema, jobConsumptionReceiptSchema, jobStateSchema, jobStatusReadSchema, hostStatusReadSchema, controllerBindingStatusReadSchema, queueStatusReadSchema, outcomeStatusReadSchema, externalInferenceVolumeWindowReadSchema, externalInferenceFailureCountReadSchema, externalInferenceHostDiagnosticsReadSchema, externalInferenceProfileActivityReadSchema, externalInferenceStatusReadSchema, nativeResearchEvidenceSourceSchema, externalAgentResearchEvidenceSourceSchema, researchEvidenceSourceSchema, reportedResearchTokenUsageSchema, unavailableResearchTokenUsageSchema, researchTokenUsageSchema, externalInferenceProductLineageBaseShape, traderExternalInferenceProductLineageSchema, decisionChatExternalInferenceProductLineageSchema, screenerExternalInferenceProductLineageSchema, externalInferenceProductLineageSchema, normalProductLinkageSchema, evidenceMaterializationMarkerSchema, deliveredExternalAgentSourceIdentitySchema, deliveredRequestEvidenceSchema, researchEvidenceBaseShape, researchEvidenceBaseSchema, validateExactUtf8, validateResearchEvidence, providerResponseResearchEvidenceSchema, decisionCandidateResearchEvidenceSchema, researchEvidenceSchema;
14725
+ var EXTERNAL_INFERENCE_CONTRACT_VERSION, EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION, EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION_V2, EXTERNAL_INFERENCE_ADVERTISEMENT_SCHEMA_VERSION, EXTERNAL_INFERENCE_ENVELOPE_SCHEMA_VERSION, EXTERNAL_INFERENCE_COMPRESSED_INPUT_ENVELOPE_SCHEMA_VERSION, EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION, LEGACY_EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION, EXTERNAL_INFERENCE_USAGE_SCHEMA_VERSION, EXTERNAL_INFERENCE_INPUT_HASH_DOMAIN, MAX_EXTERNAL_INFERENCE_STATUS_HOSTS, MAX_PROFILE_EXTERNAL_INFERENCE_FALLBACKS_PER_LANE, MAX_GENERATION, MAX_SAFE_INTEGER, MAX_PROMPT_BYTES, MAX_IMMUTABLE_JOB_INPUT_BYTES, MAX_CANDIDATE_PLAINTEXT_BYTES, MAX_CIPHERTEXT_CHARS, SHA256_INITIAL_STATE, SHA256_ROUND_CONSTANTS, rotateRight, sha256BytesHex, sha256Utf8Hex, computeImmutableJobInputSha256, identifierSchema, operationIdentifierSchema, sha256HexSchema, generationSchema, zeroBasedGenerationSchema, nonNegativeSafeIntegerSchema, positiveSafeIntegerSchema, sqlIntegerTokenCountSchema, timestampSchema, safeCodeSchema, processExitCodeSchema, externalInferenceAdapterIdSchema, reasoningEffortSchema, modelNameSchema, displayNameSchema, authenticatedAccountEmailSchema, protocolVersionSchema, base64UrlAlphabet, isCanonicalBase64Url, base64Url32BytesSchema, base64UrlNonceSchema, base64UrlCiphertextSchema, claimHandleSchema, boundedJsonTextSchema, boundedPromptTextSchema, laneSchema, botModeSchema, executionModeSchema, responseModeSchema, controlModeSchema, dispatchOutcomeSchema, responseOutcomeSchema, nativeModelControllerSchema, legacyExternalAgentModelControllerSchema, externalAgentModelControllerSchema, boundExternalAgentModelControllerSchema, externalAgentUnboundControllerSchema, externalAgentUnboundControllerV2Schema, orderedFallbackHostIdsSchema, externalInferenceFallbackHostIdsSchema, liveModelControllerSchema, snapshotModelControllerSchema, modelIdentityMappingSchema, advertisedModelSchema, hostAdvertisementSchema, envelopeAadSchema, validateEnvelopeAad, commonEnvelopeShape, sealedKeyWrapEnvelopeSchema, sealedInputEnvelopeSchema, sealedCandidateEnvelopeSchema, sealedEnvelopeSchema, screenerCandidateRuntimeBindingSchema, screenerClientLeaseBindingSchema, screenerRuntimeBindingSchema, serverRuntimeBindingSchema, clientRuntimeBindingSchema, runtimeBindingSchema, immutableJobInputSchema, canonicalizeJsonValue, serializeImmutableJobInput, reportedTokenUsageSchema, unavailableTokenUsageSchema, tokenUsageSchema, grokToolValidationDiagnosticSchema, agentTurnReceiptSchema, agentConnectRequestSchema, agentNextRequestSchema, agentHeartbeatRequestSchema, emptyAgentNextResultSchema, claimedAgentNextResultSchema, agentNextResultSchema, agentCompleteRequestSchema, agentFailRequestSchema, requestedModelSelectionSchema, completedModelProvenanceSchema, attemptModelProvenanceSchema, providerWeeklyQuotaReadSchema, hostHeartbeatRequestSchema, jobClaimRequestBaseShape, jobClaimRequestSchema, emptyJobClaimSchema, claimedJobSchema, claimedDispatchIntentSchema, batchedJobClaimSchema, timedBatchedJobClaimSchema, jobClaimResultSchema, attemptStartRequestSchema, jobHeartbeatRequestSchema, continueHeartbeatDirectiveSchema, cancelHeartbeatDirectiveSchema, jobHeartbeatResultSchema, adapterOutcomeEvidenceSchema, completionBaseShape, validateCompletion, providerResponseCompletionSchema, decisionCandidateCompletionSchema, jobCompleteRequestSchema, codexProcessExitDiagnosticsSchema, jobFailRequestSchema, jobCancelRequestSchema, jobCancellationReceiptSchema, jobDeliveryRequestSchema, deliveryBaseShape, validateDeliveryCandidate, providerResponseDeliverySchema, decisionCandidateDeliverySchema, jobDeliveryResultSchema, jobConsumptionRequestSchema, jobConsumptionReceiptSchema, jobStateSchema, jobStatusReadSchema, hostStatusReadSchema, controllerBindingStatusReadSchema, queueStatusReadSchema, outcomeStatusReadSchema, externalInferenceVolumeWindowReadSchema, externalInferenceFailureCountReadSchema, externalInferenceHostDiagnosticsReadSchema, externalInferenceProfileActivityReadSchema, externalInferenceStatusReadSchema, nativeResearchEvidenceSourceSchema, externalAgentResearchEvidenceSourceSchema, researchEvidenceSourceSchema, reportedResearchTokenUsageSchema, unavailableResearchTokenUsageSchema, researchTokenUsageSchema, externalInferenceProductLineageBaseShape, traderExternalInferenceProductLineageSchema, decisionChatExternalInferenceProductLineageSchema, screenerExternalInferenceProductLineageSchema, externalInferenceProductLineageSchema, normalProductLinkageSchema, evidenceMaterializationMarkerSchema, deliveredExternalAgentSourceIdentitySchema, deliveredRequestEvidenceSchema, researchEvidenceBaseShape, researchEvidenceBaseSchema, validateExactUtf8, validateResearchEvidence, providerResponseResearchEvidenceSchema, decisionCandidateResearchEvidenceSchema, researchEvidenceSchema;
14726
14726
  var init_external_inference_contract = __esm({
14727
14727
  "lib/external-inference-contract.ts"() {
14728
14728
  "use strict";
@@ -15490,9 +15490,37 @@ var init_external_inference_contract = __esm({
15490
15490
  reportedTokenUsageSchema,
15491
15491
  unavailableTokenUsageSchema
15492
15492
  ]);
15493
+ grokToolValidationDiagnosticSchema = external_exports.strictObject({
15494
+ schema_version: external_exports.literal("external_inference_grok_tool_validation_v1"),
15495
+ reason: external_exports.enum(["invalid_tools", "invalid_type", "missing_name", "unexpected_tools"]),
15496
+ route: external_exports.enum(["/responses", "/chat/completions"]),
15497
+ tools_shape: external_exports.enum(["undefined", "null", "array", "object", "string", "number", "boolean", "bigint", "symbol", "function"]),
15498
+ tool_count: nonNegativeSafeIntegerSchema.nullable(),
15499
+ expected_tool_count: nonNegativeSafeIntegerSchema,
15500
+ tools: external_exports.array(external_exports.strictObject({
15501
+ type: external_exports.enum(["function", "web_search", "web_search_preview", "file_search", "computer_use", "missing", "invalid", "redacted"]),
15502
+ name: external_exports.enum(["search_tool", "use_tool", "bash", "read_file", "write_file", "edit_file", "web_search", "vtx_get_data", "vtx_submit_decision", "vtx_decision_status", "missing", "invalid", "redacted"]),
15503
+ type_sha256: sha256HexSchema.nullable(),
15504
+ name_sha256: sha256HexSchema.nullable()
15505
+ }).refine(
15506
+ (tool) => tool.type === "redacted" === (tool.type_sha256 !== null) && tool.name === "redacted" === (tool.name_sha256 !== null),
15507
+ { message: "Only redacted tool identifiers require hashes." }
15508
+ )).max(8),
15509
+ tools_truncated: external_exports.boolean(),
15510
+ prior_dispatch: external_exports.boolean(),
15511
+ completed_response_count: nonNegativeSafeIntegerSchema
15512
+ }).refine(
15513
+ (value) => value.tools_shape === "array" ? value.tool_count !== null && value.tools.length === Math.min(value.tool_count, 8) && value.tools_truncated === value.tool_count > 8 : value.tool_count === null && value.tools.length === 0 && !value.tools_truncated,
15514
+ { message: "Grok tool diagnostic counts must match the observed shape." }
15515
+ ).refine(
15516
+ (value) => value.prior_dispatch || value.completed_response_count === 0,
15517
+ { message: "Completed responses require prior dispatch." }
15518
+ );
15493
15519
  agentTurnReceiptSchema = external_exports.strictObject({
15494
15520
  terminal_status: external_exports.enum(["completed", "failed"]),
15495
15521
  failure_code: safeCodeSchema.nullable(),
15522
+ grok_tool_validation: grokToolValidationDiagnosticSchema.optional(),
15523
+ dispatch_outcome: external_exports.enum(["not_dispatched", "outcome_unknown"]).optional(),
15496
15524
  turn_id: external_exports.string().uuid(),
15497
15525
  agent_run_id: identifierSchema,
15498
15526
  requested_model: modelNameSchema,
@@ -15509,6 +15537,9 @@ var init_external_inference_contract = __esm({
15509
15537
  { message: "Agent decision operation IDs must be unique." }
15510
15538
  )
15511
15539
  }).refine(
15540
+ (value) => value.grok_tool_validation === void 0 ? value.dispatch_outcome === void 0 : value.terminal_status === "failed" && value.failure_code === `grok_tool_isolation_${value.grok_tool_validation.reason}` && value.dispatch_outcome === (value.grok_tool_validation.prior_dispatch ? "outcome_unknown" : "not_dispatched") && value.effective_model === null && value.effective_reasoning_effort === null && value.adapter_request_id === null && value.adapter_response_id === null && value.usage.availability === "unavailable",
15541
+ { message: "Grok diagnostics must match the failed Agent turn and dispatch outcome." }
15542
+ ).refine(
15512
15543
  (value) => value.terminal_status === "failed" ? value.failure_code !== null : value.failure_code === null && value.effective_model !== null && value.effective_reasoning_effort !== null && value.adapter_response_id !== null,
15513
15544
  { message: "Agent terminal evidence is incomplete." }
15514
15545
  ).refine((value) => Date.parse(value.completed_at) >= Date.parse(value.started_at), {
@@ -16006,6 +16037,7 @@ var init_external_inference_contract = __esm({
16006
16037
  adapter_result_ready_at: timestampSchema.optional(),
16007
16038
  provider_dispatch_freshness_remaining_ms: nonNegativeSafeIntegerSchema.nullable().optional(),
16008
16039
  process_exit: codexProcessExitDiagnosticsSchema.nullable().optional(),
16040
+ grok_tool_validation: grokToolValidationDiagnosticSchema.optional(),
16009
16041
  membership_disposition: external_exports.enum([
16010
16042
  "retry_same_host",
16011
16043
  "cascade_cooldown",
@@ -16015,6 +16047,9 @@ var init_external_inference_contract = __esm({
16015
16047
  ]).optional(),
16016
16048
  failed_at: timestampSchema
16017
16049
  }).superRefine((value, context) => {
16050
+ if (value.grok_tool_validation !== void 0 && (value.failure_code !== `grok_tool_isolation_${value.grok_tool_validation.reason}` || value.outcome.dispatch_outcome !== (value.grok_tool_validation.prior_dispatch ? "outcome_unknown" : "not_dispatched"))) {
16051
+ context.addIssue({ code: "custom", message: "Grok diagnostics must match the failure and dispatch outcome.", path: ["grok_tool_validation"] });
16052
+ }
16018
16053
  if (value.provider_retry_at != null !== (value.provider_retry_source != null)) {
16019
16054
  context.addIssue({ code: "custom", message: "provider retry deadline and source must be provided together", path: ["provider_retry_at"] });
16020
16055
  }
@@ -19940,6 +19975,19 @@ var init_mcp_client = __esm({
19940
19975
  #requestId = 0;
19941
19976
  #initialized = false;
19942
19977
  #providerQuotaRecoverySupported = false;
19978
+ #grokToolValidationTools = /* @__PURE__ */ new Set();
19979
+ supportsGrokToolValidationDiagnostics(tool) {
19980
+ return this.#grokToolValidationTools.has(tool);
19981
+ }
19982
+ async refreshGrokToolValidationSupport(tool, options = {}) {
19983
+ if (this.supportsGrokToolValidationDiagnostics(tool)) return true;
19984
+ try {
19985
+ await this.initialize(options);
19986
+ } catch {
19987
+ return false;
19988
+ }
19989
+ return this.supportsGrokToolValidationDiagnostics(tool);
19990
+ }
19943
19991
  supportsProviderQuotaRecovery() {
19944
19992
  return this.#providerQuotaRecoverySupported;
19945
19993
  }
@@ -19997,6 +20045,27 @@ var init_mcp_client = __esm({
19997
20045
  "inference.host.heartbeat",
19998
20046
  ["provider_quota_recovery"]
19999
20047
  ) && advertisesFields("inference.job.fail", ["provider_retry_at", "provider_retry_source"]);
20048
+ this.#grokToolValidationTools.clear();
20049
+ if (advertisesFields("inference.job.fail", ["grok_tool_validation"])) {
20050
+ this.#grokToolValidationTools.add("inference.job.fail");
20051
+ }
20052
+ const heartbeatSchema = listed.tools.find(
20053
+ (tool) => tool.name === "inference.agent.assignment.heartbeat"
20054
+ )?.inputSchema;
20055
+ const advertisesDiagnosticReceipt = (value, depth = 0) => {
20056
+ if (depth > 4 || !value || typeof value !== "object" || Array.isArray(value)) return false;
20057
+ const node = value;
20058
+ const properties = node.properties;
20059
+ if (properties && typeof properties === "object" && Object.hasOwn(properties, "grok_tool_validation") && Object.hasOwn(properties, "dispatch_outcome")) return true;
20060
+ if (typeof node.$ref === "string" && /^#\/\$defs\/[^/]+$/u.test(node.$ref)) {
20061
+ const definition = node.$ref.slice("#/$defs/".length).replace(/~1/gu, "/").replace(/~0/gu, "~");
20062
+ return advertisesDiagnosticReceipt(heartbeatSchema?.$defs?.[definition], depth + 1);
20063
+ }
20064
+ return Array.isArray(node.anyOf) && node.anyOf.some((branch) => advertisesDiagnosticReceipt(branch, depth + 1));
20065
+ };
20066
+ if (advertisesDiagnosticReceipt(heartbeatSchema?.properties?.turn_receipt)) {
20067
+ this.#grokToolValidationTools.add("inference.agent.assignment.heartbeat");
20068
+ }
20000
20069
  this.#initialized = true;
20001
20070
  }
20002
20071
  async callTool(name, argumentsValue, options = {}) {
@@ -21596,6 +21665,7 @@ var init_codex_app_server = __esm({
21596
21665
  this.terminalEvidence = options.terminalEvidence ?? null;
21597
21666
  this.rateLimits = options.rateLimits ?? null;
21598
21667
  this.processExit = options.processExit ?? null;
21668
+ this.grokToolValidation = options.grokToolValidation ?? null;
21599
21669
  }
21600
21670
  };
21601
21671
  objectOrNull = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
@@ -34407,13 +34477,31 @@ var init_grok_policy = __esm({
34407
34477
  import { createServer as createServer3 } from "node:http";
34408
34478
  import { createHash as createHash6, randomBytes as randomBytes5 } from "node:crypto";
34409
34479
  import { once } from "node:events";
34410
- var record3, count2, effort, safeCode2, GrokTransportProxy, createGrokTransportProxy;
34480
+ var diagnosticNames, diagnosticTypes, diagnosticIdentifier, record3, count2, effort, safeCode2, GrokTransportProxy, createGrokTransportProxy;
34411
34481
  var init_grok_transport_proxy = __esm({
34412
34482
  "lib/inference-host/grok-transport-proxy.ts"() {
34413
34483
  "use strict";
34414
34484
  init_define_VTX_EXO_POLICY();
34415
34485
  init_define_VTX_GROK_POLICY();
34416
34486
  init_define_VTX_PI_MODEL_POLICY();
34487
+ init_external_inference_contract();
34488
+ diagnosticNames = /* @__PURE__ */ new Set([
34489
+ "search_tool",
34490
+ "use_tool",
34491
+ "bash",
34492
+ "read_file",
34493
+ "write_file",
34494
+ "edit_file",
34495
+ "web_search",
34496
+ "vtx_get_data",
34497
+ "vtx_submit_decision",
34498
+ "vtx_decision_status"
34499
+ ]);
34500
+ diagnosticTypes = /* @__PURE__ */ new Set(["function", "web_search", "web_search_preview", "file_search", "computer_use"]);
34501
+ diagnosticIdentifier = (value, known) => {
34502
+ if (typeof value !== "string") return { label: value == null ? "missing" : "invalid", sha256: null };
34503
+ return known.has(value) ? { label: value, sha256: null } : { label: "redacted", sha256: createHash6("sha256").update(value).digest("hex") };
34504
+ };
34417
34505
  record3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
34418
34506
  count2 = (value) => Number.isSafeInteger(value) && Number(value) >= 0 ? Number(value) : null;
34419
34507
  effort = (value) => value == null ? "none" : String(value).toLowerCase();
@@ -34434,6 +34522,7 @@ var init_grok_transport_proxy = __esm({
34434
34522
  this.failureCode = null;
34435
34523
  this.rejectionStatus = null;
34436
34524
  this.terminalFailure = null;
34525
+ this.toolValidationFailure = null;
34437
34526
  const upstream = new URL(options.upstreamBaseUrl);
34438
34527
  if (upstream.protocol !== "https:" || upstream.username || upstream.password || upstream.search || upstream.hash || !options.requestedModel || typeof options.expectedSystemPrompt !== "string" || !Number.isSafeInteger(options.deadlineAtMs) || options.providerDispatchNotAfterMs !== void 0 && !Number.isSafeInteger(options.providerDispatchNotAfterMs) || !Number.isSafeInteger(options.maxRequestBytes) || options.maxRequestBytes < 1 || !Number.isSafeInteger(options.maxResponseBytes) || options.maxResponseBytes < 1 || new Set(options.allowedToolNames).size !== options.allowedToolNames.length || options.allowedToolNames.some((name) => !name)) throw new Error("grok_proxy_invalid_configuration");
34439
34528
  }
@@ -34471,6 +34560,32 @@ var init_grok_transport_proxy = __esm({
34471
34560
  throw new Error("server_account_context_expired_before_provider_dispatch");
34472
34561
  }
34473
34562
  }
34563
+ rejectTools(reason, payload, route) {
34564
+ const tools = Array.isArray(payload.tools) ? payload.tools : null;
34565
+ const diagnostic = grokToolValidationDiagnosticSchema.parse({
34566
+ schema_version: "external_inference_grok_tool_validation_v1",
34567
+ reason,
34568
+ route,
34569
+ tools_shape: tools ? "array" : payload.tools === null ? "null" : typeof payload.tools,
34570
+ tool_count: tools?.length ?? null,
34571
+ expected_tool_count: this.options.allowedToolNames.length,
34572
+ tools: (tools ?? []).slice(0, 8).map((value) => {
34573
+ const tool = record3(value);
34574
+ const type = diagnosticIdentifier(tool.type, diagnosticTypes);
34575
+ const name = diagnosticIdentifier(route === "/responses" ? tool.name : record3(tool.function).name, diagnosticNames);
34576
+ return { type: type.label, name: name.label, type_sha256: type.sha256, name_sha256: name.sha256 };
34577
+ }),
34578
+ tools_truncated: (tools?.length ?? 0) > 8,
34579
+ prior_dispatch: this.dispatched,
34580
+ completed_response_count: this.receiptValues.length
34581
+ });
34582
+ this.toolValidationFailure ??= diagnostic;
34583
+ try {
34584
+ this.options.onToolValidationFailure?.(diagnostic);
34585
+ } catch {
34586
+ }
34587
+ throw new Error(`grok_tool_isolation_${reason}`);
34588
+ }
34474
34589
  validatePayload(payload, route) {
34475
34590
  const requestedEffort = route === "/responses" ? record3(payload.reasoning).effort : payload.reasoning_effort;
34476
34591
  if (payload.model !== this.options.requestedModel || effort(requestedEffort) !== effort(this.options.requestedReasoningEffort)) {
@@ -34482,17 +34597,17 @@ var init_grok_transport_proxy = __esm({
34482
34597
  if (instructions.length !== 1 || instructions[0].role !== "system" || instructions[0].content !== this.options.expectedSystemPrompt || route === "/responses" && payload.instructions != null) {
34483
34598
  throw new Error("grok_system_prompt_mismatch");
34484
34599
  }
34485
- if (payload.tools != null && !Array.isArray(payload.tools)) throw new Error("grok_tool_isolation_failed");
34600
+ if (payload.tools != null && !Array.isArray(payload.tools)) this.rejectTools("invalid_tools", payload, route);
34486
34601
  const tools = payload.tools ?? [];
34487
34602
  const names2 = tools.map((value) => {
34488
34603
  const tool = record3(value);
34489
- if (tool.type !== "function") throw new Error("grok_tool_isolation_failed");
34604
+ if (tool.type !== "function") this.rejectTools("invalid_type", payload, route);
34490
34605
  const name = route === "/responses" ? tool.name : record3(tool.function).name;
34491
- if (typeof name !== "string") throw new Error("grok_tool_isolation_failed");
34606
+ if (typeof name !== "string") this.rejectTools("missing_name", payload, route);
34492
34607
  return name;
34493
34608
  });
34494
34609
  if (names2.sort().join("\0") !== [...this.options.allowedToolNames].sort().join("\0")) {
34495
- throw new Error("grok_tool_isolation_failed");
34610
+ this.rejectTools("unexpected_tools", payload, route);
34496
34611
  }
34497
34612
  }
34498
34613
  async handle(request, response) {
@@ -34622,8 +34737,15 @@ var init_grok_transport_proxy = __esm({
34622
34737
  if (!this.dispatched) this.pending = false;
34623
34738
  }
34624
34739
  controller.abort();
34625
- if (!response.headersSent) response.writeHead(502, { "x-should-retry": "false", "content-type": "application/json" });
34626
- response.end();
34740
+ if (!response.headersSent) {
34741
+ const localValidation = inference && this.toolValidationFailure !== null;
34742
+ response.writeHead(localValidation ? 400 : 502, { "x-should-retry": "false", "content-type": "application/json" });
34743
+ response.end(localValidation ? JSON.stringify({ error: {
34744
+ type: "vtx_host_validation_error",
34745
+ code: this.failureCode,
34746
+ message: "VTX blocked this Grok Build request locally because its tools did not match the allowed tool contract."
34747
+ } }) : void 0);
34748
+ } else response.end();
34627
34749
  } finally {
34628
34750
  clearTimeout(timer);
34629
34751
  this.options.signal?.removeEventListener("abort", abort);
@@ -35534,7 +35656,13 @@ var init_grok_adapter = __esm({
35534
35656
  providerDispatchNotAfterMs: provider?.providerDispatchNotAfterMs,
35535
35657
  onProviderDispatch: provider?.onProviderDispatch,
35536
35658
  signal: input.signal,
35537
- fetchImpl: this.options.fetchImpl
35659
+ fetchImpl: this.options.fetchImpl,
35660
+ onToolValidationFailure: (diagnostic) => this.options.emitDiagnosticEvent?.({
35661
+ event: "grok_tool_validation_failed",
35662
+ attempt_id: provider?.attemptId ?? null,
35663
+ control_mode: provider ? "provider" : "agent",
35664
+ ...diagnostic
35665
+ })
35538
35666
  });
35539
35667
  input.signal.throwIfAborted();
35540
35668
  session = new GrokAcpSession({
@@ -35647,12 +35775,13 @@ var init_grok_adapter = __esm({
35647
35775
  provider?.onTerminalDispatchOutcome?.(outcome);
35648
35776
  if (error48 instanceof CodexAppServerError) throw error48;
35649
35777
  throw new CodexAppServerError({
35650
- message: "Grok Build could not complete the inference contract.",
35778
+ message: proxy?.toolValidationFailure ? "VTX blocked an outgoing Grok Build request locally because its tools did not match the allowed tool contract." : "Grok Build could not complete the inference contract.",
35651
35779
  category: input.signal?.aborted ? "cancelled" : Date.now() >= input.deadlineAtMs ? "timeout" : proxy?.rejectionStatus === 401 || proxy?.rejectionStatus === 403 ? "auth" : "adapter",
35652
35780
  code: proxy?.failureCode ?? proxy?.terminalFailure?.code ?? (error48 instanceof Error && /^grok_[a-z0-9_]+$/u.test(error48.message) ? error48.message : "grok_adapter_failure"),
35653
35781
  httpStatusCode: proxy?.rejectionStatus,
35654
35782
  retryable: false,
35655
- dispatchOutcome: outcome
35783
+ dispatchOutcome: outcome,
35784
+ grokToolValidation: proxy?.toolValidationFailure ?? null
35656
35785
  });
35657
35786
  } finally {
35658
35787
  try {
@@ -37154,8 +37283,8 @@ var init_runner = __esm({
37154
37283
  init_mcp_client();
37155
37284
  init_config();
37156
37285
  init_oauth();
37157
- terminalFailureRequiresManualRecovery = (error48) => error48.terminalEvidence !== null && !error48.retryable && error48.category !== "auth" && !["quota_exceeded", "codex_rate_limited", "provider_rate_limited"].includes(error48.code);
37158
- canReplayFencedAgentTerminal = (state, fence) => state?.schema_version === "vtx_inference_agent_runtime_v3" && state.adapter_id === fence.adapter_id && state.host_id === fence.host_id && state.assignment.assignment_id === fence.assignment_id && state.pending_turn?.terminal_receipt?.terminal_status === "failed" && state.pending_turn.terminal_receipt.failure_code === fence.failure_code && fence.dispatch_outcome !== "outcome_unknown";
37286
+ terminalFailureRequiresManualRecovery = (error48) => (error48.terminalEvidence !== null || error48.grokToolValidation != null) && !error48.retryable && error48.category !== "auth" && !["quota_exceeded", "codex_rate_limited", "provider_rate_limited"].includes(error48.code);
37287
+ canReplayFencedAgentTerminal = (state, fence) => state?.schema_version === "vtx_inference_agent_runtime_v3" && state.adapter_id === fence.adapter_id && state.host_id === fence.host_id && state.assignment.assignment_id === fence.assignment_id && state.pending_turn?.terminal_receipt?.terminal_status === "failed" && state.pending_turn.terminal_receipt.failure_code === fence.failure_code && (fence.dispatch_outcome !== "outcome_unknown" || state.pending_turn.terminal_receipt.grok_tool_validation?.prior_dispatch === true && state.pending_turn.terminal_receipt.dispatch_outcome === "outcome_unknown");
37159
37288
  RUNTIME_RECEIPT_SCHEMA_VERSION = "vtx_inference_host_runtime_v1";
37160
37289
  ATTEMPT_RECEIPT_SCHEMA_VERSION = "vtx_inference_attempt_receipt_v1";
37161
37290
  CLAIM_DISPATCH_BATCH_SIZE = 16;
@@ -38165,7 +38294,14 @@ var init_runner = __esm({
38165
38294
  cooldown_until: retryAtMs === null ? null : isoAt(retryAtMs)
38166
38295
  }
38167
38296
  );
38168
- if (this.options.once || retryAtMs === null) return;
38297
+ if (this.options.once) return;
38298
+ if (retryAtMs === null) {
38299
+ const retained = await readInferenceAgentRuntimeState(agentRuntimeSettings.statePath);
38300
+ const fence = await readInferenceAgentFailureFence(agentRuntimeSettings.statePath);
38301
+ if (!fence || !canReplayFencedAgentTerminal(retained, fence)) return;
38302
+ await sleep4(1e3, agentIdleSignal).catch(() => void 0);
38303
+ continue;
38304
+ }
38169
38305
  try {
38170
38306
  await sleep4(Math.max(MIN_SLEEP_MS, retryAtMs - now()), agentIdleSignal);
38171
38307
  } catch {
@@ -40320,6 +40456,11 @@ var init_runner = __esm({
40320
40456
  failure2.code
40321
40457
  ]);
40322
40458
  const canReportEffective = dispatchOutcome !== "not_dispatched";
40459
+ const grokDiagnostic = heartbeatFailure === void 0 && effectiveError instanceof CodexAppServerError && effectiveError.grokToolValidation !== null && failure2.code === `grok_tool_isolation_${effectiveError.grokToolValidation.reason}` && dispatchOutcome === (effectiveError.grokToolValidation.prior_dispatch ? "outcome_unknown" : "not_dispatched") ? effectiveError.grokToolValidation : null;
40460
+ const sendGrokDiagnostic = grokDiagnostic !== null && (mcp.supportsGrokToolValidationDiagnostics?.("inference.job.fail") === true || await mcp.refreshGrokToolValidationSupport?.("inference.job.fail", {
40461
+ signal,
40462
+ deadlineAtMs: Date.parse(jobInput.evidence_expires_at)
40463
+ }) === true);
40323
40464
  const failureRequest = jobFailRequestSchema.parse({
40324
40465
  schema_version: "external_inference_job_fail_v1",
40325
40466
  contract_version: EXTERNAL_INFERENCE_CONTRACT_VERSION,
@@ -40360,6 +40501,7 @@ var init_runner = __esm({
40360
40501
  ...adapterResultReadyAt === null ? {} : { adapter_result_ready_at: adapterResultReadyAt },
40361
40502
  provider_dispatch_freshness_remaining_ms: providerDispatchFreshnessRemainingMs,
40362
40503
  ...processExit ? { process_exit: processExit } : {},
40504
+ ...sendGrokDiagnostic ? { grok_tool_validation: grokDiagnostic } : {},
40363
40505
  membership_disposition: membershipFailureDisposition({
40364
40506
  ...failure2,
40365
40507
  dispatchOutcome
@@ -40431,6 +40573,7 @@ var init_runner = __esm({
40431
40573
  }
40432
40574
  };
40433
40575
  createInferenceAgentControlClient = (mcp) => ({
40576
+ supportsGrokToolValidationDiagnostics: async (options = {}) => mcp.supportsGrokToolValidationDiagnostics?.("inference.agent.assignment.heartbeat") === true || await mcp.refreshGrokToolValidationSupport?.("inference.agent.assignment.heartbeat", options) === true,
40434
40577
  nextAssignment: async (request, options) => {
40435
40578
  const result2 = await mcp.callTool("inference.agent.assignment.next", {
40436
40579
  ...request,
@@ -40674,6 +40817,12 @@ var init_runner = __esm({
40674
40817
  if (terminal.terminal_receipt.terminal_status === "failed") {
40675
40818
  state = { ...state, pending_turn: null, updated_at: nowIso() };
40676
40819
  await writeInferenceAgentRuntimeState(this.options.statePath, state);
40820
+ if (terminal.terminal_receipt.dispatch_outcome === "outcome_unknown") {
40821
+ throw new InferenceHostRunnerError(
40822
+ "agent_terminal_failure_fenced",
40823
+ "The diagnostic receipt was acknowledged; upstream outcome remains unknown and model redispatch is fenced."
40824
+ );
40825
+ }
40677
40826
  await this.releaseForHostStop(terminal.terminal_receipt.failure_code ?? "provider_failure");
40678
40827
  return this.now() + (this.options.idlePollMs ?? 5e3);
40679
40828
  }
@@ -40970,11 +41119,12 @@ var init_runner = __esm({
40970
41119
  await writeInferenceAgentRuntimeState(this.options.statePath, state);
40971
41120
  return nextWakeAtMs;
40972
41121
  } catch (error48) {
40973
- if (error48 instanceof CodexAppServerError && error48.dispatchOutcome === "not_dispatched" && error48.terminalEvidence === null) {
41122
+ const diagnostic = error48 instanceof CodexAppServerError && error48.grokToolValidation && error48.code === `grok_tool_isolation_${error48.grokToolValidation.reason}` && error48.dispatchOutcome === (error48.grokToolValidation.prior_dispatch ? "outcome_unknown" : "not_dispatched") && await this.options.controlClient.supportsGrokToolValidationDiagnostics?.({}) === true ? error48.grokToolValidation : null;
41123
+ if (error48 instanceof CodexAppServerError && error48.dispatchOutcome === "not_dispatched" && error48.terminalEvidence === null && !diagnostic) {
40974
41124
  state = { ...state, pending_turn: null, updated_at: nowIso() };
40975
41125
  await writeInferenceAgentRuntimeState(this.options.statePath, state);
40976
41126
  }
40977
- if (state.pending_turn && !state.pending_turn.terminal_receipt && error48 instanceof CodexAppServerError && (error48.terminalEvidence !== null || error48.dispatchOutcome === "confirmed_dispatched" && ["provider_rate_limited", "codex_rate_limited", "quota_exceeded"].includes(error48.code))) {
41127
+ if (state.pending_turn && !state.pending_turn.terminal_receipt && error48 instanceof CodexAppServerError && (diagnostic != null || error48.terminalEvidence !== null || error48.dispatchOutcome === "confirmed_dispatched" && ["provider_rate_limited", "codex_rate_limited", "quota_exceeded"].includes(error48.code))) {
40978
41128
  state = { ...state, pending_turn: {
40979
41129
  ...state.pending_turn,
40980
41130
  terminal_receipt: {
@@ -40983,19 +41133,23 @@ var init_runner = __esm({
40983
41133
  turn_id: state.pending_turn.turn_id,
40984
41134
  agent_run_id: state.thread?.threadId ?? state.pending_turn.turn_id,
40985
41135
  requested_model: assignment.model_id,
40986
- effective_model: error48.terminalEvidence?.effectiveModel ?? null,
41136
+ effective_model: diagnostic ? null : error48.terminalEvidence?.effectiveModel ?? null,
40987
41137
  requested_reasoning_effort: assignment.reasoning_effort,
40988
- effective_reasoning_effort: error48.terminalEvidence?.effectiveReasoningEffort ?? null,
41138
+ effective_reasoning_effort: diagnostic ? null : error48.terminalEvidence?.effectiveReasoningEffort ?? null,
40989
41139
  started_at: state.pending_turn.started_at,
40990
41140
  completed_at: nowIso(),
40991
- adapter_request_id: error48.terminalEvidence?.adapterRequestId ?? null,
40992
- adapter_response_id: error48.terminalEvidence?.adapterResponseId ?? null,
40993
- usage: error48.usage ? reportedTokenUsage(error48.usage, this.options.adapterId) : {
41141
+ adapter_request_id: diagnostic ? null : error48.terminalEvidence?.adapterRequestId ?? null,
41142
+ adapter_response_id: diagnostic ? null : error48.terminalEvidence?.adapterResponseId ?? null,
41143
+ usage: !diagnostic && error48.usage ? reportedTokenUsage(error48.usage, this.options.adapterId) : {
40994
41144
  schema_version: EXTERNAL_INFERENCE_USAGE_SCHEMA_VERSION,
40995
41145
  availability: "unavailable",
40996
41146
  reason_code: "terminal_usage_unavailable"
40997
41147
  },
40998
- decision_operation_ids: [...state.pending_turn.decision_operation_ids]
41148
+ decision_operation_ids: [...state.pending_turn.decision_operation_ids],
41149
+ ...diagnostic ? {
41150
+ grok_tool_validation: diagnostic,
41151
+ dispatch_outcome: error48.dispatchOutcome === "not_dispatched" ? "not_dispatched" : "outcome_unknown"
41152
+ } : {}
40999
41153
  }
41000
41154
  }, updated_at: nowIso() };
41001
41155
  if (terminalFailureRequiresManualRecovery(error48)) {
@@ -43609,8 +43763,8 @@ Durable service:
43609
43763
  quiesceSignal: options.quiesceSignal
43610
43764
  }).run();
43611
43765
  };
43612
- preparePortableDurableAdapter = async (adapterId, config2, signal) => {
43613
- const adapter = adapterId === "copilot" ? new CopilotSubscriptionAdapter() : adapterId === "grok-build" ? new GrokBuildAdapter({ stateRoot: `${config2.statePath}.grok`, grokHome: `${config2.statePath}.grok-home` }) : adapterId === "pi" ? new PiAdapter({
43766
+ preparePortableDurableAdapter = async (adapterId, config2, signal, emitDiagnosticEvent) => {
43767
+ const adapter = adapterId === "copilot" ? new CopilotSubscriptionAdapter() : adapterId === "grok-build" ? new GrokBuildAdapter({ stateRoot: `${config2.statePath}.grok`, grokHome: `${config2.statePath}.grok-home`, emitDiagnosticEvent }) : adapterId === "pi" ? new PiAdapter({
43614
43768
  credentialStore: createPiCredentialStore(config2),
43615
43769
  stateRoot: `${config2.statePath}.pi`,
43616
43770
  qualifiedModels: await loadPiModelPolicy()
@@ -44456,8 +44610,8 @@ Waiting for approval...
44456
44610
  const emitDiagnosticEvent = parsed.json ? (event) => (dependencies.emitStdout ?? ((text) => {
44457
44611
  process.stdout.write(text);
44458
44612
  }))(`${JSON.stringify(event)}
44459
- `) : adapterId === "codex" ? (event) => {
44460
- if (!["codex_app_server_closed", "codex_app_server_session_started"].includes(
44613
+ `) : adapterId === "codex" || adapterId === "grok-build" ? (event) => {
44614
+ if (!["codex_app_server_closed", "codex_app_server_session_started", "grok_tool_validation_failed"].includes(
44461
44615
  String(event.event ?? "")
44462
44616
  )) return;
44463
44617
  (dependencies.emitStderr ?? ((text) => {
@@ -44466,7 +44620,16 @@ Waiting for approval...
44466
44620
  `);
44467
44621
  } : void 0;
44468
44622
  if (adapterId !== "codex") {
44469
- const prepared = adapterId === "exo" ? await (dependencies.prepareExoAdapter ?? prepareExoAdapter)(config2, parsed.exoRoot, cancellation.signal) : await (dependencies.prepareDurableAdapter ?? preparePortableDurableAdapter)(adapterId, config2, cancellation.signal);
44623
+ const diagnosticState = await readInferenceHostLocalState(config2.statePath);
44624
+ const emitPortableDiagnostic = (event) => emitDiagnosticEvent?.({
44625
+ ...event,
44626
+ schema_version: "vtx_inference_host_diagnostic_v1",
44627
+ at: (/* @__PURE__ */ new Date()).toISOString(),
44628
+ instance_name: config2.instanceName,
44629
+ host_id: diagnosticState?.host_id ?? null,
44630
+ host_runtime_version: INFERENCE_HOST_CLI_VERSION
44631
+ });
44632
+ const prepared = adapterId === "exo" ? await (dependencies.prepareExoAdapter ?? prepareExoAdapter)(config2, parsed.exoRoot, cancellation.signal) : await (dependencies.prepareDurableAdapter ?? preparePortableDurableAdapter)(adapterId, config2, cancellation.signal, emitPortableDiagnostic);
44470
44633
  const summary = await (dependencies.runPortableDurableAdapter ?? defaultRunPortableDurableAdapter)({
44471
44634
  config: config2,
44472
44635
  credentialStore: store,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtxmacro/cli",
3
- "version": "2026.9.30",
3
+ "version": "2026.9.32",
4
4
  "description": "VTX Macro CLI, MCP server, and durable external inference host.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",