@buoy-gg/ask-buoy 7.0.53 → 7.0.54

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.
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.AskBuoyModal=AskBuoyModal;var _react=require("react");var _reactNative=require("react-native");var _agentCore=require("@buoy-gg/agent-core");var _sharedUi=require("@buoy-gg/shared-ui");var _blocks=require("../blocks");var _ApprovalCard=require("./ApprovalCard");var _ChangesBar=require("./ChangesBar");var _ruleStates=require("../blocks/ruleStates");var _Composer=require("./Composer");var _KeyboardPad=require("./KeyboardPad");var _AskBuoyHeader=require("./AskBuoyHeader");var _AskBuoySettings=require("./AskBuoySettings");var _EmptyState=require("./EmptyState");var _MessageList=require("./MessageList");var _QueuedMessages=require("./QueuedMessages");var _askBuoyStore=require("../store/askBuoyStore");var _ticketPrompt=require("../store/ticketPrompt");var _useAskBuoy=require("../store/useAskBuoy");var _useAskBuoySettings=require("../store/useAskBuoySettings");var _jsxRuntime=require("react/jsx-runtime");function AskBuoyModal({visible:f,onClose:v,onBack:S,onMinimize:l,persistenceKey:R,config:u}){const{state:e,send:c,stop:k,reset:d,undoThenReset:A,approve:E,retry:I,answer:x,runAction:B,editQueued:L,removeQueued:K,configured:b,toolCount:O,availableToolIds:D}=(0,_useAskBuoy.useAskBuoy)(u);const[N,U]=(0,_react.useState)(false);const V=(0,_react.useCallback)(()=>{k();v()},[k,v]);const F=(0,_react.useCallback)(()=>_askBuoyStore.askBuoyStore.clearDraft(),[]);const[g,h]=(0,_react.useState)(false);const Q=(0,_react.useCallback)(()=>h(false),[]);const z=(0,_react.useCallback)(()=>h(true),[]);const a=!f;const C=!!e.pending||!!e.awaitingBlockId;const n=e.messages[e.messages.length-1];const y=(0,_react.useRef)(false);const T=(0,_react.useRef)(e.busy);(0,_react.useEffect)(()=>{if(a&&T.current&&!e.busy)y.current=true;if(!a)y.current=false;T.current=e.busy},[a,e.busy]);(0,_react.useEffect)(()=>{if(!a){(0,_sharedUi.setToolAttention)("ask-buoy",null);return}if(C){(0,_sharedUi.setToolAttention)("ask-buoy",{kind:"needsInput",label:e.pending?"Needs your approval":"Has a question for you"})}else if(y.current&&n?.role==="assistant"&&n.error){(0,_sharedUi.setToolAttention)("ask-buoy",{kind:"failed",label:"The last turn failed"})}else if(y.current&&!e.busy){(0,_sharedUi.setToolAttention)("ask-buoy",{kind:"done",label:"Finished"})}else{(0,_sharedUi.setToolAttention)("ask-buoy",null)}},[a,C,e.busy,e.pending,n]);(0,_react.useEffect)(()=>()=>(0,_sharedUi.setToolAttention)("ask-buoy",null),[]);(0,_react.useEffect)(()=>{if(e.pending&&g)h(false)},[e.pending,g]);const W=(0,_sharedUi.useSafeAreaInsets)({minBottom:16});const[G,J]=(0,_react.useState)("bottomSheet");const X=G==="floating"?0:W.bottom;const Y=(0,_react.useCallback)(()=>{const t=_askBuoyStore.askBuoyStore.getLedger();if(!t)return;void(async()=>{const s=await t.revertAll(_sharedUi.dispatchToolAction);if(s.failed.length===0){_askBuoyStore.askBuoyStore.setNotice(null);return}const o=s.failed.map(i=>`${i.label} (${i.error})`).join("; ");_askBuoyStore.askBuoyStore.setNotice(`Couldn't undo ${s.failed.length} change${s.failed.length===1?"":"s"} \u2014 ${o}`)})()},[]);const Z=(0,_react.useCallback)(()=>U(t=>!t),[]);const r=(0,_react.useRef)(new _reactNative.Animated.Value(560)).current;const m=(0,_react.useRef)(false);const w=(0,_react.useCallback)(()=>{if(m.current)return;m.current=true;r.stopAnimation(t=>{const s=typeof t==="number"&&t>200?t:560;_reactNative.Animated.timing(r,{toValue:120,duration:220,useNativeDriver:false}).start(()=>{setTimeout(()=>{_reactNative.Animated.spring(r,{toValue:s,friction:9,useNativeDriver:false}).start(()=>{m.current=false})},2500)})})},[r]);const p=(0,_react.useMemo)(()=>{const t=e.messages[e.messages.length-1];if(!t||t.role!=="assistant")return"";const s=t.blocks.filter(o=>o.block.kind==="peek").length;return s>0?`${t.id}:${s}`:""},[e.messages]);const j=(0,_react.useRef)("");(0,_react.useEffect)(()=>{if(p&&p!==j.current&&u?.peek!==false)w();j.current=p},[p,w,u]);const ee=(0,_react.useCallback)(()=>{const t=_askBuoyStore.askBuoyStore.getLedger();const s=t?.list().filter(o=>!o.undoneAt&&(0,_agentCore.isReversible)(o.effect)).length??0;if(s===0){d();return}_reactNative.Alert.alert("Undo changes first?",`Ask Buoy made ${s} change${s===1?"":"s"} that can still be undone. Clearing the conversation loses the only automatic undo for ${s===1?"it":"them"}.`,[{text:"Undo, then clear",onPress:()=>{void(async()=>{const o=await A();if(o.cleared)return;const i=o.reverted+o.failed.length;const le=o.failed.map(H=>`${H.label} (${H.error})`).join("\n");_reactNative.Alert.alert(`Couldn't undo ${o.failed.length} of ${i} change${i===1?"":"s"}`,`${le}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.AskBuoyModal=AskBuoyModal;var _react=require("react");var _reactNative=require("react-native");var _agentCore=require("@buoy-gg/agent-core");var _sharedUi=require("@buoy-gg/shared-ui");var _blocks=require("../blocks");var _ApprovalCard=require("./ApprovalCard");var _ChangesBar=require("./ChangesBar");var _ruleStates=require("../blocks/ruleStates");var _Composer=require("./Composer");var _KeyboardPad=require("./KeyboardPad");var _AskBuoyHeader=require("./AskBuoyHeader");var _AskBuoySettings=require("./AskBuoySettings");var _EmptyState=require("./EmptyState");var _MessageList=require("./MessageList");var _QueuedMessages=require("./QueuedMessages");var _askBuoyStore=require("../store/askBuoyStore");var _ticketPrompt=require("../store/ticketPrompt");var _useAskBuoy=require("../store/useAskBuoy");var _useAskBuoySettings=require("../store/useAskBuoySettings");var _askBuoySettings=require("../store/askBuoySettings");var _jsxRuntime=require("react/jsx-runtime");function AskBuoyModal({visible:f,onClose:v,onBack:S,onMinimize:u,persistenceKey:$,config:r}){const{state:e,send:c,stop:h,reset:d,undoThenReset:x,approve:E,retry:O,answer:A,runAction:B,editQueued:L,removeQueued:N,configured:k,toolCount:D,availableToolIds:K}=(0,_useAskBuoy.useAskBuoy)(r);const[V,z]=(0,_react.useState)(false);const U=(0,_react.useCallback)(()=>{h();v()},[h,v]);const F=(0,_react.useCallback)(()=>_askBuoyStore.askBuoyStore.clearDraft(),[]);const[g,b]=(0,_react.useState)(false);const Q=(0,_react.useCallback)(()=>b(false),[]);const W=(0,_react.useCallback)(()=>b(true),[]);const a=!f;const C=!!e.pending||!!e.awaitingBlockId;const o=e.messages[e.messages.length-1];const y=(0,_react.useRef)(false);const T=(0,_react.useRef)(e.busy);(0,_react.useEffect)(()=>{if(a&&T.current&&!e.busy)y.current=true;if(!a)y.current=false;T.current=e.busy},[a,e.busy]);(0,_react.useEffect)(()=>{if(!a){(0,_sharedUi.setToolAttention)("ask-buoy",null);return}if(C){(0,_sharedUi.setToolAttention)("ask-buoy",{kind:"needsInput",label:e.pending?"Needs your approval":"Has a question for you"})}else if(y.current&&o?.role==="assistant"&&o.error){(0,_sharedUi.setToolAttention)("ask-buoy",{kind:"failed",label:"The last turn failed"})}else if(y.current&&!e.busy){(0,_sharedUi.setToolAttention)("ask-buoy",{kind:"done",label:"Finished"})}else{(0,_sharedUi.setToolAttention)("ask-buoy",null)}},[a,C,e.busy,e.pending,o]);(0,_react.useEffect)(()=>()=>(0,_sharedUi.setToolAttention)("ask-buoy",null),[]);(0,_react.useEffect)(()=>{if(e.pending&&g)b(false)},[e.pending,g]);const G=(0,_sharedUi.useSafeAreaInsets)({minBottom:16});const[J,Y]=(0,_react.useState)("bottomSheet");const X=J==="floating"?0:G.bottom;const Z=(0,_react.useCallback)(()=>{const t=_askBuoyStore.askBuoyStore.getLedger();if(!t)return;void(async()=>{const s=await t.revertAll(_sharedUi.dispatchToolAction);if(s.failed.length===0){_askBuoyStore.askBuoyStore.setNotice(null);return}const n=s.failed.map(l=>`${l.label} (${l.error})`).join("; ");_askBuoyStore.askBuoyStore.setNotice(`Couldn't undo ${s.failed.length} change${s.failed.length===1?"":"s"} \u2014 ${n}`)})()},[]);const ee=(0,_react.useCallback)(()=>z(t=>!t),[]);const i=(0,_react.useRef)(new _reactNative.Animated.Value(560)).current;const m=(0,_react.useRef)(false);const j=(0,_react.useCallback)(()=>{if(m.current)return;m.current=true;i.stopAnimation(t=>{const s=typeof t==="number"&&t>200?t:560;_reactNative.Animated.timing(i,{toValue:120,duration:220,useNativeDriver:false}).start(()=>{setTimeout(()=>{_reactNative.Animated.spring(i,{toValue:s,friction:9,useNativeDriver:false}).start(()=>{m.current=false})},2500)})})},[i]);const p=(0,_react.useMemo)(()=>{const t=e.messages[e.messages.length-1];if(!t||t.role!=="assistant")return"";const s=t.blocks.filter(n=>n.block.kind==="peek").length;return s>0?`${t.id}:${s}`:""},[e.messages]);const w=(0,_react.useRef)("");(0,_react.useEffect)(()=>{if(p&&p!==w.current&&r?.peek!==false)j();w.current=p},[p,j,r]);const te=(0,_react.useCallback)(()=>{const t=_askBuoyStore.askBuoyStore.getLedger();const s=t?.list().filter(n=>!n.undoneAt&&(0,_agentCore.isReversible)(n.effect)).length??0;if(s===0){d();return}_reactNative.Alert.alert("Undo changes first?",`Ask Buoy made ${s} change${s===1?"":"s"} that can still be undone. Clearing the conversation loses the only automatic undo for ${s===1?"it":"them"}.`,[{text:"Undo, then clear",onPress:()=>{void(async()=>{const n=await x();if(n.cleared)return;const l=n.reverted+n.failed.length;const ce=n.failed.map(R=>`${R.label} (${R.error})`).join("\n");_reactNative.Alert.alert(`Couldn't undo ${n.failed.length} of ${l} change${l===1?"":"s"}`,`${ce}
2
2
 
3
- Still applied in the app. Clear the conversation anyway?`,[{text:"Keep conversation",style:"cancel"},{text:"Clear anyway",style:"destructive",onPress:d}])})()}},{text:"Clear anyway",style:"destructive",onPress:d},{text:"Cancel",style:"cancel"}])},[d,A]);const te=(0,_react.useMemo)(()=>{const t=e.messages[e.messages.length-1];if(!t||t.role!=="assistant"||!t.streaming)return null;return t.toolCalls.find(s=>s.status==="running")?.label??null},[e.messages]);const q=(0,_ChangesBar.useLedgerEntries)(_askBuoyStore.askBuoyStore.getLedger());const _=(0,_react.useMemo)(()=>(0,_ruleStates.ruleStatesFrom)(q),[q]);const se=(0,_react.useMemo)(()=>({answer:x,runAction:(t,s)=>{if(t.minimize){l?.({mode:"bottomSheet"});return}return B(t,s)},answered:e.answers,actionState:e.actionState,busy:e.busy,supports:{openTool:false,minimize:!!l,dispatch:true},rules:_}),[x,B,l,e.answers,e.actionState,e.busy,_]);const ne=!e.busy&&n?.role==="assistant"&&!!n.error;const M=!e.busy&&n?.role==="assistant"&&n.stopped&&!n.error?n.id:null;const oe=(0,_askBuoyStore.queuePauseReason)(e);const{showThinking:P,readOnly:$}=(0,_useAskBuoySettings.useAskBuoySettings)();const ae=(0,_react.useCallback)(()=>(0,_MessageList.transcriptToText)(e.messages,P),[e.messages,P]);const re=(0,_react.useCallback)(()=>c(_ticketPrompt.TICKET_PROMPT),[c]);const ie=g?(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:Q}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"Settings",subtitle:"Ask Buoy",testID:"buoy-ask-buoy-settings-title"})]}):(0,_jsxRuntime.jsx)(_AskBuoyHeader.AskBuoyHeader,{configured:b,busy:e.busy,failed:ne,activeLabel:te,awaitingApproval:!!e.pending,startedAt:n?.role==="assistant"&&n.streaming?n.startedAt??null:null,stopping:e.stopping,readOnly:$,toolCount:O,hasMessages:e.messages.length>0,onBack:S,onReset:ee,getTranscript:ae,onOpenSettings:z,onTicket:re});return(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:f,onClose:V,disableScrollWrapper:true,background:false,initialHeight:560,animatedHeight:r,header:{customContent:ie,showToggleButton:false},onBack:S,onMinimize:l,onModeChange:J,persistenceKey:R??"buoy-ask-buoy",enablePersistence:true,children:(0,_jsxRuntime.jsx)(_blocks.BlockHandlersProvider,{value:se,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.root,{paddingBottom:X}],children:[(0,_jsxRuntime.jsx)(_ChangesBar.ChangesBar,{ledger:_askBuoyStore.askBuoyStore.getLedger(),onUndoAll:Y,expanded:N,onToggle:Z}),e.notice&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.notice,testID:"buoy-ask-buoy-notice",children:[(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:14,color:_sharedUi.night.color.info}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.noticeText,children:e.notice})]}),(0,_jsxRuntime.jsx)(_KeyboardPad.KeyboardPad,{children:(0,_jsxRuntime.jsx)(_sharedUi.FeatureGate,{featureName:"Ask Buoy",children:g?(0,_jsxRuntime.jsx)(_AskBuoySettings.AskBuoySettings,{}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_MessageList.MessageList,{messages:e.messages,onRetry:I,waitingOnUser:!!e.pending||!!e.awaitingBlockId,ListEmptyComponent:(0,_jsxRuntime.jsx)(_EmptyState.EmptyState,{configured:b,onPick:c,availableToolIds:D,readOnly:$||!!u?.policy?.readOnly})}),(0,_jsxRuntime.jsx)(_QueuedMessages.QueuedMessages,{items:e.queued,paused:oe,onEdit:L,onRemove:K}),e.pending&&(0,_jsxRuntime.jsx)(_ApprovalCard.ApprovalCard,{pending:e.pending,onAnswer:E}),(0,_jsxRuntime.jsx)(_Composer.Composer,{onSend:c,onStop:k,busy:e.busy,draft:e.draft,onDraftTaken:F,disabled:!b,focusKey:M,canFocus:f,placeholder:M?"Tell it what to do differently\u2026":e.awaitingBlockId?"Pick an option above, or type\u2026":void 0})]})})})]})})})}const styles=_reactNative.StyleSheet.create({root:{flex:1,backgroundColor:"transparent"},notice:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:_sharedUi.night.gutter,paddingVertical:10,backgroundColor:_sharedUi.night.color.infoSoft},noticeText:{flex:1,color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.caption,lineHeight:18}});
3
+ Still applied in the app. Clear the conversation anyway?`,[{text:"Keep conversation",style:"cancel"},{text:"Clear anyway",style:"destructive",onPress:d}])})()}},{text:"Clear anyway",style:"destructive",onPress:d},{text:"Cancel",style:"cancel"}])},[d,x]);const se=(0,_react.useMemo)(()=>{const t=e.messages[e.messages.length-1];if(!t||t.role!=="assistant"||!t.streaming)return null;return t.toolCalls.find(s=>s.status==="running")?.label??null},[e.messages]);const q=(0,_ChangesBar.useLedgerEntries)(_askBuoyStore.askBuoyStore.getLedger());const _=(0,_react.useMemo)(()=>(0,_ruleStates.ruleStatesFrom)(q),[q]);const oe=(0,_react.useMemo)(()=>({answer:A,runAction:(t,s)=>{if(t.minimize){u?.({mode:"bottomSheet"});return}return B(t,s)},answered:e.answers,actionState:e.actionState,busy:e.busy,supports:{openTool:false,minimize:!!u,dispatch:true},rules:_}),[A,B,u,e.answers,e.actionState,e.busy,_]);const ne=!e.busy&&o?.role==="assistant"&&!!o.error;const P=!e.busy&&o?.role==="assistant"&&o.stopped&&!o.error?o.id:null;const re=(0,_askBuoyStore.queuePauseReason)(e);const{showThinking:M,readOnly:H,hostedNoticeSeen:ae}=(0,_useAskBuoySettings.useAskBuoySettings)();const I=r?.hosted===true&&!ae;const ie=(0,_react.useCallback)(()=>(0,_MessageList.transcriptToText)(e.messages,M),[e.messages,M]);const le=(0,_react.useCallback)(()=>c(_ticketPrompt.TICKET_PROMPT),[c]);const ue=g?(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:Q}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"Settings",subtitle:"Ask Buoy",testID:"buoy-ask-buoy-settings-title"})]}):(0,_jsxRuntime.jsx)(_AskBuoyHeader.AskBuoyHeader,{configured:k,busy:e.busy,failed:ne,activeLabel:se,awaitingApproval:!!e.pending,startedAt:o?.role==="assistant"&&o.streaming?o.startedAt??null:null,stopping:e.stopping,readOnly:H,toolCount:D,hasMessages:e.messages.length>0,onBack:S,onReset:te,getTranscript:ie,onOpenSettings:W,onTicket:le});return(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:f,onClose:U,disableScrollWrapper:true,background:false,initialHeight:560,animatedHeight:i,header:{customContent:ue,showToggleButton:false},onBack:S,onMinimize:u,onModeChange:Y,persistenceKey:$??"buoy-ask-buoy",enablePersistence:true,children:(0,_jsxRuntime.jsx)(_blocks.BlockHandlersProvider,{value:oe,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.root,{paddingBottom:X}],children:[(0,_jsxRuntime.jsx)(_ChangesBar.ChangesBar,{ledger:_askBuoyStore.askBuoyStore.getLedger(),onUndoAll:Z,expanded:V,onToggle:ee}),I&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.notice,testID:"buoy-ask-buoy-hosted-notice",children:[(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:14,color:_sharedUi.night.color.info}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1,gap:8},children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.noticeText,children:"Hosted Ask Buoy (beta) sends your question, and the app data it needs to answer, to OpenAI through OpenRouter. Buoy keeps the cost of each answer, never the chat. Your plan includes monthly credits."}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:"buoy-ask-buoy-hosted-notice-ok",accessibilityRole:"button",onPress:()=>_askBuoySettings.askBuoySettings.set("hostedNoticeSeen",true),style:({pressed:t})=>[styles.noticeButton,t&&{opacity:.7}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.noticeButtonText,children:"Got it"})})]})]}),e.notice&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.notice,testID:"buoy-ask-buoy-notice",children:[(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:14,color:_sharedUi.night.color.info}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.noticeText,children:e.notice})]}),(0,_jsxRuntime.jsx)(_KeyboardPad.KeyboardPad,{children:(0,_jsxRuntime.jsx)(_sharedUi.FeatureGate,{featureName:"Ask Buoy",children:g?(0,_jsxRuntime.jsx)(_AskBuoySettings.AskBuoySettings,{}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_MessageList.MessageList,{messages:e.messages,onRetry:O,waitingOnUser:!!e.pending||!!e.awaitingBlockId,ListEmptyComponent:(0,_jsxRuntime.jsx)(_EmptyState.EmptyState,{configured:k,onPick:c,availableToolIds:K,readOnly:H||!!r?.policy?.readOnly})}),(0,_jsxRuntime.jsx)(_QueuedMessages.QueuedMessages,{items:e.queued,paused:re,onEdit:L,onRemove:N}),e.pending&&(0,_jsxRuntime.jsx)(_ApprovalCard.ApprovalCard,{pending:e.pending,onAnswer:E}),(0,_jsxRuntime.jsx)(_Composer.Composer,{onSend:c,onStop:h,busy:e.busy,draft:e.draft,onDraftTaken:F,disabled:!k||I,focusKey:P,canFocus:f,placeholder:P?"Tell it what to do differently\u2026":e.awaitingBlockId?"Pick an option above, or type\u2026":void 0})]})})})]})})})}const styles=_reactNative.StyleSheet.create({root:{flex:1,backgroundColor:"transparent"},notice:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:_sharedUi.night.gutter,paddingVertical:10,backgroundColor:_sharedUi.night.color.infoSoft},noticeText:{flex:1,color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.caption,lineHeight:18},noticeButton:{alignSelf:"flex-start",paddingHorizontal:12,paddingVertical:6,borderRadius:_sharedUi.night.radius.row,backgroundColor:_sharedUi.night.color.button},noticeButtonText:{color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.caption,fontWeight:"600"}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.AskBuoySettings=AskBuoySettings;var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _useAskBuoySettings=require("../store/useAskBuoySettings");var _askBuoySettings=require("../store/askBuoySettings");var _askBuoyStore=require("../store/askBuoyStore");var _useAskBuoy=require("../store/useAskBuoy");var _jsxRuntime=require("react/jsx-runtime");function AskBuoySettings(){const t=(0,_useAskBuoySettings.useAskBuoySettings)();const n=(0,_useAskBuoy.useAskBuoyState)().trusted;return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.scroll,contentContainerStyle:styles.content,testID:"buoy-ask-buoy-settings",children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.section,children:"CHAT"}),(0,_jsxRuntime.jsx)(_sharedUi.ToggleRow,{testID:"buoy-ask-buoy-setting-thinking",label:"Show agent thinking",description:"Adds a collapsed strip under each answer: the model's reasoning, and every step it ran with its parameters, result, duration and token cost. Copy includes the steps and reasoning while this is on, so you can read the run outside the app.",value:t.showThinking,onValueChange:e=>_askBuoySettings.askBuoySettings.set("showThinking",e)}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.note,children:"Not every model reports reasoning. Claude thinks by default; most OpenAI models return none, and the strip then shows the steps alone."}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.section,children:"PERMISSIONS"}),(0,_jsxRuntime.jsx)(_sharedUi.ToggleRow,{testID:"buoy-ask-buoy-setting-readonly",label:"Read only",description:"Inspect the app, change nothing. Every write and simulation is refused until this is off. Undo still works \u2014 putting things back is the safe direction.",value:t.readOnly,onValueChange:e=>_askBuoySettings.askBuoySettings.set("readOnly",e)}),t.readOnly?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.note,testID:"buoy-ask-buoy-readonly-note",children:"On across reloads until you turn it off here. The header says \u201CRead only\u201D while it is on. It adds to whatever this app already restricts \u2014 it never loosens anything."}):null,(0,_jsxRuntime.jsx)(_sharedUi.ToggleRow,{testID:"buoy-ask-buoy-setting-bypass",tone:"warning",emphasizeLabel:t.bypassApprovals,disabled:t.readOnly,label:"Skip approval prompts",description:t.readOnly?"Unavailable while Read only is on \u2014 nothing can be approved.":"Runs every action the moment the agent calls it, with no Allow card \u2014 including the destructive ones that wipe or reset data.",value:t.bypassApprovals,onValueChange:e=>_askBuoySettings.askBuoySettings.set("bypassApprovals",e)}),t.bypassApprovals&&!t.readOnly?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warning,testID:"buoy-ask-buoy-bypass-warning",children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:14,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningText,children:"Nothing will ask before a change lands. A wipe or a reset runs on the model's word alone, and Undo only reverses the changes that can be reversed \u2014 the bar tells you which. This stays on across reloads and app restarts until you turn it off here, so leave it off on any device holding data you care about. It does not widen what the agent may reach: read-only mode, this app's deny list and the release-build refusals still apply."})]}):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.note,children:"On by default for destructive actions only \u2014 reads and ordinary writes already run without asking, and the changes bar records them."}),n.length>0?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.trustedBox,testID:"buoy-ask-buoy-trusted",children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.section,children:"ALLOWED WITHOUT ASKING \u2014 THIS CHAT"}),n.map(e=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.trustedRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.trustedLabel,numberOfLines:2,children:e.label}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:`buoy-ask-buoy-untrust-${e.key}`,accessibilityRole:"button",onPress:()=>_askBuoyStore.askBuoyStore.untrust(e.key),style:({pressed:o})=>[styles.forget,o&&{opacity:.7}],hitSlop:6,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.forgetText,children:"Ask again"})})]},e.key))]}):null]})}const styles=_reactNative.StyleSheet.create({scroll:{flex:1},content:{padding:_sharedUi.night.gutter,gap:10,paddingBottom:32},section:{color:_sharedUi.night.color.textTertiary,fontSize:10,fontWeight:"700",letterSpacing:.6,paddingHorizontal:4,paddingTop:4},warning:{flexDirection:"row",gap:8,padding:_sharedUi.night.cardPad,borderRadius:_sharedUi.night.radius.card,borderWidth:_reactNative.StyleSheet.hairlineWidth,borderColor:_sharedUi.night.color.warning,backgroundColor:_sharedUi.night.color.surface},warningText:{flex:1,color:_sharedUi.night.color.warning,fontSize:_sharedUi.night.font.micro,lineHeight:16},trustedBox:{gap:6,paddingTop:6},trustedRow:{flexDirection:"row",alignItems:"center",gap:10,padding:_sharedUi.night.cardPad,borderRadius:_sharedUi.night.radius.card,borderWidth:_reactNative.StyleSheet.hairlineWidth,borderColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface},trustedLabel:{flex:1,color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.caption,lineHeight:18},forget:{paddingHorizontal:10,paddingVertical:6,borderRadius:_sharedUi.night.radius.row,backgroundColor:_sharedUi.night.color.button},forgetText:{color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.micro,fontWeight:"600"},note:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.micro,lineHeight:16,paddingHorizontal:4}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.AskBuoySettings=AskBuoySettings;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _useAskBuoySettings=require("../store/useAskBuoySettings");var _askBuoySettings=require("../store/askBuoySettings");var _askBuoyStore=require("../store/askBuoyStore");var _useAskBuoy=require("../store/useAskBuoy");var _jsxRuntime=require("react/jsx-runtime");function AskBuoySettings(){const e=(0,_useAskBuoySettings.useAskBuoySettings)();const s=(0,_useAskBuoy.useAskBuoyState)().trusted;return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.scroll,contentContainerStyle:styles.content,testID:"buoy-ask-buoy-settings",children:[(0,_jsxRuntime.jsx)(HostedCredits,{}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.section,children:"CHAT"}),(0,_jsxRuntime.jsx)(_sharedUi.ToggleRow,{testID:"buoy-ask-buoy-setting-thinking",label:"Show agent thinking",description:"Adds a collapsed strip under each answer: the model's reasoning, and every step it ran with its parameters, result, duration and token cost. Copy includes the steps and reasoning while this is on, so you can read the run outside the app.",value:e.showThinking,onValueChange:t=>_askBuoySettings.askBuoySettings.set("showThinking",t)}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.note,children:"Not every model reports reasoning. Claude thinks by default; most OpenAI models return none, and the strip then shows the steps alone."}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.section,children:"PERMISSIONS"}),(0,_jsxRuntime.jsx)(_sharedUi.ToggleRow,{testID:"buoy-ask-buoy-setting-readonly",label:"Read only",description:"Inspect the app, change nothing. Every write and simulation is refused until this is off. Undo still works \u2014 putting things back is the safe direction.",value:e.readOnly,onValueChange:t=>_askBuoySettings.askBuoySettings.set("readOnly",t)}),e.readOnly?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.note,testID:"buoy-ask-buoy-readonly-note",children:"On across reloads until you turn it off here. The header says \u201CRead only\u201D while it is on. It adds to whatever this app already restricts \u2014 it never loosens anything."}):null,(0,_jsxRuntime.jsx)(_sharedUi.ToggleRow,{testID:"buoy-ask-buoy-setting-bypass",tone:"warning",emphasizeLabel:e.bypassApprovals,disabled:e.readOnly,label:"Skip approval prompts",description:e.readOnly?"Unavailable while Read only is on \u2014 nothing can be approved.":"Runs every action the moment the agent calls it, with no Allow card \u2014 including the destructive ones that wipe or reset data.",value:e.bypassApprovals,onValueChange:t=>_askBuoySettings.askBuoySettings.set("bypassApprovals",t)}),e.bypassApprovals&&!e.readOnly?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warning,testID:"buoy-ask-buoy-bypass-warning",children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:14,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningText,children:"Nothing will ask before a change lands. A wipe or a reset runs on the model's word alone, and Undo only reverses the changes that can be reversed \u2014 the bar tells you which. This stays on across reloads and app restarts until you turn it off here, so leave it off on any device holding data you care about. It does not widen what the agent may reach: read-only mode, this app's deny list and the release-build refusals still apply."})]}):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.note,children:"On by default for destructive actions only \u2014 reads and ordinary writes already run without asking, and the changes bar records them."}),s.length>0?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.trustedBox,testID:"buoy-ask-buoy-trusted",children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.section,children:"ALLOWED WITHOUT ASKING \u2014 THIS CHAT"}),s.map(t=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.trustedRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.trustedLabel,numberOfLines:2,children:t.label}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:`buoy-ask-buoy-untrust-${t.key}`,accessibilityRole:"button",onPress:()=>_askBuoyStore.askBuoyStore.untrust(t.key),style:({pressed:n})=>[styles.forget,n&&{opacity:.7}],hitSlop:6,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.forgetText,children:"Ask again"})})]},t.key))]}):null]})}function formatReset(e){const s=Date.parse(e.length===10?`${e}T00:00:00Z`:e);if(Number.isNaN(s))return e;const t=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];const n=new Date(s);return`${t[n.getUTCMonth()]} ${n.getUTCDate()}`}function HostedCredits(){const e=_askBuoyStore.askBuoyStore.getUsageReader();const[s,t]=(0,_react.useState)({kind:"loading"});const n=(0,_react.useCallback)(()=>{if(!e)return;t({kind:"loading"});e().then(r=>t({kind:"ok",usage:r})).catch(r=>t({kind:"error",message:r instanceof Error?r.message:"Could not load credits."}))},[e]);(0,_react.useEffect)(n,[n]);if(!e)return null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:"buoy-ask-buoy-credits",children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.section,children:"HOSTED AI CREDITS"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.trustedRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flex:1,gap:2},children:s.kind==="ok"?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.trustedLabel,children:[s.usage.creditsLeft.toLocaleString()," of ",s.usage.grantCredits.toLocaleString()," credits left"]}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.note,children:[s.usage.resetAt?`Resets ${formatReset(s.usage.resetAt)}. `:"","1 credit is $0.001 of AI use, included with your plan."]})]}):s.kind==="error"?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.note,children:s.message}):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.note,children:"Loading\u2026"})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:"buoy-ask-buoy-credits-refresh",accessibilityRole:"button",onPress:n,style:({pressed:r})=>[styles.forget,r&&{opacity:.7}],hitSlop:6,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.forgetText,children:"Refresh"})})]})]})}const styles=_reactNative.StyleSheet.create({scroll:{flex:1},content:{padding:_sharedUi.night.gutter,gap:10,paddingBottom:32},section:{color:_sharedUi.night.color.textTertiary,fontSize:10,fontWeight:"700",letterSpacing:.6,paddingHorizontal:4,paddingTop:4},warning:{flexDirection:"row",gap:8,padding:_sharedUi.night.cardPad,borderRadius:_sharedUi.night.radius.card,borderWidth:_reactNative.StyleSheet.hairlineWidth,borderColor:_sharedUi.night.color.warning,backgroundColor:_sharedUi.night.color.surface},warningText:{flex:1,color:_sharedUi.night.color.warning,fontSize:_sharedUi.night.font.micro,lineHeight:16},trustedBox:{gap:6,paddingTop:6},trustedRow:{flexDirection:"row",alignItems:"center",gap:10,padding:_sharedUi.night.cardPad,borderRadius:_sharedUi.night.radius.card,borderWidth:_reactNative.StyleSheet.hairlineWidth,borderColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface},trustedLabel:{flex:1,color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.caption,lineHeight:18},forget:{paddingHorizontal:10,paddingVertical:6,borderRadius:_sharedUi.night.radius.row,backgroundColor:_sharedUi.night.color.button},forgetText:{color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.micro,fontWeight:"600"},note:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.micro,lineHeight:16,paddingHorizontal:4}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.MessageList=MessageList;exports.transcriptToText=transcriptToText;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _agentCore=require("@buoy-gg/agent-core");var _BlockRenderer=require("../blocks/BlockRenderer");var _blockText=require("../blocks/blockText");var _activityGroups=require("../store/activityGroups");var _blockPlacement=require("../store/blockPlacement");var _askBuoyStore=require("../store/askBuoyStore");var _Markdown=require("./Markdown");var _ThinkingStrip=require("./ThinkingStrip");var _TypingDots=require("./TypingDots");var _useCopyAction=require("./useCopyAction");var _traceText=require("../store/traceText");var _useAskBuoySettings=require("../store/useAskBuoySettings");var _jsxRuntime=require("react/jsx-runtime");function StatusMark({status:t}){switch(t){case"running":return(0,_jsxRuntime.jsx)(_reactNative.ActivityIndicator,{size:"small",color:_sharedUi.night.color.textSecondary});case"ok":return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.mark,styles.markOk],children:(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:10,color:_sharedUi.night.color.onAccent})});case"failed":return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.mark,styles.markFailed],children:(0,_jsxRuntime.jsx)(_sharedUi.X,{size:10,color:_sharedUi.night.color.text})});case"refused":return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.mark,styles.markRefused],children:(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:10,color:_sharedUi.night.color.onAccent})});case"declined":case"stopped":return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.mark,styles.markNotRun],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.markNotRunBar})})}}function statusText(t){if(t.status==="running")return{text:"",tone:"muted"};if(t.status==="refused")return{text:"Refused",tone:"warning"};if(t.status==="failed")return{text:"Failed",tone:"danger"};if(t.status==="declined")return{text:"You declined",tone:"muted"};if(t.status==="stopped")return{text:"Not run \u2014 stopped",tone:"muted"};if(t.verification?.status==="verified")return{text:"Verified",tone:"ok"};if(t.verification?.status==="unverified")return{text:"Done \xB7 not yet visible",tone:"muted"};if(t.verification?.status==="failed")return{text:"Done \xB7 check failed",tone:"warning"};return{text:t.summary||"Done",tone:"muted"}}const isExceptional=t=>t.status==="failed"||t.status==="refused"||t.status==="declined"||t.status==="stopped";function ActivityRow({call:t,receipts:r,last:o}){const[e,n]=(0,_react.useState)(false);const i=statusText(t);const l=e?_sharedUi.ChevronDown:_sharedUi.ChevronRight;const c=t.status==="failed"&&t.summary&&t.summary!=="Failed"?t.summary:null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.row,!o&&styles.rowDivider],children:[(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{testID:`buoy-ask-buoy-tool-${t.toolId}`,accessibilityRole:"button",accessibilityLabel:`${t.label}, ${i.text||"running"}`,accessibilityState:{expanded:e},onPress:()=>n(s=>!s),children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowLine,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.markSlot,children:(0,_jsxRuntime.jsx)(StatusMark,{status:t.status})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowTitle,children:t.label}),i.text?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.rowStatus,i.tone==="danger"&&styles.rowStatusDanger,i.tone==="warning"&&styles.rowStatusWarning,i.tone==="ok"&&styles.rowStatusOk],numberOfLines:1,children:i.text}):null,(0,_jsxRuntime.jsx)(l,{size:12,color:_sharedUi.night.color.textTertiary})]}),e&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowDetail,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowTool,children:(0,_agentCore.toolTitle)(t.toolId).toUpperCase()}),t.description?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowDescription,children:t.description}):null,c?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowFailure,children:c}):null,t.verification?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.rowDescription,t.verification.status==="failed"&&styles.rowFailure,t.verification.status==="verified"&&styles.rowVerified],testID:`buoy-ask-buoy-verification-${t.verification.status}`,children:t.verification.detail}):null]})]}),e&&r.length>0&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowReceipts,testID:`buoy-ask-buoy-tool-receipt-${t.toolId}`,children:r.map(s=>(0,_jsxRuntime.jsx)(_BlockRenderer.BlockRenderer,{block:s},s.id))})]})}function ReadsGroup({label:t,count:r,calls:o,receipts:e,last:n}){const[i,l]=(0,_react.useState)(false);const c=i?_sharedUi.ChevronDown:_sharedUi.ChevronRight;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:!n&&!i&&styles.rowDivider,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:"buoy-ask-buoy-reads-group",accessibilityRole:"button",accessibilityLabel:`${t}, ${r} reads`,accessibilityState:{expanded:i},onPress:()=>l(s=>!s),style:[styles.row,i&&styles.rowDivider],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowLine,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.markSlot,children:(0,_jsxRuntime.jsx)(StatusMark,{status:"ok"})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowTitle,children:t}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.rowStatus,numberOfLines:1,children:[r," reads"]}),(0,_jsxRuntime.jsx)(c,{size:12,color:_sharedUi.night.color.textTertiary})]})}),i&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.groupBody,children:o.map((s,d)=>(0,_jsxRuntime.jsx)(ActivityRow,{call:s,receipts:e.get(s.id)??[],last:n&&d===o.length-1},s.id))})]})}function ActivityCard({calls:t,receipts:r}){const o=(0,_activityGroups.groupCalls)(t);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.card,testID:"buoy-ask-buoy-activity",children:o.map((e,n)=>e.kind==="reads"?(0,_jsxRuntime.jsx)(ReadsGroup,{label:e.label,count:e.count,calls:e.calls,receipts:r,last:n===o.length-1},e.id):(0,_jsxRuntime.jsx)(ActivityRow,{call:e.call,receipts:r.get(e.call.id)??[],last:n===o.length-1},e.call.id))})}function Blocks({blocks:t}){if(t.length===0)return null;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.blocks,children:t.map(({block:r})=>(0,_jsxRuntime.jsx)(_BlockRenderer.BlockRenderer,{block:r},r.id))})}function SystemLine({message:t}){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.systemLine,testID:"buoy-ask-buoy-system-line",children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.systemText,children:t.text})})}function UserMessage({message:t}){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.userWrap,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.userBubble,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.userText,selectable:true,children:t.text})})})}function AssistantMessage({message:t,onRetry:r,waitingOnUser:o}){const{showThinking:e}=(0,_useAskBuoySettings.useAskBuoySettings)();const n=!!t.streaming&&!o;const{nested:i,afterText:l,ask:c}=(0,_blockPlacement.placeBlocks)(t.blocks,t.toolCalls.map(s=>s.id));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.assistantWrap,children:[t.toolCalls.length>0&&(0,_jsxRuntime.jsx)(ActivityCard,{calls:t.toolCalls,receipts:i}),t.text.length>0&&(0,_jsxRuntime.jsx)(_Markdown.Markdown,{text:t.text,style:styles.assistantText}),(0,_jsxRuntime.jsx)(Blocks,{blocks:l}),(0,_jsxRuntime.jsx)(Blocks,{blocks:c}),e&&!t.streaming&&(0,_jsxRuntime.jsx)(_ThinkingStrip.ThinkingStrip,{message:t}),n&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.waitingRow,children:[(0,_jsxRuntime.jsx)(_TypingDots.TypingDots,{}),t.waiting?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.waitingText,testID:"buoy-ask-buoy-waiting",children:t.waiting}):null]}),t.error&&(0,_jsxRuntime.jsx)(ErrorNote,{error:t.error,onRetry:r}),t.stopped&&!t.error&&(0,_jsxRuntime.jsx)(StoppedNote,{onRetry:r,changed:t.toolCalls.some(s=>s.status==="ok"&&!!s.effect&&s.effect!=="read")})]})}function StoppedNote({onRetry:t,changed:r}){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.stoppedBox,testID:"buoy-ask-buoy-stopped",children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.stoppedText,children:r?"Stopped. Changes already made are listed above.":"Stopped."}),t&&(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:t,style:({pressed:o})=>[styles.retry,o&&styles.retryPressed],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.retryText,children:"Try again"})})]})}function ErrorNote({error:t,onRetry:r}){const o=/fetch failed|network|ECONN|timed? ?out|socket/i.test(t);const e=o?"Couldn't reach your AI endpoint. Check the connection and try again.":"Something went wrong with that turn.";return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.errorBox,testID:"buoy-ask-buoy-error",children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:14,color:_sharedUi.night.color.danger}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.errorBody,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.errorText,children:e}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.errorDetail,selectable:true,children:t}),r&&(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:r,style:({pressed:n})=>[styles.retry,n&&styles.retryPressed],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.retryText,children:"Try again"})})]})]})}function transcriptToText(t,r=false){const o=[];for(const e of t){if(e.role==="user"){o.push(`You: ${e.text}`);continue}if(e.system){o.push(` \u2014 ${e.text}`);continue}if(r){o.push(...(0,_traceText.traceToText)(e))}else{for(const n of e.toolCalls){const i=isExceptional(n)?` (${n.status})`:"";o.push(` \xB7 ${n.label}${n.summary?` \u2014 ${n.summary}`:""}${i}`)}}if(e.text)o.push(`Ask Buoy: ${e.text}`);for(const n of(0,_blockText.blocksToText)(e.blocks.map(i=>i.block)))o.push(n);if(e.error)o.push(` ! ${e.error}`);if(e.stopped&&!e.error)o.push(" ! Stopped by the user.")}return o.join("\n")}function CopyPill({testID:t,label:r,getText:o}){const{copied:e,copy:n}=(0,_useCopyAction.useCopyAction)(o);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{testID:t,accessibilityRole:"button",accessibilityLabel:r,onPress:n,style:({pressed:i})=>[styles.copyBtn,styles.iconBtn,i&&styles.copyPressed],children:[e?(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:11,color:_sharedUi.night.color.accent}):(0,_jsxRuntime.jsx)(_sharedUi.Copy,{size:11,color:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.copyText,e&&styles.copiedText],children:e?"Copied":r})]})}function TranscriptActions({message:t}){const{showThinking:r}=(0,_useAskBuoySettings.useAskBuoySettings)();const o=(0,_react.useCallback)(()=>transcriptToText(_askBuoyStore.askBuoyStore.getState().messages,r),[r]);const e=(0,_activityGroups.turnFooter)(t);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.transcriptActions,children:[e?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.turnFooter,testID:"buoy-ask-buoy-turn-footer",children:e}):null,(0,_jsxRuntime.jsx)(CopyPill,{testID:"buoy-ask-buoy-copy",label:"Copy conversation",getText:o})]})}const Row=(0,_react.memo)(function t({message:r,onRetry:o,waitingOnUser:e}){if(r.role==="user")return(0,_jsxRuntime.jsx)(UserMessage,{message:r});if(r.system)return(0,_jsxRuntime.jsx)(SystemLine,{message:r});const n=!r.streaming&&!r.error;return(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(AssistantMessage,{message:r,onRetry:o,waitingOnUser:e}),n&&(0,_jsxRuntime.jsx)(TranscriptActions,{message:r})]})});function MessageList({messages:t,ListHeaderComponent:r,ListEmptyComponent:o,ListFooterComponent:e,onRetry:n,waitingOnUser:i}){const l=(0,_react.useRef)(null);const c=(0,_react.useRef)(true);const s=(0,_react.useRef)(false);const d=(0,_react.useCallback)(a=>{const{contentOffset:f,contentSize:b,layoutMeasurement:w}=a.nativeEvent;const k=b.height-w.height-f.y;c.current=k<80},[]);const h=(0,_react.useCallback)(()=>{s.current=true},[]);const x=(0,_react.useCallback)(a=>{if(s.current)d(a)},[d]);const y=(0,_react.useCallback)(a=>{s.current=false;d(a)},[d]);const g=(0,_react.useCallback)(()=>{if(!c.current)return;l.current?.scrollToEnd({animated:false});requestAnimationFrame(()=>l.current?.scrollToEnd({animated:false}))},[]);const u=t[t.length-1];const p=u?`${u.id}:${u.text.length}:${u.toolCalls.length}:${u.error??""}`:"";(0,_react.useEffect)(()=>{g()},[p,g]);return(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:l,testID:"buoy-ask-buoy-messages-scroll",style:styles.list,contentContainerStyle:styles.listContent,data:t,keyExtractor:a=>a.id,renderItem:({item:a})=>(0,_jsxRuntime.jsx)(Row,{message:a,onRetry:a.id===u?.id?n:void 0,waitingOnUser:a.id===u?.id?i:false}),onScroll:x,onScrollBeginDrag:h,onScrollEndDrag:y,onMomentumScrollEnd:d,scrollEventThrottle:32,onContentSizeChange:g,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"interactive",ListHeaderComponent:r,ListEmptyComponent:o,ListFooterComponent:e})}const styles=_reactNative.StyleSheet.create({list:{flex:1,backgroundColor:"transparent"},listContent:{paddingHorizontal:_sharedUi.night.gutter,paddingTop:12,paddingBottom:16,gap:16,flexGrow:1},userWrap:{alignItems:"flex-end"},userBubble:{maxWidth:"84%",paddingHorizontal:14,paddingVertical:9,borderRadius:18,borderBottomRightRadius:6,backgroundColor:_sharedUi.night.color.accentFill,borderWidth:_reactNative.StyleSheet.hairlineWidth,borderColor:_sharedUi.night.color.accentBorder},userText:{color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.row,lineHeight:21},systemLine:{alignSelf:"stretch",paddingHorizontal:12,paddingVertical:7,borderRadius:_sharedUi.night.radius.row,backgroundColor:_sharedUi.night.color.fill},systemText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,lineHeight:16,textAlign:"center"},assistantWrap:{alignItems:"stretch",gap:10},blocks:{gap:10},waitingRow:{flexDirection:"row",alignItems:"center",gap:8},waitingText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.caption},assistantText:{color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.row,lineHeight:22,paddingHorizontal:2},card:{borderRadius:_sharedUi.night.radius.card,borderWidth:_reactNative.StyleSheet.hairlineWidth,borderColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface,overflow:"hidden"},row:{paddingHorizontal:12,paddingVertical:10},rowDivider:{borderBottomWidth:_reactNative.StyleSheet.hairlineWidth,borderBottomColor:_sharedUi.night.color.separator},rowLine:{flexDirection:"row",alignItems:"center",gap:10},markSlot:{width:18,height:18,alignItems:"center",justifyContent:"center"},mark:{width:16,height:16,borderRadius:8,alignItems:"center",justifyContent:"center"},markOk:{backgroundColor:_sharedUi.night.color.accent},markFailed:{backgroundColor:_sharedUi.night.color.danger},markRefused:{backgroundColor:_sharedUi.night.color.warning},markNotRun:{borderWidth:1.5,borderColor:_sharedUi.night.color.textTertiary},markNotRunBar:{width:7,height:1.5,borderRadius:1,backgroundColor:_sharedUi.night.color.textSecondary},rowTitle:{flex:1,color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.body,lineHeight:19},rowStatus:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption,maxWidth:120},rowStatusDanger:{color:_sharedUi.night.color.danger},rowStatusWarning:{color:_sharedUi.night.color.warning},rowStatusOk:{color:_sharedUi.night.color.accent},rowVerified:{color:_sharedUi.night.color.accent},rowDetail:{paddingLeft:28,paddingTop:8,gap:4},rowTool:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.micro,fontWeight:"600",letterSpacing:.8},rowDescription:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.caption,lineHeight:18},rowFailure:{color:_sharedUi.night.color.danger,fontSize:_sharedUi.night.font.caption,lineHeight:18},rowReceipts:{paddingTop:10,gap:10},groupBody:{paddingLeft:14,backgroundColor:_sharedUi.night.color.fill},stoppedBox:{alignItems:"flex-start",gap:2,paddingHorizontal:12,paddingVertical:8},stoppedText:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption,lineHeight:18},errorBox:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingVertical:10,borderRadius:_sharedUi.night.radius.row,backgroundColor:_sharedUi.night.color.dangerSoft},errorBody:{flex:1,gap:4},errorText:{color:_sharedUi.night.color.danger,fontSize:_sharedUi.night.font.caption,fontWeight:"600",lineHeight:18},errorDetail:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,lineHeight:15},retry:{alignSelf:"flex-start",marginTop:6,paddingHorizontal:14,paddingVertical:7,borderRadius:_sharedUi.night.radius.row,backgroundColor:_sharedUi.night.color.button},retryPressed:{opacity:.7},retryText:{color:_sharedUi.night.color.accent,fontSize:_sharedUi.night.font.caption,fontWeight:"600"},transcriptActions:{flexDirection:"row",alignItems:"center",gap:10,marginTop:8},turnFooter:{flex:1,color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.micro,fontVariant:["tabular-nums"]},copyBtn:{paddingHorizontal:10,paddingVertical:5,borderRadius:_sharedUi.night.radius.badge,backgroundColor:_sharedUi.night.color.fill},iconBtn:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8},copyPressed:{opacity:.7},copyText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,fontWeight:"600"},copiedText:{color:_sharedUi.night.color.accent}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.MessageList=MessageList;exports.transcriptToText=transcriptToText;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _agentCore=require("@buoy-gg/agent-core");var _BlockRenderer=require("../blocks/BlockRenderer");var _blockText=require("../blocks/blockText");var _activityGroups=require("../store/activityGroups");var _blockPlacement=require("../store/blockPlacement");var _askBuoyStore=require("../store/askBuoyStore");var _Markdown=require("./Markdown");var _ThinkingStrip=require("./ThinkingStrip");var _TypingDots=require("./TypingDots");var _useCopyAction=require("./useCopyAction");var _traceText=require("../store/traceText");var _useAskBuoySettings=require("../store/useAskBuoySettings");var _jsxRuntime=require("react/jsx-runtime");function StatusMark({status:e}){switch(e){case"running":return(0,_jsxRuntime.jsx)(_reactNative.ActivityIndicator,{size:"small",color:_sharedUi.night.color.textSecondary});case"ok":return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.mark,styles.markOk],children:(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:10,color:_sharedUi.night.color.onAccent})});case"failed":return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.mark,styles.markFailed],children:(0,_jsxRuntime.jsx)(_sharedUi.X,{size:10,color:_sharedUi.night.color.text})});case"refused":return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.mark,styles.markRefused],children:(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:10,color:_sharedUi.night.color.onAccent})});case"declined":case"stopped":return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.mark,styles.markNotRun],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.markNotRunBar})})}}function statusText(e){if(e.status==="running")return{text:"",tone:"muted"};if(e.status==="refused")return{text:"Refused",tone:"warning"};if(e.status==="failed")return{text:"Failed",tone:"danger"};if(e.status==="declined")return{text:"You declined",tone:"muted"};if(e.status==="stopped")return{text:"Not run \u2014 stopped",tone:"muted"};if(e.verification?.status==="verified")return{text:"Verified",tone:"ok"};if(e.verification?.status==="unverified")return{text:"Done \xB7 not yet visible",tone:"muted"};if(e.verification?.status==="failed")return{text:"Done \xB7 check failed",tone:"warning"};return{text:e.summary||"Done",tone:"muted"}}const isExceptional=e=>e.status==="failed"||e.status==="refused"||e.status==="declined"||e.status==="stopped";function ActivityRow({call:e,receipts:t,last:o}){const[r,i]=(0,_react.useState)(false);const s=statusText(e);const l=r?_sharedUi.ChevronDown:_sharedUi.ChevronRight;const a=e.status==="failed"&&e.summary&&e.summary!=="Failed"?e.summary:null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.row,!o&&styles.rowDivider],children:[(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{testID:`buoy-ask-buoy-tool-${e.toolId}`,accessibilityRole:"button",accessibilityLabel:`${e.label}, ${s.text||"running"}`,accessibilityState:{expanded:r},onPress:()=>i(n=>!n),children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowLine,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.markSlot,children:(0,_jsxRuntime.jsx)(StatusMark,{status:e.status})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowTitle,children:e.label}),s.text?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.rowStatus,s.tone==="danger"&&styles.rowStatusDanger,s.tone==="warning"&&styles.rowStatusWarning,s.tone==="ok"&&styles.rowStatusOk],numberOfLines:1,children:s.text}):null,(0,_jsxRuntime.jsx)(l,{size:12,color:_sharedUi.night.color.textTertiary})]}),r&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowDetail,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowTool,children:(0,_agentCore.toolTitle)(e.toolId).toUpperCase()}),e.description?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowDescription,children:e.description}):null,a?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowFailure,children:a}):null,e.verification?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.rowDescription,e.verification.status==="failed"&&styles.rowFailure,e.verification.status==="verified"&&styles.rowVerified],testID:`buoy-ask-buoy-verification-${e.verification.status}`,children:e.verification.detail}):null]})]}),r&&t.length>0&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowReceipts,testID:`buoy-ask-buoy-tool-receipt-${e.toolId}`,children:t.map(n=>(0,_jsxRuntime.jsx)(_BlockRenderer.BlockRenderer,{block:n},n.id))})]})}function ReadsGroup({label:e,count:t,calls:o,receipts:r,last:i}){const[s,l]=(0,_react.useState)(false);const a=s?_sharedUi.ChevronDown:_sharedUi.ChevronRight;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:!i&&!s&&styles.rowDivider,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:"buoy-ask-buoy-reads-group",accessibilityRole:"button",accessibilityLabel:`${e}, ${t} reads`,accessibilityState:{expanded:s},onPress:()=>l(n=>!n),style:[styles.row,s&&styles.rowDivider],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowLine,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.markSlot,children:(0,_jsxRuntime.jsx)(StatusMark,{status:"ok"})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowTitle,children:e}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.rowStatus,numberOfLines:1,children:[t," reads"]}),(0,_jsxRuntime.jsx)(a,{size:12,color:_sharedUi.night.color.textTertiary})]})}),s&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.groupBody,children:o.map((n,d)=>(0,_jsxRuntime.jsx)(ActivityRow,{call:n,receipts:r.get(n.id)??[],last:i&&d===o.length-1},n.id))})]})}function ActivityCard({calls:e,receipts:t}){const o=(0,_activityGroups.groupCalls)(e);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.card,testID:"buoy-ask-buoy-activity",children:o.map((r,i)=>r.kind==="reads"?(0,_jsxRuntime.jsx)(ReadsGroup,{label:r.label,count:r.count,calls:r.calls,receipts:t,last:i===o.length-1},r.id):(0,_jsxRuntime.jsx)(ActivityRow,{call:r.call,receipts:t.get(r.call.id)??[],last:i===o.length-1},r.call.id))})}function Blocks({blocks:e}){if(e.length===0)return null;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.blocks,children:e.map(({block:t})=>(0,_jsxRuntime.jsx)(_BlockRenderer.BlockRenderer,{block:t},t.id))})}function SystemLine({message:e}){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.systemLine,testID:"buoy-ask-buoy-system-line",children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.systemText,children:e.text})})}function UserMessage({message:e}){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.userWrap,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.userBubble,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.userText,selectable:true,children:e.text})})})}function AssistantMessage({message:e,onRetry:t,waitingOnUser:o}){const{showThinking:r}=(0,_useAskBuoySettings.useAskBuoySettings)();const i=!!e.streaming&&!o;const{nested:s,afterText:l,ask:a}=(0,_blockPlacement.placeBlocks)(e.blocks,e.toolCalls.map(n=>n.id));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.assistantWrap,children:[e.toolCalls.length>0&&(0,_jsxRuntime.jsx)(ActivityCard,{calls:e.toolCalls,receipts:s}),e.text.length>0&&(0,_jsxRuntime.jsx)(_Markdown.Markdown,{text:e.text,style:styles.assistantText}),(0,_jsxRuntime.jsx)(Blocks,{blocks:l}),(0,_jsxRuntime.jsx)(Blocks,{blocks:a}),r&&!e.streaming&&(0,_jsxRuntime.jsx)(_ThinkingStrip.ThinkingStrip,{message:e}),i&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.waitingRow,children:[(0,_jsxRuntime.jsx)(_TypingDots.TypingDots,{}),e.waiting?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.waitingText,testID:"buoy-ask-buoy-waiting",children:e.waiting}):null]}),e.error&&(e.errorInfo?(0,_jsxRuntime.jsx)(HostedErrorNote,{error:e.error,info:e.errorInfo,onRetry:t}):(0,_jsxRuntime.jsx)(ErrorNote,{error:e.error,onRetry:t})),e.stopped&&!e.error&&(0,_jsxRuntime.jsx)(StoppedNote,{onRetry:t,changed:e.toolCalls.some(n=>n.status==="ok"&&!!n.effect&&n.effect!=="read")})]})}function StoppedNote({onRetry:e,changed:t}){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.stoppedBox,testID:"buoy-ask-buoy-stopped",children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.stoppedText,children:t?"Stopped. Changes already made are listed above.":"Stopped."}),e&&(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:e,style:({pressed:o})=>[styles.retry,o&&styles.retryPressed],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.retryText,children:"Try again"})})]})}function ErrorNote({error:e,onRetry:t}){const o=/fetch failed|network|ECONN|timed? ?out|socket/i.test(e);const r=o?"Couldn't reach your AI endpoint. Check the connection and try again.":"Something went wrong with that turn.";return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.errorBox,testID:"buoy-ask-buoy-error",children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:14,color:_sharedUi.night.color.danger}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.errorBody,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.errorText,children:r}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.errorDetail,selectable:true,children:e}),t&&(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:t,style:({pressed:i})=>[styles.retry,i&&styles.retryPressed],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.retryText,children:"Try again"})})]})]})}const NO_RETRY=new Set(["credits_out","member_cap","plan_not_eligible","not_in_pilot","team_hosted_off","account_frozen","token_not_allowed","client_too_old","media_not_allowed","session_missing","session_revoked"]);function HostedErrorNote({error:e,info:t,onRetry:o}){const[r,i]=(0,_react.useState)("idle");const s=`Ask Buoy error ${t.code}${t.requestId?` \xB7 request ${t.requestId}`:""} \xB7 ${new Date().toISOString()}`;const{copied:l,copy:a}=(0,_useCopyAction.useCopyAction)(()=>s);const n=_askBuoyStore.askBuoyStore.getReporter();const d=(0,_react.useCallback)(()=>{if(!n)return;i("sending");n({requestId:t.requestId,code:t.code,note:"Reported from the error card."}).then(u=>i({id:u.reportId})).catch(()=>i("failed"))},[n,t.code,t.requestId]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.errorBox,testID:"buoy-ask-buoy-error",children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:14,color:_sharedUi.night.color.danger}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.errorBody,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.errorText,children:e}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.errorDetail,selectable:true,testID:"buoy-ask-buoy-error-code",children:[t.code,t.requestId?` \xB7 ${t.requestId}`:""]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.transcriptActions,children:[o&&!NO_RETRY.has(t.code)&&(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:o,style:({pressed:u})=>[styles.retry,u&&styles.retryPressed],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.retryText,children:"Try again"})}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:"buoy-ask-buoy-error-copy",accessibilityRole:"button",accessibilityLabel:"Copy details",onPress:a,style:({pressed:u})=>[styles.retry,u&&styles.retryPressed],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.retryText,children:l?"Copied":"Copy details"})}),n&&(0,_jsxRuntime.jsx)(_reactNative.Pressable,{testID:"buoy-ask-buoy-error-report",accessibilityRole:"button",accessibilityLabel:"Report problem",disabled:r!=="idle"&&r!=="failed",onPress:d,style:({pressed:u})=>[styles.retry,u&&styles.retryPressed],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.retryText,children:r==="sending"?"Sending\u2026":r==="failed"?"Report failed. Try again":typeof r==="object"?`Reported \xB7 ${r.id}`:"Report problem"})})]})]})]})}function transcriptToText(e,t=false){const o=[];for(const r of e){if(r.role==="user"){o.push(`You: ${r.text}`);continue}if(r.system){o.push(` \u2014 ${r.text}`);continue}if(t){o.push(...(0,_traceText.traceToText)(r))}else{for(const i of r.toolCalls){const s=isExceptional(i)?` (${i.status})`:"";o.push(` \xB7 ${i.label}${i.summary?` \u2014 ${i.summary}`:""}${s}`)}}if(r.text)o.push(`Ask Buoy: ${r.text}`);for(const i of(0,_blockText.blocksToText)(r.blocks.map(s=>s.block)))o.push(i);if(r.error)o.push(` ! ${r.error}`);if(r.stopped&&!r.error)o.push(" ! Stopped by the user.")}return o.join("\n")}function CopyPill({testID:e,label:t,getText:o}){const{copied:r,copy:i}=(0,_useCopyAction.useCopyAction)(o);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{testID:e,accessibilityRole:"button",accessibilityLabel:t,onPress:i,style:({pressed:s})=>[styles.copyBtn,styles.iconBtn,s&&styles.copyPressed],children:[r?(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:11,color:_sharedUi.night.color.accent}):(0,_jsxRuntime.jsx)(_sharedUi.Copy,{size:11,color:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.copyText,r&&styles.copiedText],children:r?"Copied":t})]})}function TranscriptActions({message:e}){const{showThinking:t}=(0,_useAskBuoySettings.useAskBuoySettings)();const o=(0,_react.useCallback)(()=>transcriptToText(_askBuoyStore.askBuoyStore.getState().messages,t),[t]);const r=(0,_activityGroups.turnFooter)(e);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.transcriptActions,children:[r?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.turnFooter,testID:"buoy-ask-buoy-turn-footer",children:r}):null,(0,_jsxRuntime.jsx)(CopyPill,{testID:"buoy-ask-buoy-copy",label:"Copy conversation",getText:o})]})}const Row=(0,_react.memo)(function e({message:t,onRetry:o,waitingOnUser:r}){if(t.role==="user")return(0,_jsxRuntime.jsx)(UserMessage,{message:t});if(t.system)return(0,_jsxRuntime.jsx)(SystemLine,{message:t});const i=!t.streaming&&!t.error;return(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(AssistantMessage,{message:t,onRetry:o,waitingOnUser:r}),i&&(0,_jsxRuntime.jsx)(TranscriptActions,{message:t})]})});function MessageList({messages:e,ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r,onRetry:i,waitingOnUser:s}){const l=(0,_react.useRef)(null);const a=(0,_react.useRef)(true);const n=(0,_react.useRef)(false);const d=(0,_react.useCallback)(c=>{const{contentOffset:f,contentSize:b,layoutMeasurement:k}=c.nativeEvent;const w=b.height-k.height-f.y;a.current=w<80},[]);const u=(0,_react.useCallback)(()=>{n.current=true},[]);const h=(0,_react.useCallback)(c=>{if(n.current)d(c)},[d]);const x=(0,_react.useCallback)(c=>{n.current=false;d(c)},[d]);const g=(0,_react.useCallback)(()=>{if(!a.current)return;l.current?.scrollToEnd({animated:false});requestAnimationFrame(()=>l.current?.scrollToEnd({animated:false}))},[]);const y=e[e.length-1];const p=y?`${y.id}:${y.text.length}:${y.toolCalls.length}:${y.error??""}`:"";(0,_react.useEffect)(()=>{g()},[p,g]);return(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:l,testID:"buoy-ask-buoy-messages-scroll",style:styles.list,contentContainerStyle:styles.listContent,data:e,keyExtractor:c=>c.id,renderItem:({item:c})=>(0,_jsxRuntime.jsx)(Row,{message:c,onRetry:c.id===y?.id?i:void 0,waitingOnUser:c.id===y?.id?s:false}),onScroll:h,onScrollBeginDrag:u,onScrollEndDrag:x,onMomentumScrollEnd:d,scrollEventThrottle:32,onContentSizeChange:g,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"interactive",ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r})}const styles=_reactNative.StyleSheet.create({list:{flex:1,backgroundColor:"transparent"},listContent:{paddingHorizontal:_sharedUi.night.gutter,paddingTop:12,paddingBottom:16,gap:16,flexGrow:1},userWrap:{alignItems:"flex-end"},userBubble:{maxWidth:"84%",paddingHorizontal:14,paddingVertical:9,borderRadius:18,borderBottomRightRadius:6,backgroundColor:_sharedUi.night.color.accentFill,borderWidth:_reactNative.StyleSheet.hairlineWidth,borderColor:_sharedUi.night.color.accentBorder},userText:{color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.row,lineHeight:21},systemLine:{alignSelf:"stretch",paddingHorizontal:12,paddingVertical:7,borderRadius:_sharedUi.night.radius.row,backgroundColor:_sharedUi.night.color.fill},systemText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,lineHeight:16,textAlign:"center"},assistantWrap:{alignItems:"stretch",gap:10},blocks:{gap:10},waitingRow:{flexDirection:"row",alignItems:"center",gap:8},waitingText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.caption},assistantText:{color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.row,lineHeight:22,paddingHorizontal:2},card:{borderRadius:_sharedUi.night.radius.card,borderWidth:_reactNative.StyleSheet.hairlineWidth,borderColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface,overflow:"hidden"},row:{paddingHorizontal:12,paddingVertical:10},rowDivider:{borderBottomWidth:_reactNative.StyleSheet.hairlineWidth,borderBottomColor:_sharedUi.night.color.separator},rowLine:{flexDirection:"row",alignItems:"center",gap:10},markSlot:{width:18,height:18,alignItems:"center",justifyContent:"center"},mark:{width:16,height:16,borderRadius:8,alignItems:"center",justifyContent:"center"},markOk:{backgroundColor:_sharedUi.night.color.accent},markFailed:{backgroundColor:_sharedUi.night.color.danger},markRefused:{backgroundColor:_sharedUi.night.color.warning},markNotRun:{borderWidth:1.5,borderColor:_sharedUi.night.color.textTertiary},markNotRunBar:{width:7,height:1.5,borderRadius:1,backgroundColor:_sharedUi.night.color.textSecondary},rowTitle:{flex:1,color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.body,lineHeight:19},rowStatus:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption,maxWidth:120},rowStatusDanger:{color:_sharedUi.night.color.danger},rowStatusWarning:{color:_sharedUi.night.color.warning},rowStatusOk:{color:_sharedUi.night.color.accent},rowVerified:{color:_sharedUi.night.color.accent},rowDetail:{paddingLeft:28,paddingTop:8,gap:4},rowTool:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.micro,fontWeight:"600",letterSpacing:.8},rowDescription:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.caption,lineHeight:18},rowFailure:{color:_sharedUi.night.color.danger,fontSize:_sharedUi.night.font.caption,lineHeight:18},rowReceipts:{paddingTop:10,gap:10},groupBody:{paddingLeft:14,backgroundColor:_sharedUi.night.color.fill},stoppedBox:{alignItems:"flex-start",gap:2,paddingHorizontal:12,paddingVertical:8},stoppedText:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption,lineHeight:18},errorBox:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingVertical:10,borderRadius:_sharedUi.night.radius.row,backgroundColor:_sharedUi.night.color.dangerSoft},errorBody:{flex:1,gap:4},errorText:{color:_sharedUi.night.color.danger,fontSize:_sharedUi.night.font.caption,fontWeight:"600",lineHeight:18},errorDetail:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,lineHeight:15},retry:{alignSelf:"flex-start",marginTop:6,paddingHorizontal:14,paddingVertical:7,borderRadius:_sharedUi.night.radius.row,backgroundColor:_sharedUi.night.color.button},retryPressed:{opacity:.7},retryText:{color:_sharedUi.night.color.accent,fontSize:_sharedUi.night.font.caption,fontWeight:"600"},transcriptActions:{flexDirection:"row",alignItems:"center",gap:10,marginTop:8},turnFooter:{flex:1,color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.micro,fontVariant:["tabular-nums"]},copyBtn:{paddingHorizontal:10,paddingVertical:5,borderRadius:_sharedUi.night.radius.badge,backgroundColor:_sharedUi.night.color.fill},iconBtn:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8},copyPressed:{opacity:.7},copyText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,fontWeight:"600"},copiedText:{color:_sharedUi.night.color.accent}});
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.HOSTED_MODEL=exports.HOSTED_ENDPOINT=void 0;exports.hostedAskBuoy=hostedAskBuoy;var _reactNative=require("react-native");var license=_interopRequireWildcard(require("@buoy-gg/license"));var _agentCore=require("@buoy-gg/agent-core");function _interopRequireWildcard(a,e){if("function"==typeof WeakMap)var i=new WeakMap,u=new WeakMap;return(_interopRequireWildcard=function(t,o){if(!o&&t&&t.__esModule)return t;var r,c,n={__proto__:null,default:t};if(null===t||"object"!=typeof t&&"function"!=typeof t)return n;if(r=o?u:i){if(r.has(t))return r.get(t);r.set(t,n)}for(const s in t)"default"!==s&&{}.hasOwnProperty.call(t,s)&&((c=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(t,s))&&(c.get||c.set)?r(n,s,c):n[s]=t[s]);return n})(a,e)}const HOSTED_ENDPOINT=exports.HOSTED_ENDPOINT="https://ai.buoy.gg/v1/chat/completions";const HOSTED_MODEL=exports.HOSTED_MODEL="openai/gpt-6-luna";const REFRESH_WITHIN_MS=10*6e4;async function sessionToken(a=false){const e=license.SessionManager;if(!e)return null;const i=e.getStatus();if(i.state==="active"&&(a||i.grace||(i.validUntil??0)-Date.now()<REFRESH_WITHIN_MS)){await e.refresh(true)}return e.getAccessToken()}function origin(a){const e=/^(https?:\/\/[^/]+)/.exec(a);return e?e[1]:a}function hostedAskBuoy(a={}){const{endpoint:e=HOSTED_ENDPOINT,...i}=a;const u=`ask-buoy ${_reactNative.Platform.OS}`;return{...i,endpoint:e,hosted:true,protocol:"openai",model:HOSTED_MODEL,maxTokens:8192,headers:async t=>{const o=await sessionToken((t?.attempt??1)>1);return{...o?{[_agentCore.HOSTED_HEADERS.session]:o}:{},[_agentCore.HOSTED_HEADERS.ask]:t?.askId??"ask_unknown000",[_agentCore.HOSTED_HEADERS.round]:String(t?.round??1),[_agentCore.HOSTED_HEADERS.attempt]:String(t?.attempt??1),[_agentCore.HOSTED_HEADERS.protocol]:String(_agentCore.HOSTED_PROTOCOL_VERSION),[_agentCore.HOSTED_HEADERS.client]:u}},readUsage:async()=>{const t=await sessionToken();if(!t)throw new Error("Sign in to see hosted credits.");const o=await fetch(`${origin(e)}/v1/usage`,{headers:{[_agentCore.HOSTED_HEADERS.session]:t}});if(!o.ok)throw new Error(`usage HTTP ${o.status}`);const r=await o.json();return{creditsLeft:r.creditsLeft??0,grantCredits:r.grantCredits??0,spentCredits:r.spentCredits??0,resetAt:r.resetAt??null}},reportProblem:async({requestId:t,code:o,note:r})=>{const c=await sessionToken();const n=await fetch(`${origin(e)}/v1/report`,{method:"POST",headers:{"Content-Type":"application/json",...c?{[_agentCore.HOSTED_HEADERS.session]:c}:{}},body:JSON.stringify({request_id:t,code:o,note:r,client:u})});if(!n.ok)throw new Error(`report HTTP ${n.status}`);const s=await n.json();if(!s.report_id)throw new Error("report: no id");return{reportId:s.report_id}}}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"ASK_BUOY_ADAPTER_VERSION",{enumerable:true,get:function(){return _askBuoySyncAdapter.ASK_BUOY_ADAPTER_VERSION}});Object.defineProperty(exports,"ASK_BUOY_ICON_COLOR",{enumerable:true,get:function(){return _preset.ASK_BUOY_ICON_COLOR}});Object.defineProperty(exports,"ApprovalCard",{enumerable:true,get:function(){return _ApprovalCard.ApprovalCard}});Object.defineProperty(exports,"AskBuoyHeader",{enumerable:true,get:function(){return _AskBuoyHeader.AskBuoyHeader}});Object.defineProperty(exports,"AskBuoyIcon",{enumerable:true,get:function(){return _preset.AskBuoyIcon}});Object.defineProperty(exports,"AskBuoyModal",{enumerable:true,get:function(){return _AskBuoyModal.AskBuoyModal}});Object.defineProperty(exports,"AskBuoySettings",{enumerable:true,get:function(){return _AskBuoySettings.AskBuoySettings}});Object.defineProperty(exports,"BlockActionRow",{enumerable:true,get:function(){return _blocks.ActionRow}});Object.defineProperty(exports,"BlockCard",{enumerable:true,get:function(){return _blocks.Card}});Object.defineProperty(exports,"BlockHandlersProvider",{enumerable:true,get:function(){return _blocks.BlockHandlersProvider}});Object.defineProperty(exports,"BlockRenderer",{enumerable:true,get:function(){return _blocks.BlockRenderer}});Object.defineProperty(exports,"ChangesBar",{enumerable:true,get:function(){return _ChangesBar.ChangesBar}});Object.defineProperty(exports,"Composer",{enumerable:true,get:function(){return _Composer.Composer}});Object.defineProperty(exports,"EditableUserBubble",{enumerable:true,get:function(){return _blocks.EditableUserBubble}});Object.defineProperty(exports,"ElapsedRow",{enumerable:true,get:function(){return _blocks.ElapsedRow}});Object.defineProperty(exports,"LivePill",{enumerable:true,get:function(){return _blocks.LivePill}});Object.defineProperty(exports,"Markdown",{enumerable:true,get:function(){return _Markdown.Markdown}});Object.defineProperty(exports,"MessageActions",{enumerable:true,get:function(){return _blocks.MessageActions}});Object.defineProperty(exports,"MessageList",{enumerable:true,get:function(){return _MessageList.MessageList}});Object.defineProperty(exports,"ProvenanceBadge",{enumerable:true,get:function(){return _blocks.ProvenanceBadge}});Object.defineProperty(exports,"QueuedComposer",{enumerable:true,get:function(){return _blocks.QueuedComposer}});Object.defineProperty(exports,"ReasoningStrip",{enumerable:true,get:function(){return _blocks.ReasoningStrip}});Object.defineProperty(exports,"ReloadDivider",{enumerable:true,get:function(){return _blocks.ReloadDivider}});Object.defineProperty(exports,"ThinkingStrip",{enumerable:true,get:function(){return _ThinkingStrip.ThinkingStrip}});Object.defineProperty(exports,"Timestamp",{enumerable:true,get:function(){return _blocks.Timestamp}});Object.defineProperty(exports,"askBuoySettings",{enumerable:true,get:function(){return _askBuoySettings.askBuoySettings}});Object.defineProperty(exports,"askBuoyStore",{enumerable:true,get:function(){return _askBuoyStore.askBuoyStore}});Object.defineProperty(exports,"askBuoySyncAdapter",{enumerable:true,get:function(){return _askBuoySyncAdapter.askBuoySyncAdapter}});Object.defineProperty(exports,"askBuoyToolPreset",{enumerable:true,get:function(){return _preset.askBuoyToolPreset}});Object.defineProperty(exports,"createAskBuoyTool",{enumerable:true,get:function(){return _preset.createAskBuoyTool}});Object.defineProperty(exports,"hasTrace",{enumerable:true,get:function(){return _traceText.hasTrace}});Object.defineProperty(exports,"redactForWire",{enumerable:true,get:function(){return _wire.redactForWire}});Object.defineProperty(exports,"traceEntries",{enumerable:true,get:function(){return _traceText.traceEntries}});Object.defineProperty(exports,"traceToText",{enumerable:true,get:function(){return _traceText.traceToText}});Object.defineProperty(exports,"useAskBuoy",{enumerable:true,get:function(){return _useAskBuoy.useAskBuoy}});Object.defineProperty(exports,"useAskBuoySettings",{enumerable:true,get:function(){return _useAskBuoySettings.useAskBuoySettings}});Object.defineProperty(exports,"useAskBuoyState",{enumerable:true,get:function(){return _useAskBuoy.useAskBuoyState}});Object.defineProperty(exports,"useBlockHandlers",{enumerable:true,get:function(){return _blocks.useBlockHandlers}});var _AskBuoyModal=require("./components/AskBuoyModal");var _preset=require("./preset");var _askBuoySyncAdapter=require("./sync/askBuoySyncAdapter");var _askBuoyStore=require("./store/askBuoyStore");var _useAskBuoy=require("./store/useAskBuoy");var _wire=require("./sync/wire");var _blocks=require("./blocks");var _Markdown=require("./components/Markdown");var _MessageList=require("./components/MessageList");var _AskBuoyHeader=require("./components/AskBuoyHeader");var _AskBuoySettings=require("./components/AskBuoySettings");var _ThinkingStrip=require("./components/ThinkingStrip");var _askBuoySettings=require("./store/askBuoySettings");var _useAskBuoySettings=require("./store/useAskBuoySettings");var _traceText=require("./store/traceText");var _Composer=require("./components/Composer");var _ChangesBar=require("./components/ChangesBar");var _ApprovalCard=require("./components/ApprovalCard");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"ASK_BUOY_ADAPTER_VERSION",{enumerable:true,get:function(){return _askBuoySyncAdapter.ASK_BUOY_ADAPTER_VERSION}});Object.defineProperty(exports,"ASK_BUOY_ICON_COLOR",{enumerable:true,get:function(){return _preset.ASK_BUOY_ICON_COLOR}});Object.defineProperty(exports,"ApprovalCard",{enumerable:true,get:function(){return _ApprovalCard.ApprovalCard}});Object.defineProperty(exports,"AskBuoyHeader",{enumerable:true,get:function(){return _AskBuoyHeader.AskBuoyHeader}});Object.defineProperty(exports,"AskBuoyIcon",{enumerable:true,get:function(){return _preset.AskBuoyIcon}});Object.defineProperty(exports,"AskBuoyModal",{enumerable:true,get:function(){return _AskBuoyModal.AskBuoyModal}});Object.defineProperty(exports,"AskBuoySettings",{enumerable:true,get:function(){return _AskBuoySettings.AskBuoySettings}});Object.defineProperty(exports,"BlockActionRow",{enumerable:true,get:function(){return _blocks.ActionRow}});Object.defineProperty(exports,"BlockCard",{enumerable:true,get:function(){return _blocks.Card}});Object.defineProperty(exports,"BlockHandlersProvider",{enumerable:true,get:function(){return _blocks.BlockHandlersProvider}});Object.defineProperty(exports,"BlockRenderer",{enumerable:true,get:function(){return _blocks.BlockRenderer}});Object.defineProperty(exports,"ChangesBar",{enumerable:true,get:function(){return _ChangesBar.ChangesBar}});Object.defineProperty(exports,"Composer",{enumerable:true,get:function(){return _Composer.Composer}});Object.defineProperty(exports,"EditableUserBubble",{enumerable:true,get:function(){return _blocks.EditableUserBubble}});Object.defineProperty(exports,"ElapsedRow",{enumerable:true,get:function(){return _blocks.ElapsedRow}});Object.defineProperty(exports,"HOSTED_ENDPOINT",{enumerable:true,get:function(){return _hosted.HOSTED_ENDPOINT}});Object.defineProperty(exports,"HOSTED_MODEL",{enumerable:true,get:function(){return _hosted.HOSTED_MODEL}});Object.defineProperty(exports,"LivePill",{enumerable:true,get:function(){return _blocks.LivePill}});Object.defineProperty(exports,"Markdown",{enumerable:true,get:function(){return _Markdown.Markdown}});Object.defineProperty(exports,"MessageActions",{enumerable:true,get:function(){return _blocks.MessageActions}});Object.defineProperty(exports,"MessageList",{enumerable:true,get:function(){return _MessageList.MessageList}});Object.defineProperty(exports,"ProvenanceBadge",{enumerable:true,get:function(){return _blocks.ProvenanceBadge}});Object.defineProperty(exports,"QueuedComposer",{enumerable:true,get:function(){return _blocks.QueuedComposer}});Object.defineProperty(exports,"ReasoningStrip",{enumerable:true,get:function(){return _blocks.ReasoningStrip}});Object.defineProperty(exports,"ReloadDivider",{enumerable:true,get:function(){return _blocks.ReloadDivider}});Object.defineProperty(exports,"ThinkingStrip",{enumerable:true,get:function(){return _ThinkingStrip.ThinkingStrip}});Object.defineProperty(exports,"Timestamp",{enumerable:true,get:function(){return _blocks.Timestamp}});Object.defineProperty(exports,"askBuoySettings",{enumerable:true,get:function(){return _askBuoySettings.askBuoySettings}});Object.defineProperty(exports,"askBuoyStore",{enumerable:true,get:function(){return _askBuoyStore.askBuoyStore}});Object.defineProperty(exports,"askBuoySyncAdapter",{enumerable:true,get:function(){return _askBuoySyncAdapter.askBuoySyncAdapter}});Object.defineProperty(exports,"askBuoyToolPreset",{enumerable:true,get:function(){return _preset.askBuoyToolPreset}});Object.defineProperty(exports,"createAskBuoyTool",{enumerable:true,get:function(){return _preset.createAskBuoyTool}});Object.defineProperty(exports,"hasTrace",{enumerable:true,get:function(){return _traceText.hasTrace}});Object.defineProperty(exports,"hostedAskBuoy",{enumerable:true,get:function(){return _hosted.hostedAskBuoy}});Object.defineProperty(exports,"redactForWire",{enumerable:true,get:function(){return _wire.redactForWire}});Object.defineProperty(exports,"traceEntries",{enumerable:true,get:function(){return _traceText.traceEntries}});Object.defineProperty(exports,"traceToText",{enumerable:true,get:function(){return _traceText.traceToText}});Object.defineProperty(exports,"useAskBuoy",{enumerable:true,get:function(){return _useAskBuoy.useAskBuoy}});Object.defineProperty(exports,"useAskBuoySettings",{enumerable:true,get:function(){return _useAskBuoySettings.useAskBuoySettings}});Object.defineProperty(exports,"useAskBuoyState",{enumerable:true,get:function(){return _useAskBuoy.useAskBuoyState}});Object.defineProperty(exports,"useBlockHandlers",{enumerable:true,get:function(){return _blocks.useBlockHandlers}});var _AskBuoyModal=require("./components/AskBuoyModal");var _preset=require("./preset");var _askBuoySyncAdapter=require("./sync/askBuoySyncAdapter");var _askBuoyStore=require("./store/askBuoyStore");var _useAskBuoy=require("./store/useAskBuoy");var _hosted=require("./hosted");var _wire=require("./sync/wire");var _blocks=require("./blocks");var _Markdown=require("./components/Markdown");var _MessageList=require("./components/MessageList");var _AskBuoyHeader=require("./components/AskBuoyHeader");var _AskBuoySettings=require("./components/AskBuoySettings");var _ThinkingStrip=require("./components/ThinkingStrip");var _askBuoySettings=require("./store/askBuoySettings");var _useAskBuoySettings=require("./store/useAskBuoySettings");var _traceText=require("./store/traceText");var _Composer=require("./components/Composer");var _ChangesBar=require("./components/ChangesBar");var _ApprovalCard=require("./components/ApprovalCard");
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.askBuoySettings=exports.DEFAULT_SETTINGS=void 0;var _sharedUi=require("@buoy-gg/shared-ui");const DEFAULT_SETTINGS=exports.DEFAULT_SETTINGS={showThinking:false,bypassApprovals:false,readOnly:false};const store=(0,_sharedUi.definePersistedSetting)(`${_sharedUi.devToolsStorageKeys.base}_ask_buoy_settings`,DEFAULT_SETTINGS,{sanitize:e=>({showThinking:e.showThinking===true,bypassApprovals:e.bypassApprovals===true,readOnly:e.readOnly===true})});let current=DEFAULT_SETTINGS;let loaded=false;const listeners=new Set;function emit(){for(const e of listeners){try{e()}catch{}}}const askBuoySettings=exports.askBuoySettings={get:()=>current,subscribe(e){listeners.add(e);if(!loaded){loaded=true;void store.load().then(s=>{current=s;emit()})}return()=>listeners.delete(e)},set(e,s){if(current[e]===s)return;current={...current,[e]:s};emit();void store.save(current)},reset(){current=DEFAULT_SETTINGS;loaded=false;void store.clear()}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.askBuoySettings=exports.DEFAULT_SETTINGS=void 0;var _sharedUi=require("@buoy-gg/shared-ui");const DEFAULT_SETTINGS=exports.DEFAULT_SETTINGS={showThinking:false,bypassApprovals:false,readOnly:false,hostedNoticeSeen:false};const store=(0,_sharedUi.definePersistedSetting)(`${_sharedUi.devToolsStorageKeys.base}_ask_buoy_settings`,DEFAULT_SETTINGS,{sanitize:e=>({showThinking:e.showThinking===true,bypassApprovals:e.bypassApprovals===true,readOnly:e.readOnly===true,hostedNoticeSeen:e.hostedNoticeSeen===true})});let current=DEFAULT_SETTINGS;let loaded=false;const listeners=new Set;function emit(){for(const e of listeners){try{e()}catch{}}}const askBuoySettings=exports.askBuoySettings={get:()=>current,subscribe(e){listeners.add(e);if(!loaded){loaded=true;void store.load().then(s=>{current=s;emit()})}return()=>listeners.delete(e)},set(e,s){if(current[e]===s)return;current={...current,[e]:s};emit();void store.save(current)},reset(){current=DEFAULT_SETTINGS;loaded=false;void store.clear()}};
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.askBuoyStore=void 0;exports.queuePauseReason=queuePauseReason;exports.turnPhaseOf=turnPhaseOf;var _agentCore=require("@buoy-gg/agent-core");var _sharedUi=require("@buoy-gg/shared-ui");const nextId=(0,_agentCore.idFactory)("m");const MAX_PARAM_CHARS=400;function encodeParams(t){if(!t||Object.keys(t).length===0)return void 0;try{const e=JSON.stringify(t);return e.length>MAX_PARAM_CHARS?`${e.slice(0,MAX_PARAM_CHARS)}\u2026`:e}catch{return void 0}}const nextQueuedId=(0,_agentCore.idFactory)("q");let state={messages:[],busy:false,stopping:false,pending:null,trusted:[],notice:null,configured:false,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0},meta:{}};const listeners=new Set;let ledgerRef=null;let heldSession=null;function set(t){state={...state,...t};for(const e of listeners){try{e()}catch{}}}const askBuoyStore=exports.askBuoyStore={getState:()=>state,subscribe(t){listeners.add(t);return()=>listeners.delete(t)},setLedger(t){ledgerRef=t},getLedger(){return ledgerRef},holdSession(t,e){heldSession={session:t,signature:e}},getHeldSession(){return heldSession},setNotice(t){set({notice:t})},setConfigured(t){if(t!==state.configured)set({configured:t})},setMeta(t){const e=Object.keys(t).every(r=>state.meta[r]===t[r]);if(!e)set({meta:{...state.meta,...t}})},addUser(t){set({messages:[...state.messages,{id:nextId(),role:"user",text:t,toolCalls:[],blocks:[]}],busy:true})},beginTurn(){set({busy:true})},enqueue(t){const e={id:nextQueuedId(),text:t};set({queued:[...state.queued,e]});return e},removeQueued(t){if(!state.queued.some(e=>e.id===t))return;set({queued:state.queued.filter(e=>e.id!==t)})},shiftQueued(){const[t,...e]=state.queued;if(!t)return void 0;set({queued:e});return t},takeQueuedToDraft(t){const e=state.queued.find(r=>r.id===t);if(!e)return;set({queued:state.queued.filter(r=>r.id!==t),draft:e.text})},requestStop(){if(!state.busy||state.stopping)return;set({stopping:true})},clearDraft(){if(state.draft===null)return;set({draft:null})},removeMessage(t){set({messages:state.messages.filter(e=>e.id!==t)})},recordAnswer(t){set({answers:{...state.answers,[t.blockId]:t},awaitingBlockId:state.awaitingBlockId===t.blockId?null:state.awaitingBlockId})},setActionState(t,e){const r={...state.actionState};if(e===null)delete r[t];else r[t]=e;set({actionState:r})},startAssistant(){const t=nextId();set({messages:[...state.messages,{id:t,role:"assistant",text:"",toolCalls:[],blocks:[],streaming:true,startedAt:(0,_sharedUi.realNow)()}]});return t},applyEvent(t,e){if(e.type==="history-trimmed"){const s=state.messages.findIndex(o=>o.id===t);const n={id:nextId(),role:"assistant",system:true,text:`Older messages were trimmed from the agent's memory (${e.droppedRounds} exchange${e.droppedRounds===1?"":"s"}).`+(e.droppedPinned?` ${e.droppedPinned===1?"One of them made a change that is":`${e.droppedPinned} of them made changes that are`} still applied \u2014 the changes bar still lists ${e.droppedPinned===1?"it":"them"}, but the agent no longer remembers making ${e.droppedPinned===1?"it":"them"}.`:" It may not recall setup from earlier in this chat \u2014 the changes bar still lists what is applied."),toolCalls:[],blocks:[],endedAt:(0,_sharedUi.realNow)()};const a=[...state.messages];a.splice(s<0?a.length:s,0,n);set({messages:a});return}const r=state.messages.map(s=>{if(s.id!==t)return s;switch(e.type){case"retrying":{const n=Math.max(1,Math.round(e.inMs/1e3));return{...s,waiting:e.reason==="throttled"?`Endpoint busy \u2014 retrying in ${n}s (${e.attempt} of ${e.maxAttempts})`:`Request too large \u2014 trimming older messages and retrying`}}case"text":return{...s,waiting:void 0,text:(s.breakBeforeNextText||e.breakBefore)&&s.text?`${s.text.trimEnd()}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.askBuoyStore=void 0;exports.queuePauseReason=queuePauseReason;exports.turnPhaseOf=turnPhaseOf;var _agentCore=require("@buoy-gg/agent-core");var _sharedUi=require("@buoy-gg/shared-ui");const nextId=(0,_agentCore.idFactory)("m");const MAX_PARAM_CHARS=400;function encodeParams(t){if(!t||Object.keys(t).length===0)return void 0;try{const e=JSON.stringify(t);return e.length>MAX_PARAM_CHARS?`${e.slice(0,MAX_PARAM_CHARS)}\u2026`:e}catch{return void 0}}const nextQueuedId=(0,_agentCore.idFactory)("q");let state={messages:[],busy:false,stopping:false,pending:null,trusted:[],notice:null,configured:false,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0},credits:null,meta:{}};let reporter=null;let usageReader=null;const listeners=new Set;let ledgerRef=null;let heldSession=null;function set(t){state={...state,...t};for(const e of listeners){try{e()}catch{}}}const askBuoyStore=exports.askBuoyStore={getState:()=>state,subscribe(t){listeners.add(t);return()=>listeners.delete(t)},setLedger(t){ledgerRef=t},getLedger(){return ledgerRef},holdSession(t,e){heldSession={session:t,signature:e}},getHeldSession(){return heldSession},setReporter(t){reporter=t},getReporter(){return reporter},setUsageReader(t){usageReader=t},getUsageReader(){return usageReader},setNotice(t){set({notice:t})},setConfigured(t){if(t!==state.configured)set({configured:t})},setMeta(t){const e=Object.keys(t).every(r=>state.meta[r]===t[r]);if(!e)set({meta:{...state.meta,...t}})},addUser(t){set({messages:[...state.messages,{id:nextId(),role:"user",text:t,toolCalls:[],blocks:[]}],busy:true})},beginTurn(){set({busy:true})},enqueue(t){const e={id:nextQueuedId(),text:t};set({queued:[...state.queued,e]});return e},removeQueued(t){if(!state.queued.some(e=>e.id===t))return;set({queued:state.queued.filter(e=>e.id!==t)})},shiftQueued(){const[t,...e]=state.queued;if(!t)return void 0;set({queued:e});return t},takeQueuedToDraft(t){const e=state.queued.find(r=>r.id===t);if(!e)return;set({queued:state.queued.filter(r=>r.id!==t),draft:e.text})},requestStop(){if(!state.busy||state.stopping)return;set({stopping:true})},clearDraft(){if(state.draft===null)return;set({draft:null})},removeMessage(t){set({messages:state.messages.filter(e=>e.id!==t)})},recordAnswer(t){set({answers:{...state.answers,[t.blockId]:t},awaitingBlockId:state.awaitingBlockId===t.blockId?null:state.awaitingBlockId})},setActionState(t,e){const r={...state.actionState};if(e===null)delete r[t];else r[t]=e;set({actionState:r})},startAssistant(){const t=nextId();set({messages:[...state.messages,{id:t,role:"assistant",text:"",toolCalls:[],blocks:[],streaming:true,startedAt:(0,_sharedUi.realNow)()}]});return t},applyEvent(t,e){if(e.type==="history-trimmed"){const s=state.messages.findIndex(o=>o.id===t);const n={id:nextId(),role:"assistant",system:true,text:`Older messages were trimmed from the agent's memory (${e.droppedRounds} exchange${e.droppedRounds===1?"":"s"}).`+(e.droppedPinned?` ${e.droppedPinned===1?"One of them made a change that is":`${e.droppedPinned} of them made changes that are`} still applied \u2014 the changes bar still lists ${e.droppedPinned===1?"it":"them"}, but the agent no longer remembers making ${e.droppedPinned===1?"it":"them"}.`:" It may not recall setup from earlier in this chat \u2014 the changes bar still lists what is applied."),toolCalls:[],blocks:[],endedAt:(0,_sharedUi.realNow)()};const a=[...state.messages];a.splice(s<0?a.length:s,0,n);set({messages:a});return}const r=state.messages.map(s=>{if(s.id!==t)return s;switch(e.type){case"retrying":{const n=Math.max(1,Math.round(e.inMs/1e3));return{...s,waiting:e.reason==="throttled"?`Endpoint busy \u2014 retrying in ${n}s (${e.attempt} of ${e.maxAttempts})`:`Request too large \u2014 trimming older messages and retrying`}}case"text":return{...s,waiting:void 0,text:(s.breakBeforeNextText||e.breakBefore)&&s.text?`${s.text.trimEnd()}
2
2
 
3
- ${e.delta}`:s.text+e.delta,breakBeforeNextText:false};case"reasoning":return{...s,breakBeforeNextText:true,reasoning:[...s.reasoning??[],{text:e.text,afterCalls:s.toolCalls.length}]};case"tool-start":return{...s,waiting:void 0,toolCalls:[...s.toolCalls,{id:e.id,toolId:e.toolId,action:e.action,label:e.label,description:e.description,status:"running",params:encodeParams(e.params),effect:e.effect,startedAt:(0,_sharedUi.realNow)()}]};case"tool-end":return{...s,breakBeforeNextText:true,toolCalls:s.toolCalls.map(n=>n.id===e.id?{...n,status:!e.ok&&e.summary==="refused"?"refused":!e.ok&&e.summary==="declined"?"declined":!e.ok&&e.summary==="stopped"?"stopped":e.ok?"ok":"failed",summary:e.summary,durationMs:e.durationMs,result:e.result}:n)};case"tool-verified":return{...s,toolCalls:s.toolCalls.map(n=>n.id===e.id?{...n,verification:e.verification}:n)};case"block":return{...s,breakBeforeNextText:true,blocks:[...s.blocks,{block:e.block,forToolCallId:e.forToolCallId}]};case"usage":return{...s,usage:{input:(s.usage?.input??0)+e.input,output:(s.usage?.output??0)+e.output,requests:(s.usage?.requests??0)+1}};case"error":return{...s,waiting:void 0,error:e.message};default:return s}});set({messages:r,...e.type==="awaiting-user"?{awaitingBlockId:e.blockId}:{},...e.type==="usage"?{usage:{input:state.usage.input+e.input,output:state.usage.output+e.output,requests:state.usage.requests+1}}:{}})},markStopped(t){set({messages:state.messages.map(e=>e.id===t?{...e,stopped:true}:e)})},finishAssistant(t){set({messages:state.messages.map(e=>e.id===t?{...e,streaming:false,endedAt:(0,_sharedUi.realNow)()}:e),busy:false,stopping:false})},askApproval(t){return new Promise(e=>{set({pending:{...t,resolve:e}})})},answerApproval(t){const e=state.pending;const r=typeof t==="boolean"?t:t.approved;const s=typeof t!=="boolean"&&t.trust===true&&r;const n=e?`${e.toolId}.${e.action}`:"";set({pending:null,...s&&e&&!state.trusted.some(a=>a.key===n)?{trusted:[...state.trusted,{key:n,label:e.label}]}:{}});e?.resolve(t)},untrust(t){heldSession?.session.untrust(t);set({trusted:state.trusted.filter(e=>e.key!==t)})},restorePending(t){if(state.pending||state.busy)return false;set({pending:{...t,restored:true,resolve:()=>{}}});return true},addNote(t){set({messages:[...state.messages,{id:nextId(),role:"assistant",text:t,toolCalls:[],blocks:[],endedAt:(0,_sharedUi.realNow)()}]})},hydrate(t){if(state.messages.length>0||state.busy)return false;set({messages:t.messages.map(e=>({...e,restored:true})),answers:t.answers,usage:t.usage,queued:t.queued??[]});return true},reset(){state.pending?.resolve(false);set({messages:[],busy:false,stopping:false,pending:null,trusted:[],notice:null,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0}})}};function turnPhaseOf(t){if(t.pending)return"awaitingApproval";if(t.busy)return t.stopping?"stopping":"running";if(t.awaitingBlockId)return"awaitingAnswer";return"idle"}function queuePauseReason(t){const e=turnPhaseOf(t);if(e==="running"||e==="stopping")return null;if(e==="awaitingApproval")return"Paused \u2014 answer the approval above first.";if(e==="awaitingAnswer")return"Paused \u2014 answer the question above first.";const r=t.messages[t.messages.length-1];if(r?.role==="assistant"&&r.error)return"Paused \u2014 the last turn failed.";if(r?.role==="assistant"&&r.stopped)return"Paused \u2014 you stopped the last turn.";return null}
3
+ ${e.delta}`:s.text+e.delta,breakBeforeNextText:false};case"reasoning":return{...s,breakBeforeNextText:true,reasoning:[...s.reasoning??[],{text:e.text,afterCalls:s.toolCalls.length}]};case"tool-start":return{...s,waiting:void 0,toolCalls:[...s.toolCalls,{id:e.id,toolId:e.toolId,action:e.action,label:e.label,description:e.description,status:"running",params:encodeParams(e.params),effect:e.effect,startedAt:(0,_sharedUi.realNow)()}]};case"tool-end":return{...s,breakBeforeNextText:true,toolCalls:s.toolCalls.map(n=>n.id===e.id?{...n,status:!e.ok&&e.summary==="refused"?"refused":!e.ok&&e.summary==="declined"?"declined":!e.ok&&e.summary==="stopped"?"stopped":e.ok?"ok":"failed",summary:e.summary,durationMs:e.durationMs,result:e.result}:n)};case"tool-verified":return{...s,toolCalls:s.toolCalls.map(n=>n.id===e.id?{...n,verification:e.verification}:n)};case"block":return{...s,breakBeforeNextText:true,blocks:[...s.blocks,{block:e.block,forToolCallId:e.forToolCallId}]};case"usage":return{...s,usage:{input:(s.usage?.input??0)+e.input,output:(s.usage?.output??0)+e.output,requests:(s.usage?.requests??0)+1}};case"error":return{...s,waiting:void 0,error:e.message,...e.hosted?{errorInfo:{code:e.hosted.code,requestId:e.hosted.request_id,action:e.hosted.action,resetAt:e.hosted.reset_at,helpUrl:e.hosted.help_url}}:{}};default:return s}});set({messages:r,...e.type==="awaiting-user"?{awaitingBlockId:e.blockId}:{},...e.type==="meter"&&e.frame.phase==="end"?{credits:{left:e.frame.credits_left??state.credits?.left??null,resetAt:e.frame.credits_reset??state.credits?.resetAt??null,pending:e.frame.pending===true}}:{},...e.type==="usage"?{usage:{input:state.usage.input+e.input,output:state.usage.output+e.output,requests:state.usage.requests+1}}:{}})},markStopped(t){set({messages:state.messages.map(e=>e.id===t?{...e,stopped:true}:e)})},finishAssistant(t){set({messages:state.messages.map(e=>e.id===t?{...e,streaming:false,endedAt:(0,_sharedUi.realNow)()}:e),busy:false,stopping:false})},askApproval(t){return new Promise(e=>{set({pending:{...t,resolve:e}})})},answerApproval(t){const e=state.pending;const r=typeof t==="boolean"?t:t.approved;const s=typeof t!=="boolean"&&t.trust===true&&r;const n=e?`${e.toolId}.${e.action}`:"";set({pending:null,...s&&e&&!state.trusted.some(a=>a.key===n)?{trusted:[...state.trusted,{key:n,label:e.label}]}:{}});e?.resolve(t)},untrust(t){heldSession?.session.untrust(t);set({trusted:state.trusted.filter(e=>e.key!==t)})},restorePending(t){if(state.pending||state.busy)return false;set({pending:{...t,restored:true,resolve:()=>{}}});return true},addNote(t){set({messages:[...state.messages,{id:nextId(),role:"assistant",text:t,toolCalls:[],blocks:[],endedAt:(0,_sharedUi.realNow)()}]})},hydrate(t){if(state.messages.length>0||state.busy)return false;set({messages:t.messages.map(e=>({...e,restored:true})),answers:t.answers,usage:t.usage,queued:t.queued??[]});return true},reset(){state.pending?.resolve(false);set({messages:[],busy:false,stopping:false,pending:null,trusted:[],notice:null,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0}})}};function turnPhaseOf(t){if(t.pending)return"awaitingApproval";if(t.busy)return t.stopping?"stopping":"running";if(t.awaitingBlockId)return"awaitingAnswer";return"idle"}function queuePauseReason(t){const e=turnPhaseOf(t);if(e==="running"||e==="stopping")return null;if(e==="awaitingApproval")return"Paused \u2014 answer the approval above first.";if(e==="awaitingAnswer")return"Paused \u2014 answer the question above first.";const r=t.messages[t.messages.length-1];if(r?.role==="assistant"&&r.error)return"Paused \u2014 the last turn failed.";if(r?.role==="assistant"&&r.stopped)return"Paused \u2014 you stopped the last turn.";return null}
@@ -0,0 +1 @@
1
+ "use strict";var _vitest=require("vitest");var _agentCore=require("@buoy-gg/agent-core");var _askBuoyStore=require("./askBuoyStore");(0,_vitest.beforeEach)(()=>_askBuoyStore.askBuoyStore.reset());(0,_vitest.describe)("hosted credits and errors",()=>{(0,_vitest.it)("shows credits from the closing frame, and keeps the last number while one is pending",()=>{const e=_askBuoyStore.askBuoyStore.startAssistant();_askBuoyStore.askBuoyStore.applyEvent(e,{type:"meter",frame:{phase:"start",request_id:"rq_1"}});_askBuoyStore.askBuoyStore.applyEvent(e,{type:"meter",frame:{phase:"end",request_id:"rq_1",credits_left:1240,credits_reset:"2026-11-12",charged:1}});(0,_vitest.expect)(_askBuoyStore.askBuoyStore.getState().credits).toEqual({left:1240,resetAt:"2026-11-12",pending:false});_askBuoyStore.askBuoyStore.applyEvent(e,{type:"meter",frame:{phase:"end",request_id:"rq_2",credits_left:null,credits_reset:null,charged:null,pending:true}});(0,_vitest.expect)(_askBuoyStore.askBuoyStore.getState().credits).toEqual({left:1240,resetAt:"2026-11-12",pending:true})});(0,_vitest.it)("keeps a hosted error's code and request id on the message",()=>{const e=_askBuoyStore.askBuoyStore.startAssistant();_askBuoyStore.askBuoyStore.applyEvent(e,{type:"error",message:"You used this month's credits. They come back on Nov 12.",hosted:{code:"credits_out",message:"x",request_id:"rq_9",action:_agentCore.HOSTED_ERRORS.credits_out.action,retry_after_ms:null,reset_at:"2026-11-12T00:00:00Z",help_url:null}});const t=_askBuoyStore.askBuoyStore.getState().messages.find(r=>r.id===e);(0,_vitest.expect)(t.error).toMatch(/credits/);(0,_vitest.expect)(t.errorInfo).toEqual({code:"credits_out",requestId:"rq_9",action:"none",resetAt:"2026-11-12T00:00:00Z",helpUrl:null})});(0,_vitest.it)("an error from your own endpoint has no hosted info",()=>{const e=_askBuoyStore.askBuoyStore.startAssistant();_askBuoyStore.askBuoyStore.applyEvent(e,{type:"error",message:"HTTP 500"});(0,_vitest.expect)(_askBuoyStore.askBuoyStore.getState().messages.find(t=>t.id===e).errorInfo).toBeUndefined()})});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useAskBuoy=useAskBuoy;exports.useAskBuoyState=useAskBuoyState;var _sharedUi=require("@buoy-gg/shared-ui");var _react=require("react");var _reactNative=require("react-native");var _agentCore=require("@buoy-gg/agent-core");var _askBuoyStore=require("./askBuoyStore");var _resetConversation=require("./resetConversation");var _transcriptPersistence=require("./transcriptPersistence");var _useAskBuoySettings=require("./useAskBuoySettings");const isRelease=typeof __DEV__!=="undefined"&&!__DEV__;function questionBehind(t){for(const r of _askBuoyStore.askBuoyStore.getState().messages){if(!r.restored)continue;for(const p of r.blocks){const c=p.block;if(c?.id!==t)continue;const l=c.question??c.label??c.title;return typeof l==="string"&&l.trim()?l.trim():void 0}}return void 0}function readAvailableActions(){try{const t=(0,_sharedUi.listToolActions)();for(const r of(0,_sharedUi.listSnapshotToolIds)()){if(!t[r])t[r]=[];if(!t[r].includes(_agentCore.SNAPSHOT_ACTION)){t[r]=[_agentCore.SNAPSHOT_ACTION,...t[r]]}}return t}catch{return{}}}const SAVE_DEBOUNCE_MS=600;function useAskBuoyState(){return(0,_react.useSyncExternalStore)(_askBuoyStore.askBuoyStore.subscribe,_askBuoyStore.askBuoyStore.getState,_askBuoyStore.askBuoyStore.getState)}function useAskBuoy(t){const r=useAskBuoyState();const p=(0,_sharedUi.getUseIsPro)()();const c=(0,_react.useRef)(p);c.current=p;const l=(0,_react.useCallback)((...e)=>{if(!(0,_sharedUi.hasAccountAccess)()||!c.current)return Promise.reject(new Error("Ask Buoy requires Pro access."));return(0,_sharedUi.dispatchToolAction)(...e)},[]);const u=(0,_react.useRef)(null);const T=(0,_react.useRef)(false);const y=(0,_react.useRef)(null);const C=(0,_react.useRef)(t);C.current=t;const S=!!t?.endpoint&&!!t?.model;const h=t?.persistTranscript!==false;const{bypassApprovals:A,readOnly:B}=(0,_useAskBuoySettings.useAskBuoySettings)();const v=(0,_react.useRef)(A);v.current=A;const b=(0,_react.useRef)(B);b.current=B;const m=(0,_react.useCallback)(()=>b.current?{...t?.policy??{},readOnly:true}:t?.policy??{},[t]);const[I,P]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{let e=false;void(0,_sharedUi.waitForToolRegistry)().then(()=>{if(!e)P(s=>s+1)});return()=>{e=true}},[]);const k=(0,_react.useMemo)(()=>readAvailableActions(),[I]);const x=Object.keys(k).sort().join(",");(0,_react.useEffect)(()=>{_askBuoyStore.askBuoyStore.setConfigured(S);_askBuoyStore.askBuoyStore.setMeta({model:t?.model,protocol:t?.protocol??(t?"anthropic":void 0),appName:t?.appName,platform:_reactNative.Platform.OS,build:isRelease?"release":"development"});if(!S||!t){u.current=null;_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.");return}const e=t.protocol??"anthropic";if(isRelease&&t.apiKey){_askBuoyStore.askBuoyStore.setNotice("This build carries a plaintext apiKey \u2014 that's dev-only and it ships to every install. Use the headers callback with your own gateway for distributed builds.")}else if(e==="anthropic"&&/^https?:\/\/api\.openai\.com\//i.test(t.endpoint)){_askBuoyStore.askBuoyStore.setNotice('This endpoint is api.openai.com but the protocol is "anthropic". Set protocol: "openai" in the askBuoy config.')}else if(e==="openai"&&/^https?:\/\/api\.anthropic\.com\//i.test(t.endpoint)){_askBuoyStore.askBuoyStore.setNotice('This endpoint is api.anthropic.com but the protocol is "openai". Remove protocol or set it to "anthropic".')}else{_askBuoyStore.askBuoyStore.setNotice(null)}const s=[t.endpoint,t.protocol??"anthropic",t.model].join("|");const o=_askBuoyStore.askBuoyStore.getHeldSession();if(o&&o.signature===s){u.current=o.session;o.session.setAvailableActions(k);o.session.setApprovalBypass(v.current);o.session.setReadOnly(b.current);_askBuoyStore.askBuoyStore.setLedger(o.session.ledger);return}const n=(0,_agentCore.createAskBuoySession)({endpoint:t.endpoint,protocol:t.protocol??"anthropic",model:t.model,headers:t.headers,apiKey:t.apiKey,maxTokens:t.maxTokens,anthropicVersion:t.anthropicVersion,requestOverrides:t.requestOverrides,catalog:t.tools?.length?[..._agentCore.CATALOG,...t.tools]:void 0,dispatch:l,readSnapshot:_sharedUi.readToolSnapshot,availableActions:k,policy:t.policy,context:t.context,isRelease,appName:t.appName,platform:_reactNative.Platform.OS,requestApproval:a=>_askBuoyStore.askBuoyStore.askApproval(a)});u.current=n;n.setApprovalBypass(v.current);n.setReadOnly(b.current);_askBuoyStore.askBuoyStore.holdSession(n,s);_askBuoyStore.askBuoyStore.setLedger(n.ledger);let i=false;void(0,_sharedUi.waitForToolRegistry)().then(a=>{if(a&&!i)void n.prime()});if(h&&!T.current){T.current=true;void(0,_transcriptPersistence.readTranscript)().then(a=>{if(!a)return;const V=_askBuoyStore.askBuoyStore.hydrate({messages:a.messages,answers:a.answers,usage:a.usage,queued:a.queued});if(!V)return;u.current?.restore(a.history);if(a.ledger?.length)u.current?.ledger.restore(a.ledger);if(a.pending)_askBuoyStore.askBuoyStore.restorePending(a.pending)})}return()=>{i=true}},[S,t,k,x,h]);(0,_react.useEffect)(()=>{u.current?.setApprovalBypass(A)},[A]);(0,_react.useEffect)(()=>{u.current?.setReadOnly(B)},[B]);const w=r.messages;const N=r.answers;const R=r.usage;const q=r.busy;const O=r.pending;const _=r.queued;(0,_react.useEffect)(()=>{if(!h)return;if(w.length===0)return;const e=()=>{void(0,_transcriptPersistence.writeTranscript)((0,_transcriptPersistence.buildPayload)({messages:w,history:u.current?.messages??[],answers:N,usage:R,pending:O,ledger:_askBuoyStore.askBuoyStore.getLedger()?.list(),queued:_}))};if(!q){e();return}const s=setTimeout(e,SAVE_DEBOUNCE_MS);return()=>clearTimeout(s)},[h,q,w,N,R,O,_]);const g=(0,_react.useCallback)(e=>{if(!(0,_sharedUi.hasAccountAccess)()||!c.current)return;const s=u.current;if(!s)return;_askBuoyStore.askBuoyStore.beginTurn();const o=_askBuoyStore.askBuoyStore.startAssistant();const n=new AbortController;y.current=n;s.setAvailableActions(readAvailableActions());const i=C.current?.onEvent;void(async()=>{try{for await(const a of s.send(e,n.signal)){_askBuoyStore.askBuoyStore.applyEvent(o,a);if(i){try{i(a)}catch{}}}}catch(a){if(!n.signal.aborted){_askBuoyStore.askBuoyStore.applyEvent(o,{type:"error",message:a instanceof Error?a.message:"Something went wrong talking to your AI endpoint."})}}finally{if(n.signal.aborted)_askBuoyStore.askBuoyStore.markStopped(o);_askBuoyStore.askBuoyStore.finishAssistant(o);y.current=null}})()},[]);const d=(0,_react.useCallback)(e=>{if(!(0,_sharedUi.hasAccountAccess)()||!c.current)return;const s=e.trim();if(!u.current||!s)return;if(_askBuoyStore.askBuoyStore.getState().busy){_askBuoyStore.askBuoyStore.enqueue(s);return}const o=_askBuoyStore.askBuoyStore.getState().awaitingBlockId;if(o)_askBuoyStore.askBuoyStore.recordAnswer({blockId:o,kind:"skipped"});_askBuoyStore.askBuoyStore.addUser(s);g(s)},[g]);const $=(0,_react.useCallback)(()=>{const{messages:e,busy:s}=_askBuoyStore.askBuoyStore.getState();if(s||!u.current)return;const o=[...e].reverse().find(n=>n.role==="user");if(!o)return;g(o.text)},[g]);const f=(0,_react.useCallback)(()=>{_askBuoyStore.askBuoyStore.requestStop();if(_askBuoyStore.askBuoyStore.getState().pending)_askBuoyStore.askBuoyStore.answerApproval(false);y.current?.abort();y.current=null},[]);(0,_react.useEffect)(()=>{const e=(0,_sharedUi.subscribeAccountAccess)(()=>{if(!(0,_sharedUi.hasAccountAccess)())f()});return()=>{e();f()}},[f]);(0,_react.useEffect)(()=>{if(!p)f()},[p,f]);(0,_react.useEffect)(()=>{if(r.queued.length===0)return;if((0,_askBuoyStore.turnPhaseOf)(r)!=="idle")return;if((0,_askBuoyStore.queuePauseReason)(r)!==null)return;const e=_askBuoyStore.askBuoyStore.shiftQueued();if(e)d(e.text)},[r,d]);const L=(0,_react.useCallback)(e=>_askBuoyStore.askBuoyStore.takeQueuedToDraft(e),[]);const j=(0,_react.useCallback)(e=>_askBuoyStore.askBuoyStore.removeQueued(e),[]);const D=(0,_react.useCallback)(()=>{y.current?.abort();y.current=null;(0,_resetConversation.clearConversation)()},[]);const U=(0,_react.useCallback)(()=>(0,_resetConversation.resetConversation)({dispatch:_sharedUi.dispatchToolAction,undoFirst:true}),[]);const E=(0,_react.useCallback)(async e=>{const s=_askBuoyStore.askBuoyStore.getLedger();if(!s){_askBuoyStore.askBuoyStore.setNotice(`${e.label} couldn't run \u2014 no active Ask Buoy session.`);return}const o=t?.tools?.length?[..._agentCore.CATALOG,...t.tools]:void 0;if(e.targetDigest){const i=await(0,_agentCore.readTargetDigest)({toolId:e.toolId,action:e.action,params:e.params??{},dispatch:l,catalog:o});if(i!==void 0&&i!==e.targetDigest){_askBuoyStore.askBuoyStore.addNote(`\u201C${e.label}\u201D wasn't applied \u2014 what it would change has moved on since the app restarted. Nothing was written. Ask again if you still want it.`);return}}const n=await(0,_agentCore.runGatedAction)({toolId:e.toolId,action:e.action,params:e.params??{},dispatch:l,ledger:s,policy:m(),isRelease,catalog:o});if(n.ok){_askBuoyStore.askBuoyStore.addNote(`Applied \u201C${e.label}\u201D, which was still waiting when the app restarted. Whatever else that answer was going to do is gone \u2014 ask again if there was more to it.`)}else{_askBuoyStore.askBuoyStore.setNotice(`${e.label} failed \u2014 ${n.error}`)}},[t,m]);const G=(0,_react.useCallback)(e=>{const s=_askBuoyStore.askBuoyStore.getState().pending;const o=typeof e==="boolean"?e:e.approved;_askBuoyStore.askBuoyStore.answerApproval(e);if(!s?.restored)return;if(!o){_askBuoyStore.askBuoyStore.addNote(`Skipped \u201C${s.label}\u201D. Nothing was changed.`);return}void E(s)},[E]);const K=(0,_react.useCallback)(e=>{_askBuoyStore.askBuoyStore.recordAnswer(e);const s=questionBehind(e.blockId);d(s?`${s} \u2014 ${(0,_agentCore.answerToText)(e)}`:(0,_agentCore.answerToText)(e))},[d]);const Q=(0,_react.useCallback)(async(e,s)=>{if(!(0,_sharedUi.hasAccountAccess)()||!c.current){_askBuoyStore.askBuoyStore.setNotice("Ask Buoy requires Pro access.");return}if(e.send){d(e.send);return}if(!e.dispatch)return;const o=`${s}:${e.label}`;const n=_askBuoyStore.askBuoyStore.getLedger();if(!n){_askBuoyStore.askBuoyStore.setNotice(`${e.label} failed \u2014 no active Ask Buoy session.`);return}_askBuoyStore.askBuoyStore.setActionState(o,"running");const i=await(0,_agentCore.runGatedAction)({toolId:e.dispatch.toolId,action:e.dispatch.action,params:e.dispatch.params??{},dispatch:l,ledger:n,policy:m(),isRelease,catalog:t?.tools?.length?[..._agentCore.CATALOG,...t.tools]:void 0});if(i.ok){_askBuoyStore.askBuoyStore.setActionState(o,"done")}else{_askBuoyStore.askBuoyStore.setActionState(o,"failed");_askBuoyStore.askBuoyStore.setNotice(`${e.label} failed \u2014 ${i.error}`)}},[d,t,m]);return{state:r,send:d,stop:f,reset:D,undoThenReset:U,approve:G,retry:$,answer:K,runAction:Q,editQueued:L,removeQueued:j,configured:S,toolCount:Object.keys(k).length,availableToolIds:Object.keys(k)}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useAskBuoy=useAskBuoy;exports.useAskBuoyState=useAskBuoyState;var _sharedUi=require("@buoy-gg/shared-ui");var _react=require("react");var _reactNative=require("react-native");var _agentCore=require("@buoy-gg/agent-core");var _askBuoyStore=require("./askBuoyStore");var _resetConversation=require("./resetConversation");var _transcriptPersistence=require("./transcriptPersistence");var _useAskBuoySettings=require("./useAskBuoySettings");const isRelease=typeof __DEV__!=="undefined"&&!__DEV__;function questionBehind(t){for(const r of _askBuoyStore.askBuoyStore.getState().messages){if(!r.restored)continue;for(const p of r.blocks){const c=p.block;if(c?.id!==t)continue;const l=c.question??c.label??c.title;return typeof l==="string"&&l.trim()?l.trim():void 0}}return void 0}function readAvailableActions(){try{const t=(0,_sharedUi.listToolActions)();for(const r of(0,_sharedUi.listSnapshotToolIds)()){if(!t[r])t[r]=[];if(!t[r].includes(_agentCore.SNAPSHOT_ACTION)){t[r]=[_agentCore.SNAPSHOT_ACTION,...t[r]]}}return t}catch{return{}}}const SAVE_DEBOUNCE_MS=600;function useAskBuoyState(){return(0,_react.useSyncExternalStore)(_askBuoyStore.askBuoyStore.subscribe,_askBuoyStore.askBuoyStore.getState,_askBuoyStore.askBuoyStore.getState)}function useAskBuoy(t){const r=useAskBuoyState();const p=(0,_sharedUi.getUseIsPro)()();const c=(0,_react.useRef)(p);c.current=p;const l=(0,_react.useCallback)((...e)=>{if(!(0,_sharedUi.hasAccountAccess)()||!c.current)return Promise.reject(new Error("Ask Buoy requires Pro access."));return(0,_sharedUi.dispatchToolAction)(...e)},[]);const u=(0,_react.useRef)(null);const T=(0,_react.useRef)(false);const y=(0,_react.useRef)(null);const C=(0,_react.useRef)(t);C.current=t;const f=!!t?.endpoint&&!!t?.model;const h=t?.persistTranscript!==false;const{bypassApprovals:B,readOnly:A}=(0,_useAskBuoySettings.useAskBuoySettings)();const v=(0,_react.useRef)(B);v.current=B;const b=(0,_react.useRef)(A);b.current=A;const m=(0,_react.useCallback)(()=>b.current?{...t?.policy??{},readOnly:true}:t?.policy??{},[t]);const[I,P]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{let e=false;void(0,_sharedUi.waitForToolRegistry)().then(()=>{if(!e)P(s=>s+1)});return()=>{e=true}},[]);const k=(0,_react.useMemo)(()=>readAvailableActions(),[I]);const x=Object.keys(k).sort().join(",");(0,_react.useEffect)(()=>{_askBuoyStore.askBuoyStore.setConfigured(f);_askBuoyStore.askBuoyStore.setMeta({model:t?.model,protocol:t?.protocol??(t?"anthropic":void 0),appName:t?.appName,platform:_reactNative.Platform.OS,build:isRelease?"release":"development"});if(!f||!t){u.current=null;_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.");return}const e=t.protocol??"anthropic";if(isRelease&&t.apiKey){_askBuoyStore.askBuoyStore.setNotice("This build carries a plaintext apiKey \u2014 that's dev-only and it ships to every install. Use the headers callback with your own gateway for distributed builds.")}else if(e==="anthropic"&&/^https?:\/\/api\.openai\.com\//i.test(t.endpoint)){_askBuoyStore.askBuoyStore.setNotice('This endpoint is api.openai.com but the protocol is "anthropic". Set protocol: "openai" in the askBuoy config.')}else if(e==="openai"&&/^https?:\/\/api\.anthropic\.com\//i.test(t.endpoint)){_askBuoyStore.askBuoyStore.setNotice('This endpoint is api.anthropic.com but the protocol is "openai". Remove protocol or set it to "anthropic".')}else{_askBuoyStore.askBuoyStore.setNotice(null)}_askBuoyStore.askBuoyStore.setReporter(t.reportProblem??null);_askBuoyStore.askBuoyStore.setUsageReader(t.readUsage??null);const s=[t.endpoint,t.protocol??"anthropic",t.model].join("|");const o=_askBuoyStore.askBuoyStore.getHeldSession();if(o&&o.signature===s){u.current=o.session;o.session.setAvailableActions(k);o.session.setApprovalBypass(v.current);o.session.setReadOnly(b.current);_askBuoyStore.askBuoyStore.setLedger(o.session.ledger);return}const n=(0,_agentCore.createAskBuoySession)({endpoint:t.endpoint,protocol:t.protocol??"anthropic",model:t.model,headers:t.headers,apiKey:t.apiKey,maxTokens:t.maxTokens,anthropicVersion:t.anthropicVersion,requestOverrides:t.requestOverrides,hosted:t.hosted===true,catalog:t.tools?.length?[..._agentCore.CATALOG,...t.tools]:void 0,dispatch:l,readSnapshot:_sharedUi.readToolSnapshot,availableActions:k,policy:t.policy,context:t.context,isRelease,appName:t.appName,platform:_reactNative.Platform.OS,requestApproval:a=>_askBuoyStore.askBuoyStore.askApproval(a)});u.current=n;n.setApprovalBypass(v.current);n.setReadOnly(b.current);_askBuoyStore.askBuoyStore.holdSession(n,s);_askBuoyStore.askBuoyStore.setLedger(n.ledger);let i=false;void(0,_sharedUi.waitForToolRegistry)().then(a=>{if(a&&!i)void n.prime()});if(h&&!T.current){T.current=true;void(0,_transcriptPersistence.readTranscript)().then(a=>{if(!a)return;const V=_askBuoyStore.askBuoyStore.hydrate({messages:a.messages,answers:a.answers,usage:a.usage,queued:a.queued});if(!V)return;u.current?.restore(a.history);if(a.ledger?.length)u.current?.ledger.restore(a.ledger);if(a.pending)_askBuoyStore.askBuoyStore.restorePending(a.pending)})}return()=>{i=true}},[f,t,k,x,h]);(0,_react.useEffect)(()=>{u.current?.setApprovalBypass(B)},[B]);(0,_react.useEffect)(()=>{u.current?.setReadOnly(A)},[A]);const w=r.messages;const R=r.answers;const N=r.usage;const q=r.busy;const O=r.pending;const _=r.queued;(0,_react.useEffect)(()=>{if(!h)return;if(w.length===0)return;const e=()=>{void(0,_transcriptPersistence.writeTranscript)((0,_transcriptPersistence.buildPayload)({messages:w,history:u.current?.messages??[],answers:R,usage:N,pending:O,ledger:_askBuoyStore.askBuoyStore.getLedger()?.list(),queued:_}))};if(!q){e();return}const s=setTimeout(e,SAVE_DEBOUNCE_MS);return()=>clearTimeout(s)},[h,q,w,R,N,O,_]);const g=(0,_react.useCallback)(e=>{if(!(0,_sharedUi.hasAccountAccess)()||!c.current)return;const s=u.current;if(!s)return;_askBuoyStore.askBuoyStore.beginTurn();const o=_askBuoyStore.askBuoyStore.startAssistant();const n=new AbortController;y.current=n;s.setAvailableActions(readAvailableActions());const i=C.current?.onEvent;void(async()=>{try{for await(const a of s.send(e,n.signal)){_askBuoyStore.askBuoyStore.applyEvent(o,a);if(i){try{i(a)}catch{}}}}catch(a){if(!n.signal.aborted){_askBuoyStore.askBuoyStore.applyEvent(o,{type:"error",message:a instanceof Error?a.message:"Something went wrong talking to your AI endpoint."})}}finally{if(n.signal.aborted)_askBuoyStore.askBuoyStore.markStopped(o);_askBuoyStore.askBuoyStore.finishAssistant(o);y.current=null}})()},[]);const d=(0,_react.useCallback)(e=>{if(!(0,_sharedUi.hasAccountAccess)()||!c.current)return;const s=e.trim();if(!u.current||!s)return;if(_askBuoyStore.askBuoyStore.getState().busy){_askBuoyStore.askBuoyStore.enqueue(s);return}const o=_askBuoyStore.askBuoyStore.getState().awaitingBlockId;if(o)_askBuoyStore.askBuoyStore.recordAnswer({blockId:o,kind:"skipped"});_askBuoyStore.askBuoyStore.addUser(s);g(s)},[g]);const $=(0,_react.useCallback)(()=>{const{messages:e,busy:s}=_askBuoyStore.askBuoyStore.getState();if(s||!u.current)return;const o=[...e].reverse().find(n=>n.role==="user");if(!o)return;g(o.text)},[g]);const S=(0,_react.useCallback)(()=>{_askBuoyStore.askBuoyStore.requestStop();if(_askBuoyStore.askBuoyStore.getState().pending)_askBuoyStore.askBuoyStore.answerApproval(false);y.current?.abort();y.current=null},[]);(0,_react.useEffect)(()=>{const e=(0,_sharedUi.subscribeAccountAccess)(()=>{if(!(0,_sharedUi.hasAccountAccess)())S()});return()=>{e();S()}},[S]);(0,_react.useEffect)(()=>{if(!p)S()},[p,S]);(0,_react.useEffect)(()=>{if(r.queued.length===0)return;if((0,_askBuoyStore.turnPhaseOf)(r)!=="idle")return;if((0,_askBuoyStore.queuePauseReason)(r)!==null)return;const e=_askBuoyStore.askBuoyStore.shiftQueued();if(e)d(e.text)},[r,d]);const L=(0,_react.useCallback)(e=>_askBuoyStore.askBuoyStore.takeQueuedToDraft(e),[]);const U=(0,_react.useCallback)(e=>_askBuoyStore.askBuoyStore.removeQueued(e),[]);const j=(0,_react.useCallback)(()=>{y.current?.abort();y.current=null;(0,_resetConversation.clearConversation)()},[]);const D=(0,_react.useCallback)(()=>(0,_resetConversation.resetConversation)({dispatch:_sharedUi.dispatchToolAction,undoFirst:true}),[]);const E=(0,_react.useCallback)(async e=>{const s=_askBuoyStore.askBuoyStore.getLedger();if(!s){_askBuoyStore.askBuoyStore.setNotice(`${e.label} couldn't run \u2014 no active Ask Buoy session.`);return}const o=t?.tools?.length?[..._agentCore.CATALOG,...t.tools]:void 0;if(e.targetDigest){const i=await(0,_agentCore.readTargetDigest)({toolId:e.toolId,action:e.action,params:e.params??{},dispatch:l,catalog:o});if(i!==void 0&&i!==e.targetDigest){_askBuoyStore.askBuoyStore.addNote(`\u201C${e.label}\u201D wasn't applied \u2014 what it would change has moved on since the app restarted. Nothing was written. Ask again if you still want it.`);return}}const n=await(0,_agentCore.runGatedAction)({toolId:e.toolId,action:e.action,params:e.params??{},dispatch:l,ledger:s,policy:m(),isRelease,catalog:o});if(n.ok){_askBuoyStore.askBuoyStore.addNote(`Applied \u201C${e.label}\u201D, which was still waiting when the app restarted. Whatever else that answer was going to do is gone \u2014 ask again if there was more to it.`)}else{_askBuoyStore.askBuoyStore.setNotice(`${e.label} failed \u2014 ${n.error}`)}},[t,m]);const G=(0,_react.useCallback)(e=>{const s=_askBuoyStore.askBuoyStore.getState().pending;const o=typeof e==="boolean"?e:e.approved;_askBuoyStore.askBuoyStore.answerApproval(e);if(!s?.restored)return;if(!o){_askBuoyStore.askBuoyStore.addNote(`Skipped \u201C${s.label}\u201D. Nothing was changed.`);return}void E(s)},[E]);const K=(0,_react.useCallback)(e=>{_askBuoyStore.askBuoyStore.recordAnswer(e);const s=questionBehind(e.blockId);d(s?`${s} \u2014 ${(0,_agentCore.answerToText)(e)}`:(0,_agentCore.answerToText)(e))},[d]);const Q=(0,_react.useCallback)(async(e,s)=>{if(!(0,_sharedUi.hasAccountAccess)()||!c.current){_askBuoyStore.askBuoyStore.setNotice("Ask Buoy requires Pro access.");return}if(e.send){d(e.send);return}if(!e.dispatch)return;const o=`${s}:${e.label}`;const n=_askBuoyStore.askBuoyStore.getLedger();if(!n){_askBuoyStore.askBuoyStore.setNotice(`${e.label} failed \u2014 no active Ask Buoy session.`);return}_askBuoyStore.askBuoyStore.setActionState(o,"running");const i=await(0,_agentCore.runGatedAction)({toolId:e.dispatch.toolId,action:e.dispatch.action,params:e.dispatch.params??{},dispatch:l,ledger:n,policy:m(),isRelease,catalog:t?.tools?.length?[..._agentCore.CATALOG,...t.tools]:void 0});if(i.ok){_askBuoyStore.askBuoyStore.setActionState(o,"done")}else{_askBuoyStore.askBuoyStore.setActionState(o,"failed");_askBuoyStore.askBuoyStore.setNotice(`${e.label} failed \u2014 ${i.error}`)}},[d,t,m]);return{state:r,send:d,stop:S,reset:j,undoThenReset:D,approve:G,retry:$,answer:K,runAction:Q,editQueued:L,removeQueued:U,configured:f,toolCount:Object.keys(k).length,availableToolIds:Object.keys(k)}}
@@ -1,3 +1,3 @@
1
- "use strict";import{useCallback as a,useEffect as g,useMemo as A,useRef as p,useState as P}from"react";import{Alert as W,Animated as I,StyleSheet as we,Text as Ce,View as G}from"react-native";import{isReversible as xe}from"@buoy-gg/agent-core";import{dispatchToolAction as Be,FeatureGate as $e,Info as Pe,JsModal as Ie,ModalHeader as H,night as f,setToolAttention as l,useSafeAreaInsets as He}from"@buoy-gg/shared-ui";import{BlockHandlersProvider as Le}from"../blocks";import{ApprovalCard as Me}from"./ApprovalCard";import{ChangesBar as Oe,useLedgerEntries as Re}from"./ChangesBar";import{ruleStatesFrom as De}from"../blocks/ruleStates";import{Composer as Ke}from"./Composer";import{KeyboardPad as Ee}from"./KeyboardPad";import{AskBuoyHeader as Ne}from"./AskBuoyHeader";import{AskBuoySettings as je}from"./AskBuoySettings";import{EmptyState as Fe}from"./EmptyState";import{MessageList as qe,transcriptToText as Ue}from"./MessageList";import{QueuedMessages as Ve}from"./QueuedMessages";import{askBuoyStore as i,queuePauseReason as _e}from"../store/askBuoyStore";import{TICKET_PROMPT as ze}from"../store/ticketPrompt";import{useAskBuoy as Qe}from"../store/useAskBuoy";import{useAskBuoySettings as We}from"../store/useAskBuoySettings";import{jsx as n,jsxs as T,Fragment as Ge}from"react/jsx-runtime";export function AskBuoyModal({visible:w,onClose:M,onBack:O,onMinimize:m,persistenceKey:J,config:y}){const{state:e,send:h,stop:C,reset:b,undoThenReset:R,approve:X,retry:Y,answer:D,runAction:K,editQueued:Z,removeQueued:ee,configured:x,toolCount:te,availableToolIds:se}=Qe(y);const[ne,oe]=P(false);const re=a(()=>{C();M()},[C,M]);const ae=a(()=>i.clearDraft(),[]);const[k,B]=P(false);const ie=a(()=>B(false),[]);const le=a(()=>B(true),[]);const u=!w;const E=!!e.pending||!!e.awaitingBlockId;const o=e.messages[e.messages.length-1];const v=p(false);const N=p(e.busy);g(()=>{if(u&&N.current&&!e.busy)v.current=true;if(!u)v.current=false;N.current=e.busy},[u,e.busy]);g(()=>{if(!u){l("ask-buoy",null);return}if(E){l("ask-buoy",{kind:"needsInput",label:e.pending?"Needs your approval":"Has a question for you"})}else if(v.current&&o?.role==="assistant"&&o.error){l("ask-buoy",{kind:"failed",label:"The last turn failed"})}else if(v.current&&!e.busy){l("ask-buoy",{kind:"done",label:"Finished"})}else{l("ask-buoy",null)}},[u,E,e.busy,e.pending,o]);g(()=>()=>l("ask-buoy",null),[]);g(()=>{if(e.pending&&k)B(false)},[e.pending,k]);const ue=He({minBottom:16});const[ce,de]=P("bottomSheet");const ge=ce==="floating"?0:ue.bottom;const pe=a(()=>{const t=i.getLedger();if(!t)return;void(async()=>{const s=await t.revertAll(Be);if(s.failed.length===0){i.setNotice(null);return}const r=s.failed.map(d=>`${d.label} (${d.error})`).join("; ");i.setNotice(`Couldn't undo ${s.failed.length} change${s.failed.length===1?"":"s"} \u2014 ${r}`)})()},[]);const fe=a(()=>oe(t=>!t),[]);const c=p(new I.Value(560)).current;const $=p(false);const j=a(()=>{if($.current)return;$.current=true;c.stopAnimation(t=>{const s=typeof t==="number"&&t>200?t:560;I.timing(c,{toValue:120,duration:220,useNativeDriver:false}).start(()=>{setTimeout(()=>{I.spring(c,{toValue:s,friction:9,useNativeDriver:false}).start(()=>{$.current=false})},2500)})})},[c]);const S=A(()=>{const t=e.messages[e.messages.length-1];if(!t||t.role!=="assistant")return"";const s=t.blocks.filter(r=>r.block.kind==="peek").length;return s>0?`${t.id}:${s}`:""},[e.messages]);const F=p("");g(()=>{if(S&&S!==F.current&&y?.peek!==false)j();F.current=S},[S,j,y]);const me=a(()=>{const t=i.getLedger();const s=t?.list().filter(r=>!r.undoneAt&&xe(r.effect)).length??0;if(s===0){b();return}W.alert("Undo changes first?",`Ask Buoy made ${s} change${s===1?"":"s"} that can still be undone. Clearing the conversation loses the only automatic undo for ${s===1?"it":"them"}.`,[{text:"Undo, then clear",onPress:()=>{void(async()=>{const r=await R();if(r.cleared)return;const d=r.reverted+r.failed.length;const Te=r.failed.map(Q=>`${Q.label} (${Q.error})`).join("\n");W.alert(`Couldn't undo ${r.failed.length} of ${d} change${d===1?"":"s"}`,`${Te}
1
+ "use strict";import{useCallback as a,useEffect as y,useMemo as w,useRef as h,useState as H}from"react";import{Alert as Y,Animated as R,Pressable as Ie,StyleSheet as Pe,Text as O,View as B}from"react-native";import{isReversible as $e}from"@buoy-gg/agent-core";import{dispatchToolAction as He,FeatureGate as Re,Info as X,JsModal as Oe,ModalHeader as D,night as i,setToolAttention as u,useSafeAreaInsets as De}from"@buoy-gg/shared-ui";import{BlockHandlersProvider as Ne}from"../blocks";import{ApprovalCard as Le}from"./ApprovalCard";import{ChangesBar as Me,useLedgerEntries as Ke}from"./ChangesBar";import{ruleStatesFrom as Ee}from"../blocks/ruleStates";import{Composer as je}from"./Composer";import{KeyboardPad as qe}from"./KeyboardPad";import{AskBuoyHeader as ze}from"./AskBuoyHeader";import{AskBuoySettings as Fe}from"./AskBuoySettings";import{EmptyState as Ve}from"./EmptyState";import{MessageList as Ue,transcriptToText as _e}from"./MessageList";import{QueuedMessages as Qe}from"./QueuedMessages";import{askBuoyStore as l,queuePauseReason as We}from"../store/askBuoyStore";import{TICKET_PROMPT as Ge}from"../store/ticketPrompt";import{useAskBuoy as Je}from"../store/useAskBuoy";import{useAskBuoySettings as Ye}from"../store/useAskBuoySettings";import{askBuoySettings as Xe}from"../store/askBuoySettings";import{jsx as o,jsxs as d,Fragment as Ze}from"react/jsx-runtime";export function AskBuoyModal({visible:x,onClose:N,onBack:L,onMinimize:b,persistenceKey:Z,config:g}){const{state:e,send:k,stop:C,reset:S,undoThenReset:M,approve:ee,retry:te,answer:K,runAction:E,editQueued:oe,removeQueued:se,configured:I,toolCount:ne,availableToolIds:re}=Je(g);const[ae,ie]=H(false);const le=a(()=>{C();N()},[C,N]);const ce=a(()=>l.clearDraft(),[]);const[v,P]=H(false);const ue=a(()=>P(false),[]);const de=a(()=>P(true),[]);const p=!x;const j=!!e.pending||!!e.awaitingBlockId;const n=e.messages[e.messages.length-1];const A=h(false);const q=h(e.busy);y(()=>{if(p&&q.current&&!e.busy)A.current=true;if(!p)A.current=false;q.current=e.busy},[p,e.busy]);y(()=>{if(!p){u("ask-buoy",null);return}if(j){u("ask-buoy",{kind:"needsInput",label:e.pending?"Needs your approval":"Has a question for you"})}else if(A.current&&n?.role==="assistant"&&n.error){u("ask-buoy",{kind:"failed",label:"The last turn failed"})}else if(A.current&&!e.busy){u("ask-buoy",{kind:"done",label:"Finished"})}else{u("ask-buoy",null)}},[p,j,e.busy,e.pending,n]);y(()=>()=>u("ask-buoy",null),[]);y(()=>{if(e.pending&&v)P(false)},[e.pending,v]);const ge=De({minBottom:16});const[pe,fe]=H("bottomSheet");const me=pe==="floating"?0:ge.bottom;const ye=a(()=>{const t=l.getLedger();if(!t)return;void(async()=>{const s=await t.revertAll(He);if(s.failed.length===0){l.setNotice(null);return}const r=s.failed.map(m=>`${m.label} (${m.error})`).join("; ");l.setNotice(`Couldn't undo ${s.failed.length} change${s.failed.length===1?"":"s"} \u2014 ${r}`)})()},[]);const he=a(()=>ie(t=>!t),[]);const f=h(new R.Value(560)).current;const $=h(false);const z=a(()=>{if($.current)return;$.current=true;f.stopAnimation(t=>{const s=typeof t==="number"&&t>200?t:560;R.timing(f,{toValue:120,duration:220,useNativeDriver:false}).start(()=>{setTimeout(()=>{R.spring(f,{toValue:s,friction:9,useNativeDriver:false}).start(()=>{$.current=false})},2500)})})},[f]);const T=w(()=>{const t=e.messages[e.messages.length-1];if(!t||t.role!=="assistant")return"";const s=t.blocks.filter(r=>r.block.kind==="peek").length;return s>0?`${t.id}:${s}`:""},[e.messages]);const F=h("");y(()=>{if(T&&T!==F.current&&g?.peek!==false)z();F.current=T},[T,z,g]);const be=a(()=>{const t=l.getLedger();const s=t?.list().filter(r=>!r.undoneAt&&$e(r.effect)).length??0;if(s===0){S();return}Y.alert("Undo changes first?",`Ask Buoy made ${s} change${s===1?"":"s"} that can still be undone. Clearing the conversation loses the only automatic undo for ${s===1?"it":"them"}.`,[{text:"Undo, then clear",onPress:()=>{void(async()=>{const r=await M();if(r.cleared)return;const m=r.reverted+r.failed.length;const Ce=r.failed.map(J=>`${J.label} (${J.error})`).join("\n");Y.alert(`Couldn't undo ${r.failed.length} of ${m} change${m===1?"":"s"}`,`${Ce}
2
2
 
3
- Still applied in the app. Clear the conversation anyway?`,[{text:"Keep conversation",style:"cancel"},{text:"Clear anyway",style:"destructive",onPress:b}])})()}},{text:"Clear anyway",style:"destructive",onPress:b},{text:"Cancel",style:"cancel"}])},[b,R]);const ye=A(()=>{const t=e.messages[e.messages.length-1];if(!t||t.role!=="assistant"||!t.streaming)return null;return t.toolCalls.find(s=>s.status==="running")?.label??null},[e.messages]);const q=Re(i.getLedger());const U=A(()=>De(q),[q]);const he=A(()=>({answer:D,runAction:(t,s)=>{if(t.minimize){m?.({mode:"bottomSheet"});return}return K(t,s)},answered:e.answers,actionState:e.actionState,busy:e.busy,supports:{openTool:false,minimize:!!m,dispatch:true},rules:U}),[D,K,m,e.answers,e.actionState,e.busy,U]);const be=!e.busy&&o?.role==="assistant"&&!!o.error;const V=!e.busy&&o?.role==="assistant"&&o.stopped&&!o.error?o.id:null;const ke=_e(e);const{showThinking:_,readOnly:z}=We();const ve=a(()=>Ue(e.messages,_),[e.messages,_]);const Se=a(()=>h(ze),[h]);const Ae=k?T(H,{children:[n(H.Navigation,{onBack:ie}),n(H.Content,{title:"Settings",subtitle:"Ask Buoy",testID:"buoy-ask-buoy-settings-title"})]}):n(Ne,{configured:x,busy:e.busy,failed:be,activeLabel:ye,awaitingApproval:!!e.pending,startedAt:o?.role==="assistant"&&o.streaming?o.startedAt??null:null,stopping:e.stopping,readOnly:z,toolCount:te,hasMessages:e.messages.length>0,onBack:O,onReset:me,getTranscript:ve,onOpenSettings:le,onTicket:Se});return n(Ie,{visible:w,onClose:re,disableScrollWrapper:true,background:false,initialHeight:560,animatedHeight:c,header:{customContent:Ae,showToggleButton:false},onBack:O,onMinimize:m,onModeChange:de,persistenceKey:J??"buoy-ask-buoy",enablePersistence:true,children:n(Le,{value:he,children:T(G,{style:[L.root,{paddingBottom:ge}],children:[n(Oe,{ledger:i.getLedger(),onUndoAll:pe,expanded:ne,onToggle:fe}),e.notice&&T(G,{style:L.notice,testID:"buoy-ask-buoy-notice",children:[n(Pe,{size:14,color:f.color.info}),n(Ce,{style:L.noticeText,children:e.notice})]}),n(Ee,{children:n($e,{featureName:"Ask Buoy",children:k?n(je,{}):T(Ge,{children:[n(qe,{messages:e.messages,onRetry:Y,waitingOnUser:!!e.pending||!!e.awaitingBlockId,ListEmptyComponent:n(Fe,{configured:x,onPick:h,availableToolIds:se,readOnly:z||!!y?.policy?.readOnly})}),n(Ve,{items:e.queued,paused:ke,onEdit:Z,onRemove:ee}),e.pending&&n(Me,{pending:e.pending,onAnswer:X}),n(Ke,{onSend:h,onStop:C,busy:e.busy,draft:e.draft,onDraftTaken:ae,disabled:!x,focusKey:V,canFocus:w,placeholder:V?"Tell it what to do differently\u2026":e.awaitingBlockId?"Pick an option above, or type\u2026":void 0})]})})})]})})})}const L=we.create({root:{flex:1,backgroundColor:"transparent"},notice:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:f.gutter,paddingVertical:10,backgroundColor:f.color.infoSoft},noticeText:{flex:1,color:f.color.text,fontSize:f.font.caption,lineHeight:18}});
3
+ Still applied in the app. Clear the conversation anyway?`,[{text:"Keep conversation",style:"cancel"},{text:"Clear anyway",style:"destructive",onPress:S}])})()}},{text:"Clear anyway",style:"destructive",onPress:S},{text:"Cancel",style:"cancel"}])},[S,M]);const ke=w(()=>{const t=e.messages[e.messages.length-1];if(!t||t.role!=="assistant"||!t.streaming)return null;return t.toolCalls.find(s=>s.status==="running")?.label??null},[e.messages]);const V=Ke(l.getLedger());const U=w(()=>Ee(V),[V]);const Se=w(()=>({answer:K,runAction:(t,s)=>{if(t.minimize){b?.({mode:"bottomSheet"});return}return E(t,s)},answered:e.answers,actionState:e.actionState,busy:e.busy,supports:{openTool:false,minimize:!!b,dispatch:true},rules:U}),[K,E,b,e.answers,e.actionState,e.busy,U]);const ve=!e.busy&&n?.role==="assistant"&&!!n.error;const _=!e.busy&&n?.role==="assistant"&&n.stopped&&!n.error?n.id:null;const Ae=We(e);const{showThinking:Q,readOnly:W,hostedNoticeSeen:Te}=Ye();const G=g?.hosted===true&&!Te;const we=a(()=>_e(e.messages,Q),[e.messages,Q]);const Be=a(()=>k(Ge),[k]);const xe=v?d(D,{children:[o(D.Navigation,{onBack:ue}),o(D.Content,{title:"Settings",subtitle:"Ask Buoy",testID:"buoy-ask-buoy-settings-title"})]}):o(ze,{configured:I,busy:e.busy,failed:ve,activeLabel:ke,awaitingApproval:!!e.pending,startedAt:n?.role==="assistant"&&n.streaming?n.startedAt??null:null,stopping:e.stopping,readOnly:W,toolCount:ne,hasMessages:e.messages.length>0,onBack:L,onReset:be,getTranscript:we,onOpenSettings:de,onTicket:Be});return o(Oe,{visible:x,onClose:le,disableScrollWrapper:true,background:false,initialHeight:560,animatedHeight:f,header:{customContent:xe,showToggleButton:false},onBack:L,onMinimize:b,onModeChange:fe,persistenceKey:Z??"buoy-ask-buoy",enablePersistence:true,children:o(Ne,{value:Se,children:d(B,{style:[c.root,{paddingBottom:me}],children:[o(Me,{ledger:l.getLedger(),onUndoAll:ye,expanded:ae,onToggle:he}),G&&d(B,{style:c.notice,testID:"buoy-ask-buoy-hosted-notice",children:[o(X,{size:14,color:i.color.info}),d(B,{style:{flex:1,gap:8},children:[o(O,{style:c.noticeText,children:"Hosted Ask Buoy (beta) sends your question, and the app data it needs to answer, to OpenAI through OpenRouter. Buoy keeps the cost of each answer, never the chat. Your plan includes monthly credits."}),o(Ie,{testID:"buoy-ask-buoy-hosted-notice-ok",accessibilityRole:"button",onPress:()=>Xe.set("hostedNoticeSeen",true),style:({pressed:t})=>[c.noticeButton,t&&{opacity:.7}],children:o(O,{style:c.noticeButtonText,children:"Got it"})})]})]}),e.notice&&d(B,{style:c.notice,testID:"buoy-ask-buoy-notice",children:[o(X,{size:14,color:i.color.info}),o(O,{style:c.noticeText,children:e.notice})]}),o(qe,{children:o(Re,{featureName:"Ask Buoy",children:v?o(Fe,{}):d(Ze,{children:[o(Ue,{messages:e.messages,onRetry:te,waitingOnUser:!!e.pending||!!e.awaitingBlockId,ListEmptyComponent:o(Ve,{configured:I,onPick:k,availableToolIds:re,readOnly:W||!!g?.policy?.readOnly})}),o(Qe,{items:e.queued,paused:Ae,onEdit:oe,onRemove:se}),e.pending&&o(Le,{pending:e.pending,onAnswer:ee}),o(je,{onSend:k,onStop:C,busy:e.busy,draft:e.draft,onDraftTaken:ce,disabled:!I||G,focusKey:_,canFocus:x,placeholder:_?"Tell it what to do differently\u2026":e.awaitingBlockId?"Pick an option above, or type\u2026":void 0})]})})})]})})})}const c=Pe.create({root:{flex:1,backgroundColor:"transparent"},notice:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:i.gutter,paddingVertical:10,backgroundColor:i.color.infoSoft},noticeText:{flex:1,color:i.color.text,fontSize:i.font.caption,lineHeight:18},noticeButton:{alignSelf:"flex-start",paddingHorizontal:12,paddingVertical:6,borderRadius:i.radius.row,backgroundColor:i.color.button},noticeButtonText:{color:i.color.text,fontSize:i.font.caption,fontWeight:"600"}});
@@ -1 +1 @@
1
- "use strict";import{Pressable as y,ScrollView as p,StyleSheet as i,Text as s,View as l}from"react-native";import{AlertTriangle as g,night as e,ToggleRow as d}from"@buoy-gg/shared-ui";import{useAskBuoySettings as b}from"../store/useAskBuoySettings";import{askBuoySettings as u}from"../store/askBuoySettings";import{askBuoyStore as f}from"../store/askBuoyStore";import{useAskBuoyState as w}from"../store/useAskBuoy";import{jsx as o,jsxs as a}from"react/jsx-runtime";export function AskBuoySettings(){const r=b();const c=w().trusted;return a(p,{style:t.scroll,contentContainerStyle:t.content,testID:"buoy-ask-buoy-settings",children:[o(s,{style:t.section,children:"CHAT"}),o(d,{testID:"buoy-ask-buoy-setting-thinking",label:"Show agent thinking",description:"Adds a collapsed strip under each answer: the model's reasoning, and every step it ran with its parameters, result, duration and token cost. Copy includes the steps and reasoning while this is on, so you can read the run outside the app.",value:r.showThinking,onValueChange:n=>u.set("showThinking",n)}),o(s,{style:t.note,children:"Not every model reports reasoning. Claude thinks by default; most OpenAI models return none, and the strip then shows the steps alone."}),o(s,{style:t.section,children:"PERMISSIONS"}),o(d,{testID:"buoy-ask-buoy-setting-readonly",label:"Read only",description:"Inspect the app, change nothing. Every write and simulation is refused until this is off. Undo still works \u2014 putting things back is the safe direction.",value:r.readOnly,onValueChange:n=>u.set("readOnly",n)}),r.readOnly?o(s,{style:t.note,testID:"buoy-ask-buoy-readonly-note",children:"On across reloads until you turn it off here. The header says \u201CRead only\u201D while it is on. It adds to whatever this app already restricts \u2014 it never loosens anything."}):null,o(d,{testID:"buoy-ask-buoy-setting-bypass",tone:"warning",emphasizeLabel:r.bypassApprovals,disabled:r.readOnly,label:"Skip approval prompts",description:r.readOnly?"Unavailable while Read only is on \u2014 nothing can be approved.":"Runs every action the moment the agent calls it, with no Allow card \u2014 including the destructive ones that wipe or reset data.",value:r.bypassApprovals,onValueChange:n=>u.set("bypassApprovals",n)}),r.bypassApprovals&&!r.readOnly?a(l,{style:t.warning,testID:"buoy-ask-buoy-bypass-warning",children:[o(g,{size:14,color:e.color.warning}),o(s,{style:t.warningText,children:"Nothing will ask before a change lands. A wipe or a reset runs on the model's word alone, and Undo only reverses the changes that can be reversed \u2014 the bar tells you which. This stays on across reloads and app restarts until you turn it off here, so leave it off on any device holding data you care about. It does not widen what the agent may reach: read-only mode, this app's deny list and the release-build refusals still apply."})]}):o(s,{style:t.note,children:"On by default for destructive actions only \u2014 reads and ordinary writes already run without asking, and the changes bar records them."}),c.length>0?a(l,{style:t.trustedBox,testID:"buoy-ask-buoy-trusted",children:[o(s,{style:t.section,children:"ALLOWED WITHOUT ASKING \u2014 THIS CHAT"}),c.map(n=>a(l,{style:t.trustedRow,children:[o(s,{style:t.trustedLabel,numberOfLines:2,children:n.label}),o(y,{testID:`buoy-ask-buoy-untrust-${n.key}`,accessibilityRole:"button",onPress:()=>f.untrust(n.key),style:({pressed:h})=>[t.forget,h&&{opacity:.7}],hitSlop:6,children:o(s,{style:t.forgetText,children:"Ask again"})})]},n.key))]}):null]})}const t=i.create({scroll:{flex:1},content:{padding:e.gutter,gap:10,paddingBottom:32},section:{color:e.color.textTertiary,fontSize:10,fontWeight:"700",letterSpacing:.6,paddingHorizontal:4,paddingTop:4},warning:{flexDirection:"row",gap:8,padding:e.cardPad,borderRadius:e.radius.card,borderWidth:i.hairlineWidth,borderColor:e.color.warning,backgroundColor:e.color.surface},warningText:{flex:1,color:e.color.warning,fontSize:e.font.micro,lineHeight:16},trustedBox:{gap:6,paddingTop:6},trustedRow:{flexDirection:"row",alignItems:"center",gap:10,padding:e.cardPad,borderRadius:e.radius.card,borderWidth:i.hairlineWidth,borderColor:e.color.border,backgroundColor:e.color.surface},trustedLabel:{flex:1,color:e.color.text,fontSize:e.font.caption,lineHeight:18},forget:{paddingHorizontal:10,paddingVertical:6,borderRadius:e.radius.row,backgroundColor:e.color.button},forgetText:{color:e.color.text,fontSize:e.font.micro,fontWeight:"600"},note:{color:e.color.textTertiary,fontSize:e.font.micro,lineHeight:16,paddingHorizontal:4}});
1
+ "use strict";import{useCallback as b,useEffect as f,useState as m}from"react";import{Pressable as g,ScrollView as w,StyleSheet as u,Text as s,View as c}from"react-native";import{AlertTriangle as k,night as t,ToggleRow as h}from"@buoy-gg/shared-ui";import{useAskBuoySettings as S}from"../store/useAskBuoySettings";import{askBuoySettings as y}from"../store/askBuoySettings";import{askBuoyStore as p}from"../store/askBuoyStore";import{useAskBuoyState as T}from"../store/useAskBuoy";import{jsx as o,jsxs as i,Fragment as x}from"react/jsx-runtime";export function AskBuoySettings(){const n=S();const a=T().trusted;return i(w,{style:e.scroll,contentContainerStyle:e.content,testID:"buoy-ask-buoy-settings",children:[o(I,{}),o(s,{style:e.section,children:"CHAT"}),o(h,{testID:"buoy-ask-buoy-setting-thinking",label:"Show agent thinking",description:"Adds a collapsed strip under each answer: the model's reasoning, and every step it ran with its parameters, result, duration and token cost. Copy includes the steps and reasoning while this is on, so you can read the run outside the app.",value:n.showThinking,onValueChange:r=>y.set("showThinking",r)}),o(s,{style:e.note,children:"Not every model reports reasoning. Claude thinks by default; most OpenAI models return none, and the strip then shows the steps alone."}),o(s,{style:e.section,children:"PERMISSIONS"}),o(h,{testID:"buoy-ask-buoy-setting-readonly",label:"Read only",description:"Inspect the app, change nothing. Every write and simulation is refused until this is off. Undo still works \u2014 putting things back is the safe direction.",value:n.readOnly,onValueChange:r=>y.set("readOnly",r)}),n.readOnly?o(s,{style:e.note,testID:"buoy-ask-buoy-readonly-note",children:"On across reloads until you turn it off here. The header says \u201CRead only\u201D while it is on. It adds to whatever this app already restricts \u2014 it never loosens anything."}):null,o(h,{testID:"buoy-ask-buoy-setting-bypass",tone:"warning",emphasizeLabel:n.bypassApprovals,disabled:n.readOnly,label:"Skip approval prompts",description:n.readOnly?"Unavailable while Read only is on \u2014 nothing can be approved.":"Runs every action the moment the agent calls it, with no Allow card \u2014 including the destructive ones that wipe or reset data.",value:n.bypassApprovals,onValueChange:r=>y.set("bypassApprovals",r)}),n.bypassApprovals&&!n.readOnly?i(c,{style:e.warning,testID:"buoy-ask-buoy-bypass-warning",children:[o(k,{size:14,color:t.color.warning}),o(s,{style:e.warningText,children:"Nothing will ask before a change lands. A wipe or a reset runs on the model's word alone, and Undo only reverses the changes that can be reversed \u2014 the bar tells you which. This stays on across reloads and app restarts until you turn it off here, so leave it off on any device holding data you care about. It does not widen what the agent may reach: read-only mode, this app's deny list and the release-build refusals still apply."})]}):o(s,{style:e.note,children:"On by default for destructive actions only \u2014 reads and ordinary writes already run without asking, and the changes bar records them."}),a.length>0?i(c,{style:e.trustedBox,testID:"buoy-ask-buoy-trusted",children:[o(s,{style:e.section,children:"ALLOWED WITHOUT ASKING \u2014 THIS CHAT"}),a.map(r=>i(c,{style:e.trustedRow,children:[o(s,{style:e.trustedLabel,numberOfLines:2,children:r.label}),o(g,{testID:`buoy-ask-buoy-untrust-${r.key}`,accessibilityRole:"button",onPress:()=>p.untrust(r.key),style:({pressed:l})=>[e.forget,l&&{opacity:.7}],hitSlop:6,children:o(s,{style:e.forgetText,children:"Ask again"})})]},r.key))]}):null]})}function A(n){const a=Date.parse(n.length===10?`${n}T00:00:00Z`:n);if(Number.isNaN(a))return n;const r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];const l=new Date(a);return`${r[l.getUTCMonth()]} ${l.getUTCDate()}`}function I(){const n=p.getUsageReader();const[a,r]=m({kind:"loading"});const l=b(()=>{if(!n)return;r({kind:"loading"});n().then(d=>r({kind:"ok",usage:d})).catch(d=>r({kind:"error",message:d instanceof Error?d.message:"Could not load credits."}))},[n]);f(l,[l]);if(!n)return null;return i(c,{testID:"buoy-ask-buoy-credits",children:[o(s,{style:e.section,children:"HOSTED AI CREDITS"}),i(c,{style:e.trustedRow,children:[o(c,{style:{flex:1,gap:2},children:a.kind==="ok"?i(x,{children:[i(s,{style:e.trustedLabel,children:[a.usage.creditsLeft.toLocaleString()," of ",a.usage.grantCredits.toLocaleString()," credits left"]}),i(s,{style:e.note,children:[a.usage.resetAt?`Resets ${A(a.usage.resetAt)}. `:"","1 credit is $0.001 of AI use, included with your plan."]})]}):a.kind==="error"?o(s,{style:e.note,children:a.message}):o(s,{style:e.note,children:"Loading\u2026"})}),o(g,{testID:"buoy-ask-buoy-credits-refresh",accessibilityRole:"button",onPress:l,style:({pressed:d})=>[e.forget,d&&{opacity:.7}],hitSlop:6,children:o(s,{style:e.forgetText,children:"Refresh"})})]})]})}const e=u.create({scroll:{flex:1},content:{padding:t.gutter,gap:10,paddingBottom:32},section:{color:t.color.textTertiary,fontSize:10,fontWeight:"700",letterSpacing:.6,paddingHorizontal:4,paddingTop:4},warning:{flexDirection:"row",gap:8,padding:t.cardPad,borderRadius:t.radius.card,borderWidth:u.hairlineWidth,borderColor:t.color.warning,backgroundColor:t.color.surface},warningText:{flex:1,color:t.color.warning,fontSize:t.font.micro,lineHeight:16},trustedBox:{gap:6,paddingTop:6},trustedRow:{flexDirection:"row",alignItems:"center",gap:10,padding:t.cardPad,borderRadius:t.radius.card,borderWidth:u.hairlineWidth,borderColor:t.color.border,backgroundColor:t.color.surface},trustedLabel:{flex:1,color:t.color.text,fontSize:t.font.caption,lineHeight:18},forget:{paddingHorizontal:10,paddingVertical:6,borderRadius:t.radius.row,backgroundColor:t.color.button},forgetText:{color:t.color.text,fontSize:t.font.micro,fontWeight:"600"},note:{color:t.color.textTertiary,fontSize:t.font.micro,lineHeight:16,paddingHorizontal:4}});
@@ -1 +1 @@
1
- "use strict";import{memo as N,useCallback as m,useEffect as M,useRef as S,useState as T}from"react";import{ActivityIndicator as j,FlatList as U,Pressable as x,StyleSheet as k,Text as u,View as l}from"react-native";import{AlertTriangle as C,Check as D,ChevronDown as z,ChevronRight as R,Copy as G,night as o,X as Y}from"@buoy-gg/shared-ui";import{toolTitle as _}from"@buoy-gg/agent-core";import{BlockRenderer as v}from"../blocks/BlockRenderer";import{blocksToText as q}from"../blocks/blockText";import{groupCalls as X,turnFooter as J}from"../store/activityGroups";import{placeBlocks as K}from"../store/blockPlacement";import{askBuoyStore as Q}from"../store/askBuoyStore";import{Markdown as Z}from"./Markdown";import{ThinkingStrip as tt}from"./ThinkingStrip";import{TypingDots as et}from"./TypingDots";import{useCopyAction as ot}from"./useCopyAction";import{traceToText as rt}from"../store/traceText";import{useAskBuoySettings as I}from"../store/useAskBuoySettings";import{jsx as r,jsxs as y}from"react/jsx-runtime";function B({status:t}){switch(t){case"running":return r(j,{size:"small",color:o.color.textSecondary});case"ok":return r(l,{style:[e.mark,e.markOk],children:r(D,{size:10,color:o.color.onAccent})});case"failed":return r(l,{style:[e.mark,e.markFailed],children:r(Y,{size:10,color:o.color.text})});case"refused":return r(l,{style:[e.mark,e.markRefused],children:r(C,{size:10,color:o.color.onAccent})});case"declined":case"stopped":return r(l,{style:[e.mark,e.markNotRun],children:r(l,{style:e.markNotRunBar})})}}function nt(t){if(t.status==="running")return{text:"",tone:"muted"};if(t.status==="refused")return{text:"Refused",tone:"warning"};if(t.status==="failed")return{text:"Failed",tone:"danger"};if(t.status==="declined")return{text:"You declined",tone:"muted"};if(t.status==="stopped")return{text:"Not run \u2014 stopped",tone:"muted"};if(t.verification?.status==="verified")return{text:"Verified",tone:"ok"};if(t.verification?.status==="unverified")return{text:"Done \xB7 not yet visible",tone:"muted"};if(t.verification?.status==="failed")return{text:"Done \xB7 check failed",tone:"warning"};return{text:t.summary||"Done",tone:"muted"}}const it=t=>t.status==="failed"||t.status==="refused"||t.status==="declined"||t.status==="stopped";function H({call:t,receipts:i,last:s}){const[n,a]=T(false);const c=nt(t);const p=n?z:R;const g=t.status==="failed"&&t.summary&&t.summary!=="Failed"?t.summary:null;return y(l,{style:[e.row,!s&&e.rowDivider],children:[y(x,{testID:`buoy-ask-buoy-tool-${t.toolId}`,accessibilityRole:"button",accessibilityLabel:`${t.label}, ${c.text||"running"}`,accessibilityState:{expanded:n},onPress:()=>a(d=>!d),children:[y(l,{style:e.rowLine,children:[r(l,{style:e.markSlot,children:r(B,{status:t.status})}),r(u,{style:e.rowTitle,children:t.label}),c.text?r(u,{style:[e.rowStatus,c.tone==="danger"&&e.rowStatusDanger,c.tone==="warning"&&e.rowStatusWarning,c.tone==="ok"&&e.rowStatusOk],numberOfLines:1,children:c.text}):null,r(p,{size:12,color:o.color.textTertiary})]}),n&&y(l,{style:e.rowDetail,children:[r(u,{style:e.rowTool,children:_(t.toolId).toUpperCase()}),t.description?r(u,{style:e.rowDescription,children:t.description}):null,g?r(u,{style:e.rowFailure,children:g}):null,t.verification?r(u,{style:[e.rowDescription,t.verification.status==="failed"&&e.rowFailure,t.verification.status==="verified"&&e.rowVerified],testID:`buoy-ask-buoy-verification-${t.verification.status}`,children:t.verification.detail}):null]})]}),n&&i.length>0&&r(l,{style:e.rowReceipts,testID:`buoy-ask-buoy-tool-receipt-${t.toolId}`,children:i.map(d=>r(v,{block:d},d.id))})]})}function st({label:t,count:i,calls:s,receipts:n,last:a}){const[c,p]=T(false);const g=c?z:R;return y(l,{style:!a&&!c&&e.rowDivider,children:[r(x,{testID:"buoy-ask-buoy-reads-group",accessibilityRole:"button",accessibilityLabel:`${t}, ${i} reads`,accessibilityState:{expanded:c},onPress:()=>p(d=>!d),style:[e.row,c&&e.rowDivider],children:y(l,{style:e.rowLine,children:[r(l,{style:e.markSlot,children:r(B,{status:"ok"})}),r(u,{style:e.rowTitle,children:t}),y(u,{style:e.rowStatus,numberOfLines:1,children:[i," reads"]}),r(g,{size:12,color:o.color.textTertiary})]})}),c&&r(l,{style:e.groupBody,children:s.map((d,h)=>r(H,{call:d,receipts:n.get(d.id)??[],last:a&&h===s.length-1},d.id))})]})}function lt({calls:t,receipts:i}){const s=X(t);return r(l,{style:e.card,testID:"buoy-ask-buoy-activity",children:s.map((n,a)=>n.kind==="reads"?r(st,{label:n.label,count:n.count,calls:n.calls,receipts:i,last:a===s.length-1},n.id):r(H,{call:n.call,receipts:i.get(n.call.id)??[],last:a===s.length-1},n.call.id))})}function L({blocks:t}){if(t.length===0)return null;return r(l,{style:e.blocks,children:t.map(({block:i})=>r(v,{block:i},i.id))})}function at({message:t}){return r(l,{style:e.systemLine,testID:"buoy-ask-buoy-system-line",children:r(u,{style:e.systemText,children:t.text})})}function ct({message:t}){return r(l,{style:e.userWrap,children:r(l,{style:e.userBubble,children:r(u,{style:e.userText,selectable:true,children:t.text})})})}function dt({message:t,onRetry:i,waitingOnUser:s}){const{showThinking:n}=I();const a=!!t.streaming&&!s;const{nested:c,afterText:p,ask:g}=K(t.blocks,t.toolCalls.map(d=>d.id));return y(l,{style:e.assistantWrap,children:[t.toolCalls.length>0&&r(lt,{calls:t.toolCalls,receipts:c}),t.text.length>0&&r(Z,{text:t.text,style:e.assistantText}),r(L,{blocks:p}),r(L,{blocks:g}),n&&!t.streaming&&r(tt,{message:t}),a&&y(l,{style:e.waitingRow,children:[r(et,{}),t.waiting?r(u,{style:e.waitingText,testID:"buoy-ask-buoy-waiting",children:t.waiting}):null]}),t.error&&r(yt,{error:t.error,onRetry:i}),t.stopped&&!t.error&&r(ut,{onRetry:i,changed:t.toolCalls.some(d=>d.status==="ok"&&!!d.effect&&d.effect!=="read")})]})}function ut({onRetry:t,changed:i}){return y(l,{style:e.stoppedBox,testID:"buoy-ask-buoy-stopped",children:[r(u,{style:e.stoppedText,children:i?"Stopped. Changes already made are listed above.":"Stopped."}),t&&r(x,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:t,style:({pressed:s})=>[e.retry,s&&e.retryPressed],children:r(u,{style:e.retryText,children:"Try again"})})]})}function yt({error:t,onRetry:i}){const s=/fetch failed|network|ECONN|timed? ?out|socket/i.test(t);const n=s?"Couldn't reach your AI endpoint. Check the connection and try again.":"Something went wrong with that turn.";return y(l,{style:e.errorBox,testID:"buoy-ask-buoy-error",children:[r(C,{size:14,color:o.color.danger}),y(l,{style:e.errorBody,children:[r(u,{style:e.errorText,children:n}),r(u,{style:e.errorDetail,selectable:true,children:t}),i&&r(x,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:i,style:({pressed:a})=>[e.retry,a&&e.retryPressed],children:r(u,{style:e.retryText,children:"Try again"})})]})]})}export function transcriptToText(t,i=false){const s=[];for(const n of t){if(n.role==="user"){s.push(`You: ${n.text}`);continue}if(n.system){s.push(` \u2014 ${n.text}`);continue}if(i){s.push(...rt(n))}else{for(const a of n.toolCalls){const c=it(a)?` (${a.status})`:"";s.push(` \xB7 ${a.label}${a.summary?` \u2014 ${a.summary}`:""}${c}`)}}if(n.text)s.push(`Ask Buoy: ${n.text}`);for(const a of q(n.blocks.map(c=>c.block)))s.push(a);if(n.error)s.push(` ! ${n.error}`);if(n.stopped&&!n.error)s.push(" ! Stopped by the user.")}return s.join("\n")}function ft({testID:t,label:i,getText:s}){const{copied:n,copy:a}=ot(s);return y(x,{testID:t,accessibilityRole:"button",accessibilityLabel:i,onPress:a,style:({pressed:c})=>[e.copyBtn,e.iconBtn,c&&e.copyPressed],children:[n?r(D,{size:11,color:o.color.accent}):r(G,{size:11,color:o.color.textSecondary}),r(u,{style:[e.copyText,n&&e.copiedText],children:n?"Copied":i})]})}function pt({message:t}){const{showThinking:i}=I();const s=m(()=>transcriptToText(Q.getState().messages,i),[i]);const n=J(t);return y(l,{style:e.transcriptActions,children:[n?r(u,{style:e.turnFooter,testID:"buoy-ask-buoy-turn-footer",children:n}):null,r(ft,{testID:"buoy-ask-buoy-copy",label:"Copy conversation",getText:s})]})}const gt=N(function t({message:i,onRetry:s,waitingOnUser:n}){if(i.role==="user")return r(ct,{message:i});if(i.system)return r(at,{message:i});const a=!i.streaming&&!i.error;return y(l,{children:[r(dt,{message:i,onRetry:s,waitingOnUser:n}),a&&r(pt,{message:i})]})});export function MessageList({messages:t,ListHeaderComponent:i,ListEmptyComponent:s,ListFooterComponent:n,onRetry:a,waitingOnUser:c}){const p=S(null);const g=S(true);const d=S(false);const h=m(f=>{const{contentOffset:F,contentSize:P,layoutMeasurement:O}=f.nativeEvent;const V=P.height-O.height-F.y;g.current=V<80},[]);const $=m(()=>{d.current=true},[]);const W=m(f=>{if(d.current)h(f)},[h]);const A=m(f=>{d.current=false;h(f)},[h]);const w=m(()=>{if(!g.current)return;p.current?.scrollToEnd({animated:false});requestAnimationFrame(()=>p.current?.scrollToEnd({animated:false}))},[]);const b=t[t.length-1];const E=b?`${b.id}:${b.text.length}:${b.toolCalls.length}:${b.error??""}`:"";M(()=>{w()},[E,w]);return r(U,{ref:p,testID:"buoy-ask-buoy-messages-scroll",style:e.list,contentContainerStyle:e.listContent,data:t,keyExtractor:f=>f.id,renderItem:({item:f})=>r(gt,{message:f,onRetry:f.id===b?.id?a:void 0,waitingOnUser:f.id===b?.id?c:false}),onScroll:W,onScrollBeginDrag:$,onScrollEndDrag:A,onMomentumScrollEnd:h,scrollEventThrottle:32,onContentSizeChange:w,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"interactive",ListHeaderComponent:i,ListEmptyComponent:s,ListFooterComponent:n})}const e=k.create({list:{flex:1,backgroundColor:"transparent"},listContent:{paddingHorizontal:o.gutter,paddingTop:12,paddingBottom:16,gap:16,flexGrow:1},userWrap:{alignItems:"flex-end"},userBubble:{maxWidth:"84%",paddingHorizontal:14,paddingVertical:9,borderRadius:18,borderBottomRightRadius:6,backgroundColor:o.color.accentFill,borderWidth:k.hairlineWidth,borderColor:o.color.accentBorder},userText:{color:o.color.text,fontSize:o.font.row,lineHeight:21},systemLine:{alignSelf:"stretch",paddingHorizontal:12,paddingVertical:7,borderRadius:o.radius.row,backgroundColor:o.color.fill},systemText:{color:o.color.textSecondary,fontSize:o.font.micro,lineHeight:16,textAlign:"center"},assistantWrap:{alignItems:"stretch",gap:10},blocks:{gap:10},waitingRow:{flexDirection:"row",alignItems:"center",gap:8},waitingText:{color:o.color.textSecondary,fontSize:o.font.caption},assistantText:{color:o.color.text,fontSize:o.font.row,lineHeight:22,paddingHorizontal:2},card:{borderRadius:o.radius.card,borderWidth:k.hairlineWidth,borderColor:o.color.border,backgroundColor:o.color.surface,overflow:"hidden"},row:{paddingHorizontal:12,paddingVertical:10},rowDivider:{borderBottomWidth:k.hairlineWidth,borderBottomColor:o.color.separator},rowLine:{flexDirection:"row",alignItems:"center",gap:10},markSlot:{width:18,height:18,alignItems:"center",justifyContent:"center"},mark:{width:16,height:16,borderRadius:8,alignItems:"center",justifyContent:"center"},markOk:{backgroundColor:o.color.accent},markFailed:{backgroundColor:o.color.danger},markRefused:{backgroundColor:o.color.warning},markNotRun:{borderWidth:1.5,borderColor:o.color.textTertiary},markNotRunBar:{width:7,height:1.5,borderRadius:1,backgroundColor:o.color.textSecondary},rowTitle:{flex:1,color:o.color.text,fontSize:o.font.body,lineHeight:19},rowStatus:{color:o.color.textTertiary,fontSize:o.font.caption,maxWidth:120},rowStatusDanger:{color:o.color.danger},rowStatusWarning:{color:o.color.warning},rowStatusOk:{color:o.color.accent},rowVerified:{color:o.color.accent},rowDetail:{paddingLeft:28,paddingTop:8,gap:4},rowTool:{color:o.color.textTertiary,fontSize:o.font.micro,fontWeight:"600",letterSpacing:.8},rowDescription:{color:o.color.textSecondary,fontSize:o.font.caption,lineHeight:18},rowFailure:{color:o.color.danger,fontSize:o.font.caption,lineHeight:18},rowReceipts:{paddingTop:10,gap:10},groupBody:{paddingLeft:14,backgroundColor:o.color.fill},stoppedBox:{alignItems:"flex-start",gap:2,paddingHorizontal:12,paddingVertical:8},stoppedText:{color:o.color.textTertiary,fontSize:o.font.caption,lineHeight:18},errorBox:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingVertical:10,borderRadius:o.radius.row,backgroundColor:o.color.dangerSoft},errorBody:{flex:1,gap:4},errorText:{color:o.color.danger,fontSize:o.font.caption,fontWeight:"600",lineHeight:18},errorDetail:{color:o.color.textSecondary,fontSize:o.font.micro,lineHeight:15},retry:{alignSelf:"flex-start",marginTop:6,paddingHorizontal:14,paddingVertical:7,borderRadius:o.radius.row,backgroundColor:o.color.button},retryPressed:{opacity:.7},retryText:{color:o.color.accent,fontSize:o.font.caption,fontWeight:"600"},transcriptActions:{flexDirection:"row",alignItems:"center",gap:10,marginTop:8},turnFooter:{flex:1,color:o.color.textTertiary,fontSize:o.font.micro,fontVariant:["tabular-nums"]},copyBtn:{paddingHorizontal:10,paddingVertical:5,borderRadius:o.radius.badge,backgroundColor:o.color.fill},iconBtn:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8},copyPressed:{opacity:.7},copyText:{color:o.color.textSecondary,fontSize:o.font.micro,fontWeight:"600"},copiedText:{color:o.color.accent}});
1
+ "use strict";import{memo as q,useCallback as k,useEffect as j,useRef as S,useState as C}from"react";import{ActivityIndicator as M,FlatList as U,Pressable as m,StyleSheet as w,Text as u,View as a}from"react-native";import{AlertTriangle as D,Check as I,ChevronDown as R,ChevronRight as z,Copy as Y,night as o,X as G}from"@buoy-gg/shared-ui";import{toolTitle as X}from"@buoy-gg/agent-core";import{BlockRenderer as v}from"../blocks/BlockRenderer";import{blocksToText as J}from"../blocks/blockText";import{groupCalls as K,turnFooter as Q}from"../store/activityGroups";import{placeBlocks as Z}from"../store/blockPlacement";import{askBuoyStore as B}from"../store/askBuoyStore";import{Markdown as ee}from"./Markdown";import{ThinkingStrip as te}from"./ThinkingStrip";import{TypingDots as re}from"./TypingDots";import{useCopyAction as $}from"./useCopyAction";import{traceToText as oe}from"../store/traceText";import{useAskBuoySettings as L}from"../store/useAskBuoySettings";import{jsx as r,jsxs as y}from"react/jsx-runtime";function H({status:e}){switch(e){case"running":return r(M,{size:"small",color:o.color.textSecondary});case"ok":return r(a,{style:[t.mark,t.markOk],children:r(I,{size:10,color:o.color.onAccent})});case"failed":return r(a,{style:[t.mark,t.markFailed],children:r(G,{size:10,color:o.color.text})});case"refused":return r(a,{style:[t.mark,t.markRefused],children:r(D,{size:10,color:o.color.onAccent})});case"declined":case"stopped":return r(a,{style:[t.mark,t.markNotRun],children:r(a,{style:t.markNotRunBar})})}}function ne(e){if(e.status==="running")return{text:"",tone:"muted"};if(e.status==="refused")return{text:"Refused",tone:"warning"};if(e.status==="failed")return{text:"Failed",tone:"danger"};if(e.status==="declined")return{text:"You declined",tone:"muted"};if(e.status==="stopped")return{text:"Not run \u2014 stopped",tone:"muted"};if(e.verification?.status==="verified")return{text:"Verified",tone:"ok"};if(e.verification?.status==="unverified")return{text:"Done \xB7 not yet visible",tone:"muted"};if(e.verification?.status==="failed")return{text:"Done \xB7 check failed",tone:"warning"};return{text:e.summary||"Done",tone:"muted"}}const ie=e=>e.status==="failed"||e.status==="refused"||e.status==="declined"||e.status==="stopped";function _({call:e,receipts:n,last:s}){const[i,l]=C(false);const d=ne(e);const p=i?R:z;const f=e.status==="failed"&&e.summary&&e.summary!=="Failed"?e.summary:null;return y(a,{style:[t.row,!s&&t.rowDivider],children:[y(m,{testID:`buoy-ask-buoy-tool-${e.toolId}`,accessibilityRole:"button",accessibilityLabel:`${e.label}, ${d.text||"running"}`,accessibilityState:{expanded:i},onPress:()=>l(c=>!c),children:[y(a,{style:t.rowLine,children:[r(a,{style:t.markSlot,children:r(H,{status:e.status})}),r(u,{style:t.rowTitle,children:e.label}),d.text?r(u,{style:[t.rowStatus,d.tone==="danger"&&t.rowStatusDanger,d.tone==="warning"&&t.rowStatusWarning,d.tone==="ok"&&t.rowStatusOk],numberOfLines:1,children:d.text}):null,r(p,{size:12,color:o.color.textTertiary})]}),i&&y(a,{style:t.rowDetail,children:[r(u,{style:t.rowTool,children:X(e.toolId).toUpperCase()}),e.description?r(u,{style:t.rowDescription,children:e.description}):null,f?r(u,{style:t.rowFailure,children:f}):null,e.verification?r(u,{style:[t.rowDescription,e.verification.status==="failed"&&t.rowFailure,e.verification.status==="verified"&&t.rowVerified],testID:`buoy-ask-buoy-verification-${e.verification.status}`,children:e.verification.detail}):null]})]}),i&&n.length>0&&r(a,{style:t.rowReceipts,testID:`buoy-ask-buoy-tool-receipt-${e.toolId}`,children:n.map(c=>r(v,{block:c},c.id))})]})}function se({label:e,count:n,calls:s,receipts:i,last:l}){const[d,p]=C(false);const f=d?R:z;return y(a,{style:!l&&!d&&t.rowDivider,children:[r(m,{testID:"buoy-ask-buoy-reads-group",accessibilityRole:"button",accessibilityLabel:`${e}, ${n} reads`,accessibilityState:{expanded:d},onPress:()=>p(c=>!c),style:[t.row,d&&t.rowDivider],children:y(a,{style:t.rowLine,children:[r(a,{style:t.markSlot,children:r(H,{status:"ok"})}),r(u,{style:t.rowTitle,children:e}),y(u,{style:t.rowStatus,numberOfLines:1,children:[n," reads"]}),r(f,{size:12,color:o.color.textTertiary})]})}),d&&r(a,{style:t.groupBody,children:s.map((c,h)=>r(_,{call:c,receipts:i.get(c.id)??[],last:l&&h===s.length-1},c.id))})]})}function le({calls:e,receipts:n}){const s=K(e);return r(a,{style:t.card,testID:"buoy-ask-buoy-activity",children:s.map((i,l)=>i.kind==="reads"?r(se,{label:i.label,count:i.count,calls:i.calls,receipts:n,last:l===s.length-1},i.id):r(_,{call:i.call,receipts:n.get(i.call.id)??[],last:l===s.length-1},i.call.id))})}function P({blocks:e}){if(e.length===0)return null;return r(a,{style:t.blocks,children:e.map(({block:n})=>r(v,{block:n},n.id))})}function ae({message:e}){return r(a,{style:t.systemLine,testID:"buoy-ask-buoy-system-line",children:r(u,{style:t.systemText,children:e.text})})}function ce({message:e}){return r(a,{style:t.userWrap,children:r(a,{style:t.userBubble,children:r(u,{style:t.userText,selectable:true,children:e.text})})})}function de({message:e,onRetry:n,waitingOnUser:s}){const{showThinking:i}=L();const l=!!e.streaming&&!s;const{nested:d,afterText:p,ask:f}=Z(e.blocks,e.toolCalls.map(c=>c.id));return y(a,{style:t.assistantWrap,children:[e.toolCalls.length>0&&r(le,{calls:e.toolCalls,receipts:d}),e.text.length>0&&r(ee,{text:e.text,style:t.assistantText}),r(P,{blocks:p}),r(P,{blocks:f}),i&&!e.streaming&&r(te,{message:e}),l&&y(a,{style:t.waitingRow,children:[r(re,{}),e.waiting?r(u,{style:t.waitingText,testID:"buoy-ask-buoy-waiting",children:e.waiting}):null]}),e.error&&(e.errorInfo?r(fe,{error:e.error,info:e.errorInfo,onRetry:n}):r(ye,{error:e.error,onRetry:n})),e.stopped&&!e.error&&r(ue,{onRetry:n,changed:e.toolCalls.some(c=>c.status==="ok"&&!!c.effect&&c.effect!=="read")})]})}function ue({onRetry:e,changed:n}){return y(a,{style:t.stoppedBox,testID:"buoy-ask-buoy-stopped",children:[r(u,{style:t.stoppedText,children:n?"Stopped. Changes already made are listed above.":"Stopped."}),e&&r(m,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:e,style:({pressed:s})=>[t.retry,s&&t.retryPressed],children:r(u,{style:t.retryText,children:"Try again"})})]})}function ye({error:e,onRetry:n}){const s=/fetch failed|network|ECONN|timed? ?out|socket/i.test(e);const i=s?"Couldn't reach your AI endpoint. Check the connection and try again.":"Something went wrong with that turn.";return y(a,{style:t.errorBox,testID:"buoy-ask-buoy-error",children:[r(D,{size:14,color:o.color.danger}),y(a,{style:t.errorBody,children:[r(u,{style:t.errorText,children:i}),r(u,{style:t.errorDetail,selectable:true,children:e}),n&&r(m,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:n,style:({pressed:l})=>[t.retry,l&&t.retryPressed],children:r(u,{style:t.retryText,children:"Try again"})})]})]})}const pe=new Set(["credits_out","member_cap","plan_not_eligible","not_in_pilot","team_hosted_off","account_frozen","token_not_allowed","client_too_old","media_not_allowed","session_missing","session_revoked"]);function fe({error:e,info:n,onRetry:s}){const[i,l]=C("idle");const d=`Ask Buoy error ${n.code}${n.requestId?` \xB7 request ${n.requestId}`:""} \xB7 ${new Date().toISOString()}`;const{copied:p,copy:f}=$(()=>d);const c=B.getReporter();const h=k(()=>{if(!c)return;l("sending");c({requestId:n.requestId,code:n.code,note:"Reported from the error card."}).then(b=>l({id:b.reportId})).catch(()=>l("failed"))},[c,n.code,n.requestId]);return y(a,{style:t.errorBox,testID:"buoy-ask-buoy-error",children:[r(D,{size:14,color:o.color.danger}),y(a,{style:t.errorBody,children:[r(u,{style:t.errorText,children:e}),y(u,{style:t.errorDetail,selectable:true,testID:"buoy-ask-buoy-error-code",children:[n.code,n.requestId?` \xB7 ${n.requestId}`:""]}),y(a,{style:t.transcriptActions,children:[s&&!pe.has(n.code)&&r(m,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:s,style:({pressed:b})=>[t.retry,b&&t.retryPressed],children:r(u,{style:t.retryText,children:"Try again"})}),r(m,{testID:"buoy-ask-buoy-error-copy",accessibilityRole:"button",accessibilityLabel:"Copy details",onPress:f,style:({pressed:b})=>[t.retry,b&&t.retryPressed],children:r(u,{style:t.retryText,children:p?"Copied":"Copy details"})}),c&&r(m,{testID:"buoy-ask-buoy-error-report",accessibilityRole:"button",accessibilityLabel:"Report problem",disabled:i!=="idle"&&i!=="failed",onPress:h,style:({pressed:b})=>[t.retry,b&&t.retryPressed],children:r(u,{style:t.retryText,children:i==="sending"?"Sending\u2026":i==="failed"?"Report failed. Try again":typeof i==="object"?`Reported \xB7 ${i.id}`:"Report problem"})})]})]})]})}export function transcriptToText(e,n=false){const s=[];for(const i of e){if(i.role==="user"){s.push(`You: ${i.text}`);continue}if(i.system){s.push(` \u2014 ${i.text}`);continue}if(n){s.push(...oe(i))}else{for(const l of i.toolCalls){const d=ie(l)?` (${l.status})`:"";s.push(` \xB7 ${l.label}${l.summary?` \u2014 ${l.summary}`:""}${d}`)}}if(i.text)s.push(`Ask Buoy: ${i.text}`);for(const l of J(i.blocks.map(d=>d.block)))s.push(l);if(i.error)s.push(` ! ${i.error}`);if(i.stopped&&!i.error)s.push(" ! Stopped by the user.")}return s.join("\n")}function ge({testID:e,label:n,getText:s}){const{copied:i,copy:l}=$(s);return y(m,{testID:e,accessibilityRole:"button",accessibilityLabel:n,onPress:l,style:({pressed:d})=>[t.copyBtn,t.iconBtn,d&&t.copyPressed],children:[i?r(I,{size:11,color:o.color.accent}):r(Y,{size:11,color:o.color.textSecondary}),r(u,{style:[t.copyText,i&&t.copiedText],children:i?"Copied":n})]})}function he({message:e}){const{showThinking:n}=L();const s=k(()=>transcriptToText(B.getState().messages,n),[n]);const i=Q(e);return y(a,{style:t.transcriptActions,children:[i?r(u,{style:t.turnFooter,testID:"buoy-ask-buoy-turn-footer",children:i}):null,r(ge,{testID:"buoy-ask-buoy-copy",label:"Copy conversation",getText:s})]})}const be=q(function e({message:n,onRetry:s,waitingOnUser:i}){if(n.role==="user")return r(ce,{message:n});if(n.system)return r(ae,{message:n});const l=!n.streaming&&!n.error;return y(a,{children:[r(de,{message:n,onRetry:s,waitingOnUser:i}),l&&r(he,{message:n})]})});export function MessageList({messages:e,ListHeaderComponent:n,ListEmptyComponent:s,ListFooterComponent:i,onRetry:l,waitingOnUser:d}){const p=S(null);const f=S(true);const c=S(false);const h=k(g=>{const{contentOffset:F,contentSize:O,layoutMeasurement:V}=g.nativeEvent;const N=O.height-V.height-F.y;f.current=N<80},[]);const b=k(()=>{c.current=true},[]);const W=k(g=>{if(c.current)h(g)},[h]);const A=k(g=>{c.current=false;h(g)},[h]);const T=k(()=>{if(!f.current)return;p.current?.scrollToEnd({animated:false});requestAnimationFrame(()=>p.current?.scrollToEnd({animated:false}))},[]);const x=e[e.length-1];const E=x?`${x.id}:${x.text.length}:${x.toolCalls.length}:${x.error??""}`:"";j(()=>{T()},[E,T]);return r(U,{ref:p,testID:"buoy-ask-buoy-messages-scroll",style:t.list,contentContainerStyle:t.listContent,data:e,keyExtractor:g=>g.id,renderItem:({item:g})=>r(be,{message:g,onRetry:g.id===x?.id?l:void 0,waitingOnUser:g.id===x?.id?d:false}),onScroll:W,onScrollBeginDrag:b,onScrollEndDrag:A,onMomentumScrollEnd:h,scrollEventThrottle:32,onContentSizeChange:T,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"interactive",ListHeaderComponent:n,ListEmptyComponent:s,ListFooterComponent:i})}const t=w.create({list:{flex:1,backgroundColor:"transparent"},listContent:{paddingHorizontal:o.gutter,paddingTop:12,paddingBottom:16,gap:16,flexGrow:1},userWrap:{alignItems:"flex-end"},userBubble:{maxWidth:"84%",paddingHorizontal:14,paddingVertical:9,borderRadius:18,borderBottomRightRadius:6,backgroundColor:o.color.accentFill,borderWidth:w.hairlineWidth,borderColor:o.color.accentBorder},userText:{color:o.color.text,fontSize:o.font.row,lineHeight:21},systemLine:{alignSelf:"stretch",paddingHorizontal:12,paddingVertical:7,borderRadius:o.radius.row,backgroundColor:o.color.fill},systemText:{color:o.color.textSecondary,fontSize:o.font.micro,lineHeight:16,textAlign:"center"},assistantWrap:{alignItems:"stretch",gap:10},blocks:{gap:10},waitingRow:{flexDirection:"row",alignItems:"center",gap:8},waitingText:{color:o.color.textSecondary,fontSize:o.font.caption},assistantText:{color:o.color.text,fontSize:o.font.row,lineHeight:22,paddingHorizontal:2},card:{borderRadius:o.radius.card,borderWidth:w.hairlineWidth,borderColor:o.color.border,backgroundColor:o.color.surface,overflow:"hidden"},row:{paddingHorizontal:12,paddingVertical:10},rowDivider:{borderBottomWidth:w.hairlineWidth,borderBottomColor:o.color.separator},rowLine:{flexDirection:"row",alignItems:"center",gap:10},markSlot:{width:18,height:18,alignItems:"center",justifyContent:"center"},mark:{width:16,height:16,borderRadius:8,alignItems:"center",justifyContent:"center"},markOk:{backgroundColor:o.color.accent},markFailed:{backgroundColor:o.color.danger},markRefused:{backgroundColor:o.color.warning},markNotRun:{borderWidth:1.5,borderColor:o.color.textTertiary},markNotRunBar:{width:7,height:1.5,borderRadius:1,backgroundColor:o.color.textSecondary},rowTitle:{flex:1,color:o.color.text,fontSize:o.font.body,lineHeight:19},rowStatus:{color:o.color.textTertiary,fontSize:o.font.caption,maxWidth:120},rowStatusDanger:{color:o.color.danger},rowStatusWarning:{color:o.color.warning},rowStatusOk:{color:o.color.accent},rowVerified:{color:o.color.accent},rowDetail:{paddingLeft:28,paddingTop:8,gap:4},rowTool:{color:o.color.textTertiary,fontSize:o.font.micro,fontWeight:"600",letterSpacing:.8},rowDescription:{color:o.color.textSecondary,fontSize:o.font.caption,lineHeight:18},rowFailure:{color:o.color.danger,fontSize:o.font.caption,lineHeight:18},rowReceipts:{paddingTop:10,gap:10},groupBody:{paddingLeft:14,backgroundColor:o.color.fill},stoppedBox:{alignItems:"flex-start",gap:2,paddingHorizontal:12,paddingVertical:8},stoppedText:{color:o.color.textTertiary,fontSize:o.font.caption,lineHeight:18},errorBox:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingVertical:10,borderRadius:o.radius.row,backgroundColor:o.color.dangerSoft},errorBody:{flex:1,gap:4},errorText:{color:o.color.danger,fontSize:o.font.caption,fontWeight:"600",lineHeight:18},errorDetail:{color:o.color.textSecondary,fontSize:o.font.micro,lineHeight:15},retry:{alignSelf:"flex-start",marginTop:6,paddingHorizontal:14,paddingVertical:7,borderRadius:o.radius.row,backgroundColor:o.color.button},retryPressed:{opacity:.7},retryText:{color:o.color.accent,fontSize:o.font.caption,fontWeight:"600"},transcriptActions:{flexDirection:"row",alignItems:"center",gap:10,marginTop:8},turnFooter:{flex:1,color:o.color.textTertiary,fontSize:o.font.micro,fontVariant:["tabular-nums"]},copyBtn:{paddingHorizontal:10,paddingVertical:5,borderRadius:o.radius.badge,backgroundColor:o.color.fill},iconBtn:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8},copyPressed:{opacity:.7},copyText:{color:o.color.textSecondary,fontSize:o.font.micro,fontWeight:"600"},copiedText:{color:o.color.accent}});
@@ -0,0 +1 @@
1
+ "use strict";import{Platform as g}from"react-native";import*as h from"@buoy-gg/license";import{HOSTED_HEADERS as o,HOSTED_PROTOCOL_VERSION as l}from"@buoy-gg/agent-core";export const HOSTED_ENDPOINT="https://ai.buoy.gg/v1/chat/completions";export const HOSTED_MODEL="openai/gpt-6-luna";const w=10*6e4;async function c(s=false){const t=h.SessionManager;if(!t)return null;const i=t.getStatus();if(i.state==="active"&&(s||i.grace||(i.validUntil??0)-Date.now()<w)){await t.refresh(true)}return t.getAccessToken()}function f(s){const t=/^(https?:\/\/[^/]+)/.exec(s);return t?t[1]:s}export function hostedAskBuoy(s={}){const{endpoint:t=HOSTED_ENDPOINT,...i}=s;const u=`ask-buoy ${g.OS}`;return{...i,endpoint:t,hosted:true,protocol:"openai",model:HOSTED_MODEL,maxTokens:8192,headers:async e=>{const r=await c((e?.attempt??1)>1);return{...r?{[o.session]:r}:{},[o.ask]:e?.askId??"ask_unknown000",[o.round]:String(e?.round??1),[o.attempt]:String(e?.attempt??1),[o.protocol]:String(l),[o.client]:u}},readUsage:async()=>{const e=await c();if(!e)throw new Error("Sign in to see hosted credits.");const r=await fetch(`${f(t)}/v1/usage`,{headers:{[o.session]:e}});if(!r.ok)throw new Error(`usage HTTP ${r.status}`);const n=await r.json();return{creditsLeft:n.creditsLeft??0,grantCredits:n.grantCredits??0,spentCredits:n.spentCredits??0,resetAt:n.resetAt??null}},reportProblem:async({requestId:e,code:r,note:n})=>{const p=await c();const a=await fetch(`${f(t)}/v1/report`,{method:"POST",headers:{"Content-Type":"application/json",...p?{[o.session]:p}:{}},body:JSON.stringify({request_id:e,code:r,note:n,client:u})});if(!a.ok)throw new Error(`report HTTP ${a.status}`);const d=await a.json();if(!d.report_id)throw new Error("report: no id");return{reportId:d.report_id}}}}
@@ -1 +1 @@
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";
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{hostedAskBuoy,HOSTED_ENDPOINT,HOSTED_MODEL}from"./hosted";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";
@@ -1 +1 @@
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()}};
1
+ "use strict";import{definePersistedSetting as a,devToolsStorageKeys as l}from"@buoy-gg/shared-ui";export const DEFAULT_SETTINGS={showThinking:false,bypassApprovals:false,readOnly:false,hostedNoticeSeen:false};const o=a(`${l.base}_ask_buoy_settings`,DEFAULT_SETTINGS,{sanitize:e=>({showThinking:e.showThinking===true,bypassApprovals:e.bypassApprovals===true,readOnly:e.readOnly===true,hostedNoticeSeen:e.hostedNoticeSeen===true})});let s=DEFAULT_SETTINGS;let n=false;const r=new Set;function i(){for(const e of r){try{e()}catch{}}}export const askBuoySettings={get:()=>s,subscribe(e){r.add(e);if(!n){n=true;void o.load().then(t=>{s=t;i()})}return()=>r.delete(e)},set(e,t){if(s[e]===t)return;s={...s,[e]:t};i();void o.save(s)},reset(){s=DEFAULT_SETTINGS;n=false;void o.clear()}};