@vtxmacro/cli 2026.9.3 → 2026.9.5

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.3",
19
+ package_version: "2026.9.5",
20
20
  codex_package_name: "@openai/codex",
21
21
  codex_version: "0.147.0",
22
22
  copilot_sdk_package_name: "@github/copilot-sdk",
package/bin/vtx.js CHANGED
@@ -47,7 +47,7 @@ var init_agent_cli_release = __esm({
47
47
  "agent-cli-release.json"() {
48
48
  agent_cli_release_default = {
49
49
  package_name: "@vtxmacro/cli",
50
- package_version: "2026.9.3",
50
+ package_version: "2026.9.5",
51
51
  codex_package_name: "@openai/codex",
52
52
  codex_version: "0.147.0",
53
53
  copilot_sdk_package_name: "@github/copilot-sdk",
@@ -33526,16 +33526,53 @@ var init_runner = __esm({
33526
33526
  updated_at: isoAt(now())
33527
33527
  };
33528
33528
  await this.persistReceipt(receipt, now);
33529
- let receiptMutationChain = Promise.resolve();
33529
+ let receiptRevision = 0;
33530
+ let persistedReceiptRevision = 0;
33531
+ let receiptWriter = null;
33532
+ let receiptWriterFailed = false;
33533
+ let receiptWriteFailure;
33534
+ const receiptDurabilityWaiters = [];
33535
+ const scheduleReceiptWriter = () => {
33536
+ if (receiptWriter || receiptWriterFailed) return;
33537
+ receiptWriter = (async () => {
33538
+ try {
33539
+ while (persistedReceiptRevision < receiptRevision) {
33540
+ const targetRevision = receiptRevision;
33541
+ const snapshot = receipt;
33542
+ await this.persistReceipt(snapshot, now);
33543
+ persistedReceiptRevision = targetRevision;
33544
+ for (let index = receiptDurabilityWaiters.length - 1; index >= 0; index -= 1) {
33545
+ const waiter = receiptDurabilityWaiters[index];
33546
+ if (waiter.revision > persistedReceiptRevision) continue;
33547
+ receiptDurabilityWaiters.splice(index, 1);
33548
+ waiter.resolve();
33549
+ }
33550
+ }
33551
+ } catch (error48) {
33552
+ receiptWriterFailed = true;
33553
+ receiptWriteFailure = error48;
33554
+ for (const waiter of receiptDurabilityWaiters.splice(0)) {
33555
+ waiter.reject(error48);
33556
+ }
33557
+ } finally {
33558
+ receiptWriter = null;
33559
+ if (!receiptWriterFailed && persistedReceiptRevision < receiptRevision) {
33560
+ scheduleReceiptWriter();
33561
+ }
33562
+ }
33563
+ })();
33564
+ };
33530
33565
  const mutateReceipt = async (mutation) => {
33531
- let result2;
33532
- const operation = receiptMutationChain.then(async () => {
33533
- result2 = mutation(receipt);
33534
- receipt = result2;
33535
- await this.persistReceipt(receipt, now);
33566
+ if (receiptWriterFailed) throw receiptWriteFailure;
33567
+ const result2 = mutation(receipt);
33568
+ receipt = result2;
33569
+ const revision = receiptRevision + 1;
33570
+ receiptRevision = revision;
33571
+ const durable = new Promise((resolve6, reject) => {
33572
+ receiptDurabilityWaiters.push({ revision, resolve: resolve6, reject });
33536
33573
  });
33537
- receiptMutationChain = operation;
33538
- await operation;
33574
+ scheduleReceiptWriter();
33575
+ await durable;
33539
33576
  return result2;
33540
33577
  };
33541
33578
  const envelopePublicKey = await this.dependencies.envelopePublicKey(credential);
@@ -33763,6 +33800,31 @@ var init_runner = __esm({
33763
33800
  let nextClaimAt = Math.max(now(), providerRetryAtMs ?? 0);
33764
33801
  let pendingClaimPromotions = 0;
33765
33802
  let onceClaimed = false;
33803
+ const preparePendingClaim = (current) => {
33804
+ if (current.pending_claim_request) return current;
33805
+ const claimSequence = current.claim_sequence + 1;
33806
+ const requestedAt = now();
33807
+ return {
33808
+ ...current,
33809
+ claim_sequence: claimSequence,
33810
+ pending_claim_request: {
33811
+ schema_version: "external_inference_job_claim_v1",
33812
+ contract_version: EXTERNAL_INFERENCE_CONTRACT_VERSION,
33813
+ host_id: localState.host_id,
33814
+ host_generation: localState.host_generation,
33815
+ advertisement_generation: current.advertisement_generation,
33816
+ key_generation: localState.key_generation,
33817
+ claim_request_id: stableOperationId("claim", [
33818
+ localState.host_id,
33819
+ localState.host_generation,
33820
+ current.advertisement_generation,
33821
+ claimSequence
33822
+ ]),
33823
+ requested_at: isoAt(requestedAt)
33824
+ },
33825
+ updated_at: isoAt(requestedAt)
33826
+ };
33827
+ };
33766
33828
  const hostHeartbeatAbort = new AbortController();
33767
33829
  stopHostHeartbeatLoop = () => hostHeartbeatAbort.abort();
33768
33830
  let nextHostHeartbeatAt = now() + settings.hostHeartbeatMs;
@@ -33978,7 +34040,11 @@ var init_runner = __esm({
33978
34040
  },
33979
34041
  resumeReceipt: recovery,
33980
34042
  claimRequest,
33981
- onClaimPersisted: settleClaimPromotion
34043
+ onClaimPersisted: settleClaimPromotion,
34044
+ rolloverClaimRequest: (current) => {
34045
+ if (drainRequested || this.options.once || settings.maxConcurrency !== null && active.size + 1 >= settings.maxConcurrency) return current;
34046
+ return preparePendingClaim(current);
34047
+ }
33982
34048
  }).then((outcome) => {
33983
34049
  if (outcome === "completed") {
33984
34050
  attemptStartRetryCounts.delete(attemptId);
@@ -34173,31 +34239,7 @@ var init_runner = __esm({
34173
34239
  }
34174
34240
  while (!drainRequested && recoveryQueue.length === 0 && (!this.options.once || !onceClaimed) && (settings.maxConcurrency === null || active.size < settings.maxConcurrency) && pendingClaimPromotions === 0 && now() >= nextClaimAt) {
34175
34241
  if (!receipt.pending_claim_request) {
34176
- await mutateReceipt((current) => {
34177
- if (current.pending_claim_request) return current;
34178
- const claimSequence = current.claim_sequence + 1;
34179
- const pendingClaimRequest = {
34180
- schema_version: "external_inference_job_claim_v1",
34181
- contract_version: EXTERNAL_INFERENCE_CONTRACT_VERSION,
34182
- host_id: localState.host_id,
34183
- host_generation: localState.host_generation,
34184
- advertisement_generation: current.advertisement_generation,
34185
- key_generation: localState.key_generation,
34186
- claim_request_id: stableOperationId("claim", [
34187
- localState.host_id,
34188
- localState.host_generation,
34189
- current.advertisement_generation,
34190
- claimSequence
34191
- ]),
34192
- requested_at: isoAt(now())
34193
- };
34194
- return {
34195
- ...current,
34196
- claim_sequence: claimSequence,
34197
- pending_claim_request: pendingClaimRequest,
34198
- updated_at: isoAt(now())
34199
- };
34200
- });
34242
+ await mutateReceipt(preparePendingClaim);
34201
34243
  }
34202
34244
  const request = receipt.pending_claim_request;
34203
34245
  let claim;
@@ -34405,14 +34447,52 @@ var init_runner = __esm({
34405
34447
  updated_at: isoAt(now())
34406
34448
  });
34407
34449
  attemptReceipt = nextAttemptReceipt;
34408
- await options.updateReceipt((current) => ({
34409
- ...current,
34410
- pending_claim_request: clearPendingClaim && options.claimRequest && current.pending_claim_request?.claim_request_id === options.claimRequest.claim_request_id ? null : current.pending_claim_request ?? null,
34411
- attempts: { ...current.attempts, [attemptId]: nextAttemptReceipt },
34412
- updated_at: isoAt(now())
34413
- }));
34450
+ await options.updateReceipt((current) => {
34451
+ const retiresClaimRequest = Boolean(
34452
+ clearPendingClaim && options.claimRequest && current.pending_claim_request?.claim_request_id === options.claimRequest.claim_request_id
34453
+ );
34454
+ const promoted = {
34455
+ ...current,
34456
+ pending_claim_request: retiresClaimRequest ? null : current.pending_claim_request ?? null,
34457
+ attempts: { ...current.attempts, [attemptId]: nextAttemptReceipt },
34458
+ updated_at: isoAt(now())
34459
+ };
34460
+ return retiresClaimRequest && options.rolloverClaimRequest ? options.rolloverClaimRequest(promoted) : promoted;
34461
+ });
34414
34462
  if (clearPendingClaim) options.onClaimPersisted?.();
34415
34463
  };
34464
+ const persistAttemptHeartbeat = async (sequence) => {
34465
+ attemptReceipt = validateAttemptReceipt({
34466
+ ...attemptReceipt,
34467
+ job_heartbeat_sequence: Math.max(
34468
+ attemptReceipt.job_heartbeat_sequence,
34469
+ sequence
34470
+ ),
34471
+ updated_at: isoAt(now())
34472
+ });
34473
+ let persisted = false;
34474
+ await options.updateReceipt((current) => {
34475
+ const currentAttempt = current.attempts[attemptId];
34476
+ if (!currentAttempt || currentAttempt.job_id !== attemptReceipt.job_id || currentAttempt.claim_generation !== attemptReceipt.claim_generation || currentAttempt.input_sha256 !== attemptReceipt.input_sha256) return current;
34477
+ persisted = true;
34478
+ return {
34479
+ ...current,
34480
+ attempts: {
34481
+ ...current.attempts,
34482
+ [attemptId]: validateAttemptReceipt({
34483
+ ...currentAttempt,
34484
+ job_heartbeat_sequence: Math.max(
34485
+ currentAttempt.job_heartbeat_sequence,
34486
+ sequence
34487
+ ),
34488
+ updated_at: isoAt(now())
34489
+ })
34490
+ },
34491
+ updated_at: isoAt(now())
34492
+ };
34493
+ });
34494
+ return persisted;
34495
+ };
34416
34496
  const removeAttempt = async () => {
34417
34497
  await options.updateReceipt((current) => {
34418
34498
  const attempts = { ...current.attempts };
@@ -34434,9 +34514,6 @@ var init_runner = __esm({
34434
34514
  } catch (error48) {
34435
34515
  inputValidationError = error48;
34436
34516
  }
34437
- if (!options.resumeReceipt) {
34438
- await persistAttempt({ phase: "claimed" }, true);
34439
- }
34440
34517
  if (attemptReceipt.phase === "claimed") {
34441
34518
  const attemptDeadlineAtMs = Math.min(
34442
34519
  Date.parse(claim.deadline_at),
@@ -34448,13 +34525,25 @@ var init_runner = __esm({
34448
34525
  }
34449
34526
  let startResult;
34450
34527
  const startCallStartedAtMs = now();
34451
- try {
34452
- startResult = await retryExact(() => mcp.callTool(
34453
- "inference.job.start",
34454
- startRequest,
34455
- { signal, deadlineAtMs: attemptDeadlineAtMs }
34456
- ), { signal, deadlineAtMs: attemptDeadlineAtMs });
34457
- } catch (error48) {
34528
+ let startCallCompletedAtMs = startCallStartedAtMs;
34529
+ const claimPromotionPromise = options.resumeReceipt ? Promise.resolve() : persistAttempt({ phase: "claimed" }, true);
34530
+ const startCallPromise = retryExact(() => mcp.callTool(
34531
+ "inference.job.start",
34532
+ startRequest,
34533
+ { signal, deadlineAtMs: attemptDeadlineAtMs }
34534
+ ), { signal, deadlineAtMs: attemptDeadlineAtMs }).then((result2) => {
34535
+ startCallCompletedAtMs = now();
34536
+ return result2;
34537
+ });
34538
+ const [startOutcome, claimPromotionOutcome] = await Promise.allSettled([
34539
+ startCallPromise,
34540
+ claimPromotionPromise
34541
+ ]);
34542
+ if (claimPromotionOutcome.status === "rejected") {
34543
+ throw claimPromotionOutcome.reason;
34544
+ }
34545
+ if (startOutcome.status === "rejected") {
34546
+ const error48 = startOutcome.reason;
34458
34547
  if (error48 instanceof ExternalInferenceMcpError && error48.serverFailureCode === "server_account_context_expired_before_provider_dispatch") {
34459
34548
  await removeAttempt();
34460
34549
  options.onAttemptOutcome?.({
@@ -34499,6 +34588,7 @@ var init_runner = __esm({
34499
34588
  await options.sleep(retryDelayMs, signal);
34500
34589
  return "retry_claimed";
34501
34590
  }
34591
+ startResult = startOutcome.value;
34502
34592
  assertStartResult(startRequest, startResult);
34503
34593
  if (serverProviderDispatchDeadlineMs !== void 0) {
34504
34594
  const serverRemaining = startResult.provider_dispatch_freshness_remaining_ms;
@@ -34508,7 +34598,6 @@ var init_runner = __esm({
34508
34598
  "The Server provider-dispatch freshness receipt is unavailable."
34509
34599
  );
34510
34600
  }
34511
- const startCallCompletedAtMs = now();
34512
34601
  startRoundTripMs = Math.max(0, startCallCompletedAtMs - startCallStartedAtMs);
34513
34602
  serverReportedFreshnessRemainingMs = Number(serverRemaining);
34514
34603
  const conservativeRemainingMs = Math.max(
@@ -34556,7 +34645,7 @@ var init_runner = __esm({
34556
34645
  sequence,
34557
34646
  observed_at: isoAt(now())
34558
34647
  };
34559
- await persistAttempt({ job_heartbeat_sequence: sequence });
34648
+ if (!await persistAttemptHeartbeat(sequence)) return;
34560
34649
  const heartbeatDeadlineAtMs = Date.parse(claim.deadline_at);
34561
34650
  const directive = await retryExact(
34562
34651
  () => mcp.callTool(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtxmacro/cli",
3
- "version": "2026.9.3",
3
+ "version": "2026.9.5",
4
4
  "description": "VTX Macro CLI, MCP server, and durable external inference host.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",