@vtxmacro/cli 2026.9.36 → 2026.9.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/vtx.js CHANGED
@@ -59,7 +59,7 @@ var init_define_VTX_EXO_POLICY = __esm({
59
59
  var define_VTX_GROK_POLICY_default;
60
60
  var init_define_VTX_GROK_POLICY = __esm({
61
61
  "<define:__VTX_GROK_POLICY__>"() {
62
- define_VTX_GROK_POLICY_default = { subscription_proxy_base_url: "https://cli-chat-proxy.grok.com/v1", maximum_transport_request_bytes: 8388608, maximum_transport_response_bytes: 8388608, effective_model_aliases: { "grok-4.5": ["grok-4.5-build"] } };
62
+ define_VTX_GROK_POLICY_default = { subscription_proxy_base_url: "https://cli-chat-proxy.grok.com/v1", maximum_transport_request_bytes: 8388608, maximum_transport_response_bytes: 8388608 };
63
63
  }
64
64
  });
65
65
 
@@ -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.36",
80
+ package_version: "2026.9.38",
81
81
  codex_package_name: "@openai/codex",
82
82
  codex_version: "0.153.3",
83
83
  copilot_sdk_package_name: "@github/copilot-sdk",
@@ -389,9 +389,9 @@ function floatSafeRemainder(val, step) {
389
389
  const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
390
390
  return valInt % stepInt / 10 ** decCount;
391
391
  }
392
- function defineLazy(object5, key, getter) {
392
+ function defineLazy(object6, key, getter) {
393
393
  let value = void 0;
394
- Object.defineProperty(object5, key, {
394
+ Object.defineProperty(object6, key, {
395
395
  get() {
396
396
  if (value === EVALUATING) {
397
397
  return void 0;
@@ -403,7 +403,7 @@ function defineLazy(object5, key, getter) {
403
403
  return value;
404
404
  },
405
405
  set(v) {
406
- Object.defineProperty(object5, key, {
406
+ Object.defineProperty(object6, key, {
407
407
  value: v
408
408
  // configurable: true,
409
409
  });
@@ -18654,28 +18654,28 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
18654
18654
  return await cachedSystemBootIdentity;
18655
18655
  }
18656
18656
  const read = async () => {
18657
- let identity = null;
18657
+ let identity2 = null;
18658
18658
  if (platform === "linux") {
18659
18659
  try {
18660
- identity = (await readFile("/proc/sys/kernel/random/boot_id", "utf8")).trim();
18660
+ identity2 = (await readFile("/proc/sys/kernel/random/boot_id", "utf8")).trim();
18661
18661
  } catch {
18662
- identity = null;
18662
+ identity2 = null;
18663
18663
  }
18664
18664
  } else if (platform === "win32") {
18665
18665
  const invocation = windowsBootIdentityInvocation();
18666
- identity = await runSmallIdentityCommand(
18666
+ identity2 = await runSmallIdentityCommand(
18667
18667
  "powershell.exe",
18668
18668
  invocation.args,
18669
18669
  invocation.env,
18670
18670
  invocation.timeoutMs
18671
18671
  );
18672
18672
  } else if (platform === "darwin") {
18673
- identity = await runSmallIdentityCommand("sysctl", ["-n", "kern.boottime"], void 0);
18673
+ identity2 = await runSmallIdentityCommand("sysctl", ["-n", "kern.boottime"], void 0);
18674
18674
  }
18675
- if (!identity || /[\r\n\0]/u.test(identity)) {
18675
+ if (!identity2 || /[\r\n\0]/u.test(identity2)) {
18676
18676
  throw new Error("Inference host could not establish the current system boot identity.");
18677
18677
  }
18678
- return `${platform}:${identity}`;
18678
+ return `${platform}:${identity2}`;
18679
18679
  };
18680
18680
  const pending2 = read();
18681
18681
  if (platform === process.platform) cachedSystemBootIdentity = pending2;
@@ -18693,9 +18693,9 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
18693
18693
  return null;
18694
18694
  };
18695
18695
  defaultCurrentProcessIdentity = async () => {
18696
- const identity = await defaultProcessIdentity(process.pid);
18697
- if (!identity) throw new Error("Inference host could not establish its process-start identity.");
18698
- return identity;
18696
+ const identity2 = await defaultProcessIdentity(process.pid);
18697
+ if (!identity2) throw new Error("Inference host could not establish its process-start identity.");
18698
+ return identity2;
18699
18699
  };
18700
18700
  processLockObservationCache = /* @__PURE__ */ new Map();
18701
18701
  inferenceProcessIdentitiesMatch = (stored, observed) => stored === observed;
@@ -18829,19 +18829,19 @@ function validateInferenceHostCredential(value) {
18829
18829
  updated_at: updatedAt
18830
18830
  };
18831
18831
  }
18832
- function inferenceCredentialAccountKey(identity) {
18833
- const issuer = canonicalUrl(identity.issuer, "Inference OAuth issuer");
18834
- if (!identity.clientId || identity.clientId.length > 512) {
18832
+ function inferenceCredentialAccountKey(identity2) {
18833
+ const issuer = canonicalUrl(identity2.issuer, "Inference OAuth issuer");
18834
+ if (!identity2.clientId || identity2.clientId.length > 512) {
18835
18835
  throw new Error("Inference OAuth client ID is invalid.");
18836
18836
  }
18837
- if (!SAFE_IDENTIFIER.test(identity.hostId)) {
18837
+ if (!SAFE_IDENTIFIER.test(identity2.hostId)) {
18838
18838
  throw new Error("Inference host ID is invalid.");
18839
18839
  }
18840
18840
  return createHash("sha256").update(
18841
18841
  JSON.stringify({
18842
18842
  issuer,
18843
- client_id: identity.clientId,
18844
- host_id: identity.hostId
18843
+ client_id: identity2.clientId,
18844
+ host_id: identity2.hostId
18845
18845
  }),
18846
18846
  "utf8"
18847
18847
  ).digest("hex");
@@ -24222,7 +24222,7 @@ var init_codex_adapter = __esm({
24222
24222
  reasoningContent: external_exports.string().min(1).max(CODEX_REASONING_CONTENT_MAX_UTF8_BYTES).nullable().optional().transform((value) => value ?? null),
24223
24223
  reasoningSummary: external_exports.string().min(1).max(CODEX_REASONING_SUMMARY_MAX_UTF8_BYTES).nullable().optional().transform((value) => value ?? null),
24224
24224
  requestedModel: external_exports.string().regex(CODEX_MODEL_NAME_PATTERN),
24225
- effectiveModel: external_exports.string().regex(CODEX_MODEL_NAME_PATTERN),
24225
+ effectiveModel: external_exports.string().min(1).max(256).refine((value) => value.trim().length > 0 && !/[\u0000-\u001f\u007f]/u.test(value)),
24226
24226
  requestedReasoningEffort: external_exports.string().regex(CODEX_REASONING_EFFORT_PATTERN),
24227
24227
  effectiveReasoningEffort: external_exports.string().regex(CODEX_REASONING_EFFORT_PATTERN),
24228
24228
  adapterRequestId: external_exports.string().min(1).max(512),
@@ -24232,7 +24232,7 @@ var init_codex_adapter = __esm({
24232
24232
  timeToFirstTokenMs: external_exports.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).nullable(),
24233
24233
  terminalStatus: external_exports.literal("completed")
24234
24234
  }).superRefine((value, context) => {
24235
- if (value.reasoningContent != null && utf8Bytes(value.reasoningContent) > CODEX_REASONING_CONTENT_MAX_UTF8_BYTES || value.reasoningSummary != null && utf8Bytes(value.reasoningSummary) > CODEX_REASONING_SUMMARY_MAX_UTF8_BYTES || value.usage.cachedInputTokens > value.usage.inputTokens || value.usage.reasoningOutputTokens > value.usage.outputTokens || value.usage.totalTokens !== value.usage.inputTokens + value.usage.outputTokens || value.effectiveModel !== value.requestedModel || value.effectiveReasoningEffort !== value.requestedReasoningEffort) {
24235
+ if (value.reasoningContent != null && utf8Bytes(value.reasoningContent) > CODEX_REASONING_CONTENT_MAX_UTF8_BYTES || value.reasoningSummary != null && utf8Bytes(value.reasoningSummary) > CODEX_REASONING_SUMMARY_MAX_UTF8_BYTES || value.usage.cachedInputTokens > value.usage.inputTokens || value.usage.reasoningOutputTokens > value.usage.outputTokens || value.usage.totalTokens !== value.usage.inputTokens + value.usage.outputTokens || value.effectiveReasoningEffort !== value.requestedReasoningEffort) {
24236
24236
  context.addIssue({ code: "custom", message: "Invalid Codex recovery usage or identity." });
24237
24237
  }
24238
24238
  });
@@ -25232,7 +25232,7 @@ var init_codex_adapter = __esm({
25232
25232
  }
25233
25233
  if (prior.terminal?.kind === "completed") {
25234
25234
  const recovered = prior.terminal.result;
25235
- if (recovered.requestedModel !== input.requestedModel || recovered.effectiveModel !== input.requestedModel || recovered.requestedReasoningEffort !== input.requestedReasoningEffort || recovered.effectiveReasoningEffort !== input.requestedReasoningEffort || recovered.terminalStatus !== "completed") {
25235
+ if (recovered.requestedModel !== input.requestedModel || typeof recovered.effectiveModel !== "string" || recovered.effectiveModel.trim().length === 0 || recovered.effectiveModel.length > 256 || /[\u0000-\u001f\u007f]/u.test(recovered.effectiveModel) || recovered.requestedReasoningEffort !== input.requestedReasoningEffort || recovered.effectiveReasoningEffort !== input.requestedReasoningEffort || recovered.terminalStatus !== "completed") {
25236
25236
  throw new CodexAppServerError({
25237
25237
  message: "Codex completed recovery receipt changed immutable model identity.",
25238
25238
  category: "adapter",
@@ -25849,7 +25849,7 @@ import {
25849
25849
  RuntimeConnection,
25850
25850
  defineTool
25851
25851
  } from "@github/copilot-sdk";
25852
- var COPILOT_SDK_VERSION, MAX_RESULT_BYTES, resolveRuntimePackage, copilotRuntimePackageCandidates, resolvePinnedCopilotCliPath, createPrivateWorkspace, cleanCopilotEnvironment, defaultClient, modelCapabilities, requiredUsageInteger, optionalUsageInteger, copilotAgentToolDefinitions, CopilotSubscriptionAdapter;
25852
+ var COPILOT_SDK_VERSION, MAX_RESULT_BYTES, resolveRuntimePackage, copilotRuntimePackageCandidates, resolvePinnedCopilotCliPath, createPrivateWorkspace, cleanCopilotEnvironment, defaultClient, modelCapabilities, requiredUsageInteger, optionalUsageInteger, responseModelLabel, coherentResponseModel, copilotAgentToolDefinitions, CopilotSubscriptionAdapter;
25853
25853
  var init_copilot_adapter = __esm({
25854
25854
  "lib/inference-host/copilot-adapter.ts"() {
25855
25855
  "use strict";
@@ -25948,9 +25948,20 @@ var init_copilot_adapter = __esm({
25948
25948
  }
25949
25949
  return Number(value);
25950
25950
  };
25951
- copilotAgentToolDefinitions = (input, evidence) => {
25951
+ responseModelLabel = (value) => {
25952
+ if (typeof value !== "string" || value.trim().length === 0 || value.length > 256 || /[\u0000-\u001f\u007f]/u.test(value)) {
25953
+ throw new Error("copilot_effective_model_invalid");
25954
+ }
25955
+ return value;
25956
+ };
25957
+ coherentResponseModel = (models) => {
25958
+ if (models.size !== 1) throw new Error("copilot_effective_model_mismatch");
25959
+ return [...models][0];
25960
+ };
25961
+ copilotAgentToolDefinitions = (input, evidence, beforeExecute) => {
25952
25962
  const execute = async (tool, argumentsValue) => {
25953
25963
  const argumentsRecord = argumentsValue && typeof argumentsValue === "object" && !Array.isArray(argumentsValue) ? argumentsValue : {};
25964
+ await beforeExecute();
25954
25965
  const callId = randomUUID();
25955
25966
  const result2 = await input.executeTool({
25956
25967
  callId,
@@ -26149,7 +26160,7 @@ ${input.outputSchemaJson}`
26149
26160
  let providerCallId = null;
26150
26161
  for (const event of usageEvents) {
26151
26162
  if (event.type !== "assistant.usage") continue;
26152
- observedModels.add(event.data.model);
26163
+ observedModels.add(responseModelLabel(event.data.model));
26153
26164
  if (event.data.reasoningEffort) observedEfforts.add(event.data.reasoningEffort);
26154
26165
  inputTokens += requiredUsageInteger(event.data.inputTokens, "input_tokens");
26155
26166
  cachedInputTokens += optionalUsageInteger(event.data.cacheReadTokens, "cache_read_tokens");
@@ -26170,10 +26181,8 @@ ${input.outputSchemaJson}`
26170
26181
  if (usageEvents.length === 0) {
26171
26182
  throw new Error("copilot_usage_receipt_missing");
26172
26183
  }
26173
- if (response.data.model) observedModels.add(response.data.model);
26174
- if (observedModels.size !== 1 || !observedModels.has(input.requestedModel)) {
26175
- throw new Error("copilot_effective_model_mismatch");
26176
- }
26184
+ if (response.data.model !== void 0) observedModels.add(responseModelLabel(response.data.model));
26185
+ const effectiveModel = coherentResponseModel(observedModels);
26177
26186
  const effectiveEffort = input.requestedReasoningEffort === "none" ? observedEfforts.size === 0 ? "none" : observedEfforts.size === 1 ? [...observedEfforts][0] : null : observedEfforts.size === 1 ? [...observedEfforts][0] : null;
26178
26187
  if (effectiveEffort !== input.requestedReasoningEffort) {
26179
26188
  throw new Error("copilot_effective_effort_mismatch");
@@ -26192,7 +26201,7 @@ ${input.outputSchemaJson}`
26192
26201
  reasoningContent: response.data.reasoningText ?? null,
26193
26202
  reasoningSummary: null,
26194
26203
  requestedModel: input.requestedModel,
26195
- effectiveModel: input.requestedModel,
26204
+ effectiveModel,
26196
26205
  requestedReasoningEffort: input.requestedReasoningEffort,
26197
26206
  effectiveReasoningEffort: effectiveEffort,
26198
26207
  adapterRequestId: providerCallId ?? response.data.requestId ?? response.data.messageId,
@@ -26261,9 +26270,22 @@ ${input.outputSchemaJson}`
26261
26270
  let durableCheckpointed = input.durableThread !== null;
26262
26271
  let dispatchEntered = false;
26263
26272
  const toolEvidence = [];
26273
+ const observedModels = /* @__PURE__ */ new Set();
26274
+ let modelReceiptError = null;
26275
+ let thread = null;
26276
+ const checkpointObservedModel = async () => {
26277
+ if (modelReceiptError) throw modelReceiptError;
26278
+ if (observedModels.size === 0 || !thread) return;
26279
+ const effectiveModel = coherentResponseModel(observedModels);
26280
+ if (thread.effectiveModel !== effectiveModel) {
26281
+ const updatedThread = { ...thread, effectiveModel };
26282
+ await input.onThreadReady?.(updatedThread);
26283
+ thread = updatedThread;
26284
+ }
26285
+ };
26264
26286
  try {
26265
26287
  await client.start();
26266
- const tools = copilotAgentToolDefinitions(input, toolEvidence);
26288
+ const tools = copilotAgentToolDefinitions(input, toolEvidence, checkpointObservedModel);
26267
26289
  const sessionConfig = {
26268
26290
  clientName: "@vtxmacro/cli durable Copilot Agent host",
26269
26291
  model: input.requestedModel,
@@ -26289,7 +26311,7 @@ ${JSON.stringify(input.outputSchema)}`
26289
26311
  workspacePath,
26290
26312
  cleanup: ownedWorkspace?.cleanup ?? null
26291
26313
  };
26292
- const thread = {
26314
+ thread = {
26293
26315
  threadId: session.sessionId,
26294
26316
  threadPath: workspacePath,
26295
26317
  effectiveModel: input.requestedModel,
@@ -26301,7 +26323,15 @@ ${JSON.stringify(input.outputSchema)}`
26301
26323
  }
26302
26324
  const usageEvents = [];
26303
26325
  session.on((event) => {
26304
- if (event.type === "assistant.usage" && !event.agentId) usageEvents.push(event);
26326
+ if (event.type === "assistant.usage" && !event.agentId) {
26327
+ usageEvents.push(event);
26328
+ try {
26329
+ observedModels.add(responseModelLabel(event.data.model));
26330
+ coherentResponseModel(observedModels);
26331
+ } catch (error48) {
26332
+ modelReceiptError = error48;
26333
+ }
26334
+ }
26305
26335
  });
26306
26336
  const onAbort = () => {
26307
26337
  void session?.abort().catch(() => void 0);
@@ -26320,7 +26350,6 @@ ${JSON.stringify(input.outputSchema)}`
26320
26350
  if (!response?.data.content || Buffer.byteLength(response.data.content, "utf8") > MAX_RESULT_BYTES) {
26321
26351
  throw new Error("copilot_agent_invalid_result");
26322
26352
  }
26323
- const observedModels = /* @__PURE__ */ new Set();
26324
26353
  const observedEfforts = /* @__PURE__ */ new Set();
26325
26354
  let inputTokens = 0;
26326
26355
  let cachedInputTokens = 0;
@@ -26332,7 +26361,7 @@ ${JSON.stringify(input.outputSchema)}`
26332
26361
  let providerCallId = null;
26333
26362
  for (const event of usageEvents) {
26334
26363
  if (event.type !== "assistant.usage") continue;
26335
- observedModels.add(event.data.model);
26364
+ observedModels.add(responseModelLabel(event.data.model));
26336
26365
  if (event.data.reasoningEffort) observedEfforts.add(event.data.reasoningEffort);
26337
26366
  inputTokens += requiredUsageInteger(event.data.inputTokens, "input_tokens");
26338
26367
  cachedInputTokens += optionalUsageInteger(event.data.cacheReadTokens, "cache_read_tokens");
@@ -26348,10 +26377,9 @@ ${JSON.stringify(input.outputSchema)}`
26348
26377
  providerCallId = event.data.providerCallId ?? event.data.apiCallId ?? providerCallId;
26349
26378
  }
26350
26379
  if (usageEvents.length === 0) throw new Error("copilot_agent_usage_receipt_missing");
26351
- if (response.data.model) observedModels.add(response.data.model);
26352
- if (observedModels.size !== 1 || !observedModels.has(input.requestedModel)) {
26353
- throw new Error("copilot_agent_effective_model_mismatch");
26354
- }
26380
+ if (response.data.model !== void 0) observedModels.add(responseModelLabel(response.data.model));
26381
+ const effectiveModel = coherentResponseModel(observedModels);
26382
+ await checkpointObservedModel();
26355
26383
  const effectiveEffort = input.requestedReasoningEffort === "none" ? observedEfforts.size === 0 ? "none" : observedEfforts.size === 1 ? [...observedEfforts][0] : null : observedEfforts.size === 1 ? [...observedEfforts][0] : null;
26356
26384
  if (effectiveEffort !== input.requestedReasoningEffort) {
26357
26385
  throw new Error("copilot_agent_effective_effort_mismatch");
@@ -26372,7 +26400,7 @@ ${JSON.stringify(input.outputSchema)}`
26372
26400
  reasoningContent: response.data.reasoningText ?? null,
26373
26401
  reasoningSummary: null,
26374
26402
  requestedModel: input.requestedModel,
26375
- effectiveModel: input.requestedModel,
26403
+ effectiveModel,
26376
26404
  requestedReasoningEffort: input.requestedReasoningEffort,
26377
26405
  effectiveReasoningEffort: effectiveEffort,
26378
26406
  adapterRequestId: providerCallId ?? response.data.requestId ?? response.data.messageId,
@@ -26482,6 +26510,7 @@ var init_deepseek_transport_proxy = __esm({
26482
26510
  this.upstreamRequestStartedValue = false;
26483
26511
  this.providerResponseObservedValue = false;
26484
26512
  this.unansweredUpstreamRequestsValue = 0;
26513
+ this.latestReceiptValue = null;
26485
26514
  }
26486
26515
  get baseUrl() {
26487
26516
  if (!this.urlValue) throw new Error("deepseek_transport_proxy_not_started");
@@ -26490,6 +26519,9 @@ var init_deepseek_transport_proxy = __esm({
26490
26519
  get receipts() {
26491
26520
  return [...this.receiptsValue];
26492
26521
  }
26522
+ get lastReceipt() {
26523
+ return this.latestReceiptValue;
26524
+ }
26493
26525
  get providerResponseObserved() {
26494
26526
  return this.providerResponseObservedValue;
26495
26527
  }
@@ -26528,6 +26560,7 @@ var init_deepseek_transport_proxy = __esm({
26528
26560
  const controller = new AbortController();
26529
26561
  this.controllers.add(controller);
26530
26562
  try {
26563
+ this.latestReceiptValue = null;
26531
26564
  this.upstreamRequestStartedValue = true;
26532
26565
  this.unansweredUpstreamRequestsValue += 1;
26533
26566
  const upstream = await this.fetchImpl(
@@ -26571,6 +26604,7 @@ var init_deepseek_transport_proxy = __esm({
26571
26604
  const decoder2 = new TextDecoder();
26572
26605
  let pending2 = "";
26573
26606
  let observedId = "";
26607
+ let observedModel = "";
26574
26608
  let terminalObserved = false;
26575
26609
  const forwardLine = (line) => {
26576
26610
  if (!line.startsWith("data:")) {
@@ -26585,25 +26619,18 @@ var init_deepseek_transport_proxy = __esm({
26585
26619
  return;
26586
26620
  }
26587
26621
  if (value === "[DONE]") {
26588
- if (terminalObserved || !observedId) {
26622
+ if (terminalObserved || !observedId || !observedModel) {
26589
26623
  throw new Error("deepseek_provider_receipt_missing_or_mismatched");
26590
26624
  }
26591
26625
  terminalObserved = true;
26592
- this.receiptsValue.push({
26593
- id: observedId,
26594
- model: this.expectedModel,
26595
- requestedModel,
26596
- requestedReasoningEffort: requestedEffort
26597
- });
26598
- response.write(`${line}
26599
- `);
26600
26626
  return;
26601
26627
  }
26602
26628
  const event = JSON.parse(value);
26603
26629
  const eventId = typeof event.id === "string" ? event.id.trim() : "";
26604
- const eventModel = typeof event.model === "string" ? event.model.trim() : "";
26605
- if (!eventId || eventModel !== this.expectedModel || observedId && eventId !== observedId) throw new Error("deepseek_provider_receipt_missing_or_mismatched");
26630
+ const eventModel = typeof event.model === "string" ? event.model : "";
26631
+ if (terminalObserved || !eventId || !eventModel.trim() || eventModel.length > 256 || /[\u0000-\u001f\u007f]/u.test(eventModel) || observedModel && eventModel !== observedModel || observedId && eventId !== observedId) throw new Error("deepseek_provider_receipt_missing_or_mismatched");
26606
26632
  observedId = eventId;
26633
+ observedModel = eventModel;
26607
26634
  response.write(`${line}
26608
26635
  `);
26609
26636
  };
@@ -26620,6 +26647,10 @@ var init_deepseek_transport_proxy = __esm({
26620
26647
  if (!terminalObserved) {
26621
26648
  throw new Error("deepseek_provider_receipt_missing_or_mismatched");
26622
26649
  }
26650
+ const receipt = { id: observedId, model: observedModel, requestedModel, requestedReasoningEffort: requestedEffort };
26651
+ this.receiptsValue.push(receipt);
26652
+ this.latestReceiptValue = receipt;
26653
+ response.write("data: [DONE]\n\n");
26623
26654
  response.end();
26624
26655
  } finally {
26625
26656
  this.controllers.delete(controller);
@@ -27145,6 +27176,12 @@ ${JSON.stringify(input.outputSchema)}`,
27145
27176
  },
27146
27177
  execute: async (argumentsValue) => {
27147
27178
  const argumentsRecord = argumentsValue && typeof argumentsValue === "object" && !Array.isArray(argumentsValue) ? argumentsValue : {};
27179
+ const receipt = proxy.lastReceipt;
27180
+ if (!receipt) throw new Error("deepseek_harness_agent_receipt_missing");
27181
+ if (thread.effectiveModel !== receipt.model) {
27182
+ thread = { ...thread, effectiveModel: receipt.model };
27183
+ await input.onThreadReady?.(thread);
27184
+ }
27148
27185
  const callId = randomUUID2();
27149
27186
  const result2 = await input.executeTool({ callId, tool: definition.name, arguments: argumentsRecord });
27150
27187
  evidence.push({ callId, tool: definition.name, arguments: argumentsRecord, success: result2.success });
@@ -27192,7 +27229,7 @@ ${JSON.stringify(input.outputSchema)}`,
27192
27229
  yield* next();
27193
27230
  })();
27194
27231
  });
27195
- const thread = {
27232
+ let thread = {
27196
27233
  threadId: String(sessionId),
27197
27234
  threadPath: rootPath,
27198
27235
  effectiveModel: input.requestedModel,
@@ -27244,6 +27281,10 @@ ${JSON.stringify(input.outputSchema)}`,
27244
27281
  }
27245
27282
  const text = validateText(textFromBlocks(last.data.message.content, "text"), "deepseek_harness_agent_result_invalid");
27246
27283
  const receipts = proxy.receipts;
27284
+ if (thread.effectiveModel !== receipts.at(-1).model) {
27285
+ thread = { ...thread, effectiveModel: receipts.at(-1).model };
27286
+ await input.onThreadReady?.(thread);
27287
+ }
27247
27288
  await handle.dispose();
27248
27289
  return {
27249
27290
  thread,
@@ -33852,7 +33893,7 @@ var init_pi_transport = __esm({
33852
33893
  if (new Set(this.receipts.map((receipt) => receipt.id)).size !== this.receipts.length) throw new Error("pi_response_identity_reused");
33853
33894
  for (const receipt of this.receipts) {
33854
33895
  if (receipt.reasoningEffortChanged || (this.options.model.reasoning ? receipt.reasoningEffort !== this.options.expectedEffort.native : receipt.reasoningEffort !== null && receipt.reasoningEffort !== "none")) throw new Error("pi_native_effort_mismatch");
33855
- if (!receipt.id || receipt.model !== this.options.model.id || !receipt.terminal || receipt.input === null || receipt.output === null || receipt.cachedInput > receipt.input || receipt.input + receipt.output <= 0) {
33896
+ if (!receipt.id || typeof receipt.model !== "string" || !receipt.model.trim() || receipt.model.length > 256 || /[\u0000-\u001f\u007f]/u.test(receipt.model) || !receipt.terminal || receipt.input === null || receipt.output === null || receipt.cachedInput > receipt.input || receipt.input + receipt.output <= 0) {
33856
33897
  throw new Error("pi_native_receipt_unqualified");
33857
33898
  }
33858
33899
  }
@@ -34080,7 +34121,7 @@ var init_pi_adapter = __esm({
34080
34121
  if (this.activeThreads.has(cwd)) throw fail("pi_thread_busy");
34081
34122
  this.activeThreads.add(cwd);
34082
34123
  ownedPath = cwd;
34083
- if (agent.durableThread && (agent.durableThread.effectiveModel !== input.requestedModel || agent.durableThread.effectiveReasoningEffort !== input.requestedReasoningEffort)) throw fail("pi_thread_binding_changed", "model");
34124
+ if (agent.durableThread && agent.durableThread.effectiveReasoningEffort !== input.requestedReasoningEffort) throw fail("pi_thread_binding_changed", "model");
34084
34125
  }
34085
34126
  const settings = SettingsManager.inMemory({
34086
34127
  retry: { enabled: false, maxRetries: 0, provider: { maxRetries: 0 } },
@@ -34107,6 +34148,8 @@ var init_pi_adapter = __esm({
34107
34148
  if (!info.isFile() || info.isSymbolicLink()) throw fail("pi_session_not_owned");
34108
34149
  manager = SessionManager.open(sessionFile, cwd, cwd);
34109
34150
  if (manager.getSessionId() !== agent.durableThread.threadId || manager.getHeader()?.cwd !== cwd) throw fail("pi_session_binding_changed");
34151
+ const selection = manager.buildSessionContext().model;
34152
+ if (!selection || selection.provider !== model.provider || selection.modelId !== model.id) throw fail("pi_thread_binding_changed", "model");
34110
34153
  } else if (agent) {
34111
34154
  const initial = SessionManager.inMemory(cwd, { id: basename2(cwd).slice("agent-".length) });
34112
34155
  await writeAtomicInferencePrivateFile(sessionFile, `${JSON.stringify(initial.getHeader())}
@@ -34150,6 +34193,11 @@ var init_pi_adapter = __esm({
34150
34193
  session?.agent.abort();
34151
34194
  throw boundaryFailure;
34152
34195
  }
34196
+ const effectiveModel2 = `${model.provider}/${transport.lastReceipt.model}`;
34197
+ if (thread && thread.effectiveModel !== effectiveModel2) {
34198
+ thread = { ...thread, effectiveModel: effectiveModel2 };
34199
+ await agent.onThreadReady?.(thread);
34200
+ }
34153
34201
  const tool = definition.name;
34154
34202
  const result2 = await agent.executeTool({ callId, tool, arguments: args });
34155
34203
  tools.push({ callId, tool, arguments: args, success: result2.success });
@@ -34248,7 +34296,7 @@ var init_pi_adapter = __esm({
34248
34296
  for (let i = 0; i < messages.length; i++) {
34249
34297
  const message = messages[i];
34250
34298
  const native = observer.receipts[i];
34251
- if (message.responseId !== native.id || message.provider !== model.provider || message.model !== model.id || message.usage.input + message.usage.cacheRead + message.usage.cacheWrite !== native.input || message.usage.output !== native.output || message.usage.cacheRead !== native.cachedInput) throw fail("pi_receipt_mismatch");
34299
+ if (message.responseId !== native.id || message.provider !== model.provider || message.usage.input + message.usage.cacheRead + message.usage.cacheWrite !== native.input || message.usage.output !== native.output || message.usage.cacheRead !== native.cachedInput) throw fail("pi_receipt_mismatch");
34252
34300
  }
34253
34301
  if (!last) throw fail("pi_result_missing");
34254
34302
  if (last.stopReason !== "stop") throw fail("pi_terminal_incomplete");
@@ -34262,13 +34310,18 @@ var init_pi_adapter = __esm({
34262
34310
  }
34263
34311
  if (!validateOutput(output3)) throw fail("pi_output_schema_mismatch", "schema");
34264
34312
  const reasoning = last.content.flatMap((part) => part.type === "thinking" ? [part.thinking] : []).join("");
34313
+ const effectiveModel = `${model.provider}/${observer.receipts.at(-1).model}`;
34314
+ if (agent && thread && thread.effectiveModel !== effectiveModel) {
34315
+ thread = { ...thread, effectiveModel };
34316
+ await agent.onThreadReady?.(thread);
34317
+ }
34265
34318
  if (!agent) input.onTerminalDispatchOutcome?.("confirmed_dispatched");
34266
34319
  return { thread, tools, turn: {
34267
34320
  text,
34268
34321
  reasoningContent: reasoning ? Buffer.from(reasoning).subarray(0, 32768).toString("utf8") : null,
34269
34322
  reasoningSummary: null,
34270
34323
  requestedModel: input.requestedModel,
34271
- effectiveModel: `${model.provider}/${observer.receipts.at(-1).model}`,
34324
+ effectiveModel,
34272
34325
  requestedReasoningEffort: input.requestedReasoningEffort,
34273
34326
  effectiveReasoningEffort: observer.effectiveReasoningEffort(),
34274
34327
  adapterRequestId: observer.receipts[0].id,
@@ -34292,7 +34345,9 @@ var init_pi_adapter = __esm({
34292
34345
  };
34293
34346
  try {
34294
34347
  const effort2 = transport.effectiveReasoningEffort();
34295
- terminalEvidence = { ...terminalEvidence, effectiveModel: input.requestedModel, effectiveReasoningEffort: effort2 };
34348
+ const provider = input.requestedModel.slice(0, input.requestedModel.indexOf("/"));
34349
+ const actualModel = transport.lastReceipt?.model;
34350
+ if (actualModel) terminalEvidence = { ...terminalEvidence, effectiveModel: `${provider}/${actualModel}`, effectiveReasoningEffort: effort2 };
34296
34351
  } catch {
34297
34352
  }
34298
34353
  }
@@ -34300,7 +34355,7 @@ var init_pi_adapter = __esm({
34300
34355
  try {
34301
34356
  const qualified = messages.filter((message, index) => {
34302
34357
  const receipt = transport?.receipts[index];
34303
- return receipt && receipt.terminal && receipt.id === message.responseId && `${message.provider}/${receipt.model}` === input.requestedModel && message.usage.input + message.usage.cacheRead + message.usage.cacheWrite === receipt.input && message.usage.output === receipt.output && message.usage.cacheRead === receipt.cachedInput && (receipt.input ?? 0) + (receipt.output ?? 0) > 0;
34358
+ return receipt && receipt.terminal && receipt.id === message.responseId && message.provider === input.requestedModel.slice(0, input.requestedModel.indexOf("/")) && typeof receipt.model === "string" && Boolean(receipt.model.trim()) && receipt.model.length <= 256 && !/[\u0000-\u001f\u007f]/u.test(receipt.model) && message.usage.input + message.usage.cacheRead + message.usage.cacheWrite === receipt.input && message.usage.output === receipt.output && message.usage.cacheRead === receipt.cachedInput && (receipt.input ?? 0) + (receipt.output ?? 0) > 0;
34304
34359
  });
34305
34360
  if (qualified.length) usage = usageSum(qualified);
34306
34361
  } catch {
@@ -34484,7 +34539,7 @@ var init_grok_binary = __esm({
34484
34539
  import { readFile as readFile6 } from "node:fs/promises";
34485
34540
  import { dirname as dirname7, resolve as resolve5 } from "node:path";
34486
34541
  import { fileURLToPath } from "node:url";
34487
- var validateGrokPolicy, grokAllowedEffectiveModels, loadGrokPolicy;
34542
+ var validateGrokPolicy, loadGrokPolicy;
34488
34543
  var init_grok_policy = __esm({
34489
34544
  "lib/inference-host/grok-policy.ts"() {
34490
34545
  "use strict";
@@ -34502,26 +34557,12 @@ var init_grok_policy = __esm({
34502
34557
  throw new Error("Grok transport bounds are missing or invalid.");
34503
34558
  }
34504
34559
  }
34505
- const aliases = policy.effective_model_aliases;
34506
- if (!aliases || typeof aliases !== "object" || Array.isArray(aliases) || ![Object.prototype, null].includes(Object.getPrototypeOf(aliases)) || Object.keys(aliases).length > 64) throw new Error("Grok effective model aliases are missing or invalid.");
34507
- const validModel = (model) => typeof model === "string" && model.length > 0 && model.length <= 256 && model.trim() === model && !/[\u0000-\u001f\u007f]/u.test(model);
34508
- const entries = Object.entries(aliases);
34509
- for (const [requested, effective] of entries) {
34510
- if (!validModel(requested) || !Array.isArray(effective) || effective.length < 1 || effective.length > 15 || !effective.every(validModel) || new Set(effective).size !== effective.length || effective.includes(requested)) {
34511
- throw new Error("Grok effective model aliases are missing or invalid.");
34512
- }
34513
- }
34514
- const effectiveModelAliases = Object.freeze(Object.fromEntries(
34515
- entries.map(([requested, effective]) => [requested, Object.freeze([...effective])])
34516
- ));
34517
34560
  return Object.freeze({
34518
34561
  subscription_proxy_base_url: url2.href,
34519
34562
  maximum_transport_request_bytes: Number(policy.maximum_transport_request_bytes),
34520
- maximum_transport_response_bytes: Number(policy.maximum_transport_response_bytes),
34521
- effective_model_aliases: effectiveModelAliases
34563
+ maximum_transport_response_bytes: Number(policy.maximum_transport_response_bytes)
34522
34564
  });
34523
34565
  };
34524
- grokAllowedEffectiveModels = (policy, requested) => Object.freeze([requested, ...Object.hasOwn(policy.effective_model_aliases, requested) ? policy.effective_model_aliases[requested] : []]);
34525
34566
  loadGrokPolicy = async () => {
34526
34567
  if (typeof define_VTX_GROK_POLICY_default !== "undefined") return validateGrokPolicy(define_VTX_GROK_POLICY_default);
34527
34568
  const config2 = parse3(await readFile6(resolve5(dirname7(fileURLToPath(import.meta.url)), "../../../config.toml"), "utf8"));
@@ -34530,6 +34571,46 @@ var init_grok_policy = __esm({
34530
34571
  }
34531
34572
  });
34532
34573
 
34574
+ // lib/inference-host/grok-model-catalog.ts
34575
+ var object3, identity, parseGrokModelCatalog;
34576
+ var init_grok_model_catalog = __esm({
34577
+ "lib/inference-host/grok-model-catalog.ts"() {
34578
+ "use strict";
34579
+ init_define_VTX_EXO_POLICY();
34580
+ init_define_VTX_GROK_POLICY();
34581
+ init_define_VTX_PI_MODEL_POLICY();
34582
+ object3 = (value) => {
34583
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("grok_model_catalog_invalid");
34584
+ return value;
34585
+ };
34586
+ identity = (value) => {
34587
+ if (value == null) return void 0;
34588
+ if (typeof value !== "string" || !value || value !== value.trim() || value.length > 256 || /[\u0000-\u001f\u007f]/u.test(value)) throw new Error("grok_model_catalog_identity_invalid");
34589
+ return value;
34590
+ };
34591
+ parseGrokModelCatalog = (value) => {
34592
+ const data4 = object3(value).data;
34593
+ if (!Array.isArray(data4)) throw new Error("grok_model_catalog_invalid");
34594
+ const result2 = /* @__PURE__ */ new Map();
34595
+ for (const raw of data4) {
34596
+ const row = object3(raw);
34597
+ const meta3 = row._meta == null ? {} : object3(row._meta);
34598
+ const id2 = identity(row.id);
34599
+ const transportModel = identity(row.model) ?? identity(row.modelId) ?? id2 ?? identity(meta3.model) ?? identity(meta3.modelId);
34600
+ if (!transportModel) throw new Error("grok_model_catalog_identity_missing");
34601
+ const selector = id2 ?? transportModel;
34602
+ if (result2.has(selector)) throw new Error("grok_model_catalog_identity_ambiguous");
34603
+ result2.set(selector, Object.freeze({
34604
+ selector,
34605
+ transportModel,
34606
+ allowedEffectiveModels: Object.freeze([.../* @__PURE__ */ new Set([selector, transportModel])])
34607
+ }));
34608
+ }
34609
+ return result2;
34610
+ };
34611
+ }
34612
+ });
34613
+
34533
34614
  // lib/inference-host/grok-transport-proxy.ts
34534
34615
  import { createServer as createServer3 } from "node:http";
34535
34616
  import { createHash as createHash6, randomBytes as randomBytes5 } from "node:crypto";
@@ -34541,6 +34622,7 @@ var init_grok_transport_proxy = __esm({
34541
34622
  init_define_VTX_EXO_POLICY();
34542
34623
  init_define_VTX_GROK_POLICY();
34543
34624
  init_define_VTX_PI_MODEL_POLICY();
34625
+ init_grok_model_catalog();
34544
34626
  init_external_inference_contract();
34545
34627
  diagnosticNames = /* @__PURE__ */ new Set([
34546
34628
  "search_tool",
@@ -34574,6 +34656,8 @@ var init_grok_transport_proxy = __esm({
34574
34656
  this.requestFingerprints = /* @__PURE__ */ new Set();
34575
34657
  this.pending = false;
34576
34658
  this.closed = false;
34659
+ this.catalogValue = null;
34660
+ this.boundIdentity = null;
34577
34661
  this.observedModel = null;
34578
34662
  this.dispatched = false;
34579
34663
  this.responded = false;
@@ -34583,11 +34667,7 @@ var init_grok_transport_proxy = __esm({
34583
34667
  this.toolValidationFailure = null;
34584
34668
  this.responseIdentityFailure = null;
34585
34669
  const upstream = new URL(options.upstreamBaseUrl);
34586
- const models = options.allowedEffectiveModels ?? [options.requestedModel];
34587
- if (!models.includes(options.requestedModel) || models.length > 16 || new Set(models).size !== models.length || models.some((model) => typeof model !== "string" || !model.trim())) {
34588
- throw new Error("grok_proxy_invalid_configuration");
34589
- }
34590
- 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");
34670
+ if (upstream.protocol !== "https:" || upstream.username || upstream.password || upstream.search || upstream.hash || !options.metadataOnly && !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");
34591
34671
  }
34592
34672
  get baseUrl() {
34593
34673
  if (!this.urlValue) throw new Error("grok_proxy_not_started");
@@ -34602,6 +34682,18 @@ var init_grok_transport_proxy = __esm({
34602
34682
  get pendingRequest() {
34603
34683
  return this.pending;
34604
34684
  }
34685
+ get modelCatalog() {
34686
+ return this.catalogValue ? new Map(this.catalogValue) : null;
34687
+ }
34688
+ bindModelIdentity(selector, frozenProviderAllowance) {
34689
+ if (this.options.metadataOnly || this.boundIdentity || this.pending || this.dispatched || this.closed || selector !== this.options.requestedModel) throw new Error("grok_model_identity_binding_invalid");
34690
+ const identity2 = this.catalogValue?.get(selector);
34691
+ if (!identity2) throw new Error("grok_model_catalog_identity_missing");
34692
+ const allowed = identity2.allowedEffectiveModels.filter((model) => !frozenProviderAllowance || frozenProviderAllowance.includes(model));
34693
+ if (!allowed.includes(identity2.transportModel)) throw new Error("grok_model_catalog_identity_changed");
34694
+ this.boundIdentity = Object.freeze({ ...identity2, allowedEffectiveModels: Object.freeze(allowed) });
34695
+ return this.boundIdentity;
34696
+ }
34605
34697
  async start() {
34606
34698
  if (this.server) return;
34607
34699
  if (this.closed) throw new Error("grok_proxy_closed");
@@ -34651,7 +34743,8 @@ var init_grok_transport_proxy = __esm({
34651
34743
  }
34652
34744
  validatePayload(payload, route) {
34653
34745
  const requestedEffort = route === "/responses" ? record3(payload.reasoning).effort : payload.reasoning_effort;
34654
- if (payload.model !== this.options.requestedModel || effort(requestedEffort) !== effort(this.options.requestedReasoningEffort)) {
34746
+ if (!this.boundIdentity) throw new Error("grok_model_identity_not_bound");
34747
+ if (payload.model !== this.boundIdentity.transportModel || effort(requestedEffort) !== effort(this.options.requestedReasoningEffort)) {
34655
34748
  throw new Error("grok_outbound_model_or_effort_mismatch");
34656
34749
  }
34657
34750
  if (payload.stream !== true) throw new Error("grok_streaming_required");
@@ -34704,6 +34797,7 @@ var init_grok_transport_proxy = __esm({
34704
34797
  if (!authorization?.startsWith("Bearer ") || authorization.length <= 7) throw new Error("grok_proxy_auth_required");
34705
34798
  let body;
34706
34799
  if (inference) {
34800
+ if (this.options.metadataOnly) throw new Error("grok_metadata_only");
34707
34801
  if (this.pending || this.failureCode || this.terminalFailure || this.rejectionStatus) {
34708
34802
  throw new Error("grok_redispatch_blocked");
34709
34803
  }
@@ -34754,7 +34848,7 @@ var init_grok_transport_proxy = __esm({
34754
34848
  if (typeof value === "string") headers.set(name, value);
34755
34849
  }
34756
34850
  if (inference) {
34757
- if (headers.has("x-grok-model-override") && headers.get("x-grok-model-override") !== this.options.requestedModel) {
34851
+ if (headers.has("x-grok-model-override") && headers.get("x-grok-model-override") !== this.boundIdentity.transportModel) {
34758
34852
  throw new Error("grok_outbound_model_or_effort_mismatch");
34759
34853
  }
34760
34854
  this.checkDispatch();
@@ -34792,6 +34886,29 @@ var init_grok_transport_proxy = __esm({
34792
34886
  const value = upstream.headers.get(name);
34793
34887
  if (value) responseHeaders[name] = value;
34794
34888
  }
34889
+ if (metadata && route === "/models") {
34890
+ const chunks = [];
34891
+ let bytes3 = 0;
34892
+ const reader = upstream.body.getReader();
34893
+ try {
34894
+ for (; ; ) {
34895
+ if (controller.signal.aborted) throw new Error("grok_proxy_cancelled");
34896
+ const part = await reader.read();
34897
+ if (part.done) break;
34898
+ bytes3 += part.value.byteLength;
34899
+ if (bytes3 > this.options.maxResponseBytes) throw new Error("grok_response_too_large");
34900
+ chunks.push(part.value);
34901
+ }
34902
+ } finally {
34903
+ await reader.cancel().catch(() => void 0);
34904
+ }
34905
+ const catalogBytes = Buffer.concat(chunks);
34906
+ const catalog = parseGrokModelCatalog(JSON.parse(catalogBytes.toString("utf8")));
34907
+ if (!this.boundIdentity) this.catalogValue = catalog;
34908
+ response.writeHead(upstream.status, responseHeaders);
34909
+ response.end(catalogBytes);
34910
+ return;
34911
+ }
34795
34912
  response.writeHead(upstream.status, responseHeaders);
34796
34913
  await this.forward(upstream, response, inference ? route : null, controller.signal);
34797
34914
  response.end();
@@ -34858,17 +34975,17 @@ var init_grok_transport_proxy = __esm({
34858
34975
  const event = record3(JSON.parse(data4));
34859
34976
  const native = route === "/responses" ? record3(event.response) : event;
34860
34977
  if (native.id !== void 0 || native.model !== void 0) {
34861
- if (typeof native.id !== "string" || !native.id || !(this.options.allowedEffectiveModels ?? [this.options.requestedModel]).includes(native.model) || id2 && native.id !== id2) {
34978
+ if (typeof native.id !== "string" || !native.id || typeof native.model !== "string" || !native.model.trim() || native.model.length > 256 || /[\u0000-\u001f\u007f]/u.test(native.model) || id2 && native.id !== id2) {
34862
34979
  const idPresent = typeof native.id === "string" && native.id.length > 0;
34863
34980
  const modelPresent = typeof native.model === "string" && native.model.length > 0;
34864
34981
  const modelMatches = native.model === this.options.requestedModel;
34865
- if (idPresent && !modelMatches && id2 && native.id !== id2 && (this.options.allowedEffectiveModels ?? [this.options.requestedModel]).includes(native.model)) {
34982
+ if (idPresent && !modelMatches && id2 && native.id !== id2) {
34866
34983
  throw new Error("grok_provider_response_id_changed");
34867
34984
  }
34868
34985
  const eventType = route === "/responses" ? event.type : event.object;
34869
34986
  this.responseIdentityFailure = grokResponseIdentityDiagnosticSchema.parse({
34870
34987
  schema_version: "external_inference_grok_response_identity_v1",
34871
- reason: !idPresent ? "invalid_id" : !modelMatches ? "model_mismatch" : "changed_id",
34988
+ reason: !idPresent ? "invalid_id" : id2 && native.id !== id2 ? "changed_id" : "model_mismatch",
34872
34989
  route,
34873
34990
  response_event: ["response.created", "response.in_progress", "response.completed", "chat.completion.chunk"].includes(String(eventType)) ? eventType : "other",
34874
34991
  id_present: idPresent,
@@ -35543,11 +35660,11 @@ var init_grok_adapter = __esm({
35543
35660
  isDefault: state.currentModelId === model.modelId
35544
35661
  }];
35545
35662
  });
35546
- grokPromptUsage = (value, expectedModel, allowedEffectiveModels = [expectedModel]) => {
35663
+ grokPromptUsage = (value, expectedModel) => {
35547
35664
  const usage = grokObject(value);
35548
35665
  if (usage.usageIsIncomplete === true) throw new Error("grok_usage_incomplete");
35549
35666
  const models = Object.keys(grokObject(usage.modelUsage));
35550
- if (models.length !== 1 || !allowedEffectiveModels.includes(models[0])) throw new Error("grok_effective_model_mismatch");
35667
+ if (models.length !== 1 || models[0] !== expectedModel) throw new Error("grok_effective_model_mismatch");
35551
35668
  const inputTokens = integer2(usage.inputTokens, "input_tokens");
35552
35669
  const outputTokens = integer2(usage.outputTokens, "output_tokens");
35553
35670
  const cachedInputTokens = integer2(usage.cachedReadTokens, "cached_input_tokens");
@@ -35641,29 +35758,49 @@ var init_grok_adapter = __esm({
35641
35758
  signal.throwIfAborted();
35642
35759
  const workspace = await createGrokOwnedWorkspace(this.stateOptions, "preflight");
35643
35760
  let session = null;
35761
+ let proxy = null;
35644
35762
  try {
35645
35763
  signal.throwIfAborted();
35646
- session = new GrokAcpSession({ binaryPath: binary.path, grokHome: this.grokHome, cwd: workspace });
35647
- this.active.add(session);
35648
35764
  const deadline = Date.now() + 3e4;
35765
+ const policy = this.options.policy ?? await loadGrokPolicy();
35766
+ proxy = await createGrokTransportProxy({
35767
+ upstreamBaseUrl: policy.subscription_proxy_base_url,
35768
+ maxRequestBytes: policy.maximum_transport_request_bytes,
35769
+ maxResponseBytes: policy.maximum_transport_response_bytes,
35770
+ metadataOnly: true,
35771
+ requestedModel: "",
35772
+ requestedReasoningEffort: "none",
35773
+ expectedSystemPrompt: "",
35774
+ allowedToolNames: [],
35775
+ deadlineAtMs: deadline,
35776
+ signal,
35777
+ fetchImpl: this.options.fetchImpl
35778
+ });
35779
+ session = new GrokAcpSession({
35780
+ binaryPath: binary.path,
35781
+ grokHome: this.grokHome,
35782
+ cwd: workspace,
35783
+ config: { endpoints: { cli_chat_proxy_base_url: proxy.baseUrl } }
35784
+ });
35785
+ this.active.add(session);
35649
35786
  await this.initialize(session, "VTX inference host capability discovery.", deadline, signal);
35650
35787
  const auth = unwrap(await session.request("_x.ai/auth/info", {}, deadline, signal));
35651
35788
  if (auth.methodId !== "cached_token" || auth.userBlockedReason || list(auth.teamBlockedReasons).length) {
35652
35789
  throw new Error("grok_subscription_auth_unavailable");
35653
35790
  }
35654
35791
  const state = unwrap(await session.request("_x.ai/models/list", {}, deadline, signal));
35655
- const policy = this.options.policy ?? await loadGrokPolicy();
35656
- const capabilities = grokModelCapabilities(state).map((capability) => ({
35657
- ...capability,
35658
- allowedEffectiveModels: grokAllowedEffectiveModels(policy, capability.model)
35659
- }));
35792
+ const capabilities = grokModelCapabilities(state).map((capability) => {
35793
+ const identity3 = proxy.modelCatalog?.get(capability.model);
35794
+ if (!identity3) throw new Error("grok_model_catalog_identity_missing");
35795
+ return { ...capability, allowedEffectiveModels: identity3.allowedEffectiveModels };
35796
+ });
35660
35797
  if (!capabilities.length) throw new Error("grok_model_catalog_empty");
35661
- const identity = typeof auth.principalId === "string" && auth.principalId ? auth.principalId : typeof auth.email === "string" && auth.email ? auth.email.toLowerCase() : null;
35662
- if (!identity) throw new Error("grok_account_identity_required");
35798
+ const identity2 = typeof auth.principalId === "string" && auth.principalId ? auth.principalId : typeof auth.email === "string" && auth.email ? auth.email.toLowerCase() : null;
35799
+ if (!identity2) throw new Error("grok_account_identity_required");
35663
35800
  return {
35664
35801
  adapterId: "grok-build",
35665
35802
  runtimeVersion: binary.version,
35666
- authenticatedAccountIdentity: identity,
35803
+ authenticatedAccountIdentity: identity2,
35667
35804
  authenticatedAccountEmail: typeof auth.email === "string" ? auth.email : null,
35668
35805
  authenticatedAccountPlan: null,
35669
35806
  modelCapabilities: capabilities,
@@ -35676,7 +35813,11 @@ var init_grok_adapter = __esm({
35676
35813
  await session?.close();
35677
35814
  } finally {
35678
35815
  if (session) this.active.delete(session);
35679
- await releaseGrokOwnedWorkspace(this.stateOptions, workspace);
35816
+ try {
35817
+ await proxy?.close();
35818
+ } finally {
35819
+ await releaseGrokOwnedWorkspace(this.stateOptions, workspace);
35820
+ }
35680
35821
  }
35681
35822
  }
35682
35823
  }
@@ -35701,7 +35842,6 @@ var init_grok_adapter = __esm({
35701
35842
  const startedAt = Date.now();
35702
35843
  const binary = await this.binary();
35703
35844
  const policy = this.options.policy ?? await loadGrokPolicy();
35704
- const allowedEffectiveModels = grokAllowedEffectiveModels(policy, input.requestedModel);
35705
35845
  input.signal.throwIfAborted();
35706
35846
  const workspace = agent?.durableThread ? await validateGrokOwnedThread(this.stateOptions, agent.durableThread) : await createGrokOwnedWorkspace(this.stateOptions, agent ? "agent" : "attempt");
35707
35847
  let mcp = null;
@@ -35757,7 +35897,6 @@ var init_grok_adapter = __esm({
35757
35897
  expectedSystemPrompt: input.systemPrompt,
35758
35898
  requestedModel: input.requestedModel,
35759
35899
  requestedReasoningEffort: input.requestedReasoningEffort,
35760
- allowedEffectiveModels,
35761
35900
  allowedToolNames: agent ? ["search_tool", "use_tool"] : [],
35762
35901
  deadlineAtMs: input.deadlineAtMs,
35763
35902
  providerDispatchNotAfterMs: provider?.providerDispatchNotAfterMs,
@@ -35795,6 +35934,8 @@ var init_grok_adapter = __esm({
35795
35934
  const catalog = unwrap(await session.request("_x.ai/models/list", {}, input.deadlineAtMs, input.signal));
35796
35935
  const selectedCapability = grokModelCapabilities(catalog).find((entry) => entry.model === input.requestedModel);
35797
35936
  if (!selectedCapability?.supportedReasoningEfforts.includes(input.requestedReasoningEffort)) throw new Error("grok_model_selection_unavailable");
35937
+ if (provider && !provider.allowedEffectiveModels) throw new Error("grok_model_identity_contract_missing");
35938
+ const { transportModel } = proxy.bindModelIdentity(input.requestedModel, provider?.allowedEffectiveModels);
35798
35939
  const metadata = {
35799
35940
  systemPromptOverride: input.systemPrompt,
35800
35941
  agentProfile: agentProfile(Boolean(agent)),
@@ -35821,6 +35962,14 @@ var init_grok_adapter = __esm({
35821
35962
  _meta: metadata
35822
35963
  }, input.deadlineAtMs, input.signal);
35823
35964
  }
35965
+ if (transportModel !== input.requestedModel) {
35966
+ created = await session.request("session/load", {
35967
+ sessionId,
35968
+ cwd: workspace,
35969
+ mcpServers: mcp ? [mcp.descriptor] : [],
35970
+ _meta: metadata
35971
+ }, input.deadlineAtMs, input.signal);
35972
+ }
35824
35973
  assertSelection(created, input.requestedModel, input.requestedReasoningEffort);
35825
35974
  const thread = {
35826
35975
  threadId: sessionId,
@@ -35853,8 +36002,9 @@ var init_grok_adapter = __esm({
35853
36002
  if (meta3.structuredOutputError || meta3.structuredOutput === void 0) throw new Error("grok_structured_output_missing");
35854
36003
  const text = JSON.stringify(meta3.structuredOutput);
35855
36004
  if (Buffer.byteLength(text) > 3e5) throw new Error("grok_result_too_large");
35856
- const usage = grokPromptUsage(meta3.usage, input.requestedModel, allowedEffectiveModels);
35857
- const actualModel = Object.keys(grokObject(grokObject(meta3.usage).modelUsage))[0];
36005
+ const actualModel = proxy.observedModel;
36006
+ if (!actualModel) throw new Error("grok_transport_receipt_missing");
36007
+ const usage = grokPromptUsage(meta3.usage, actualModel);
35858
36008
  if (!proxy.dispatched || !proxy.responded || proxy.terminalFailure) throw new Error(proxy.failureCode ?? "grok_transport_receipt_missing");
35859
36009
  const receipts = proxy.receipts;
35860
36010
  if (!receipts.length || proxy.pendingRequest || receipts.some((receipt) => receipt.model !== actualModel || receipt.requestedReasoningEffort !== input.requestedReasoningEffort || receipt.input === null || receipt.output === null || receipt.cachedInput === null) || receipts.reduce((sum, receipt) => sum + receipt.input, 0) !== usage.inputTokens || receipts.reduce((sum, receipt) => sum + receipt.output, 0) !== usage.outputTokens || receipts.reduce((sum, receipt) => sum + receipt.cachedInput, 0) !== usage.cachedInputTokens || integer2(grokObject(meta3.usage).modelCalls, "model_calls") !== receipts.length) {
@@ -36024,7 +36174,7 @@ import { createServer as createServer5 } from "node:http";
36024
36174
  import { access as access3, lstat as lstat8, readdir as readdir4, realpath as realpath7, rm as rm9 } from "node:fs/promises";
36025
36175
  import { basename as basename4, dirname as dirname9, join as join12, resolve as resolve7 } from "node:path";
36026
36176
  import { fileURLToPath as fileURLToPath2 } from "node:url";
36027
- var import_ajv2, failure, object3, receiptUsage, assertOwnedRuntime, cleanupExoOwnedState, ExoForegroundAdapter;
36177
+ var import_ajv2, failure, object4, validModel, receiptUsage, assertOwnedRuntime, cleanupExoOwnedState, ExoForegroundAdapter;
36028
36178
  var init_exo_adapter = __esm({
36029
36179
  "lib/inference-host/exo-adapter.ts"() {
36030
36180
  "use strict";
@@ -36042,9 +36192,10 @@ var init_exo_adapter = __esm({
36042
36192
  retryable: false,
36043
36193
  dispatchOutcome: dispatched ? "outcome_unknown" : "not_dispatched"
36044
36194
  });
36045
- object3 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
36195
+ object4 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
36196
+ validModel = (value) => typeof value === "string" && Boolean(value.trim()) && value.length <= 256 && !/[\u0000-\u001f\u007f]/u.test(value);
36046
36197
  receiptUsage = (value) => {
36047
- const usage = object3(value);
36198
+ const usage = object4(value);
36048
36199
  for (const key of ["inputTokens", "cachedInputTokens", "outputTokens", "reasoningOutputTokens", "totalTokens"]) {
36049
36200
  if (!Number.isSafeInteger(usage[key]) || Number(usage[key]) < 0) return null;
36050
36201
  }
@@ -36063,8 +36214,9 @@ var init_exo_adapter = __esm({
36063
36214
  const info = await lstat8(root);
36064
36215
  if (!info.isDirectory() || info.isSymbolicLink() || await realpath7(root) !== root) throw failure("exo_state_not_owned");
36065
36216
  const raw = await readInferencePrivateFile(join12(root, "vtx-owner.json"), "Exo state owner");
36066
- const owner2 = raw === null ? {} : object3(JSON.parse(raw));
36217
+ const owner2 = raw === null ? {} : object4(JSON.parse(raw));
36067
36218
  if (owner2.adapter !== "exo" || owner2.id !== id2 || owner2.root !== root) throw failure("exo_state_not_owned");
36219
+ return owner2;
36068
36220
  };
36069
36221
  cleanupExoOwnedState = async (stateRoot) => {
36070
36222
  try {
@@ -36203,8 +36355,10 @@ var init_exo_adapter = __esm({
36203
36355
  if (!credential || credential.provider !== provider) throw failure("exo_credential_required", false, "auth");
36204
36356
  const id2 = agent?.durableThread?.threadId ?? randomUUID6();
36205
36357
  const runtimeRoot = agent?.durableThread ? await this.ownedRoot(agent.durableThread) : join12(await realpath7(this.options.stateRoot), `${agent ? "agent" : "attempt"}-${id2}`);
36206
- const thread = { threadId: id2, threadPath: runtimeRoot, effectiveModel: input.requestedModel, effectiveReasoningEffort: input.requestedReasoningEffort };
36207
- if (agent?.durableThread && (agent.durableThread.effectiveModel !== thread.effectiveModel || agent.durableThread.effectiveReasoningEffort !== thread.effectiveReasoningEffort)) throw failure("exo_thread_selection_mismatch");
36358
+ let thread = { threadId: id2, threadPath: runtimeRoot, effectiveModel: input.requestedModel, effectiveReasoningEffort: input.requestedReasoningEffort };
36359
+ const owner2 = agent?.durableThread ? await assertOwnedRuntime(runtimeRoot, id2) : null;
36360
+ const boundSelection = owner2?.requestedModel ?? agent?.durableThread?.effectiveModel;
36361
+ if (agent?.durableThread && (boundSelection !== input.requestedModel || agent.durableThread.effectiveReasoningEffort !== thread.effectiveReasoningEffort)) throw failure("exo_thread_selection_mismatch");
36208
36362
  const schema = agent ? agent.outputSchema : JSON.parse(input.outputSchemaJson);
36209
36363
  const validate = new import_ajv2.default({ allErrors: true }).compile(schema);
36210
36364
  const started = Date.now();
@@ -36265,7 +36419,7 @@ var init_exo_adapter = __esm({
36265
36419
  raw += String(chunk);
36266
36420
  if (Buffer.byteLength(raw) > 2e6) throw failure("exo_bridge_input_too_large");
36267
36421
  }
36268
- const body = object3(JSON.parse(raw));
36422
+ const body = object4(JSON.parse(raw));
36269
36423
  if (terminal || workerFailure) throw failure("exo_turn_already_finished");
36270
36424
  if (request.url === "/dispatch") {
36271
36425
  if (body.model !== providerModel || body.reasoningEffort !== input.requestedReasoningEffort) throw failure("exo_dispatch_identity_mismatch");
@@ -36279,11 +36433,15 @@ var init_exo_adapter = __esm({
36279
36433
  return;
36280
36434
  }
36281
36435
  if (request.url === "/tool") {
36282
- if (!agent || !dispatched || toolBusy || typeof body.callId !== "string" || toolIds.has(body.callId) || !CODEX_AGENT_DYNAMIC_TOOLS.includes(body.tool) || body.effectiveModel !== input.requestedModel || body.effectiveReasoningEffort !== input.requestedReasoningEffort) throw failure("exo_tool_not_authorized");
36436
+ if (!agent || !dispatched || toolBusy || typeof body.callId !== "string" || toolIds.has(body.callId) || !CODEX_AGENT_DYNAMIC_TOOLS.includes(body.tool) || !validModel(body.effectiveModel) || body.effectiveReasoningEffort !== input.requestedReasoningEffort) throw failure("exo_tool_not_authorized");
36283
36437
  toolBusy = true;
36284
36438
  toolIds.add(body.callId);
36285
- const call = { callId: body.callId, tool: body.tool, arguments: object3(body.arguments) };
36439
+ const call = { callId: body.callId, tool: body.tool, arguments: object4(body.arguments) };
36286
36440
  try {
36441
+ if (thread.effectiveModel !== body.effectiveModel) {
36442
+ thread = { ...thread, effectiveModel: body.effectiveModel };
36443
+ await agent.onThreadReady?.(thread);
36444
+ }
36287
36445
  let result2;
36288
36446
  try {
36289
36447
  result2 = await agent.executeTool(call);
@@ -36317,7 +36475,10 @@ var init_exo_adapter = __esm({
36317
36475
  try {
36318
36476
  input.signal?.throwIfAborted();
36319
36477
  await ensureInferencePrivateDirectory(runtimeRoot);
36320
- if (!agent?.durableThread) await writeAtomicInferencePrivateFile(join12(runtimeRoot, "vtx-owner.json"), JSON.stringify({ adapter: "exo", id: id2, root: runtimeRoot }));
36478
+ if (!owner2 || owner2.requestedModel === void 0) await writeAtomicInferencePrivateFile(
36479
+ join12(runtimeRoot, "vtx-owner.json"),
36480
+ JSON.stringify({ adapter: "exo", id: id2, root: runtimeRoot, requestedModel: input.requestedModel })
36481
+ );
36321
36482
  await new Promise((done, reject) => {
36322
36483
  server.once("error", reject);
36323
36484
  server.listen(0, "127.0.0.1", done);
@@ -36338,7 +36499,7 @@ var init_exo_adapter = __esm({
36338
36499
  }
36339
36500
  const result2 = terminal;
36340
36501
  if (!result2 || workerFailure) throw failure("exo_terminal_receipt_missing", dispatched);
36341
- if (result2.providerModel !== providerModel || result2.reasoningEffort !== input.requestedReasoningEffort) throw failure("exo_effective_identity_mismatch", dispatched, "model");
36502
+ if (!validModel(result2.providerModel) || result2.reasoningEffort !== input.requestedReasoningEffort) throw failure("exo_effective_identity_mismatch", dispatched, "model");
36342
36503
  const usage = receiptUsage(result2.usage);
36343
36504
  if (!usage) throw failure("exo_usage_invalid", dispatched);
36344
36505
  let validOutput = false;
@@ -36350,13 +36511,18 @@ var init_exo_adapter = __esm({
36350
36511
  }
36351
36512
  if (!validOutput || typeof result2.text !== "string") throw failure("exo_output_schema_invalid", dispatched, "schema");
36352
36513
  if (typeof result2.responseId !== "string" || !result2.responseId) throw failure("exo_response_id_missing", dispatched);
36514
+ const effectiveModel = `${provider}/${result2.providerModel}`;
36515
+ if (thread.effectiveModel !== effectiveModel) {
36516
+ thread = { ...thread, effectiveModel };
36517
+ await agent?.onThreadReady?.(thread);
36518
+ }
36353
36519
  if (!agent) input.onTerminalDispatchOutcome?.("confirmed_dispatched");
36354
36520
  return { thread, tools, turn: {
36355
36521
  text: result2.text,
36356
36522
  reasoningContent: null,
36357
36523
  reasoningSummary: null,
36358
36524
  requestedModel: input.requestedModel,
36359
- effectiveModel: input.requestedModel,
36525
+ effectiveModel,
36360
36526
  requestedReasoningEffort: input.requestedReasoningEffort,
36361
36527
  effectiveReasoningEffort: input.requestedReasoningEffort,
36362
36528
  adapterRequestId: id2,
@@ -36372,7 +36538,7 @@ var init_exo_adapter = __esm({
36372
36538
  const receipt = terminal;
36373
36539
  const completed = receipt !== null || knownFailure?.terminalKnown === true;
36374
36540
  const evidence = receipt ?? knownFailure;
36375
- const identityQualified = evidence?.providerModel === providerModel && evidence?.reasoningEffort === input.requestedReasoningEffort;
36541
+ const identityQualified = validModel(evidence?.providerModel) && evidence?.reasoningEffort === input.requestedReasoningEffort;
36376
36542
  const outcome = !dispatched ? "not_dispatched" : completed ? "confirmed_dispatched" : "outcome_unknown";
36377
36543
  const knownCode = typeof knownFailure?.code === "string" && /^exo_[a-z_]+$/u.test(knownFailure.code) ? knownFailure.code : null;
36378
36544
  const observedCode = completed ? knownCode ?? (error48 instanceof CodexAppServerError ? error48.code : "exo_turn_failed") : abort.signal.aborted ? "exo_interrupted" : "exo_unconfirmed_result";
@@ -36388,7 +36554,7 @@ var init_exo_adapter = __esm({
36388
36554
  httpStatusCode: ["quota_exceeded", "provider_rate_limited"].includes(code) ? 429 : null,
36389
36555
  retryAtMs: completed && Number.isSafeInteger(evidence?.retryAtMs) && Number(evidence?.retryAtMs) > Date.now() ? Number(evidence?.retryAtMs) : null,
36390
36556
  terminalEvidence: completed ? {
36391
- effectiveModel: identityQualified ? input.requestedModel : null,
36557
+ effectiveModel: identityQualified ? `${provider}/${evidence.providerModel}` : null,
36392
36558
  effectiveReasoningEffort: identityQualified ? input.requestedReasoningEffort : null,
36393
36559
  adapterRequestId: id2,
36394
36560
  adapterResponseId: typeof evidence?.responseId === "string" && evidence.responseId ? evidence.responseId : null
@@ -36500,11 +36666,11 @@ var init_exo_credential_store = __esm({
36500
36666
  }
36501
36667
  const provider = validateProvider(record4.provider);
36502
36668
  const apiKey = validateApiKey(record4.api_key);
36503
- const identity = credentialIdentity(provider, apiKey);
36504
- if (record4.schema_version !== 1 || record4.adapter !== "exo" || record4.identity !== identity || Object.keys(record4).sort().join(",") !== "adapter,api_key,identity,provider,schema_version") {
36669
+ const identity2 = credentialIdentity(provider, apiKey);
36670
+ if (record4.schema_version !== 1 || record4.adapter !== "exo" || record4.identity !== identity2 || Object.keys(record4).sort().join(",") !== "adapter,api_key,identity,provider,schema_version") {
36505
36671
  throw new Error("Stored Exo credential failed validation.");
36506
36672
  }
36507
- return { provider, apiKey, identity };
36673
+ return { provider, apiKey, identity: identity2 };
36508
36674
  };
36509
36675
  serializeCredential = (provider, apiKey) => {
36510
36676
  const validated = validateApiKey(apiKey);
@@ -36698,11 +36864,11 @@ var init_pi_credential_store = __esm({
36698
36864
  const record4 = value;
36699
36865
  const provider = validateProvider2(String(record4.provider ?? ""));
36700
36866
  const apiKey = validateApiKey2(String(record4.api_key ?? ""));
36701
- const identity = credentialIdentity2(provider, apiKey);
36702
- if (record4.schema_version !== 1 || record4.adapter !== "pi" || record4.identity !== identity || Object.keys(record4).sort().join(",") !== "adapter,api_key,identity,provider,schema_version") {
36867
+ const identity2 = credentialIdentity2(provider, apiKey);
36868
+ if (record4.schema_version !== 1 || record4.adapter !== "pi" || record4.identity !== identity2 || Object.keys(record4).sort().join(",") !== "adapter,api_key,identity,provider,schema_version") {
36703
36869
  throw new Error("Stored Pi credential failed validation.");
36704
36870
  }
36705
- return { provider, apiKey, identity };
36871
+ return { provider, apiKey, identity: identity2 };
36706
36872
  };
36707
36873
  serializeCredential2 = (provider, apiKey) => {
36708
36874
  const validated = validateApiKey2(apiKey);
@@ -36854,11 +37020,11 @@ var init_deepseek_credential_store = __esm({
36854
37020
  }
36855
37021
  const record4 = value;
36856
37022
  const apiKey = validateApiKey3(String(record4.api_key ?? ""));
36857
- const identity = credentialIdentity3(apiKey);
36858
- if (record4.schema_version !== 1 || record4.adapter !== "deepseek-harness" || record4.identity !== identity || Object.keys(record4).sort().join(",") !== "adapter,api_key,identity,schema_version") {
37023
+ const identity2 = credentialIdentity3(apiKey);
37024
+ if (record4.schema_version !== 1 || record4.adapter !== "deepseek-harness" || record4.identity !== identity2 || Object.keys(record4).sort().join(",") !== "adapter,api_key,identity,schema_version") {
36859
37025
  throw new Error("Stored DeepSeek Harness credential failed validation.");
36860
37026
  }
36861
- return { apiKey, identity };
37027
+ return { apiKey, identity: identity2 };
36862
37028
  };
36863
37029
  serializeCredential3 = (apiKey) => {
36864
37030
  const validated = validateApiKey3(apiKey);
@@ -37112,8 +37278,8 @@ var init_crypto = __esm({
37112
37278
  cipher.setAAD(aad);
37113
37279
  return Buffer.concat([cipher.update(plaintext), cipher.final(), cipher.getAuthTag()]);
37114
37280
  };
37115
- assertIdentity = (aad, identity) => {
37116
- if (aad.job_id !== identity.job_id || aad.host_id !== identity.host_id || aad.host_generation !== identity.host_generation || aad.key_generation !== identity.key_generation || aad.claim_generation !== identity.claim_generation) {
37281
+ assertIdentity = (aad, identity2) => {
37282
+ if (aad.job_id !== identity2.job_id || aad.host_id !== identity2.host_id || aad.host_generation !== identity2.host_generation || aad.key_generation !== identity2.key_generation || aad.claim_generation !== identity2.claim_generation) {
37117
37283
  throw new ExternalInferenceEnvelopeError(
37118
37284
  "identity_mismatch",
37119
37285
  "External inference envelope identity is invalid."
@@ -37270,7 +37436,7 @@ var init_crypto = __esm({
37270
37436
  "External inference claim does not contain a job."
37271
37437
  );
37272
37438
  }
37273
- const identity = {
37439
+ const identity2 = {
37274
37440
  job_id: claim.job_id,
37275
37441
  host_id: claim.host_id,
37276
37442
  host_generation: claim.host_generation,
@@ -37280,9 +37446,9 @@ var init_crypto = __esm({
37280
37446
  const jobKey = unwrapExternalInferenceJobKey(
37281
37447
  hostPrivateKey,
37282
37448
  claim.sealed_job_key,
37283
- identity
37449
+ identity2
37284
37450
  );
37285
- const jobInput = decryptExternalInferenceJobInput(jobKey, claim.sealed_input, identity);
37451
+ const jobInput = decryptExternalInferenceJobInput(jobKey, claim.sealed_input, identity2);
37286
37452
  if (jobInput.advertisement_generation !== claim.advertisement_generation || jobInput.controller_generation !== claim.controller_generation || jobInput.input_sha256 !== claim.input_sha256 || jobInput.requested_model !== claim.requested_model || jobInput.requested_reasoning_effort !== claim.requested_reasoning_effort || jobInput.response_mode !== claim.response_mode || jobInput.output_schema_version !== claim.output_schema_version) {
37287
37453
  throw new ExternalInferenceEnvelopeError(
37288
37454
  "identity_mismatch",
@@ -40295,6 +40461,9 @@ var init_runner = __esm({
40295
40461
  userPrompt: jobInput.user_prompt,
40296
40462
  outputSchemaJson: outputContract.adapterSchemaJson,
40297
40463
  requestedModel: jobInput.requested_model,
40464
+ allowedEffectiveModels: jobInput.allowed_model_identities.find(
40465
+ (mapping2) => mapping2.requested_model === jobInput.requested_model
40466
+ )?.effective_models,
40298
40467
  requestedReasoningEffort: jobInput.requested_reasoning_effort,
40299
40468
  deadlineAtMs: Date.parse(jobInput.deadline_at),
40300
40469
  ...providerDispatchNotAfterMs === void 0 ? {} : { providerDispatchNotAfterMs },
@@ -40687,7 +40856,8 @@ var init_runner = __esm({
40687
40856
  const mapping2 = jobInput.allowed_model_identities.find(
40688
40857
  (candidate) => candidate.requested_model === jobInput.requested_model
40689
40858
  );
40690
- if (result2.requestedModel !== jobInput.requested_model || result2.requestedReasoningEffort !== jobInput.requested_reasoning_effort || !mapping2?.effective_models.includes(result2.effectiveModel) || !jobInput.allowed_effective_reasoning_efforts.includes(result2.effectiveReasoningEffort)) {
40859
+ const effectiveModelMatches = mapping2 !== void 0 && jobInput.controller.adapter === (this.options.adapterId ?? "codex") && typeof result2.effectiveModel === "string" && result2.effectiveModel.trim().length > 0 && result2.effectiveModel.length <= 256 && !/[\u0000-\u001f\u007f]/u.test(result2.effectiveModel);
40860
+ if (result2.requestedModel !== jobInput.requested_model || result2.requestedReasoningEffort !== jobInput.requested_reasoning_effort || !effectiveModelMatches || !jobInput.allowed_effective_reasoning_efforts.includes(result2.effectiveReasoningEffort)) {
40691
40861
  throw new InferenceHostRunnerError(
40692
40862
  "effective_model_mismatch",
40693
40863
  "The effective adapter model provenance did not match the immutable allowance."
@@ -42083,8 +42253,8 @@ WantedBy=default.target
42083
42253
  }
42084
42254
  }
42085
42255
  windowsTaskName() {
42086
- const identity = this.username.replaceAll(/[^A-Za-z0-9_.@-]+/gu, "_").slice(-80) || "current-user";
42087
- return `VTX Macro Inference Host (${identity})`;
42256
+ const identity2 = this.username.replaceAll(/[^A-Za-z0-9_.@-]+/gu, "_").slice(-80) || "current-user";
42257
+ return `VTX Macro Inference Host (${identity2})`;
42088
42258
  }
42089
42259
  windowsPowerShell(script) {
42090
42260
  return [
@@ -46307,16 +46477,16 @@ Waiting for approval...
46307
46477
  hasExplicitCredentialStoreConfiguration = (env) => Boolean(
46308
46478
  String(env.VTX_INFERENCE_HOST_CREDENTIAL_STORE || "").trim() || String(env.VTX_INFERENCE_HOST_CREDENTIAL_FILE || "").trim()
46309
46479
  );
46310
- credentialEnvironmentForIdentity = (identity) => {
46311
- if (identity.startsWith("file:")) {
46312
- const path = identity.slice("file:".length);
46480
+ credentialEnvironmentForIdentity = (identity2) => {
46481
+ if (identity2.startsWith("file:")) {
46482
+ const path = identity2.slice("file:".length);
46313
46483
  if (!path) throw new Error("Inference host credential store identity is invalid.");
46314
46484
  return {
46315
46485
  VTX_INFERENCE_HOST_CREDENTIAL_STORE: "file",
46316
46486
  VTX_INFERENCE_HOST_CREDENTIAL_FILE: path
46317
46487
  };
46318
46488
  }
46319
- if (identity.startsWith("os:")) {
46489
+ if (identity2.startsWith("os:")) {
46320
46490
  return {
46321
46491
  VTX_INFERENCE_HOST_CREDENTIAL_STORE: "os",
46322
46492
  VTX_INFERENCE_HOST_CREDENTIAL_FILE: void 0
@@ -54116,10 +54286,10 @@ function arrayifyInteger(value) {
54116
54286
  }
54117
54287
  return result2;
54118
54288
  }
54119
- function _encode2(object5) {
54120
- if (Array.isArray(object5)) {
54289
+ function _encode2(object6) {
54290
+ if (Array.isArray(object6)) {
54121
54291
  let payload = [];
54122
- object5.forEach(function(child) {
54292
+ object6.forEach(function(child) {
54123
54293
  payload = payload.concat(_encode2(child));
54124
54294
  });
54125
54295
  if (payload.length <= 55) {
@@ -54130,7 +54300,7 @@ function _encode2(object5) {
54130
54300
  length2.unshift(247 + length2.length);
54131
54301
  return length2.concat(payload);
54132
54302
  }
54133
- const data4 = Array.prototype.slice.call(getBytes(object5, "object"));
54303
+ const data4 = Array.prototype.slice.call(getBytes(object6, "object"));
54134
54304
  if (data4.length === 1 && data4[0] <= 127) {
54135
54305
  return data4;
54136
54306
  } else if (data4.length <= 55) {
@@ -54141,9 +54311,9 @@ function _encode2(object5) {
54141
54311
  length.unshift(183 + length.length);
54142
54312
  return length.concat(data4);
54143
54313
  }
54144
- function encodeRlp(object5) {
54314
+ function encodeRlp(object6) {
54145
54315
  let result2 = "0x";
54146
- for (const v of _encode2(object5)) {
54316
+ for (const v of _encode2(object6)) {
54147
54317
  result2 += nibbles[v >> 4];
54148
54318
  result2 += nibbles[v & 15];
54149
54319
  }
@@ -54291,15 +54461,15 @@ function toObject(names2, items, deep) {
54291
54461
  }
54292
54462
  function checkResultErrors(result2) {
54293
54463
  const errors = [];
54294
- const checkErrors = function(path, object5) {
54295
- if (!Array.isArray(object5)) {
54464
+ const checkErrors = function(path, object6) {
54465
+ if (!Array.isArray(object6)) {
54296
54466
  return;
54297
54467
  }
54298
- for (let key in object5) {
54468
+ for (let key in object6) {
54299
54469
  const childPath = path.slice();
54300
54470
  childPath.push(key);
54301
54471
  try {
54302
- checkErrors(childPath, object5[key]);
54472
+ checkErrors(childPath, object6[key]);
54303
54473
  } catch (error48) {
54304
54474
  errors.push({ path: childPath, error: error48 });
54305
54475
  }
@@ -56549,15 +56719,15 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
56549
56719
  };
56550
56720
  return genUntil;
56551
56721
  }
56552
- function validateObject(object5, validators, optValidators = {}) {
56722
+ function validateObject(object6, validators, optValidators = {}) {
56553
56723
  const checkField = (fieldName, type, isOptional) => {
56554
56724
  const checkVal = validatorFns[type];
56555
56725
  if (typeof checkVal !== "function")
56556
56726
  throw new Error(`Invalid validator "${type}", expected function`);
56557
- const val = object5[fieldName];
56727
+ const val = object6[fieldName];
56558
56728
  if (isOptional && val === void 0)
56559
56729
  return;
56560
- if (!checkVal(val, object5)) {
56730
+ if (!checkVal(val, object6)) {
56561
56731
  throw new Error(`Invalid param ${String(fieldName)}=${val} (${typeof val}), expected ${type}`);
56562
56732
  }
56563
56733
  };
@@ -56565,7 +56735,7 @@ function validateObject(object5, validators, optValidators = {}) {
56565
56735
  checkField(fieldName, type, false);
56566
56736
  for (const [fieldName, type] of Object.entries(optValidators))
56567
56737
  checkField(fieldName, type, true);
56568
- return object5;
56738
+ return object6;
56569
56739
  }
56570
56740
  var _0n2, _1n2, _2n2, u8a3, hexes, bitSet, bitMask, u8n, u8fr, validatorFns;
56571
56741
  var init_utils4 = __esm({
@@ -56592,7 +56762,7 @@ var init_utils4 = __esm({
56592
56762
  stringOrUint8Array: (val) => typeof val === "string" || val instanceof Uint8Array,
56593
56763
  isSafeInteger: (val) => Number.isSafeInteger(val),
56594
56764
  array: (val) => Array.isArray(val),
56595
- field: (val, object5) => object5.Fp.isValid(val),
56765
+ field: (val, object6) => object6.Fp.isValid(val),
56596
56766
  hash: (val) => typeof val === "function" && Number.isSafeInteger(val.outputLen)
56597
56767
  };
56598
56768
  }
@@ -68330,7 +68500,7 @@ function arrayOf(format, allowNull2) {
68330
68500
  return array2.map((i) => format(i));
68331
68501
  });
68332
68502
  }
68333
- function object4(format, altNames) {
68503
+ function object5(format, altNames) {
68334
68504
  return ((value) => {
68335
68505
  const result2 = {};
68336
68506
  for (const key in format) {
@@ -68398,7 +68568,7 @@ function formatTransactionResponse(value) {
68398
68568
  if (value.to && getBigInt(value.to) === BN_011) {
68399
68569
  value.to = "0x0000000000000000000000000000000000000000";
68400
68570
  }
68401
- const result2 = object4({
68571
+ const result2 = object5({
68402
68572
  hash: formatHash,
68403
68573
  // Some nodes do not return this, usually test nodes (like Ganache)
68404
68574
  index: allowNull(getNumber, void 0),
@@ -68484,7 +68654,7 @@ var init_format = __esm({
68484
68654
  init_transaction2();
68485
68655
  init_utils();
68486
68656
  BN_011 = BigInt(0);
68487
- _formatLog = object4({
68657
+ _formatLog = object5({
68488
68658
  address: getAddress,
68489
68659
  blockHash: formatHash,
68490
68660
  blockNumber: getNumber,
@@ -68497,7 +68667,7 @@ var init_format = __esm({
68497
68667
  }, {
68498
68668
  index: ["logIndex"]
68499
68669
  });
68500
- _formatBlock = object4({
68670
+ _formatBlock = object5({
68501
68671
  hash: allowNull(formatHash),
68502
68672
  parentHash: formatHash,
68503
68673
  parentBeaconBlockRoot: allowNull(formatHash, null),
@@ -68518,7 +68688,7 @@ var init_format = __esm({
68518
68688
  }, {
68519
68689
  prevRandao: ["mixHash"]
68520
68690
  });
68521
- _formatReceiptLog = object4({
68691
+ _formatReceiptLog = object5({
68522
68692
  transactionIndex: getNumber,
68523
68693
  blockNumber: getNumber,
68524
68694
  transactionHash: formatHash,
@@ -68530,7 +68700,7 @@ var init_format = __esm({
68530
68700
  }, {
68531
68701
  index: ["logIndex"]
68532
68702
  });
68533
- _formatTransactionReceipt = object4({
68703
+ _formatTransactionReceipt = object5({
68534
68704
  to: allowNull(getAddress, null),
68535
68705
  from: allowNull(getAddress, null),
68536
68706
  contractAddress: allowNull(getAddress, null),
@@ -79336,13 +79506,13 @@ function getPassword(password) {
79336
79506
  }
79337
79507
  return getBytesCopy(password);
79338
79508
  }
79339
- function spelunk(object5, _path) {
79509
+ function spelunk(object6, _path) {
79340
79510
  const match = _path.match(/^([a-z0-9$_.-]*)(:([a-z]+))?(!)?$/i);
79341
79511
  assertArgument(match != null, "invalid path", "path", _path);
79342
79512
  const path = match[1];
79343
79513
  const type = match[3];
79344
79514
  const reqd = match[4] === "!";
79345
- let cur = object5;
79515
+ let cur = object6;
79346
79516
  for (const comp of path.toLowerCase().split(".")) {
79347
79517
  if (Array.isArray(cur)) {
79348
79518
  if (!comp.match(/^[0-9]+$/)) {