@ai-matrx/api 0.1.28 → 0.1.29

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/CHANGELOG.md CHANGED
@@ -2,13 +2,35 @@
2
2
 
3
3
  ### Unreleased
4
4
 
5
+ - **Warm-up retries transient failures.** `createWarmup` re-sends a batch that failed with a network error or 408/425/429/5xx (not 501) after 2s, 8s and 30s while the scope is unchanged — a server rollover is exactly when a warm-up matters. New option `retryDelaysMs` (its length is the budget; `[]` disables). Refusals never retry. Consumer action: none.
5
6
  - **Removed** the deprecated aliases `ENDPOINTS.ai.chat` (use `ENDPOINTS.ai.manual`) and `ENDPOINTS.utilities.pdfExtractText` (use `ENDPOINTS.pdf.extractText`); no importer existed. Added `FEATURE.md`. Consumer action: none.
6
7
 
7
- ## 0.1.28
8
+ ## 0.1.29
8
9
 
9
10
  UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
10
11
  Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/api/src`.
11
12
 
13
+ ## 0.1.28
14
+
15
+ SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
16
+ so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
17
+ Diff: `git diff 3702c2122e 6638270587 -- apps/shared/api/src`
18
+
19
+ Changed shipped source files (31):
20
+ - `apps/shared/api/src/deployments.generated.ts`
21
+ - `apps/shared/api/src/generated/account.ts`
22
+ - `apps/shared/api/src/generated/agents.ts`
23
+ - `apps/shared/api/src/generated/ai.ts`
24
+ - `apps/shared/api/src/generated/apps.ts`
25
+ - `apps/shared/api/src/generated/architecture.ts`
26
+ - `apps/shared/api/src/generated/audio.ts`
27
+ - `apps/shared/api/src/generated/chat.ts`
28
+ - `apps/shared/api/src/generated/code.ts`
29
+ - `apps/shared/api/src/generated/commerce.ts`
30
+ - `apps/shared/api/src/generated/communications.ts`
31
+ - `apps/shared/api/src/generated/computer.ts`
32
+ - ...and 19 more
33
+
12
34
  ## 0.1.27
13
35
 
14
36
  Automatic changed-only republish (docs/metadata drift since the last published version; verified: `git diff 967a33b7f1 3702c2122e -- apps/shared/api/src`
package/dist/index.cjs CHANGED
@@ -532,6 +532,10 @@ function runWaitTimeoutMessage(kind, modelLabel, seconds) {
532
532
  var WARM_PATH = "/ai/warm";
533
533
  var DEFAULT_COALESCE_MS = 50;
534
534
  var DEFAULT_DEDUPE_MS = 6e4;
535
+ var DEFAULT_RETRY_DELAYS_MS = [2e3, 8e3, 3e4];
536
+ function isTransientStatus(status) {
537
+ return status === 408 || status === 425 || status === 429 || status >= 500 && status !== 501;
538
+ }
535
539
  var SWEEP_AT = 256;
536
540
  var QUEUE_MAX = 64;
537
541
  function itemId(item) {
@@ -545,6 +549,7 @@ function createWarmup(options) {
545
549
  organizationId,
546
550
  coalesceMs = DEFAULT_COALESCE_MS,
547
551
  dedupeMs = DEFAULT_DEDUPE_MS,
552
+ retryDelaysMs = DEFAULT_RETRY_DELAYS_MS,
548
553
  now = Date.now
549
554
  } = options;
550
555
  const sentAt = /* @__PURE__ */ new Map();
@@ -594,6 +599,9 @@ function createWarmup(options) {
594
599
  if (batch.length === 0) return;
595
600
  const keys = batch.map((i) => `${current}|${itemId(i)}`);
596
601
  keys.forEach((k) => inFlight.add(k));
602
+ send(batch, keys, reason, current, 0);
603
+ }
604
+ function send(batch, keys, reason, sendScope, attempt2) {
597
605
  const settle = (ok) => {
598
606
  const t = now();
599
607
  for (const k of keys) {
@@ -601,6 +609,21 @@ function createWarmup(options) {
601
609
  if (ok) sentAt.set(k, t);
602
610
  }
603
611
  };
612
+ const failed = (transient, detail) => {
613
+ const delay = retryDelaysMs[attempt2];
614
+ if (transient && delay !== void 0) {
615
+ setTimeout(() => {
616
+ if (currentScope() !== sendScope) {
617
+ settle(false);
618
+ return;
619
+ }
620
+ send(batch, keys, reason, sendScope, attempt2 + 1);
621
+ }, delay);
622
+ return;
623
+ }
624
+ settle(false);
625
+ announce(attempt2 > 0 ? `${detail} after ${attempt2 + 1} attempts` : detail);
626
+ };
604
627
  try {
605
628
  const org = organizationId ? organizationId() : null;
606
629
  void transport.fetch(WARM_PATH, {
@@ -612,12 +635,11 @@ function createWarmup(options) {
612
635
  body: JSON.stringify({ reason, items: batch })
613
636
  }).then(
614
637
  (response) => {
615
- settle(response.ok);
616
- if (!response.ok) announce(`HTTP ${response.status}`);
638
+ if (response.ok) settle(true);
639
+ else failed(isTransientStatus(response.status), `HTTP ${response.status}`);
617
640
  },
618
641
  (err) => {
619
- settle(false);
620
- announce(String(err));
642
+ failed(true, String(err));
621
643
  }
622
644
  );
623
645
  } catch (err) {
@@ -1574,9 +1596,9 @@ async function reportProviderSessionUsage(transport, usage, options = {}) {
1574
1596
  return "retry";
1575
1597
  }
1576
1598
  }
1577
- var DEFAULT_RETRY_DELAYS_MS = [1e3, 4e3, 15e3, 6e4, 18e4];
1599
+ var DEFAULT_RETRY_DELAYS_MS2 = [1e3, 4e3, 15e3, 6e4, 18e4];
1578
1600
  function createProviderUsageReporter(options) {
1579
- const delays = options.retryDelaysMs ?? DEFAULT_RETRY_DELAYS_MS;
1601
+ const delays = options.retryDelaysMs ?? DEFAULT_RETRY_DELAYS_MS2;
1580
1602
  const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
1581
1603
  const seen = /* @__PURE__ */ new Set();
1582
1604
  const inflight = /* @__PURE__ */ new Set();
package/dist/index.d.cts CHANGED
@@ -837,6 +837,12 @@ declare function runWaitTimeoutMessage(kind: RunOutputKind, modelLabel: string |
837
837
  * out → nothing is sent. Until the server endpoint exists the call answers 404
838
838
  * and the primitive stays silent (one `console.debug`, once).
839
839
  *
840
+ * TRANSIENT FAILURES ARE RETRIED. A server rollover (a release every ~30 min)
841
+ * answers `Failed to fetch` or a 502/503/504 for a few seconds — exactly when a
842
+ * warm-up matters most, because the new server's caches are cold. A batch that
843
+ * fails that way goes again after `retryDelaysMs` (default 2s, 8s, 30s) while
844
+ * the scope is unchanged; a refusal (4xx other than 408/425/429) never retries.
845
+ *
840
846
  * Auth, base URL and `X-Organization-Id` are the injected `MatrxTransport`'s
841
847
  * job, exactly as for every other call in this package.
842
848
  */
@@ -874,6 +880,11 @@ interface CreateWarmupOptions {
874
880
  coalesceMs?: number;
875
881
  /** Per-scope per-item dedupe window after a 2xx. Default 60_000ms. */
876
882
  dedupeMs?: number;
883
+ /**
884
+ * Delay before each retry of a batch that failed transiently (network error,
885
+ * 408/425/429/5xx); its length is the retry budget. Default 2s, 8s, 30s.
886
+ */
887
+ retryDelaysMs?: readonly number[];
877
888
  /** Clock, for tests. Default `Date.now`. */
878
889
  now?: () => number;
879
890
  }
package/dist/index.d.ts CHANGED
@@ -837,6 +837,12 @@ declare function runWaitTimeoutMessage(kind: RunOutputKind, modelLabel: string |
837
837
  * out → nothing is sent. Until the server endpoint exists the call answers 404
838
838
  * and the primitive stays silent (one `console.debug`, once).
839
839
  *
840
+ * TRANSIENT FAILURES ARE RETRIED. A server rollover (a release every ~30 min)
841
+ * answers `Failed to fetch` or a 502/503/504 for a few seconds — exactly when a
842
+ * warm-up matters most, because the new server's caches are cold. A batch that
843
+ * fails that way goes again after `retryDelaysMs` (default 2s, 8s, 30s) while
844
+ * the scope is unchanged; a refusal (4xx other than 408/425/429) never retries.
845
+ *
840
846
  * Auth, base URL and `X-Organization-Id` are the injected `MatrxTransport`'s
841
847
  * job, exactly as for every other call in this package.
842
848
  */
@@ -874,6 +880,11 @@ interface CreateWarmupOptions {
874
880
  coalesceMs?: number;
875
881
  /** Per-scope per-item dedupe window after a 2xx. Default 60_000ms. */
876
882
  dedupeMs?: number;
883
+ /**
884
+ * Delay before each retry of a batch that failed transiently (network error,
885
+ * 408/425/429/5xx); its length is the retry budget. Default 2s, 8s, 30s.
886
+ */
887
+ retryDelaysMs?: readonly number[];
877
888
  /** Clock, for tests. Default `Date.now`. */
878
889
  now?: () => number;
879
890
  }
package/dist/index.js CHANGED
@@ -532,6 +532,10 @@ function runWaitTimeoutMessage(kind, modelLabel, seconds) {
532
532
  var WARM_PATH = "/ai/warm";
533
533
  var DEFAULT_COALESCE_MS = 50;
534
534
  var DEFAULT_DEDUPE_MS = 6e4;
535
+ var DEFAULT_RETRY_DELAYS_MS = [2e3, 8e3, 3e4];
536
+ function isTransientStatus(status) {
537
+ return status === 408 || status === 425 || status === 429 || status >= 500 && status !== 501;
538
+ }
535
539
  var SWEEP_AT = 256;
536
540
  var QUEUE_MAX = 64;
537
541
  function itemId(item) {
@@ -545,6 +549,7 @@ function createWarmup(options) {
545
549
  organizationId,
546
550
  coalesceMs = DEFAULT_COALESCE_MS,
547
551
  dedupeMs = DEFAULT_DEDUPE_MS,
552
+ retryDelaysMs = DEFAULT_RETRY_DELAYS_MS,
548
553
  now = Date.now
549
554
  } = options;
550
555
  const sentAt = /* @__PURE__ */ new Map();
@@ -594,6 +599,9 @@ function createWarmup(options) {
594
599
  if (batch.length === 0) return;
595
600
  const keys = batch.map((i) => `${current}|${itemId(i)}`);
596
601
  keys.forEach((k) => inFlight.add(k));
602
+ send(batch, keys, reason, current, 0);
603
+ }
604
+ function send(batch, keys, reason, sendScope, attempt2) {
597
605
  const settle = (ok) => {
598
606
  const t = now();
599
607
  for (const k of keys) {
@@ -601,6 +609,21 @@ function createWarmup(options) {
601
609
  if (ok) sentAt.set(k, t);
602
610
  }
603
611
  };
612
+ const failed = (transient, detail) => {
613
+ const delay = retryDelaysMs[attempt2];
614
+ if (transient && delay !== void 0) {
615
+ setTimeout(() => {
616
+ if (currentScope() !== sendScope) {
617
+ settle(false);
618
+ return;
619
+ }
620
+ send(batch, keys, reason, sendScope, attempt2 + 1);
621
+ }, delay);
622
+ return;
623
+ }
624
+ settle(false);
625
+ announce(attempt2 > 0 ? `${detail} after ${attempt2 + 1} attempts` : detail);
626
+ };
604
627
  try {
605
628
  const org = organizationId ? organizationId() : null;
606
629
  void transport.fetch(WARM_PATH, {
@@ -612,12 +635,11 @@ function createWarmup(options) {
612
635
  body: JSON.stringify({ reason, items: batch })
613
636
  }).then(
614
637
  (response) => {
615
- settle(response.ok);
616
- if (!response.ok) announce(`HTTP ${response.status}`);
638
+ if (response.ok) settle(true);
639
+ else failed(isTransientStatus(response.status), `HTTP ${response.status}`);
617
640
  },
618
641
  (err) => {
619
- settle(false);
620
- announce(String(err));
642
+ failed(true, String(err));
621
643
  }
622
644
  );
623
645
  } catch (err) {
@@ -1574,9 +1596,9 @@ async function reportProviderSessionUsage(transport, usage, options = {}) {
1574
1596
  return "retry";
1575
1597
  }
1576
1598
  }
1577
- var DEFAULT_RETRY_DELAYS_MS = [1e3, 4e3, 15e3, 6e4, 18e4];
1599
+ var DEFAULT_RETRY_DELAYS_MS2 = [1e3, 4e3, 15e3, 6e4, 18e4];
1578
1600
  function createProviderUsageReporter(options) {
1579
- const delays = options.retryDelaysMs ?? DEFAULT_RETRY_DELAYS_MS;
1601
+ const delays = options.retryDelaysMs ?? DEFAULT_RETRY_DELAYS_MS2;
1580
1602
  const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
1581
1603
  const seen = /* @__PURE__ */ new Set();
1582
1604
  const inflight = /* @__PURE__ */ new Set();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-matrx/api",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "description": "The one way every app talks to every AI Matrx server: generated from the server contract, split by domain so an app loads only the requests it calls. Transport, five credential kinds, organization binding, streams, job follow. No screens, app state or database code.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -439,5 +439,5 @@
439
439
  "check:sections": "node scripts/section-probe.mjs \"$PWD\"",
440
440
  "verify:tarball": "node scripts/verify-tarball.mjs"
441
441
  },
442
- "gitHead": "663827058712d4e48f1c98d95b8efbdafd0667bd"
442
+ "gitHead": "fab8a30b0b60555c3314c6116dd8d4a7a29473fd"
443
443
  }