@buoy-gg/ask-buoy 7.0.33 → 7.0.34

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 (153) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/blocks/AskBlocks.js +1 -338
  3. package/lib/commonjs/blocks/BlockRenderer.js +1 -250
  4. package/lib/commonjs/blocks/ChromePrototypes.js +1 -514
  5. package/lib/commonjs/blocks/DataBlocks.js +1 -545
  6. package/lib/commonjs/blocks/ExtraBlocks.js +1 -1821
  7. package/lib/commonjs/blocks/MediaBlocks.js +1 -140
  8. package/lib/commonjs/blocks/ReceiptBlocks.js +1 -596
  9. package/lib/commonjs/blocks/context.js +1 -42
  10. package/lib/commonjs/blocks/icons.js +1 -96
  11. package/lib/commonjs/blocks/index.js +1 -95
  12. package/lib/commonjs/blocks/primitives.js +1 -312
  13. package/lib/commonjs/blocks/primitivesIndex.js +1 -56
  14. package/lib/commonjs/components/ApprovalCard.js +1 -140
  15. package/lib/commonjs/components/AskBuoyHeader.js +1 -127
  16. package/lib/commonjs/components/AskBuoyIcon.js +1 -19
  17. package/lib/commonjs/components/AskBuoyModal.js +1 -322
  18. package/lib/commonjs/components/ChangesBar.js +1 -211
  19. package/lib/commonjs/components/Composer.js +1 -175
  20. package/lib/commonjs/components/EmptyState.js +1 -154
  21. package/lib/commonjs/components/Markdown.js +1 -252
  22. package/lib/commonjs/components/MessageList.js +1 -648
  23. package/lib/commonjs/components/TypingDots.js +1 -63
  24. package/lib/commonjs/index.js +1 -205
  25. package/lib/commonjs/preset.js +1 -90
  26. package/lib/commonjs/store/askBuoyStore.js +1 -279
  27. package/lib/commonjs/store/useAskBuoy.js +1 -299
  28. package/lib/commonjs/sync/askBuoySyncAdapter.js +1 -119
  29. package/lib/commonjs/sync/askBuoySyncAdapter.test.js +1 -136
  30. package/lib/commonjs/sync/wire.js +1 -58
  31. package/lib/commonjs/types.js +1 -6
  32. package/lib/module/blocks/AskBlocks.js +1 -331
  33. package/lib/module/blocks/BlockRenderer.js +1 -245
  34. package/lib/module/blocks/ChromePrototypes.js +1 -503
  35. package/lib/module/blocks/DataBlocks.js +1 -532
  36. package/lib/module/blocks/ExtraBlocks.js +1 -1794
  37. package/lib/module/blocks/MediaBlocks.js +1 -135
  38. package/lib/module/blocks/ReceiptBlocks.js +1 -584
  39. package/lib/module/blocks/context.js +1 -35
  40. package/lib/module/blocks/icons.js +1 -91
  41. package/lib/module/blocks/index.js +1 -8
  42. package/lib/module/blocks/primitives.js +1 -301
  43. package/lib/module/blocks/primitivesIndex.js +1 -5
  44. package/lib/module/components/ApprovalCard.js +1 -135
  45. package/lib/module/components/AskBuoyHeader.js +1 -124
  46. package/lib/module/components/AskBuoyIcon.js +1 -8
  47. package/lib/module/components/AskBuoyModal.js +1 -317
  48. package/lib/module/components/ChangesBar.js +1 -206
  49. package/lib/module/components/Composer.js +1 -170
  50. package/lib/module/components/EmptyState.js +1 -149
  51. package/lib/module/components/Markdown.js +1 -246
  52. package/lib/module/components/MessageList.js +1 -642
  53. package/lib/module/components/TypingDots.js +1 -58
  54. package/lib/module/index.js +1 -29
  55. package/lib/module/preset.js +1 -73
  56. package/lib/module/store/askBuoyStore.js +1 -275
  57. package/lib/module/store/useAskBuoy.js +1 -293
  58. package/lib/module/sync/askBuoySyncAdapter.js +1 -114
  59. package/lib/module/sync/askBuoySyncAdapter.test.js +1 -135
  60. package/lib/module/sync/wire.js +1 -47
  61. package/lib/module/types.js +1 -4
  62. package/lib/typescript/preset.d.ts +1 -1
  63. package/package.json +8 -8
  64. package/lib/commonjs/blocks/AskBlocks.js.map +0 -1
  65. package/lib/commonjs/blocks/BlockRenderer.js.map +0 -1
  66. package/lib/commonjs/blocks/ChromePrototypes.js.map +0 -1
  67. package/lib/commonjs/blocks/DataBlocks.js.map +0 -1
  68. package/lib/commonjs/blocks/ExtraBlocks.js.map +0 -1
  69. package/lib/commonjs/blocks/MediaBlocks.js.map +0 -1
  70. package/lib/commonjs/blocks/ReceiptBlocks.js.map +0 -1
  71. package/lib/commonjs/blocks/context.js.map +0 -1
  72. package/lib/commonjs/blocks/icons.js.map +0 -1
  73. package/lib/commonjs/blocks/index.js.map +0 -1
  74. package/lib/commonjs/blocks/primitives.js.map +0 -1
  75. package/lib/commonjs/blocks/primitivesIndex.js.map +0 -1
  76. package/lib/commonjs/components/ApprovalCard.js.map +0 -1
  77. package/lib/commonjs/components/AskBuoyHeader.js.map +0 -1
  78. package/lib/commonjs/components/AskBuoyIcon.js.map +0 -1
  79. package/lib/commonjs/components/AskBuoyModal.js.map +0 -1
  80. package/lib/commonjs/components/ChangesBar.js.map +0 -1
  81. package/lib/commonjs/components/Composer.js.map +0 -1
  82. package/lib/commonjs/components/EmptyState.js.map +0 -1
  83. package/lib/commonjs/components/Markdown.js.map +0 -1
  84. package/lib/commonjs/components/MessageList.js.map +0 -1
  85. package/lib/commonjs/components/TypingDots.js.map +0 -1
  86. package/lib/commonjs/index.js.map +0 -1
  87. package/lib/commonjs/preset.js.map +0 -1
  88. package/lib/commonjs/store/askBuoyStore.js.map +0 -1
  89. package/lib/commonjs/store/useAskBuoy.js.map +0 -1
  90. package/lib/commonjs/sync/askBuoySyncAdapter.js.map +0 -1
  91. package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +0 -1
  92. package/lib/commonjs/sync/wire.js.map +0 -1
  93. package/lib/commonjs/types.js.map +0 -1
  94. package/lib/module/blocks/AskBlocks.js.map +0 -1
  95. package/lib/module/blocks/BlockRenderer.js.map +0 -1
  96. package/lib/module/blocks/ChromePrototypes.js.map +0 -1
  97. package/lib/module/blocks/DataBlocks.js.map +0 -1
  98. package/lib/module/blocks/ExtraBlocks.js.map +0 -1
  99. package/lib/module/blocks/MediaBlocks.js.map +0 -1
  100. package/lib/module/blocks/ReceiptBlocks.js.map +0 -1
  101. package/lib/module/blocks/context.js.map +0 -1
  102. package/lib/module/blocks/icons.js.map +0 -1
  103. package/lib/module/blocks/index.js.map +0 -1
  104. package/lib/module/blocks/primitives.js.map +0 -1
  105. package/lib/module/blocks/primitivesIndex.js.map +0 -1
  106. package/lib/module/components/ApprovalCard.js.map +0 -1
  107. package/lib/module/components/AskBuoyHeader.js.map +0 -1
  108. package/lib/module/components/AskBuoyIcon.js.map +0 -1
  109. package/lib/module/components/AskBuoyModal.js.map +0 -1
  110. package/lib/module/components/ChangesBar.js.map +0 -1
  111. package/lib/module/components/Composer.js.map +0 -1
  112. package/lib/module/components/EmptyState.js.map +0 -1
  113. package/lib/module/components/Markdown.js.map +0 -1
  114. package/lib/module/components/MessageList.js.map +0 -1
  115. package/lib/module/components/TypingDots.js.map +0 -1
  116. package/lib/module/index.js.map +0 -1
  117. package/lib/module/preset.js.map +0 -1
  118. package/lib/module/store/askBuoyStore.js.map +0 -1
  119. package/lib/module/store/useAskBuoy.js.map +0 -1
  120. package/lib/module/sync/askBuoySyncAdapter.js.map +0 -1
  121. package/lib/module/sync/askBuoySyncAdapter.test.js.map +0 -1
  122. package/lib/module/sync/wire.js.map +0 -1
  123. package/lib/module/types.js.map +0 -1
  124. package/lib/typescript/blocks/AskBlocks.d.ts.map +0 -1
  125. package/lib/typescript/blocks/BlockRenderer.d.ts.map +0 -1
  126. package/lib/typescript/blocks/ChromePrototypes.d.ts.map +0 -1
  127. package/lib/typescript/blocks/DataBlocks.d.ts.map +0 -1
  128. package/lib/typescript/blocks/ExtraBlocks.d.ts.map +0 -1
  129. package/lib/typescript/blocks/MediaBlocks.d.ts.map +0 -1
  130. package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +0 -1
  131. package/lib/typescript/blocks/context.d.ts.map +0 -1
  132. package/lib/typescript/blocks/icons.d.ts.map +0 -1
  133. package/lib/typescript/blocks/index.d.ts.map +0 -1
  134. package/lib/typescript/blocks/primitives.d.ts.map +0 -1
  135. package/lib/typescript/blocks/primitivesIndex.d.ts.map +0 -1
  136. package/lib/typescript/components/ApprovalCard.d.ts.map +0 -1
  137. package/lib/typescript/components/AskBuoyHeader.d.ts.map +0 -1
  138. package/lib/typescript/components/AskBuoyIcon.d.ts.map +0 -1
  139. package/lib/typescript/components/AskBuoyModal.d.ts.map +0 -1
  140. package/lib/typescript/components/ChangesBar.d.ts.map +0 -1
  141. package/lib/typescript/components/Composer.d.ts.map +0 -1
  142. package/lib/typescript/components/EmptyState.d.ts.map +0 -1
  143. package/lib/typescript/components/Markdown.d.ts.map +0 -1
  144. package/lib/typescript/components/MessageList.d.ts.map +0 -1
  145. package/lib/typescript/components/TypingDots.d.ts.map +0 -1
  146. package/lib/typescript/index.d.ts.map +0 -1
  147. package/lib/typescript/preset.d.ts.map +0 -1
  148. package/lib/typescript/store/askBuoyStore.d.ts.map +0 -1
  149. package/lib/typescript/store/useAskBuoy.d.ts.map +0 -1
  150. package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +0 -1
  151. package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +0 -1
  152. package/lib/typescript/sync/wire.d.ts.map +0 -1
  153. package/lib/typescript/types.d.ts.map +0 -1
