@terreno/blocks 57.12.0 → 57.13.0
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/errors.d.ts +2 -0
- package/dist/errors.js +2 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +13 -1
- package/dist/interactive.d.ts +26 -0
- package/dist/interactive.js +62 -0
- package/dist/limits.d.ts +26 -0
- package/dist/limits.js +26 -0
- package/dist/lint.d.ts +18 -1
- package/dist/lint.js +186 -26
- package/dist/plainText.d.ts +17 -0
- package/dist/plainText.js +56 -0
- package/dist/prompt.d.ts +10 -1
- package/dist/prompt.js +73 -3
- package/dist/schema.d.ts +113 -2
- package/dist/schema.js +121 -5
- package/dist/validate.js +26 -2
- package/package.json +1 -1
- package/src/__snapshots__/prompt.test.ts.snap +530 -0
- package/src/errors.ts +4 -0
- package/src/fixtures/golden/sunday-roast.yaml +174 -0
- package/src/fixtures/invalid/card-eyebrow-empty.yaml +7 -0
- package/src/fixtures/invalid/card-eyebrow-too-long.yaml +7 -0
- package/src/fixtures/invalid/checklist-duplicate-item.yaml +9 -0
- package/src/fixtures/invalid/checklist-item-id-too-long.yaml +7 -0
- package/src/fixtures/invalid/checklist-reserved-id.yaml +16 -0
- package/src/fixtures/invalid/copy-missing-text-and-target.yaml +10 -0
- package/src/fixtures/invalid/copy-target.yaml +14 -0
- package/src/fixtures/invalid/gallery-caption-too-long.yaml +9 -0
- package/src/fixtures/invalid/gallery-image-host.yaml +10 -0
- package/src/fixtures/invalid/gallery-too-few.yaml +6 -0
- package/src/fixtures/invalid/list-image-host.yaml +12 -0
- package/src/fixtures/invalid/list-missing-title.yaml +6 -0
- package/src/fixtures/invalid/list-too-many.yaml +17 -0
- package/src/fixtures/invalid/stepper-decimals.yaml +14 -0
- package/src/fixtures/invalid/stepper-out-of-range.yaml +10 -0
- package/src/fixtures/invalid/stepper-reserved-id.yaml +19 -0
- package/src/fixtures/valid/card-eyebrow.yaml +8 -0
- package/src/fixtures/valid/checklist.yaml +29 -0
- package/src/fixtures/valid/copy.yaml +85 -0
- package/src/fixtures/valid/gallery.yaml +22 -0
- package/src/fixtures/valid/list.yaml +24 -0
- package/src/fixtures/valid/stepper.yaml +35 -0
- package/src/golden.test.ts +234 -0
- package/src/index.test.ts +9 -0
- package/src/index.ts +24 -0
- package/src/interactive.test.ts +141 -0
- package/src/interactive.ts +75 -0
- package/src/limits.ts +26 -0
- package/src/lint.test.ts +672 -0
- package/src/lint.ts +264 -33
- package/src/parse.test.ts +40 -0
- package/src/plainText.test.ts +158 -0
- package/src/plainText.ts +81 -0
- package/src/prompt.test.ts +325 -2
- package/src/prompt.ts +87 -2
- package/src/schema.ts +259 -6
- package/src/validate.ts +26 -2
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
|
|
2
|
+
|
|
3
|
+
exports[`blocksPromptSection with richBlocks false matches the pre-rich-blocks prompt for allowHtml, even with stepper and checklist actions 1`] = `
|
|
4
|
+
"Your entire reply is one document; no prose outside it; no text before tool calls.
|
|
5
|
+
The document is YAML or JSON. Keys, when present, are in this order: v, datasets, blocks.
|
|
6
|
+
v is 1.
|
|
7
|
+
Block types: heading, text, metric, badge, divider, context, chart, table, actions, columns, card, html, callout, image, details.
|
|
8
|
+
An html field is at most 100000 bytes.
|
|
9
|
+
html requires html and may set title and height (sm, md, or lg). It is a display preview: no scripts, no links, no network.
|
|
10
|
+
callout requires text and may set status to info, warning, or alert.
|
|
11
|
+
image requires alt and src. src is a data:image URL, a file: ref, or an https URL on an allowed host.
|
|
12
|
+
Do not emit an https image src. Use a data:image URL or a file: ref.
|
|
13
|
+
details requires title and text.
|
|
14
|
+
heading requires text. text requires markdown. metric requires label and value. badge requires text. context requires text.
|
|
15
|
+
chart kind is line, bar, area, or donut. Bind it with data, x, and y, or with points of label and value.
|
|
16
|
+
table requires data, the name of a dataset. actions requires id and elements.
|
|
17
|
+
An element is a button (id, text, action) or a segmented control (id, target, options of label and data).
|
|
18
|
+
action.kind is reply (text), open (url or route, exactly one), select (target and data), or callback (name and optional payload).
|
|
19
|
+
columns has 2 to 4 children. card has children and an optional title. Do not nest columns or card inside columns or card.
|
|
20
|
+
At most 50 blocks, including nested blocks.
|
|
21
|
+
Depth is at most 2.
|
|
22
|
+
An actions block has at most 25 elements.
|
|
23
|
+
columns has 2 to 4 children.
|
|
24
|
+
At most 8 datasets.
|
|
25
|
+
An inline dataset has at most 500 rows and 12 columns.
|
|
26
|
+
A ref dataset limit is at most 1000.
|
|
27
|
+
A text block has at most 4000 characters.
|
|
28
|
+
A document has at most 20000 characters of text.
|
|
29
|
+
Heading text is at most 200 characters.
|
|
30
|
+
Badge text is at most 80 characters.
|
|
31
|
+
Context text is at most 280 characters.
|
|
32
|
+
A card title is at most 120 characters.
|
|
33
|
+
A metric label is at most 80 characters, its value 80, its delta 40, and its helper 120.
|
|
34
|
+
A bar chart warns above 60 categories.
|
|
35
|
+
A donut chart warns above 8 slices.
|
|
36
|
+
Use the datasetId a tool returned; never paste more than 500 rows.
|
|
37
|
+
No callback names are registered. Do not emit kind callback.
|
|
38
|
+
Example with data:
|
|
39
|
+
v: 1
|
|
40
|
+
datasets:
|
|
41
|
+
signups:
|
|
42
|
+
columns:
|
|
43
|
+
- name: month
|
|
44
|
+
type: string
|
|
45
|
+
- name: count
|
|
46
|
+
type: number
|
|
47
|
+
rows:
|
|
48
|
+
- [Jan, 120]
|
|
49
|
+
- [Feb, 180]
|
|
50
|
+
blocks:
|
|
51
|
+
- type: chart
|
|
52
|
+
id: signups_chart
|
|
53
|
+
kind: bar
|
|
54
|
+
data: signups
|
|
55
|
+
x: month
|
|
56
|
+
y: count
|
|
57
|
+
title: Signups by month
|
|
58
|
+
- type: actions
|
|
59
|
+
id: followups
|
|
60
|
+
elements:
|
|
61
|
+
- type: button
|
|
62
|
+
id: weekly
|
|
63
|
+
text: Show weekly
|
|
64
|
+
action:
|
|
65
|
+
kind: reply
|
|
66
|
+
text: Show weekly signups for this quarter
|
|
67
|
+
Example with prose only:
|
|
68
|
+
v: 1
|
|
69
|
+
blocks:
|
|
70
|
+
- type: text
|
|
71
|
+
markdown: I could not find any signups for that range. Try a wider date window."
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
exports[`blocksPromptSection with richBlocks false matches the pre-rich-blocks prompt for everything, even with stepper and checklist actions 1`] = `
|
|
75
|
+
"Your entire reply is one document; no prose outside it; no text before tool calls.
|
|
76
|
+
The document is YAML or JSON. Keys, when present, are in this order: v, datasets, blocks.
|
|
77
|
+
v is 1.
|
|
78
|
+
Block types: heading, text, metric, badge, divider, context, chart, table, actions, columns, card, html, callout, image, details.
|
|
79
|
+
An html field is at most 100000 bytes.
|
|
80
|
+
html requires html and may set title and height (sm, md, or lg). It is a display preview: no scripts, no links, no network.
|
|
81
|
+
callout requires text and may set status to info, warning, or alert.
|
|
82
|
+
image requires alt and src. src is a data:image URL, a file: ref, or an https URL on an allowed host.
|
|
83
|
+
An https image src must use one of these hosts: cdn.example.com.
|
|
84
|
+
details requires title and text.
|
|
85
|
+
heading requires text. text requires markdown. metric requires label and value. badge requires text. context requires text.
|
|
86
|
+
chart kind is line, bar, area, or donut. Bind it with data, x, and y, or with points of label and value.
|
|
87
|
+
table requires data, the name of a dataset. actions requires id and elements.
|
|
88
|
+
An element is a button (id, text, action) or a segmented control (id, target, options of label and data).
|
|
89
|
+
action.kind is reply (text), open (url or route, exactly one), select (target and data), or callback (name and optional payload).
|
|
90
|
+
columns has 2 to 4 children. card has children and an optional title. Do not nest columns or card inside columns or card.
|
|
91
|
+
At most 50 blocks, including nested blocks.
|
|
92
|
+
Depth is at most 2.
|
|
93
|
+
An actions block has at most 25 elements.
|
|
94
|
+
columns has 2 to 4 children.
|
|
95
|
+
At most 8 datasets.
|
|
96
|
+
An inline dataset has at most 500 rows and 12 columns.
|
|
97
|
+
A ref dataset limit is at most 1000.
|
|
98
|
+
A text block has at most 4000 characters.
|
|
99
|
+
A document has at most 20000 characters of text.
|
|
100
|
+
Heading text is at most 200 characters.
|
|
101
|
+
Badge text is at most 80 characters.
|
|
102
|
+
Context text is at most 280 characters.
|
|
103
|
+
A card title is at most 120 characters.
|
|
104
|
+
A metric label is at most 80 characters, its value 80, its delta 40, and its helper 120.
|
|
105
|
+
A bar chart warns above 60 categories.
|
|
106
|
+
A donut chart warns above 8 slices.
|
|
107
|
+
Use the datasetId a tool returned; never paste more than 500 rows.
|
|
108
|
+
A callback name must be one of: approve, scaleStepper.
|
|
109
|
+
Example with data:
|
|
110
|
+
v: 1
|
|
111
|
+
datasets:
|
|
112
|
+
signups:
|
|
113
|
+
columns:
|
|
114
|
+
- name: month
|
|
115
|
+
type: string
|
|
116
|
+
- name: count
|
|
117
|
+
type: number
|
|
118
|
+
rows:
|
|
119
|
+
- [Jan, 120]
|
|
120
|
+
- [Feb, 180]
|
|
121
|
+
blocks:
|
|
122
|
+
- type: chart
|
|
123
|
+
id: signups_chart
|
|
124
|
+
kind: bar
|
|
125
|
+
data: signups
|
|
126
|
+
x: month
|
|
127
|
+
y: count
|
|
128
|
+
title: Signups by month
|
|
129
|
+
- type: actions
|
|
130
|
+
id: followups
|
|
131
|
+
elements:
|
|
132
|
+
- type: button
|
|
133
|
+
id: weekly
|
|
134
|
+
text: Show weekly
|
|
135
|
+
action:
|
|
136
|
+
kind: reply
|
|
137
|
+
text: Show weekly signups for this quarter
|
|
138
|
+
Example with prose only:
|
|
139
|
+
v: 1
|
|
140
|
+
blocks:
|
|
141
|
+
- type: text
|
|
142
|
+
markdown: I could not find any signups for that range. Try a wider date window."
|
|
143
|
+
`;
|
|
144
|
+
|
|
145
|
+
exports[`blocksPromptSection with richBlocks false matches the pre-rich-blocks prompt for hostActions, even with stepper and checklist actions 1`] = `
|
|
146
|
+
"Your entire reply is one document; no prose outside it; no text before tool calls.
|
|
147
|
+
The document is YAML or JSON. Keys, when present, are in this order: v, datasets, blocks.
|
|
148
|
+
v is 1.
|
|
149
|
+
Block types: heading, text, metric, badge, divider, context, chart, table, actions, columns, card, callout, image, details. Do not emit type html.
|
|
150
|
+
An html field is at most 100000 bytes.
|
|
151
|
+
callout requires text and may set status to info, warning, or alert.
|
|
152
|
+
image requires alt and src. src is a data:image URL, a file: ref, or an https URL on an allowed host.
|
|
153
|
+
Do not emit an https image src. Use a data:image URL or a file: ref.
|
|
154
|
+
details requires title and text.
|
|
155
|
+
heading requires text. text requires markdown. metric requires label and value. badge requires text. context requires text.
|
|
156
|
+
chart kind is line, bar, area, or donut. Bind it with data, x, and y, or with points of label and value.
|
|
157
|
+
table requires data, the name of a dataset. actions requires id and elements.
|
|
158
|
+
An element is a button (id, text, action) or a segmented control (id, target, options of label and data).
|
|
159
|
+
action.kind is reply (text), open (url or route, exactly one), select (target and data), or callback (name and optional payload).
|
|
160
|
+
columns has 2 to 4 children. card has children and an optional title. Do not nest columns or card inside columns or card.
|
|
161
|
+
At most 50 blocks, including nested blocks.
|
|
162
|
+
Depth is at most 2.
|
|
163
|
+
An actions block has at most 25 elements.
|
|
164
|
+
columns has 2 to 4 children.
|
|
165
|
+
At most 8 datasets.
|
|
166
|
+
An inline dataset has at most 500 rows and 12 columns.
|
|
167
|
+
A ref dataset limit is at most 1000.
|
|
168
|
+
A text block has at most 4000 characters.
|
|
169
|
+
A document has at most 20000 characters of text.
|
|
170
|
+
Heading text is at most 200 characters.
|
|
171
|
+
Badge text is at most 80 characters.
|
|
172
|
+
Context text is at most 280 characters.
|
|
173
|
+
A card title is at most 120 characters.
|
|
174
|
+
A metric label is at most 80 characters, its value 80, its delta 40, and its helper 120.
|
|
175
|
+
A bar chart warns above 60 categories.
|
|
176
|
+
A donut chart warns above 8 slices.
|
|
177
|
+
Use the datasetId a tool returned; never paste more than 500 rows.
|
|
178
|
+
A callback name must be one of: exportDataset.
|
|
179
|
+
Example with data:
|
|
180
|
+
v: 1
|
|
181
|
+
datasets:
|
|
182
|
+
signups:
|
|
183
|
+
columns:
|
|
184
|
+
- name: month
|
|
185
|
+
type: string
|
|
186
|
+
- name: count
|
|
187
|
+
type: number
|
|
188
|
+
rows:
|
|
189
|
+
- [Jan, 120]
|
|
190
|
+
- [Feb, 180]
|
|
191
|
+
blocks:
|
|
192
|
+
- type: chart
|
|
193
|
+
id: signups_chart
|
|
194
|
+
kind: bar
|
|
195
|
+
data: signups
|
|
196
|
+
x: month
|
|
197
|
+
y: count
|
|
198
|
+
title: Signups by month
|
|
199
|
+
- type: actions
|
|
200
|
+
id: followups
|
|
201
|
+
elements:
|
|
202
|
+
- type: button
|
|
203
|
+
id: weekly
|
|
204
|
+
text: Show weekly
|
|
205
|
+
action:
|
|
206
|
+
kind: reply
|
|
207
|
+
text: Show weekly signups for this quarter
|
|
208
|
+
Example with prose only:
|
|
209
|
+
v: 1
|
|
210
|
+
blocks:
|
|
211
|
+
- type: text
|
|
212
|
+
markdown: I could not find any signups for that range. Try a wider date window."
|
|
213
|
+
`;
|
|
214
|
+
|
|
215
|
+
exports[`blocksPromptSection with richBlocks false matches the pre-rich-blocks prompt for imageHosts, even with stepper and checklist actions 1`] = `
|
|
216
|
+
"Your entire reply is one document; no prose outside it; no text before tool calls.
|
|
217
|
+
The document is YAML or JSON. Keys, when present, are in this order: v, datasets, blocks.
|
|
218
|
+
v is 1.
|
|
219
|
+
Block types: heading, text, metric, badge, divider, context, chart, table, actions, columns, card, callout, image, details. Do not emit type html.
|
|
220
|
+
An html field is at most 100000 bytes.
|
|
221
|
+
callout requires text and may set status to info, warning, or alert.
|
|
222
|
+
image requires alt and src. src is a data:image URL, a file: ref, or an https URL on an allowed host.
|
|
223
|
+
An https image src must use one of these hosts: cdn.example.com.
|
|
224
|
+
details requires title and text.
|
|
225
|
+
heading requires text. text requires markdown. metric requires label and value. badge requires text. context requires text.
|
|
226
|
+
chart kind is line, bar, area, or donut. Bind it with data, x, and y, or with points of label and value.
|
|
227
|
+
table requires data, the name of a dataset. actions requires id and elements.
|
|
228
|
+
An element is a button (id, text, action) or a segmented control (id, target, options of label and data).
|
|
229
|
+
action.kind is reply (text), open (url or route, exactly one), select (target and data), or callback (name and optional payload).
|
|
230
|
+
columns has 2 to 4 children. card has children and an optional title. Do not nest columns or card inside columns or card.
|
|
231
|
+
At most 50 blocks, including nested blocks.
|
|
232
|
+
Depth is at most 2.
|
|
233
|
+
An actions block has at most 25 elements.
|
|
234
|
+
columns has 2 to 4 children.
|
|
235
|
+
At most 8 datasets.
|
|
236
|
+
An inline dataset has at most 500 rows and 12 columns.
|
|
237
|
+
A ref dataset limit is at most 1000.
|
|
238
|
+
A text block has at most 4000 characters.
|
|
239
|
+
A document has at most 20000 characters of text.
|
|
240
|
+
Heading text is at most 200 characters.
|
|
241
|
+
Badge text is at most 80 characters.
|
|
242
|
+
Context text is at most 280 characters.
|
|
243
|
+
A card title is at most 120 characters.
|
|
244
|
+
A metric label is at most 80 characters, its value 80, its delta 40, and its helper 120.
|
|
245
|
+
A bar chart warns above 60 categories.
|
|
246
|
+
A donut chart warns above 8 slices.
|
|
247
|
+
Use the datasetId a tool returned; never paste more than 500 rows.
|
|
248
|
+
No callback names are registered. Do not emit kind callback.
|
|
249
|
+
Example with data:
|
|
250
|
+
v: 1
|
|
251
|
+
datasets:
|
|
252
|
+
signups:
|
|
253
|
+
columns:
|
|
254
|
+
- name: month
|
|
255
|
+
type: string
|
|
256
|
+
- name: count
|
|
257
|
+
type: number
|
|
258
|
+
rows:
|
|
259
|
+
- [Jan, 120]
|
|
260
|
+
- [Feb, 180]
|
|
261
|
+
blocks:
|
|
262
|
+
- type: chart
|
|
263
|
+
id: signups_chart
|
|
264
|
+
kind: bar
|
|
265
|
+
data: signups
|
|
266
|
+
x: month
|
|
267
|
+
y: count
|
|
268
|
+
title: Signups by month
|
|
269
|
+
- type: actions
|
|
270
|
+
id: followups
|
|
271
|
+
elements:
|
|
272
|
+
- type: button
|
|
273
|
+
id: weekly
|
|
274
|
+
text: Show weekly
|
|
275
|
+
action:
|
|
276
|
+
kind: reply
|
|
277
|
+
text: Show weekly signups for this quarter
|
|
278
|
+
Example with prose only:
|
|
279
|
+
v: 1
|
|
280
|
+
blocks:
|
|
281
|
+
- type: text
|
|
282
|
+
markdown: I could not find any signups for that range. Try a wider date window."
|
|
283
|
+
`;
|
|
284
|
+
|
|
285
|
+
exports[`blocksPromptSection with richBlocks false matches the pre-rich-blocks prompt for none, even with stepper and checklist actions 1`] = `
|
|
286
|
+
"Your entire reply is one document; no prose outside it; no text before tool calls.
|
|
287
|
+
The document is YAML or JSON. Keys, when present, are in this order: v, datasets, blocks.
|
|
288
|
+
v is 1.
|
|
289
|
+
Block types: heading, text, metric, badge, divider, context, chart, table, actions, columns, card, callout, image, details. Do not emit type html.
|
|
290
|
+
An html field is at most 100000 bytes.
|
|
291
|
+
callout requires text and may set status to info, warning, or alert.
|
|
292
|
+
image requires alt and src. src is a data:image URL, a file: ref, or an https URL on an allowed host.
|
|
293
|
+
Do not emit an https image src. Use a data:image URL or a file: ref.
|
|
294
|
+
details requires title and text.
|
|
295
|
+
heading requires text. text requires markdown. metric requires label and value. badge requires text. context requires text.
|
|
296
|
+
chart kind is line, bar, area, or donut. Bind it with data, x, and y, or with points of label and value.
|
|
297
|
+
table requires data, the name of a dataset. actions requires id and elements.
|
|
298
|
+
An element is a button (id, text, action) or a segmented control (id, target, options of label and data).
|
|
299
|
+
action.kind is reply (text), open (url or route, exactly one), select (target and data), or callback (name and optional payload).
|
|
300
|
+
columns has 2 to 4 children. card has children and an optional title. Do not nest columns or card inside columns or card.
|
|
301
|
+
At most 50 blocks, including nested blocks.
|
|
302
|
+
Depth is at most 2.
|
|
303
|
+
An actions block has at most 25 elements.
|
|
304
|
+
columns has 2 to 4 children.
|
|
305
|
+
At most 8 datasets.
|
|
306
|
+
An inline dataset has at most 500 rows and 12 columns.
|
|
307
|
+
A ref dataset limit is at most 1000.
|
|
308
|
+
A text block has at most 4000 characters.
|
|
309
|
+
A document has at most 20000 characters of text.
|
|
310
|
+
Heading text is at most 200 characters.
|
|
311
|
+
Badge text is at most 80 characters.
|
|
312
|
+
Context text is at most 280 characters.
|
|
313
|
+
A card title is at most 120 characters.
|
|
314
|
+
A metric label is at most 80 characters, its value 80, its delta 40, and its helper 120.
|
|
315
|
+
A bar chart warns above 60 categories.
|
|
316
|
+
A donut chart warns above 8 slices.
|
|
317
|
+
Use the datasetId a tool returned; never paste more than 500 rows.
|
|
318
|
+
No callback names are registered. Do not emit kind callback.
|
|
319
|
+
Example with data:
|
|
320
|
+
v: 1
|
|
321
|
+
datasets:
|
|
322
|
+
signups:
|
|
323
|
+
columns:
|
|
324
|
+
- name: month
|
|
325
|
+
type: string
|
|
326
|
+
- name: count
|
|
327
|
+
type: number
|
|
328
|
+
rows:
|
|
329
|
+
- [Jan, 120]
|
|
330
|
+
- [Feb, 180]
|
|
331
|
+
blocks:
|
|
332
|
+
- type: chart
|
|
333
|
+
id: signups_chart
|
|
334
|
+
kind: bar
|
|
335
|
+
data: signups
|
|
336
|
+
x: month
|
|
337
|
+
y: count
|
|
338
|
+
title: Signups by month
|
|
339
|
+
- type: actions
|
|
340
|
+
id: followups
|
|
341
|
+
elements:
|
|
342
|
+
- type: button
|
|
343
|
+
id: weekly
|
|
344
|
+
text: Show weekly
|
|
345
|
+
action:
|
|
346
|
+
kind: reply
|
|
347
|
+
text: Show weekly signups for this quarter
|
|
348
|
+
Example with prose only:
|
|
349
|
+
v: 1
|
|
350
|
+
blocks:
|
|
351
|
+
- type: text
|
|
352
|
+
markdown: I could not find any signups for that range. Try a wider date window."
|
|
353
|
+
`;
|
|
354
|
+
|
|
355
|
+
exports[`blocksPromptSection with richBlocks on matches the full rich-blocks prompt with stepper and checklist actions 1`] = `
|
|
356
|
+
"Your entire reply is one document; no prose outside it; no text before tool calls.
|
|
357
|
+
The document is YAML or JSON. Keys, when present, are in this order: v, datasets, blocks.
|
|
358
|
+
v is 1.
|
|
359
|
+
Block types: heading, text, metric, badge, divider, context, chart, table, actions, columns, card, callout, image, details, stepper, checklist, gallery, list. Do not emit type html.
|
|
360
|
+
An html field is at most 100000 bytes.
|
|
361
|
+
callout requires text and may set status to info, warning, or alert.
|
|
362
|
+
image requires alt and src. src is a data:image URL, a file: ref, or an https URL on an allowed host.
|
|
363
|
+
An https image src must use one of these hosts: images.example.com.
|
|
364
|
+
details requires title and text.
|
|
365
|
+
stepper requires id, label, value, min, max, and callback (name and optional payload). It may set step (above 0, default 1), unit, itemsTitle, items, and note. min is below max, and value is between them.
|
|
366
|
+
Its decrease and increase buttons send the callback with payload.value set to the next value. The host returns the updated stepper, so write item amounts for the starting value.
|
|
367
|
+
A stepper callback name must be one of: scaleStepper.
|
|
368
|
+
A stepper item requires label and amount. It may set unit, decimals, and round (nearest or up).
|
|
369
|
+
A stepper id is at most 54 characters. No other id may be <id>_decrease or <id>_increase.
|
|
370
|
+
A stepper label and itemsTitle are at most 80 characters, its unit 40, and its note 280.
|
|
371
|
+
A stepper has at most 12 items. An item label is at most 80 characters, its unit 20, and decimals is 0 to 3.
|
|
372
|
+
checklist requires id and items, and may set title. It shows a done count such as 2 of 8.
|
|
373
|
+
A checklist item requires id and text. It may set meta (a short label such as a time, shown under the text), detail (a muted line under that), and checked (true or false).
|
|
374
|
+
Set a checklist callback name to one of: toggleChecklist. Its payload is optional. Each tick sends the callback with payload.itemId, payload.checked, and payload.state, and the host returns the updated checklist.
|
|
375
|
+
A checklist id is at most 31 characters and an item id 32. Item ids are unique in the checklist, and no other id may be <id>_<item id>.
|
|
376
|
+
A checklist has 1 to 30 items. Its title is at most 120 characters, an item text 120, an item meta 40, and an item detail 280.
|
|
377
|
+
gallery requires images: 2 to 6 photos shown together. Each image requires src and alt, and may set caption. Each src follows the image src rules above.
|
|
378
|
+
A gallery image alt is at most 200 characters and its caption 120.
|
|
379
|
+
list requires items: 1 to 12 entries stacked one under another. Each item requires title, and may set text (plain text, not markdown), meta (a short label such as a time or a price), and image (src and alt, a thumbnail). Each image src follows the image src rules above.
|
|
380
|
+
A list item title is at most 120 characters, its text 500, its meta 40, and its image alt 200.
|
|
381
|
+
A card may set eyebrow, a short label shown small above its title. An eyebrow is at most 60 characters.
|
|
382
|
+
heading requires text. text requires markdown. metric requires label and value. badge requires text. context requires text.
|
|
383
|
+
chart kind is line, bar, area, or donut. Bind it with data, x, and y, or with points of label and value.
|
|
384
|
+
table requires data, the name of a dataset. actions requires id and elements.
|
|
385
|
+
An element is a button (id, text, action) or a segmented control (id, target, options of label and data).
|
|
386
|
+
action.kind is reply (text), open (url or route, exactly one), select (target and data), or callback (name and optional payload).
|
|
387
|
+
action.kind may also be copy: it copies to the clipboard on the device and never reaches the host. A copy action sets exactly one of text (at most 4000 characters, copied as written) or target (the id of a stepper, checklist, list, table, or text block in this document, whose current contents are copied).
|
|
388
|
+
columns has 2 to 4 children. card has children and an optional title. Do not nest columns or card inside columns or card.
|
|
389
|
+
At most 50 blocks, including nested blocks.
|
|
390
|
+
Depth is at most 2.
|
|
391
|
+
An actions block has at most 25 elements.
|
|
392
|
+
columns has 2 to 4 children.
|
|
393
|
+
At most 8 datasets.
|
|
394
|
+
An inline dataset has at most 500 rows and 12 columns.
|
|
395
|
+
A ref dataset limit is at most 1000.
|
|
396
|
+
A text block has at most 4000 characters.
|
|
397
|
+
A document has at most 20000 characters of text.
|
|
398
|
+
Heading text is at most 200 characters.
|
|
399
|
+
Badge text is at most 80 characters.
|
|
400
|
+
Context text is at most 280 characters.
|
|
401
|
+
A card title is at most 120 characters.
|
|
402
|
+
A metric label is at most 80 characters, its value 80, its delta 40, and its helper 120.
|
|
403
|
+
A bar chart warns above 60 categories.
|
|
404
|
+
A donut chart warns above 8 slices.
|
|
405
|
+
Use the datasetId a tool returned; never paste more than 500 rows.
|
|
406
|
+
A callback name must be one of: approve, scaleStepper, toggleChecklist.
|
|
407
|
+
Example with data:
|
|
408
|
+
v: 1
|
|
409
|
+
datasets:
|
|
410
|
+
signups:
|
|
411
|
+
columns:
|
|
412
|
+
- name: month
|
|
413
|
+
type: string
|
|
414
|
+
- name: count
|
|
415
|
+
type: number
|
|
416
|
+
rows:
|
|
417
|
+
- [Jan, 120]
|
|
418
|
+
- [Feb, 180]
|
|
419
|
+
blocks:
|
|
420
|
+
- type: chart
|
|
421
|
+
id: signups_chart
|
|
422
|
+
kind: bar
|
|
423
|
+
data: signups
|
|
424
|
+
x: month
|
|
425
|
+
y: count
|
|
426
|
+
title: Signups by month
|
|
427
|
+
- type: actions
|
|
428
|
+
id: followups
|
|
429
|
+
elements:
|
|
430
|
+
- type: button
|
|
431
|
+
id: weekly
|
|
432
|
+
text: Show weekly
|
|
433
|
+
action:
|
|
434
|
+
kind: reply
|
|
435
|
+
text: Show weekly signups for this quarter
|
|
436
|
+
Example with prose only:
|
|
437
|
+
v: 1
|
|
438
|
+
blocks:
|
|
439
|
+
- type: text
|
|
440
|
+
markdown: I could not find any signups for that range. Try a wider date window."
|
|
441
|
+
`;
|
|
442
|
+
|
|
443
|
+
exports[`blocksPromptSection with richBlocks on matches the full rich-blocks prompt with html allowed 1`] = `
|
|
444
|
+
"Your entire reply is one document; no prose outside it; no text before tool calls.
|
|
445
|
+
The document is YAML or JSON. Keys, when present, are in this order: v, datasets, blocks.
|
|
446
|
+
v is 1.
|
|
447
|
+
Block types: heading, text, metric, badge, divider, context, chart, table, actions, columns, card, html, callout, image, details, stepper, checklist, gallery, list.
|
|
448
|
+
An html field is at most 100000 bytes.
|
|
449
|
+
html requires html and may set title and height (sm, md, or lg). It is a display preview: no scripts, no links, no network.
|
|
450
|
+
callout requires text and may set status to info, warning, or alert.
|
|
451
|
+
image requires alt and src. src is a data:image URL, a file: ref, or an https URL on an allowed host.
|
|
452
|
+
An https image src must use one of these hosts: images.example.com.
|
|
453
|
+
details requires title and text.
|
|
454
|
+
stepper requires id, label, value, min, max, and callback (name and optional payload). It may set step (above 0, default 1), unit, itemsTitle, items, and note. min is below max, and value is between them.
|
|
455
|
+
Its decrease and increase buttons send the callback with payload.value set to the next value. The host returns the updated stepper, so write item amounts for the starting value.
|
|
456
|
+
A stepper callback name must be one of: scaleStepper.
|
|
457
|
+
A stepper item requires label and amount. It may set unit, decimals, and round (nearest or up).
|
|
458
|
+
A stepper id is at most 54 characters. No other id may be <id>_decrease or <id>_increase.
|
|
459
|
+
A stepper label and itemsTitle are at most 80 characters, its unit 40, and its note 280.
|
|
460
|
+
A stepper has at most 12 items. An item label is at most 80 characters, its unit 20, and decimals is 0 to 3.
|
|
461
|
+
checklist requires id and items, and may set title. It shows a done count such as 2 of 8.
|
|
462
|
+
A checklist item requires id and text. It may set meta (a short label such as a time, shown under the text), detail (a muted line under that), and checked (true or false).
|
|
463
|
+
Set a checklist callback name to one of: toggleChecklist. Its payload is optional. Each tick sends the callback with payload.itemId, payload.checked, and payload.state, and the host returns the updated checklist.
|
|
464
|
+
A checklist id is at most 31 characters and an item id 32. Item ids are unique in the checklist, and no other id may be <id>_<item id>.
|
|
465
|
+
A checklist has 1 to 30 items. Its title is at most 120 characters, an item text 120, an item meta 40, and an item detail 280.
|
|
466
|
+
gallery requires images: 2 to 6 photos shown together. Each image requires src and alt, and may set caption. Each src follows the image src rules above.
|
|
467
|
+
A gallery image alt is at most 200 characters and its caption 120.
|
|
468
|
+
list requires items: 1 to 12 entries stacked one under another. Each item requires title, and may set text (plain text, not markdown), meta (a short label such as a time or a price), and image (src and alt, a thumbnail). Each image src follows the image src rules above.
|
|
469
|
+
A list item title is at most 120 characters, its text 500, its meta 40, and its image alt 200.
|
|
470
|
+
A card may set eyebrow, a short label shown small above its title. An eyebrow is at most 60 characters.
|
|
471
|
+
heading requires text. text requires markdown. metric requires label and value. badge requires text. context requires text.
|
|
472
|
+
chart kind is line, bar, area, or donut. Bind it with data, x, and y, or with points of label and value.
|
|
473
|
+
table requires data, the name of a dataset. actions requires id and elements.
|
|
474
|
+
An element is a button (id, text, action) or a segmented control (id, target, options of label and data).
|
|
475
|
+
action.kind is reply (text), open (url or route, exactly one), select (target and data), or callback (name and optional payload).
|
|
476
|
+
action.kind may also be copy: it copies to the clipboard on the device and never reaches the host. A copy action sets exactly one of text (at most 4000 characters, copied as written) or target (the id of a stepper, checklist, list, table, or text block in this document, whose current contents are copied).
|
|
477
|
+
columns has 2 to 4 children. card has children and an optional title. Do not nest columns or card inside columns or card.
|
|
478
|
+
At most 50 blocks, including nested blocks.
|
|
479
|
+
Depth is at most 2.
|
|
480
|
+
An actions block has at most 25 elements.
|
|
481
|
+
columns has 2 to 4 children.
|
|
482
|
+
At most 8 datasets.
|
|
483
|
+
An inline dataset has at most 500 rows and 12 columns.
|
|
484
|
+
A ref dataset limit is at most 1000.
|
|
485
|
+
A text block has at most 4000 characters.
|
|
486
|
+
A document has at most 20000 characters of text.
|
|
487
|
+
Heading text is at most 200 characters.
|
|
488
|
+
Badge text is at most 80 characters.
|
|
489
|
+
Context text is at most 280 characters.
|
|
490
|
+
A card title is at most 120 characters.
|
|
491
|
+
A metric label is at most 80 characters, its value 80, its delta 40, and its helper 120.
|
|
492
|
+
A bar chart warns above 60 categories.
|
|
493
|
+
A donut chart warns above 8 slices.
|
|
494
|
+
Use the datasetId a tool returned; never paste more than 500 rows.
|
|
495
|
+
A callback name must be one of: approve, scaleStepper, toggleChecklist.
|
|
496
|
+
Example with data:
|
|
497
|
+
v: 1
|
|
498
|
+
datasets:
|
|
499
|
+
signups:
|
|
500
|
+
columns:
|
|
501
|
+
- name: month
|
|
502
|
+
type: string
|
|
503
|
+
- name: count
|
|
504
|
+
type: number
|
|
505
|
+
rows:
|
|
506
|
+
- [Jan, 120]
|
|
507
|
+
- [Feb, 180]
|
|
508
|
+
blocks:
|
|
509
|
+
- type: chart
|
|
510
|
+
id: signups_chart
|
|
511
|
+
kind: bar
|
|
512
|
+
data: signups
|
|
513
|
+
x: month
|
|
514
|
+
y: count
|
|
515
|
+
title: Signups by month
|
|
516
|
+
- type: actions
|
|
517
|
+
id: followups
|
|
518
|
+
elements:
|
|
519
|
+
- type: button
|
|
520
|
+
id: weekly
|
|
521
|
+
text: Show weekly
|
|
522
|
+
action:
|
|
523
|
+
kind: reply
|
|
524
|
+
text: Show weekly signups for this quarter
|
|
525
|
+
Example with prose only:
|
|
526
|
+
v: 1
|
|
527
|
+
blocks:
|
|
528
|
+
- type: text
|
|
529
|
+
markdown: I could not find any signups for that range. Try a wider date window."
|
|
530
|
+
`;
|
package/src/errors.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export const BLOCK_ERROR_CODES = {
|
|
3
3
|
COLUMN_NOT_FOUND: "A chart or table names a column the dataset does not have.",
|
|
4
4
|
COLUMN_TYPE_MISMATCH: "A column value does not match the column type.",
|
|
5
|
+
COPY_TARGET_INVALID:
|
|
6
|
+
"A copy action names a block that is not a stepper, checklist, list, table, or text block.",
|
|
5
7
|
DATASET_NOT_FOUND: "A chart or table names a dataset the document does not define.",
|
|
6
8
|
DATASET_TOO_LARGE: "A dataset has more rows or columns than allowed.",
|
|
7
9
|
DEPTH_EXCEEDED: "A columns or card block is nested inside another columns or card block.",
|
|
@@ -16,6 +18,8 @@ export const BLOCK_ERROR_CODES = {
|
|
|
16
18
|
KEY_ORDER: "Top-level keys are not in the order v, datasets, blocks.",
|
|
17
19
|
MISSING_REQUIRED: "A required field is missing.",
|
|
18
20
|
NOT_A_DOCUMENT: "The reply is not one YAML or JSON mapping with a v field.",
|
|
21
|
+
OUT_OF_RANGE:
|
|
22
|
+
"A number is outside its allowed range, such as a stepper value outside min and max.",
|
|
19
23
|
ROW_ARITY_MISMATCH: "A dataset row does not have one value per column.",
|
|
20
24
|
SELECT_TARGET_INVALID: "A select action names a block that is not a chart or table.",
|
|
21
25
|
TABLE_TOO_WIDE: "A table lists more columns than allowed.",
|