@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.
Files changed (54) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/content-transfer/index.cjs +12 -12
  3. package/dist/content-transfer/index.cjs.map +1 -1
  4. package/dist/content-transfer/index.d.cts +1 -1
  5. package/dist/content-transfer/index.d.ts +1 -1
  6. package/dist/content-transfer/index.js +12 -12
  7. package/dist/content-transfer/index.js.map +1 -1
  8. package/dist/content-transfer/react/index.cjs +12 -12
  9. package/dist/content-transfer/react/index.cjs.map +1 -1
  10. package/dist/content-transfer/react/index.d.cts +1 -1
  11. package/dist/content-transfer/react/index.d.ts +1 -1
  12. package/dist/content-transfer/react/index.js +12 -12
  13. package/dist/content-transfer/react/index.js.map +1 -1
  14. package/dist/generated/api-types.cjs.map +1 -1
  15. package/dist/generated/api-types.d.cts +5 -0
  16. package/dist/generated/api-types.d.ts +5 -0
  17. package/dist/index.cjs +1458 -1220
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +2 -2
  20. package/dist/index.d.ts +2 -2
  21. package/dist/index.js +1461 -1223
  22. package/dist/index.js.map +1 -1
  23. package/dist/{keys.generated-DCtN66RS.d.cts → keys.generated-DL-5LCNz.d.cts} +4 -4
  24. package/dist/{keys.generated-DCtN66RS.d.ts → keys.generated-DL-5LCNz.d.ts} +4 -4
  25. package/dist/mandates/index.cjs +2 -2
  26. package/dist/mandates/index.cjs.map +1 -1
  27. package/dist/mandates/index.d.cts +2 -2
  28. package/dist/mandates/index.d.ts +2 -2
  29. package/dist/mandates/index.js +2 -2
  30. package/dist/mandates/index.js.map +1 -1
  31. package/dist/matrx/index.cjs +1721 -1483
  32. package/dist/matrx/index.cjs.map +1 -1
  33. package/dist/matrx/index.d.cts +376 -211
  34. package/dist/matrx/index.d.ts +376 -211
  35. package/dist/matrx/index.js +1724 -1486
  36. package/dist/matrx/index.js.map +1 -1
  37. package/dist/message-parts/index.d.cts +1 -100929
  38. package/dist/message-parts/index.d.ts +1 -100929
  39. package/dist/portable/mcp.cjs +99 -11
  40. package/dist/portable/mcp.cjs.map +1 -1
  41. package/dist/portable/mcp.js +99 -11
  42. package/dist/portable/mcp.js.map +1 -1
  43. package/dist/react/index.cjs +145 -57
  44. package/dist/react/index.cjs.map +1 -1
  45. package/dist/react/index.d.cts +3 -1
  46. package/dist/react/index.d.ts +3 -1
  47. package/dist/react/index.js +145 -57
  48. package/dist/react/index.js.map +1 -1
  49. package/generated/api-types.ts +5 -0
  50. package/mandates/snapshots/keys.0.37.0.json +653 -0
  51. package/mandates/snapshots/keys.0.37.1.json +653 -0
  52. package/package.json +4 -4
  53. package/dist/{operations-BT5kKMHl.d.cts → operations-DqOe2zob.d.cts} +34 -34
  54. package/dist/{operations-BT5kKMHl.d.ts → operations-DqOe2zob.d.ts} +34 -34
@@ -1,4 +1,4 @@
1
- import { d as MatrxNdjsonIssue, e as MatrxStreamEnvelopeObservation, f as MatrxConversationStart, g as MatrxJsonValue, h as MatrxJsonObject, M as MatrxTransport, c as MatrxRuntimeExecutionStatus, b as MatrxRuntimeOperationEvent } from '../operations-BT5kKMHl.cjs';
1
+ import { d as MatrxNdjsonIssue, e as MatrxStreamEnvelopeObservation, f as MatrxConversationStart, g as MatrxJsonValue, h as MatrxJsonObject, M as MatrxTransport, c as MatrxRuntimeExecutionStatus, b as MatrxRuntimeOperationEvent } from '../operations-DqOe2zob.cjs';
2
2
 
3
3
  /**
4
4
  * The PRODUCTION `MatrxTransport` — the full connection pipeline every Matrx
@@ -60,6 +60,8 @@ interface MatrxCallError {
60
60
  name?: string;
61
61
  /** Original exception stack. */
62
62
  stack?: string;
63
+ /** JSON-safe dump of the original thrown value. */
64
+ raw?: unknown;
63
65
  }
64
66
 
