@puckeditor/plugin-ai 0.1.0-canary.bde85814 → 0.1.0-canary.c433e7ae

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/dist/index.css CHANGED
@@ -1423,7 +1423,7 @@ a._Avatar_meij0_1:hover ._Avatar-name_meij0_41 {
1423
1423
  }
1424
1424
 
1425
1425
  /* css-module:/home/runner/work/puck-platform/puck-platform/packages/plugin-ai/src/components/ChatBody/styles.module.css/#css-module-data */
1426
- ._Chat_dx6l4_1 {
1426
+ ._Chat_14j71_1 {
1427
1427
  --fade-size: 32px;
1428
1428
  --chat-background-color: white;
1429
1429
  display: flex;
@@ -1433,46 +1433,46 @@ a._Avatar_meij0_1:hover ._Avatar-name_meij0_41 {
1433
1433
  overflow: hidden;
1434
1434
  }
1435
1435
  @media (min-width: 638px) {
1436
- ._Chat_dx6l4_1 {
1436
+ ._Chat_14j71_1 {
1437
1437
  max-height: none;
1438
1438
  }
1439
1439
  }
1440
- ._Chat-inner_dx6l4_17 {
1440
+ ._Chat-inner_14j71_17 {
1441
1441
  background-color: var(--chat-background-color);
1442
1442
  display: flex;
1443
1443
  flex-direction: column;
1444
1444
  max-height: 100%;
1445
1445
  position: relative;
1446
1446
  }
1447
- ._Chat--hasMessages_dx6l4_25 ._Chat-inner_dx6l4_17 {
1447
+ ._Chat--hasMessages_14j71_25 ._Chat-inner_14j71_17 {
1448
1448
  padding-top: 0;
1449
1449
  }
1450
- ._Chat_dx6l4_1:not(._Chat--hasChildren_dx6l4_29) ._Chat-inner_dx6l4_17 {
1450
+ ._Chat_14j71_1:not(._Chat--hasChildren_14j71_29) ._Chat-inner_14j71_17 {
1451
1451
  height: 100%;
1452
1452
  padding-top: 0;
1453
1453
  }
1454
- ._Chat--hasMessages_dx6l4_25 ._Chat-messages_dx6l4_34 {
1454
+ ._Chat--hasMessages_14j71_25 ._Chat-messages_14j71_34 {
1455
1455
  display: flex;
1456
1456
  flex-direction: column-reverse;
1457
1457
  padding: 16px;
1458
1458
  overflow: auto;
1459
1459
  }
1460
- ._Chat-form_dx6l4_41 {
1460
+ ._Chat-form_14j71_41 {
1461
1461
  background-color: white;
1462
1462
  padding: 16px;
1463
1463
  }
1464
- ._Chat--hideInput_dx6l4_46 ._Chat-form_dx6l4_41 {
1464
+ ._Chat--hideInput_14j71_46 ._Chat-form_14j71_41 {
1465
1465
  display: none;
1466
1466
  }
1467
- ._Chat--hasMessages_dx6l4_25 ._Chat-form_dx6l4_41 {
1467
+ ._Chat--hasMessages_14j71_25 ._Chat-form_14j71_41 {
1468
1468
  border-top: 1px solid var(--puck-color-grey-09);
1469
1469
  }
1470
1470
  @media (min-width: 638px) {
1471
- ._Chat-form_dx6l4_41 {
1471
+ ._Chat-form_14j71_41 {
1472
1472
  border-top: 1px solid var(--puck-color-grey-09);
1473
1473
  }
1474
1474
  }
1475
- ._Chat-formHelper_dx6l4_60 {
1475
+ ._Chat-formHelper_14j71_60 {
1476
1476
  align-items: center;
1477
1477
  display: flex;
1478
1478
  color: var(--puck-color-grey-04);
@@ -1481,11 +1481,11 @@ a._Avatar_meij0_1:hover ._Avatar-name_meij0_41 {
1481
1481
  gap: 8px;
1482
1482
  padding-bottom: 12px;
1483
1483
  }
1484
- ._Chat--hasMessages_dx6l4_25 ._Chat-formHelper_dx6l4_60 {
1484
+ ._Chat--hasMessages_14j71_25 ._Chat-formHelper_14j71_60 {
1485
1485
  opacity: 0;
1486
1486
  transition: opacity 250ms ease-in;
1487
1487
  }
1488
- ._Chat-examplePrompts_dx6l4_75 {
1488
+ ._Chat-examplePrompts_14j71_75 {
1489
1489
  align-items: center;
1490
1490
  display: flex;
1491
1491
  flex-wrap: nowrap;
@@ -1494,7 +1494,7 @@ a._Avatar_meij0_1:hover ._Avatar-name_meij0_41 {
1494
1494
  width: 100%;
1495
1495
  overflow-x: auto;
1496
1496
  }
1497
- ._Chat-examplePrompt_dx6l4_75 {
1497
+ ._Chat-examplePrompt_14j71_75 {
1498
1498
  align-items: center;
1499
1499
  background: white;
1500
1500
  border: 1px solid var(--puck-color-grey-09);
@@ -1505,33 +1505,33 @@ a._Avatar_meij0_1:hover ._Avatar-name_meij0_41 {
1505
1505
  padding: 6px 12px;
1506
1506
  text-wrap: nowrap;
1507
1507
  }
1508
- ._Chat-examplePrompt_dx6l4_75:hover {
1508
+ ._Chat-examplePrompt_14j71_75:hover {
1509
1509
  background: var(--puck-color-azure-11);
1510
1510
  border-color: var(--puck-color-azure-08);
1511
1511
  color: var(--puck-color-azure-04);
1512
1512
  }
1513
- ._Chat-examplePromptArrow_dx6l4_103 {
1513
+ ._Chat-examplePromptArrow_14j71_103 {
1514
1514
  margin-left: auto;
1515
1515
  }
1516
- ._Chat-default_dx6l4_107 {
1516
+ ._Chat-default_14j71_107 {
1517
1517
  overflow-y: auto;
1518
1518
  flex-grow: 1;
1519
1519
  }
1520
- ._Chat--hasMessages_dx6l4_25 ._Chat-default_dx6l4_107 {
1520
+ ._Chat--hasMessages_14j71_25 ._Chat-default_14j71_107 {
1521
1521
  opacity: 0;
1522
1522
  padding: 0;
1523
1523
  pointer-events: none;
1524
1524
  transition: opacity 250ms ease-in;
1525
1525
  }
1526
- ._Chat--hasMessages_dx6l4_25 {
1526
+ ._Chat--hasMessages_14j71_25 {
1527
1527
  background-color: white;
1528
1528
  transition: background-color 250ms ease-in;
1529
1529
  }
1530
- ._ChatMessage_dx6l4_124 {
1530
+ ._ChatMessage_14j71_124 {
1531
1531
  font-size: var(--puck-font-size-xs);
1532
1532
  line-height: var(--line-height-s);
1533
1533
  }
1534
- ._ChatMessage--userRole_dx6l4_129 ._ChatMessage-text_dx6l4_129 {
1534
+ ._ChatMessage--userRole_14j71_129 ._ChatMessage-text_14j71_129 {
1535
1535
  background: var(--puck-color-azure-10);
1536
1536
  border-radius: 16px;
1537
1537
  color: var(--puck-color-grey-03);
@@ -1540,64 +1540,64 @@ a._Avatar_meij0_1:hover ._Avatar-name_meij0_41 {
1540
1540
  margin-top: 8px;
1541
1541
  padding: 12px 16px;
1542
1542
  }
1543
- ._ChatMessage_dx6l4_124 ul,
1544
- ._ChatMessage_dx6l4_124 ol {
1543
+ ._ChatMessage_14j71_124 ul,
1544
+ ._ChatMessage_14j71_124 ol {
1545
1545
  list-style: decimal;
1546
1546
  margin: 0;
1547
1547
  margin-bottom: 12px;
1548
1548
  margin-top: 12px;
1549
1549
  padding-left: 32px;
1550
1550
  }
1551
- ._ChatMessage_dx6l4_124 li {
1551
+ ._ChatMessage_14j71_124 li {
1552
1552
  margin-bottom: 8px;
1553
1553
  margin-top: 8px;
1554
1554
  padding-left: 8px;
1555
1555
  }
1556
- ._ChatMessage_dx6l4_124 h1,
1557
- ._ChatMessage_dx6l4_124 h2,
1558
- ._ChatMessage_dx6l4_124 h3,
1559
- ._ChatMessage_dx6l4_124 h4,
1560
- ._ChatMessage_dx6l4_124 h5,
1561
- ._ChatMessage_dx6l4_124 h6 {
1556
+ ._ChatMessage_14j71_124 h1,
1557
+ ._ChatMessage_14j71_124 h2,
1558
+ ._ChatMessage_14j71_124 h3,
1559
+ ._ChatMessage_14j71_124 h4,
1560
+ ._ChatMessage_14j71_124 h5,
1561
+ ._ChatMessage_14j71_124 h6 {
1562
1562
  font-weight: 600;
1563
1563
  }
1564
- ._ChatMessage_dx6l4_124 h1 {
1564
+ ._ChatMessage_14j71_124 h1 {
1565
1565
  font-size: var(--puck-font-l);
1566
1566
  }
1567
- ._ChatMessage_dx6l4_124 h2 {
1567
+ ._ChatMessage_14j71_124 h2 {
1568
1568
  font-size: var(--puck-font-m);
1569
1569
  }
1570
- ._ChatMessage_dx6l4_124 h3 {
1570
+ ._ChatMessage_14j71_124 h3 {
1571
1571
  font-size: var(--puck-font-m);
1572
1572
  }
1573
- ._ChatMessage_dx6l4_124 h4 {
1573
+ ._ChatMessage_14j71_124 h4 {
1574
1574
  font-size: var(--puck-font-s);
1575
1575
  }
1576
- ._ChatMessage_dx6l4_124 h5 {
1576
+ ._ChatMessage_14j71_124 h5 {
1577
1577
  font-size: var(--puck-font-xs);
1578
1578
  }
1579
- ._ChatMessage_dx6l4_124 h6 {
1579
+ ._ChatMessage_14j71_124 h6 {
1580
1580
  font-size: var(--puck-font-xm);
1581
1581
  }
1582
- ._ChatMessage_dx6l4_124 p {
1582
+ ._ChatMessage_14j71_124 p {
1583
1583
  margin-bottom: 8px;
1584
1584
  margin-top: 8px;
1585
1585
  }
1586
- ._ChatMessage_dx6l4_124 a {
1586
+ ._ChatMessage_14j71_124 a {
1587
1587
  color: var(--puck-color-azure-04);
1588
1588
  font-weight: 600;
1589
1589
  text-decoration: none;
1590
1590
  }
1591
- ._ChatMessage_dx6l4_124 a:hover {
1591
+ ._ChatMessage_14j71_124 a:hover {
1592
1592
  color: var(--puck-color-azure-05);
1593
1593
  }
1594
- ._ChatMessage_dx6l4_124 hr {
1594
+ ._ChatMessage_14j71_124 hr {
1595
1595
  border-top: none;
1596
1596
  border-bottom-color: var(--puck-color-grey-09);
1597
1597
  margin-bottom: 16px;
1598
1598
  margin-top: 16px;
1599
1599
  }
1600
- ._ChatMessage_dx6l4_124 blockquote {
1600
+ ._ChatMessage_14j71_124 blockquote {
1601
1601
  margin-bottom: 8px;
1602
1602
  margin-top: 8px;
1603
1603
  margin-left: 0;
@@ -1606,7 +1606,7 @@ a._Avatar_meij0_1:hover ._Avatar-name_meij0_41 {
1606
1606
  padding-bottom: 2px;
1607
1607
  padding-top: 2px;
1608
1608
  }
1609
- ._ChatMessage-data_dx6l4_219 {
1609
+ ._ChatMessage-data_14j71_219 {
1610
1610
  background: var(--puck-color-grey-12);
1611
1611
  border: 1px solid var(--puck-color-grey-08);
1612
1612
  border-radius: 16px;
@@ -1616,18 +1616,32 @@ a._Avatar_meij0_1:hover ._Avatar-name_meij0_41 {
1616
1616
  margin-top: 12px;
1617
1617
  padding: 12px 16px;
1618
1618
  }
1619
- ._ChatMessage-dataInner_dx6l4_230 {
1619
+ ._ChatMessage-dataInner_14j71_230 {
1620
1620
  align-items: center;
1621
1621
  display: flex;
1622
1622
  gap: 8px;
1623
1623
  }
1624
- ._ChatMessage-dataIcon_dx6l4_236 {
1624
+ ._ChatMessage-dataIcon_14j71_236 {
1625
1625
  display: flex;
1626
1626
  }
1627
- ._Chat-loader_dx6l4_240 {
1627
+ ._Chat-loader_14j71_240 {
1628
1628
  padding: 16px;
1629
1629
  padding-top: 0;
1630
1630
  }
1631
+ ._Chat-error_14j71_245 {
1632
+ align-items: center;
1633
+ display: flex;
1634
+ gap: 8px;
1635
+ font-size: var(--puck-font-size-xxs);
1636
+ margin: 16px;
1637
+ margin-top: 0;
1638
+ }
1639
+ ._Chat-errorLabel_14j71_254 {
1640
+ color: var(--puck-color-red-04);
1641
+ }
1642
+ ._Chat-errorAction_14j71_258 {
1643
+ margin-left: auto;
1644
+ }
1631
1645
 
1632
1646
  /* css-module:/home/runner/work/puck-platform/puck-platform/packages/plugin-ai/src/components/PromptForm/styles.module.css/#css-module-data */
1633
1647
  ._PromptForm_136g1_1 {
package/dist/index.d.mts CHANGED
@@ -32,7 +32,9 @@ type ChatProps = {
32
32
  inputRef?: RefObject<HTMLTextAreaElement | null>;
33
33
  status?: ChatStatus;
34
34
  messages?: PuckMessage[];
35
+ error?: string;
36
+ handleRetry?: () => void;
35
37
  };
36
- declare function ChatBody({ children, examplePrompts, handleSubmit, hideInput, inputRef, messages, status, }: ChatProps): react_jsx_runtime.JSX.Element;
38
+ declare function ChatBody({ children, examplePrompts, handleSubmit, hideInput, inputRef, messages, status, error, handleRetry, }: ChatProps): react_jsx_runtime.JSX.Element;
37
39
 
38
40
  export { ChatBody, createAIPlugin as default };
package/dist/index.d.ts CHANGED
@@ -32,7 +32,9 @@ type ChatProps = {
32
32
  inputRef?: RefObject<HTMLTextAreaElement | null>;
33
33
  status?: ChatStatus;
34
34
  messages?: PuckMessage[];
35
+ error?: string;
36
+ handleRetry?: () => void;
35
37
  };
36
- declare function ChatBody({ children, examplePrompts, handleSubmit, hideInput, inputRef, messages, status, }: ChatProps): react_jsx_runtime.JSX.Element;
38
+ declare function ChatBody({ children, examplePrompts, handleSubmit, hideInput, inputRef, messages, status, error, handleRetry, }: ChatProps): react_jsx_runtime.JSX.Element;
37
39
 
38
40
  export { ChatBody, createAIPlugin as default };
package/dist/index.js CHANGED
@@ -262,6 +262,13 @@ var Bot = createLucideIcon("Bot", [
262
262
  init_react_import();
263
263
  var Check = createLucideIcon("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
264
264
 
265
+ // ../../node_modules/.pnpm/lucide-react@0.452.0_react@19.1.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.js
266
+ init_react_import();
267
+ var RotateCcw = createLucideIcon("RotateCcw", [
268
+ ["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
269
+ ["path", { d: "M3 3v5h5", key: "1xhq8a" }]
270
+ ]);
271
+
265
272
  // src/components/Chat/index.tsx
266
273
  init_react_import();
267
274
  var import_react20 = require("@ai-sdk/react");
@@ -606,6 +613,57 @@ var IconButton_module_default = { "IconButton": "_IconButton_thegm_1", "IconButt
606
613
  // ../platform-client/components/IconButton/IconButton.tsx
607
614
  var import_jsx_runtime13 = require("react/jsx-runtime");
608
615
  var getClassName10 = get_class_name_factory_default("IconButton", IconButton_module_default);
616
+ var IconButton = ({
617
+ children,
618
+ href,
619
+ onClick,
620
+ variant = "primary",
621
+ type,
622
+ disabled,
623
+ tabIndex,
624
+ newTab,
625
+ fullWidth,
626
+ title,
627
+ dark
628
+ }) => {
629
+ const [loading, setLoading] = (0, import_react9.useState)(false);
630
+ const ElementType = href ? "a" : onClick ? "button" : "div";
631
+ const el = /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
632
+ ElementType,
633
+ {
634
+ className: getClassName10({
635
+ primary: variant === "primary",
636
+ secondary: variant === "secondary",
637
+ disabled,
638
+ fullWidth,
639
+ dark
640
+ }),
641
+ onClick: (e) => {
642
+ if (!onClick) return;
643
+ setLoading(true);
644
+ Promise.resolve(onClick(e)).then(() => {
645
+ setLoading(false);
646
+ });
647
+ },
648
+ type,
649
+ disabled: disabled || loading,
650
+ tabIndex,
651
+ target: newTab ? "_blank" : void 0,
652
+ rel: newTab ? "noreferrer" : void 0,
653
+ href,
654
+ title,
655
+ children: [
656
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: getClassName10("title"), children: title }),
657
+ children,
658
+ loading && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
659
+ "\xA0\xA0",
660
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Loader, { size: 14 })
661
+ ] })
662
+ ]
663
+ }
664
+ );
665
+ return el;
666
+ };
609
667
 
610
668
  // ../platform-client/components/InfoBar/index.tsx
611
669
  init_react_import();
@@ -936,7 +994,7 @@ var import_react_markdown = __toESM(require("react-markdown"));
936
994
 
937
995
  // css-module:/home/runner/work/puck-platform/puck-platform/packages/plugin-ai/src/components/ChatBody/styles.module.css#css-module
938
996
  init_react_import();
939
- var styles_module_default4 = { "Chat": "_Chat_dx6l4_1", "Chat-inner": "_Chat-inner_dx6l4_17", "Chat--hasMessages": "_Chat--hasMessages_dx6l4_25", "Chat--hasChildren": "_Chat--hasChildren_dx6l4_29", "Chat-messages": "_Chat-messages_dx6l4_34", "Chat-form": "_Chat-form_dx6l4_41", "Chat--hideInput": "_Chat--hideInput_dx6l4_46", "Chat-formHelper": "_Chat-formHelper_dx6l4_60", "Chat-examplePrompts": "_Chat-examplePrompts_dx6l4_75", "Chat-examplePrompt": "_Chat-examplePrompt_dx6l4_75", "Chat-examplePromptArrow": "_Chat-examplePromptArrow_dx6l4_103", "Chat-default": "_Chat-default_dx6l4_107", "ChatMessage": "_ChatMessage_dx6l4_124", "ChatMessage--userRole": "_ChatMessage--userRole_dx6l4_129", "ChatMessage-text": "_ChatMessage-text_dx6l4_129", "ChatMessage-data": "_ChatMessage-data_dx6l4_219", "ChatMessage-dataInner": "_ChatMessage-dataInner_dx6l4_230", "ChatMessage-dataIcon": "_ChatMessage-dataIcon_dx6l4_236", "Chat-loader": "_Chat-loader_dx6l4_240" };
997
+ var styles_module_default4 = { "Chat": "_Chat_14j71_1", "Chat-inner": "_Chat-inner_14j71_17", "Chat--hasMessages": "_Chat--hasMessages_14j71_25", "Chat--hasChildren": "_Chat--hasChildren_14j71_29", "Chat-messages": "_Chat-messages_14j71_34", "Chat-form": "_Chat-form_14j71_41", "Chat--hideInput": "_Chat--hideInput_14j71_46", "Chat-formHelper": "_Chat-formHelper_14j71_60", "Chat-examplePrompts": "_Chat-examplePrompts_14j71_75", "Chat-examplePrompt": "_Chat-examplePrompt_14j71_75", "Chat-examplePromptArrow": "_Chat-examplePromptArrow_14j71_103", "Chat-default": "_Chat-default_14j71_107", "ChatMessage": "_ChatMessage_14j71_124", "ChatMessage--userRole": "_ChatMessage--userRole_14j71_129", "ChatMessage-text": "_ChatMessage-text_14j71_129", "ChatMessage-data": "_ChatMessage-data_14j71_219", "ChatMessage-dataInner": "_ChatMessage-dataInner_14j71_230", "ChatMessage-dataIcon": "_ChatMessage-dataIcon_14j71_236", "Chat-loader": "_Chat-loader_14j71_240", "Chat-error": "_Chat-error_14j71_245", "Chat-errorLabel": "_Chat-errorLabel_14j71_254", "Chat-errorAction": "_Chat-errorAction_14j71_258" };
940
998
 
941
999
  // src/components/PromptForm/index.tsx
942
1000
  init_react_import();
@@ -1060,7 +1118,9 @@ function ChatBody({
1060
1118
  hideInput,
1061
1119
  inputRef,
1062
1120
  messages = [],
1063
- status
1121
+ status,
1122
+ error,
1123
+ handleRetry
1064
1124
  }) {
1065
1125
  const { scrollRef, contentRef } = (0, import_use_stick_to_bottom.useStickToBottom)();
1066
1126
  const hasMessages = messages && messages.length > 0;
@@ -1068,7 +1128,11 @@ function ChatBody({
1068
1128
  children ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: cx5("default"), children }) : null,
1069
1129
  /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: cx5("inner"), ref: scrollRef, children: [
1070
1130
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: cx5("messages"), ref: contentRef, children: messages.toReversed().map((message) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ChatMessage, { message }, message.id)) }),
1071
- status === "submitted" && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: cx5("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Loader, {}) }),
1131
+ status === "submitted" && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: cx5("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Loader, { size: 14 }) }),
1132
+ error && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: cx5("error"), children: [
1133
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: cx5("errorLabel"), children: "Something went wrong." }),
1134
+ handleRetry && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: cx5("errorAction"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(IconButton, { title: "Retry", onClick: handleRetry, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(RotateCcw, { size: "14" }) }) })
1135
+ ] }),
1072
1136
  /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: cx5("form"), children: [
1073
1137
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
1074
1138
  PromptForm,
@@ -1176,8 +1240,9 @@ function Chat({
1176
1240
  const [localChatId, setLocalChatId] = (0, import_react21.useState)(chatId);
1177
1241
  const inputRef = (0, import_react21.useRef)(null);
1178
1242
  const pluginRef = (0, import_react21.useRef)(null);
1243
+ const [error, setError] = (0, import_react21.useState)();
1179
1244
  const [toolStatus, setToolStatus] = (0, import_react21.useState)({});
1180
- const { messages, status, sendMessage } = (0, import_react20.useChat)({
1245
+ const { messages, status, sendMessage, regenerate } = (0, import_react20.useChat)({
1181
1246
  generateId: () => prefixedUlid("msg"),
1182
1247
  messages: initialMessages,
1183
1248
  transport: new import_ai.DefaultChatTransport({
@@ -1353,6 +1418,7 @@ function Chat({
1353
1418
  if (BENCHMARK) {
1354
1419
  console.timeEnd("chat");
1355
1420
  }
1421
+ setError(e.message);
1356
1422
  },
1357
1423
  onFinish: () => {
1358
1424
  puckDispatch({
@@ -1370,6 +1436,7 @@ function Chat({
1370
1436
  if (!text) {
1371
1437
  return;
1372
1438
  }
1439
+ setError("");
1373
1440
  sendMessage(
1374
1441
  {
1375
1442
  text
@@ -1405,6 +1472,11 @@ function Chat({
1405
1472
  inputRef,
1406
1473
  status,
1407
1474
  examplePrompts: examplePrompts == null ? void 0 : examplePrompts.map(({ label, href }) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ExamplePrompt, { label, href }, label)),
1475
+ error,
1476
+ handleRetry: () => {
1477
+ setError("");
1478
+ regenerate();
1479
+ },
1408
1480
  children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
1409
1481
  Placeholder,
1410
1482
  {
@@ -1504,6 +1576,7 @@ lucide-react/dist/esm/icons/arrow-right.js:
1504
1576
  lucide-react/dist/esm/icons/arrow-up.js:
1505
1577
  lucide-react/dist/esm/icons/bot.js:
1506
1578
  lucide-react/dist/esm/icons/check.js:
1579
+ lucide-react/dist/esm/icons/rotate-ccw.js:
1507
1580
  lucide-react/dist/esm/lucide-react.js:
1508
1581
  (**
1509
1582
  * @license lucide-react v0.452.0 - ISC
package/dist/index.mjs CHANGED
@@ -249,6 +249,13 @@ var Bot = createLucideIcon("Bot", [
249
249
  init_react_import();
250
250
  var Check = createLucideIcon("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
251
251
 
252
+ // ../../node_modules/.pnpm/lucide-react@0.452.0_react@19.1.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.js
253
+ init_react_import();
254
+ var RotateCcw = createLucideIcon("RotateCcw", [
255
+ ["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
256
+ ["path", { d: "M3 3v5h5", key: "1xhq8a" }]
257
+ ]);
258
+
252
259
  // src/components/Chat/index.tsx
253
260
  init_react_import();
254
261
  import { useChat } from "@ai-sdk/react";
@@ -593,6 +600,57 @@ var IconButton_module_default = { "IconButton": "_IconButton_thegm_1", "IconButt
593
600
  // ../platform-client/components/IconButton/IconButton.tsx
594
601
  import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
595
602
  var getClassName10 = get_class_name_factory_default("IconButton", IconButton_module_default);
603
+ var IconButton = ({
604
+ children,
605
+ href,
606
+ onClick,
607
+ variant = "primary",
608
+ type,
609
+ disabled,
610
+ tabIndex,
611
+ newTab,
612
+ fullWidth,
613
+ title,
614
+ dark
615
+ }) => {
616
+ const [loading, setLoading] = useState4(false);
617
+ const ElementType = href ? "a" : onClick ? "button" : "div";
618
+ const el = /* @__PURE__ */ jsxs8(
619
+ ElementType,
620
+ {
621
+ className: getClassName10({
622
+ primary: variant === "primary",
623
+ secondary: variant === "secondary",
624
+ disabled,
625
+ fullWidth,
626
+ dark
627
+ }),
628
+ onClick: (e) => {
629
+ if (!onClick) return;
630
+ setLoading(true);
631
+ Promise.resolve(onClick(e)).then(() => {
632
+ setLoading(false);
633
+ });
634
+ },
635
+ type,
636
+ disabled: disabled || loading,
637
+ tabIndex,
638
+ target: newTab ? "_blank" : void 0,
639
+ rel: newTab ? "noreferrer" : void 0,
640
+ href,
641
+ title,
642
+ children: [
643
+ /* @__PURE__ */ jsx13("span", { className: getClassName10("title"), children: title }),
644
+ children,
645
+ loading && /* @__PURE__ */ jsxs8(Fragment2, { children: [
646
+ "\xA0\xA0",
647
+ /* @__PURE__ */ jsx13(Loader, { size: 14 })
648
+ ] })
649
+ ]
650
+ }
651
+ );
652
+ return el;
653
+ };
596
654
 
597
655
  // ../platform-client/components/InfoBar/index.tsx
598
656
  init_react_import();
@@ -762,7 +820,7 @@ init_react_import();
762
820
  var PuckHeader_module_default = { "PuckHeader": "_PuckHeader_19h0f_1", "PuckHeader-left": "_PuckHeader-left_19h0f_16", "PuckHeader-center": "_PuckHeader-center_19h0f_22", "PuckHeader-right": "_PuckHeader-right_19h0f_27", "PuckHeader-pageInput": "_PuckHeader-pageInput_19h0f_34", "PuckHeader-pageInputActions": "_PuckHeader-pageInputActions_19h0f_50", "PuckHeader-input": "_PuckHeader-input_19h0f_56", "PuckHeader-historyActions": "_PuckHeader-historyActions_19h0f_69" };
763
821
 
764
822
  // ../platform-client/components/PuckHeader/PuckHeader.tsx
765
- import { IconButton, usePuck } from "@measured/puck";
823
+ import { IconButton as IconButton2, usePuck } from "@measured/puck";
766
824
 
767
825
  // ../platform-client/context/editor.tsx
768
826
  init_react_import();
@@ -923,7 +981,7 @@ import Markdown from "react-markdown";
923
981
 
924
982
  // css-module:/home/runner/work/puck-platform/puck-platform/packages/plugin-ai/src/components/ChatBody/styles.module.css#css-module
925
983
  init_react_import();
926
- var styles_module_default4 = { "Chat": "_Chat_dx6l4_1", "Chat-inner": "_Chat-inner_dx6l4_17", "Chat--hasMessages": "_Chat--hasMessages_dx6l4_25", "Chat--hasChildren": "_Chat--hasChildren_dx6l4_29", "Chat-messages": "_Chat-messages_dx6l4_34", "Chat-form": "_Chat-form_dx6l4_41", "Chat--hideInput": "_Chat--hideInput_dx6l4_46", "Chat-formHelper": "_Chat-formHelper_dx6l4_60", "Chat-examplePrompts": "_Chat-examplePrompts_dx6l4_75", "Chat-examplePrompt": "_Chat-examplePrompt_dx6l4_75", "Chat-examplePromptArrow": "_Chat-examplePromptArrow_dx6l4_103", "Chat-default": "_Chat-default_dx6l4_107", "ChatMessage": "_ChatMessage_dx6l4_124", "ChatMessage--userRole": "_ChatMessage--userRole_dx6l4_129", "ChatMessage-text": "_ChatMessage-text_dx6l4_129", "ChatMessage-data": "_ChatMessage-data_dx6l4_219", "ChatMessage-dataInner": "_ChatMessage-dataInner_dx6l4_230", "ChatMessage-dataIcon": "_ChatMessage-dataIcon_dx6l4_236", "Chat-loader": "_Chat-loader_dx6l4_240" };
984
+ var styles_module_default4 = { "Chat": "_Chat_14j71_1", "Chat-inner": "_Chat-inner_14j71_17", "Chat--hasMessages": "_Chat--hasMessages_14j71_25", "Chat--hasChildren": "_Chat--hasChildren_14j71_29", "Chat-messages": "_Chat-messages_14j71_34", "Chat-form": "_Chat-form_14j71_41", "Chat--hideInput": "_Chat--hideInput_14j71_46", "Chat-formHelper": "_Chat-formHelper_14j71_60", "Chat-examplePrompts": "_Chat-examplePrompts_14j71_75", "Chat-examplePrompt": "_Chat-examplePrompt_14j71_75", "Chat-examplePromptArrow": "_Chat-examplePromptArrow_14j71_103", "Chat-default": "_Chat-default_14j71_107", "ChatMessage": "_ChatMessage_14j71_124", "ChatMessage--userRole": "_ChatMessage--userRole_14j71_129", "ChatMessage-text": "_ChatMessage-text_14j71_129", "ChatMessage-data": "_ChatMessage-data_14j71_219", "ChatMessage-dataInner": "_ChatMessage-dataInner_14j71_230", "ChatMessage-dataIcon": "_ChatMessage-dataIcon_14j71_236", "Chat-loader": "_Chat-loader_14j71_240", "Chat-error": "_Chat-error_14j71_245", "Chat-errorLabel": "_Chat-errorLabel_14j71_254", "Chat-errorAction": "_Chat-errorAction_14j71_258" };
927
985
 
928
986
  // src/components/PromptForm/index.tsx
929
987
  init_react_import();
@@ -1051,7 +1109,9 @@ function ChatBody({
1051
1109
  hideInput,
1052
1110
  inputRef,
1053
1111
  messages = [],
1054
- status
1112
+ status,
1113
+ error,
1114
+ handleRetry
1055
1115
  }) {
1056
1116
  const { scrollRef, contentRef } = useStickToBottom();
1057
1117
  const hasMessages = messages && messages.length > 0;
@@ -1059,7 +1119,11 @@ function ChatBody({
1059
1119
  children ? /* @__PURE__ */ jsx33("div", { className: cx5("default"), children }) : null,
1060
1120
  /* @__PURE__ */ jsxs21("div", { className: cx5("inner"), ref: scrollRef, children: [
1061
1121
  /* @__PURE__ */ jsx33("div", { className: cx5("messages"), ref: contentRef, children: messages.toReversed().map((message) => /* @__PURE__ */ jsx33(ChatMessage, { message }, message.id)) }),
1062
- status === "submitted" && /* @__PURE__ */ jsx33("div", { className: cx5("loader"), children: /* @__PURE__ */ jsx33(Loader, {}) }),
1122
+ status === "submitted" && /* @__PURE__ */ jsx33("div", { className: cx5("loader"), children: /* @__PURE__ */ jsx33(Loader, { size: 14 }) }),
1123
+ error && /* @__PURE__ */ jsxs21("div", { className: cx5("error"), children: [
1124
+ /* @__PURE__ */ jsx33("div", { className: cx5("errorLabel"), children: "Something went wrong." }),
1125
+ handleRetry && /* @__PURE__ */ jsx33("div", { className: cx5("errorAction"), children: /* @__PURE__ */ jsx33(IconButton, { title: "Retry", onClick: handleRetry, children: /* @__PURE__ */ jsx33(RotateCcw, { size: "14" }) }) })
1126
+ ] }),
1063
1127
  /* @__PURE__ */ jsxs21("div", { className: cx5("form"), children: [
1064
1128
  /* @__PURE__ */ jsx33(
1065
1129
  PromptForm,
@@ -1167,8 +1231,9 @@ function Chat({
1167
1231
  const [localChatId, setLocalChatId] = useState12(chatId);
1168
1232
  const inputRef = useRef3(null);
1169
1233
  const pluginRef = useRef3(null);
1234
+ const [error, setError] = useState12();
1170
1235
  const [toolStatus, setToolStatus] = useState12({});
1171
- const { messages, status, sendMessage } = useChat({
1236
+ const { messages, status, sendMessage, regenerate } = useChat({
1172
1237
  generateId: () => prefixedUlid("msg"),
1173
1238
  messages: initialMessages,
1174
1239
  transport: new DefaultChatTransport({
@@ -1344,6 +1409,7 @@ function Chat({
1344
1409
  if (BENCHMARK) {
1345
1410
  console.timeEnd("chat");
1346
1411
  }
1412
+ setError(e.message);
1347
1413
  },
1348
1414
  onFinish: () => {
1349
1415
  puckDispatch({
@@ -1361,6 +1427,7 @@ function Chat({
1361
1427
  if (!text) {
1362
1428
  return;
1363
1429
  }
1430
+ setError("");
1364
1431
  sendMessage(
1365
1432
  {
1366
1433
  text
@@ -1396,6 +1463,11 @@ function Chat({
1396
1463
  inputRef,
1397
1464
  status,
1398
1465
  examplePrompts: examplePrompts == null ? void 0 : examplePrompts.map(({ label, href }) => /* @__PURE__ */ jsx34(ExamplePrompt, { label, href }, label)),
1466
+ error,
1467
+ handleRetry: () => {
1468
+ setError("");
1469
+ regenerate();
1470
+ },
1399
1471
  children: /* @__PURE__ */ jsx34(
1400
1472
  Placeholder,
1401
1473
  {
@@ -1495,6 +1567,7 @@ lucide-react/dist/esm/icons/arrow-right.js:
1495
1567
  lucide-react/dist/esm/icons/arrow-up.js:
1496
1568
  lucide-react/dist/esm/icons/bot.js:
1497
1569
  lucide-react/dist/esm/icons/check.js:
1570
+ lucide-react/dist/esm/icons/rotate-ccw.js:
1498
1571
  lucide-react/dist/esm/lucide-react.js:
1499
1572
  (**
1500
1573
  * @license lucide-react v0.452.0 - ISC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puckeditor/plugin-ai",
3
- "version": "0.1.0-canary.bde85814",
3
+ "version": "0.1.0-canary.c433e7ae",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "puckeditor/puck",
6
6
  "bugs": "https://github.com/puckeditor/puck/issues",