@buoy-gg/ask-buoy 7.0.41 → 7.0.43
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 +13 -98
- package/lib/commonjs/blocks/AskBlocks.js +1 -338
- package/lib/commonjs/blocks/BlockRenderer.js +1 -262
- package/lib/commonjs/blocks/ChromePrototypes.js +1 -514
- package/lib/commonjs/blocks/DataBlocks.js +1 -783
- package/lib/commonjs/blocks/ExtraBlocks.js +1 -1862
- package/lib/commonjs/blocks/MediaBlocks.js +1 -158
- package/lib/commonjs/blocks/ReceiptBlocks.js +2 -592
- package/lib/commonjs/blocks/blockText.js +1 -60
- package/lib/commonjs/blocks/blockText.test.js +1 -53
- 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 -457
- package/lib/commonjs/blocks/primitivesIndex.js +1 -62
- package/lib/commonjs/blocks/ruleStates.js +1 -39
- package/lib/commonjs/components/ApprovalCard.js +1 -297
- package/lib/commonjs/components/AskBuoyHeader.js +1 -196
- package/lib/commonjs/components/AskBuoyIcon.js +1 -19
- package/lib/commonjs/components/AskBuoyModal.js +2 -482
- package/lib/commonjs/components/AskBuoySettings.js +1 -181
- package/lib/commonjs/components/ChangesBar.js +1 -212
- package/lib/commonjs/components/Composer.js +1 -255
- package/lib/commonjs/components/EmptyState.js +1 -161
- package/lib/commonjs/components/KeyboardPad.js +1 -80
- package/lib/commonjs/components/Markdown.js +1 -310
- package/lib/commonjs/components/MessageList.js +1 -970
- package/lib/commonjs/components/QueuedMessages.js +1 -145
- package/lib/commonjs/components/ThinkingStrip.js +1 -223
- package/lib/commonjs/components/TypingDots.js +1 -63
- package/lib/commonjs/components/markdownParse.js +1 -131
- package/lib/commonjs/components/markdownParse.test.js +1 -99
- package/lib/commonjs/components/useCopyAction.js +1 -50
- package/lib/commonjs/index.js +1 -252
- package/lib/commonjs/preset.js +1 -91
- package/lib/commonjs/store/activityGroups.js +1 -110
- package/lib/commonjs/store/activityGroups.test.js +1 -78
- package/lib/commonjs/store/askBuoySettings.js +1 -72
- package/lib/commonjs/store/askBuoyStore.js +2 -588
- package/lib/commonjs/store/blockPlacement.js +1 -64
- package/lib/commonjs/store/blockPlacement.test.js +1 -123
- package/lib/commonjs/store/queue.test.js +1 -150
- package/lib/commonjs/store/resetConversation.js +1 -77
- package/lib/commonjs/store/restorePending.test.js +1 -63
- package/lib/commonjs/store/restoredIds.test.js +1 -47
- package/lib/commonjs/store/suggestions.js +1 -54
- package/lib/commonjs/store/suggestions.test.js +1 -58
- package/lib/commonjs/store/systemLine.test.js +1 -77
- package/lib/commonjs/store/ticketPrompt.js +1 -17
- package/lib/commonjs/store/traceText.js +1 -81
- package/lib/commonjs/store/traceText.test.js +1 -112
- package/lib/commonjs/store/transcriptPersistence.js +1 -297
- package/lib/commonjs/store/transcriptPersistence.test.js +1 -333
- package/lib/commonjs/store/turnRendering.test.js +1 -151
- package/lib/commonjs/store/useAskBuoy.js +1 -651
- package/lib/commonjs/store/useAskBuoySettings.js +1 -14
- package/lib/commonjs/sync/askBuoySyncAdapter.js +1 -153
- 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 -257
- package/lib/module/blocks/ChromePrototypes.js +1 -503
- package/lib/module/blocks/DataBlocks.js +1 -769
- package/lib/module/blocks/ExtraBlocks.js +1 -1835
- package/lib/module/blocks/MediaBlocks.js +1 -153
- package/lib/module/blocks/ReceiptBlocks.js +2 -580
- package/lib/module/blocks/blockText.js +1 -55
- package/lib/module/blocks/blockText.test.js +1 -53
- 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 -445
- package/lib/module/blocks/primitivesIndex.js +1 -5
- package/lib/module/blocks/ruleStates.js +1 -35
- package/lib/module/components/ApprovalCard.js +1 -292
- package/lib/module/components/AskBuoyHeader.js +1 -193
- package/lib/module/components/AskBuoyIcon.js +1 -8
- package/lib/module/components/AskBuoyModal.js +2 -477
- package/lib/module/components/AskBuoySettings.js +1 -176
- package/lib/module/components/ChangesBar.js +1 -206
- package/lib/module/components/Composer.js +1 -250
- package/lib/module/components/EmptyState.js +1 -156
- package/lib/module/components/KeyboardPad.js +1 -75
- package/lib/module/components/Markdown.js +1 -305
- package/lib/module/components/MessageList.js +1 -964
- package/lib/module/components/QueuedMessages.js +1 -140
- package/lib/module/components/ThinkingStrip.js +1 -218
- package/lib/module/components/TypingDots.js +1 -58
- package/lib/module/components/markdownParse.js +1 -125
- package/lib/module/components/markdownParse.test.js +1 -98
- package/lib/module/components/useCopyAction.js +1 -46
- package/lib/module/index.js +1 -34
- package/lib/module/preset.js +1 -74
- package/lib/module/store/activityGroups.js +1 -103
- package/lib/module/store/activityGroups.test.js +1 -77
- package/lib/module/store/askBuoySettings.js +1 -67
- package/lib/module/store/askBuoyStore.js +2 -582
- package/lib/module/store/blockPlacement.js +1 -59
- package/lib/module/store/blockPlacement.test.js +1 -122
- package/lib/module/store/queue.test.js +1 -149
- package/lib/module/store/resetConversation.js +1 -72
- package/lib/module/store/restorePending.test.js +1 -62
- package/lib/module/store/restoredIds.test.js +1 -46
- package/lib/module/store/suggestions.js +1 -49
- package/lib/module/store/suggestions.test.js +1 -57
- package/lib/module/store/systemLine.test.js +1 -76
- package/lib/module/store/ticketPrompt.js +1 -13
- package/lib/module/store/traceText.js +1 -75
- package/lib/module/store/traceText.test.js +1 -111
- package/lib/module/store/transcriptPersistence.js +1 -287
- package/lib/module/store/transcriptPersistence.test.js +1 -332
- package/lib/module/store/turnRendering.test.js +1 -150
- package/lib/module/store/useAskBuoy.js +1 -646
- package/lib/module/store/useAskBuoySettings.js +1 -9
- package/lib/module/sync/askBuoySyncAdapter.js +1 -148
- 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/web/index.mjs +11 -12
- package/package.json +8 -12
- 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/blockText.js.map +0 -1
- package/lib/commonjs/blocks/blockText.test.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/blocks/ruleStates.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/KeyboardPad.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/QueuedMessages.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/markdownParse.js.map +0 -1
- package/lib/commonjs/components/markdownParse.test.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/activityGroups.js.map +0 -1
- package/lib/commonjs/store/activityGroups.test.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/blockPlacement.js.map +0 -1
- package/lib/commonjs/store/blockPlacement.test.js.map +0 -1
- package/lib/commonjs/store/queue.test.js.map +0 -1
- package/lib/commonjs/store/resetConversation.js.map +0 -1
- package/lib/commonjs/store/restorePending.test.js.map +0 -1
- package/lib/commonjs/store/restoredIds.test.js.map +0 -1
- package/lib/commonjs/store/suggestions.js.map +0 -1
- package/lib/commonjs/store/suggestions.test.js.map +0 -1
- package/lib/commonjs/store/systemLine.test.js.map +0 -1
- package/lib/commonjs/store/ticketPrompt.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/turnRendering.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/blockText.js.map +0 -1
- package/lib/module/blocks/blockText.test.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/blocks/ruleStates.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/KeyboardPad.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/QueuedMessages.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/markdownParse.js.map +0 -1
- package/lib/module/components/markdownParse.test.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/activityGroups.js.map +0 -1
- package/lib/module/store/activityGroups.test.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/blockPlacement.js.map +0 -1
- package/lib/module/store/blockPlacement.test.js.map +0 -1
- package/lib/module/store/queue.test.js.map +0 -1
- package/lib/module/store/resetConversation.js.map +0 -1
- package/lib/module/store/restorePending.test.js.map +0 -1
- package/lib/module/store/restoredIds.test.js.map +0 -1
- package/lib/module/store/suggestions.js.map +0 -1
- package/lib/module/store/suggestions.test.js.map +0 -1
- package/lib/module/store/systemLine.test.js.map +0 -1
- package/lib/module/store/ticketPrompt.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/turnRendering.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/blockText.d.ts.map +0 -1
- package/lib/typescript/blocks/blockText.test.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/blocks/ruleStates.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/KeyboardPad.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/QueuedMessages.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/markdownParse.d.ts.map +0 -1
- package/lib/typescript/components/markdownParse.test.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/activityGroups.d.ts.map +0 -1
- package/lib/typescript/store/activityGroups.test.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/blockPlacement.d.ts.map +0 -1
- package/lib/typescript/store/blockPlacement.test.d.ts.map +0 -1
- package/lib/typescript/store/queue.test.d.ts.map +0 -1
- package/lib/typescript/store/resetConversation.d.ts.map +0 -1
- package/lib/typescript/store/restorePending.test.d.ts.map +0 -1
- package/lib/typescript/store/restoredIds.test.d.ts.map +0 -1
- package/lib/typescript/store/suggestions.d.ts.map +0 -1
- package/lib/typescript/store/suggestions.test.d.ts.map +0 -1
- package/lib/typescript/store/systemLine.test.d.ts.map +0 -1
- package/lib/typescript/store/ticketPrompt.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/turnRendering.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,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Copy that reports what happened.
|
|
5
|
-
*
|
|
6
|
-
* Both clipboard libraries are OPTIONAL peers, so `copyToClipboard` resolves
|
|
7
|
-
* false in an app that installed neither — a copy button that silently does
|
|
8
|
-
* nothing is worse than no copy button, so that case falls through to the OS
|
|
9
|
-
* share sheet (which also offers Copy) instead of failing quietly.
|
|
10
|
-
*
|
|
11
|
-
* `getText` is read on PRESS, not on render: the whole-transcript callers
|
|
12
|
-
* would otherwise rebuild the transcript on every frame of a streaming answer
|
|
13
|
-
* just to have a string ready for a button nobody tapped.
|
|
14
|
-
*/
|
|
15
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
16
|
-
import { Share } from "react-native";
|
|
17
|
-
import { copyToClipboard } from "@buoy-gg/shared-ui";
|
|
18
|
-
|
|
19
|
-
/** Long enough to notice out of the corner of an eye, short enough not to linger. */
|
|
20
|
-
const COPIED_MS = 1500;
|
|
21
|
-
export function useCopyAction(getText) {
|
|
22
|
-
const [copied, setCopied] = useState(false);
|
|
23
|
-
const timer = useRef(null);
|
|
24
|
-
useEffect(() => () => {
|
|
25
|
-
if (timer.current) clearTimeout(timer.current);
|
|
26
|
-
}, []);
|
|
27
|
-
const copy = useCallback(() => {
|
|
28
|
-
const text = getText();
|
|
29
|
-
void copyToClipboard(text).then(ok => {
|
|
30
|
-
if (!ok) {
|
|
31
|
-
void Share.share({
|
|
32
|
-
message: text
|
|
33
|
-
}).catch(() => {});
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
setCopied(true);
|
|
37
|
-
if (timer.current) clearTimeout(timer.current);
|
|
38
|
-
timer.current = setTimeout(() => setCopied(false), COPIED_MS);
|
|
39
|
-
}).catch(() => {});
|
|
40
|
-
}, [getText]);
|
|
41
|
-
return {
|
|
42
|
-
copied,
|
|
43
|
-
copy
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=useCopyAction.js.map
|
|
1
|
+
"use strict";import{useCallback as i,useEffect as n,useRef as a,useState as f}from"react";import{Share as m}from"react-native";import{copyToClipboard as p}from"@buoy-gg/shared-ui";const l=1500;export function useCopyAction(t){const[c,r]=f(false);const e=a(null);n(()=>()=>{if(e.current)clearTimeout(e.current)},[]);const s=i(()=>{const o=t();void p(o).then(u=>{if(!u){void m.share({message:o}).catch(()=>{});return}r(true);if(e.current)clearTimeout(e.current);e.current=setTimeout(()=>r(false),l)}).catch(()=>{})},[t]);return{copied:c,copy:s}}
|
package/lib/module/index.js
CHANGED
|
@@ -1,34 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @buoy-gg/ask-buoy — "Ask Buoy".
|
|
5
|
-
*
|
|
6
|
-
* A chat sheet that drives every other Buoy tool on behalf of someone who does
|
|
7
|
-
* not read code. The model runs on the company's own endpoint (see
|
|
8
|
-
* `AskBuoyConfig`), the tool calls go through the same `dispatchToolAction`
|
|
9
|
-
* seam a Scenario step uses, and anything it changes is listed in a bar with an
|
|
10
|
-
* Undo.
|
|
11
|
-
*/
|
|
12
|
-
export { AskBuoyModal } from "./components/AskBuoyModal";
|
|
13
|
-
export { askBuoyToolPreset, createAskBuoyTool, AskBuoyIcon, ASK_BUOY_ICON_COLOR } from "./preset";
|
|
14
|
-
export { askBuoySyncAdapter, ASK_BUOY_ADAPTER_VERSION } from "./sync/askBuoySyncAdapter";
|
|
15
|
-
export { askBuoyStore } from "./store/askBuoyStore";
|
|
16
|
-
export { useAskBuoy, useAskBuoyState } from "./store/useAskBuoy";
|
|
17
|
-
export { redactForWire } from "./sync/wire";
|
|
18
|
-
export { BlockRenderer, BlockHandlersProvider, useBlockHandlers } from "./blocks";
|
|
19
|
-
export { Card as BlockCard, ActionRow as BlockActionRow, ProvenanceBadge } from "./blocks";
|
|
20
|
-
export { MessageActions, ReasoningStrip, ElapsedRow, QueuedComposer, ReloadDivider, Timestamp, EditableUserBubble, LivePill } from "./blocks";
|
|
21
|
-
export { Markdown } from "./components/Markdown";
|
|
22
|
-
// The real transcript pieces, exported so the example app's "chat scenes" page
|
|
23
|
-
// can stage conversations in the actual sheet chrome.
|
|
24
|
-
export { MessageList } from "./components/MessageList";
|
|
25
|
-
export { AskBuoyHeader } from "./components/AskBuoyHeader";
|
|
26
|
-
export { AskBuoySettings } from "./components/AskBuoySettings";
|
|
27
|
-
export { ThinkingStrip } from "./components/ThinkingStrip";
|
|
28
|
-
export { askBuoySettings } from "./store/askBuoySettings";
|
|
29
|
-
export { useAskBuoySettings } from "./store/useAskBuoySettings";
|
|
30
|
-
export { traceEntries, traceToText, hasTrace } from "./store/traceText";
|
|
31
|
-
export { Composer } from "./components/Composer";
|
|
32
|
-
export { ChangesBar } from "./components/ChangesBar";
|
|
33
|
-
export { ApprovalCard } from "./components/ApprovalCard";
|
|
34
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";export{AskBuoyModal}from"./components/AskBuoyModal";export{askBuoyToolPreset,createAskBuoyTool,AskBuoyIcon,ASK_BUOY_ICON_COLOR}from"./preset";export{askBuoySyncAdapter,ASK_BUOY_ADAPTER_VERSION}from"./sync/askBuoySyncAdapter";export{askBuoyStore}from"./store/askBuoyStore";export{useAskBuoy,useAskBuoyState}from"./store/useAskBuoy";export{redactForWire}from"./sync/wire";export{BlockRenderer,BlockHandlersProvider,useBlockHandlers}from"./blocks";export{Card as BlockCard,ActionRow as BlockActionRow,ProvenanceBadge}from"./blocks";export{MessageActions,ReasoningStrip,ElapsedRow,QueuedComposer,ReloadDivider,Timestamp,EditableUserBubble,LivePill}from"./blocks";export{Markdown}from"./components/Markdown";export{MessageList}from"./components/MessageList";export{AskBuoyHeader}from"./components/AskBuoyHeader";export{AskBuoySettings}from"./components/AskBuoySettings";export{ThinkingStrip}from"./components/ThinkingStrip";export{askBuoySettings}from"./store/askBuoySettings";export{useAskBuoySettings}from"./store/useAskBuoySettings";export{traceEntries,traceToText,hasTrace}from"./store/traceText";export{Composer}from"./components/Composer";export{ChangesBar}from"./components/ChangesBar";export{ApprovalCard}from"./components/ApprovalCard";
|
package/lib/module/preset.js
CHANGED
|
@@ -1,74 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The Ask Buoy tool preset.
|
|
5
|
-
*
|
|
6
|
-
* Manual chrome (`component` renders its own JsModal) rather than the
|
|
7
|
-
* declarative `modal` config, because ToolModalShell forwards neither a footer
|
|
8
|
-
* slot nor `initialHeight` — and a chat needs a sticky composer and more than
|
|
9
|
-
* the default 400pt of sheet.
|
|
10
|
-
*
|
|
11
|
-
* The config is closed over at creation time rather than read from a store, so
|
|
12
|
-
* the endpoint and headers come from the app's own code on every render and
|
|
13
|
-
* there is never a copy of them sitting anywhere Buoy persists.
|
|
14
|
-
*/
|
|
15
|
-
import { AskBuoyIcon, ASK_BUOY_ICON_COLOR } from "./components/AskBuoyIcon";
|
|
16
|
-
import { AskBuoyModal } from "./components/AskBuoyModal";
|
|
17
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
-
export { AskBuoyIcon, ASK_BUOY_ICON_COLOR };
|
|
19
|
-
export const askBuoyToolPreset = {
|
|
20
|
-
id: "ask-buoy",
|
|
21
|
-
name: "ASK BUOY",
|
|
22
|
-
description: "Ask about this app in plain English",
|
|
23
|
-
slot: "both",
|
|
24
|
-
// Set here rather than in floating-tools-core's `toolColors` map: that map
|
|
25
|
-
// is already missing half the shipped tools, so the web twin falls back to a
|
|
26
|
-
// generic accent for them. A color on the preset is the one place both
|
|
27
|
-
// native and web read.
|
|
28
|
-
color: ASK_BUOY_ICON_COLOR,
|
|
29
|
-
// The approved composition uses a 48pt optical size in the 32pt dial slot.
|
|
30
|
-
// Compact row/header uses keep their requested size.
|
|
31
|
-
icon: ({
|
|
32
|
-
size,
|
|
33
|
-
slot
|
|
34
|
-
}) => /*#__PURE__*/_jsx(AskBuoyIcon, {
|
|
35
|
-
size: slot === 'dial' ? size * 1.5 : size
|
|
36
|
-
}),
|
|
37
|
-
component: AskBuoyModal
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* `endpoint` and `model` are REQUIRED at the type level. This used to extend
|
|
42
|
-
* Partial<AskBuoyConfig> with a cast, so a missing endpoint type-checked and
|
|
43
|
-
* only surfaced as a runtime "not set up yet" — the wrong moment to learn it.
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Wire Ask Buoy to your team's AI endpoint.
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* createAskBuoyTool({
|
|
51
|
-
* endpoint: "https://ai.acme.com/v1/messages",
|
|
52
|
-
* model: "claude-opus-5",
|
|
53
|
-
* headers: async () => ({ Authorization: `Bearer ${await auth.getToken()}` }),
|
|
54
|
-
* context: { notes: ["user.rewards.points = loyalty points"] },
|
|
55
|
-
* })
|
|
56
|
-
*/
|
|
57
|
-
export function createAskBuoyTool(config) {
|
|
58
|
-
const {
|
|
59
|
-
name,
|
|
60
|
-
description,
|
|
61
|
-
...rest
|
|
62
|
-
} = config;
|
|
63
|
-
const resolved = rest;
|
|
64
|
-
return {
|
|
65
|
-
...askBuoyToolPreset,
|
|
66
|
-
name: name ?? askBuoyToolPreset.name,
|
|
67
|
-
description: description ?? askBuoyToolPreset.description,
|
|
68
|
-
component: props => /*#__PURE__*/_jsx(AskBuoyModal, {
|
|
69
|
-
...props,
|
|
70
|
-
config: resolved
|
|
71
|
-
})
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=preset.js.map
|
|
1
|
+
"use strict";import{AskBuoyIcon as n,ASK_BUOY_ICON_COLOR as s}from"./components/AskBuoyIcon";import{AskBuoyModal as e}from"./components/AskBuoyModal";import{jsx as i}from"react/jsx-runtime";export{n as AskBuoyIcon,s as ASK_BUOY_ICON_COLOR};export const askBuoyToolPreset={id:"ask-buoy",name:"ASK BUOY",description:"Ask about this app in plain English",slot:"both",color:s,icon:({size:o,slot:t})=>i(n,{size:t==="dial"?o*1.5:o}),component:e};export function createAskBuoyTool(o){const{name:t,description:r,...c}=o;const p=c;return{...askBuoyToolPreset,name:t??askBuoyToolPreset.name,description:r??askBuoyToolPreset.description,component:a=>i(e,{...a,config:p})}}
|
|
@@ -1,103 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* How tool rows fold in the activity card.
|
|
5
|
-
*
|
|
6
|
-
* Consecutive SUCCESSFUL READS fold into one row — "Looked at Network, Storage
|
|
7
|
-
* · 3 reads" — and nothing else ever folds. The previous rule folded by count:
|
|
8
|
-
* past four steps the card became "Did 7 things · 1 failed" with every row but
|
|
9
|
-
* the failures hidden, including the one successful write, which is the row
|
|
10
|
-
* the user most needs to see. Codex's exec cell does the same thing for file
|
|
11
|
-
* reads ("Explored — Read a, b, c") and keeps every run visible.
|
|
12
|
-
*
|
|
13
|
-
* A group never crosses a write: a read after a mutation is a different
|
|
14
|
-
* observation from a read before it, and merging them would misreport order.
|
|
15
|
-
* Uses the engine's `effect` classification, never the action's name.
|
|
16
|
-
*/
|
|
17
|
-
import { toolTitle } from "@buoy-gg/agent-core";
|
|
18
|
-
const foldable = c => c.effect === "read" && c.status === "ok";
|
|
19
|
-
export function groupCalls(calls) {
|
|
20
|
-
const out = [];
|
|
21
|
-
let run = [];
|
|
22
|
-
const flush = () => {
|
|
23
|
-
if (run.length === 0) return;
|
|
24
|
-
if (run.length === 1) {
|
|
25
|
-
out.push({
|
|
26
|
-
kind: "call",
|
|
27
|
-
call: run[0]
|
|
28
|
-
});
|
|
29
|
-
} else {
|
|
30
|
-
const titles = [...new Set(run.map(c => toolTitle(c.toolId)))];
|
|
31
|
-
out.push({
|
|
32
|
-
kind: "reads",
|
|
33
|
-
id: run.map(c => c.id).join("+"),
|
|
34
|
-
calls: run,
|
|
35
|
-
label: `Looked at ${joinNatural(titles)}`,
|
|
36
|
-
count: run.length
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
run = [];
|
|
40
|
-
};
|
|
41
|
-
for (const call of calls) {
|
|
42
|
-
if (foldable(call)) {
|
|
43
|
-
run.push(call);
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
flush();
|
|
47
|
-
out.push({
|
|
48
|
-
kind: "call",
|
|
49
|
-
call
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
flush();
|
|
53
|
-
return out;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** "Network", "Network and Storage", "Network, Storage and Screen". */
|
|
57
|
-
function joinNatural(items) {
|
|
58
|
-
if (items.length <= 1) return items[0] ?? "";
|
|
59
|
-
if (items.length === 2) return `${items[0]} and ${items[1]}`;
|
|
60
|
-
return `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* "48s · 6 actions · 1 declined" — the line under a finished answer.
|
|
65
|
-
*
|
|
66
|
-
* "Actions" is tool calls, not provider rounds: rounds are an implementation
|
|
67
|
-
* detail nobody outside the engine can count. Failed, refused, declined and
|
|
68
|
-
* stopped are listed separately because they are different outcomes — a
|
|
69
|
-
* failed exploratory read the agent recovered from is not a failed task. No
|
|
70
|
-
* duration is invented when the message has no start time (a restored note).
|
|
71
|
-
*/
|
|
72
|
-
export function turnFooter(message) {
|
|
73
|
-
const parts = [];
|
|
74
|
-
if (message.startedAt !== undefined && message.endedAt !== undefined && message.endedAt >= message.startedAt) {
|
|
75
|
-
parts.push(formatElapsed(message.endedAt - message.startedAt));
|
|
76
|
-
}
|
|
77
|
-
const n = message.toolCalls.length;
|
|
78
|
-
if (n > 0) {
|
|
79
|
-
parts.push(`${n} action${n === 1 ? "" : "s"}`);
|
|
80
|
-
const count = s => message.toolCalls.filter(c => c.status === s).length;
|
|
81
|
-
const failed = count("failed");
|
|
82
|
-
const refused = count("refused");
|
|
83
|
-
const declined = count("declined");
|
|
84
|
-
const stopped = count("stopped");
|
|
85
|
-
if (failed) parts.push(`${failed} failed`);
|
|
86
|
-
if (refused) parts.push(`${refused} refused`);
|
|
87
|
-
if (declined) parts.push(`${declined} declined`);
|
|
88
|
-
if (stopped) parts.push(`${stopped} not run`);
|
|
89
|
-
}
|
|
90
|
-
return parts.length ? parts.join(" · ") : null;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/** "4s", "1m 04s", "1h 02m". Compact, for a subtitle or a footer. */
|
|
94
|
-
export function formatElapsed(ms) {
|
|
95
|
-
const total = Math.max(0, Math.floor(ms / 1000));
|
|
96
|
-
if (total < 60) return `${total}s`;
|
|
97
|
-
const m = Math.floor(total / 60);
|
|
98
|
-
const s = total % 60;
|
|
99
|
-
if (m < 60) return `${m}m ${String(s).padStart(2, "0")}s`;
|
|
100
|
-
const h = Math.floor(m / 60);
|
|
101
|
-
return `${h}h ${String(m % 60).padStart(2, "0")}m`;
|
|
102
|
-
}
|
|
103
|
-
//# sourceMappingURL=activityGroups.js.map
|
|
1
|
+
"use strict";import{toolTitle as a}from"@buoy-gg/agent-core";const c=t=>t.effect==="read"&&t.status==="ok";export function groupCalls(t){const n=[];let o=[];const e=()=>{if(o.length===0)return;if(o.length===1){n.push({kind:"call",call:o[0]})}else{const l=[...new Set(o.map(r=>a(r.toolId)))];n.push({kind:"reads",id:o.map(r=>r.id).join("+"),calls:o,label:`Looked at ${s(l)}`,count:o.length})}o=[]};for(const l of t){if(c(l)){o.push(l);continue}e();n.push({kind:"call",call:l})}e();return n}function s(t){if(t.length<=1)return t[0]??"";if(t.length===2)return`${t[0]} and ${t[1]}`;return`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}export function turnFooter(t){const n=[];if(t.startedAt!==void 0&&t.endedAt!==void 0&&t.endedAt>=t.startedAt){n.push(formatElapsed(t.endedAt-t.startedAt))}const o=t.toolCalls.length;if(o>0){n.push(`${o} action${o===1?"":"s"}`);const e=f=>t.toolCalls.filter(i=>i.status===f).length;const l=e("failed");const r=e("refused");const d=e("declined");const u=e("stopped");if(l)n.push(`${l} failed`);if(r)n.push(`${r} refused`);if(d)n.push(`${d} declined`);if(u)n.push(`${u} not run`)}return n.length?n.join(" \xB7 "):null}export function formatElapsed(t){const n=Math.max(0,Math.floor(t/1e3));if(n<60)return`${n}s`;const o=Math.floor(n/60);const e=n%60;if(o<60)return`${o}m ${String(e).padStart(2,"0")}s`;const l=Math.floor(o/60);return`${l}h ${String(o%60).padStart(2,"0")}m`}
|
|
@@ -1,77 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The fold rule: consecutive successful reads fold, nothing else ever does,
|
|
5
|
-
* and a group never crosses a write.
|
|
6
|
-
*/
|
|
7
|
-
import { describe, expect, it } from "vitest";
|
|
8
|
-
import { formatElapsed, groupCalls, turnFooter } from "./activityGroups";
|
|
9
|
-
const call = (id, toolId, effect, status = "ok") => ({
|
|
10
|
-
id,
|
|
11
|
-
toolId,
|
|
12
|
-
action: "x",
|
|
13
|
-
label: `${toolId} ${id}`,
|
|
14
|
-
status,
|
|
15
|
-
effect
|
|
16
|
-
});
|
|
17
|
-
describe("groupCalls", () => {
|
|
18
|
-
it("leaves a single read as an ordinary row", () => {
|
|
19
|
-
const items = groupCalls([call("a", "console", "read")]);
|
|
20
|
-
expect(items).toEqual([{
|
|
21
|
-
kind: "call",
|
|
22
|
-
call: expect.objectContaining({
|
|
23
|
-
id: "a"
|
|
24
|
-
})
|
|
25
|
-
}]);
|
|
26
|
-
});
|
|
27
|
-
it("folds consecutive successful reads and names the tools once each", () => {
|
|
28
|
-
const items = groupCalls([call("a", "network", "read"), call("b", "storage", "read"), call("c", "storage", "read")]);
|
|
29
|
-
expect(items).toHaveLength(1);
|
|
30
|
-
const g = items[0];
|
|
31
|
-
expect(g.kind).toBe("reads");
|
|
32
|
-
expect(g.kind === "reads" && g.count).toBe(3);
|
|
33
|
-
expect(g.kind === "reads" && g.label).toBe("Looked at Network and Storage");
|
|
34
|
-
});
|
|
35
|
-
it("never folds a write, and never folds reads across one", () => {
|
|
36
|
-
const items = groupCalls([call("a", "network", "read"), call("b", "storage", "read"), call("w", "zustand", "write"), call("c", "storage", "read"), call("d", "console", "read")]);
|
|
37
|
-
expect(items.map(i => i.kind === "reads" ? `reads:${i.count}` : `call:${i.call.id}`)).toEqual(["reads:2", "call:w", "reads:2"]);
|
|
38
|
-
});
|
|
39
|
-
it("keeps failed, refused, declined, stopped and running reads as their own rows", () => {
|
|
40
|
-
const items = groupCalls([call("a", "network", "read"), call("f", "storage", "read", "failed"), call("b", "storage", "read"), call("r", "storage", "read", "running")]);
|
|
41
|
-
expect(items.map(i => i.kind)).toEqual(["call", "call", "call", "call"]);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
describe("turnFooter", () => {
|
|
45
|
-
it("reports duration and action count", () => {
|
|
46
|
-
expect(turnFooter({
|
|
47
|
-
startedAt: 1_000,
|
|
48
|
-
endedAt: 13_000,
|
|
49
|
-
toolCalls: [call("a", "network", "read"), call("b", "zustand", "write")]
|
|
50
|
-
})).toBe("12s · 2 actions");
|
|
51
|
-
});
|
|
52
|
-
it("separates the outcomes that were not plain successes", () => {
|
|
53
|
-
expect(turnFooter({
|
|
54
|
-
startedAt: 0,
|
|
55
|
-
endedAt: 48_000,
|
|
56
|
-
toolCalls: [call("a", "network", "read"), call("b", "storage", "write", "failed"), call("c", "storage", "destructive", "declined"), call("d", "storage", "write", "stopped")]
|
|
57
|
-
})).toBe("48s · 4 actions · 1 failed · 1 declined · 1 not run");
|
|
58
|
-
});
|
|
59
|
-
it("invents no duration for a note with no start time", () => {
|
|
60
|
-
expect(turnFooter({
|
|
61
|
-
endedAt: 5_000,
|
|
62
|
-
toolCalls: []
|
|
63
|
-
})).toBeNull();
|
|
64
|
-
expect(turnFooter({
|
|
65
|
-
endedAt: 5_000,
|
|
66
|
-
toolCalls: [call("a", "network", "read")]
|
|
67
|
-
})).toBe("1 action");
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
describe("formatElapsed", () => {
|
|
71
|
-
it("is compact", () => {
|
|
72
|
-
expect(formatElapsed(4_200)).toBe("4s");
|
|
73
|
-
expect(formatElapsed(64_000)).toBe("1m 04s");
|
|
74
|
-
expect(formatElapsed(3_720_000)).toBe("1h 02m");
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
//# sourceMappingURL=activityGroups.test.js.map
|
|
1
|
+
"use strict";import{describe as n,expect as a,it as r}from"vitest";import{formatElapsed as l,groupCalls as s,turnFooter as d}from"./activityGroups";const e=(o,t,c,i="ok")=>({id:o,toolId:t,action:"x",label:`${t} ${o}`,status:i,effect:c});n("groupCalls",()=>{r("leaves a single read as an ordinary row",()=>{const o=s([e("a","console","read")]);a(o).toEqual([{kind:"call",call:a.objectContaining({id:"a"})}])});r("folds consecutive successful reads and names the tools once each",()=>{const o=s([e("a","network","read"),e("b","storage","read"),e("c","storage","read")]);a(o).toHaveLength(1);const t=o[0];a(t.kind).toBe("reads");a(t.kind==="reads"&&t.count).toBe(3);a(t.kind==="reads"&&t.label).toBe("Looked at Network and Storage")});r("never folds a write, and never folds reads across one",()=>{const o=s([e("a","network","read"),e("b","storage","read"),e("w","zustand","write"),e("c","storage","read"),e("d","console","read")]);a(o.map(t=>t.kind==="reads"?`reads:${t.count}`:`call:${t.call.id}`)).toEqual(["reads:2","call:w","reads:2"])});r("keeps failed, refused, declined, stopped and running reads as their own rows",()=>{const o=s([e("a","network","read"),e("f","storage","read","failed"),e("b","storage","read"),e("r","storage","read","running")]);a(o.map(t=>t.kind)).toEqual(["call","call","call","call"])})});n("turnFooter",()=>{r("reports duration and action count",()=>{a(d({startedAt:1e3,endedAt:13e3,toolCalls:[e("a","network","read"),e("b","zustand","write")]})).toBe("12s \xB7 2 actions")});r("separates the outcomes that were not plain successes",()=>{a(d({startedAt:0,endedAt:48e3,toolCalls:[e("a","network","read"),e("b","storage","write","failed"),e("c","storage","destructive","declined"),e("d","storage","write","stopped")]})).toBe("48s \xB7 4 actions \xB7 1 failed \xB7 1 declined \xB7 1 not run")});r("invents no duration for a note with no start time",()=>{a(d({endedAt:5e3,toolCalls:[]})).toBeNull();a(d({endedAt:5e3,toolCalls:[e("a","network","read")]})).toBe("1 action")})});n("formatElapsed",()=>{r("is compact",()=>{a(l(4200)).toBe("4s");a(l(64e3)).toBe("1m 04s");a(l(372e4)).toBe("1h 02m")})});
|
|
@@ -1,67 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Ask Buoy's own preferences — the things a tester sets on the sheet, not the
|
|
5
|
-
* things a developer sets in `askBuoy={{ … }}`.
|
|
6
|
-
*
|
|
7
|
-
* Module-level and subscribable for the same reason the transcript is: the
|
|
8
|
-
* sheet unmounts whenever the tool is closed or minimised, and a preference
|
|
9
|
-
* that reset on every close would not be a preference.
|
|
10
|
-
*/
|
|
11
|
-
import { definePersistedSetting, devToolsStorageKeys } from "@buoy-gg/shared-ui";
|
|
12
|
-
export const DEFAULT_SETTINGS = {
|
|
13
|
-
showThinking: false,
|
|
14
|
-
bypassApprovals: false,
|
|
15
|
-
readOnly: false
|
|
16
|
-
};
|
|
17
|
-
const store = definePersistedSetting(`${devToolsStorageKeys.base}_ask_buoy_settings`, DEFAULT_SETTINGS, {
|
|
18
|
-
sanitize: merged => ({
|
|
19
|
-
showThinking: merged.showThinking === true,
|
|
20
|
-
// Fails closed: anything but a literal `true` on disk means "ask me".
|
|
21
|
-
bypassApprovals: merged.bypassApprovals === true,
|
|
22
|
-
readOnly: merged.readOnly === true
|
|
23
|
-
})
|
|
24
|
-
});
|
|
25
|
-
let current = DEFAULT_SETTINGS;
|
|
26
|
-
let loaded = false;
|
|
27
|
-
const listeners = new Set();
|
|
28
|
-
function emit() {
|
|
29
|
-
for (const fn of listeners) {
|
|
30
|
-
try {
|
|
31
|
-
fn();
|
|
32
|
-
} catch {
|
|
33
|
-
// A throwing subscriber must not take the sheet down.
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
export const askBuoySettings = {
|
|
38
|
-
get: () => current,
|
|
39
|
-
subscribe(fn) {
|
|
40
|
-
listeners.add(fn);
|
|
41
|
-
// First subscriber pays for the read; everyone after gets the cached value.
|
|
42
|
-
if (!loaded) {
|
|
43
|
-
loaded = true;
|
|
44
|
-
void store.load().then(value => {
|
|
45
|
-
current = value;
|
|
46
|
-
emit();
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return () => listeners.delete(fn);
|
|
50
|
-
},
|
|
51
|
-
set(key, value) {
|
|
52
|
-
if (current[key] === value) return;
|
|
53
|
-
current = {
|
|
54
|
-
...current,
|
|
55
|
-
[key]: value
|
|
56
|
-
};
|
|
57
|
-
emit();
|
|
58
|
-
void store.save(current);
|
|
59
|
-
},
|
|
60
|
-
/** Tests only — the module cache would otherwise leak between them. */
|
|
61
|
-
reset() {
|
|
62
|
-
current = DEFAULT_SETTINGS;
|
|
63
|
-
loaded = false;
|
|
64
|
-
void store.clear();
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=askBuoySettings.js.map
|
|
1
|
+
"use strict";import{definePersistedSetting as i,devToolsStorageKeys as l}from"@buoy-gg/shared-ui";export const DEFAULT_SETTINGS={showThinking:false,bypassApprovals:false,readOnly:false};const o=i(`${l.base}_ask_buoy_settings`,DEFAULT_SETTINGS,{sanitize:e=>({showThinking:e.showThinking===true,bypassApprovals:e.bypassApprovals===true,readOnly:e.readOnly===true})});let s=DEFAULT_SETTINGS;let r=false;const n=new Set;function a(){for(const e of n){try{e()}catch{}}}export const askBuoySettings={get:()=>s,subscribe(e){n.add(e);if(!r){r=true;void o.load().then(t=>{s=t;a()})}return()=>n.delete(e)},set(e,t){if(s[e]===t)return;s={...s,[e]:t};a();void o.save(s)},reset(){s=DEFAULT_SETTINGS;r=false;void o.clear()}};
|