@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,584 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Receipts — engine-made blocks for the tools people ask about most.
5
- * Each one is a card the matching Buoy tool could have drawn, with one tap
6
- * into that tool where the host supports it.
7
- */
8
- import { useState } from "react";
9
- import { Pressable, StyleSheet, Text, View } from "react-native";
10
- import { AlertTriangle, ChevronRight, Eye, night } from "@buoy-gg/shared-ui";
11
- import { CAPS } from "@buoy-gg/agent-core";
12
- import { useBlockHandlers } from "./context";
13
- import { ActionRow, blockStyles as b, Card, More, useExpand } from "./primitives";
14
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
- function statusColor(status) {
16
- if (status === undefined) return night.color.textTertiary;
17
- if (status >= 500) return night.color.danger;
18
- if (status >= 400) return night.color.warning;
19
- if (status >= 300) return night.color.info;
20
- return night.color.accent;
21
- }
22
- function pathOf(url) {
23
- try {
24
- const u = new URL(url);
25
- return u.pathname + (u.search ? "?…" : "");
26
- } catch {
27
- return url;
28
- }
29
- }
30
- function StatusPill({
31
- status
32
- }) {
33
- return /*#__PURE__*/_jsx(View, {
34
- style: [b.pill, {
35
- backgroundColor: `${statusColor(status)}22`
36
- }],
37
- children: /*#__PURE__*/_jsx(Text, {
38
- style: [b.pillText, {
39
- color: statusColor(status)
40
- }],
41
- children: status ?? "…"
42
- })
43
- });
44
- }
45
- export function RequestList({
46
- block
47
- }) {
48
- const h = useBlockHandlers();
49
- const canOpen = h.supports?.openTool !== false;
50
- const {
51
- visible,
52
- expanded,
53
- toggle
54
- } = useExpand(block.requests, CAPS.listItems);
55
- return /*#__PURE__*/_jsxs(Card, {
56
- title: block.title ?? "Network requests",
57
- source: block.source,
58
- testID: `buoy-block-requests-${block.id}`,
59
- children: [visible.map((r, i) => /*#__PURE__*/_jsxs(Pressable, {
60
- disabled: !canOpen,
61
- onPress: () => void h.runAction({
62
- label: "Open in Network",
63
- openTool: {
64
- toolId: "network",
65
- select: r.id
66
- }
67
- }, block.id),
68
- style: [b.row, i > 0 && b.rowDivider],
69
- accessibilityRole: canOpen ? "button" : undefined,
70
- children: [/*#__PURE__*/_jsx(Text, {
71
- style: styles.method,
72
- children: r.method
73
- }), /*#__PURE__*/_jsx(Text, {
74
- style: b.rowTitle,
75
- numberOfLines: 1,
76
- children: pathOf(r.url)
77
- }), r.mocked ? /*#__PURE__*/_jsx(Text, {
78
- style: styles.mockedChip,
79
- children: "MOCKED"
80
- }) : null, r.durationMs !== undefined ? /*#__PURE__*/_jsxs(Text, {
81
- style: b.rowTrailing,
82
- children: [r.durationMs, " ms"]
83
- }) : null, /*#__PURE__*/_jsx(StatusPill, {
84
- status: r.status
85
- }), canOpen ? /*#__PURE__*/_jsx(ChevronRight, {
86
- size: 12,
87
- color: night.color.textTertiary
88
- }) : null]
89
- }, r.id)), /*#__PURE__*/_jsx(More, {
90
- shown: visible.length,
91
- total: block.total ?? block.requests.length,
92
- onExpand: block.requests.length > visible.length || expanded ? toggle : undefined,
93
- expanded: expanded
94
- })]
95
- });
96
- }
97
- export function RequestCard({
98
- block
99
- }) {
100
- const [tab, setTab] = useState("response");
101
- const body = tab === "response" ? block.responseBody : block.requestBody;
102
- const text = body === undefined ? "(none)" : typeof body === "string" ? body : JSON.stringify(body, null, 2);
103
- const h = useBlockHandlers();
104
- return /*#__PURE__*/_jsxs(Card, {
105
- source: block.source,
106
- testID: `buoy-block-request-${block.id}`,
107
- children: [/*#__PURE__*/_jsxs(View, {
108
- style: [b.row, styles.reqHead],
109
- children: [/*#__PURE__*/_jsx(Text, {
110
- style: styles.method,
111
- children: block.request.method
112
- }), /*#__PURE__*/_jsx(Text, {
113
- style: b.rowTitle,
114
- numberOfLines: 2,
115
- children: pathOf(block.request.url)
116
- }), block.request.mocked ? /*#__PURE__*/_jsx(Text, {
117
- style: styles.mockedChip,
118
- children: "MOCKED"
119
- }) : null, /*#__PURE__*/_jsx(StatusPill, {
120
- status: block.request.status
121
- })]
122
- }), /*#__PURE__*/_jsx(View, {
123
- style: styles.tabs,
124
- children: ["response", "request"].map(t => /*#__PURE__*/_jsx(Pressable, {
125
- onPress: () => setTab(t),
126
- style: [styles.tab, tab === t && styles.tabOn],
127
- accessibilityRole: "tab",
128
- children: /*#__PURE__*/_jsx(Text, {
129
- style: [styles.tabText, tab === t && styles.tabTextOn],
130
- children: t === "response" ? "Response" : "Request"
131
- })
132
- }, t))
133
- }), /*#__PURE__*/_jsx(Text, {
134
- style: [b.mono, styles.body],
135
- numberOfLines: 14,
136
- selectable: true,
137
- children: text.length > 1600 ? `${text.slice(0, 1600)}\n…` : text
138
- }), /*#__PURE__*/_jsx(ActionRow, {
139
- blockId: block.id,
140
- actions: [{
141
- label: "Open in Network",
142
- openTool: {
143
- toolId: "network",
144
- select: block.request.id
145
- }
146
- }]
147
- }), h.supports?.openTool === false ? null : null]
148
- });
149
- }
150
- export function RuleCard({
151
- block
152
- }) {
153
- const r = block.rule;
154
- const outcome = r.kind === "fail" ? "fails (no network)" : r.kind === "delay" ? `delayed ${r.delayMs ?? 0} ms` : `returns ${r.status ?? 200}`;
155
- return /*#__PURE__*/_jsxs(Card, {
156
- title: r.name ?? "Network override",
157
- source: block.source,
158
- testID: `buoy-block-rule-${block.id}`,
159
- tone: r.enabled ? "warning" : undefined,
160
- children: [/*#__PURE__*/_jsxs(View, {
161
- style: styles.ruleBody,
162
- children: [/*#__PURE__*/_jsxs(Text, {
163
- style: styles.ruleLine,
164
- children: [/*#__PURE__*/_jsxs(Text, {
165
- style: styles.ruleKey,
166
- children: [r.methods?.length ? r.methods.join("/") : "ANY", " "]
167
- }), /*#__PURE__*/_jsx(Text, {
168
- style: b.mono,
169
- children: r.urlPattern
170
- })]
171
- }), /*#__PURE__*/_jsxs(Text, {
172
- style: styles.ruleLine,
173
- children: [/*#__PURE__*/_jsx(Text, {
174
- style: styles.ruleKey,
175
- children: "\u2192 "
176
- }), outcome, r.times ? ` · ${r.times === 1 ? "once" : `${r.times} times`}` : " · every time", r.hits !== undefined ? ` · ${r.hits} hit${r.hits === 1 ? "" : "s"}` : ""]
177
- }), /*#__PURE__*/_jsx(View, {
178
- style: [b.pill, r.enabled ? styles.on : styles.off],
179
- children: /*#__PURE__*/_jsx(Text, {
180
- style: [b.pillText, {
181
- color: r.enabled ? night.color.onAccent : night.color.textSecondary
182
- }],
183
- children: r.enabled ? "ON" : "OFF"
184
- })
185
- })]
186
- }), /*#__PURE__*/_jsx(ActionRow, {
187
- blockId: block.id,
188
- actions: [r.enabled ? {
189
- label: "Turn off",
190
- dispatch: {
191
- toolId: "network",
192
- action: "setOverrideRuleEnabled",
193
- params: {
194
- id: r.id,
195
- enabled: false
196
- }
197
- }
198
- } : {
199
- label: "Turn on",
200
- primary: true,
201
- dispatch: {
202
- toolId: "network",
203
- action: "setOverrideRuleEnabled",
204
- params: {
205
- id: r.id,
206
- enabled: true
207
- }
208
- }
209
- }, {
210
- label: "Delete",
211
- dispatch: {
212
- toolId: "network",
213
- action: "deleteOverrideRule",
214
- params: {
215
- id: r.id
216
- }
217
- }
218
- }]
219
- })]
220
- });
221
- }
222
- export function ScreenElements({
223
- block
224
- }) {
225
- const h = useBlockHandlers();
226
- const {
227
- visible,
228
- expanded,
229
- toggle
230
- } = useExpand(block.elements, CAPS.chips);
231
- return /*#__PURE__*/_jsxs(Card, {
232
- title: block.title ?? "On screen right now",
233
- source: block.source,
234
- testID: `buoy-block-screen-${block.id}`,
235
- children: [visible.map((e, i) => /*#__PURE__*/_jsxs(Pressable, {
236
- onPress: () => void h.runAction({
237
- label: "Highlight",
238
- dispatch: {
239
- toolId: "highlight-updates",
240
- action: "setSpotlight",
241
- params: {
242
- nativeTag: e.nativeTag
243
- }
244
- }
245
- }, block.id),
246
- disabled: h.supports?.dispatch === false,
247
- style: [b.row, i > 0 && b.rowDivider],
248
- accessibilityRole: "button",
249
- children: [/*#__PURE__*/_jsx(Eye, {
250
- size: 12,
251
- color: night.color.textTertiary
252
- }), /*#__PURE__*/_jsx(Text, {
253
- style: b.rowTitle,
254
- numberOfLines: 1,
255
- children: e.label ?? e.testID ?? e.name
256
- }), /*#__PURE__*/_jsx(Text, {
257
- style: b.rowTrailing,
258
- numberOfLines: 1,
259
- children: e.name
260
- })]
261
- }, e.nativeTag)), /*#__PURE__*/_jsx(More, {
262
- shown: visible.length,
263
- total: block.total,
264
- onExpand: block.elements.length > visible.length || expanded ? toggle : undefined,
265
- expanded: expanded
266
- })]
267
- });
268
- }
269
- export function RouteChips({
270
- block
271
- }) {
272
- const h = useBlockHandlers();
273
- const [expanded, setExpanded] = useState(false);
274
- const routes = expanded ? block.routes : block.routes.slice(0, CAPS.chips);
275
- return /*#__PURE__*/_jsxs(Card, {
276
- title: block.current ? `Routes · you're on ${block.current}` : "Routes",
277
- source: block.source,
278
- testID: `buoy-block-routes-${block.id}`,
279
- children: [/*#__PURE__*/_jsx(View, {
280
- style: styles.chips,
281
- children: routes.map(r => /*#__PURE__*/_jsx(Pressable, {
282
- disabled: h.supports?.dispatch === false,
283
- onPress: () => r.dynamic ? h.answer({
284
- blockId: block.id,
285
- kind: "input",
286
- value: `Open ${r.path} — which id?`
287
- }) : void h.runAction({
288
- label: `Open ${r.path}`,
289
- dispatch: {
290
- toolId: "route-events",
291
- action: "navigate",
292
- params: {
293
- path: r.path
294
- }
295
- }
296
- }, block.id),
297
- style: [styles.chip, r.path === block.current && styles.chipCurrent],
298
- accessibilityRole: "button",
299
- children: /*#__PURE__*/_jsx(Text, {
300
- style: [styles.chipText, r.dynamic && styles.chipDynamic],
301
- children: r.path
302
- })
303
- }, r.path))
304
- }), /*#__PURE__*/_jsx(More, {
305
- shown: routes.length,
306
- total: block.total ?? block.routes.length,
307
- onExpand: () => setExpanded(v => !v),
308
- expanded: expanded
309
- })]
310
- });
311
- }
312
- const LEVEL_COLOR = {
313
- error: night.color.danger,
314
- warn: night.color.warning,
315
- warning: night.color.warning,
316
- info: night.color.info
317
- };
318
- export function LogList({
319
- block
320
- }) {
321
- const {
322
- visible,
323
- expanded,
324
- toggle
325
- } = useExpand(block.entries, CAPS.listItems);
326
- return /*#__PURE__*/_jsxs(Card, {
327
- title: "Console",
328
- source: block.source,
329
- testID: `buoy-block-logs-${block.id}`,
330
- children: [visible.map((e, i) => /*#__PURE__*/_jsxs(View, {
331
- style: [b.row, i > 0 && b.rowDivider, styles.logRow],
332
- children: [/*#__PURE__*/_jsx(View, {
333
- style: [b.pill, {
334
- backgroundColor: `${LEVEL_COLOR[e.level] ?? night.color.textTertiary}22`
335
- }],
336
- children: /*#__PURE__*/_jsx(Text, {
337
- style: [b.pillText, {
338
- color: LEVEL_COLOR[e.level] ?? night.color.textSecondary
339
- }],
340
- children: e.level.toUpperCase()
341
- })
342
- }), /*#__PURE__*/_jsx(Text, {
343
- style: [b.rowTitle, b.mono],
344
- numberOfLines: 3,
345
- children: e.message
346
- }), e.count > 1 ? /*#__PURE__*/_jsxs(Text, {
347
- style: b.rowTrailing,
348
- children: ["\xD7", e.count]
349
- }) : null]
350
- }, `${e.level}-${e.message}-${i}`)), /*#__PURE__*/_jsx(More, {
351
- shown: visible.length,
352
- total: block.total,
353
- onExpand: block.entries.length > visible.length || expanded ? toggle : undefined,
354
- expanded: expanded
355
- })]
356
- });
357
- }
358
- export function Crash({
359
- block
360
- }) {
361
- return /*#__PURE__*/_jsxs(Card, {
362
- tone: "danger",
363
- testID: `buoy-block-crash-${block.id}`,
364
- children: [/*#__PURE__*/_jsxs(View, {
365
- style: styles.crashHead,
366
- children: [/*#__PURE__*/_jsx(AlertTriangle, {
367
- size: 14,
368
- color: night.color.danger
369
- }), /*#__PURE__*/_jsxs(Text, {
370
- style: styles.crashTitle,
371
- children: ["The app crashed", block.route ? ` on ${block.route}` : ""]
372
- })]
373
- }), /*#__PURE__*/_jsx(Text, {
374
- style: [b.mono, styles.crashMsg],
375
- numberOfLines: 4,
376
- selectable: true,
377
- children: block.message
378
- }), block.suspect ? /*#__PURE__*/_jsxs(Text, {
379
- style: styles.suspect,
380
- children: ["Most likely cause: ", block.suspect.label]
381
- }) : null, /*#__PURE__*/_jsx(ActionRow, {
382
- blockId: block.id,
383
- actions: [...(block.suspect?.action ? [{
384
- ...block.suspect.action,
385
- primary: true
386
- }] : []), ...(block.actions ?? [])].slice(0, 2)
387
- })]
388
- });
389
- }
390
-
391
- /** A chip, not a card: the agent moved the app; let the user look. */
392
- export function Peek({
393
- block
394
- }) {
395
- const h = useBlockHandlers();
396
- const can = h.supports?.minimize !== false;
397
- return /*#__PURE__*/_jsxs(Pressable, {
398
- testID: `buoy-block-peek-${block.id}`,
399
- disabled: !can,
400
- onPress: () => void h.runAction({
401
- label: "Look",
402
- minimize: true
403
- }, block.id),
404
- style: ({
405
- pressed
406
- }) => [styles.peek, pressed && {
407
- opacity: 0.7
408
- }],
409
- accessibilityRole: "button",
410
- accessibilityLabel: `${block.label}. Look at the app`,
411
- children: [/*#__PURE__*/_jsx(Text, {
412
- style: styles.peekText,
413
- children: block.label
414
- }), can ? /*#__PURE__*/_jsxs(View, {
415
- style: styles.peekLook,
416
- children: [/*#__PURE__*/_jsx(Eye, {
417
- size: 12,
418
- color: night.color.accent
419
- }), /*#__PURE__*/_jsx(Text, {
420
- style: styles.peekLookText,
421
- children: "Look"
422
- })]
423
- }) : null]
424
- });
425
- }
426
- const styles = StyleSheet.create({
427
- method: {
428
- color: night.color.textSecondary,
429
- fontSize: night.font.micro,
430
- fontWeight: "700",
431
- letterSpacing: 0.4,
432
- width: 44
433
- },
434
- // The provenance chip for a response an override rule synthesized. Loud on
435
- // purpose: mocked data rendered like live data is how testers file bugs
436
- // against reality that never existed.
437
- mockedChip: {
438
- color: night.color.warning,
439
- backgroundColor: night.color.warningSoft,
440
- fontSize: 9,
441
- fontWeight: "700",
442
- letterSpacing: 0.6,
443
- paddingHorizontal: 5,
444
- paddingVertical: 1,
445
- borderRadius: night.radius.badge,
446
- overflow: "hidden"
447
- },
448
- reqHead: {
449
- paddingTop: 12
450
- },
451
- tabs: {
452
- flexDirection: "row",
453
- gap: 6,
454
- paddingHorizontal: 12,
455
- paddingTop: 4,
456
- paddingBottom: 8
457
- },
458
- tab: {
459
- paddingHorizontal: 10,
460
- paddingVertical: 5,
461
- borderRadius: night.radius.badge,
462
- backgroundColor: night.color.fill
463
- },
464
- tabOn: {
465
- backgroundColor: night.color.accentSoft
466
- },
467
- tabText: {
468
- color: night.color.textSecondary,
469
- fontSize: night.font.micro,
470
- fontWeight: "600"
471
- },
472
- tabTextOn: {
473
- color: night.color.accent
474
- },
475
- body: {
476
- paddingHorizontal: 12,
477
- paddingBottom: 4,
478
- lineHeight: 16,
479
- color: night.color.textSecondary
480
- },
481
- ruleBody: {
482
- paddingHorizontal: 12,
483
- paddingTop: 4,
484
- paddingBottom: 4,
485
- gap: 4
486
- },
487
- ruleLine: {
488
- color: night.color.text,
489
- fontSize: night.font.caption,
490
- lineHeight: 18
491
- },
492
- ruleKey: {
493
- color: night.color.textSecondary,
494
- fontWeight: "700"
495
- },
496
- on: {
497
- alignSelf: "flex-start",
498
- backgroundColor: night.color.accent,
499
- marginTop: 4
500
- },
501
- off: {
502
- alignSelf: "flex-start",
503
- backgroundColor: night.color.fillTertiary,
504
- marginTop: 4
505
- },
506
- chips: {
507
- flexDirection: "row",
508
- flexWrap: "wrap",
509
- gap: 6,
510
- padding: 12
511
- },
512
- chip: {
513
- paddingHorizontal: 10,
514
- paddingVertical: 6,
515
- borderRadius: night.radius.chip,
516
- backgroundColor: night.color.fill,
517
- borderWidth: StyleSheet.hairlineWidth,
518
- borderColor: night.color.border
519
- },
520
- chipCurrent: {
521
- backgroundColor: night.color.accentSoft,
522
- borderColor: night.color.accentBorderStrong
523
- },
524
- chipText: {
525
- color: night.color.text,
526
- fontSize: night.font.caption,
527
- fontFamily: "Menlo"
528
- },
529
- chipDynamic: {
530
- color: night.color.textSecondary
531
- },
532
- logRow: {
533
- alignItems: "flex-start"
534
- },
535
- crashHead: {
536
- flexDirection: "row",
537
- alignItems: "center",
538
- gap: 8,
539
- paddingHorizontal: 12,
540
- paddingTop: 12
541
- },
542
- crashTitle: {
543
- color: night.color.danger,
544
- fontSize: night.font.row,
545
- fontWeight: "600"
546
- },
547
- crashMsg: {
548
- paddingHorizontal: 12,
549
- paddingTop: 6,
550
- color: night.color.text
551
- },
552
- suspect: {
553
- color: night.color.textSecondary,
554
- fontSize: night.font.caption,
555
- paddingHorizontal: 12,
556
- paddingTop: 6
557
- },
558
- peek: {
559
- alignSelf: "flex-start",
560
- flexDirection: "row",
561
- alignItems: "center",
562
- gap: 10,
563
- paddingLeft: 12,
564
- paddingRight: 10,
565
- paddingVertical: 7,
566
- borderRadius: night.radius.chip,
567
- backgroundColor: night.color.fill
568
- },
569
- peekText: {
570
- color: night.color.textSecondary,
571
- fontSize: night.font.caption
572
- },
573
- peekLook: {
574
- flexDirection: "row",
575
- alignItems: "center",
576
- gap: 4
577
- },
578
- peekLookText: {
579
- color: night.color.accent,
580
- fontSize: night.font.caption,
581
- fontWeight: "600"
582
- }
583
- });
584
- //# sourceMappingURL=ReceiptBlocks.js.map
1
+ "use strict";import{useState}from"react";import{Pressable,StyleSheet,Text,View}from"react-native";import{AlertTriangle,ChevronRight,Eye,night}from"@buoy-gg/shared-ui";import{CAPS}from"@buoy-gg/agent-core";import{useBlockHandlers}from"./context";import{ActionRow,blockStyles as b,Card,More,useExpand}from"./primitives";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";function statusColor(e){return void 0===e?night.color.textTertiary:e>=500?night.color.danger:e>=400?night.color.warning:e>=300?night.color.info:night.color.accent}function pathOf(e){try{const t=new URL(e);return t.pathname+(t.search?"?…":"")}catch{return e}}function StatusPill({status:e}){return _jsx(View,{style:[b.pill,{backgroundColor:`${statusColor(e)}22`}],children:_jsx(Text,{style:[b.pillText,{color:statusColor(e)}],children:e??"…"})})}export function RequestList({block:e}){const t=useBlockHandlers(),o=!1!==t.supports?.openTool,{visible:s,expanded:n,toggle:l}=useExpand(e.requests,CAPS.listItems);return _jsxs(Card,{title:e.title??"Network requests",source:e.source,testID:`buoy-block-requests-${e.id}`,children:[s.map((s,n)=>_jsxs(Pressable,{disabled:!o,onPress:()=>{t.runAction({label:"Open in Network",openTool:{toolId:"network",select:s.id}},e.id)},style:[b.row,n>0&&b.rowDivider],accessibilityRole:o?"button":void 0,children:[_jsx(Text,{style:styles.method,children:s.method}),_jsx(Text,{style:b.rowTitle,numberOfLines:1,children:pathOf(s.url)}),s.mocked?_jsx(Text,{style:styles.mockedChip,children:"MOCKED"}):null,void 0!==s.durationMs?_jsxs(Text,{style:b.rowTrailing,children:[s.durationMs," ms"]}):null,_jsx(StatusPill,{status:s.status}),o?_jsx(ChevronRight,{size:12,color:night.color.textTertiary}):null]},s.id)),_jsx(More,{shown:s.length,total:e.total??e.requests.length,onExpand:e.requests.length>s.length||n?l:void 0,expanded:n})]})}export function RequestCard({block:e}){const[t,o]=useState("response"),s="response"===t?e.responseBody:e.requestBody,n=void 0===s?"(none)":"string"==typeof s?s:JSON.stringify(s,null,2),l=useBlockHandlers();return _jsxs(Card,{source:e.source,testID:`buoy-block-request-${e.id}`,children:[_jsxs(View,{style:[b.row,styles.reqHead],children:[_jsx(Text,{style:styles.method,children:e.request.method}),_jsx(Text,{style:b.rowTitle,numberOfLines:2,children:pathOf(e.request.url)}),e.request.mocked?_jsx(Text,{style:styles.mockedChip,children:"MOCKED"}):null,_jsx(StatusPill,{status:e.request.status})]}),_jsx(View,{style:styles.tabs,children:["response","request"].map(e=>_jsx(Pressable,{onPress:()=>o(e),style:[styles.tab,t===e&&styles.tabOn],accessibilityRole:"tab",children:_jsx(Text,{style:[styles.tabText,t===e&&styles.tabTextOn],children:"response"===e?"Response":"Request"})},e))}),_jsx(Text,{style:[b.mono,styles.body],numberOfLines:14,selectable:!0,children:n.length>1600?`${n.slice(0,1600)}\n…`:n}),_jsx(ActionRow,{blockId:e.id,actions:[{label:"Open in Network",openTool:{toolId:"network",select:e.request.id}}]}),(l.supports,null)]})}export function RuleCard({block:e}){const t=e.rule,o="fail"===t.kind?"fails (no network)":"delay"===t.kind?`delayed ${t.delayMs??0} ms`:`returns ${t.status??200}`;return _jsxs(Card,{title:t.name??"Network override",source:e.source,testID:`buoy-block-rule-${e.id}`,tone:t.enabled?"warning":void 0,children:[_jsxs(View,{style:styles.ruleBody,children:[_jsxs(Text,{style:styles.ruleLine,children:[_jsxs(Text,{style:styles.ruleKey,children:[t.methods?.length?t.methods.join("/"):"ANY"," "]}),_jsx(Text,{style:b.mono,children:t.urlPattern})]}),_jsxs(Text,{style:styles.ruleLine,children:[_jsx(Text,{style:styles.ruleKey,children:"→ "}),o,t.times?" · "+(1===t.times?"once":`${t.times} times`):" · every time",void 0!==t.hits?` · ${t.hits} hit${1===t.hits?"":"s"}`:""]}),_jsx(View,{style:[b.pill,t.enabled?styles.on:styles.off],children:_jsx(Text,{style:[b.pillText,{color:t.enabled?night.color.onAccent:night.color.textSecondary}],children:t.enabled?"ON":"OFF"})})]}),_jsx(ActionRow,{blockId:e.id,actions:[t.enabled?{label:"Turn off",dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:t.id,enabled:!1}}}:{label:"Turn on",primary:!0,dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:t.id,enabled:!0}}},{label:"Delete",dispatch:{toolId:"network",action:"deleteOverrideRule",params:{id:t.id}}}]})]})}export function ScreenElements({block:e}){const t=useBlockHandlers(),{visible:o,expanded:s,toggle:n}=useExpand(e.elements,CAPS.chips);return _jsxs(Card,{title:e.title??"On screen right now",source:e.source,testID:`buoy-block-screen-${e.id}`,children:[o.map((o,s)=>_jsxs(Pressable,{onPress:()=>{t.runAction({label:"Highlight",dispatch:{toolId:"highlight-updates",action:"setSpotlight",params:{nativeTag:o.nativeTag}}},e.id)},disabled:!1===t.supports?.dispatch,style:[b.row,s>0&&b.rowDivider],accessibilityRole:"button",children:[_jsx(Eye,{size:12,color:night.color.textTertiary}),_jsx(Text,{style:b.rowTitle,numberOfLines:1,children:o.label??o.testID??o.name}),_jsx(Text,{style:b.rowTrailing,numberOfLines:1,children:o.name})]},o.nativeTag)),_jsx(More,{shown:o.length,total:e.total,onExpand:e.elements.length>o.length||s?n:void 0,expanded:s})]})}export function RouteChips({block:e}){const t=useBlockHandlers(),[o,s]=useState(!1),n=o?e.routes:e.routes.slice(0,CAPS.chips);return _jsxs(Card,{title:e.current?`Routes · you're on ${e.current}`:"Routes",source:e.source,testID:`buoy-block-routes-${e.id}`,children:[_jsx(View,{style:styles.chips,children:n.map(o=>_jsx(Pressable,{disabled:!1===t.supports?.dispatch,onPress:()=>o.dynamic?t.answer({blockId:e.id,kind:"input",value:`Open ${o.path} — which id?`}):void t.runAction({label:`Open ${o.path}`,dispatch:{toolId:"route-events",action:"navigate",params:{path:o.path}}},e.id),style:[styles.chip,o.path===e.current&&styles.chipCurrent],accessibilityRole:"button",children:_jsx(Text,{style:[styles.chipText,o.dynamic&&styles.chipDynamic],children:o.path})},o.path))}),_jsx(More,{shown:n.length,total:e.total??e.routes.length,onExpand:()=>s(e=>!e),expanded:o})]})}const LEVEL_COLOR={error:night.color.danger,warn:night.color.warning,warning:night.color.warning,info:night.color.info};export function LogList({block:e}){const{visible:t,expanded:o,toggle:s}=useExpand(e.entries,CAPS.listItems);return _jsxs(Card,{title:"Console",source:e.source,testID:`buoy-block-logs-${e.id}`,children:[t.map((e,t)=>_jsxs(View,{style:[b.row,t>0&&b.rowDivider,styles.logRow],children:[_jsx(View,{style:[b.pill,{backgroundColor:`${LEVEL_COLOR[e.level]??night.color.textTertiary}22`}],children:_jsx(Text,{style:[b.pillText,{color:LEVEL_COLOR[e.level]??night.color.textSecondary}],children:e.level.toUpperCase()})}),_jsx(Text,{style:[b.rowTitle,b.mono],numberOfLines:3,children:e.message}),e.count>1?_jsxs(Text,{style:b.rowTrailing,children:["×",e.count]}):null]},`${e.level}-${e.message}-${t}`)),_jsx(More,{shown:t.length,total:e.total,onExpand:e.entries.length>t.length||o?s:void 0,expanded:o})]})}export function Crash({block:e}){return _jsxs(Card,{tone:"danger",testID:`buoy-block-crash-${e.id}`,children:[_jsxs(View,{style:styles.crashHead,children:[_jsx(AlertTriangle,{size:14,color:night.color.danger}),_jsxs(Text,{style:styles.crashTitle,children:["The app crashed",e.route?` on ${e.route}`:""]})]}),_jsx(Text,{style:[b.mono,styles.crashMsg],numberOfLines:4,selectable:!0,children:e.message}),e.suspect?_jsxs(Text,{style:styles.suspect,children:["Most likely cause: ",e.suspect.label]}):null,_jsx(ActionRow,{blockId:e.id,actions:[...e.suspect?.action?[{...e.suspect.action,primary:!0}]:[],...e.actions??[]].slice(0,2)})]})}export function Peek({block:e}){const t=useBlockHandlers(),o=!1!==t.supports?.minimize;return _jsxs(Pressable,{testID:`buoy-block-peek-${e.id}`,disabled:!o,onPress:()=>{t.runAction({label:"Look",minimize:!0},e.id)},style:({pressed:e})=>[styles.peek,e&&{opacity:.7}],accessibilityRole:"button",accessibilityLabel:`${e.label}. Look at the app`,children:[_jsx(Text,{style:styles.peekText,children:e.label}),o?_jsxs(View,{style:styles.peekLook,children:[_jsx(Eye,{size:12,color:night.color.accent}),_jsx(Text,{style:styles.peekLookText,children:"Look"})]}):null]})}const styles=StyleSheet.create({method:{color:night.color.textSecondary,fontSize:night.font.micro,fontWeight:"700",letterSpacing:.4,width:44},mockedChip:{color:night.color.warning,backgroundColor:night.color.warningSoft,fontSize:9,fontWeight:"700",letterSpacing:.6,paddingHorizontal:5,paddingVertical:1,borderRadius:night.radius.badge,overflow:"hidden"},reqHead:{paddingTop:12},tabs:{flexDirection:"row",gap:6,paddingHorizontal:12,paddingTop:4,paddingBottom:8},tab:{paddingHorizontal:10,paddingVertical:5,borderRadius:night.radius.badge,backgroundColor:night.color.fill},tabOn:{backgroundColor:night.color.accentSoft},tabText:{color:night.color.textSecondary,fontSize:night.font.micro,fontWeight:"600"},tabTextOn:{color:night.color.accent},body:{paddingHorizontal:12,paddingBottom:4,lineHeight:16,color:night.color.textSecondary},ruleBody:{paddingHorizontal:12,paddingTop:4,paddingBottom:4,gap:4},ruleLine:{color:night.color.text,fontSize:night.font.caption,lineHeight:18},ruleKey:{color:night.color.textSecondary,fontWeight:"700"},on:{alignSelf:"flex-start",backgroundColor:night.color.accent,marginTop:4},off:{alignSelf:"flex-start",backgroundColor:night.color.fillTertiary,marginTop:4},chips:{flexDirection:"row",flexWrap:"wrap",gap:6,padding:12},chip:{paddingHorizontal:10,paddingVertical:6,borderRadius:night.radius.chip,backgroundColor:night.color.fill,borderWidth:StyleSheet.hairlineWidth,borderColor:night.color.border},chipCurrent:{backgroundColor:night.color.accentSoft,borderColor:night.color.accentBorderStrong},chipText:{color:night.color.text,fontSize:night.font.caption,fontFamily:"Menlo"},chipDynamic:{color:night.color.textSecondary},logRow:{alignItems:"flex-start"},crashHead:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingTop:12},crashTitle:{color:night.color.danger,fontSize:night.font.row,fontWeight:"600"},crashMsg:{paddingHorizontal:12,paddingTop:6,color:night.color.text},suspect:{color:night.color.textSecondary,fontSize:night.font.caption,paddingHorizontal:12,paddingTop:6},peek:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:10,paddingLeft:12,paddingRight:10,paddingVertical:7,borderRadius:night.radius.chip,backgroundColor:night.color.fill},peekText:{color:night.color.textSecondary,fontSize:night.font.caption},peekLook:{flexDirection:"row",alignItems:"center",gap:4},peekLookText:{color:night.color.accent,fontSize:night.font.caption,fontWeight:"600"}});
@@ -1,35 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * How a block talks back to the sheet.
5
- *
6
- * Blocks are pure data; everything that happens when one is tapped goes
7
- * through this context so the same renderers work inside the real transcript,
8
- * on the example app's review page, and (later) on the desktop with a
9
- * different set of handlers behind them.
10
- */
11
- import { createContext, useContext } from "react";
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- const noop = {
14
- answer: () => {},
15
- runAction: () => {},
16
- answered: {},
17
- supports: {}
18
- };
19
- const Ctx = /*#__PURE__*/createContext(noop);
20
- export function BlockHandlersProvider({
21
- value,
22
- children
23
- }) {
24
- return /*#__PURE__*/_jsx(Ctx.Provider, {
25
- value: value,
26
- children: children
27
- });
28
- }
29
- export function useBlockHandlers() {
30
- return useContext(Ctx);
31
- }
32
- export function actionKey(blockId, action) {
33
- return `${blockId}:${action.label}`;
34
- }
35
- //# sourceMappingURL=context.js.map
1
+ "use strict";import{createContext,useContext}from"react";import{jsx as _jsx}from"react/jsx-runtime";const noop={answer:()=>{},runAction:()=>{},answered:{},supports:{}},Ctx=createContext(noop);export function BlockHandlersProvider({value:e,children:t}){return _jsx(Ctx.Provider,{value:e,children:t})}export function useBlockHandlers(){return useContext(Ctx)}export function actionKey(e,t){return`${e}:${t.label}`}