@vtxmacro/cli 2026.9.21 → 2026.9.22

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.21",
19
+ package_version: "2026.9.22",
20
20
  codex_package_name: "@openai/codex",
21
21
  codex_version: "0.153.3",
22
22
  copilot_sdk_package_name: "@github/copilot-sdk",
package/bin/vtx.js CHANGED
@@ -69,7 +69,7 @@ var init_agent_cli_release = __esm({
69
69
  "agent-cli-release.json"() {
70
70
  agent_cli_release_default = {
71
71
  package_name: "@vtxmacro/cli",
72
- package_version: "2026.9.21",
72
+ package_version: "2026.9.22",
73
73
  codex_package_name: "@openai/codex",
74
74
  codex_version: "0.153.3",
75
75
  copilot_sdk_package_name: "@github/copilot-sdk",
@@ -36139,6 +36139,7 @@ var init_runner = __esm({
36139
36139
  let providerDispatchWatchdogDrainRequested = false;
36140
36140
  const agentAbort = new AbortController();
36141
36141
  let agentLoop = Promise.resolve();
36142
+ let modelCatalogRefresh = null;
36142
36143
  let wakeDrain;
36143
36144
  const drainSignal = new Promise((resolve10) => {
36144
36145
  wakeDrain = resolve10;
@@ -36561,6 +36562,7 @@ var init_runner = __esm({
36561
36562
  }
36562
36563
  };
36563
36564
  let advertisementHandoff = null;
36565
+ const claimPreparation = { unsent: null };
36564
36566
  const publishAdvertisement = async (health, forceAdvance, retryRemote = true, allowDefinitiveReseed = true) => {
36565
36567
  let advertisement = receipt.pending_advertisement;
36566
36568
  if (!advertisement) {
@@ -36778,6 +36780,45 @@ var init_runner = __esm({
36778
36780
  return gapMs;
36779
36781
  };
36780
36782
  let nextAdvertisementAttemptAt = 0;
36783
+ let renewalYieldedToClaim = false;
36784
+ let catalogRefreshGeneration = null;
36785
+ const refreshModelCatalog = () => {
36786
+ if (modelCatalogRefresh || !this.dependencies.codexAdapter.readModelCapabilities || receipt.pending_advertisement || catalogRefreshGeneration === receipt.advertisement_generation) return;
36787
+ catalogRefreshGeneration = receipt.advertisement_generation;
36788
+ modelCatalogRefresh = (async () => {
36789
+ try {
36790
+ const capabilities = await this.dependencies.codexAdapter.readModelCapabilities(
36791
+ Date.now() + Math.max(1, Math.floor(settings.advertisementRefreshLeadMs / 2)),
36792
+ agentAbort.signal
36793
+ );
36794
+ if (agentAbort.signal.aborted) return;
36795
+ const refreshedModels = buildInferenceAdvertisedModels(
36796
+ capabilities,
36797
+ this.options.adapterRuntimeVersion,
36798
+ settings.adapterId,
36799
+ this.options.structuredOutput ?? settings.adapterId === "codex",
36800
+ settings.sameAttemptRecovery,
36801
+ settings.agentRuntime ? ["provider", "agent"] : ["provider"]
36802
+ );
36803
+ const changed = !exactJson2(settings.advertisedModels, refreshedModels);
36804
+ settings.advertisedModels = refreshedModels;
36805
+ emitDiagnostic("model_catalog_refreshed", {
36806
+ model_count: refreshedModels.length,
36807
+ changed,
36808
+ active_attempts: active.size
36809
+ });
36810
+ } catch (error48) {
36811
+ if (agentAbort.signal.aborted) return;
36812
+ emitDiagnostic("model_catalog_refresh_failed", {
36813
+ failure_category: error48 instanceof CodexAppServerError ? error48.category : "adapter",
36814
+ failure_code: error48 instanceof CodexAppServerError ? error48.code : "model_catalog_refresh_failed",
36815
+ retained_model_count: settings.advertisedModels.length
36816
+ });
36817
+ } finally {
36818
+ modelCatalogRefresh = null;
36819
+ }
36820
+ })();
36821
+ };
36781
36822
  let nextProviderRateLimitRefreshAt = now() + settings.providerRateLimitRefreshMs;
36782
36823
  let nextClaimAt = now();
36783
36824
  let pendingClaimPromotions = 0;
@@ -36819,6 +36860,7 @@ var init_runner = __esm({
36819
36860
  schema_version: "external_inference_job_claim_v1",
36820
36861
  ...claimRequestBase
36821
36862
  };
36863
+ claimPreparation.unsent = pendingClaimRequest;
36822
36864
  return {
36823
36865
  ...current,
36824
36866
  claim_sequence: claimSequence,
@@ -37294,39 +37336,20 @@ var init_runner = __esm({
37294
37336
  }
37295
37337
  }
37296
37338
  const expiresAt = receipt.advertisement_expires_at ? Date.parse(receipt.advertisement_expires_at) : 0;
37297
- if (currentTime >= nextAdvertisementAttemptAt && expiresAt - currentTime <= settings.advertisementRefreshLeadMs) {
37339
+ const renewalDue = currentTime >= nextAdvertisementAttemptAt && expiresAt - currentTime <= settings.advertisementRefreshLeadMs;
37340
+ if (renewalDue) refreshModelCatalog();
37341
+ const yieldRenewalToClaim = renewalDue && !renewalYieldedToClaim && !receipt.pending_advertisement && expiresAt > now() && recoveryQueue.length === 0 && (!this.options.once || !onceClaimed) && (settings.maxConcurrency === null || active.size < settings.maxConcurrency) && pendingClaimPromotions === 0 && now() >= Math.max(
37342
+ nextClaimAt,
37343
+ claimAvailabilityBackoff?.untilMs ?? 0,
37344
+ providerRetryAtMs ?? 0,
37345
+ providerFailureRetryAtMs
37346
+ );
37347
+ if (yieldRenewalToClaim) renewalYieldedToClaim = true;
37348
+ if (renewalDue && !yieldRenewalToClaim) {
37298
37349
  try {
37299
- if (!receipt.pending_advertisement && this.dependencies.codexAdapter.readModelCapabilities) {
37300
- try {
37301
- const capabilities = await this.dependencies.codexAdapter.readModelCapabilities(
37302
- Date.now() + Math.max(1, Math.floor(settings.advertisementRefreshLeadMs / 2)),
37303
- this.options.signal
37304
- );
37305
- const refreshedModels = buildInferenceAdvertisedModels(
37306
- capabilities,
37307
- this.options.adapterRuntimeVersion,
37308
- settings.adapterId,
37309
- this.options.structuredOutput ?? settings.adapterId === "codex",
37310
- settings.sameAttemptRecovery,
37311
- settings.agentRuntime ? ["provider", "agent"] : ["provider"]
37312
- );
37313
- const changed = !exactJson2(settings.advertisedModels, refreshedModels);
37314
- settings.advertisedModels = refreshedModels;
37315
- emitDiagnostic("model_catalog_refreshed", {
37316
- model_count: refreshedModels.length,
37317
- changed,
37318
- active_attempts: active.size
37319
- });
37320
- } catch (error48) {
37321
- emitDiagnostic("model_catalog_refresh_failed", {
37322
- failure_category: error48 instanceof CodexAppServerError ? error48.category : "adapter",
37323
- failure_code: error48 instanceof CodexAppServerError ? error48.code : "model_catalog_refresh_failed",
37324
- retained_model_count: settings.advertisedModels.length
37325
- });
37326
- }
37327
- }
37328
37350
  await publishAdvertisement("healthy", true, false);
37329
37351
  nextAdvertisementAttemptAt = 0;
37352
+ renewalYieldedToClaim = false;
37330
37353
  } catch (error48) {
37331
37354
  if (controlPlaneFatal(error48)) {
37332
37355
  requestDrain("authority_lost");
@@ -37344,23 +37367,38 @@ var init_runner = __esm({
37344
37367
  const recovery = recoveryQueue.shift();
37345
37368
  launchClaim(recovery.claim, recovery);
37346
37369
  }
37347
- while (!drainRequested && recoveryQueue.length === 0 && (!this.options.once || !onceClaimed) && (settings.maxConcurrency === null || active.size < settings.maxConcurrency) && pendingClaimPromotions === 0 && now() >= Math.max(
37370
+ let claimOpportunities = 0;
37371
+ while (!drainRequested && (!yieldRenewalToClaim || claimOpportunities === 0) && recoveryQueue.length === 0 && (!this.options.once || !onceClaimed) && (settings.maxConcurrency === null || active.size < settings.maxConcurrency) && pendingClaimPromotions === 0 && now() >= Math.max(
37348
37372
  nextClaimAt,
37349
37373
  claimAvailabilityBackoff?.untilMs ?? 0,
37350
37374
  providerRetryAtMs ?? 0,
37351
37375
  providerFailureRetryAtMs
37352
37376
  )) {
37377
+ if (receipt.pending_claim_request === claimPreparation.unsent && claimPreparation.unsent !== null && claimPreparation.unsent.advertisement_generation !== receipt.advertisement_generation) {
37378
+ await mutateReceipt((current) => preparePendingClaim({
37379
+ ...current,
37380
+ pending_claim_request: null
37381
+ }));
37382
+ }
37383
+ const knownUnsent = receipt.pending_claim_request === null || receipt.pending_claim_request === claimPreparation.unsent;
37384
+ if (knownUnsent && Date.parse(receipt.advertisement_expires_at ?? "") <= now()) break;
37353
37385
  if (!receipt.pending_claim_request) {
37354
37386
  await mutateReceipt(preparePendingClaim);
37355
37387
  }
37356
37388
  const request = receipt.pending_claim_request;
37389
+ if (request === claimPreparation.unsent && Date.parse(receipt.advertisement_expires_at ?? "") <= now()) break;
37357
37390
  let claim;
37358
37391
  const claimCallStartedAtMs = now();
37359
37392
  try {
37393
+ claimOpportunities += 1;
37394
+ if (claimPreparation.unsent === request) claimPreparation.unsent = null;
37360
37395
  claim = await mcp.callTool(
37361
37396
  "inference.job.claim",
37362
37397
  request,
37363
- { signal: this.options.signal }
37398
+ {
37399
+ signal: this.options.signal,
37400
+ ...yieldRenewalToClaim ? { deadlineAtMs: expiresAt } : {}
37401
+ }
37364
37402
  );
37365
37403
  assertClaimResult(request, claim);
37366
37404
  } catch (error48) {
@@ -37585,6 +37623,7 @@ var init_runner = __esm({
37585
37623
  now() + settings.hostHeartbeatMs,
37586
37624
  Math.max(now() + MIN_SLEEP_MS, advertisementDueAt)
37587
37625
  );
37626
+ if (yieldRenewalToClaim) continue;
37588
37627
  await Promise.race([
37589
37628
  sleep4(Math.max(MIN_SLEEP_MS, wakeAt - now())),
37590
37629
  drainSignal,
@@ -37634,6 +37673,7 @@ var init_runner = __esm({
37634
37673
  agentAbort.abort();
37635
37674
  const agentCleanup = Promise.allSettled([
37636
37675
  agentLoop,
37676
+ modelCatalogRefresh,
37637
37677
  Promise.resolve().then(async () => {
37638
37678
  await settings.agentRuntime?.adapter.close();
37639
37679
  })
@@ -48099,6 +48139,7 @@ async function postClientRuntime(path, profileId, body, options) {
48099
48139
  let lastNetworkError = null;
48100
48140
  let missingRuntimeLeaseRecoveryAttempted = false;
48101
48141
  let replacementLeaseRetryUsed = false;
48142
+ let lastRequestId = null;
48102
48143
  const deadlineError = (attempt, cause) => annotateRuntimeRequestError(
48103
48144
  Object.assign(
48104
48145
  new Error("Client runtime decision persistence deadline exceeded after the AI run completed."),
@@ -48113,7 +48154,8 @@ async function postClientRuntime(path, profileId, body, options) {
48113
48154
  keepalive,
48114
48155
  hadRuntimeLeaseToken: Boolean(resolvedRuntimeLeaseToken),
48115
48156
  deadlineAtMs,
48116
- deadlineExceeded: true
48157
+ deadlineExceeded: true,
48158
+ requestId: lastRequestId
48117
48159
  }
48118
48160
  );
48119
48161
  const waitBeforeRetry = async (delayMs, attempt, cause) => {
@@ -48152,12 +48194,13 @@ async function postClientRuntime(path, profileId, body, options) {
48152
48194
  }, Math.max(1, attemptTimeoutMs));
48153
48195
  requestSignal = timeoutController.signal;
48154
48196
  }
48197
+ lastRequestId = path === "/runtime/decision" ? createIdempotencyKey("runtime-request") : null;
48155
48198
  const trace = startRuntimeNetworkDebugTrace({
48156
48199
  kind: "runtime",
48157
48200
  label: "client_runtime_api",
48158
48201
  method: "POST",
48159
48202
  url: requestUrl,
48160
- note: `path=${path} attempt=${attempt}/${maxAttempts}`
48203
+ note: `path=${path} attempt=${attempt}/${maxAttempts}${lastRequestId ? ` reconcile_only=${options?.reconcileOnly === true} request_id=${lastRequestId}` : ""}`
48161
48204
  });
48162
48205
  try {
48163
48206
  response = await fetch(requestUrl, {
@@ -48165,7 +48208,10 @@ async function postClientRuntime(path, profileId, body, options) {
48165
48208
  credentials: "include",
48166
48209
  keepalive,
48167
48210
  signal: requestSignal,
48168
- headers: { ...requestHeaders },
48211
+ headers: {
48212
+ ...requestHeaders,
48213
+ ...lastRequestId ? { "X-Request-ID": lastRequestId } : {}
48214
+ },
48169
48215
  body
48170
48216
  });
48171
48217
  if (!response.ok) {
@@ -48246,7 +48292,8 @@ async function postClientRuntime(path, profileId, body, options) {
48246
48292
  status: response?.status ?? null,
48247
48293
  keepalive,
48248
48294
  hadRuntimeLeaseToken: Boolean(resolvedRuntimeLeaseToken),
48249
- deadlineAtMs
48295
+ deadlineAtMs,
48296
+ requestId: lastRequestId
48250
48297
  });
48251
48298
  }
48252
48299
  await waitBeforeRetry(
@@ -48687,6 +48734,7 @@ var init_api2 = __esm({
48687
48734
  target.runtimeRequestTransientNetwork = isTransientNetworkFetchError(error48);
48688
48735
  target.runtimeRequestKeepalive = metadata.keepalive;
48689
48736
  target.runtimeRequestHadLeaseToken = metadata.hadRuntimeLeaseToken;
48737
+ if (metadata.requestId !== void 0) target.runtimeRequestId = metadata.requestId;
48690
48738
  if (metadata.deadlineAtMs !== void 0) {
48691
48739
  target.runtimeRequestDeadlineAtMs = metadata.deadlineAtMs;
48692
48740
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtxmacro/cli",
3
- "version": "2026.9.21",
3
+ "version": "2026.9.22",
4
4
  "description": "VTX Macro CLI, MCP server, and durable external inference host.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",