@fungi.computer/grove 0.14.3 → 0.14.4

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.
Files changed (31) hide show
  1. package/dist/assets/{anthropic-messages-CJY16LDS.js → anthropic-messages-By4Z1bIQ.js} +3 -3
  2. package/dist/assets/{azure-openai-responses-CyIsMW3H.js → azure-openai-responses-BsDOUkgl.js} +1 -1
  3. package/dist/assets/{burger-CXZHp3Vm.js → burger-X7GJ8_Mj.js} +1 -1
  4. package/dist/assets/{cat-DFP4OQG_.js → cat-CNPpI38P.js} +1 -1
  5. package/dist/assets/{classifier-shared-BeyBBH6Z.js → classifier-shared-DvEpCno6.js} +1 -1
  6. package/dist/assets/{cloudflare-workers-ai-system-one-3h0jQXVW.js → cloudflare-workers-ai-system-one-DPsBwamJ.js} +1 -1
  7. package/dist/assets/{compat-yFrEl-nt.js → compat-CUOPBfwj.js} +2 -2
  8. package/dist/assets/{conversation-toast-CD2t_Qou.js → conversation-toast-D_EnORj5.js} +1 -1
  9. package/dist/assets/{extension-hook-0yB9nu6P.js → extension-hook-CejZHRxr.js} +3 -3
  10. package/dist/assets/{google-generative-ai-DHTpiQh0.js → google-generative-ai-DUCr7VeE.js} +1 -1
  11. package/dist/assets/{google-shared-CmgOGva7.js → google-shared-frBE3xCX.js} +1 -1
  12. package/dist/assets/{google-vertex-CZn0Rvpx.js → google-vertex-CD8r-zzv.js} +1 -1
  13. package/dist/assets/{index-Bt4eKlCq.js → index-D_xvnJKX.js} +4 -4
  14. package/dist/assets/{mistral-conversations-B-P0vlHt.js → mistral-conversations-Bw8p4PjN.js} +1 -1
  15. package/dist/assets/{node.browser-BZP4UCyF.js → node.browser-BZ5SwBMx.js} +1 -1
  16. package/dist/assets/{openai-codex-responses-T-wixMeT.js → openai-codex-responses-Dle2iCls.js} +1 -1
  17. package/dist/assets/{openai-completions-CsTOKFVX.js → openai-completions-B4WqFHby.js} +1 -1
  18. package/dist/assets/{openai-decisions-DKDTBjy8.js → openai-decisions-CVKh6c0B.js} +1 -1
  19. package/dist/assets/{openai-responses-CBkA_vk2.js → openai-responses-CkPbCkKF.js} +1 -1
  20. package/dist/assets/{openai-responses-shared-WiOcnzkF.js → openai-responses-shared-Clw6C8fA.js} +1 -1
  21. package/dist/assets/{openrouter-images-Dnkxh2k-.js → openrouter-images-BjBROYh8.js} +1 -1
  22. package/dist/assets/{parakeet-DzPDg3KU.js → parakeet-DopRJWw7.js} +1 -1
  23. package/dist/assets/{parakeet-conversation-CWVM_dXk.js → parakeet-conversation-2EAHj4_-.js} +1 -1
  24. package/dist/assets/{pi-messages---TE9XeZ.js → pi-messages-9oLqnyFC.js} +1 -1
  25. package/dist/assets/{runtime-core-DikVW_MY.js → runtime-core-Bfm0wdUM.js} +1 -1
  26. package/dist/assets/{system-one-shared-BZoqXlpk.js → system-one-shared-Bv09betA.js} +1 -1
  27. package/dist/assets/{transform-messages-CIryzy1w.js → transform-messages-Btz1iqkc.js} +1 -1
  28. package/dist/assets/{typesafe-system-one-DPCzc8aL.js → typesafe-system-one-DbReeYyW.js} +1 -1
  29. package/dist/assets/{website-conversation-BBx0dHMM.js → website-conversation-MEoi-Lrs.js} +1 -1
  30. package/dist/index.html +3 -3
  31. package/package.json +6 -6
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Br as t,Ci as n,Er as r,Fi as i,Gr as a,Hr as o,Mr as s,O as c,Ri as l,Vr as u,f as d,pt as f,t as p,u as m,v as ee,zr as h}from"./conversation-toast-CD2t_Qou.js";import{Ea as g,Ta as te,Zi as _,_a as v,ar as y,ba as ne,da as re,fa as ie,ht as ae,ra as oe,xa as b,ya as se}from"./Effect-DeiDqvoz.js";import{Ci as x,Di as S,Ei as C,Fi as ce,Ia as le,Ji as ue,Ki as w,La as T,Li as E,Na as D,Nr as de,Pi as O,Qi as k,Ra as A,Ri as fe,Ta as j,Ti as pe,Wi as me,_a as he,_i as M,ai as ge,ci as N,gi as P,i as F,jr as _e,ka as I,mi as ve,pa as L,pi as R,si as ye,ta as be,ua as xe,ui as z,wi as Se,xa as B,xi as Ce}from"./extension-hook-0yB9nu6P.js";import{a as we,c as Te,d as V,i as Ee,l as De,n as Oe,o as ke,r as Ae,s as je,u as Me}from"./parakeet-DzPDg3KU.js";import{_ as Ne,g as H,h as Pe,m as Fe,p as Ie,t as Le,v as Re,y as ze}from"./index-Bt4eKlCq.js";var U=e(l(),1),W=n(),G=C.check(I(1),j(256)),Be=R.check(L(1),B(2**53-1)),Ve=R.check(L(0),B(2**53-1)),He=M([`write`,`external`]),Ue=S({module:x(G),access:He}),We=S({agentId:x(G)}),Ge=S({principalId:G,agentId:x(G),sessionId:x(G),displayName:G}),Ke=S({title:C.check(I(1),j(512)),app:A(S({displayName:C.check(I(1),j(80)),operationLabel:C.check(I(1),j(1e3))})),inputBytes:R.check(L(0)),inputSha256:C.check(D(/^[a-f0-9]{64}$/))});S({kind:P(`pending_approval`),recordId:G,description:Ke});var qe=M([`requested`,`pending`,`approved`,`claimed`,`applied`,`denied`,`expired`,`outcome_unknown`]),Je=M([`not-found`,`not-eligible`,`already-answered`,`stale-revision`,`expired`,`declined`,`fenced`,`not-granted`,`read-only`,`pending`,`in-flight`,`outcome-unknown`,`identity-conflict`]),Ye=C.check(I(1),j(512),D(/^(?=.*\S)[^\p{Cc}\u2028\u2029]*$/u)),Xe=N(S({kind:P(`artifact`),ref:C.check(D(/^sha256:[a-f0-9]{64}$/)),mediaType:P(`image/png`),bytes:R.check(L(1),B(5242880))})).check(j(4)),Ze=S({recordId:G,requester:Ge,module:G,operation:G,access:He,description:Ke,evidence:A(Xe),authorityFence:G,reversibility:M([`reversible`,`irreversible-external`]),state:qe,by:x(O([S({kind:P(`human`),memberId:G}),S({kind:P(`policy`)})])),reason:x(Je),denialNote:A(Ye),requestedAt:Ve,expiresAt:Ve,updatedAt:Ve,revision:Be}),Qe=S({record:Ze,canAnswer:z,canSetAutoApprove:z});S({state:A(qe),cursor:A(G),limit:A(R.check(L(1),B(100)))}),S({recordId:G}),S({recordId:G,decision:M([`approve`,`deny`]),expectedRevision:Be,denialNote:A(Ye)});var $e=S({scope:We,family:Ue,enabled:z}),et=S({kind:P(`refused`),reason:Je,denialNote:A(Ye)});w(k(Ze),{onExcessProperty:`error`}),ue(k(Ze)),w(S({record_json:C})),w(k(ve)),ue(k(ve)),w(S({input_json:C,output_json:x(C)}));var tt=et,nt=S({items:N(Qe),nextCursor:x(C)}),rt=O([S({kind:P(`answered`),view:Qe}),tt]),it=O([S({kind:P(`updated`),rule:$e}),tt]),K=e=>Fe(te().transform(t=>w(e,{onExcessProperty:`error`})(t))),q=Re(`approvals`,1,ie(()=>Pe({list:H(K(nt)),get:H(K(x(Qe))),answer:H(K(rt)),setAutoApprove:H(K(it))}))),at=(e,t)=>{if(e.length<=t)return e;let n=Math.max(1,Math.floor((t-1)/2));return`${e.slice(0,n)}…${e.slice(-(t-n-1))}`},ot=(e,t)=>e.length<=t?e:`${e.slice(0,t-1)}…`,st=e=>e.map(([e,t])=>({label:e,value:t}));function ct(e,t){let{record:n}=e,r=Math.max(0,n.expiresAt-t);return[[`Agent`,`${n.requester.displayName} · ${n.requester.agentId??`none`}`],[`Session`,n.requester.sessionId??`none`],[`Requester`,n.requester.principalId],[`Request`,`${n.module}.${n.operation} · ${n.access}`],[`Input`,`${n.description.inputBytes.toLocaleString()} bytes · SHA-256 ${n.description.inputSha256.slice(0,8)}…${n.description.inputSha256.slice(-6)}`],[`Expires`,`in ${String(Math.floor(r/36e5))} h ${String(Math.floor(r%36e5/6e4))} m`],[`Record`,`${n.recordId} · revision ${String(n.revision)}`]]}function lt(e){return[`Undo`,e.record.reversibility===`irreversible-external`?`Can't be undone`:`Can be undone`]}function ut(e){let t=e.operationLabel.trim().replace(/\.$/,``);return t.length===0||/[.!?\n]/.test(t)?`Allow ${e.displayName} · ${e.operationLabel}?`:`Allow ${e.displayName} to ${t.charAt(0).toLowerCase()}${t.slice(1)}?`}function dt(e,t){let{record:n}=e;return{content:{title:n.description.app===void 0?`Allow ${n.module} · ${n.operation}?`:ut(n.description.app),summary:`${n.requester.displayName} wants to use a connected tool.`,facts:[{label:`Effect`,value:(n.access===`write`?`Changes data in Fungi`:`Changes things outside Fungi`)+(n.reversibility===`irreversible-external`?` · can't be undone`:``)}],details:st([lt(e),...ct(e,t)])}}}function ft(e,t,n,r,i){let a=t.prefix?.join(` `),o=a!==void 0&&t.alwaysAllowUnavailableReason===void 0,s=t.command,c=`Allow \`${s}\`?`.length<=n?`Allow \`${s}\`?`:`Allow this command?`,l=t.cwd===r?`~`:t.cwd.startsWith(`${r}/`)?`~${t.cwd.slice(r.length)}`:t.cwd,u=Math.max(8,(n-8)*2-2),d=t.justification.length<=u?`“${t.justification}”`:`“${t.justification.slice(0,u-1)}…”`,f=[[`Folder`,at(l,Math.max(8,n-10))],[`Why`,d]];t.kind===`extension-install`&&f.push([`Note`,`Extensions run inside Fungi with access to every Agent.`]),o&&t.alwaysAllowCoverage!==void 0&&f.push([`Scope`,ot(t.alwaysAllowCoverage,Math.max(8,n-12))]),!o&&t.risk!==void 0&&f.push([`Risk`,t.risk.summary]);let p=o?`Always allow “${at(a,Math.max(8,n-5-32))}” in this project…`:void 0,m=[[`Command`,s]];return t.argv!==void 0&&m.push([`Arguments`,JSON.stringify(t.argv)]),m.push([`Folder`,t.cwd],[`Runs`,`Outside the sandbox, as you`],lt(e)),!o&&t.alwaysAllowUnavailableReason!==void 0?m.push([`Rule`,t.alwaysAllowUnavailableReason]):t.form===`shell`?m.push([`Rule`,`Shell command: no Always-allow rule can match it.`]):o&&(m.push([`Rule`,`“${a}” would match \`${a} …\` in this project`]),t.alwaysAllowCoverage!==void 0&&m.push([`Coverage`,t.alwaysAllowCoverage])),t.risk!==void 0&&m.push([`Risk`,t.risk.detail]),m.push(...ct(e,i)),{content:{title:c,body:c===`Allow this command?`?s:void 0,bodyLabel:c===`Allow this command?`?`Command`:void 0,summary:`${e.record.requester.displayName} wants to run this outside the sandbox, as you.`,facts:st(f),details:st(m)},always:p===void 0?void 0:ot(p,Math.max(12,n-5)),confirmation:o?{title:`Always allow “${a}” in this project?`,body:ot(t.alwaysAllowCoverage??`Any Workspace Agent here can then run \`${a} …\` without asking.`,Math.max(12,(n-8)*2-2))}:void 0,confirmWarning:o?t.risk?.summary:void 0,confirmYes:o?`Always allow “${a}” and run it now`:void 0}}function pt(e,t,n){let r=Math.min(n.width,60);return t===void 0?dt(e,n.now):ft(e,t,r,n.home,n.now)}function mt(e,t){switch(e){case`stale-revision`:case`already-answered`:case`not-pending`:return`This request changed. Look again before answering.`;case`expired`:return`This request expired. Nothing ran.`;case`not-found`:return`This request is gone. Nothing ran. Ask the Agent to try again.`;case`declined`:return`This request was already denied. Nothing ran.`;case`not-eligible`:return t===`always-allow`?`Always allow isn't available for this command. Approve once or deny.`:`You can't answer this request. Nothing ran. Ask whoever owns it.`;case`not-granted`:case`read-only`:return`You aren't allowed to answer this request. Nothing ran. Ask whoever owns it.`;case`fenced`:case`identity-conflict`:return`This request no longer matches what you saw. Nothing ran. Refresh and look again.`;case`pending`:return`This request hasn't been answered yet. Answer it first.`;case`in-flight`:return`This is already running. Wait for it to finish.`;case`outcome-unknown`:return`We can't tell whether this ran. Check before trying again.`;case`not-attached`:return`This session isn't connected anymore. Reconnect and try again. Nothing ran.`;default:return`Couldn't answer this request. Nothing ran. Try again.`}}var ht=`Couldn't send your answer. It may not have been recorded.`;async function gt(e,t){let{view:n,source:r}=t,i=pt(n,r.review,{width:t.width,home:t.home,now:t.now}),a=n.record;try{let n,o,s=!1;for(;n===void 0;){let c=await e.prompt({type:`decision`,message:i.content.title,summary:s?`Automatic approval is on for ${a.description.app?.displayName??`this tool`}.`:i.content.summary,facts:i.content.facts?.map(e=>({...e})),body:i.content.body,bodyLabel:i.content.bodyLabel,details:i.content.details?.map(e=>({...e})),options:[{value:`approve`,label:`Approve once`},...i.always===void 0?[]:[{value:`always`,label:i.always}],...r.family===void 0||s?[]:[{value:`family`,label:r.family.label}],{value:`deny`,label:`Deny`}],other:{label:`Deny and say why…`,placeholder:`A short reason for the Agent (optional)`,maxLength:t.noteLimit,blank:`deny`}});if(!t.stillCurrent())return{kind:`abandoned`};if(c.text!==void 0)o=c.text.trim()||void 0,n=`deny`;else if(c.selected[0]===`always`){let r=i.confirmation,a=await e.prompt({type:`decision`,message:r?.title??i.content.title,summary:i.confirmWarning,body:r?.body,options:[{value:`back`,label:`Back`},{value:`always-allow`,label:i.confirmYes??`Always allow`}],escape:`back`});if(!t.stillCurrent())return{kind:`abandoned`};a.selected[0]===`always-allow`&&(n=`always-allow`)}else if(c.selected[0]===`family`&&r.family!==void 0){let n=await e.prompt({type:`decision`,message:`${r.family.label}?`,summary:`All ${a.description.app?.displayName??`this tool`} requests that ${a.access===`write`?`change data in Fungi`:`reach outside Fungi`} will run without asking, not just this action.`,options:[{value:`back`,label:`Back`},{value:`family`,label:r.family.label}],escape:`back`});if(!t.stillCurrent()||n.selected[0]===`family`&&(s=await r.family.enable(),!t.stillCurrent()))return{kind:`abandoned`}}else c.selected[0]===`approve`?n=`approve`:c.selected[0]===`deny`&&(n=`deny`)}let c={recordId:a.recordId,decision:n,expectedRevision:a.revision},l=await r.answer(o===void 0?c:{...c,denialNote:o});return t.stillCurrent()?l.kind===`refused`?{kind:`refused`,message:mt(l.reason??`unknown`,n)}:{kind:`answered`}:{kind:`abandoned`}}catch(n){return e.signal.aborted?{kind:`abandoned`}:(t.onFailure(n),{kind:`refused`,message:ht})}}var _t=()=>void 0,vt=()=>()=>void 0;function yt(e){let{source:t,store:n,enabled:r,home:i,width:a,noteLimit:o,onFailure:s}=e,c=(0,U.useRef)(s);c.current=s;let l=(0,U.useRef)({home:i,width:a,noteLimit:o});l.current={home:i,width:a,noteLimit:o};let u=(0,U.useSyncExternalStore)(t?.subscribe??vt,t?.snapshot??_t),d=(0,U.useRef)(u);d.current=u;let f=u===void 0?void 0:JSON.stringify([`approval`,u.record.recordId,u.record.revision,u.canAnswer]);(0,U.useEffect)(()=>{let e=d.current;if(!r||t===void 0||e===void 0||!e.canAnswer||f===void 0)return;let{home:i,width:a,noteLimit:o}=l.current,s=De({title:`Approval`}),u=s.begin(),p=()=>{let n=t.snapshot();return!u.interaction.signal.aborted&&n?.record.recordId===e.record.recordId&&n.record.revision===e.record.revision&&n.canAnswer},m=n.awaiting.add({key:f,kind:`approval`,arrivedAt:Date.now(),host:s});return gt(u.interaction,{view:e,source:t,home:i,width:a,now:Date.now(),noteLimit:o,stillCurrent:p,onFailure:e=>{c.current(e)}}).then(e=>{e.kind===`refused`?u.settle({status:`failed`,message:e.message}):(m(),u.settle(e.kind===`answered`?{status:`handled`}:{status:`cancelled`}))}),()=>{m(),s.cancel()}},[t,f,r,n])}var J=fe(e=>Me.safeParse(e).success,{representation:{id:`@fungi.computer/whistle/catalog-step/v1`,payload:null}});ae(()=>ye());var bt=C.pipe(E(I(1)),E(j(4e3)),E(D(/\S/u,{message:`Goal objective is blank`}))),xt=C.pipe(E(I(1)),E(j(1e3)),E(D(/\S/u))),St=C.pipe(E(I(1)),E(j(256))),Ct=R.check(L(0)),wt=S({kind:M([`person`,`delegator`,`blocked`,`stalled`,`cancelled`,`failed`,`no-terminal`]),detail:x(C)}),Y=S({revision:C,objective:bt,state:M([`active`,`paused`]),startedAt:Ct,pauseCause:x(wt)}),Tt=S({sequence:R.check(xe(0)),objective:bt,outcome:M([`achieved`,`cleared`]),reason:x(xt),clearedBy:A(Ce.check(j(256))),endedAt:Ct,afterSequence:R.check(L(0))}),Et=O([S({action:P(`set`),objective:bt,requestId:St,expectedRevision:T(x(C)),confirmed:T(z)}),S({action:M([`pause`,`resume`,`replace`,`clear`,`clear-ask`]),confirmed:T(z)}),S({})]),Dt=S({goal:x(Y),ended:N(Tt).check(j(16)),omitted:R.check(L(0))}),Ot={id:F.make(`botanical-session-goal`),commands:{controlAgent:{scope:`session`,input:S({action:M([`pause`,`resume`,`clear`]),reason:xt}),output:O([S({result:P(`paused`),goal:Y}),S({result:P(`resumed`),goal:Y}),S({result:P(`cleared`)}),S({result:P(`no_goal`)}),S({result:P(`refused`),reason:M([`not_delegator`,`not_paused_by_delegator`])})])},goal:{scope:`session`,input:Et,output:J},pause:{scope:`session`,input:S({}),output:Y},resume:{scope:`session`,input:S({}),output:Y},clear:{scope:`session`,input:S({}),output:S({})},set:{scope:`session`,input:S({objective:bt,expectedRevision:x(C),requestId:St,adoptCommandId:A(St)}),output:S({goal:Y,accepted:S({status:P(`accepted`),commandId:C})})}},projection:{schema:Dt}},X=e=>{let t=e.replace(/\s+/gu,` `).trim();return t.length<=80?t:`${t.slice(0,79)}…`},kt=e=>{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`};function At(e){let t=e.state===`active`,n=t?`Pursuing goal since ${kt(e.startedAt)}`:e.pauseCause?.kind===`delegator`?`Goal paused by ${X(e.pauseCause.detail??`delegator`)} (/goal resume)`:`Goal paused (/goal resume)`,r=!t&&e.pauseCause?.kind!==`delegator`&&e.pauseCause?.detail!=null?[X(e.pauseCause.detail)]:[],i={id:`goal`,title:[n,X(e.objective),...r].join(` · `),tone:t?`running`:`muted`,actions:[{id:`goal`,label:t?`Pause goal`:`Resume goal`,input:{action:t?`pause`:`resume`}}]};return X(e.objective)===e.objective?i:{...i,detail:e.objective.slice(0,1024)}}function jt(e){let t={id:`goal-ended`,title:`${e.outcome===`achieved`?`Goal achieved`:`Goal cleared`} · ${X(e.objective)}`,tone:e.outcome===`achieved`?`settled`:`muted`},n=e.reason===null?t:{...t,detail:e.reason};return{id:String(e.sequence),sequence:e.sequence,at:e.endedAt,commandId:null,afterSequence:e.afterSequence,rows:[n]}}var Mt=V(Ot,{promptPresentation:`footer`,contribute:e=>{if(e.status!==`running`||e.value===null)return{chips:[],panel:[],timeline:{cells:[],omitted:0},waiting:null};let{goal:t,ended:n,omitted:r}=e.value;return{chips:[],panel:t===null?[]:[At(t)],timeline:{cells:n.map(jt),omitted:r},waiting:null}}}),Nt=C.pipe(E(I(1)),E(j(256))),Pt=C.pipe(E(I(1)),E(j(262144))),Ft=S({expression:C.pipe(E(I(1)),E(j(256))),timeZone:C.pipe(E(I(1)),E(j(128)))}),Z=S({loopId:C,origin:M([`human`,`model`]),expiresAt:x(R),prompt:Pt,mode:M([`self_paced`,`fixed_interval`]),cron:x(Ft),state:M([`active`,`paused`,`finished`,`failed`,`cancelled`]),commandId:C,reason:x(C),nextDueAt:x(R),lastError:x(C),consecutiveFailures:R.pipe(E(L(0)))}),It=S({after:A(Nt),limit:A(R.pipe(E(be({minimum:1,maximum:64}))))}),Lt=C.pipe(E(I(1)),E(j(200))),Rt=S({loop:Z,accepted:S({status:P(`accepted`),commandId:C})}),zt=O([S({action:P(`start`),text:Pt,requestId:Lt}),S({action:M([`status`,`pause`,`resume`,`stop`,`stop-ask`,`new`]),confirmed:T(z)}),S({})]),Bt=S({loop:Z}),Vt=S({sessionId:Nt,loopId:Z.fields.loopId}),Ht={id:F.make(`botanical-session-loop`),commands:{list:{scope:`agent`,input:It,output:N(S({...Z.fields,sessionId:Nt})).pipe(E(j(64)))},pauseLoop:{scope:`agent`,input:Vt,output:Z},resumeLoop:{scope:`agent`,input:Vt,output:Z},stopLoop:{scope:`agent`,input:Vt,output:Z},loop:{scope:`session`,input:zt,output:J},startSelfPaced:{scope:`session`,input:S({prompt:Pt,requestId:Lt}),output:Rt},startFixedInterval:{scope:`session`,input:S({prompt:Pt,requestId:Lt,...Ft.fields}),output:Rt},pause:{scope:`session`,input:S({}),output:Z},resume:{scope:`session`,input:S({}),output:Z},stop:{scope:`session`,input:S({}),output:Z}},projection:{schema:Bt}},Ut=e=>{let t=e.replace(/\s+/gu,` `).trim();return t.length<=60?t:`${t.slice(0,59)}…`},Wt=e=>e.state===`failed`?`error`:e.state===`active`?`running`:e.state===`paused`?`muted`:`settled`,Gt=e=>new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,timeZoneName:`short`}).format(e),Kt=V(Ht,{promptPresentation:`footer`,contribute:e=>{if(e.status!==`running`||e.value===null)return{chips:[],panel:[],timeline:{cells:[],omitted:0},waiting:null};let{loop:t}=e.value,n=t.state===`active`&&t.nextDueAt!==null;return{chips:t.state!==`active`&&t.state!==`paused`?[]:[{id:`loop`,order:2,row:{id:`loop`,title:`Loop ${t.mode===`self_paced`?`self-paced`:`fixed`}${n?` (waiting)`:``}`,tone:Wt(t)}}],panel:[{id:`loop`,title:`Loop · ${t.state} · ${t.mode===`self_paced`?`self-paced`:`${t.cron?.expression??`fixed`} ${t.cron?.timeZone??``}`}${t.nextDueAt===null?``:` · Next ${Gt(t.nextDueAt)}`} · ${Ut(t.prompt)}`,detail:[t.reason,t.prompt].filter(e=>e!==null).join(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Br as t,Ci as n,Er as r,Fi as i,Gr as a,Hr as o,Mr as s,O as c,Ri as l,Vr as u,f as d,pt as f,t as p,u as m,v as ee,zr as h}from"./conversation-toast-D_EnORj5.js";import{Ea as g,Ta as te,Zi as _,_a as v,ar as y,ba as ne,da as re,fa as ie,ht as ae,ra as oe,xa as b,ya as se}from"./Effect-DeiDqvoz.js";import{Ci as x,Di as S,Ei as C,Fi as ce,Ia as le,Ji as ue,Ki as w,La as T,Li as E,Na as D,Nr as de,Pi as O,Qi as k,Ra as A,Ri as fe,Ta as j,Ti as pe,Wi as me,_a as he,_i as M,ai as ge,ci as N,gi as P,i as F,jr as _e,ka as I,mi as ve,pa as L,pi as R,si as ye,ta as be,ua as xe,ui as z,wi as Se,xa as B,xi as Ce}from"./extension-hook-CejZHRxr.js";import{a as we,c as Te,d as V,i as Ee,l as De,n as Oe,o as ke,r as Ae,s as je,u as Me}from"./parakeet-DopRJWw7.js";import{_ as Ne,g as H,h as Pe,m as Fe,p as Ie,t as Le,v as Re,y as ze}from"./index-D_xvnJKX.js";var U=e(l(),1),W=n(),G=C.check(I(1),j(256)),Be=R.check(L(1),B(2**53-1)),Ve=R.check(L(0),B(2**53-1)),He=M([`write`,`external`]),Ue=S({module:x(G),access:He}),We=S({agentId:x(G)}),Ge=S({principalId:G,agentId:x(G),sessionId:x(G),displayName:G}),Ke=S({title:C.check(I(1),j(512)),app:A(S({displayName:C.check(I(1),j(80)),operationLabel:C.check(I(1),j(1e3))})),inputBytes:R.check(L(0)),inputSha256:C.check(D(/^[a-f0-9]{64}$/))});S({kind:P(`pending_approval`),recordId:G,description:Ke});var qe=M([`requested`,`pending`,`approved`,`claimed`,`applied`,`denied`,`expired`,`outcome_unknown`]),Je=M([`not-found`,`not-eligible`,`already-answered`,`stale-revision`,`expired`,`declined`,`fenced`,`not-granted`,`read-only`,`pending`,`in-flight`,`outcome-unknown`,`identity-conflict`]),Ye=C.check(I(1),j(512),D(/^(?=.*\S)[^\p{Cc}\u2028\u2029]*$/u)),Xe=N(S({kind:P(`artifact`),ref:C.check(D(/^sha256:[a-f0-9]{64}$/)),mediaType:P(`image/png`),bytes:R.check(L(1),B(5242880))})).check(j(4)),Ze=S({recordId:G,requester:Ge,module:G,operation:G,access:He,description:Ke,evidence:A(Xe),authorityFence:G,reversibility:M([`reversible`,`irreversible-external`]),state:qe,by:x(O([S({kind:P(`human`),memberId:G}),S({kind:P(`policy`)})])),reason:x(Je),denialNote:A(Ye),requestedAt:Ve,expiresAt:Ve,updatedAt:Ve,revision:Be}),Qe=S({record:Ze,canAnswer:z,canSetAutoApprove:z});S({state:A(qe),cursor:A(G),limit:A(R.check(L(1),B(100)))}),S({recordId:G}),S({recordId:G,decision:M([`approve`,`deny`]),expectedRevision:Be,denialNote:A(Ye)});var $e=S({scope:We,family:Ue,enabled:z}),et=S({kind:P(`refused`),reason:Je,denialNote:A(Ye)});w(k(Ze),{onExcessProperty:`error`}),ue(k(Ze)),w(S({record_json:C})),w(k(ve)),ue(k(ve)),w(S({input_json:C,output_json:x(C)}));var tt=et,nt=S({items:N(Qe),nextCursor:x(C)}),rt=O([S({kind:P(`answered`),view:Qe}),tt]),it=O([S({kind:P(`updated`),rule:$e}),tt]),K=e=>Fe(te().transform(t=>w(e,{onExcessProperty:`error`})(t))),q=Re(`approvals`,1,ie(()=>Pe({list:H(K(nt)),get:H(K(x(Qe))),answer:H(K(rt)),setAutoApprove:H(K(it))}))),at=(e,t)=>{if(e.length<=t)return e;let n=Math.max(1,Math.floor((t-1)/2));return`${e.slice(0,n)}…${e.slice(-(t-n-1))}`},ot=(e,t)=>e.length<=t?e:`${e.slice(0,t-1)}…`,st=e=>e.map(([e,t])=>({label:e,value:t}));function ct(e,t){let{record:n}=e,r=Math.max(0,n.expiresAt-t);return[[`Agent`,`${n.requester.displayName} · ${n.requester.agentId??`none`}`],[`Session`,n.requester.sessionId??`none`],[`Requester`,n.requester.principalId],[`Request`,`${n.module}.${n.operation} · ${n.access}`],[`Input`,`${n.description.inputBytes.toLocaleString()} bytes · SHA-256 ${n.description.inputSha256.slice(0,8)}…${n.description.inputSha256.slice(-6)}`],[`Expires`,`in ${String(Math.floor(r/36e5))} h ${String(Math.floor(r%36e5/6e4))} m`],[`Record`,`${n.recordId} · revision ${String(n.revision)}`]]}function lt(e){return[`Undo`,e.record.reversibility===`irreversible-external`?`Can't be undone`:`Can be undone`]}function ut(e){let t=e.operationLabel.trim().replace(/\.$/,``);return t.length===0||/[.!?\n]/.test(t)?`Allow ${e.displayName} · ${e.operationLabel}?`:`Allow ${e.displayName} to ${t.charAt(0).toLowerCase()}${t.slice(1)}?`}function dt(e,t){let{record:n}=e;return{content:{title:n.description.app===void 0?`Allow ${n.module} · ${n.operation}?`:ut(n.description.app),summary:`${n.requester.displayName} wants to use a connected tool.`,facts:[{label:`Effect`,value:(n.access===`write`?`Changes data in Fungi`:`Changes things outside Fungi`)+(n.reversibility===`irreversible-external`?` · can't be undone`:``)}],details:st([lt(e),...ct(e,t)])}}}function ft(e,t,n,r,i){let a=t.prefix?.join(` `),o=a!==void 0&&t.alwaysAllowUnavailableReason===void 0,s=t.command,c=`Allow \`${s}\`?`.length<=n?`Allow \`${s}\`?`:`Allow this command?`,l=t.cwd===r?`~`:t.cwd.startsWith(`${r}/`)?`~${t.cwd.slice(r.length)}`:t.cwd,u=Math.max(8,(n-8)*2-2),d=t.justification.length<=u?`“${t.justification}”`:`“${t.justification.slice(0,u-1)}…”`,f=[[`Folder`,at(l,Math.max(8,n-10))],[`Why`,d]];t.kind===`extension-install`&&f.push([`Note`,`Extensions run inside Fungi with access to every Agent.`]),o&&t.alwaysAllowCoverage!==void 0&&f.push([`Scope`,ot(t.alwaysAllowCoverage,Math.max(8,n-12))]),!o&&t.risk!==void 0&&f.push([`Risk`,t.risk.summary]);let p=o?`Always allow “${at(a,Math.max(8,n-5-32))}” in this project…`:void 0,m=[[`Command`,s]];return t.argv!==void 0&&m.push([`Arguments`,JSON.stringify(t.argv)]),m.push([`Folder`,t.cwd],[`Runs`,`Outside the sandbox, as you`],lt(e)),!o&&t.alwaysAllowUnavailableReason!==void 0?m.push([`Rule`,t.alwaysAllowUnavailableReason]):t.form===`shell`?m.push([`Rule`,`Shell command: no Always-allow rule can match it.`]):o&&(m.push([`Rule`,`“${a}” would match \`${a} …\` in this project`]),t.alwaysAllowCoverage!==void 0&&m.push([`Coverage`,t.alwaysAllowCoverage])),t.risk!==void 0&&m.push([`Risk`,t.risk.detail]),m.push(...ct(e,i)),{content:{title:c,body:c===`Allow this command?`?s:void 0,bodyLabel:c===`Allow this command?`?`Command`:void 0,summary:`${e.record.requester.displayName} wants to run this outside the sandbox, as you.`,facts:st(f),details:st(m)},always:p===void 0?void 0:ot(p,Math.max(12,n-5)),confirmation:o?{title:`Always allow “${a}” in this project?`,body:ot(t.alwaysAllowCoverage??`Any Workspace Agent here can then run \`${a} …\` without asking.`,Math.max(12,(n-8)*2-2))}:void 0,confirmWarning:o?t.risk?.summary:void 0,confirmYes:o?`Always allow “${a}” and run it now`:void 0}}function pt(e,t,n){let r=Math.min(n.width,60);return t===void 0?dt(e,n.now):ft(e,t,r,n.home,n.now)}function mt(e,t){switch(e){case`stale-revision`:case`already-answered`:case`not-pending`:return`This request changed. Look again before answering.`;case`expired`:return`This request expired. Nothing ran.`;case`not-found`:return`This request is gone. Nothing ran. Ask the Agent to try again.`;case`declined`:return`This request was already denied. Nothing ran.`;case`not-eligible`:return t===`always-allow`?`Always allow isn't available for this command. Approve once or deny.`:`You can't answer this request. Nothing ran. Ask whoever owns it.`;case`not-granted`:case`read-only`:return`You aren't allowed to answer this request. Nothing ran. Ask whoever owns it.`;case`fenced`:case`identity-conflict`:return`This request no longer matches what you saw. Nothing ran. Refresh and look again.`;case`pending`:return`This request hasn't been answered yet. Answer it first.`;case`in-flight`:return`This is already running. Wait for it to finish.`;case`outcome-unknown`:return`We can't tell whether this ran. Check before trying again.`;case`not-attached`:return`This session isn't connected anymore. Reconnect and try again. Nothing ran.`;default:return`Couldn't answer this request. Nothing ran. Try again.`}}var ht=`Couldn't send your answer. It may not have been recorded.`;async function gt(e,t){let{view:n,source:r}=t,i=pt(n,r.review,{width:t.width,home:t.home,now:t.now}),a=n.record;try{let n,o,s=!1;for(;n===void 0;){let c=await e.prompt({type:`decision`,message:i.content.title,summary:s?`Automatic approval is on for ${a.description.app?.displayName??`this tool`}.`:i.content.summary,facts:i.content.facts?.map(e=>({...e})),body:i.content.body,bodyLabel:i.content.bodyLabel,details:i.content.details?.map(e=>({...e})),options:[{value:`approve`,label:`Approve once`},...i.always===void 0?[]:[{value:`always`,label:i.always}],...r.family===void 0||s?[]:[{value:`family`,label:r.family.label}],{value:`deny`,label:`Deny`}],other:{label:`Deny and say why…`,placeholder:`A short reason for the Agent (optional)`,maxLength:t.noteLimit,blank:`deny`}});if(!t.stillCurrent())return{kind:`abandoned`};if(c.text!==void 0)o=c.text.trim()||void 0,n=`deny`;else if(c.selected[0]===`always`){let r=i.confirmation,a=await e.prompt({type:`decision`,message:r?.title??i.content.title,summary:i.confirmWarning,body:r?.body,options:[{value:`back`,label:`Back`},{value:`always-allow`,label:i.confirmYes??`Always allow`}],escape:`back`});if(!t.stillCurrent())return{kind:`abandoned`};a.selected[0]===`always-allow`&&(n=`always-allow`)}else if(c.selected[0]===`family`&&r.family!==void 0){let n=await e.prompt({type:`decision`,message:`${r.family.label}?`,summary:`All ${a.description.app?.displayName??`this tool`} requests that ${a.access===`write`?`change data in Fungi`:`reach outside Fungi`} will run without asking, not just this action.`,options:[{value:`back`,label:`Back`},{value:`family`,label:r.family.label}],escape:`back`});if(!t.stillCurrent()||n.selected[0]===`family`&&(s=await r.family.enable(),!t.stillCurrent()))return{kind:`abandoned`}}else c.selected[0]===`approve`?n=`approve`:c.selected[0]===`deny`&&(n=`deny`)}let c={recordId:a.recordId,decision:n,expectedRevision:a.revision},l=await r.answer(o===void 0?c:{...c,denialNote:o});return t.stillCurrent()?l.kind===`refused`?{kind:`refused`,message:mt(l.reason??`unknown`,n)}:{kind:`answered`}:{kind:`abandoned`}}catch(n){return e.signal.aborted?{kind:`abandoned`}:(t.onFailure(n),{kind:`refused`,message:ht})}}var _t=()=>void 0,vt=()=>()=>void 0;function yt(e){let{source:t,store:n,enabled:r,home:i,width:a,noteLimit:o,onFailure:s}=e,c=(0,U.useRef)(s);c.current=s;let l=(0,U.useRef)({home:i,width:a,noteLimit:o});l.current={home:i,width:a,noteLimit:o};let u=(0,U.useSyncExternalStore)(t?.subscribe??vt,t?.snapshot??_t),d=(0,U.useRef)(u);d.current=u;let f=u===void 0?void 0:JSON.stringify([`approval`,u.record.recordId,u.record.revision,u.canAnswer]);(0,U.useEffect)(()=>{let e=d.current;if(!r||t===void 0||e===void 0||!e.canAnswer||f===void 0)return;let{home:i,width:a,noteLimit:o}=l.current,s=De({title:`Approval`}),u=s.begin(),p=()=>{let n=t.snapshot();return!u.interaction.signal.aborted&&n?.record.recordId===e.record.recordId&&n.record.revision===e.record.revision&&n.canAnswer},m=n.awaiting.add({key:f,kind:`approval`,arrivedAt:Date.now(),host:s});return gt(u.interaction,{view:e,source:t,home:i,width:a,now:Date.now(),noteLimit:o,stillCurrent:p,onFailure:e=>{c.current(e)}}).then(e=>{e.kind===`refused`?u.settle({status:`failed`,message:e.message}):(m(),u.settle(e.kind===`answered`?{status:`handled`}:{status:`cancelled`}))}),()=>{m(),s.cancel()}},[t,f,r,n])}var J=fe(e=>Me.safeParse(e).success,{representation:{id:`@fungi.computer/whistle/catalog-step/v1`,payload:null}});ae(()=>ye());var bt=C.pipe(E(I(1)),E(j(4e3)),E(D(/\S/u,{message:`Goal objective is blank`}))),xt=C.pipe(E(I(1)),E(j(1e3)),E(D(/\S/u))),St=C.pipe(E(I(1)),E(j(256))),Ct=R.check(L(0)),wt=S({kind:M([`person`,`delegator`,`blocked`,`stalled`,`cancelled`,`failed`,`no-terminal`]),detail:x(C)}),Y=S({revision:C,objective:bt,state:M([`active`,`paused`]),startedAt:Ct,pauseCause:x(wt)}),Tt=S({sequence:R.check(xe(0)),objective:bt,outcome:M([`achieved`,`cleared`]),reason:x(xt),clearedBy:A(Ce.check(j(256))),endedAt:Ct,afterSequence:R.check(L(0))}),Et=O([S({action:P(`set`),objective:bt,requestId:St,expectedRevision:T(x(C)),confirmed:T(z)}),S({action:M([`pause`,`resume`,`replace`,`clear`,`clear-ask`]),confirmed:T(z)}),S({})]),Dt=S({goal:x(Y),ended:N(Tt).check(j(16)),omitted:R.check(L(0))}),Ot={id:F.make(`botanical-session-goal`),commands:{controlAgent:{scope:`session`,input:S({action:M([`pause`,`resume`,`clear`]),reason:xt}),output:O([S({result:P(`paused`),goal:Y}),S({result:P(`resumed`),goal:Y}),S({result:P(`cleared`)}),S({result:P(`no_goal`)}),S({result:P(`refused`),reason:M([`not_delegator`,`not_paused_by_delegator`])})])},goal:{scope:`session`,input:Et,output:J},pause:{scope:`session`,input:S({}),output:Y},resume:{scope:`session`,input:S({}),output:Y},clear:{scope:`session`,input:S({}),output:S({})},set:{scope:`session`,input:S({objective:bt,expectedRevision:x(C),requestId:St,adoptCommandId:A(St)}),output:S({goal:Y,accepted:S({status:P(`accepted`),commandId:C})})}},projection:{schema:Dt}},X=e=>{let t=e.replace(/\s+/gu,` `).trim();return t.length<=80?t:`${t.slice(0,79)}…`},kt=e=>{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`};function At(e){let t=e.state===`active`,n=t?`Pursuing goal since ${kt(e.startedAt)}`:e.pauseCause?.kind===`delegator`?`Goal paused by ${X(e.pauseCause.detail??`delegator`)} (/goal resume)`:`Goal paused (/goal resume)`,r=!t&&e.pauseCause?.kind!==`delegator`&&e.pauseCause?.detail!=null?[X(e.pauseCause.detail)]:[],i={id:`goal`,title:[n,X(e.objective),...r].join(` · `),tone:t?`running`:`muted`,actions:[{id:`goal`,label:t?`Pause goal`:`Resume goal`,input:{action:t?`pause`:`resume`}}]};return X(e.objective)===e.objective?i:{...i,detail:e.objective.slice(0,1024)}}function jt(e){let t={id:`goal-ended`,title:`${e.outcome===`achieved`?`Goal achieved`:`Goal cleared`} · ${X(e.objective)}`,tone:e.outcome===`achieved`?`settled`:`muted`},n=e.reason===null?t:{...t,detail:e.reason};return{id:String(e.sequence),sequence:e.sequence,at:e.endedAt,commandId:null,afterSequence:e.afterSequence,rows:[n]}}var Mt=V(Ot,{promptPresentation:`footer`,contribute:e=>{if(e.status!==`running`||e.value===null)return{chips:[],panel:[],timeline:{cells:[],omitted:0},waiting:null};let{goal:t,ended:n,omitted:r}=e.value;return{chips:[],panel:t===null?[]:[At(t)],timeline:{cells:n.map(jt),omitted:r},waiting:null}}}),Nt=C.pipe(E(I(1)),E(j(256))),Pt=C.pipe(E(I(1)),E(j(262144))),Ft=S({expression:C.pipe(E(I(1)),E(j(256))),timeZone:C.pipe(E(I(1)),E(j(128)))}),Z=S({loopId:C,origin:M([`human`,`model`]),expiresAt:x(R),prompt:Pt,mode:M([`self_paced`,`fixed_interval`]),cron:x(Ft),state:M([`active`,`paused`,`finished`,`failed`,`cancelled`]),commandId:C,reason:x(C),nextDueAt:x(R),lastError:x(C),consecutiveFailures:R.pipe(E(L(0)))}),It=S({after:A(Nt),limit:A(R.pipe(E(be({minimum:1,maximum:64}))))}),Lt=C.pipe(E(I(1)),E(j(200))),Rt=S({loop:Z,accepted:S({status:P(`accepted`),commandId:C})}),zt=O([S({action:P(`start`),text:Pt,requestId:Lt}),S({action:M([`status`,`pause`,`resume`,`stop`,`stop-ask`,`new`]),confirmed:T(z)}),S({})]),Bt=S({loop:Z}),Vt=S({sessionId:Nt,loopId:Z.fields.loopId}),Ht={id:F.make(`botanical-session-loop`),commands:{list:{scope:`agent`,input:It,output:N(S({...Z.fields,sessionId:Nt})).pipe(E(j(64)))},pauseLoop:{scope:`agent`,input:Vt,output:Z},resumeLoop:{scope:`agent`,input:Vt,output:Z},stopLoop:{scope:`agent`,input:Vt,output:Z},loop:{scope:`session`,input:zt,output:J},startSelfPaced:{scope:`session`,input:S({prompt:Pt,requestId:Lt}),output:Rt},startFixedInterval:{scope:`session`,input:S({prompt:Pt,requestId:Lt,...Ft.fields}),output:Rt},pause:{scope:`session`,input:S({}),output:Z},resume:{scope:`session`,input:S({}),output:Z},stop:{scope:`session`,input:S({}),output:Z}},projection:{schema:Bt}},Ut=e=>{let t=e.replace(/\s+/gu,` `).trim();return t.length<=60?t:`${t.slice(0,59)}…`},Wt=e=>e.state===`failed`?`error`:e.state===`active`?`running`:e.state===`paused`?`muted`:`settled`,Gt=e=>new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,timeZoneName:`short`}).format(e),Kt=V(Ht,{promptPresentation:`footer`,contribute:e=>{if(e.status!==`running`||e.value===null)return{chips:[],panel:[],timeline:{cells:[],omitted:0},waiting:null};let{loop:t}=e.value,n=t.state===`active`&&t.nextDueAt!==null;return{chips:t.state!==`active`&&t.state!==`paused`?[]:[{id:`loop`,order:2,row:{id:`loop`,title:`Loop ${t.mode===`self_paced`?`self-paced`:`fixed`}${n?` (waiting)`:``}`,tone:Wt(t)}}],panel:[{id:`loop`,title:`Loop · ${t.state} · ${t.mode===`self_paced`?`self-paced`:`${t.cron?.expression??`fixed`} ${t.cron?.timeZone??``}`}${t.nextDueAt===null?``:` · Next ${Gt(t.nextDueAt)}`} · ${Ut(t.prompt)}`,detail:[t.reason,t.prompt].filter(e=>e!==null).join(`
2
2
  `).slice(0,1024),tone:Wt(t)},...t.lastError===null?[]:[{id:`error`,title:t.lastError.slice(0,4096),tone:`error`}]],timeline:{cells:[],omitted:0},waiting:n?{summary:`Waiting until ${Gt(t.nextDueAt)}`,cancel:{id:`loop`,label:`stop loop`,input:{action:`stop-ask`}}}:null}}});function qt(e){return S({nextSequence:R.check(xe(0)),omitted:R.check(L(0)),events:N(S({id:C,sequence:R,at:R,commandId:x(C),event:e}))})}new TextEncoder;var Jt=S({explanation:A(C.pipe(E(j(2e3)))),steps:N(S({step:C.pipe(E(I(1)),E(j(500))),status:M([`pending`,`in_progress`,`completed`])})).pipe(E(j(50)))});Jt.pipe(E(le(e=>e.steps.filter(e=>e.status===`in_progress`).length<=1||`At most one plan step may be in progress`)));function Yt(e){return e.steps.some(e=>e.status!==`completed`)}var Xt=S({plan:Jt,history:qt(Jt)}),Zt=O([S({action:P(`clear`)}),S({})]),Qt={id:F.make(`botanical-session-plan`),commands:{plan:{scope:`session`,input:Zt,output:J}},projection:{schema:Xt}},$t=e=>{let t=e.steps.findIndex(e=>e.status===`in_progress`),n=e.steps.filter(e=>e.status===`completed`).length;return{title:(t<0?e.steps.find(e=>e.status===`pending`):e.steps[t])?.step??`Plan complete`,detail:`${String(t<0?n:t+1)}/${String(e.steps.length)}`}},en=e=>e.steps.map((e,t)=>({id:String(t),title:e.step,tone:e.status===`completed`?`settled`:e.status===`in_progress`?`running`:`muted`})),tn=V(Qt,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null||!Yt(e.value.plan)?[]:[{id:`plan`,...$t(e.value.plan),actions:[{id:`plan`,label:`Clear plan`,input:{action:`clear`}}],inspection:{commandId:`plan`,title:`Plan`,rows:en(e.value.plan)}}],timeline:{cells:[],omitted:0},waiting:null})}),Q=e=>C.check(I(1),j(e),D(/\S/u)),nn=S({id:Q(32).check(D(/^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/u)),header:Q(12),question:Q(1e3),options:N(S({label:Q(60),description:Q(300)})).check(I(2),j(4),le(e=>new Set(e.map(e=>e.label)).size===e.length||`Option labels must be unique`,{representation:{id:`botanical/ask/unique-option-labels`,payload:null}})),multiple:A(z)}),rn=N(nn).check(I(1),j(4),le(e=>new Set(e.map(e=>e.id)).size===e.length||`Question ids must be unique`,{representation:{id:`botanical/ask/unique-question-ids`,payload:null}})),an=S({askId:C,waitingOn:A(de),escalated:A(_e),questions:rn,status:M([`live`,`parked`]),createdAt:Se,expiresAt:x(Se)}),on=S({asks:N(an).check(j(4))}),sn=Q(256),cn=pe(nn.fields.id,S({selected:N(Q(60)).check(j(4)),text:A(C.check(j(4e3)))})),ln=S({askId:Q(256),requestId:sn,answers:cn}),un=S({askId:Q(256),requestId:sn,note:A(C.check(j(4e3)))}),dn=M([`answered`,`declined`,`withdrawn`,`expired`,`cancelled`,`undeliverable`]),fn=O([S({result:P(`accepted`),via:M([`in_turn`,`follow_up`]),commandId:A(Q(256))}),S({result:P(`closed`),status:dn}),S({result:P(`not_found`)})]),pn=S({result:P(`refused`),reason:P(`not_sender`)}),mn=O([fn,pn]),hn=S({kind:P(`agent`),agentId:Q(256)}),gn=O([S({result:P(`escalated`),to:P(`agent`),waitingOn:de}),S({result:P(`escalated`),to:P(`person`)}),S({result:P(`closed`),status:dn}),S({result:P(`not_found`)}),pn]),_n=S({askId:Q(256),note:T(C.check(j(1e3)))}),vn={askId:ln.fields.askId,requestId:sn,index:Se.check(he(),be({minimum:0,maximum:3})),answers:cn},yn=O([S({stage:P(`decision`),...vn,answer:cn.value}),S({askId:ln.fields.askId}),S({})]),bn={id:F.make(`botanical-session-question`),commands:{answerFlow:{scope:`session`,input:yn,output:J},answer:{scope:`session`,input:ln,output:fn},answerAgent:{scope:`session`,input:ln,output:S({result:mn,answeredBy:hn})},escalateAgent:{scope:`session`,input:_n,output:gn},decline:{scope:`session`,input:un,output:fn},list:{scope:`session`,input:S({}),output:on}},projection:{schema:on}},xn=V(bn,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null?[]:e.value.asks.map(e=>{let t=e.questions[0],n=`${t?.question??`Question`}${e.questions.length>1?` (+${String(e.questions.length-1)} more)`:``}`,r=t?.options.map(e=>e.label).join(` · `)??``;if(e.escalated!==void 0){let{by:t,reason:i,note:a}=e.escalated;n=`${i===`escalated`?`escalated by ${t.name}`:i===`sender_archived`?`${t.name} archived`:`${t.name} is gone`} · ${n}`,a!==void 0&&(r=`${r}\n${a}`)}return e.waitingOn===void 0?{id:e.askId,title:n,detail:r,tone:`attention`,actions:[{id:`answerFlow`,label:`Answer`,input:{askId:e.askId},awaiting:`question`}]}:{id:e.askId,title:`waiting on ${e.waitingOn.name} · ${n}`,detail:r,tone:`muted`,actions:[{id:`answerFlow`,label:`Answer`,input:{askId:e.askId}}]}}),timeline:{cells:[],omitted:0},waiting:null})}),$=C.check(I(1),j(256)),Sn=M([`escalated`,`sender_archived`,`sender_absent`]),Cn=M([`working`,`waiting_on_agent`,`needs_you`,`idle`,`failed`,`unavailable`]),wn=S({agentId:$,name:$,sessionId:x($),state:Cn,attention:A(C.check(j(200))),waitingOn:A($),escalated:A(S({by:$,reason:Sn})),ask:A(S({askId:$,questions:rn}))}),Tn=S({agents:N(wn).check(j(16)),more:R.check(L(0)),uncounted:R.check(L(0)),counts:S({working:R.check(L(0)),waiting_on_agent:R.check(L(0)),needs_you:R.check(L(0)),idle:R.check(L(0)),failed:R.check(L(0)),unavailable:R.check(L(0))}),escalated:R.check(L(0)),waitingOn:N(S({name:$,count:R.check(xe(0))})),escalatedBy:N(S({name:$,reason:Sn,count:R.check(xe(0))})),expanded:z}),En={agentId:$,sessionId:$},Dn=O(yn.members.map(e=>S({...e.fields,...En}))),On={agents:{scope:`session`,input:S({}),output:J},answerChild:{scope:`session`,input:Dn,output:J}},kn={id:F.make(`botanical-session-subagents`),commands:On,projection:{schema:Tn}};function An(e){if(e!==void 0)return e.reason===`escalated`?`escalated by ${e.by}`:e.reason===`sender_archived`?`${e.by} archived`:`${e.by} is gone`}var jn={working:{label:`working`,tone:`running`,status:`info`},waiting_on_agent:{label:`waiting`,tone:`muted`,status:`neutral`},needs_you:{label:`needs you`,tone:`attention`,status:`warning`},idle:{label:`idle`,tone:`settled`,status:`success`},failed:{label:`failed`,tone:`error`,status:`error`},unavailable:{label:`unavailable`,tone:`muted`,status:`neutral`}};function Mn(e){let t=e.state===`waiting_on_agent`?`waiting on ${e.waitingOn??`its parent`}`:jn[e.state].label,n=An(e.escalated);return n===void 0?t:`${t} · ${n}`}function Nn(e){let t=jn[e.state],n={id:e.agentId,title:`${e.name} · ${Mn(e)}`,tone:t.tone,status:{label:Mn(e),tone:t.status}},r=e.ask?.questions[0]?.question??e.attention,i=r===void 0?n:{...n,detail:r.slice(0,200)};if(e.sessionId===null)return{...i,detail:e.attention??`not messaged yet`};let a={...i,open:{params:[{key:`agent`,value:e.agentId},{key:`session`,value:e.sessionId}]}};if(e.ask===void 0)return a;let o={id:`answerChild`,label:`Answer`,input:{agentId:e.agentId,sessionId:e.sessionId,askId:e.ask.askId}};return{...a,actions:[e.state===`needs_you`?{...o,awaiting:`question`}:o]}}function Pn(e){let t=t=>e.counts[t],n=e.waitingOn.map(({name:e,count:t})=>`${String(t)} waiting on ${e}`),r=e.escalatedBy.map(({name:n,reason:r,count:i})=>{let a=An({by:n,reason:r});return e.escalated===t(`needs_you`)&&e.escalatedBy.length===1?a:`${String(i)} ${a}`}),i=r.length===0?`needs you`:`needs you (${r.join(`; `)})`,a=[...[`working`].map(e=>[e,t(e)]).filter(([,e])=>e>0).map(([e,t])=>`${String(t)} ${jn[e].label}`),...n,...[`needs_you`,`failed`,`unavailable`].map(e=>[e,t(e)]).filter(([,e])=>e>0).map(([e,t])=>`${String(t)} ${e===`needs_you`?i:jn[e].label}`)],o=t(`working`)+t(`needs_you`),s=t(`needs_you`)>0?`attention`:t(`failed`)>0?`error`:t(`working`)>0?`running`:`muted`;return{id:`summary`,title:[`${String(o)} sub-agent${o===1?``:`s`}`,...a,...e.uncounted>0?[`${String(e.uncounted)} not read`]:[],`/agents shows them`].join(` · `),tone:s}}var Fn=V(kn,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null?[]:e.value.agents.length>0&&!e.value.expanded?[Pn(e.value)]:[...e.value.agents.map(Nn),...e.value.more===0&&e.value.uncounted===0?[]:[{id:`more`,title:[...e.value.more===0?[]:[`${String(e.value.more)} more sub-agent${e.value.more===1?``:`s`}`],...e.value.uncounted===0?[]:[`${String(e.value.uncounted)} not read`]].join(` · `),tone:`muted`}]],timeline:{cells:[],omitted:0},waiting:null})});function In(e,t){if(e===null||!URL.canParse(t))return!1;let n=new URL(t);return n.protocol!==`https:`||n.hash!==`#team-billing`?!1:(e.openTeamBilling().catch(t=>(console.error(`Chat Billing navigation failed`,t),e.showToast({message:`Billing could not be opened. Please try again.`,tone:`error`}))),!0)}function Ln(e){if(e.name!==`execute`||e.status!==`completed`)return;let t=e.result?.content;if(t?.length!==1||t[0]?.type!==`text`)return;let n=me(k(ce))(t[0].text);if(y(n))return;let r=f.safeParse(n.value);return r.success?r.data.file:void 0}function Rn({item:e,ui:t}){let n=Ln(e),[i,a]=(0,U.useState)(!1);if(!n)return null;let o=async()=>{a(!0);try{await t.openNavigation(n)}catch(e){console.error(`Chat file navigation failed`,e),p(t,{variant:`error`,message:`The file could not be opened. Try again.`})}finally{a(!1)}};return(0,W.jsx)(`div`,{className:`px-3 py-2`,children:(0,W.jsx)(r,{variant:`ghost`,size:`sm`,disabled:i,onClick:()=>void o(),type:`button`,children:i?`Opening file…`:`Open ${n.path} in Inkcap`})})}var zn=O([S({kind:P(`compose`),text:C.pipe(E(I(1)),E(j(2e3)))}),S({kind:P(`navigate`),params:N(S({key:C.pipe(E(I(1)),E(j(64))),value:C.pipe(E(j(1024)))})).pipe(E(j(16)))})]);O([S({role:C.pipe(E(I(1)),E(j(80))),intent:zn}),S({appId:C.pipe(E(I(1)),E(j(128))),intent:zn})],{mode:`oneOf`});var Bn=ne({displayName:b().min(1).max(80).nullable()}).nullable(),Vn=Re(`apps.open`,1,ie(()=>Pe({open:Ne,role:H(Fe(Bn))}))),Hn=(e,t)=>e.require(Vn).open(t);Re(`apps.call`,1,ie(()=>Pe({call:H(Fe(te().transform(e=>i(e))))})));var Un=v({printId:b().min(1).max(256),destination:ne({computerId:b().min(1),path:b().min(1)}),format:_([`png`,`jpeg`,`gif`,`webp`])}),Wn=re(),Gn=oe(Wn).or(se(b(),Wn).transform(e=>Object.values(e)));function Kn(e,t){let n=Un.safeParse(e);if(n.success)return[n.data];if(t>=3)return[];let r=Gn.safeParse(e);return r.success?r.data.flatMap(e=>Kn(e,t+1)):[]}var qn=Wn.transform(e=>Kn(e,0)).pipe(oe(Un).min(1).max(8));function Jn(e){if(e.name!==`execute`||e.status!==`completed`||e.result===void 0)return;let t=e.result.content,n=t.at(0);if(n?.type!==`text`||t.slice(1).some(e=>e.type!==`image`))return;let r=me(k(ce))(n.text);if(y(r))return;let i=qn.safeParse(r.value);return i.success?i.data:void 0}function Yn(e){return Jn(e)!==void 0}function Xn({printId:e,pictures:t,capabilities:n,ui:i}){let[a,o]=(0,U.useState)(!1),s=async()=>{o(!0);try{await Hn(n,{role:`media`,intent:{kind:`navigate`,params:[{key:`print`,value:e}]}})}catch(e){console.error(`Chat print navigation failed`,e),p(i,{variant:`error`,message:`Prints could not be opened. Try again.`})}finally{o(!1)}};return(0,W.jsxs)(`div`,{className:`flex flex-col items-start gap-2 px-3 py-2`,children:[t.map((e,t)=>(0,W.jsx)(`img`,{alt:`Panel saved in Prints`,className:`max-w-full rounded-box`,src:`data:${e.mimeType};base64,${e.data}`,style:{maxHeight:320}},t)),(0,W.jsx)(r,{variant:`outline`,size:`sm`,disabled:a,onClick:()=>void s(),type:`button`,children:a?`Opening Prints…`:`Open in Prints`})]})}function Zn({item:e,capabilities:t,ui:n}){let r=Jn(e);if(r&&t){let i=(e.result?.content??[]).flatMap(e=>e.type===`image`?[e]:[]),a=i.length===r.length;return(0,W.jsx)(W.Fragment,{children:r.map((e,r)=>(0,W.jsx)(Xn,{printId:e.printId,pictures:a?i.slice(r,r+1):r===0?i:[],capabilities:t,ui:n},e.printId))})}return null}var Qn=2e3;function $n(e,t,n,r){let[i,a]=(0,U.useState)([]);return(0,U.useEffect)(()=>{if(e===void 0){a([]);return}let i=e,o=!0;async function s(){try{let e=(await i.require(q).list({state:`pending`,limit:100})).items.filter(e=>e.record.requester.agentId===t&&e.record.requester.sessionId===n).map(e=>e.record.recordId);o&&a(t=>t.join()===e.join()?t:e)}catch(e){console.warn(`Grove could not list pending approvals`,e)}}if(s(),!r)return()=>{o=!1};let c=setInterval(()=>void s(),Qn);return()=>{o=!1,clearInterval(c)}},[e,t,n,r]),i}var er=`Couldn't send your answer. It may not have been recorded.`;function tr({recordId:e,capabilities:t,agentId:n}){let r=je(),[i,a]=(0,U.useState)(),o=(0,U.useRef)(void 0),s=(0,U.useRef)(new Set),c=(0,U.useCallback)(e=>{o.current=e??void 0,a(e);for(let e of s.current)e()},[]);(0,U.useEffect)(()=>{o.current=void 0,a(void 0)},[t]),(0,U.useEffect)(()=>{let n=!0;async function r(){try{let r=await t.require(q).get({recordId:e});n&&c(r)}catch(e){console.warn(`Grove could not read the approval`,e)}}return r(),()=>{n=!1}},[t,e,c]);let l=i?.canAnswer===!0&&i.record.state===`pending`,u=i?.canSetAutoApprove===!0,d=i?.record.module,f=i?.record.access,p=i?.record.description.app?.displayName??`this App`;return yt({source:(0,U.useMemo)(()=>{if(l)return{snapshot:()=>o.current,subscribe:e=>(s.current.add(e),()=>{s.current.delete(e)}),answer:async e=>{let n=t.require(q),r=e.decision===`always-allow`?void 0:{recordId:e.recordId,decision:e.decision,expectedRevision:e.expectedRevision};if(r===void 0)return{kind:`refused`,reason:`not-eligible`};let i=await n.answer(e.denialNote===void 0?r:{...r,denialNote:e.denialNote});return i.kind===`answered`&&c(i.view),i},family:!u||d===void 0||f===void 0?void 0:{label:`Always allow ${p} to ${f===`write`?`change data`:`act outside Fungi`}`,enable:async()=>(await t.require(q).setAutoApprove({scope:{agentId:n},family:{module:d,access:f},enabled:!0})).kind===`updated`}}},[l,t,n,u,d,f,p,c]),store:r,enabled:!0,home:``,width:72,noteLimit:512,onFailure:nr}),null}function nr(e){console.warn(er,e)}function rr({capabilities:e,agentId:t,sessionId:n,children:r}){let i=Te(),a=$n(e,t,n,(0,U.useMemo)(()=>[...i.settled,...i.tail].some(e=>e.kind===`tool_group`&&e.tools.some(e=>e.status===`running`)),[i.settled,i.tail]));return(0,W.jsxs)(W.Fragment,{children:[e===void 0?null:a.map(n=>(0,W.jsx)(tr,{recordId:n,capabilities:e,agentId:t},n)),r]})}var ir=(0,U.forwardRef)(function({heading:e,eyebrow:n,cover:i,action:s,children:c,className:l,...d},f){return(0,W.jsxs)(h,{...d,className:a(`caps-game-share`,l),ref:f,children:[i?(0,W.jsx)(`div`,{className:`caps-game-share-cover`,children:i}):null,(0,W.jsxs)(o,{children:[n,(0,W.jsx)(`h3`,{className:`caps-game-share-heading`,children:e})]}),(0,W.jsx)(t,{className:`gap-sm`,children:c}),(0,W.jsx)(u,{children:(0,W.jsx)(r,{asChild:!0,variant:`primary`,className:`caps-game-share-action`,children:s})})]})});function ar(e){let t=0;return e.map(e=>{let n={...e,offset:t};return t+=e.text.length,n})}function or({value:e,label:t,fieldLabel:n,displayValue:i,layout:o,title:l,tokens:u,className:f,...p}){let h=(0,U.useId)(),[g,te]=(0,U.useState)({kind:`ready`}),_=u?u.map(e=>e.text).join(``):e,v=async()=>{te(await navigator.clipboard.writeText(_).then(()=>({kind:`copied`}),e=>({kind:`failed`,cause:e})))};if(n!==void 0)return(0,W.jsxs)(`div`,{...p,className:a(`caps-copy-field-input`,f),children:[(0,W.jsx)(d,{htmlFor:h,children:n}),(0,W.jsxs)(m,{children:[(0,W.jsx)(ee,{className:`caps-copy-field-control`,"aria-label":n,id:h,onFocus:e=>{e.currentTarget.select()},readOnly:!0,value:i??_}),(0,W.jsx)(r,{onClick:()=>void v(),variant:`outline`,children:g.kind===`copied`?`Copied`:t??`Copy`})]}),g.kind===`failed`?(0,W.jsx)(`span`,{role:`status`,children:`Could not copy. Select the text to copy it.`}):null]});let y=g.kind===`copied`?`Copied`:g.kind===`failed`?`Copy failed`:t??`Copy`;return o===`block`?(0,W.jsxs)(`figure`,{...p,className:a(`caps-copy-field-block`,f),"data-state":g.kind,children:[(0,W.jsxs)(`figcaption`,{className:`caps-copy-field-header`,children:[(0,W.jsx)(`span`,{className:`caps-copy-field-title`,children:l}),(0,W.jsxs)(r,{onClick:()=>void v(),size:`sm`,variant:g.kind===`copied`?`ghost`:`outline`,children:[g.kind===`copied`?(0,W.jsx)(c,{"aria-hidden":`true`,size:15}):(0,W.jsx)(Ee,{"aria-hidden":`true`,size:15}),y]}),(0,W.jsx)(s,{role:`status`,children:g.kind===`copied`?`Copied to the clipboard`:g.kind===`failed`?`Could not copy. Select the code to copy it.`:``})]}),(0,W.jsx)(`pre`,{className:`caps-copy-field-code`,tabIndex:0,children:(0,W.jsx)(`code`,{children:u?ar(u).map(e=>(0,W.jsx)(`span`,{className:`caps-copy-field-token`,"data-kind":e.kind,children:e.text},e.offset)):_})})]}):(0,W.jsxs)(`div`,{...p,className:a(`caps-copy-field`,f),children:[(0,W.jsx)(`code`,{className:`caps-copy-field-value`,children:_}),(0,W.jsxs)(r,{"aria-label":`${y}: ${_}`,onClick:()=>void v(),size:`sm`,variant:`outline`,children:[g.kind===`copied`?(0,W.jsx)(c,{size:15}):(0,W.jsx)(Ee,{size:15}),y]})]})}var sr=v({game:v({title:b().min(1),summary:b(),coverUrl:g().nullable(),shareUrl:g()})});function cr(e){let t=/(?:^|\n)\s*Share:\s*(https?:\/\/[^\s<>]+)/iu.exec(e);if(!t?.[1])return null;let n=t[1].replace(/[.,;!?]+$/u,``);if(!URL.canParse(n))return null;let r=new URL(n);return r.username||r.password||r.hash||r.protocol===`http:`&&![`localhost`,`127.0.0.1`].includes(r.hostname)?null:r.href}function lr(e){return cr(e)?e.split(`
3
3
  `).filter(e=>!/^\s*Share:\s*/iu.test(e)).join(`
4
4
  `).trim():e}function ur(e){let t=new URL(e),n=/^\/([a-z0-9]+(?:-[a-z0-9]+)*)\/?$/u.exec(t.pathname)?.[1];return!n||t.search?null:new URL(`/api/games/${n}`,t.origin)}function dr({reply:e,previewGame:t}){let n=cr(e),r=n?ur(n):null,{data:i}=ze({queryKey:Ie.of(null,`game-share`,n),enabled:r!==null&&t===void 0,queryFn:async({signal:e})=>{if(!r)return null;let t=await fetch(r,{signal:e});if(!t.ok)return null;let i=sr.safeParse(await t.json());return i.success&&i.data.game.shareUrl===n?i.data.game:null}}),a=t??i;if(!n)return null;let o=new URL(n),s=`${o.host}${o.pathname.replace(/\/$/u,``)}`,c=a?.coverUrl&&r?t?a.coverUrl:new URL(`${r.pathname}/cover`,r.origin).href:null;return(0,W.jsxs)(ir,{"data-game-share-card":`true`,"data-theme":`vishnu`,heading:a?.title??`Your game is ready`,eyebrow:(0,W.jsx)(Ae,{tone:`secondary`,variant:`quiet`,children:`Made with your Agent`}),cover:c?(0,W.jsx)(`img`,{alt:`A scene from ${a?.title??`your game`}`,src:c}):null,action:(0,W.jsx)(`a`,{href:n,rel:`noopener noreferrer`,target:`_blank`,children:`Play ↗`}),children:[a?.summary?(0,W.jsx)(`p`,{className:`text-sm`,children:a.summary}):null,(0,W.jsx)(or,{displayValue:s,fieldLabel:`Share link`,label:`Copy link`,value:n})]})}var fr=[Mt,Kt,tn,xn,Fn],pr=e=>(0,W.jsx)(dr,{reply:e});function mr({prefill:e,onPrefilled:t}){let n=ke(),r=(0,U.useRef)(null);return(0,U.useEffect)(()=>{!e||r.current===e.requestId||(r.current=e.requestId,n.setDraft(e.text),e.send===!0&&n.send(),t())},[n.setDraft,n.send,t,e]),null}function hr({session:e,draftIdentity:t,connection:n,commands:r,prefill:i=null,onPrefilled:a=()=>void 0,onOpen:o,models:s,autoFocus:c}){let l=n?.ui??null,u=n?.capabilities,d=(0,U.useMemo)(()=>({modelSetup:s===void 0?void 0:{state:s,fix:{label:`Add a model key`,onSelect:()=>{l?.openSetup(`model`).catch(e=>{console.error(`Grove could not open model setup`,e)})}}},starters:Le}),[s,l]),f=(0,U.useCallback)(e=>In(l,e),[l]),m=(0,U.useCallback)(e=>l?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Rn,{item:e,ui:l}),(0,W.jsx)(Zn,{item:e,capabilities:u,ui:l})]}):null,[l,u]),ee=(0,U.useCallback)(e=>u!==void 0&&Yn(e),[u]),h=(0,U.useCallback)(e=>{p(l,e)},[l]);return(0,W.jsxs)(we,{session:e,draftIdentity:t,clients:fr,authorOf:ge,onToast:h,children:[(0,W.jsx)(mr,{prefill:i,onPrefilled:a}),(0,W.jsx)(rr,{capabilities:u,agentId:t.agentId,sessionId:t.sessionId,children:(0,W.jsx)(Oe,{onLink:f,onOpen:o,hostFacts:d,autoFocus:c,composerActionVariant:`outline`,commands:r,renderAssistantAttachment:pr,formatAssistantText:lr,renderToolActions:m,claimsToolMedia:ee})},t.sessionId)]})}export{hr as ParakeetConversation};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./text-_WthCHzw.js";import{t}from"./provider-env-CcCbsTJq.js";import{a as n,n as r,t as i}from"./diagnostics-CxvqSC4Q.js";import{n as a,t as o}from"./headers-FK4rgixo.js";import{n as s}from"./streaming-json-Dg-jk7Sx.js";import{getIdentityHeaders as c}from"./compat-yFrEl-nt.js";var l=class extends Error{code;diagnosticDetails;constructor(e,t,n){super(e),this.name=`PiMessagesResponseError`,this.code=t,this.diagnosticDetails=n}};function u(e){try{let t=JSON.parse(e),n=t?.error;return t&&typeof n==`object`&&n&&!Array.isArray(n)?t:void 0}catch{return}}function d(t){let n=8192;return t.length>n?`${e(t,0,n)}…`:t}function f(e,t,n){let r=typeof n?.error?.message==`string`?n.error.message:void 0,i=typeof n?.error?.code==`string`?n.error.code:void 0,a=r??t,o=i?` (${i})`:``;return`${e.status} ${e.statusText}: ${a}${o}`}function p(e,t,n,r){let i=u(r),a=typeof i?.error?.code==`string`?i.error.code:void 0;return new l(f(n,r,i),a,{version:1,provider:e.provider,model:e.id,url:t.toString(),status:n.status,statusText:n.statusText,...i?.error===void 0?{}:{error:i.error},...i?{}:{body:d(r)},timestampMs:Date.now()})}function m(){return{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}function h(e,t){t&&i(e,{type:`pi_messages_rewrite`,timestamp:Date.now(),details:{...t}})}function g(e){let t={role:`assistant`,content:[],api:e.api,provider:e.provider,model:e.id,usage:m(),stopReason:`pending`,timestamp:Date.now()},n=new Map;return e=>{if(`contentIndex`in e){let n=e.contentIndex,r=e.type.endsWith(`_start`)?t.content.length:t.content.length-1;if(typeof n!=`number`||!Number.isInteger(n)||n<0||n>r)throw Error(`Invalid contentIndex ${JSON.stringify(n)} in pi-messages ${e.type} event`)}switch(e.type){case`done`:return Object.assign(t,{stopReason:e.reason,usage:e.usage,responseId:e.responseId}),e.responseModel!==void 0&&(t.responseModel=e.responseModel),e.providerThinkingLevel!==void 0&&(t.providerThinkingLevel=e.providerThinkingLevel),h(t,e.rewrite),{type:`done`,reason:e.reason,message:t};case`error`:return Object.assign(t,{stopReason:e.reason,usage:e.usage,errorMessage:e.errorMessage,responseId:e.responseId}),e.responseModel!==void 0&&(t.responseModel=e.responseModel),e.providerThinkingLevel!==void 0&&(t.providerThinkingLevel=e.providerThinkingLevel),h(t,e.rewrite),{type:`error`,reason:e.reason,error:t};case`start`:break;case`text_start`:t.content[e.contentIndex]={type:`text`,text:``};break;case`text_delta`:t.content[e.contentIndex].text+=e.delta;break;case`text_end`:Object.assign(t.content[e.contentIndex],{text:e.content,textSignature:e.contentSignature});break;case`thinking_start`:t.content[e.contentIndex]={type:`thinking`,thinking:``};break;case`thinking_delta`:t.content[e.contentIndex].thinking+=e.delta;break;case`thinking_end`:Object.assign(t.content[e.contentIndex],{thinking:e.content,thinkingSignature:e.contentSignature,redacted:e.redacted});break;case`toolcall_start`:t.content[e.contentIndex]={type:`toolCall`,id:e.id,name:e.toolName,arguments:{}},n.set(e.contentIndex,new s);break;case`toolcall_delta`:{let r=n.get(e.contentIndex);r!==void 0&&(t.content[e.contentIndex].arguments=r.append(e.delta));break}case`toolcall_end`:return Object.assign(t.content[e.contentIndex],e.toolCall),n.delete(e.contentIndex),{type:`toolcall_end`,contentIndex:e.contentIndex,toolCall:t.content[e.contentIndex],partial:t}}return{...e,partial:t}}}async function*_(e){let t=new TextDecoder,n=e.getReader(),r=``;try{for(;;){let{done:e,value:i}=await n.read();r+=e?t.decode():t.decode(i,{stream:!0}),r=r.replace(/\r\n/g,`
1
+ import{r as e}from"./text-_WthCHzw.js";import{t}from"./provider-env-CcCbsTJq.js";import{a as n,n as r,t as i}from"./diagnostics-CxvqSC4Q.js";import{n as a,t as o}from"./headers-FK4rgixo.js";import{n as s}from"./streaming-json-Dg-jk7Sx.js";import{getIdentityHeaders as c}from"./compat-CUOPBfwj.js";var l=class extends Error{code;diagnosticDetails;constructor(e,t,n){super(e),this.name=`PiMessagesResponseError`,this.code=t,this.diagnosticDetails=n}};function u(e){try{let t=JSON.parse(e),n=t?.error;return t&&typeof n==`object`&&n&&!Array.isArray(n)?t:void 0}catch{return}}function d(t){let n=8192;return t.length>n?`${e(t,0,n)}…`:t}function f(e,t,n){let r=typeof n?.error?.message==`string`?n.error.message:void 0,i=typeof n?.error?.code==`string`?n.error.code:void 0,a=r??t,o=i?` (${i})`:``;return`${e.status} ${e.statusText}: ${a}${o}`}function p(e,t,n,r){let i=u(r),a=typeof i?.error?.code==`string`?i.error.code:void 0;return new l(f(n,r,i),a,{version:1,provider:e.provider,model:e.id,url:t.toString(),status:n.status,statusText:n.statusText,...i?.error===void 0?{}:{error:i.error},...i?{}:{body:d(r)},timestampMs:Date.now()})}function m(){return{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}function h(e,t){t&&i(e,{type:`pi_messages_rewrite`,timestamp:Date.now(),details:{...t}})}function g(e){let t={role:`assistant`,content:[],api:e.api,provider:e.provider,model:e.id,usage:m(),stopReason:`pending`,timestamp:Date.now()},n=new Map;return e=>{if(`contentIndex`in e){let n=e.contentIndex,r=e.type.endsWith(`_start`)?t.content.length:t.content.length-1;if(typeof n!=`number`||!Number.isInteger(n)||n<0||n>r)throw Error(`Invalid contentIndex ${JSON.stringify(n)} in pi-messages ${e.type} event`)}switch(e.type){case`done`:return Object.assign(t,{stopReason:e.reason,usage:e.usage,responseId:e.responseId}),e.responseModel!==void 0&&(t.responseModel=e.responseModel),e.providerThinkingLevel!==void 0&&(t.providerThinkingLevel=e.providerThinkingLevel),h(t,e.rewrite),{type:`done`,reason:e.reason,message:t};case`error`:return Object.assign(t,{stopReason:e.reason,usage:e.usage,errorMessage:e.errorMessage,responseId:e.responseId}),e.responseModel!==void 0&&(t.responseModel=e.responseModel),e.providerThinkingLevel!==void 0&&(t.providerThinkingLevel=e.providerThinkingLevel),h(t,e.rewrite),{type:`error`,reason:e.reason,error:t};case`start`:break;case`text_start`:t.content[e.contentIndex]={type:`text`,text:``};break;case`text_delta`:t.content[e.contentIndex].text+=e.delta;break;case`text_end`:Object.assign(t.content[e.contentIndex],{text:e.content,textSignature:e.contentSignature});break;case`thinking_start`:t.content[e.contentIndex]={type:`thinking`,thinking:``};break;case`thinking_delta`:t.content[e.contentIndex].thinking+=e.delta;break;case`thinking_end`:Object.assign(t.content[e.contentIndex],{thinking:e.content,thinkingSignature:e.contentSignature,redacted:e.redacted});break;case`toolcall_start`:t.content[e.contentIndex]={type:`toolCall`,id:e.id,name:e.toolName,arguments:{}},n.set(e.contentIndex,new s);break;case`toolcall_delta`:{let r=n.get(e.contentIndex);r!==void 0&&(t.content[e.contentIndex].arguments=r.append(e.delta));break}case`toolcall_end`:return Object.assign(t.content[e.contentIndex],e.toolCall),n.delete(e.contentIndex),{type:`toolcall_end`,contentIndex:e.contentIndex,toolCall:t.content[e.contentIndex],partial:t}}return{...e,partial:t}}}async function*_(e){let t=new TextDecoder,n=e.getReader(),r=``;try{for(;;){let{done:e,value:i}=await n.read();r+=e?t.decode():t.decode(i,{stream:!0}),r=r.replace(/\r\n/g,`
2
2
  `);let a=r.indexOf(`
3
3
 
4
4
  `);for(;a!==-1;){let e=v(r.slice(0,a));e&&(yield e),r=r.slice(a+2),a=r.indexOf(`
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,Ct as n,D as r,F as i,G as a,I as o,J as s,K as c,N as l,O as u,P as d,Qr as f,R as p,St as m,V as h,Y as g,Z as _,Zi as v,_ as ee,_a as y,_t as te,a as b,ar as ne,ba as x,bt as re,c as ie,ct as ae,d as oe,da as se,dr as S,dt as ce,et as le,f as C,fa as w,ft as ue,g as T,ga as de,gt as E,h as D,ht as O,i as fe,ir as k,j as A,lt as pe,m as j,mr as me,mt as M,n as he,nr as ge,o as _e,ot as ve,p as N,pa as ye,pr as P,pt as F,qn as be,r as xe,ra as Se,rr as Ce,s as I,sr as we,st as Te,t as Ee,tr as De,tt as Oe,vt as ke,w as Ae,wa as je,wt as L,xa as R,xi as Me,xt as z,y as B}from"./Effect-DeiDqvoz.js";import{$ as Ne,$n as Pe,$t as Fe,A as Ie,Ai as Le,An as Re,Ao as ze,At as Be,B as Ve,Ba as He,Bi as Ue,Bn as We,Bo as Ge,Bt as Ke,C as qe,Cn as Je,Cr as V,Ct as Ye,D as Xe,Di as H,Dn as Ze,Dr as U,Dt as Qe,E as $e,Ei as et,En as tt,Er as nt,Et as rt,F as it,Fi as at,Fn as ot,Fo as st,Fr as ct,Ft as lt,G as ut,Gi as W,Gn as dt,Gr as ft,Gt as pt,H as mt,Ha as ht,Hn as gt,Ho as _t,Ht as vt,I as yt,Ia as bt,In as xt,Io as St,It as Ct,J as wt,Ji as Tt,Jn as Et,Jt as Dt,K as Ot,Ki as kt,Kn as At,Kr as jt,Kt as Mt,L as Nt,La as Pt,Li as G,Lo as Ft,Lt as It,M as Lt,Mn as Rt,Mr as zt,Mt as Bt,N as Vt,Na as Ht,Ni as Ut,Nn as Wt,No as Gt,Nt as Kt,O as qt,Oi as Jt,On as Yt,Oo as Xt,Ot as Zt,P as Qt,Pi as $t,Pn as en,Po as tn,Pr as nn,Pt as rn,Q as an,Qa as on,Qi as sn,Qn as cn,Qt as ln,R as un,Ra as K,Rn as dn,Ro as fn,Rr as pn,Rt as mn,S as hn,Sn as gn,Sr as _n,St as vn,T as yn,Ta as bn,Ti as xn,Tn as Sn,Tr as Cn,Tt as wn,U as Tn,Un as En,Ur as Dn,Ut as On,V as kn,Va as q,Vi as An,Vn as jn,Vr as Mn,Vt as Nn,W as Pn,Wa as Fn,Wn as In,Wr as Ln,Wt as Rn,X as zn,Xn as Bn,Xr as Vn,Xt as Hn,Y as Un,Yi as Wn,Yn as Gn,Yr as Kn,Yt as qn,Z as Jn,Zi as Yn,Zn as Xn,Zr as Zn,Zt as Qn,_ as $n,_i as er,_n as tr,_o as nr,_t as rr,a as ir,ai as ar,an as or,ar as sr,at as cr,b as lr,bi as ur,bn as dr,bo as fr,br as pr,bt as mr,c as hr,ci as gr,cn as J,ct as _r,dn as vr,do as yr,dt as br,ei as xr,en as Sr,er as Cr,et as wr,fi as Tr,fn as Er,fo as Dr,fr as Or,ft as kr,g as Ar,gi as jr,gn as Mr,go as Nr,gt as Pr,h as Fr,hi as Ir,hn as Lr,ho as Rr,ht as zr,i as Br,ii as Vr,in as Hr,ir as Ur,it as Wr,j as Gr,jn as Kr,jo as qr,jt as Jr,k as Yr,ka as Xr,kn as Zr,ko as Qr,kr as $r,kt as ei,li as ti,ln as ni,lr as ri,lt as ii,mi as ai,mn as oi,mt as si,n as ci,nn as li,nr as ui,nt as di,o as fi,oi as pi,on as mi,or as hi,ot as gi,pa as _i,pi as vi,pn as yi,po as bi,pr as xi,pt as Si,q as Ci,qi as wi,qn as Ti,qt as Ei,r as Di,rn as Oi,rr as ki,rt as Ai,s as ji,si as Mi,sn as Ni,st as Pi,t as Fi,tn as Ii,tr as Li,tt as Ri,ua as zi,ui as Bi,un as Vi,ut as Hi,v as Ui,vn as Wi,vo as Gi,vt as Ki,w as qi,wi as Ji,wn as Yi,wr as Xi,wt as Zi,x as Qi,xa as $i,xi as ea,xn as ta,xo as na,xr as ra,xt as ia,y as aa,yn as oa,yo as sa,yr as ca,yt as la,z as ua,zn as da,zo as fa,zr as pa,zt as ma}from"./extension-hook-0yB9nu6P.js";import{t as ha}from"./text-_WthCHzw.js";import{c as ga}from"./preload-helper-CfILh1TC.js";import{a as _a,c as va,d as ya,f as ba,i as xa,l as Sa,o as Ca,s as wa,u as Ta}from"./index-Bt4eKlCq.js";import{n as Ea,t as Da}from"./estimate-DElUjJag.js";var Oa=He(()=>$a),ka=gr(Oa),Aa=H({id:ea,payload:ai}),ja=H({...Aa.fields,schemas:Pt(ka)});function Ma(e){let t={};for(let[n,r]of Object.entries(e))on(r)&&f(t,n,r);return Object.keys(t).length===0?S():P(t)}var Na=Pt(xn(et,at)).pipe(Wn(K(Ir),{decode:yr(),encode:bi(e=>ne(e)||e.value===void 0?S():Ma(e.value))})),Pa=He(()=>La),Fa=gr(Pa),Ia={annotations:Na,checks:Fa},La=$t([H({_tag:q(`Filter`),representation:ja,annotations:Na,aborted:Bi}),H({_tag:q(`FilterGroup`),representation:Pt(ja),annotations:Na,checks:ur(Pa)})]);function Y(e){return H({_tag:q(e),...Ia})}var Ra=H({_tag:q(`Declaration`),representation:Aa,annotations:Na,typeParameters:ka,checks:Fa}),za=H({_tag:q(`Suspend`),annotations:Na,checks:Le([]),thunk:Oa});function Ba(e,t){return t.pipe(Wn(H({type:q(e),value:t}),{decode:Dr(e=>e.value),encode:Dr(t=>({type:e,value:t}))}))}var Va=Ba(`string`,et),Ha=Ba(`number`,Ji),Ua=H({_tag:q(`Literal`),...Ia,literal:$t([Va,Ba(`number`,Tr),Ba(`bigint`,ti),Ba(`boolean`,Bi)])}),Wa=H({_tag:q(`UniqueSymbol`),...Ia,symbol:Jt}),Ga=H({_tag:q(`Enum`),...Ia,enums:gr(Le([et,$t([Va,Ha])]))}),Ka=H({_tag:q(`TemplateLiteral`),...Ia,parts:ka}),qa=H({isOptional:Bi,type:Oa,annotations:Na}),Ja=H({_tag:q(`Arrays`),...Ia,elements:gr(qa),rest:ka}),Ya=H({name:$t([Va,Ha,Ba(`symbol`,Jt)]),type:Oa,isOptional:Bi,isMutable:Bi,annotations:Na}),Xa=H({parameter:Oa,type:Oa}),Za=H({_tag:q(`Objects`),...Ia,propertySignatures:gr(Ya),indexSignatures:gr(Xa)}),Qa=H({_tag:q(`Union`),...Ia,types:ka,options:K(H({mode:K(er([`anyOf`,`oneOf`]))}))}),$a=$t([Ra,H({_tag:q(`Reference`),$ref:ea}),za,Y(`Null`),Y(`Undefined`),Y(`Void`),Y(`Never`),Y(`Unknown`),Y(`Any`),Y(`String`),Y(`Number`),Y(`Boolean`),Y(`BigInt`),Y(`Symbol`),Y(`ObjectKeyword`),Ua,Wa,Ga,Ka,Ja,Za,Qa]),eo=Tt(ht(H({representation:Oa,references:xn(et,Oa)})));function to(e){return eo(e)}function no(e){return e.sql.exec(`CREATE TABLE IF NOT EXISTS shiitake_fleet_delegations (
1
+ import{n as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,Ct as n,D as r,F as i,G as a,I as o,J as s,K as c,N as l,O as u,P as d,Qr as f,R as p,St as m,V as h,Y as g,Z as _,Zi as v,_ as ee,_a as y,_t as te,a as b,ar as ne,ba as x,bt as re,c as ie,ct as ae,d as oe,da as se,dr as S,dt as ce,et as le,f as C,fa as w,ft as ue,g as T,ga as de,gt as E,h as D,ht as O,i as fe,ir as k,j as A,lt as pe,m as j,mr as me,mt as M,n as he,nr as ge,o as _e,ot as ve,p as N,pa as ye,pr as P,pt as F,qn as be,r as xe,ra as Se,rr as Ce,s as I,sr as we,st as Te,t as Ee,tr as De,tt as Oe,vt as ke,w as Ae,wa as je,wt as L,xa as R,xi as Me,xt as z,y as B}from"./Effect-DeiDqvoz.js";import{$ as Ne,$n as Pe,$t as Fe,A as Ie,Ai as Le,An as Re,Ao as ze,At as Be,B as Ve,Ba as He,Bi as Ue,Bn as We,Bo as Ge,Bt as Ke,C as qe,Cn as Je,Cr as V,Ct as Ye,D as Xe,Di as H,Dn as Ze,Dr as U,Dt as Qe,E as $e,Ei as et,En as tt,Er as nt,Et as rt,F as it,Fi as at,Fn as ot,Fo as st,Fr as ct,Ft as lt,G as ut,Gi as W,Gn as dt,Gr as ft,Gt as pt,H as mt,Ha as ht,Hn as gt,Ho as _t,Ht as vt,I as yt,Ia as bt,In as xt,Io as St,It as Ct,J as wt,Ji as Tt,Jn as Et,Jt as Dt,K as Ot,Ki as kt,Kn as At,Kr as jt,Kt as Mt,L as Nt,La as Pt,Li as G,Lo as Ft,Lt as It,M as Lt,Mn as Rt,Mr as zt,Mt as Bt,N as Vt,Na as Ht,Ni as Ut,Nn as Wt,No as Gt,Nt as Kt,O as qt,Oi as Jt,On as Yt,Oo as Xt,Ot as Zt,P as Qt,Pi as $t,Pn as en,Po as tn,Pr as nn,Pt as rn,Q as an,Qa as on,Qi as sn,Qn as cn,Qt as ln,R as un,Ra as K,Rn as dn,Ro as fn,Rr as pn,Rt as mn,S as hn,Sn as gn,Sr as _n,St as vn,T as yn,Ta as bn,Ti as xn,Tn as Sn,Tr as Cn,Tt as wn,U as Tn,Un as En,Ur as Dn,Ut as On,V as kn,Va as q,Vi as An,Vn as jn,Vr as Mn,Vt as Nn,W as Pn,Wa as Fn,Wn as In,Wr as Ln,Wt as Rn,X as zn,Xn as Bn,Xr as Vn,Xt as Hn,Y as Un,Yi as Wn,Yn as Gn,Yr as Kn,Yt as qn,Z as Jn,Zi as Yn,Zn as Xn,Zr as Zn,Zt as Qn,_ as $n,_i as er,_n as tr,_o as nr,_t as rr,a as ir,ai as ar,an as or,ar as sr,at as cr,b as lr,bi as ur,bn as dr,bo as fr,br as pr,bt as mr,c as hr,ci as gr,cn as J,ct as _r,dn as vr,do as yr,dt as br,ei as xr,en as Sr,er as Cr,et as wr,fi as Tr,fn as Er,fo as Dr,fr as Or,ft as kr,g as Ar,gi as jr,gn as Mr,go as Nr,gt as Pr,h as Fr,hi as Ir,hn as Lr,ho as Rr,ht as zr,i as Br,ii as Vr,in as Hr,ir as Ur,it as Wr,j as Gr,jn as Kr,jo as qr,jt as Jr,k as Yr,ka as Xr,kn as Zr,ko as Qr,kr as $r,kt as ei,li as ti,ln as ni,lr as ri,lt as ii,mi as ai,mn as oi,mt as si,n as ci,nn as li,nr as ui,nt as di,o as fi,oi as pi,on as mi,or as hi,ot as gi,pa as _i,pi as vi,pn as yi,po as bi,pr as xi,pt as Si,q as Ci,qi as wi,qn as Ti,qt as Ei,r as Di,rn as Oi,rr as ki,rt as Ai,s as ji,si as Mi,sn as Ni,st as Pi,t as Fi,tn as Ii,tr as Li,tt as Ri,ua as zi,ui as Bi,un as Vi,ut as Hi,v as Ui,vn as Wi,vo as Gi,vt as Ki,w as qi,wi as Ji,wn as Yi,wr as Xi,wt as Zi,x as Qi,xa as $i,xi as ea,xn as ta,xo as na,xr as ra,xt as ia,y as aa,yn as oa,yo as sa,yr as ca,yt as la,z as ua,zn as da,zo as fa,zr as pa,zt as ma}from"./extension-hook-CejZHRxr.js";import{t as ha}from"./text-_WthCHzw.js";import{c as ga}from"./preload-helper-CfILh1TC.js";import{a as _a,c as va,d as ya,f as ba,i as xa,l as Sa,o as Ca,s as wa,u as Ta}from"./index-D_xvnJKX.js";import{n as Ea,t as Da}from"./estimate-DElUjJag.js";var Oa=He(()=>$a),ka=gr(Oa),Aa=H({id:ea,payload:ai}),ja=H({...Aa.fields,schemas:Pt(ka)});function Ma(e){let t={};for(let[n,r]of Object.entries(e))on(r)&&f(t,n,r);return Object.keys(t).length===0?S():P(t)}var Na=Pt(xn(et,at)).pipe(Wn(K(Ir),{decode:yr(),encode:bi(e=>ne(e)||e.value===void 0?S():Ma(e.value))})),Pa=He(()=>La),Fa=gr(Pa),Ia={annotations:Na,checks:Fa},La=$t([H({_tag:q(`Filter`),representation:ja,annotations:Na,aborted:Bi}),H({_tag:q(`FilterGroup`),representation:Pt(ja),annotations:Na,checks:ur(Pa)})]);function Y(e){return H({_tag:q(e),...Ia})}var Ra=H({_tag:q(`Declaration`),representation:Aa,annotations:Na,typeParameters:ka,checks:Fa}),za=H({_tag:q(`Suspend`),annotations:Na,checks:Le([]),thunk:Oa});function Ba(e,t){return t.pipe(Wn(H({type:q(e),value:t}),{decode:Dr(e=>e.value),encode:Dr(t=>({type:e,value:t}))}))}var Va=Ba(`string`,et),Ha=Ba(`number`,Ji),Ua=H({_tag:q(`Literal`),...Ia,literal:$t([Va,Ba(`number`,Tr),Ba(`bigint`,ti),Ba(`boolean`,Bi)])}),Wa=H({_tag:q(`UniqueSymbol`),...Ia,symbol:Jt}),Ga=H({_tag:q(`Enum`),...Ia,enums:gr(Le([et,$t([Va,Ha])]))}),Ka=H({_tag:q(`TemplateLiteral`),...Ia,parts:ka}),qa=H({isOptional:Bi,type:Oa,annotations:Na}),Ja=H({_tag:q(`Arrays`),...Ia,elements:gr(qa),rest:ka}),Ya=H({name:$t([Va,Ha,Ba(`symbol`,Jt)]),type:Oa,isOptional:Bi,isMutable:Bi,annotations:Na}),Xa=H({parameter:Oa,type:Oa}),Za=H({_tag:q(`Objects`),...Ia,propertySignatures:gr(Ya),indexSignatures:gr(Xa)}),Qa=H({_tag:q(`Union`),...Ia,types:ka,options:K(H({mode:K(er([`anyOf`,`oneOf`]))}))}),$a=$t([Ra,H({_tag:q(`Reference`),$ref:ea}),za,Y(`Null`),Y(`Undefined`),Y(`Void`),Y(`Never`),Y(`Unknown`),Y(`Any`),Y(`String`),Y(`Number`),Y(`Boolean`),Y(`BigInt`),Y(`Symbol`),Y(`ObjectKeyword`),Ua,Wa,Ga,Ka,Ja,Za,Qa]),eo=Tt(ht(H({representation:Oa,references:xn(et,Oa)})));function to(e){return eo(e)}function no(e){return e.sql.exec(`CREATE TABLE IF NOT EXISTS shiitake_fleet_delegations (
2
2
  request_id TEXT PRIMARY KEY, input TEXT NOT NULL, mail TEXT NOT NULL,
3
3
  receipt TEXT
4
4
  ) STRICT`),e.sql.exec(`CREATE TABLE IF NOT EXISTS shiitake_fleet_held_delegations (
@@ -1 +1 @@
1
- import{n as e,t}from"./error-body-C7MTmn8e.js";import{i as n,n as r,r as i,t as a}from"./classifier-shared-BeyBBH6Z.js";var o={"TypeSafe-Danger-Zone-Images":`true`};function s(e,t,r){if(!a(t))throw Error(`${e} returned invalid probabilities for ${r}`);return Object.fromEntries(Object.entries(t).map(([t,i])=>[t,n(e,i,`probability for ${r}.${t}`)]))}function c(e,t,r){if(!a(t))throw Error(`${e} returned an unexpected response`);let i=[];for(let[o,c]of Object.entries(r.questions)){let r=t[o];if(!a(r))throw Error(`${e} did not return an answer for ${o}`);if(c.type===`choice`){if(r.type!==`choice`||typeof r.choice!=`string`)throw Error(`${e} did not return a choice answer for ${o}`);i.push([o,{type:`choice`,choice:r.choice,probabilities:s(e,r.probabilities,o),confidence:n(e,r.confidence,`confidence for ${o}`)}])}else if(c.type===`score`){if(r.type!==`score`)throw Error(`${e} did not return a score answer for ${o}`);i.push([o,{type:`score`,score:n(e,r.score,`score for ${o}`),confidence:n(e,r.confidence,`confidence for ${o}`)}])}else{if(r.type!==`noul`)throw Error(`${e} did not return a bool answer for ${o}`);i.push([o,{type:`bool`,probability:n(e,r.noul,`probability for ${o}`)}])}}return Object.fromEntries(i)}var l={"image/png":`png`,"image/jpeg":`jpeg`},u=new Set([`image/png`,`image/jpeg`,`image/webp`]),d=4;function f(e,t,n,r,i){if(n===`images`){if(r.length>d)throw Error(`${e} accepts at most ${d} images for ${t.id}, got ${r.length}`);i.images=r.map(n=>{if(!u.has(n.mimeType))throw Error(`${e} accepts PNG, JPEG, and WebP images for ${t.id}, got ${n.mimeType}`);return`data:${n.mimeType};base64,${n.data}`});return}if(n===`state-image-urls`){i.state=[...r.map(e=>({type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}})),i.state];return}let a={};r.forEach((n,r)=>{let i=l[n.mimeType];if(!i)throw Error(`${e} accepts PNG and JPEG images for ${t.id}, got ${n.mimeType}`);a[`<image-${r+1}>`]={type:`image`,format:i,data_base64:n.data}}),i.assets=a,i.state=[...Object.keys(a),i.state]}function p(e){return{state:e.state,questions:Object.fromEntries(Object.entries(e.questions).map(([e,t])=>[e,t.type===`bool`?{...t,type:`noul`}:t]))}}async function m(n,a,s,l){let u={api:a.api,provider:a.provider,model:a.id,answers:{},stopReason:`stop`,timestamp:Date.now()};try{if(a.api!==n.api)throw Error(`Unsupported classifier API: ${a.api}`);let e=p(s),t=l;if(s.images?.length){if(!a.input.includes(`image`))throw Error(`${n.label} does not support image input for ${a.id}`);let r=n.detectCompat(a),i=a.compat?.imageInput??r.imageInput;f(n.label,a,i,s.images,e),(a.compat?.sendImageOptInHeader??r.sendImageOptInHeader)&&(t={...l,headers:{...o,...l?.headers}})}let d=await i(n.label,n.url(a),a,n.payload(a,e),t),m=n.output(d),h=r(m.usage,a);return h&&(u.usage=h),u.answers=c(n.label,m.answers,s),u}catch(r){return u.stopReason=l?.signal?.aborted?`aborted`:`error`,u.errorMessage=t(e(r),`${n.label} error`),u}}export{m as t};
1
+ import{n as e,t}from"./error-body-C7MTmn8e.js";import{i as n,n as r,r as i,t as a}from"./classifier-shared-DvEpCno6.js";var o={"TypeSafe-Danger-Zone-Images":`true`};function s(e,t,r){if(!a(t))throw Error(`${e} returned invalid probabilities for ${r}`);return Object.fromEntries(Object.entries(t).map(([t,i])=>[t,n(e,i,`probability for ${r}.${t}`)]))}function c(e,t,r){if(!a(t))throw Error(`${e} returned an unexpected response`);let i=[];for(let[o,c]of Object.entries(r.questions)){let r=t[o];if(!a(r))throw Error(`${e} did not return an answer for ${o}`);if(c.type===`choice`){if(r.type!==`choice`||typeof r.choice!=`string`)throw Error(`${e} did not return a choice answer for ${o}`);i.push([o,{type:`choice`,choice:r.choice,probabilities:s(e,r.probabilities,o),confidence:n(e,r.confidence,`confidence for ${o}`)}])}else if(c.type===`score`){if(r.type!==`score`)throw Error(`${e} did not return a score answer for ${o}`);i.push([o,{type:`score`,score:n(e,r.score,`score for ${o}`),confidence:n(e,r.confidence,`confidence for ${o}`)}])}else{if(r.type!==`noul`)throw Error(`${e} did not return a bool answer for ${o}`);i.push([o,{type:`bool`,probability:n(e,r.noul,`probability for ${o}`)}])}}return Object.fromEntries(i)}var l={"image/png":`png`,"image/jpeg":`jpeg`},u=new Set([`image/png`,`image/jpeg`,`image/webp`]),d=4;function f(e,t,n,r,i){if(n===`images`){if(r.length>d)throw Error(`${e} accepts at most ${d} images for ${t.id}, got ${r.length}`);i.images=r.map(n=>{if(!u.has(n.mimeType))throw Error(`${e} accepts PNG, JPEG, and WebP images for ${t.id}, got ${n.mimeType}`);return`data:${n.mimeType};base64,${n.data}`});return}if(n===`state-image-urls`){i.state=[...r.map(e=>({type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}})),i.state];return}let a={};r.forEach((n,r)=>{let i=l[n.mimeType];if(!i)throw Error(`${e} accepts PNG and JPEG images for ${t.id}, got ${n.mimeType}`);a[`<image-${r+1}>`]={type:`image`,format:i,data_base64:n.data}}),i.assets=a,i.state=[...Object.keys(a),i.state]}function p(e){return{state:e.state,questions:Object.fromEntries(Object.entries(e.questions).map(([e,t])=>[e,t.type===`bool`?{...t,type:`noul`}:t]))}}async function m(n,a,s,l){let u={api:a.api,provider:a.provider,model:a.id,answers:{},stopReason:`stop`,timestamp:Date.now()};try{if(a.api!==n.api)throw Error(`Unsupported classifier API: ${a.api}`);let e=p(s),t=l;if(s.images?.length){if(!a.input.includes(`image`))throw Error(`${n.label} does not support image input for ${a.id}`);let r=n.detectCompat(a),i=a.compat?.imageInput??r.imageInput;f(n.label,a,i,s.images,e),(a.compat?.sendImageOptInHeader??r.sendImageOptInHeader)&&(t={...l,headers:{...o,...l?.headers}})}let d=await i(n.label,n.url(a),a,n.payload(a,e),t),m=n.output(d),h=r(m.usage,a);return h&&(u.usage=h),u.answers=c(n.label,m.answers,s),u}catch(r){return u.stopReason=l?.signal?.aborted?`aborted`:`error`,u.errorMessage=t(e(r),`${n.label} error`),u}}export{m as t};
@@ -1 +1 @@
1
- import{t as e}from"./estimate-DElUjJag.js";import{clampThinkingLevel as t}from"./compat-yFrEl-nt.js";var n=class extends Error{},r=[`$ref`,`$defs`,`definitions`,`allOf`,`oneOf`,`patternProperties`,`dependentSchemas`,`dependencies`,`unevaluatedProperties`,`propertyNames`,`contains`,`prefixItems`,`not`,`if`,`then`,`else`];function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){if(!i(e))return!1;let t=typeof e.type==`string`?[e.type]:Array.isArray(e.type)?e.type:[];return t.includes(`object`)||t.includes(`array`)||e.properties!==void 0||e.items!==void 0}function o(e){return i(e)?e.type===`null`||Array.isArray(e.type)&&e.type.includes(`null`)||e.const===null||Array.isArray(e.enum)&&e.enum.includes(null)?!0:Array.isArray(e.anyOf)&&e.anyOf.some(e=>o(e)):!1}function s(e,t){if(!i(e))throw new n(`boolean schemas are unsupported`);for(let t of r)if(e[t]!==void 0)throw new n(`${t} schemas are unsupported`);if(t){for(let[r,i]of Object.entries(e))if(t(r,i))throw new n(`${r}: ${JSON.stringify(i)} is unsupported`)}if(e.anyOf!==void 0){if(!Array.isArray(e.anyOf)||e.anyOf.length===0)throw new n(`anyOf must contain at least one schema`);for(let r of e.anyOf){if(a(r))throw new n(`object and array unions are unsupported`);s(r,t)}}if(e.items!==void 0){if(Array.isArray(e.items))throw new n(`tuple schemas are unsupported`);s(e.items,t)}let c=e.type===`object`;if(e.properties!==void 0&&!c)throw new n(`properties require type object`);if(!c)return;if(e.additionalProperties!==void 0&&e.additionalProperties!==!1)throw new n(`schema-valued or true additionalProperties is unsupported`);if(e.properties!==void 0&&!i(e.properties))throw new n(`object properties must be a schema map`);if(e.required!==void 0&&(!Array.isArray(e.required)||e.required.some(e=>typeof e!=`string`)))throw new n(`object required must be a string array`);let l=e.properties??{},u=Object.keys(l),d=new Set(Array.isArray(e.required)?e.required:[]);if([...d].some(e=>!u.includes(e)))throw new n(`required contains an unknown property`);for(let[e,n]of Object.entries(l))s(n,t),!d.has(e)&&!o(n)&&(l[e]={anyOf:[n,{type:`null`}]});e.required=u,e.additionalProperties=!1}function c(e,t){let r=structuredClone(e);if(!i(r)||(s(r,t),r.type!==`object`))throw new n(`root schema must have type object`);return r}function l(e){let t=e.constrainedSampling;return!!t&&t.type===`json_schema`&&t.strict===`prefer`}function u(e,t){return t===!0?c(e.parameters):e.parameters}function d(e,t,n){let r=t[n];if(typeof r!=`string`)throw Error(`Grammar tool call "${e}" requires argument "${n}" to be a string.`);return r}function f(e,t,n){if(e.closed)throw Error(`grammar tool input for property "${t}" changed after it was closed`);if(n.length!==0)return e.input+=n,m(e,t)+JSON.stringify(n).slice(1,-1)}function p(e,t,n){if(e.closed){if(n===void 0||n===e.input)return;throw Error(`grammar tool input for property "${t}" changed after it was closed`)}if(n!==void 0&&!n.startsWith(e.input))throw Error(`grammar tool input for property "${t}" changed non-monotonically`);let r=n===void 0?``:n.slice(e.input.length);return n!==void 0&&(e.input=n),e.closed=!0,`${m(e,t)}${JSON.stringify(r).slice(1,-1)}"}`}function m(e,t){return e.started?``:(e.started=!0,`{${JSON.stringify(t)}:"`)}function h(e){let t=e.parameters;if(t.type!==`object`)throw Error(`grammar constrained sampling requires an object parameter schema`);if(!Array.isArray(t.required)||t.required.length!==1||typeof t.required[0]!=`string`)throw Error(`grammar constrained sampling requires exactly one required string property`);let n=t.required[0];if(!t.properties?.[n])throw Error(`grammar constrained sampling requires a properties entry for ${n}`);if(t.properties[n]?.type!==`string`)throw Error(`grammar constrained sampling property ${n} must have type string`);return n}function g(e,t,r){let i=e.constrainedSampling;if(!(!i||i.type!==`json_schema`)){if(t)try{return c(e.parameters,r),!0}catch(t){if(!(t instanceof n))throw t;if(i.strict!==`require`)return;throw Error(`Tool "${e.name}" requires JSON-schema constrained sampling, but ${t.message}.`)}if(i.strict===`require`)throw Error(`Tool "${e.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`)}}function _(e,t){let n=e.constrainedSampling;if(!n||n.type!==`grammar`||!t)return;let r=n.variants.openai_lark,i=n.variants.openai_regex,a=typeof r==`string`&&r.trim().length>0,o=typeof i==`string`&&i.trim().length>0;if(!a&&!o)throw Error(`Tool "${e.name}" cannot use grammar constrained sampling: no supported grammar variant was provided.`);try{return{format:a?`lark`:`regex`,definition:a?r:i,inputProperty:h(e)}}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Tool "${e.name}" cannot use grammar constrained sampling: ${n}.`)}}function v(e,t){let n=new Map;for(let r of e??[]){let e=_(r,t);e&&n.set(r.name,e.inputProperty)}return n}var y=4096,b=.15,x=32768,S=1;function C(t,n,r){if(t.contextWindow<=0)return Math.max(S,r);let i=e(n).tokens,a=Math.max(y,Math.ceil(i*b)),o=t.contextWindow-i-a;return o<x&&(o=Math.min(x,t.contextWindow-i-y)),Math.min(r,Math.max(S,o))}function w(e,n,r){let i=t(e,n),a=e.samplingParamsByThinkingLevel?.[i];return e.samplingParams||a||r?{...e.samplingParams,...a,...r}:void 0}function T(e,t,n,r){let i=w(e,n?.reasoning??`off`,n?.samplingParams);return{temperature:n?.temperature,samplingParams:i,maxTokens:C(e,t,n?.maxTokens??e.maxTokens),signal:n?.signal,telemetry:n?.telemetry,apiKey:r||n?.apiKey,fetch:n?.fetch,transport:n?.transport,cacheRetention:n?.cacheRetention,sessionId:n?.sessionId,disableContinuation:n?.disableContinuation,headers:n?.headers,identity:n?.identity,onPayload:n?.onPayload,onResponse:n?.onResponse,onProviderStreamEvent:n?.onProviderStreamEvent,timeoutMs:n?.timeoutMs,websocketConnectTimeoutMs:n?.websocketConnectTimeoutMs,maxRetries:n?.maxRetries,maxRetryDelayMs:n?.maxRetryDelayMs,metadata:n?.metadata,env:n?.env}}var E=1024,D={minimal:1024,low:2048,medium:8192,high:16384};function O(e){return e===`xhigh`||e===`max`?`high`:e}function k(e,t){return{...D,...t}[O(e)]}function A(e,t){return Math.min(e,Math.max(0,t-E))}function j(e,t,n,r){let i=k(n,r),a=e===void 0?t:Math.min(e+i,t);return a<=i&&(i=A(i,a)),{maxTokens:a,thinkingBudget:i}}var M=`(image omitted: model does not support images)`,N=`(tool image omitted: model does not support images)`,P=`(image attached after the tool results)`;function F(e){if(!e.isError)return;let t=e.content.filter(e=>e.type===`image`);if(t.length!==0)return{content:I(e.content,P),caption:`Images from the error result of tool call ${e.toolCallId} (${e.toolName}):`,images:t}}function I(e,t){let n=[],r=!1;for(let i of e){if(i.type===`image`){r||n.push({type:`text`,text:t}),r=!0;continue}n.push(i),r=i.text===t}return n}function L(e,t){return t.input.includes(`image`)?e:e.map(e=>e.role===`user`&&Array.isArray(e.content)?{...e,content:I(e.content,M)}:e.role===`toolResult`?{...e,content:I(e.content,N)}:e)}function R(e,t,n){let r=new Map,i=L(e.map(e=>e.content==null?{...e,content:[]}:e),t).map(e=>{if(e.role===`system`||e.role===`user`)return e;if(e.role===`toolResult`){let t=r.get(e.toolCallId);return t&&t!==e.toolCallId?{...e,toolCallId:t}:e}if(e.role===`assistant`){let i=e,a=i.provider===t.provider&&i.api===t.api&&i.model===t.id,o=i.content.flatMap(e=>{if(e.type===`thinking`)return a?e.redacted||e.thinkingSignature?e:!e.thinking||e.thinking.trim()===``?[]:e:[];if(e.type===`text`)return a?e:{type:`text`,text:e.text};if(e.type===`toolCall`){let o=e,s=o;if(!a&&o.thoughtSignature&&(s={...o},delete s.thoughtSignature),!a&&n){let e=n(o.id,t,i);e!==o.id&&(r.set(o.id,e),s={...s,id:e})}return s}return e});return{...i,content:o}}return e}),a=[],o=[],s=new Set,c=[],l=()=>{if(o.length>0){for(let e of o)s.has(e.id)||a.push({role:`toolResult`,toolCallId:e.id,toolName:e.name,content:[{type:`text`,text:`No result provided`}],isError:!0,timestamp:Date.now()});o=[],s=new Set}a.push(...c),c.length=0};for(let e=0;e<i.length;e++){let t=i[e];if(t.role===`assistant`){l();let e=t;if(e.stopReason===`error`||e.stopReason===`aborted`)continue;let n=e.content.filter(e=>e.type===`toolCall`);n.length>0&&(o=n,s=new Set),a.push(t)}else t.role===`toolResult`?(s.add(t.toolCallId),a.push(t)):t.role===`system`?o.length>0?c.push(t):a.push(t):(t.role===`user`&&l(),a.push(t))}return l(),a}export{C as a,k as c,v as d,d as f,g,_ as h,T as i,f as l,l as m,R as n,A as o,u as p,j as r,w as s,F as t,p as u};
1
+ import{t as e}from"./estimate-DElUjJag.js";import{clampThinkingLevel as t}from"./compat-CUOPBfwj.js";var n=class extends Error{},r=[`$ref`,`$defs`,`definitions`,`allOf`,`oneOf`,`patternProperties`,`dependentSchemas`,`dependencies`,`unevaluatedProperties`,`propertyNames`,`contains`,`prefixItems`,`not`,`if`,`then`,`else`];function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){if(!i(e))return!1;let t=typeof e.type==`string`?[e.type]:Array.isArray(e.type)?e.type:[];return t.includes(`object`)||t.includes(`array`)||e.properties!==void 0||e.items!==void 0}function o(e){return i(e)?e.type===`null`||Array.isArray(e.type)&&e.type.includes(`null`)||e.const===null||Array.isArray(e.enum)&&e.enum.includes(null)?!0:Array.isArray(e.anyOf)&&e.anyOf.some(e=>o(e)):!1}function s(e,t){if(!i(e))throw new n(`boolean schemas are unsupported`);for(let t of r)if(e[t]!==void 0)throw new n(`${t} schemas are unsupported`);if(t){for(let[r,i]of Object.entries(e))if(t(r,i))throw new n(`${r}: ${JSON.stringify(i)} is unsupported`)}if(e.anyOf!==void 0){if(!Array.isArray(e.anyOf)||e.anyOf.length===0)throw new n(`anyOf must contain at least one schema`);for(let r of e.anyOf){if(a(r))throw new n(`object and array unions are unsupported`);s(r,t)}}if(e.items!==void 0){if(Array.isArray(e.items))throw new n(`tuple schemas are unsupported`);s(e.items,t)}let c=e.type===`object`;if(e.properties!==void 0&&!c)throw new n(`properties require type object`);if(!c)return;if(e.additionalProperties!==void 0&&e.additionalProperties!==!1)throw new n(`schema-valued or true additionalProperties is unsupported`);if(e.properties!==void 0&&!i(e.properties))throw new n(`object properties must be a schema map`);if(e.required!==void 0&&(!Array.isArray(e.required)||e.required.some(e=>typeof e!=`string`)))throw new n(`object required must be a string array`);let l=e.properties??{},u=Object.keys(l),d=new Set(Array.isArray(e.required)?e.required:[]);if([...d].some(e=>!u.includes(e)))throw new n(`required contains an unknown property`);for(let[e,n]of Object.entries(l))s(n,t),!d.has(e)&&!o(n)&&(l[e]={anyOf:[n,{type:`null`}]});e.required=u,e.additionalProperties=!1}function c(e,t){let r=structuredClone(e);if(!i(r)||(s(r,t),r.type!==`object`))throw new n(`root schema must have type object`);return r}function l(e){let t=e.constrainedSampling;return!!t&&t.type===`json_schema`&&t.strict===`prefer`}function u(e,t){return t===!0?c(e.parameters):e.parameters}function d(e,t,n){let r=t[n];if(typeof r!=`string`)throw Error(`Grammar tool call "${e}" requires argument "${n}" to be a string.`);return r}function f(e,t,n){if(e.closed)throw Error(`grammar tool input for property "${t}" changed after it was closed`);if(n.length!==0)return e.input+=n,m(e,t)+JSON.stringify(n).slice(1,-1)}function p(e,t,n){if(e.closed){if(n===void 0||n===e.input)return;throw Error(`grammar tool input for property "${t}" changed after it was closed`)}if(n!==void 0&&!n.startsWith(e.input))throw Error(`grammar tool input for property "${t}" changed non-monotonically`);let r=n===void 0?``:n.slice(e.input.length);return n!==void 0&&(e.input=n),e.closed=!0,`${m(e,t)}${JSON.stringify(r).slice(1,-1)}"}`}function m(e,t){return e.started?``:(e.started=!0,`{${JSON.stringify(t)}:"`)}function h(e){let t=e.parameters;if(t.type!==`object`)throw Error(`grammar constrained sampling requires an object parameter schema`);if(!Array.isArray(t.required)||t.required.length!==1||typeof t.required[0]!=`string`)throw Error(`grammar constrained sampling requires exactly one required string property`);let n=t.required[0];if(!t.properties?.[n])throw Error(`grammar constrained sampling requires a properties entry for ${n}`);if(t.properties[n]?.type!==`string`)throw Error(`grammar constrained sampling property ${n} must have type string`);return n}function g(e,t,r){let i=e.constrainedSampling;if(!(!i||i.type!==`json_schema`)){if(t)try{return c(e.parameters,r),!0}catch(t){if(!(t instanceof n))throw t;if(i.strict!==`require`)return;throw Error(`Tool "${e.name}" requires JSON-schema constrained sampling, but ${t.message}.`)}if(i.strict===`require`)throw Error(`Tool "${e.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`)}}function _(e,t){let n=e.constrainedSampling;if(!n||n.type!==`grammar`||!t)return;let r=n.variants.openai_lark,i=n.variants.openai_regex,a=typeof r==`string`&&r.trim().length>0,o=typeof i==`string`&&i.trim().length>0;if(!a&&!o)throw Error(`Tool "${e.name}" cannot use grammar constrained sampling: no supported grammar variant was provided.`);try{return{format:a?`lark`:`regex`,definition:a?r:i,inputProperty:h(e)}}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Tool "${e.name}" cannot use grammar constrained sampling: ${n}.`)}}function v(e,t){let n=new Map;for(let r of e??[]){let e=_(r,t);e&&n.set(r.name,e.inputProperty)}return n}var y=4096,b=.15,x=32768,S=1;function C(t,n,r){if(t.contextWindow<=0)return Math.max(S,r);let i=e(n).tokens,a=Math.max(y,Math.ceil(i*b)),o=t.contextWindow-i-a;return o<x&&(o=Math.min(x,t.contextWindow-i-y)),Math.min(r,Math.max(S,o))}function w(e,n,r){let i=t(e,n),a=e.samplingParamsByThinkingLevel?.[i];return e.samplingParams||a||r?{...e.samplingParams,...a,...r}:void 0}function T(e,t,n,r){let i=w(e,n?.reasoning??`off`,n?.samplingParams);return{temperature:n?.temperature,samplingParams:i,maxTokens:C(e,t,n?.maxTokens??e.maxTokens),signal:n?.signal,telemetry:n?.telemetry,apiKey:r||n?.apiKey,fetch:n?.fetch,transport:n?.transport,cacheRetention:n?.cacheRetention,sessionId:n?.sessionId,disableContinuation:n?.disableContinuation,headers:n?.headers,identity:n?.identity,onPayload:n?.onPayload,onResponse:n?.onResponse,onProviderStreamEvent:n?.onProviderStreamEvent,timeoutMs:n?.timeoutMs,websocketConnectTimeoutMs:n?.websocketConnectTimeoutMs,maxRetries:n?.maxRetries,maxRetryDelayMs:n?.maxRetryDelayMs,metadata:n?.metadata,env:n?.env}}var E=1024,D={minimal:1024,low:2048,medium:8192,high:16384};function O(e){return e===`xhigh`||e===`max`?`high`:e}function k(e,t){return{...D,...t}[O(e)]}function A(e,t){return Math.min(e,Math.max(0,t-E))}function j(e,t,n,r){let i=k(n,r),a=e===void 0?t:Math.min(e+i,t);return a<=i&&(i=A(i,a)),{maxTokens:a,thinkingBudget:i}}var M=`(image omitted: model does not support images)`,N=`(tool image omitted: model does not support images)`,P=`(image attached after the tool results)`;function F(e){if(!e.isError)return;let t=e.content.filter(e=>e.type===`image`);if(t.length!==0)return{content:I(e.content,P),caption:`Images from the error result of tool call ${e.toolCallId} (${e.toolName}):`,images:t}}function I(e,t){let n=[],r=!1;for(let i of e){if(i.type===`image`){r||n.push({type:`text`,text:t}),r=!0;continue}n.push(i),r=i.text===t}return n}function L(e,t){return t.input.includes(`image`)?e:e.map(e=>e.role===`user`&&Array.isArray(e.content)?{...e,content:I(e.content,M)}:e.role===`toolResult`?{...e,content:I(e.content,N)}:e)}function R(e,t,n){let r=new Map,i=L(e.map(e=>e.content==null?{...e,content:[]}:e),t).map(e=>{if(e.role===`system`||e.role===`user`)return e;if(e.role===`toolResult`){let t=r.get(e.toolCallId);return t&&t!==e.toolCallId?{...e,toolCallId:t}:e}if(e.role===`assistant`){let i=e,a=i.provider===t.provider&&i.api===t.api&&i.model===t.id,o=i.content.flatMap(e=>{if(e.type===`thinking`)return a?e.redacted||e.thinkingSignature?e:!e.thinking||e.thinking.trim()===``?[]:e:[];if(e.type===`text`)return a?e:{type:`text`,text:e.text};if(e.type===`toolCall`){let o=e,s=o;if(!a&&o.thoughtSignature&&(s={...o},delete s.thoughtSignature),!a&&n){let e=n(o.id,t,i);e!==o.id&&(r.set(o.id,e),s={...s,id:e})}return s}return e});return{...i,content:o}}return e}),a=[],o=[],s=new Set,c=[],l=()=>{if(o.length>0){for(let e of o)s.has(e.id)||a.push({role:`toolResult`,toolCallId:e.id,toolName:e.name,content:[{type:`text`,text:`No result provided`}],isError:!0,timestamp:Date.now()});o=[],s=new Set}a.push(...c),c.length=0};for(let e=0;e<i.length;e++){let t=i[e];if(t.role===`assistant`){l();let e=t;if(e.stopReason===`error`||e.stopReason===`aborted`)continue;let n=e.content.filter(e=>e.type===`toolCall`);n.length>0&&(o=n,s=new Set),a.push(t)}else t.role===`toolResult`?(s.add(t.toolCallId),a.push(t)):t.role===`system`?o.length>0?c.push(t):a.push(t):(t.role===`user`&&l(),a.push(t))}return l(),a}export{C as a,k as c,v as d,d as f,g,_ as h,T as i,f as l,l as m,R as n,A as o,u as p,j as r,w as s,F as t,p as u};
@@ -1 +1 @@
1
- import{t as e}from"./classifier-shared-BeyBBH6Z.js";import{t}from"./system-one-shared-BZoqXlpk.js";var n={api:`typesafe-system-one`,label:`System One API`,detectCompat:e=>e.provider===`openrouter`||e.baseUrl.includes(`openrouter.ai`)?{imageInput:`state-image-urls`,sendImageOptInHeader:!1}:{imageInput:`assets`,sendImageOptInHeader:!0},url:e=>new URL(`systemone`,`${e.baseUrl.replace(/\/+$/u,``)}/`),payload:(e,t)=>({model:e.id,...t}),output:t=>{if(!e(t))throw Error(`System One API returned an unexpected response`);return t}},r=(e,r,i)=>t(n,e,r,i);export{r as classify};
1
+ import{t as e}from"./classifier-shared-DvEpCno6.js";import{t}from"./system-one-shared-Bv09betA.js";var n={api:`typesafe-system-one`,label:`System One API`,detectCompat:e=>e.provider===`openrouter`||e.baseUrl.includes(`openrouter.ai`)?{imageInput:`state-image-urls`,sendImageOptInHeader:!1}:{imageInput:`assets`,sendImageOptInHeader:!0},url:e=>new URL(`systemone`,`${e.baseUrl.replace(/\/+$/u,``)}/`),payload:(e,t)=>({model:e.id,...t}),output:t=>{if(!e(t))throw Error(`System One API returned an unexpected response`);return t}},r=(e,r,i)=>t(n,e,r,i);export{r as classify};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,Ci as n,Er as r,F as i,I as a,M as o,N as s,P as c,Ri as l,t as u,z as d}from"./conversation-toast-CD2t_Qou.js";import{ai as f}from"./extension-hook-0yB9nu6P.js";import{t as p}from"./parakeet-DzPDg3KU.js";var m=e(l(),1),h=n();function g({inbox:e,ui:n}){let{selected:l,session:g,action:_,canManage:v}=e,[y,b]=(0,m.useState)(null);(0,m.useEffect)(()=>{b(null)},[l?.bindingId,l?.conversation.sessionId,v]);let x=_.error;if((0,m.useEffect)(()=>{x!==null&&u(n,{variant:`error`,message:`This conversation changed or website access was removed. Refresh and try again.`})},[x,n]),l===void 0)return null;let S=l.conversation;return(0,h.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":`Website conversation`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-base-300 p-2`,children:[(0,h.jsx)(`span`,{className:`min-w-0 flex-1 text-sm`,children:S.heldByYou?`You're replying. The Agent is paused.`:S.held?`${S.heldByName??`A teammate`} is replying.`:`The Agent is replying. Take over to answer as yourself.`}),v?(0,h.jsx)(r,{size:`sm`,disabled:_.isPending,onClick:()=>{let e={bindingId:l.bindingId,sessionId:S.sessionId};S.heldByYou?_.mutate({kind:`release`,...e,expectedVersion:S.holdVersion,confirm:!1}):S.held?b({...e,version:S.holdVersion,name:S.heldByName??`A teammate`}):_.mutate({kind:`hold`,...e,expectedVersion:S.holdVersion,confirm:!1})},children:S.heldByYou?`Hand back to Agent`:`Take over`}):null]}),(0,h.jsx)(t,{open:y!==null,onOpenChange:e=>{e||b(null)},children:(0,h.jsxs)(s,{children:[(0,h.jsxs)(a,{children:[(0,h.jsxs)(d,{children:[y?.name,` is replying — take over?`]}),(0,h.jsx)(c,{children:`You will reply as yourself. Their replies stop until they take over again.`})]}),(0,h.jsxs)(i,{children:[(0,h.jsx)(o,{render:(0,h.jsx)(r,{variant:`outline`}),children:`Cancel`}),(0,h.jsx)(r,{disabled:_.isPending||!v,onClick:()=>{y!==null&&(_.mutate({kind:`hold`,bindingId:y.bindingId,sessionId:y.sessionId,expectedVersion:y.version,confirm:!0}),b(null))},children:`Take over`})]})]})}),v?null:(0,h.jsx)(`p`,{className:`p-3 text-sm`,children:`Allow takeover in Grove's App permissions to reply. Your Team permissions still apply.`}),g?(0,h.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,h.jsx)(p,{authorOf:f,disambiguateAuthors:!0,session:g,markdownPolicy:`visitor`,composerActionVariant:`outline`},`${l.bindingId}:${S.sessionId}`)}):null]})}export{g as WebsiteConversation};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,Ci as n,Er as r,F as i,I as a,M as o,N as s,P as c,Ri as l,t as u,z as d}from"./conversation-toast-D_EnORj5.js";import{ai as f}from"./extension-hook-CejZHRxr.js";import{t as p}from"./parakeet-DopRJWw7.js";var m=e(l(),1),h=n();function g({inbox:e,ui:n}){let{selected:l,session:g,action:_,canManage:v}=e,[y,b]=(0,m.useState)(null);(0,m.useEffect)(()=>{b(null)},[l?.bindingId,l?.conversation.sessionId,v]);let x=_.error;if((0,m.useEffect)(()=>{x!==null&&u(n,{variant:`error`,message:`This conversation changed or website access was removed. Refresh and try again.`})},[x,n]),l===void 0)return null;let S=l.conversation;return(0,h.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":`Website conversation`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-base-300 p-2`,children:[(0,h.jsx)(`span`,{className:`min-w-0 flex-1 text-sm`,children:S.heldByYou?`You're replying. The Agent is paused.`:S.held?`${S.heldByName??`A teammate`} is replying.`:`The Agent is replying. Take over to answer as yourself.`}),v?(0,h.jsx)(r,{size:`sm`,disabled:_.isPending,onClick:()=>{let e={bindingId:l.bindingId,sessionId:S.sessionId};S.heldByYou?_.mutate({kind:`release`,...e,expectedVersion:S.holdVersion,confirm:!1}):S.held?b({...e,version:S.holdVersion,name:S.heldByName??`A teammate`}):_.mutate({kind:`hold`,...e,expectedVersion:S.holdVersion,confirm:!1})},children:S.heldByYou?`Hand back to Agent`:`Take over`}):null]}),(0,h.jsx)(t,{open:y!==null,onOpenChange:e=>{e||b(null)},children:(0,h.jsxs)(s,{children:[(0,h.jsxs)(a,{children:[(0,h.jsxs)(d,{children:[y?.name,` is replying — take over?`]}),(0,h.jsx)(c,{children:`You will reply as yourself. Their replies stop until they take over again.`})]}),(0,h.jsxs)(i,{children:[(0,h.jsx)(o,{render:(0,h.jsx)(r,{variant:`outline`}),children:`Cancel`}),(0,h.jsx)(r,{disabled:_.isPending||!v,onClick:()=>{y!==null&&(_.mutate({kind:`hold`,bindingId:y.bindingId,sessionId:y.sessionId,expectedVersion:y.version,confirm:!0}),b(null))},children:`Take over`})]})]})}),v?null:(0,h.jsx)(`p`,{className:`p-3 text-sm`,children:`Allow takeover in Grove's App permissions to reply. Your Team permissions still apply.`}),g?(0,h.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,h.jsx)(p,{authorOf:f,disambiguateAuthors:!0,session:g,markdownPolicy:`visitor`,composerActionVariant:`outline`},`${l.bindingId}:${S.sessionId}`)}):null]})}export{g as WebsiteConversation};
package/dist/index.html CHANGED
@@ -4,14 +4,14 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>Inbox</title>
7
- <script type="module" crossorigin src="/assets/index-Bt4eKlCq.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-D_xvnJKX.js"></script>
8
8
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
9
9
  <link rel="modulepreload" crossorigin href="/assets/Effect-DeiDqvoz.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/text-_WthCHzw.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-CfILh1TC.js">
12
- <link rel="modulepreload" crossorigin href="/assets/extension-hook-0yB9nu6P.js">
12
+ <link rel="modulepreload" crossorigin href="/assets/extension-hook-CejZHRxr.js">
13
13
  <link rel="modulepreload" crossorigin href="/assets/animation-Ca8A_H2p.js">
14
- <link rel="modulepreload" crossorigin href="/assets/conversation-toast-CD2t_Qou.js">
14
+ <link rel="modulepreload" crossorigin href="/assets/conversation-toast-D_EnORj5.js">
15
15
  <link rel="modulepreload" crossorigin href="/assets/document-CEriO-BY.js">
16
16
  <link rel="modulepreload" crossorigin href="/assets/base-face-Biu4f93I.js">
17
17
  <link rel="stylesheet" crossorigin href="/assets/index-ODpmGtEN.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/grove",
3
- "version": "0.14.3",
3
+ "version": "0.14.4",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "type": "module",
6
6
  "description": "Grove: conversations with agents that call your other Apps, for Oyster",
@@ -9,10 +9,10 @@
9
9
  "@fungi.computer/approvals": "0.2.4",
10
10
  "@fungi.computer/cairn": "0.1.0",
11
11
  "@fungi.computer/caps": "0.12.0",
12
- "@fungi.computer/knapsack": "0.4.14",
12
+ "@fungi.computer/knapsack": "0.4.15",
13
13
  "@fungi.computer/maosaico": "0.1.2",
14
- "@fungi.computer/parakeet": "0.12.3",
15
- "@fungi.computer/shiitake": "0.19.1",
14
+ "@fungi.computer/parakeet": "0.12.4",
15
+ "@fungi.computer/shiitake": "0.19.2",
16
16
  "@fungi.computer/sigils": "0.3.2",
17
17
  "@fungi.computer/sprite": "0.2.2",
18
18
  "@fungi.computer/sprite-zdog": "0.3.2",
@@ -26,13 +26,13 @@
26
26
  "react": "18.3.1",
27
27
  "react-dom": "18.3.1",
28
28
  "zod": "4.4.3",
29
- "@fungi.computer/shiitake-extensions": "0.11.3",
29
+ "@fungi.computer/shiitake-extensions": "0.11.4",
30
30
  "@fungi.computer/gills": "0.3.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@fungi.computer/watchdog": "0.1.4",
34
34
  "@cloudflare/workers-types": "5.20260828.1",
35
- "@fungi.computer/parakeet-testing": "0.2.30",
35
+ "@fungi.computer/parakeet-testing": "0.2.31",
36
36
  "@ladle/react": "5.1.1",
37
37
  "@tailwindcss/vite": "4.2.1",
38
38
  "@types/react": "18.3.3",