@ai-matrx/api 0.1.9 → 0.1.11

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.
Files changed (135) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +1 -1
  3. package/dist/account.d.cts +1 -1
  4. package/dist/account.d.ts +1 -1
  5. package/dist/agents.cjs +12 -12
  6. package/dist/agents.d.cts +1 -1
  7. package/dist/agents.d.ts +1 -1
  8. package/dist/agents.js +2 -2
  9. package/dist/ai.cjs +3 -3
  10. package/dist/ai.d.cts +1 -1
  11. package/dist/ai.d.ts +1 -1
  12. package/dist/ai.js +2 -2
  13. package/dist/apps.cjs +6 -6
  14. package/dist/apps.d.cts +1 -1
  15. package/dist/apps.d.ts +1 -1
  16. package/dist/apps.js +2 -2
  17. package/dist/architecture.cjs +11 -11
  18. package/dist/architecture.d.cts +1 -1
  19. package/dist/architecture.d.ts +1 -1
  20. package/dist/architecture.js +2 -2
  21. package/dist/audio.cjs +5 -5
  22. package/dist/audio.d.cts +1 -1
  23. package/dist/audio.d.ts +1 -1
  24. package/dist/audio.js +2 -2
  25. package/dist/chat.cjs +12 -12
  26. package/dist/chat.d.cts +1 -1
  27. package/dist/chat.d.ts +1 -1
  28. package/dist/chat.js +2 -2
  29. package/dist/{chunk-PMGKZ4FT.cjs → chunk-2ZHIYXHV.cjs} +279 -34
  30. package/dist/{chunk-PIVTHTVR.js → chunk-6KHHHBG5.js} +270 -36
  31. package/dist/{chunk-KIEAFMKB.js → chunk-PIPE5OML.js} +100 -46
  32. package/dist/{chunk-2SXAAKGV.cjs → chunk-PKYPPATQ.cjs} +100 -45
  33. package/dist/code.cjs +7 -7
  34. package/dist/code.d.cts +1 -1
  35. package/dist/code.d.ts +1 -1
  36. package/dist/code.js +2 -2
  37. package/dist/commerce.d.cts +1 -1
  38. package/dist/commerce.d.ts +1 -1
  39. package/dist/communications.cjs +5 -5
  40. package/dist/communications.d.cts +1 -1
  41. package/dist/communications.d.ts +1 -1
  42. package/dist/communications.js +2 -2
  43. package/dist/computer.cjs +4 -4
  44. package/dist/computer.d.cts +1 -1
  45. package/dist/computer.d.ts +1 -1
  46. package/dist/computer.js +2 -2
  47. package/dist/content.cjs +5 -5
  48. package/dist/content.d.cts +1 -1
  49. package/dist/content.d.ts +1 -1
  50. package/dist/content.js +2 -2
  51. package/dist/crm.cjs +3 -3
  52. package/dist/crm.d.cts +1 -1
  53. package/dist/crm.d.ts +1 -1
  54. package/dist/crm.js +2 -2
  55. package/dist/data.d.cts +1 -1
  56. package/dist/data.d.ts +1 -1
  57. package/dist/education.cjs +5 -5
  58. package/dist/education.d.cts +1 -1
  59. package/dist/education.d.ts +1 -1
  60. package/dist/education.js +2 -2
  61. package/dist/files.cjs +21 -21
  62. package/dist/files.d.cts +1 -1
  63. package/dist/files.d.ts +1 -1
  64. package/dist/files.js +2 -2
  65. package/dist/human-resources.d.cts +1 -1
  66. package/dist/human-resources.d.ts +1 -1
  67. package/dist/{index-C3ZlP3BI.d.cts → index-Gj30ybjE.d.cts} +42 -3
  68. package/dist/{index-C3ZlP3BI.d.ts → index-Gj30ybjE.d.ts} +42 -3
  69. package/dist/index.cjs +188 -288
  70. package/dist/index.d.cts +129 -180
  71. package/dist/index.d.ts +129 -180
  72. package/dist/index.js +81 -206
  73. package/dist/integrations.cjs +4 -4
  74. package/dist/integrations.d.cts +1 -1
  75. package/dist/integrations.d.ts +1 -1
  76. package/dist/integrations.js +2 -2
  77. package/dist/intelligence.cjs +10 -8
  78. package/dist/intelligence.d.cts +13 -13
  79. package/dist/intelligence.d.ts +13 -13
  80. package/dist/intelligence.js +5 -3
  81. package/dist/{keys.generated-CK_C5UXG.d.cts → keys.generated-DZUiM-uA.d.cts} +5 -3
  82. package/dist/{keys.generated-CK_C5UXG.d.ts → keys.generated-DZUiM-uA.d.ts} +5 -3
  83. package/dist/knowledge.cjs +43 -43
  84. package/dist/knowledge.d.cts +13 -13
  85. package/dist/knowledge.d.ts +13 -13
  86. package/dist/knowledge.js +2 -2
  87. package/dist/legal.cjs +7 -7
  88. package/dist/legal.d.cts +1 -1
  89. package/dist/legal.d.ts +1 -1
  90. package/dist/legal.js +2 -2
  91. package/dist/marketing.cjs +77 -77
  92. package/dist/marketing.d.cts +27 -27
  93. package/dist/marketing.d.ts +27 -27
  94. package/dist/marketing.js +2 -2
  95. package/dist/masterwork.cjs +33 -33
  96. package/dist/masterwork.d.cts +1 -1
  97. package/dist/masterwork.d.ts +1 -1
  98. package/dist/masterwork.js +2 -2
  99. package/dist/media.cjs +12 -12
  100. package/dist/media.d.cts +1 -1
  101. package/dist/media.d.ts +1 -1
  102. package/dist/media.js +2 -2
  103. package/dist/net.cjs +19 -20
  104. package/dist/net.d.cts +41 -41
  105. package/dist/net.d.ts +41 -41
  106. package/dist/net.js +1 -2
  107. package/dist/platform.cjs +4 -4
  108. package/dist/platform.d.cts +1 -1
  109. package/dist/platform.d.ts +1 -1
  110. package/dist/platform.js +2 -2
  111. package/dist/publish.cjs +8 -8
  112. package/dist/publish.d.cts +1 -1
  113. package/dist/publish.d.ts +1 -1
  114. package/dist/publish.js +2 -2
  115. package/dist/schemas.d.cts +78 -15
  116. package/dist/schemas.d.ts +78 -15
  117. package/dist/stream.cjs +11 -11
  118. package/dist/stream.d.cts +1 -1
  119. package/dist/stream.d.ts +1 -1
  120. package/dist/stream.js +2 -2
  121. package/dist/types.cjs +2 -0
  122. package/dist/types.d.cts +72245 -0
  123. package/dist/types.d.ts +72245 -0
  124. package/dist/types.js +1 -0
  125. package/dist/web.cjs +27 -27
  126. package/dist/web.d.cts +17 -17
  127. package/dist/web.d.ts +17 -17
  128. package/dist/web.js +2 -2
  129. package/dist/workflows.cjs +14 -14
  130. package/dist/workflows.d.cts +23 -26
  131. package/dist/workflows.d.ts +23 -26
  132. package/dist/workflows.js +2 -2
  133. package/package.json +14 -4
  134. package/dist/chunk-FNIYADWI.cjs +0 -59
  135. package/dist/chunk-YTEOFGFC.js +0 -57
