@buoy-gg/ask-buoy 7.0.59 → 7.0.61

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 +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 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
+ "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 C=(0,_react.useRef)(false);const y=(0,_react.useRef)(null);const R=(0,_react.useRef)(t);R.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&&!C.current){C.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 N=r.answers;const q=r.usage;const O=r.busy;const T=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:q,pending:T,ledger:_askBuoyStore.askBuoyStore.getLedger()?.list(),queued:_}))};if(!O||T){e();return}const s=setTimeout(e,SAVE_DEBOUNCE_MS);return()=>clearTimeout(s)},[h,O,w,N,q,T,_]);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=R.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 +1 @@
1
- "use strict";import{getUseIsPro as ne,hasAccountAccess as k,subscribeAccountAccess as ae}from"@buoy-gg/shared-ui";import{useCallback as c,useEffect as h,useMemo as ie,useRef as m,useState as ce,useSyncExternalStore as le}from"react";import{Platform as L}from"react-native";import{dispatchToolAction as K,listSnapshotToolIds as ue,listToolActions as de,readToolSnapshot as pe,waitForToolRegistry as Q}from"@buoy-gg/shared-ui";import{answerToText as V,CATALOG as E,createAskBuoySession as he,readTargetDigest as fe,runGatedAction as M,SNAPSHOT_ACTION as F}from"@buoy-gg/agent-core";import{askBuoyStore as t,queuePauseReason as me,turnPhaseOf as ye}from"./askBuoyStore";import{clearConversation as Ae,resetConversation as be}from"./resetConversation";import{buildPayload as ge,readTranscript as ke,writeTranscript as we}from"./transcriptPersistence";import{useAskBuoySettings as ve}from"./useAskBuoySettings";const w=typeof __DEV__!=="undefined"&&!__DEV__;function Se(s){for(const n of t.getState().messages){if(!n.restored)continue;for(const y of n.blocks){const d=y.block;if(d?.id!==s)continue;const p=d.question??d.label??d.title;return typeof p==="string"&&p.trim()?p.trim():void 0}}return void 0}function G(){try{const s=de();for(const n of ue()){if(!s[n])s[n]=[];if(!s[n].includes(F)){s[n]=[F,...s[n]]}}return s}catch{return{}}}const Te=600;export function useAskBuoyState(){return le(t.subscribe,t.getState,t.getState)}export function useAskBuoy(s){const n=useAskBuoyState();const y=ne()();const d=m(y);d.current=y;const p=c((...e)=>{if(!k()||!d.current)return Promise.reject(new Error("Ask Buoy requires Pro access."));return K(...e)},[]);const l=m(null);const P=m(false);const A=m(null);const $=m(s);$.current=s;const v=!!s?.endpoint&&!!s?.model;const S=s?.persistTranscript!==false;const{bypassApprovals:T,readOnly:N}=ve();const I=m(T);I.current=T;const R=m(N);R.current=N;const O=c(()=>R.current?{...s?.policy??{},readOnly:true}:s?.policy??{},[s]);const[H,W]=ce(0);h(()=>{let e=false;void Q().then(()=>{if(!e)W(r=>r+1)});return()=>{e=true}},[]);const b=ie(()=>G(),[H]);const z=Object.keys(b).sort().join(",");h(()=>{t.setConfigured(v);t.setMeta({model:s?.model,protocol:s?.protocol??(s?"anthropic":void 0),appName:s?.appName,platform:L.OS,build:w?"release":"development"});if(!v||!s){l.current=null;t.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=s.protocol??"anthropic";if(w&&s.apiKey){t.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(s.endpoint)){t.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(s.endpoint)){t.setNotice('This endpoint is api.anthropic.com but the protocol is "openai". Remove protocol or set it to "anthropic".')}else{t.setNotice(null)}t.setReporter(s.reportProblem??null);t.setUsageReader(s.readUsage??null);const r=[s.endpoint,s.protocol??"anthropic",s.model].join("|");const o=t.getHeldSession();if(o&&o.signature===r){l.current=o.session;o.session.setAvailableActions(b);o.session.setApprovalBypass(I.current);o.session.setReadOnly(R.current);t.setLedger(o.session.ledger);return}const i=he({endpoint:s.endpoint,protocol:s.protocol??"anthropic",model:s.model,headers:s.headers,apiKey:s.apiKey,maxTokens:s.maxTokens,anthropicVersion:s.anthropicVersion,requestOverrides:s.requestOverrides,hosted:s.hosted===true,catalog:s.tools?.length?[...E,...s.tools]:void 0,dispatch:p,readSnapshot:pe,availableActions:b,policy:s.policy,context:s.context,isRelease:w,appName:s.appName,platform:L.OS,requestApproval:a=>t.askApproval(a)});l.current=i;i.setApprovalBypass(I.current);i.setReadOnly(R.current);t.holdSession(i,r);t.setLedger(i.ledger);let u=false;void Q().then(a=>{if(a&&!u)void i.prime()});if(S&&!P.current){P.current=true;void ke().then(a=>{if(!a)return;const oe=t.hydrate({messages:a.messages,answers:a.answers,usage:a.usage,queued:a.queued});if(!oe)return;l.current?.restore(a.history);if(a.ledger?.length)l.current?.ledger.restore(a.ledger);if(a.pending)t.restorePending(a.pending)})}return()=>{u=true}},[v,s,b,z,S]);h(()=>{l.current?.setApprovalBypass(T)},[T]);h(()=>{l.current?.setReadOnly(N)},[N]);const q=n.messages;const x=n.answers;const _=n.usage;const C=n.busy;const D=n.pending;const U=n.queued;h(()=>{if(!S)return;if(q.length===0)return;const e=()=>{void we(ge({messages:q,history:l.current?.messages??[],answers:x,usage:_,pending:D,ledger:t.getLedger()?.list(),queued:U}))};if(!C){e();return}const r=setTimeout(e,Te);return()=>clearTimeout(r)},[S,C,q,x,_,D,U]);const B=c(e=>{if(!k()||!d.current)return;const r=l.current;if(!r)return;t.beginTurn();const o=t.startAssistant();const i=new AbortController;A.current=i;r.setAvailableActions(G());const u=$.current?.onEvent;void(async()=>{try{for await(const a of r.send(e,i.signal)){t.applyEvent(o,a);if(u){try{u(a)}catch{}}}}catch(a){if(!i.signal.aborted){t.applyEvent(o,{type:"error",message:a instanceof Error?a.message:"Something went wrong talking to your AI endpoint."})}}finally{if(i.signal.aborted)t.markStopped(o);t.finishAssistant(o);A.current=null}})()},[]);const f=c(e=>{if(!k()||!d.current)return;const r=e.trim();if(!l.current||!r)return;if(t.getState().busy){t.enqueue(r);return}const o=t.getState().awaitingBlockId;if(o)t.recordAnswer({blockId:o,kind:"skipped"});t.addUser(r);B(r)},[B]);const J=c(()=>{const{messages:e,busy:r}=t.getState();if(r||!l.current)return;const o=[...e].reverse().find(i=>i.role==="user");if(!o)return;B(o.text)},[B]);const g=c(()=>{t.requestStop();if(t.getState().pending)t.answerApproval(false);A.current?.abort();A.current=null},[]);h(()=>{const e=ae(()=>{if(!k())g()});return()=>{e();g()}},[g]);h(()=>{if(!y)g()},[y,g]);h(()=>{if(n.queued.length===0)return;if(ye(n)!=="idle")return;if(me(n)!==null)return;const e=t.shiftQueued();if(e)f(e.text)},[n,f]);const X=c(e=>t.takeQueuedToDraft(e),[]);const Y=c(e=>t.removeQueued(e),[]);const Z=c(()=>{A.current?.abort();A.current=null;Ae()},[]);const ee=c(()=>be({dispatch:K,undoFirst:true}),[]);const j=c(async e=>{const r=t.getLedger();if(!r){t.setNotice(`${e.label} couldn't run \u2014 no active Ask Buoy session.`);return}const o=s?.tools?.length?[...E,...s.tools]:void 0;if(e.targetDigest){const u=await fe({toolId:e.toolId,action:e.action,params:e.params??{},dispatch:p,catalog:o});if(u!==void 0&&u!==e.targetDigest){t.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 i=await M({toolId:e.toolId,action:e.action,params:e.params??{},dispatch:p,ledger:r,policy:O(),isRelease:w,catalog:o});if(i.ok){t.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{t.setNotice(`${e.label} failed \u2014 ${i.error}`)}},[s,O]);const te=c(e=>{const r=t.getState().pending;const o=typeof e==="boolean"?e:e.approved;t.answerApproval(e);if(!r?.restored)return;if(!o){t.addNote(`Skipped \u201C${r.label}\u201D. Nothing was changed.`);return}void j(r)},[j]);const se=c(e=>{t.recordAnswer(e);const r=Se(e.blockId);f(r?`${r} \u2014 ${V(e)}`:V(e))},[f]);const re=c(async(e,r)=>{if(!k()||!d.current){t.setNotice("Ask Buoy requires Pro access.");return}if(e.send){f(e.send);return}if(!e.dispatch)return;const o=`${r}:${e.label}`;const i=t.getLedger();if(!i){t.setNotice(`${e.label} failed \u2014 no active Ask Buoy session.`);return}t.setActionState(o,"running");const u=await M({toolId:e.dispatch.toolId,action:e.dispatch.action,params:e.dispatch.params??{},dispatch:p,ledger:i,policy:O(),isRelease:w,catalog:s?.tools?.length?[...E,...s.tools]:void 0});if(u.ok){t.setActionState(o,"done")}else{t.setActionState(o,"failed");t.setNotice(`${e.label} failed \u2014 ${u.error}`)}},[f,s,O]);return{state:n,send:f,stop:g,reset:Z,undoThenReset:ee,approve:te,retry:J,answer:se,runAction:re,editQueued:X,removeQueued:Y,configured:v,toolCount:Object.keys(b).length,availableToolIds:Object.keys(b)}}
1
+ "use strict";import{getUseIsPro as ne,hasAccountAccess as k,subscribeAccountAccess as ae}from"@buoy-gg/shared-ui";import{useCallback as c,useEffect as h,useMemo as ie,useRef as m,useState as ce,useSyncExternalStore as le}from"react";import{Platform as L}from"react-native";import{dispatchToolAction as K,listSnapshotToolIds as ue,listToolActions as de,readToolSnapshot as pe,waitForToolRegistry as Q}from"@buoy-gg/shared-ui";import{answerToText as V,CATALOG as P,createAskBuoySession as he,readTargetDigest as fe,runGatedAction as M,SNAPSHOT_ACTION as F}from"@buoy-gg/agent-core";import{askBuoyStore as t,queuePauseReason as me,turnPhaseOf as ye}from"./askBuoyStore";import{clearConversation as Ae,resetConversation as be}from"./resetConversation";import{buildPayload as ge,readTranscript as ke,writeTranscript as we}from"./transcriptPersistence";import{useAskBuoySettings as ve}from"./useAskBuoySettings";const w=typeof __DEV__!=="undefined"&&!__DEV__;function Se(s){for(const n of t.getState().messages){if(!n.restored)continue;for(const y of n.blocks){const d=y.block;if(d?.id!==s)continue;const p=d.question??d.label??d.title;return typeof p==="string"&&p.trim()?p.trim():void 0}}return void 0}function G(){try{const s=de();for(const n of ue()){if(!s[n])s[n]=[];if(!s[n].includes(F)){s[n]=[F,...s[n]]}}return s}catch{return{}}}const Te=600;export function useAskBuoyState(){return le(t.subscribe,t.getState,t.getState)}export function useAskBuoy(s){const n=useAskBuoyState();const y=ne()();const d=m(y);d.current=y;const p=c((...e)=>{if(!k()||!d.current)return Promise.reject(new Error("Ask Buoy requires Pro access."));return K(...e)},[]);const l=m(null);const $=m(false);const A=m(null);const x=m(s);x.current=s;const v=!!s?.endpoint&&!!s?.model;const S=s?.persistTranscript!==false;const{bypassApprovals:T,readOnly:N}=ve();const I=m(T);I.current=T;const R=m(N);R.current=N;const O=c(()=>R.current?{...s?.policy??{},readOnly:true}:s?.policy??{},[s]);const[H,W]=ce(0);h(()=>{let e=false;void Q().then(()=>{if(!e)W(r=>r+1)});return()=>{e=true}},[]);const b=ie(()=>G(),[H]);const z=Object.keys(b).sort().join(",");h(()=>{t.setConfigured(v);t.setMeta({model:s?.model,protocol:s?.protocol??(s?"anthropic":void 0),appName:s?.appName,platform:L.OS,build:w?"release":"development"});if(!v||!s){l.current=null;t.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=s.protocol??"anthropic";if(w&&s.apiKey){t.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(s.endpoint)){t.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(s.endpoint)){t.setNotice('This endpoint is api.anthropic.com but the protocol is "openai". Remove protocol or set it to "anthropic".')}else{t.setNotice(null)}t.setReporter(s.reportProblem??null);t.setUsageReader(s.readUsage??null);const r=[s.endpoint,s.protocol??"anthropic",s.model].join("|");const o=t.getHeldSession();if(o&&o.signature===r){l.current=o.session;o.session.setAvailableActions(b);o.session.setApprovalBypass(I.current);o.session.setReadOnly(R.current);t.setLedger(o.session.ledger);return}const i=he({endpoint:s.endpoint,protocol:s.protocol??"anthropic",model:s.model,headers:s.headers,apiKey:s.apiKey,maxTokens:s.maxTokens,anthropicVersion:s.anthropicVersion,requestOverrides:s.requestOverrides,hosted:s.hosted===true,catalog:s.tools?.length?[...P,...s.tools]:void 0,dispatch:p,readSnapshot:pe,availableActions:b,policy:s.policy,context:s.context,isRelease:w,appName:s.appName,platform:L.OS,requestApproval:a=>t.askApproval(a)});l.current=i;i.setApprovalBypass(I.current);i.setReadOnly(R.current);t.holdSession(i,r);t.setLedger(i.ledger);let u=false;void Q().then(a=>{if(a&&!u)void i.prime()});if(S&&!$.current){$.current=true;void ke().then(a=>{if(!a)return;const oe=t.hydrate({messages:a.messages,answers:a.answers,usage:a.usage,queued:a.queued});if(!oe)return;l.current?.restore(a.history);if(a.ledger?.length)l.current?.ledger.restore(a.ledger);if(a.pending)t.restorePending(a.pending)})}return()=>{u=true}},[v,s,b,z,S]);h(()=>{l.current?.setApprovalBypass(T)},[T]);h(()=>{l.current?.setReadOnly(N)},[N]);const q=n.messages;const _=n.answers;const C=n.usage;const D=n.busy;const E=n.pending;const U=n.queued;h(()=>{if(!S)return;if(q.length===0)return;const e=()=>{void we(ge({messages:q,history:l.current?.messages??[],answers:_,usage:C,pending:E,ledger:t.getLedger()?.list(),queued:U}))};if(!D||E){e();return}const r=setTimeout(e,Te);return()=>clearTimeout(r)},[S,D,q,_,C,E,U]);const B=c(e=>{if(!k()||!d.current)return;const r=l.current;if(!r)return;t.beginTurn();const o=t.startAssistant();const i=new AbortController;A.current=i;r.setAvailableActions(G());const u=x.current?.onEvent;void(async()=>{try{for await(const a of r.send(e,i.signal)){t.applyEvent(o,a);if(u){try{u(a)}catch{}}}}catch(a){if(!i.signal.aborted){t.applyEvent(o,{type:"error",message:a instanceof Error?a.message:"Something went wrong talking to your AI endpoint."})}}finally{if(i.signal.aborted)t.markStopped(o);t.finishAssistant(o);A.current=null}})()},[]);const f=c(e=>{if(!k()||!d.current)return;const r=e.trim();if(!l.current||!r)return;if(t.getState().busy){t.enqueue(r);return}const o=t.getState().awaitingBlockId;if(o)t.recordAnswer({blockId:o,kind:"skipped"});t.addUser(r);B(r)},[B]);const J=c(()=>{const{messages:e,busy:r}=t.getState();if(r||!l.current)return;const o=[...e].reverse().find(i=>i.role==="user");if(!o)return;B(o.text)},[B]);const g=c(()=>{t.requestStop();if(t.getState().pending)t.answerApproval(false);A.current?.abort();A.current=null},[]);h(()=>{const e=ae(()=>{if(!k())g()});return()=>{e();g()}},[g]);h(()=>{if(!y)g()},[y,g]);h(()=>{if(n.queued.length===0)return;if(ye(n)!=="idle")return;if(me(n)!==null)return;const e=t.shiftQueued();if(e)f(e.text)},[n,f]);const X=c(e=>t.takeQueuedToDraft(e),[]);const Y=c(e=>t.removeQueued(e),[]);const Z=c(()=>{A.current?.abort();A.current=null;Ae()},[]);const ee=c(()=>be({dispatch:K,undoFirst:true}),[]);const j=c(async e=>{const r=t.getLedger();if(!r){t.setNotice(`${e.label} couldn't run \u2014 no active Ask Buoy session.`);return}const o=s?.tools?.length?[...P,...s.tools]:void 0;if(e.targetDigest){const u=await fe({toolId:e.toolId,action:e.action,params:e.params??{},dispatch:p,catalog:o});if(u!==void 0&&u!==e.targetDigest){t.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 i=await M({toolId:e.toolId,action:e.action,params:e.params??{},dispatch:p,ledger:r,policy:O(),isRelease:w,catalog:o});if(i.ok){t.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{t.setNotice(`${e.label} failed \u2014 ${i.error}`)}},[s,O]);const te=c(e=>{const r=t.getState().pending;const o=typeof e==="boolean"?e:e.approved;t.answerApproval(e);if(!r?.restored)return;if(!o){t.addNote(`Skipped \u201C${r.label}\u201D. Nothing was changed.`);return}void j(r)},[j]);const se=c(e=>{t.recordAnswer(e);const r=Se(e.blockId);f(r?`${r} \u2014 ${V(e)}`:V(e))},[f]);const re=c(async(e,r)=>{if(!k()||!d.current){t.setNotice("Ask Buoy requires Pro access.");return}if(e.send){f(e.send);return}if(!e.dispatch)return;const o=`${r}:${e.label}`;const i=t.getLedger();if(!i){t.setNotice(`${e.label} failed \u2014 no active Ask Buoy session.`);return}t.setActionState(o,"running");const u=await M({toolId:e.dispatch.toolId,action:e.dispatch.action,params:e.dispatch.params??{},dispatch:p,ledger:i,policy:O(),isRelease:w,catalog:s?.tools?.length?[...P,...s.tools]:void 0});if(u.ok){t.setActionState(o,"done")}else{t.setActionState(o,"failed");t.setNotice(`${e.label} failed \u2014 ${u.error}`)}},[f,s,O]);return{state:n,send:f,stop:g,reset:Z,undoThenReset:ee,approve:te,retry:J,answer:se,runAction:re,editQueued:X,removeQueued:Y,configured:v,toolCount:Object.keys(b).length,availableToolIds:Object.keys(b)}}
package/lib/web/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
- "use client";var Qo=Object.defineProperty;var Gn=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames;var Yn=Object.prototype.hasOwnProperty;var Qn=(e,t)=>{for(var o in t)Qo(e,o,{get:t[o],enumerable:true})},Xo=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Jn(t))!Yn.call(e,n)&&n!==o&&Qo(e,n,{get:()=>t[n],enumerable:!(r=Gn(t,n))||r.enumerable});return e},Xn=(e,t,o)=>(Xo(e,t,"default"),o&&Xo(o,t,"default"));var Xt=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{useCallback as Me,useEffect as Ot,useMemo as Zt,useRef as Wt,useState as ho}from"react";var Zo={};Qn(Zo,{AccessibilityInfo:()=>oi,ActivityIndicator:()=>Vt,Alert:()=>fo,Animated:()=>ce,AppRegistry:()=>ni,AppState:()=>ii,Appearance:()=>ri,BackHandler:()=>li,Button:()=>Ni,CheckBox:()=>mi,Clipboard:()=>ai,DeviceEventEmitter:()=>Bi,Dimensions:()=>si,Easing:()=>Rt,FlatList:()=>tr,I18nManager:()=>ci,Image:()=>mt,ImageBackground:()=>xi,InteractionManager:()=>di,Keyboard:()=>go,KeyboardAvoidingView:()=>ki,LayoutAnimation:()=>ui,Linking:()=>pi,LogBox:()=>Ai,Modal:()=>Vi,NativeEventEmitter:()=>hi,NativeModules:()=>ti,PanResponder:()=>gi,Picker:()=>wi,PixelRatio:()=>fi,Platform:()=>$t,Pressable:()=>m,ProgressBar:()=>vi,RefreshControl:()=>Si,SafeAreaView:()=>Ti,ScrollView:()=>Fe,SectionList:()=>Ci,Share:()=>er,StatusBar:()=>Ii,StyleSheet:()=>w,Switch:()=>rr,Text:()=>l,TextInput:()=>Ze,Touchable:()=>zi,TouchableHighlight:()=>Wi,TouchableNativeFeedback:()=>Di,TouchableOpacity:()=>Et,TouchableWithoutFeedback:()=>Ei,UIManager:()=>bi,Vibration:()=>yi,View:()=>s,VirtualizedList:()=>Ri,YellowBox:()=>$i,findNodeHandle:()=>ji,unstable_createElement:()=>ei,useColorScheme:()=>Hi,useLocaleContext:()=>Li,useWindowDimensions:()=>or});Xn(Zo,Zn);import*as Zn from"react-native-web";import{unstable_createElement as ei,NativeModules as ti,AccessibilityInfo as oi,Animated as ce,Appearance as ri,AppRegistry as ni,AppState as ii,BackHandler as li,Clipboard as ai,Dimensions as si,Easing as Rt,I18nManager as ci,Keyboard as go,InteractionManager as di,LayoutAnimation as ui,Linking as pi,NativeEventEmitter as hi,PanResponder as gi,PixelRatio as fi,Platform as $t,Share as er,StyleSheet as w,UIManager as bi,Vibration as yi,CheckBox as mi,FlatList as tr,Image as mt,ImageBackground as xi,KeyboardAvoidingView as ki,Picker as wi,ProgressBar as vi,RefreshControl as Si,SafeAreaView as Ti,SectionList as Ci,StatusBar as Ii,Touchable as zi,TouchableNativeFeedback as Di,VirtualizedList as Ri,YellowBox as $i,LogBox as Ai,DeviceEventEmitter as Bi,useColorScheme as Hi,useLocaleContext as Li,useWindowDimensions as or}from"react-native-web";import*as $e from"react-native-web";import{createElement as Pi,forwardRef as Oi}from"react";function Oe(e){let t=Oi((r,n)=>{let{accessibilityState:i,accessibilityValue:a,...h}=r;for(let u of["busy","checked","disabled","expanded","selected"])i?.[u]!==void 0&&h[`aria-${u}`]===void 0&&(h[`aria-${u}`]=i[u]);for(let[u,g]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[u]!==void 0&&h[`aria-${g}`]===void 0&&(h[`aria-${g}`]=a[u]);return Pi(e,{...h,ref:n})}),o=e.State;return o&&Object.assign(t,{State:o}),t.displayName=e.displayName??e.name??"NativeWebView",t}var s=Oe($e.View),l=Oe($e.Text),Ze=Oe($e.TextInput),Et=Oe($e.TouchableOpacity),Wi=Oe($e.TouchableHighlight),Ei=Oe($e.TouchableWithoutFeedback),m=Oe($e.Pressable),Fe=Oe($e.ScrollView),Vi=Oe($e.Modal),rr=Oe($e.Switch),Vt=Oe($e.ActivityIndicator),Ni=Oe($e.Button),ji=$e.findNodeHandle,fo={alert(e,t,o,r){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let i=document.createElement("h2");if(i.textContent=e,i.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(i),t){let g=document.createElement("p");g.textContent=t,g.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(g)}let a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let h=o?.length?o:[{text:"OK"}],u=()=>{n.close?.(),n.remove()};for(let g of h){let y=document.createElement("button");y.type="button",y.textContent=g.text??"OK",y.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${g.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,y.onclick=()=>{u(),g.onPress?.()},a.appendChild(y)}n.addEventListener("cancel",g=>{g.preventDefault(),r?.cancelable!==false&&(u(),r?.onDismiss?.())}),n.appendChild(a),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{isReversible as qi}from"@buoy-gg/agent-core/web";import{dispatchToolAction as Mi,FeatureGate as Fi,Info as nr,JsModal as _i,ModalHeader as bo,night as _e,setToolAttention as At,useSafeAreaInsets as Ui}from"@buoy-gg/shared-ui/web";import{Component as Ki}from"react";import{night as ir}from"@buoy-gg/shared-ui/web";import{useState as Gi}from"react";import{Check as Ji,ChevronRight as Yi,night as N}from"@buoy-gg/shared-ui/web";import{createContext as Qi,useContext as Xi}from"react";import{jsx as Zi}from"react/jsx-runtime";var el={answer:()=>{},runAction:()=>{},answered:{},supports:{}},lr=Qi(el);function ar({value:e,children:t}){return Zi(lr.Provider,{value:e,children:t})}function Z(){return Xi(lr)}function tl(e,t){return`${e}:${t.label}`}import{AlertTriangle as ol,Check as rl,Clock as nl,Database as il,Eye as ll,Globe as al,Image as sl,Info as cl,Layers as sr,Navigation as dl,night as Nt,User as ul}from"@buoy-gg/shared-ui/web";import{jsx as Ae}from"react/jsx-runtime";function cr({name:e,size:t=14}){let o=Nt.color.textSecondary,r=(()=>{switch(e){case"network":return Ae(al,{size:t,color:o});case"storage":return Ae(il,{size:t,color:o});case"route":return Ae(dl,{size:t,color:o});case"screen":return Ae(ll,{size:t,color:o});case"user":return Ae(ul,{size:t,color:o});case"image":return Ae(sl,{size:t,color:o});case"check":return Ae(rl,{size:t,color:Nt.color.accent});case"warn":return Ae(ol,{size:t,color:Nt.color.warning});case"info":return Ae(cl,{size:t,color:Nt.color.info});case"store":return Ae(sr,{size:t,color:o});case"query":return Ae(sr,{size:t,color:o});case"clock":return Ae(nl,{size:t,color:o})}})();return Ae(s,{style:pl.wrap,children:r})}var pl=w.create({wrap:{width:24,height:24,borderRadius:6,backgroundColor:Nt.color.fill,alignItems:"center",justifyContent:"center"}});import{useState as dr}from"react";import{Check as hl,ChevronDown as ur,ChevronUp as pr,night as I,X as gl}from"@buoy-gg/shared-ui/web";function fl(e,t,o,r){let n=Math.min(o,e),i=Math.max(0,e-n),a=o>t&&e>t;return{hidden:i,next:Math.min(i,r),expanded:a,canExpand:i>0,canCollapse:a}}import{jsx as we,jsxs as et}from"react/jsx-runtime";function xt(e){switch(e){case"accent":return I.color.accent;case"warning":return I.color.warning;case"danger":return I.color.danger;case"info":return I.color.info;case"muted":return I.color.textTertiary;default:return I.color.text}}function hr({source:e}){if(!e||e==="live")return null;let t=e==="changed"?"CHANGED BY ASK BUOY":e==="mocked"?"MOCKED":"FROM THE MODEL",o=e==="changed"?I.color.warning:e==="mocked"?I.color.danger:I.color.textTertiary;return we(s,{style:[F.badge,{borderColor:o}],children:we(l,{style:[F.badgeText,{color:o}],children:t})})}function O({title:e,source:t,children:o,testID:r,tone:n,collapsible:i,summary:a}){let[h,u]=dr(false),g=!!i&&!h;return et(s,{style:[F.card,n==="warning"&&F.cardWarning,n==="danger"&&F.cardDanger,n==="info"&&F.cardInfo],testID:r,children:[(e||t&&t!=="live")&&et(s,{style:F.titleRow,children:[e?we(l,{style:F.title,numberOfLines:2,children:e}):we(s,{style:F.flex}),we(hr,{source:t})]}),i?et(m,{testID:r?`${r}-toggle`:void 0,onPress:()=>u(y=>!y),accessibilityRole:"button",accessibilityState:{expanded:h},accessibilityLabel:`${a??"Details"}, ${h?"hide":"show"}`,style:({pressed:y})=>[F.disclosure,!g&&F.disclosureOpen,y&&F.pressed],children:[we(l,{style:F.disclosureText,numberOfLines:1,children:a??"Details"}),g?we(ur,{size:12,color:I.color.textTertiary}):we(pr,{size:12,color:I.color.textTertiary})]}):null,g?null:o]})}var bl=5;function tt(e,t,o=bl){let[r,n]=dr(t),{hidden:i,next:a,expanded:h,canExpand:u,canCollapse:g}=fl(e.length,t,r,o);return{visible:e.slice(0,r),hidden:i,next:a,expanded:h,showMore:u?()=>n(y=>y+o):void 0,showLess:g?()=>n(t):void 0}}function ot({paged:e}){let{next:t,showMore:o,showLess:r}=e;return!o&&!r?null:et(s,{style:F.moreRow,children:[o?et(m,{testID:"buoy-block-show-more",onPress:o,style:[F.more,F.moreCell],accessibilityRole:"button",children:[et(l,{style:F.moreText,children:["Show ",t," more"]}),we(ur,{size:12,color:I.color.textTertiary})]}):null,r?et(m,{testID:"buoy-block-show-fewer",onPress:r,style:[F.more,F.moreCell],accessibilityRole:"button",children:[we(l,{style:F.moreText,children:"Show fewer"}),we(pr,{size:12,color:I.color.textTertiary})]}):null]})}function yl({shown:e,total:t}){return!t||t<=e?null:we(s,{style:F.more,children:et(l,{style:F.moreNote,children:[e," of ",t," shown"]})})}function We({actions:e,blockId:t,align:o="left"}){let r=Z();if(!e?.length)return null;let n=e.filter(i=>i.openTool?r.supports?.openTool!==false:i.minimize?r.supports?.minimize!==false:i.dispatch?r.supports?.dispatch!==false:true);return n.length===0?null:we(s,{style:[F.actions,o==="right"&&F.actionsRight],children:n.slice(0,2).map(i=>{let a=r.actionState?.[tl(t,i)],h=!!r.busy||a==="running"||a==="done";return et(m,{accessibilityRole:"button",accessibilityLabel:i.label,testID:`buoy-block-action-${i.label.toLowerCase().replace(/\s+/g,"-")}`,disabled:h,onPress:()=>void r.runAction(i,t),style:({pressed:u})=>[F.button,i.primary?F.buttonPrimary:F.buttonPlate,h&&F.buttonDisabled,u&&!h&&F.pressed],children:[a==="running"?we(Vt,{size:"small",color:i.primary?I.color.onAccent:I.color.text}):a==="done"?we(hl,{size:12,color:i.primary?I.color.onAccent:I.color.accent}):a==="failed"?we(gl,{size:12,color:I.color.danger}):null,we(l,{style:[F.buttonText,i.primary?F.buttonTextPrimary:F.buttonTextPlate],children:i.label})]},i.label)})})}var D=w.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},rowDivider:{borderTopWidth:w.hairlineWidth,borderTopColor:I.color.separator},rowTitle:{flex:1,color:I.color.text,fontSize:I.font.body,lineHeight:19},rowSub:{color:I.color.textSecondary,fontSize:I.font.caption,lineHeight:17},rowTrailing:{color:I.color.textTertiary,fontSize:I.font.caption,maxWidth:120,textAlign:"right"},mono:{fontFamily:"Menlo",fontSize:12,color:I.color.text},pill:{paddingHorizontal:7,paddingVertical:2,borderRadius:I.radius.badge,backgroundColor:I.color.fill},pillText:{fontSize:I.font.micro,fontWeight:"700",letterSpacing:.4,color:I.color.textSecondary}}),F=w.create({card:{borderRadius:I.radius.card,borderWidth:w.hairlineWidth,borderColor:I.color.border,backgroundColor:I.color.surface,overflow:"hidden"},cardWarning:{borderColor:I.color.warning,backgroundColor:I.color.warningSoft},cardDanger:{borderColor:I.color.danger,backgroundColor:I.color.dangerSoft},cardInfo:{borderColor:I.color.accentBorderStrong,backgroundColor:I.color.accentSoft},titleRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:6},flex:{flex:1},title:{flex:1,color:I.color.text,fontSize:I.font.caption,fontWeight:"600"},disclosure:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:9},disclosureOpen:{borderBottomWidth:w.hairlineWidth,borderBottomColor:I.color.separator},disclosureText:{flex:1,color:I.color.textSecondary,fontSize:I.font.caption},badge:{borderWidth:w.hairlineWidth,borderRadius:I.radius.badge,paddingHorizontal:6,paddingVertical:2},badgeText:{fontSize:9,fontWeight:"700",letterSpacing:.6},moreRow:{flexDirection:"row"},more:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:4,paddingVertical:9,paddingHorizontal:8,borderTopWidth:w.hairlineWidth,borderTopColor:I.color.separator},moreCell:{flex:1},moreText:{color:I.color.textSecondary,fontSize:I.font.caption,fontWeight:"600"},moreNote:{color:I.color.textTertiary,fontSize:I.font.caption},actions:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:10,flexWrap:"wrap"},actionsRight:{justifyContent:"flex-end"},button:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:14,paddingVertical:9,borderRadius:I.radius.row},buttonPrimary:{backgroundColor:I.color.accent},buttonPlate:{backgroundColor:I.color.button},buttonDisabled:{opacity:.55},buttonText:{fontSize:I.font.caption,fontWeight:"600"},buttonTextPrimary:{color:I.color.onAccent},buttonTextPlate:{color:I.color.text},pressed:{opacity:.7}});import{Fragment as ml,jsx as le,jsxs as kt}from"react/jsx-runtime";function xl({block:e}){let t=Z(),o=t.answered[e.id],r=o?.kind==="choice"?o.optionId:null,n=!!o;return kt(O,{testID:`buoy-block-choice-${e.id}`,tone:n?void 0:"info",children:[le(l,{style:q.question,children:e.question}),le(s,{style:q.options,children:e.options.slice(0,5).map((i,a)=>{let h=r===i.id;return kt(m,{testID:`buoy-block-option-${i.id}`,accessibilityRole:"button",accessibilityState:{selected:h,disabled:n},disabled:n,onPress:()=>t.answer({blockId:e.id,kind:"choice",optionId:i.id,label:i.label}),style:({pressed:u})=>[q.option,a>0&&q.optionDivider,h&&q.optionChosen,n&&!h&&q.optionDimmed,u&&!n&&q.pressed],children:[i.icon?le(cr,{name:i.icon}):null,kt(s,{style:q.optionText,children:[le(l,{style:[q.optionLabel,h&&q.optionLabelChosen],children:i.label}),i.detail?le(l,{style:q.optionDetail,children:i.detail}):null]}),h?le(Ji,{size:14,color:N.color.accent}):n?null:le(Yi,{size:14,color:N.color.textTertiary})]},i.id)})}),!n&&e.allowFreeText!==false?le(l,{style:q.hint,children:"Or just type your answer below."}):null]})}function kl({block:e}){let t=Z(),o=t.answered[e.id],r=!!o,n=o?.kind==="confirm"?o.approved:null;return kt(O,{testID:`buoy-block-confirm-${e.id}`,tone:r?void 0:"warning",children:[le(l,{style:q.confirmTitle,children:e.title}),le(l,{style:q.confirmChange,children:e.change}),e.consequence?le(l,{style:q.confirmConsequence,children:e.consequence}):null,le(s,{style:q.confirmActions,children:r?le(l,{style:q.decided,children:n?`\u2713 ${e.approveLabel??"Done"}`:`\u2715 ${e.declineLabel??"Not now"}`}):kt(ml,{children:[le(m,{testID:"buoy-block-approve",accessibilityRole:"button",onPress:()=>t.answer({blockId:e.id,kind:"confirm",approved:true}),style:({pressed:i})=>[q.button,q.buttonPrimary,i&&q.pressed],children:le(l,{style:q.buttonTextPrimary,children:e.approveLabel??"Do it"})}),le(m,{testID:"buoy-block-decline",accessibilityRole:"button",onPress:()=>t.answer({blockId:e.id,kind:"confirm",approved:false}),style:({pressed:i})=>[q.button,q.buttonPlate,i&&q.pressed],children:le(l,{style:q.buttonTextPlate,children:e.declineLabel??"Not now"})})]})})]})}function wl({block:e}){let t=Z(),o=t.answered[e.id],r=!!o,[n,i]=Gi(""),a=e.type==="secret",h=()=>{let u=n.trim();u&&t.answer({blockId:e.id,kind:"input",value:u})};return kt(O,{testID:`buoy-block-input-${e.id}`,tone:r?void 0:"info",children:[le(l,{style:q.question,children:e.label}),r?le(l,{style:q.decided,children:o.kind==="input"?a?"\u2022\u2022\u2022\u2022\u2022\u2022":o.value:"(skipped)"}):kt(s,{style:q.inputRow,children:[le(Ze,{testID:"buoy-block-input-field",style:q.input,value:n,onChangeText:i,placeholder:e.placeholder??"",placeholderTextColor:N.color.placeholder,keyboardType:e.type==="number"?"numeric":"ascii-capable",secureTextEntry:a,autoCapitalize:"none",autoCorrect:false,returnKeyType:"send",onSubmitEditing:h}),le(m,{testID:"buoy-block-input-submit",accessibilityRole:"button",disabled:!n.trim(),onPress:h,style:({pressed:u})=>[q.button,q.buttonPrimary,!n.trim()&&q.buttonDisabled,u&&q.pressed],children:le(l,{style:q.buttonTextPrimary,children:e.submitLabel??"Send"})})]})]})}var q=w.create({question:{color:N.color.text,fontSize:N.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},options:{marginHorizontal:8,marginBottom:8,borderRadius:N.radius.row,backgroundColor:N.color.surfaceElevated,overflow:"hidden"},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:11},optionDivider:{borderTopWidth:w.hairlineWidth,borderTopColor:N.color.separator},optionChosen:{backgroundColor:N.color.accentSoft},optionDimmed:{opacity:.45},optionText:{flex:1,gap:2},optionLabel:{color:N.color.text,fontSize:N.font.body,fontWeight:"500"},optionLabelChosen:{color:N.color.accent},optionDetail:{color:N.color.textSecondary,fontSize:N.font.caption,lineHeight:17},hint:{color:N.color.textTertiary,fontSize:N.font.micro,paddingHorizontal:12,paddingBottom:10},confirmTitle:{color:N.color.text,fontSize:N.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:N.color.text,fontSize:N.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6},confirmConsequence:{color:N.color.warning,fontSize:N.font.caption,lineHeight:17,paddingHorizontal:12,paddingTop:6},confirmActions:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:12,alignItems:"center"},decided:{color:N.color.textSecondary,fontSize:N.font.caption,fontWeight:"600",paddingHorizontal:12,paddingVertical:10},inputRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingBottom:12},input:{flex:1,height:38,paddingHorizontal:12,borderRadius:N.radius.row,backgroundColor:N.color.surfaceElevated,color:N.color.text,fontSize:N.font.body},button:{paddingHorizontal:14,paddingVertical:9,borderRadius:N.radius.row},buttonPrimary:{backgroundColor:N.color.accent},buttonPlate:{backgroundColor:N.color.button},buttonDisabled:{opacity:.5},buttonTextPrimary:{color:N.color.onAccent,fontSize:N.font.caption,fontWeight:"600"},buttonTextPlate:{color:N.color.text,fontSize:N.font.caption,fontWeight:"600"},pressed:{opacity:.7}});import{useState as gr}from"react";import{AlertTriangle as vl,Check as Sl,Info as Tl,night as B,X as Cl}from"@buoy-gg/shared-ui/web";import{DataViewer as Il,TreeDiffViewer as zl}from"@buoy-gg/shared-ui/web/dataViewer";import{CAPS as jt}from"@buoy-gg/agent-core/web";import{useState as Dl}from"react";import{night as ae}from"@buoy-gg/shared-ui/web";var fr=e=>/^\s*\|.*\|\s*$/.test(e),Rl=e=>/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(e),br=e=>e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim()),$l=/^\s*```\s*([\w+-]*)\s*$/;function Al(e){let t=[],o=[],r=()=>{o.length&&t.push({kind:"p",text:o.join(" ")}),o=[]},n=e.split(`
1
+ "use client";var Yo=Object.defineProperty;var Gn=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames;var Qn=Object.prototype.hasOwnProperty;var Yn=(e,t)=>{for(var o in t)Yo(e,o,{get:t[o],enumerable:true})},Xo=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Jn(t))!Qn.call(e,n)&&n!==o&&Yo(e,n,{get:()=>t[n],enumerable:!(r=Gn(t,n))||r.enumerable});return e},Xn=(e,t,o)=>(Xo(e,t,"default"),o&&Xo(o,t,"default"));var Xt=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{useCallback as Me,useEffect as Ot,useMemo as Zt,useRef as Wt,useState as ho}from"react";var Zo={};Yn(Zo,{AccessibilityInfo:()=>oi,ActivityIndicator:()=>Vt,Alert:()=>fo,Animated:()=>ce,AppRegistry:()=>ni,AppState:()=>ii,Appearance:()=>ri,BackHandler:()=>li,Button:()=>Ni,CheckBox:()=>mi,Clipboard:()=>ai,DeviceEventEmitter:()=>Bi,Dimensions:()=>si,Easing:()=>Rt,FlatList:()=>tr,I18nManager:()=>ci,Image:()=>mt,ImageBackground:()=>xi,InteractionManager:()=>di,Keyboard:()=>go,KeyboardAvoidingView:()=>ki,LayoutAnimation:()=>ui,Linking:()=>pi,LogBox:()=>Ai,Modal:()=>Vi,NativeEventEmitter:()=>hi,NativeModules:()=>ti,PanResponder:()=>gi,Picker:()=>wi,PixelRatio:()=>fi,Platform:()=>$t,Pressable:()=>m,ProgressBar:()=>vi,RefreshControl:()=>Si,SafeAreaView:()=>Ti,ScrollView:()=>Fe,SectionList:()=>Ci,Share:()=>er,StatusBar:()=>Ii,StyleSheet:()=>w,Switch:()=>rr,Text:()=>l,TextInput:()=>Ze,Touchable:()=>zi,TouchableHighlight:()=>Wi,TouchableNativeFeedback:()=>Di,TouchableOpacity:()=>Et,TouchableWithoutFeedback:()=>Ei,UIManager:()=>bi,Vibration:()=>yi,View:()=>s,VirtualizedList:()=>Ri,YellowBox:()=>$i,findNodeHandle:()=>ji,unstable_createElement:()=>ei,useColorScheme:()=>Hi,useLocaleContext:()=>Li,useWindowDimensions:()=>or});Xn(Zo,Zn);import*as Zn from"react-native-web";import{unstable_createElement as ei,NativeModules as ti,AccessibilityInfo as oi,Animated as ce,Appearance as ri,AppRegistry as ni,AppState as ii,BackHandler as li,Clipboard as ai,Dimensions as si,Easing as Rt,I18nManager as ci,Keyboard as go,InteractionManager as di,LayoutAnimation as ui,Linking as pi,NativeEventEmitter as hi,PanResponder as gi,PixelRatio as fi,Platform as $t,Share as er,StyleSheet as w,UIManager as bi,Vibration as yi,CheckBox as mi,FlatList as tr,Image as mt,ImageBackground as xi,KeyboardAvoidingView as ki,Picker as wi,ProgressBar as vi,RefreshControl as Si,SafeAreaView as Ti,SectionList as Ci,StatusBar as Ii,Touchable as zi,TouchableNativeFeedback as Di,VirtualizedList as Ri,YellowBox as $i,LogBox as Ai,DeviceEventEmitter as Bi,useColorScheme as Hi,useLocaleContext as Li,useWindowDimensions as or}from"react-native-web";import*as $e from"react-native-web";import{createElement as Pi,forwardRef as Oi}from"react";function Oe(e){let t=Oi((r,n)=>{let{accessibilityState:i,accessibilityValue:a,...h}=r;for(let u of["busy","checked","disabled","expanded","selected"])i?.[u]!==void 0&&h[`aria-${u}`]===void 0&&(h[`aria-${u}`]=i[u]);for(let[u,g]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[u]!==void 0&&h[`aria-${g}`]===void 0&&(h[`aria-${g}`]=a[u]);return Pi(e,{...h,ref:n})}),o=e.State;return o&&Object.assign(t,{State:o}),t.displayName=e.displayName??e.name??"NativeWebView",t}var s=Oe($e.View),l=Oe($e.Text),Ze=Oe($e.TextInput),Et=Oe($e.TouchableOpacity),Wi=Oe($e.TouchableHighlight),Ei=Oe($e.TouchableWithoutFeedback),m=Oe($e.Pressable),Fe=Oe($e.ScrollView),Vi=Oe($e.Modal),rr=Oe($e.Switch),Vt=Oe($e.ActivityIndicator),Ni=Oe($e.Button),ji=$e.findNodeHandle,fo={alert(e,t,o,r){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let i=document.createElement("h2");if(i.textContent=e,i.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(i),t){let g=document.createElement("p");g.textContent=t,g.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(g)}let a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let h=o?.length?o:[{text:"OK"}],u=()=>{n.close?.(),n.remove()};for(let g of h){let y=document.createElement("button");y.type="button",y.textContent=g.text??"OK",y.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${g.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,y.onclick=()=>{u(),g.onPress?.()},a.appendChild(y)}n.addEventListener("cancel",g=>{g.preventDefault(),r?.cancelable!==false&&(u(),r?.onDismiss?.())}),n.appendChild(a),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{isReversible as qi}from"@buoy-gg/agent-core/web";import{dispatchToolAction as Mi,FeatureGate as Fi,Info as nr,JsModal as _i,ModalHeader as bo,night as _e,setToolAttention as At,useSafeAreaInsets as Ui}from"@buoy-gg/shared-ui/web";import{Component as Ki}from"react";import{night as ir}from"@buoy-gg/shared-ui/web";import{useState as Gi}from"react";import{Check as Ji,ChevronRight as Qi,night as N}from"@buoy-gg/shared-ui/web";import{createContext as Yi,useContext as Xi}from"react";import{jsx as Zi}from"react/jsx-runtime";var el={answer:()=>{},runAction:()=>{},answered:{},supports:{}},lr=Yi(el);function ar({value:e,children:t}){return Zi(lr.Provider,{value:e,children:t})}function Z(){return Xi(lr)}function tl(e,t){return`${e}:${t.label}`}import{AlertTriangle as ol,Check as rl,Clock as nl,Database as il,Eye as ll,Globe as al,Image as sl,Info as cl,Layers as sr,Navigation as dl,night as Nt,User as ul}from"@buoy-gg/shared-ui/web";import{jsx as Ae}from"react/jsx-runtime";function cr({name:e,size:t=14}){let o=Nt.color.textSecondary,r=(()=>{switch(e){case"network":return Ae(al,{size:t,color:o});case"storage":return Ae(il,{size:t,color:o});case"route":return Ae(dl,{size:t,color:o});case"screen":return Ae(ll,{size:t,color:o});case"user":return Ae(ul,{size:t,color:o});case"image":return Ae(sl,{size:t,color:o});case"check":return Ae(rl,{size:t,color:Nt.color.accent});case"warn":return Ae(ol,{size:t,color:Nt.color.warning});case"info":return Ae(cl,{size:t,color:Nt.color.info});case"store":return Ae(sr,{size:t,color:o});case"query":return Ae(sr,{size:t,color:o});case"clock":return Ae(nl,{size:t,color:o})}})();return Ae(s,{style:pl.wrap,children:r})}var pl=w.create({wrap:{width:24,height:24,borderRadius:6,backgroundColor:Nt.color.fill,alignItems:"center",justifyContent:"center"}});import{useState as dr}from"react";import{Check as hl,ChevronDown as ur,ChevronUp as pr,night as I,X as gl}from"@buoy-gg/shared-ui/web";function fl(e,t,o,r){let n=Math.min(o,e),i=Math.max(0,e-n),a=o>t&&e>t;return{hidden:i,next:Math.min(i,r),expanded:a,canExpand:i>0,canCollapse:a}}import{jsx as we,jsxs as et}from"react/jsx-runtime";function xt(e){switch(e){case"accent":return I.color.accent;case"warning":return I.color.warning;case"danger":return I.color.danger;case"info":return I.color.info;case"muted":return I.color.textTertiary;default:return I.color.text}}function hr({source:e}){if(!e||e==="live")return null;let t=e==="changed"?"CHANGED BY ASK BUOY":e==="mocked"?"MOCKED":"FROM THE MODEL",o=e==="changed"?I.color.warning:e==="mocked"?I.color.danger:I.color.textTertiary;return we(s,{style:[F.badge,{borderColor:o}],children:we(l,{style:[F.badgeText,{color:o}],children:t})})}function O({title:e,source:t,children:o,testID:r,tone:n,collapsible:i,summary:a}){let[h,u]=dr(false),g=!!i&&!h;return et(s,{style:[F.card,n==="warning"&&F.cardWarning,n==="danger"&&F.cardDanger,n==="info"&&F.cardInfo],testID:r,children:[(e||t&&t!=="live")&&et(s,{style:F.titleRow,children:[e?we(l,{style:F.title,numberOfLines:2,children:e}):we(s,{style:F.flex}),we(hr,{source:t})]}),i?et(m,{testID:r?`${r}-toggle`:void 0,onPress:()=>u(y=>!y),accessibilityRole:"button",accessibilityState:{expanded:h},accessibilityLabel:`${a??"Details"}, ${h?"hide":"show"}`,style:({pressed:y})=>[F.disclosure,!g&&F.disclosureOpen,y&&F.pressed],children:[we(l,{style:F.disclosureText,numberOfLines:1,children:a??"Details"}),g?we(ur,{size:12,color:I.color.textTertiary}):we(pr,{size:12,color:I.color.textTertiary})]}):null,g?null:o]})}var bl=5;function tt(e,t,o=bl){let[r,n]=dr(t),{hidden:i,next:a,expanded:h,canExpand:u,canCollapse:g}=fl(e.length,t,r,o);return{visible:e.slice(0,r),hidden:i,next:a,expanded:h,showMore:u?()=>n(y=>y+o):void 0,showLess:g?()=>n(t):void 0}}function ot({paged:e}){let{next:t,showMore:o,showLess:r}=e;return!o&&!r?null:et(s,{style:F.moreRow,children:[o?et(m,{testID:"buoy-block-show-more",onPress:o,style:[F.more,F.moreCell],accessibilityRole:"button",children:[et(l,{style:F.moreText,children:["Show ",t," more"]}),we(ur,{size:12,color:I.color.textTertiary})]}):null,r?et(m,{testID:"buoy-block-show-fewer",onPress:r,style:[F.more,F.moreCell],accessibilityRole:"button",children:[we(l,{style:F.moreText,children:"Show fewer"}),we(pr,{size:12,color:I.color.textTertiary})]}):null]})}function yl({shown:e,total:t}){return!t||t<=e?null:we(s,{style:F.more,children:et(l,{style:F.moreNote,children:[e," of ",t," shown"]})})}function We({actions:e,blockId:t,align:o="left"}){let r=Z();if(!e?.length)return null;let n=e.filter(i=>i.openTool?r.supports?.openTool!==false:i.minimize?r.supports?.minimize!==false:i.dispatch?r.supports?.dispatch!==false:true);return n.length===0?null:we(s,{style:[F.actions,o==="right"&&F.actionsRight],children:n.slice(0,2).map(i=>{let a=r.actionState?.[tl(t,i)],h=!!r.busy||a==="running"||a==="done";return et(m,{accessibilityRole:"button",accessibilityLabel:i.label,testID:`buoy-block-action-${i.label.toLowerCase().replace(/\s+/g,"-")}`,disabled:h,onPress:()=>void r.runAction(i,t),style:({pressed:u})=>[F.button,i.primary?F.buttonPrimary:F.buttonPlate,h&&F.buttonDisabled,u&&!h&&F.pressed],children:[a==="running"?we(Vt,{size:"small",color:i.primary?I.color.onAccent:I.color.text}):a==="done"?we(hl,{size:12,color:i.primary?I.color.onAccent:I.color.accent}):a==="failed"?we(gl,{size:12,color:I.color.danger}):null,we(l,{style:[F.buttonText,i.primary?F.buttonTextPrimary:F.buttonTextPlate],children:i.label})]},i.label)})})}var D=w.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},rowDivider:{borderTopWidth:w.hairlineWidth,borderTopColor:I.color.separator},rowTitle:{flex:1,color:I.color.text,fontSize:I.font.body,lineHeight:19},rowSub:{color:I.color.textSecondary,fontSize:I.font.caption,lineHeight:17},rowTrailing:{color:I.color.textTertiary,fontSize:I.font.caption,maxWidth:120,textAlign:"right"},mono:{fontFamily:"Menlo",fontSize:12,color:I.color.text},pill:{paddingHorizontal:7,paddingVertical:2,borderRadius:I.radius.badge,backgroundColor:I.color.fill},pillText:{fontSize:I.font.micro,fontWeight:"700",letterSpacing:.4,color:I.color.textSecondary}}),F=w.create({card:{borderRadius:I.radius.card,borderWidth:w.hairlineWidth,borderColor:I.color.border,backgroundColor:I.color.surface,overflow:"hidden"},cardWarning:{borderColor:I.color.warning,backgroundColor:I.color.warningSoft},cardDanger:{borderColor:I.color.danger,backgroundColor:I.color.dangerSoft},cardInfo:{borderColor:I.color.accentBorderStrong,backgroundColor:I.color.accentSoft},titleRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:6},flex:{flex:1},title:{flex:1,color:I.color.text,fontSize:I.font.caption,fontWeight:"600"},disclosure:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:9},disclosureOpen:{borderBottomWidth:w.hairlineWidth,borderBottomColor:I.color.separator},disclosureText:{flex:1,color:I.color.textSecondary,fontSize:I.font.caption},badge:{borderWidth:w.hairlineWidth,borderRadius:I.radius.badge,paddingHorizontal:6,paddingVertical:2},badgeText:{fontSize:9,fontWeight:"700",letterSpacing:.6},moreRow:{flexDirection:"row"},more:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:4,paddingVertical:9,paddingHorizontal:8,borderTopWidth:w.hairlineWidth,borderTopColor:I.color.separator},moreCell:{flex:1},moreText:{color:I.color.textSecondary,fontSize:I.font.caption,fontWeight:"600"},moreNote:{color:I.color.textTertiary,fontSize:I.font.caption},actions:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:10,flexWrap:"wrap"},actionsRight:{justifyContent:"flex-end"},button:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:14,paddingVertical:9,borderRadius:I.radius.row},buttonPrimary:{backgroundColor:I.color.accent},buttonPlate:{backgroundColor:I.color.button},buttonDisabled:{opacity:.55},buttonText:{fontSize:I.font.caption,fontWeight:"600"},buttonTextPrimary:{color:I.color.onAccent},buttonTextPlate:{color:I.color.text},pressed:{opacity:.7}});import{Fragment as ml,jsx as le,jsxs as kt}from"react/jsx-runtime";function xl({block:e}){let t=Z(),o=t.answered[e.id],r=o?.kind==="choice"?o.optionId:null,n=!!o;return kt(O,{testID:`buoy-block-choice-${e.id}`,tone:n?void 0:"info",children:[le(l,{style:q.question,children:e.question}),le(s,{style:q.options,children:e.options.slice(0,5).map((i,a)=>{let h=r===i.id;return kt(m,{testID:`buoy-block-option-${i.id}`,accessibilityRole:"button",accessibilityState:{selected:h,disabled:n},disabled:n,onPress:()=>t.answer({blockId:e.id,kind:"choice",optionId:i.id,label:i.label}),style:({pressed:u})=>[q.option,a>0&&q.optionDivider,h&&q.optionChosen,n&&!h&&q.optionDimmed,u&&!n&&q.pressed],children:[i.icon?le(cr,{name:i.icon}):null,kt(s,{style:q.optionText,children:[le(l,{style:[q.optionLabel,h&&q.optionLabelChosen],children:i.label}),i.detail?le(l,{style:q.optionDetail,children:i.detail}):null]}),h?le(Ji,{size:14,color:N.color.accent}):n?null:le(Qi,{size:14,color:N.color.textTertiary})]},i.id)})}),!n&&e.allowFreeText!==false?le(l,{style:q.hint,children:"Or just type your answer below."}):null]})}function kl({block:e}){let t=Z(),o=t.answered[e.id],r=!!o,n=o?.kind==="confirm"?o.approved:null;return kt(O,{testID:`buoy-block-confirm-${e.id}`,tone:r?void 0:"warning",children:[le(l,{style:q.confirmTitle,children:e.title}),le(l,{style:q.confirmChange,children:e.change}),e.consequence?le(l,{style:q.confirmConsequence,children:e.consequence}):null,le(s,{style:q.confirmActions,children:r?le(l,{style:q.decided,children:n?`\u2713 ${e.approveLabel??"Done"}`:`\u2715 ${e.declineLabel??"Not now"}`}):kt(ml,{children:[le(m,{testID:"buoy-block-approve",accessibilityRole:"button",onPress:()=>t.answer({blockId:e.id,kind:"confirm",approved:true}),style:({pressed:i})=>[q.button,q.buttonPrimary,i&&q.pressed],children:le(l,{style:q.buttonTextPrimary,children:e.approveLabel??"Do it"})}),le(m,{testID:"buoy-block-decline",accessibilityRole:"button",onPress:()=>t.answer({blockId:e.id,kind:"confirm",approved:false}),style:({pressed:i})=>[q.button,q.buttonPlate,i&&q.pressed],children:le(l,{style:q.buttonTextPlate,children:e.declineLabel??"Not now"})})]})})]})}function wl({block:e}){let t=Z(),o=t.answered[e.id],r=!!o,[n,i]=Gi(""),a=e.type==="secret",h=()=>{let u=n.trim();u&&t.answer({blockId:e.id,kind:"input",value:u})};return kt(O,{testID:`buoy-block-input-${e.id}`,tone:r?void 0:"info",children:[le(l,{style:q.question,children:e.label}),r?le(l,{style:q.decided,children:o.kind==="input"?a?"\u2022\u2022\u2022\u2022\u2022\u2022":o.value:"(skipped)"}):kt(s,{style:q.inputRow,children:[le(Ze,{testID:"buoy-block-input-field",style:q.input,value:n,onChangeText:i,placeholder:e.placeholder??"",placeholderTextColor:N.color.placeholder,keyboardType:e.type==="number"?"numeric":"ascii-capable",secureTextEntry:a,autoCapitalize:"none",autoCorrect:false,returnKeyType:"send",onSubmitEditing:h}),le(m,{testID:"buoy-block-input-submit",accessibilityRole:"button",disabled:!n.trim(),onPress:h,style:({pressed:u})=>[q.button,q.buttonPrimary,!n.trim()&&q.buttonDisabled,u&&q.pressed],children:le(l,{style:q.buttonTextPrimary,children:e.submitLabel??"Send"})})]})]})}var q=w.create({question:{color:N.color.text,fontSize:N.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},options:{marginHorizontal:8,marginBottom:8,borderRadius:N.radius.row,backgroundColor:N.color.surfaceElevated,overflow:"hidden"},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:11},optionDivider:{borderTopWidth:w.hairlineWidth,borderTopColor:N.color.separator},optionChosen:{backgroundColor:N.color.accentSoft},optionDimmed:{opacity:.45},optionText:{flex:1,gap:2},optionLabel:{color:N.color.text,fontSize:N.font.body,fontWeight:"500"},optionLabelChosen:{color:N.color.accent},optionDetail:{color:N.color.textSecondary,fontSize:N.font.caption,lineHeight:17},hint:{color:N.color.textTertiary,fontSize:N.font.micro,paddingHorizontal:12,paddingBottom:10},confirmTitle:{color:N.color.text,fontSize:N.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:N.color.text,fontSize:N.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6},confirmConsequence:{color:N.color.warning,fontSize:N.font.caption,lineHeight:17,paddingHorizontal:12,paddingTop:6},confirmActions:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:12,alignItems:"center"},decided:{color:N.color.textSecondary,fontSize:N.font.caption,fontWeight:"600",paddingHorizontal:12,paddingVertical:10},inputRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingBottom:12},input:{flex:1,height:38,paddingHorizontal:12,borderRadius:N.radius.row,backgroundColor:N.color.surfaceElevated,color:N.color.text,fontSize:N.font.body},button:{paddingHorizontal:14,paddingVertical:9,borderRadius:N.radius.row},buttonPrimary:{backgroundColor:N.color.accent},buttonPlate:{backgroundColor:N.color.button},buttonDisabled:{opacity:.5},buttonTextPrimary:{color:N.color.onAccent,fontSize:N.font.caption,fontWeight:"600"},buttonTextPlate:{color:N.color.text,fontSize:N.font.caption,fontWeight:"600"},pressed:{opacity:.7}});import{useState as gr}from"react";import{AlertTriangle as vl,Check as Sl,Info as Tl,night as B,X as Cl}from"@buoy-gg/shared-ui/web";import{DataViewer as Il,TreeDiffViewer as zl}from"@buoy-gg/shared-ui/web/dataViewer";import{CAPS as jt}from"@buoy-gg/agent-core/web";import{useState as Dl}from"react";import{night as ae}from"@buoy-gg/shared-ui/web";var fr=e=>/^\s*\|.*\|\s*$/.test(e),Rl=e=>/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(e),br=e=>e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim()),$l=/^\s*```\s*([\w+-]*)\s*$/;function Al(e){let t=[],o=[],r=()=>{o.length&&t.push({kind:"p",text:o.join(" ")}),o=[]},n=e.split(`
2
2
  `);for(let i=0;i<n.length;i++){let a=n[i].replace(/\s+$/,""),h=$l.exec(a);if(h){r();let y=[],C=i+1,j=false;for(;C<n.length;){if(/^\s*```\s*$/.test(n[C])){j=true;break}y.push(n[C]),C++}t.push({kind:"code",lang:h[1]??"",text:y.join(`
3
3
  `),closed:j}),i=j?C:n.length;continue}if(!a.trim()){r();continue}if(fr(a)&&n[i+1]&&Rl(n[i+1])){r();let y=br(a),C=[],j=i+2;for(;j<n.length&&fr(n[j]);)C.push(br(n[j])),j++;t.push({kind:"table",header:y,rows:C}),i=j-1;continue}let u=/^#{1,6}\s+(.*)$/.exec(a);if(u){r(),t.push({kind:"h",text:u[1]});continue}let g=/^(\s*)([-*•]|\d+[.)])\s+(.*)$/.exec(a);if(g){r();let y=Math.min(2,Math.floor(g[1].length/2)),C=/^\d/.test(g[2])?g[2].replace(")","."):"\u2022";t.push({kind:"li",text:g[3],marker:C,depth:y});continue}o.push(a.trim())}return r(),t}var yo=12,mo=4;function Bl(e,t){let o=[];return t.length>yo&&o.push(`${yo} of ${t.length} rows`),e.length>mo&&o.push(`${mo} of ${e.length} columns`),o.length?`Showing ${o.join(" \xB7 ")}`:null}import{jsx as ye,jsxs as eo}from"react/jsx-runtime";function Bt(e,t){let o=e.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1"),r=[],n=/(\*\*[^*]+\*\*|`[^`]+`|\*[^*\s][^*]*\*|_[^_\s][^_]*_)/g,i=0,a,h=0;for(;a=n.exec(o);){a.index>i&&r.push(o.slice(i,a.index));let u=a[0];u.startsWith("**")?r.push(ye(l,{style:[t,U.bold],children:u.slice(2,-2)},h++)):u.startsWith("`")?r.push(ye(l,{style:[t,U.code],children:u.slice(1,-1)},h++)):r.push(ye(l,{style:[t,U.italic],children:u.slice(1,-1)},h++)),i=a.index+u.length}return i<o.length&&r.push(o.slice(i)),r}var Hl=e=>e.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1");function Ll({header:e,rows:t}){let[o,r]=Dl(false),n=Bl(e,t),i=o?e:e.slice(0,mo),a=o?t:t.slice(0,yo),h=eo(s,{style:o&&U.tableWide,children:[ye(s,{style:U.tableHead,children:i.map((u,g)=>ye(l,{style:[U.th,g===0&&U.firstCol,o&&U.colFixed],numberOfLines:1,children:u.replace(/\*\*/g,"")},g))}),a.map((u,g)=>ye(s,{style:[U.tr,g>0&&U.trDivider],children:i.map((y,C)=>ye(l,{style:[U.td,C===0&&U.firstCol,C===0&&U.tdFirst,o&&U.colFixed],numberOfLines:o?3:2,children:Bt(Hl(u[C]??""),U.td)},C))},g))]});return eo(s,{style:U.table,testID:"buoy-ask-buoy-md-table",children:[o?ye(Fe,{style:U.tableScrollV,nestedScrollEnabled:true,children:ye(Fe,{horizontal:true,showsHorizontalScrollIndicator:true,children:h})}):h,n?eo(m,{testID:"buoy-ask-buoy-md-table-toggle",accessibilityRole:"button",accessibilityLabel:o?"Show fewer rows":"Show all rows and columns",onPress:()=>r(u=>!u),style:({pressed:u})=>[U.tfoot,u&&U.pressed],children:[ye(l,{style:U.tfootText,children:o?`All ${t.length} rows \xB7 ${e.length} columns`:n}),ye(l,{style:U.tfootAction,children:o?"Show fewer":"Show all"})]}):null]})}function yr({text:e,style:t}){let o=Al(e);return ye(s,{style:U.wrap,children:o.map((r,n)=>r.kind==="table"?ye(Ll,{header:r.header,rows:r.rows},n):r.kind==="code"?ye(Fe,{horizontal:true,style:U.codeBlock,contentContainerStyle:U.codeBlockContent,testID:"buoy-ask-buoy-md-code",children:ye(l,{style:U.codeText,selectable:true,children:r.text})},n):r.kind==="li"?eo(s,{style:[U.li,{paddingLeft:4+r.depth*14}],children:[ye(l,{style:[t,U.marker],children:r.marker}),ye(l,{style:[t,U.liText],selectable:true,children:Bt(r.text,t)})]},n):ye(l,{style:[t,r.kind==="h"&&U.bold],selectable:true,children:Bt(r.text,t)},n))})}var U=w.create({wrap:{gap:8},bold:{fontWeight:"600"},italic:{fontStyle:"italic"},code:{fontFamily:"Menlo",fontSize:13,color:ae.color.accent,backgroundColor:ae.color.fill},codeBlock:{borderRadius:ae.radius.row,borderWidth:w.hairlineWidth,borderColor:ae.color.border,backgroundColor:ae.color.surface},codeBlockContent:{paddingHorizontal:12,paddingVertical:10},codeText:{fontFamily:"Menlo",fontSize:12,lineHeight:18,color:ae.color.text},li:{flexDirection:"row",gap:8},table:{borderRadius:ae.radius.row,borderWidth:w.hairlineWidth,borderColor:ae.color.border,backgroundColor:ae.color.surface,overflow:"hidden"},tableWide:{minWidth:"100%"},tableScrollV:{maxHeight:320},tableHead:{flexDirection:"row",paddingHorizontal:10,paddingVertical:6,gap:8,backgroundColor:ae.color.fill},th:{flex:1,color:ae.color.textTertiary,fontSize:ae.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:10,paddingVertical:7,gap:8},trDivider:{borderTopWidth:w.hairlineWidth,borderTopColor:ae.color.separator},td:{flex:1,color:ae.color.textSecondary,fontSize:ae.font.caption,lineHeight:17},tdFirst:{color:ae.color.text,fontWeight:"500"},firstCol:{flex:1.3},colFixed:{flex:0,width:110},tfoot:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:10,paddingVertical:8,borderTopWidth:w.hairlineWidth,borderTopColor:ae.color.border},tfootText:{color:ae.color.textSecondary,fontSize:ae.font.micro},tfootAction:{color:ae.color.accent,fontSize:ae.font.micro,fontWeight:"600"},pressed:{opacity:.7},marker:{color:ae.color.textSecondary,minWidth:14,textAlign:"right"},liText:{flex:1}});import{useCallback as Pl,useEffect as Ol,useRef as Wl,useState as El}from"react";import{copyToClipboard as Vl}from"@buoy-gg/shared-ui/web";var Nl=1500;function to(e){let[t,o]=El(false),r=Wl(null);Ol(()=>()=>{r.current&&clearTimeout(r.current)},[]);let n=Pl(()=>{let i=e();Vl(i).then(a=>{if(!a){er.share({message:i}).catch(()=>{});return}o(true),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>o(false),Nl)}).catch(()=>{})},[e]);return{copied:t,copy:n}}var jl=e=>typeof e=="string"?e:e.text;function mr(e){switch(e.kind){case"finding":return[e.title,...e.evidence.map(t=>`${t.label}: ${t.value}`)].join(`
4
4
  `);case"keyValue":return[e.title,...e.pairs.map(t=>`${t.key}: ${typeof t.value=="string"?t.value:JSON.stringify(t.value)}`)].filter(Boolean).join(`
5
5
  `);case"table":{let t=e.columns.join(" | "),o=e.rows.map(n=>n.map(jl).join(" | ")),r=e.total&&e.total>e.rows.length?`\u2026 ${e.total-e.rows.length} more rows`:null;return[e.title,t,...o,r].filter(Boolean).join(`
6
6
  `)}case"list":{let t=e.items.map(r=>`- ${r.title}${r.subtitle?` \u2014 ${r.subtitle}`:""}${r.trailing?` (${r.trailing})`:""}`),o=e.total&&e.total>e.items.length?`\u2026 ${e.total-e.items.length} more`:null;return[e.title,...t,o].filter(Boolean).join(`
7
- `)}case"notice":return e.text;case"claim":return e.text;case"diff":case"chart":case"imageGrid":case"requestList":case"requestCard":case"logList":case"crash":case"screenElements":return`[${e.kind} card${"title"in e&&typeof e.title=="string"?`: ${e.title}`:""}]`;default:return null}}function ql(e){return e.map(mr).filter(t=>!!t)}import{Fragment as Ml,jsx as z,jsxs as he}from"react/jsx-runtime";function xo(e){if(e===void 0)return"\u2014";if(e===null)return"null";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{let t=JSON.stringify(e);return t.length>120?`${t.slice(0,117)}\u2026`:t}catch{return String(e)}}function Fl({block:e}){let t=tt(e.rows,jt.tableRows),{visible:o}=t,r=e.columns.slice(0,4);return he(O,{title:e.title,source:e.source,testID:`buoy-block-table-${e.id}`,children:[z(s,{style:$.tableHead,children:r.map((n,i)=>z(l,{style:[$.th,i===0&&$.firstCol],numberOfLines:1,children:n},n))}),o.map((n,i)=>z(s,{style:[$.tr,i>0&&D.rowDivider],children:r.map((a,h)=>{let u=n[h],g=typeof u=="string"?u:u?.text??"",y=typeof u=="string"?void 0:u?.tone;return z(l,{style:[$.td,h===0&&$.firstCol,h===0&&$.tdFirst,y&&{color:xt(y)}],numberOfLines:2,children:Bt(g,$.td)},h)})},i)),z(ot,{paged:t})]})}function _l({block:e}){let t=tt(e.pairs,jt.keyValuePairs),{visible:o}=t,[r,n]=gr(null);return he(O,{title:e.title,source:e.source,testID:`buoy-block-keyvalue-${e.id}`,children:[o.map((i,a)=>{let h=typeof i.value=="object"&&i.value!==null,u=r===i.key;return he(m,{onPress:h?()=>n(u?null:i.key):void 0,style:[$.kvRow,a>0&&D.rowDivider],children:[z(l,{style:$.kvKey,numberOfLines:1,children:i.key}),z(l,{style:[$.kvValue,u&&D.mono],numberOfLines:u?void 0:2,selectable:true,children:u?JSON.stringify(i.value,null,2):xo(i.value)})]},i.key)}),z(ot,{paged:t})]})}function Ul(e){let t=!!e.image;return{canExpand:t,rowRunsAction:!!e.action&&!t,actionIsOwnControl:!!e.action&&t}}function Kl({block:e}){let t=Z(),o=tt(e.items,jt.listItems),{visible:r}=o,[n,i]=gr(null);return he(O,{title:e.title,source:e.source,testID:`buoy-block-list-${e.id}`,children:[r.map((a,h)=>{let u=`${a.id??a.title}-${h}`,g=n===u,{canExpand:y,rowRunsAction:C,actionIsOwnControl:j}=Ul(a),M=y||C?m:s,X=y?{onPress:()=>i(g?null:u),accessibilityRole:"button",accessibilityState:{expanded:g},accessibilityLabel:`${a.title}, ${g?"hide":"show"} picture`,testID:`buoy-block-list-row-${u}`}:C?{onPress:()=>void t.runAction(a.action,e.id),accessibilityRole:"button"}:{};return he(s,{style:h>0?D.rowDivider:void 0,children:[g&&a.image?z(m,{onPress:()=>i(null),accessibilityRole:"button",accessibilityLabel:`Hide ${a.title}`,testID:`buoy-block-list-hero-${u}`,style:$.listHero,children:z(mt,{testID:"buoy-internal-chat-image",source:{uri:a.image},style:$.listHeroImage,resizeMode:"contain",accessibilityLabel:a.title})}):null,he(M,{...X,style:D.row,children:[a.image&&!g?z(mt,{testID:"buoy-internal-chat-image",source:{uri:a.image},style:$.thumb,resizeMode:"contain",accessibilityLabel:a.title}):a.icon?z(cr,{name:a.icon}):null,he(s,{style:$.flex,children:[z(l,{style:[D.rowTitle,a.tone&&{color:xt(a.tone)}],numberOfLines:g?void 0:2,children:Bt(a.title,D.rowTitle)}),a.subtitle?z(l,{style:D.rowSub,numberOfLines:g?void 0:2,children:Bt(a.subtitle,D.rowSub)}):null]}),a.trailing?z(l,{style:[D.rowTrailing,a.tone&&{color:xt(a.tone)}],numberOfLines:1,children:a.trailing}):null,a.action?j?z(m,{onPress:()=>void t.runAction(a.action,e.id),accessibilityRole:"button",accessibilityLabel:a.action.label,hitSlop:8,children:z(l,{style:$.rowAction,children:a.action.label})}):z(l,{style:$.rowAction,children:a.action.label}):null]})]},u)}),z(ot,{paged:o})]})}function xr(e){return e!==null&&typeof e=="object"}function Gl(e){let t=e.map(n=>n.path),o=t.slice(0,3).join(", "),r=t.length-3;return`${t.length===1?"1 field":`${t.length} fields`} \xB7 ${o}${r>0?`, +${r}`:""}`}function Jl({block:e}){let t=tt(e.changes,jt.keyValuePairs);return he(O,{title:e.title??"What changed",source:e.source,testID:`buoy-block-diff-${e.id}`,collapsible:true,summary:Gl(e.changes),children:[t.visible.map((o,r)=>{let n=o.before===void 0&&o.after!==void 0,i=o.after===void 0&&o.before!==void 0;return he(s,{style:[$.diffRow,r>0&&D.rowDivider],children:[z(l,{style:$.diffPath,numberOfLines:1,children:o.path}),xr(o.before)||xr(o.after)?z(s,{style:$.diffTree,children:z(zl,{oldValue:o.before,newValue:o.after,showUnchanged:false,scrollEnabled:false})}):he(Ml,{children:[n?null:he(s,{style:$.diffLine,children:[z(l,{style:[$.diffMark,{color:B.color.danger}],children:"\u2212"}),z(l,{style:[$.diffValue,{color:B.color.danger}],numberOfLines:3,selectable:true,children:xo(o.before)})]}),i?null:he(s,{style:$.diffLine,children:[z(l,{style:[$.diffMark,{color:B.color.accent}],children:"+"}),z(l,{style:[$.diffValue,{color:B.color.accent}],numberOfLines:3,selectable:true,children:xo(o.after)})]})]})]},`${o.path}-${r}`)}),z(ot,{paged:t})]})}function Yl({block:e}){let t=e.bars.slice(0,jt.chartBars),o=e.max??Math.max(1,...t.map(r=>r.value));return z(O,{title:e.title,source:e.source,testID:`buoy-block-chart-${e.id}`,children:z(s,{style:$.chart,children:t.map((r,n)=>he(s,{style:$.barRow,children:[z(l,{style:$.barLabel,numberOfLines:1,children:r.label}),z(s,{style:$.barTrack,children:z(s,{style:[$.bar,{width:`${Math.max(2,Math.round(r.value/o*100))}%`,backgroundColor:xt(r.tone??"accent")}]})}),he(l,{style:$.barValue,numberOfLines:1,children:[r.value,r.unit?` ${r.unit}`:""]})]},`${r.label}-${n}`))})})}function Ql({block:e}){return z(O,{title:e.title,testID:`buoy-block-steps-${e.id}`,children:e.steps.map((t,o)=>he(s,{style:[$.step,o>0&&D.rowDivider],children:[z(s,{style:[$.stepMark,t.state==="done"&&$.stepDone,t.state==="failed"&&$.stepFailed],children:t.state==="done"?z(Sl,{size:10,color:B.color.onAccent}):t.state==="failed"?z(Cl,{size:10,color:B.color.text}):z(l,{style:$.stepNum,children:o+1})}),z(l,{style:[D.rowTitle,t.state==="done"&&$.stepTextDone],children:t.text})]},o))})}function Xl(e){try{let t=JSON.parse(e);return t!==null&&typeof t=="object"?t:void 0}catch{return}}function Zl({block:e,value:t}){return z(O,{title:e.title,testID:`buoy-block-code-${e.id}`,children:z(s,{style:$.viewer,children:z(Il,{title:e.title??"Payload",data:t,initialExpanded:true,showTypeFilter:false,testIDPrefix:`buoy-block-code-${e.id}`})})})}function ea({block:e}){return z(O,{title:e.title,testID:`buoy-block-code-${e.id}`,children:z(l,{style:[D.mono,$.code],selectable:true,children:e.text})})}function ta({block:e}){let t=Xl(e.text);return t===void 0?z(ea,{block:e}):z(Zl,{block:e,value:t})}function oa({block:e}){let t=e.tone==="danger"?B.color.danger:e.tone==="warning"?B.color.warning:B.color.info,o=e.tone==="info"?Tl:vl;return he(O,{tone:e.tone,testID:`buoy-block-notice-${e.id}`,children:[he(s,{style:$.noticeRow,children:[z(o,{size:14,color:t}),z(l,{style:$.noticeText,children:e.text})]}),z(We,{actions:e.actions,blockId:e.id})]})}function ra({block:e}){let{copied:t,copy:o}=to(()=>mr(e)??e.title);return he(O,{title:e.title,source:e.source,testID:`buoy-block-finding-${e.id}`,tone:"warning",children:[e.evidence.map((r,n)=>he(s,{style:[$.kvRow,n>0&&D.rowDivider],children:[z(l,{style:$.kvKey,numberOfLines:1,children:r.label}),z(l,{style:[$.kvValue,r.tone&&{color:xt(r.tone)}],selectable:true,children:r.value})]},`${r.label}-${n}`)),z(s,{style:$.findingFoot,children:z(m,{testID:`buoy-block-finding-copy-${e.id}`,accessibilityRole:"button",accessibilityLabel:t?"Copied":"Copy this finding",onPress:o,style:({pressed:r})=>[$.findingCopy,r&&{opacity:.7}],children:z(l,{style:[$.findingCopyText,t&&{color:B.color.accent}],children:t?"Copied":"Copy finding"})})}),z(We,{actions:e.actions,blockId:e.id})]})}var $=w.create({flex:{flex:1},tableHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,gap:8,backgroundColor:B.color.fill},th:{flex:1,color:B.color.textTertiary,fontSize:B.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"center"},td:{flex:1,color:B.color.textSecondary,fontSize:B.font.caption,lineHeight:17},tdFirst:{color:B.color.text,fontWeight:"500"},firstCol:{flex:1.4},kvRow:{flexDirection:"row",gap:12,paddingHorizontal:12,paddingVertical:8,alignItems:"flex-start"},kvKey:{width:110,color:B.color.textSecondary,fontSize:B.font.caption,paddingTop:1},kvValue:{flex:1,color:B.color.text,fontSize:B.font.caption,lineHeight:17},findingFoot:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,borderTopWidth:w.hairlineWidth,borderTopColor:B.color.separator},findingCopy:{paddingHorizontal:10,paddingVertical:5,borderRadius:B.radius.badge,backgroundColor:B.color.fill},findingCopyText:{color:B.color.textSecondary,fontSize:B.font.micro,fontWeight:"600"},thumb:{width:40,height:40,borderRadius:8,backgroundColor:B.color.fill},listHero:{paddingHorizontal:12,paddingTop:12},listHeroImage:{width:"100%",height:240,borderRadius:B.radius.row,backgroundColor:B.color.fill},rowAction:{color:B.color.accent,fontSize:B.font.caption,fontWeight:"600"},diffRow:{paddingHorizontal:12,paddingVertical:8,gap:3},diffPath:{color:B.color.textSecondary,fontSize:B.font.micro,fontWeight:"600",letterSpacing:.3},diffLine:{flexDirection:"row",gap:8,alignItems:"flex-start"},diffMark:{fontFamily:"Menlo",fontSize:12,width:10},diffValue:{flex:1,fontFamily:"Menlo",fontSize:12,lineHeight:16},diffTree:{borderRadius:B.radius.row,overflow:"hidden"},chart:{paddingHorizontal:12,paddingVertical:10,gap:8},barRow:{flexDirection:"row",alignItems:"center",gap:8},barLabel:{width:96,color:B.color.textSecondary,fontSize:B.font.caption},barTrack:{flex:1,height:10,borderRadius:5,backgroundColor:B.color.fill,overflow:"hidden"},bar:{height:10,borderRadius:5},barValue:{width:72,textAlign:"right",color:B.color.text,fontSize:B.font.caption,fontWeight:"600"},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:B.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:B.color.accent},stepFailed:{backgroundColor:B.color.danger},stepNum:{color:B.color.text,fontSize:B.font.micro,fontWeight:"700"},stepTextDone:{color:B.color.textSecondary},viewer:{paddingHorizontal:4,paddingBottom:8},code:{paddingHorizontal:12,paddingVertical:10,lineHeight:17},noticeRow:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:4},noticeText:{flex:1,color:B.color.text,fontSize:B.font.caption,lineHeight:18}});import{useState as na}from"react";import{night as Ee}from"@buoy-gg/shared-ui/web";import{CAPS as kr}from"@buoy-gg/agent-core/web";import{jsx as Ve,jsxs as ko}from"react/jsx-runtime";function ia({block:e}){let[t,o]=na(null),{width:r}=or(),n=e.images.slice(0,kr.gridMax),i=n.length>kr.gridImages,a=Math.min(150,Math.floor((r-2*Ee.gutter-24-8)/2)),h=({img:u,i:g})=>ko(m,{testID:`buoy-block-image-${g}`,accessibilityRole:"imagebutton",accessibilityLabel:u.alt,onPress:()=>o(t===g?null:g),style:[Ne.tile,{width:a},i&&Ne.tileCarousel],children:[Ve(mt,{testID:"buoy-internal-chat-image",source:{uri:u.url},style:[Ne.image,{width:a,height:a}],resizeMode:"contain",accessibilityLabel:u.alt}),Ve(l,{style:Ne.name,numberOfLines:1,children:u.alt}),u.caption?Ve(l,{style:Ne.caption,numberOfLines:1,children:u.caption}):null]},`${u.url}-${g}`);return ko(O,{title:e.title,source:e.source,testID:`buoy-block-imagegrid-${e.id}`,children:[t!==null&&n[t]?ko(m,{onPress:()=>o(null),style:Ne.hero,accessibilityRole:"button",accessibilityLabel:`Close ${n[t].alt}`,children:[Ve(mt,{testID:"buoy-internal-chat-image",source:{uri:n[t].url},style:Ne.heroImage,resizeMode:"contain",accessibilityLabel:n[t].alt}),Ve(l,{style:Ne.heroCaption,children:n[t].alt}),n[t].caption?Ve(l,{style:Ne.caption,children:n[t].caption}):null]}):null,i?Ve(Fe,{horizontal:true,showsHorizontalScrollIndicator:false,snapToInterval:a+8,decelerationRate:"fast",contentContainerStyle:Ne.carousel,children:n.map((u,g)=>Ve(h,{img:u,i:g},g))}):Ve(s,{style:Ne.grid,children:n.map((u,g)=>Ve(h,{img:u,i:g},g))}),Ve(yl,{shown:n.length,total:e.total})]})}var Ne=w.create({grid:{flexDirection:"row",flexWrap:"wrap",gap:8,padding:12},carousel:{gap:8,paddingHorizontal:12,paddingVertical:12},tile:{gap:4},tileCarousel:{},image:{borderRadius:Ee.radius.row,backgroundColor:Ee.color.fill},name:{color:Ee.color.text,fontSize:Ee.font.micro,fontWeight:"600"},caption:{color:Ee.color.textSecondary,fontSize:Ee.font.micro},hero:{alignItems:"center",padding:12,gap:6,borderBottomWidth:w.hairlineWidth,borderBottomColor:Ee.color.separator},heroImage:{width:"100%",height:240,borderRadius:Ee.radius.row,backgroundColor:Ee.color.fill},heroCaption:{color:Ee.color.text,fontSize:Ee.font.caption}});import{useState as la}from"react";import{AlertTriangle as aa,ChevronRight as sa,Eye as wr,night as R,NightSegmented as ca}from"@buoy-gg/shared-ui/web";import{CAPS as oo}from"@buoy-gg/agent-core/web";import{jsx as P,jsxs as se}from"react/jsx-runtime";function vr(e){return e===void 0?R.color.textTertiary:e>=500?R.color.danger:e>=400?R.color.warning:e>=300?R.color.info:R.color.accent}function Sr(e){try{let t=new URL(e);return t.pathname+(t.search?"?\u2026":"")}catch{return e}}function Tr({status:e}){return P(s,{style:[D.pill,{backgroundColor:`${vr(e)}22`}],children:P(l,{style:[D.pillText,{color:vr(e)}],children:e??"\u2026"})})}function da({block:e}){let t=Z(),o=t.supports?.openTool!==false,r=tt(e.requests,oo.listItems),{visible:n}=r;return se(O,{title:e.title??"Network requests",source:e.source,testID:`buoy-block-requests-${e.id}`,children:[n.map((i,a)=>se(m,{disabled:!o,onPress:()=>void t.runAction({label:"Open in Network",openTool:{toolId:"network",select:i.id}},e.id),style:[D.row,a>0&&D.rowDivider],accessibilityRole:o?"button":void 0,children:[P(l,{style:G.method,children:i.method}),P(l,{style:D.rowTitle,numberOfLines:1,children:Sr(i.url)}),i.mocked?P(l,{style:G.mockedChip,children:"MOCKED"}):null,i.durationMs!==void 0?se(l,{style:D.rowTrailing,children:[i.durationMs," ms"]}):null,P(Tr,{status:i.status}),o?P(sa,{size:12,color:R.color.textTertiary}):null]},`${i.id}-${a}`)),P(ot,{paged:r})]})}var ua=[{key:"response",label:"Response"},{key:"request",label:"Request"}];function pa({block:e}){let[t,o]=la("response"),r=t==="response"?e.responseBody:e.requestBody,n=r===void 0?"(none)":typeof r=="string"?r:JSON.stringify(r,null,2),i=Z();return se(O,{source:e.source,testID:`buoy-block-request-${e.id}`,children:[se(s,{style:[D.row,G.reqHead],children:[P(l,{style:G.method,children:e.request.method}),P(l,{style:D.rowTitle,numberOfLines:2,children:Sr(e.request.url)}),e.request.mocked?P(l,{style:G.mockedChip,children:"MOCKED"}):null,P(Tr,{status:e.request.status})]}),P(s,{style:G.tabs,children:P(ca,{tabs:ua,activeKey:t,onChange:a=>o(a),size:"sm"})}),P(l,{style:[D.mono,G.body],numberOfLines:14,selectable:true,children:n.length>1600?`${n.slice(0,1600)}
8
- \u2026`:n}),P(We,{blockId:e.id,actions:[{label:"Open in Network",openTool:{toolId:"network",select:e.request.id}}]}),(i.supports?.openTool===false,null)]})}function ha({block:e}){let t=Z().rules?.[e.rule.id],o=t?.deleted===true,r={...e.rule,enabled:o?false:t?.enabled??e.rule.enabled},n=r.kind==="fail"?"fails (no network)":r.kind==="delay"?`delayed ${r.delayMs??0} ms`:`returns ${r.status??200}`;return se(O,{title:r.name??"Network override",source:e.source,testID:`buoy-block-rule-${e.id}`,tone:r.enabled?"warning":void 0,children:[se(s,{style:G.ruleBody,children:[se(l,{style:G.ruleLine,children:[se(l,{style:G.ruleKey,children:[r.methods?.length?r.methods.join("/"):"ANY"," "]}),P(l,{style:D.mono,children:r.urlPattern})]}),se(l,{style:G.ruleLine,children:[P(l,{style:G.ruleKey,children:"\u2192 "}),n,r.times?` \xB7 ${r.times===1?"once":`${r.times} times`}`:" \xB7 every time",r.hits!==void 0?` \xB7 ${r.hits} hit${r.hits===1?"":"s"}`:""]}),P(s,{style:[D.pill,r.enabled?G.on:G.off],children:P(l,{style:[D.pillText,{color:r.enabled?R.color.onAccent:R.color.textSecondary}],children:o?"DELETED":r.enabled?"ON":"OFF"})})]}),o?null:P(We,{blockId:e.id,actions:[r.enabled?{label:"Turn off",dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:r.id,enabled:false}}}:{label:"Turn on",primary:true,dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:r.id,enabled:true}}},{label:"Delete",dispatch:{toolId:"network",action:"deleteOverrideRule",params:{id:r.id}}}]})]})}function ga({block:e}){let t=Z(),o=tt(e.elements,oo.chips),{visible:r}=o;return se(O,{title:e.title??"On screen right now",source:e.source,testID:`buoy-block-screen-${e.id}`,children:[r.map((n,i)=>se(m,{onPress:()=>void t.runAction({label:"Highlight",dispatch:{toolId:"highlight-updates",action:"setSpotlight",params:{nativeTag:n.nativeTag}}},e.id),disabled:t.supports?.dispatch===false,style:[D.row,i>0&&D.rowDivider],accessibilityRole:"button",children:[P(wr,{size:12,color:R.color.textTertiary}),P(l,{style:D.rowTitle,numberOfLines:1,children:n.label??n.testID??n.name}),P(l,{style:D.rowTrailing,numberOfLines:1,children:n.name})]},`${n.nativeTag}-${i}`)),P(ot,{paged:o})]})}function fa({block:e}){let t=Z(),o=tt(e.routes,oo.chips),r=o.visible;return se(O,{title:e.current?`Routes \xB7 you're on ${e.current}`:"Routes",source:e.source,testID:`buoy-block-routes-${e.id}`,children:[P(s,{style:G.chips,children:r.map((n,i)=>P(m,{disabled:t.supports?.dispatch===false,onPress:()=>n.dynamic?t.answer({blockId:e.id,kind:"input",value:`Open ${n.path} \u2014 which id?`}):void t.runAction({label:`Open ${n.path}`,dispatch:{toolId:"route-events",action:"navigate",params:{path:n.path}}},e.id),style:[G.chip,n.path===e.current&&G.chipCurrent],accessibilityRole:"button",children:P(l,{style:[G.chipText,n.dynamic&&G.chipDynamic],children:n.path})},`${n.path}-${i}`))}),P(ot,{paged:o})]})}var Cr={error:R.color.danger,warn:R.color.warning,warning:R.color.warning,info:R.color.info};function ba({block:e}){let t=tt(e.entries,oo.listItems),{visible:o}=t;return se(O,{title:"Console",source:e.source,testID:`buoy-block-logs-${e.id}`,children:[o.map((r,n)=>se(s,{style:[D.row,n>0&&D.rowDivider,G.logRow],children:[P(s,{style:[D.pill,{backgroundColor:`${Cr[r.level]??R.color.textTertiary}22`}],children:P(l,{style:[D.pillText,{color:Cr[r.level]??R.color.textSecondary}],children:r.level.toUpperCase()})}),P(l,{style:[D.rowTitle,D.mono],numberOfLines:3,children:r.message}),r.count>1?se(l,{style:D.rowTrailing,children:["\xD7",r.count]}):null]},`${r.level}-${r.message}-${n}`)),P(ot,{paged:t})]})}function ya({block:e}){return se(O,{tone:"danger",testID:`buoy-block-crash-${e.id}`,children:[se(s,{style:G.crashHead,children:[P(aa,{size:14,color:R.color.danger}),se(l,{style:G.crashTitle,children:["The app crashed",e.route?` on ${e.route}`:""]})]}),P(l,{style:[D.mono,G.crashMsg],numberOfLines:4,selectable:true,children:e.message}),e.suspect?se(l,{style:G.suspect,children:["Most likely cause: ",e.suspect.label]}):null,P(We,{blockId:e.id,actions:[...e.suspect?.action?[{...e.suspect.action,primary:true}]:[],...e.actions??[]].slice(0,2)})]})}function ma({block:e}){let t=Z(),o=t.supports?.minimize!==false;return se(m,{testID:`buoy-block-peek-${e.id}`,disabled:!o,onPress:()=>void t.runAction({label:"Look",minimize:true},e.id),style:({pressed:r})=>[G.peek,r&&{opacity:.7}],accessibilityRole:"button",accessibilityLabel:`${e.label}. Look at the app`,children:[P(l,{style:G.peekText,children:e.label}),o?se(s,{style:G.peekLook,children:[P(wr,{size:12,color:R.color.accent}),P(l,{style:G.peekLookText,children:"Look"})]}):null]})}var G=w.create({method:{color:R.color.textSecondary,fontSize:R.font.micro,fontWeight:"700",letterSpacing:.4,width:44},mockedChip:{color:R.color.warning,backgroundColor:R.color.warningSoft,fontSize:9,fontWeight:"700",letterSpacing:.6,paddingHorizontal:5,paddingVertical:1,borderRadius:R.radius.badge,overflow:"hidden"},reqHead:{paddingTop:12},tabs:{paddingHorizontal:12,paddingTop:4,paddingBottom:8},tab:{paddingHorizontal:10,paddingVertical:5,borderRadius:R.radius.badge,backgroundColor:R.color.fill},tabOn:{backgroundColor:R.color.accentSoft},tabText:{color:R.color.textSecondary,fontSize:R.font.micro,fontWeight:"600"},tabTextOn:{color:R.color.accent},body:{paddingHorizontal:12,paddingBottom:4,lineHeight:16,color:R.color.textSecondary},ruleBody:{paddingHorizontal:12,paddingTop:4,paddingBottom:4,gap:4},ruleLine:{color:R.color.text,fontSize:R.font.caption,lineHeight:18},ruleKey:{color:R.color.textSecondary,fontWeight:"700"},on:{alignSelf:"flex-start",backgroundColor:R.color.accent,marginTop:4},off:{alignSelf:"flex-start",backgroundColor:R.color.fillTertiary,marginTop:4},chips:{flexDirection:"row",flexWrap:"wrap",gap:6,padding:12},chip:{paddingHorizontal:10,paddingVertical:6,borderRadius:R.radius.chip,backgroundColor:R.color.fill,borderWidth:w.hairlineWidth,borderColor:R.color.border},chipCurrent:{backgroundColor:R.color.accentSoft,borderColor:R.color.accentBorderStrong},chipText:{color:R.color.text,fontSize:R.font.caption,fontFamily:"Menlo"},chipDynamic:{color:R.color.textSecondary},logRow:{alignItems:"flex-start"},crashHead:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingTop:12},crashTitle:{color:R.color.danger,fontSize:R.font.row,fontWeight:"600"},crashMsg:{paddingHorizontal:12,paddingTop:6,color:R.color.text},suspect:{color:R.color.textSecondary,fontSize:R.font.caption,paddingHorizontal:12,paddingTop:6},peek:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:10,paddingLeft:12,paddingRight:10,paddingVertical:7,borderRadius:R.radius.chip,backgroundColor:R.color.fill},peekText:{color:R.color.textSecondary,fontSize:R.font.caption},peekLook:{flexDirection:"row",alignItems:"center",gap:4},peekLookText:{color:R.color.accent,fontSize:R.font.caption,fontWeight:"600"}});import{useEffect as xa,useRef as Ir,useState as Ue}from"react";import{AlertTriangle as ka,Check as zr,ChevronDown as Dr,ChevronRight as Rr,night as d,NightSegmented as wa,RefreshCw as va,Search as Sa,X as Ta}from"@buoy-gg/shared-ui/web";import{Fragment as ro,jsx as p,jsxs as v}from"react/jsx-runtime";var $r=e=>typeof e=="string"?e:e===void 0?"\u2014":JSON.stringify(e);function Ca({block:e}){let t=Z();return p(s,{style:c.chips,testID:`buoy-block-suggestions-${e.id}`,children:e.chips.slice(0,4).map(o=>p(m,{disabled:!!t.busy,onPress:()=>void t.runAction({label:o.label,send:o.send??o.label},e.id),style:({pressed:r})=>[c.chip,r&&c.pressed],accessibilityRole:"button",children:p(l,{style:c.chipText,children:o.label})},o.label))})}function Ia({block:e}){let t=Z(),o=t.answered[e.id],r=!!o,[n,i]=Ue([]),a=o?.kind==="multi"?o.optionIds:n,h=g=>i(y=>y.includes(g)?y.filter(C=>C!==g):[...y,g]),u=n.length>=(e.min??1)&&(!e.max||n.length<=e.max);return v(O,{testID:`buoy-block-multi-${e.id}`,tone:r?void 0:"info",children:[p(l,{style:c.question,children:e.question}),p(s,{style:c.optionsBox,children:e.options.map((g,y)=>{let C=a.includes(g.id);return v(m,{disabled:r,onPress:()=>h(g.id),style:[c.option,y>0&&D.rowDivider,r&&!C&&c.dim],accessibilityRole:"checkbox",accessibilityState:{checked:C},children:[p(s,{style:[c.checkbox,C&&c.checkboxOn],children:C?p(zr,{size:11,color:d.color.onAccent}):null}),v(s,{style:c.flex,children:[p(l,{style:c.optionLabel,children:g.label}),g.detail?p(l,{style:c.optionDetail,children:g.detail}):null]})]},g.id)})}),r?null:p(s,{style:c.rowEnd,children:p(m,{testID:"buoy-block-multi-submit",disabled:!u,onPress:()=>t.answer({blockId:e.id,kind:"multi",optionIds:n,labels:e.options.filter(g=>n.includes(g.id)).map(g=>g.label)}),style:[c.button,c.buttonPrimary,!u&&c.disabled],children:p(l,{style:c.buttonTextPrimary,children:e.submitLabel??`Use ${n.length||""}`.trim()})})})]})}var za=8;function Da({block:e}){let t=Z(),o=t.answered[e.id],[r,n]=Ue(""),[i,a]=Ue(false),h=o?.kind==="select"?o.label:null,u=e.options.filter(y=>!r||y.label.toLowerCase().includes(r.toLowerCase())).slice(0,8),g=e.searchable!==false&&e.options.length>=za;return v(O,{testID:`buoy-block-select-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),h?p(l,{style:c.decided,children:h}):v(s,{style:c.selectBox,children:[v(m,{onPress:()=>a(y=>!y),style:c.selectField,accessibilityRole:"button",children:[p(l,{style:c.selectPlaceholder,children:i?"Choose\u2026":`${e.options.length} options`}),p(Dr,{size:14,color:d.color.textSecondary})]}),i&&v(ro,{children:[g&&v(s,{style:c.search,children:[p(Sa,{size:12,color:d.color.textSecondary}),p(Ze,{style:c.searchInput,value:r,onChangeText:n,placeholder:"Search",placeholderTextColor:d.color.placeholder,autoCapitalize:"none",autoCorrect:false})]}),u.map((y,C)=>v(m,{onPress:()=>t.answer({blockId:e.id,kind:"select",optionId:y.id,label:y.label}),style:[c.option,C>0&&D.rowDivider],accessibilityRole:"button",children:[v(s,{style:c.flex,children:[p(l,{style:c.optionLabel,children:y.label}),y.detail?p(l,{style:c.optionDetail,children:y.detail}):null]}),p(Rr,{size:12,color:d.color.textTertiary})]},y.id)),e.options.length>u.length?v(l,{style:c.hint,children:[e.options.length-u.length," more \u2014 keep typing"]}):null]})]})]})}function Ar({min:e,max:t,step:o=1,value:r,unit:n,onChange:i,disabled:a}){let h=Ir(0),u=t>e?(r-e)/(t-e)*100:0,g=M=>Math.min(t,Math.max(e,+(Math.round((M-e)/o)*o+e).toFixed(6))),y=M=>!a&&i(g(r+M*o)),C=M=>{if(a||h.current<=0)return;let X=Math.min(1,Math.max(0,M.nativeEvent.locationX/h.current));i(g(e+X*(t-e)))},j=M=>{h.current=M.nativeEvent.layout.width};return v(s,{style:c.sliderRow,children:[p(m,{disabled:a,onPress:()=>y(-1),style:c.stepBtn,accessibilityRole:"button",accessibilityLabel:"Decrease",children:p(l,{style:c.stepText,children:"\u2212"})}),p(m,{style:c.trackHit,onLayout:j,onPress:C,disabled:a,accessibilityRole:"adjustable",accessibilityValue:{min:e,max:t,now:r},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:M=>y(M.nativeEvent.actionName==="increment"?1:-1),children:v(s,{style:c.track,pointerEvents:"none",children:[p(s,{style:[c.fill,{width:`${u}%`}]}),p(s,{style:[c.thumb,{left:`${u}%`}]})]})}),p(m,{disabled:a,onPress:()=>y(1),style:c.stepBtn,accessibilityRole:"button",accessibilityLabel:"Increase",children:p(l,{style:c.stepText,children:"+"})}),v(l,{style:c.sliderValue,children:[r,n?` ${n}`:""]})]})}function Ra({block:e}){let t=Z(),o=t.answered[e.id],[r,n]=Ue(e.value??e.min);return v(O,{testID:`buoy-block-slider-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),p(s,{style:c.pad,children:p(Ar,{min:e.min,max:e.max,step:e.step,value:o?.kind==="slider"?o.value:r,unit:e.unit,onChange:n,disabled:!!o})}),o?null:p(s,{style:c.rowEnd,children:p(m,{onPress:()=>t.answer({blockId:e.id,kind:"slider",value:r,unit:e.unit}),style:[c.button,c.buttonPrimary],children:v(l,{style:c.buttonTextPrimary,children:["Use ",r,e.unit?` ${e.unit}`:""]})})})]})}function $a({block:e}){let t=Z(),o=t.answered[e.id],[r,n]=Ue(""),i=e.presets??[{label:"Now",value:new Date().toISOString()},{label:"Tomorrow",value:new Date(Date.now()+864e5).toISOString()},{label:"+7 days",value:new Date(Date.now()+7*864e5).toISOString()},{label:"+30 days",value:new Date(Date.now()+30*864e5).toISOString()}];return v(O,{testID:`buoy-block-datetime-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),o?p(l,{style:c.decided,children:o.kind==="dateTime"?o.label??o.value:"(skipped)"}):v(ro,{children:[p(s,{style:[c.chips,c.pad],children:i.map(a=>p(m,{onPress:()=>t.answer({blockId:e.id,kind:"dateTime",value:a.value,label:a.label}),style:c.chip,children:p(l,{style:c.chipText,children:a.label})},a.label))}),v(s,{style:[c.inputRow,c.pad],children:[p(Ze,{style:c.input,value:r,onChangeText:n,placeholder:e.mode==="time"?"14:30":"2026-09-15",placeholderTextColor:d.color.placeholder,keyboardType:"numbers-and-punctuation"}),p(m,{disabled:!r.trim(),onPress:()=>t.answer({blockId:e.id,kind:"dateTime",value:r.trim()}),style:[c.button,c.buttonPrimary,!r.trim()&&c.disabled],children:p(l,{style:c.buttonTextPrimary,children:"Use"})})]})]})]})}function Br({f:e,value:t,onChange:o,disabled:r}){return e.type==="toggle"?v(s,{style:c.fieldRow,children:[p(l,{style:c.fieldLabel,children:e.label}),p(rr,{value:!!t,onValueChange:o,disabled:r,trackColor:{true:d.color.accent,false:d.color.fillTertiary},thumbColor:d.color.knob})]}):e.type==="select"?v(s,{style:c.fieldCol,children:[p(l,{style:c.fieldLabel,children:e.label}),p(s,{style:c.chips,children:e.options.map(n=>p(m,{disabled:r,onPress:()=>o(n.id),style:[c.chip,t===n.id&&c.chipOn],children:p(l,{style:[c.chipText,t===n.id&&c.chipTextOn],children:n.label})},n.id))})]}):e.type==="slider"?v(s,{style:c.fieldCol,children:[p(l,{style:c.fieldLabel,children:e.label}),p(Ar,{min:e.min,max:e.max,step:e.step,unit:e.unit,value:typeof t=="number"?t:e.min,onChange:o,disabled:r})]}):v(s,{style:c.fieldRow,children:[p(l,{style:c.fieldLabel,children:e.label}),p(Ze,{style:c.fieldInput,value:t==null?"":String(t),onChangeText:o,editable:!r,placeholder:e.placeholder??"",placeholderTextColor:d.color.placeholder,keyboardType:e.type==="number"?"numeric":"ascii-capable",secureTextEntry:e.type==="secret",autoCapitalize:"none",autoCorrect:false})]})}function Hr(e){let[t,o]=Ue(()=>Object.fromEntries(e.map(r=>[r.key,r.value])));return{values:t,set:(r,n)=>o(i=>({...i,[r]:n}))}}function Aa({block:e}){let t=Z(),o=t.answered[e.id],{values:r,set:n}=Hr(e.fields);return v(O,{title:e.title,testID:`buoy-block-form-${e.id}`,tone:o?void 0:"info",children:[p(s,{style:c.pad,children:e.fields.map(i=>p(Br,{f:i,value:r[i.key],onChange:a=>n(i.key,a),disabled:!!o},i.key))}),o?p(l,{style:c.decided,children:"Sent"}):p(s,{style:c.rowEnd,children:p(m,{onPress:()=>t.answer({blockId:e.id,kind:"form",values:r}),style:[c.button,c.buttonPrimary],children:p(l,{style:c.buttonTextPrimary,children:e.submitLabel??"Send"})})})]})}function Ba({block:e}){let t=Z(),o=t.answered[e.id],{values:r,set:n}=Hr(e.fields),i=o?.kind==="proposal"?o.approved:null;return v(O,{testID:`buoy-block-proposal-${e.id}`,tone:o?void 0:"warning",children:[p(l,{style:c.confirmTitle,children:e.title}),p(l,{style:c.confirmChange,children:e.change}),p(s,{style:c.pad,children:e.fields.map(a=>p(Br,{f:a,value:r[a.key],onChange:h=>n(a.key,h),disabled:!!o},a.key))}),e.consequence?p(l,{style:c.consequence,children:e.consequence}):null,p(s,{style:c.actionsRow,children:o?p(l,{style:c.decided,children:i?"\u2713 Applied with these values":"\u2715 Not applied"}):v(ro,{children:[p(m,{onPress:()=>t.answer({blockId:e.id,kind:"proposal",approved:true,values:r}),style:[c.button,c.buttonPrimary],children:p(l,{style:c.buttonTextPrimary,children:e.approveLabel??"Apply"})}),p(m,{onPress:()=>t.answer({blockId:e.id,kind:"proposal",approved:false}),style:[c.button,c.buttonPlate],children:p(l,{style:c.buttonTextPlate,children:"Not now"})})]})})]})}function Ha({block:e}){let t=Z(),[o,r]=Ue(null),n=t.actionState?.[`${e.id}:${e.verify?.label??"Verify"}`],i=e.verified||n==="done";return v(s,{style:c.claim,testID:`buoy-block-claim-${e.id}`,children:[v(l,{style:c.claimText,children:[e.text,e.sources.map((a,h)=>v(l,{onPress:()=>r(o===h?null:h),style:c.cite,children:[" [",h+1,"]"]},h)),i?p(l,{style:c.verified,children:" \u2713 verified"}):null]}),o!==null&&e.sources[o]?v(s,{style:c.citeBox,children:[v(l,{style:c.citeLabel,children:["[",o+1,"] ",e.sources[o].label]}),e.sources[o].detail?p(l,{style:c.citeDetail,children:e.sources[o].detail}):null]}):null,e.verify&&!i?v(m,{onPress:()=>void t.runAction(e.verify,e.id),style:c.verifyBtn,accessibilityRole:"button",children:[p(va,{size:11,color:d.color.accent}),p(l,{style:c.verifyText,children:n==="running"?"Checking\u2026":e.verify.label})]}):null]})}function La({block:e}){let[t,o]=Ue(!!e.open);return v(O,{testID:`buoy-block-details-${e.id}`,children:[v(m,{onPress:()=>o(r=>!r),style:D.row,accessibilityRole:"button",accessibilityState:{expanded:t},children:[p(l,{style:D.rowTitle,children:e.summary}),t?p(Dr,{size:12,color:d.color.textTertiary}):p(Rr,{size:12,color:d.color.textTertiary})]}),t?p(l,{style:c.detailsBody,selectable:true,children:e.body}):null]})}function Pa({block:e,renderNested:t}){let[o,r]=Ue(0),n=e.tabs.map((a,h)=>({key:String(h),label:a.label})),i=e.tabs[o];return v(s,{style:c.tabsWrap,testID:`buoy-block-tabs-${e.id}`,children:[p(wa,{tabs:n,activeKey:String(o),onChange:a=>r(Number(a)),size:"sm"}),i&&t?t(i.block):null]})}var Oa=10;function Wa({block:e}){let t=tt(e.events,Oa);return v(O,{title:e.title??"What happened",source:e.source,testID:`buoy-block-timeline-${e.id}`,children:[t.visible.map((o,r)=>v(s,{style:c.tlRow,children:[p(l,{style:c.tlAt,children:o.at}),v(s,{style:c.tlLine,children:[p(s,{style:[c.tlDot,{backgroundColor:xt(o.tone??"muted")}]}),r<t.visible.length-1?p(s,{style:c.tlStem}):null]}),v(s,{style:c.flex,children:[p(l,{style:c.tlSource,children:o.source.toUpperCase()}),p(l,{style:D.rowTitle,numberOfLines:2,children:o.label})]})]},r)),p(ot,{paged:t})]})}function Ea({block:e}){let t=e.series.slice(-60),o=Math.max(1,...t),r=Math.min(...t,0),n=44;return v(O,{title:e.title,source:e.source,testID:`buoy-block-sparkline-${e.id}`,children:[v(s,{style:c.sparkHead,children:[v(l,{style:c.sparkCurrent,children:[e.current??t[t.length-1],e.unit?v(l,{style:c.sparkUnit,children:[" ",e.unit]}):null]}),e.live?p(Lr,{}):null]}),p(s,{style:[c.spark,{height:n}],children:t.map((i,a)=>p(s,{style:[c.sparkBar,{height:Math.max(2,(i-r)/(o-r||1)*n),backgroundColor:a===t.length-1?d.color.accent:d.color.accentBorderStrong}]},a))}),e.label?p(l,{style:c.hint,children:e.label}):null]})}function Lr(){let e=Ir(new ce.Value(1)).current;return xa(()=>{let t=ce.loop(ce.sequence([ce.timing(e,{toValue:.3,duration:700,useNativeDriver:true}),ce.timing(e,{toValue:1,duration:700,useNativeDriver:true})]));return t.start(),()=>t.stop()},[e]),v(s,{style:c.live,children:[p(ce.View,{style:[c.liveDot,{opacity:e}]}),p(l,{style:c.liveText,children:"LIVE"})]})}function Va({block:e}){let t=[...new Set([...e.left.pairs.map(n=>n.key),...e.right.pairs.map(n=>n.key)])],o=Object.fromEntries(e.left.pairs.map(n=>[n.key,n.value])),r=Object.fromEntries(e.right.pairs.map(n=>[n.key,n.value]));return v(O,{title:e.title,source:e.source,testID:`buoy-block-compare-${e.id}`,children:[v(s,{style:c.cmpHead,children:[p(l,{style:c.cmpKey}),p(l,{style:c.cmpCol,children:e.left.title}),p(l,{style:c.cmpCol,children:e.right.title})]}),t.map((n,i)=>{let a=JSON.stringify(o[n])!==JSON.stringify(r[n]);return v(s,{style:[c.cmpRow,i>0&&D.rowDivider,a&&c.cmpDiff],children:[p(l,{style:c.cmpKey,numberOfLines:1,children:n}),p(l,{style:[c.cmpVal,a&&{color:d.color.danger}],numberOfLines:2,children:$r(o[n])}),p(l,{style:[c.cmpVal,a&&{color:d.color.accent}],numberOfLines:2,children:$r(r[n])})]},n)})]})}function Pr({c:e,id:t}){return v(ro,{children:[e.image?p(mt,{testID:"buoy-internal-chat-image",source:{uri:e.image},style:c.cardImage,resizeMode:"contain",accessibilityLabel:e.title}):null,v(s,{style:c.cardText,children:[p(l,{style:c.cardTitle,numberOfLines:2,children:e.title}),e.subtitle?p(l,{style:D.rowSub,numberOfLines:2,children:e.subtitle}):null,e.facts?.slice(0,4).map(o=>v(s,{style:c.fact,children:[p(l,{style:c.factLabel,children:o.label}),p(l,{style:[c.factValue,o.tone&&{color:xt(o.tone)}],children:o.value})]},o.label))]}),p(We,{actions:e.actions,blockId:t})]})}function Na({block:e}){return p(O,{source:e.source,testID:`buoy-block-card-${e.id}`,children:p(Pr,{c:e,id:e.id})})}function ja({block:e}){return v(s,{testID:`buoy-block-cardcarousel-${e.id}`,children:[e.title?p(l,{style:c.carouselTitle,children:e.title}):null,p(Fe,{horizontal:true,showsHorizontalScrollIndicator:false,snapToInterval:232,decelerationRate:"fast",contentContainerStyle:c.carousel,children:e.cards.slice(0,8).map((t,o)=>p(s,{style:c.carouselCard,children:p(Pr,{c:t,id:`${e.id}-${o}`})},`${t.title}-${o}`))})]})}function qa({block:e}){let[t,o]=Ue(false);return v(O,{title:e.route?`Screen \xB7 ${e.route}`:"Screen",source:e.source,testID:`buoy-block-screenshot-${e.id}`,children:[p(m,{onPress:()=>o(r=>!r),accessibilityRole:"imagebutton",accessibilityLabel:e.caption??"Screenshot",children:p(mt,{testID:"buoy-internal-chat-image",source:{uri:e.url},style:[c.shot,t&&c.shotBig],resizeMode:"contain"})}),e.caption?p(l,{style:c.hint,children:e.caption}):null]})}function Ma({block:e}){let t=e.steps.filter(o=>o.state==="done").length;return v(O,{title:e.title,testID:`buoy-block-plan-${e.id}`,tone:e.pending?"info":void 0,children:[p(s,{style:c.progress,children:p(s,{style:[c.progressFill,{width:`${t/Math.max(1,e.steps.length)*100}%`}]})}),e.steps.map((o,r)=>v(s,{style:[c.step,r>0&&D.rowDivider],children:[p(s,{style:[c.stepMark,o.state==="done"&&c.stepDone,o.state==="failed"&&c.stepFailed,o.state==="running"&&c.stepRunning],children:o.state==="done"?p(zr,{size:10,color:d.color.onAccent}):o.state==="failed"?p(Ta,{size:10,color:d.color.text}):p(l,{style:c.stepNum,children:r+1})}),v(l,{style:[D.rowTitle,o.state==="done"&&c.muted],children:[o.text,o.state==="running"?"\u2026":""]})]},r)),p(We,{actions:e.actions??(e.pending?[{label:"Go",primary:true,send:"Go ahead with the plan."},{label:"Change it",send:"Let me change the plan first."}]:void 0),blockId:e.id})]})}function Fa({block:e}){let t=Z();return v(m,{testID:`buoy-block-checkpoint-${e.id}`,disabled:!e.restore,onPress:()=>e.restore&&void t.runAction(e.restore,e.id),style:c.checkpoint,accessibilityRole:"button",children:[p(s,{style:c.cpFlag}),v(l,{style:c.cpText,children:[e.label,e.at?` \xB7 ${e.at}`:""]}),e.restore?p(l,{style:c.cpRestore,children:e.restore.label}):null]})}function _a({block:e}){let t=e.status==="failed"?d.color.danger:e.status==="done"?d.color.accent:d.color.info;return v(O,{testID:`buoy-block-task-${e.id}`,children:[v(s,{style:c.taskHead,children:[p(l,{style:c.cardTitle,children:e.title}),p(s,{style:[D.pill,{backgroundColor:`${t}22`}],children:p(l,{style:[D.pillText,{color:t}],children:e.status.toUpperCase()})})]}),e.progress!==void 0?p(s,{style:[c.progress,c.pad],children:p(s,{style:[c.progressFill,{width:`${Math.round(e.progress*100)}%`,backgroundColor:t}]})}):null,e.detail?p(l,{style:c.hint,children:e.detail}):null,p(We,{actions:e.actions,blockId:e.id})]})}function Ua({block:e}){let t=e.tone==="danger"?d.color.danger:e.tone==="warning"?d.color.warning:d.color.info;return v(s,{style:[c.banner,{borderColor:t,backgroundColor:`${t}1A`}],testID:`buoy-block-banner-${e.id}`,children:[p(ka,{size:13,color:t}),p(l,{style:[c.bannerText,{color:t}],numberOfLines:2,children:e.text}),e.actions?.[0]?p(We,{actions:e.actions.slice(0,1),blockId:e.id,align:"right"}):null]})}function Ka({block:e}){return v(O,{testID:`buoy-block-file-${e.id}`,children:[v(s,{style:D.row,children:[p(s,{style:c.fileIcon,children:p(l,{style:c.fileExt,children:(e.type??e.name.split(".").pop()??"file").toUpperCase().slice(0,4)})}),v(s,{style:c.flex,children:[p(l,{style:D.rowTitle,numberOfLines:1,children:e.name}),e.size?p(l,{style:D.rowSub,children:e.size}):null]})]}),p(We,{actions:e.actions,blockId:e.id})]})}function Ga({block:e}){let t=Z(),o=t.answered[e.id];return v(O,{testID:`buoy-block-upload-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),o?p(l,{style:c.decided,children:o.kind==="upload"?`Attached ${o.name}`:"(skipped)"}):p(s,{style:[c.rowEnd,{justifyContent:"flex-start"}],children:p(m,{onPress:()=>t.answer({blockId:e.id,kind:"upload",name:"screenshot.png"}),style:[c.button,c.buttonPlate],children:p(l,{style:c.buttonTextPlate,children:e.accept==="image"?"Choose a screenshot":"Choose a file"})})})]})}var c=w.create({flex:{flex:1},pad:{paddingHorizontal:12,paddingBottom:8},muted:{color:d.color.textSecondary},dim:{opacity:.45},disabled:{opacity:.5},pressed:{opacity:.7},question:{color:d.color.text,fontSize:d.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},hint:{color:d.color.textTertiary,fontSize:d.font.micro,paddingHorizontal:12,paddingBottom:10},decided:{color:d.color.textSecondary,fontSize:d.font.caption,fontWeight:"600",paddingHorizontal:12,paddingVertical:10},rowEnd:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:12,paddingBottom:12,gap:8},actionsRow:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:12,alignItems:"center"},button:{paddingHorizontal:14,paddingVertical:9,borderRadius:d.radius.row},buttonPrimary:{backgroundColor:d.color.accent},buttonPlate:{backgroundColor:d.color.button},buttonTextPrimary:{color:d.color.onAccent,fontSize:d.font.caption,fontWeight:"600"},buttonTextPlate:{color:d.color.text,fontSize:d.font.caption,fontWeight:"600"},chips:{flexDirection:"row",flexWrap:"wrap",gap:6},chip:{paddingHorizontal:12,paddingVertical:7,borderRadius:d.radius.chip,backgroundColor:d.color.fill,borderWidth:w.hairlineWidth,borderColor:d.color.border},chipOn:{backgroundColor:d.color.accentSoft,borderColor:d.color.accentBorderStrong},chipText:{color:d.color.text,fontSize:d.font.caption},chipTextOn:{color:d.color.accent,fontWeight:"600"},optionsBox:{marginHorizontal:8,marginBottom:8,borderRadius:d.radius.row,backgroundColor:d.color.surfaceElevated,overflow:"hidden"},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:10},optionLabel:{color:d.color.text,fontSize:d.font.body,fontWeight:"500"},optionDetail:{color:d.color.textSecondary,fontSize:d.font.caption},checkbox:{width:20,height:20,borderRadius:6,borderWidth:1.5,borderColor:d.color.textTertiary,alignItems:"center",justifyContent:"center"},checkboxOn:{backgroundColor:d.color.accent,borderColor:d.color.accent},selectBox:{marginHorizontal:12,marginBottom:12,borderRadius:d.radius.row,backgroundColor:d.color.surfaceElevated,overflow:"hidden"},selectField:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:11},selectPlaceholder:{color:d.color.textSecondary,fontSize:d.font.body},search:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:6,borderTopWidth:w.hairlineWidth,borderTopColor:d.color.separator},searchInput:{flex:1,color:d.color.text,fontSize:d.font.caption,paddingVertical:4},sliderRow:{flexDirection:"row",alignItems:"center",gap:8},stepBtn:{width:28,height:28,borderRadius:14,backgroundColor:d.color.fill,alignItems:"center",justifyContent:"center"},stepText:{color:d.color.text,fontSize:16,fontWeight:"600"},trackHit:{flex:1,height:36,justifyContent:"center"},track:{height:6,borderRadius:3,backgroundColor:d.color.fillTertiary,justifyContent:"center"},fill:{height:6,borderRadius:3,backgroundColor:d.color.accent},thumb:{position:"absolute",width:20,height:20,borderRadius:10,backgroundColor:d.color.knob,marginLeft:-10,shadowColor:"#000",shadowOpacity:.35,shadowRadius:3,shadowOffset:{width:0,height:1}},sliderValue:{width:64,textAlign:"right",color:d.color.text,fontSize:d.font.caption,fontWeight:"600"},inputRow:{flexDirection:"row",alignItems:"center",gap:8,paddingBottom:12},input:{flex:1,height:38,paddingHorizontal:12,borderRadius:d.radius.row,backgroundColor:d.color.surfaceElevated,color:d.color.text,fontSize:d.font.body},fieldRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:10,paddingVertical:6},fieldCol:{paddingVertical:6,gap:6},fieldLabel:{color:d.color.textSecondary,fontSize:d.font.caption,width:110},fieldInput:{flex:1,height:34,paddingHorizontal:10,borderRadius:d.radius.segment,backgroundColor:d.color.surfaceElevated,color:d.color.text,fontSize:d.font.caption},confirmTitle:{color:d.color.text,fontSize:d.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:d.color.text,fontSize:d.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6,paddingBottom:6},consequence:{color:d.color.warning,fontSize:d.font.caption,paddingHorizontal:12},claim:{gap:6,paddingHorizontal:2},claimText:{color:d.color.text,fontSize:d.font.row,lineHeight:22},cite:{color:d.color.accent,fontSize:d.font.caption,fontWeight:"700"},verified:{color:d.color.accent,fontSize:d.font.caption,fontWeight:"600"},citeBox:{padding:10,borderRadius:d.radius.row,backgroundColor:d.color.surface,borderWidth:w.hairlineWidth,borderColor:d.color.border,gap:2},citeLabel:{color:d.color.text,fontSize:d.font.caption,fontWeight:"600"},citeDetail:{color:d.color.textSecondary,fontSize:d.font.caption,fontFamily:"Menlo"},verifyBtn:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:5,paddingHorizontal:10,paddingVertical:5,borderRadius:d.radius.chip,backgroundColor:d.color.accentSoft},verifyText:{color:d.color.accent,fontSize:d.font.micro,fontWeight:"700"},detailsBody:{color:d.color.textSecondary,fontSize:d.font.caption,lineHeight:18,paddingHorizontal:12,paddingBottom:12},tabsWrap:{gap:8},tabBar:{flexDirection:"row",gap:6},tab:{paddingHorizontal:12,paddingVertical:6,borderRadius:d.radius.badge,backgroundColor:d.color.fill},tabOn:{backgroundColor:d.color.accentSoft},tabText:{color:d.color.textSecondary,fontSize:d.font.caption,fontWeight:"600"},tabTextOn:{color:d.color.accent},tlRow:{flexDirection:"row",gap:10,paddingHorizontal:12,paddingVertical:4,alignItems:"flex-start"},tlAt:{width:46,color:d.color.textTertiary,fontSize:d.font.micro,fontFamily:"Menlo",paddingTop:3},tlLine:{width:12,alignItems:"center"},tlDot:{width:8,height:8,borderRadius:4,marginTop:5},tlStem:{width:1,flex:1,minHeight:18,backgroundColor:d.color.separator,marginTop:2},tlSource:{color:d.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6},sparkHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingTop:8},sparkCurrent:{color:d.color.text,fontSize:22,fontWeight:"700"},sparkUnit:{color:d.color.textSecondary,fontSize:d.font.caption,fontWeight:"500"},spark:{flexDirection:"row",alignItems:"flex-end",gap:2,paddingHorizontal:12,paddingTop:6,paddingBottom:6},sparkBar:{flex:1,borderRadius:1},live:{flexDirection:"row",alignItems:"center",gap:5,paddingHorizontal:8,paddingVertical:3,borderRadius:d.radius.badge,backgroundColor:d.color.dangerSoft},liveDot:{width:6,height:6,borderRadius:3,backgroundColor:d.color.danger},liveText:{color:d.color.danger,fontSize:9,fontWeight:"800",letterSpacing:.8},cmpHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,backgroundColor:d.color.fill,gap:8},cmpCol:{flex:1,color:d.color.textTertiary,fontSize:d.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},cmpRow:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"flex-start"},cmpDiff:{backgroundColor:d.color.fill},cmpKey:{width:90,color:d.color.textSecondary,fontSize:d.font.caption},cmpVal:{flex:1,color:d.color.text,fontSize:d.font.caption,fontFamily:"Menlo"},cardImage:{width:"100%",height:140,backgroundColor:d.color.fill},cardText:{paddingHorizontal:12,paddingTop:10,paddingBottom:4,gap:4},cardTitle:{color:d.color.text,fontSize:d.font.row,fontWeight:"600"},fact:{flexDirection:"row",justifyContent:"space-between",gap:8},factLabel:{color:d.color.textSecondary,fontSize:d.font.caption},factValue:{color:d.color.text,fontSize:d.font.caption,fontWeight:"500"},carouselTitle:{color:d.color.text,fontSize:d.font.caption,fontWeight:"600",paddingBottom:8},carousel:{gap:8,paddingRight:8},carouselCard:{width:224,borderRadius:d.radius.card,borderWidth:w.hairlineWidth,borderColor:d.color.border,backgroundColor:d.color.surface,overflow:"hidden"},shot:{width:"100%",height:220,backgroundColor:d.color.fill},shotBig:{height:520},progress:{height:4,backgroundColor:d.color.fill,marginHorizontal:12,marginTop:6,marginBottom:8,borderRadius:2,overflow:"hidden"},progressFill:{height:4,backgroundColor:d.color.accent},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:d.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:d.color.accent},stepFailed:{backgroundColor:d.color.danger},stepRunning:{backgroundColor:d.color.info},stepNum:{color:d.color.text,fontSize:d.font.micro,fontWeight:"700"},checkpoint:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:7,borderRadius:d.radius.chip,backgroundColor:d.color.fill},cpFlag:{width:8,height:8,borderRadius:2,backgroundColor:d.color.info},cpText:{color:d.color.textSecondary,fontSize:d.font.caption},cpRestore:{color:d.color.accent,fontSize:d.font.caption,fontWeight:"600"},taskHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8,paddingHorizontal:12,paddingTop:12},banner:{flexDirection:"row",alignItems:"center",gap:8,paddingLeft:12,paddingRight:4,paddingVertical:4,borderRadius:d.radius.row,borderWidth:w.hairlineWidth},bannerText:{flex:1,fontSize:d.font.caption,fontWeight:"600"},fileIcon:{width:40,height:40,borderRadius:8,backgroundColor:d.color.fill,alignItems:"center",justifyContent:"center"},fileExt:{color:d.color.textSecondary,fontSize:10,fontWeight:"800"}});import{jsx as A}from"react/jsx-runtime";var Ja=class extends Ki{constructor(){super(...arguments);this.state={failed:false}}static getDerivedStateFromError(){return{failed:true}}render(){return this.state.failed?A(l,{style:Ya.fallback,testID:"buoy-block-render-failed",children:"This card couldn't be drawn \u2014 the data behind it is still in the conversation."}):this.props.children}},Ya=w.create({fallback:{color:ir.color.textTertiary,fontSize:ir.font.micro,fontStyle:"italic",paddingVertical:6}}),Qa=e=>A(no,{block:e});function no({block:e}){return A(Ja,{children:A(Xa,{block:e})})}function Xa({block:e}){switch(e.kind){case"choice":return A(xl,{block:e});case"confirm":return A(kl,{block:e});case"input":return A(wl,{block:e});case"table":return A(Fl,{block:e});case"keyValue":return A(_l,{block:e});case"list":return A(Kl,{block:e});case"imageGrid":return A(ia,{block:e});case"diff":return A(Jl,{block:e});case"chart":return A(Yl,{block:e});case"steps":return A(Ql,{block:e});case"code":return A(ta,{block:e});case"actions":return A(We,{actions:e.actions,blockId:e.id});case"notice":return A(oa,{block:e});case"finding":return A(ra,{block:e});case"requestList":return A(da,{block:e});case"requestCard":return A(pa,{block:e});case"ruleCard":return A(ha,{block:e});case"screenElements":return A(ga,{block:e});case"routeChips":return A(fa,{block:e});case"logList":return A(ba,{block:e});case"crash":return A(ya,{block:e});case"peek":return A(ma,{block:e});case"suggestions":return A(Ca,{block:e});case"multiSelect":return A(Ia,{block:e});case"select":return A(Da,{block:e});case"slider":return A(Ra,{block:e});case"dateTime":return A($a,{block:e});case"form":return A(Aa,{block:e});case"proposal":return A(Ba,{block:e});case"claim":return A(Ha,{block:e});case"details":return A(La,{block:e});case"tabs":return A(Pa,{block:e,renderNested:Qa});case"timeline":return A(Wa,{block:e});case"sparkline":return A(Ea,{block:e});case"compare":return A(Va,{block:e});case"card":return A(Na,{block:e});case"cardCarousel":return A(ja,{block:e});case"screenshot":return A(qa,{block:e});case"plan":return A(Ma,{block:e});case"checkpoint":return A(Fa,{block:e});case"task":return A(_a,{block:e});case"banner":return A(Ua,{block:e});case"file":return A(Ka,{block:e});case"upload":return A(Ga,{block:e});default:return null}}import{useEffect as Za,useState as wt}from"react";import{ChevronDown as es,ChevronRight as ts,Copy as os,night as T,RefreshCw as rs}from"@buoy-gg/shared-ui/web";import{jsx as E,jsxs as ze}from"react/jsx-runtime";function qt({label:e,onPress:t,children:o}){return E(m,{onPress:t,accessibilityRole:"button",accessibilityLabel:e,style:({pressed:r})=>[L.iconBtn,r&&L.pressed],children:o})}function ns({id:e="chrome-actions"}){let t=Z(),[o,r]=wt(null),n=i=>void t.runAction({label:i,send:`__chrome__:${i}`},e);return ze(s,{style:L.actions,testID:"chrome-message-actions",children:[E(qt,{label:"Copy",onPress:()=>n("copy"),children:E(os,{size:13,color:T.color.textSecondary})}),E(qt,{label:"Retry",onPress:()=>n("retry"),children:E(rs,{size:13,color:T.color.textSecondary})}),E(qt,{label:"Good answer",onPress:()=>{r("up"),n("thumbs up")},children:E(l,{style:[L.glyph,o==="up"&&L.glyphOn],children:"\u{1F44D}"})}),E(qt,{label:"Bad answer",onPress:()=>{r("down"),n("thumbs down")},children:E(l,{style:[L.glyph,o==="down"&&L.glyphOn],children:"\u{1F44E}"})}),E(qt,{label:"Export",onPress:()=>n("export transcript"),children:E(l,{style:L.textBtn,children:"Export"})})]})}function is({text:e,live:t}){let[o,r]=wt(false);return ze(s,{style:L.reasoning,testID:"chrome-reasoning",children:[ze(m,{onPress:()=>r(n=>!n),style:L.reasoningHead,accessibilityRole:"button",accessibilityState:{expanded:o},children:[t?E(Vt,{size:"small",color:T.color.textTertiary}):null,E(l,{style:L.reasoningTitle,children:t?"Working it out\u2026":"How I got here"}),o?E(es,{size:12,color:T.color.textTertiary}):E(ts,{size:12,color:T.color.textTertiary})]}),o?E(l,{style:L.reasoningBody,children:e}):null]})}function ls({label:e}){let[t,o]=wt(0);return Za(()=>{let r=setInterval(()=>o(n=>n+250),250);return()=>clearInterval(r)},[]),ze(s,{style:L.elapsed,testID:"chrome-elapsed",children:[E(Vt,{size:"small",color:T.color.textSecondary}),E(l,{style:L.elapsedLabel,children:e}),ze(l,{style:L.elapsedMs,children:[(t/1e3).toFixed(1),"s"]})]})}function as(){let[e,t]=wt(""),[o,r]=wt(null);return ze(s,{style:L.composerWrap,testID:"chrome-queue",children:[o?ze(s,{style:L.queuedRow,children:[ze(l,{style:L.queuedText,numberOfLines:1,children:['Queued: "',o,'"']}),E(m,{onPress:()=>r(null),children:E(l,{style:L.queuedCancel,children:"Cancel"})})]}):null,ze(s,{style:L.composer,children:[E(Ze,{style:L.composerInput,value:e,onChangeText:t,placeholder:"Agent is busy \u2014 type and it sends next",placeholderTextColor:T.color.placeholder}),E(m,{disabled:!e.trim(),onPress:()=>{r(e.trim()),t("")},style:[L.queueBtn,!e.trim()&&{opacity:.5}],children:E(l,{style:L.queueBtnText,children:"Queue"})})]})]})}function ss({at:e}){return ze(s,{style:L.divider,testID:"chrome-divider",children:[E(s,{style:L.dividerLine}),ze(l,{style:L.dividerText,children:["App reloaded \xB7 ",e]}),E(s,{style:L.dividerLine})]})}function cs({at:e}){return E(l,{style:L.timestamp,children:e})}function ds({text:e}){let t=Z(),[o,r]=wt(false),[n,i]=wt(e);return E(s,{style:L.userWrap,testID:"chrome-edit-bubble",children:o?ze(s,{style:L.editBox,children:[E(Ze,{style:L.editInput,value:n,onChangeText:i,multiline:true}),ze(s,{style:L.editActions,children:[E(m,{onPress:()=>{r(false),t.runAction({label:"re-run edited",send:`__chrome__:re-run "${n}"`},"chrome-edit")},style:L.editPrimary,children:E(l,{style:L.editPrimaryText,children:"Re-run from here"})}),E(m,{onPress:()=>{r(false),t.runAction({label:"branch",send:`__chrome__:branch "${n}"`},"chrome-edit")},style:L.editPlate,children:E(l,{style:L.editPlateText,children:"Branch"})}),E(m,{onPress:()=>r(false),style:L.editPlate,children:E(l,{style:L.editPlateText,children:"Cancel"})})]})]}):ze(m,{onLongPress:()=>r(true),onPress:()=>r(true),style:L.bubble,accessibilityRole:"button",accessibilityLabel:"Edit message",children:[E(l,{style:L.bubbleText,children:n}),E(l,{style:L.bubbleHint,children:"tap to edit \xB7 2 branches"})]})})}var L=w.create({actions:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:2},iconBtn:{paddingHorizontal:8,paddingVertical:6,borderRadius:T.radius.badge},pressed:{backgroundColor:T.color.fill},glyph:{fontSize:13,opacity:.6},glyphOn:{opacity:1},textBtn:{color:T.color.textSecondary,fontSize:T.font.micro,fontWeight:"600"},reasoning:{borderRadius:T.radius.row,backgroundColor:T.color.fill,overflow:"hidden"},reasoningHead:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:8},reasoningTitle:{flex:1,color:T.color.textSecondary,fontSize:T.font.caption,fontStyle:"italic"},reasoningBody:{color:T.color.textSecondary,fontSize:T.font.caption,lineHeight:18,paddingHorizontal:12,paddingBottom:10},elapsed:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:10,borderRadius:T.radius.card,borderWidth:w.hairlineWidth,borderColor:T.color.border,backgroundColor:T.color.surface},elapsedLabel:{flex:1,color:T.color.text,fontSize:T.font.body},elapsedMs:{color:T.color.textTertiary,fontSize:T.font.caption,fontFamily:"Menlo"},composerWrap:{gap:6},queuedRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:6,borderRadius:T.radius.row,backgroundColor:T.color.infoSoft},queuedText:{flex:1,color:T.color.text,fontSize:T.font.caption},queuedCancel:{color:T.color.info,fontSize:T.font.caption,fontWeight:"600"},composer:{flexDirection:"row",alignItems:"center",gap:8},composerInput:{flex:1,height:40,paddingHorizontal:16,borderRadius:20,borderWidth:w.hairlineWidth,borderColor:T.color.border,backgroundColor:T.color.surfaceElevated,color:T.color.text,fontSize:T.font.body},queueBtn:{paddingHorizontal:14,height:40,borderRadius:20,backgroundColor:T.color.button,alignItems:"center",justifyContent:"center"},queueBtnText:{color:T.color.text,fontSize:T.font.caption,fontWeight:"600"},divider:{flexDirection:"row",alignItems:"center",gap:10,paddingVertical:4},dividerLine:{flex:1,height:w.hairlineWidth,backgroundColor:T.color.border},dividerText:{color:T.color.textTertiary,fontSize:T.font.micro},timestamp:{alignSelf:"center",color:T.color.textTertiary,fontSize:T.font.micro},userWrap:{alignItems:"flex-end"},bubble:{maxWidth:"84%",paddingHorizontal:14,paddingVertical:9,borderRadius:18,borderBottomRightRadius:6,backgroundColor:T.color.accentFill,borderWidth:w.hairlineWidth,borderColor:T.color.accentBorder,gap:4},bubbleText:{color:T.color.text,fontSize:T.font.row,lineHeight:21},bubbleHint:{color:T.color.textTertiary,fontSize:10,textAlign:"right"},editBox:{width:"100%",gap:8},editInput:{minHeight:60,padding:12,borderRadius:T.radius.row,backgroundColor:T.color.surfaceElevated,color:T.color.text,fontSize:T.font.row,borderWidth:w.hairlineWidth,borderColor:T.color.accentBorderStrong},editActions:{flexDirection:"row",gap:8,justifyContent:"flex-end",flexWrap:"wrap"},editPrimary:{paddingHorizontal:12,paddingVertical:8,borderRadius:T.radius.row,backgroundColor:T.color.accent},editPrimaryText:{color:T.color.onAccent,fontSize:T.font.caption,fontWeight:"600"},editPlate:{paddingHorizontal:12,paddingVertical:8,borderRadius:T.radius.row,backgroundColor:T.color.button},editPlateText:{color:T.color.text,fontSize:T.font.caption,fontWeight:"600"}});import{useState as Or}from"react";import{AlertTriangle as us,ChevronDown as ps,night as W}from"@buoy-gg/shared-ui/web";import{jsx as me,jsxs as Mt}from"react/jsx-runtime";function Wr({pending:e,onAnswer:t}){let[o,r]=Or("");return Mt(s,{style:J.card,testID:"buoy-ask-buoy-approval",children:[Mt(s,{style:J.titleRow,children:[me(us,{size:14,color:W.color.warning}),me(l,{style:J.title,children:"Allow this change?"})]}),e.restored?me(l,{style:J.restored,testID:"buoy-ask-buoy-approval-restored",children:"Asked before the app restarted \u2014 check it still applies."}):null,me(l,{style:J.label,children:e.label}),me(l,{style:J.reason,children:e.reason}),e.description?me(hs,{text:e.description}):null,me(Ze,{testID:"buoy-ask-buoy-approval-note",value:o,onChangeText:r,placeholder:"Add a note for the agent (optional)",placeholderTextColor:W.color.textTertiary,style:J.note,returnKeyType:"done",blurOnSubmit:true}),Mt(s,{style:J.actions,children:[me(m,{testID:"buoy-ask-buoy-approve",accessibilityRole:"button",onPress:()=>t({approved:true,reason:o}),style:({pressed:n})=>[J.button,J.approve,n&&J.pressed],children:me(l,{style:J.approveText,children:"Allow"})}),e.restored?null:me(m,{testID:"buoy-ask-buoy-approve-trust",accessibilityRole:"button",onPress:()=>t({approved:true,reason:o,trust:true}),style:({pressed:n})=>[J.button,J.trust,n&&J.pressed],children:me(l,{style:J.trustText,children:"Allow for this chat"})}),me(m,{testID:"buoy-ask-buoy-reject",accessibilityRole:"button",onPress:()=>t({approved:false,reason:o}),style:({pressed:n})=>[J.button,J.reject,n&&J.pressed],children:me(l,{style:J.rejectText,children:"Not now"})})]})]})}function hs({text:e}){let[t,o]=Or(false);return Mt(s,{children:[Mt(m,{testID:"buoy-ask-buoy-approval-details",accessibilityRole:"button",accessibilityState:{expanded:t},onPress:()=>o(r=>!r),style:({pressed:r})=>[J.disclosure,r&&J.pressed],hitSlop:6,children:[me(s,{style:t?J.chevronOpen:J.chevronClosed,children:me(ps,{size:12,color:W.color.textTertiary})}),me(l,{style:J.disclosureText,children:t?"Hide details":"Details"})]}),t?me(Fe,{style:J.detail,contentContainerStyle:J.detailContent,nestedScrollEnabled:true,children:me(l,{style:J.description,children:e})}):null]})}var J=w.create({card:{marginHorizontal:W.gutter,marginBottom:10,padding:W.cardPad,borderRadius:W.radius.card,borderWidth:w.hairlineWidth,borderColor:W.color.accentBorderStrong,backgroundColor:W.color.surface,gap:6},titleRow:{flexDirection:"row",alignItems:"center",gap:6},title:{color:W.color.text,fontSize:W.font.caption,fontWeight:"600"},label:{color:W.color.text,fontSize:W.font.row,fontWeight:"600",lineHeight:20},description:{color:W.color.textSecondary,fontSize:W.font.caption,lineHeight:18},reason:{color:W.color.warning,fontSize:W.font.caption,lineHeight:18},restored:{color:W.color.info,backgroundColor:W.color.infoSoft,fontSize:W.font.micro,lineHeight:16,paddingHorizontal:8,paddingVertical:5,borderRadius:8},disclosure:{flexDirection:"row",alignItems:"center",gap:4,paddingVertical:4},disclosureText:{color:W.color.textTertiary,fontSize:W.font.micro,fontWeight:"600"},chevronOpen:{transform:[{rotate:"0deg"}]},chevronClosed:{transform:[{rotate:"-90deg"}]},detail:{maxHeight:150,marginTop:2},detailContent:{paddingBottom:2},note:{color:W.color.text,fontSize:W.font.caption,paddingHorizontal:10,paddingVertical:7,borderRadius:W.radius.row,borderWidth:w.hairlineWidth,borderColor:W.color.border,backgroundColor:W.color.button,marginTop:2},actions:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},button:{paddingHorizontal:16,paddingVertical:9,borderRadius:W.radius.row},approve:{backgroundColor:W.color.accent},approveText:{color:W.color.onAccent,fontWeight:"600",fontSize:W.font.caption},trust:{backgroundColor:W.color.button,borderWidth:w.hairlineWidth,borderColor:W.color.accentBorderStrong},trustText:{color:W.color.accent,fontWeight:"600",fontSize:W.font.caption},reject:{backgroundColor:W.color.button},rejectText:{color:W.color.text,fontSize:W.font.caption},pressed:{opacity:.7}});import{useSyncExternalStore as gs}from"react";import{ChevronDown as fs,ChevronRight as bs,night as oe}from"@buoy-gg/shared-ui/web";import{isReversible as Er}from"@buoy-gg/agent-core/web";import{jsx as rt,jsxs as ct}from"react/jsx-runtime";var Vr=[];function Nr(e){return gs(t=>e?.subscribe(t)??(()=>{}),()=>e?.list()??Vr,()=>e?.list()??Vr)}function jr({ledger:e,onUndoAll:t,expanded:o,onToggle:r}){let n=Nr(e).filter(C=>!C.undoneAt),i=n.filter(C=>C.effect.kind!=="transient");if(i.length===0)return null;let a=i.filter(C=>Er(C.effect)),h=i.length-a.length,u=n.length-i.length,g=o?fs:bs,y=[a.length>0?`${a.length} undoable`:null,h>0?`${h} permanent`:null].filter(Boolean).join(" \xB7 ");return ct(s,{style:ge.wrap,children:[ct(m,{testID:"buoy-ask-buoy-changes-bar",accessibilityRole:"button",accessibilityState:{expanded:o},onPress:r,style:ge.bar,children:[rt(s,{style:ge.dot}),rt(l,{style:ge.summary,numberOfLines:1,children:"Changed this app"}),rt(l,{style:ge.counts,numberOfLines:1,children:y}),rt(g,{size:12,color:oe.color.textSecondary})]}),o&&ct(s,{style:ge.panel,children:[ct(Fe,{style:ge.panelScroll,testID:"buoy-ask-buoy-changes-scroll",keyboardShouldPersistTaps:"handled",children:[i.map(C=>{let j=!Er(C.effect);return ct(s,{style:ge.row,children:[rt(l,{style:ge.rowLabel,children:C.effect.label}),rt(l,{style:[ge.rowTag,j&&ge.rowTagMuted],children:j?"Permanent":"Undoable"})]},C.id)}),u>0&&rt(s,{style:ge.row,children:ct(l,{style:[ge.rowLabel,ge.rowLabelMuted],children:["Also did ",u," one-shot action",u===1?"":"s"," (navigation, taps) \u2014 nothing to undo."]})})]}),ct(s,{style:ge.footer,children:[a.length>0&&rt(m,{testID:"buoy-ask-buoy-undo-all",accessibilityRole:"button",onPress:t,style:({pressed:C})=>[ge.undo,C&&ge.pressed],children:ct(l,{style:ge.undoText,children:["Undo ",a.length," change",a.length===1?"":"s"]})}),h>0&&rt(l,{style:ge.footnote,children:"Permanent changes can't be undone from here."})]})]})]})}var ge=w.create({wrap:{borderBottomWidth:w.hairlineWidth,borderBottomColor:oe.color.border,backgroundColor:oe.color.warningSoft},bar:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:oe.gutter,paddingVertical:10},dot:{width:7,height:7,borderRadius:4,backgroundColor:oe.color.warning},summary:{color:oe.color.text,fontSize:oe.font.caption,fontWeight:"600"},counts:{flex:1,color:oe.color.textSecondary,fontSize:oe.font.caption},panel:{paddingHorizontal:oe.gutter,paddingBottom:12,gap:10},panelScroll:{maxHeight:180},row:{flexDirection:"row",alignItems:"flex-start",gap:10,paddingVertical:8,borderTopWidth:w.hairlineWidth,borderTopColor:oe.color.separator},rowLabel:{flex:1,color:oe.color.text,fontSize:oe.font.caption,lineHeight:18},rowTag:{color:oe.color.accent,fontSize:oe.font.micro,fontWeight:"600",letterSpacing:.6,textTransform:"uppercase",paddingTop:2},rowTagMuted:{color:oe.color.textTertiary},rowLabelMuted:{color:oe.color.textTertiary},footer:{flexDirection:"row",alignItems:"center",gap:12,flexWrap:"wrap"},undo:{paddingHorizontal:14,paddingVertical:8,borderRadius:oe.radius.row,backgroundColor:oe.color.button},undoText:{color:oe.color.accent,fontSize:oe.font.caption,fontWeight:"600"},footnote:{flex:1,color:oe.color.textTertiary,fontSize:oe.font.micro},pressed:{opacity:.7}});function ys(e){let t={};for(let o of e){let r=o.effect;if(r.kind==="network-override")t[r.ruleId]=o.undoneAt?{deleted:true}:{enabled:true};else if(r.kind==="inverse-call"&&r.toolId==="network"&&r.action==="setOverrideRuleEnabled"&&typeof r.params.id=="string"){let n=r.params.enabled===true;if(t[r.params.id]?.deleted)continue;t[r.params.id]={enabled:o.undoneAt?n:!n}}}return t}import{useCallback as ms,useEffect as qr,useRef as xs,useState as ks}from"react";import{night as Te}from"@buoy-gg/shared-ui/web";import{jsx as dt,jsxs as ws}from"react/jsx-runtime";var Mr=40,vs=120,Fr=$t.OS==="ios"?10:6,Ss=16;function _r({onSend:e,onStop:t,busy:o,draft:r,onDraftTaken:n,disabled:i,placeholder:a,focusKey:h,canFocus:u=true}){let[g,y]=ks(""),C=xs(null);qr(()=>{!h||!u||i||C.current?.focus()},[h,u,i]),qr(()=>{r&&(y(ee=>ee?`${ee} ${r}`:r),n?.())},[r,n]);let j=ms(()=>{let ee=g.trim();ee&&(y(""),e(ee))},[g,e]),M=g.trim().length>0&&!o&&!i,X=g.trim().length>0&&o&&!i;return ws(s,{style:xe.wrap,children:[dt(s,{style:[xe.field,i&&xe.fieldDisabled],children:dt(Ze,{ref:C,testID:"buoy-ask-buoy-input",style:[xe.input,g.length===0&&xe.inputEmpty],value:g,onChangeText:y,placeholder:a??(i?"Ask Buoy isn't set up yet":"Ask, or tell it what to change\u2026"),placeholderTextColor:Te.color.placeholder,multiline:true,editable:!i,keyboardType:"ascii-capable",autoCorrect:true,autoCapitalize:"sentences",blurOnSubmit:false,onSubmitEditing:j,returnKeyType:"send",maxLength:4e3})}),X&&dt(m,{testID:"buoy-ask-buoy-queue",accessibilityRole:"button",accessibilityLabel:"Queue message",onPress:j,style:({pressed:ee})=>[xe.button,xe.queue,ee&&xe.pressed],children:dt(l,{style:[xe.sendGlyph,{color:Te.color.accent}],children:"\u2191"})}),o?dt(m,{testID:"buoy-ask-buoy-stop",accessibilityRole:"button",accessibilityLabel:"Stop",onPress:t,style:({pressed:ee})=>[xe.button,xe.stop,ee&&xe.pressed],children:dt(s,{style:xe.stopGlyph})}):dt(m,{testID:"buoy-ask-buoy-send",accessibilityRole:"button",accessibilityLabel:"Send",disabled:!M,onPress:j,style:({pressed:ee})=>[xe.button,M?xe.sendOn:xe.sendOff,ee&&M&&xe.pressed],children:dt(l,{style:[xe.sendGlyph,{color:M?Te.color.onAccent:Te.color.textTertiary}],children:"\u2191"})})]})}var xe=w.create({wrap:{flexDirection:"row",alignItems:"flex-end",gap:8,paddingHorizontal:Te.gutter,paddingTop:10,paddingBottom:6,borderTopWidth:w.hairlineWidth,borderTopColor:Te.color.border,backgroundColor:Te.color.bg},field:{flex:1,minHeight:Mr,justifyContent:"center",borderRadius:20,borderWidth:w.hairlineWidth,borderColor:Te.color.border,backgroundColor:Te.color.surfaceElevated},fieldDisabled:{opacity:.6},input:{maxHeight:vs,paddingHorizontal:Ss,paddingTop:Fr,paddingBottom:Fr,color:Te.color.text,fontSize:Te.font.row},inputEmpty:{height:Mr},button:{width:40,height:40,borderRadius:20,alignItems:"center",justifyContent:"center"},sendGlyph:{fontSize:20,fontWeight:"700",lineHeight:22},sendOn:{backgroundColor:Te.color.accent},sendOff:{backgroundColor:Te.color.fill},stop:{backgroundColor:Te.color.fillTertiary},queue:{backgroundColor:"transparent",borderWidth:w.hairlineWidth,borderColor:Te.color.accentBorderStrong},stopGlyph:{width:12,height:12,borderRadius:2,backgroundColor:Te.color.text},pressed:{opacity:.7}});import{useEffect as Ts,useRef as Ur}from"react";import{jsx as Cs}from"react/jsx-runtime";function Is({children:e}){let t=Ur(null),o=Ur(new ce.Value(0)).current;return Ts(()=>{if($t.OS!=="ios")return;let r=(h,u)=>{ce.timing(o,{toValue:h,duration:u.duration||250,easing:Rt.bezier(.17,.59,.4,.77),useNativeDriver:false}).start()},n=h=>{let u=t.current;u&&u.measureInWindow((g,y,C,j)=>{let M=y+j-h.endCoordinates.screenY;r(Math.max(0,M),h)})},i=h=>r(0,h),a=[go.addListener("keyboardWillChangeFrame",n),go.addListener("keyboardWillHide",i)];return()=>a.forEach(h=>h.remove())},[o]),Cs(ce.View,{ref:t,style:[zs.flex,{paddingBottom:o}],children:e})}var zs=w.create({flex:{flex:1}});import{useEffect as Kr,useState as Gr}from"react";import{Check as Ds,Copy as Rs,FileText as $s,ModalHeader as io,night as Ke,Otto as As,Plus as Bs,SettingsSolid as Hs,realNow as wo}from"@buoy-gg/shared-ui/web";import{toolTitle as Ls}from"@buoy-gg/agent-core/web";var Ps=e=>e.effect==="read"&&e.status==="ok";function Os(e){let t=[],o=[],r=()=>{if(o.length!==0){if(o.length===1)t.push({kind:"call",call:o[0]});else{let n=[...new Set(o.map(i=>Ls(i.toolId)))];t.push({kind:"reads",id:o.map(i=>i.id).join("+"),calls:o,label:`Looked at ${Ws(n)}`,count:o.length})}o=[]}};for(let n of e){if(Ps(n)){o.push(n);continue}r(),t.push({kind:"call",call:n})}return r(),t}function Ws(e){return e.length<=1?e[0]??"":e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Es(e){let t=[];e.startedAt!==void 0&&e.endedAt!==void 0&&e.endedAt>=e.startedAt&&t.push(Jr(e.endedAt-e.startedAt));let o=e.toolCalls.length;if(o>0){t.push(`${o} action${o===1?"":"s"}`);let r=u=>e.toolCalls.filter(g=>g.status===u).length,n=r("failed"),i=r("refused"),a=r("declined"),h=r("stopped");n&&t.push(`${n} failed`),i&&t.push(`${i} refused`),a&&t.push(`${a} declined`),h&&t.push(`${h} not run`)}return t.length?t.join(" \xB7 "):null}function Jr(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let o=Math.floor(t/60),r=t%60;return o<60?`${o}m ${String(r).padStart(2,"0")}s`:`${Math.floor(o/60)}h ${String(o%60).padStart(2,"0")}m`}import{jsx as Be,jsxs as Yr}from"react/jsx-runtime";var Vs=200,Ns=()=>"";function Qr({configured:e,busy:t,failed:o=false,activeLabel:r,awaitingApproval:n=false,startedAt:i=null,stopping:a=false,readOnly:h=false,toolCount:u,hasMessages:g,onBack:y,onReset:C,getTranscript:j,onOpenSettings:M,onTicket:X}){let{copied:ee,copy:ke}=to(j??Ns),[Ge,Re]=Gr(false);Kr(()=>{t?r&&Re(true):Re(false)},[t,r]);let Je=t&&!n&&i!==null,[Ye,ft]=Gr(()=>wo());Kr(()=>{if(!Je)return;ft(wo());let st=setInterval(()=>ft(wo()),1e3);return()=>clearInterval(st)},[Je]);let bt=Je&&i!==null?Jr(Ye-i):null,It=e?o?"error":t?r||Ge?"robot":"thinking":"idle":"confused",qe=a?"Stopping":r??"Thinking",at=e?n?"Waiting for you":t?bt?`${qe} \xB7 ${bt}`:`${qe}\u2026`:h?`Read only${u>0?` \xB7 ${u} tool${u===1?"":"s"}`:""}`:u>0?`Ready \xB7 ${u} tool${u===1?"":"s"} available`:"Ready":"Not set up in this app";return Yr(io,{children:[y?Be(io.Navigation,{onBack:y}):null,Be(s,{style:ut.otto,testID:"buoy-ask-buoy-otto",children:Be(As,{state:It,pixelSize:2,tickMs:Vs,water:false})}),Be(io.Content,{title:"Ask Buoy",subtitle:at,testID:"buoy-ask-buoy-title"}),Yr(io.Actions,{children:[X?Be(Et,{testID:"buoy-ask-buoy-ticket",accessibilityRole:"button",accessibilityLabel:"Summarize for a ticket",disabled:!g||t,onPress:X,style:[ut.actionBtn,(!g||t)&&ut.actionBtnDisabled],children:Be($s,{size:14,color:g&&!t?Ke.color.textSecondary:Ke.color.textTertiary})}):null,j?Be(Et,{testID:"buoy-ask-buoy-copy-chat",accessibilityRole:"button",accessibilityLabel:ee?"Conversation copied":"Copy conversation",disabled:!g,onPress:ke,style:[ut.actionBtn,!g&&ut.actionBtnDisabled],children:ee?Be(Ds,{size:14,color:Ke.color.accent}):Be(Rs,{size:14,color:g?Ke.color.textSecondary:Ke.color.textTertiary})}):null,M?Be(Et,{testID:"buoy-ask-buoy-settings",accessibilityRole:"button",accessibilityLabel:"Settings",onPress:M,style:ut.actionBtn,children:Be(Hs,{size:14,color:Ke.color.textSecondary})}):null,Be(Et,{testID:"buoy-ask-buoy-reset",accessibilityRole:"button",accessibilityLabel:"New conversation",disabled:!g,onPress:C,style:[ut.actionBtn,!g&&ut.actionBtnDisabled],children:Be(Bs,{size:14,color:g?Ke.color.textSecondary:Ke.color.textTertiary})})]})]})}var ut=w.create({otto:{marginRight:8,justifyContent:"center"},actionBtn:{width:32,height:32,borderRadius:8,backgroundColor:Ke.color.buttonSurface,borderWidth:1,borderColor:Ke.color.border,alignItems:"center",justifyContent:"center"},actionBtnDisabled:{opacity:.55}});import{useCallback as js,useEffect as qs,useState as Ms}from"react";import{AlertTriangle as Fs,night as de,ToggleRow as vo}from"@buoy-gg/shared-ui/web";import{useSyncExternalStore as _s}from"react";import{definePersistedSetting as Us,devToolsStorageKeys as Ks}from"@buoy-gg/shared-ui/web";var So={showThinking:false,bypassApprovals:false,readOnly:false,hostedNoticeSeen:false},To=Us(`${Ks.base}_ask_buoy_settings`,So,{sanitize:e=>({showThinking:e.showThinking===true,bypassApprovals:e.bypassApprovals===true,readOnly:e.readOnly===true,hostedNoticeSeen:e.hostedNoticeSeen===true})}),vt=So,Co=false,Io=new Set;function Xr(){for(let e of Io)try{e()}catch{}}var pt={get:()=>vt,subscribe(e){return Io.add(e),Co||(Co=true,To.load().then(t=>{vt=t,Xr()})),()=>Io.delete(e)},set(e,t){vt[e]!==t&&(vt={...vt,[e]:t},Xr(),To.save(vt))},reset(){vt=So,Co=false,To.clear()}};function Ht(){return _s(pt.subscribe,pt.get,pt.get)}import{idFactory as Zr}from"@buoy-gg/agent-core/web";import{realNow as Ft}from"@buoy-gg/shared-ui/web";var lo=Zr("m"),en=400;function Gs(e){if(!(!e||Object.keys(e).length===0))try{let t=JSON.stringify(e);return t.length>en?`${t.slice(0,en)}\u2026`:t}catch{return}}var Js=Zr("q"),H={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:{}},tn=null,on=null,zo=new Set,rn=null,Do=null;function Y(e){H={...H,...e};for(let t of zo)try{t()}catch{}}var b={getState:()=>H,subscribe(e){return zo.add(e),()=>zo.delete(e)},setLedger(e){rn=e},getLedger(){return rn},holdSession(e,t){Do={session:e,signature:t}},getHeldSession(){return Do},setReporter(e){tn=e},getReporter(){return tn},setUsageReader(e){on=e},getUsageReader(){return on},setNotice(e){Y({notice:e})},setConfigured(e){e!==H.configured&&Y({configured:e})},setMeta(e){Object.keys(e).every(t=>H.meta[t]===e[t])||Y({meta:{...H.meta,...e}})},addUser(e){Y({messages:[...H.messages,{id:lo(),role:"user",text:e,toolCalls:[],blocks:[]}],busy:true})},beginTurn(){Y({busy:true})},enqueue(e){let t={id:Js(),text:e};return Y({queued:[...H.queued,t]}),t},removeQueued(e){H.queued.some(t=>t.id===e)&&Y({queued:H.queued.filter(t=>t.id!==e)})},shiftQueued(){let[e,...t]=H.queued;if(e)return Y({queued:t}),e},takeQueuedToDraft(e){let t=H.queued.find(o=>o.id===e);t&&Y({queued:H.queued.filter(o=>o.id!==e),draft:t.text})},requestStop(){!H.busy||H.stopping||Y({stopping:true})},clearDraft(){H.draft!==null&&Y({draft:null})},removeMessage(e){Y({messages:H.messages.filter(t=>t.id!==e)})},recordAnswer(e){Y({answers:{...H.answers,[e.blockId]:e},awaitingBlockId:H.awaitingBlockId===e.blockId?null:H.awaitingBlockId})},setActionState(e,t){let o={...H.actionState};t===null?delete o[e]:o[e]=t,Y({actionState:o})},startAssistant(){let e=lo();return Y({messages:[...H.messages,{id:e,role:"assistant",text:"",toolCalls:[],blocks:[],streaming:true,startedAt:Ft()}]}),e},applyEvent(e,t){if(t.type==="history-trimmed"){let r=H.messages.findIndex(a=>a.id===e),n={id:lo(),role:"assistant",system:true,text:`Older messages were trimmed from the agent's memory (${t.droppedRounds} exchange${t.droppedRounds===1?"":"s"}).`+(t.droppedPinned?` ${t.droppedPinned===1?"One of them made a change that is":`${t.droppedPinned} of them made changes that are`} still applied \u2014 the changes bar still lists ${t.droppedPinned===1?"it":"them"}, but the agent no longer remembers making ${t.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:Ft()},i=[...H.messages];i.splice(r<0?i.length:r,0,n),Y({messages:i});return}let o=H.messages.map(r=>{if(r.id!==e)return r;switch(t.type){case"retrying":{let n=Math.max(1,Math.round(t.inMs/1e3));return{...r,waiting:t.reason==="throttled"?`Endpoint busy \u2014 retrying in ${n}s (${t.attempt} of ${t.maxAttempts})`:"Request too large \u2014 trimming older messages and retrying"}}case"text":return{...r,waiting:void 0,text:(r.breakBeforeNextText||t.breakBefore)&&r.text?`${r.text.trimEnd()}
7
+ `)}case"notice":return e.text;case"claim":return e.text;case"diff":case"chart":case"imageGrid":case"requestList":case"requestCard":case"logList":case"crash":case"screenElements":return`[${e.kind} card${"title"in e&&typeof e.title=="string"?`: ${e.title}`:""}]`;default:return null}}function ql(e){return e.map(mr).filter(t=>!!t)}import{Fragment as Ml,jsx as z,jsxs as he}from"react/jsx-runtime";function xo(e){if(e===void 0)return"\u2014";if(e===null)return"null";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{let t=JSON.stringify(e);return t.length>120?`${t.slice(0,117)}\u2026`:t}catch{return String(e)}}function Fl({block:e}){let t=tt(e.rows,jt.tableRows),{visible:o}=t,r=e.columns.slice(0,4);return he(O,{title:e.title,source:e.source,testID:`buoy-block-table-${e.id}`,children:[z(s,{style:$.tableHead,children:r.map((n,i)=>z(l,{style:[$.th,i===0&&$.firstCol],numberOfLines:1,children:n},n))}),o.map((n,i)=>z(s,{style:[$.tr,i>0&&D.rowDivider],children:r.map((a,h)=>{let u=n[h],g=typeof u=="string"?u:u?.text??"",y=typeof u=="string"?void 0:u?.tone;return z(l,{style:[$.td,h===0&&$.firstCol,h===0&&$.tdFirst,y&&{color:xt(y)}],numberOfLines:2,children:Bt(g,$.td)},h)})},i)),z(ot,{paged:t})]})}function _l({block:e}){let t=tt(e.pairs,jt.keyValuePairs),{visible:o}=t,[r,n]=gr(null);return he(O,{title:e.title,source:e.source,testID:`buoy-block-keyvalue-${e.id}`,children:[o.map((i,a)=>{let h=typeof i.value=="object"&&i.value!==null,u=r===i.key;return he(m,{onPress:h?()=>n(u?null:i.key):void 0,style:[$.kvRow,a>0&&D.rowDivider],children:[z(l,{style:$.kvKey,numberOfLines:1,children:i.key}),z(l,{style:[$.kvValue,u&&D.mono],numberOfLines:u?void 0:2,selectable:true,children:u?JSON.stringify(i.value,null,2):xo(i.value)})]},i.key)}),z(ot,{paged:t})]})}function Ul(e){let t=!!e.image;return{canExpand:t,rowRunsAction:!!e.action&&!t,actionIsOwnControl:!!e.action&&t}}function Kl({block:e}){let t=Z(),o=tt(e.items,jt.listItems),{visible:r}=o,[n,i]=gr(null);return he(O,{title:e.title,source:e.source,testID:`buoy-block-list-${e.id}`,children:[r.map((a,h)=>{let u=`${a.id??a.title}-${h}`,g=n===u,{canExpand:y,rowRunsAction:C,actionIsOwnControl:j}=Ul(a),M=y||C?m:s,X=y?{onPress:()=>i(g?null:u),accessibilityRole:"button",accessibilityState:{expanded:g},accessibilityLabel:`${a.title}, ${g?"hide":"show"} picture`,testID:`buoy-block-list-row-${u}`}:C?{onPress:()=>void t.runAction(a.action,e.id),accessibilityRole:"button"}:{};return he(s,{style:h>0?D.rowDivider:void 0,children:[g&&a.image?z(m,{onPress:()=>i(null),accessibilityRole:"button",accessibilityLabel:`Hide ${a.title}`,testID:`buoy-block-list-hero-${u}`,style:$.listHero,children:z(mt,{testID:"buoy-internal-chat-image",source:{uri:a.image},style:$.listHeroImage,resizeMode:"contain",accessibilityLabel:a.title})}):null,he(M,{...X,style:D.row,children:[a.image&&!g?z(mt,{testID:"buoy-internal-chat-image",source:{uri:a.image},style:$.thumb,resizeMode:"contain",accessibilityLabel:a.title}):a.icon?z(cr,{name:a.icon}):null,he(s,{style:$.flex,children:[z(l,{style:[D.rowTitle,a.tone&&{color:xt(a.tone)}],numberOfLines:g?void 0:2,children:Bt(a.title,D.rowTitle)}),a.subtitle?z(l,{style:D.rowSub,numberOfLines:g?void 0:2,children:Bt(a.subtitle,D.rowSub)}):null]}),a.trailing?z(l,{style:[D.rowTrailing,a.tone&&{color:xt(a.tone)}],numberOfLines:1,children:a.trailing}):null,a.action?j?z(m,{onPress:()=>void t.runAction(a.action,e.id),accessibilityRole:"button",accessibilityLabel:a.action.label,hitSlop:8,children:z(l,{style:$.rowAction,children:a.action.label})}):z(l,{style:$.rowAction,children:a.action.label}):null]})]},u)}),z(ot,{paged:o})]})}function xr(e){return e!==null&&typeof e=="object"}function Gl(e){let t=e.map(n=>n.path),o=t.slice(0,3).join(", "),r=t.length-3;return`${t.length===1?"1 field":`${t.length} fields`} \xB7 ${o}${r>0?`, +${r}`:""}`}function Jl({block:e}){let t=tt(e.changes,jt.keyValuePairs);return he(O,{title:e.title??"What changed",source:e.source,testID:`buoy-block-diff-${e.id}`,collapsible:true,summary:Gl(e.changes),children:[t.visible.map((o,r)=>{let n=o.before===void 0&&o.after!==void 0,i=o.after===void 0&&o.before!==void 0;return he(s,{style:[$.diffRow,r>0&&D.rowDivider],children:[z(l,{style:$.diffPath,numberOfLines:1,children:o.path}),xr(o.before)||xr(o.after)?z(s,{style:$.diffTree,children:z(zl,{oldValue:o.before,newValue:o.after,showUnchanged:false,scrollEnabled:false})}):he(Ml,{children:[n?null:he(s,{style:$.diffLine,children:[z(l,{style:[$.diffMark,{color:B.color.danger}],children:"\u2212"}),z(l,{style:[$.diffValue,{color:B.color.danger}],numberOfLines:3,selectable:true,children:xo(o.before)})]}),i?null:he(s,{style:$.diffLine,children:[z(l,{style:[$.diffMark,{color:B.color.accent}],children:"+"}),z(l,{style:[$.diffValue,{color:B.color.accent}],numberOfLines:3,selectable:true,children:xo(o.after)})]})]})]},`${o.path}-${r}`)}),z(ot,{paged:t})]})}function Ql({block:e}){let t=e.bars.slice(0,jt.chartBars),o=e.max??Math.max(1,...t.map(r=>r.value));return z(O,{title:e.title,source:e.source,testID:`buoy-block-chart-${e.id}`,children:z(s,{style:$.chart,children:t.map((r,n)=>he(s,{style:$.barRow,children:[z(l,{style:$.barLabel,numberOfLines:1,children:r.label}),z(s,{style:$.barTrack,children:z(s,{style:[$.bar,{width:`${Math.max(2,Math.round(r.value/o*100))}%`,backgroundColor:xt(r.tone??"accent")}]})}),he(l,{style:$.barValue,numberOfLines:1,children:[r.value,r.unit?` ${r.unit}`:""]})]},`${r.label}-${n}`))})})}function Yl({block:e}){return z(O,{title:e.title,testID:`buoy-block-steps-${e.id}`,children:e.steps.map((t,o)=>he(s,{style:[$.step,o>0&&D.rowDivider],children:[z(s,{style:[$.stepMark,t.state==="done"&&$.stepDone,t.state==="failed"&&$.stepFailed],children:t.state==="done"?z(Sl,{size:10,color:B.color.onAccent}):t.state==="failed"?z(Cl,{size:10,color:B.color.text}):z(l,{style:$.stepNum,children:o+1})}),z(l,{style:[D.rowTitle,t.state==="done"&&$.stepTextDone],children:t.text})]},o))})}function Xl(e){try{let t=JSON.parse(e);return t!==null&&typeof t=="object"?t:void 0}catch{return}}function Zl({block:e,value:t}){return z(O,{title:e.title,testID:`buoy-block-code-${e.id}`,children:z(s,{style:$.viewer,children:z(Il,{title:e.title??"Payload",data:t,initialExpanded:true,showTypeFilter:false,testIDPrefix:`buoy-block-code-${e.id}`})})})}function ea({block:e}){return z(O,{title:e.title,testID:`buoy-block-code-${e.id}`,children:z(l,{style:[D.mono,$.code],selectable:true,children:e.text})})}function ta({block:e}){let t=Xl(e.text);return t===void 0?z(ea,{block:e}):z(Zl,{block:e,value:t})}function oa({block:e}){let t=e.tone==="danger"?B.color.danger:e.tone==="warning"?B.color.warning:B.color.info,o=e.tone==="info"?Tl:vl;return he(O,{tone:e.tone,testID:`buoy-block-notice-${e.id}`,children:[he(s,{style:$.noticeRow,children:[z(o,{size:14,color:t}),z(l,{style:$.noticeText,children:e.text})]}),z(We,{actions:e.actions,blockId:e.id})]})}function ra({block:e}){let{copied:t,copy:o}=to(()=>mr(e)??e.title);return he(O,{title:e.title,source:e.source,testID:`buoy-block-finding-${e.id}`,tone:"warning",children:[e.evidence.map((r,n)=>he(s,{style:[$.kvRow,n>0&&D.rowDivider],children:[z(l,{style:$.kvKey,numberOfLines:1,children:r.label}),z(l,{style:[$.kvValue,r.tone&&{color:xt(r.tone)}],selectable:true,children:r.value})]},`${r.label}-${n}`)),z(s,{style:$.findingFoot,children:z(m,{testID:`buoy-block-finding-copy-${e.id}`,accessibilityRole:"button",accessibilityLabel:t?"Copied":"Copy this finding",onPress:o,style:({pressed:r})=>[$.findingCopy,r&&{opacity:.7}],children:z(l,{style:[$.findingCopyText,t&&{color:B.color.accent}],children:t?"Copied":"Copy finding"})})}),z(We,{actions:e.actions,blockId:e.id})]})}var $=w.create({flex:{flex:1},tableHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,gap:8,backgroundColor:B.color.fill},th:{flex:1,color:B.color.textTertiary,fontSize:B.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"center"},td:{flex:1,color:B.color.textSecondary,fontSize:B.font.caption,lineHeight:17},tdFirst:{color:B.color.text,fontWeight:"500"},firstCol:{flex:1.4},kvRow:{flexDirection:"row",gap:12,paddingHorizontal:12,paddingVertical:8,alignItems:"flex-start"},kvKey:{width:110,color:B.color.textSecondary,fontSize:B.font.caption,paddingTop:1},kvValue:{flex:1,color:B.color.text,fontSize:B.font.caption,lineHeight:17},findingFoot:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,borderTopWidth:w.hairlineWidth,borderTopColor:B.color.separator},findingCopy:{paddingHorizontal:10,paddingVertical:5,borderRadius:B.radius.badge,backgroundColor:B.color.fill},findingCopyText:{color:B.color.textSecondary,fontSize:B.font.micro,fontWeight:"600"},thumb:{width:40,height:40,borderRadius:8,backgroundColor:B.color.fill},listHero:{paddingHorizontal:12,paddingTop:12},listHeroImage:{width:"100%",height:240,borderRadius:B.radius.row,backgroundColor:B.color.fill},rowAction:{color:B.color.accent,fontSize:B.font.caption,fontWeight:"600"},diffRow:{paddingHorizontal:12,paddingVertical:8,gap:3},diffPath:{color:B.color.textSecondary,fontSize:B.font.micro,fontWeight:"600",letterSpacing:.3},diffLine:{flexDirection:"row",gap:8,alignItems:"flex-start"},diffMark:{fontFamily:"Menlo",fontSize:12,width:10},diffValue:{flex:1,fontFamily:"Menlo",fontSize:12,lineHeight:16},diffTree:{borderRadius:B.radius.row,overflow:"hidden"},chart:{paddingHorizontal:12,paddingVertical:10,gap:8},barRow:{flexDirection:"row",alignItems:"center",gap:8},barLabel:{width:96,color:B.color.textSecondary,fontSize:B.font.caption},barTrack:{flex:1,height:10,borderRadius:5,backgroundColor:B.color.fill,overflow:"hidden"},bar:{height:10,borderRadius:5},barValue:{width:72,textAlign:"right",color:B.color.text,fontSize:B.font.caption,fontWeight:"600"},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:B.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:B.color.accent},stepFailed:{backgroundColor:B.color.danger},stepNum:{color:B.color.text,fontSize:B.font.micro,fontWeight:"700"},stepTextDone:{color:B.color.textSecondary},viewer:{paddingHorizontal:4,paddingBottom:8},code:{paddingHorizontal:12,paddingVertical:10,lineHeight:17},noticeRow:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:4},noticeText:{flex:1,color:B.color.text,fontSize:B.font.caption,lineHeight:18}});import{useState as na}from"react";import{night as Ee}from"@buoy-gg/shared-ui/web";import{CAPS as kr}from"@buoy-gg/agent-core/web";import{jsx as Ne,jsxs as ko}from"react/jsx-runtime";function ia({block:e}){let[t,o]=na(null),{width:r}=or(),n=e.images.slice(0,kr.gridMax),i=n.length>kr.gridImages,a=Math.min(150,Math.floor((r-2*Ee.gutter-24-8)/2)),h=({img:u,i:g})=>ko(m,{testID:`buoy-block-image-${g}`,accessibilityRole:"imagebutton",accessibilityLabel:u.alt,onPress:()=>o(t===g?null:g),style:[je.tile,{width:a},i&&je.tileCarousel],children:[Ne(mt,{testID:"buoy-internal-chat-image",source:{uri:u.url},style:[je.image,{width:a,height:a}],resizeMode:"contain",accessibilityLabel:u.alt}),Ne(l,{style:je.name,numberOfLines:1,children:u.alt}),u.caption?Ne(l,{style:je.caption,numberOfLines:1,children:u.caption}):null]},`${u.url}-${g}`);return ko(O,{title:e.title,source:e.source,testID:`buoy-block-imagegrid-${e.id}`,children:[t!==null&&n[t]?ko(m,{onPress:()=>o(null),style:je.hero,accessibilityRole:"button",accessibilityLabel:`Close ${n[t].alt}`,children:[Ne(mt,{testID:"buoy-internal-chat-image",source:{uri:n[t].url},style:je.heroImage,resizeMode:"contain",accessibilityLabel:n[t].alt}),Ne(l,{style:je.heroCaption,children:n[t].alt}),n[t].caption?Ne(l,{style:je.caption,children:n[t].caption}):null]}):null,i?Ne(Fe,{horizontal:true,showsHorizontalScrollIndicator:false,snapToInterval:a+8,decelerationRate:"fast",contentContainerStyle:je.carousel,children:n.map((u,g)=>Ne(h,{img:u,i:g},g))}):Ne(s,{style:je.grid,children:n.map((u,g)=>Ne(h,{img:u,i:g},g))}),Ne(yl,{shown:n.length,total:e.total})]})}var je=w.create({grid:{flexDirection:"row",flexWrap:"wrap",gap:8,padding:12},carousel:{gap:8,paddingHorizontal:12,paddingVertical:12},tile:{gap:4},tileCarousel:{},image:{borderRadius:Ee.radius.row,backgroundColor:Ee.color.fill},name:{color:Ee.color.text,fontSize:Ee.font.micro,fontWeight:"600"},caption:{color:Ee.color.textSecondary,fontSize:Ee.font.micro},hero:{alignItems:"center",padding:12,gap:6,borderBottomWidth:w.hairlineWidth,borderBottomColor:Ee.color.separator},heroImage:{width:"100%",height:240,borderRadius:Ee.radius.row,backgroundColor:Ee.color.fill},heroCaption:{color:Ee.color.text,fontSize:Ee.font.caption}});import{useState as la}from"react";import{AlertTriangle as aa,ChevronRight as sa,Eye as wr,night as R,NightSegmented as ca}from"@buoy-gg/shared-ui/web";import{CAPS as oo}from"@buoy-gg/agent-core/web";import{jsx as P,jsxs as se}from"react/jsx-runtime";function vr(e){return e===void 0?R.color.textTertiary:e>=500?R.color.danger:e>=400?R.color.warning:e>=300?R.color.info:R.color.accent}function Sr(e){try{let t=new URL(e);return t.pathname+(t.search?"?\u2026":"")}catch{return e}}function Tr({status:e}){return P(s,{style:[D.pill,{backgroundColor:`${vr(e)}22`}],children:P(l,{style:[D.pillText,{color:vr(e)}],children:e??"\u2026"})})}function da({block:e}){let t=Z(),o=t.supports?.openTool!==false,r=tt(e.requests,oo.listItems),{visible:n}=r;return se(O,{title:e.title??"Network requests",source:e.source,testID:`buoy-block-requests-${e.id}`,children:[n.map((i,a)=>se(m,{disabled:!o,onPress:()=>void t.runAction({label:"Open in Network",openTool:{toolId:"network",select:i.id}},e.id),style:[D.row,a>0&&D.rowDivider],accessibilityRole:o?"button":void 0,children:[P(l,{style:G.method,children:i.method}),P(l,{style:D.rowTitle,numberOfLines:1,children:Sr(i.url)}),i.mocked?P(l,{style:G.mockedChip,children:"MOCKED"}):null,i.durationMs!==void 0?se(l,{style:D.rowTrailing,children:[i.durationMs," ms"]}):null,P(Tr,{status:i.status}),o?P(sa,{size:12,color:R.color.textTertiary}):null]},`${i.id}-${a}`)),P(ot,{paged:r})]})}var ua=[{key:"response",label:"Response"},{key:"request",label:"Request"}];function pa({block:e}){let[t,o]=la("response"),r=t==="response"?e.responseBody:e.requestBody,n=r===void 0?"(none)":typeof r=="string"?r:JSON.stringify(r,null,2),i=Z();return se(O,{source:e.source,testID:`buoy-block-request-${e.id}`,children:[se(s,{style:[D.row,G.reqHead],children:[P(l,{style:G.method,children:e.request.method}),P(l,{style:D.rowTitle,numberOfLines:2,children:Sr(e.request.url)}),e.request.mocked?P(l,{style:G.mockedChip,children:"MOCKED"}):null,P(Tr,{status:e.request.status})]}),P(s,{style:G.tabs,children:P(ca,{tabs:ua,activeKey:t,onChange:a=>o(a),size:"sm"})}),P(l,{style:[D.mono,G.body],numberOfLines:14,selectable:true,children:n.length>1600?`${n.slice(0,1600)}
8
+ \u2026`:n}),P(We,{blockId:e.id,actions:[{label:"Open in Network",openTool:{toolId:"network",select:e.request.id}}]}),(i.supports?.openTool===false,null)]})}function ha({block:e}){let t=Z().rules?.[e.rule.id],o=t?.deleted===true,r={...e.rule,enabled:o?false:t?.enabled??e.rule.enabled},n=r.kind==="fail"?"fails (no network)":r.kind==="delay"?`delayed ${r.delayMs??0} ms`:`returns ${r.status??200}`;return se(O,{title:r.name??"Network override",source:e.source,testID:`buoy-block-rule-${e.id}`,tone:r.enabled?"warning":void 0,children:[se(s,{style:G.ruleBody,children:[se(l,{style:G.ruleLine,children:[se(l,{style:G.ruleKey,children:[r.methods?.length?r.methods.join("/"):"ANY"," "]}),P(l,{style:D.mono,children:r.urlPattern})]}),se(l,{style:G.ruleLine,children:[P(l,{style:G.ruleKey,children:"\u2192 "}),n,r.times?` \xB7 ${r.times===1?"once":`${r.times} times`}`:" \xB7 every time",r.hits!==void 0?` \xB7 ${r.hits} hit${r.hits===1?"":"s"}`:""]}),P(s,{style:[D.pill,r.enabled?G.on:G.off],children:P(l,{style:[D.pillText,{color:r.enabled?R.color.onAccent:R.color.textSecondary}],children:o?"DELETED":r.enabled?"ON":"OFF"})})]}),o?null:P(We,{blockId:e.id,actions:[r.enabled?{label:"Turn off",dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:r.id,enabled:false}}}:{label:"Turn on",primary:true,dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:r.id,enabled:true}}},{label:"Delete",dispatch:{toolId:"network",action:"deleteOverrideRule",params:{id:r.id}}}]})]})}function ga({block:e}){let t=Z(),o=tt(e.elements,oo.chips),{visible:r}=o;return se(O,{title:e.title??"On screen right now",source:e.source,testID:`buoy-block-screen-${e.id}`,children:[r.map((n,i)=>se(m,{onPress:()=>void t.runAction({label:"Highlight",dispatch:{toolId:"highlight-updates",action:"setSpotlight",params:{nativeTag:n.nativeTag}}},e.id),disabled:t.supports?.dispatch===false,style:[D.row,i>0&&D.rowDivider],accessibilityRole:"button",children:[P(wr,{size:12,color:R.color.textTertiary}),P(l,{style:D.rowTitle,numberOfLines:1,children:n.label??n.testID??n.name}),P(l,{style:D.rowTrailing,numberOfLines:1,children:n.name})]},`${n.nativeTag}-${i}`)),P(ot,{paged:o})]})}function fa({block:e}){let t=Z(),o=tt(e.routes,oo.chips),r=o.visible;return se(O,{title:e.current?`Routes \xB7 you're on ${e.current}`:"Routes",source:e.source,testID:`buoy-block-routes-${e.id}`,children:[P(s,{style:G.chips,children:r.map((n,i)=>P(m,{disabled:t.supports?.dispatch===false,onPress:()=>n.dynamic?t.answer({blockId:e.id,kind:"input",value:`Open ${n.path} \u2014 which id?`}):void t.runAction({label:`Open ${n.path}`,dispatch:{toolId:"route-events",action:"navigate",params:{path:n.path}}},e.id),style:[G.chip,n.path===e.current&&G.chipCurrent],accessibilityRole:"button",children:P(l,{style:[G.chipText,n.dynamic&&G.chipDynamic],children:n.path})},`${n.path}-${i}`))}),P(ot,{paged:o})]})}var Cr={error:R.color.danger,warn:R.color.warning,warning:R.color.warning,info:R.color.info};function ba({block:e}){let t=tt(e.entries,oo.listItems),{visible:o}=t;return se(O,{title:"Console",source:e.source,testID:`buoy-block-logs-${e.id}`,children:[o.map((r,n)=>se(s,{style:[D.row,n>0&&D.rowDivider,G.logRow],children:[P(s,{style:[D.pill,{backgroundColor:`${Cr[r.level]??R.color.textTertiary}22`}],children:P(l,{style:[D.pillText,{color:Cr[r.level]??R.color.textSecondary}],children:r.level.toUpperCase()})}),P(l,{style:[D.rowTitle,D.mono],numberOfLines:3,children:r.message}),r.count>1?se(l,{style:D.rowTrailing,children:["\xD7",r.count]}):null]},`${r.level}-${r.message}-${n}`)),P(ot,{paged:t})]})}function ya({block:e}){return se(O,{tone:"danger",testID:`buoy-block-crash-${e.id}`,children:[se(s,{style:G.crashHead,children:[P(aa,{size:14,color:R.color.danger}),se(l,{style:G.crashTitle,children:["The app crashed",e.route?` on ${e.route}`:""]})]}),P(l,{style:[D.mono,G.crashMsg],numberOfLines:4,selectable:true,children:e.message}),e.suspect?se(l,{style:G.suspect,children:["Most likely cause: ",e.suspect.label]}):null,P(We,{blockId:e.id,actions:[...e.suspect?.action?[{...e.suspect.action,primary:true}]:[],...e.actions??[]].slice(0,2)})]})}function ma({block:e}){let t=Z(),o=t.supports?.minimize!==false;return se(m,{testID:`buoy-block-peek-${e.id}`,disabled:!o,onPress:()=>void t.runAction({label:"Look",minimize:true},e.id),style:({pressed:r})=>[G.peek,r&&{opacity:.7}],accessibilityRole:"button",accessibilityLabel:`${e.label}. Look at the app`,children:[P(l,{style:G.peekText,children:e.label}),o?se(s,{style:G.peekLook,children:[P(wr,{size:12,color:R.color.accent}),P(l,{style:G.peekLookText,children:"Look"})]}):null]})}var G=w.create({method:{color:R.color.textSecondary,fontSize:R.font.micro,fontWeight:"700",letterSpacing:.4,width:44},mockedChip:{color:R.color.warning,backgroundColor:R.color.warningSoft,fontSize:9,fontWeight:"700",letterSpacing:.6,paddingHorizontal:5,paddingVertical:1,borderRadius:R.radius.badge,overflow:"hidden"},reqHead:{paddingTop:12},tabs:{paddingHorizontal:12,paddingTop:4,paddingBottom:8},tab:{paddingHorizontal:10,paddingVertical:5,borderRadius:R.radius.badge,backgroundColor:R.color.fill},tabOn:{backgroundColor:R.color.accentSoft},tabText:{color:R.color.textSecondary,fontSize:R.font.micro,fontWeight:"600"},tabTextOn:{color:R.color.accent},body:{paddingHorizontal:12,paddingBottom:4,lineHeight:16,color:R.color.textSecondary},ruleBody:{paddingHorizontal:12,paddingTop:4,paddingBottom:4,gap:4},ruleLine:{color:R.color.text,fontSize:R.font.caption,lineHeight:18},ruleKey:{color:R.color.textSecondary,fontWeight:"700"},on:{alignSelf:"flex-start",backgroundColor:R.color.accent,marginTop:4},off:{alignSelf:"flex-start",backgroundColor:R.color.fillTertiary,marginTop:4},chips:{flexDirection:"row",flexWrap:"wrap",gap:6,padding:12},chip:{paddingHorizontal:10,paddingVertical:6,borderRadius:R.radius.chip,backgroundColor:R.color.fill,borderWidth:w.hairlineWidth,borderColor:R.color.border},chipCurrent:{backgroundColor:R.color.accentSoft,borderColor:R.color.accentBorderStrong},chipText:{color:R.color.text,fontSize:R.font.caption,fontFamily:"Menlo"},chipDynamic:{color:R.color.textSecondary},logRow:{alignItems:"flex-start"},crashHead:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingTop:12},crashTitle:{color:R.color.danger,fontSize:R.font.row,fontWeight:"600"},crashMsg:{paddingHorizontal:12,paddingTop:6,color:R.color.text},suspect:{color:R.color.textSecondary,fontSize:R.font.caption,paddingHorizontal:12,paddingTop:6},peek:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:10,paddingLeft:12,paddingRight:10,paddingVertical:7,borderRadius:R.radius.chip,backgroundColor:R.color.fill},peekText:{color:R.color.textSecondary,fontSize:R.font.caption},peekLook:{flexDirection:"row",alignItems:"center",gap:4},peekLookText:{color:R.color.accent,fontSize:R.font.caption,fontWeight:"600"}});import{useEffect as xa,useRef as Ir,useState as Ue}from"react";import{AlertTriangle as ka,Check as zr,ChevronDown as Dr,ChevronRight as Rr,night as d,NightSegmented as wa,RefreshCw as va,Search as Sa,X as Ta}from"@buoy-gg/shared-ui/web";import{Fragment as ro,jsx as p,jsxs as v}from"react/jsx-runtime";var $r=e=>typeof e=="string"?e:e===void 0?"\u2014":JSON.stringify(e);function Ca({block:e}){let t=Z();return p(s,{style:c.chips,testID:`buoy-block-suggestions-${e.id}`,children:e.chips.slice(0,4).map(o=>p(m,{disabled:!!t.busy,onPress:()=>void t.runAction({label:o.label,send:o.send??o.label},e.id),style:({pressed:r})=>[c.chip,r&&c.pressed],accessibilityRole:"button",children:p(l,{style:c.chipText,children:o.label})},o.label))})}function Ia({block:e}){let t=Z(),o=t.answered[e.id],r=!!o,[n,i]=Ue([]),a=o?.kind==="multi"?o.optionIds:n,h=g=>i(y=>y.includes(g)?y.filter(C=>C!==g):[...y,g]),u=n.length>=(e.min??1)&&(!e.max||n.length<=e.max);return v(O,{testID:`buoy-block-multi-${e.id}`,tone:r?void 0:"info",children:[p(l,{style:c.question,children:e.question}),p(s,{style:c.optionsBox,children:e.options.map((g,y)=>{let C=a.includes(g.id);return v(m,{disabled:r,onPress:()=>h(g.id),style:[c.option,y>0&&D.rowDivider,r&&!C&&c.dim],accessibilityRole:"checkbox",accessibilityState:{checked:C},children:[p(s,{style:[c.checkbox,C&&c.checkboxOn],children:C?p(zr,{size:11,color:d.color.onAccent}):null}),v(s,{style:c.flex,children:[p(l,{style:c.optionLabel,children:g.label}),g.detail?p(l,{style:c.optionDetail,children:g.detail}):null]})]},g.id)})}),r?null:p(s,{style:c.rowEnd,children:p(m,{testID:"buoy-block-multi-submit",disabled:!u,onPress:()=>t.answer({blockId:e.id,kind:"multi",optionIds:n,labels:e.options.filter(g=>n.includes(g.id)).map(g=>g.label)}),style:[c.button,c.buttonPrimary,!u&&c.disabled],children:p(l,{style:c.buttonTextPrimary,children:e.submitLabel??`Use ${n.length||""}`.trim()})})})]})}var za=8;function Da({block:e}){let t=Z(),o=t.answered[e.id],[r,n]=Ue(""),[i,a]=Ue(false),h=o?.kind==="select"?o.label:null,u=e.options.filter(y=>!r||y.label.toLowerCase().includes(r.toLowerCase())).slice(0,8),g=e.searchable!==false&&e.options.length>=za;return v(O,{testID:`buoy-block-select-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),h?p(l,{style:c.decided,children:h}):v(s,{style:c.selectBox,children:[v(m,{onPress:()=>a(y=>!y),style:c.selectField,accessibilityRole:"button",children:[p(l,{style:c.selectPlaceholder,children:i?"Choose\u2026":`${e.options.length} options`}),p(Dr,{size:14,color:d.color.textSecondary})]}),i&&v(ro,{children:[g&&v(s,{style:c.search,children:[p(Sa,{size:12,color:d.color.textSecondary}),p(Ze,{style:c.searchInput,value:r,onChangeText:n,placeholder:"Search",placeholderTextColor:d.color.placeholder,autoCapitalize:"none",autoCorrect:false})]}),u.map((y,C)=>v(m,{onPress:()=>t.answer({blockId:e.id,kind:"select",optionId:y.id,label:y.label}),style:[c.option,C>0&&D.rowDivider],accessibilityRole:"button",children:[v(s,{style:c.flex,children:[p(l,{style:c.optionLabel,children:y.label}),y.detail?p(l,{style:c.optionDetail,children:y.detail}):null]}),p(Rr,{size:12,color:d.color.textTertiary})]},y.id)),e.options.length>u.length?v(l,{style:c.hint,children:[e.options.length-u.length," more \u2014 keep typing"]}):null]})]})]})}function Ar({min:e,max:t,step:o=1,value:r,unit:n,onChange:i,disabled:a}){let h=Ir(0),u=t>e?(r-e)/(t-e)*100:0,g=M=>Math.min(t,Math.max(e,+(Math.round((M-e)/o)*o+e).toFixed(6))),y=M=>!a&&i(g(r+M*o)),C=M=>{if(a||h.current<=0)return;let X=Math.min(1,Math.max(0,M.nativeEvent.locationX/h.current));i(g(e+X*(t-e)))},j=M=>{h.current=M.nativeEvent.layout.width};return v(s,{style:c.sliderRow,children:[p(m,{disabled:a,onPress:()=>y(-1),style:c.stepBtn,accessibilityRole:"button",accessibilityLabel:"Decrease",children:p(l,{style:c.stepText,children:"\u2212"})}),p(m,{style:c.trackHit,onLayout:j,onPress:C,disabled:a,accessibilityRole:"adjustable",accessibilityValue:{min:e,max:t,now:r},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:M=>y(M.nativeEvent.actionName==="increment"?1:-1),children:v(s,{style:c.track,pointerEvents:"none",children:[p(s,{style:[c.fill,{width:`${u}%`}]}),p(s,{style:[c.thumb,{left:`${u}%`}]})]})}),p(m,{disabled:a,onPress:()=>y(1),style:c.stepBtn,accessibilityRole:"button",accessibilityLabel:"Increase",children:p(l,{style:c.stepText,children:"+"})}),v(l,{style:c.sliderValue,children:[r,n?` ${n}`:""]})]})}function Ra({block:e}){let t=Z(),o=t.answered[e.id],[r,n]=Ue(e.value??e.min);return v(O,{testID:`buoy-block-slider-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),p(s,{style:c.pad,children:p(Ar,{min:e.min,max:e.max,step:e.step,value:o?.kind==="slider"?o.value:r,unit:e.unit,onChange:n,disabled:!!o})}),o?null:p(s,{style:c.rowEnd,children:p(m,{onPress:()=>t.answer({blockId:e.id,kind:"slider",value:r,unit:e.unit}),style:[c.button,c.buttonPrimary],children:v(l,{style:c.buttonTextPrimary,children:["Use ",r,e.unit?` ${e.unit}`:""]})})})]})}function $a({block:e}){let t=Z(),o=t.answered[e.id],[r,n]=Ue(""),i=e.presets??[{label:"Now",value:new Date().toISOString()},{label:"Tomorrow",value:new Date(Date.now()+864e5).toISOString()},{label:"+7 days",value:new Date(Date.now()+7*864e5).toISOString()},{label:"+30 days",value:new Date(Date.now()+30*864e5).toISOString()}];return v(O,{testID:`buoy-block-datetime-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),o?p(l,{style:c.decided,children:o.kind==="dateTime"?o.label??o.value:"(skipped)"}):v(ro,{children:[p(s,{style:[c.chips,c.pad],children:i.map(a=>p(m,{onPress:()=>t.answer({blockId:e.id,kind:"dateTime",value:a.value,label:a.label}),style:c.chip,children:p(l,{style:c.chipText,children:a.label})},a.label))}),v(s,{style:[c.inputRow,c.pad],children:[p(Ze,{style:c.input,value:r,onChangeText:n,placeholder:e.mode==="time"?"14:30":"2026-09-15",placeholderTextColor:d.color.placeholder,keyboardType:"numbers-and-punctuation"}),p(m,{disabled:!r.trim(),onPress:()=>t.answer({blockId:e.id,kind:"dateTime",value:r.trim()}),style:[c.button,c.buttonPrimary,!r.trim()&&c.disabled],children:p(l,{style:c.buttonTextPrimary,children:"Use"})})]})]})]})}function Br({f:e,value:t,onChange:o,disabled:r}){return e.type==="toggle"?v(s,{style:c.fieldRow,children:[p(l,{style:c.fieldLabel,children:e.label}),p(rr,{value:!!t,onValueChange:o,disabled:r,trackColor:{true:d.color.accent,false:d.color.fillTertiary},thumbColor:d.color.knob})]}):e.type==="select"?v(s,{style:c.fieldCol,children:[p(l,{style:c.fieldLabel,children:e.label}),p(s,{style:c.chips,children:e.options.map(n=>p(m,{disabled:r,onPress:()=>o(n.id),style:[c.chip,t===n.id&&c.chipOn],children:p(l,{style:[c.chipText,t===n.id&&c.chipTextOn],children:n.label})},n.id))})]}):e.type==="slider"?v(s,{style:c.fieldCol,children:[p(l,{style:c.fieldLabel,children:e.label}),p(Ar,{min:e.min,max:e.max,step:e.step,unit:e.unit,value:typeof t=="number"?t:e.min,onChange:o,disabled:r})]}):v(s,{style:c.fieldRow,children:[p(l,{style:c.fieldLabel,children:e.label}),p(Ze,{style:c.fieldInput,value:t==null?"":String(t),onChangeText:o,editable:!r,placeholder:e.placeholder??"",placeholderTextColor:d.color.placeholder,keyboardType:e.type==="number"?"numeric":"ascii-capable",secureTextEntry:e.type==="secret",autoCapitalize:"none",autoCorrect:false})]})}function Hr(e){let[t,o]=Ue(()=>Object.fromEntries(e.map(r=>[r.key,r.value])));return{values:t,set:(r,n)=>o(i=>({...i,[r]:n}))}}function Aa({block:e}){let t=Z(),o=t.answered[e.id],{values:r,set:n}=Hr(e.fields);return v(O,{title:e.title,testID:`buoy-block-form-${e.id}`,tone:o?void 0:"info",children:[p(s,{style:c.pad,children:e.fields.map(i=>p(Br,{f:i,value:r[i.key],onChange:a=>n(i.key,a),disabled:!!o},i.key))}),o?p(l,{style:c.decided,children:"Sent"}):p(s,{style:c.rowEnd,children:p(m,{onPress:()=>t.answer({blockId:e.id,kind:"form",values:r}),style:[c.button,c.buttonPrimary],children:p(l,{style:c.buttonTextPrimary,children:e.submitLabel??"Send"})})})]})}function Ba({block:e}){let t=Z(),o=t.answered[e.id],{values:r,set:n}=Hr(e.fields),i=o?.kind==="proposal"?o.approved:null;return v(O,{testID:`buoy-block-proposal-${e.id}`,tone:o?void 0:"warning",children:[p(l,{style:c.confirmTitle,children:e.title}),p(l,{style:c.confirmChange,children:e.change}),p(s,{style:c.pad,children:e.fields.map(a=>p(Br,{f:a,value:r[a.key],onChange:h=>n(a.key,h),disabled:!!o},a.key))}),e.consequence?p(l,{style:c.consequence,children:e.consequence}):null,p(s,{style:c.actionsRow,children:o?p(l,{style:c.decided,children:i?"\u2713 Applied with these values":"\u2715 Not applied"}):v(ro,{children:[p(m,{onPress:()=>t.answer({blockId:e.id,kind:"proposal",approved:true,values:r}),style:[c.button,c.buttonPrimary],children:p(l,{style:c.buttonTextPrimary,children:e.approveLabel??"Apply"})}),p(m,{onPress:()=>t.answer({blockId:e.id,kind:"proposal",approved:false}),style:[c.button,c.buttonPlate],children:p(l,{style:c.buttonTextPlate,children:"Not now"})})]})})]})}function Ha({block:e}){let t=Z(),[o,r]=Ue(null),n=t.actionState?.[`${e.id}:${e.verify?.label??"Verify"}`],i=e.verified||n==="done";return v(s,{style:c.claim,testID:`buoy-block-claim-${e.id}`,children:[v(l,{style:c.claimText,children:[e.text,e.sources.map((a,h)=>v(l,{onPress:()=>r(o===h?null:h),style:c.cite,children:[" [",h+1,"]"]},h)),i?p(l,{style:c.verified,children:" \u2713 verified"}):null]}),o!==null&&e.sources[o]?v(s,{style:c.citeBox,children:[v(l,{style:c.citeLabel,children:["[",o+1,"] ",e.sources[o].label]}),e.sources[o].detail?p(l,{style:c.citeDetail,children:e.sources[o].detail}):null]}):null,e.verify&&!i?v(m,{onPress:()=>void t.runAction(e.verify,e.id),style:c.verifyBtn,accessibilityRole:"button",children:[p(va,{size:11,color:d.color.accent}),p(l,{style:c.verifyText,children:n==="running"?"Checking\u2026":e.verify.label})]}):null]})}function La({block:e}){let[t,o]=Ue(!!e.open);return v(O,{testID:`buoy-block-details-${e.id}`,children:[v(m,{onPress:()=>o(r=>!r),style:D.row,accessibilityRole:"button",accessibilityState:{expanded:t},children:[p(l,{style:D.rowTitle,children:e.summary}),t?p(Dr,{size:12,color:d.color.textTertiary}):p(Rr,{size:12,color:d.color.textTertiary})]}),t?p(l,{style:c.detailsBody,selectable:true,children:e.body}):null]})}function Pa({block:e,renderNested:t}){let[o,r]=Ue(0),n=e.tabs.map((a,h)=>({key:String(h),label:a.label})),i=e.tabs[o];return v(s,{style:c.tabsWrap,testID:`buoy-block-tabs-${e.id}`,children:[p(wa,{tabs:n,activeKey:String(o),onChange:a=>r(Number(a)),size:"sm"}),i&&t?t(i.block):null]})}var Oa=10;function Wa({block:e}){let t=tt(e.events,Oa);return v(O,{title:e.title??"What happened",source:e.source,testID:`buoy-block-timeline-${e.id}`,children:[t.visible.map((o,r)=>v(s,{style:c.tlRow,children:[p(l,{style:c.tlAt,children:o.at}),v(s,{style:c.tlLine,children:[p(s,{style:[c.tlDot,{backgroundColor:xt(o.tone??"muted")}]}),r<t.visible.length-1?p(s,{style:c.tlStem}):null]}),v(s,{style:c.flex,children:[p(l,{style:c.tlSource,children:o.source.toUpperCase()}),p(l,{style:D.rowTitle,numberOfLines:2,children:o.label})]})]},r)),p(ot,{paged:t})]})}function Ea({block:e}){let t=e.series.slice(-60),o=Math.max(1,...t),r=Math.min(...t,0),n=44;return v(O,{title:e.title,source:e.source,testID:`buoy-block-sparkline-${e.id}`,children:[v(s,{style:c.sparkHead,children:[v(l,{style:c.sparkCurrent,children:[e.current??t[t.length-1],e.unit?v(l,{style:c.sparkUnit,children:[" ",e.unit]}):null]}),e.live?p(Lr,{}):null]}),p(s,{style:[c.spark,{height:n}],children:t.map((i,a)=>p(s,{style:[c.sparkBar,{height:Math.max(2,(i-r)/(o-r||1)*n),backgroundColor:a===t.length-1?d.color.accent:d.color.accentBorderStrong}]},a))}),e.label?p(l,{style:c.hint,children:e.label}):null]})}function Lr(){let e=Ir(new ce.Value(1)).current;return xa(()=>{let t=ce.loop(ce.sequence([ce.timing(e,{toValue:.3,duration:700,useNativeDriver:true}),ce.timing(e,{toValue:1,duration:700,useNativeDriver:true})]));return t.start(),()=>t.stop()},[e]),v(s,{style:c.live,children:[p(ce.View,{style:[c.liveDot,{opacity:e}]}),p(l,{style:c.liveText,children:"LIVE"})]})}function Va({block:e}){let t=[...new Set([...e.left.pairs.map(n=>n.key),...e.right.pairs.map(n=>n.key)])],o=Object.fromEntries(e.left.pairs.map(n=>[n.key,n.value])),r=Object.fromEntries(e.right.pairs.map(n=>[n.key,n.value]));return v(O,{title:e.title,source:e.source,testID:`buoy-block-compare-${e.id}`,children:[v(s,{style:c.cmpHead,children:[p(l,{style:c.cmpKey}),p(l,{style:c.cmpCol,children:e.left.title}),p(l,{style:c.cmpCol,children:e.right.title})]}),t.map((n,i)=>{let a=JSON.stringify(o[n])!==JSON.stringify(r[n]);return v(s,{style:[c.cmpRow,i>0&&D.rowDivider,a&&c.cmpDiff],children:[p(l,{style:c.cmpKey,numberOfLines:1,children:n}),p(l,{style:[c.cmpVal,a&&{color:d.color.danger}],numberOfLines:2,children:$r(o[n])}),p(l,{style:[c.cmpVal,a&&{color:d.color.accent}],numberOfLines:2,children:$r(r[n])})]},n)})]})}function Pr({c:e,id:t}){return v(ro,{children:[e.image?p(mt,{testID:"buoy-internal-chat-image",source:{uri:e.image},style:c.cardImage,resizeMode:"contain",accessibilityLabel:e.title}):null,v(s,{style:c.cardText,children:[p(l,{style:c.cardTitle,numberOfLines:2,children:e.title}),e.subtitle?p(l,{style:D.rowSub,numberOfLines:2,children:e.subtitle}):null,e.facts?.slice(0,4).map(o=>v(s,{style:c.fact,children:[p(l,{style:c.factLabel,children:o.label}),p(l,{style:[c.factValue,o.tone&&{color:xt(o.tone)}],children:o.value})]},o.label))]}),p(We,{actions:e.actions,blockId:t})]})}function Na({block:e}){return p(O,{source:e.source,testID:`buoy-block-card-${e.id}`,children:p(Pr,{c:e,id:e.id})})}function ja({block:e}){return v(s,{testID:`buoy-block-cardcarousel-${e.id}`,children:[e.title?p(l,{style:c.carouselTitle,children:e.title}):null,p(Fe,{horizontal:true,showsHorizontalScrollIndicator:false,snapToInterval:232,decelerationRate:"fast",contentContainerStyle:c.carousel,children:e.cards.slice(0,8).map((t,o)=>p(s,{style:c.carouselCard,children:p(Pr,{c:t,id:`${e.id}-${o}`})},`${t.title}-${o}`))})]})}function qa({block:e}){let[t,o]=Ue(false);return v(O,{title:e.route?`Screen \xB7 ${e.route}`:"Screen",source:e.source,testID:`buoy-block-screenshot-${e.id}`,children:[p(m,{onPress:()=>o(r=>!r),accessibilityRole:"imagebutton",accessibilityLabel:e.caption??"Screenshot",children:p(mt,{testID:"buoy-internal-chat-image",source:{uri:e.url},style:[c.shot,t&&c.shotBig],resizeMode:"contain"})}),e.caption?p(l,{style:c.hint,children:e.caption}):null]})}function Ma({block:e}){let t=e.steps.filter(o=>o.state==="done").length;return v(O,{title:e.title,testID:`buoy-block-plan-${e.id}`,tone:e.pending?"info":void 0,children:[p(s,{style:c.progress,children:p(s,{style:[c.progressFill,{width:`${t/Math.max(1,e.steps.length)*100}%`}]})}),e.steps.map((o,r)=>v(s,{style:[c.step,r>0&&D.rowDivider],children:[p(s,{style:[c.stepMark,o.state==="done"&&c.stepDone,o.state==="failed"&&c.stepFailed,o.state==="running"&&c.stepRunning],children:o.state==="done"?p(zr,{size:10,color:d.color.onAccent}):o.state==="failed"?p(Ta,{size:10,color:d.color.text}):p(l,{style:c.stepNum,children:r+1})}),v(l,{style:[D.rowTitle,o.state==="done"&&c.muted],children:[o.text,o.state==="running"?"\u2026":""]})]},r)),p(We,{actions:e.actions??(e.pending?[{label:"Go",primary:true,send:"Go ahead with the plan."},{label:"Change it",send:"Let me change the plan first."}]:void 0),blockId:e.id})]})}function Fa({block:e}){let t=Z();return v(m,{testID:`buoy-block-checkpoint-${e.id}`,disabled:!e.restore,onPress:()=>e.restore&&void t.runAction(e.restore,e.id),style:c.checkpoint,accessibilityRole:"button",children:[p(s,{style:c.cpFlag}),v(l,{style:c.cpText,children:[e.label,e.at?` \xB7 ${e.at}`:""]}),e.restore?p(l,{style:c.cpRestore,children:e.restore.label}):null]})}function _a({block:e}){let t=e.status==="failed"?d.color.danger:e.status==="done"?d.color.accent:d.color.info;return v(O,{testID:`buoy-block-task-${e.id}`,children:[v(s,{style:c.taskHead,children:[p(l,{style:c.cardTitle,children:e.title}),p(s,{style:[D.pill,{backgroundColor:`${t}22`}],children:p(l,{style:[D.pillText,{color:t}],children:e.status.toUpperCase()})})]}),e.progress!==void 0?p(s,{style:[c.progress,c.pad],children:p(s,{style:[c.progressFill,{width:`${Math.round(e.progress*100)}%`,backgroundColor:t}]})}):null,e.detail?p(l,{style:c.hint,children:e.detail}):null,p(We,{actions:e.actions,blockId:e.id})]})}function Ua({block:e}){let t=e.tone==="danger"?d.color.danger:e.tone==="warning"?d.color.warning:d.color.info;return v(s,{style:[c.banner,{borderColor:t,backgroundColor:`${t}1A`}],testID:`buoy-block-banner-${e.id}`,children:[p(ka,{size:13,color:t}),p(l,{style:[c.bannerText,{color:t}],numberOfLines:2,children:e.text}),e.actions?.[0]?p(We,{actions:e.actions.slice(0,1),blockId:e.id,align:"right"}):null]})}function Ka({block:e}){return v(O,{testID:`buoy-block-file-${e.id}`,children:[v(s,{style:D.row,children:[p(s,{style:c.fileIcon,children:p(l,{style:c.fileExt,children:(e.type??e.name.split(".").pop()??"file").toUpperCase().slice(0,4)})}),v(s,{style:c.flex,children:[p(l,{style:D.rowTitle,numberOfLines:1,children:e.name}),e.size?p(l,{style:D.rowSub,children:e.size}):null]})]}),p(We,{actions:e.actions,blockId:e.id})]})}function Ga({block:e}){let t=Z(),o=t.answered[e.id];return v(O,{testID:`buoy-block-upload-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.question,children:e.label}),o?p(l,{style:c.decided,children:o.kind==="upload"?`Attached ${o.name}`:"(skipped)"}):p(s,{style:[c.rowEnd,{justifyContent:"flex-start"}],children:p(m,{onPress:()=>t.answer({blockId:e.id,kind:"upload",name:"screenshot.png"}),style:[c.button,c.buttonPlate],children:p(l,{style:c.buttonTextPlate,children:e.accept==="image"?"Choose a screenshot":"Choose a file"})})})]})}var c=w.create({flex:{flex:1},pad:{paddingHorizontal:12,paddingBottom:8},muted:{color:d.color.textSecondary},dim:{opacity:.45},disabled:{opacity:.5},pressed:{opacity:.7},question:{color:d.color.text,fontSize:d.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},hint:{color:d.color.textTertiary,fontSize:d.font.micro,paddingHorizontal:12,paddingBottom:10},decided:{color:d.color.textSecondary,fontSize:d.font.caption,fontWeight:"600",paddingHorizontal:12,paddingVertical:10},rowEnd:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:12,paddingBottom:12,gap:8},actionsRow:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:12,alignItems:"center"},button:{paddingHorizontal:14,paddingVertical:9,borderRadius:d.radius.row},buttonPrimary:{backgroundColor:d.color.accent},buttonPlate:{backgroundColor:d.color.button},buttonTextPrimary:{color:d.color.onAccent,fontSize:d.font.caption,fontWeight:"600"},buttonTextPlate:{color:d.color.text,fontSize:d.font.caption,fontWeight:"600"},chips:{flexDirection:"row",flexWrap:"wrap",gap:6},chip:{paddingHorizontal:12,paddingVertical:7,borderRadius:d.radius.chip,backgroundColor:d.color.fill,borderWidth:w.hairlineWidth,borderColor:d.color.border},chipOn:{backgroundColor:d.color.accentSoft,borderColor:d.color.accentBorderStrong},chipText:{color:d.color.text,fontSize:d.font.caption},chipTextOn:{color:d.color.accent,fontWeight:"600"},optionsBox:{marginHorizontal:8,marginBottom:8,borderRadius:d.radius.row,backgroundColor:d.color.surfaceElevated,overflow:"hidden"},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:10},optionLabel:{color:d.color.text,fontSize:d.font.body,fontWeight:"500"},optionDetail:{color:d.color.textSecondary,fontSize:d.font.caption},checkbox:{width:20,height:20,borderRadius:6,borderWidth:1.5,borderColor:d.color.textTertiary,alignItems:"center",justifyContent:"center"},checkboxOn:{backgroundColor:d.color.accent,borderColor:d.color.accent},selectBox:{marginHorizontal:12,marginBottom:12,borderRadius:d.radius.row,backgroundColor:d.color.surfaceElevated,overflow:"hidden"},selectField:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:11},selectPlaceholder:{color:d.color.textSecondary,fontSize:d.font.body},search:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:6,borderTopWidth:w.hairlineWidth,borderTopColor:d.color.separator},searchInput:{flex:1,color:d.color.text,fontSize:d.font.caption,paddingVertical:4},sliderRow:{flexDirection:"row",alignItems:"center",gap:8},stepBtn:{width:28,height:28,borderRadius:14,backgroundColor:d.color.fill,alignItems:"center",justifyContent:"center"},stepText:{color:d.color.text,fontSize:16,fontWeight:"600"},trackHit:{flex:1,height:36,justifyContent:"center"},track:{height:6,borderRadius:3,backgroundColor:d.color.fillTertiary,justifyContent:"center"},fill:{height:6,borderRadius:3,backgroundColor:d.color.accent},thumb:{position:"absolute",width:20,height:20,borderRadius:10,backgroundColor:d.color.knob,marginLeft:-10,shadowColor:"#000",shadowOpacity:.35,shadowRadius:3,shadowOffset:{width:0,height:1}},sliderValue:{width:64,textAlign:"right",color:d.color.text,fontSize:d.font.caption,fontWeight:"600"},inputRow:{flexDirection:"row",alignItems:"center",gap:8,paddingBottom:12},input:{flex:1,height:38,paddingHorizontal:12,borderRadius:d.radius.row,backgroundColor:d.color.surfaceElevated,color:d.color.text,fontSize:d.font.body},fieldRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:10,paddingVertical:6},fieldCol:{paddingVertical:6,gap:6},fieldLabel:{color:d.color.textSecondary,fontSize:d.font.caption,width:110},fieldInput:{flex:1,height:34,paddingHorizontal:10,borderRadius:d.radius.segment,backgroundColor:d.color.surfaceElevated,color:d.color.text,fontSize:d.font.caption},confirmTitle:{color:d.color.text,fontSize:d.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:d.color.text,fontSize:d.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6,paddingBottom:6},consequence:{color:d.color.warning,fontSize:d.font.caption,paddingHorizontal:12},claim:{gap:6,paddingHorizontal:2},claimText:{color:d.color.text,fontSize:d.font.row,lineHeight:22},cite:{color:d.color.accent,fontSize:d.font.caption,fontWeight:"700"},verified:{color:d.color.accent,fontSize:d.font.caption,fontWeight:"600"},citeBox:{padding:10,borderRadius:d.radius.row,backgroundColor:d.color.surface,borderWidth:w.hairlineWidth,borderColor:d.color.border,gap:2},citeLabel:{color:d.color.text,fontSize:d.font.caption,fontWeight:"600"},citeDetail:{color:d.color.textSecondary,fontSize:d.font.caption,fontFamily:"Menlo"},verifyBtn:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:5,paddingHorizontal:10,paddingVertical:5,borderRadius:d.radius.chip,backgroundColor:d.color.accentSoft},verifyText:{color:d.color.accent,fontSize:d.font.micro,fontWeight:"700"},detailsBody:{color:d.color.textSecondary,fontSize:d.font.caption,lineHeight:18,paddingHorizontal:12,paddingBottom:12},tabsWrap:{gap:8},tabBar:{flexDirection:"row",gap:6},tab:{paddingHorizontal:12,paddingVertical:6,borderRadius:d.radius.badge,backgroundColor:d.color.fill},tabOn:{backgroundColor:d.color.accentSoft},tabText:{color:d.color.textSecondary,fontSize:d.font.caption,fontWeight:"600"},tabTextOn:{color:d.color.accent},tlRow:{flexDirection:"row",gap:10,paddingHorizontal:12,paddingVertical:4,alignItems:"flex-start"},tlAt:{width:46,color:d.color.textTertiary,fontSize:d.font.micro,fontFamily:"Menlo",paddingTop:3},tlLine:{width:12,alignItems:"center"},tlDot:{width:8,height:8,borderRadius:4,marginTop:5},tlStem:{width:1,flex:1,minHeight:18,backgroundColor:d.color.separator,marginTop:2},tlSource:{color:d.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6},sparkHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingTop:8},sparkCurrent:{color:d.color.text,fontSize:22,fontWeight:"700"},sparkUnit:{color:d.color.textSecondary,fontSize:d.font.caption,fontWeight:"500"},spark:{flexDirection:"row",alignItems:"flex-end",gap:2,paddingHorizontal:12,paddingTop:6,paddingBottom:6},sparkBar:{flex:1,borderRadius:1},live:{flexDirection:"row",alignItems:"center",gap:5,paddingHorizontal:8,paddingVertical:3,borderRadius:d.radius.badge,backgroundColor:d.color.dangerSoft},liveDot:{width:6,height:6,borderRadius:3,backgroundColor:d.color.danger},liveText:{color:d.color.danger,fontSize:9,fontWeight:"800",letterSpacing:.8},cmpHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,backgroundColor:d.color.fill,gap:8},cmpCol:{flex:1,color:d.color.textTertiary,fontSize:d.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},cmpRow:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"flex-start"},cmpDiff:{backgroundColor:d.color.fill},cmpKey:{width:90,color:d.color.textSecondary,fontSize:d.font.caption},cmpVal:{flex:1,color:d.color.text,fontSize:d.font.caption,fontFamily:"Menlo"},cardImage:{width:"100%",height:140,backgroundColor:d.color.fill},cardText:{paddingHorizontal:12,paddingTop:10,paddingBottom:4,gap:4},cardTitle:{color:d.color.text,fontSize:d.font.row,fontWeight:"600"},fact:{flexDirection:"row",justifyContent:"space-between",gap:8},factLabel:{color:d.color.textSecondary,fontSize:d.font.caption},factValue:{color:d.color.text,fontSize:d.font.caption,fontWeight:"500"},carouselTitle:{color:d.color.text,fontSize:d.font.caption,fontWeight:"600",paddingBottom:8},carousel:{gap:8,paddingRight:8},carouselCard:{width:224,borderRadius:d.radius.card,borderWidth:w.hairlineWidth,borderColor:d.color.border,backgroundColor:d.color.surface,overflow:"hidden"},shot:{width:"100%",height:220,backgroundColor:d.color.fill},shotBig:{height:520},progress:{height:4,backgroundColor:d.color.fill,marginHorizontal:12,marginTop:6,marginBottom:8,borderRadius:2,overflow:"hidden"},progressFill:{height:4,backgroundColor:d.color.accent},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:d.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:d.color.accent},stepFailed:{backgroundColor:d.color.danger},stepRunning:{backgroundColor:d.color.info},stepNum:{color:d.color.text,fontSize:d.font.micro,fontWeight:"700"},checkpoint:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:7,borderRadius:d.radius.chip,backgroundColor:d.color.fill},cpFlag:{width:8,height:8,borderRadius:2,backgroundColor:d.color.info},cpText:{color:d.color.textSecondary,fontSize:d.font.caption},cpRestore:{color:d.color.accent,fontSize:d.font.caption,fontWeight:"600"},taskHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8,paddingHorizontal:12,paddingTop:12},banner:{flexDirection:"row",alignItems:"center",gap:8,paddingLeft:12,paddingRight:4,paddingVertical:4,borderRadius:d.radius.row,borderWidth:w.hairlineWidth},bannerText:{flex:1,fontSize:d.font.caption,fontWeight:"600"},fileIcon:{width:40,height:40,borderRadius:8,backgroundColor:d.color.fill,alignItems:"center",justifyContent:"center"},fileExt:{color:d.color.textSecondary,fontSize:10,fontWeight:"800"}});import{jsx as A}from"react/jsx-runtime";var Ja=class extends Ki{constructor(){super(...arguments);this.state={failed:false}}static getDerivedStateFromError(){return{failed:true}}render(){return this.state.failed?A(l,{style:Qa.fallback,testID:"buoy-block-render-failed",children:"This card couldn't be drawn \u2014 the data behind it is still in the conversation."}):this.props.children}},Qa=w.create({fallback:{color:ir.color.textTertiary,fontSize:ir.font.micro,fontStyle:"italic",paddingVertical:6}}),Ya=e=>A(no,{block:e});function no({block:e}){return A(Ja,{children:A(Xa,{block:e})})}function Xa({block:e}){switch(e.kind){case"choice":return A(xl,{block:e});case"confirm":return A(kl,{block:e});case"input":return A(wl,{block:e});case"table":return A(Fl,{block:e});case"keyValue":return A(_l,{block:e});case"list":return A(Kl,{block:e});case"imageGrid":return A(ia,{block:e});case"diff":return A(Jl,{block:e});case"chart":return A(Ql,{block:e});case"steps":return A(Yl,{block:e});case"code":return A(ta,{block:e});case"actions":return A(We,{actions:e.actions,blockId:e.id});case"notice":return A(oa,{block:e});case"finding":return A(ra,{block:e});case"requestList":return A(da,{block:e});case"requestCard":return A(pa,{block:e});case"ruleCard":return A(ha,{block:e});case"screenElements":return A(ga,{block:e});case"routeChips":return A(fa,{block:e});case"logList":return A(ba,{block:e});case"crash":return A(ya,{block:e});case"peek":return A(ma,{block:e});case"suggestions":return A(Ca,{block:e});case"multiSelect":return A(Ia,{block:e});case"select":return A(Da,{block:e});case"slider":return A(Ra,{block:e});case"dateTime":return A($a,{block:e});case"form":return A(Aa,{block:e});case"proposal":return A(Ba,{block:e});case"claim":return A(Ha,{block:e});case"details":return A(La,{block:e});case"tabs":return A(Pa,{block:e,renderNested:Ya});case"timeline":return A(Wa,{block:e});case"sparkline":return A(Ea,{block:e});case"compare":return A(Va,{block:e});case"card":return A(Na,{block:e});case"cardCarousel":return A(ja,{block:e});case"screenshot":return A(qa,{block:e});case"plan":return A(Ma,{block:e});case"checkpoint":return A(Fa,{block:e});case"task":return A(_a,{block:e});case"banner":return A(Ua,{block:e});case"file":return A(Ka,{block:e});case"upload":return A(Ga,{block:e});default:return null}}import{useEffect as Za,useState as wt}from"react";import{ChevronDown as es,ChevronRight as ts,Copy as os,night as T,RefreshCw as rs}from"@buoy-gg/shared-ui/web";import{jsx as E,jsxs as ze}from"react/jsx-runtime";function qt({label:e,onPress:t,children:o}){return E(m,{onPress:t,accessibilityRole:"button",accessibilityLabel:e,style:({pressed:r})=>[L.iconBtn,r&&L.pressed],children:o})}function ns({id:e="chrome-actions"}){let t=Z(),[o,r]=wt(null),n=i=>void t.runAction({label:i,send:`__chrome__:${i}`},e);return ze(s,{style:L.actions,testID:"chrome-message-actions",children:[E(qt,{label:"Copy",onPress:()=>n("copy"),children:E(os,{size:13,color:T.color.textSecondary})}),E(qt,{label:"Retry",onPress:()=>n("retry"),children:E(rs,{size:13,color:T.color.textSecondary})}),E(qt,{label:"Good answer",onPress:()=>{r("up"),n("thumbs up")},children:E(l,{style:[L.glyph,o==="up"&&L.glyphOn],children:"\u{1F44D}"})}),E(qt,{label:"Bad answer",onPress:()=>{r("down"),n("thumbs down")},children:E(l,{style:[L.glyph,o==="down"&&L.glyphOn],children:"\u{1F44E}"})}),E(qt,{label:"Export",onPress:()=>n("export transcript"),children:E(l,{style:L.textBtn,children:"Export"})})]})}function is({text:e,live:t}){let[o,r]=wt(false);return ze(s,{style:L.reasoning,testID:"chrome-reasoning",children:[ze(m,{onPress:()=>r(n=>!n),style:L.reasoningHead,accessibilityRole:"button",accessibilityState:{expanded:o},children:[t?E(Vt,{size:"small",color:T.color.textTertiary}):null,E(l,{style:L.reasoningTitle,children:t?"Working it out\u2026":"How I got here"}),o?E(es,{size:12,color:T.color.textTertiary}):E(ts,{size:12,color:T.color.textTertiary})]}),o?E(l,{style:L.reasoningBody,children:e}):null]})}function ls({label:e}){let[t,o]=wt(0);return Za(()=>{let r=setInterval(()=>o(n=>n+250),250);return()=>clearInterval(r)},[]),ze(s,{style:L.elapsed,testID:"chrome-elapsed",children:[E(Vt,{size:"small",color:T.color.textSecondary}),E(l,{style:L.elapsedLabel,children:e}),ze(l,{style:L.elapsedMs,children:[(t/1e3).toFixed(1),"s"]})]})}function as(){let[e,t]=wt(""),[o,r]=wt(null);return ze(s,{style:L.composerWrap,testID:"chrome-queue",children:[o?ze(s,{style:L.queuedRow,children:[ze(l,{style:L.queuedText,numberOfLines:1,children:['Queued: "',o,'"']}),E(m,{onPress:()=>r(null),children:E(l,{style:L.queuedCancel,children:"Cancel"})})]}):null,ze(s,{style:L.composer,children:[E(Ze,{style:L.composerInput,value:e,onChangeText:t,placeholder:"Agent is busy \u2014 type and it sends next",placeholderTextColor:T.color.placeholder}),E(m,{disabled:!e.trim(),onPress:()=>{r(e.trim()),t("")},style:[L.queueBtn,!e.trim()&&{opacity:.5}],children:E(l,{style:L.queueBtnText,children:"Queue"})})]})]})}function ss({at:e}){return ze(s,{style:L.divider,testID:"chrome-divider",children:[E(s,{style:L.dividerLine}),ze(l,{style:L.dividerText,children:["App reloaded \xB7 ",e]}),E(s,{style:L.dividerLine})]})}function cs({at:e}){return E(l,{style:L.timestamp,children:e})}function ds({text:e}){let t=Z(),[o,r]=wt(false),[n,i]=wt(e);return E(s,{style:L.userWrap,testID:"chrome-edit-bubble",children:o?ze(s,{style:L.editBox,children:[E(Ze,{style:L.editInput,value:n,onChangeText:i,multiline:true}),ze(s,{style:L.editActions,children:[E(m,{onPress:()=>{r(false),t.runAction({label:"re-run edited",send:`__chrome__:re-run "${n}"`},"chrome-edit")},style:L.editPrimary,children:E(l,{style:L.editPrimaryText,children:"Re-run from here"})}),E(m,{onPress:()=>{r(false),t.runAction({label:"branch",send:`__chrome__:branch "${n}"`},"chrome-edit")},style:L.editPlate,children:E(l,{style:L.editPlateText,children:"Branch"})}),E(m,{onPress:()=>r(false),style:L.editPlate,children:E(l,{style:L.editPlateText,children:"Cancel"})})]})]}):ze(m,{onLongPress:()=>r(true),onPress:()=>r(true),style:L.bubble,accessibilityRole:"button",accessibilityLabel:"Edit message",children:[E(l,{style:L.bubbleText,children:n}),E(l,{style:L.bubbleHint,children:"tap to edit \xB7 2 branches"})]})})}var L=w.create({actions:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:2},iconBtn:{paddingHorizontal:8,paddingVertical:6,borderRadius:T.radius.badge},pressed:{backgroundColor:T.color.fill},glyph:{fontSize:13,opacity:.6},glyphOn:{opacity:1},textBtn:{color:T.color.textSecondary,fontSize:T.font.micro,fontWeight:"600"},reasoning:{borderRadius:T.radius.row,backgroundColor:T.color.fill,overflow:"hidden"},reasoningHead:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:8},reasoningTitle:{flex:1,color:T.color.textSecondary,fontSize:T.font.caption,fontStyle:"italic"},reasoningBody:{color:T.color.textSecondary,fontSize:T.font.caption,lineHeight:18,paddingHorizontal:12,paddingBottom:10},elapsed:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:10,borderRadius:T.radius.card,borderWidth:w.hairlineWidth,borderColor:T.color.border,backgroundColor:T.color.surface},elapsedLabel:{flex:1,color:T.color.text,fontSize:T.font.body},elapsedMs:{color:T.color.textTertiary,fontSize:T.font.caption,fontFamily:"Menlo"},composerWrap:{gap:6},queuedRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:6,borderRadius:T.radius.row,backgroundColor:T.color.infoSoft},queuedText:{flex:1,color:T.color.text,fontSize:T.font.caption},queuedCancel:{color:T.color.info,fontSize:T.font.caption,fontWeight:"600"},composer:{flexDirection:"row",alignItems:"center",gap:8},composerInput:{flex:1,height:40,paddingHorizontal:16,borderRadius:20,borderWidth:w.hairlineWidth,borderColor:T.color.border,backgroundColor:T.color.surfaceElevated,color:T.color.text,fontSize:T.font.body},queueBtn:{paddingHorizontal:14,height:40,borderRadius:20,backgroundColor:T.color.button,alignItems:"center",justifyContent:"center"},queueBtnText:{color:T.color.text,fontSize:T.font.caption,fontWeight:"600"},divider:{flexDirection:"row",alignItems:"center",gap:10,paddingVertical:4},dividerLine:{flex:1,height:w.hairlineWidth,backgroundColor:T.color.border},dividerText:{color:T.color.textTertiary,fontSize:T.font.micro},timestamp:{alignSelf:"center",color:T.color.textTertiary,fontSize:T.font.micro},userWrap:{alignItems:"flex-end"},bubble:{maxWidth:"84%",paddingHorizontal:14,paddingVertical:9,borderRadius:18,borderBottomRightRadius:6,backgroundColor:T.color.accentFill,borderWidth:w.hairlineWidth,borderColor:T.color.accentBorder,gap:4},bubbleText:{color:T.color.text,fontSize:T.font.row,lineHeight:21},bubbleHint:{color:T.color.textTertiary,fontSize:10,textAlign:"right"},editBox:{width:"100%",gap:8},editInput:{minHeight:60,padding:12,borderRadius:T.radius.row,backgroundColor:T.color.surfaceElevated,color:T.color.text,fontSize:T.font.row,borderWidth:w.hairlineWidth,borderColor:T.color.accentBorderStrong},editActions:{flexDirection:"row",gap:8,justifyContent:"flex-end",flexWrap:"wrap"},editPrimary:{paddingHorizontal:12,paddingVertical:8,borderRadius:T.radius.row,backgroundColor:T.color.accent},editPrimaryText:{color:T.color.onAccent,fontSize:T.font.caption,fontWeight:"600"},editPlate:{paddingHorizontal:12,paddingVertical:8,borderRadius:T.radius.row,backgroundColor:T.color.button},editPlateText:{color:T.color.text,fontSize:T.font.caption,fontWeight:"600"}});import{useState as Or}from"react";import{AlertTriangle as us,ChevronDown as ps,night as W}from"@buoy-gg/shared-ui/web";import{jsx as me,jsxs as Mt}from"react/jsx-runtime";function Wr({pending:e,onAnswer:t}){let[o,r]=Or("");return Mt(s,{style:J.card,testID:"buoy-ask-buoy-approval",children:[Mt(s,{style:J.titleRow,children:[me(us,{size:14,color:W.color.warning}),me(l,{style:J.title,children:"Allow this change?"})]}),e.restored?me(l,{style:J.restored,testID:"buoy-ask-buoy-approval-restored",children:"Asked before the app restarted \u2014 check it still applies."}):null,me(l,{style:J.label,children:e.label}),me(l,{style:J.reason,children:e.reason}),e.description?me(hs,{text:e.description}):null,me(Ze,{testID:"buoy-ask-buoy-approval-note",value:o,onChangeText:r,placeholder:"Add a note for the agent (optional)",placeholderTextColor:W.color.textTertiary,style:J.note,returnKeyType:"done",blurOnSubmit:true}),Mt(s,{style:J.actions,children:[me(m,{testID:"buoy-ask-buoy-approve",accessibilityRole:"button",onPress:()=>t({approved:true,reason:o}),style:({pressed:n})=>[J.button,J.approve,n&&J.pressed],children:me(l,{style:J.approveText,children:"Allow"})}),e.restored?null:me(m,{testID:"buoy-ask-buoy-approve-trust",accessibilityRole:"button",onPress:()=>t({approved:true,reason:o,trust:true}),style:({pressed:n})=>[J.button,J.trust,n&&J.pressed],children:me(l,{style:J.trustText,children:"Allow for this chat"})}),me(m,{testID:"buoy-ask-buoy-reject",accessibilityRole:"button",onPress:()=>t({approved:false,reason:o}),style:({pressed:n})=>[J.button,J.reject,n&&J.pressed],children:me(l,{style:J.rejectText,children:"Not now"})})]})]})}function hs({text:e}){let[t,o]=Or(false);return Mt(s,{children:[Mt(m,{testID:"buoy-ask-buoy-approval-details",accessibilityRole:"button",accessibilityState:{expanded:t},onPress:()=>o(r=>!r),style:({pressed:r})=>[J.disclosure,r&&J.pressed],hitSlop:6,children:[me(s,{style:t?J.chevronOpen:J.chevronClosed,children:me(ps,{size:12,color:W.color.textTertiary})}),me(l,{style:J.disclosureText,children:t?"Hide details":"Details"})]}),t?me(Fe,{style:J.detail,contentContainerStyle:J.detailContent,nestedScrollEnabled:true,children:me(l,{style:J.description,children:e})}):null]})}var J=w.create({card:{marginHorizontal:W.gutter,marginBottom:10,padding:W.cardPad,borderRadius:W.radius.card,borderWidth:w.hairlineWidth,borderColor:W.color.accentBorderStrong,backgroundColor:W.color.surface,gap:6},titleRow:{flexDirection:"row",alignItems:"center",gap:6},title:{color:W.color.text,fontSize:W.font.caption,fontWeight:"600"},label:{color:W.color.text,fontSize:W.font.row,fontWeight:"600",lineHeight:20},description:{color:W.color.textSecondary,fontSize:W.font.caption,lineHeight:18},reason:{color:W.color.warning,fontSize:W.font.caption,lineHeight:18},restored:{color:W.color.info,backgroundColor:W.color.infoSoft,fontSize:W.font.micro,lineHeight:16,paddingHorizontal:8,paddingVertical:5,borderRadius:8},disclosure:{flexDirection:"row",alignItems:"center",gap:4,paddingVertical:4},disclosureText:{color:W.color.textTertiary,fontSize:W.font.micro,fontWeight:"600"},chevronOpen:{transform:[{rotate:"0deg"}]},chevronClosed:{transform:[{rotate:"-90deg"}]},detail:{maxHeight:150,marginTop:2},detailContent:{paddingBottom:2},note:{color:W.color.text,fontSize:W.font.caption,paddingHorizontal:10,paddingVertical:7,borderRadius:W.radius.row,borderWidth:w.hairlineWidth,borderColor:W.color.border,backgroundColor:W.color.button,marginTop:2},actions:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},button:{paddingHorizontal:16,paddingVertical:9,borderRadius:W.radius.row},approve:{backgroundColor:W.color.accent},approveText:{color:W.color.onAccent,fontWeight:"600",fontSize:W.font.caption},trust:{backgroundColor:W.color.button,borderWidth:w.hairlineWidth,borderColor:W.color.accentBorderStrong},trustText:{color:W.color.accent,fontWeight:"600",fontSize:W.font.caption},reject:{backgroundColor:W.color.button},rejectText:{color:W.color.text,fontSize:W.font.caption},pressed:{opacity:.7}});import{useSyncExternalStore as gs}from"react";import{ChevronDown as fs,ChevronRight as bs,night as oe}from"@buoy-gg/shared-ui/web";import{isReversible as Er}from"@buoy-gg/agent-core/web";import{jsx as rt,jsxs as ct}from"react/jsx-runtime";var Vr=[];function Nr(e){return gs(t=>e?.subscribe(t)??(()=>{}),()=>e?.list()??Vr,()=>e?.list()??Vr)}function jr({ledger:e,onUndoAll:t,expanded:o,onToggle:r}){let n=Nr(e).filter(C=>!C.undoneAt),i=n.filter(C=>C.effect.kind!=="transient");if(i.length===0)return null;let a=i.filter(C=>Er(C.effect)),h=i.length-a.length,u=n.length-i.length,g=o?fs:bs,y=[a.length>0?`${a.length} undoable`:null,h>0?`${h} permanent`:null].filter(Boolean).join(" \xB7 ");return ct(s,{style:ge.wrap,children:[ct(m,{testID:"buoy-ask-buoy-changes-bar",accessibilityRole:"button",accessibilityState:{expanded:o},onPress:r,style:ge.bar,children:[rt(s,{style:ge.dot}),rt(l,{style:ge.summary,numberOfLines:1,children:"Changed this app"}),rt(l,{style:ge.counts,numberOfLines:1,children:y}),rt(g,{size:12,color:oe.color.textSecondary})]}),o&&ct(s,{style:ge.panel,children:[ct(Fe,{style:ge.panelScroll,testID:"buoy-ask-buoy-changes-scroll",keyboardShouldPersistTaps:"handled",children:[i.map(C=>{let j=!Er(C.effect);return ct(s,{style:ge.row,children:[rt(l,{style:ge.rowLabel,children:C.effect.label}),rt(l,{style:[ge.rowTag,j&&ge.rowTagMuted],children:j?"Permanent":"Undoable"})]},C.id)}),u>0&&rt(s,{style:ge.row,children:ct(l,{style:[ge.rowLabel,ge.rowLabelMuted],children:["Also did ",u," one-shot action",u===1?"":"s"," (navigation, taps) \u2014 nothing to undo."]})})]}),ct(s,{style:ge.footer,children:[a.length>0&&rt(m,{testID:"buoy-ask-buoy-undo-all",accessibilityRole:"button",onPress:t,style:({pressed:C})=>[ge.undo,C&&ge.pressed],children:ct(l,{style:ge.undoText,children:["Undo ",a.length," change",a.length===1?"":"s"]})}),h>0&&rt(l,{style:ge.footnote,children:"Permanent changes can't be undone from here."})]})]})]})}var ge=w.create({wrap:{borderBottomWidth:w.hairlineWidth,borderBottomColor:oe.color.border,backgroundColor:oe.color.warningSoft},bar:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:oe.gutter,paddingVertical:10},dot:{width:7,height:7,borderRadius:4,backgroundColor:oe.color.warning},summary:{color:oe.color.text,fontSize:oe.font.caption,fontWeight:"600"},counts:{flex:1,color:oe.color.textSecondary,fontSize:oe.font.caption},panel:{paddingHorizontal:oe.gutter,paddingBottom:12,gap:10},panelScroll:{maxHeight:180},row:{flexDirection:"row",alignItems:"flex-start",gap:10,paddingVertical:8,borderTopWidth:w.hairlineWidth,borderTopColor:oe.color.separator},rowLabel:{flex:1,color:oe.color.text,fontSize:oe.font.caption,lineHeight:18},rowTag:{color:oe.color.accent,fontSize:oe.font.micro,fontWeight:"600",letterSpacing:.6,textTransform:"uppercase",paddingTop:2},rowTagMuted:{color:oe.color.textTertiary},rowLabelMuted:{color:oe.color.textTertiary},footer:{flexDirection:"row",alignItems:"center",gap:12,flexWrap:"wrap"},undo:{paddingHorizontal:14,paddingVertical:8,borderRadius:oe.radius.row,backgroundColor:oe.color.button},undoText:{color:oe.color.accent,fontSize:oe.font.caption,fontWeight:"600"},footnote:{flex:1,color:oe.color.textTertiary,fontSize:oe.font.micro},pressed:{opacity:.7}});function ys(e){let t={};for(let o of e){let r=o.effect;if(r.kind==="network-override")t[r.ruleId]=o.undoneAt?{deleted:true}:{enabled:true};else if(r.kind==="inverse-call"&&r.toolId==="network"&&r.action==="setOverrideRuleEnabled"&&typeof r.params.id=="string"){let n=r.params.enabled===true;if(t[r.params.id]?.deleted)continue;t[r.params.id]={enabled:o.undoneAt?n:!n}}}return t}import{useCallback as ms,useEffect as qr,useRef as xs,useState as ks}from"react";import{night as Te}from"@buoy-gg/shared-ui/web";import{jsx as dt,jsxs as ws}from"react/jsx-runtime";var Mr=40,vs=120,Fr=$t.OS==="ios"?10:6,Ss=16;function _r({onSend:e,onStop:t,busy:o,draft:r,onDraftTaken:n,disabled:i,placeholder:a,focusKey:h,canFocus:u=true}){let[g,y]=ks(""),C=xs(null);qr(()=>{!h||!u||i||C.current?.focus()},[h,u,i]),qr(()=>{r&&(y(ee=>ee?`${ee} ${r}`:r),n?.())},[r,n]);let j=ms(()=>{let ee=g.trim();ee&&(y(""),e(ee))},[g,e]),M=g.trim().length>0&&!o&&!i,X=g.trim().length>0&&o&&!i;return ws(s,{style:xe.wrap,children:[dt(s,{style:[xe.field,i&&xe.fieldDisabled],children:dt(Ze,{ref:C,testID:"buoy-ask-buoy-input",style:[xe.input,g.length===0&&xe.inputEmpty],value:g,onChangeText:y,placeholder:a??(i?"Ask Buoy isn't set up yet":"Ask, or tell it what to change\u2026"),placeholderTextColor:Te.color.placeholder,multiline:true,editable:!i,keyboardType:"ascii-capable",autoCorrect:true,autoCapitalize:"sentences",blurOnSubmit:false,onSubmitEditing:j,returnKeyType:"send",maxLength:4e3})}),X&&dt(m,{testID:"buoy-ask-buoy-queue",accessibilityRole:"button",accessibilityLabel:"Queue message",onPress:j,style:({pressed:ee})=>[xe.button,xe.queue,ee&&xe.pressed],children:dt(l,{style:[xe.sendGlyph,{color:Te.color.accent}],children:"\u2191"})}),o?dt(m,{testID:"buoy-ask-buoy-stop",accessibilityRole:"button",accessibilityLabel:"Stop",onPress:t,style:({pressed:ee})=>[xe.button,xe.stop,ee&&xe.pressed],children:dt(s,{style:xe.stopGlyph})}):dt(m,{testID:"buoy-ask-buoy-send",accessibilityRole:"button",accessibilityLabel:"Send",disabled:!M,onPress:j,style:({pressed:ee})=>[xe.button,M?xe.sendOn:xe.sendOff,ee&&M&&xe.pressed],children:dt(l,{style:[xe.sendGlyph,{color:M?Te.color.onAccent:Te.color.textTertiary}],children:"\u2191"})})]})}var xe=w.create({wrap:{flexDirection:"row",alignItems:"flex-end",gap:8,paddingHorizontal:Te.gutter,paddingTop:10,paddingBottom:6,borderTopWidth:w.hairlineWidth,borderTopColor:Te.color.border,backgroundColor:Te.color.bg},field:{flex:1,minHeight:Mr,justifyContent:"center",borderRadius:20,borderWidth:w.hairlineWidth,borderColor:Te.color.border,backgroundColor:Te.color.surfaceElevated},fieldDisabled:{opacity:.6},input:{maxHeight:vs,paddingHorizontal:Ss,paddingTop:Fr,paddingBottom:Fr,color:Te.color.text,fontSize:Te.font.row},inputEmpty:{height:Mr},button:{width:40,height:40,borderRadius:20,alignItems:"center",justifyContent:"center"},sendGlyph:{fontSize:20,fontWeight:"700",lineHeight:22},sendOn:{backgroundColor:Te.color.accent},sendOff:{backgroundColor:Te.color.fill},stop:{backgroundColor:Te.color.fillTertiary},queue:{backgroundColor:"transparent",borderWidth:w.hairlineWidth,borderColor:Te.color.accentBorderStrong},stopGlyph:{width:12,height:12,borderRadius:2,backgroundColor:Te.color.text},pressed:{opacity:.7}});import{useEffect as Ts,useRef as Ur}from"react";import{jsx as Cs}from"react/jsx-runtime";function Is({children:e}){let t=Ur(null),o=Ur(new ce.Value(0)).current;return Ts(()=>{if($t.OS!=="ios")return;let r=(h,u)=>{ce.timing(o,{toValue:h,duration:u.duration||250,easing:Rt.bezier(.17,.59,.4,.77),useNativeDriver:false}).start()},n=h=>{let u=t.current;u&&u.measureInWindow((g,y,C,j)=>{let M=y+j-h.endCoordinates.screenY;r(Math.max(0,M),h)})},i=h=>r(0,h),a=[go.addListener("keyboardWillChangeFrame",n),go.addListener("keyboardWillHide",i)];return()=>a.forEach(h=>h.remove())},[o]),Cs(ce.View,{ref:t,style:[zs.flex,{paddingBottom:o}],children:e})}var zs=w.create({flex:{flex:1}});import{useEffect as Kr,useState as Gr}from"react";import{Check as Ds,Copy as Rs,FileText as $s,ModalHeader as io,night as Ke,Otto as As,Plus as Bs,SettingsSolid as Hs,realNow as wo}from"@buoy-gg/shared-ui/web";import{toolTitle as Ls}from"@buoy-gg/agent-core/web";var Ps=e=>e.effect==="read"&&e.status==="ok";function Os(e){let t=[],o=[],r=()=>{if(o.length!==0){if(o.length===1)t.push({kind:"call",call:o[0]});else{let n=[...new Set(o.map(i=>Ls(i.toolId)))];t.push({kind:"reads",id:o.map(i=>i.id).join("+"),calls:o,label:`Looked at ${Ws(n)}`,count:o.length})}o=[]}};for(let n of e){if(Ps(n)){o.push(n);continue}r(),t.push({kind:"call",call:n})}return r(),t}function Ws(e){return e.length<=1?e[0]??"":e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Es(e){let t=[];e.startedAt!==void 0&&e.endedAt!==void 0&&e.endedAt>=e.startedAt&&t.push(Jr(e.endedAt-e.startedAt));let o=e.toolCalls.length;if(o>0){t.push(`${o} action${o===1?"":"s"}`);let r=u=>e.toolCalls.filter(g=>g.status===u).length,n=r("failed"),i=r("refused"),a=r("declined"),h=r("stopped");n&&t.push(`${n} failed`),i&&t.push(`${i} refused`),a&&t.push(`${a} declined`),h&&t.push(`${h} not run`)}return t.length?t.join(" \xB7 "):null}function Jr(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let o=Math.floor(t/60),r=t%60;return o<60?`${o}m ${String(r).padStart(2,"0")}s`:`${Math.floor(o/60)}h ${String(o%60).padStart(2,"0")}m`}import{jsx as Be,jsxs as Qr}from"react/jsx-runtime";var Vs=200,Ns=()=>"";function Yr({configured:e,busy:t,failed:o=false,activeLabel:r,awaitingApproval:n=false,startedAt:i=null,stopping:a=false,readOnly:h=false,toolCount:u,hasMessages:g,onBack:y,onReset:C,getTranscript:j,onOpenSettings:M,onTicket:X}){let{copied:ee,copy:ke}=to(j??Ns),[Ge,Re]=Gr(false);Kr(()=>{t?r&&Re(true):Re(false)},[t,r]);let Je=t&&!n&&i!==null,[Qe,ft]=Gr(()=>wo());Kr(()=>{if(!Je)return;ft(wo());let st=setInterval(()=>ft(wo()),1e3);return()=>clearInterval(st)},[Je]);let bt=Je&&i!==null?Jr(Qe-i):null,It=e?o?"error":t?r||Ge?"robot":"thinking":"idle":"confused",Ve=a?"Stopping":r??"Thinking",at=e?n?"Waiting for you":t?bt?`${Ve} \xB7 ${bt}`:`${Ve}\u2026`:h?`Read only${u>0?` \xB7 ${u} tool${u===1?"":"s"}`:""}`:u>0?`Ready \xB7 ${u} tool${u===1?"":"s"} available`:"Ready":"Not set up in this app";return Qr(io,{children:[y?Be(io.Navigation,{onBack:y}):null,Be(s,{style:ut.otto,testID:"buoy-ask-buoy-otto",children:Be(As,{state:It,pixelSize:2,tickMs:Vs,water:false})}),Be(io.Content,{title:"Ask Buoy",subtitle:at,testID:"buoy-ask-buoy-title"}),Qr(io.Actions,{children:[X?Be(Et,{testID:"buoy-ask-buoy-ticket",accessibilityRole:"button",accessibilityLabel:"Summarize for a ticket",disabled:!g||t,onPress:X,style:[ut.actionBtn,(!g||t)&&ut.actionBtnDisabled],children:Be($s,{size:14,color:g&&!t?Ke.color.textSecondary:Ke.color.textTertiary})}):null,j?Be(Et,{testID:"buoy-ask-buoy-copy-chat",accessibilityRole:"button",accessibilityLabel:ee?"Conversation copied":"Copy conversation",disabled:!g,onPress:ke,style:[ut.actionBtn,!g&&ut.actionBtnDisabled],children:ee?Be(Ds,{size:14,color:Ke.color.accent}):Be(Rs,{size:14,color:g?Ke.color.textSecondary:Ke.color.textTertiary})}):null,M?Be(Et,{testID:"buoy-ask-buoy-settings",accessibilityRole:"button",accessibilityLabel:"Settings",onPress:M,style:ut.actionBtn,children:Be(Hs,{size:14,color:Ke.color.textSecondary})}):null,Be(Et,{testID:"buoy-ask-buoy-reset",accessibilityRole:"button",accessibilityLabel:"New conversation",disabled:!g,onPress:C,style:[ut.actionBtn,!g&&ut.actionBtnDisabled],children:Be(Bs,{size:14,color:g?Ke.color.textSecondary:Ke.color.textTertiary})})]})]})}var ut=w.create({otto:{marginRight:8,justifyContent:"center"},actionBtn:{width:32,height:32,borderRadius:8,backgroundColor:Ke.color.buttonSurface,borderWidth:1,borderColor:Ke.color.border,alignItems:"center",justifyContent:"center"},actionBtnDisabled:{opacity:.55}});import{useCallback as js,useEffect as qs,useState as Ms}from"react";import{AlertTriangle as Fs,night as de,ToggleRow as vo}from"@buoy-gg/shared-ui/web";import{useSyncExternalStore as _s}from"react";import{definePersistedSetting as Us,devToolsStorageKeys as Ks}from"@buoy-gg/shared-ui/web";var So={showThinking:false,bypassApprovals:false,readOnly:false,hostedNoticeSeen:false},To=Us(`${Ks.base}_ask_buoy_settings`,So,{sanitize:e=>({showThinking:e.showThinking===true,bypassApprovals:e.bypassApprovals===true,readOnly:e.readOnly===true,hostedNoticeSeen:e.hostedNoticeSeen===true})}),vt=So,Co=false,Io=new Set;function Xr(){for(let e of Io)try{e()}catch{}}var pt={get:()=>vt,subscribe(e){return Io.add(e),Co||(Co=true,To.load().then(t=>{vt=t,Xr()})),()=>Io.delete(e)},set(e,t){vt[e]!==t&&(vt={...vt,[e]:t},Xr(),To.save(vt))},reset(){vt=So,Co=false,To.clear()}};function Ht(){return _s(pt.subscribe,pt.get,pt.get)}import{idFactory as Zr}from"@buoy-gg/agent-core/web";import{realNow as Ft}from"@buoy-gg/shared-ui/web";var lo=Zr("m"),en=400;function Gs(e){if(!(!e||Object.keys(e).length===0))try{let t=JSON.stringify(e);return t.length>en?`${t.slice(0,en)}\u2026`:t}catch{return}}var Js=Zr("q"),H={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:{}},tn=null,on=null,zo=new Set,rn=null,Do=null;function Q(e){H={...H,...e};for(let t of zo)try{t()}catch{}}var b={getState:()=>H,subscribe(e){return zo.add(e),()=>zo.delete(e)},setLedger(e){rn=e},getLedger(){return rn},holdSession(e,t){Do={session:e,signature:t}},getHeldSession(){return Do},setReporter(e){tn=e},getReporter(){return tn},setUsageReader(e){on=e},getUsageReader(){return on},setNotice(e){Q({notice:e})},setConfigured(e){e!==H.configured&&Q({configured:e})},setMeta(e){Object.keys(e).every(t=>H.meta[t]===e[t])||Q({meta:{...H.meta,...e}})},addUser(e){Q({messages:[...H.messages,{id:lo(),role:"user",text:e,toolCalls:[],blocks:[]}],busy:true})},beginTurn(){Q({busy:true})},enqueue(e){let t={id:Js(),text:e};return Q({queued:[...H.queued,t]}),t},removeQueued(e){H.queued.some(t=>t.id===e)&&Q({queued:H.queued.filter(t=>t.id!==e)})},shiftQueued(){let[e,...t]=H.queued;if(e)return Q({queued:t}),e},takeQueuedToDraft(e){let t=H.queued.find(o=>o.id===e);t&&Q({queued:H.queued.filter(o=>o.id!==e),draft:t.text})},requestStop(){!H.busy||H.stopping||Q({stopping:true})},clearDraft(){H.draft!==null&&Q({draft:null})},removeMessage(e){Q({messages:H.messages.filter(t=>t.id!==e)})},recordAnswer(e){Q({answers:{...H.answers,[e.blockId]:e},awaitingBlockId:H.awaitingBlockId===e.blockId?null:H.awaitingBlockId})},setActionState(e,t){let o={...H.actionState};t===null?delete o[e]:o[e]=t,Q({actionState:o})},startAssistant(){let e=lo();return Q({messages:[...H.messages,{id:e,role:"assistant",text:"",toolCalls:[],blocks:[],streaming:true,startedAt:Ft()}]}),e},applyEvent(e,t){if(t.type==="history-trimmed"){let r=H.messages.findIndex(a=>a.id===e),n={id:lo(),role:"assistant",system:true,text:`Older messages were trimmed from the agent's memory (${t.droppedRounds} exchange${t.droppedRounds===1?"":"s"}).`+(t.droppedPinned?` ${t.droppedPinned===1?"One of them made a change that is":`${t.droppedPinned} of them made changes that are`} still applied \u2014 the changes bar still lists ${t.droppedPinned===1?"it":"them"}, but the agent no longer remembers making ${t.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:Ft()},i=[...H.messages];i.splice(r<0?i.length:r,0,n),Q({messages:i});return}let o=H.messages.map(r=>{if(r.id!==e)return r;switch(t.type){case"retrying":{let n=Math.max(1,Math.round(t.inMs/1e3));return{...r,waiting:t.reason==="throttled"?`Endpoint busy \u2014 retrying in ${n}s (${t.attempt} of ${t.maxAttempts})`:"Request too large \u2014 trimming older messages and retrying"}}case"text":return{...r,waiting:void 0,text:(r.breakBeforeNextText||t.breakBefore)&&r.text?`${r.text.trimEnd()}
9
9
 
10
- ${t.delta}`:r.text+t.delta,breakBeforeNextText:false};case"reasoning":return{...r,breakBeforeNextText:true,reasoning:[...r.reasoning??[],{text:t.text,afterCalls:r.toolCalls.length}]};case"tool-start":return{...r,waiting:void 0,toolCalls:[...r.toolCalls,{id:t.id,toolId:t.toolId,action:t.action,label:t.label,description:t.description,status:"running",params:Gs(t.params),effect:t.effect,startedAt:Ft()}]};case"tool-end":return{...r,breakBeforeNextText:true,toolCalls:r.toolCalls.map(n=>n.id===t.id?{...n,status:!t.ok&&t.summary==="refused"?"refused":!t.ok&&t.summary==="declined"?"declined":!t.ok&&t.summary==="stopped"?"stopped":t.ok?"ok":"failed",summary:t.summary,durationMs:t.durationMs,result:t.result}:n)};case"tool-verified":return{...r,toolCalls:r.toolCalls.map(n=>n.id===t.id?{...n,verification:t.verification}:n)};case"block":return{...r,breakBeforeNextText:true,blocks:[...r.blocks,{block:t.block,forToolCallId:t.forToolCallId}]};case"usage":return{...r,usage:{input:(r.usage?.input??0)+t.input,output:(r.usage?.output??0)+t.output,requests:(r.usage?.requests??0)+1}};case"error":return{...r,waiting:void 0,error:t.message,...t.hosted?{errorInfo:{code:t.hosted.code,requestId:t.hosted.request_id,action:t.hosted.action,resetAt:t.hosted.reset_at,helpUrl:t.hosted.help_url}}:{}};default:return r}});Y({messages:o,...t.type==="awaiting-user"?{awaitingBlockId:t.blockId}:{},...t.type==="meter"&&t.frame.phase==="end"?{credits:{left:t.frame.credits_left??H.credits?.left??null,resetAt:t.frame.credits_reset??H.credits?.resetAt??null,pending:t.frame.pending===true}}:{},...t.type==="usage"?{usage:{input:H.usage.input+t.input,output:H.usage.output+t.output,requests:H.usage.requests+1}}:{}})},markStopped(e){Y({messages:H.messages.map(t=>t.id===e?{...t,stopped:true}:t)})},finishAssistant(e){Y({messages:H.messages.map(t=>t.id===e?{...t,streaming:false,endedAt:Ft()}:t),busy:false,stopping:false})},askApproval(e){return new Promise(t=>{Y({pending:{...e,resolve:t}})})},answerApproval(e){let t=H.pending,o=typeof e=="boolean"?e:e.approved,r=typeof e!="boolean"&&e.trust===true&&o,n=t?`${t.toolId}.${t.action}`:"";Y({pending:null,...r&&t&&!H.trusted.some(i=>i.key===n)?{trusted:[...H.trusted,{key:n,label:t.label}]}:{}}),t?.resolve(e)},untrust(e){Do?.session.untrust(e),Y({trusted:H.trusted.filter(t=>t.key!==e)})},restorePending(e){return H.pending||H.busy?false:(Y({pending:{...e,restored:true,resolve:()=>{}}}),true)},addNote(e){Y({messages:[...H.messages,{id:lo(),role:"assistant",text:e,toolCalls:[],blocks:[],endedAt:Ft()}]})},hydrate(e){return H.messages.length>0||H.busy?false:(Y({messages:e.messages.map(t=>({...t,restored:true})),answers:e.answers,usage:e.usage,queued:e.queued??[]}),true)},reset(){H.pending?.resolve(false),Y({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 nn(e){return e.pending?"awaitingApproval":e.busy?e.stopping?"stopping":"running":e.awaitingBlockId?"awaitingAnswer":"idle"}function ln(e){let t=nn(e);if(t==="running"||t==="stopping")return null;if(t==="awaitingApproval")return"Paused \u2014 answer the approval above first.";if(t==="awaitingAnswer")return"Paused \u2014 answer the question above first.";let o=e.messages[e.messages.length-1];return o?.role==="assistant"&&o.error?"Paused \u2014 the last turn failed.":o?.role==="assistant"&&o.stopped?"Paused \u2014 you stopped the last turn.":null}import{getUseIsPro as Ys,hasAccountAccess as _t,subscribeAccountAccess as Qs}from"@buoy-gg/shared-ui/web";import{useCallback as De,useEffect as ht,useMemo as Xs,useRef as St,useState as Zs,useSyncExternalStore as ec}from"react";import{dispatchToolAction as an,listSnapshotToolIds as tc,listToolActions as oc,readToolSnapshot as rc,waitForToolRegistry as sn}from"@buoy-gg/shared-ui/web";import{answerToText as cn,CATALOG as Ro,createAskBuoySession as nc,readTargetDigest as ic,runGatedAction as dn,SNAPSHOT_ACTION as un}from"@buoy-gg/agent-core/web";import{persistentStorage as $o,devToolsStorageKeys as lc}from"@buoy-gg/shared-ui/web";import{dispatchToolAction as pn}from"@buoy-gg/shared-ui/web";var ac=[{re:/\bBearer\s+[A-Za-z0-9._~+/-]{12,}=*/gi,label:"[bearer token removed]"},{re:/\beyJ[A-Za-z0-9._-]{20,}/g,label:"[jwt removed]"},{re:/\bsk-[A-Za-z0-9_-]{16,}/g,label:"[api key removed]"},{re:/\bBUOY-[A-Z0-9-]{8,}/g,label:"[license key removed]"},{re:/("|')?(authorization|x-api-key|api[_-]?key|password|secret|access_token|refresh_token)\1?\s*[:=]\s*("|')?(?!(?:authorization|bearer|cookie|header)\b)[^\s"',}]{6,}/gi,label:"[credential removed]"}];function Ut(e){if(!e)return e;let t=e;for(let{re:o,label:r}of ac)t=t.replace(o,r);return t}var Ao=`${lc.base}_ask_buoy_transcript`,Bo=1,hn=60,sc=256e3,cc="[not kept across a restart \u2014 read it again if you need it]";function nt(e){return e&&Ut(e)}function dc(e){let t=e.streaming===true;return{...e,text:nt(e.text),streaming:false,reasoning:e.reasoning?.map(o=>({...o,text:nt(o.text)})),toolCalls:e.toolCalls.map(o=>{let r=o.params?nt(o.params):void 0,{result:n,...i}=o;return o.status==="running"?{...i,params:r,status:"failed",summary:"Interrupted"}:{...i,params:r}}),error:e.error??(t&&!e.text?"This answer was interrupted \u2014 the app restarted mid-turn.":void 0)}}function uc(e){return e.map(t=>t.role==="tool-results"?{...t,results:t.results.map(o=>({...o,content:cc}))}:t.role==="assistant"?{...t,text:nt(t.text)}:{...t,text:nt(t.text)})}function pc(e){let t={...e,messages:e.messages.slice(-hn),history:e.history.slice(-hn*2)},o=JSON.stringify(t);for(;o.length>sc&&t.messages.length>1;)t={...t,messages:t.messages.slice(1),history:t.history.slice(Math.min(2,t.history.length))},o=JSON.stringify(t);return t}function hc(e){if(!e)return null;let t=e.params;if(!t)return null;let o;try{o=JSON.stringify(t)}catch{return null}return Ut(o)!==o?null:{id:e.id,toolId:e.toolId,action:e.action,label:nt(e.label),description:e.description?nt(e.description):void 0,reason:nt(e.reason),params:t,targetDigest:e.targetDigest}}function gc(e){if(typeof e!="object"||e===null)return false;let t=e;return typeof t.id=="string"&&typeof t.toolId=="string"&&typeof t.action=="string"&&typeof t.label=="string"&&typeof t.reason=="string"&&typeof t.params=="object"&&t.params!==null}function fc(e){if(!e?.length)return;let t=e.filter(o=>{try{let r=JSON.stringify(o);return Ut(r)===r}catch{return false}});return t.length?t:void 0}function bc(e){return pc({v:Bo,savedAt:Date.now(),messages:e.messages.map(dc),history:uc(e.history),answers:e.answers,usage:e.usage,pending:hc(e.pending),ledger:fc(e.ledger),queued:e.queued?.length?e.queued.map(t=>({id:t.id,text:nt(t.text)})):void 0})}function yc(e){if(!e)return null;try{let t=JSON.parse(e);return t?.v!==Bo||!Array.isArray(t.messages)||t.messages.length===0?null:{v:Bo,savedAt:typeof t.savedAt=="number"?t.savedAt:0,messages:t.messages,history:Array.isArray(t.history)?t.history:[],answers:t.answers??{},usage:t.usage??{input:0,output:0,requests:0},pending:gc(t.pending)?t.pending:null,ledger:Array.isArray(t.ledger)?t.ledger.filter(o=>typeof o=="object"&&o!==null&&typeof o.id=="string"):void 0,queued:Array.isArray(t.queued)?t.queued.filter(o=>typeof o=="object"&&o!==null&&typeof o.id=="string"&&typeof o.text=="string"):void 0}}catch{return null}}async function mc(){try{return yc(await $o.getItem(Ao))}catch{return null}}async function xc(e){try{await $o.setItem(Ao,JSON.stringify(e))}catch{}}async function kc(){try{await $o.removeItem(Ao)}catch{}}function Ho(){b.getHeldSession()?.session.reset(),b.reset(),kc()}async function gn(e){if(b.getState().busy)return{cleared:false,reverted:0,failed:[{label:"A turn is running",error:"Stop it first."}]};let t=b.getLedger();if(e.undoFirst&&t){let o=await t.revertAll(e.dispatch);return o.failed.length>0?{cleared:false,reverted:o.reverted,failed:o.failed}:(Ho(),{cleared:true,reverted:o.reverted,failed:[]})}return Ho(),{cleared:true,reverted:0,failed:[]}}var Kt=typeof Xt<"u"&&!Xt;function wc(e){for(let t of b.getState().messages)if(t.restored)for(let o of t.blocks){let r=o.block;if(r?.id!==e)continue;let n=r.question??r.label??r.title;return typeof n=="string"&&n.trim()?n.trim():void 0}}function fn(){try{let e=oc();for(let t of tc())e[t]||(e[t]=[]),e[t].includes(un)||(e[t]=[un,...e[t]]);return e}catch{return{}}}var vc=600;function Lo(){return ec(b.subscribe,b.getState,b.getState)}function bn(e){let t=Lo(),o=Ys()(),r=St(o);r.current=o;let n=De((...S)=>!_t()||!r.current?Promise.reject(new Error("Ask Buoy requires Pro access.")):an(...S),[]),i=St(null),a=St(false),h=St(null),u=St(e);u.current=e;let g=!!e?.endpoint&&!!e?.model,y=e?.persistTranscript!==false,{bypassApprovals:C,readOnly:j}=Ht(),M=St(C);M.current=C;let X=St(j);X.current=j;let ee=De(()=>X.current?{...e?.policy??{},readOnly:true}:e?.policy??{},[e]),[ke,Ge]=Zs(0);ht(()=>{let S=false;return sn().then(()=>{S||Ge(V=>V+1)}),()=>{S=true}},[]);let Re=Xs(()=>fn(),[ke]),Je=Object.keys(Re).sort().join(",");ht(()=>{if(b.setConfigured(g),b.setMeta({model:e?.model,protocol:e?.protocol??(e?"anthropic":void 0),appName:e?.appName,platform:$t.OS,build:Kt?"release":"development"}),!g||!e){i.current=null,b.setNotice("Ask Buoy isn't set up in this app yet. A developer needs to point it at your team's AI endpoint.");return}let S=e.protocol??"anthropic";Kt&&e.apiKey?b.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."):S==="anthropic"&&/^https?:\/\/api\.openai\.com\//i.test(e.endpoint)?b.setNotice('This endpoint is api.openai.com but the protocol is "anthropic". Set protocol: "openai" in the askBuoy config.'):S==="openai"&&/^https?:\/\/api\.anthropic\.com\//i.test(e.endpoint)?b.setNotice('This endpoint is api.anthropic.com but the protocol is "openai". Remove protocol or set it to "anthropic".'):b.setNotice(null),b.setReporter(e.reportProblem??null),b.setUsageReader(e.readUsage??null);let V=[e.endpoint,e.protocol??"anthropic",e.model].join("|"),_=b.getHeldSession();if(_&&_.signature===V){i.current=_.session,_.session.setAvailableActions(Re),_.session.setApprovalBypass(M.current),_.session.setReadOnly(X.current),b.setLedger(_.session.ledger);return}let ne=nc({endpoint:e.endpoint,protocol:e.protocol??"anthropic",model:e.model,headers:e.headers,apiKey:e.apiKey,maxTokens:e.maxTokens,anthropicVersion:e.anthropicVersion,requestOverrides:e.requestOverrides,hosted:e.hosted===true,catalog:e.tools?.length?[...Ro,...e.tools]:void 0,dispatch:n,readSnapshot:rc,availableActions:Re,policy:e.policy,context:e.context,isRelease:Kt,appName:e.appName,platform:$t.OS,requestApproval:te=>b.askApproval(te)});i.current=ne,ne.setApprovalBypass(M.current),ne.setReadOnly(X.current),b.holdSession(ne,V),b.setLedger(ne.ledger);let Se=false;return sn().then(te=>{te&&!Se&&ne.prime()}),y&&!a.current&&(a.current=true,mc().then(te=>{!te||!b.hydrate({messages:te.messages,answers:te.answers,usage:te.usage,queued:te.queued})||(i.current?.restore(te.history),te.ledger?.length&&i.current?.ledger.restore(te.ledger),te.pending&&b.restorePending(te.pending))})),()=>{Se=true}},[g,e,Re,Je,y]),ht(()=>{i.current?.setApprovalBypass(C)},[C]),ht(()=>{i.current?.setReadOnly(j)},[j]);let Ye=t.messages,ft=t.answers,bt=t.usage,It=t.busy,qe=t.pending,at=t.queued;ht(()=>{if(!y||Ye.length===0)return;let S=()=>{xc(bc({messages:Ye,history:i.current?.messages??[],answers:ft,usage:bt,pending:qe,ledger:b.getLedger()?.list(),queued:at}))};if(!It){S();return}let V=setTimeout(S,vc);return()=>clearTimeout(V)},[y,It,Ye,ft,bt,qe,at]);let st=De(S=>{if(!_t()||!r.current)return;let V=i.current;if(!V)return;b.beginTurn();let _=b.startAssistant(),ne=new AbortController;h.current=ne,V.setAvailableActions(fn());let Se=u.current?.onEvent;(async()=>{try{for await(let te of V.send(S,ne.signal))if(b.applyEvent(_,te),Se)try{Se(te)}catch{}}catch(te){ne.signal.aborted||b.applyEvent(_,{type:"error",message:te instanceof Error?te.message:"Something went wrong talking to your AI endpoint."})}finally{ne.signal.aborted&&b.markStopped(_),b.finishAssistant(_),h.current=null}})()},[]),Qe=De(S=>{if(!_t()||!r.current)return;let V=S.trim();if(!i.current||!V)return;if(b.getState().busy){b.enqueue(V);return}let _=b.getState().awaitingBlockId;_&&b.recordAnswer({blockId:_,kind:"skipped"}),b.addUser(V),st(V)},[st]),yt=De(()=>{let{messages:S,busy:V}=b.getState();if(V||!i.current)return;let _=[...S].reverse().find(ne=>ne.role==="user");_&&st(_.text)},[st]),Xe=De(()=>{b.requestStop(),b.getState().pending&&b.answerApproval(false),h.current?.abort(),h.current=null},[]);ht(()=>{let S=Qs(()=>{_t()||Xe()});return()=>{S(),Xe()}},[Xe]),ht(()=>{o||Xe()},[o,Xe]),ht(()=>{if(t.queued.length===0||nn(t)!=="idle"||ln(t)!==null)return;let S=b.shiftQueued();S&&Qe(S.text)},[t,Qe]);let Ie=De(S=>b.takeQueuedToDraft(S),[]),zt=De(S=>b.removeQueued(S),[]),Jt=De(()=>{h.current?.abort(),h.current=null,Ho()},[]),so=De(()=>gn({dispatch:an,undoFirst:true}),[]),Yt=De(async S=>{let V=b.getLedger();if(!V){b.setNotice(`${S.label} couldn't run \u2014 no active Ask Buoy session.`);return}let _=e?.tools?.length?[...Ro,...e.tools]:void 0;if(S.targetDigest){let Se=await ic({toolId:S.toolId,action:S.action,params:S.params??{},dispatch:n,catalog:_});if(Se!==void 0&&Se!==S.targetDigest){b.addNote(`\u201C${S.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}}let ne=await dn({toolId:S.toolId,action:S.action,params:S.params??{},dispatch:n,ledger:V,policy:ee(),isRelease:Kt,catalog:_});ne.ok?b.addNote(`Applied \u201C${S.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.`):b.setNotice(`${S.label} failed \u2014 ${ne.error}`)},[e,ee]),co=De(S=>{let V=b.getState().pending,_=typeof S=="boolean"?S:S.approved;if(b.answerApproval(S),!!V?.restored){if(!_){b.addNote(`Skipped \u201C${V.label}\u201D. Nothing was changed.`);return}Yt(V)}},[Yt]),uo=De(S=>{b.recordAnswer(S);let V=wc(S.blockId);Qe(V?`${V} \u2014 ${cn(S)}`:cn(S))},[Qe]),po=De(async(S,V)=>{if(!_t()||!r.current){b.setNotice("Ask Buoy requires Pro access.");return}if(S.send){Qe(S.send);return}if(!S.dispatch)return;let _=`${V}:${S.label}`,ne=b.getLedger();if(!ne){b.setNotice(`${S.label} failed \u2014 no active Ask Buoy session.`);return}b.setActionState(_,"running");let Se=await dn({toolId:S.dispatch.toolId,action:S.dispatch.action,params:S.dispatch.params??{},dispatch:n,ledger:ne,policy:ee(),isRelease:Kt,catalog:e?.tools?.length?[...Ro,...e.tools]:void 0});Se.ok?b.setActionState(_,"done"):(b.setActionState(_,"failed"),b.setNotice(`${S.label} failed \u2014 ${Se.error}`))},[Qe,e,ee]);return{state:t,send:Qe,stop:Xe,reset:Jt,undoThenReset:so,approve:co,retry:yt,answer:uo,runAction:po,editQueued:Ie,removeQueued:zt,configured:g,toolCount:Object.keys(Re).length,availableToolIds:Object.keys(Re)}}import{Fragment as Sc,jsx as ue,jsxs as it}from"react/jsx-runtime";function yn(){let e=Ht(),t=Lo().trusted;return it(Fe,{style:re.scroll,contentContainerStyle:re.content,testID:"buoy-ask-buoy-settings",children:[ue(Cc,{}),ue(l,{style:re.section,children:"CHAT"}),ue(vo,{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:o=>pt.set("showThinking",o)}),ue(l,{style:re.note,children:"Not every model reports reasoning. Claude thinks by default; most OpenAI models return none, and the strip then shows the steps alone."}),ue(l,{style:re.section,children:"PERMISSIONS"}),ue(vo,{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:o=>pt.set("readOnly",o)}),e.readOnly?ue(l,{style:re.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,ue(vo,{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:o=>pt.set("bypassApprovals",o)}),e.bypassApprovals&&!e.readOnly?it(s,{style:re.warning,testID:"buoy-ask-buoy-bypass-warning",children:[ue(Fs,{size:14,color:de.color.warning}),ue(l,{style:re.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."})]}):ue(l,{style:re.note,children:"On by default for destructive actions only \u2014 reads and ordinary writes already run without asking, and the changes bar records them."}),t.length>0?it(s,{style:re.trustedBox,testID:"buoy-ask-buoy-trusted",children:[ue(l,{style:re.section,children:"ALLOWED WITHOUT ASKING \u2014 THIS CHAT"}),t.map(o=>it(s,{style:re.trustedRow,children:[ue(l,{style:re.trustedLabel,numberOfLines:2,children:o.label}),ue(m,{testID:`buoy-ask-buoy-untrust-${o.key}`,accessibilityRole:"button",onPress:()=>b.untrust(o.key),style:({pressed:r})=>[re.forget,r&&{opacity:.7}],hitSlop:6,children:ue(l,{style:re.forgetText,children:"Ask again"})})]},o.key))]}):null]})}function Tc(e){let t=Date.parse(e.length===10?`${e}T00:00:00Z`:e);if(Number.isNaN(t))return e;let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=new Date(t);return`${o[r.getUTCMonth()]} ${r.getUTCDate()}`}function Cc(){let e=b.getUsageReader(),[t,o]=Ms({kind:"loading"}),r=js(()=>{e&&(o({kind:"loading"}),e().then(n=>o({kind:"ok",usage:n})).catch(n=>o({kind:"error",message:n instanceof Error?n.message:"Could not load credits."})))},[e]);return qs(r,[r]),e?it(s,{testID:"buoy-ask-buoy-credits",children:[ue(l,{style:re.section,children:"HOSTED AI CREDITS"}),it(s,{style:re.trustedRow,children:[ue(s,{style:{flex:1,gap:2},children:t.kind==="ok"?it(Sc,{children:[it(l,{style:re.trustedLabel,children:[t.usage.creditsLeft.toLocaleString()," of ",t.usage.grantCredits.toLocaleString()," credits left"]}),it(l,{style:re.note,children:[t.usage.resetAt?`Resets ${Tc(t.usage.resetAt)}. `:"","1 credit is $0.001 of AI use, included with your plan."]})]}):t.kind==="error"?ue(l,{style:re.note,children:t.message}):ue(l,{style:re.note,children:"Loading\u2026"})}),ue(m,{testID:"buoy-ask-buoy-credits-refresh",accessibilityRole:"button",onPress:r,style:({pressed:n})=>[re.forget,n&&{opacity:.7}],hitSlop:6,children:ue(l,{style:re.forgetText,children:"Refresh"})})]})]}):null}var re=w.create({scroll:{flex:1},content:{padding:de.gutter,gap:10,paddingBottom:32},section:{color:de.color.textTertiary,fontSize:10,fontWeight:"700",letterSpacing:.6,paddingHorizontal:4,paddingTop:4},warning:{flexDirection:"row",gap:8,padding:de.cardPad,borderRadius:de.radius.card,borderWidth:w.hairlineWidth,borderColor:de.color.warning,backgroundColor:de.color.surface},warningText:{flex:1,color:de.color.warning,fontSize:de.font.micro,lineHeight:16},trustedBox:{gap:6,paddingTop:6},trustedRow:{flexDirection:"row",alignItems:"center",gap:10,padding:de.cardPad,borderRadius:de.radius.card,borderWidth:w.hairlineWidth,borderColor:de.color.border,backgroundColor:de.color.surface},trustedLabel:{flex:1,color:de.color.text,fontSize:de.font.caption,lineHeight:18},forget:{paddingHorizontal:10,paddingVertical:6,borderRadius:de.radius.row,backgroundColor:de.color.button},forgetText:{color:de.color.text,fontSize:de.font.micro,fontWeight:"600"},note:{color:de.color.textTertiary,fontSize:de.font.micro,lineHeight:16,paddingHorizontal:4}});import{ChevronRight as Ic,night as ve,NightSectionLabel as zc}from"@buoy-gg/shared-ui/web";var Dc=[{text:"Why is this screen empty?"},{text:"What did the last few network calls return?",needs:"network"},{text:"Show me what's saved for this user",needs:"storage"},{text:"Make the next request to this screen fail with a 500",needs:"network",write:true,devOnly:true},{text:"Who am I signed in as right now?"},{text:"Did anything crash or log an error recently?",needs:"console"}],Rc=4;function $c(e){let t=e.availableToolIds.length>0;return Dc.filter(o=>o.write&&e.readOnly||o.devOnly&&e.isRelease?false:o.needs?t&&e.availableToolIds.includes(o.needs):true).slice(0,Rc).map(o=>o.text)}import{jsx as je,jsxs as Gt}from"react/jsx-runtime";var mn=typeof Xt<"u"&&!Xt;function Ac({configured:e,onPick:t,availableToolIds:o=[],readOnly:r=false}){let n=$c({availableToolIds:o,readOnly:r,isRelease:mn});return e?Gt(s,{style:Ce.wrap,testID:"buoy-ask-buoy-empty",children:[je(l,{style:Ce.title,children:"Ask about this app"}),je(l,{style:Ce.body,children:"Ask what the app is doing right now, or tell it to change something. Anything it changes shows up in a bar at the top, with what can be undone."}),je(l,{style:Ce.buildLine,testID:"buoy-ask-buoy-build-line",children:mn?"Release build \u2014 reading, impersonation and navigation work; simulations (forcing server responses, driving the screen) need a dev build.":"Dev build \u2014 full simulation available."}),Gt(s,{style:Ce.group,children:[je(zc,{children:"Try asking"}),je(s,{style:Ce.card,children:n.map((i,a)=>je(Bc,{text:i,onPick:t,last:a===n.length-1},i))})]})]}):Gt(s,{style:Ce.wrap,testID:"buoy-ask-buoy-unconfigured",children:[je(l,{style:Ce.title,children:"Not set up yet"}),Gt(l,{style:Ce.body,children:["Ask Buoy talks to your own company's AI endpoint \u2014 nothing goes to Buoy. A developer needs to add the ",je(l,{style:Ce.code,children:"askBuoy"})," prop to"," ",je(l,{style:Ce.code,children:"<FloatingDevTools />"})," with your team's endpoint and model."]})]})}function Bc({text:e,onPick:t,last:o}){return Gt(m,{testID:`buoy-ask-buoy-suggestion-${e.slice(0,12)}`,accessibilityRole:"button",onPress:()=>t(e),style:({pressed:r})=>[Ce.row,!o&&Ce.rowDivider,r&&Ce.pressed],children:[je(l,{style:Ce.rowText,children:e}),je(Ic,{size:14,color:ve.color.textTertiary})]})}var Ce=w.create({wrap:{flex:1,justifyContent:"center",paddingHorizontal:ve.gutter,paddingVertical:24,gap:8},title:{color:ve.color.text,fontSize:22,fontWeight:"700",letterSpacing:-.3},body:{color:ve.color.textSecondary,fontSize:ve.font.body,lineHeight:20},code:{color:ve.color.text,fontFamily:"Menlo"},buildLine:{marginTop:8,color:ve.color.textTertiary,fontSize:ve.font.micro,lineHeight:15},group:{marginTop:ve.groupGap-8},card:{borderRadius:ve.radius.card,borderWidth:w.hairlineWidth,borderColor:ve.color.border,backgroundColor:ve.color.surface,overflow:"hidden"},row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:ve.rowPadH,paddingVertical:13},rowDivider:{borderBottomWidth:w.hairlineWidth,borderBottomColor:ve.color.separator},rowText:{flex:1,color:ve.color.text,fontSize:ve.font.body,lineHeight:19},pressed:{backgroundColor:ve.color.fill}});import{memo as Hc,useCallback as Tt,useEffect as Lc,useRef as Po,useState as Oo}from"react";import{AlertTriangle as Wo,Check as xn,ChevronDown as kn,ChevronRight as wn,Copy as Pc,night as k,X as Oc}from"@buoy-gg/shared-ui/web";import{toolTitle as Wc}from"@buoy-gg/agent-core/web";import{isAskBlock as Ec}from"@buoy-gg/agent-core/web";function Vc({block:e,forToolCallId:t}){if(!t)return false;let o="source"in e?e.source:void 0;return o==="live"||o==="mocked"}function Nc(e,t){let o=new Set(t),r=new Map,n=[],i=[];for(let a of e){if(Ec(a.block)){i.push(a);continue}if(Vc(a)&&o.has(a.forToolCallId)){let h=r.get(a.forToolCallId)??[];h.push(a.block),r.set(a.forToolCallId,h)}else n.push(a)}return{nested:r,afterText:n,ask:i}}import{useState as vn}from"react";import{Activity as jc,ChevronDown as qc,ChevronRight as Mc,night as Q}from"@buoy-gg/shared-ui/web";function Eo(e){let t=[...e.reasoning??[]].sort((i,a)=>i.afterCalls-a.afterCalls),o=[],r=0,n=i=>{for(;r<t.length&&t[r].afterCalls<=i;)o.push({kind:"thought",text:t[r].text}),r+=1};return e.toolCalls.forEach((i,a)=>{n(a),o.push({kind:"step",n:a+1,call:i})}),n(e.toolCalls.length),o}function Sn(e){return(e.reasoning?.length??0)>0||e.toolCalls.length>0}var Fc=e=>e.status==="ok"?e.summary||"done":e.status==="running"?"running":`${e.status}${e.summary?` \u2014 ${e.summary}`:""}`;function Tn(e,t=" "){let o=[];for(let r of Eo(e))if(r.kind==="thought"){o.push(`${t}[thinking]`);for(let n of r.text.trim().split(`
11
- `))o.push(`${t} ${n}`)}else{let{n,call:i}=r;o.push(`${t}[${n}] ${i.toolId}.${i.action} \u2014 ${Fc(i)}`),i.params&&o.push(`${t} ${i.params}`)}return o}import{Fragment as _c,jsx as He,jsxs as lt}from"react/jsx-runtime";function Uc({n:e,call:t}){let[o,r]=vn(false),n=t.status==="failed"||t.status==="refused";return lt(m,{onPress:()=>r(i=>!i),accessibilityRole:"button",accessibilityState:{expanded:o},style:fe.step,children:[lt(s,{style:fe.stepLine,children:[He(l,{style:fe.stepN,children:e}),lt(l,{style:[fe.stepName,n&&fe.stepFailed],numberOfLines:1,children:[t.toolId,".",t.action]}),t.durationMs!==void 0?lt(l,{style:fe.stepMs,children:[t.durationMs,"ms"]}):null,He(l,{style:[fe.stepStatus,n&&fe.stepFailed],numberOfLines:1,children:t.status==="ok"?t.summary||"done":t.status})]}),o?lt(s,{style:fe.detail,children:[He(l,{style:fe.detailLabel,children:"SENT"}),He(l,{style:fe.code,selectable:true,children:t.params??"no parameters"}),t.result?lt(_c,{children:[He(l,{style:fe.detailLabel,children:"RETURNED"}),He(l,{style:fe.code,selectable:true,children:t.result})]}):null]}):null]})}function Cn({message:e}){let[t,o]=vn(false);if(!Sn(e))return null;let r=Eo(e),n=r.filter(u=>u.kind==="step").length,i=r.length-n,a=e.startedAt!==void 0&&e.endedAt!==void 0?`${((e.endedAt-e.startedAt)/1e3).toFixed(1)}s`:null,h=[n?`${n} step${n===1?"":"s"}`:null,i?`${i} thought${i===1?"":"s"}`:null,a,e.usage?`${e.usage.input+e.usage.output} tokens`:null].filter(Boolean).join(" \xB7 ");return lt(s,{style:fe.wrap,testID:"buoy-ask-buoy-thinking",children:[lt(m,{testID:"buoy-ask-buoy-thinking-toggle",onPress:()=>o(u=>!u),accessibilityRole:"button",accessibilityLabel:t?"Hide agent thinking":"Show agent thinking",accessibilityState:{expanded:t},style:fe.head,children:[He(jc,{size:12,color:Q.color.textTertiary}),He(l,{style:fe.headText,children:h}),t?He(qc,{size:12,color:Q.color.textTertiary}):He(Mc,{size:12,color:Q.color.textTertiary})]}),t?lt(s,{style:fe.body,children:[r.map((u,g)=>u.kind==="thought"?He(l,{style:fe.thought,selectable:true,children:u.text.trim()},`t${g}`):He(Uc,{n:u.n,call:u.call},u.call.id)),i===0?He(l,{style:fe.none,children:"This model reports no reasoning \u2014 the steps above are the whole trace."}):null]}):null]})}var fe=w.create({wrap:{marginTop:8,borderRadius:Q.radius.badge,borderWidth:w.hairlineWidth,borderColor:Q.color.separator,backgroundColor:Q.color.fill,overflow:"hidden"},head:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:7},headText:{flex:1,color:Q.color.textTertiary,fontSize:Q.font.micro,fontWeight:"600"},body:{borderTopWidth:w.hairlineWidth,borderTopColor:Q.color.separator},thought:{color:Q.color.textSecondary,fontSize:Q.font.micro,lineHeight:17,fontStyle:"italic",paddingHorizontal:10,paddingVertical:8},step:{paddingHorizontal:10,paddingVertical:7},stepLine:{flexDirection:"row",alignItems:"center",gap:8},stepN:{color:Q.color.textTertiary,fontSize:Q.font.micro,width:14},stepName:{flex:1,color:Q.color.textSecondary,fontSize:Q.font.micro,fontWeight:"600"},stepMs:{color:Q.color.textTertiary,fontSize:Q.font.micro},stepStatus:{color:Q.color.textTertiary,fontSize:Q.font.micro,maxWidth:110},stepFailed:{color:Q.color.danger},detail:{marginTop:6,marginLeft:22,gap:3},detailLabel:{color:Q.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5},code:{color:Q.color.textSecondary,fontSize:Q.font.micro,lineHeight:16,marginBottom:3},none:{color:Q.color.textTertiary,fontSize:Q.font.micro,fontStyle:"italic",paddingHorizontal:10,paddingVertical:8}});import{useEffect as Kc,useRef as Gc}from"react";import{night as Jc}from"@buoy-gg/shared-ui/web";import{jsx as In}from"react/jsx-runtime";function Yc(){let e=Gc([0,1,2].map(()=>new ce.Value(.25))).current;return Kc(()=>{let t=e.map((o,r)=>ce.loop(ce.sequence([ce.delay(r*140),ce.timing(o,{toValue:1,duration:320,easing:Rt.inOut(Rt.ease),useNativeDriver:true}),ce.timing(o,{toValue:.25,duration:320,easing:Rt.inOut(Rt.ease),useNativeDriver:true}),ce.delay((2-r)*140)])));return t.forEach(o=>o.start()),()=>t.forEach(o=>o.stop())},[e]),In(s,{style:zn.wrap,testID:"buoy-ask-buoy-typing",accessibilityLabel:"Thinking",children:e.map((t,o)=>In(ce.View,{style:[zn.dot,{opacity:t}]},o))})}var zn=w.create({wrap:{flexDirection:"row",alignItems:"center",gap:5,paddingVertical:8,paddingHorizontal:2},dot:{width:7,height:7,borderRadius:4,backgroundColor:Jc.color.textSecondary}});import{jsx as x,jsxs as be}from"react/jsx-runtime";function Dn({status:e}){switch(e){case"running":return x(Vt,{size:"small",color:k.color.textSecondary});case"ok":return x(s,{style:[f.mark,f.markOk],children:x(xn,{size:10,color:k.color.onAccent})});case"failed":return x(s,{style:[f.mark,f.markFailed],children:x(Oc,{size:10,color:k.color.text})});case"refused":return x(s,{style:[f.mark,f.markRefused],children:x(Wo,{size:10,color:k.color.onAccent})});case"declined":case"stopped":return x(s,{style:[f.mark,f.markNotRun],children:x(s,{style:f.markNotRunBar})})}}function Qc(e){return e.status==="running"?{text:"",tone:"muted"}:e.status==="refused"?{text:"Refused",tone:"warning"}:e.status==="failed"?{text:"Failed",tone:"danger"}:e.status==="declined"?{text:"You declined",tone:"muted"}:e.status==="stopped"?{text:"Not run \u2014 stopped",tone:"muted"}:e.verification?.status==="verified"?{text:"Verified",tone:"ok"}:e.verification?.status==="unverified"?{text:"Done \xB7 not yet visible",tone:"muted"}:e.verification?.status==="failed"?{text:"Done \xB7 check failed",tone:"warning"}:{text:e.summary||"Done",tone:"muted"}}var Xc=e=>e.status==="failed"||e.status==="refused"||e.status==="declined"||e.status==="stopped";function Rn({call:e,receipts:t,last:o}){let[r,n]=Oo(false),i=Qc(e),a=r?kn:wn,h=e.status==="failed"&&e.summary&&e.summary!=="Failed"?e.summary:null;return be(s,{style:[f.row,!o&&f.rowDivider],children:[be(m,{testID:`buoy-ask-buoy-tool-${e.toolId}`,accessibilityRole:"button",accessibilityLabel:`${e.label}, ${i.text||"running"}`,accessibilityState:{expanded:r},onPress:()=>n(u=>!u),children:[be(s,{style:f.rowLine,children:[x(s,{style:f.markSlot,children:x(Dn,{status:e.status})}),x(l,{style:f.rowTitle,children:e.label}),i.text?x(l,{style:[f.rowStatus,i.tone==="danger"&&f.rowStatusDanger,i.tone==="warning"&&f.rowStatusWarning,i.tone==="ok"&&f.rowStatusOk],numberOfLines:1,children:i.text}):null,x(a,{size:12,color:k.color.textTertiary})]}),r&&be(s,{style:f.rowDetail,children:[x(l,{style:f.rowTool,children:Wc(e.toolId).toUpperCase()}),e.description?x(l,{style:f.rowDescription,children:e.description}):null,h?x(l,{style:f.rowFailure,children:h}):null,e.verification?x(l,{style:[f.rowDescription,e.verification.status==="failed"&&f.rowFailure,e.verification.status==="verified"&&f.rowVerified],testID:`buoy-ask-buoy-verification-${e.verification.status}`,children:e.verification.detail}):null]})]}),r&&t.length>0&&x(s,{style:f.rowReceipts,testID:`buoy-ask-buoy-tool-receipt-${e.toolId}`,children:t.map(u=>x(no,{block:u},u.id))})]})}function Zc({label:e,count:t,calls:o,receipts:r,last:n}){let[i,a]=Oo(false),h=i?kn:wn;return be(s,{style:!n&&!i&&f.rowDivider,children:[x(m,{testID:"buoy-ask-buoy-reads-group",accessibilityRole:"button",accessibilityLabel:`${e}, ${t} reads`,accessibilityState:{expanded:i},onPress:()=>a(u=>!u),style:[f.row,i&&f.rowDivider],children:be(s,{style:f.rowLine,children:[x(s,{style:f.markSlot,children:x(Dn,{status:"ok"})}),x(l,{style:f.rowTitle,children:e}),be(l,{style:f.rowStatus,numberOfLines:1,children:[t," reads"]}),x(h,{size:12,color:k.color.textTertiary})]})}),i&&x(s,{style:f.groupBody,children:o.map((u,g)=>x(Rn,{call:u,receipts:r.get(u.id)??[],last:n&&g===o.length-1},u.id))})]})}function ed({calls:e,receipts:t}){let o=Os(e);return x(s,{style:f.card,testID:"buoy-ask-buoy-activity",children:o.map((r,n)=>r.kind==="reads"?x(Zc,{label:r.label,count:r.count,calls:r.calls,receipts:t,last:n===o.length-1},r.id):x(Rn,{call:r.call,receipts:t.get(r.call.id)??[],last:n===o.length-1},r.call.id))})}function $n({blocks:e}){return e.length===0?null:x(s,{style:f.blocks,children:e.map(({block:t})=>x(no,{block:t},t.id))})}function td({message:e}){return x(s,{style:f.systemLine,testID:"buoy-ask-buoy-system-line",children:x(l,{style:f.systemText,children:e.text})})}function od({message:e}){return x(s,{style:f.userWrap,children:x(s,{style:f.userBubble,children:x(l,{style:f.userText,selectable:true,children:e.text})})})}function rd({message:e,onRetry:t,waitingOnUser:o}){let{showThinking:r}=Ht(),n=!!e.streaming&&!o,{nested:i,afterText:a,ask:h}=Nc(e.blocks,e.toolCalls.map(u=>u.id));return be(s,{style:f.assistantWrap,children:[e.toolCalls.length>0&&x(ed,{calls:e.toolCalls,receipts:i}),e.text.length>0&&x(yr,{text:e.text,style:f.assistantText}),x($n,{blocks:a}),x($n,{blocks:h}),r&&!e.streaming&&x(Cn,{message:e}),n&&be(s,{style:f.waitingRow,children:[x(Yc,{}),e.waiting?x(l,{style:f.waitingText,testID:"buoy-ask-buoy-waiting",children:e.waiting}):null]}),e.error&&(e.errorInfo?x(ad,{error:e.error,info:e.errorInfo,onRetry:t}):x(id,{error:e.error,onRetry:t})),e.stopped&&!e.error&&x(nd,{onRetry:t,changed:e.toolCalls.some(u=>u.status==="ok"&&!!u.effect&&u.effect!=="read")})]})}function nd({onRetry:e,changed:t}){return be(s,{style:f.stoppedBox,testID:"buoy-ask-buoy-stopped",children:[x(l,{style:f.stoppedText,children:t?"Stopped. Changes already made are listed above.":"Stopped."}),e&&x(m,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:e,style:({pressed:o})=>[f.retry,o&&f.retryPressed],children:x(l,{style:f.retryText,children:"Try again"})})]})}function id({error:e,onRetry:t}){let o=/fetch failed|network|ECONN|timed? ?out|socket/i.test(e)?"Couldn't reach your AI endpoint. Check the connection and try again.":"Something went wrong with that turn.";return be(s,{style:f.errorBox,testID:"buoy-ask-buoy-error",children:[x(Wo,{size:14,color:k.color.danger}),be(s,{style:f.errorBody,children:[x(l,{style:f.errorText,children:o}),x(l,{style:f.errorDetail,selectable:true,children:e}),t&&x(m,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:t,style:({pressed:r})=>[f.retry,r&&f.retryPressed],children:x(l,{style:f.retryText,children:"Try again"})})]})]})}var ld=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 ad({error:e,info:t,onRetry:o}){let[r,n]=Oo("idle"),i=`Ask Buoy error ${t.code}${t.requestId?` \xB7 request ${t.requestId}`:""} \xB7 ${new Date().toISOString()}`,{copied:a,copy:h}=to(()=>i),u=b.getReporter(),g=Tt(()=>{u&&(n("sending"),u({requestId:t.requestId,code:t.code,note:"Reported from the error card."}).then(y=>n({id:y.reportId})).catch(()=>n("failed")))},[u,t.code,t.requestId]);return be(s,{style:f.errorBox,testID:"buoy-ask-buoy-error",children:[x(Wo,{size:14,color:k.color.danger}),be(s,{style:f.errorBody,children:[x(l,{style:f.errorText,children:e}),be(l,{style:f.errorDetail,selectable:true,testID:"buoy-ask-buoy-error-code",children:[t.code,t.requestId?` \xB7 ${t.requestId}`:""]}),be(s,{style:f.transcriptActions,children:[o&&!ld.has(t.code)&&x(m,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:o,style:({pressed:y})=>[f.retry,y&&f.retryPressed],children:x(l,{style:f.retryText,children:"Try again"})}),x(m,{testID:"buoy-ask-buoy-error-copy",accessibilityRole:"button",accessibilityLabel:"Copy details",onPress:h,style:({pressed:y})=>[f.retry,y&&f.retryPressed],children:x(l,{style:f.retryText,children:a?"Copied":"Copy details"})}),u&&x(m,{testID:"buoy-ask-buoy-error-report",accessibilityRole:"button",accessibilityLabel:"Report problem",disabled:r!=="idle"&&r!=="failed",onPress:g,style:({pressed:y})=>[f.retry,y&&f.retryPressed],children:x(l,{style:f.retryText,children:r==="sending"?"Sending\u2026":r==="failed"?"Report failed. Try again":typeof r=="object"?`Reported \xB7 ${r.id}`:"Report problem"})})]})]})]})}function An(e,t=false){let o=[];for(let 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(...Tn(r));else for(let n of r.toolCalls){let i=Xc(n)?` (${n.status})`:"";o.push(` \xB7 ${n.label}${n.summary?` \u2014 ${n.summary}`:""}${i}`)}r.text&&o.push(`Ask Buoy: ${r.text}`);for(let n of ql(r.blocks.map(i=>i.block)))o.push(n);r.error&&o.push(` ! ${r.error}`),r.stopped&&!r.error&&o.push(" ! Stopped by the user.")}return o.join(`
12
- `)}function sd({testID:e,label:t,getText:o}){let{copied:r,copy:n}=to(o);return be(m,{testID:e,accessibilityRole:"button",accessibilityLabel:t,onPress:n,style:({pressed:i})=>[f.copyBtn,f.iconBtn,i&&f.copyPressed],children:[r?x(xn,{size:11,color:k.color.accent}):x(Pc,{size:11,color:k.color.textSecondary}),x(l,{style:[f.copyText,r&&f.copiedText],children:r?"Copied":t})]})}function cd({message:e}){let{showThinking:t}=Ht(),o=Tt(()=>An(b.getState().messages,t),[t]),r=Es(e);return be(s,{style:f.transcriptActions,children:[r?x(l,{style:f.turnFooter,testID:"buoy-ask-buoy-turn-footer",children:r}):null,x(sd,{testID:"buoy-ask-buoy-copy",label:"Copy conversation",getText:o})]})}var dd=Hc(function({message:e,onRetry:t,waitingOnUser:o}){if(e.role==="user")return x(od,{message:e});if(e.system)return x(td,{message:e});let r=!e.streaming&&!e.error;return be(s,{children:[x(rd,{message:e,onRetry:t,waitingOnUser:o}),r&&x(cd,{message:e})]})});function Bn({messages:e,ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r,onRetry:n,waitingOnUser:i}){let a=Po(null),h=Po(true),u=Po(false),g=Tt(ke=>{let{contentOffset:Ge,contentSize:Re,layoutMeasurement:Je}=ke.nativeEvent,Ye=Re.height-Je.height-Ge.y;h.current=Ye<80},[]),y=Tt(()=>{u.current=true},[]),C=Tt(ke=>{u.current&&g(ke)},[g]),j=Tt(ke=>{u.current=false,g(ke)},[g]),M=Tt(()=>{h.current&&(a.current?.scrollToEnd({animated:false}),requestAnimationFrame(()=>a.current?.scrollToEnd({animated:false})))},[]),X=e[e.length-1],ee=X?`${X.id}:${X.text.length}:${X.toolCalls.length}:${X.error??""}`:"";return Lc(()=>{M()},[ee,M]),x(tr,{ref:a,testID:"buoy-ask-buoy-messages-scroll",style:f.list,contentContainerStyle:f.listContent,data:e,keyExtractor:ke=>ke.id,renderItem:({item:ke})=>x(dd,{message:ke,onRetry:ke.id===X?.id?n:void 0,waitingOnUser:ke.id===X?.id?i:false}),onScroll:C,onScrollBeginDrag:y,onScrollEndDrag:j,onMomentumScrollEnd:g,scrollEventThrottle:32,onContentSizeChange:M,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"interactive",ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r})}var f=w.create({list:{flex:1,backgroundColor:"transparent"},listContent:{paddingHorizontal:k.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:k.color.accentFill,borderWidth:w.hairlineWidth,borderColor:k.color.accentBorder},userText:{color:k.color.text,fontSize:k.font.row,lineHeight:21},systemLine:{alignSelf:"stretch",paddingHorizontal:12,paddingVertical:7,borderRadius:k.radius.row,backgroundColor:k.color.fill},systemText:{color:k.color.textSecondary,fontSize:k.font.micro,lineHeight:16,textAlign:"center"},assistantWrap:{alignItems:"stretch",gap:10},blocks:{gap:10},waitingRow:{flexDirection:"row",alignItems:"center",gap:8},waitingText:{color:k.color.textSecondary,fontSize:k.font.caption},assistantText:{color:k.color.text,fontSize:k.font.row,lineHeight:22,paddingHorizontal:2},card:{borderRadius:k.radius.card,borderWidth:w.hairlineWidth,borderColor:k.color.border,backgroundColor:k.color.surface,overflow:"hidden"},row:{paddingHorizontal:12,paddingVertical:10},rowDivider:{borderBottomWidth:w.hairlineWidth,borderBottomColor:k.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:k.color.accent},markFailed:{backgroundColor:k.color.danger},markRefused:{backgroundColor:k.color.warning},markNotRun:{borderWidth:1.5,borderColor:k.color.textTertiary},markNotRunBar:{width:7,height:1.5,borderRadius:1,backgroundColor:k.color.textSecondary},rowTitle:{flex:1,color:k.color.text,fontSize:k.font.body,lineHeight:19},rowStatus:{color:k.color.textTertiary,fontSize:k.font.caption,maxWidth:120},rowStatusDanger:{color:k.color.danger},rowStatusWarning:{color:k.color.warning},rowStatusOk:{color:k.color.accent},rowVerified:{color:k.color.accent},rowDetail:{paddingLeft:28,paddingTop:8,gap:4},rowTool:{color:k.color.textTertiary,fontSize:k.font.micro,fontWeight:"600",letterSpacing:.8},rowDescription:{color:k.color.textSecondary,fontSize:k.font.caption,lineHeight:18},rowFailure:{color:k.color.danger,fontSize:k.font.caption,lineHeight:18},rowReceipts:{paddingTop:10,gap:10},groupBody:{paddingLeft:14,backgroundColor:k.color.fill},stoppedBox:{alignItems:"flex-start",gap:2,paddingHorizontal:12,paddingVertical:8},stoppedText:{color:k.color.textTertiary,fontSize:k.font.caption,lineHeight:18},errorBox:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingVertical:10,borderRadius:k.radius.row,backgroundColor:k.color.dangerSoft},errorBody:{flex:1,gap:4},errorText:{color:k.color.danger,fontSize:k.font.caption,fontWeight:"600",lineHeight:18},errorDetail:{color:k.color.textSecondary,fontSize:k.font.micro,lineHeight:15},retry:{alignSelf:"flex-start",marginTop:6,paddingHorizontal:14,paddingVertical:7,borderRadius:k.radius.row,backgroundColor:k.color.button},retryPressed:{opacity:.7},retryText:{color:k.color.accent,fontSize:k.font.caption,fontWeight:"600"},transcriptActions:{flexDirection:"row",alignItems:"center",gap:10,marginTop:8},turnFooter:{flex:1,color:k.color.textTertiary,fontSize:k.font.micro,fontVariant:["tabular-nums"]},copyBtn:{paddingHorizontal:10,paddingVertical:5,borderRadius:k.radius.badge,backgroundColor:k.color.fill},iconBtn:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8},copyPressed:{opacity:.7},copyText:{color:k.color.textSecondary,fontSize:k.font.micro,fontWeight:"600"},copiedText:{color:k.color.accent}});import{night as Le,X as ud}from"@buoy-gg/shared-ui/web";import{jsx as Lt,jsxs as Vo}from"react/jsx-runtime";var pd=132;function hd({items:e,paused:t,onEdit:o,onRemove:r}){return e.length===0?null:Vo(s,{style:Pe.wrap,testID:"buoy-ask-buoy-queued",children:[Lt(Fe,{style:Pe.list,contentContainerStyle:Pe.listContent,keyboardShouldPersistTaps:"handled",children:e.map((n,i)=>Vo(s,{style:[Pe.row,t!==null&&Pe.rowPaused],children:[Vo(m,{testID:`buoy-ask-buoy-queue-item-${i}`,accessibilityRole:"button",accessibilityLabel:`Edit queued message: ${n.text}`,onPress:()=>o(n.id),style:({pressed:a})=>[Pe.rowBody,a&&Pe.pressed],children:[Lt(l,{style:Pe.ordinal,children:i===0?"NEXT":"THEN"}),Lt(l,{style:Pe.text,numberOfLines:3,children:n.text})]}),Lt(m,{testID:`buoy-ask-buoy-queue-remove-${i}`,accessibilityRole:"button",accessibilityLabel:"Remove queued message",onPress:()=>r(n.id),hitSlop:8,style:({pressed:a})=>[Pe.remove,a&&Pe.pressed],children:Lt(ud,{size:11,color:Le.color.textTertiary})})]},n.id))}),Lt(l,{style:[Pe.hint,t!==null&&Pe.hintPaused],testID:"buoy-ask-buoy-queue-hint",children:t??"Sends one at a time when this turn finishes \xB7 tap to edit"})]})}var Pe=w.create({wrap:{paddingHorizontal:Le.gutter,paddingTop:8,gap:6,backgroundColor:Le.color.bg},list:{maxHeight:pd},listContent:{gap:6},row:{flexDirection:"row",alignItems:"center",borderRadius:Le.radius.row,borderWidth:w.hairlineWidth,borderColor:Le.color.border,backgroundColor:Le.color.surface},rowPaused:{borderColor:Le.color.warning},rowBody:{flex:1,flexDirection:"row",alignItems:"center",gap:8,paddingVertical:7,paddingLeft:10},ordinal:{color:Le.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6,width:30},text:{flex:1,color:Le.color.textSecondary,fontSize:Le.font.caption,lineHeight:17},remove:{width:32,height:32,alignItems:"center",justifyContent:"center"},pressed:{opacity:.7},hint:{color:Le.color.textTertiary,fontSize:Le.font.micro},hintPaused:{color:Le.color.warning}});var gd="Summarize this conversation as a bug ticket, using one buoy_ui finding block and nothing else. Title it with the problem in one line. Evidence rows, in this order: Steps (what we did), Expected, Observed, Build (dev or release, platform), Evidence (the exact requests, statuses, logs or values you actually saw this conversation), Still applied (overrides or changes from your changes list that are still live, or 'none'). Only facts you observed in this conversation; write 'unknown' where you don't know rather than guessing, and put anything you inferred rather than saw in a final row labelled Inference. Do not run any tool or change anything to produce this.";import{Fragment as fd,jsx as pe,jsxs as Pt}from"react/jsx-runtime";function No({visible:e,onClose:t,onBack:o,onMinimize:r,persistenceKey:n,config:i}){let{state:a,send:h,stop:u,reset:g,undoThenReset:y,approve:C,retry:j,answer:M,runAction:X,editQueued:ee,removeQueued:ke,configured:Ge,toolCount:Re,availableToolIds:Je}=bn(i),[Ye,ft]=ho(false),bt=Me(()=>{u(),t()},[u,t]),It=Me(()=>b.clearDraft(),[]),[qe,at]=ho(false),st=Me(()=>at(false),[]),Qe=Me(()=>at(true),[]),yt=!e,Xe=!!a.pending||!!a.awaitingBlockId,Ie=a.messages[a.messages.length-1],zt=Wt(false),Jt=Wt(a.busy);Ot(()=>{yt&&Jt.current&&!a.busy&&(zt.current=true),yt||(zt.current=false),Jt.current=a.busy},[yt,a.busy]),Ot(()=>{if(!yt){At("ask-buoy",null);return}Xe?At("ask-buoy",{kind:"needsInput",label:a.pending?"Needs your approval":"Has a question for you"}):zt.current&&Ie?.role==="assistant"&&Ie.error?At("ask-buoy",{kind:"failed",label:"The last turn failed"}):zt.current&&!a.busy?At("ask-buoy",{kind:"done",label:"Finished"}):At("ask-buoy",null)},[yt,Xe,a.busy,a.pending,Ie]),Ot(()=>()=>At("ask-buoy",null),[]),Ot(()=>{a.pending&&qe&&at(false)},[a.pending,qe]);let so=Ui({minBottom:16}),[Yt,co]=ho("bottomSheet"),uo=Yt==="floating"?0:so.bottom,po=Me(()=>{let K=b.getLedger();K&&(async()=>{let ie=await K.revertAll(Mi);if(ie.failed.length===0){b.setNotice(null);return}let Dt=ie.failed.map(Qt=>`${Qt.label} (${Qt.error})`).join("; ");b.setNotice(`Couldn't undo ${ie.failed.length} change${ie.failed.length===1?"":"s"} \u2014 ${Dt}`)})()},[]),S=Me(()=>ft(K=>!K),[]),V=Wt(new ce.Value(560)).current,_=Wt(false),ne=Me(()=>{_.current||(_.current=true,V.stopAnimation(K=>{let ie=typeof K=="number"&&K>200?K:560;ce.timing(V,{toValue:120,duration:220,useNativeDriver:false}).start(()=>{setTimeout(()=>{ce.spring(V,{toValue:ie,friction:9,useNativeDriver:false}).start(()=>{_.current=false})},2500)})}))},[V]),Se=Zt(()=>{let K=a.messages[a.messages.length-1];if(!K||K.role!=="assistant")return"";let ie=K.blocks.filter(Dt=>Dt.block.kind==="peek").length;return ie>0?`${K.id}:${ie}`:""},[a.messages]),te=Wt("");Ot(()=>{Se&&Se!==te.current&&i?.peek!==false&&ne(),te.current=Se},[Se,ne,i]);let Vn=Me(()=>{let K=b.getLedger()?.list().filter(ie=>!ie.undoneAt&&qi(ie.effect)).length??0;if(K===0){g();return}fo.alert("Undo changes first?",`Ask Buoy made ${K} change${K===1?"":"s"} that can still be undone. Clearing the conversation loses the only automatic undo for ${K===1?"it":"them"}.`,[{text:"Undo, then clear",onPress:()=>{(async()=>{let ie=await y();if(ie.cleared)return;let Dt=ie.reverted+ie.failed.length,Qt=ie.failed.map(Yo=>`${Yo.label} (${Yo.error})`).join(`
13
- `);fo.alert(`Couldn't undo ${ie.failed.length} of ${Dt} change${Dt===1?"":"s"}`,`${Qt}
10
+ ${t.delta}`:r.text+t.delta,breakBeforeNextText:false};case"reasoning":return{...r,breakBeforeNextText:true,reasoning:[...r.reasoning??[],{text:t.text,afterCalls:r.toolCalls.length}]};case"tool-start":return{...r,waiting:void 0,toolCalls:[...r.toolCalls,{id:t.id,toolId:t.toolId,action:t.action,label:t.label,description:t.description,status:"running",params:Gs(t.params),effect:t.effect,startedAt:Ft()}]};case"tool-end":return{...r,breakBeforeNextText:true,toolCalls:r.toolCalls.map(n=>n.id===t.id?{...n,status:!t.ok&&t.summary==="refused"?"refused":!t.ok&&t.summary==="declined"?"declined":!t.ok&&t.summary==="stopped"?"stopped":t.ok?"ok":"failed",summary:t.summary,durationMs:t.durationMs,result:t.result}:n)};case"tool-verified":return{...r,toolCalls:r.toolCalls.map(n=>n.id===t.id?{...n,verification:t.verification}:n)};case"block":return{...r,breakBeforeNextText:true,blocks:[...r.blocks,{block:t.block,forToolCallId:t.forToolCallId}]};case"usage":return{...r,usage:{input:(r.usage?.input??0)+t.input,output:(r.usage?.output??0)+t.output,requests:(r.usage?.requests??0)+1}};case"error":return{...r,waiting:void 0,error:t.message,...t.hosted?{errorInfo:{code:t.hosted.code,requestId:t.hosted.request_id,action:t.hosted.action,resetAt:t.hosted.reset_at,helpUrl:t.hosted.help_url}}:{}};default:return r}});Q({messages:o,...t.type==="awaiting-user"?{awaitingBlockId:t.blockId}:{},...t.type==="meter"&&t.frame.phase==="end"?{credits:{left:t.frame.credits_left??H.credits?.left??null,resetAt:t.frame.credits_reset??H.credits?.resetAt??null,pending:t.frame.pending===true}}:{},...t.type==="usage"?{usage:{input:H.usage.input+t.input,output:H.usage.output+t.output,requests:H.usage.requests+1}}:{}})},markStopped(e){Q({messages:H.messages.map(t=>t.id===e?{...t,stopped:true}:t)})},finishAssistant(e){Q({messages:H.messages.map(t=>t.id===e?{...t,streaming:false,endedAt:Ft()}:t),busy:false,stopping:false})},askApproval(e){return new Promise(t=>{Q({pending:{...e,resolve:t}})})},answerApproval(e){let t=H.pending,o=typeof e=="boolean"?e:e.approved,r=typeof e!="boolean"&&e.trust===true&&o,n=t?`${t.toolId}.${t.action}`:"";Q({pending:null,...r&&t&&!H.trusted.some(i=>i.key===n)?{trusted:[...H.trusted,{key:n,label:t.label}]}:{}}),t?.resolve(e)},untrust(e){Do?.session.untrust(e),Q({trusted:H.trusted.filter(t=>t.key!==e)})},restorePending(e){return H.pending||H.busy?false:(Q({pending:{...e,restored:true,resolve:()=>{}}}),true)},addNote(e){Q({messages:[...H.messages,{id:lo(),role:"assistant",text:e,toolCalls:[],blocks:[],endedAt:Ft()}]})},hydrate(e){return H.messages.length>0||H.busy?false:(Q({messages:e.messages.map(t=>({...t,restored:true})),answers:e.answers,usage:e.usage,queued:e.queued??[]}),true)},reset(){H.pending?.resolve(false),Q({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 nn(e){return e.pending?"awaitingApproval":e.busy?e.stopping?"stopping":"running":e.awaitingBlockId?"awaitingAnswer":"idle"}function ln(e){let t=nn(e);if(t==="running"||t==="stopping")return null;if(t==="awaitingApproval")return"Paused \u2014 answer the approval above first.";if(t==="awaitingAnswer")return"Paused \u2014 answer the question above first.";let o=e.messages[e.messages.length-1];return o?.role==="assistant"&&o.error?"Paused \u2014 the last turn failed.":o?.role==="assistant"&&o.stopped?"Paused \u2014 you stopped the last turn.":null}import{getUseIsPro as Qs,hasAccountAccess as _t,subscribeAccountAccess as Ys}from"@buoy-gg/shared-ui/web";import{useCallback as De,useEffect as ht,useMemo as Xs,useRef as St,useState as Zs,useSyncExternalStore as ec}from"react";import{dispatchToolAction as an,listSnapshotToolIds as tc,listToolActions as oc,readToolSnapshot as rc,waitForToolRegistry as sn}from"@buoy-gg/shared-ui/web";import{answerToText as cn,CATALOG as Ro,createAskBuoySession as nc,readTargetDigest as ic,runGatedAction as dn,SNAPSHOT_ACTION as un}from"@buoy-gg/agent-core/web";import{persistentStorage as $o,devToolsStorageKeys as lc}from"@buoy-gg/shared-ui/web";import{dispatchToolAction as pn}from"@buoy-gg/shared-ui/web";var ac=[{re:/\bBearer\s+[A-Za-z0-9._~+/-]{12,}=*/gi,label:"[bearer token removed]"},{re:/\beyJ[A-Za-z0-9._-]{20,}/g,label:"[jwt removed]"},{re:/\bsk-[A-Za-z0-9_-]{16,}/g,label:"[api key removed]"},{re:/\bBUOY-[A-Z0-9-]{8,}/g,label:"[license key removed]"},{re:/("|')?(authorization|x-api-key|api[_-]?key|password|secret|access_token|refresh_token)\1?\s*[:=]\s*("|')?(?!(?:authorization|bearer|cookie|header)\b)[^\s"',}]{6,}/gi,label:"[credential removed]"}];function Ut(e){if(!e)return e;let t=e;for(let{re:o,label:r}of ac)t=t.replace(o,r);return t}var Ao=`${lc.base}_ask_buoy_transcript`,Bo=1,hn=60,sc=256e3,cc="[not kept across a restart \u2014 read it again if you need it]";function nt(e){return e&&Ut(e)}function dc(e){let t=e.streaming===true;return{...e,text:nt(e.text),streaming:false,reasoning:e.reasoning?.map(o=>({...o,text:nt(o.text)})),toolCalls:e.toolCalls.map(o=>{let r=o.params?nt(o.params):void 0,{result:n,...i}=o;return o.status==="running"?{...i,params:r,status:"failed",summary:"Interrupted"}:{...i,params:r}}),error:e.error??(t&&!e.text?"This answer was interrupted \u2014 the app restarted mid-turn.":void 0)}}function uc(e){return e.map(t=>t.role==="tool-results"?{...t,results:t.results.map(o=>({...o,content:cc}))}:t.role==="assistant"?{...t,text:nt(t.text)}:{...t,text:nt(t.text)})}function pc(e){let t={...e,messages:e.messages.slice(-hn),history:e.history.slice(-hn*2)},o=JSON.stringify(t);for(;o.length>sc&&t.messages.length>1;)t={...t,messages:t.messages.slice(1),history:t.history.slice(Math.min(2,t.history.length))},o=JSON.stringify(t);return t}function hc(e){if(!e)return null;let t=e.params;if(!t)return null;let o;try{o=JSON.stringify(t)}catch{return null}return Ut(o)!==o?null:{id:e.id,toolId:e.toolId,action:e.action,label:nt(e.label),description:e.description?nt(e.description):void 0,reason:nt(e.reason),params:t,targetDigest:e.targetDigest}}function gc(e){if(typeof e!="object"||e===null)return false;let t=e;return typeof t.id=="string"&&typeof t.toolId=="string"&&typeof t.action=="string"&&typeof t.label=="string"&&typeof t.reason=="string"&&typeof t.params=="object"&&t.params!==null}function fc(e){if(!e?.length)return;let t=e.filter(o=>{try{let r=JSON.stringify(o);return Ut(r)===r}catch{return false}});return t.length?t:void 0}function bc(e){return pc({v:Bo,savedAt:Date.now(),messages:e.messages.map(dc),history:uc(e.history),answers:e.answers,usage:e.usage,pending:hc(e.pending),ledger:fc(e.ledger),queued:e.queued?.length?e.queued.map(t=>({id:t.id,text:nt(t.text)})):void 0})}function yc(e){if(!e)return null;try{let t=JSON.parse(e);return t?.v!==Bo||!Array.isArray(t.messages)||t.messages.length===0?null:{v:Bo,savedAt:typeof t.savedAt=="number"?t.savedAt:0,messages:t.messages,history:Array.isArray(t.history)?t.history:[],answers:t.answers??{},usage:t.usage??{input:0,output:0,requests:0},pending:gc(t.pending)?t.pending:null,ledger:Array.isArray(t.ledger)?t.ledger.filter(o=>typeof o=="object"&&o!==null&&typeof o.id=="string"):void 0,queued:Array.isArray(t.queued)?t.queued.filter(o=>typeof o=="object"&&o!==null&&typeof o.id=="string"&&typeof o.text=="string"):void 0}}catch{return null}}async function mc(){try{return yc(await $o.getItem(Ao))}catch{return null}}async function xc(e){try{await $o.setItem(Ao,JSON.stringify(e))}catch{}}async function kc(){try{await $o.removeItem(Ao)}catch{}}function Ho(){b.getHeldSession()?.session.reset(),b.reset(),kc()}async function gn(e){if(b.getState().busy)return{cleared:false,reverted:0,failed:[{label:"A turn is running",error:"Stop it first."}]};let t=b.getLedger();if(e.undoFirst&&t){let o=await t.revertAll(e.dispatch);return o.failed.length>0?{cleared:false,reverted:o.reverted,failed:o.failed}:(Ho(),{cleared:true,reverted:o.reverted,failed:[]})}return Ho(),{cleared:true,reverted:0,failed:[]}}var Kt=typeof Xt<"u"&&!Xt;function wc(e){for(let t of b.getState().messages)if(t.restored)for(let o of t.blocks){let r=o.block;if(r?.id!==e)continue;let n=r.question??r.label??r.title;return typeof n=="string"&&n.trim()?n.trim():void 0}}function fn(){try{let e=oc();for(let t of tc())e[t]||(e[t]=[]),e[t].includes(un)||(e[t]=[un,...e[t]]);return e}catch{return{}}}var vc=600;function Lo(){return ec(b.subscribe,b.getState,b.getState)}function bn(e){let t=Lo(),o=Qs()(),r=St(o);r.current=o;let n=De((...S)=>!_t()||!r.current?Promise.reject(new Error("Ask Buoy requires Pro access.")):an(...S),[]),i=St(null),a=St(false),h=St(null),u=St(e);u.current=e;let g=!!e?.endpoint&&!!e?.model,y=e?.persistTranscript!==false,{bypassApprovals:C,readOnly:j}=Ht(),M=St(C);M.current=C;let X=St(j);X.current=j;let ee=De(()=>X.current?{...e?.policy??{},readOnly:true}:e?.policy??{},[e]),[ke,Ge]=Zs(0);ht(()=>{let S=false;return sn().then(()=>{S||Ge(V=>V+1)}),()=>{S=true}},[]);let Re=Xs(()=>fn(),[ke]),Je=Object.keys(Re).sort().join(",");ht(()=>{if(b.setConfigured(g),b.setMeta({model:e?.model,protocol:e?.protocol??(e?"anthropic":void 0),appName:e?.appName,platform:$t.OS,build:Kt?"release":"development"}),!g||!e){i.current=null,b.setNotice("Ask Buoy isn't set up in this app yet. A developer needs to point it at your team's AI endpoint.");return}let S=e.protocol??"anthropic";Kt&&e.apiKey?b.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."):S==="anthropic"&&/^https?:\/\/api\.openai\.com\//i.test(e.endpoint)?b.setNotice('This endpoint is api.openai.com but the protocol is "anthropic". Set protocol: "openai" in the askBuoy config.'):S==="openai"&&/^https?:\/\/api\.anthropic\.com\//i.test(e.endpoint)?b.setNotice('This endpoint is api.anthropic.com but the protocol is "openai". Remove protocol or set it to "anthropic".'):b.setNotice(null),b.setReporter(e.reportProblem??null),b.setUsageReader(e.readUsage??null);let V=[e.endpoint,e.protocol??"anthropic",e.model].join("|"),_=b.getHeldSession();if(_&&_.signature===V){i.current=_.session,_.session.setAvailableActions(Re),_.session.setApprovalBypass(M.current),_.session.setReadOnly(X.current),b.setLedger(_.session.ledger);return}let ne=nc({endpoint:e.endpoint,protocol:e.protocol??"anthropic",model:e.model,headers:e.headers,apiKey:e.apiKey,maxTokens:e.maxTokens,anthropicVersion:e.anthropicVersion,requestOverrides:e.requestOverrides,hosted:e.hosted===true,catalog:e.tools?.length?[...Ro,...e.tools]:void 0,dispatch:n,readSnapshot:rc,availableActions:Re,policy:e.policy,context:e.context,isRelease:Kt,appName:e.appName,platform:$t.OS,requestApproval:te=>b.askApproval(te)});i.current=ne,ne.setApprovalBypass(M.current),ne.setReadOnly(X.current),b.holdSession(ne,V),b.setLedger(ne.ledger);let Se=false;return sn().then(te=>{te&&!Se&&ne.prime()}),y&&!a.current&&(a.current=true,mc().then(te=>{!te||!b.hydrate({messages:te.messages,answers:te.answers,usage:te.usage,queued:te.queued})||(i.current?.restore(te.history),te.ledger?.length&&i.current?.ledger.restore(te.ledger),te.pending&&b.restorePending(te.pending))})),()=>{Se=true}},[g,e,Re,Je,y]),ht(()=>{i.current?.setApprovalBypass(C)},[C]),ht(()=>{i.current?.setReadOnly(j)},[j]);let Qe=t.messages,ft=t.answers,bt=t.usage,It=t.busy,Ve=t.pending,at=t.queued;ht(()=>{if(!y||Qe.length===0)return;let S=()=>{xc(bc({messages:Qe,history:i.current?.messages??[],answers:ft,usage:bt,pending:Ve,ledger:b.getLedger()?.list(),queued:at}))};if(!It||Ve){S();return}let V=setTimeout(S,vc);return()=>clearTimeout(V)},[y,It,Qe,ft,bt,Ve,at]);let st=De(S=>{if(!_t()||!r.current)return;let V=i.current;if(!V)return;b.beginTurn();let _=b.startAssistant(),ne=new AbortController;h.current=ne,V.setAvailableActions(fn());let Se=u.current?.onEvent;(async()=>{try{for await(let te of V.send(S,ne.signal))if(b.applyEvent(_,te),Se)try{Se(te)}catch{}}catch(te){ne.signal.aborted||b.applyEvent(_,{type:"error",message:te instanceof Error?te.message:"Something went wrong talking to your AI endpoint."})}finally{ne.signal.aborted&&b.markStopped(_),b.finishAssistant(_),h.current=null}})()},[]),Ye=De(S=>{if(!_t()||!r.current)return;let V=S.trim();if(!i.current||!V)return;if(b.getState().busy){b.enqueue(V);return}let _=b.getState().awaitingBlockId;_&&b.recordAnswer({blockId:_,kind:"skipped"}),b.addUser(V),st(V)},[st]),yt=De(()=>{let{messages:S,busy:V}=b.getState();if(V||!i.current)return;let _=[...S].reverse().find(ne=>ne.role==="user");_&&st(_.text)},[st]),Xe=De(()=>{b.requestStop(),b.getState().pending&&b.answerApproval(false),h.current?.abort(),h.current=null},[]);ht(()=>{let S=Ys(()=>{_t()||Xe()});return()=>{S(),Xe()}},[Xe]),ht(()=>{o||Xe()},[o,Xe]),ht(()=>{if(t.queued.length===0||nn(t)!=="idle"||ln(t)!==null)return;let S=b.shiftQueued();S&&Ye(S.text)},[t,Ye]);let Ie=De(S=>b.takeQueuedToDraft(S),[]),zt=De(S=>b.removeQueued(S),[]),Jt=De(()=>{h.current?.abort(),h.current=null,Ho()},[]),so=De(()=>gn({dispatch:an,undoFirst:true}),[]),Qt=De(async S=>{let V=b.getLedger();if(!V){b.setNotice(`${S.label} couldn't run \u2014 no active Ask Buoy session.`);return}let _=e?.tools?.length?[...Ro,...e.tools]:void 0;if(S.targetDigest){let Se=await ic({toolId:S.toolId,action:S.action,params:S.params??{},dispatch:n,catalog:_});if(Se!==void 0&&Se!==S.targetDigest){b.addNote(`\u201C${S.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}}let ne=await dn({toolId:S.toolId,action:S.action,params:S.params??{},dispatch:n,ledger:V,policy:ee(),isRelease:Kt,catalog:_});ne.ok?b.addNote(`Applied \u201C${S.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.`):b.setNotice(`${S.label} failed \u2014 ${ne.error}`)},[e,ee]),co=De(S=>{let V=b.getState().pending,_=typeof S=="boolean"?S:S.approved;if(b.answerApproval(S),!!V?.restored){if(!_){b.addNote(`Skipped \u201C${V.label}\u201D. Nothing was changed.`);return}Qt(V)}},[Qt]),uo=De(S=>{b.recordAnswer(S);let V=wc(S.blockId);Ye(V?`${V} \u2014 ${cn(S)}`:cn(S))},[Ye]),po=De(async(S,V)=>{if(!_t()||!r.current){b.setNotice("Ask Buoy requires Pro access.");return}if(S.send){Ye(S.send);return}if(!S.dispatch)return;let _=`${V}:${S.label}`,ne=b.getLedger();if(!ne){b.setNotice(`${S.label} failed \u2014 no active Ask Buoy session.`);return}b.setActionState(_,"running");let Se=await dn({toolId:S.dispatch.toolId,action:S.dispatch.action,params:S.dispatch.params??{},dispatch:n,ledger:ne,policy:ee(),isRelease:Kt,catalog:e?.tools?.length?[...Ro,...e.tools]:void 0});Se.ok?b.setActionState(_,"done"):(b.setActionState(_,"failed"),b.setNotice(`${S.label} failed \u2014 ${Se.error}`))},[Ye,e,ee]);return{state:t,send:Ye,stop:Xe,reset:Jt,undoThenReset:so,approve:co,retry:yt,answer:uo,runAction:po,editQueued:Ie,removeQueued:zt,configured:g,toolCount:Object.keys(Re).length,availableToolIds:Object.keys(Re)}}import{Fragment as Sc,jsx as ue,jsxs as it}from"react/jsx-runtime";function yn(){let e=Ht(),t=Lo().trusted;return it(Fe,{style:re.scroll,contentContainerStyle:re.content,testID:"buoy-ask-buoy-settings",children:[ue(Cc,{}),ue(l,{style:re.section,children:"CHAT"}),ue(vo,{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:o=>pt.set("showThinking",o)}),ue(l,{style:re.note,children:"Not every model reports reasoning. Claude thinks by default; most OpenAI models return none, and the strip then shows the steps alone."}),ue(l,{style:re.section,children:"PERMISSIONS"}),ue(vo,{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:o=>pt.set("readOnly",o)}),e.readOnly?ue(l,{style:re.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,ue(vo,{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:o=>pt.set("bypassApprovals",o)}),e.bypassApprovals&&!e.readOnly?it(s,{style:re.warning,testID:"buoy-ask-buoy-bypass-warning",children:[ue(Fs,{size:14,color:de.color.warning}),ue(l,{style:re.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."})]}):ue(l,{style:re.note,children:"On by default for destructive actions only \u2014 reads and ordinary writes already run without asking, and the changes bar records them."}),t.length>0?it(s,{style:re.trustedBox,testID:"buoy-ask-buoy-trusted",children:[ue(l,{style:re.section,children:"ALLOWED WITHOUT ASKING \u2014 THIS CHAT"}),t.map(o=>it(s,{style:re.trustedRow,children:[ue(l,{style:re.trustedLabel,numberOfLines:2,children:o.label}),ue(m,{testID:`buoy-ask-buoy-untrust-${o.key}`,accessibilityRole:"button",onPress:()=>b.untrust(o.key),style:({pressed:r})=>[re.forget,r&&{opacity:.7}],hitSlop:6,children:ue(l,{style:re.forgetText,children:"Ask again"})})]},o.key))]}):null]})}function Tc(e){let t=Date.parse(e.length===10?`${e}T00:00:00Z`:e);if(Number.isNaN(t))return e;let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=new Date(t);return`${o[r.getUTCMonth()]} ${r.getUTCDate()}`}function Cc(){let e=b.getUsageReader(),[t,o]=Ms({kind:"loading"}),r=js(()=>{e&&(o({kind:"loading"}),e().then(n=>o({kind:"ok",usage:n})).catch(n=>o({kind:"error",message:n instanceof Error?n.message:"Could not load credits."})))},[e]);return qs(r,[r]),e?it(s,{testID:"buoy-ask-buoy-credits",children:[ue(l,{style:re.section,children:"HOSTED AI CREDITS"}),it(s,{style:re.trustedRow,children:[ue(s,{style:{flex:1,gap:2},children:t.kind==="ok"?it(Sc,{children:[it(l,{style:re.trustedLabel,children:[t.usage.creditsLeft.toLocaleString()," of ",t.usage.grantCredits.toLocaleString()," credits left"]}),it(l,{style:re.note,children:[t.usage.resetAt?`Resets ${Tc(t.usage.resetAt)}. `:"","1 credit is $0.001 of AI use, included with your plan."]})]}):t.kind==="error"?ue(l,{style:re.note,children:t.message}):ue(l,{style:re.note,children:"Loading\u2026"})}),ue(m,{testID:"buoy-ask-buoy-credits-refresh",accessibilityRole:"button",onPress:r,style:({pressed:n})=>[re.forget,n&&{opacity:.7}],hitSlop:6,children:ue(l,{style:re.forgetText,children:"Refresh"})})]})]}):null}var re=w.create({scroll:{flex:1},content:{padding:de.gutter,gap:10,paddingBottom:32},section:{color:de.color.textTertiary,fontSize:10,fontWeight:"700",letterSpacing:.6,paddingHorizontal:4,paddingTop:4},warning:{flexDirection:"row",gap:8,padding:de.cardPad,borderRadius:de.radius.card,borderWidth:w.hairlineWidth,borderColor:de.color.warning,backgroundColor:de.color.surface},warningText:{flex:1,color:de.color.warning,fontSize:de.font.micro,lineHeight:16},trustedBox:{gap:6,paddingTop:6},trustedRow:{flexDirection:"row",alignItems:"center",gap:10,padding:de.cardPad,borderRadius:de.radius.card,borderWidth:w.hairlineWidth,borderColor:de.color.border,backgroundColor:de.color.surface},trustedLabel:{flex:1,color:de.color.text,fontSize:de.font.caption,lineHeight:18},forget:{paddingHorizontal:10,paddingVertical:6,borderRadius:de.radius.row,backgroundColor:de.color.button},forgetText:{color:de.color.text,fontSize:de.font.micro,fontWeight:"600"},note:{color:de.color.textTertiary,fontSize:de.font.micro,lineHeight:16,paddingHorizontal:4}});import{ChevronRight as Ic,night as ve,NightSectionLabel as zc}from"@buoy-gg/shared-ui/web";var Dc=[{text:"Why is this screen empty?"},{text:"What did the last few network calls return?",needs:"network"},{text:"Show me what's saved for this user",needs:"storage"},{text:"Make the next request to this screen fail with a 500",needs:"network",write:true,devOnly:true},{text:"Who am I signed in as right now?"},{text:"Did anything crash or log an error recently?",needs:"console"}],Rc=4;function $c(e){let t=e.availableToolIds.length>0;return Dc.filter(o=>o.write&&e.readOnly||o.devOnly&&e.isRelease?false:o.needs?t&&e.availableToolIds.includes(o.needs):true).slice(0,Rc).map(o=>o.text)}import{jsx as qe,jsxs as Gt}from"react/jsx-runtime";var mn=typeof Xt<"u"&&!Xt;function Ac({configured:e,onPick:t,availableToolIds:o=[],readOnly:r=false}){let n=$c({availableToolIds:o,readOnly:r,isRelease:mn});return e?Gt(s,{style:Ce.wrap,testID:"buoy-ask-buoy-empty",children:[qe(l,{style:Ce.title,children:"Ask about this app"}),qe(l,{style:Ce.body,children:"Ask what the app is doing right now, or tell it to change something. Anything it changes shows up in a bar at the top, with what can be undone."}),qe(l,{style:Ce.buildLine,testID:"buoy-ask-buoy-build-line",children:mn?"Release build \u2014 reading, impersonation and navigation work; simulations (forcing server responses, driving the screen) need a dev build.":"Dev build \u2014 full simulation available."}),Gt(s,{style:Ce.group,children:[qe(zc,{children:"Try asking"}),qe(s,{style:Ce.card,children:n.map((i,a)=>qe(Bc,{text:i,onPick:t,last:a===n.length-1},i))})]})]}):Gt(s,{style:Ce.wrap,testID:"buoy-ask-buoy-unconfigured",children:[qe(l,{style:Ce.title,children:"Not set up yet"}),Gt(l,{style:Ce.body,children:["Ask Buoy talks to your own company's AI endpoint \u2014 nothing goes to Buoy. A developer needs to add the ",qe(l,{style:Ce.code,children:"askBuoy"})," prop to"," ",qe(l,{style:Ce.code,children:"<FloatingDevTools />"})," with your team's endpoint and model."]})]})}function Bc({text:e,onPick:t,last:o}){return Gt(m,{testID:`buoy-ask-buoy-suggestion-${e.slice(0,12)}`,accessibilityRole:"button",onPress:()=>t(e),style:({pressed:r})=>[Ce.row,!o&&Ce.rowDivider,r&&Ce.pressed],children:[qe(l,{style:Ce.rowText,children:e}),qe(Ic,{size:14,color:ve.color.textTertiary})]})}var Ce=w.create({wrap:{flex:1,justifyContent:"center",paddingHorizontal:ve.gutter,paddingVertical:24,gap:8},title:{color:ve.color.text,fontSize:22,fontWeight:"700",letterSpacing:-.3},body:{color:ve.color.textSecondary,fontSize:ve.font.body,lineHeight:20},code:{color:ve.color.text,fontFamily:"Menlo"},buildLine:{marginTop:8,color:ve.color.textTertiary,fontSize:ve.font.micro,lineHeight:15},group:{marginTop:ve.groupGap-8},card:{borderRadius:ve.radius.card,borderWidth:w.hairlineWidth,borderColor:ve.color.border,backgroundColor:ve.color.surface,overflow:"hidden"},row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:ve.rowPadH,paddingVertical:13},rowDivider:{borderBottomWidth:w.hairlineWidth,borderBottomColor:ve.color.separator},rowText:{flex:1,color:ve.color.text,fontSize:ve.font.body,lineHeight:19},pressed:{backgroundColor:ve.color.fill}});import{memo as Hc,useCallback as Tt,useEffect as Lc,useRef as Po,useState as Oo}from"react";import{AlertTriangle as Wo,Check as xn,ChevronDown as kn,ChevronRight as wn,Copy as Pc,night as k,X as Oc}from"@buoy-gg/shared-ui/web";import{toolTitle as Wc}from"@buoy-gg/agent-core/web";import{isAskBlock as Ec}from"@buoy-gg/agent-core/web";function Vc({block:e,forToolCallId:t}){if(!t)return false;let o="source"in e?e.source:void 0;return o==="live"||o==="mocked"}function Nc(e,t){let o=new Set(t),r=new Map,n=[],i=[];for(let a of e){if(Ec(a.block)){i.push(a);continue}if(Vc(a)&&o.has(a.forToolCallId)){let h=r.get(a.forToolCallId)??[];h.push(a.block),r.set(a.forToolCallId,h)}else n.push(a)}return{nested:r,afterText:n,ask:i}}import{useState as vn}from"react";import{Activity as jc,ChevronDown as qc,ChevronRight as Mc,night as Y}from"@buoy-gg/shared-ui/web";function Eo(e){let t=[...e.reasoning??[]].sort((i,a)=>i.afterCalls-a.afterCalls),o=[],r=0,n=i=>{for(;r<t.length&&t[r].afterCalls<=i;)o.push({kind:"thought",text:t[r].text}),r+=1};return e.toolCalls.forEach((i,a)=>{n(a),o.push({kind:"step",n:a+1,call:i})}),n(e.toolCalls.length),o}function Sn(e){return(e.reasoning?.length??0)>0||e.toolCalls.length>0}var Fc=e=>e.status==="ok"?e.summary||"done":e.status==="running"?"running":`${e.status}${e.summary?` \u2014 ${e.summary}`:""}`;function Tn(e,t=" "){let o=[];for(let r of Eo(e))if(r.kind==="thought"){o.push(`${t}[thinking]`);for(let n of r.text.trim().split(`
11
+ `))o.push(`${t} ${n}`)}else{let{n,call:i}=r;o.push(`${t}[${n}] ${i.toolId}.${i.action} \u2014 ${Fc(i)}`),i.params&&o.push(`${t} ${i.params}`)}return o}import{Fragment as _c,jsx as He,jsxs as lt}from"react/jsx-runtime";function Uc({n:e,call:t}){let[o,r]=vn(false),n=t.status==="failed"||t.status==="refused";return lt(m,{onPress:()=>r(i=>!i),accessibilityRole:"button",accessibilityState:{expanded:o},style:fe.step,children:[lt(s,{style:fe.stepLine,children:[He(l,{style:fe.stepN,children:e}),lt(l,{style:[fe.stepName,n&&fe.stepFailed],numberOfLines:1,children:[t.toolId,".",t.action]}),t.durationMs!==void 0?lt(l,{style:fe.stepMs,children:[t.durationMs,"ms"]}):null,He(l,{style:[fe.stepStatus,n&&fe.stepFailed],numberOfLines:1,children:t.status==="ok"?t.summary||"done":t.status})]}),o?lt(s,{style:fe.detail,children:[He(l,{style:fe.detailLabel,children:"SENT"}),He(l,{style:fe.code,selectable:true,children:t.params??"no parameters"}),t.result?lt(_c,{children:[He(l,{style:fe.detailLabel,children:"RETURNED"}),He(l,{style:fe.code,selectable:true,children:t.result})]}):null]}):null]})}function Cn({message:e}){let[t,o]=vn(false);if(!Sn(e))return null;let r=Eo(e),n=r.filter(u=>u.kind==="step").length,i=r.length-n,a=e.startedAt!==void 0&&e.endedAt!==void 0?`${((e.endedAt-e.startedAt)/1e3).toFixed(1)}s`:null,h=[n?`${n} step${n===1?"":"s"}`:null,i?`${i} thought${i===1?"":"s"}`:null,a,e.usage?`${e.usage.input+e.usage.output} tokens`:null].filter(Boolean).join(" \xB7 ");return lt(s,{style:fe.wrap,testID:"buoy-ask-buoy-thinking",children:[lt(m,{testID:"buoy-ask-buoy-thinking-toggle",onPress:()=>o(u=>!u),accessibilityRole:"button",accessibilityLabel:t?"Hide agent thinking":"Show agent thinking",accessibilityState:{expanded:t},style:fe.head,children:[He(jc,{size:12,color:Y.color.textTertiary}),He(l,{style:fe.headText,children:h}),t?He(qc,{size:12,color:Y.color.textTertiary}):He(Mc,{size:12,color:Y.color.textTertiary})]}),t?lt(s,{style:fe.body,children:[r.map((u,g)=>u.kind==="thought"?He(l,{style:fe.thought,selectable:true,children:u.text.trim()},`t${g}`):He(Uc,{n:u.n,call:u.call},u.call.id)),i===0?He(l,{style:fe.none,children:"This model reports no reasoning \u2014 the steps above are the whole trace."}):null]}):null]})}var fe=w.create({wrap:{marginTop:8,borderRadius:Y.radius.badge,borderWidth:w.hairlineWidth,borderColor:Y.color.separator,backgroundColor:Y.color.fill,overflow:"hidden"},head:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:7},headText:{flex:1,color:Y.color.textTertiary,fontSize:Y.font.micro,fontWeight:"600"},body:{borderTopWidth:w.hairlineWidth,borderTopColor:Y.color.separator},thought:{color:Y.color.textSecondary,fontSize:Y.font.micro,lineHeight:17,fontStyle:"italic",paddingHorizontal:10,paddingVertical:8},step:{paddingHorizontal:10,paddingVertical:7},stepLine:{flexDirection:"row",alignItems:"center",gap:8},stepN:{color:Y.color.textTertiary,fontSize:Y.font.micro,width:14},stepName:{flex:1,color:Y.color.textSecondary,fontSize:Y.font.micro,fontWeight:"600"},stepMs:{color:Y.color.textTertiary,fontSize:Y.font.micro},stepStatus:{color:Y.color.textTertiary,fontSize:Y.font.micro,maxWidth:110},stepFailed:{color:Y.color.danger},detail:{marginTop:6,marginLeft:22,gap:3},detailLabel:{color:Y.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5},code:{color:Y.color.textSecondary,fontSize:Y.font.micro,lineHeight:16,marginBottom:3},none:{color:Y.color.textTertiary,fontSize:Y.font.micro,fontStyle:"italic",paddingHorizontal:10,paddingVertical:8}});import{useEffect as Kc,useRef as Gc}from"react";import{night as Jc}from"@buoy-gg/shared-ui/web";import{jsx as In}from"react/jsx-runtime";function Qc(){let e=Gc([0,1,2].map(()=>new ce.Value(.25))).current;return Kc(()=>{let t=e.map((o,r)=>ce.loop(ce.sequence([ce.delay(r*140),ce.timing(o,{toValue:1,duration:320,easing:Rt.inOut(Rt.ease),useNativeDriver:true}),ce.timing(o,{toValue:.25,duration:320,easing:Rt.inOut(Rt.ease),useNativeDriver:true}),ce.delay((2-r)*140)])));return t.forEach(o=>o.start()),()=>t.forEach(o=>o.stop())},[e]),In(s,{style:zn.wrap,testID:"buoy-ask-buoy-typing",accessibilityLabel:"Thinking",children:e.map((t,o)=>In(ce.View,{style:[zn.dot,{opacity:t}]},o))})}var zn=w.create({wrap:{flexDirection:"row",alignItems:"center",gap:5,paddingVertical:8,paddingHorizontal:2},dot:{width:7,height:7,borderRadius:4,backgroundColor:Jc.color.textSecondary}});import{jsx as x,jsxs as be}from"react/jsx-runtime";function Dn({status:e}){switch(e){case"running":return x(Vt,{size:"small",color:k.color.textSecondary});case"ok":return x(s,{style:[f.mark,f.markOk],children:x(xn,{size:10,color:k.color.onAccent})});case"failed":return x(s,{style:[f.mark,f.markFailed],children:x(Oc,{size:10,color:k.color.text})});case"refused":return x(s,{style:[f.mark,f.markRefused],children:x(Wo,{size:10,color:k.color.onAccent})});case"declined":case"stopped":return x(s,{style:[f.mark,f.markNotRun],children:x(s,{style:f.markNotRunBar})})}}function Yc(e){return e.status==="running"?{text:"",tone:"muted"}:e.status==="refused"?{text:"Refused",tone:"warning"}:e.status==="failed"?{text:"Failed",tone:"danger"}:e.status==="declined"?{text:"You declined",tone:"muted"}:e.status==="stopped"?{text:"Not run \u2014 stopped",tone:"muted"}:e.verification?.status==="verified"?{text:"Verified",tone:"ok"}:e.verification?.status==="unverified"?{text:"Done \xB7 not yet visible",tone:"muted"}:e.verification?.status==="failed"?{text:"Done \xB7 check failed",tone:"warning"}:{text:e.summary||"Done",tone:"muted"}}var Xc=e=>e.status==="failed"||e.status==="refused"||e.status==="declined"||e.status==="stopped";function Rn({call:e,receipts:t,last:o}){let[r,n]=Oo(false),i=Yc(e),a=r?kn:wn,h=e.status==="failed"&&e.summary&&e.summary!=="Failed"?e.summary:null;return be(s,{style:[f.row,!o&&f.rowDivider],children:[be(m,{testID:`buoy-ask-buoy-tool-${e.toolId}`,accessibilityRole:"button",accessibilityLabel:`${e.label}, ${i.text||"running"}`,accessibilityState:{expanded:r},onPress:()=>n(u=>!u),children:[be(s,{style:f.rowLine,children:[x(s,{style:f.markSlot,children:x(Dn,{status:e.status})}),x(l,{style:f.rowTitle,children:e.label}),i.text?x(l,{style:[f.rowStatus,i.tone==="danger"&&f.rowStatusDanger,i.tone==="warning"&&f.rowStatusWarning,i.tone==="ok"&&f.rowStatusOk],numberOfLines:1,children:i.text}):null,x(a,{size:12,color:k.color.textTertiary})]}),r&&be(s,{style:f.rowDetail,children:[x(l,{style:f.rowTool,children:Wc(e.toolId).toUpperCase()}),e.description?x(l,{style:f.rowDescription,children:e.description}):null,h?x(l,{style:f.rowFailure,children:h}):null,e.verification?x(l,{style:[f.rowDescription,e.verification.status==="failed"&&f.rowFailure,e.verification.status==="verified"&&f.rowVerified],testID:`buoy-ask-buoy-verification-${e.verification.status}`,children:e.verification.detail}):null]})]}),r&&t.length>0&&x(s,{style:f.rowReceipts,testID:`buoy-ask-buoy-tool-receipt-${e.toolId}`,children:t.map(u=>x(no,{block:u},u.id))})]})}function Zc({label:e,count:t,calls:o,receipts:r,last:n}){let[i,a]=Oo(false),h=i?kn:wn;return be(s,{style:!n&&!i&&f.rowDivider,children:[x(m,{testID:"buoy-ask-buoy-reads-group",accessibilityRole:"button",accessibilityLabel:`${e}, ${t} reads`,accessibilityState:{expanded:i},onPress:()=>a(u=>!u),style:[f.row,i&&f.rowDivider],children:be(s,{style:f.rowLine,children:[x(s,{style:f.markSlot,children:x(Dn,{status:"ok"})}),x(l,{style:f.rowTitle,children:e}),be(l,{style:f.rowStatus,numberOfLines:1,children:[t," reads"]}),x(h,{size:12,color:k.color.textTertiary})]})}),i&&x(s,{style:f.groupBody,children:o.map((u,g)=>x(Rn,{call:u,receipts:r.get(u.id)??[],last:n&&g===o.length-1},u.id))})]})}function ed({calls:e,receipts:t}){let o=Os(e);return x(s,{style:f.card,testID:"buoy-ask-buoy-activity",children:o.map((r,n)=>r.kind==="reads"?x(Zc,{label:r.label,count:r.count,calls:r.calls,receipts:t,last:n===o.length-1},r.id):x(Rn,{call:r.call,receipts:t.get(r.call.id)??[],last:n===o.length-1},r.call.id))})}function $n({blocks:e}){return e.length===0?null:x(s,{style:f.blocks,children:e.map(({block:t})=>x(no,{block:t},t.id))})}function td({message:e}){return x(s,{style:f.systemLine,testID:"buoy-ask-buoy-system-line",children:x(l,{style:f.systemText,children:e.text})})}function od({message:e}){return x(s,{style:f.userWrap,children:x(s,{style:f.userBubble,children:x(l,{style:f.userText,selectable:true,children:e.text})})})}function rd({message:e,onRetry:t,waitingOnUser:o}){let{showThinking:r}=Ht(),n=!!e.streaming&&!o,{nested:i,afterText:a,ask:h}=Nc(e.blocks,e.toolCalls.map(u=>u.id));return be(s,{style:f.assistantWrap,children:[e.toolCalls.length>0&&x(ed,{calls:e.toolCalls,receipts:i}),e.text.length>0&&x(yr,{text:e.text,style:f.assistantText}),x($n,{blocks:a}),x($n,{blocks:h}),r&&!e.streaming&&x(Cn,{message:e}),n&&be(s,{style:f.waitingRow,children:[x(Qc,{}),e.waiting?x(l,{style:f.waitingText,testID:"buoy-ask-buoy-waiting",children:e.waiting}):null]}),e.error&&(e.errorInfo?x(ad,{error:e.error,info:e.errorInfo,onRetry:t}):x(id,{error:e.error,onRetry:t})),e.stopped&&!e.error&&x(nd,{onRetry:t,changed:e.toolCalls.some(u=>u.status==="ok"&&!!u.effect&&u.effect!=="read")})]})}function nd({onRetry:e,changed:t}){return be(s,{style:f.stoppedBox,testID:"buoy-ask-buoy-stopped",children:[x(l,{style:f.stoppedText,children:t?"Stopped. Changes already made are listed above.":"Stopped."}),e&&x(m,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:e,style:({pressed:o})=>[f.retry,o&&f.retryPressed],children:x(l,{style:f.retryText,children:"Try again"})})]})}function id({error:e,onRetry:t}){let o=/fetch failed|network|ECONN|timed? ?out|socket/i.test(e)?"Couldn't reach your AI endpoint. Check the connection and try again.":"Something went wrong with that turn.";return be(s,{style:f.errorBox,testID:"buoy-ask-buoy-error",children:[x(Wo,{size:14,color:k.color.danger}),be(s,{style:f.errorBody,children:[x(l,{style:f.errorText,children:o}),x(l,{style:f.errorDetail,selectable:true,children:e}),t&&x(m,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:t,style:({pressed:r})=>[f.retry,r&&f.retryPressed],children:x(l,{style:f.retryText,children:"Try again"})})]})]})}var ld=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 ad({error:e,info:t,onRetry:o}){let[r,n]=Oo("idle"),i=`Ask Buoy error ${t.code}${t.requestId?` \xB7 request ${t.requestId}`:""} \xB7 ${new Date().toISOString()}`,{copied:a,copy:h}=to(()=>i),u=b.getReporter(),g=Tt(()=>{u&&(n("sending"),u({requestId:t.requestId,code:t.code,note:"Reported from the error card."}).then(y=>n({id:y.reportId})).catch(()=>n("failed")))},[u,t.code,t.requestId]);return be(s,{style:f.errorBox,testID:"buoy-ask-buoy-error",children:[x(Wo,{size:14,color:k.color.danger}),be(s,{style:f.errorBody,children:[x(l,{style:f.errorText,children:e}),be(l,{style:f.errorDetail,selectable:true,testID:"buoy-ask-buoy-error-code",children:[t.code,t.requestId?` \xB7 ${t.requestId}`:""]}),be(s,{style:f.transcriptActions,children:[o&&!ld.has(t.code)&&x(m,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:o,style:({pressed:y})=>[f.retry,y&&f.retryPressed],children:x(l,{style:f.retryText,children:"Try again"})}),x(m,{testID:"buoy-ask-buoy-error-copy",accessibilityRole:"button",accessibilityLabel:"Copy details",onPress:h,style:({pressed:y})=>[f.retry,y&&f.retryPressed],children:x(l,{style:f.retryText,children:a?"Copied":"Copy details"})}),u&&x(m,{testID:"buoy-ask-buoy-error-report",accessibilityRole:"button",accessibilityLabel:"Report problem",disabled:r!=="idle"&&r!=="failed",onPress:g,style:({pressed:y})=>[f.retry,y&&f.retryPressed],children:x(l,{style:f.retryText,children:r==="sending"?"Sending\u2026":r==="failed"?"Report failed. Try again":typeof r=="object"?`Reported \xB7 ${r.id}`:"Report problem"})})]})]})]})}function An(e,t=false){let o=[];for(let 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(...Tn(r));else for(let n of r.toolCalls){let i=Xc(n)?` (${n.status})`:"";o.push(` \xB7 ${n.label}${n.summary?` \u2014 ${n.summary}`:""}${i}`)}r.text&&o.push(`Ask Buoy: ${r.text}`);for(let n of ql(r.blocks.map(i=>i.block)))o.push(n);r.error&&o.push(` ! ${r.error}`),r.stopped&&!r.error&&o.push(" ! Stopped by the user.")}return o.join(`
12
+ `)}function sd({testID:e,label:t,getText:o}){let{copied:r,copy:n}=to(o);return be(m,{testID:e,accessibilityRole:"button",accessibilityLabel:t,onPress:n,style:({pressed:i})=>[f.copyBtn,f.iconBtn,i&&f.copyPressed],children:[r?x(xn,{size:11,color:k.color.accent}):x(Pc,{size:11,color:k.color.textSecondary}),x(l,{style:[f.copyText,r&&f.copiedText],children:r?"Copied":t})]})}function cd({message:e}){let{showThinking:t}=Ht(),o=Tt(()=>An(b.getState().messages,t),[t]),r=Es(e);return be(s,{style:f.transcriptActions,children:[r?x(l,{style:f.turnFooter,testID:"buoy-ask-buoy-turn-footer",children:r}):null,x(sd,{testID:"buoy-ask-buoy-copy",label:"Copy conversation",getText:o})]})}var dd=Hc(function({message:e,onRetry:t,waitingOnUser:o}){if(e.role==="user")return x(od,{message:e});if(e.system)return x(td,{message:e});let r=!e.streaming&&!e.error;return be(s,{children:[x(rd,{message:e,onRetry:t,waitingOnUser:o}),r&&x(cd,{message:e})]})});function Bn({messages:e,ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r,onRetry:n,waitingOnUser:i}){let a=Po(null),h=Po(true),u=Po(false),g=Tt(ke=>{let{contentOffset:Ge,contentSize:Re,layoutMeasurement:Je}=ke.nativeEvent,Qe=Re.height-Je.height-Ge.y;h.current=Qe<80},[]),y=Tt(()=>{u.current=true},[]),C=Tt(ke=>{u.current&&g(ke)},[g]),j=Tt(ke=>{u.current=false,g(ke)},[g]),M=Tt(()=>{h.current&&(a.current?.scrollToEnd({animated:false}),requestAnimationFrame(()=>a.current?.scrollToEnd({animated:false})))},[]),X=e[e.length-1],ee=X?`${X.id}:${X.text.length}:${X.toolCalls.length}:${X.error??""}`:"";return Lc(()=>{M()},[ee,M]),x(tr,{ref:a,testID:"buoy-ask-buoy-messages-scroll",style:f.list,contentContainerStyle:f.listContent,data:e,keyExtractor:ke=>ke.id,renderItem:({item:ke})=>x(dd,{message:ke,onRetry:ke.id===X?.id?n:void 0,waitingOnUser:ke.id===X?.id?i:false}),onScroll:C,onScrollBeginDrag:y,onScrollEndDrag:j,onMomentumScrollEnd:g,scrollEventThrottle:32,onContentSizeChange:M,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"interactive",ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r})}var f=w.create({list:{flex:1,backgroundColor:"transparent"},listContent:{paddingHorizontal:k.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:k.color.accentFill,borderWidth:w.hairlineWidth,borderColor:k.color.accentBorder},userText:{color:k.color.text,fontSize:k.font.row,lineHeight:21},systemLine:{alignSelf:"stretch",paddingHorizontal:12,paddingVertical:7,borderRadius:k.radius.row,backgroundColor:k.color.fill},systemText:{color:k.color.textSecondary,fontSize:k.font.micro,lineHeight:16,textAlign:"center"},assistantWrap:{alignItems:"stretch",gap:10},blocks:{gap:10},waitingRow:{flexDirection:"row",alignItems:"center",gap:8},waitingText:{color:k.color.textSecondary,fontSize:k.font.caption},assistantText:{color:k.color.text,fontSize:k.font.row,lineHeight:22,paddingHorizontal:2},card:{borderRadius:k.radius.card,borderWidth:w.hairlineWidth,borderColor:k.color.border,backgroundColor:k.color.surface,overflow:"hidden"},row:{paddingHorizontal:12,paddingVertical:10},rowDivider:{borderBottomWidth:w.hairlineWidth,borderBottomColor:k.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:k.color.accent},markFailed:{backgroundColor:k.color.danger},markRefused:{backgroundColor:k.color.warning},markNotRun:{borderWidth:1.5,borderColor:k.color.textTertiary},markNotRunBar:{width:7,height:1.5,borderRadius:1,backgroundColor:k.color.textSecondary},rowTitle:{flex:1,color:k.color.text,fontSize:k.font.body,lineHeight:19},rowStatus:{color:k.color.textTertiary,fontSize:k.font.caption,maxWidth:120},rowStatusDanger:{color:k.color.danger},rowStatusWarning:{color:k.color.warning},rowStatusOk:{color:k.color.accent},rowVerified:{color:k.color.accent},rowDetail:{paddingLeft:28,paddingTop:8,gap:4},rowTool:{color:k.color.textTertiary,fontSize:k.font.micro,fontWeight:"600",letterSpacing:.8},rowDescription:{color:k.color.textSecondary,fontSize:k.font.caption,lineHeight:18},rowFailure:{color:k.color.danger,fontSize:k.font.caption,lineHeight:18},rowReceipts:{paddingTop:10,gap:10},groupBody:{paddingLeft:14,backgroundColor:k.color.fill},stoppedBox:{alignItems:"flex-start",gap:2,paddingHorizontal:12,paddingVertical:8},stoppedText:{color:k.color.textTertiary,fontSize:k.font.caption,lineHeight:18},errorBox:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingVertical:10,borderRadius:k.radius.row,backgroundColor:k.color.dangerSoft},errorBody:{flex:1,gap:4},errorText:{color:k.color.danger,fontSize:k.font.caption,fontWeight:"600",lineHeight:18},errorDetail:{color:k.color.textSecondary,fontSize:k.font.micro,lineHeight:15},retry:{alignSelf:"flex-start",marginTop:6,paddingHorizontal:14,paddingVertical:7,borderRadius:k.radius.row,backgroundColor:k.color.button},retryPressed:{opacity:.7},retryText:{color:k.color.accent,fontSize:k.font.caption,fontWeight:"600"},transcriptActions:{flexDirection:"row",alignItems:"center",gap:10,marginTop:8},turnFooter:{flex:1,color:k.color.textTertiary,fontSize:k.font.micro,fontVariant:["tabular-nums"]},copyBtn:{paddingHorizontal:10,paddingVertical:5,borderRadius:k.radius.badge,backgroundColor:k.color.fill},iconBtn:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8},copyPressed:{opacity:.7},copyText:{color:k.color.textSecondary,fontSize:k.font.micro,fontWeight:"600"},copiedText:{color:k.color.accent}});import{night as Le,X as ud}from"@buoy-gg/shared-ui/web";import{jsx as Lt,jsxs as Vo}from"react/jsx-runtime";var pd=132;function hd({items:e,paused:t,onEdit:o,onRemove:r}){return e.length===0?null:Vo(s,{style:Pe.wrap,testID:"buoy-ask-buoy-queued",children:[Lt(Fe,{style:Pe.list,contentContainerStyle:Pe.listContent,keyboardShouldPersistTaps:"handled",children:e.map((n,i)=>Vo(s,{style:[Pe.row,t!==null&&Pe.rowPaused],children:[Vo(m,{testID:`buoy-ask-buoy-queue-item-${i}`,accessibilityRole:"button",accessibilityLabel:`Edit queued message: ${n.text}`,onPress:()=>o(n.id),style:({pressed:a})=>[Pe.rowBody,a&&Pe.pressed],children:[Lt(l,{style:Pe.ordinal,children:i===0?"NEXT":"THEN"}),Lt(l,{style:Pe.text,numberOfLines:3,children:n.text})]}),Lt(m,{testID:`buoy-ask-buoy-queue-remove-${i}`,accessibilityRole:"button",accessibilityLabel:"Remove queued message",onPress:()=>r(n.id),hitSlop:8,style:({pressed:a})=>[Pe.remove,a&&Pe.pressed],children:Lt(ud,{size:11,color:Le.color.textTertiary})})]},n.id))}),Lt(l,{style:[Pe.hint,t!==null&&Pe.hintPaused],testID:"buoy-ask-buoy-queue-hint",children:t??"Sends one at a time when this turn finishes \xB7 tap to edit"})]})}var Pe=w.create({wrap:{paddingHorizontal:Le.gutter,paddingTop:8,gap:6,backgroundColor:Le.color.bg},list:{maxHeight:pd},listContent:{gap:6},row:{flexDirection:"row",alignItems:"center",borderRadius:Le.radius.row,borderWidth:w.hairlineWidth,borderColor:Le.color.border,backgroundColor:Le.color.surface},rowPaused:{borderColor:Le.color.warning},rowBody:{flex:1,flexDirection:"row",alignItems:"center",gap:8,paddingVertical:7,paddingLeft:10},ordinal:{color:Le.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6,width:30},text:{flex:1,color:Le.color.textSecondary,fontSize:Le.font.caption,lineHeight:17},remove:{width:32,height:32,alignItems:"center",justifyContent:"center"},pressed:{opacity:.7},hint:{color:Le.color.textTertiary,fontSize:Le.font.micro},hintPaused:{color:Le.color.warning}});var gd="Summarize this conversation as a bug ticket, using one buoy_ui finding block and nothing else. Title it with the problem in one line. Evidence rows, in this order: Steps (what we did), Expected, Observed, Build (dev or release, platform), Evidence (the exact requests, statuses, logs or values you actually saw this conversation), Still applied (overrides or changes from your changes list that are still live, or 'none'). Only facts you observed in this conversation; write 'unknown' where you don't know rather than guessing, and put anything you inferred rather than saw in a final row labelled Inference. Do not run any tool or change anything to produce this.";import{Fragment as fd,jsx as pe,jsxs as Pt}from"react/jsx-runtime";function No({visible:e,onClose:t,onBack:o,onMinimize:r,persistenceKey:n,config:i}){let{state:a,send:h,stop:u,reset:g,undoThenReset:y,approve:C,retry:j,answer:M,runAction:X,editQueued:ee,removeQueued:ke,configured:Ge,toolCount:Re,availableToolIds:Je}=bn(i),[Qe,ft]=ho(false),bt=Me(()=>{u(),t()},[u,t]),It=Me(()=>b.clearDraft(),[]),[Ve,at]=ho(false),st=Me(()=>at(false),[]),Ye=Me(()=>at(true),[]),yt=!e,Xe=!!a.pending||!!a.awaitingBlockId,Ie=a.messages[a.messages.length-1],zt=Wt(false),Jt=Wt(a.busy);Ot(()=>{yt&&Jt.current&&!a.busy&&(zt.current=true),yt||(zt.current=false),Jt.current=a.busy},[yt,a.busy]),Ot(()=>{if(!yt){At("ask-buoy",null);return}Xe?At("ask-buoy",{kind:"needsInput",label:a.pending?"Needs your approval":"Has a question for you"}):zt.current&&Ie?.role==="assistant"&&Ie.error?At("ask-buoy",{kind:"failed",label:"The last turn failed"}):zt.current&&!a.busy?At("ask-buoy",{kind:"done",label:"Finished"}):At("ask-buoy",null)},[yt,Xe,a.busy,a.pending,Ie]),Ot(()=>()=>At("ask-buoy",null),[]),Ot(()=>{a.pending&&Ve&&at(false)},[a.pending,Ve]);let so=Ui({minBottom:16}),[Qt,co]=ho("bottomSheet"),uo=Qt==="floating"?0:so.bottom,po=Me(()=>{let K=b.getLedger();K&&(async()=>{let ie=await K.revertAll(Mi);if(ie.failed.length===0){b.setNotice(null);return}let Dt=ie.failed.map(Yt=>`${Yt.label} (${Yt.error})`).join("; ");b.setNotice(`Couldn't undo ${ie.failed.length} change${ie.failed.length===1?"":"s"} \u2014 ${Dt}`)})()},[]),S=Me(()=>ft(K=>!K),[]),V=Wt(new ce.Value(560)).current,_=Wt(false),ne=Me(()=>{_.current||(_.current=true,V.stopAnimation(K=>{let ie=typeof K=="number"&&K>200?K:560;ce.timing(V,{toValue:120,duration:220,useNativeDriver:false}).start(()=>{setTimeout(()=>{ce.spring(V,{toValue:ie,friction:9,useNativeDriver:false}).start(()=>{_.current=false})},2500)})}))},[V]),Se=Zt(()=>{let K=a.messages[a.messages.length-1];if(!K||K.role!=="assistant")return"";let ie=K.blocks.filter(Dt=>Dt.block.kind==="peek").length;return ie>0?`${K.id}:${ie}`:""},[a.messages]),te=Wt("");Ot(()=>{Se&&Se!==te.current&&i?.peek!==false&&ne(),te.current=Se},[Se,ne,i]);let Vn=Me(()=>{let K=b.getLedger()?.list().filter(ie=>!ie.undoneAt&&qi(ie.effect)).length??0;if(K===0){g();return}fo.alert("Undo changes first?",`Ask Buoy made ${K} change${K===1?"":"s"} that can still be undone. Clearing the conversation loses the only automatic undo for ${K===1?"it":"them"}.`,[{text:"Undo, then clear",onPress:()=>{(async()=>{let ie=await y();if(ie.cleared)return;let Dt=ie.reverted+ie.failed.length,Yt=ie.failed.map(Qo=>`${Qo.label} (${Qo.error})`).join(`
13
+ `);fo.alert(`Couldn't undo ${ie.failed.length} of ${Dt} change${Dt===1?"":"s"}`,`${Yt}
14
14
 
15
- Still applied in the app. Clear the conversation anyway?`,[{text:"Keep conversation",style:"cancel"},{text:"Clear anyway",style:"destructive",onPress:g}])})()}},{text:"Clear anyway",style:"destructive",onPress:g},{text:"Cancel",style:"cancel"}])},[g,y]),Nn=Zt(()=>{let K=a.messages[a.messages.length-1];return!K||K.role!=="assistant"||!K.streaming?null:K.toolCalls.find(ie=>ie.status==="running")?.label??null},[a.messages]),Fo=Nr(b.getLedger()),_o=Zt(()=>ys(Fo),[Fo]),jn=Zt(()=>({answer:M,runAction:(K,ie)=>{if(K.minimize){r?.({mode:"bottomSheet"});return}return X(K,ie)},answered:a.answers,actionState:a.actionState,busy:a.busy,supports:{openTool:false,minimize:!!r,dispatch:true},rules:_o}),[M,X,r,a.answers,a.actionState,a.busy,_o]),qn=!a.busy&&Ie?.role==="assistant"&&!!Ie.error,Uo=!a.busy&&Ie?.role==="assistant"&&Ie.stopped&&!Ie.error?Ie.id:null,Mn=ln(a),{showThinking:Ko,readOnly:Go,hostedNoticeSeen:Fn}=Ht(),Jo=i?.hosted===true&&!Fn,_n=Me(()=>An(a.messages,Ko),[a.messages,Ko]),Un=Me(()=>h(gd),[h]),Kn=qe?Pt(bo,{children:[pe(bo.Navigation,{onBack:st}),pe(bo.Content,{title:"Settings",subtitle:"Ask Buoy",testID:"buoy-ask-buoy-settings-title"})]}):pe(Qr,{configured:Ge,busy:a.busy,failed:qn,activeLabel:Nn,awaitingApproval:!!a.pending,startedAt:Ie?.role==="assistant"&&Ie.streaming?Ie.startedAt??null:null,stopping:a.stopping,readOnly:Go,toolCount:Re,hasMessages:a.messages.length>0,onBack:o,onReset:Vn,getTranscript:_n,onOpenSettings:Qe,onTicket:Un});return pe(_i,{visible:e,onClose:bt,disableScrollWrapper:true,background:false,initialHeight:560,animatedHeight:V,header:{customContent:Kn,showToggleButton:false},onBack:o,onMinimize:r,onModeChange:co,persistenceKey:n??"buoy-ask-buoy",enablePersistence:true,children:pe(ar,{value:jn,children:Pt(s,{style:[Ct.root,{paddingBottom:uo}],children:[pe(jr,{ledger:b.getLedger(),onUndoAll:po,expanded:Ye,onToggle:S}),Jo&&Pt(s,{style:Ct.notice,testID:"buoy-ask-buoy-hosted-notice",children:[pe(nr,{size:14,color:_e.color.info}),Pt(s,{style:{flex:1,gap:8},children:[pe(l,{style:Ct.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 weekly credits."}),pe(m,{testID:"buoy-ask-buoy-hosted-notice-ok",accessibilityRole:"button",onPress:()=>pt.set("hostedNoticeSeen",true),style:({pressed:K})=>[Ct.noticeButton,K&&{opacity:.7}],children:pe(l,{style:Ct.noticeButtonText,children:"Got it"})})]})]}),a.notice&&Pt(s,{style:Ct.notice,testID:"buoy-ask-buoy-notice",children:[pe(nr,{size:14,color:_e.color.info}),pe(l,{style:Ct.noticeText,children:a.notice})]}),pe(Is,{children:pe(Fi,{featureName:"Ask Buoy",children:qe?pe(yn,{}):Pt(fd,{children:[pe(Bn,{messages:a.messages,onRetry:j,waitingOnUser:!!a.pending||!!a.awaitingBlockId,ListEmptyComponent:pe(Ac,{configured:Ge,onPick:h,availableToolIds:Je,readOnly:Go||!!i?.policy?.readOnly})}),pe(hd,{items:a.queued,paused:Mn,onEdit:ee,onRemove:ke}),a.pending&&pe(Wr,{pending:a.pending,onAnswer:C}),pe(_r,{onSend:h,onStop:u,busy:a.busy,draft:a.draft,onDraftTaken:It,disabled:!Ge||Jo,focusKey:Uo,canFocus:e,placeholder:Uo?"Tell it what to do differently\u2026":a.awaitingBlockId?"Pick an option above, or type\u2026":void 0})]})})})]})})})}var Ct=w.create({root:{flex:1,backgroundColor:"transparent"},notice:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:_e.gutter,paddingVertical:10,backgroundColor:_e.color.infoSoft},noticeText:{flex:1,color:_e.color.text,fontSize:_e.font.caption,lineHeight:18},noticeButton:{alignSelf:"flex-start",paddingHorizontal:12,paddingVertical:6,borderRadius:_e.radius.row,backgroundColor:_e.color.button},noticeButtonText:{color:_e.color.text,fontSize:_e.font.caption,fontWeight:"600"}});import{AskBuoyIcon as Hn,ASK_BUOY_ICON_COLOR as Ln}from"@buoy-gg/floating-tools-core/web";import{jsx as Pn}from"react/jsx-runtime";var ao={id:"ask-buoy",name:"ASK BUOY",description:"Ask about this app in plain English",slot:"both",color:Ln,icon:({size:e,slot:t})=>Pn(Hn,{size:t==="dial"?e*1.5:e}),component:No};function bd(e){let{name:t,description:o,...r}=e,n=r;return{...ao,name:t??ao.name,description:o??ao.description,component:i=>Pn(No,{...i,config:n})}}import{isReversible as jo}from"@buoy-gg/agent-core/web";var qo=1,yd={version:qo,async dispose(e){let t=b.getLedger();for(let o of t?.list()??[])o.undoneAt||o.effect.kind==="network-override"&&await e("network","deleteOverrideRule",{id:o.effect.ruleId})},getSnapshot(){let e=b.getState(),t=(b.getLedger()?.list()??[]).filter(o=>!o.undoneAt);return{version:qo,busy:e.busy,configured:e.configured,notice:e.notice,messageCount:e.messages.length,messages:e.messages.map(o=>({id:o.id,role:o.role,text:Ut(o.text),streaming:!!o.streaming,toolCalls:o.toolCalls.map(r=>({toolId:r.toolId,action:r.action,status:r.status}))})),usage:e.usage,pendingApproval:e.pending?{toolId:e.pending.toolId,action:e.pending.action,label:e.pending.label}:null,changes:{reversible:t.filter(o=>jo(o.effect)).length,permanent:t.filter(o=>o.effect.kind!=="transient"&&!jo(o.effect)).length,transients:t.filter(o=>o.effect.kind==="transient").length,items:t.map(o=>({kind:o.effect.kind,label:o.effect.label}))}}},subscribe(e){let t=b.subscribe(e),o=b.getLedger()?.subscribe(e);return()=>{t(),o?.()}},actions:{listChanges:()=>(b.getLedger()?.list()??[]).filter(e=>!e.undoneAt).map(e=>({id:e.id,at:e.at,toolId:e.toolId,action:e.action,kind:e.effect.kind,label:e.effect.label,reversible:jo(e.effect)})),undoAll:async()=>{let e=b.getLedger();return e?{ok:true,...await e.revertAll(pn)}:{ok:false,error:"No Ask Buoy session on this device."}},reset:async()=>{let e=await gn({dispatch:pn,undoFirst:true});return e.cleared?{ok:true,reverted:e.reverted}:{ok:false,error:`Couldn't undo ${e.failed.length} change${e.failed.length===1?"":"s"} \u2014 conversation kept.`,failed:e.failed}}}};import*as md from"@buoy-gg/license/web";import{HOSTED_HEADERS as gt,HOSTED_PROTOCOL_VERSION as xd}from"@buoy-gg/agent-core/web";var On="https://ai.buoy.gg/v1/chat/completions",Wn="openai/gpt-6-luna",kd=10*6e4;async function Mo(e=false){let t=md.SessionManager;if(!t)return null;let o=t.getStatus();return o.state==="active"&&(e||o.grace||(o.validUntil??0)-Date.now()<kd)&&await t.refresh(true),t.getAccessToken()}function En(e){let t=/^(https?:\/\/[^/]+)/.exec(e);return t?t[1]:e}function wd(e={}){let{endpoint:t=On,...o}=e,r=`ask-buoy ${$t.OS}`;return{...o,endpoint:t,hosted:true,protocol:"openai",model:Wn,maxTokens:8192,headers:async n=>{let i=await Mo((n?.attempt??1)>1);return{...i?{[gt.session]:i}:{},[gt.ask]:n?.askId??"ask_unknown000",[gt.round]:String(n?.round??1),[gt.attempt]:String(n?.attempt??1),[gt.protocol]:String(xd),[gt.client]:r}},readUsage:async()=>{let n=await Mo();if(!n)throw new Error("Sign in to see hosted credits.");let i=await fetch(`${En(t)}/v1/usage`,{headers:{[gt.session]:n}});if(!i.ok)throw new Error(`usage HTTP ${i.status}`);let a=await i.json();return{creditsLeft:a.creditsLeft??0,grantCredits:a.grantCredits??0,spentCredits:a.spentCredits??0,resetAt:a.resetAt??null}},reportProblem:async({requestId:n,code:i,note:a})=>{let h=await Mo(),u=await fetch(`${En(t)}/v1/report`,{method:"POST",headers:{"Content-Type":"application/json",...h?{[gt.session]:h}:{}},body:JSON.stringify({request_id:n,code:i,note:a,client:r})});if(!u.ok)throw new Error(`report HTTP ${u.status}`);let g=await u.json();if(!g.report_id)throw new Error("report: no id");return{reportId:g.report_id}}}}export{qo as ASK_BUOY_ADAPTER_VERSION,Ln as ASK_BUOY_ICON_COLOR,Wr as ApprovalCard,Qr as AskBuoyHeader,Hn as AskBuoyIcon,No as AskBuoyModal,yn as AskBuoySettings,We as BlockActionRow,O as BlockCard,ar as BlockHandlersProvider,no as BlockRenderer,jr as ChangesBar,_r as Composer,ds as EditableUserBubble,ls as ElapsedRow,On as HOSTED_ENDPOINT,Wn as HOSTED_MODEL,Lr as LivePill,yr as Markdown,ns as MessageActions,Bn as MessageList,hr as ProvenanceBadge,as as QueuedComposer,is as ReasoningStrip,ss as ReloadDivider,Cn as ThinkingStrip,cs as Timestamp,pt as askBuoySettings,b as askBuoyStore,yd as askBuoySyncAdapter,ao as askBuoyToolPreset,bd as createAskBuoyTool,Sn as hasTrace,wd as hostedAskBuoy,Ut as redactForWire,Eo as traceEntries,Tn as traceToText,bn as useAskBuoy,Ht as useAskBuoySettings,Lo as useAskBuoyState,Z as useBlockHandlers};
15
+ Still applied in the app. Clear the conversation anyway?`,[{text:"Keep conversation",style:"cancel"},{text:"Clear anyway",style:"destructive",onPress:g}])})()}},{text:"Clear anyway",style:"destructive",onPress:g},{text:"Cancel",style:"cancel"}])},[g,y]),Nn=Zt(()=>{let K=a.messages[a.messages.length-1];return!K||K.role!=="assistant"||!K.streaming?null:K.toolCalls.find(ie=>ie.status==="running")?.label??null},[a.messages]),Fo=Nr(b.getLedger()),_o=Zt(()=>ys(Fo),[Fo]),jn=Zt(()=>({answer:M,runAction:(K,ie)=>{if(K.minimize){r?.({mode:"bottomSheet"});return}return X(K,ie)},answered:a.answers,actionState:a.actionState,busy:a.busy,supports:{openTool:false,minimize:!!r,dispatch:true},rules:_o}),[M,X,r,a.answers,a.actionState,a.busy,_o]),qn=!a.busy&&Ie?.role==="assistant"&&!!Ie.error,Uo=!a.busy&&Ie?.role==="assistant"&&Ie.stopped&&!Ie.error?Ie.id:null,Mn=ln(a),{showThinking:Ko,readOnly:Go,hostedNoticeSeen:Fn}=Ht(),Jo=i?.hosted===true&&!Fn,_n=Me(()=>An(a.messages,Ko),[a.messages,Ko]),Un=Me(()=>h(gd),[h]),Kn=Ve?Pt(bo,{children:[pe(bo.Navigation,{onBack:st}),pe(bo.Content,{title:"Settings",subtitle:"Ask Buoy",testID:"buoy-ask-buoy-settings-title"})]}):pe(Yr,{configured:Ge,busy:a.busy,failed:qn,activeLabel:Nn,awaitingApproval:!!a.pending,startedAt:Ie?.role==="assistant"&&Ie.streaming?Ie.startedAt??null:null,stopping:a.stopping,readOnly:Go,toolCount:Re,hasMessages:a.messages.length>0,onBack:o,onReset:Vn,getTranscript:_n,onOpenSettings:Ye,onTicket:Un});return pe(_i,{visible:e,onClose:bt,disableScrollWrapper:true,background:false,initialHeight:560,animatedHeight:V,header:{customContent:Kn,showToggleButton:false},onBack:o,onMinimize:r,onModeChange:co,persistenceKey:n??"buoy-ask-buoy",enablePersistence:true,children:pe(ar,{value:jn,children:Pt(s,{style:[Ct.root,{paddingBottom:uo}],children:[pe(jr,{ledger:b.getLedger(),onUndoAll:po,expanded:Qe,onToggle:S}),Jo&&Pt(s,{style:Ct.notice,testID:"buoy-ask-buoy-hosted-notice",children:[pe(nr,{size:14,color:_e.color.info}),Pt(s,{style:{flex:1,gap:8},children:[pe(l,{style:Ct.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 weekly credits."}),pe(m,{testID:"buoy-ask-buoy-hosted-notice-ok",accessibilityRole:"button",onPress:()=>pt.set("hostedNoticeSeen",true),style:({pressed:K})=>[Ct.noticeButton,K&&{opacity:.7}],children:pe(l,{style:Ct.noticeButtonText,children:"Got it"})})]})]}),a.notice&&Pt(s,{style:Ct.notice,testID:"buoy-ask-buoy-notice",children:[pe(nr,{size:14,color:_e.color.info}),pe(l,{style:Ct.noticeText,children:a.notice})]}),pe(Is,{children:pe(Fi,{featureName:"Ask Buoy",children:Ve?pe(yn,{}):Pt(fd,{children:[pe(Bn,{messages:a.messages,onRetry:j,waitingOnUser:!!a.pending||!!a.awaitingBlockId,ListEmptyComponent:pe(Ac,{configured:Ge,onPick:h,availableToolIds:Je,readOnly:Go||!!i?.policy?.readOnly})}),pe(hd,{items:a.queued,paused:Mn,onEdit:ee,onRemove:ke}),a.pending&&pe(Wr,{pending:a.pending,onAnswer:C}),pe(_r,{onSend:h,onStop:u,busy:a.busy,draft:a.draft,onDraftTaken:It,disabled:!Ge||Jo,focusKey:Uo,canFocus:e,placeholder:Uo?"Tell it what to do differently\u2026":a.awaitingBlockId?"Pick an option above, or type\u2026":void 0})]})})})]})})})}var Ct=w.create({root:{flex:1,backgroundColor:"transparent"},notice:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:_e.gutter,paddingVertical:10,backgroundColor:_e.color.infoSoft},noticeText:{flex:1,color:_e.color.text,fontSize:_e.font.caption,lineHeight:18},noticeButton:{alignSelf:"flex-start",paddingHorizontal:12,paddingVertical:6,borderRadius:_e.radius.row,backgroundColor:_e.color.button},noticeButtonText:{color:_e.color.text,fontSize:_e.font.caption,fontWeight:"600"}});import{AskBuoyIcon as Hn,ASK_BUOY_ICON_COLOR as Ln}from"@buoy-gg/floating-tools-core/web";import{jsx as Pn}from"react/jsx-runtime";var ao={id:"ask-buoy",name:"ASK BUOY",description:"Ask about this app in plain English",slot:"both",color:Ln,icon:({size:e,slot:t})=>Pn(Hn,{size:t==="dial"?e*1.5:e}),component:No};function bd(e){let{name:t,description:o,...r}=e,n=r;return{...ao,name:t??ao.name,description:o??ao.description,component:i=>Pn(No,{...i,config:n})}}import{isReversible as jo}from"@buoy-gg/agent-core/web";var qo=1,yd={version:qo,async dispose(e){let t=b.getLedger();for(let o of t?.list()??[])o.undoneAt||o.effect.kind==="network-override"&&await e("network","deleteOverrideRule",{id:o.effect.ruleId})},getSnapshot(){let e=b.getState(),t=(b.getLedger()?.list()??[]).filter(o=>!o.undoneAt);return{version:qo,busy:e.busy,configured:e.configured,notice:e.notice,messageCount:e.messages.length,messages:e.messages.map(o=>({id:o.id,role:o.role,text:Ut(o.text),streaming:!!o.streaming,toolCalls:o.toolCalls.map(r=>({toolId:r.toolId,action:r.action,status:r.status}))})),usage:e.usage,pendingApproval:e.pending?{toolId:e.pending.toolId,action:e.pending.action,label:e.pending.label}:null,changes:{reversible:t.filter(o=>jo(o.effect)).length,permanent:t.filter(o=>o.effect.kind!=="transient"&&!jo(o.effect)).length,transients:t.filter(o=>o.effect.kind==="transient").length,items:t.map(o=>({kind:o.effect.kind,label:o.effect.label}))}}},subscribe(e){let t=b.subscribe(e),o=b.getLedger()?.subscribe(e);return()=>{t(),o?.()}},actions:{listChanges:()=>(b.getLedger()?.list()??[]).filter(e=>!e.undoneAt).map(e=>({id:e.id,at:e.at,toolId:e.toolId,action:e.action,kind:e.effect.kind,label:e.effect.label,reversible:jo(e.effect)})),undoAll:async()=>{let e=b.getLedger();return e?{ok:true,...await e.revertAll(pn)}:{ok:false,error:"No Ask Buoy session on this device."}},reset:async()=>{let e=await gn({dispatch:pn,undoFirst:true});return e.cleared?{ok:true,reverted:e.reverted}:{ok:false,error:`Couldn't undo ${e.failed.length} change${e.failed.length===1?"":"s"} \u2014 conversation kept.`,failed:e.failed}}}};import*as md from"@buoy-gg/license/web";import{HOSTED_HEADERS as gt,HOSTED_PROTOCOL_VERSION as xd}from"@buoy-gg/agent-core/web";var On="https://ai.buoy.gg/v1/chat/completions",Wn="openai/gpt-6-luna",kd=10*6e4;async function Mo(e=false){let t=md.SessionManager;if(!t)return null;let o=t.getStatus();return o.state==="active"&&(e||o.grace||(o.validUntil??0)-Date.now()<kd)&&await t.refresh(true),t.getAccessToken()}function En(e){let t=/^(https?:\/\/[^/]+)/.exec(e);return t?t[1]:e}function wd(e={}){let{endpoint:t=On,...o}=e,r=`ask-buoy ${$t.OS}`;return{...o,endpoint:t,hosted:true,protocol:"openai",model:Wn,maxTokens:8192,headers:async n=>{let i=await Mo((n?.attempt??1)>1);return{...i?{[gt.session]:i}:{},[gt.ask]:n?.askId??"ask_unknown000",[gt.round]:String(n?.round??1),[gt.attempt]:String(n?.attempt??1),[gt.protocol]:String(xd),[gt.client]:r}},readUsage:async()=>{let n=await Mo();if(!n)throw new Error("Sign in to see hosted credits.");let i=await fetch(`${En(t)}/v1/usage`,{headers:{[gt.session]:n}});if(!i.ok)throw new Error(`usage HTTP ${i.status}`);let a=await i.json();return{creditsLeft:a.creditsLeft??0,grantCredits:a.grantCredits??0,spentCredits:a.spentCredits??0,resetAt:a.resetAt??null}},reportProblem:async({requestId:n,code:i,note:a})=>{let h=await Mo(),u=await fetch(`${En(t)}/v1/report`,{method:"POST",headers:{"Content-Type":"application/json",...h?{[gt.session]:h}:{}},body:JSON.stringify({request_id:n,code:i,note:a,client:r})});if(!u.ok)throw new Error(`report HTTP ${u.status}`);let g=await u.json();if(!g.report_id)throw new Error("report: no id");return{reportId:g.report_id}}}}export{qo as ASK_BUOY_ADAPTER_VERSION,Ln as ASK_BUOY_ICON_COLOR,Wr as ApprovalCard,Yr as AskBuoyHeader,Hn as AskBuoyIcon,No as AskBuoyModal,yn as AskBuoySettings,We as BlockActionRow,O as BlockCard,ar as BlockHandlersProvider,no as BlockRenderer,jr as ChangesBar,_r as Composer,ds as EditableUserBubble,ls as ElapsedRow,On as HOSTED_ENDPOINT,Wn as HOSTED_MODEL,Lr as LivePill,yr as Markdown,ns as MessageActions,Bn as MessageList,hr as ProvenanceBadge,as as QueuedComposer,is as ReasoningStrip,ss as ReloadDivider,Cn as ThinkingStrip,cs as Timestamp,pt as askBuoySettings,b as askBuoyStore,yd as askBuoySyncAdapter,ao as askBuoyToolPreset,bd as createAskBuoyTool,Sn as hasTrace,wd as hostedAskBuoy,Ut as redactForWire,Eo as traceEntries,Tn as traceToText,bn as useAskBuoy,Ht as useAskBuoySettings,Lo as useAskBuoyState,Z as useBlockHandlers};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/ask-buoy",
3
- "version": "7.0.59",
3
+ "version": "7.0.61",
4
4
  "description": "In-app AI chat for supported Buoy inspection and action tools, using a configured model endpoint.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -25,12 +25,12 @@
25
25
  "buoy"
26
26
  ],
27
27
  "dependencies": {
28
- "@buoy-gg/agent-core": "^7.0.59",
29
- "@buoy-gg/shared-ui": "^7.0.59",
30
- "@buoy-gg/floating-tools-core": "^7.0.59"
28
+ "@buoy-gg/agent-core": "^7.0.61",
29
+ "@buoy-gg/floating-tools-core": "^7.0.61",
30
+ "@buoy-gg/shared-ui": "^7.0.61"
31
31
  },
32
32
  "peerDependencies": {
33
- "@buoy-gg/license": "7.0.59",
33
+ "@buoy-gg/license": "7.0.61",
34
34
  "react": "*"
35
35
  },
36
36
  "peerDependenciesMeta": {
@@ -51,8 +51,8 @@
51
51
  "@types/react": "^19.1.0",
52
52
  "@types/react-native": "^0.73.0",
53
53
  "typescript": "~5.8.3",
54
- "@buoy-gg/core": "^7.0.59",
55
- "@buoy-gg/license": "^7.0.59"
54
+ "@buoy-gg/license": "^7.0.61",
55
+ "@buoy-gg/core": "^7.0.61"
56
56
  },
57
57
  "react-native-builder-bob": {
58
58
  "source": "src",