@@ -1,532 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Show blocks — data the user should see rather than read.
5
- * Every one honours a cap and says "+N more" rather than growing the page.
6
- */
7
- import { useState } from "react";
8
- import { Image, Pressable, StyleSheet, Text, View } from "react-native";
9
- import { AlertTriangle, Check, Info, night, X } from "@buoy-gg/shared-ui";
10
- import { CAPS } from "@buoy-gg/agent-core";
11
- import { ActionRow, blockStyles as b, Card, More, toneColor, useBlockHandlers, useExpand } from "./primitivesIndex";
12
- import { renderInline } from "../components/Markdown";
13
- import { BlockIcon } from "./icons";
14
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
- function fmt(v) {
16
- if (v === undefined) return "—";
17
- if (v === null) return "null";
18
- if (typeof v === "string") return v;
19
- if (typeof v === "number" || typeof v === "boolean") return String(v);
20
- try {
21
- const s = JSON.stringify(v);
22
- return s.length > 120 ? `${s.slice(0, 117)}…` : s;
23
- } catch {
24
- return String(v);
25
- }
26
- }
27
- export function Table({
28
- block
29
- }) {
30
- const {
31
- visible,
32
- expanded,
33
- toggle
34
- } = useExpand(block.rows, CAPS.tableRows);
35
- const cols = block.columns.slice(0, 4);
36
- return /*#__PURE__*/_jsxs(Card, {
37
- title: block.title,
38
- source: block.source,
39
- testID: `buoy-block-table-${block.id}`,
40
- children: [/*#__PURE__*/_jsx(View, {
41
- style: styles.tableHead,
42
- children: cols.map((c, i) => /*#__PURE__*/_jsx(Text, {
43
- style: [styles.th, i === 0 && styles.firstCol],
44
- numberOfLines: 1,
45
- children: c
46
- }, c))
47
- }), visible.map((row, r) => /*#__PURE__*/_jsx(View, {
48
- style: [styles.tr, r > 0 && b.rowDivider],
49
- children: cols.map((_, i) => {
50
- const cell = row[i];
51
- const text = typeof cell === "string" ? cell : cell?.text ?? "";
52
- const tone = typeof cell === "string" ? undefined : cell?.tone;
53
- return /*#__PURE__*/_jsx(Text, {
54
- style: [styles.td, i === 0 && styles.firstCol, i === 0 && styles.tdFirst, tone && {
55
- color: toneColor(tone)
56
- }],
57
- numberOfLines: 2,
58
- children: renderInline(text, styles.td)
59
- }, i);
60
- })
61
- }, r)), /*#__PURE__*/_jsx(More, {
62
- shown: visible.length,
63
- total: block.total ?? block.rows.length,
64
- onExpand: block.rows.length > visible.length || expanded ? toggle : undefined,
65
- expanded: expanded
66
- })]
67
- });
68
- }
69
- export function KeyValue({
70
- block
71
- }) {
72
- const {
73
- visible,
74
- expanded,
75
- toggle
76
- } = useExpand(block.pairs, CAPS.keyValuePairs);
77
- const [open, setOpen] = useState(null);
78
- return /*#__PURE__*/_jsxs(Card, {
79
- title: block.title,
80
- source: block.source,
81
- testID: `buoy-block-keyvalue-${block.id}`,
82
- children: [visible.map((p, i) => {
83
- const long = typeof p.value === "object" && p.value !== null;
84
- const isOpen = open === p.key;
85
- return /*#__PURE__*/_jsxs(Pressable, {
86
- onPress: long ? () => setOpen(isOpen ? null : p.key) : undefined,
87
- style: [styles.kvRow, i > 0 && b.rowDivider],
88
- children: [/*#__PURE__*/_jsx(Text, {
89
- style: styles.kvKey,
90
- numberOfLines: 1,
91
- children: p.key
92
- }), /*#__PURE__*/_jsx(Text, {
93
- style: [styles.kvValue, isOpen && b.mono],
94
- numberOfLines: isOpen ? undefined : 2,
95
- selectable: true,
96
- children: isOpen ? JSON.stringify(p.value, null, 2) : fmt(p.value)
97
- })]
98
- }, p.key);
99
- }), /*#__PURE__*/_jsx(More, {
100
- shown: visible.length,
101
- total: block.pairs.length,
102
- onExpand: block.pairs.length > CAPS.keyValuePairs ? toggle : undefined,
103
- expanded: expanded
104
- })]
105
- });
106
- }
107
- export function List({
108
- block
109
- }) {
110
- const h = useBlockHandlers();
111
- const {
112
- visible,
113
- expanded,
114
- toggle
115
- } = useExpand(block.items, CAPS.listItems);
116
- return /*#__PURE__*/_jsxs(Card, {
117
- title: block.title,
118
- source: block.source,
119
- testID: `buoy-block-list-${block.id}`,
120
- children: [visible.map((it, i) => {
121
- const Row = it.action ? Pressable : View;
122
- return /*#__PURE__*/_jsxs(Row, {
123
- ...(it.action ? {
124
- onPress: () => void h.runAction(it.action, block.id),
125
- accessibilityRole: "button"
126
- } : {}),
127
- style: [b.row, i > 0 && b.rowDivider],
128
- children: [it.image ? /*#__PURE__*/_jsx(Image, {
129
- source: {
130
- uri: it.image
131
- },
132
- style: styles.thumb,
133
- accessibilityLabel: it.title
134
- }) : it.icon ? /*#__PURE__*/_jsx(BlockIcon, {
135
- name: it.icon
136
- }) : null, /*#__PURE__*/_jsxs(View, {
137
- style: styles.flex,
138
- children: [/*#__PURE__*/_jsx(Text, {
139
- style: [b.rowTitle, it.tone && {
140
- color: toneColor(it.tone)
141
- }],
142
- numberOfLines: 2,
143
- children: renderInline(it.title, b.rowTitle)
144
- }), it.subtitle ? /*#__PURE__*/_jsx(Text, {
145
- style: b.rowSub,
146
- numberOfLines: 2,
147
- children: renderInline(it.subtitle, b.rowSub)
148
- }) : null]
149
- }), it.trailing ? /*#__PURE__*/_jsx(Text, {
150
- style: [b.rowTrailing, it.tone && {
151
- color: toneColor(it.tone)
152
- }],
153
- numberOfLines: 1,
154
- children: it.trailing
155
- }) : null, it.action ? /*#__PURE__*/_jsx(Text, {
156
- style: styles.rowAction,
157
- children: it.action.label
158
- }) : null]
159
- }, it.id ?? `${it.title}-${i}`);
160
- }), /*#__PURE__*/_jsx(More, {
161
- shown: visible.length,
162
- total: block.total ?? block.items.length,
163
- onExpand: block.items.length > visible.length || expanded ? toggle : undefined,
164
- expanded: expanded
165
- })]
166
- });
167
- }
168
- export function Diff({
169
- block
170
- }) {
171
- return /*#__PURE__*/_jsxs(Card, {
172
- title: block.title ?? "What changed",
173
- source: block.source,
174
- testID: `buoy-block-diff-${block.id}`,
175
- children: [block.changes.slice(0, CAPS.keyValuePairs).map((c, i) => {
176
- const added = c.before === undefined && c.after !== undefined;
177
- const removed = c.after === undefined && c.before !== undefined;
178
- return /*#__PURE__*/_jsxs(View, {
179
- style: [styles.diffRow, i > 0 && b.rowDivider],
180
- children: [/*#__PURE__*/_jsx(Text, {
181
- style: styles.diffPath,
182
- numberOfLines: 1,
183
- children: c.path
184
- }), !added ? /*#__PURE__*/_jsxs(View, {
185
- style: styles.diffLine,
186
- children: [/*#__PURE__*/_jsx(Text, {
187
- style: [styles.diffMark, {
188
- color: night.color.danger
189
- }],
190
- children: "\u2212"
191
- }), /*#__PURE__*/_jsx(Text, {
192
- style: [styles.diffValue, {
193
- color: night.color.danger
194
- }],
195
- numberOfLines: 3,
196
- selectable: true,
197
- children: fmt(c.before)
198
- })]
199
- }) : null, !removed ? /*#__PURE__*/_jsxs(View, {
200
- style: styles.diffLine,
201
- children: [/*#__PURE__*/_jsx(Text, {
202
- style: [styles.diffMark, {
203
- color: night.color.accent
204
- }],
205
- children: "+"
206
- }), /*#__PURE__*/_jsx(Text, {
207
- style: [styles.diffValue, {
208
- color: night.color.accent
209
- }],
210
- numberOfLines: 3,
211
- selectable: true,
212
- children: fmt(c.after)
213
- })]
214
- }) : null]
215
- }, `${c.path}-${i}`);
216
- }), /*#__PURE__*/_jsx(More, {
217
- shown: Math.min(block.changes.length, CAPS.keyValuePairs),
218
- total: block.changes.length
219
- })]
220
- });
221
- }
222
- export function Chart({
223
- block
224
- }) {
225
- const bars = block.bars.slice(0, CAPS.chartBars);
226
- const max = block.max ?? Math.max(1, ...bars.map(x => x.value));
227
- return /*#__PURE__*/_jsx(Card, {
228
- title: block.title,
229
- source: block.source,
230
- testID: `buoy-block-chart-${block.id}`,
231
- children: /*#__PURE__*/_jsx(View, {
232
- style: styles.chart,
233
- children: bars.map(x => /*#__PURE__*/_jsxs(View, {
234
- style: styles.barRow,
235
- children: [/*#__PURE__*/_jsx(Text, {
236
- style: styles.barLabel,
237
- numberOfLines: 1,
238
- children: x.label
239
- }), /*#__PURE__*/_jsx(View, {
240
- style: styles.barTrack,
241
- children: /*#__PURE__*/_jsx(View, {
242
- style: [styles.bar, {
243
- width: `${Math.max(2, Math.round(x.value / max * 100))}%`,
244
- backgroundColor: toneColor(x.tone ?? "accent")
245
- }]
246
- })
247
- }), /*#__PURE__*/_jsxs(Text, {
248
- style: styles.barValue,
249
- numberOfLines: 1,
250
- children: [x.value, x.unit ? ` ${x.unit}` : ""]
251
- })]
252
- }, x.label))
253
- })
254
- });
255
- }
256
- export function Steps({
257
- block
258
- }) {
259
- return /*#__PURE__*/_jsx(Card, {
260
- title: block.title,
261
- testID: `buoy-block-steps-${block.id}`,
262
- children: block.steps.map((s, i) => /*#__PURE__*/_jsxs(View, {
263
- style: [styles.step, i > 0 && b.rowDivider],
264
- children: [/*#__PURE__*/_jsx(View, {
265
- style: [styles.stepMark, s.state === "done" && styles.stepDone, s.state === "failed" && styles.stepFailed],
266
- children: s.state === "done" ? /*#__PURE__*/_jsx(Check, {
267
- size: 10,
268
- color: night.color.onAccent
269
- }) : s.state === "failed" ? /*#__PURE__*/_jsx(X, {
270
- size: 10,
271
- color: night.color.text
272
- }) : /*#__PURE__*/_jsx(Text, {
273
- style: styles.stepNum,
274
- children: i + 1
275
- })
276
- }), /*#__PURE__*/_jsx(Text, {
277
- style: [b.rowTitle, s.state === "done" && styles.stepTextDone],
278
- children: s.text
279
- })]
280
- }, i))
281
- });
282
- }
283
- export function Code({
284
- block
285
- }) {
286
- const text = block.language === "json" ? tryPretty(block.text) : block.text;
287
- return /*#__PURE__*/_jsx(Card, {
288
- title: block.title,
289
- testID: `buoy-block-code-${block.id}`,
290
- children: /*#__PURE__*/_jsx(Text, {
291
- style: [b.mono, styles.code],
292
- selectable: true,
293
- children: text
294
- })
295
- });
296
- }
297
- function tryPretty(text) {
298
- try {
299
- return JSON.stringify(JSON.parse(text), null, 2);
300
- } catch {
301
- return text;
302
- }
303
- }
304
- export function Notice({
305
- block
306
- }) {
307
- const color = block.tone === "danger" ? night.color.danger : block.tone === "warning" ? night.color.warning : night.color.info;
308
- const Icon = block.tone === "info" ? Info : AlertTriangle;
309
- return /*#__PURE__*/_jsxs(Card, {
310
- tone: block.tone,
311
- testID: `buoy-block-notice-${block.id}`,
312
- children: [/*#__PURE__*/_jsxs(View, {
313
- style: styles.noticeRow,
314
- children: [/*#__PURE__*/_jsx(Icon, {
315
- size: 14,
316
- color: color
317
- }), /*#__PURE__*/_jsx(Text, {
318
- style: styles.noticeText,
319
- children: block.text
320
- })]
321
- }), /*#__PURE__*/_jsx(ActionRow, {
322
- actions: block.actions,
323
- blockId: block.id
324
- })]
325
- });
326
- }
327
- export function Finding({
328
- block
329
- }) {
330
- return /*#__PURE__*/_jsxs(Card, {
331
- title: block.title,
332
- source: block.source,
333
- testID: `buoy-block-finding-${block.id}`,
334
- tone: "warning",
335
- children: [block.evidence.map((e, i) => /*#__PURE__*/_jsxs(View, {
336
- style: [styles.kvRow, i > 0 && b.rowDivider],
337
- children: [/*#__PURE__*/_jsx(Text, {
338
- style: styles.kvKey,
339
- numberOfLines: 1,
340
- children: e.label
341
- }), /*#__PURE__*/_jsx(Text, {
342
- style: [styles.kvValue, e.tone && {
343
- color: toneColor(e.tone)
344
- }],
345
- numberOfLines: 3,
346
- children: e.value
347
- })]
348
- }, `${e.label}-${i}`)), /*#__PURE__*/_jsx(ActionRow, {
349
- actions: block.actions,
350
- blockId: block.id
351
- })]
352
- });
353
- }
354
- const styles = StyleSheet.create({
355
- flex: {
356
- flex: 1
357
- },
358
- tableHead: {
359
- flexDirection: "row",
360
- paddingHorizontal: 12,
361
- paddingVertical: 6,
362
- gap: 8,
363
- backgroundColor: night.color.fill
364
- },
365
- th: {
366
- flex: 1,
367
- color: night.color.textTertiary,
368
- fontSize: night.font.micro,
369
- fontWeight: "700",
370
- letterSpacing: 0.6,
371
- textTransform: "uppercase"
372
- },
373
- tr: {
374
- flexDirection: "row",
375
- paddingHorizontal: 12,
376
- paddingVertical: 8,
377
- gap: 8,
378
- alignItems: "center"
379
- },
380
- td: {
381
- flex: 1,
382
- color: night.color.textSecondary,
383
- fontSize: night.font.caption,
384
- lineHeight: 17
385
- },
386
- tdFirst: {
387
- color: night.color.text,
388
- fontWeight: "500"
389
- },
390
- firstCol: {
391
- flex: 1.4
392
- },
393
- kvRow: {
394
- flexDirection: "row",
395
- gap: 12,
396
- paddingHorizontal: 12,
397
- paddingVertical: 8,
398
- alignItems: "flex-start"
399
- },
400
- kvKey: {
401
- width: 110,
402
- color: night.color.textSecondary,
403
- fontSize: night.font.caption,
404
- paddingTop: 1
405
- },
406
- kvValue: {
407
- flex: 1,
408
- color: night.color.text,
409
- fontSize: night.font.caption,
410
- lineHeight: 17
411
- },
412
- thumb: {
413
- width: 40,
414
- height: 40,
415
- borderRadius: 8,
416
- backgroundColor: night.color.fill
417
- },
418
- rowAction: {
419
- color: night.color.accent,
420
- fontSize: night.font.caption,
421
- fontWeight: "600"
422
- },
423
- diffRow: {
424
- paddingHorizontal: 12,
425
- paddingVertical: 8,
426
- gap: 3
427
- },
428
- diffPath: {
429
- color: night.color.textSecondary,
430
- fontSize: night.font.micro,
431
- fontWeight: "600",
432
- letterSpacing: 0.3
433
- },
434
- diffLine: {
435
- flexDirection: "row",
436
- gap: 8,
437
- alignItems: "flex-start"
438
- },
439
- diffMark: {
440
- fontFamily: "Menlo",
441
- fontSize: 12,
442
- width: 10
443
- },
444
- diffValue: {
445
- flex: 1,
446
- fontFamily: "Menlo",
447
- fontSize: 12,
448
- lineHeight: 16
449
- },
450
- chart: {
451
- paddingHorizontal: 12,
452
- paddingVertical: 10,
453
- gap: 8
454
- },
455
- barRow: {
456
- flexDirection: "row",
457
- alignItems: "center",
458
- gap: 8
459
- },
460
- barLabel: {
461
- width: 96,
462
- color: night.color.textSecondary,
463
- fontSize: night.font.caption
464
- },
465
- barTrack: {
466
- flex: 1,
467
- height: 10,
468
- borderRadius: 5,
469
- backgroundColor: night.color.fill,
470
- overflow: "hidden"
471
- },
472
- bar: {
473
- height: 10,
474
- borderRadius: 5
475
- },
476
- barValue: {
477
- width: 72,
478
- textAlign: "right",
479
- color: night.color.text,
480
- fontSize: night.font.caption,
481
- fontWeight: "600"
482
- },
483
- step: {
484
- flexDirection: "row",
485
- alignItems: "center",
486
- gap: 10,
487
- paddingHorizontal: 12,
488
- paddingVertical: 9
489
- },
490
- stepMark: {
491
- width: 20,
492
- height: 20,
493
- borderRadius: 10,
494
- backgroundColor: night.color.fillTertiary,
495
- alignItems: "center",
496
- justifyContent: "center"
497
- },
498
- stepDone: {
499
- backgroundColor: night.color.accent
500
- },
501
- stepFailed: {
502
- backgroundColor: night.color.danger
503
- },
504
- stepNum: {
505
- color: night.color.text,
506
- fontSize: night.font.micro,
507
- fontWeight: "700"
508
- },
509
- stepTextDone: {
510
- color: night.color.textSecondary
511
- },
512
- code: {
513
- paddingHorizontal: 12,
514
- paddingVertical: 10,
515
- lineHeight: 17
516
- },
517
- noticeRow: {
518
- flexDirection: "row",
519
- alignItems: "flex-start",
520
- gap: 8,
521
- paddingHorizontal: 12,
522
- paddingTop: 10,
523
- paddingBottom: 4
524
- },
525
- noticeText: {
526
- flex: 1,
527
- color: night.color.text,
528
- fontSize: night.font.caption,
529
- lineHeight: 18
530
- }
531
- });
532
- //# sourceMappingURL=DataBlocks.js.map
1
+ "use strict";import{useState}from"react";import{Image,Pressable,StyleSheet,Text,View}from"react-native";import{AlertTriangle,Check,Info,night,X}from"@buoy-gg/shared-ui";import{CAPS}from"@buoy-gg/agent-core";import{ActionRow,blockStyles as b,Card,More,toneColor,useBlockHandlers,useExpand}from"./primitivesIndex";import{renderInline}from"../components/Markdown";import{BlockIcon}from"./icons";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";function fmt(e){if(void 0===e)return"—";if(null===e)return"null";if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e)return String(e);try{const t=JSON.stringify(e);return t.length>120?`${t.slice(0,117)}…`:t}catch{return String(e)}}export function Table({block:e}){const{visible:t,expanded:o,toggle:n}=useExpand(e.rows,CAPS.tableRows),i=e.columns.slice(0,4);return _jsxs(Card,{title:e.title,source:e.source,testID:`buoy-block-table-${e.id}`,children:[_jsx(View,{style:styles.tableHead,children:i.map((e,t)=>_jsx(Text,{style:[styles.th,0===t&&styles.firstCol],numberOfLines:1,children:e},e))}),t.map((e,t)=>_jsx(View,{style:[styles.tr,t>0&&b.rowDivider],children:i.map((t,o)=>{const n=e[o],i="string"==typeof n?n:n?.text??"",l="string"==typeof n?void 0:n?.tone;return _jsx(Text,{style:[styles.td,0===o&&styles.firstCol,0===o&&styles.tdFirst,l&&{color:toneColor(l)}],numberOfLines:2,children:renderInline(i,styles.td)},o)})},t)),_jsx(More,{shown:t.length,total:e.total??e.rows.length,onExpand:e.rows.length>t.length||o?n:void 0,expanded:o})]})}export function KeyValue({block:e}){const{visible:t,expanded:o,toggle:n}=useExpand(e.pairs,CAPS.keyValuePairs),[i,l]=useState(null);return _jsxs(Card,{title:e.title,source:e.source,testID:`buoy-block-keyvalue-${e.id}`,children:[t.map((e,t)=>{const o="object"==typeof e.value&&null!==e.value,n=i===e.key;return _jsxs(Pressable,{onPress:o?()=>l(n?null:e.key):void 0,style:[styles.kvRow,t>0&&b.rowDivider],children:[_jsx(Text,{style:styles.kvKey,numberOfLines:1,children:e.key}),_jsx(Text,{style:[styles.kvValue,n&&b.mono],numberOfLines:n?void 0:2,selectable:!0,children:n?JSON.stringify(e.value,null,2):fmt(e.value)})]},e.key)}),_jsx(More,{shown:t.length,total:e.pairs.length,onExpand:e.pairs.length>CAPS.keyValuePairs?n:void 0,expanded:o})]})}export function List({block:e}){const t=useBlockHandlers(),{visible:o,expanded:n,toggle:i}=useExpand(e.items,CAPS.listItems);return _jsxs(Card,{title:e.title,source:e.source,testID:`buoy-block-list-${e.id}`,children:[o.map((o,n)=>{const i=o.action?Pressable:View;return _jsxs(i,{...o.action?{onPress:()=>{t.runAction(o.action,e.id)},accessibilityRole:"button"}:{},style:[b.row,n>0&&b.rowDivider],children:[o.image?_jsx(Image,{source:{uri:o.image},style:styles.thumb,accessibilityLabel:o.title}):o.icon?_jsx(BlockIcon,{name:o.icon}):null,_jsxs(View,{style:styles.flex,children:[_jsx(Text,{style:[b.rowTitle,o.tone&&{color:toneColor(o.tone)}],numberOfLines:2,children:renderInline(o.title,b.rowTitle)}),o.subtitle?_jsx(Text,{style:b.rowSub,numberOfLines:2,children:renderInline(o.subtitle,b.rowSub)}):null]}),o.trailing?_jsx(Text,{style:[b.rowTrailing,o.tone&&{color:toneColor(o.tone)}],numberOfLines:1,children:o.trailing}):null,o.action?_jsx(Text,{style:styles.rowAction,children:o.action.label}):null]},o.id??`${o.title}-${n}`)}),_jsx(More,{shown:o.length,total:e.total??e.items.length,onExpand:e.items.length>o.length||n?i:void 0,expanded:n})]})}export function Diff({block:e}){return _jsxs(Card,{title:e.title??"What changed",source:e.source,testID:`buoy-block-diff-${e.id}`,children:[e.changes.slice(0,CAPS.keyValuePairs).map((e,t)=>{const o=void 0===e.before&&void 0!==e.after,n=void 0===e.after&&void 0!==e.before;return _jsxs(View,{style:[styles.diffRow,t>0&&b.rowDivider],children:[_jsx(Text,{style:styles.diffPath,numberOfLines:1,children:e.path}),o?null:_jsxs(View,{style:styles.diffLine,children:[_jsx(Text,{style:[styles.diffMark,{color:night.color.danger}],children:"−"}),_jsx(Text,{style:[styles.diffValue,{color:night.color.danger}],numberOfLines:3,selectable:!0,children:fmt(e.before)})]}),n?null:_jsxs(View,{style:styles.diffLine,children:[_jsx(Text,{style:[styles.diffMark,{color:night.color.accent}],children:"+"}),_jsx(Text,{style:[styles.diffValue,{color:night.color.accent}],numberOfLines:3,selectable:!0,children:fmt(e.after)})]})]},`${e.path}-${t}`)}),_jsx(More,{shown:Math.min(e.changes.length,CAPS.keyValuePairs),total:e.changes.length})]})}export function Chart({block:e}){const t=e.bars.slice(0,CAPS.chartBars),o=e.max??Math.max(1,...t.map(e=>e.value));return _jsx(Card,{title:e.title,source:e.source,testID:`buoy-block-chart-${e.id}`,children:_jsx(View,{style:styles.chart,children:t.map(e=>_jsxs(View,{style:styles.barRow,children:[_jsx(Text,{style:styles.barLabel,numberOfLines:1,children:e.label}),_jsx(View,{style:styles.barTrack,children:_jsx(View,{style:[styles.bar,{width:`${Math.max(2,Math.round(e.value/o*100))}%`,backgroundColor:toneColor(e.tone??"accent")}]})}),_jsxs(Text,{style:styles.barValue,numberOfLines:1,children:[e.value,e.unit?` ${e.unit}`:""]})]},e.label))})})}export function Steps({block:e}){return _jsx(Card,{title:e.title,testID:`buoy-block-steps-${e.id}`,children:e.steps.map((e,t)=>_jsxs(View,{style:[styles.step,t>0&&b.rowDivider],children:[_jsx(View,{style:[styles.stepMark,"done"===e.state&&styles.stepDone,"failed"===e.state&&styles.stepFailed],children:"done"===e.state?_jsx(Check,{size:10,color:night.color.onAccent}):"failed"===e.state?_jsx(X,{size:10,color:night.color.text}):_jsx(Text,{style:styles.stepNum,children:t+1})}),_jsx(Text,{style:[b.rowTitle,"done"===e.state&&styles.stepTextDone],children:e.text})]},t))})}export function Code({block:e}){const t="json"===e.language?tryPretty(e.text):e.text;return _jsx(Card,{title:e.title,testID:`buoy-block-code-${e.id}`,children:_jsx(Text,{style:[b.mono,styles.code],selectable:!0,children:t})})}function tryPretty(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}export function Notice({block:e}){const t="danger"===e.tone?night.color.danger:"warning"===e.tone?night.color.warning:night.color.info,o="info"===e.tone?Info:AlertTriangle;return _jsxs(Card,{tone:e.tone,testID:`buoy-block-notice-${e.id}`,children:[_jsxs(View,{style:styles.noticeRow,children:[_jsx(o,{size:14,color:t}),_jsx(Text,{style:styles.noticeText,children:e.text})]}),_jsx(ActionRow,{actions:e.actions,blockId:e.id})]})}export function Finding({block:e}){return _jsxs(Card,{title:e.title,source:e.source,testID:`buoy-block-finding-${e.id}`,tone:"warning",children:[e.evidence.map((e,t)=>_jsxs(View,{style:[styles.kvRow,t>0&&b.rowDivider],children:[_jsx(Text,{style:styles.kvKey,numberOfLines:1,children:e.label}),_jsx(Text,{style:[styles.kvValue,e.tone&&{color:toneColor(e.tone)}],numberOfLines:3,children:e.value})]},`${e.label}-${t}`)),_jsx(ActionRow,{actions:e.actions,blockId:e.id})]})}const styles=StyleSheet.create({flex:{flex:1},tableHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,gap:8,backgroundColor:night.color.fill},th:{flex:1,color:night.color.textTertiary,fontSize:night.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"center"},td:{flex:1,color:night.color.textSecondary,fontSize:night.font.caption,lineHeight:17},tdFirst:{color:night.color.text,fontWeight:"500"},firstCol:{flex:1.4},kvRow:{flexDirection:"row",gap:12,paddingHorizontal:12,paddingVertical:8,alignItems:"flex-start"},kvKey:{width:110,color:night.color.textSecondary,fontSize:night.font.caption,paddingTop:1},kvValue:{flex:1,color:night.color.text,fontSize:night.font.caption,lineHeight:17},thumb:{width:40,height:40,borderRadius:8,backgroundColor:night.color.fill},rowAction:{color:night.color.accent,fontSize:night.font.caption,fontWeight:"600"},diffRow:{paddingHorizontal:12,paddingVertical:8,gap:3},diffPath:{color:night.color.textSecondary,fontSize:night.font.micro,fontWeight:"600",letterSpacing:.3},diffLine:{flexDirection:"row",gap:8,alignItems:"flex-start"},diffMark:{fontFamily:"Menlo",fontSize:12,width:10},diffValue:{flex:1,fontFamily:"Menlo",fontSize:12,lineHeight:16},chart:{paddingHorizontal:12,paddingVertical:10,gap:8},barRow:{flexDirection:"row",alignItems:"center",gap:8},barLabel:{width:96,color:night.color.textSecondary,fontSize:night.font.caption},barTrack:{flex:1,height:10,borderRadius:5,backgroundColor:night.color.fill,overflow:"hidden"},bar:{height:10,borderRadius:5},barValue:{width:72,textAlign:"right",color:night.color.text,fontSize:night.font.caption,fontWeight:"600"},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:night.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:night.color.accent},stepFailed:{backgroundColor:night.color.danger},stepNum:{color:night.color.text,fontSize:night.font.micro,fontWeight:"700"},stepTextDone:{color:night.color.textSecondary},code:{paddingHorizontal:12,paddingVertical:10,lineHeight:17},noticeRow:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:4},noticeText:{flex:1,color:night.color.text,fontSize:night.font.caption,lineHeight:18}});