@ai-matrx/agents 0.36.0 → 0.37.1
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/dist/content-transfer/index.cjs +12 -12
- package/dist/content-transfer/index.cjs.map +1 -1
- package/dist/content-transfer/index.d.cts +1 -1
- package/dist/content-transfer/index.d.ts +1 -1
- package/dist/content-transfer/index.js +12 -12
- package/dist/content-transfer/index.js.map +1 -1
- package/dist/content-transfer/react/index.cjs +12 -12
- package/dist/content-transfer/react/index.cjs.map +1 -1
- package/dist/content-transfer/react/index.d.cts +1 -1
- package/dist/content-transfer/react/index.d.ts +1 -1
- package/dist/content-transfer/react/index.js +12 -12
- package/dist/content-transfer/react/index.js.map +1 -1
- package/dist/generated/api-types.cjs.map +1 -1
- package/dist/generated/api-types.d.cts +5 -0
- package/dist/generated/api-types.d.ts +5 -0
- package/dist/index.cjs +1458 -1220
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1461 -1223
- package/dist/index.js.map +1 -1
- package/dist/{keys.generated-DCtN66RS.d.cts → keys.generated-DL-5LCNz.d.cts} +4 -4
- package/dist/{keys.generated-DCtN66RS.d.ts → keys.generated-DL-5LCNz.d.ts} +4 -4
- package/dist/mandates/index.cjs +2 -2
- package/dist/mandates/index.cjs.map +1 -1
- package/dist/mandates/index.d.cts +2 -2
- package/dist/mandates/index.d.ts +2 -2
- package/dist/mandates/index.js +2 -2
- package/dist/mandates/index.js.map +1 -1
- package/dist/matrx/index.cjs +1721 -1483
- package/dist/matrx/index.cjs.map +1 -1
- package/dist/matrx/index.d.cts +376 -211
- package/dist/matrx/index.d.ts +376 -211
- package/dist/matrx/index.js +1724 -1486
- package/dist/matrx/index.js.map +1 -1
- package/dist/message-parts/index.d.cts +1 -100929
- package/dist/message-parts/index.d.ts +1 -100929
- package/dist/portable/mcp.cjs +99 -11
- package/dist/portable/mcp.cjs.map +1 -1
- package/dist/portable/mcp.js +99 -11
- package/dist/portable/mcp.js.map +1 -1
- package/dist/react/index.cjs +145 -57
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +3 -1
- package/dist/react/index.d.ts +3 -1
- package/dist/react/index.js +145 -57
- package/dist/react/index.js.map +1 -1
- package/generated/api-types.ts +5 -0
- package/mandates/snapshots/keys.0.37.0.json +653 -0
- package/mandates/snapshots/keys.0.37.1.json +653 -0
- package/package.json +4 -4
- package/dist/{operations-BT5kKMHl.d.cts → operations-DqOe2zob.d.cts} +34 -34
- package/dist/{operations-BT5kKMHl.d.ts → operations-DqOe2zob.d.ts} +34 -34
package/dist/react/index.cjs
CHANGED
|
@@ -295,69 +295,43 @@ function extractMatrxErrorCode(serverDetail) {
|
|
|
295
295
|
// matrx/client.ts
|
|
296
296
|
var import_data = require("@ai-matrx/data");
|
|
297
297
|
var import_data2 = require("@ai-matrx/data");
|
|
298
|
+
var import_net = require("@ai-matrx/data/net");
|
|
298
299
|
|
|
299
|
-
// matrx/
|
|
300
|
-
var
|
|
301
|
-
|
|
300
|
+
// matrx/backend-errors.ts
|
|
301
|
+
var BackendApiError = class extends Error {
|
|
302
|
+
/** Machine-readable error code */
|
|
302
303
|
code;
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
name: err.name
|
|
323
|
-
};
|
|
304
|
+
/** Developer-facing detail */
|
|
305
|
+
detail;
|
|
306
|
+
/** Safe to display directly in the UI */
|
|
307
|
+
userMessage;
|
|
308
|
+
/** Extra info (validation errors, etc.) */
|
|
309
|
+
details;
|
|
310
|
+
/** Unique request ID for support/debugging */
|
|
311
|
+
requestId;
|
|
312
|
+
/** HTTP status code (if from an HTTP response) */
|
|
313
|
+
status;
|
|
314
|
+
constructor(data) {
|
|
315
|
+
super(data.userMessage);
|
|
316
|
+
this.name = "BackendApiError";
|
|
317
|
+
this.code = data.code;
|
|
318
|
+
this.detail = data.detail;
|
|
319
|
+
this.userMessage = data.userMessage;
|
|
320
|
+
this.details = data.details ?? null;
|
|
321
|
+
this.requestId = data.requestId ?? "";
|
|
322
|
+
this.status = data.status ?? null;
|
|
324
323
|
}
|
|
325
|
-
|
|
324
|
+
/** Convert to the wire format for logging */
|
|
325
|
+
toJSON() {
|
|
326
326
|
return {
|
|
327
|
-
|
|
328
|
-
message:
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
327
|
+
error: this.code,
|
|
328
|
+
message: this.detail,
|
|
329
|
+
user_message: this.userMessage,
|
|
330
|
+
details: this.details,
|
|
331
|
+
request_id: this.requestId
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
|
-
|
|
335
|
-
return { type: "abort_error", message: "Request was cancelled." };
|
|
336
|
-
}
|
|
337
|
-
if ((0, import_data.isNetError)(err)) {
|
|
338
|
-
if (err.code === "aborted") {
|
|
339
|
-
return { type: "abort_error", message: err.message };
|
|
340
|
-
}
|
|
341
|
-
if (err.code === "http") {
|
|
342
|
-
const status = err.status ?? 0;
|
|
343
|
-
return { type: classifyStatus(status), message: err.message, status };
|
|
344
|
-
}
|
|
345
|
-
return { type: "network_error", message: err.message };
|
|
346
|
-
}
|
|
347
|
-
if (err instanceof Error) {
|
|
348
|
-
const httpMatch = err.message.match(/HTTP (\d+):\s*(.*)/);
|
|
349
|
-
if (httpMatch) {
|
|
350
|
-
const status = parseInt(httpMatch[1], 10);
|
|
351
|
-
return {
|
|
352
|
-
type: classifyStatus(status),
|
|
353
|
-
message: httpMatch[2] ?? err.message,
|
|
354
|
-
status
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
return { type: "network_error", message: err.message };
|
|
358
|
-
}
|
|
359
|
-
return { type: "unknown", message: String(err ?? "Unknown error") };
|
|
360
|
-
}
|
|
334
|
+
};
|
|
361
335
|
|
|
362
336
|
// stream/ndjson.ts
|
|
363
337
|
var DEFAULT_MATRX_NDJSON_READ_AHEAD = 64;
|
|
@@ -579,6 +553,120 @@ async function* readMatrxNdjsonStream(body, options = {}) {
|
|
|
579
553
|
}
|
|
580
554
|
}
|
|
581
555
|
|
|
556
|
+
// matrx/org-context.ts
|
|
557
|
+
var import_uuid = require("@ai-matrx/kit/uuid");
|
|
558
|
+
var OrganizationContextError = class extends Error {
|
|
559
|
+
code;
|
|
560
|
+
constructor(code, message) {
|
|
561
|
+
super(message);
|
|
562
|
+
this.name = "OrganizationContextError";
|
|
563
|
+
this.code = code;
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
// matrx/call.ts
|
|
568
|
+
var BARE_TRANSPORT_CODE = /^\s*(?:HTTP|HTTP\s*Error|Status(?:\s*Code)?)?\s*[:\-]?\s*\d{3}\s*[.:!]?\s*$/i;
|
|
569
|
+
function isBareTransportCode(text) {
|
|
570
|
+
if (!text) return false;
|
|
571
|
+
return BARE_TRANSPORT_CODE.test(text);
|
|
572
|
+
}
|
|
573
|
+
function bareStatusSentence(status) {
|
|
574
|
+
if (status === 401 || status === 403) {
|
|
575
|
+
return "The server would not let this request through \u2014 your session may have expired, or this account may not have access here. Sign in again, and if it repeats, ask an administrator.";
|
|
576
|
+
}
|
|
577
|
+
if (status === 404) {
|
|
578
|
+
return "The server has nothing at that address. Reload the page; if it repeats, report it \u2014 a client asking for something that no longer exists is a defect, not your mistake.";
|
|
579
|
+
}
|
|
580
|
+
if (status === 429) {
|
|
581
|
+
return "The server is rate-limiting this request. Wait a few seconds and try again.";
|
|
582
|
+
}
|
|
583
|
+
if (status >= 500) {
|
|
584
|
+
return "The server failed while answering this, and sent no explanation. Try again in a moment; if it repeats, report it with the request id above.";
|
|
585
|
+
}
|
|
586
|
+
return "The server refused this request and sent no reason with it \u2014 the missing reason is itself a defect worth reporting. Reload the page and try once more; if it repeats, report it with the request id above.";
|
|
587
|
+
}
|
|
588
|
+
function honestTransportMessage(raw, status) {
|
|
589
|
+
if (raw && !isBareTransportCode(raw)) return raw;
|
|
590
|
+
return bareStatusSentence(status ?? 0);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// matrx/client.ts
|
|
594
|
+
function classifyStatus(status) {
|
|
595
|
+
return status >= 400 && status < 500 ? "validation_error" : "http_error";
|
|
596
|
+
}
|
|
597
|
+
function normalizeMatrxError(err) {
|
|
598
|
+
if (err instanceof OrganizationContextError) {
|
|
599
|
+
return {
|
|
600
|
+
type: "validation_error",
|
|
601
|
+
message: err.message,
|
|
602
|
+
code: err.code,
|
|
603
|
+
name: err.name,
|
|
604
|
+
...err.stack !== void 0 ? { stack: err.stack } : {}
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
if (err instanceof DOMException && err.name === "AbortError") {
|
|
608
|
+
return { type: "abort_error", message: "Request was cancelled." };
|
|
609
|
+
}
|
|
610
|
+
if (err instanceof MatrxApiError) {
|
|
611
|
+
return {
|
|
612
|
+
type: classifyStatus(err.status),
|
|
613
|
+
message: honestTransportMessage(err.message, err.status),
|
|
614
|
+
status: err.status,
|
|
615
|
+
serverDetail: err.serverDetail,
|
|
616
|
+
...err.code ? { code: err.code } : {},
|
|
617
|
+
name: err.name
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
if (err instanceof BackendApiError) {
|
|
621
|
+
return {
|
|
622
|
+
type: "network_error",
|
|
623
|
+
message: honestTransportMessage(
|
|
624
|
+
err.detail || err.userMessage,
|
|
625
|
+
err.status ?? void 0
|
|
626
|
+
),
|
|
627
|
+
code: err.code,
|
|
628
|
+
name: err.name,
|
|
629
|
+
...err.status !== null ? { status: err.status } : {},
|
|
630
|
+
...err.details !== null ? { serverDetail: err.details } : {}
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
if ((0, import_data.isNetError)(err)) {
|
|
634
|
+
if (err.code === "aborted") {
|
|
635
|
+
return { type: "abort_error", message: err.message };
|
|
636
|
+
}
|
|
637
|
+
if (err.code === "http") {
|
|
638
|
+
const status = err.status ?? 0;
|
|
639
|
+
return {
|
|
640
|
+
type: classifyStatus(status),
|
|
641
|
+
message: honestTransportMessage(err.message, status),
|
|
642
|
+
status
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
return { type: "network_error", message: err.message };
|
|
646
|
+
}
|
|
647
|
+
if (err instanceof Error) {
|
|
648
|
+
const httpMatch = err.message.match(/HTTP (\d+):\s*(.*)/);
|
|
649
|
+
if (httpMatch) {
|
|
650
|
+
const status = parseInt(httpMatch[1], 10);
|
|
651
|
+
return {
|
|
652
|
+
type: classifyStatus(status),
|
|
653
|
+
message: honestTransportMessage(httpMatch[2] ?? err.message, status),
|
|
654
|
+
status
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
if (isBareTransportCode(err.message)) {
|
|
658
|
+
const status = Number.parseInt(err.message.replace(/\D+/g, ""), 10);
|
|
659
|
+
return {
|
|
660
|
+
type: classifyStatus(status),
|
|
661
|
+
message: bareStatusSentence(status),
|
|
662
|
+
status
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
return { type: "network_error", message: err.message };
|
|
666
|
+
}
|
|
667
|
+
return { type: "unknown", message: (0, import_net.extractErrorMessage)(err) };
|
|
668
|
+
}
|
|
669
|
+
|
|
582
670
|
// matrx/internal.ts
|
|
583
671
|
function encodePathSegment(value) {
|
|
584
672
|
return encodeURIComponent(value);
|