@buoy-gg/ask-buoy 7.0.34 → 7.0.35
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 +1 -1
- package/lib/commonjs/blocks/AskBlocks.js +338 -1
- package/lib/commonjs/blocks/AskBlocks.js.map +1 -0
- package/lib/commonjs/blocks/BlockRenderer.js +250 -1
- package/lib/commonjs/blocks/BlockRenderer.js.map +1 -0
- package/lib/commonjs/blocks/ChromePrototypes.js +514 -1
- package/lib/commonjs/blocks/ChromePrototypes.js.map +1 -0
- package/lib/commonjs/blocks/DataBlocks.js +688 -1
- package/lib/commonjs/blocks/DataBlocks.js.map +1 -0
- package/lib/commonjs/blocks/ExtraBlocks.js +1854 -1
- package/lib/commonjs/blocks/ExtraBlocks.js.map +1 -0
- package/lib/commonjs/blocks/MediaBlocks.js +140 -1
- package/lib/commonjs/blocks/MediaBlocks.js.map +1 -0
- package/lib/commonjs/blocks/ReceiptBlocks.js +586 -1
- package/lib/commonjs/blocks/ReceiptBlocks.js.map +1 -0
- package/lib/commonjs/blocks/context.js +42 -1
- package/lib/commonjs/blocks/context.js.map +1 -0
- package/lib/commonjs/blocks/icons.js +96 -1
- package/lib/commonjs/blocks/icons.js.map +1 -0
- package/lib/commonjs/blocks/index.js +95 -1
- package/lib/commonjs/blocks/index.js.map +1 -0
- package/lib/commonjs/blocks/listRow.test.js +55 -0
- package/lib/commonjs/blocks/listRow.test.js.map +1 -0
- package/lib/commonjs/blocks/pageState.js +34 -0
- package/lib/commonjs/blocks/pageState.js.map +1 -0
- package/lib/commonjs/blocks/pageState.test.js +57 -0
- package/lib/commonjs/blocks/pageState.test.js.map +1 -0
- package/lib/commonjs/blocks/primitives.js +401 -1
- package/lib/commonjs/blocks/primitives.js.map +1 -0
- package/lib/commonjs/blocks/primitivesIndex.js +62 -1
- package/lib/commonjs/blocks/primitivesIndex.js.map +1 -0
- package/lib/commonjs/components/ApprovalCard.js +140 -1
- package/lib/commonjs/components/ApprovalCard.js.map +1 -0
- package/lib/commonjs/components/AskBuoyHeader.js +164 -1
- package/lib/commonjs/components/AskBuoyHeader.js.map +1 -0
- package/lib/commonjs/components/AskBuoyIcon.js +19 -1
- package/lib/commonjs/components/AskBuoyIcon.js.map +1 -0
- package/lib/commonjs/components/AskBuoyModal.js +353 -1
- package/lib/commonjs/components/AskBuoyModal.js.map +1 -0
- package/lib/commonjs/components/AskBuoySettings.js +69 -0
- package/lib/commonjs/components/AskBuoySettings.js.map +1 -0
- package/lib/commonjs/components/ChangesBar.js +211 -1
- package/lib/commonjs/components/ChangesBar.js.map +1 -0
- package/lib/commonjs/components/Composer.js +175 -1
- package/lib/commonjs/components/Composer.js.map +1 -0
- package/lib/commonjs/components/EmptyState.js +154 -1
- package/lib/commonjs/components/EmptyState.js.map +1 -0
- package/lib/commonjs/components/Markdown.js +252 -1
- package/lib/commonjs/components/Markdown.js.map +1 -0
- package/lib/commonjs/components/MessageList.js +683 -1
- package/lib/commonjs/components/MessageList.js.map +1 -0
- package/lib/commonjs/components/ThinkingStrip.js +223 -0
- package/lib/commonjs/components/ThinkingStrip.js.map +1 -0
- package/lib/commonjs/components/TypingDots.js +63 -1
- package/lib/commonjs/components/TypingDots.js.map +1 -0
- package/lib/commonjs/components/useCopyAction.js +50 -0
- package/lib/commonjs/components/useCopyAction.js.map +1 -0
- package/lib/commonjs/index.js +252 -1
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/preset.js +90 -1
- package/lib/commonjs/preset.js.map +1 -0
- package/lib/commonjs/store/askBuoySettings.js +67 -0
- package/lib/commonjs/store/askBuoySettings.js.map +1 -0
- package/lib/commonjs/store/askBuoyStore.js +365 -1
- package/lib/commonjs/store/askBuoyStore.js.map +1 -0
- package/lib/commonjs/store/restoredIds.test.js +47 -0
- package/lib/commonjs/store/restoredIds.test.js.map +1 -0
- package/lib/commonjs/store/traceText.js +81 -0
- package/lib/commonjs/store/traceText.js.map +1 -0
- package/lib/commonjs/store/traceText.test.js +112 -0
- package/lib/commonjs/store/traceText.test.js.map +1 -0
- package/lib/commonjs/store/transcriptPersistence.js +208 -0
- package/lib/commonjs/store/transcriptPersistence.js.map +1 -0
- package/lib/commonjs/store/transcriptPersistence.test.js +185 -0
- package/lib/commonjs/store/transcriptPersistence.test.js.map +1 -0
- package/lib/commonjs/store/useAskBuoy.js +400 -1
- package/lib/commonjs/store/useAskBuoy.js.map +1 -0
- package/lib/commonjs/store/useAskBuoySettings.js +14 -0
- package/lib/commonjs/store/useAskBuoySettings.js.map +1 -0
- package/lib/commonjs/sync/askBuoySyncAdapter.js +119 -1
- package/lib/commonjs/sync/askBuoySyncAdapter.js.map +1 -0
- package/lib/commonjs/sync/askBuoySyncAdapter.test.js +141 -1
- package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +1 -0
- package/lib/commonjs/sync/wire.js +58 -1
- package/lib/commonjs/sync/wire.js.map +1 -0
- package/lib/commonjs/types.js +6 -1
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/blocks/AskBlocks.js +331 -1
- package/lib/module/blocks/AskBlocks.js.map +1 -0
- package/lib/module/blocks/BlockRenderer.js +245 -1
- package/lib/module/blocks/BlockRenderer.js.map +1 -0
- package/lib/module/blocks/ChromePrototypes.js +503 -1
- package/lib/module/blocks/ChromePrototypes.js.map +1 -0
- package/lib/module/blocks/DataBlocks.js +674 -1
- package/lib/module/blocks/DataBlocks.js.map +1 -0
- package/lib/module/blocks/ExtraBlocks.js +1827 -1
- package/lib/module/blocks/ExtraBlocks.js.map +1 -0
- package/lib/module/blocks/MediaBlocks.js +135 -1
- package/lib/module/blocks/MediaBlocks.js.map +1 -0
- package/lib/module/blocks/ReceiptBlocks.js +574 -1
- package/lib/module/blocks/ReceiptBlocks.js.map +1 -0
- package/lib/module/blocks/context.js +35 -1
- package/lib/module/blocks/context.js.map +1 -0
- package/lib/module/blocks/icons.js +91 -1
- package/lib/module/blocks/icons.js.map +1 -0
- package/lib/module/blocks/index.js +8 -1
- package/lib/module/blocks/index.js.map +1 -0
- package/lib/module/blocks/listRow.test.js +56 -0
- package/lib/module/blocks/listRow.test.js.map +1 -0
- package/lib/module/blocks/pageState.js +30 -0
- package/lib/module/blocks/pageState.js.map +1 -0
- package/lib/module/blocks/pageState.test.js +56 -0
- package/lib/module/blocks/pageState.test.js.map +1 -0
- package/lib/module/blocks/primitives.js +389 -1
- package/lib/module/blocks/primitives.js.map +1 -0
- package/lib/module/blocks/primitivesIndex.js +5 -1
- package/lib/module/blocks/primitivesIndex.js.map +1 -0
- package/lib/module/components/ApprovalCard.js +135 -1
- package/lib/module/components/ApprovalCard.js.map +1 -0
- package/lib/module/components/AskBuoyHeader.js +161 -1
- package/lib/module/components/AskBuoyHeader.js.map +1 -0
- package/lib/module/components/AskBuoyIcon.js +8 -1
- package/lib/module/components/AskBuoyIcon.js.map +1 -0
- package/lib/module/components/AskBuoyModal.js +348 -1
- package/lib/module/components/AskBuoyModal.js.map +1 -0
- package/lib/module/components/AskBuoySettings.js +64 -0
- package/lib/module/components/AskBuoySettings.js.map +1 -0
- package/lib/module/components/ChangesBar.js +206 -1
- package/lib/module/components/ChangesBar.js.map +1 -0
- package/lib/module/components/Composer.js +170 -1
- package/lib/module/components/Composer.js.map +1 -0
- package/lib/module/components/EmptyState.js +149 -1
- package/lib/module/components/EmptyState.js.map +1 -0
- package/lib/module/components/Markdown.js +246 -1
- package/lib/module/components/Markdown.js.map +1 -0
- package/lib/module/components/MessageList.js +677 -1
- package/lib/module/components/MessageList.js.map +1 -0
- package/lib/module/components/ThinkingStrip.js +218 -0
- package/lib/module/components/ThinkingStrip.js.map +1 -0
- package/lib/module/components/TypingDots.js +58 -1
- package/lib/module/components/TypingDots.js.map +1 -0
- package/lib/module/components/useCopyAction.js +46 -0
- package/lib/module/components/useCopyAction.js.map +1 -0
- package/lib/module/index.js +34 -1
- package/lib/module/index.js.map +1 -0
- package/lib/module/preset.js +73 -1
- package/lib/module/preset.js.map +1 -0
- package/lib/module/store/askBuoySettings.js +62 -0
- package/lib/module/store/askBuoySettings.js.map +1 -0
- package/lib/module/store/askBuoyStore.js +361 -1
- package/lib/module/store/askBuoyStore.js.map +1 -0
- package/lib/module/store/restoredIds.test.js +46 -0
- package/lib/module/store/restoredIds.test.js.map +1 -0
- package/lib/module/store/traceText.js +75 -0
- package/lib/module/store/traceText.js.map +1 -0
- package/lib/module/store/traceText.test.js +111 -0
- package/lib/module/store/traceText.test.js.map +1 -0
- package/lib/module/store/transcriptPersistence.js +198 -0
- package/lib/module/store/transcriptPersistence.js.map +1 -0
- package/lib/module/store/transcriptPersistence.test.js +184 -0
- package/lib/module/store/transcriptPersistence.test.js.map +1 -0
- package/lib/module/store/useAskBuoy.js +394 -1
- package/lib/module/store/useAskBuoy.js.map +1 -0
- package/lib/module/store/useAskBuoySettings.js +9 -0
- package/lib/module/store/useAskBuoySettings.js.map +1 -0
- package/lib/module/sync/askBuoySyncAdapter.js +114 -1
- package/lib/module/sync/askBuoySyncAdapter.js.map +1 -0
- package/lib/module/sync/askBuoySyncAdapter.test.js +140 -1
- package/lib/module/sync/askBuoySyncAdapter.test.js.map +1 -0
- package/lib/module/sync/wire.js +47 -1
- package/lib/module/sync/wire.js.map +1 -0
- package/lib/module/types.js +4 -1
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/blocks/AskBlocks.d.ts.map +1 -0
- package/lib/typescript/blocks/BlockRenderer.d.ts.map +1 -0
- package/lib/typescript/blocks/ChromePrototypes.d.ts.map +1 -0
- package/lib/typescript/blocks/DataBlocks.d.ts +31 -0
- package/lib/typescript/blocks/DataBlocks.d.ts.map +1 -0
- package/lib/typescript/blocks/ExtraBlocks.d.ts +11 -0
- package/lib/typescript/blocks/ExtraBlocks.d.ts.map +1 -0
- package/lib/typescript/blocks/MediaBlocks.d.ts.map +1 -0
- package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +1 -0
- package/lib/typescript/blocks/context.d.ts.map +1 -0
- package/lib/typescript/blocks/icons.d.ts.map +1 -0
- package/lib/typescript/blocks/index.d.ts.map +1 -0
- package/lib/typescript/blocks/listRow.test.d.ts +2 -0
- package/lib/typescript/blocks/listRow.test.d.ts.map +1 -0
- package/lib/typescript/blocks/pageState.d.ts +23 -0
- package/lib/typescript/blocks/pageState.d.ts.map +1 -0
- package/lib/typescript/blocks/pageState.test.d.ts +2 -0
- package/lib/typescript/blocks/pageState.test.d.ts.map +1 -0
- package/lib/typescript/blocks/primitives.d.ts +39 -9
- package/lib/typescript/blocks/primitives.d.ts.map +1 -0
- package/lib/typescript/blocks/primitivesIndex.d.ts +2 -1
- package/lib/typescript/blocks/primitivesIndex.d.ts.map +1 -0
- package/lib/typescript/components/ApprovalCard.d.ts.map +1 -0
- package/lib/typescript/components/AskBuoyHeader.d.ts +11 -1
- package/lib/typescript/components/AskBuoyHeader.d.ts.map +1 -0
- package/lib/typescript/components/AskBuoyIcon.d.ts.map +1 -0
- package/lib/typescript/components/AskBuoyModal.d.ts.map +1 -0
- package/lib/typescript/components/AskBuoySettings.d.ts +2 -0
- package/lib/typescript/components/AskBuoySettings.d.ts.map +1 -0
- package/lib/typescript/components/ChangesBar.d.ts.map +1 -0
- package/lib/typescript/components/Composer.d.ts.map +1 -0
- package/lib/typescript/components/EmptyState.d.ts.map +1 -0
- package/lib/typescript/components/Markdown.d.ts.map +1 -0
- package/lib/typescript/components/MessageList.d.ts +12 -5
- package/lib/typescript/components/MessageList.d.ts.map +1 -0
- package/lib/typescript/components/ThinkingStrip.d.ts +5 -0
- package/lib/typescript/components/ThinkingStrip.d.ts.map +1 -0
- package/lib/typescript/components/TypingDots.d.ts.map +1 -0
- package/lib/typescript/components/useCopyAction.d.ts +5 -0
- package/lib/typescript/components/useCopyAction.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/preset.d.ts.map +1 -0
- package/lib/typescript/store/askBuoySettings.d.ts +22 -0
- package/lib/typescript/store/askBuoySettings.d.ts.map +1 -0
- package/lib/typescript/store/askBuoyStore.d.ts +74 -13
- package/lib/typescript/store/askBuoyStore.d.ts.map +1 -0
- package/lib/typescript/store/restoredIds.test.d.ts +2 -0
- package/lib/typescript/store/restoredIds.test.d.ts.map +1 -0
- package/lib/typescript/store/traceText.d.ts +33 -0
- package/lib/typescript/store/traceText.d.ts.map +1 -0
- package/lib/typescript/store/traceText.test.d.ts +2 -0
- package/lib/typescript/store/traceText.test.d.ts.map +1 -0
- package/lib/typescript/store/transcriptPersistence.d.ts +40 -0
- package/lib/typescript/store/transcriptPersistence.d.ts.map +1 -0
- package/lib/typescript/store/transcriptPersistence.test.d.ts +2 -0
- package/lib/typescript/store/transcriptPersistence.test.d.ts.map +1 -0
- package/lib/typescript/store/useAskBuoy.d.ts.map +1 -0
- package/lib/typescript/store/useAskBuoySettings.d.ts +3 -0
- package/lib/typescript/store/useAskBuoySettings.d.ts.map +1 -0
- package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +1 -0
- package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +1 -0
- package/lib/typescript/sync/wire.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +24 -1
- package/lib/typescript/types.d.ts.map +1 -0
- package/package.json +8 -8
|
@@ -1 +1,400 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAskBuoy = useAskBuoy;
|
|
7
|
+
exports.useAskBuoyState = useAskBuoyState;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
11
|
+
var _agentCore = require("@buoy-gg/agent-core");
|
|
12
|
+
var _askBuoyStore = require("./askBuoyStore");
|
|
13
|
+
var _transcriptPersistence = require("./transcriptPersistence");
|
|
14
|
+
/**
|
|
15
|
+
* Wire the sheet to the agent.
|
|
16
|
+
*
|
|
17
|
+
* Two things here are load-bearing:
|
|
18
|
+
*
|
|
19
|
+
* 1. DISPATCH GOES THROUGH `dispatchToolAction`, the same on-device seam a
|
|
20
|
+
* Scenario step and a desktop click use. No second adapter map, nothing
|
|
21
|
+
* that can drift from what the broker sees.
|
|
22
|
+
* 2. THE SESSION IS REBUILT WHEN THE TOOL LIST CHANGES. The adapter map is a
|
|
23
|
+
* memo whose contents depend on which packages resolved and whether a
|
|
24
|
+
* QueryClientProvider is above FloatingDevTools — it is per-app and per
|
|
25
|
+
* render, never a constant. A session that cached the tool list at open
|
|
26
|
+
* would offer the model tools that are no longer there.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
const isRelease = typeof __DEV__ !== "undefined" && !__DEV__;
|
|
30
|
+
|
|
31
|
+
/** Long enough to coalesce a streaming answer's deltas, short enough to beat a crash. */
|
|
32
|
+
const SAVE_DEBOUNCE_MS = 600;
|
|
33
|
+
function useAskBuoyState() {
|
|
34
|
+
return (0, _react.useSyncExternalStore)(_askBuoyStore.askBuoyStore.subscribe, _askBuoyStore.askBuoyStore.getState, _askBuoyStore.askBuoyStore.getState);
|
|
35
|
+
}
|
|
36
|
+
function useAskBuoy(config) {
|
|
37
|
+
const state = useAskBuoyState();
|
|
38
|
+
const sessionRef = (0, _react.useRef)(null);
|
|
39
|
+
/** One restore attempt per mount — see the note at the read. */
|
|
40
|
+
const restoredRef = (0, _react.useRef)(false);
|
|
41
|
+
const abortRef = (0, _react.useRef)(null);
|
|
42
|
+
// Read through a ref where a stable callback needs the LATEST config (the
|
|
43
|
+
// onEvent tap) without re-creating the callback per render.
|
|
44
|
+
const configRef = (0, _react.useRef)(config);
|
|
45
|
+
configRef.current = config;
|
|
46
|
+
const configured = !!config?.endpoint && !!config?.model;
|
|
47
|
+
/**
|
|
48
|
+
* On by default. The conversation surviving a reload is what makes the tool
|
|
49
|
+
* usable while iterating, and it is the only thing that survives a crash —
|
|
50
|
+
* but it puts the chat on disk, so a host handling regulated data can say no.
|
|
51
|
+
*/
|
|
52
|
+
const persist = config?.persistTranscript !== false;
|
|
53
|
+
|
|
54
|
+
// Recomputed each render: the set of dispatchable tools is not a constant.
|
|
55
|
+
//
|
|
56
|
+
// `getSnapshot` is folded in here because half of Buoy's read surface is not
|
|
57
|
+
// an action at all — console entries, network events, routes and env live
|
|
58
|
+
// only in the adapter's snapshot. Without this the model is offered a
|
|
59
|
+
// console tool whose sole action wipes the logs, and no way to read them.
|
|
60
|
+
const availableActions = (0, _react.useMemo)(() => {
|
|
61
|
+
try {
|
|
62
|
+
const actions = (0, _sharedUi.listToolActions)();
|
|
63
|
+
for (const toolId of (0, _sharedUi.listSnapshotToolIds)()) {
|
|
64
|
+
if (!actions[toolId]) actions[toolId] = [];
|
|
65
|
+
if (!actions[toolId].includes(_agentCore.SNAPSHOT_ACTION)) {
|
|
66
|
+
actions[toolId] = [_agentCore.SNAPSHOT_ACTION, ...actions[toolId]];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return actions;
|
|
70
|
+
} catch {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
}, []);
|
|
74
|
+
const toolKey = Object.keys(availableActions).sort().join(",");
|
|
75
|
+
(0, _react.useEffect)(() => {
|
|
76
|
+
_askBuoyStore.askBuoyStore.setConfigured(configured);
|
|
77
|
+
// Stamped on the store so an exported run says what it ran against.
|
|
78
|
+
_askBuoyStore.askBuoyStore.setMeta({
|
|
79
|
+
model: config?.model,
|
|
80
|
+
protocol: config?.protocol ?? (config ? "anthropic" : undefined),
|
|
81
|
+
appName: config?.appName,
|
|
82
|
+
platform: _reactNative.Platform.OS,
|
|
83
|
+
build: isRelease ? "release" : "development"
|
|
84
|
+
});
|
|
85
|
+
if (!configured || !config) {
|
|
86
|
+
sessionRef.current = null;
|
|
87
|
+
_askBuoyStore.askBuoyStore.setNotice("Ask Buoy isn't set up in this app yet. A developer needs to point it at your team's AI endpoint.");
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// The classic first-run mistake, caught statically: a provider's own URL
|
|
91
|
+
// with the wrong protocol fails with a raw error that says nothing about
|
|
92
|
+
// the one-line fix. ONLY the canonical provider hosts are checked — a
|
|
93
|
+
// gateway may legitimately speak either protocol on any path (our own dev
|
|
94
|
+
// gateway serves OpenAI framing on /v1/messages, and a path-based version
|
|
95
|
+
// of this check flagged it on the first device run).
|
|
96
|
+
const protocol = config.protocol ?? "anthropic";
|
|
97
|
+
if (isRelease && config.apiKey) {
|
|
98
|
+
_askBuoyStore.askBuoyStore.setNotice("This build carries a plaintext apiKey — that's dev-only and it ships to every install. Use the headers callback with your own gateway for distributed builds.");
|
|
99
|
+
} else if (protocol === "anthropic" && /^https?:\/\/api\.openai\.com\//i.test(config.endpoint)) {
|
|
100
|
+
_askBuoyStore.askBuoyStore.setNotice('This endpoint is api.openai.com but the protocol is "anthropic". Set protocol: "openai" in the askBuoy config.');
|
|
101
|
+
} else if (protocol === "openai" && /^https?:\/\/api\.anthropic\.com\//i.test(config.endpoint)) {
|
|
102
|
+
_askBuoyStore.askBuoyStore.setNotice('This endpoint is api.anthropic.com but the protocol is "openai". Remove protocol or set it to "anthropic".');
|
|
103
|
+
} else {
|
|
104
|
+
_askBuoyStore.askBuoyStore.setNotice(null);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Reuse the held session while nothing material changed. The transcript
|
|
108
|
+
// already survives close/reopen in the module store; without this the
|
|
109
|
+
// session and ledger did not — reopening the sheet swapped in an empty
|
|
110
|
+
// ledger (undo bar gone, agent changes still live in the app) and a blank
|
|
111
|
+
// model memory behind a transcript that still showed the conversation.
|
|
112
|
+
// The tool list is deliberately NOT part of this signature. Packages
|
|
113
|
+
// register a frame or two apart, so `toolKey` legitimately changes right
|
|
114
|
+
// after open — and keying on it silently rebuilt the session mid-chat,
|
|
115
|
+
// throwing away the conversation, the model's memory and the undo ledger
|
|
116
|
+
// while the transcript (a separate store) kept rendering as if nothing
|
|
117
|
+
// happened. Verified on device: a destructive change went unrecorded
|
|
118
|
+
// because it landed in a ledger that had just been replaced.
|
|
119
|
+
const signature = [config.endpoint, config.protocol ?? "anthropic", config.model].join("|");
|
|
120
|
+
const held = _askBuoyStore.askBuoyStore.getHeldSession();
|
|
121
|
+
if (held && held.signature === signature) {
|
|
122
|
+
sessionRef.current = held.session;
|
|
123
|
+
held.session.setAvailableActions(availableActions);
|
|
124
|
+
_askBuoyStore.askBuoyStore.setLedger(held.session.ledger);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const session = (0, _agentCore.createAskBuoySession)({
|
|
128
|
+
endpoint: config.endpoint,
|
|
129
|
+
protocol: config.protocol ?? "anthropic",
|
|
130
|
+
model: config.model,
|
|
131
|
+
headers: config.headers,
|
|
132
|
+
apiKey: config.apiKey,
|
|
133
|
+
maxTokens: config.maxTokens,
|
|
134
|
+
anthropicVersion: config.anthropicVersion,
|
|
135
|
+
requestOverrides: config.requestOverrides,
|
|
136
|
+
// Host-declared custom tools join the built-in catalog. toProviderTools
|
|
137
|
+
// still filters against the live registry, so a descriptor whose
|
|
138
|
+
// `custom:<id>` adapter never registered is simply not offered.
|
|
139
|
+
catalog: config.tools?.length ? [..._agentCore.CATALOG, ...config.tools] : undefined,
|
|
140
|
+
dispatch: _sharedUi.dispatchToolAction,
|
|
141
|
+
readSnapshot: _sharedUi.readToolSnapshot,
|
|
142
|
+
availableActions,
|
|
143
|
+
policy: config.policy,
|
|
144
|
+
context: config.context,
|
|
145
|
+
isRelease,
|
|
146
|
+
appName: config.appName,
|
|
147
|
+
platform: _reactNative.Platform.OS,
|
|
148
|
+
requestApproval: input => _askBuoyStore.askBuoyStore.askApproval(input)
|
|
149
|
+
});
|
|
150
|
+
sessionRef.current = session;
|
|
151
|
+
_askBuoyStore.askBuoyStore.holdSession(session, signature);
|
|
152
|
+
_askBuoyStore.askBuoyStore.setLedger(session.ledger);
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Bring the last conversation back — both halves of it.
|
|
156
|
+
*
|
|
157
|
+
* The transcript and the model's memory are separate things (the store and
|
|
158
|
+
* the session), and restoring only the first is worse than restoring
|
|
159
|
+
* neither: the user reads a conversation the agent has no recollection of,
|
|
160
|
+
* and "undo that" or "now do the same for Pikachu" lands on an empty
|
|
161
|
+
* history. So the session is restored in the same pass, and only into a
|
|
162
|
+
* session this effect just built.
|
|
163
|
+
*/
|
|
164
|
+
// The registry publishes on mount, a frame or two after first paint. Warm
|
|
165
|
+
// the grounding once it is there so the first question does not pay for it.
|
|
166
|
+
let cancelled = false;
|
|
167
|
+
void (0, _sharedUi.waitForToolRegistry)().then(ready => {
|
|
168
|
+
if (ready && !cancelled) void session.prime();
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* NOT gated on `cancelled`, and once per mount.
|
|
173
|
+
*
|
|
174
|
+
* The disk read races the tool registry, and it was losing about half the
|
|
175
|
+
* time. `availableActions` legitimately changes a frame or two after open
|
|
176
|
+
* (see the note above) — that re-runs this effect, whose cleanup sets
|
|
177
|
+
* `cancelled`, and the in-flight restore then threw its result away. The
|
|
178
|
+
* second pass takes the held-session branch and returns early, so nothing
|
|
179
|
+
* ever retried: the conversation was on disk, read correctly, and dropped
|
|
180
|
+
* on the floor. Caught by the e2e, where one test restored and the next
|
|
181
|
+
* did not, with no difference between them.
|
|
182
|
+
*
|
|
183
|
+
* Safe to leave running: `hydrate` refuses if anything has been said since,
|
|
184
|
+
* and `restore` refuses a session that already has history. Resolved
|
|
185
|
+
* against `sessionRef.current` rather than the captured `session` so a
|
|
186
|
+
* genuine reconfiguration mid-read restores into the session in use.
|
|
187
|
+
*/
|
|
188
|
+
if (persist && !restoredRef.current) {
|
|
189
|
+
restoredRef.current = true;
|
|
190
|
+
void (0, _transcriptPersistence.readTranscript)().then(saved => {
|
|
191
|
+
if (!saved) return;
|
|
192
|
+
const hydrated = _askBuoyStore.askBuoyStore.hydrate({
|
|
193
|
+
messages: saved.messages,
|
|
194
|
+
answers: saved.answers,
|
|
195
|
+
usage: saved.usage
|
|
196
|
+
});
|
|
197
|
+
if (hydrated) sessionRef.current?.restore(saved.history);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return () => {
|
|
201
|
+
cancelled = true;
|
|
202
|
+
};
|
|
203
|
+
}, [configured, config, availableActions, toolKey, persist]);
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Save on change: coalesced while a turn streams, immediate the moment it ends.
|
|
207
|
+
*
|
|
208
|
+
* The debounce exists because a streaming answer changes the store on every
|
|
209
|
+
* delta, and writing a whole transcript per token would cost more than the
|
|
210
|
+
* turn does. But applying it to the END of a turn as well left a window
|
|
211
|
+
* where the finished answer was on screen and not yet on disk — a crash or a
|
|
212
|
+
* fast reload inside it lost the whole turn, which is precisely the case
|
|
213
|
+
* this feature exists for. An e2e that relaunched as soon as the answer
|
|
214
|
+
* rendered lost it every time, and that is a real user doing a fast reload,
|
|
215
|
+
* not a harness artefact.
|
|
216
|
+
*
|
|
217
|
+
* Saving still happens DURING a turn as well, which is what lets a bubble
|
|
218
|
+
* the app died in come back marked interrupted rather than blank.
|
|
219
|
+
*/
|
|
220
|
+
const messages = state.messages;
|
|
221
|
+
const answers = state.answers;
|
|
222
|
+
const usage = state.usage;
|
|
223
|
+
const busy = state.busy;
|
|
224
|
+
(0, _react.useEffect)(() => {
|
|
225
|
+
if (!persist) return;
|
|
226
|
+
if (messages.length === 0) return;
|
|
227
|
+
const write = () => {
|
|
228
|
+
void (0, _transcriptPersistence.writeTranscript)((0, _transcriptPersistence.buildPayload)({
|
|
229
|
+
messages,
|
|
230
|
+
history: sessionRef.current?.messages ?? [],
|
|
231
|
+
answers,
|
|
232
|
+
usage
|
|
233
|
+
}));
|
|
234
|
+
};
|
|
235
|
+
if (!busy) {
|
|
236
|
+
write();
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const timer = setTimeout(write, SAVE_DEBOUNCE_MS);
|
|
240
|
+
return () => clearTimeout(timer);
|
|
241
|
+
}, [persist, busy, messages, answers, usage]);
|
|
242
|
+
|
|
243
|
+
/** Stream one turn into a fresh assistant bubble. Callers set up the user side. */
|
|
244
|
+
const runTurn = (0, _react.useCallback)(text => {
|
|
245
|
+
const session = sessionRef.current;
|
|
246
|
+
if (!session) return;
|
|
247
|
+
_askBuoyStore.askBuoyStore.beginTurn();
|
|
248
|
+
const messageId = _askBuoyStore.askBuoyStore.startAssistant();
|
|
249
|
+
const controller = new AbortController();
|
|
250
|
+
abortRef.current = controller;
|
|
251
|
+
const onEvent = configRef.current?.onEvent;
|
|
252
|
+
void (async () => {
|
|
253
|
+
try {
|
|
254
|
+
for await (const ev of session.send(text, controller.signal)) {
|
|
255
|
+
_askBuoyStore.askBuoyStore.applyEvent(messageId, ev);
|
|
256
|
+
if (onEvent) {
|
|
257
|
+
try {
|
|
258
|
+
onEvent(ev);
|
|
259
|
+
} catch {
|
|
260
|
+
// The audit tap must never take the chat down.
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
} catch (err) {
|
|
265
|
+
_askBuoyStore.askBuoyStore.applyEvent(messageId, {
|
|
266
|
+
type: "error",
|
|
267
|
+
message: err instanceof Error ? err.message : "Something went wrong talking to your AI endpoint."
|
|
268
|
+
});
|
|
269
|
+
} finally {
|
|
270
|
+
_askBuoyStore.askBuoyStore.finishAssistant(messageId);
|
|
271
|
+
abortRef.current = null;
|
|
272
|
+
}
|
|
273
|
+
})();
|
|
274
|
+
}, []);
|
|
275
|
+
const send = (0, _react.useCallback)(text => {
|
|
276
|
+
const trimmed = text.trim();
|
|
277
|
+
if (!sessionRef.current || !trimmed) return;
|
|
278
|
+
|
|
279
|
+
// Typed mid-turn: park it. The composer already cleared the field, and
|
|
280
|
+
// silently dropping the words was the worst of all outcomes.
|
|
281
|
+
if (_askBuoyStore.askBuoyStore.getState().busy) {
|
|
282
|
+
_askBuoyStore.askBuoyStore.setQueued(trimmed);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// Typing past an Ask block IS an answer: the block is skipped and locks.
|
|
287
|
+
// Without this the composer stayed on "Pick an option above…" forever and
|
|
288
|
+
// a stale choice sat tappable in the history.
|
|
289
|
+
const awaiting = _askBuoyStore.askBuoyStore.getState().awaitingBlockId;
|
|
290
|
+
if (awaiting) _askBuoyStore.askBuoyStore.recordAnswer({
|
|
291
|
+
blockId: awaiting,
|
|
292
|
+
kind: "skipped"
|
|
293
|
+
});
|
|
294
|
+
_askBuoyStore.askBuoyStore.addUser(trimmed);
|
|
295
|
+
runTurn(trimmed);
|
|
296
|
+
}, [runTurn]);
|
|
297
|
+
const retry = (0, _react.useCallback)(() => {
|
|
298
|
+
const {
|
|
299
|
+
messages,
|
|
300
|
+
busy
|
|
301
|
+
} = _askBuoyStore.askBuoyStore.getState();
|
|
302
|
+
if (busy || !sessionRef.current) return;
|
|
303
|
+
const lastUser = [...messages].reverse().find(m => m.role === "user");
|
|
304
|
+
if (!lastUser) return;
|
|
305
|
+
// Replace the failed bubble rather than stacking a second one under it.
|
|
306
|
+
const last = messages[messages.length - 1];
|
|
307
|
+
if (last && last.role === "assistant" && last.error) _askBuoyStore.askBuoyStore.removeMessage(last.id);
|
|
308
|
+
runTurn(lastUser.text);
|
|
309
|
+
}, [runTurn]);
|
|
310
|
+
const stop = (0, _react.useCallback)(() => {
|
|
311
|
+
// A pending approval parks an unresolved promise inside the engine; the
|
|
312
|
+
// abort signal is only read between steps, so Stop must also answer the
|
|
313
|
+
// approval (as declined) or the generator hangs forever.
|
|
314
|
+
if (_askBuoyStore.askBuoyStore.getState().pending) _askBuoyStore.askBuoyStore.answerApproval(false);
|
|
315
|
+
abortRef.current?.abort();
|
|
316
|
+
abortRef.current = null;
|
|
317
|
+
}, []);
|
|
318
|
+
|
|
319
|
+
// Flush the parked message the moment the turn ends.
|
|
320
|
+
const queued = state.queued;
|
|
321
|
+
(0, _react.useEffect)(() => {
|
|
322
|
+
if (!state.busy && queued) {
|
|
323
|
+
_askBuoyStore.askBuoyStore.setQueued(null);
|
|
324
|
+
send(queued);
|
|
325
|
+
}
|
|
326
|
+
}, [state.busy, queued, send]);
|
|
327
|
+
const reset = (0, _react.useCallback)(() => {
|
|
328
|
+
abortRef.current?.abort();
|
|
329
|
+
sessionRef.current?.reset();
|
|
330
|
+
_askBuoyStore.askBuoyStore.reset();
|
|
331
|
+
// "New conversation" means gone, not hidden. Leaving the last chat on disk
|
|
332
|
+
// after the user asked for a clean one is the opposite of what they said.
|
|
333
|
+
void (0, _transcriptPersistence.clearTranscript)();
|
|
334
|
+
}, []);
|
|
335
|
+
const approve = (0, _react.useCallback)(approved => {
|
|
336
|
+
_askBuoyStore.askBuoyStore.answerApproval(approved);
|
|
337
|
+
}, []);
|
|
338
|
+
const answer = (0, _react.useCallback)(a => {
|
|
339
|
+
_askBuoyStore.askBuoyStore.recordAnswer(a);
|
|
340
|
+
// Plain words to the model, never JSON: "Business checkout", "Yes, go ahead."
|
|
341
|
+
send((0, _agentCore.answerToText)(a));
|
|
342
|
+
}, [send]);
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Block buttons. `send` is a chat reply; `dispatch` runs the action through
|
|
346
|
+
* `runGatedAction` — the SAME validation, policy and ledger path a model
|
|
347
|
+
* call takes, minus the model. The first version called `dispatchToolAction`
|
|
348
|
+
* raw, which made a model-authored button an invisible, ungoverned,
|
|
349
|
+
* unundoable mutation while the `buoy_ui` schema promised the opposite.
|
|
350
|
+
* The human's tap satisfies `requireApproval`; deny lists, read-only mode
|
|
351
|
+
* and release refusals still stand. Button state is tracked so a tap shows
|
|
352
|
+
* running → done and can't double-fire.
|
|
353
|
+
* (`minimize` / `openTool` are the sheet's to handle; see AskBuoyModal.)
|
|
354
|
+
*/
|
|
355
|
+
const runAction = (0, _react.useCallback)(async (action, blockId) => {
|
|
356
|
+
if (action.send) {
|
|
357
|
+
send(action.send);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (!action.dispatch) return;
|
|
361
|
+
const key = `${blockId}:${action.label}`;
|
|
362
|
+
const ledger = _askBuoyStore.askBuoyStore.getLedger();
|
|
363
|
+
if (!ledger) {
|
|
364
|
+
_askBuoyStore.askBuoyStore.setNotice(`${action.label} failed — no active Ask Buoy session.`);
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
_askBuoyStore.askBuoyStore.setActionState(key, "running");
|
|
368
|
+
const outcome = await (0, _agentCore.runGatedAction)({
|
|
369
|
+
toolId: action.dispatch.toolId,
|
|
370
|
+
action: action.dispatch.action,
|
|
371
|
+
params: action.dispatch.params ?? {},
|
|
372
|
+
dispatch: _sharedUi.dispatchToolAction,
|
|
373
|
+
ledger,
|
|
374
|
+
policy: config?.policy ?? {},
|
|
375
|
+
isRelease,
|
|
376
|
+
// Same merged catalog the session offers, so a button on a custom
|
|
377
|
+
// tool's block is not refused as unknown.
|
|
378
|
+
catalog: config?.tools?.length ? [..._agentCore.CATALOG, ...config.tools] : undefined
|
|
379
|
+
});
|
|
380
|
+
if (outcome.ok) {
|
|
381
|
+
_askBuoyStore.askBuoyStore.setActionState(key, "done");
|
|
382
|
+
} else {
|
|
383
|
+
_askBuoyStore.askBuoyStore.setActionState(key, "failed");
|
|
384
|
+
_askBuoyStore.askBuoyStore.setNotice(`${action.label} failed — ${outcome.error}`);
|
|
385
|
+
}
|
|
386
|
+
}, [send, config]);
|
|
387
|
+
return {
|
|
388
|
+
state,
|
|
389
|
+
send,
|
|
390
|
+
stop,
|
|
391
|
+
reset,
|
|
392
|
+
approve,
|
|
393
|
+
retry,
|
|
394
|
+
answer,
|
|
395
|
+
runAction,
|
|
396
|
+
configured,
|
|
397
|
+
toolCount: Object.keys(availableActions).length
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
//# sourceMappingURL=useAskBuoy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_sharedUi","_agentCore","_askBuoyStore","_transcriptPersistence","isRelease","__DEV__","SAVE_DEBOUNCE_MS","useAskBuoyState","useSyncExternalStore","askBuoyStore","subscribe","getState","useAskBuoy","config","state","sessionRef","useRef","restoredRef","abortRef","configRef","current","configured","endpoint","model","persist","persistTranscript","availableActions","useMemo","actions","listToolActions","toolId","listSnapshotToolIds","includes","SNAPSHOT_ACTION","toolKey","Object","keys","sort","join","useEffect","setConfigured","setMeta","protocol","undefined","appName","platform","Platform","OS","build","setNotice","apiKey","test","signature","held","getHeldSession","session","setAvailableActions","setLedger","ledger","createAskBuoySession","headers","maxTokens","anthropicVersion","requestOverrides","catalog","tools","length","CATALOG","dispatch","dispatchToolAction","readSnapshot","readToolSnapshot","policy","context","requestApproval","input","askApproval","holdSession","cancelled","waitForToolRegistry","then","ready","prime","readTranscript","saved","hydrated","hydrate","messages","answers","usage","restore","history","busy","write","writeTranscript","buildPayload","timer","setTimeout","clearTimeout","runTurn","useCallback","text","beginTurn","messageId","startAssistant","controller","AbortController","onEvent","ev","send","signal","applyEvent","err","type","message","Error","finishAssistant","trimmed","trim","setQueued","awaiting","awaitingBlockId","recordAnswer","blockId","kind","addUser","retry","lastUser","reverse","find","m","role","last","error","removeMessage","id","stop","pending","answerApproval","abort","queued","reset","clearTranscript","approve","approved","answer","a","answerToText","runAction","action","key","label","getLedger","setActionState","outcome","runGatedAction","params","ok","toolCount"],"sourceRoot":"../../../src","sources":["store/useAskBuoy.ts"],"mappings":";;;;;;;AAcA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAOA,IAAAG,UAAA,GAAAH,OAAA;AAWA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,sBAAA,GAAAL,OAAA;AAnCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA8BA,MAAMM,SAAS,GAAG,OAAOC,OAAO,KAAK,WAAW,IAAI,CAACA,OAAO;;AAE5D;AAC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G,OAAO,CAACrB,KAAK,EAAE,CAAC;IACrE;EACF,CAAC,EACD,CAACxB,IAAI,EAAEhG,MAAM,CACf,CAAC;EAED,OAAO;IACLC,KAAK;IACL+F,IAAI;IACJ2B,IAAI;IACJK,KAAK;IACLE,OAAO;IACPjB,KAAK;IACLmB,MAAM;IACNG,SAAS;IACT/H,UAAU;IACVyI,SAAS,EAAE3H,MAAM,CAACC,IAAI,CAACV,gBAAgB,CAAC,CAACwC;EAC3C,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAskBuoySettings = useAskBuoySettings;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _askBuoySettings = require("./askBuoySettings");
|
|
9
|
+
/** Subscribe the sheet to Ask Buoy's own preferences. */
|
|
10
|
+
|
|
11
|
+
function useAskBuoySettings() {
|
|
12
|
+
return (0, _react.useSyncExternalStore)(_askBuoySettings.askBuoySettings.subscribe, _askBuoySettings.askBuoySettings.get, _askBuoySettings.askBuoySettings.get);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=useAskBuoySettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_askBuoySettings","useAskBuoySettings","useSyncExternalStore","askBuoySettings","subscribe","get"],"sourceRoot":"../../../src","sources":["store/useAskBuoySettings.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,gBAAA,GAAAD,OAAA;AAHA;;AAKO,SAASE,kBAAkBA,CAAA,EAAoB;EACpD,OAAO,IAAAC,2BAAoB,EAACC,gCAAe,CAACC,SAAS,EAAED,gCAAe,CAACE,GAAG,EAAEF,gCAAe,CAACE,GAAG,CAAC;AAClG","ignoreList":[]}
|
|
@@ -1 +1,119 @@
|
|
|
1
|
-
"use strict";
|
|
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;QACnCC,EAAE,EAAED,CAAC,CAACC,EAAE;QACRC,IAAI,EAAEF,CAAC,CAACE,IAAI;QACZC,IAAI,EAAE,IAAAC,mBAA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