65
67
  /**
@@ -1,4 +1,4 @@
1
- import { d as MatrxNdjsonIssue, e as MatrxStreamEnvelopeObservation, f as MatrxConversationStart, g as MatrxJsonValue, h as MatrxJsonObject, M as MatrxTransport, c as MatrxRuntimeExecutionStatus, b as MatrxRuntimeOperationEvent } from '../operations-BT5kKMHl.js';
1
+ import { d as MatrxNdjsonIssue, e as MatrxStreamEnvelopeObservation, f as MatrxConversationStart, g as MatrxJsonValue, h as MatrxJsonObject, M as MatrxTransport, c as MatrxRuntimeExecutionStatus, b as MatrxRuntimeOperationEvent } from '../operations-DqOe2zob.js';
2
2
 
3
3
  /**
4
4
  * The PRODUCTION `MatrxTransport` — the full connection pipeline every Matrx
@@ -60,6 +60,8 @@ interface MatrxCallError {
60
60
  name?: string;
61
61
  /** Original exception stack. */
62
62
  stack?: string;
63
+ /** JSON-safe dump of the original thrown value. */
64
+ raw?: unknown;
63
65
  }
64
66
 
65
67
  /**
@@ -269,69 +269,43 @@ function extractMatrxErrorCode(serverDetail) {
269
269
  // matrx/client.ts
270
270
  import { isNetError } from "@ai-matrx/data";
271
271
  import { credentialToHeaders } from "@ai-matrx/data";
272
+ import { extractErrorMessage } from "@ai-matrx/data/net";
272
273
 
273
- // matrx/org-context.ts
274
- import { isUuidShape } from "@ai-matrx/kit/uuid";
275
- var OrganizationContextError = class extends Error {
274
+ // matrx/backend-errors.ts
275
+ var BackendApiError = class extends Error {
276
+ /** Machine-readable error code */
276
277
  code;
277
- constructor(code, message) {
278
- super(message);
279
- this.name = "OrganizationContextError";
280
- this.code = code;
281
- }
282
- };
283
-
284
- // matrx/client.ts
285
- function classifyStatus(status) {
286
- return status >= 400 && status < 500 ? "validation_error" : "http_error";
287
- }
288
- function normalizeMatrxError(err) {
289
- if (err instanceof MatrxApiError) {
290
- return {
291
- type: classifyStatus(err.status),
292
- message: err.message,
293
- status: err.status,
294
- serverDetail: err.serverDetail,
295
- ...err.code ? { code: err.code } : {},
296
- name: err.name
297
- };
278
+ /** Developer-facing detail */
279
+ detail;
280
+ /** Safe to display directly in the UI */
281
+ userMessage;
282
+ /** Extra info (validation errors, etc.) */
283
+ details;
284
+ /** Unique request ID for support/debugging */
285
+ requestId;
286
+ /** HTTP status code (if from an HTTP response) */
287
+ status;
288
+ constructor(data) {
289
+ super(data.userMessage);
290
+ this.name = "BackendApiError";
291
+ this.code = data.code;
292
+ this.detail = data.detail;
293
+ this.userMessage = data.userMessage;
294
+ this.details = data.details ?? null;
295
+ this.requestId = data.requestId ?? "";
296
+ this.status = data.status ?? null;
298
297
  }
299
- if (err instanceof OrganizationContextError) {
298
+ /** Convert to the wire format for logging */
299
+ toJSON() {
300
300
  return {
301
- type: "validation_error",
302
- message: err.message,
303
- code: err.code,
304
- name: err.name,
305
- ...err.stack !== void 0 ? { stack: err.stack } : {}
301
+ error: this.code,
302
+ message: this.detail,
303
+ user_message: this.userMessage,
304
+ details: this.details,
305
+ request_id: this.requestId
306
306
  };
307
307
  }
308
- if (err instanceof DOMException && err.name === "AbortError") {
309
- return { type: "abort_error", message: "Request was cancelled." };
310
- }
311
- if (isNetError(err)) {
312
- if (err.code === "aborted") {
313
- return { type: "abort_error", message: err.message };
314
- }
315
- if (err.code === "http") {
316
- const status = err.status ?? 0;
317
- return { type: classifyStatus(status), message: err.message, status };
318
- }
319
- return { type: "network_error", message: err.message };
320
- }
321
- if (err instanceof Error) {
322
- const httpMatch = err.message.match(/HTTP (\d+):\s*(.*)/);
323
- if (httpMatch) {
324
- const status = parseInt(httpMatch[1], 10);
325
- return {
326
- type: classifyStatus(status),
327
- message: httpMatch[2] ?? err.message,
328
- status
329
- };
330
- }
331
- return { type: "network_error", message: err.message };
332
- }
333
- return { type: "unknown", message: String(err ?? "Unknown error") };
334
- }
308
+ };
335
309
 
336
310
  // stream/ndjson.ts
337
311
  var DEFAULT_MATRX_NDJSON_READ_AHEAD = 64;
@@ -553,6 +527,120 @@ async function* readMatrxNdjsonStream(body, options = {}) {
553
527
  }
554
528
  }
