@brokr/sdk 2.1.0 → 2.1.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 (58) hide show
  1. package/dist/feature.js +22 -2
  2. package/dist/feature.mjs +22 -2
  3. package/dist/index.js +22 -2
  4. package/dist/index.mjs +22 -2
  5. package/dist/next.js +22 -2
  6. package/dist/next.mjs +22 -2
  7. package/dist/react-styles.js +273 -94
  8. package/dist/react-styles.mjs +273 -94
  9. package/dist/react.js +329 -81
  10. package/dist/react.mjs +335 -87
  11. package/dist/runtime.js +22 -2
  12. package/dist/runtime.mjs +22 -2
  13. package/dist/src/chat/config.d.ts +2 -0
  14. package/dist/src/chat/config.d.ts.map +1 -1
  15. package/dist/src/gateway.d.ts.map +1 -1
  16. package/dist/src/models.d.ts +2 -0
  17. package/dist/src/models.d.ts.map +1 -1
  18. package/dist/src/react/chat/AIChat.d.ts.map +1 -1
  19. package/dist/src/react/chat/ChatContext.d.ts +3 -6
  20. package/dist/src/react/chat/ChatContext.d.ts.map +1 -1
  21. package/dist/src/react/chat/MarkdownRenderer.d.ts.map +1 -1
  22. package/dist/src/react/chat/ModelSelector.d.ts +1 -1
  23. package/dist/src/react/chat/ModelSelector.d.ts.map +1 -1
  24. package/dist/src/react/chat/ThreadSidebar.d.ts.map +1 -1
  25. package/dist/src/react/chat/memory.d.ts +12 -0
  26. package/dist/src/react/chat/memory.d.ts.map +1 -0
  27. package/dist/src/react/chat/types.d.ts +6 -0
  28. package/dist/src/react/chat/types.d.ts.map +1 -1
  29. package/dist/src/react/chat/useChat.d.ts +8 -6
  30. package/dist/src/react/chat/useChat.d.ts.map +1 -1
  31. package/dist/src/react/composites/FabAI.d.ts +6 -1
  32. package/dist/src/react/composites/FabAI.d.ts.map +1 -1
  33. package/dist/src/react/composites/fab-context.d.ts +26 -0
  34. package/dist/src/react/composites/fab-context.d.ts.map +1 -0
  35. package/dist/src/react/css/account.d.ts +1 -1
  36. package/dist/src/react/css/account.d.ts.map +1 -1
  37. package/dist/src/react/css/auth.d.ts +1 -1
  38. package/dist/src/react/css/auth.d.ts.map +1 -1
  39. package/dist/src/react/css/chat-extras.d.ts +1 -1
  40. package/dist/src/react/css/chat-extras.d.ts.map +1 -1
  41. package/dist/src/react/css/chat.d.ts +1 -1
  42. package/dist/src/react/css/chat.d.ts.map +1 -1
  43. package/dist/src/react/css/composites.d.ts +1 -1
  44. package/dist/src/react/css/composites.d.ts.map +1 -1
  45. package/dist/src/react/css/gates.d.ts +1 -1
  46. package/dist/src/react/css/gates.d.ts.map +1 -1
  47. package/dist/src/react/css/markdown.d.ts +1 -1
  48. package/dist/src/react/css/markdown.d.ts.map +1 -1
  49. package/dist/src/react/css/primitives.d.ts +1 -1
  50. package/dist/src/react/css/primitives.d.ts.map +1 -1
  51. package/dist/src/react/css/reset.d.ts +1 -1
  52. package/dist/src/react/css/reset.d.ts.map +1 -1
  53. package/dist/src/react/css/responsive.d.ts +1 -1
  54. package/dist/src/react/css/responsive.d.ts.map +1 -1
  55. package/dist/src/react/css/skeleton.d.ts +1 -1
  56. package/dist/src/react/css/skeleton.d.ts.map +1 -1
  57. package/dist/tsconfig.tsbuildinfo +1 -1
  58. package/package.json +1 -1
