@ai-matrx/api 0.1.9 → 0.1.10
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 +5 -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-PIVTHTVR.js → chunk-FLANGLCG.js} +260 -36
- package/dist/{chunk-KIEAFMKB.js → chunk-PIPE5OML.js} +100 -46
- package/dist/{chunk-2SXAAKGV.cjs → chunk-PKYPPATQ.cjs} +100 -45
- package/dist/{chunk-PMGKZ4FT.cjs → chunk-SPASYIUH.cjs} +268 -34
- 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 +183 -288
- package/dist/index.d.cts +129 -180
- package/dist/index.d.ts +129 -180
- package/dist/index.js +76 -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 +49823 -0
- package/dist/types.d.ts +49823 -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, BackendApiError, parseHttpError, MatrxApiError, applyAiApiVersion, applyOrganizationContextHeader, extractMatrxErrorCode, extractMatrxErrorMessage, readMatrxNdjsonStream, readMatrxSseStream, requireOrganizationContext, MATRX_AI_API_VERSION_DEFAULT, StreamTransportError } from './chunk-FLANGLCG.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-FLANGLCG.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,29 @@ 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 onCallerAbort = () => controller.abort(callerSignal?.reason);
|
|
302
|
-
if (callerSignal) {
|
|
303
|
-
if (callerSignal.aborted) controller.abort(callerSignal.reason);
|
|
304
|
-
else callerSignal.addEventListener("abort", onCallerAbort, { once: true });
|
|
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
|
+
});
|
|
311
212
|
try {
|
|
312
|
-
|
|
213
|
+
const { response } = await sendOnWire({
|
|
214
|
+
url,
|
|
215
|
+
method: init.method ?? "GET",
|
|
216
|
+
headers,
|
|
217
|
+
...init.body !== void 0 && init.body !== null ? { body: init.body } : {},
|
|
218
|
+
...callerSignal ? { signal: callerSignal } : {},
|
|
219
|
+
// No deadline unless the caller set one: the raw lane carries bytes
|
|
220
|
+
// and long reads whose length only the caller knows.
|
|
221
|
+
connectTimeoutMs: options.timeoutMs ?? 24 * 60 * 60 * 1e3,
|
|
222
|
+
totalTimeoutMs: null,
|
|
223
|
+
...options.onUploadProgress ? { onUploadProgress: options.onUploadProgress } : {}
|
|
224
|
+
});
|
|
225
|
+
return response;
|
|
313
226
|
} catch (error) {
|
|
314
|
-
if (
|
|
227
|
+
if (isNetError(error) && error.code === "aborted") {
|
|
228
|
+
throw callerSignal?.reason instanceof Error ? callerSignal.reason : new DOMException("The request was cancelled.", "AbortError");
|
|
229
|
+
}
|
|
230
|
+
if (options.timeoutMs !== void 0 && isNetError(error) && error.code === "connect-timeout") {
|
|
315
231
|
throw new BackendApiError({
|
|
316
232
|
code: "request_timeout",
|
|
317
233
|
detail: `${init.method ?? "GET"} ${url} exceeded ${options.timeoutMs}ms`,
|
|
@@ -319,10 +235,10 @@ async function sendMatrxRequest(url, init = {}, options = {}) {
|
|
|
319
235
|
status: 504
|
|
320
236
|
});
|
|
321
237
|
}
|
|
238
|
+
if (isNetError(error) && (error.code === "network" || error.code === "offline")) {
|
|
239
|
+
throw error.cause instanceof Error ? error.cause : error;
|
|
240
|
+
}
|
|
322
241
|
throw error;
|
|
323
|
-
} finally {
|
|
324
|
-
clearTimeout(timer);
|
|
325
|
-
callerSignal?.removeEventListener("abort", onCallerAbort);
|
|
326
242
|
}
|
|
327
243
|
}
|
|
328
244
|
async function readMatrxJsonResponse(response) {
|
|
@@ -330,6 +246,8 @@ async function readMatrxJsonResponse(response) {
|
|
|
330
246
|
if (response.status === 204) return null;
|
|
331
247
|
return await response.json();
|
|
332
248
|
}
|
|
249
|
+
|
|
250
|
+
// src/core/client.ts
|
|
333
251
|
function classifyStatus(status) {
|
|
334
252
|
return status >= 400 && status < 500 ? "validation_error" : "http_error";
|
|
335
253
|
}
|
|
@@ -414,6 +332,7 @@ function stripContentType(headers) {
|
|
|
414
332
|
);
|
|
415
333
|
}
|
|
416
334
|
var ORGANIZATION_HEADER = "x-organization-id";
|
|
335
|
+
var ORGANIZATION_HEADER_CANONICAL = "X-Organization-Id";
|
|
417
336
|
function readOrganizationHeader(headers) {
|
|
418
337
|
for (const [name, value] of Object.entries(headers ?? {})) {
|
|
419
338
|
if (name.toLowerCase() === ORGANIZATION_HEADER && value.trim().length > 0) {
|
|
@@ -440,7 +359,9 @@ function createMatrxTransport(options) {
|
|
|
440
359
|
totalTimeoutMs = null,
|
|
441
360
|
expectedErrorStatuses,
|
|
442
361
|
diagnostics,
|
|
443
|
-
source = "matrxTransport"
|
|
362
|
+
source = "matrxTransport",
|
|
363
|
+
refreshCredentials,
|
|
364
|
+
readyTimeoutMs
|
|
444
365
|
} = options;
|
|
445
366
|
if (baseUrl === void 0 === (resolveTarget === void 0)) {
|
|
446
367
|
throw new Error(
|
|
@@ -464,17 +385,13 @@ function createMatrxTransport(options) {
|
|
|
464
385
|
const callOrganizationId = readOrganizationHeader(init.headers);
|
|
465
386
|
const versionedPath = applyAiApiVersion(path, resolveVersion());
|
|
466
387
|
const url = `${target.baseUrl}${versionedPath}`;
|
|
467
|
-
const credentialHeaders = credentials ? credentialToHeaders(await credentials.get()) : {};
|
|
468
388
|
const policyHeaders = stripContentType(target.policyHeaders ?? {});
|
|
469
|
-
let
|
|
470
|
-
...init.headers,
|
|
471
|
-
...stripContentType(credentialHeaders),
|
|
472
|
-
...callOrganizationId === null ? policyHeaders : stripOrganizationHeader(policyHeaders)
|
|
473
|
-
};
|
|
389
|
+
let overHeaders = callOrganizationId === null ? policyHeaders : stripOrganizationHeader(policyHeaders);
|
|
474
390
|
const orgId = resolveOrganizationId(callOrganizationId);
|
|
475
391
|
if (orgId !== null) {
|
|
476
|
-
|
|
392
|
+
overHeaders = applyOrganizationContextHeader(overHeaders, orgId);
|
|
477
393
|
}
|
|
394
|
+
const wireHeaders = callOrganizationId === null ? { ...init.headers } : stripOrganizationHeader({ ...init.headers });
|
|
478
395
|
const info = {
|
|
479
396
|
url,
|
|
480
397
|
method: init.method,
|
|
@@ -485,19 +402,23 @@ function createMatrxTransport(options) {
|
|
|
485
402
|
diagnostics?.onRequest?.(info);
|
|
486
403
|
let response;
|
|
487
404
|
try {
|
|
488
|
-
({ response } = await
|
|
489
|
-
url,
|
|
405
|
+
({ response } = await sendOnWire(
|
|
490
406
|
{
|
|
407
|
+
url,
|
|
491
408
|
method: init.method,
|
|
492
|
-
headers,
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
{
|
|
409
|
+
headers: wireHeaders,
|
|
410
|
+
overHeaders: orgId === null && callOrganizationId !== null ? { ...overHeaders, [ORGANIZATION_HEADER_CANONICAL]: callOrganizationId } : overHeaders,
|
|
411
|
+
...init.body !== void 0 ? { body: init.body } : {},
|
|
496
412
|
...init.signal ? { signal: init.signal } : {},
|
|
413
|
+
...init.onUploadProgress ? { onUploadProgress: init.onUploadProgress } : {},
|
|
497
414
|
connectTimeoutMs,
|
|
498
415
|
totalTimeoutMs,
|
|
499
|
-
|
|
500
|
-
|
|
416
|
+
...diagnostics?.onProtocolDowngrade ? { onProtocolDowngrade: diagnostics.onProtocolDowngrade } : {}
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
...credentials ? { credentials } : {},
|
|
420
|
+
...refreshCredentials ? { refreshCredentials } : {},
|
|
421
|
+
...readyTimeoutMs !== void 0 ? { readyTimeoutMs } : {}
|
|
501
422
|
}
|
|
502
423
|
));
|
|
503
424
|
} catch (err) {
|
|
@@ -523,42 +444,6 @@ function createMatrxTransport(options) {
|
|
|
523
444
|
};
|
|
524
445
|
}
|
|
525
446
|
|
|
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
447
|
// src/core/endpoint-path.ts
|
|
563
448
|
function normalizeLeadingSlash(value) {
|
|
564
449
|
const trimmed = value.trim();
|
|
@@ -580,21 +465,6 @@ function resolveEndpointPath(canonicalPath, config) {
|
|
|
580
465
|
}
|
|
581
466
|
return canonicalPath;
|
|
582
467
|
}
|
|
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
468
|
var RUN_OUTPUT_KINDS = ["text", "image", "video", "audio"];
|
|
599
469
|
var RUN_WAIT_KNOB_FEATURE = "agents.run_wait";
|
|
600
470
|
var RUN_STREAM_LIFETIME_BACKSTOP_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -1093,27 +963,27 @@ async function rejoinRuntimeOperation(transport, requestId, options = {}) {
|
|
|
1093
963
|
var MATRX_RUN_IN_PROGRESS = "run_in_progress";
|
|
1094
964
|
var MATRX_RESUME_CONFLICT = "resume_conflict";
|
|
1095
965
|
var MATRX_LIVE_STREAM_UNAVAILABLE = "live_stream_unavailable";
|
|
1096
|
-
function
|
|
966
|
+
function isRecord(value) {
|
|
1097
967
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1098
968
|
}
|
|
1099
969
|
function nonBlank(value) {
|
|
1100
970
|
return typeof value === "string" && value.trim() ? value : null;
|
|
1101
971
|
}
|
|
1102
972
|
function detailCandidates(body) {
|
|
1103
|
-
if (!
|
|
973
|
+
if (!isRecord(body)) return [];
|
|
1104
974
|
const out = [];
|
|
1105
|
-
if (
|
|
1106
|
-
if (
|
|
975
|
+
if (isRecord(body.detail)) out.push(body.detail);
|
|
976
|
+
if (isRecord(body.details)) out.push(body.details);
|
|
1107
977
|
out.push(body);
|
|
1108
978
|
return out;
|
|
1109
979
|
}
|
|
1110
980
|
function statusOf(error) {
|
|
1111
|
-
if (!
|
|
981
|
+
if (!isRecord(error) && !(error instanceof Error)) return null;
|
|
1112
982
|
const status = error.status;
|
|
1113
983
|
return typeof status === "number" ? status : null;
|
|
1114
984
|
}
|
|
1115
985
|
function bodyOf(error) {
|
|
1116
|
-
if (!
|
|
986
|
+
if (!isRecord(error) && !(error instanceof Error)) return void 0;
|
|
1117
987
|
return error.serverDetail;
|
|
1118
988
|
}
|
|
1119
989
|
function readMatrxErrorCode(error) {
|
|
@@ -1174,7 +1044,7 @@ function readLiveRunRejoin(error) {
|
|
|
1174
1044
|
rejoinPath,
|
|
1175
1045
|
runId: firstString(candidates, "run_id"),
|
|
1176
1046
|
code,
|
|
1177
|
-
body:
|
|
1047
|
+
body: isRecord(root) ? root : {}
|
|
1178
1048
|
};
|
|
1179
1049
|
}
|
|
1180
1050
|
function readLiveRunRequestId(error) {
|
|
@@ -1190,8 +1060,8 @@ function runtimeOperationRejoinPath(requestId) {
|
|
|
1190
1060
|
return `/runtime/operations/${encodePathSegment(requestId)}/rejoin`;
|
|
1191
1061
|
}
|
|
1192
1062
|
function streamErrorText(eventOrPayload) {
|
|
1193
|
-
if (!
|
|
1194
|
-
const payload = typeof eventOrPayload.event === "string" &&
|
|
1063
|
+
if (!isRecord(eventOrPayload)) return null;
|
|
1064
|
+
const payload = typeof eventOrPayload.event === "string" && isRecord(eventOrPayload.data) ? eventOrPayload.data : eventOrPayload;
|
|
1195
1065
|
return nonBlank(payload.user_message) ?? nonBlank(payload.message);
|
|
1196
1066
|
}
|
|
1197
1067
|
async function openMatrxStream(transport, path, options = {}) {
|
|
@@ -1241,7 +1111,7 @@ async function followWorkflowRunEvents(transport, runId, options) {
|
|
|
1241
1111
|
} catch {
|
|
1242
1112
|
continue;
|
|
1243
1113
|
}
|
|
1244
|
-
if (!
|
|
1114
|
+
if (!isRecord(parsed)) continue;
|
|
1245
1115
|
options.onEvent(parsed, parsed.event === "node_stream" ? null : frame.seq);
|
|
1246
1116
|
}
|
|
1247
1117
|
} catch (error) {
|
|
@@ -1812,11 +1682,11 @@ var MatrxRunError = class extends Error {
|
|
|
1812
1682
|
this.partialText = args.partialText ?? "";
|
|
1813
1683
|
}
|
|
1814
1684
|
};
|
|
1815
|
-
function
|
|
1685
|
+
function isRecord2(value) {
|
|
1816
1686
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1817
1687
|
}
|
|
1818
1688
|
function stringField(value, key) {
|
|
1819
|
-
if (!
|
|
1689
|
+
if (!isRecord2(value)) return null;
|
|
1820
1690
|
const field = value[key];
|
|
1821
1691
|
return typeof field === "string" && field ? field : null;
|
|
1822
1692
|
}
|
|
@@ -1836,7 +1706,7 @@ async function runAgentToCompletion(transport, agentId, request, options = {}) {
|
|
|
1836
1706
|
continue;
|
|
1837
1707
|
}
|
|
1838
1708
|
if (envelope.event === "error" && failure === null) {
|
|
1839
|
-
const payload =
|
|
1709
|
+
const payload = isRecord2(envelope.data) ? envelope.data : null;
|
|
1840
1710
|
failure = new MatrxRunError({
|
|
1841
1711
|
message: streamErrorText(payload) ?? "The agent run failed",
|
|
1842
1712
|
errorPayload: payload,
|
|
@@ -1844,12 +1714,12 @@ async function runAgentToCompletion(transport, agentId, request, options = {}) {
|
|
|
1844
1714
|
});
|
|
1845
1715
|
continue;
|
|
1846
1716
|
}
|
|
1847
|
-
if (envelope.event !== "completion" || !
|
|
1717
|
+
if (envelope.event !== "completion" || !isRecord2(envelope.data)) continue;
|
|
1848
1718
|
if (envelope.data.operation !== "user_request") continue;
|
|
1849
1719
|
completion = envelope.data;
|
|
1850
1720
|
const status = envelope.data.status;
|
|
1851
1721
|
if ((status === "failed" || status === "cancelled") && failure === null) {
|
|
1852
|
-
const result =
|
|
1722
|
+
const result = isRecord2(envelope.data.result) ? envelope.data.result : null;
|
|
1853
1723
|
failure = new MatrxRunError({
|
|
1854
1724
|
message: stringField(result, "error") ?? stringField(result, "user_message") ?? `The agent run ${status}`,
|
|
1855
1725
|
completionStatus: status,
|
|
@@ -2374,4 +2244,4 @@ var ENDPOINTS = {
|
|
|
2374
2244
|
}
|
|
2375
2245
|
};
|
|
2376
2246
|
|
|
2377
|
-
export { ENDPOINTS,
|
|
2247
|
+
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 chunkSPASYIUH_cjs = require('./chunk-SPASYIUH.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 chunkSPASYIUH_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 chunkSPASYIUH_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-FLANGLCG.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 chunkSPASYIUH_cjs = require('./chunk-SPASYIUH.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 chunkSPASYIUH_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 chunkSPASYIUH_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 chunkSPASYIUH_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 chunkSPASYIUH_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 chunkSPASYIUH_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) {
|