@puckeditor/plugin-ai 0.1.1-canary.f3bb46a1 → 0.2.0-canary.a49c281e

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
@@ -1,23 +1,24 @@
1
1
  /* css-module:/home/runner/work/puck-platform/puck-platform/packages/plugin-ai/src/components/Chat/styles.module.css/#css-module-data */
2
- ._Chat_1mv7h_1 {
2
+ ._Chat_lckw1_1 {
3
3
  background: white;
4
4
  height: 100%;
5
5
  display: flex;
6
6
  flex-direction: column;
7
+ text-align: left;
7
8
  }
8
- ._Chat-header_1mv7h_8 {
9
+ ._Chat-header_lckw1_9 {
9
10
  display: block;
10
11
  padding: 8px 16px;
11
12
  font-weight: 600;
12
13
  border-bottom: 1px solid var(--puck-color-grey-09);
13
14
  }
14
15
  @media (min-width: 638px) {
15
- ._Chat-header_1mv7h_8 {
16
+ ._Chat-header_lckw1_9 {
16
17
  display: block;
17
18
  padding: 16px;
18
19
  }
19
20
  }
20
- ._Chat-placeholder_1mv7h_22 {
21
+ ._Chat-placeholder_lckw1_23 {
21
22
  align-items: center;
22
23
  color: var(--puck-color-grey-06);
23
24
  display: none;
@@ -29,37 +30,37 @@
29
30
  gap: 8px;
30
31
  }
31
32
  @media (min-width: 638px) {
32
- ._Chat-placeholder_1mv7h_22 {
33
+ ._Chat-placeholder_lckw1_23 {
33
34
  display: flex;
34
35
  }
35
36
  }
36
- ._Chat-actions_1mv7h_40 {
37
+ ._Chat-actions_lckw1_41 {
37
38
  display: flex;
38
39
  gap: 8px;
39
40
  justify-content: center;
40
41
  flex-wrap: wrap;
41
42
  margin-top: 4px;
42
43
  }
43
- ._Chat-action_1mv7h_40,
44
- ._Chat-actionOutlined_1mv7h_49 {
44
+ ._Chat-action_lckw1_41,
45
+ ._Chat-actionOutlined_lckw1_50 {
45
46
  border: 1px solid var(--puck-color-azure-04);
46
47
  border-radius: 16px;
47
48
  padding: 4px 12px;
48
49
  font-size: 12px;
49
50
  cursor: pointer;
50
51
  }
51
- ._Chat-action_1mv7h_40 {
52
+ ._Chat-action_lckw1_41 {
52
53
  background: var(--puck-color-azure-04);
53
54
  color: white;
54
55
  }
55
- ._Chat-action_1mv7h_40:hover {
56
+ ._Chat-action_lckw1_41:hover {
56
57
  opacity: 0.8;
57
58
  }
58
- ._Chat-actionOutlined_1mv7h_49 {
59
+ ._Chat-actionOutlined_lckw1_50 {
59
60
  background: transparent;
60
61
  color: var(--puck-color-azure-04);
61
62
  }
62
- ._Chat-actionOutlined_1mv7h_49:hover {
63
+ ._Chat-actionOutlined_lckw1_50:hover {
63
64
  background: var(--puck-color-azure-11);
64
65
  }
65
66
 
@@ -263,7 +264,7 @@ p {
263
264
  }
264
265
 
265
266
  /* css-module:/home/runner/work/puck-platform/puck-platform/packages/platform-client/components/Button/Button.module.css/#css-module-data */
266
- ._Button_1fon5_1 {
267
+ ._Button_1uqtp_1 {
267
268
  appearance: none;
268
269
  background: none;
269
270
  border: 1px solid transparent;
@@ -285,80 +286,98 @@ p {
285
286
  white-space: nowrap;
286
287
  margin: 0;
287
288
  }
288
- ._Button_1fon5_1:hover,
289
- ._Button_1fon5_1:active {
289
+ ._Button_1uqtp_1:hover,
290
+ ._Button_1uqtp_1:active {
290
291
  transition: none;
291
292
  }
292
- ._Button--medium_1fon5_29 {
293
+ ._Button_1uqtp_1:focus-visible {
294
+ outline: 2px solid var(--puck-color-azure-05);
295
+ outline-offset: 2px;
296
+ }
297
+ ._Button--medium_1uqtp_34 {
293
298
  min-height: 34px;
294
299
  padding-bottom: 7px;
295
300
  padding-left: 19px;
296
301
  padding-right: 19px;
297
302
  padding-top: 7px;
298
303
  }
299
- ._Button--large_1fon5_37 {
304
+ ._Button--large_1uqtp_42 {
300
305
  padding-bottom: 11px;
301
306
  padding-left: 19px;
302
307
  padding-right: 19px;
303
308
  padding-top: 11px;
304
309
  }
305
- ._Button-icon_1fon5_44 {
310
+ ._Button-icon_1uqtp_49 {
306
311
  margin-top: 2px;
307
312
  }
308
- ._Button--primary_1fon5_48 {
309
- background: var(--puck-color-azure-04);
313
+ ._Button--brand_1uqtp_53 {
314
+ background-image:
315
+ linear-gradient(
316
+ 210deg,
317
+ var(--puck-color-azure-01) 0%,
318
+ var(--puck-color-azure-03) 40%,
319
+ var(--puck-color-red-05) 100%);
320
+ border: none;
321
+ border-radius: 48px;
310
322
  }
311
- ._Button_1fon5_1:focus-visible {
312
- outline: 2px solid var(--puck-color-azure-05);
313
- outline-offset: 2px;
323
+ @media (hover: hover) and (pointer: fine) {
324
+ ._Button--brand_1uqtp_53:hover {
325
+ opacity: 0.8;
326
+ }
327
+ }
328
+ ._Button--brand_1uqtp_53:active {
329
+ opacity: 0.8;
330
+ }
331
+ ._Button--primary_1uqtp_74 {
332
+ background: var(--puck-color-azure-04);
314
333
  }
315
334
  @media (hover: hover) and (pointer: fine) {
316
- ._Button--primary_1fon5_48:hover {
335
+ ._Button--primary_1uqtp_74:hover {
317
336
  background-color: var(--puck-color-azure-03);
318
337
  }
319
338
  }
320
- ._Button--primary_1fon5_48:active {
339
+ ._Button--primary_1uqtp_74:active {
321
340
  background-color: var(--puck-color-azure-02);
322
341
  }
323
- ._Button--secondary_1fon5_67 {
342
+ ._Button--secondary_1uqtp_88 {
324
343
  border: 1px solid currentColor;
325
344
  color: currentColor;
326
345
  }
327
346
  @media (hover: hover) and (pointer: fine) {
328
- ._Button--secondary_1fon5_67:hover {
347
+ ._Button--secondary_1uqtp_88:hover {
329
348
  background-color: var(--puck-color-azure-12);
330
349
  color: var(--puck-color-black);
331
350
  }
332
351
  }
333
- ._Button--secondary_1fon5_67:active {
352
+ ._Button--secondary_1uqtp_88:active {
334
353
  background-color: var(--puck-color-azure-11);
335
354
  color: var(--puck-color-black);
336
355
  }
337
- ._Button--danger_1fon5_84 {
356
+ ._Button--danger_1uqtp_105 {
338
357
  background: var(--puck-color-red-04);
339
358
  }
340
359
  @media (hover: hover) and (pointer: fine) {
341
- ._Button--danger_1fon5_84:hover {
360
+ ._Button--danger_1uqtp_105:hover {
342
361
  background-color: var(--puck-color-red-03);
343
362
  }
344
363
  }
345
- ._Button--danger_1fon5_84:active {
364
+ ._Button--danger_1uqtp_105:active {
346
365
  background-color: var(--puck-color-red-02);
347
366
  }
348
- ._Button--flush_1fon5_98 {
367
+ ._Button--flush_1uqtp_119 {
349
368
  border-radius: 0;
350
369
  }
351
- ._Button--disabled_1fon5_102,
352
- ._Button--disabled_1fon5_102:hover {
370
+ ._Button--disabled_1uqtp_123,
371
+ ._Button--disabled_1uqtp_123:hover {
353
372
  background-color: var(--puck-color-grey-09);
354
373
  color: var(--puck-color-grey-05);
355
374
  cursor: not-allowed;
356
375
  }
357
- ._Button--fullWidth_1fon5_109 {
376
+ ._Button--fullWidth_1uqtp_130 {
358
377
  justify-content: center;
359
378
  width: 100%;
360
379
  }
361
- ._Button-spinner_1fon5_114 {
380
+ ._Button-spinner_1uqtp_135 {
362
381
  padding-left: 8px;
363
382
  }
364
383
 
@@ -1099,7 +1118,7 @@ p {
1099
1118
  }
1100
1119
 
1101
1120
  /* css-module:/home/runner/work/puck-platform/puck-platform/packages/plugin-ai/src/components/ChatBody/styles.module.css/#css-module-data */
1102
- ._Chat_150yz_1 {
1121
+ ._Chat_1ybjn_1 {
1103
1122
  --fade-size: 32px;
1104
1123
  --chat-background-color: white;
1105
1124
  display: flex;
@@ -1109,46 +1128,46 @@ p {
1109
1128
  overflow: hidden;
1110
1129
  }
1111
1130
  @media (min-width: 638px) {
1112
- ._Chat_150yz_1 {
1131
+ ._Chat_1ybjn_1 {
1113
1132
  max-height: none;
1114
1133
  }
1115
1134
  }
1116
- ._Chat-inner_150yz_17 {
1135
+ ._Chat-inner_1ybjn_17 {
1117
1136
  background-color: var(--chat-background-color);
1118
1137
  display: flex;
1119
1138
  flex-direction: column;
1120
1139
  max-height: 100%;
1121
1140
  position: relative;
1122
1141
  }
1123
- ._Chat--hasMessages_150yz_25 ._Chat-inner_150yz_17 {
1142
+ ._Chat--hasMessages_1ybjn_25 ._Chat-inner_1ybjn_17 {
1124
1143
  padding-top: 0;
1125
1144
  }
1126
- ._Chat_150yz_1:not(._Chat--hasChildren_150yz_29) ._Chat-inner_150yz_17 {
1145
+ ._Chat_1ybjn_1:not(._Chat--hasChildren_1ybjn_29) ._Chat-inner_1ybjn_17 {
1127
1146
  height: 100%;
1128
1147
  padding-top: 0;
1129
1148
  }
1130
- ._Chat--hasMessages_150yz_25 ._Chat-messages_150yz_34 {
1149
+ ._Chat--hasMessages_1ybjn_25 ._Chat-messages_1ybjn_34 {
1131
1150
  display: flex;
1132
1151
  flex-direction: column-reverse;
1133
1152
  padding: 16px;
1134
1153
  overflow: auto;
1135
1154
  }
1136
- ._Chat-form_150yz_41 {
1155
+ ._Chat-form_1ybjn_41 {
1137
1156
  background-color: white;
1138
1157
  padding: 16px;
1139
1158
  }
1140
- ._Chat--hideInput_150yz_46 ._Chat-form_150yz_41 {
1159
+ ._Chat--hideInput_1ybjn_46 ._Chat-form_1ybjn_41 {
1141
1160
  display: none;
1142
1161
  }
1143
- ._Chat--hasMessages_150yz_25 ._Chat-form_150yz_41 {
1162
+ ._Chat--hasMessages_1ybjn_25 ._Chat-form_1ybjn_41 {
1144
1163
  border-top: 1px solid var(--puck-color-grey-09);
1145
1164
  }
1146
1165
  @media (min-width: 638px) {
1147
- ._Chat-form_150yz_41 {
1166
+ ._Chat-form_1ybjn_41 {
1148
1167
  border-top: 1px solid var(--puck-color-grey-09);
1149
1168
  }
1150
1169
  }
1151
- ._Chat-formHelper_150yz_60 {
1170
+ ._Chat-formHelper_1ybjn_60 {
1152
1171
  align-items: center;
1153
1172
  display: flex;
1154
1173
  color: var(--puck-color-grey-04);
@@ -1157,11 +1176,11 @@ p {
1157
1176
  gap: 8px;
1158
1177
  padding-bottom: 12px;
1159
1178
  }
1160
- ._Chat--hasMessages_150yz_25 ._Chat-formHelper_150yz_60 {
1179
+ ._Chat--hasMessages_1ybjn_25 ._Chat-formHelper_1ybjn_60 {
1161
1180
  opacity: 0;
1162
1181
  transition: opacity 250ms ease-in;
1163
1182
  }
1164
- ._Chat-examplePrompts_150yz_75 {
1183
+ ._Chat-examplePrompts_1ybjn_75 {
1165
1184
  align-items: center;
1166
1185
  display: flex;
1167
1186
  flex-wrap: nowrap;
@@ -1170,45 +1189,46 @@ p {
1170
1189
  width: 100%;
1171
1190
  overflow-x: auto;
1172
1191
  }
1173
- ._Chat-examplePrompt_150yz_75 {
1192
+ ._Chat-examplePrompt_1ybjn_75 {
1174
1193
  align-items: center;
1175
1194
  background: white;
1176
1195
  border: 1px solid var(--puck-color-grey-09);
1177
1196
  border-radius: 48px;
1197
+ cursor: pointer;
1178
1198
  display: flex;
1179
1199
  gap: 4px;
1180
1200
  font-size: var(--puck-font-size-xxxs);
1181
1201
  padding: 6px 12px;
1182
1202
  text-wrap: nowrap;
1183
1203
  }
1184
- ._Chat-examplePrompt_150yz_75:hover {
1204
+ ._Chat-examplePrompt_1ybjn_75:hover {
1185
1205
  background: var(--puck-color-azure-11);
1186
1206
  border-color: var(--puck-color-azure-08);
1187
1207
  color: var(--puck-color-azure-04);
1188
1208
  }
1189
- ._Chat-examplePromptArrow_150yz_103 {
1209
+ ._Chat-examplePromptArrow_1ybjn_104 {
1190
1210
  margin-left: auto;
1191
1211
  }
1192
- ._Chat-default_150yz_107 {
1212
+ ._Chat-default_1ybjn_108 {
1193
1213
  overflow-y: auto;
1194
1214
  flex-grow: 1;
1195
1215
  }
1196
- ._Chat--hasMessages_150yz_25 ._Chat-default_150yz_107 {
1216
+ ._Chat--hasMessages_1ybjn_25 ._Chat-default_1ybjn_108 {
1197
1217
  opacity: 0;
1198
1218
  padding: 0;
1199
1219
  pointer-events: none;
1200
1220
  transition: opacity 250ms ease-in;
1201
1221
  }
1202
- ._Chat--hasMessages_150yz_25 {
1222
+ ._Chat--hasMessages_1ybjn_25 {
1203
1223
  background-color: white;
1204
1224
  transition: background-color 250ms ease-in;
1205
1225
  }
1206
- ._ChatMessage_150yz_124 {
1226
+ ._ChatMessage_1ybjn_125 {
1207
1227
  font-size: var(--puck-font-size-xs);
1208
1228
  line-height: var(--line-height-s);
1209
1229
  overflow-wrap: break-word;
1210
1230
  }
1211
- ._ChatMessage--userRole_150yz_130 ._ChatMessage-text_150yz_130 {
1231
+ ._ChatMessage--userRole_1ybjn_131 ._ChatMessage-text_1ybjn_131 {
1212
1232
  background: var(--puck-color-azure-10);
1213
1233
  border-radius: 16px;
1214
1234
  color: var(--puck-color-grey-03);
@@ -1217,64 +1237,70 @@ p {
1217
1237
  margin-top: 8px;
1218
1238
  padding: 12px 16px;
1219
1239
  }
1220
- ._ChatMessage_150yz_124 ul,
1221
- ._ChatMessage_150yz_124 ol {
1240
+ ._ChatMessage_1ybjn_125 ul,
1241
+ ._ChatMessage_1ybjn_125 ol {
1222
1242
  list-style: decimal;
1223
1243
  margin: 0;
1224
1244
  margin-bottom: 12px;
1225
1245
  margin-top: 12px;
1226
1246
  padding-left: 32px;
1227
1247
  }
1228
- ._ChatMessage_150yz_124 li {
1248
+ ._ChatMessage_1ybjn_125 li {
1229
1249
  margin-bottom: 8px;
1230
1250
  margin-top: 8px;
1231
1251
  padding-left: 8px;
1232
1252
  }
1233
- ._ChatMessage_150yz_124 h1,
1234
- ._ChatMessage_150yz_124 h2,
1235
- ._ChatMessage_150yz_124 h3,
1236
- ._ChatMessage_150yz_124 h4,
1237
- ._ChatMessage_150yz_124 h5,
1238
- ._ChatMessage_150yz_124 h6 {
1253
+ ._ChatMessage_1ybjn_125 h1,
1254
+ ._ChatMessage_1ybjn_125 h2,
1255
+ ._ChatMessage_1ybjn_125 h3,
1256
+ ._ChatMessage_1ybjn_125 h4,
1257
+ ._ChatMessage_1ybjn_125 h5,
1258
+ ._ChatMessage_1ybjn_125 h6 {
1239
1259
  font-weight: 600;
1240
1260
  }
1241
- ._ChatMessage_150yz_124 h1 {
1261
+ ._ChatMessage_1ybjn_125 h1 {
1242
1262
  font-size: var(--puck-font-l);
1243
1263
  }
1244
- ._ChatMessage_150yz_124 h2 {
1264
+ ._ChatMessage_1ybjn_125 h2 {
1245
1265
  font-size: var(--puck-font-m);
1246
1266
  }
1247
- ._ChatMessage_150yz_124 h3 {
1267
+ ._ChatMessage_1ybjn_125 h3 {
1248
1268
  font-size: var(--puck-font-m);
1249
1269
  }
1250
- ._ChatMessage_150yz_124 h4 {
1270
+ ._ChatMessage_1ybjn_125 h4 {
1251
1271
  font-size: var(--puck-font-s);
1252
1272
  }
1253
- ._ChatMessage_150yz_124 h5 {
1273
+ ._ChatMessage_1ybjn_125 h5 {
1254
1274
  font-size: var(--puck-font-xs);
1255
1275
  }
1256
- ._ChatMessage_150yz_124 h6 {
1276
+ ._ChatMessage_1ybjn_125 h6 {
1257
1277
  font-size: var(--puck-font-xm);
1258
1278
  }
1259
- ._ChatMessage_150yz_124 p {
1279
+ ._ChatMessage_1ybjn_125 p {
1260
1280
  margin-bottom: 8px;
1261
1281
  margin-top: 8px;
1262
1282
  }
1263
- ._ChatMessage_150yz_124 a {
1283
+ ._ChatMessage--userRole_1ybjn_131 ._ChatMessage-text_1ybjn_131 > *:first-of-type {
1284
+ margin-top: 0px;
1285
+ }
1286
+ ._ChatMessage--userRole_1ybjn_131 ._ChatMessage-text_1ybjn_131 > *:last-of-type {
1287
+ margin-bottom: 0px;
1288
+ }
1289
+ ._ChatMessage_1ybjn_125 a {
1264
1290
  color: var(--puck-color-azure-04);
1265
1291
  font-weight: 600;
1266
1292
  text-decoration: none;
1267
1293
  }
1268
- ._ChatMessage_150yz_124 a:hover {
1294
+ ._ChatMessage_1ybjn_125 a:hover {
1269
1295
  color: var(--puck-color-azure-05);
1270
1296
  }
1271
- ._ChatMessage_150yz_124 hr {
1297
+ ._ChatMessage_1ybjn_125 hr {
1272
1298
  border-top: none;
1273
1299
  border-bottom-color: var(--puck-color-grey-09);
1274
1300
  margin-bottom: 16px;
1275
1301
  margin-top: 16px;
1276
1302
  }
1277
- ._ChatMessage_150yz_124 blockquote {
1303
+ ._ChatMessage_1ybjn_125 blockquote {
1278
1304
  margin-bottom: 8px;
1279
1305
  margin-top: 8px;
1280
1306
  margin-left: 0;
@@ -1283,7 +1309,7 @@ p {
1283
1309
  padding-bottom: 2px;
1284
1310
  padding-top: 2px;
1285
1311
  }
1286
- ._ChatMessage-data_150yz_220 {
1312
+ ._ChatMessage-data_1ybjn_229 {
1287
1313
  background: var(--puck-color-grey-12);
1288
1314
  border: 1px solid var(--puck-color-grey-08);
1289
1315
  border-radius: 16px;
@@ -1293,19 +1319,19 @@ p {
1293
1319
  margin-top: 12px;
1294
1320
  padding: 12px 16px;
1295
1321
  }
1296
- ._ChatMessage-dataInner_150yz_231 {
1322
+ ._ChatMessage-dataInner_1ybjn_240 {
1297
1323
  align-items: center;
1298
1324
  display: flex;
1299
1325
  gap: 8px;
1300
1326
  }
1301
- ._ChatMessage-dataIcon_150yz_237 {
1327
+ ._ChatMessage-dataIcon_1ybjn_246 {
1302
1328
  display: flex;
1303
1329
  }
1304
- ._Chat-loader_150yz_241 {
1330
+ ._Chat-loader_1ybjn_250 {
1305
1331
  padding: 16px;
1306
1332
  padding-top: 0;
1307
1333
  }
1308
- ._Chat-error_150yz_246 {
1334
+ ._Chat-error_1ybjn_255 {
1309
1335
  align-items: center;
1310
1336
  display: flex;
1311
1337
  gap: 8px;
@@ -1313,10 +1339,10 @@ p {
1313
1339
  margin: 16px;
1314
1340
  margin-top: 0;
1315
1341
  }
1316
- ._Chat-errorLabel_150yz_255 {
1342
+ ._Chat-errorLabel_1ybjn_264 {
1317
1343
  color: var(--puck-color-red-04);
1318
1344
  }
1319
- ._Chat-errorAction_150yz_259 {
1345
+ ._Chat-errorAction_1ybjn_268 {
1320
1346
  margin-left: auto;
1321
1347
  }
1322
1348
 
package/dist/index.d.mts CHANGED
@@ -1,4 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { LanguageModelUsage, UIMessage, DataUIPart, ChatStatus } from 'ai';
3
+ import { PuckAction } from '@measured/puck';
2
4
 
3
5
  type _JSONSchema = boolean | JSONSchema;
4
6
  type JSONSchema = {
@@ -98,16 +100,93 @@ declare module "@measured/puck" {
98
100
  }
99
101
  }
100
102
 
103
+ type ToolStatus = {
104
+ loading: boolean;
105
+ label: string;
106
+ error?: {
107
+ message: string;
108
+ };
109
+ };
110
+ type DataToolStatus = {
111
+ status: ToolStatus;
112
+ toolCallId: string;
113
+ };
114
+ type AddOperation = {
115
+ op: "add";
116
+ id: string;
117
+ index: number;
118
+ zone: string;
119
+ type: string;
120
+ props: object;
121
+ };
122
+ type UpdateOperation = {
123
+ op: "update";
124
+ id: string;
125
+ props: object;
126
+ };
127
+ type UpdateRootOperation = {
128
+ op: "updateRoot";
129
+ props: object;
130
+ };
131
+ type MoveOperation = {
132
+ op: "move";
133
+ zone: string;
134
+ id: string;
135
+ index: number;
136
+ };
137
+ type DeleteOperation = {
138
+ op: "delete";
139
+ id: string;
140
+ };
141
+ type DuplicateOperation = {
142
+ op: "duplicate";
143
+ id: string;
144
+ };
145
+ type ResetOperation = {
146
+ op: "reset";
147
+ };
148
+ type Operation = AddOperation | UpdateOperation | UpdateRootOperation | MoveOperation | DeleteOperation | DuplicateOperation | ResetOperation;
149
+ type PuckDataParts = {
150
+ "new-chat-created": {
151
+ chatId: string;
152
+ };
153
+ "puck-actions": PuckAction[];
154
+ "build-op": Operation;
155
+ "tool-status": DataToolStatus;
156
+ "user-tool": {
157
+ toolCallId: string;
158
+ tools: {
159
+ name: string;
160
+ input: any;
161
+ }[];
162
+ };
163
+ };
164
+ type PuckProviderMetadata = {
165
+ tokenUsage?: LanguageModelUsage;
166
+ };
167
+
168
+ type PuckMessage = UIMessage<PuckProviderMetadata, PuckDataParts>;
169
+
101
170
  type AiPluginProps = {
102
171
  host?: string;
103
172
  chat?: {
104
173
  onSubmit?: (prompt: string) => void;
105
174
  examplePrompts?: {
106
- href: string;
107
175
  label: string;
176
+ href?: string;
177
+ onClick?: () => void;
108
178
  }[];
109
179
  };
110
180
  };
181
+ declare global {
182
+ interface Window {
183
+ __PUCK_AI: {
184
+ setMessages: (_messages: PuckMessage[]) => void;
185
+ processData: (_messages: DataUIPart<PuckDataParts>) => void;
186
+ setStatus: (_status: ChatStatus) => void;
187
+ };
188
+ }
189
+ }
111
190
 
112
191
  declare function createAiPlugin(opts?: AiPluginProps): {
113
192
  label: string;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { LanguageModelUsage, UIMessage, DataUIPart, ChatStatus } from 'ai';
3
+ import { PuckAction } from '@measured/puck';
2
4
 
3
5
  type _JSONSchema = boolean | JSONSchema;
4
6
  type JSONSchema = {
@@ -98,16 +100,93 @@ declare module "@measured/puck" {
98
100
  }
99
101
  }
100
102
 
103
+ type ToolStatus = {
104
+ loading: boolean;
105
+ label: string;
106
+ error?: {
107
+ message: string;
108
+ };
109
+ };
110
+ type DataToolStatus = {
111
+ status: ToolStatus;
112
+ toolCallId: string;
113
+ };
114
+ type AddOperation = {
115
+ op: "add";
116
+ id: string;
117
+ index: number;
118
+ zone: string;
119
+ type: string;
120
+ props: object;
121
+ };
122
+ type UpdateOperation = {
123
+ op: "update";
124
+ id: string;
125
+ props: object;
126
+ };
127
+ type UpdateRootOperation = {
128
+ op: "updateRoot";
129
+ props: object;
130
+ };
131
+ type MoveOperation = {
132
+ op: "move";
133
+ zone: string;
134
+ id: string;
135
+ index: number;
136
+ };
137
+ type DeleteOperation = {
138
+ op: "delete";
139
+ id: string;
140
+ };
141
+ type DuplicateOperation = {
142
+ op: "duplicate";
143
+ id: string;
144
+ };
145
+ type ResetOperation = {
146
+ op: "reset";
147
+ };
148
+ type Operation = AddOperation | UpdateOperation | UpdateRootOperation | MoveOperation | DeleteOperation | DuplicateOperation | ResetOperation;
149
+ type PuckDataParts = {
150
+ "new-chat-created": {
151
+ chatId: string;
152
+ };
153
+ "puck-actions": PuckAction[];
154
+ "build-op": Operation;
155
+ "tool-status": DataToolStatus;
156
+ "user-tool": {
157
+ toolCallId: string;
158
+ tools: {
159
+ name: string;
160
+ input: any;
161
+ }[];
162
+ };
163
+ };
164
+ type PuckProviderMetadata = {
165
+ tokenUsage?: LanguageModelUsage;
166
+ };
167
+
168
+ type PuckMessage = UIMessage<PuckProviderMetadata, PuckDataParts>;
169
+
101
170
  type AiPluginProps = {
102
171
  host?: string;
103
172
  chat?: {
104
173
  onSubmit?: (prompt: string) => void;
105
174
  examplePrompts?: {
106
- href: string;
107
175
  label: string;
176
+ href?: string;
177
+ onClick?: () => void;
108
178
  }[];
109
179
  };
110
180
  };
181
+ declare global {
182
+ interface Window {
183
+ __PUCK_AI: {
184
+ setMessages: (_messages: PuckMessage[]) => void;
185
+ processData: (_messages: DataUIPart<PuckDataParts>) => void;
186
+ setStatus: (_status: ChatStatus) => void;
187
+ };
188
+ }
189
+ }
111
190
 
112
191
  declare function createAiPlugin(opts?: AiPluginProps): {
113
192
  label: string;