package/dist/feature.js CHANGED
@@ -700,9 +700,29 @@ async function gatewayStream(gatewayUrl, token, path, body, capability) {
700
700
  if (res.status === 401) {
701
701
  throw new BrokrAuthError("Invalid or expired BROKR_TOKEN.", "BROKR_TOKEN_INVALID");
702
702
  }
703
- if (!res.ok || !res.body) {
703
+ if (!res.ok) {
704
+ const body2 = await res.json().catch(() => ({}));
705
+ const errObj = typeof body2.error === "object" && body2.error !== null ? body2.error : void 0;
706
+ const errorData = body2.data ?? errObj?.data ?? body2;
707
+ const errorCode = errorData.errorCode ?? body2.code;
708
+ const hint = errorData.hint;
709
+ const requestId = errorData.requestId ?? res.headers.get("x-request-id");
710
+ const retryable = body2.retryable ?? errorData.retryable;
711
+ const errorStr = typeof body2.error === "string" ? body2.error : void 0;
712
+ const message = body2.message ?? errObj?.message ?? errorStr ?? `${capability} stream failed (HTTP ${res.status})`;
713
+ throw new BrokrError(
714
+ message,
715
+ errorCode ?? `${capability.toUpperCase()}_STREAM_FAILED`,
716
+ capability,
717
+ retryable ?? false,
718
+ errorCode ?? void 0,
719
+ requestId ?? void 0,
720
+ hint ?? void 0
721
+ );
722
+ }
723
+ if (!res.body) {
704
724
  throw new BrokrError(
705
- `${capability} stream failed (HTTP ${res.status})`,
725
+ `${capability} stream failed (empty body)`,
706
726
  `${capability.toUpperCase()}_STREAM_FAILED`,
707
727
  capability
708
728
  );
package/dist/feature.mjs CHANGED
@@ -675,9 +675,29 @@ async function gatewayStream(gatewayUrl, token, path, body, capability) {
675
675
  if (res.status === 401) {
676
676
  throw new BrokrAuthError("Invalid or expired BROKR_TOKEN.", "BROKR_TOKEN_INVALID");
677
677
  }
678
- if (!res.ok || !res.body) {
678
+ if (!res.ok) {
679
+ const body2 = await res.json().catch(() => ({}));
680
+ const errObj = typeof body2.error === "object" && body2.error !== null ? body2.error : void 0;
681
+ const errorData = body2.data ?? errObj?.data ?? body2;
682
+ const errorCode = errorData.errorCode ?? body2.code;
683
+ const hint = errorData.hint;
684
+ const requestId = errorData.requestId ?? res.headers.get("x-request-id");
685
+ const retryable = body2.retryable ?? errorData.retryable;
686
+ const errorStr = typeof body2.error === "string" ? body2.error : void 0;
687
+ const message = body2.message ?? errObj?.message ?? errorStr ?? `${capability} stream failed (HTTP ${res.status})`;
688
+ throw new BrokrError(
689
+ message,
690
+ errorCode ?? `${capability.toUpperCase()}_STREAM_FAILED`,
691
+ capability,
692
+ retryable ?? false,
693
+ errorCode ?? void 0,
694
+ requestId ?? void 0,
695
+ hint ?? void 0
696
+ );
697
+ }
698
+ if (!res.body) {
679
699
  throw new BrokrError(
680
- `${capability} stream failed (HTTP ${res.status})`,
700
+ `${capability} stream failed (empty body)`,
681
701
  `${capability.toUpperCase()}_STREAM_FAILED`,
682
702
  capability
683
703
  );
package/dist/index.js CHANGED
@@ -1533,9 +1533,29 @@ async function gatewayStream(gatewayUrl, token, path, body, capability) {
1533
1533
  if (res.status === 401) {
1534
1534
  throw new BrokrAuthError("Invalid or expired BROKR_TOKEN.", "BROKR_TOKEN_INVALID");
1535
1535
  }
1536
- if (!res.ok || !res.body) {
1536
+ if (!res.ok) {
1537
+ const body2 = await res.json().catch(() => ({}));
1538
+ const errObj = typeof body2.error === "object" && body2.error !== null ? body2.error : void 0;
1539
+ const errorData = body2.data ?? errObj?.data ?? body2;
1540
+ const errorCode = errorData.errorCode ?? body2.code;
1541
+ const hint = errorData.hint;
1542
+ const requestId = errorData.requestId ?? res.headers.get("x-request-id");
1543
+ const retryable = body2.retryable ?? errorData.retryable;
1544
+ const errorStr = typeof body2.error === "string" ? body2.error : void 0;
1545
+ const message = body2.message ?? errObj?.message ?? errorStr ?? `${capability} stream failed (HTTP ${res.status})`;
1546
+ throw new BrokrError(
1547
+ message,
1548
+ errorCode ?? `${capability.toUpperCase()}_STREAM_FAILED`,
1549
+ capability,
1550
+ retryable ?? false,
1551
+ errorCode ?? void 0,
1552
+ requestId ?? void 0,
1553
+ hint ?? void 0
1554
+ );
1555
+ }
1556
+ if (!res.body) {
1537
1557
  throw new BrokrError(
1538
- `${capability} stream failed (HTTP ${res.status})`,
1558
+ `${capability} stream failed (empty body)`,
1539
1559
  `${capability.toUpperCase()}_STREAM_FAILED`,
1540
1560
  capability
1541
1561
  );
package/dist/index.mjs CHANGED
@@ -1501,9 +1501,29 @@ async function gatewayStream(gatewayUrl, token, path, body, capability) {
1501
1501
  if (res.status === 401) {
1502
1502
  throw new BrokrAuthError("Invalid or expired BROKR_TOKEN.", "BROKR_TOKEN_INVALID");
1503
1503
  }
1504
- if (!res.ok || !res.body) {
1504
+ if (!res.ok) {
1505
+ const body2 = await res.json().catch(() => ({}));
1506
+ const errObj = typeof body2.error === "object" && body2.error !== null ? body2.error : void 0;
1507
+ const errorData = body2.data ?? errObj?.data ?? body2;
1508
+ const errorCode = errorData.errorCode ?? body2.code;
1509
+ const hint = errorData.hint;
1510
+ const requestId = errorData.requestId ?? res.headers.get("x-request-id");
1511
+ const retryable = body2.retryable ?? errorData.retryable;
1512
+ const errorStr = typeof body2.error === "string" ? body2.error : void 0;
1513
+ const message = body2.message ?? errObj?.message ?? errorStr ?? `${capability} stream failed (HTTP ${res.status})`;
1514
+ throw new BrokrError(
1515
+ message,
1516
+ errorCode ?? `${capability.toUpperCase()}_STREAM_FAILED`,
1517
+ capability,
1518
+ retryable ?? false,
1519
+ errorCode ?? void 0,
1520
+ requestId ?? void 0,
1521
+ hint ?? void 0
1522
+ );
1523
+ }
1524
+ if (!res.body) {
1505
1525
  throw new BrokrError(
1506
- `${capability} stream failed (HTTP ${res.status})`,
1526
+ `${capability} stream failed (empty body)`,
1507
1527
  `${capability.toUpperCase()}_STREAM_FAILED`,
1508
1528
  capability
1509
1529
  );
package/dist/next.js CHANGED
@@ -1569,9 +1569,29 @@ async function gatewayStream(gatewayUrl, token, path, body, capability) {
1569
1569
  if (res.status === 401) {
1570
1570
  throw new BrokrAuthError("Invalid or expired BROKR_TOKEN.", "BROKR_TOKEN_INVALID");
1571
1571
  }
1572
- if (!res.ok || !res.body) {
1572
+ if (!res.ok) {
1573
+ const body2 = await res.json().catch(() => ({}));
1574
+ const errObj = typeof body2.error === "object" && body2.error !== null ? body2.error : void 0;
1575
+ const errorData = body2.data ?? errObj?.data ?? body2;
1576
+ const errorCode = errorData.errorCode ?? body2.code;
1577
+ const hint = errorData.hint;
1578
+ const requestId = errorData.requestId ?? res.headers.get("x-request-id");
1579
+ const retryable = body2.retryable ?? errorData.retryable;
1580
+ const errorStr = typeof body2.error === "string" ? body2.error : void 0;
1581
+ const message = body2.message ?? errObj?.message ?? errorStr ?? `${capability} stream failed (HTTP ${res.status})`;
1582
+ throw new BrokrError(
1583
+ message,
1584
+ errorCode ?? `${capability.toUpperCase()}_STREAM_FAILED`,
1585
+ capability,
1586
+ retryable ?? false,
1587
+ errorCode ?? void 0,
1588
+ requestId ?? void 0,
1589
+ hint ?? void 0
1590
+ );
1591
+ }
1592
+ if (!res.body) {
1573
1593
  throw new BrokrError(
1574
- `${capability} stream failed (HTTP ${res.status})`,
1594
+ `${capability} stream failed (empty body)`,
1575
1595
  `${capability.toUpperCase()}_STREAM_FAILED`,
1576
1596
  capability
1577
1597
  );
package/dist/next.mjs CHANGED
@@ -1555,9 +1555,29 @@ async function gatewayStream(gatewayUrl, token, path, body, capability) {
1555
1555
  if (res.status === 401) {
1556
1556
  throw new BrokrAuthError("Invalid or expired BROKR_TOKEN.", "BROKR_TOKEN_INVALID");
1557
1557
  }
1558
- if (!res.ok || !res.body) {
1558
+ if (!res.ok) {
1559
+ const body2 = await res.json().catch(() => ({}));
1560
+ const errObj = typeof body2.error === "object" && body2.error !== null ? body2.error : void 0;
1561
+ const errorData = body2.data ?? errObj?.data ?? body2;
1562
+ const errorCode = errorData.errorCode ?? body2.code;
1563
+ const hint = errorData.hint;
1564
+ const requestId = errorData.requestId ?? res.headers.get("x-request-id");
1565
+ const retryable = body2.retryable ?? errorData.retryable;
1566
+ const errorStr = typeof body2.error === "string" ? body2.error : void 0;
1567
+ const message = body2.message ?? errObj?.message ?? errorStr ?? `${capability} stream failed (HTTP ${res.status})`;
1568
+ throw new BrokrError(
1569
+ message,
1570
+ errorCode ?? `${capability.toUpperCase()}_STREAM_FAILED`,
1571
+ capability,
1572
+ retryable ?? false,
1573
+ errorCode ?? void 0,
1574
+ requestId ?? void 0,
1575
+ hint ?? void 0
1576
+ );
1577
+ }
1578
+ if (!res.body) {
1559
1579
  throw new BrokrError(
1560
- `${capability} stream failed (HTTP ${res.status})`,
1580
+ `${capability} stream failed (empty body)`,
1561
1581
  `${capability.toUpperCase()}_STREAM_FAILED`,
1562
1582
  capability
1563
1583
  );