@buoy-gg/ask-buoy 7.0.35 → 7.0.38
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/README.md +73 -15
- package/lib/commonjs/blocks/AskBlocks.js +1 -338
- package/lib/commonjs/blocks/BlockRenderer.js +1 -250
- package/lib/commonjs/blocks/ChromePrototypes.js +1 -514
- package/lib/commonjs/blocks/DataBlocks.js +1 -688
- package/lib/commonjs/blocks/ExtraBlocks.js +1 -1854
- package/lib/commonjs/blocks/MediaBlocks.js +1 -140
- package/lib/commonjs/blocks/ReceiptBlocks.js +1 -586
- package/lib/commonjs/blocks/blockText.js +1 -0
- package/lib/commonjs/blocks/blockText.test.js +1 -0
- package/lib/commonjs/blocks/context.js +1 -42
- package/lib/commonjs/blocks/icons.js +1 -96
- package/lib/commonjs/blocks/index.js +1 -95
- package/lib/commonjs/blocks/listRow.test.js +1 -55
- package/lib/commonjs/blocks/pageState.js +1 -34
- package/lib/commonjs/blocks/pageState.test.js +1 -57
- package/lib/commonjs/blocks/primitives.js +1 -401
- package/lib/commonjs/blocks/primitivesIndex.js +1 -62
- package/lib/commonjs/components/ApprovalCard.js +1 -140
- package/lib/commonjs/components/AskBuoyHeader.js +1 -164
- package/lib/commonjs/components/AskBuoyIcon.js +1 -19
- package/lib/commonjs/components/AskBuoyModal.js +1 -353
- package/lib/commonjs/components/AskBuoySettings.js +1 -69
- package/lib/commonjs/components/ChangesBar.js +1 -211
- package/lib/commonjs/components/Composer.js +1 -175
- package/lib/commonjs/components/EmptyState.js +1 -154
- package/lib/commonjs/components/KeyboardPad.js +1 -0
- package/lib/commonjs/components/Markdown.js +1 -252
- package/lib/commonjs/components/MessageList.js +1 -683
- package/lib/commonjs/components/QueuedMessages.js +1 -0
- package/lib/commonjs/components/ThinkingStrip.js +1 -223
- package/lib/commonjs/components/TypingDots.js +1 -63
- package/lib/commonjs/components/markdownParse.js +1 -0
- package/lib/commonjs/components/markdownParse.test.js +1 -0
- package/lib/commonjs/components/useCopyAction.js +1 -50
- package/lib/commonjs/index.js +1 -252
- package/lib/commonjs/preset.js +1 -90
- package/lib/commonjs/store/activityGroups.js +1 -0
- package/lib/commonjs/store/activityGroups.test.js +1 -0
- package/lib/commonjs/store/askBuoySettings.js +1 -67
- package/lib/commonjs/store/askBuoyStore.js +1 -365
- package/lib/commonjs/store/blockPlacement.js +1 -0
- package/lib/commonjs/store/blockPlacement.test.js +1 -0
- package/lib/commonjs/store/queue.test.js +1 -0
- package/lib/commonjs/store/resetConversation.js +1 -0
- package/lib/commonjs/store/restorePending.test.js +1 -0
- package/lib/commonjs/store/restoredIds.test.js +1 -47
- package/lib/commonjs/store/suggestions.js +1 -0
- package/lib/commonjs/store/suggestions.test.js +1 -0
- package/lib/commonjs/store/systemLine.test.js +1 -0
- package/lib/commonjs/store/ticketPrompt.js +1 -0
- package/lib/commonjs/store/traceText.js +1 -81
- package/lib/commonjs/store/traceText.test.js +1 -112
- package/lib/commonjs/store/transcriptPersistence.js +1 -208
- package/lib/commonjs/store/transcriptPersistence.test.js +1 -185
- package/lib/commonjs/store/turnRendering.test.js +1 -0
- package/lib/commonjs/store/useAskBuoy.js +1 -400
- package/lib/commonjs/store/useAskBuoySettings.js +1 -14
- package/lib/commonjs/sync/askBuoySyncAdapter.js +1 -119
- package/lib/commonjs/sync/askBuoySyncAdapter.test.js +1 -141
- package/lib/commonjs/sync/wire.js +1 -58
- package/lib/commonjs/types.js +1 -6
- package/lib/module/blocks/AskBlocks.js +1 -331
- package/lib/module/blocks/BlockRenderer.js +1 -245
- package/lib/module/blocks/ChromePrototypes.js +1 -503
- package/lib/module/blocks/DataBlocks.js +1 -674
- package/lib/module/blocks/ExtraBlocks.js +1 -1827
- package/lib/module/blocks/MediaBlocks.js +1 -135
- package/lib/module/blocks/ReceiptBlocks.js +1 -574
- package/lib/module/blocks/blockText.js +1 -0
- package/lib/module/blocks/blockText.test.js +1 -0
- package/lib/module/blocks/context.js +1 -35
- package/lib/module/blocks/icons.js +1 -91
- package/lib/module/blocks/index.js +1 -8
- package/lib/module/blocks/listRow.test.js +1 -56
- package/lib/module/blocks/pageState.js +1 -30
- package/lib/module/blocks/pageState.test.js +1 -56
- package/lib/module/blocks/primitives.js +1 -389
- package/lib/module/blocks/primitivesIndex.js +1 -5
- package/lib/module/components/ApprovalCard.js +1 -135
- package/lib/module/components/AskBuoyHeader.js +1 -161
- package/lib/module/components/AskBuoyIcon.js +1 -8
- package/lib/module/components/AskBuoyModal.js +1 -348
- package/lib/module/components/AskBuoySettings.js +1 -64
- package/lib/module/components/ChangesBar.js +1 -206
- package/lib/module/components/Composer.js +1 -170
- package/lib/module/components/EmptyState.js +1 -149
- package/lib/module/components/KeyboardPad.js +1 -0
- package/lib/module/components/Markdown.js +1 -246
- package/lib/module/components/MessageList.js +1 -677
- package/lib/module/components/QueuedMessages.js +1 -0
- package/lib/module/components/ThinkingStrip.js +1 -218
- package/lib/module/components/TypingDots.js +1 -58
- package/lib/module/components/markdownParse.js +1 -0
- package/lib/module/components/markdownParse.test.js +1 -0
- package/lib/module/components/useCopyAction.js +1 -46
- package/lib/module/index.js +1 -34
- package/lib/module/preset.js +1 -73
- package/lib/module/store/activityGroups.js +1 -0
- package/lib/module/store/activityGroups.test.js +1 -0
- package/lib/module/store/askBuoySettings.js +1 -62
- package/lib/module/store/askBuoyStore.js +1 -361
- package/lib/module/store/blockPlacement.js +1 -0
- package/lib/module/store/blockPlacement.test.js +1 -0
- package/lib/module/store/queue.test.js +1 -0
- package/lib/module/store/resetConversation.js +1 -0
- package/lib/module/store/restorePending.test.js +1 -0
- package/lib/module/store/restoredIds.test.js +1 -46
- package/lib/module/store/suggestions.js +1 -0
- package/lib/module/store/suggestions.test.js +1 -0
- package/lib/module/store/systemLine.test.js +1 -0
- package/lib/module/store/ticketPrompt.js +1 -0
- package/lib/module/store/traceText.js +1 -75
- package/lib/module/store/traceText.test.js +1 -111
- package/lib/module/store/transcriptPersistence.js +1 -198
- package/lib/module/store/transcriptPersistence.test.js +1 -184
- package/lib/module/store/turnRendering.test.js +1 -0
- package/lib/module/store/useAskBuoy.js +1 -394
- package/lib/module/store/useAskBuoySettings.js +1 -9
- package/lib/module/sync/askBuoySyncAdapter.js +1 -114
- package/lib/module/sync/askBuoySyncAdapter.test.js +1 -140
- package/lib/module/sync/wire.js +1 -47
- package/lib/module/types.js +1 -4
- package/lib/typescript/blocks/DataBlocks.d.ts +11 -0
- package/lib/typescript/blocks/ExtraBlocks.d.ts +18 -2
- package/lib/typescript/blocks/blockText.d.ts +14 -0
- package/lib/typescript/blocks/blockText.test.d.ts +2 -0
- package/lib/typescript/blocks/primitives.d.ts +16 -1
- package/lib/typescript/components/ApprovalCard.d.ts +9 -1
- package/lib/typescript/components/AskBuoyHeader.d.ts +31 -1
- package/lib/typescript/components/Composer.d.ts +16 -1
- package/lib/typescript/components/EmptyState.d.ts +5 -1
- package/lib/typescript/components/KeyboardPad.d.ts +33 -0
- package/lib/typescript/components/Markdown.d.ts +0 -10
- package/lib/typescript/components/MessageList.d.ts +7 -2
- package/lib/typescript/components/QueuedMessages.d.ts +10 -0
- package/lib/typescript/components/markdownParse.d.ts +49 -0
- package/lib/typescript/components/markdownParse.test.d.ts +2 -0
- package/lib/typescript/preset.d.ts +4 -2
- package/lib/typescript/store/activityGroups.d.ts +29 -0
- package/lib/typescript/store/activityGroups.test.d.ts +2 -0
- package/lib/typescript/store/askBuoySettings.d.ts +22 -0
- package/lib/typescript/store/askBuoyStore.d.ts +174 -9
- package/lib/typescript/store/blockPlacement.d.ts +30 -0
- package/lib/typescript/store/blockPlacement.test.d.ts +2 -0
- package/lib/typescript/store/queue.test.d.ts +2 -0
- package/lib/typescript/store/resetConversation.d.ts +38 -0
- package/lib/typescript/store/restorePending.test.d.ts +2 -0
- package/lib/typescript/store/suggestions.d.ts +32 -0
- package/lib/typescript/store/suggestions.test.d.ts +2 -0
- package/lib/typescript/store/systemLine.test.d.ts +2 -0
- package/lib/typescript/store/ticketPrompt.d.ts +11 -0
- package/lib/typescript/store/transcriptPersistence.d.ts +41 -2
- package/lib/typescript/store/turnRendering.test.d.ts +2 -0
- package/lib/typescript/store/useAskBuoy.d.ts +26 -3
- package/lib/typescript/sync/askBuoySyncAdapter.d.ts +29 -6
- package/package.json +10 -10
- package/lib/commonjs/blocks/AskBlocks.js.map +0 -1
- package/lib/commonjs/blocks/BlockRenderer.js.map +0 -1
- package/lib/commonjs/blocks/ChromePrototypes.js.map +0 -1
- package/lib/commonjs/blocks/DataBlocks.js.map +0 -1
- package/lib/commonjs/blocks/ExtraBlocks.js.map +0 -1
- package/lib/commonjs/blocks/MediaBlocks.js.map +0 -1
- package/lib/commonjs/blocks/ReceiptBlocks.js.map +0 -1
- package/lib/commonjs/blocks/context.js.map +0 -1
- package/lib/commonjs/blocks/icons.js.map +0 -1
- package/lib/commonjs/blocks/index.js.map +0 -1
- package/lib/commonjs/blocks/listRow.test.js.map +0 -1
- package/lib/commonjs/blocks/pageState.js.map +0 -1
- package/lib/commonjs/blocks/pageState.test.js.map +0 -1
- package/lib/commonjs/blocks/primitives.js.map +0 -1
- package/lib/commonjs/blocks/primitivesIndex.js.map +0 -1
- package/lib/commonjs/components/ApprovalCard.js.map +0 -1
- package/lib/commonjs/components/AskBuoyHeader.js.map +0 -1
- package/lib/commonjs/components/AskBuoyIcon.js.map +0 -1
- package/lib/commonjs/components/AskBuoyModal.js.map +0 -1
- package/lib/commonjs/components/AskBuoySettings.js.map +0 -1
- package/lib/commonjs/components/ChangesBar.js.map +0 -1
- package/lib/commonjs/components/Composer.js.map +0 -1
- package/lib/commonjs/components/EmptyState.js.map +0 -1
- package/lib/commonjs/components/Markdown.js.map +0 -1
- package/lib/commonjs/components/MessageList.js.map +0 -1
- package/lib/commonjs/components/ThinkingStrip.js.map +0 -1
- package/lib/commonjs/components/TypingDots.js.map +0 -1
- package/lib/commonjs/components/useCopyAction.js.map +0 -1
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/preset.js.map +0 -1
- package/lib/commonjs/store/askBuoySettings.js.map +0 -1
- package/lib/commonjs/store/askBuoyStore.js.map +0 -1
- package/lib/commonjs/store/restoredIds.test.js.map +0 -1
- package/lib/commonjs/store/traceText.js.map +0 -1
- package/lib/commonjs/store/traceText.test.js.map +0 -1
- package/lib/commonjs/store/transcriptPersistence.js.map +0 -1
- package/lib/commonjs/store/transcriptPersistence.test.js.map +0 -1
- package/lib/commonjs/store/useAskBuoy.js.map +0 -1
- package/lib/commonjs/store/useAskBuoySettings.js.map +0 -1
- package/lib/commonjs/sync/askBuoySyncAdapter.js.map +0 -1
- package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +0 -1
- package/lib/commonjs/sync/wire.js.map +0 -1
- package/lib/commonjs/types.js.map +0 -1
- package/lib/module/blocks/AskBlocks.js.map +0 -1
- package/lib/module/blocks/BlockRenderer.js.map +0 -1
- package/lib/module/blocks/ChromePrototypes.js.map +0 -1
- package/lib/module/blocks/DataBlocks.js.map +0 -1
- package/lib/module/blocks/ExtraBlocks.js.map +0 -1
- package/lib/module/blocks/MediaBlocks.js.map +0 -1
- package/lib/module/blocks/ReceiptBlocks.js.map +0 -1
- package/lib/module/blocks/context.js.map +0 -1
- package/lib/module/blocks/icons.js.map +0 -1
- package/lib/module/blocks/index.js.map +0 -1
- package/lib/module/blocks/listRow.test.js.map +0 -1
- package/lib/module/blocks/pageState.js.map +0 -1
- package/lib/module/blocks/pageState.test.js.map +0 -1
- package/lib/module/blocks/primitives.js.map +0 -1
- package/lib/module/blocks/primitivesIndex.js.map +0 -1
- package/lib/module/components/ApprovalCard.js.map +0 -1
- package/lib/module/components/AskBuoyHeader.js.map +0 -1
- package/lib/module/components/AskBuoyIcon.js.map +0 -1
- package/lib/module/components/AskBuoyModal.js.map +0 -1
- package/lib/module/components/AskBuoySettings.js.map +0 -1
- package/lib/module/components/ChangesBar.js.map +0 -1
- package/lib/module/components/Composer.js.map +0 -1
- package/lib/module/components/EmptyState.js.map +0 -1
- package/lib/module/components/Markdown.js.map +0 -1
- package/lib/module/components/MessageList.js.map +0 -1
- package/lib/module/components/ThinkingStrip.js.map +0 -1
- package/lib/module/components/TypingDots.js.map +0 -1
- package/lib/module/components/useCopyAction.js.map +0 -1
- package/lib/module/index.js.map +0 -1
- package/lib/module/preset.js.map +0 -1
- package/lib/module/store/askBuoySettings.js.map +0 -1
- package/lib/module/store/askBuoyStore.js.map +0 -1
- package/lib/module/store/restoredIds.test.js.map +0 -1
- package/lib/module/store/traceText.js.map +0 -1
- package/lib/module/store/traceText.test.js.map +0 -1
- package/lib/module/store/transcriptPersistence.js.map +0 -1
- package/lib/module/store/transcriptPersistence.test.js.map +0 -1
- package/lib/module/store/useAskBuoy.js.map +0 -1
- package/lib/module/store/useAskBuoySettings.js.map +0 -1
- package/lib/module/sync/askBuoySyncAdapter.js.map +0 -1
- package/lib/module/sync/askBuoySyncAdapter.test.js.map +0 -1
- package/lib/module/sync/wire.js.map +0 -1
- package/lib/module/types.js.map +0 -1
- package/lib/typescript/blocks/AskBlocks.d.ts.map +0 -1
- package/lib/typescript/blocks/BlockRenderer.d.ts.map +0 -1
- package/lib/typescript/blocks/ChromePrototypes.d.ts.map +0 -1
- package/lib/typescript/blocks/DataBlocks.d.ts.map +0 -1
- package/lib/typescript/blocks/ExtraBlocks.d.ts.map +0 -1
- package/lib/typescript/blocks/MediaBlocks.d.ts.map +0 -1
- package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +0 -1
- package/lib/typescript/blocks/context.d.ts.map +0 -1
- package/lib/typescript/blocks/icons.d.ts.map +0 -1
- package/lib/typescript/blocks/index.d.ts.map +0 -1
- package/lib/typescript/blocks/listRow.test.d.ts.map +0 -1
- package/lib/typescript/blocks/pageState.d.ts.map +0 -1
- package/lib/typescript/blocks/pageState.test.d.ts.map +0 -1
- package/lib/typescript/blocks/primitives.d.ts.map +0 -1
- package/lib/typescript/blocks/primitivesIndex.d.ts.map +0 -1
- package/lib/typescript/components/ApprovalCard.d.ts.map +0 -1
- package/lib/typescript/components/AskBuoyHeader.d.ts.map +0 -1
- package/lib/typescript/components/AskBuoyIcon.d.ts.map +0 -1
- package/lib/typescript/components/AskBuoyModal.d.ts.map +0 -1
- package/lib/typescript/components/AskBuoySettings.d.ts.map +0 -1
- package/lib/typescript/components/ChangesBar.d.ts.map +0 -1
- package/lib/typescript/components/Composer.d.ts.map +0 -1
- package/lib/typescript/components/EmptyState.d.ts.map +0 -1
- package/lib/typescript/components/Markdown.d.ts.map +0 -1
- package/lib/typescript/components/MessageList.d.ts.map +0 -1
- package/lib/typescript/components/ThinkingStrip.d.ts.map +0 -1
- package/lib/typescript/components/TypingDots.d.ts.map +0 -1
- package/lib/typescript/components/useCopyAction.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
- package/lib/typescript/store/askBuoySettings.d.ts.map +0 -1
- package/lib/typescript/store/askBuoyStore.d.ts.map +0 -1
- package/lib/typescript/store/restoredIds.test.d.ts.map +0 -1
- package/lib/typescript/store/traceText.d.ts.map +0 -1
- package/lib/typescript/store/traceText.test.d.ts.map +0 -1
- package/lib/typescript/store/transcriptPersistence.d.ts.map +0 -1
- package/lib/typescript/store/transcriptPersistence.test.d.ts.map +0 -1
- package/lib/typescript/store/useAskBuoy.d.ts.map +0 -1
- package/lib/typescript/store/useAskBuoySettings.d.ts.map +0 -1
- package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +0 -1
- package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +0 -1
- package/lib/typescript/sync/wire.d.ts.map +0 -1
- package/lib/typescript/types.d.ts.map +0 -1
|
@@ -1,141 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _agentCore = require("@buoy-gg/agent-core");
|
|
5
|
-
var _askBuoySyncAdapter = require("./askBuoySyncAdapter");
|
|
6
|
-
var _wire = require("./wire");
|
|
7
|
-
var _askBuoyStore = require("../store/askBuoyStore");
|
|
8
|
-
/**
|
|
9
|
-
* What Ask Buoy is allowed to put on the broker wire, and what it refuses to
|
|
10
|
-
* accept from it.
|
|
11
|
-
*
|
|
12
|
-
* Both directions matter. The broker has no authentication, accepts any client
|
|
13
|
-
* that calls itself "Dashboard", and forwards to every connected dashboard — it
|
|
14
|
-
* already broadcasts license keys that way. So: no tool results go out, and no
|
|
15
|
-
* remote client can make the agent say anything.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
(0, _vitest.beforeEach)(() => {
|
|
19
|
-
_askBuoyStore.askBuoyStore.reset();
|
|
20
|
-
_askBuoyStore.askBuoyStore.setLedger(null);
|
|
21
|
-
});
|
|
22
|
-
(0, _vitest.describe)("the wire surface", () => {
|
|
23
|
-
(0, _vitest.it)("exposes no action that can make the agent talk", () => {
|
|
24
|
-
// A `send` here would let anyone on the LAN drive a mutating agent on a
|
|
25
|
-
// tester's phone. The conversation starts on-device, by a person.
|
|
26
|
-
const actions = Object.keys(_askBuoySyncAdapter.askBuoySyncAdapter.actions);
|
|
27
|
-
(0, _vitest.expect)(actions).not.toContain("send");
|
|
28
|
-
(0, _vitest.expect)(actions).not.toContain("ask");
|
|
29
|
-
(0, _vitest.expect)(actions).not.toContain("prompt");
|
|
30
|
-
(0, _vitest.expect)(actions.sort()).toEqual(["listChanges", "reset", "undoAll"]);
|
|
31
|
-
});
|
|
32
|
-
(0, _vitest.it)("puts the shape of the conversation on the wire, never tool payloads", () => {
|
|
33
|
-
_askBuoyStore.askBuoyStore.addUser("what is in storage");
|
|
34
|
-
const id = _askBuoyStore.askBuoyStore.startAssistant();
|
|
35
|
-
_askBuoyStore.askBuoyStore.applyEvent(id, {
|
|
36
|
-
type: "tool-start",
|
|
37
|
-
id: "c1",
|
|
38
|
-
toolId: "storage",
|
|
39
|
-
action: "async.getItem",
|
|
40
|
-
label: "Read session",
|
|
41
|
-
description: "Read one AsyncStorage key",
|
|
42
|
-
params: {
|
|
43
|
-
key: "session"
|
|
44
|
-
},
|
|
45
|
-
effect: "read"
|
|
46
|
-
});
|
|
47
|
-
_askBuoyStore.askBuoyStore.applyEvent(id, {
|
|
48
|
-
type: "tool-end",
|
|
49
|
-
id: "c1",
|
|
50
|
-
ok: true,
|
|
51
|
-
durationMs: 12,
|
|
52
|
-
summary: "eyJhbGciOiJIUzI1NiJ9.super.secret"
|
|
53
|
-
});
|
|
54
|
-
const snap = _askBuoySyncAdapter.askBuoySyncAdapter.getSnapshot();
|
|
55
|
-
const call = snap.messages[1].toolCalls[0];
|
|
56
|
-
(0, _vitest.expect)(call).toEqual({
|
|
57
|
-
toolId: "storage",
|
|
58
|
-
action: "async.getItem",
|
|
59
|
-
status: "ok"
|
|
60
|
-
});
|
|
61
|
-
// The result summary is not on the wire at all — there is no field for it.
|
|
62
|
-
(0, _vitest.expect)(JSON.stringify(snap)).not.toContain("super.secret");
|
|
63
|
-
});
|
|
64
|
-
(0, _vitest.it)("redacts credentials that made it into the assistant's prose", () => {
|
|
65
|
-
_askBuoyStore.askBuoyStore.addUser("show me the auth header");
|
|
66
|
-
const id = _askBuoyStore.askBuoyStore.startAssistant();
|
|
67
|
-
_askBuoyStore.askBuoyStore.applyEvent(id, {
|
|
68
|
-
type: "text",
|
|
69
|
-
delta: "It sends Authorization: Bearer abcdef0123456789ghijkl to the API."
|
|
70
|
-
});
|
|
71
|
-
const snap = _askBuoySyncAdapter.askBuoySyncAdapter.getSnapshot();
|
|
72
|
-
(0, _vitest.expect)(JSON.stringify(snap)).not.toContain("abcdef0123456789ghijkl");
|
|
73
|
-
});
|
|
74
|
-
(0, _vitest.it)("reports reversible and permanent changes separately", () => {
|
|
75
|
-
const ledger = new _agentCore.EffectLedger();
|
|
76
|
-
_askBuoyStore.askBuoyStore.setLedger(ledger);
|
|
77
|
-
ledger.record("storage", "async.setItem", {
|
|
78
|
-
kind: "storage-write",
|
|
79
|
-
toolId: "storage",
|
|
80
|
-
action: "async.setItem",
|
|
81
|
-
key: "points",
|
|
82
|
-
before: "240",
|
|
83
|
-
label: "Set points to 1500"
|
|
84
|
-
});
|
|
85
|
-
ledger.record("perf-monitor", "clearAll", {
|
|
86
|
-
kind: "transient",
|
|
87
|
-
label: "Cleared samples"
|
|
88
|
-
});
|
|
89
|
-
// A store write with no captured prior state: recorded, visible, and
|
|
90
|
-
// NOT something Undo can deliver — it must count as permanent.
|
|
91
|
-
ledger.record("zustand", "setState", {
|
|
92
|
-
kind: "state-write",
|
|
93
|
-
toolId: "zustand",
|
|
94
|
-
action: "setState",
|
|
95
|
-
label: "Update the cart store"
|
|
96
|
-
});
|
|
97
|
-
const snap = _askBuoySyncAdapter.askBuoySyncAdapter.getSnapshot();
|
|
98
|
-
(0, _vitest.expect)(snap.changes.reversible).toBe(1);
|
|
99
|
-
// The transient is an ACTION, not a change — it must not inflate
|
|
100
|
-
// "permanent" (that read "Changed this app · N permanent" after a
|
|
101
|
-
// read-only tour). It is still reported, in its own count.
|
|
102
|
-
(0, _vitest.expect)(snap.changes.permanent).toBe(1);
|
|
103
|
-
(0, _vitest.expect)(snap.changes.transients).toBe(1);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
(0, _vitest.describe)("redactForWire", () => {
|
|
107
|
-
(0, _vitest.it)("removes bearer tokens, JWTs, api keys and license keys", () => {
|
|
108
|
-
const cases = ["Authorization: Bearer abcdefghijklmnop123456", "token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9abcdefgh", "key sk-abcdefghijklmnop1234", "license BUOY-ABCD-1234-EFGH", 'the header is "x-api-key": "supersecretvalue"'];
|
|
109
|
-
for (const input of cases) {
|
|
110
|
-
(0, _vitest.expect)((0, _wire.redactForWire)(input)).toContain("removed]");
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
(0, _vitest.it)("leaves ordinary prose alone", () => {
|
|
114
|
-
const text = "The /menu call returned 200 with 12 items and the burger was in stock.";
|
|
115
|
-
(0, _vitest.expect)((0, _wire.redactForWire)(text)).toBe(text);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
(0, _vitest.describe)("undo from the desktop", () => {
|
|
119
|
-
(0, _vitest.it)("is allowed, because putting things back is the safe direction", async () => {
|
|
120
|
-
const ledger = new _agentCore.EffectLedger();
|
|
121
|
-
_askBuoyStore.askBuoyStore.setLedger(ledger);
|
|
122
|
-
const store = new Map([["points", "1500"]]);
|
|
123
|
-
ledger.record("storage", "async.setItem", {
|
|
124
|
-
kind: "storage-write",
|
|
125
|
-
toolId: "storage",
|
|
126
|
-
action: "async.setItem",
|
|
127
|
-
key: "points",
|
|
128
|
-
before: "240",
|
|
129
|
-
label: "Set points to 1500"
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
// The adapter dispatches through the real seam; stub it at the ledger.
|
|
133
|
-
await ledger.revertAll(async (_t, action, params) => {
|
|
134
|
-
const p = params;
|
|
135
|
-
if (action === "async.setItem") store.set(p.key, p.value);
|
|
136
|
-
return undefined;
|
|
137
|
-
});
|
|
138
|
-
(0, _vitest.expect)(store.get("points")).toBe("240");
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
//# sourceMappingURL=askBuoySyncAdapter.test.js.map
|
|
1
|
+
"use strict";var _vitest=require("vitest"),_agentCore=require("@buoy-gg/agent-core"),_askBuoySyncAdapter=require("./askBuoySyncAdapter"),_wire=require("./wire"),_askBuoyStore=require("../store/askBuoyStore");(0,_vitest.beforeEach)(()=>{_askBuoyStore.askBuoyStore.reset(),_askBuoyStore.askBuoyStore.setLedger(null)}),(0,_vitest.describe)("the wire surface",()=>{(0,_vitest.it)("exposes no action that can make the agent talk",()=>{const e=Object.keys(_askBuoySyncAdapter.askBuoySyncAdapter.actions);(0,_vitest.expect)(e).not.toContain("send"),(0,_vitest.expect)(e).not.toContain("ask"),(0,_vitest.expect)(e).not.toContain("prompt"),(0,_vitest.expect)(e.sort()).toEqual(["listChanges","reset","undoAll"])}),(0,_vitest.it)("puts the shape of the conversation on the wire, never tool payloads",()=>{_askBuoyStore.askBuoyStore.addUser("what is in storage");const e=_askBuoyStore.askBuoyStore.startAssistant();_askBuoyStore.askBuoyStore.applyEvent(e,{type:"tool-start",id:"c1",toolId:"storage",action:"async.getItem",label:"Read session",description:"Read one AsyncStorage key",params:{key:"session"},effect:"read"}),_askBuoyStore.askBuoyStore.applyEvent(e,{type:"tool-end",id:"c1",ok:!0,durationMs:12,summary:"eyJhbGciOiJIUzI1NiJ9.super.secret"});const t=_askBuoySyncAdapter.askBuoySyncAdapter.getSnapshot(),s=t.messages[1].toolCalls[0];(0,_vitest.expect)(s).toEqual({toolId:"storage",action:"async.getItem",status:"ok"}),(0,_vitest.expect)(JSON.stringify(t)).not.toContain("super.secret")}),(0,_vitest.it)("redacts credentials that made it into the assistant's prose",()=>{_askBuoyStore.askBuoyStore.addUser("show me the auth header");const e=_askBuoyStore.askBuoyStore.startAssistant();_askBuoyStore.askBuoyStore.applyEvent(e,{type:"text",delta:"It sends Authorization: Bearer abcdef0123456789ghijkl to the API."});const t=_askBuoySyncAdapter.askBuoySyncAdapter.getSnapshot();(0,_vitest.expect)(JSON.stringify(t)).not.toContain("abcdef0123456789ghijkl")}),(0,_vitest.it)("reports reversible and permanent changes separately",()=>{const e=new _agentCore.EffectLedger;_askBuoyStore.askBuoyStore.setLedger(e),e.record("storage","async.setItem",{kind:"storage-write",toolId:"storage",action:"async.setItem",key:"points",before:"240",label:"Set points to 1500"}),e.record("perf-monitor","clearAll",{kind:"transient",label:"Cleared samples"}),e.record("zustand","setState",{kind:"state-write",toolId:"zustand",action:"setState",label:"Update the cart store"});const t=_askBuoySyncAdapter.askBuoySyncAdapter.getSnapshot();(0,_vitest.expect)(t.changes.reversible).toBe(1),(0,_vitest.expect)(t.changes.permanent).toBe(1),(0,_vitest.expect)(t.changes.transients).toBe(1)})}),(0,_vitest.describe)("redactForWire",()=>{(0,_vitest.it)("removes bearer tokens, JWTs, api keys and license keys",()=>{const e=["Authorization: Bearer abcdefghijklmnop123456","token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9abcdefgh","key sk-abcdefghijklmnop1234","license BUOY-ABCD-1234-EFGH",'the header is "x-api-key": "supersecretvalue"'];for(const t of e)(0,_vitest.expect)((0,_wire.redactForWire)(t)).toContain("removed]")}),(0,_vitest.it)("leaves ordinary prose alone",()=>{const e="The /menu call returned 200 with 12 items and the burger was in stock.";(0,_vitest.expect)((0,_wire.redactForWire)(e)).toBe(e)})}),(0,_vitest.describe)("undo from the desktop",()=>{(0,_vitest.it)("is allowed, because putting things back is the safe direction",async()=>{const e=new _agentCore.EffectLedger;_askBuoyStore.askBuoyStore.setLedger(e);const t=new Map([["points","1500"]]);e.record("storage","async.setItem",{kind:"storage-write",toolId:"storage",action:"async.setItem",key:"points",before:"240",label:"Set points to 1500"}),await e.revertAll(async(e,s,o)=>{const a=o;"async.setItem"===s&&t.set(a.key,a.value)}),(0,_vitest.expect)(t.get("points")).toBe("240")})});
|
|
@@ -1,58 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "dispatchToolAction", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _sharedUi.dispatchToolAction;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
exports.redactForWire = redactForWire;
|
|
13
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
14
|
-
/**
|
|
15
|
-
* What the sync adapter is allowed to put on the broker wire.
|
|
16
|
-
*
|
|
17
|
-
* The broker has no authentication, `cors.origin: "*"`, binds every interface,
|
|
18
|
-
* and forwards to every connected dashboard — it already broadcasts each
|
|
19
|
-
* device's license key to every socket. A chat transcript is not a safe thing
|
|
20
|
-
* to add to that channel unfiltered: the agent reads storage values, network
|
|
21
|
-
* response bodies and user records, and any of it can end up quoted in an
|
|
22
|
-
* answer.
|
|
23
|
-
*
|
|
24
|
-
* So text crossing the wire is scrubbed for the shapes that are unambiguously
|
|
25
|
-
* credentials. This is a reduction in blast radius, not a guarantee — the real
|
|
26
|
-
* guarantee is that tool RESULTS never cross at all (see askBuoySyncAdapter).
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
const PATTERNS = [{
|
|
30
|
-
re: /\bBearer\s+[A-Za-z0-9._~+/-]{12,}=*/gi,
|
|
31
|
-
label: "[bearer token removed]"
|
|
32
|
-
}, {
|
|
33
|
-
re: /\beyJ[A-Za-z0-9._-]{20,}/g,
|
|
34
|
-
label: "[jwt removed]"
|
|
35
|
-
}, {
|
|
36
|
-
re: /\bsk-[A-Za-z0-9_-]{16,}/g,
|
|
37
|
-
label: "[api key removed]"
|
|
38
|
-
}, {
|
|
39
|
-
re: /\bBUOY-[A-Z0-9-]{8,}/g,
|
|
40
|
-
label: "[license key removed]"
|
|
41
|
-
},
|
|
42
|
-
// Common "key: value" credential shapes in a quoted payload.
|
|
43
|
-
{
|
|
44
|
-
re: /("|')?(authorization|x-api-key|api[_-]?key|password|secret|access_token|refresh_token)\1?\s*[:=]\s*("|')?[^\s"',}]{6,}/gi,
|
|
45
|
-
label: "[credential removed]"
|
|
46
|
-
}];
|
|
47
|
-
function redactForWire(text) {
|
|
48
|
-
if (!text) return text;
|
|
49
|
-
let out = text;
|
|
50
|
-
for (const {
|
|
51
|
-
re,
|
|
52
|
-
label
|
|
53
|
-
} of PATTERNS) {
|
|
54
|
-
out = out.replace(re, label);
|
|
55
|
-
}
|
|
56
|
-
return out;
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=wire.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"dispatchToolAction",{enumerable:!0,get:function(){return _sharedUi.dispatchToolAction}}),exports.redactForWire=redactForWire;var _sharedUi=require("@buoy-gg/shared-ui");const PATTERNS=[{re:/\bBearer\s+[A-Za-z0-9._~+/-]{12,}=*/gi,label:"[bearer token removed]"},{re:/\beyJ[A-Za-z0-9._-]{20,}/g,label:"[jwt removed]"},{re:/\bsk-[A-Za-z0-9_-]{16,}/g,label:"[api key removed]"},{re:/\bBUOY-[A-Z0-9-]{8,}/g,label:"[license key removed]"},{re:/("|')?(authorization|x-api-key|api[_-]?key|password|secret|access_token|refresh_token)\1?\s*[:=]\s*("|')?[^\s"',}]{6,}/gi,label:"[credential removed]"}];function redactForWire(e){if(!e)return e;let r=e;for(const{re:e,label:o}of PATTERNS)r=r.replace(e,o);return r}
|
package/lib/commonjs/types.js
CHANGED
|
@@ -1,331 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Ask blocks — the user has to decide, and the turn is waiting.
|
|
5
|
-
*
|
|
6
|
-
* Choice, Confirm and Input all lock once answered: the chosen option stays
|
|
7
|
-
* highlighted, the rest dim, and nothing in history is tappable twice. The
|
|
8
|
-
* answer is handed to the sheet as a BlockAnswer and becomes the next user
|
|
9
|
-
* message, so the model reads plain words ("Business checkout"), never JSON.
|
|
10
|
-
*/
|
|
11
|
-
import { useState } from "react";
|
|
12
|
-
import { Pressable, StyleSheet, Text, TextInput, View } from "react-native";
|
|
13
|
-
import { Check, ChevronRight, night } from "@buoy-gg/shared-ui";
|
|
14
|
-
import { useBlockHandlers } from "./context";
|
|
15
|
-
import { BlockIcon } from "./icons";
|
|
16
|
-
import { Card } from "./primitives";
|
|
17
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
|
-
export function Choice({
|
|
19
|
-
block
|
|
20
|
-
}) {
|
|
21
|
-
const h = useBlockHandlers();
|
|
22
|
-
const answer = h.answered[block.id];
|
|
23
|
-
const chosen = answer?.kind === "choice" ? answer.optionId : null;
|
|
24
|
-
const locked = !!answer;
|
|
25
|
-
return /*#__PURE__*/_jsxs(Card, {
|
|
26
|
-
testID: `buoy-block-choice-${block.id}`,
|
|
27
|
-
tone: locked ? undefined : "info",
|
|
28
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
29
|
-
style: styles.question,
|
|
30
|
-
children: block.question
|
|
31
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
32
|
-
style: styles.options,
|
|
33
|
-
children: block.options.slice(0, 5).map((o, i) => {
|
|
34
|
-
const isChosen = chosen === o.id;
|
|
35
|
-
return /*#__PURE__*/_jsxs(Pressable, {
|
|
36
|
-
testID: `buoy-block-option-${o.id}`,
|
|
37
|
-
accessibilityRole: "button",
|
|
38
|
-
accessibilityState: {
|
|
39
|
-
selected: isChosen,
|
|
40
|
-
disabled: locked
|
|
41
|
-
},
|
|
42
|
-
disabled: locked,
|
|
43
|
-
onPress: () => h.answer({
|
|
44
|
-
blockId: block.id,
|
|
45
|
-
kind: "choice",
|
|
46
|
-
optionId: o.id,
|
|
47
|
-
label: o.label
|
|
48
|
-
}),
|
|
49
|
-
style: ({
|
|
50
|
-
pressed
|
|
51
|
-
}) => [styles.option, i > 0 && styles.optionDivider, isChosen && styles.optionChosen, locked && !isChosen && styles.optionDimmed, pressed && !locked && styles.pressed],
|
|
52
|
-
children: [o.icon ? /*#__PURE__*/_jsx(BlockIcon, {
|
|
53
|
-
name: o.icon
|
|
54
|
-
}) : null, /*#__PURE__*/_jsxs(View, {
|
|
55
|
-
style: styles.optionText,
|
|
56
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
57
|
-
style: [styles.optionLabel, isChosen && styles.optionLabelChosen],
|
|
58
|
-
children: o.label
|
|
59
|
-
}), o.detail ? /*#__PURE__*/_jsx(Text, {
|
|
60
|
-
style: styles.optionDetail,
|
|
61
|
-
children: o.detail
|
|
62
|
-
}) : null]
|
|
63
|
-
}), isChosen ? /*#__PURE__*/_jsx(Check, {
|
|
64
|
-
size: 14,
|
|
65
|
-
color: night.color.accent
|
|
66
|
-
}) : locked ? null : /*#__PURE__*/_jsx(ChevronRight, {
|
|
67
|
-
size: 14,
|
|
68
|
-
color: night.color.textTertiary
|
|
69
|
-
})]
|
|
70
|
-
}, o.id);
|
|
71
|
-
})
|
|
72
|
-
}), !locked && block.allowFreeText !== false ? /*#__PURE__*/_jsx(Text, {
|
|
73
|
-
style: styles.hint,
|
|
74
|
-
children: "Or just type your answer below."
|
|
75
|
-
}) : null]
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
export function Confirm({
|
|
79
|
-
block
|
|
80
|
-
}) {
|
|
81
|
-
const h = useBlockHandlers();
|
|
82
|
-
const answer = h.answered[block.id];
|
|
83
|
-
const locked = !!answer;
|
|
84
|
-
const approved = answer?.kind === "confirm" ? answer.approved : null;
|
|
85
|
-
return /*#__PURE__*/_jsxs(Card, {
|
|
86
|
-
testID: `buoy-block-confirm-${block.id}`,
|
|
87
|
-
tone: locked ? undefined : "warning",
|
|
88
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
89
|
-
style: styles.confirmTitle,
|
|
90
|
-
children: block.title
|
|
91
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
92
|
-
style: styles.confirmChange,
|
|
93
|
-
children: block.change
|
|
94
|
-
}), block.consequence ? /*#__PURE__*/_jsx(Text, {
|
|
95
|
-
style: styles.confirmConsequence,
|
|
96
|
-
children: block.consequence
|
|
97
|
-
}) : null, /*#__PURE__*/_jsx(View, {
|
|
98
|
-
style: styles.confirmActions,
|
|
99
|
-
children: locked ? /*#__PURE__*/_jsx(Text, {
|
|
100
|
-
style: styles.decided,
|
|
101
|
-
children: approved ? `✓ ${block.approveLabel ?? "Done"}` : `✕ ${block.declineLabel ?? "Not now"}`
|
|
102
|
-
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
103
|
-
children: [/*#__PURE__*/_jsx(Pressable, {
|
|
104
|
-
testID: "buoy-block-approve",
|
|
105
|
-
accessibilityRole: "button",
|
|
106
|
-
onPress: () => h.answer({
|
|
107
|
-
blockId: block.id,
|
|
108
|
-
kind: "confirm",
|
|
109
|
-
approved: true
|
|
110
|
-
}),
|
|
111
|
-
style: ({
|
|
112
|
-
pressed
|
|
113
|
-
}) => [styles.button, styles.buttonPrimary, pressed && styles.pressed],
|
|
114
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
115
|
-
style: styles.buttonTextPrimary,
|
|
116
|
-
children: block.approveLabel ?? "Do it"
|
|
117
|
-
})
|
|
118
|
-
}), /*#__PURE__*/_jsx(Pressable, {
|
|
119
|
-
testID: "buoy-block-decline",
|
|
120
|
-
accessibilityRole: "button",
|
|
121
|
-
onPress: () => h.answer({
|
|
122
|
-
blockId: block.id,
|
|
123
|
-
kind: "confirm",
|
|
124
|
-
approved: false
|
|
125
|
-
}),
|
|
126
|
-
style: ({
|
|
127
|
-
pressed
|
|
128
|
-
}) => [styles.button, styles.buttonPlate, pressed && styles.pressed],
|
|
129
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
130
|
-
style: styles.buttonTextPlate,
|
|
131
|
-
children: block.declineLabel ?? "Not now"
|
|
132
|
-
})
|
|
133
|
-
})]
|
|
134
|
-
})
|
|
135
|
-
})]
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
export function Input({
|
|
139
|
-
block
|
|
140
|
-
}) {
|
|
141
|
-
const h = useBlockHandlers();
|
|
142
|
-
const answer = h.answered[block.id];
|
|
143
|
-
const locked = !!answer;
|
|
144
|
-
const [value, setValue] = useState("");
|
|
145
|
-
const secret = block.type === "secret";
|
|
146
|
-
const submit = () => {
|
|
147
|
-
const v = value.trim();
|
|
148
|
-
if (!v) return;
|
|
149
|
-
h.answer({
|
|
150
|
-
blockId: block.id,
|
|
151
|
-
kind: "input",
|
|
152
|
-
value: v
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
return /*#__PURE__*/_jsxs(Card, {
|
|
156
|
-
testID: `buoy-block-input-${block.id}`,
|
|
157
|
-
tone: locked ? undefined : "info",
|
|
158
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
159
|
-
style: styles.question,
|
|
160
|
-
children: block.label
|
|
161
|
-
}), locked ? /*#__PURE__*/_jsx(Text, {
|
|
162
|
-
style: styles.decided,
|
|
163
|
-
children: answer.kind === "input" ? secret ? "••••••" : answer.value : "(skipped)"
|
|
164
|
-
}) : /*#__PURE__*/_jsxs(View, {
|
|
165
|
-
style: styles.inputRow,
|
|
166
|
-
children: [/*#__PURE__*/_jsx(TextInput, {
|
|
167
|
-
testID: "buoy-block-input-field",
|
|
168
|
-
style: styles.input,
|
|
169
|
-
value: value,
|
|
170
|
-
onChangeText: setValue,
|
|
171
|
-
placeholder: block.placeholder ?? "",
|
|
172
|
-
placeholderTextColor: night.color.placeholder,
|
|
173
|
-
keyboardType: block.type === "number" ? "numeric" : "ascii-capable",
|
|
174
|
-
secureTextEntry: secret,
|
|
175
|
-
autoCapitalize: "none",
|
|
176
|
-
autoCorrect: false,
|
|
177
|
-
returnKeyType: "send",
|
|
178
|
-
onSubmitEditing: submit
|
|
179
|
-
}), /*#__PURE__*/_jsx(Pressable, {
|
|
180
|
-
testID: "buoy-block-input-submit",
|
|
181
|
-
accessibilityRole: "button",
|
|
182
|
-
disabled: !value.trim(),
|
|
183
|
-
onPress: submit,
|
|
184
|
-
style: ({
|
|
185
|
-
pressed
|
|
186
|
-
}) => [styles.button, styles.buttonPrimary, !value.trim() && styles.buttonDisabled, pressed && styles.pressed],
|
|
187
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
188
|
-
style: styles.buttonTextPrimary,
|
|
189
|
-
children: block.submitLabel ?? "Send"
|
|
190
|
-
})
|
|
191
|
-
})]
|
|
192
|
-
})]
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
const styles = StyleSheet.create({
|
|
196
|
-
question: {
|
|
197
|
-
color: night.color.text,
|
|
198
|
-
fontSize: night.font.row,
|
|
199
|
-
fontWeight: "600",
|
|
200
|
-
lineHeight: 20,
|
|
201
|
-
paddingHorizontal: 12,
|
|
202
|
-
paddingTop: 12,
|
|
203
|
-
paddingBottom: 8
|
|
204
|
-
},
|
|
205
|
-
options: {
|
|
206
|
-
marginHorizontal: 8,
|
|
207
|
-
marginBottom: 8,
|
|
208
|
-
borderRadius: night.radius.row,
|
|
209
|
-
backgroundColor: night.color.surfaceElevated,
|
|
210
|
-
overflow: "hidden"
|
|
211
|
-
},
|
|
212
|
-
option: {
|
|
213
|
-
flexDirection: "row",
|
|
214
|
-
alignItems: "center",
|
|
215
|
-
gap: 10,
|
|
216
|
-
paddingHorizontal: 12,
|
|
217
|
-
paddingVertical: 11
|
|
218
|
-
},
|
|
219
|
-
optionDivider: {
|
|
220
|
-
borderTopWidth: StyleSheet.hairlineWidth,
|
|
221
|
-
borderTopColor: night.color.separator
|
|
222
|
-
},
|
|
223
|
-
optionChosen: {
|
|
224
|
-
backgroundColor: night.color.accentSoft
|
|
225
|
-
},
|
|
226
|
-
optionDimmed: {
|
|
227
|
-
opacity: 0.45
|
|
228
|
-
},
|
|
229
|
-
optionText: {
|
|
230
|
-
flex: 1,
|
|
231
|
-
gap: 2
|
|
232
|
-
},
|
|
233
|
-
optionLabel: {
|
|
234
|
-
color: night.color.text,
|
|
235
|
-
fontSize: night.font.body,
|
|
236
|
-
fontWeight: "500"
|
|
237
|
-
},
|
|
238
|
-
optionLabelChosen: {
|
|
239
|
-
color: night.color.accent
|
|
240
|
-
},
|
|
241
|
-
optionDetail: {
|
|
242
|
-
color: night.color.textSecondary,
|
|
243
|
-
fontSize: night.font.caption,
|
|
244
|
-
lineHeight: 17
|
|
245
|
-
},
|
|
246
|
-
hint: {
|
|
247
|
-
color: night.color.textTertiary,
|
|
248
|
-
fontSize: night.font.micro,
|
|
249
|
-
paddingHorizontal: 12,
|
|
250
|
-
paddingBottom: 10
|
|
251
|
-
},
|
|
252
|
-
confirmTitle: {
|
|
253
|
-
color: night.color.text,
|
|
254
|
-
fontSize: night.font.row,
|
|
255
|
-
fontWeight: "600",
|
|
256
|
-
paddingHorizontal: 12,
|
|
257
|
-
paddingTop: 12
|
|
258
|
-
},
|
|
259
|
-
confirmChange: {
|
|
260
|
-
color: night.color.text,
|
|
261
|
-
fontSize: night.font.body,
|
|
262
|
-
lineHeight: 19,
|
|
263
|
-
paddingHorizontal: 12,
|
|
264
|
-
paddingTop: 6
|
|
265
|
-
},
|
|
266
|
-
confirmConsequence: {
|
|
267
|
-
color: night.color.warning,
|
|
268
|
-
fontSize: night.font.caption,
|
|
269
|
-
lineHeight: 17,
|
|
270
|
-
paddingHorizontal: 12,
|
|
271
|
-
paddingTop: 6
|
|
272
|
-
},
|
|
273
|
-
confirmActions: {
|
|
274
|
-
flexDirection: "row",
|
|
275
|
-
gap: 8,
|
|
276
|
-
paddingHorizontal: 12,
|
|
277
|
-
paddingVertical: 12,
|
|
278
|
-
alignItems: "center"
|
|
279
|
-
},
|
|
280
|
-
decided: {
|
|
281
|
-
color: night.color.textSecondary,
|
|
282
|
-
fontSize: night.font.caption,
|
|
283
|
-
fontWeight: "600",
|
|
284
|
-
paddingHorizontal: 12,
|
|
285
|
-
paddingVertical: 10
|
|
286
|
-
},
|
|
287
|
-
inputRow: {
|
|
288
|
-
flexDirection: "row",
|
|
289
|
-
alignItems: "center",
|
|
290
|
-
gap: 8,
|
|
291
|
-
paddingHorizontal: 12,
|
|
292
|
-
paddingBottom: 12
|
|
293
|
-
},
|
|
294
|
-
input: {
|
|
295
|
-
flex: 1,
|
|
296
|
-
height: 38,
|
|
297
|
-
paddingHorizontal: 12,
|
|
298
|
-
borderRadius: night.radius.row,
|
|
299
|
-
backgroundColor: night.color.surfaceElevated,
|
|
300
|
-
color: night.color.text,
|
|
301
|
-
fontSize: night.font.body
|
|
302
|
-
},
|
|
303
|
-
button: {
|
|
304
|
-
paddingHorizontal: 14,
|
|
305
|
-
paddingVertical: 9,
|
|
306
|
-
borderRadius: night.radius.row
|
|
307
|
-
},
|
|
308
|
-
buttonPrimary: {
|
|
309
|
-
backgroundColor: night.color.accent
|
|
310
|
-
},
|
|
311
|
-
buttonPlate: {
|
|
312
|
-
backgroundColor: night.color.button
|
|
313
|
-
},
|
|
314
|
-
buttonDisabled: {
|
|
315
|
-
opacity: 0.5
|
|
316
|
-
},
|
|
317
|
-
buttonTextPrimary: {
|
|
318
|
-
color: night.color.onAccent,
|
|
319
|
-
fontSize: night.font.caption,
|
|
320
|
-
fontWeight: "600"
|
|
321
|
-
},
|
|
322
|
-
buttonTextPlate: {
|
|
323
|
-
color: night.color.text,
|
|
324
|
-
fontSize: night.font.caption,
|
|
325
|
-
fontWeight: "600"
|
|
326
|
-
},
|
|
327
|
-
pressed: {
|
|
328
|
-
opacity: 0.7
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
//# sourceMappingURL=AskBlocks.js.map
|
|
1
|
+
"use strict";import{useState}from"react";import{Pressable,StyleSheet,Text,TextInput,View}from"react-native";import{Check,ChevronRight,night}from"@buoy-gg/shared-ui";import{useBlockHandlers}from"./context";import{BlockIcon}from"./icons";import{Card}from"./primitives";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export function Choice({block:e}){const t=useBlockHandlers(),o=t.answered[e.id],n="choice"===o?.kind?o.optionId:null,i=!!o;return _jsxs(Card,{testID:`buoy-block-choice-${e.id}`,tone:i?void 0:"info",children:[_jsx(Text,{style:styles.question,children:e.question}),_jsx(View,{style:styles.options,children:e.options.slice(0,5).map((o,l)=>{const s=n===o.id;return _jsxs(Pressable,{testID:`buoy-block-option-${o.id}`,accessibilityRole:"button",accessibilityState:{selected:s,disabled:i},disabled:i,onPress:()=>t.answer({blockId:e.id,kind:"choice",optionId:o.id,label:o.label}),style:({pressed:e})=>[styles.option,l>0&&styles.optionDivider,s&&styles.optionChosen,i&&!s&&styles.optionDimmed,e&&!i&&styles.pressed],children:[o.icon?_jsx(BlockIcon,{name:o.icon}):null,_jsxs(View,{style:styles.optionText,children:[_jsx(Text,{style:[styles.optionLabel,s&&styles.optionLabelChosen],children:o.label}),o.detail?_jsx(Text,{style:styles.optionDetail,children:o.detail}):null]}),s?_jsx(Check,{size:14,color:night.color.accent}):i?null:_jsx(ChevronRight,{size:14,color:night.color.textTertiary})]},o.id)})}),i||!1===e.allowFreeText?null:_jsx(Text,{style:styles.hint,children:"Or just type your answer below."})]})}export function Confirm({block:e}){const t=useBlockHandlers(),o=t.answered[e.id],n=!!o,i="confirm"===o?.kind?o.approved:null;return _jsxs(Card,{testID:`buoy-block-confirm-${e.id}`,tone:n?void 0:"warning",children:[_jsx(Text,{style:styles.confirmTitle,children:e.title}),_jsx(Text,{style:styles.confirmChange,children:e.change}),e.consequence?_jsx(Text,{style:styles.confirmConsequence,children:e.consequence}):null,_jsx(View,{style:styles.confirmActions,children:n?_jsx(Text,{style:styles.decided,children:i?`✓ ${e.approveLabel??"Done"}`:`✕ ${e.declineLabel??"Not now"}`}):_jsxs(_Fragment,{children:[_jsx(Pressable,{testID:"buoy-block-approve",accessibilityRole:"button",onPress:()=>t.answer({blockId:e.id,kind:"confirm",approved:!0}),style:({pressed:e})=>[styles.button,styles.buttonPrimary,e&&styles.pressed],children:_jsx(Text,{style:styles.buttonTextPrimary,children:e.approveLabel??"Do it"})}),_jsx(Pressable,{testID:"buoy-block-decline",accessibilityRole:"button",onPress:()=>t.answer({blockId:e.id,kind:"confirm",approved:!1}),style:({pressed:e})=>[styles.button,styles.buttonPlate,e&&styles.pressed],children:_jsx(Text,{style:styles.buttonTextPlate,children:e.declineLabel??"Not now"})})]})})]})}export function Input({block:e}){const t=useBlockHandlers(),o=t.answered[e.id],n=!!o,[i,l]=useState(""),s="secret"===e.type,r=()=>{const o=i.trim();o&&t.answer({blockId:e.id,kind:"input",value:o})};return _jsxs(Card,{testID:`buoy-block-input-${e.id}`,tone:n?void 0:"info",children:[_jsx(Text,{style:styles.question,children:e.label}),n?_jsx(Text,{style:styles.decided,children:"input"===o.kind?s?"••••••":o.value:"(skipped)"}):_jsxs(View,{style:styles.inputRow,children:[_jsx(TextInput,{testID:"buoy-block-input-field",style:styles.input,value:i,onChangeText:l,placeholder:e.placeholder??"",placeholderTextColor:night.color.placeholder,keyboardType:"number"===e.type?"numeric":"ascii-capable",secureTextEntry:s,autoCapitalize:"none",autoCorrect:!1,returnKeyType:"send",onSubmitEditing:r}),_jsx(Pressable,{testID:"buoy-block-input-submit",accessibilityRole:"button",disabled:!i.trim(),onPress:r,style:({pressed:e})=>[styles.button,styles.buttonPrimary,!i.trim()&&styles.buttonDisabled,e&&styles.pressed],children:_jsx(Text,{style:styles.buttonTextPrimary,children:e.submitLabel??"Send"})})]})]})}const styles=StyleSheet.create({question:{color:night.color.text,fontSize:night.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},options:{marginHorizontal:8,marginBottom:8,borderRadius:night.radius.row,backgroundColor:night.color.surfaceElevated,overflow:"hidden"},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:11},optionDivider:{borderTopWidth:StyleSheet.hairlineWidth,borderTopColor:night.color.separator},optionChosen:{backgroundColor:night.color.accentSoft},optionDimmed:{opacity:.45},optionText:{flex:1,gap:2},optionLabel:{color:night.color.text,fontSize:night.font.body,fontWeight:"500"},optionLabelChosen:{color:night.color.accent},optionDetail:{color:night.color.textSecondary,fontSize:night.font.caption,lineHeight:17},hint:{color:night.color.textTertiary,fontSize:night.font.micro,paddingHorizontal:12,paddingBottom:10},confirmTitle:{color:night.color.text,fontSize:night.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:night.color.text,fontSize:night.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6},confirmConsequence:{color:night.color.warning,fontSize:night.font.caption,lineHeight:17,paddingHorizontal:12,paddingTop:6},confirmActions:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:12,alignItems:"center"},decided:{color:night.color.textSecondary,fontSize:night.font.caption,fontWeight:"600",paddingHorizontal:12,paddingVertical:10},inputRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingBottom:12},input:{flex:1,height:38,paddingHorizontal:12,borderRadius:night.radius.row,backgroundColor:night.color.surfaceElevated,color:night.color.text,fontSize:night.font.body},button:{paddingHorizontal:14,paddingVertical:9,borderRadius:night.radius.row},buttonPrimary:{backgroundColor:night.color.accent},buttonPlate:{backgroundColor:night.color.button},buttonDisabled:{opacity:.5},buttonTextPrimary:{color:night.color.onAccent,fontSize:night.font.caption,fontWeight:"600"},buttonTextPlate:{color:night.color.text,fontSize:night.font.caption,fontWeight:"600"},pressed:{opacity:.7}});
|