@@ -1,9 +1,92 @@
1
1
  'use strict';
2
2
 
3
- var chunk2SXAAKGV_cjs = require('./chunk-2SXAAKGV.cjs');
3
+ var chunkPKYPPATQ_cjs = require('./chunk-PKYPPATQ.cjs');
4
4
  var uuid = require('@ai-matrx/kit/uuid');
5
5
  var credentials = require('@ai-matrx/auth/credentials');
6
6
 
7
+ // src/core/protocol.ts
8
+ var MATRX_AI_API_VERSION_DEFAULT = "v2";
9
+ var V2_COVERED_AI_PATH_TEMPLATES = [
10
+ "/ai/manual",
11
+ "/ai/chat",
12
+ "/ai/agents/{agent_id}",
13
+ "/ai/agent/{agent_id}",
14
+ // singular alias — behaves identically
15
+ "/ai/conversations/{conversation_id}",
16
+ "/ai/conversation/{conversation_id}",
17
+ // singular alias
18
+ "/ai/prompts/{prompt_id}",
19
+ // saved-prompt execution
20
+ "/ai/mandates/{mandate_key}"
21
+ // THE MANDATE DOOR — `/v2` sibling exists (routers/v2.py)
22
+ ];
23
+ function toV2Path(path) {
24
+ const withLead = path.startsWith("/") ? path : `/${path}`;
25
+ if (withLead.startsWith("/api/")) {
26
+ const rest = withLead.slice("/api".length);
27
+ return rest.startsWith("/v2/") ? withLead : `/api/v2${rest}`;
28
+ }
29
+ return withLead.startsWith("/v2/") ? withLead : `/v2${withLead}`;
30
+ }
31
+ var COVERED_INTERPOLATED_PATH = [
32
+ /^(?:\/api)?\/ai\/manual$/,
33
+ /^(?:\/api)?\/ai\/chat$/,
34
+ /^(?:\/api)?\/ai\/agents\/[^/]+$/,
35
+ /^(?:\/api)?\/ai\/agent\/[^/]+$/,
36
+ /^(?:\/api)?\/ai\/conversations\/[^/]+$/,
37
+ /^(?:\/api)?\/ai\/conversation\/[^/]+$/,
38
+ /^(?:\/api)?\/ai\/prompts\/[^/]+$/,
39
+ // `/warm` etc. deliberately don't match
40
+ /^(?:\/api)?\/ai\/mandates\/[^/]+$/
41
+ // the mandate door
42
+ ];
43
+ function isCoveredAiPath(path) {
44
+ return COVERED_INTERPOLATED_PATH.some((re) => re.test(path));
45
+ }
46
+ function isV2Path(pathOrUrl) {
47
+ return /\/v2\/ai\//.test(pathOrUrl);
48
+ }
49
+ function toV1FallbackUrl(url) {
50
+ return url.replace(/\/v2\/ai\//, "/ai/");
51
+ }
52
+ function applyAiApiVersion(path, version) {
53
+ if (version !== "v2") return path;
54
+ return isCoveredAiPath(path) ? toV2Path(path) : path;
55
+ }
56
+ async function fetchWithMatrxProtocolFallback(url, init, opts = {}) {
57
+ const { onDowngrade, ...fetchOpts } = opts;
58
+ const logDowngrade = (reason, status2) => {
59
+ console.warn(
60
+ `[matrx] ai_v2_downgrade \u2192 retrying on v1. v2=${url} reason=${reason}`
61
+ );
62
+ onDowngrade?.({ url, reason, ...status2 !== void 0 ? { status: status2 } : {} });
63
+ };
64
+ if (!isV2Path(url)) return chunkPKYPPATQ_cjs.resilientFetch(url, init, fetchOpts);
65
+ let result;
66
+ try {
67
+ result = await chunkPKYPPATQ_cjs.resilientFetch(url, init, fetchOpts);
68
+ } catch (err) {
69
+ const isAbort = chunkPKYPPATQ_cjs.isNetError(err) && err.code === "aborted" || err instanceof Error && err.name === "AbortError";
70
+ if (isAbort) throw err;
71
+ logDowngrade(String(err));
72
+ return chunkPKYPPATQ_cjs.resilientFetch(toV1FallbackUrl(url), init, fetchOpts);
73
+ }
74
+ const status = result.response.status;
75
+ if (status === 404 || status === 405 || status >= 500) {
76
+ logDowngrade(`HTTP ${status}`, status);
77
+ return chunkPKYPPATQ_cjs.resilientFetch(toV1FallbackUrl(url), init, fetchOpts);
78
+ }
79
+ return result;
80
+ }
81
+ function aiVersionPathOverrides(version) {
82
+ if (version !== "v2") return {};
83
+ const map = {};
84
+ for (const template of V2_COVERED_AI_PATH_TEMPLATES) {
85
+ map[template] = toV2Path(template);
86
+ }
87
+ return map;
88
+ }
89
+
7
90
  // src/core/backend-errors.ts
8
91
  var BackendApiError = class extends Error {
9
92
  /** Machine-readable error code */
@@ -824,7 +907,177 @@ var DEPLOYMENTS = {
824
907
  }
825
908
  };
826
909
  var DOMAINS = ["account", "agents", "ai", "apps", "architecture", "audio", "chat", "code", "commerce", "communications", "computer", "content", "crm", "data", "education", "files", "human-resources", "integrations", "intelligence", "knowledge", "legal", "marketing", "masterwork", "media", "platform", "publish", "web", "workflows"];
910
+ var WIRE_FETCH_OPTION_KEYS = [
911
+ "redirect",
912
+ "cache",
913
+ "credentials",
914
+ "mode",
915
+ "keepalive",
916
+ "referrerPolicy",
917
+ "integrity",
918
+ "priority"
919
+ ];
920
+ var SESSION_READY_TIMEOUT_MS = 3e3;
827
921
  var DEFAULT_CONNECT_TIMEOUT_MS = 15e3;
922
+ function isBodyInit(body) {
923
+ return typeof body === "string" || typeof Blob !== "undefined" && body instanceof Blob || typeof FormData !== "undefined" && body instanceof FormData || typeof URLSearchParams !== "undefined" && body instanceof URLSearchParams || body instanceof ArrayBuffer || ArrayBuffer.isView(body) || typeof ReadableStream !== "undefined" && body instanceof ReadableStream;
924
+ }
925
+ async function waitForSessionReady(credentials, timeoutMs = SESSION_READY_TIMEOUT_MS) {
926
+ const ready = credentials?.ready;
927
+ if (!ready) return;
928
+ let timer;
929
+ try {
930
+ await Promise.race([
931
+ ready.call(credentials).catch(() => void 0),
932
+ new Promise((resolve) => {
933
+ timer = setTimeout(resolve, Math.max(0, timeoutMs));
934
+ })
935
+ ]);
936
+ } finally {
937
+ if (timer !== void 0) clearTimeout(timer);
938
+ }
939
+ }
940
+ function headerBag(headers) {
941
+ return { ...headers ?? {} };
942
+ }
943
+ function hasHeader(headers, name) {
944
+ const lower = name.toLowerCase();
945
+ return Object.keys(headers).some((key) => key.toLowerCase() === lower);
946
+ }
947
+ function encodeBody(method, body, headers) {
948
+ const upper = method.toUpperCase();
949
+ if (body === void 0 || upper === "GET" || upper === "HEAD") return void 0;
950
+ if (isBodyInit(body)) return body;
951
+ if (!hasHeader(headers, "content-type")) headers["Content-Type"] = "application/json";
952
+ return JSON.stringify(body);
953
+ }
954
+ function bodySize(body) {
955
+ if (body === void 0) return 0;
956
+ if (typeof body === "string") return new TextEncoder().encode(body).byteLength;
957
+ if (typeof Blob !== "undefined" && body instanceof Blob) return body.size;
958
+ if (body instanceof ArrayBuffer) return body.byteLength;
959
+ if (ArrayBuffer.isView(body)) return body.byteLength;
960
+ return 0;
961
+ }
962
+ function parseXhrHeaders(raw) {
963
+ const headers = new Headers();
964
+ for (const line of raw.trim().split(/[\r\n]+/)) {
965
+ const index = line.indexOf(":");
966
+ if (index <= 0) continue;
967
+ try {
968
+ headers.append(line.slice(0, index).trim(), line.slice(index + 1).trim());
969
+ } catch {
970
+ }
971
+ }
972
+ return headers;
973
+ }
974
+ function sendWithXhr(url, init, signal, totalTimeoutMs, onUploadProgress) {
975
+ const controller = new AbortController();
976
+ return new Promise((resolve, reject) => {
977
+ const xhr = new XMLHttpRequest();
978
+ xhr.open(init.method, url, true);
979
+ xhr.responseType = "arraybuffer";
980
+ for (const [name, value] of Object.entries(init.headers)) xhr.setRequestHeader(name, value);
981
+ if (totalTimeoutMs !== null && totalTimeoutMs > 0) xhr.timeout = totalTimeoutMs;
982
+ let lastLoaded = 0;
983
+ xhr.upload.onprogress = (event) => {
984
+ const loaded = Math.max(lastLoaded, event.loaded);
985
+ lastLoaded = loaded;
986
+ onUploadProgress({ loaded, total: event.lengthComputable ? event.total : 0 });
987
+ };
988
+ const onAbort = () => xhr.abort();
989
+ signal?.addEventListener("abort", onAbort, { once: true });
990
+ controller.signal.addEventListener("abort", onAbort, { once: true });
991
+ const cleanup = () => signal?.removeEventListener("abort", onAbort);
992
+ xhr.onload = () => {
993
+ cleanup();
994
+ const status = xhr.status === 0 ? 200 : xhr.status;
995
+ const nullBody = status === 204 || status === 205 || status === 304;
996
+ const response = new Response(nullBody ? null : xhr.response, {
997
+ status,
998
+ statusText: xhr.statusText,
999
+ headers: parseXhrHeaders(xhr.getAllResponseHeaders())
1000
+ });
1001
+ resolve({ response, controller });
1002
+ };
1003
+ xhr.onerror = () => {
1004
+ cleanup();
1005
+ reject(new TypeError(`Network failure uploading to ${url}`));
1006
+ };
1007
+ xhr.ontimeout = () => {
1008
+ cleanup();
1009
+ reject(new DOMException(`Upload to ${url} exceeded ${totalTimeoutMs}ms`, "TimeoutError"));
1010
+ };
1011
+ xhr.onabort = () => {
1012
+ cleanup();
1013
+ reject(new DOMException("The upload was cancelled.", "AbortError"));
1014
+ };
1015
+ if (signal?.aborted) {
1016
+ xhr.abort();
1017
+ return;
1018
+ }
1019
+ xhr.send(init.body ?? null);
1020
+ });
1021
+ }
1022
+ async function sendOnWire(request, auth = {}) {
1023
+ const method = request.method.toUpperCase();
1024
+ const headers = headerBag(request.headers);
1025
+ const body = encodeBody(method, request.body, headers);
1026
+ await waitForSessionReady(auth.credentials, auth.readyTimeoutMs);
1027
+ const credentialHeaders = auth.credentials ? credentials.credentialToHeaders(await auth.credentials.get()) : {};
1028
+ const attempt = (sendHeaders) => {
1029
+ if (request.signal?.aborted) return Promise.reject(new chunkPKYPPATQ_cjs.AbortedError(request.signal.reason));
1030
+ const merged = { ...sendHeaders };
1031
+ if (request.onUploadProgress && body !== void 0) {
1032
+ if (typeof XMLHttpRequest !== "undefined" && !(typeof ReadableStream !== "undefined" && body instanceof ReadableStream)) {
1033
+ return sendWithXhr(
1034
+ request.url,
1035
+ { method, headers: merged, body },
1036
+ request.signal,
1037
+ request.totalTimeoutMs ?? null,
1038
+ request.onUploadProgress
1039
+ );
1040
+ }
1041
+ }
1042
+ return fetchWithMatrxProtocolFallback(
1043
+ request.url,
1044
+ { ...request.fetchOptions, method, headers: merged, ...body !== void 0 ? { body } : {} },
1045
+ {
1046
+ ...request.signal ? { signal: request.signal } : {},
1047
+ connectTimeoutMs: request.connectTimeoutMs ?? DEFAULT_CONNECT_TIMEOUT_MS,
1048
+ totalTimeoutMs: request.totalTimeoutMs !== void 0 ? request.totalTimeoutMs : null,
1049
+ throwOnHttpError: false,
1050
+ ...request.onProtocolDowngrade ? { onDowngrade: request.onProtocolDowngrade } : {}
1051
+ }
1052
+ ).then((result) => {
1053
+ if (request.onUploadProgress && body !== void 0) {
1054
+ const total = bodySize(body);
1055
+ request.onUploadProgress({ loaded: total, total });
1056
+ }
1057
+ return result;
1058
+ });
1059
+ };
1060
+ const over = Object.fromEntries(
1061
+ Object.entries(request.overHeaders ?? {}).filter(([name]) => name.toLowerCase() !== "content-type")
1062
+ );
1063
+ const firstHeaders = { ...headers, ...credentialHeaders, ...over };
1064
+ const idempotent = method === "GET" || method === "HEAD";
1065
+ const attempts = Math.max(1, request.retryAttempts ?? 1);
1066
+ const first = idempotent && attempts > 1 && !request.stream ? await chunkPKYPPATQ_cjs.withRetry(() => attempt(firstHeaders), {
1067
+ attempts,
1068
+ retryOn: chunkPKYPPATQ_cjs.isTransportFailure,
1069
+ ...request.signal ? { signal: request.signal } : {}
1070
+ }) : await attempt(firstHeaders);
1071
+ if (first.response.status !== 401 || !auth.refreshCredentials) return first;
1072
+ if (!await auth.refreshCredentials()) return first;
1073
+ await first.response.body?.cancel().catch(() => void 0);
1074
+ const retryHeaders = { ...headers };
1075
+ Object.assign(retryHeaders, auth.credentials ? credentials.credentialToHeaders(await auth.credentials.get()) : {}, over);
1076
+ return attempt(retryHeaders);
1077
+ }
1078
+
1079
+ // src/api.ts
1080
+ var DEFAULT_CONNECT_TIMEOUT_MS2 = 15e3;
828
1081
  function defaultRequestId() {
829
1082
  const c = globalThis.crypto;
830
1083
  if (c?.randomUUID) return c.randomUUID();
@@ -853,9 +1106,6 @@ function queryString(query) {
853
1106
  }
854
1107
  return parts.length ? `?${parts.join("&")}` : "";
855
1108
  }
856
- function isBodyInit(body) {
857
- return typeof body === "string" || typeof Blob !== "undefined" && body instanceof Blob || typeof FormData !== "undefined" && body instanceof FormData || typeof URLSearchParams !== "undefined" && body instanceof URLSearchParams || body instanceof ArrayBuffer || ArrayBuffer.isView(body) || typeof ReadableStream !== "undefined" && body instanceof ReadableStream;
858
- }
859
1109
  function acceptFor(stream) {
860
1110
  switch (stream) {
861
1111
  case "ndjson":
@@ -921,43 +1171,27 @@ function createApi(options = {}) {
921
1171
  Accept: acceptFor(op.s),
922
1172
  [credentials.MATRX_HEADERS.requestId]: requestId
923
1173
  };
924
- let body;
925
- if (args?.body !== void 0 && op.m !== "GET" && op.m !== "HEAD") {
926
- if (isBodyInit(args.body)) {
927
- body = args.body;
928
- } else {
929
- body = JSON.stringify(args.body);
930
- headers["Content-Type"] = "application/json";
931
- }
932
- }
933
- const credentialHeaders = credentials.credentialToHeaders(await credentials$1.get());
934
- Object.assign(headers, credentialHeaders);
935
1174
  if (orgId !== null) headers[credentials.MATRX_HEADERS.organization] = orgId;
936
1175
  options.onRequest?.({ operation: op.n, method: op.m, url, requestId, deployment: op.d });
937
- const attempt = (sendHeaders = headers) => chunk2SXAAKGV_cjs.resilientFetch(
938
- url,
939
- { method: op.m, headers: sendHeaders, ...body !== void 0 ? { body } : {} },
1176
+ const { response, controller } = await sendOnWire(
940
1177
  {
1178
+ url,
1179
+ method: op.m,
1180
+ headers,
1181
+ body: args?.body,
941
1182
  ...call?.signal ? { signal: call.signal } : {},
942
- connectTimeoutMs: call?.connectTimeoutMs ?? options.connectTimeoutMs ?? DEFAULT_CONNECT_TIMEOUT_MS,
1183
+ connectTimeoutMs: call?.connectTimeoutMs ?? options.connectTimeoutMs ?? DEFAULT_CONNECT_TIMEOUT_MS2,
943
1184
  totalTimeoutMs: call?.totalTimeoutMs !== void 0 ? call.totalTimeoutMs : options.totalTimeoutMs ?? null,
944
- throwOnHttpError: false
1185
+ stream: Boolean(op.s),
1186
+ retryAttempts,
1187
+ ...call?.onUploadProgress ? { onUploadProgress: call.onUploadProgress } : {}
1188
+ },
1189
+ {
1190
+ credentials: credentials$1,
1191
+ ...options.readyTimeoutMs !== void 0 ? { readyTimeoutMs: options.readyTimeoutMs } : {},
1192
+ ...options.refreshCredentials ? { refreshCredentials: options.refreshCredentials } : {}
945
1193
  }
946
1194
  );
947
- const idempotent = op.m === "GET" || op.m === "HEAD";
948
- const { response, controller } = idempotent && retryAttempts > 1 && !op.s ? await chunk2SXAAKGV_cjs.withRetry(() => attempt(), {
949
- attempts: retryAttempts,
950
- retryOn: chunk2SXAAKGV_cjs.isTransportFailure,
951
- ...call?.signal ? { signal: call.signal } : {}
952
- }) : await attempt();
953
- if (response.status === 401 && options.refreshCredentials && await options.refreshCredentials()) {
954
- const retryHeaders = { ...headers };
955
- for (const name of Object.keys(credentialHeaders)) delete retryHeaders[name];
956
- Object.assign(retryHeaders, credentials.credentialToHeaders(await credentials$1.get()));
957
- const retried = await attempt(retryHeaders);
958
- if (!retried.response.ok) throw await errorFrom(retried.response, interpolate(op.p, args?.path));
959
- return { response: retried.response, requestId, controller: retried.controller };
960
- }
961
1195
  if (!response.ok) throw await errorFrom(response, interpolate(op.p, args?.path));
962
1196
  return { response, requestId, controller };
963
1197
  };
@@ -1029,9 +1263,14 @@ exports.CONTRACT_SHA256 = CONTRACT_SHA256;
1029
1263
  exports.DEFAULT_MATRX_NDJSON_READ_AHEAD = DEFAULT_MATRX_NDJSON_READ_AHEAD;
1030
1264
  exports.DEPLOYMENTS = DEPLOYMENTS;
1031
1265
  exports.DOMAINS = DOMAINS;
1266
+ exports.MATRX_AI_API_VERSION_DEFAULT = MATRX_AI_API_VERSION_DEFAULT;
1032
1267
  exports.MatrxApiError = MatrxApiError;
1033
1268
  exports.OrganizationContextError = OrganizationContextError;
1034
1269
  exports.StreamTransportError = StreamTransportError;
1270
+ exports.V2_COVERED_AI_PATH_TEMPLATES = V2_COVERED_AI_PATH_TEMPLATES;
1271
+ exports.WIRE_FETCH_OPTION_KEYS = WIRE_FETCH_OPTION_KEYS;
1272
+ exports.aiVersionPathOverrides = aiVersionPathOverrides;
1273
+ exports.applyAiApiVersion = applyAiApiVersion;
1035
1274
  exports.applyOrganizationContextHeader = applyOrganizationContextHeader;
1036
1275
  exports.assertOrganizationMatchesOperation = assertOrganizationMatchesOperation;
1037
1276
  exports.assertQueryOrganizationMatchesContext = assertQueryOrganizationMatchesContext;
@@ -1042,9 +1281,12 @@ exports.createOrganizationOperation = createOrganizationOperation;
1042
1281
  exports.describeBackendFailure = describeBackendFailure;
1043
1282
  exports.extractMatrxErrorCode = extractMatrxErrorCode;
1044
1283
  exports.extractMatrxErrorMessage = extractMatrxErrorMessage;
1284
+ exports.fetchWithMatrxProtocolFallback = fetchWithMatrxProtocolFallback;
1045
1285
  exports.getUserMessage = getUserMessage;
1286
+ exports.isCoveredAiPath = isCoveredAiPath;
1046
1287
  exports.isGenericUserMessage = isGenericUserMessage;
1047
1288
  exports.isStreamTransportLost = isStreamTransportLost;
1289
+ exports.isV2Path = isV2Path;
1048
1290
  exports.normalizeMatrxStreamEnvelope = normalizeMatrxStreamEnvelope;
1049
1291
  exports.openJsonOrStream = openJsonOrStream;
1050
1292
  exports.openStream = openStream;
@@ -1057,4 +1299,7 @@ exports.parseStreamError = parseStreamError;
1057
1299
  exports.readMatrxNdjsonStream = readMatrxNdjsonStream;
1058
1300
  exports.readMatrxSseStream = readMatrxSseStream;
1059
1301
  exports.requireOrganizationContext = requireOrganizationContext;
1302
+ exports.sendOnWire = sendOnWire;
1303
+ exports.toV1FallbackUrl = toV1FallbackUrl;
1304
+ exports.toV2Path = toV2Path;
1060
1305
  exports.unwrapUpstreamError = unwrapUpstreamError;