555
529
 
530
+ // matrx/org-context.ts
531
+ import { isUuidShape } from "@ai-matrx/kit/uuid";
532
+ var OrganizationContextError = class extends Error {
533
+ code;
534
+ constructor(code, message) {
535
+ super(message);
536
+ this.name = "OrganizationContextError";
537
+ this.code = code;
538
+ }
539
+ };
540
+
541
+ // matrx/call.ts
542
+ var BARE_TRANSPORT_CODE = /^\s*(?:HTTP|HTTP\s*Error|Status(?:\s*Code)?)?\s*[:\-]?\s*\d{3}\s*[.:!]?\s*$/i;
543
+ function isBareTransportCode(text) {
544
+ if (!text) return false;
545
+ return BARE_TRANSPORT_CODE.test(text);
546
+ }
547
+ function bareStatusSentence(status) {
548
+ if (status === 401 || status === 403) {
549
+ 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.";
550
+ }
551
+ if (status === 404) {
552
+ 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.";
553
+ }
554
+ if (status === 429) {
555
+ return "The server is rate-limiting this request. Wait a few seconds and try again.";
556
+ }
557
+ if (status >= 500) {
558
+ 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.";
559
+ }
560
+ 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.";
561
+ }
562
+ function honestTransportMessage(raw, status) {
563
+ if (raw && !isBareTransportCode(raw)) return raw;
564
+ return bareStatusSentence(status ?? 0);
565
+ }
566
+
567
+ // matrx/client.ts
568
+ function classifyStatus(status) {
569
+ return status >= 400 && status < 500 ? "validation_error" : "http_error";
570
+ }
571
+ function normalizeMatrxError(err) {
572
+ if (err instanceof OrganizationContextError) {
573
+ return {
574
+ type: "validation_error",
575
+ message: err.message,
576
+ code: err.code,
577
+ name: err.name,
578
+ ...err.stack !== void 0 ? { stack: err.stack } : {}
579
+ };
580
+ }
581
+ if (err instanceof DOMException && err.name === "AbortError") {
582
+ return { type: "abort_error", message: "Request was cancelled." };
583
+ }
584
+ if (err instanceof MatrxApiError) {
585
+ return {
586
+ type: classifyStatus(err.status),
587
+ message: honestTransportMessage(err.message, err.status),
588
+ status: err.status,
589
+ serverDetail: err.serverDetail,
590
+ ...err.code ? { code: err.code } : {},
591
+ name: err.name
592
+ };
593
+ }
594
+ if (err instanceof BackendApiError) {
595
+ return {
596
+ type: "network_error",
597
+ message: honestTransportMessage(
598
+ err.detail || err.userMessage,
599
+ err.status ?? void 0
600
+ ),
601
+ code: err.code,
602
+ name: err.name,
603
+ ...err.status !== null ? { status: err.status } : {},
604
+ ...err.details !== null ? { serverDetail: err.details } : {}
605
+ };
606
+ }
607
+ if (isNetError(err)) {
608
+ if (err.code === "aborted") {
609
+ return { type: "abort_error", message: err.message };
610
+ }
611
+ if (err.code === "http") {
612
+ const status = err.status ?? 0;
613
+ return {
614
+ type: classifyStatus(status),
615
+ message: honestTransportMessage(err.message, status),
616
+ status
617
+ };
618
+ }
619
+ return { type: "network_error", message: err.message };
620
+ }
621
+ if (err instanceof Error) {
622
+ const httpMatch = err.message.match(/HTTP (\d+):\s*(.*)/);
623
+ if (httpMatch) {
624
+ const status = parseInt(httpMatch[1], 10);
625
+ return {
626
+ type: classifyStatus(status),
627
+ message: honestTransportMessage(httpMatch[2] ?? err.message, status),
628
+ status
629
+ };
630
+ }
631
+ if (isBareTransportCode(err.message)) {
632
+ const status = Number.parseInt(err.message.replace(/\D+/g, ""), 10);
633
+ return {
634
+ type: classifyStatus(status),
635
+ message: bareStatusSentence(status),
636
+ status
637
+ };
638
+ }
639
+ return { type: "network_error", message: err.message };
640
+ }
641
+ return { type: "unknown", message: extractErrorMessage(err) };
642
+ }
643
+
556
644
  // matrx/internal.ts
557
645
  function encodePathSegment(value) {
558
646
  return encodeURIComponent(value);