@buoy-gg/ask-buoy 7.0.33
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/LICENSE +58 -0
- package/README.md +50 -0
- package/lib/commonjs/blocks/AskBlocks.js +338 -0
- package/lib/commonjs/blocks/AskBlocks.js.map +1 -0
- package/lib/commonjs/blocks/BlockRenderer.js +250 -0
- package/lib/commonjs/blocks/BlockRenderer.js.map +1 -0
- package/lib/commonjs/blocks/ChromePrototypes.js +514 -0
- package/lib/commonjs/blocks/ChromePrototypes.js.map +1 -0
- package/lib/commonjs/blocks/DataBlocks.js +545 -0
- package/lib/commonjs/blocks/DataBlocks.js.map +1 -0
- package/lib/commonjs/blocks/ExtraBlocks.js +1821 -0
- package/lib/commonjs/blocks/ExtraBlocks.js.map +1 -0
- package/lib/commonjs/blocks/MediaBlocks.js +140 -0
- package/lib/commonjs/blocks/MediaBlocks.js.map +1 -0
- package/lib/commonjs/blocks/ReceiptBlocks.js +596 -0
- package/lib/commonjs/blocks/ReceiptBlocks.js.map +1 -0
- package/lib/commonjs/blocks/context.js +42 -0
- package/lib/commonjs/blocks/context.js.map +1 -0
- package/lib/commonjs/blocks/icons.js +96 -0
- package/lib/commonjs/blocks/icons.js.map +1 -0
- package/lib/commonjs/blocks/index.js +95 -0
- package/lib/commonjs/blocks/index.js.map +1 -0
- package/lib/commonjs/blocks/primitives.js +312 -0
- package/lib/commonjs/blocks/primitives.js.map +1 -0
- package/lib/commonjs/blocks/primitivesIndex.js +56 -0
- package/lib/commonjs/blocks/primitivesIndex.js.map +1 -0
- package/lib/commonjs/components/ApprovalCard.js +140 -0
- package/lib/commonjs/components/ApprovalCard.js.map +1 -0
- package/lib/commonjs/components/AskBuoyHeader.js +127 -0
- package/lib/commonjs/components/AskBuoyHeader.js.map +1 -0
- package/lib/commonjs/components/AskBuoyIcon.js +19 -0
- package/lib/commonjs/components/AskBuoyIcon.js.map +1 -0
- package/lib/commonjs/components/AskBuoyModal.js +322 -0
- package/lib/commonjs/components/AskBuoyModal.js.map +1 -0
- package/lib/commonjs/components/ChangesBar.js +211 -0
- package/lib/commonjs/components/ChangesBar.js.map +1 -0
- package/lib/commonjs/components/Composer.js +175 -0
- package/lib/commonjs/components/Composer.js.map +1 -0
- package/lib/commonjs/components/EmptyState.js +154 -0
- package/lib/commonjs/components/EmptyState.js.map +1 -0
- package/lib/commonjs/components/Markdown.js +252 -0
- package/lib/commonjs/components/Markdown.js.map +1 -0
- package/lib/commonjs/components/MessageList.js +648 -0
- package/lib/commonjs/components/MessageList.js.map +1 -0
- package/lib/commonjs/components/TypingDots.js +63 -0
- package/lib/commonjs/components/TypingDots.js.map +1 -0
- package/lib/commonjs/index.js +205 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/preset.js +90 -0
- package/lib/commonjs/preset.js.map +1 -0
- package/lib/commonjs/store/askBuoyStore.js +279 -0
- package/lib/commonjs/store/askBuoyStore.js.map +1 -0
- package/lib/commonjs/store/useAskBuoy.js +299 -0
- package/lib/commonjs/store/useAskBuoy.js.map +1 -0
- package/lib/commonjs/sync/askBuoySyncAdapter.js +119 -0
- package/lib/commonjs/sync/askBuoySyncAdapter.js.map +1 -0
- package/lib/commonjs/sync/askBuoySyncAdapter.test.js +136 -0
- package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +1 -0
- package/lib/commonjs/sync/wire.js +58 -0
- package/lib/commonjs/sync/wire.js.map +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/blocks/AskBlocks.js +331 -0
- package/lib/module/blocks/AskBlocks.js.map +1 -0
- package/lib/module/blocks/BlockRenderer.js +245 -0
- package/lib/module/blocks/BlockRenderer.js.map +1 -0
- package/lib/module/blocks/ChromePrototypes.js +503 -0
- package/lib/module/blocks/ChromePrototypes.js.map +1 -0
- package/lib/module/blocks/DataBlocks.js +532 -0
- package/lib/module/blocks/DataBlocks.js.map +1 -0
- package/lib/module/blocks/ExtraBlocks.js +1794 -0
- package/lib/module/blocks/ExtraBlocks.js.map +1 -0
- package/lib/module/blocks/MediaBlocks.js +135 -0
- package/lib/module/blocks/MediaBlocks.js.map +1 -0
- package/lib/module/blocks/ReceiptBlocks.js +584 -0
- package/lib/module/blocks/ReceiptBlocks.js.map +1 -0
- package/lib/module/blocks/context.js +35 -0
- package/lib/module/blocks/context.js.map +1 -0
- package/lib/module/blocks/icons.js +91 -0
- package/lib/module/blocks/icons.js.map +1 -0
- package/lib/module/blocks/index.js +8 -0
- package/lib/module/blocks/index.js.map +1 -0
- package/lib/module/blocks/primitives.js +301 -0
- package/lib/module/blocks/primitives.js.map +1 -0
- package/lib/module/blocks/primitivesIndex.js +5 -0
- package/lib/module/blocks/primitivesIndex.js.map +1 -0
- package/lib/module/components/ApprovalCard.js +135 -0
- package/lib/module/components/ApprovalCard.js.map +1 -0
- package/lib/module/components/AskBuoyHeader.js +124 -0
- package/lib/module/components/AskBuoyHeader.js.map +1 -0
- package/lib/module/components/AskBuoyIcon.js +8 -0
- package/lib/module/components/AskBuoyIcon.js.map +1 -0
- package/lib/module/components/AskBuoyModal.js +317 -0
- package/lib/module/components/AskBuoyModal.js.map +1 -0
- package/lib/module/components/ChangesBar.js +206 -0
- package/lib/module/components/ChangesBar.js.map +1 -0
- package/lib/module/components/Composer.js +170 -0
- package/lib/module/components/Composer.js.map +1 -0
- package/lib/module/components/EmptyState.js +149 -0
- package/lib/module/components/EmptyState.js.map +1 -0
- package/lib/module/components/Markdown.js +246 -0
- package/lib/module/components/Markdown.js.map +1 -0
- package/lib/module/components/MessageList.js +642 -0
- package/lib/module/components/MessageList.js.map +1 -0
- package/lib/module/components/TypingDots.js +58 -0
- package/lib/module/components/TypingDots.js.map +1 -0
- package/lib/module/index.js +29 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/preset.js +73 -0
- package/lib/module/preset.js.map +1 -0
- package/lib/module/store/askBuoyStore.js +275 -0
- package/lib/module/store/askBuoyStore.js.map +1 -0
- package/lib/module/store/useAskBuoy.js +293 -0
- package/lib/module/store/useAskBuoy.js.map +1 -0
- package/lib/module/sync/askBuoySyncAdapter.js +114 -0
- package/lib/module/sync/askBuoySyncAdapter.js.map +1 -0
- package/lib/module/sync/askBuoySyncAdapter.test.js +135 -0
- package/lib/module/sync/askBuoySyncAdapter.test.js.map +1 -0
- package/lib/module/sync/wire.js +47 -0
- package/lib/module/sync/wire.js.map +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/blocks/AskBlocks.d.ts +11 -0
- package/lib/typescript/blocks/AskBlocks.d.ts.map +1 -0
- package/lib/typescript/blocks/BlockRenderer.d.ts +5 -0
- package/lib/typescript/blocks/BlockRenderer.d.ts.map +1 -0
- package/lib/typescript/blocks/ChromePrototypes.d.ts +27 -0
- package/lib/typescript/blocks/ChromePrototypes.d.ts.map +1 -0
- package/lib/typescript/blocks/DataBlocks.d.ts +29 -0
- package/lib/typescript/blocks/DataBlocks.d.ts.map +1 -0
- package/lib/typescript/blocks/ExtraBlocks.d.ts +69 -0
- package/lib/typescript/blocks/ExtraBlocks.d.ts.map +1 -0
- package/lib/typescript/blocks/MediaBlocks.d.ts +5 -0
- package/lib/typescript/blocks/MediaBlocks.d.ts.map +1 -0
- package/lib/typescript/blocks/ReceiptBlocks.d.ts +27 -0
- package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +1 -0
- package/lib/typescript/blocks/context.d.ts +35 -0
- package/lib/typescript/blocks/context.d.ts.map +1 -0
- package/lib/typescript/blocks/icons.d.ts +6 -0
- package/lib/typescript/blocks/icons.d.ts.map +1 -0
- package/lib/typescript/blocks/index.d.ts +6 -0
- package/lib/typescript/blocks/index.d.ts.map +1 -0
- package/lib/typescript/blocks/primitives.d.ts +85 -0
- package/lib/typescript/blocks/primitives.d.ts.map +1 -0
- package/lib/typescript/blocks/primitivesIndex.d.ts +3 -0
- package/lib/typescript/blocks/primitivesIndex.d.ts.map +1 -0
- package/lib/typescript/components/ApprovalCard.d.ts +7 -0
- package/lib/typescript/components/ApprovalCard.d.ts.map +1 -0
- package/lib/typescript/components/AskBuoyHeader.d.ts +14 -0
- package/lib/typescript/components/AskBuoyHeader.d.ts.map +1 -0
- package/lib/typescript/components/AskBuoyIcon.d.ts +6 -0
- package/lib/typescript/components/AskBuoyIcon.d.ts.map +1 -0
- package/lib/typescript/components/AskBuoyModal.d.ts +13 -0
- package/lib/typescript/components/AskBuoyModal.d.ts.map +1 -0
- package/lib/typescript/components/ChangesBar.d.ts +9 -0
- package/lib/typescript/components/ChangesBar.d.ts.map +1 -0
- package/lib/typescript/components/Composer.d.ts +9 -0
- package/lib/typescript/components/Composer.d.ts.map +1 -0
- package/lib/typescript/components/EmptyState.d.ts +6 -0
- package/lib/typescript/components/EmptyState.d.ts.map +1 -0
- package/lib/typescript/components/Markdown.d.ts +23 -0
- package/lib/typescript/components/Markdown.d.ts.map +1 -0
- package/lib/typescript/components/MessageList.d.ts +18 -0
- package/lib/typescript/components/MessageList.d.ts.map +1 -0
- package/lib/typescript/components/TypingDots.d.ts +2 -0
- package/lib/typescript/components/TypingDots.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +28 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/preset.d.ts +61 -0
- package/lib/typescript/preset.d.ts.map +1 -0
- package/lib/typescript/store/askBuoyStore.d.ts +124 -0
- package/lib/typescript/store/askBuoyStore.d.ts.map +1 -0
- package/lib/typescript/store/useAskBuoy.d.ts +22 -0
- package/lib/typescript/store/useAskBuoy.d.ts.map +1 -0
- package/lib/typescript/sync/askBuoySyncAdapter.d.ts +73 -0
- package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +1 -0
- package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts +2 -0
- package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +1 -0
- package/lib/typescript/sync/wire.d.ts +17 -0
- package/lib/typescript/sync/wire.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +119 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.askBuoySyncAdapter = exports.ASK_BUOY_ADAPTER_VERSION = void 0;
|
|
7
|
+
var _wire = require("./wire");
|
|
8
|
+
var _agentCore = require("@buoy-gg/agent-core");
|
|
9
|
+
var _askBuoyStore = require("../store/askBuoyStore");
|
|
10
|
+
/**
|
|
11
|
+
* The sync adapter, so Buoy Desktop and MCP can see what Ask Buoy is doing.
|
|
12
|
+
*
|
|
13
|
+
* Read-heavy on purpose. There is no `send` action: letting a remote client
|
|
14
|
+
* put words in the agent's mouth would mean anyone who can reach the broker —
|
|
15
|
+
* which has no authentication at all, binds 0.0.0.0, and accepts any client
|
|
16
|
+
* calling itself "Dashboard" — could drive a mutating agent on a tester's
|
|
17
|
+
* device. The chat is initiated on-device, by a person, full stop.
|
|
18
|
+
*
|
|
19
|
+
* `undoAll` IS exposed, because the asymmetry is deliberate: putting things
|
|
20
|
+
* back is the safe direction, and a dev watching from the desktop should be
|
|
21
|
+
* able to clean up a device without walking over to it.
|
|
22
|
+
*
|
|
23
|
+
* The transcript is redacted before it crosses the wire. Action results the
|
|
24
|
+
* agent read can contain storage values and response bodies, and this socket
|
|
25
|
+
* broadcasts to every connected dashboard — it already leaks license keys the
|
|
26
|
+
* same way.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
const ASK_BUOY_ADAPTER_VERSION = exports.ASK_BUOY_ADAPTER_VERSION = 1;
|
|
30
|
+
const askBuoySyncAdapter = exports.askBuoySyncAdapter = {
|
|
31
|
+
version: ASK_BUOY_ADAPTER_VERSION,
|
|
32
|
+
getSnapshot() {
|
|
33
|
+
const state = _askBuoyStore.askBuoyStore.getState();
|
|
34
|
+
const ledger = _askBuoyStore.askBuoyStore.getLedger();
|
|
35
|
+
const entries = ledger?.list() ?? [];
|
|
36
|
+
const outstanding = entries.filter(e => !e.undoneAt);
|
|
37
|
+
return {
|
|
38
|
+
version: ASK_BUOY_ADAPTER_VERSION,
|
|
39
|
+
busy: state.busy,
|
|
40
|
+
configured: state.configured,
|
|
41
|
+
notice: state.notice,
|
|
42
|
+
messageCount: state.messages.length,
|
|
43
|
+
// Only the shape of the conversation, never tool payloads.
|
|
44
|
+
messages: state.messages.map(m => ({
|
|
45
|
+
id: m.id,
|
|
46
|
+
role: m.role,
|
|
47
|
+
text: (0, _wire.redactForWire)(m.text),
|
|
48
|
+
streaming: !!m.streaming,
|
|
49
|
+
toolCalls: m.toolCalls.map(c => ({
|
|
50
|
+
toolId: c.toolId,
|
|
51
|
+
action: c.action,
|
|
52
|
+
status: c.status
|
|
53
|
+
}))
|
|
54
|
+
})),
|
|
55
|
+
// Session token totals, so a desktop/MCP observer can meter cost.
|
|
56
|
+
usage: state.usage,
|
|
57
|
+
pendingApproval: state.pending ? {
|
|
58
|
+
toolId: state.pending.toolId,
|
|
59
|
+
action: state.pending.action,
|
|
60
|
+
label: state.pending.label
|
|
61
|
+
} : null,
|
|
62
|
+
changes: {
|
|
63
|
+
// Transients (navigation, taps) are one-shot actions, not changes —
|
|
64
|
+
// same rule as the on-device bar, so desktop and device tell one story.
|
|
65
|
+
reversible: outstanding.filter(e => (0, _agentCore.isReversible)(e.effect)).length,
|
|
66
|
+
permanent: outstanding.filter(e => e.effect.kind !== "transient" && !(0, _agentCore.isReversible)(e.effect)).length,
|
|
67
|
+
transients: outstanding.filter(e => e.effect.kind === "transient").length,
|
|
68
|
+
items: outstanding.map(e => ({
|
|
69
|
+
kind: e.effect.kind,
|
|
70
|
+
label: e.effect.label
|
|
71
|
+
}))
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
subscribe(onChange) {
|
|
76
|
+
const offStore = _askBuoyStore.askBuoyStore.subscribe(onChange);
|
|
77
|
+
const offLedger = _askBuoyStore.askBuoyStore.getLedger()?.subscribe(onChange);
|
|
78
|
+
return () => {
|
|
79
|
+
offStore();
|
|
80
|
+
offLedger?.();
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
actions: {
|
|
84
|
+
/** What the agent changed, and whether it can be put back. */
|
|
85
|
+
listChanges: () => {
|
|
86
|
+
const entries = _askBuoyStore.askBuoyStore.getLedger()?.list() ?? [];
|
|
87
|
+
return entries.filter(e => !e.undoneAt).map(e => ({
|
|
88
|
+
id: e.id,
|
|
89
|
+
at: e.at,
|
|
90
|
+
toolId: e.toolId,
|
|
91
|
+
action: e.action,
|
|
92
|
+
kind: e.effect.kind,
|
|
93
|
+
label: e.effect.label,
|
|
94
|
+
reversible: (0, _agentCore.isReversible)(e.effect)
|
|
95
|
+
}));
|
|
96
|
+
},
|
|
97
|
+
/** Put back everything that can be put back. Safe direction only. */
|
|
98
|
+
undoAll: async () => {
|
|
99
|
+
const ledger = _askBuoyStore.askBuoyStore.getLedger();
|
|
100
|
+
if (!ledger) return {
|
|
101
|
+
ok: false,
|
|
102
|
+
error: "No Ask Buoy session on this device."
|
|
103
|
+
};
|
|
104
|
+
const outcome = await ledger.revertAll(_wire.dispatchToolAction);
|
|
105
|
+
return {
|
|
106
|
+
ok: true,
|
|
107
|
+
...outcome
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
/** Clear the transcript and the ledger. Does not undo anything. */
|
|
111
|
+
reset: () => {
|
|
112
|
+
_askBuoyStore.askBuoyStore.reset();
|
|
113
|
+
return {
|
|
114
|
+
ok: true
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=askBuoySyncAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_wire","require","_agentCore","_askBuoyStore","ASK_BUOY_ADAPTER_VERSION","exports","askBuoySyncAdapter","version","getSnapshot","state","askBuoyStore","getState","ledger","getLedger","entries","list","outstanding","filter","e","undoneAt","busy","configured","notice","messageCount","messages","length","map","m","id","role","text","redactForWire","streaming","toolCalls","c","toolId","action","status","usage","pendingApproval","pending","label","changes","reversible","isReversible","effect","permanent","kind","transients","items","subscribe","onChange","offStore","offLedger","actions","listChanges","at","undoAll","ok","error","outcome","revertAll","dispatchToolAction","reset"],"sourceRoot":"../../../src","sources":["sync/askBuoySyncAdapter.ts"],"mappings":";;;;;;AAkBA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AApBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKO,MAAMG,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG,CAAC;AAElC,MAAME,kBAAkB,GAAAD,OAAA,CAAAC,kBAAA,GAAG;EAChCC,OAAO,EAAEH,wBAAwB;EAEjCI,WAAWA,CAAA,EAAG;IACZ,MAAMC,KAAK,GAAGC,0BAAY,CAACC,QAAQ,CAAC,CAAC;IACrC,MAAMC,MAAM,GAAGF,0BAAY,CAACG,SAAS,CAAC,CAAC;IACvC,MAAMC,OAAO,GAAGF,MAAM,EAAEG,IAAI,CAAC,CAAC,IAAI,EAAE;IACpC,MAAMC,WAAW,GAAGF,OAAO,CAACG,MAAM,CAAEC,CAAC,IAAK,CAACA,CAAC,CAACC,QAAQ,CAAC;IAEtD,OAAO;MACLZ,OAAO,EAAEH,wBAAwB;MACjCgB,IAAI,EAAEX,KAAK,CAACW,IAAI;MAChBC,UAAU,EAAEZ,KAAK,CAACY,UAAU;MAC5BC,MAAM,EAAEb,KAAK,CAACa,MAAM;MACpBC,YAAY,EAAEd,KAAK,CAACe,QAAQ,CAACC,MAAM;MACnC;MACAD,QAAQ,EAAEf,KAAK,CAACe,QAAQ,CAACE,GAAG,CAAEC,CAAC,KAAM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;MAAsC,CAAC;MAC/E,MAAMC,OAAO,GAAG,MAAMhD,MAAM,CAACiD,SAAS,CAACC,wBAAkB,CAAC;MAC1D,OAAO;QAAEJ,EAAE,EAAE,IAAI;QAAE,GAAGE;MAAQ,CAAC;IACjC,CAAC;IAED;IACAG,KAAK,EAAEA,CAAA,KAAM;MACXrD,0BAAY,CAACqD,KAAK,CAAC,CAAC;MACpB,OAAO;QAAEL,EAAE,EAAE;MAAK,CAAC;IACrB;EACF;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
});
|
|
43
|
+
_askBuoyStore.askBuoyStore.applyEvent(id, {
|
|
44
|
+
type: "tool-end",
|
|
45
|
+
id: "c1",
|
|
46
|
+
ok: true,
|
|
47
|
+
summary: "eyJhbGciOiJIUzI1NiJ9.super.secret"
|
|
48
|
+
});
|
|
49
|
+
const snap = _askBuoySyncAdapter.askBuoySyncAdapter.getSnapshot();
|
|
50
|
+
const call = snap.messages[1].toolCalls[0];
|
|
51
|
+
(0, _vitest.expect)(call).toEqual({
|
|
52
|
+
toolId: "storage",
|
|
53
|
+
action: "async.getItem",
|
|
54
|
+
status: "ok"
|
|
55
|
+
});
|
|
56
|
+
// The result summary is not on the wire at all — there is no field for it.
|
|
57
|
+
(0, _vitest.expect)(JSON.stringify(snap)).not.toContain("super.secret");
|
|
58
|
+
});
|
|
59
|
+
(0, _vitest.it)("redacts credentials that made it into the assistant's prose", () => {
|
|
60
|
+
_askBuoyStore.askBuoyStore.addUser("show me the auth header");
|
|
61
|
+
const id = _askBuoyStore.askBuoyStore.startAssistant();
|
|
62
|
+
_askBuoyStore.askBuoyStore.applyEvent(id, {
|
|
63
|
+
type: "text",
|
|
64
|
+
delta: "It sends Authorization: Bearer abcdef0123456789ghijkl to the API."
|
|
65
|
+
});
|
|
66
|
+
const snap = _askBuoySyncAdapter.askBuoySyncAdapter.getSnapshot();
|
|
67
|
+
(0, _vitest.expect)(JSON.stringify(snap)).not.toContain("abcdef0123456789ghijkl");
|
|
68
|
+
});
|
|
69
|
+
(0, _vitest.it)("reports reversible and permanent changes separately", () => {
|
|
70
|
+
const ledger = new _agentCore.EffectLedger();
|
|
71
|
+
_askBuoyStore.askBuoyStore.setLedger(ledger);
|
|
72
|
+
ledger.record("storage", "async.setItem", {
|
|
73
|
+
kind: "storage-write",
|
|
74
|
+
toolId: "storage",
|
|
75
|
+
action: "async.setItem",
|
|
76
|
+
key: "points",
|
|
77
|
+
before: "240",
|
|
78
|
+
label: "Set points to 1500"
|
|
79
|
+
});
|
|
80
|
+
ledger.record("perf-monitor", "clearAll", {
|
|
81
|
+
kind: "transient",
|
|
82
|
+
label: "Cleared samples"
|
|
83
|
+
});
|
|
84
|
+
// A store write with no captured prior state: recorded, visible, and
|
|
85
|
+
// NOT something Undo can deliver — it must count as permanent.
|
|
86
|
+
ledger.record("zustand", "setState", {
|
|
87
|
+
kind: "state-write",
|
|
88
|
+
toolId: "zustand",
|
|
89
|
+
action: "setState",
|
|
90
|
+
label: "Update the cart store"
|
|
91
|
+
});
|
|
92
|
+
const snap = _askBuoySyncAdapter.askBuoySyncAdapter.getSnapshot();
|
|
93
|
+
(0, _vitest.expect)(snap.changes.reversible).toBe(1);
|
|
94
|
+
// The transient is an ACTION, not a change — it must not inflate
|
|
95
|
+
// "permanent" (that read "Changed this app · N permanent" after a
|
|
96
|
+
// read-only tour). It is still reported, in its own count.
|
|
97
|
+
(0, _vitest.expect)(snap.changes.permanent).toBe(1);
|
|
98
|
+
(0, _vitest.expect)(snap.changes.transients).toBe(1);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
(0, _vitest.describe)("redactForWire", () => {
|
|
102
|
+
(0, _vitest.it)("removes bearer tokens, JWTs, api keys and license keys", () => {
|
|
103
|
+
const cases = ["Authorization: Bearer abcdefghijklmnop123456", "token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9abcdefgh", "key sk-abcdefghijklmnop1234", "license BUOY-ABCD-1234-EFGH", 'the header is "x-api-key": "supersecretvalue"'];
|
|
104
|
+
for (const input of cases) {
|
|
105
|
+
(0, _vitest.expect)((0, _wire.redactForWire)(input)).toContain("removed]");
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
(0, _vitest.it)("leaves ordinary prose alone", () => {
|
|
109
|
+
const text = "The /menu call returned 200 with 12 items and the burger was in stock.";
|
|
110
|
+
(0, _vitest.expect)((0, _wire.redactForWire)(text)).toBe(text);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
(0, _vitest.describe)("undo from the desktop", () => {
|
|
114
|
+
(0, _vitest.it)("is allowed, because putting things back is the safe direction", async () => {
|
|
115
|
+
const ledger = new _agentCore.EffectLedger();
|
|
116
|
+
_askBuoyStore.askBuoyStore.setLedger(ledger);
|
|
117
|
+
const store = new Map([["points", "1500"]]);
|
|
118
|
+
ledger.record("storage", "async.setItem", {
|
|
119
|
+
kind: "storage-write",
|
|
120
|
+
toolId: "storage",
|
|
121
|
+
action: "async.setItem",
|
|
122
|
+
key: "points",
|
|
123
|
+
before: "240",
|
|
124
|
+
label: "Set points to 1500"
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// The adapter dispatches through the real seam; stub it at the ledger.
|
|
128
|
+
await ledger.revertAll(async (_t, action, params) => {
|
|
129
|
+
const p = params;
|
|
130
|
+
if (action === "async.setItem") store.set(p.key, p.value);
|
|
131
|
+
return undefined;
|
|
132
|
+
});
|
|
133
|
+
(0, _vitest.expect)(store.get("points")).toBe("240");
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=askBuoySyncAdapter.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_vitest","require","_agentCore","_askBuoySyncAdapter","_wire","_askBuoyStore","beforeEach","askBuoyStore","reset","setLedger","describe","it","actions","Object","keys","askBuoySyncAdapter","expect","not","toContain","sort","toEqual","addUser","id","startAssistant","applyEvent","type","toolId","action","label","description","ok","summary","snap","getSnapshot","call","messages","toolCalls","status","JSON","stringify","delta","ledger","EffectLedger","record","kind","key","before","changes","reversible","toBe","permanent","transients","cases","input","redactForWire","text","store","Map","revertAll","_t","params","p","set","value","undefined","get"],"sourceRoot":"../../../src","sources":["sync/askBuoySyncAdapter.test.ts"],"mappings":";;AASA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,IAAAK,kBAAU,EAAC,MAAM;EACfC,0BAAY,CAACC,KAAK,CAAC,CAAC;EACpBD,0BAAY,CAACE,SAAS,CAAC,IAAI,CAAC;AAC9B,CAAC,CAAC;AAEF,IAAAC,gBAAQ,EAAC,kBAAkB,EAAE,MAAM;EACjC,IAAAC,UAAE,EAAC,gDAAgD,EAAE,MAAM;IACzD;IACA;IACA,MAAMC,OAAO,GAAGC,MAAM,CAACC,IAAI,CAACC,sCAAkB,CAACH,OAAO,CAAC;IACvD,IAAAI,cAAM,EAACJ,OAAO,CAAC,CAACK,GAAG,CAACC,SAAS,CAAC,MAAM,CAAC;IACrC,IAAAF,cAAM,EAACJ,OAAO,CAAC,CAACK,GAAG,CAACC,SAAS,CAAC,KAAK,CAAC;IACpC,IAAAF,cAAM,EAACJ,OAAO,CAAC,CAACK,GAAG,CAACC,SAAS,CAAC,QAAQ,CAAC;IACvC,IAAAF,cAAM,EAACJ,OAAO,CAACO,IAAI,CAAC,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,aAAa,EAAE,OAAO,EAAE,SAAS,CAAC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AAGD,MAAyC;MACnD,IAAIjC,MAAM,KAAK,eAAe,EAAE6B,KAAK,CAACM,GAAG,CAACD,CAAC,CAAChB,GAAG,EAAEgB,CAAC,CAACE,KAAM,CAAC;MAC1D,OAAOC,SAAS;IAClB,CAAC,CAAC;IAEF,IAAAhD,cAAM,EAACwC,KAAK,CAACS,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAChB,IAAI,CAAC,KAAK,CAAC;EACzC,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_sharedUi","require","PATTERNS","re","label","redactForWire","text","out","replace"],"sourceRoot":"../../../src","sources":["sync/wire.ts"],"mappings":";;;;;;;;;;;;AAcA,IAAAA,SAAA,GAAAC,OAAA;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,MAAMC,QAAyC,GAAG,CAChD;EAAEC,EAAE,EAAE,uCAAuC;EAAEC,KAAK,EAAE;AAAyB,CAAC,EAChF;EAAED,EAAE,EAAE,2BAA2B;EAAEC,KAAK,EAAE;AAAgB,CAAC,EAC3D;EAAED,EAAE,EAAE,0BAA0B;EAAEC,KAAK,EAAE;AAAoB,CAAC,EAC9D;EAAED,EAAE,EAAE,uBAAuB;EAAEC,KAAK,EAAE;AAAwB,CAAC;AAC/D;AACA;EACED,EAAE,EAAE,0HAA0H;EAC9HC,KAAK,EAAE;AACT,CAAC,CACF;AAEM,SAASC,aAAaA,CAACC,IAAY,EAAU;EAClD,IAAI,CAACA,IAAI,EAAE,OAAOA,IAAI;EACtB,IAAIC,GAAG,GAAGD,IAAI;EACd,KAAK,MAAM;IAAEH,EAAE;IAAEC;EAAM,CAAC,IAAIF,QAAQ,EAAE;IACpCK,GAAG,GAAGA,GAAG,CAACC,OAAO,CAACL,EAAE,EAAEC,KAAK,CAAC;EAC9B;EACA,OAAOG,GAAG;AACZ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,331 @@
|
|
|
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
|