@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.
- package/CHANGELOG.md +11 -0
- package/README.md +1 -1
- package/dist/account.d.cts +1 -1
- package/dist/account.d.ts +1 -1
- package/dist/agents.cjs +12 -12
- package/dist/agents.d.cts +1 -1
- package/dist/agents.d.ts +1 -1
- package/dist/agents.js +2 -2
- package/dist/ai.cjs +3 -3
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.js +2 -2
- package/dist/apps.cjs +6 -6
- package/dist/apps.d.cts +1 -1
- package/dist/apps.d.ts +1 -1
- package/dist/apps.js +2 -2
- package/dist/architecture.cjs +11 -11
- package/dist/architecture.d.cts +1 -1
- package/dist/architecture.d.ts +1 -1
- package/dist/architecture.js +2 -2
- package/dist/audio.cjs +5 -5
- package/dist/audio.d.cts +1 -1
- package/dist/audio.d.ts +1 -1
- package/dist/audio.js +2 -2
- package/dist/chat.cjs +12 -12
- package/dist/chat.d.cts +1 -1
- package/dist/chat.d.ts +1 -1
- package/dist/chat.js +2 -2
- package/dist/{chunk-PMGKZ4FT.cjs → chunk-2ZHIYXHV.cjs} +279 -34
- package/dist/{chunk-PIVTHTVR.js → chunk-6KHHHBG5.js} +270 -36
- package/dist/{chunk-KIEAFMKB.js → chunk-PIPE5OML.js} +100 -46
- package/dist/{chunk-2SXAAKGV.cjs → chunk-PKYPPATQ.cjs} +100 -45
- package/dist/code.cjs +7 -7
- package/dist/code.d.cts +1 -1
- package/dist/code.d.ts +1 -1
- package/dist/code.js +2 -2
- package/dist/commerce.d.cts +1 -1
- package/dist/commerce.d.ts +1 -1
- package/dist/communications.cjs +5 -5
- package/dist/communications.d.cts +1 -1
- package/dist/communications.d.ts +1 -1
- package/dist/communications.js +2 -2
- package/dist/computer.cjs +4 -4
- package/dist/computer.d.cts +1 -1
- package/dist/computer.d.ts +1 -1
- package/dist/computer.js +2 -2
- package/dist/content.cjs +5 -5
- package/dist/content.d.cts +1 -1
- package/dist/content.d.ts +1 -1
- package/dist/content.js +2 -2
- package/dist/crm.cjs +3 -3
- package/dist/crm.d.cts +1 -1
- package/dist/crm.d.ts +1 -1
- package/dist/crm.js +2 -2
- package/dist/data.d.cts +1 -1
- package/dist/data.d.ts +1 -1
- package/dist/education.cjs +5 -5
- package/dist/education.d.cts +1 -1
- package/dist/education.d.ts +1 -1
- package/dist/education.js +2 -2
- package/dist/files.cjs +21 -21
- package/dist/files.d.cts +1 -1
- package/dist/files.d.ts +1 -1
- package/dist/files.js +2 -2
- package/dist/human-resources.d.cts +1 -1
- package/dist/human-resources.d.ts +1 -1
- package/dist/{index-C3ZlP3BI.d.cts → index-Gj30ybjE.d.cts} +42 -3
- package/dist/{index-C3ZlP3BI.d.ts → index-Gj30ybjE.d.ts} +42 -3
- package/dist/index.cjs +188 -288
- package/dist/index.d.cts +129 -180
- package/dist/index.d.ts +129 -180
- package/dist/index.js +81 -206
- package/dist/integrations.cjs +4 -4
- package/dist/integrations.d.cts +1 -1
- package/dist/integrations.d.ts +1 -1
- package/dist/integrations.js +2 -2
- package/dist/intelligence.cjs +10 -8
- package/dist/intelligence.d.cts +13 -13
- package/dist/intelligence.d.ts +13 -13
- package/dist/intelligence.js +5 -3
- package/dist/{keys.generated-CK_C5UXG.d.cts → keys.generated-DZUiM-uA.d.cts} +5 -3
- package/dist/{keys.generated-CK_C5UXG.d.ts → keys.generated-DZUiM-uA.d.ts} +5 -3
- package/dist/knowledge.cjs +43 -43
- package/dist/knowledge.d.cts +13 -13
- package/dist/knowledge.d.ts +13 -13
- package/dist/knowledge.js +2 -2
- package/dist/legal.cjs +7 -7
- package/dist/legal.d.cts +1 -1
- package/dist/legal.d.ts +1 -1
- package/dist/legal.js +2 -2
- package/dist/marketing.cjs +77 -77
- package/dist/marketing.d.cts +27 -27
- package/dist/marketing.d.ts +27 -27
- package/dist/marketing.js +2 -2
- package/dist/masterwork.cjs +33 -33
- package/dist/masterwork.d.cts +1 -1
- package/dist/masterwork.d.ts +1 -1
- package/dist/masterwork.js +2 -2
- package/dist/media.cjs +12 -12
- package/dist/media.d.cts +1 -1
- package/dist/media.d.ts +1 -1
- package/dist/media.js +2 -2
- package/dist/net.cjs +19 -20
- package/dist/net.d.cts +41 -41
- package/dist/net.d.ts +41 -41
- package/dist/net.js +1 -2
- package/dist/platform.cjs +4 -4
- package/dist/platform.d.cts +1 -1
- package/dist/platform.d.ts +1 -1
- package/dist/platform.js +2 -2
- package/dist/publish.cjs +8 -8
- package/dist/publish.d.cts +1 -1
- package/dist/publish.d.ts +1 -1
- package/dist/publish.js +2 -2
- package/dist/schemas.d.cts +78 -15
- package/dist/schemas.d.ts +78 -15
- package/dist/stream.cjs +11 -11
- package/dist/stream.d.cts +1 -1
- package/dist/stream.d.ts +1 -1
- package/dist/stream.js +2 -2
- package/dist/types.cjs +2 -0
- package/dist/types.d.cts +72245 -0
- package/dist/types.d.ts +72245 -0
- package/dist/types.js +1 -0
- package/dist/web.cjs +27 -27
- package/dist/web.d.cts +17 -17
- package/dist/web.d.ts +17 -17
- package/dist/web.js +2 -2
- package/dist/workflows.cjs +14 -14
- package/dist/workflows.d.cts +23 -26
- package/dist/workflows.d.ts +23 -26
- package/dist/workflows.js +2 -2
- package/package.json +14 -4
- package/dist/chunk-FNIYADWI.cjs +0 -59
- package/dist/chunk-YTEOFGFC.js +0 -57
package/dist/index.js
CHANGED
|
@@ -1,95 +1,10 @@
|
|
|
1
|
-
export { monitorStream } from './chunk-YTEOFGFC.js';
|
|
2
1
|
export { API_KEY_PREFIX, MATRX_HEADERS, credentialToHeaders, toCredentialsPort } from './chunk-7MZPBCFV.js';
|
|
3
|
-
import { OrganizationContextError, BackendApiError, parseHttpError, MatrxApiError, applyOrganizationContextHeader, extractMatrxErrorCode, extractMatrxErrorMessage, readMatrxNdjsonStream, readMatrxSseStream, requireOrganizationContext, StreamTransportError } from './chunk-
|
|
4
|
-
export { BackendApiError, CONTRACT_SHA256, DEPLOYMENTS, DOMAINS, MatrxApiError, OrganizationContextError, StreamTransportError, applyOrganizationContextHeader, assertOrganizationMatchesOperation, assertQueryOrganizationMatchesContext, createApi, createOrganizationOperation, describeBackendFailure, extractMatrxErrorCode, extractMatrxErrorMessage, getUserMessage, isGenericUserMessage, isStreamTransportLost, openJsonOrStream, openStream, parseCallApiError, parseHttpError, parseHttpErrorBody, parsePersistedBackendError, parseStreamError, requireOrganizationContext, unwrapUpstreamError } from './chunk-
|
|
5
|
-
import {
|
|
6
|
-
export { AbortedError, ConnectTimeoutError, HeartbeatTimeoutError, HttpError, NetError, NetworkError, OfflineError, TotalTimeoutError, extractErrorMessage, isNetError, isTransportFailure, resilientFetch, toNetError, withRetry } from './chunk-
|
|
7
|
-
import { credentialToHeaders } from '@ai-matrx/auth/credentials';
|
|
2
|
+
import { OrganizationContextError, sendOnWire, WIRE_FETCH_OPTION_KEYS, BackendApiError, parseHttpError, MatrxApiError, applyAiApiVersion, applyOrganizationContextHeader, extractMatrxErrorCode, extractMatrxErrorMessage, readMatrxNdjsonStream, readMatrxSseStream, requireOrganizationContext, MATRX_AI_API_VERSION_DEFAULT, StreamTransportError } from './chunk-6KHHHBG5.js';
|
|
3
|
+
export { BackendApiError, CONTRACT_SHA256, DEPLOYMENTS, DOMAINS, MATRX_AI_API_VERSION_DEFAULT, MatrxApiError, OrganizationContextError, StreamTransportError, V2_COVERED_AI_PATH_TEMPLATES, aiVersionPathOverrides, applyAiApiVersion, applyOrganizationContextHeader, assertOrganizationMatchesOperation, assertQueryOrganizationMatchesContext, createApi, createOrganizationOperation, describeBackendFailure, extractMatrxErrorCode, extractMatrxErrorMessage, fetchWithMatrxProtocolFallback, getUserMessage, isCoveredAiPath, isGenericUserMessage, isStreamTransportLost, isV2Path, openJsonOrStream, openStream, parseCallApiError, parseHttpError, parseHttpErrorBody, parsePersistedBackendError, parseStreamError, requireOrganizationContext, toV1FallbackUrl, toV2Path, unwrapUpstreamError } from './chunk-6KHHHBG5.js';
|
|
4
|
+
import { isNetError, extractErrorMessage } from './chunk-PIPE5OML.js';
|
|
5
|
+
export { AbortedError, ConnectTimeoutError, HeartbeatTimeoutError, HttpError, NetError, NetworkError, OfflineError, TotalTimeoutError, extractErrorMessage, isNetError, isTransportFailure, monitorStream, resilientFetch, toNetError, withRetry } from './chunk-PIPE5OML.js';
|
|
8
6
|
import { formatDurationSeconds } from '@ai-matrx/kit/format';
|
|
9
7
|
|
|
10
|
-
// src/core/protocol.ts
|
|
11
|
-
var MATRX_AI_API_VERSION_DEFAULT = "v2";
|
|
12
|
-
var V2_COVERED_AI_PATH_TEMPLATES = [
|
|
13
|
-
"/ai/manual",
|
|
14
|
-
"/ai/chat",
|
|
15
|
-
"/ai/agents/{agent_id}",
|
|
16
|
-
"/ai/agent/{agent_id}",
|
|
17
|
-
// singular alias — behaves identically
|
|
18
|
-
"/ai/conversations/{conversation_id}",
|
|
19
|
-
"/ai/conversation/{conversation_id}",
|
|
20
|
-
// singular alias
|
|
21
|
-
"/ai/prompts/{prompt_id}",
|
|
22
|
-
// saved-prompt execution
|
|
23
|
-
"/ai/mandates/{mandate_key}"
|
|
24
|
-
// THE MANDATE DOOR — `/v2` sibling exists (routers/v2.py)
|
|
25
|
-
];
|
|
26
|
-
function toV2Path(path) {
|
|
27
|
-
const withLead = path.startsWith("/") ? path : `/${path}`;
|
|
28
|
-
if (withLead.startsWith("/api/")) {
|
|
29
|
-
const rest = withLead.slice("/api".length);
|
|
30
|
-
return rest.startsWith("/v2/") ? withLead : `/api/v2${rest}`;
|
|
31
|
-
}
|
|
32
|
-
return withLead.startsWith("/v2/") ? withLead : `/v2${withLead}`;
|
|
33
|
-
}
|
|
34
|
-
var COVERED_INTERPOLATED_PATH = [
|
|
35
|
-
/^(?:\/api)?\/ai\/manual$/,
|
|
36
|
-
/^(?:\/api)?\/ai\/chat$/,
|
|
37
|
-
/^(?:\/api)?\/ai\/agents\/[^/]+$/,
|
|
38
|
-
/^(?:\/api)?\/ai\/agent\/[^/]+$/,
|
|
39
|
-
/^(?:\/api)?\/ai\/conversations\/[^/]+$/,
|
|
40
|
-
/^(?:\/api)?\/ai\/conversation\/[^/]+$/,
|
|
41
|
-
/^(?:\/api)?\/ai\/prompts\/[^/]+$/,
|
|
42
|
-
// `/warm` etc. deliberately don't match
|
|
43
|
-
/^(?:\/api)?\/ai\/mandates\/[^/]+$/
|
|
44
|
-
// the mandate door
|
|
45
|
-
];
|
|
46
|
-
function isCoveredAiPath(path) {
|
|
47
|
-
return COVERED_INTERPOLATED_PATH.some((re) => re.test(path));
|
|
48
|
-
}
|
|
49
|
-
function isV2Path(pathOrUrl) {
|
|
50
|
-
return /\/v2\/ai\//.test(pathOrUrl);
|
|
51
|
-
}
|
|
52
|
-
function toV1FallbackUrl(url) {
|
|
53
|
-
return url.replace(/\/v2\/ai\//, "/ai/");
|
|
54
|
-
}
|
|
55
|
-
function applyAiApiVersion(path, version) {
|
|
56
|
-
if (version !== "v2") return path;
|
|
57
|
-
return isCoveredAiPath(path) ? toV2Path(path) : path;
|
|
58
|
-
}
|
|
59
|
-
async function fetchWithMatrxProtocolFallback(url, init, opts = {}) {
|
|
60
|
-
const { onDowngrade, ...fetchOpts } = opts;
|
|
61
|
-
const logDowngrade = (reason, status2) => {
|
|
62
|
-
console.warn(
|
|
63
|
-
`[matrx] ai_v2_downgrade \u2192 retrying on v1. v2=${url} reason=${reason}`
|
|
64
|
-
);
|
|
65
|
-
onDowngrade?.({ url, reason, ...status2 !== void 0 ? { status: status2 } : {} });
|
|
66
|
-
};
|
|
67
|
-
if (!isV2Path(url)) return resilientFetch(url, init, fetchOpts);
|
|
68
|
-
let result;
|
|
69
|
-
try {
|
|
70
|
-
result = await resilientFetch(url, init, fetchOpts);
|
|
71
|
-
} catch (err) {
|
|
72
|
-
const isAbort2 = isNetError(err) && err.code === "aborted" || err instanceof Error && err.name === "AbortError";
|
|
73
|
-
if (isAbort2) throw err;
|
|
74
|
-
logDowngrade(String(err));
|
|
75
|
-
return resilientFetch(toV1FallbackUrl(url), init, fetchOpts);
|
|
76
|
-
}
|
|
77
|
-
const status = result.response.status;
|
|
78
|
-
if (status === 404 || status === 405 || status >= 500) {
|
|
79
|
-
logDowngrade(`HTTP ${status}`, status);
|
|
80
|
-
return resilientFetch(toV1FallbackUrl(url), init, fetchOpts);
|
|
81
|
-
}
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
function aiVersionPathOverrides(version) {
|
|
85
|
-
if (version !== "v2") return {};
|
|
86
|
-
const map = {};
|
|
87
|
-
for (const template of V2_COVERED_AI_PATH_TEMPLATES) {
|
|
88
|
-
map[template] = toV2Path(template);
|
|
89
|
-
}
|
|
90
|
-
return map;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
8
|
// src/core/call.ts
|
|
94
9
|
function buildMatrxRequestUrl(baseUrl, pathTemplate, pathParams, queryParams) {
|
|
95
10
|
let resolvedPath = pathTemplate;
|
|
@@ -244,21 +159,17 @@ async function httpErrorFrom(response) {
|
|
|
244
159
|
async function executeMatrxCall(request, hooks = {}) {
|
|
245
160
|
const upper = request.method.toUpperCase();
|
|
246
161
|
const sendsBody = request.stream || upper !== "GET" && upper !== "HEAD";
|
|
247
|
-
const { response } = await
|
|
248
|
-
request.url,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
throwOnHttpError: false,
|
|
259
|
-
...hooks.onProtocolDowngrade ? { onDowngrade: hooks.onProtocolDowngrade } : {}
|
|
260
|
-
}
|
|
261
|
-
);
|
|
162
|
+
const { response } = await sendOnWire({
|
|
163
|
+
url: request.url,
|
|
164
|
+
method: request.method,
|
|
165
|
+
headers: request.headers,
|
|
166
|
+
...sendsBody ? { body: JSON.stringify(request.body) } : {},
|
|
167
|
+
...request.signal ? { signal: request.signal } : {},
|
|
168
|
+
connectTimeoutMs: request.connectTimeoutMs ?? DEFAULT_CONNECT_TIMEOUT_MS,
|
|
169
|
+
totalTimeoutMs: request.stream ? null : request.totalTimeoutMs === void 0 ? DEFAULT_JSON_TOTAL_TIMEOUT_MS : request.totalTimeoutMs,
|
|
170
|
+
...request.stream ? { stream: true } : {},
|
|
171
|
+
...hooks.onProtocolDowngrade ? { onProtocolDowngrade: hooks.onProtocolDowngrade } : {}
|
|
172
|
+
});
|
|
262
173
|
const requestId = response.headers.get("X-Request-ID");
|
|
263
174
|
const conversationId = response.headers.get("X-Conversation-ID");
|
|
264
175
|
const idFields = {
|
|
@@ -294,24 +205,34 @@ async function executeMatrxCall(request, hooks = {}) {
|
|
|
294
205
|
}
|
|
295
206
|
async function sendMatrxRequest(url, init = {}, options = {}) {
|
|
296
207
|
const callerSignal = options.signal ?? init.signal ?? void 0;
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
if (
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
let timedOut = false;
|
|
307
|
-
const timer = setTimeout(() => {
|
|
308
|
-
timedOut = true;
|
|
309
|
-
controller.abort();
|
|
310
|
-
}, options.timeoutMs);
|
|
208
|
+
const headers = {};
|
|
209
|
+
new Headers(init.headers ?? {}).forEach((value, name) => {
|
|
210
|
+
headers[name] = value;
|
|
211
|
+
});
|
|
212
|
+
const fetchOptions = {};
|
|
213
|
+
for (const key of WIRE_FETCH_OPTION_KEYS) {
|
|
214
|
+
if (init[key] !== void 0) fetchOptions[key] = init[key];
|
|
215
|
+
}
|
|
311
216
|
try {
|
|
312
|
-
|
|
217
|
+
const { response } = await sendOnWire({
|
|
218
|
+
url,
|
|
219
|
+
method: init.method ?? "GET",
|
|
220
|
+
fetchOptions,
|
|
221
|
+
headers,
|
|
222
|
+
...init.body !== void 0 && init.body !== null ? { body: init.body } : {},
|
|
223
|
+
...callerSignal ? { signal: callerSignal } : {},
|
|
224
|
+
// No deadline unless the caller set one: the raw lane carries bytes
|
|
225
|
+
// and long reads whose length only the caller knows.
|
|
226
|
+
connectTimeoutMs: options.timeoutMs ?? 24 * 60 * 60 * 1e3,
|
|
227
|
+
totalTimeoutMs: null,
|
|
228
|
+
...options.onUploadProgress ? { onUploadProgress: options.onUploadProgress } : {}
|
|
229
|
+
});
|
|
230
|
+
return response;
|
|
313
231
|
} catch (error) {
|
|
314
|
-
if (
|
|
232
|
+
if (isNetError(error) && error.code === "aborted") {
|
|
233
|
+
throw callerSignal?.reason instanceof Error ? callerSignal.reason : new DOMException("The request was cancelled.", "AbortError");
|
|
234
|
+
}
|
|
235
|
+
if (options.timeoutMs !== void 0 && isNetError(error) && error.code === "connect-timeout") {
|
|
315
236
|
throw new BackendApiError({
|
|
316
237
|
code: "request_timeout",
|
|
317
238
|
detail: `${init.method ?? "GET"} ${url} exceeded ${options.timeoutMs}ms`,
|
|
@@ -319,10 +240,10 @@ async function sendMatrxRequest(url, init = {}, options = {}) {
|
|
|
319
240
|
status: 504
|
|
320
241
|
});
|
|
321
242
|
}
|
|
243
|
+
if (isNetError(error) && (error.code === "network" || error.code === "offline")) {
|
|
244
|
+
throw error.cause instanceof Error ? error.cause : error;
|
|
245
|
+
}
|
|
322
246
|
throw error;
|
|
323
|
-
} finally {
|
|
324
|
-
clearTimeout(timer);
|
|
325
|
-
callerSignal?.removeEventListener("abort", onCallerAbort);
|
|
326
247
|
}
|
|
327
248
|
}
|
|
328
249
|
async function readMatrxJsonResponse(response) {
|
|
@@ -330,6 +251,8 @@ async function readMatrxJsonResponse(response) {
|
|
|
330
251
|
if (response.status === 204) return null;
|
|
331
252
|
return await response.json();
|
|
332
253
|
}
|
|
254
|
+
|
|
255
|
+
// src/core/client.ts
|
|
333
256
|
function classifyStatus(status) {
|
|
334
257
|
return status >= 400 && status < 500 ? "validation_error" : "http_error";
|
|
335
258
|
}
|
|
@@ -414,6 +337,7 @@ function stripContentType(headers) {
|
|
|
414
337
|
);
|
|
415
338
|
}
|
|
416
339
|
var ORGANIZATION_HEADER = "x-organization-id";
|
|
340
|
+
var ORGANIZATION_HEADER_CANONICAL = "X-Organization-Id";
|
|
417
341
|
function readOrganizationHeader(headers) {
|
|
418
342
|
for (const [name, value] of Object.entries(headers ?? {})) {
|
|
419
343
|
if (name.toLowerCase() === ORGANIZATION_HEADER && value.trim().length > 0) {
|
|
@@ -440,7 +364,9 @@ function createMatrxTransport(options) {
|
|
|
440
364
|
totalTimeoutMs = null,
|
|
441
365
|
expectedErrorStatuses,
|
|
442
366
|
diagnostics,
|
|
443
|
-
source = "matrxTransport"
|
|
367
|
+
source = "matrxTransport",
|
|
368
|
+
refreshCredentials,
|
|
369
|
+
readyTimeoutMs
|
|
444
370
|
} = options;
|
|
445
371
|
if (baseUrl === void 0 === (resolveTarget === void 0)) {
|
|
446
372
|
throw new Error(
|
|
@@ -464,17 +390,13 @@ function createMatrxTransport(options) {
|
|
|
464
390
|
const callOrganizationId = readOrganizationHeader(init.headers);
|
|
465
391
|
const versionedPath = applyAiApiVersion(path, resolveVersion());
|
|
466
392
|
const url = `${target.baseUrl}${versionedPath}`;
|
|
467
|
-
const credentialHeaders = credentials ? credentialToHeaders(await credentials.get()) : {};
|
|
468
393
|
const policyHeaders = stripContentType(target.policyHeaders ?? {});
|
|
469
|
-
let
|
|
470
|
-
...init.headers,
|
|
471
|
-
...stripContentType(credentialHeaders),
|
|
472
|
-
...callOrganizationId === null ? policyHeaders : stripOrganizationHeader(policyHeaders)
|
|
473
|
-
};
|
|
394
|
+
let overHeaders = callOrganizationId === null ? policyHeaders : stripOrganizationHeader(policyHeaders);
|
|
474
395
|
const orgId = resolveOrganizationId(callOrganizationId);
|
|
475
396
|
if (orgId !== null) {
|
|
476
|
-
|
|
397
|
+
overHeaders = applyOrganizationContextHeader(overHeaders, orgId);
|
|
477
398
|
}
|
|
399
|
+
const wireHeaders = callOrganizationId === null ? { ...init.headers } : stripOrganizationHeader({ ...init.headers });
|
|
478
400
|
const info = {
|
|
479
401
|
url,
|
|
480
402
|
method: init.method,
|
|
@@ -485,19 +407,23 @@ function createMatrxTransport(options) {
|
|
|
485
407
|
diagnostics?.onRequest?.(info);
|
|
486
408
|
let response;
|
|
487
409
|
try {
|
|
488
|
-
({ response } = await
|
|
489
|
-
url,
|
|
410
|
+
({ response } = await sendOnWire(
|
|
490
411
|
{
|
|
412
|
+
url,
|
|
491
413
|
method: init.method,
|
|
492
|
-
headers,
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
{
|
|
414
|
+
headers: wireHeaders,
|
|
415
|
+
overHeaders: orgId === null && callOrganizationId !== null ? { ...overHeaders, [ORGANIZATION_HEADER_CANONICAL]: callOrganizationId } : overHeaders,
|
|
416
|
+
...init.body !== void 0 ? { body: init.body } : {},
|
|
496
417
|
...init.signal ? { signal: init.signal } : {},
|
|
418
|
+
...init.onUploadProgress ? { onUploadProgress: init.onUploadProgress } : {},
|
|
497
419
|
connectTimeoutMs,
|
|
498
420
|
totalTimeoutMs,
|
|
499
|
-
|
|
500
|
-
|
|
421
|
+
...diagnostics?.onProtocolDowngrade ? { onProtocolDowngrade: diagnostics.onProtocolDowngrade } : {}
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
...credentials ? { credentials } : {},
|
|
425
|
+
...refreshCredentials ? { refreshCredentials } : {},
|
|
426
|
+
...readyTimeoutMs !== void 0 ? { readyTimeoutMs } : {}
|
|
501
427
|
}
|
|
502
428
|
));
|
|
503
429
|
} catch (err) {
|
|
@@ -523,42 +449,6 @@ function createMatrxTransport(options) {
|
|
|
523
449
|
};
|
|
524
450
|
}
|
|
525
451
|
|
|
526
|
-
// src/core/api-target-log.ts
|
|
527
|
-
var SUSPECT_HOST_FRAGMENTS = ["sandbox"];
|
|
528
|
-
function looksSuspect(url) {
|
|
529
|
-
const lower = url.toLowerCase();
|
|
530
|
-
return SUSPECT_HOST_FRAGMENTS.some((frag) => lower.includes(frag));
|
|
531
|
-
}
|
|
532
|
-
function logApiTarget(url, context) {
|
|
533
|
-
const { source, method, channel, activeServer, ...extra } = context;
|
|
534
|
-
let origin = url;
|
|
535
|
-
try {
|
|
536
|
-
origin = new URL(url).origin;
|
|
537
|
-
} catch {
|
|
538
|
-
}
|
|
539
|
-
const suspect = looksSuspect(url);
|
|
540
|
-
const tag = suspect ? "\u{1F6A8} API TARGET (SANDBOX?)" : "\u{1F4E1} API TARGET";
|
|
541
|
-
const style = suspect ? "font-weight:bold;color:#fff;background:#c0392b;padding:1px 4px;border-radius:3px;" : "font-weight:bold;color:#fff;background:#16a085;padding:1px 4px;border-radius:3px;";
|
|
542
|
-
const meta = {
|
|
543
|
-
origin,
|
|
544
|
-
fullUrl: url,
|
|
545
|
-
source
|
|
546
|
-
};
|
|
547
|
-
if (method) meta.method = method;
|
|
548
|
-
if (channel) meta.channel = channel;
|
|
549
|
-
if (activeServer) meta.activeServer = activeServer;
|
|
550
|
-
for (const [k, v] of Object.entries(extra)) {
|
|
551
|
-
if (v !== void 0) meta[k] = v;
|
|
552
|
-
}
|
|
553
|
-
const log = suspect ? console.error : console.info;
|
|
554
|
-
log(
|
|
555
|
-
`%c${tag}%c ${method ? method + " " : ""}${url}`,
|
|
556
|
-
style,
|
|
557
|
-
"color:inherit;",
|
|
558
|
-
meta
|
|
559
|
-
);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
452
|
// src/core/endpoint-path.ts
|
|
563
453
|
function normalizeLeadingSlash(value) {
|
|
564
454
|
const trimmed = value.trim();
|
|
@@ -580,21 +470,6 @@ function resolveEndpointPath(canonicalPath, config) {
|
|
|
580
470
|
}
|
|
581
471
|
return canonicalPath;
|
|
582
472
|
}
|
|
583
|
-
|
|
584
|
-
// src/core/desktop-target.ts
|
|
585
|
-
var DESKTOP_NATIVE_CAPABILITY = "desktop-native";
|
|
586
|
-
function applyDesktopTargetToRequestBody(body, targetInstanceId) {
|
|
587
|
-
if (!targetInstanceId || !isRecord(body)) return;
|
|
588
|
-
const existingClient = isRecord(body.client) ? body.client : null;
|
|
589
|
-
const existingState = existingClient && isRecord(existingClient.state) ? existingClient.state : null;
|
|
590
|
-
const existingDesktopState = existingState && isRecord(existingState[DESKTOP_NATIVE_CAPABILITY]) ? existingState[DESKTOP_NATIVE_CAPABILITY] : null;
|
|
591
|
-
if (!existingClient || !existingState || !existingDesktopState) return;
|
|
592
|
-
body.target_instance_id ??= targetInstanceId;
|
|
593
|
-
existingDesktopState.target_instance_id ??= targetInstanceId;
|
|
594
|
-
}
|
|
595
|
-
function isRecord(value) {
|
|
596
|
-
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
597
|
-
}
|
|
598
473
|
var RUN_OUTPUT_KINDS = ["text", "image", "video", "audio"];
|
|
599
474
|
var RUN_WAIT_KNOB_FEATURE = "agents.run_wait";
|
|
600
475
|
var RUN_STREAM_LIFETIME_BACKSTOP_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -1093,27 +968,27 @@ async function rejoinRuntimeOperation(transport, requestId, options = {}) {
|
|
|
1093
968
|
var MATRX_RUN_IN_PROGRESS = "run_in_progress";
|
|
1094
969
|
var MATRX_RESUME_CONFLICT = "resume_conflict";
|
|
1095
970
|
var MATRX_LIVE_STREAM_UNAVAILABLE = "live_stream_unavailable";
|
|
1096
|
-
function
|
|
971
|
+
function isRecord(value) {
|
|
1097
972
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1098
973
|
}
|
|
1099
974
|
function nonBlank(value) {
|
|
1100
975
|
return typeof value === "string" && value.trim() ? value : null;
|
|
1101
976
|
}
|
|
1102
977
|
function detailCandidates(body) {
|
|
1103
|
-
if (!
|
|
978
|
+
if (!isRecord(body)) return [];
|
|
1104
979
|
const out = [];
|
|
1105
|
-
if (
|
|
1106
|
-
if (
|
|
980
|
+
if (isRecord(body.detail)) out.push(body.detail);
|
|
981
|
+
if (isRecord(body.details)) out.push(body.details);
|
|
1107
982
|
out.push(body);
|
|
1108
983
|
return out;
|
|
1109
984
|
}
|
|
1110
985
|
function statusOf(error) {
|
|
1111
|
-
if (!
|
|
986
|
+
if (!isRecord(error) && !(error instanceof Error)) return null;
|
|
1112
987
|
const status = error.status;
|
|
1113
988
|
return typeof status === "number" ? status : null;
|
|
1114
989
|
}
|
|
1115
990
|
function bodyOf(error) {
|
|
1116
|
-
if (!
|
|
991
|
+
if (!isRecord(error) && !(error instanceof Error)) return void 0;
|
|
1117
992
|
return error.serverDetail;
|
|
1118
993
|
}
|
|
1119
994
|
function readMatrxErrorCode(error) {
|
|
@@ -1174,7 +1049,7 @@ function readLiveRunRejoin(error) {
|
|
|
1174
1049
|
rejoinPath,
|
|
1175
1050
|
runId: firstString(candidates, "run_id"),
|
|
1176
1051
|
code,
|
|
1177
|
-
body:
|
|
1052
|
+
body: isRecord(root) ? root : {}
|
|
1178
1053
|
};
|
|
1179
1054
|
}
|
|
1180
1055
|
function readLiveRunRequestId(error) {
|
|
@@ -1190,8 +1065,8 @@ function runtimeOperationRejoinPath(requestId) {
|
|
|
1190
1065
|
return `/runtime/operations/${encodePathSegment(requestId)}/rejoin`;
|
|
1191
1066
|
}
|
|
1192
1067
|
function streamErrorText(eventOrPayload) {
|
|
1193
|
-
if (!
|
|
1194
|
-
const payload = typeof eventOrPayload.event === "string" &&
|
|
1068
|
+
if (!isRecord(eventOrPayload)) return null;
|
|
1069
|
+
const payload = typeof eventOrPayload.event === "string" && isRecord(eventOrPayload.data) ? eventOrPayload.data : eventOrPayload;
|
|
1195
1070
|
return nonBlank(payload.user_message) ?? nonBlank(payload.message);
|
|
1196
1071
|
}
|
|
1197
1072
|
async function openMatrxStream(transport, path, options = {}) {
|
|
@@ -1241,7 +1116,7 @@ async function followWorkflowRunEvents(transport, runId, options) {
|
|
|
1241
1116
|
} catch {
|
|
1242
1117
|
continue;
|
|
1243
1118
|
}
|
|
1244
|
-
if (!
|
|
1119
|
+
if (!isRecord(parsed)) continue;
|
|
1245
1120
|
options.onEvent(parsed, parsed.event === "node_stream" ? null : frame.seq);
|
|
1246
1121
|
}
|
|
1247
1122
|
} catch (error) {
|
|
@@ -1812,11 +1687,11 @@ var MatrxRunError = class extends Error {
|
|
|
1812
1687
|
this.partialText = args.partialText ?? "";
|
|
1813
1688
|
}
|
|
1814
1689
|
};
|
|
1815
|
-
function
|
|
1690
|
+
function isRecord2(value) {
|
|
1816
1691
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1817
1692
|
}
|
|
1818
1693
|
function stringField(value, key) {
|
|
1819
|
-
if (!
|
|
1694
|
+
if (!isRecord2(value)) return null;
|
|
1820
1695
|
const field = value[key];
|
|
1821
1696
|
return typeof field === "string" && field ? field : null;
|
|
1822
1697
|
}
|
|
@@ -1836,7 +1711,7 @@ async function runAgentToCompletion(transport, agentId, request, options = {}) {
|
|
|
1836
1711
|
continue;
|
|
1837
1712
|
}
|
|
1838
1713
|
if (envelope.event === "error" && failure === null) {
|
|
1839
|
-
const payload =
|
|
1714
|
+
const payload = isRecord2(envelope.data) ? envelope.data : null;
|
|
1840
1715
|
failure = new MatrxRunError({
|
|
1841
1716
|
message: streamErrorText(payload) ?? "The agent run failed",
|
|
1842
1717
|
errorPayload: payload,
|
|
@@ -1844,12 +1719,12 @@ async function runAgentToCompletion(transport, agentId, request, options = {}) {
|
|
|
1844
1719
|
});
|
|
1845
1720
|
continue;
|
|
1846
1721
|
}
|
|
1847
|
-
if (envelope.event !== "completion" || !
|
|
1722
|
+
if (envelope.event !== "completion" || !isRecord2(envelope.data)) continue;
|
|
1848
1723
|
if (envelope.data.operation !== "user_request") continue;
|
|
1849
1724
|
completion = envelope.data;
|
|
1850
1725
|
const status = envelope.data.status;
|
|
1851
1726
|
if ((status === "failed" || status === "cancelled") && failure === null) {
|
|
1852
|
-
const result =
|
|
1727
|
+
const result = isRecord2(envelope.data.result) ? envelope.data.result : null;
|
|
1853
1728
|
failure = new MatrxRunError({
|
|
1854
1729
|
message: stringField(result, "error") ?? stringField(result, "user_message") ?? `The agent run ${status}`,
|
|
1855
1730
|
completionStatus: status,
|
|
@@ -2374,4 +2249,4 @@ var ENDPOINTS = {
|
|
|
2374
2249
|
}
|
|
2375
2250
|
};
|
|
2376
2251
|
|
|
2377
|
-
export { ENDPOINTS,
|
|
2252
|
+
export { ENDPOINTS, MATRX_LIVE_STREAM_UNAVAILABLE, MATRX_RESUME_CONFLICT, MATRX_RUN_IN_PROGRESS, MATRX_UI_ONLY_BODY_FIELDS, MatrxRunError, RUN_OUTPUT_KINDS, RUN_STREAM_LIFETIME_BACKSTOP_MS, RUN_WAIT_KNOB_FEATURE, TERMINAL_MATRX_RUNTIME_STATUSES, WARM_PATH, bareStatusSentence, buildMatrxRequestBody, buildMatrxRequestUrl, buildQuery, buildSafeRequestLog, cancelAgentRun, continueAgentConversation, continueEphemeralConversationStart, continueStoredConversationStart, createMatrxTransport, createProviderUsageReporter, createStreamReplayCursor, createWarmup, encodePathSegment, executeMatrxCall, followRuntimeOperationEvents, followRuntimeOperationToEnd, followServerJob, followUnavailableRejoin, followWorkflowRunEvents, getRuntimeOperationStatus, getRuntimeOperationsByLink, honestTransportMessage, isBareTransportCode, isEmptyProviderUsage, isJobOutputKind, isLiveStreamUnavailable, isResumeConflict, isServerJobSettled, listConversationPendingToolCalls, listRuntimeOperationEvents, listUserPendingToolCalls, mintMatrxConversationId, newEphemeralConversationStart, newStoredConversationStart, normalizeMatrxError, openMatrxStream, parseMatrxNdjsonResponse, pickServerJobOperation, preconnectServer, providerSessionFailureBody, providerSessionUsageBody, readConversationOrganizationId, readLiveRunRejoin, readLiveRunRequestId, readLiveStreamUnavailable, readMatrxErrorCode, readMatrxErrorCodeFromMessage, readMatrxJsonResponse, readStreamCursor, redactUrlForRequestLog, rejoinRuntimeOperation, reportProviderSessionFailure, reportProviderSessionUsage, requestJson, requestStream, resetPreconnectedForTests, resolveEndpointPath, resolveRunWaitWith, resumeAgentConversation, resumeOrRejoin, runAgentToCompletion, runJobLabel, runOutputKindFromModalities, runWaitKnobKey, runWaitTimeoutMessage, runtimeOperationRejoinPath, sendMatrxRequest, serverJobRejoinHandle, settleRunPickup, shouldReportMatrxCallError, startAgentRun, startMandateRun, streamErrorText, submitAgentToolResults, toRunHandle, withRunOrganization };
|
package/dist/integrations.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunk2ZHIYXHV_cjs = require('./chunk-2ZHIYXHV.cjs');
|
|
4
|
+
require('./chunk-PKYPPATQ.cjs');
|
|
5
5
|
|
|
6
6
|
// src/generated/integrations.ts
|
|
7
7
|
var $ebayAccountDeletionChallenge = { m: "GET", p: "/ebay/account-deletion", d: "aidream", a: "guest", o: "optional", n: "integrations.ebay_account_deletion_challenge" };
|
|
@@ -3562,11 +3562,11 @@ function bingIntegrationsDisconnect(api, args, options) {
|
|
|
3562
3562
|
}
|
|
3563
3563
|
var $importNotionZip = { m: "POST", p: "/notion-import/zip", d: "aidream", a: "user", o: "required", s: "ndjson", n: "integrations.import_notion_zip" };
|
|
3564
3564
|
function importNotionZip(api, args, options) {
|
|
3565
|
-
return
|
|
3565
|
+
return chunk2ZHIYXHV_cjs.openStream(api, $importNotionZip, args, options);
|
|
3566
3566
|
}
|
|
3567
3567
|
var $importNotionConnected = { m: "POST", p: "/notion-import/connected", d: "aidream", a: "user", o: "required", s: "ndjson", n: "integrations.import_notion_connected" };
|
|
3568
3568
|
function importNotionConnected(api, args, options) {
|
|
3569
|
-
return
|
|
3569
|
+
return chunk2ZHIYXHV_cjs.openStream(api, $importNotionConnected, args, options);
|
|
3570
3570
|
}
|
|
3571
3571
|
var TABLE = {
|
|
3572
3572
|
"GET /ebay/account-deletion": $ebayAccountDeletionChallenge,
|
package/dist/integrations.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as Api, C as CallOptions, a as ApiStream, N as NdjsonEvent } from './index-
|
|
1
|
+
import { A as Api, C as CallOptions, a as ApiStream, N as NdjsonEvent } from './index-Gj30ybjE.cjs';
|
|
2
2
|
import { JsonValue, CalendarLocalRefreshResult, CalendarCreateResult, CalendarEventAttendee, StorageImportResult } from './schemas.cjs';
|
|
3
3
|
import '@ai-matrx/auth/credentials';
|
|
4
4
|
|
package/dist/integrations.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as Api, C as CallOptions, a as ApiStream, N as NdjsonEvent } from './index-
|
|
1
|
+
import { A as Api, C as CallOptions, a as ApiStream, N as NdjsonEvent } from './index-Gj30ybjE.js';
|
|
2
2
|
import { JsonValue, CalendarLocalRefreshResult, CalendarCreateResult, CalendarEventAttendee, StorageImportResult } from './schemas.js';
|
|
3
3
|
import '@ai-matrx/auth/credentials';
|
|
4
4
|
|
package/dist/integrations.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { openStream } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
import { openStream } from './chunk-6KHHHBG5.js';
|
|
2
|
+
import './chunk-PIPE5OML.js';
|
|
3
3
|
|
|
4
4
|
// src/generated/integrations.ts
|
|
5
5
|
var $ebayAccountDeletionChallenge = { m: "GET", p: "/ebay/account-deletion", d: "aidream", a: "guest", o: "optional", n: "integrations.ebay_account_deletion_challenge" };
|
package/dist/intelligence.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunk2ZHIYXHV_cjs = require('./chunk-2ZHIYXHV.cjs');
|
|
4
|
+
require('./chunk-PKYPPATQ.cjs');
|
|
5
5
|
|
|
6
6
|
// src/intelligence/keys.generated.ts
|
|
7
7
|
var MANDATE_KEYS_META = {
|
|
8
|
-
aidreamRevision: "
|
|
8
|
+
aidreamRevision: "3c4d804a528edcb76c200bffa1fa31f4f5c271e1",
|
|
9
9
|
generatorVersion: "1.0.0",
|
|
10
10
|
packageVersion: "0.59.0",
|
|
11
11
|
retireWindow: 3
|
|
@@ -125,6 +125,8 @@ var MANDATE_KEYS = {
|
|
|
125
125
|
data__row_action: "data.row_action",
|
|
126
126
|
data__table_chat: "data.table_chat",
|
|
127
127
|
desktop__cloud_chat: "desktop.cloud_chat",
|
|
128
|
+
desktop__cloud_chat_advanced: "desktop.cloud_chat_advanced",
|
|
129
|
+
desktop__cloud_chat_work: "desktop.cloud_chat_work",
|
|
128
130
|
dictionary__workspace_guide: "dictionary.workspace_guide",
|
|
129
131
|
distillation__timeline_distiller: "distillation.timeline_distiller",
|
|
130
132
|
distillation__timeline_unfolder: "distillation.timeline_unfolder",
|
|
@@ -715,7 +717,7 @@ function getAgentCalibration(api, args, options) {
|
|
|
715
717
|
}
|
|
716
718
|
var $createDecision = { m: "POST", p: "/ai/decisions", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "intelligence.create_decision" };
|
|
717
719
|
function createDecision(api, args, options) {
|
|
718
|
-
return
|
|
720
|
+
return chunk2ZHIYXHV_cjs.openStream(api, $createDecision, args, options);
|
|
719
721
|
}
|
|
720
722
|
var $readDecision = { m: "GET", p: "/ai/decisions/{execution_id}", d: "aidream", a: "guest", o: "required", n: "intelligence.read_decision" };
|
|
721
723
|
function readDecision(api, args, options) {
|
|
@@ -859,11 +861,11 @@ function triggerDrain(api, args, options) {
|
|
|
859
861
|
}
|
|
860
862
|
var $runInitial = { m: "POST", p: "/agent-iteration/run-initial", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "intelligence.run_initial" };
|
|
861
863
|
function runInitial(api, args, options) {
|
|
862
|
-
return
|
|
864
|
+
return chunk2ZHIYXHV_cjs.openStream(api, $runInitial, args, options);
|
|
863
865
|
}
|
|
864
866
|
var $runFeedback = { m: "POST", p: "/agent-iteration/feedback", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "intelligence.run_feedback" };
|
|
865
867
|
function runFeedback(api, args, options) {
|
|
866
|
-
return
|
|
868
|
+
return chunk2ZHIYXHV_cjs.openStream(api, $runFeedback, args, options);
|
|
867
869
|
}
|
|
868
870
|
var $commitChoice = { m: "POST", p: "/agent-iteration/commit-choice", d: "aidream", a: "guest", o: "required", n: "intelligence.commit_choice" };
|
|
869
871
|
function commitChoice(api, args, options) {
|
|
@@ -1019,7 +1021,7 @@ function getMandateRun(api, args, options) {
|
|
|
1019
1021
|
}
|
|
1020
1022
|
var $replayMandateRun = { m: "POST", p: "/mandates/runs/{conversation_id}/replay", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "intelligence.replay_mandate_run" };
|
|
1021
1023
|
function replayMandateRun(api, args, options) {
|
|
1022
|
-
return
|
|
1024
|
+
return chunk2ZHIYXHV_cjs.openStream(api, $replayMandateRun, args, options);
|
|
1023
1025
|
}
|
|
1024
1026
|
var $getMandateRunResult = { m: "GET", p: "/mandates/runs/{request_id}/result", d: "aidream", a: "guest", o: "optional", n: "intelligence.get_mandate_run_result" };
|
|
1025
1027
|
function getMandateRunResult(api, args, options) {
|
|
@@ -1027,7 +1029,7 @@ function getMandateRunResult(api, args, options) {
|
|
|
1027
1029
|
}
|
|
1028
1030
|
var $answerMandateRun = { m: "POST", p: "/mandates/runs/{request_id}/answer", d: "aidream", a: "guest", o: "required", s: "ndjson", n: "intelligence.answer_mandate_run" };
|
|
1029
1031
|
function answerMandateRun(api, args, options) {
|
|
1030
|
-
return
|
|
1032
|
+
return chunk2ZHIYXHV_cjs.openStream(api, $answerMandateRun, args, options);
|
|
1031
1033
|
}
|
|
1032
1034
|
var $getMandateRuns = { m: "GET", p: "/mandates/{mandate_key}/runs", d: "aidream", a: "guest", o: "optional", n: "intelligence.get_mandate_runs" };
|
|
1033
1035
|
function getMandateRuns(api, args, options) {
|