@fungi.computer/grove 0.10.12 → 0.10.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{anthropic-messages-BWXuVGZQ.js → anthropic-messages-WRVxllkJ.js} +3 -3
- package/dist/assets/{azure-openai-responses-DJoea3Zs.js → azure-openai-responses-BBuY7snK.js} +1 -1
- package/dist/assets/{burger-2ZdB4Sl9.js → burger-DV1cRs5y.js} +1 -1
- package/dist/assets/{cat-k2Rng6Lu.js → cat-BpBgUnMm.js} +1 -1
- package/dist/assets/{compat-DUbHgxRO.js → compat-BN91LPfV.js} +2 -2
- package/dist/assets/{extension-hook-DLrsMGve.js → extension-hook-BnOqqson.js} +2 -2
- package/dist/assets/{google-generative-ai-TUZdtSpk.js → google-generative-ai-CIJJsOtq.js} +1 -1
- package/dist/assets/{google-shared-DvA7s4SN.js → google-shared-CBzhY66y.js} +1 -1
- package/dist/assets/{google-vertex-BeoXemR4.js → google-vertex-Q_zC3sxm.js} +1 -1
- package/dist/assets/{index-DUvJpRP8.js → index-DAuVGvQA.js} +26 -26
- package/dist/assets/{index-HZRTeHup.css → index-DMBHvLFB.css} +1 -1
- package/dist/assets/{mistral-conversations-C0FGU8qe.js → mistral-conversations-qh54QYfg.js} +1 -1
- package/dist/assets/{node.browser-CaQn4b26.js → node.browser-CF_NEhZd.js} +1 -1
- package/dist/assets/{openai-codex-responses-CBb7f1AX.js → openai-codex-responses-DA8WdfZD.js} +1 -1
- package/dist/assets/{openai-completions-BK4TN2aO.js → openai-completions-BIoDbZEt.js} +1 -1
- package/dist/assets/{openai-responses-C1riVcPW.js → openai-responses-bq18xm1w.js} +1 -1
- package/dist/assets/{openai-responses-shared-UKY-Si2_.js → openai-responses-shared-DX9XGbcU.js} +1 -1
- package/dist/assets/{parakeet-COz-7hhx.js → parakeet-BiFGn0qi.js} +2 -2
- package/dist/assets/parakeet-conversation-C0z_NMMy.js +4 -0
- package/dist/assets/{runtime-core-CdYXUKdk.js → runtime-core-BdWfAAUI.js} +1 -1
- package/dist/assets/{sigil-Cl1OL4iT.js → sigil-_E02VlAZ.js} +2 -2
- package/dist/assets/{transform-messages-DW8NgNGQ.js → transform-messages-mU6-wF5N.js} +1 -1
- package/dist/assets/{website-conversation-DaKGTRlY.js → website-conversation-xBQ7B6Gf.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +3 -3
- package/dist/assets/parakeet-conversation-gdukKCPQ.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./models-BM_0GHMS.js";import{r as t}from"./runtime-core-
|
|
1
|
+
import{n as e}from"./models-BM_0GHMS.js";import{r as t}from"./runtime-core-BdWfAAUI.js";function n(){return typeof process>`u`||!(process.versions?.node||process.versions?.bun)?null:process.getBuiltinModule?.(`node:os`)??null}var r=n();function i(){return r?`pi (${r.platform()} ${r.release()}; ${r.arch()})`:`pi (browser)`}var a=class extends Error{},o=[`$ref`,`$defs`,`definitions`,`allOf`,`oneOf`,`patternProperties`,`dependentSchemas`,`dependencies`,`unevaluatedProperties`,`propertyNames`,`contains`,`prefixItems`,`not`,`if`,`then`,`else`];function s(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function c(e){if(!s(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 l(e){return s(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=>l(e)):!1}function u(e,t){if(!s(e))throw new a(`boolean schemas are unsupported`);for(let t of o)if(e[t]!==void 0)throw new a(`${t} schemas are unsupported`);if(t){for(let[n,r]of Object.entries(e))if(t(n,r))throw new a(`${n}: ${JSON.stringify(r)} is unsupported`)}if(e.anyOf!==void 0){if(!Array.isArray(e.anyOf)||e.anyOf.length===0)throw new a(`anyOf must contain at least one schema`);for(let n of e.anyOf){if(c(n))throw new a(`object and array unions are unsupported`);u(n,t)}}if(e.items!==void 0){if(Array.isArray(e.items))throw new a(`tuple schemas are unsupported`);u(e.items,t)}let n=e.type===`object`;if(e.properties!==void 0&&!n)throw new a(`properties require type object`);if(!n)return;if(e.additionalProperties!==void 0&&e.additionalProperties!==!1)throw new a(`schema-valued or true additionalProperties is unsupported`);if(e.properties!==void 0&&!s(e.properties))throw new a(`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 a(`object required must be a string array`);let r=e.properties??{},i=Object.keys(r),d=new Set(Array.isArray(e.required)?e.required:[]);if([...d].some(e=>!i.includes(e)))throw new a(`required contains an unknown property`);for(let[e,n]of Object.entries(r))u(n,t),!d.has(e)&&!l(n)&&(r[e]={anyOf:[n,{type:`null`}]});e.required=i,e.additionalProperties=!1}function d(e,t){let n=structuredClone(e);if(!s(n)||(u(n,t),n.type!==`object`))throw new a(`root schema must have type object`);return n}function f(e,t){return t===!0?d(e.parameters):e.parameters}function p(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 m(e,t,n,r){if(e.closed){if(r&&n===e.input)return;throw Error(`grammar tool input for property "${t}" changed after it was closed`)}if(!n.startsWith(e.input))throw Error(`grammar tool input for property "${t}" changed non-monotonically`);let i=n.slice(e.input.length);if(!r&&i.length===0)return;let a=``;return e.started||=(a+=`{${JSON.stringify(t)}:"`,!0),a+=JSON.stringify(i).slice(1,-1),e.input=n,r&&(a+=`"}`,e.closed=!0),a}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,n){let r=e.constrainedSampling;if(!(!r||r.type!==`json_schema`)){if(t)try{return d(e.parameters,n),!0}catch(t){if(!(t instanceof a))throw t;if(r.strict!==`require`)return;throw Error(`Tool "${e.name}" requires JSON-schema constrained sampling, but ${t.message}.`)}if(r.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=1;function x(e,n,r){if(e.contextWindow<=0)return Math.max(b,r);let i=e.contextWindow-t(n).tokens-y;return Math.min(r,Math.max(b,i))}function S(t,n,r){let i=e(t,n),a=t.samplingParamsByThinkingLevel?.[i];return t.samplingParams||a||r?{...t.samplingParams,...a,...r}:void 0}function C(e,t,n,r){let i=S(e,n?.reasoning??`off`,n?.samplingParams);return{temperature:n?.temperature,samplingParams:i,maxTokens:x(e,t,n?.maxTokens??e.maxTokens),signal:n?.signal,telemetryContext:n?.telemetryContext,apiKey:r||n?.apiKey,fetch:n?.fetch,transport:n?.transport,cacheRetention:n?.cacheRetention,sessionId:n?.sessionId,headers:n?.headers,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 w=1024,T={minimal:1024,low:2048,medium:8192,high:16384};function E(e){return e===`xhigh`||e===`max`?`high`:e}function D(e,t){return{...T,...t}[E(e)]}function O(e,t){return Math.min(e,Math.max(0,t-w))}function k(e,t,n,r){let i=D(n,r),a=e===void 0?t:Math.min(e+i,t);return a<=i&&(i=O(i,a)),{maxTokens:a,thinkingBudget:i}}var A=`(image omitted: model does not support images)`,j=`(tool image omitted: model does not support images)`,M=`(image attached after the tool results)`;function N(e){if(!e.isError)return;let t=e.content.filter(e=>e.type===`image`);if(t.length!==0)return{content:P(e.content,M),caption:`Images from the error result of tool call ${e.toolCallId} (${e.toolName}):`,images:t}}function P(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 F(e,t){return t.input.includes(`image`)?e:e.map(e=>e.role===`user`&&Array.isArray(e.content)?{...e,content:P(e.content,A)}:e.role===`toolResult`?{...e,content:P(e.content,j)}:e)}function I(e,t,n){let r=new Map,i=F(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{x as a,D as c,p as d,f,i as h,C as i,m as l,g as m,I as n,O as o,_ as p,k as r,S as s,N as t,v as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,Ai as n,L as r,M as i,N as a,O as o,P as s,hi as c,j as l,vr as u}from"./sigil-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,Ai as n,L as r,M as i,N as a,O as o,P as s,hi as c,j as l,vr as u}from"./sigil-_E02VlAZ.js";import{ti as d}from"./extension-hook-BnOqqson.js";import{t as f}from"./parakeet-BiFGn0qi.js";var p=e(n(),1),m=c();function h({inbox:e}){let{selected:n,session:c,action:h,canManage:g,openingError:_}=e,[v,y]=(0,p.useState)(null);if((0,p.useEffect)(()=>{y(null)},[n?.bindingId,n?.conversation.sessionId,g]),n===void 0)return null;let b=n.conversation;return(0,m.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":`Website conversation`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-base-300 p-2`,children:[(0,m.jsx)(`span`,{className:`min-w-0 flex-1 text-sm`,children:b.heldByYou?`You're replying. The Agent is paused.`:b.held?`${b.heldByName??`A teammate`} is replying.`:`The Agent is replying. Take over to answer as yourself.`}),g?(0,m.jsx)(u,{size:`sm`,disabled:h.isPending,onClick:()=>{let e={bindingId:n.bindingId,sessionId:b.sessionId};b.heldByYou?h.mutate({kind:`release`,...e,expectedVersion:b.holdVersion,confirm:!1}):b.held?y({...e,version:b.holdVersion,name:b.heldByName??`A teammate`}):h.mutate({kind:`hold`,...e,expectedVersion:b.holdVersion,confirm:!1})},children:b.heldByYou?`Hand back to Agent`:`Take over`}):null]}),(0,m.jsx)(o,{open:v!==null,onOpenChange:e=>{e||y(null)},children:(0,m.jsxs)(l,{children:[(0,m.jsxs)(s,{children:[(0,m.jsxs)(r,{children:[v?.name,` is replying — take over?`]}),(0,m.jsx)(i,{children:`You will reply as yourself. Their replies stop until they take over again.`})]}),(0,m.jsxs)(a,{children:[(0,m.jsx)(t,{render:(0,m.jsx)(u,{variant:`outline`}),children:`Cancel`}),(0,m.jsx)(u,{disabled:h.isPending||!g,onClick:()=>{v!==null&&(h.mutate({kind:`hold`,bindingId:v.bindingId,sessionId:v.sessionId,expectedVersion:v.version,confirm:!0}),y(null))},children:`Take over`})]})]})}),g?null:(0,m.jsx)(`p`,{className:`p-3 text-sm`,children:`Allow takeover in Grove's App permissions to reply. Your Team permissions still apply.`}),h.isError?(0,m.jsx)(`p`,{role:`alert`,className:`p-2 text-sm text-error`,children:`This conversation changed or website access was removed. Refresh and try again.`}):null,_?(0,m.jsx)(`p`,{role:`alert`,className:`p-2 text-sm text-error`,children:_}):null,c?(0,m.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,m.jsx)(f,{authorOf:d,disambiguateAuthors:!0,session:c,markdownPolicy:`visitor`,composerActionVariant:`outline`},`${n.bindingId}:${b.sessionId}`)}):null]})}export{h as WebsiteConversation};
|
package/dist/index.html
CHANGED
|
@@ -4,16 +4,16 @@
|
|
|
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-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-DAuVGvQA.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/Effect-CsknxyoC.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-DY31Aviq.js">
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/extension-hook-
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/extension-hook-BnOqqson.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/animation-Ca8A_H2p.js">
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/assets/sigil-
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/assets/sigil-_E02VlAZ.js">
|
|
14
14
|
<link rel="modulepreload" crossorigin href="/assets/document-Bq-ilh6h.js">
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/base-face-BYNJAADF.js">
|
|
16
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
16
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DMBHvLFB.css">
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
|
19
19
|
<div id="inbox-root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/grove",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.14",
|
|
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",
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
"@fungi.computer/agar": "0.9.1",
|
|
9
9
|
"@fungi.computer/approvals": "0.2.3",
|
|
10
10
|
"@fungi.computer/cairn": "0.1.0",
|
|
11
|
-
"@fungi.computer/caps": "0.10.
|
|
11
|
+
"@fungi.computer/caps": "0.10.4",
|
|
12
12
|
"@fungi.computer/knapsack": "0.4.9",
|
|
13
13
|
"@fungi.computer/maosaico": "0.1.2",
|
|
14
|
-
"@fungi.computer/parakeet": "0.11.
|
|
14
|
+
"@fungi.computer/parakeet": "0.11.8",
|
|
15
15
|
"@fungi.computer/shiitake": "0.12.4",
|
|
16
16
|
"@fungi.computer/sigils": "0.3.0",
|
|
17
17
|
"@fungi.computer/sprite": "0.2.2",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ai as t,Ar as n,Di as r,E as i,Ir as a,Mr as o,Nr as s,Pr as c,an as l,c as u,g as d,hi as f,jr as p,u as m,vr as h,wr as ee}from"./sigil-Cl1OL4iT.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,sr as se,xa as b,ya as ce}from"./Effect-CsknxyoC.js";import{Ai as x,Bi as le,Ci as S,Dr as ue,Hi as C,Ji as w,Ma as de,Na as T,Ni as E,Pa as D,Pi as fe,Si as O,Ta as k,Wi as pe,Zi as me,_a as A,_i as he,bi as ge,fi as j,i as M,ii as N,ji as _e,ka as P,kr as ve,la as F,li as I,oa as L,oi as R,pa as ye,pi as z,ri as be,ti as xe,ui as Se,xa as B,xi as Ce,yi as V}from"./extension-hook-DLrsMGve.js";import{a as we,c as Te,d as H,i as Ee,l as De,n as Oe,o as ke,r as Ae,s as je,u as Me}from"./parakeet-COz-7hhx.js";import{_ as Ne,g as U,h as Pe,m as Fe,p as Ie,t as Le,v as Re,y as ze}from"./index-DUvJpRP8.js";var Be=(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))}`},Ve=(e,t)=>e.length<=t?e:`${e.slice(0,t-1)}…`,He=e=>e.map(([e,t])=>({label:e,value:t}));function Ue(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 We(e){return[`Undo`,e.record.reversibility===`irreversible-external`?`Can't be undone`:`Can be undone`]}function Ge(e,t){let{record:n}=e;return{content:{title:`Allow ${n.module} · ${n.operation}?`,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:He([We(e),...Ue(e,t)])}}}function Ke(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`,Be(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`,Ve(t.alwaysAllowCoverage,Math.max(8,n-12))]),!o&&t.warning!==void 0&&f.push([`Warning`,t.warning]);let p=o?`Always allow “${Be(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`],We(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])),!o&&t.warning!==void 0&&m.push([`Warning`,t.warning]),m.push(...Ue(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:He(f),details:He(m)},always:p===void 0?void 0:Ve(p,Math.max(12,n-5)),confirmation:o?{title:`Always allow “${a}” in this project?`,body:Ve(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 qe(e,t,n){let r=Math.min(n.width,60);return t===void 0?Ge(e,n.now):Ke(e,t,r,n.home,n.now)}function Je(e,t){switch(e){case`stale-revision`:case`already-answered`:return`This request changed. Look again before answering.`;case`expired`:return`This request expired. Nothing ran.`;case`not-eligible`:if(t===`always-allow`)return`Always allow isn't available for this command. Approve once or deny.`}return`Couldn't answer (${e}). Nothing ran.`}var Ye=`Couldn't send your answer. It may not have been recorded.`;async function Xe(e,t){let{view:n,source:r}=t,i=qe(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 this family.`: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:`Later ${a.module} requests that ${a.access===`write`?`change data in Fungi`:`reach outside Fungi`} will run without asking.`,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:Je(l.reason??`unknown`,n)}:{kind:`answered`}:{kind:`abandoned`}}catch(n){return e.signal.aborted?{kind:`abandoned`}:(t.onFailure(n),{kind:`refused`,message:Ye})}}var W=e(t(),1),Ze=()=>void 0,Qe=()=>()=>void 0;function $e(e){let{source:t,store:n,enabled:r,home:i,width:a,noteLimit:o,onFailure:s}=e,c=(0,W.useRef)(s);c.current=s;let l=(0,W.useRef)({home:i,width:a,noteLimit:o});l.current={home:i,width:a,noteLimit:o};let u=(0,W.useSyncExternalStore)(t?.subscribe??Qe,t?.snapshot??Ze),d=(0,W.useRef)(u);d.current=u;let f=u===void 0?void 0:JSON.stringify([`approval`,u.record.recordId,u.record.revision,u.canAnswer]);(0,W.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 Xe(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 G=f(),K=O.check(k(1),B(256)),et=I.check(F(1),A(2**53-1)),tt=I.check(F(0),A(2**53-1)),nt=z([`write`,`external`]),rt=S({module:V(K),access:nt}),it=S({agentId:V(K)}),at=S({principalId:K,agentId:V(K),sessionId:V(K),displayName:K}),ot=S({title:O.check(k(1),B(512)),inputBytes:I.check(F(0)),inputSha256:O.check(P(/^[a-f0-9]{64}$/))}),st=S({kind:j(`pending_approval`),recordId:K,description:ot}),ct=z([`requested`,`pending`,`approved`,`claimed`,`applied`,`denied`,`expired`,`outcome_unknown`]),lt=z([`not-found`,`not-eligible`,`already-answered`,`stale-revision`,`expired`,`declined`,`fenced`,`not-granted`,`read-only`,`pending`,`in-flight`,`outcome-unknown`,`identity-conflict`]),ut=O.check(k(1),B(512),P(/^(?=.*\S)[^\p{Cc}\u2028\u2029]*$/u)),dt=N(S({kind:j(`artifact`),ref:O.check(P(/^sha256:[a-f0-9]{64}$/)),mediaType:j(`image/png`),bytes:I.check(F(1),A(5242880))})).check(B(4)),ft=S({recordId:K,requester:at,module:K,operation:K,access:nt,description:ot,evidence:D(dt),authorityFence:K,reversibility:z([`reversible`,`irreversible-external`]),state:ct,by:V(x([S({kind:j(`human`),memberId:K}),S({kind:j(`policy`)})])),reason:V(lt),denialNote:D(ut),requestedAt:tt,expiresAt:tt,updatedAt:tt,revision:et}),pt=S({record:ft,canAnswer:R,canSetAutoApprove:R});S({state:D(ct),cursor:D(K),limit:D(I.check(F(1),A(100)))}),S({recordId:K}),S({recordId:K,decision:z([`approve`,`deny`]),expectedRevision:et,denialNote:D(ut)});var mt=S({scope:it,family:rt,enabled:R}),ht=S({kind:j(`refused`),reason:lt,denialNote:D(ut)});C(w(ft),{onExcessProperty:`error`}),pe(w(ft)),C(S({record_json:O})),C(w(Se)),pe(w(Se)),C(S({input_json:O,output_json:V(O)}));var gt=ht,_t=S({items:N(pt),nextCursor:V(O)}),vt=x([S({kind:j(`answered`),view:pt}),gt]),yt=x([S({kind:j(`updated`),rule:mt}),gt]),q=e=>Fe(te().transform(t=>C(e,{onExcessProperty:`error`})(t))),bt=Re(`approvals`,1,ie(()=>Pe({list:U(q(_t)),get:U(q(V(pt))),answer:U(q(vt)),setAutoApprove:U(q(yt))}))),J=fe(e=>Me.safeParse(e).success,{representation:{id:`@fungi.computer/whistle/catalog-step/v1`,payload:null}});ae(()=>be());var xt=O.pipe(E(k(1)),E(B(4e3)),E(P(/\S/u,{message:`Goal objective is blank`}))),St=O.pipe(E(k(1)),E(B(1e3)),E(P(/\S/u))),Ct=O.pipe(E(k(1)),E(B(256))),wt=I.check(F(0)),Tt=S({kind:z([`person`,`delegator`,`blocked`,`stalled`,`cancelled`,`failed`,`no-terminal`]),detail:V(O)}),Y=S({revision:O,objective:xt,state:z([`active`,`paused`]),startedAt:wt,pauseCause:V(Tt)}),Et=S({sequence:I.check(L(0)),objective:xt,outcome:z([`achieved`,`cleared`]),reason:V(St),clearedBy:D(he.check(B(256))),endedAt:wt,afterSequence:I.check(F(0))}),Dt=x([S({action:j(`set`),objective:xt,requestId:Ct,expectedRevision:T(V(O)),confirmed:T(R)}),S({action:z([`pause`,`resume`,`replace`,`clear`,`clear-ask`]),confirmed:T(R)}),S({})]),Ot=S({goal:V(Y),ended:N(Et).check(B(16)),omitted:I.check(F(0))}),kt={id:M.make(`botanical-session-goal`),commands:{controlAgent:{scope:`session`,input:S({action:z([`pause`,`resume`,`clear`]),reason:St}),output:x([S({result:j(`paused`),goal:Y}),S({result:j(`resumed`),goal:Y}),S({result:j(`cleared`)}),S({result:j(`no_goal`)}),S({result:j(`refused`),reason:z([`not_delegator`,`not_paused_by_delegator`])})])},goal:{scope:`session`,input:Dt,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:xt,expectedRevision:V(O),requestId:Ct,adoptCommandId:D(Ct)}),output:S({goal:Y,accepted:S({status:j(`accepted`),commandId:O})})}},projection:{schema:Ot}},X=e=>{let t=e.replace(/\s+/gu,` `).trim();return t.length<=80?t:`${t.slice(0,79)}…`},At=e=>{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`};function jt(e){let t=e.state===`active`,n=t?`Pursuing goal since ${At(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 Mt(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 Nt=H(kt,{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?[]:[jt(t)],timeline:{cells:n.map(Mt),omitted:r},waiting:null}}}),Pt=O.pipe(E(k(1)),E(B(256))),Ft=O.pipe(E(k(1)),E(B(262144))),It=S({expression:O.pipe(E(k(1)),E(B(256))),timeZone:O.pipe(E(k(1)),E(B(128)))}),Z=S({loopId:O,origin:z([`human`,`model`]),expiresAt:V(I),prompt:Ft,mode:z([`self_paced`,`fixed_interval`]),cron:V(It),state:z([`active`,`paused`,`finished`,`failed`,`cancelled`]),commandId:O,reason:V(O),nextDueAt:V(I),lastError:V(O),consecutiveFailures:I.pipe(E(F(0)))}),Lt=S({after:D(Pt),limit:D(I.pipe(E(me({minimum:1,maximum:64}))))}),Rt=O.pipe(E(k(1)),E(B(200))),zt=S({loop:Z,accepted:S({status:j(`accepted`),commandId:O})}),Bt=x([S({action:j(`start`),text:Ft,requestId:Rt}),S({action:z([`status`,`pause`,`resume`,`stop`,`stop-ask`,`new`]),confirmed:T(R)}),S({})]),Vt=S({loop:Z}),Ht=S({sessionId:Pt,loopId:Z.fields.loopId}),Ut={id:M.make(`botanical-session-loop`),commands:{list:{scope:`agent`,input:Lt,output:N(S({...Z.fields,sessionId:Pt})).pipe(E(B(64)))},pauseLoop:{scope:`agent`,input:Ht,output:Z},resumeLoop:{scope:`agent`,input:Ht,output:Z},stopLoop:{scope:`agent`,input:Ht,output:Z},loop:{scope:`session`,input:Bt,output:J},startSelfPaced:{scope:`session`,input:S({prompt:Ft,requestId:Rt}),output:zt},startFixedInterval:{scope:`session`,input:S({prompt:Ft,requestId:Rt,...It.fields}),output:zt},pause:{scope:`session`,input:S({}),output:Z},resume:{scope:`session`,input:S({}),output:Z},stop:{scope:`session`,input:S({}),output:Z}},projection:{schema:Vt}},Wt=e=>{let t=e.replace(/\s+/gu,` `).trim();return t.length<=60?t:`${t.slice(0,59)}…`},Gt=e=>e.state===`failed`?`error`:e.state===`active`?`running`:e.state===`paused`?`muted`:`settled`,Kt=e=>new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,timeZoneName:`short`}).format(e),qt=H(Ut,{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:Gt(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 ${Kt(t.nextDueAt)}`} · ${Wt(t.prompt)}`,detail:[t.reason,t.prompt].filter(e=>e!==null).join(`
|
|
2
|
-
`).slice(0,1024),tone:Gt(t)},...t.lastError===null?[]:[{id:`error`,title:t.lastError.slice(0,4096),tone:`error`}]],timeline:{cells:[],omitted:0},waiting:n?{summary:`Waiting until ${Kt(t.nextDueAt)}`,cancel:{id:`loop`,label:`stop loop`,input:{action:`stop-ask`}}}:null}}});function Jt(e){return S({nextSequence:I.check(L(0)),omitted:I.check(F(0)),events:N(S({id:O,sequence:I,at:I,commandId:V(O),event:e}))})}new TextEncoder;var Yt=S({explanation:D(O.pipe(E(B(2e3)))),steps:N(S({step:O.pipe(E(k(1)),E(B(500))),status:z([`pending`,`in_progress`,`completed`])})).pipe(E(B(50)))});Yt.pipe(E(de(e=>e.steps.filter(e=>e.status===`in_progress`).length<=1||`At most one plan step may be in progress`)));function Xt(e){return e.steps.some(e=>e.status!==`completed`)}var Zt=S({plan:Yt,history:Jt(Yt)}),Qt=x([S({action:j(`clear`)}),S({})]),$t={id:M.make(`botanical-session-plan`),commands:{plan:{scope:`session`,input:Qt,output:J}},projection:{schema:Zt}},en=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)}`}},tn=e=>e.steps.map((e,t)=>({id:String(t),title:e.step,tone:e.status===`completed`?`settled`:e.status===`in_progress`?`running`:`muted`})),nn=H($t,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null||!Xt(e.value.plan)?[]:[{id:`plan`,...en(e.value.plan),actions:[{id:`plan`,label:`Clear plan`,input:{action:`clear`}}],inspection:{commandId:`plan`,title:`Plan`,rows:tn(e.value.plan)}}],timeline:{cells:[],omitted:0},waiting:null})}),Q=e=>O.check(k(1),B(e),P(/\S/u)),rn=S({id:Q(32).check(P(/^[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(k(2),B(4),de(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:D(R)}),an=N(rn).check(k(1),B(4),de(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}})),on=S({askId:O,waitingOn:D(ve),escalated:D(ue),questions:an,status:z([`live`,`parked`]),createdAt:ge,expiresAt:V(ge)}),sn=S({asks:N(on).check(B(4))}),cn=Q(256),ln=Ce(rn.fields.id,S({selected:N(Q(60)).check(B(4)),text:D(O.check(B(4e3)))})),un=S({askId:Q(256),requestId:cn,answers:ln}),dn=S({askId:Q(256),requestId:cn,note:D(O.check(B(4e3)))}),fn=z([`answered`,`declined`,`withdrawn`,`expired`,`cancelled`,`undeliverable`]),pn=x([S({result:j(`accepted`),via:z([`in_turn`,`follow_up`]),commandId:D(Q(256))}),S({result:j(`closed`),status:fn}),S({result:j(`not_found`)})]),mn=S({result:j(`refused`),reason:j(`not_sender`)}),hn=x([pn,mn]),gn=S({kind:j(`agent`),agentId:Q(256)}),_n=x([S({result:j(`escalated`),to:j(`agent`),waitingOn:ve}),S({result:j(`escalated`),to:j(`person`)}),S({result:j(`closed`),status:fn}),S({result:j(`not_found`)}),mn]),vn=S({askId:Q(256),note:T(O.check(B(1e3)))}),yn={askId:un.fields.askId,requestId:cn,index:ge.check(ye(),me({minimum:0,maximum:3})),answers:ln},bn=x([S({stage:j(`decision`),...yn,answer:ln.value}),S({askId:un.fields.askId}),S({})]),xn={id:M.make(`botanical-session-question`),commands:{answerFlow:{scope:`session`,input:bn,output:J},answer:{scope:`session`,input:un,output:pn},answerAgent:{scope:`session`,input:un,output:S({result:hn,answeredBy:gn})},escalateAgent:{scope:`session`,input:vn,output:_n},decline:{scope:`session`,input:dn,output:pn},list:{scope:`session`,input:S({}),output:sn}},projection:{schema:sn}},Sn=H(xn,{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})}),$=O.check(k(1),B(256)),Cn=z([`escalated`,`sender_archived`,`sender_absent`]),wn=z([`working`,`waiting_on_agent`,`needs_you`,`idle`,`failed`,`unavailable`]),Tn=S({agentId:$,name:$,sessionId:V($),state:wn,attention:D(O.check(B(200))),waitingOn:D($),escalated:D(S({by:$,reason:Cn})),ask:D(S({askId:$,questions:an}))}),En=S({agents:N(Tn).check(B(16)),more:I.check(F(0)),uncounted:I.check(F(0)),counts:S({working:I.check(F(0)),waiting_on_agent:I.check(F(0)),needs_you:I.check(F(0)),idle:I.check(F(0)),failed:I.check(F(0)),unavailable:I.check(F(0))}),escalated:I.check(F(0)),waitingOn:N(S({name:$,count:I.check(L(0))})),escalatedBy:N(S({name:$,reason:Cn,count:I.check(L(0))})),expanded:R}),Dn={agentId:$,sessionId:$},On=x(bn.members.map(e=>S({...e.fields,...Dn}))),kn={agents:{scope:`session`,input:S({}),output:J},answerChild:{scope:`session`,input:On,output:J}},An={id:M.make(`botanical-session-subagents`),commands:kn,projection:{schema:En}};function jn(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 Mn={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 Nn(e){let t=e.state===`waiting_on_agent`?`waiting on ${e.waitingOn??`its parent`}`:Mn[e.state].label,n=jn(e.escalated);return n===void 0?t:`${t} · ${n}`}function Pn(e){let t=Mn[e.state],n={id:e.agentId,title:`${e.name} · ${Nn(e)}`,tone:t.tone,status:{label:Nn(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 Fn(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=jn({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)} ${Mn[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:Mn[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 In=H(An,{contribute:e=>({chips:[],panel:e.status!==`running`||e.value===null?[]:e.value.agents.length>0&&!e.value.expanded?[Fn(e.value)]:[...e.value.agents.map(Pn),...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 Ln(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 Rn(e,t){e!==null&&e.showToast({message:t.message,tone:t.variant}).catch(e=>{console.error(`Chat toast failed`,e)})}function zn(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=le(w(_e))(t[0].text);if(y(n))return;let r=l.safeParse(n.value);return r.success?r.data.file:void 0}function Bn({item:e,ui:t}){let n=zn(e),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(!1);if(!n)return null;let s=async()=>{i(!0),o(!1);try{await t.openNavigation(n)}catch(e){console.error(`Chat file navigation failed`,e),o(!0)}finally{i(!1)}};return(0,G.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,G.jsx)(h,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void s(),type:`button`,children:r?`Opening file…`:`Open ${n.path} in Inkcap`}),a?(0,G.jsx)(`p`,{role:`alert`,children:`The file could not be opened. Try again.`}):null]})}var Vn=x([S({kind:j(`compose`),text:O.pipe(E(k(1)),E(B(2e3)))}),S({kind:j(`navigate`),params:N(S({key:O.pipe(E(k(1)),E(B(64))),value:O.pipe(E(B(1024)))})).pipe(E(B(16)))})]);x([S({role:O.pipe(E(k(1)),E(B(80))),intent:Vn}),S({appId:O.pipe(E(k(1)),E(B(128))),intent:Vn})],{mode:`oneOf`});var Hn=ne({displayName:b().min(1).max(80).nullable()}).nullable(),Un=Re(`apps.open`,1,ie(()=>Pe({open:Ne,role:U(Fe(Hn))}))),Wn=(e,t)=>e.require(Un).open(t);Re(`apps.call`,1,ie(()=>Pe({call:U(Fe(te().transform(e=>r(e))))})));var Gn=v({printId:b().min(1).max(256),destination:ne({computerId:b().min(1),path:b().min(1)}),format:_([`png`,`jpeg`,`gif`,`webp`])}),Kn=re(),qn=oe(Kn).or(ce(b(),Kn).transform(e=>Object.values(e)));function Jn(e,t){let n=Gn.safeParse(e);if(n.success)return[n.data];if(t>=3)return[];let r=qn.safeParse(e);return r.success?r.data.flatMap(e=>Jn(e,t+1)):[]}var Yn=Kn.transform(e=>Jn(e,0)).pipe(oe(Gn).min(1).max(8));function Xn(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=le(w(_e))(n.text);if(y(r))return;let i=Yn.safeParse(r.value);return i.success?i.data:void 0}function Zn(e){return Xn(e)!==void 0}function Qn({printId:e,pictures:t,capabilities:n}){let[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(!1),s=async()=>{i(!0),o(!1);try{await Wn(n,{role:`media`,intent:{kind:`navigate`,params:[{key:`print`,value:e}]}})}catch(e){console.error(`Chat print navigation failed`,e),o(!0)}finally{i(!1)}};return(0,G.jsxs)(`div`,{className:`flex flex-col items-start gap-2 px-3 py-2`,children:[t.map((e,t)=>(0,G.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,G.jsx)(h,{variant:`outline`,size:`sm`,disabled:r,onClick:()=>void s(),type:`button`,children:r?`Opening Prints…`:`Open in Prints`}),a?(0,G.jsx)(`p`,{role:`alert`,children:`Prints could not be opened. Try again.`}):null]})}function $n({item:e,capabilities:t}){let n=Xn(e);if(n&&t){let r=(e.result?.content??[]).flatMap(e=>e.type===`image`?[e]:[]),i=r.length===n.length;return(0,G.jsx)(G.Fragment,{children:n.map((e,n)=>(0,G.jsx)(Qn,{printId:e.printId,pictures:i?r.slice(n,n+1):n===0?r:[],capabilities:t},e.printId))})}return null}var er=le(w(st),{onExcessProperty:`error`});function tr(e){if(!(e.status!==`completed`||e.result?.isError))for(let t of e.result?.content??[]){if(t.type!==`text`)continue;let e=er(t.text);if(se(e))return e.value.recordId}}var nr=(0,W.createContext)(void 0);function rr(){return(0,W.useContext)(nr)}var ir=`Couldn't send your answer. It may not have been recorded.`;function ar({recordId:e,attempt:t,capabilities:n,agentId:r,publish:i}){let a=je(),[o,s]=(0,W.useState)(),c=(0,W.useRef)(void 0),l=(0,W.useRef)(new Set),u=(0,W.useCallback)(t=>{c.current=t??void 0,s(t),i(e,{view:t,failed:!1});for(let e of l.current)e()},[i,e]);(0,W.useEffect)(()=>{c.current=void 0,s(void 0)},[n]),(0,W.useEffect)(()=>{let t=!0;async function r(){try{let r=await n.require(bt).get({recordId:e});t&&u(r)}catch(n){console.warn(`Grove could not read the approval`,n),t&&i(e,{view:null,failed:!0})}}return r(),()=>{t=!1}},[n,e,t,u,i]);let d=o?.canAnswer===!0&&o.record.state===`pending`,f=o?.canSetAutoApprove===!0,p=o?.record.module,m=o?.record.access;return $e({source:(0,W.useMemo)(()=>{if(d)return{snapshot:()=>c.current,subscribe:e=>(l.current.add(e),()=>{l.current.delete(e)}),answer:async e=>{let t=n.require(bt),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 t.answer(e.denialNote===void 0?r:{...r,denialNote:e.denialNote});return i.kind===`answered`&&u(i.view),i},family:!f||p===void 0||m===void 0?void 0:{label:`Always approve this family`,enable:async()=>(await n.require(bt).setAutoApprove({scope:{agentId:r},family:{module:p,access:m},enabled:!0})).kind===`updated`}}},[d,n,r,f,p,m,u]),store:a,enabled:!0,home:``,width:72,noteLimit:512,onFailure:or}),null}function or(e){console.warn(ir,e)}function sr({capabilities:e,agentId:t,children:n}){let r=Te(),i=(0,W.useMemo)(()=>{let e=new Set;for(let t of[...r.settled,...r.tail])if(t.kind===`tool_group`)for(let n of t.tools){let t=tr(n);t!==void 0&&e.add(t)}return[...e]},[r.settled,r.tail]),[a,o]=(0,W.useState)(new Map),[s,c]=(0,W.useState)(new Map),l=(0,W.useCallback)((e,t)=>{o(n=>new Map(n).set(e,t))},[]),u=(0,W.useMemo)(()=>({entry:e=>a.get(e),refresh:e=>{c(t=>new Map(t).set(e,(t.get(e)??0)+1))},agentId:t}),[a,t]);return(0,G.jsxs)(nr.Provider,{value:e===void 0?void 0:u,children:[e===void 0?null:i.map(n=>(0,G.jsx)(ar,{recordId:n,attempt:s.get(n)??0,capabilities:e,agentId:t,publish:l},n)),n]})}var cr={requested:`Approval requested.`,pending:`Pending approval.`,approved:`Approved. Waiting to run.`,applied:`Done.`,denied:`Denied.`,expired:`Expired. Nothing ran.`,claimed:`Dispatch in progress.`,outcome_unknown:`Outcome unknown. Check before trying again.`};function lr({view:e,scope:t,onRefresh:r,onAnswer:i}){let{record:a}=e,l=e.canAnswer&&a.state===`pending`;return(0,G.jsxs)(n,{role:`group`,"aria-label":`Approval request`,density:`compact`,children:[(0,G.jsxs)(s,{children:[(0,G.jsxs)(c,{children:[l?`Allow `:``,a.module,` · `,a.operation,l?`?`:``]}),(0,G.jsxs)(`p`,{children:[a.requester.displayName,` wants to use a connected tool.`]})]}),(0,G.jsxs)(p,{className:`min-w-0 space-y-2`,children:[(0,G.jsxs)(`p`,{children:[`Effect`,` `,a.access===`write`?`Changes data in Fungi`:`Changes things outside Fungi`,a.reversibility===`irreversible-external`?` · can't be undone`:``]}),(0,G.jsx)(`p`,{role:`status`,children:l?`Waiting for your answer.`:cr[a.state]}),(0,G.jsxs)(`details`,{children:[(0,G.jsx)(`summary`,{children:`Details`}),(0,G.jsxs)(`p`,{children:[`Requester: `,a.requester.principalId]}),(0,G.jsxs)(`p`,{children:[`Agent: `,a.requester.displayName,` ·`,` `,a.requester.agentId??`none`]}),(0,G.jsxs)(`p`,{children:[`Session: `,a.requester.sessionId??`none`]}),(0,G.jsxs)(`p`,{children:[`Request: `,a.module,`.`,a.operation,` · `,a.access]}),(0,G.jsxs)(`p`,{children:[`Undo:`,` `,a.reversibility===`irreversible-external`?`Can't be undone`:`Can be undone`]}),(0,G.jsxs)(`p`,{children:[`Can answer: `,e.canAnswer?`Yes`:`No`]}),(0,G.jsxs)(`p`,{children:[`Can set auto-approve: `,e.canSetAutoApprove?`Yes`:`No`]}),a.by?.kind===`policy`?(0,G.jsx)(`p`,{children:`Auto-approved by policy`}):null,(0,G.jsx)(`p`,{children:a.description.title}),(0,G.jsxs)(`p`,{className:`break-all`,children:[`Input: `,a.description.inputBytes,` bytes · SHA-256`,` `,a.description.inputSha256]}),(0,G.jsxs)(`p`,{children:[`Record: `,a.recordId,` · revision `,a.revision]}),e.canSetAutoApprove?(0,G.jsxs)(`p`,{children:[`Policy scope:`,` `,t.agentId===null?`whole home`:`agent ${t.agentId}`]}):null]})]}),(0,G.jsxs)(o,{className:`flex flex-wrap gap-2`,children:[l?(0,G.jsx)(h,{variant:`outline`,onClick:i,children:`Answer`}):null,(0,G.jsx)(h,{variant:`ghost`,onClick:r,children:`Refresh approval`})]})]})}function ur({recordId:e}){let t=rr(),n=je(),r=t?.entry(e);return t===void 0||r===void 0?null:r.failed?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{role:`alert`,children:`Couldn't load this approval. Try again.`}),(0,G.jsx)(h,{variant:`ghost`,onClick:()=>{t.refresh(e)},children:`Refresh approval`})]}):r.view===null||r.view.record.state===`expired`?null:(0,G.jsx)(lr,{view:r.view,scope:{agentId:t.agentId},onRefresh:()=>{t.refresh(e)},onAnswer:()=>{n.awaiting.focus()}})}var dr=(0,W.forwardRef)(function({heading:e,eyebrow:t,cover:r,action:i,children:c,className:l,...u},d){return(0,G.jsxs)(n,{...u,className:a(`caps-game-share`,l),ref:d,children:[r?(0,G.jsx)(`div`,{className:`caps-game-share-cover`,children:r}):null,(0,G.jsxs)(s,{children:[t,(0,G.jsx)(`h3`,{className:`caps-game-share-heading`,children:e})]}),(0,G.jsx)(p,{className:`gap-sm`,children:c}),(0,G.jsx)(o,{children:(0,G.jsx)(h,{asChild:!0,variant:`primary`,className:`caps-game-share-action`,children:i})})]})});function fr(e){let t=0;return e.map(e=>{let n={...e,offset:t};return t+=e.text.length,n})}function pr({value:e,label:t,fieldLabel:n,displayValue:r,layout:o,title:s,tokens:c,className:l,...f}){let p=(0,W.useId)(),[g,te]=(0,W.useState)({kind:`ready`}),_=c?c.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,G.jsxs)(`div`,{...f,className:a(`caps-copy-field-input`,l),children:[(0,G.jsx)(m,{htmlFor:p,children:n}),(0,G.jsxs)(u,{children:[(0,G.jsx)(d,{className:`caps-copy-field-control`,"aria-label":n,id:p,onFocus:e=>{e.currentTarget.select()},readOnly:!0,value:r??_}),(0,G.jsx)(h,{onClick:()=>void v(),size:`sm`,variant:`outline`,children:g.kind===`copied`?`Copied`:t??`Copy`})]}),g.kind===`failed`?(0,G.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,G.jsxs)(`figure`,{...f,className:a(`caps-copy-field-block`,l),"data-state":g.kind,children:[(0,G.jsxs)(`figcaption`,{className:`caps-copy-field-header`,children:[(0,G.jsx)(`span`,{className:`caps-copy-field-title`,children:s}),(0,G.jsxs)(h,{onClick:()=>void v(),size:`sm`,variant:g.kind===`copied`?`ghost`:`outline`,children:[g.kind===`copied`?(0,G.jsx)(i,{"aria-hidden":`true`,size:15}):(0,G.jsx)(Ee,{"aria-hidden":`true`,size:15}),y]}),(0,G.jsx)(ee,{role:`status`,children:g.kind===`copied`?`Copied to the clipboard`:g.kind===`failed`?`Could not copy. Select the code to copy it.`:``})]}),(0,G.jsx)(`pre`,{className:`caps-copy-field-code`,tabIndex:0,children:(0,G.jsx)(`code`,{children:c?fr(c).map(e=>(0,G.jsx)(`span`,{className:`caps-copy-field-token`,"data-kind":e.kind,children:e.text},e.offset)):_})})]}):(0,G.jsxs)(`div`,{...f,className:a(`caps-copy-field`,l),children:[(0,G.jsx)(`code`,{className:`caps-copy-field-value`,children:_}),(0,G.jsxs)(h,{"aria-label":`${y}: ${_}`,onClick:()=>void v(),size:`sm`,variant:`outline`,children:[g.kind===`copied`?(0,G.jsx)(i,{size:15}):(0,G.jsx)(Ee,{size:15}),y]})]})}var mr=v({game:v({title:b().min(1),summary:b(),coverUrl:g().nullable(),shareUrl:g()})});function hr(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 gr(e){return hr(e)?e.split(`
|
|
3
|
-
`).filter(e=>!/^\s*Share:\s*/iu.test(e)).join(`
|
|
4
|
-
`).trim():e}function _r(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 vr({reply:e,previewGame:t}){let n=hr(e),r=n?_r(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=mr.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,G.jsxs)(dr,{"data-game-share-card":`true`,"data-theme":`vishnu`,heading:a?.title??`Your game is ready`,eyebrow:(0,G.jsx)(Ae,{tone:`secondary`,variant:`quiet`,children:`Made with your Agent`}),cover:c?(0,G.jsx)(`img`,{alt:`A scene from ${a?.title??`your game`}`,src:c}):null,action:(0,G.jsx)(`a`,{href:n,rel:`noopener noreferrer`,target:`_blank`,children:`Play ↗`}),children:[a?.summary?(0,G.jsx)(`p`,{className:`text-sm`,children:a.summary}):null,(0,G.jsx)(pr,{displayValue:s,fieldLabel:`Share link`,label:`Copy link`,value:n})]})}var yr=[Nt,qt,nn,Sn,In],br=e=>(0,G.jsx)(vr,{reply:e});function xr({prefill:e,onPrefilled:t}){let n=ke(),r=(0,W.useRef)(null);return(0,W.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 Sr({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,W.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,W.useCallback)(e=>Ln(l,e),[l]),p=(0,W.useCallback)(e=>{let t=tr(e);return t!==void 0&&u!==void 0?(0,G.jsx)(ur,{recordId:t},t):l?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Bn,{item:e,ui:l}),(0,G.jsx)($n,{item:e,capabilities:u})]}):null},[l,u]),m=(0,W.useCallback)(e=>u!==void 0&&Zn(e),[u]),h=(0,W.useCallback)(e=>{Rn(l,e)},[l]);return(0,G.jsxs)(we,{session:e,draftIdentity:t,clients:yr,authorOf:xe,onToast:h,children:[(0,G.jsx)(xr,{prefill:i,onPrefilled:a}),(0,G.jsx)(sr,{capabilities:u,agentId:t.agentId,children:(0,G.jsx)(Oe,{onLink:f,onOpen:o,hostFacts:d,autoFocus:c,composerActionVariant:`outline`,commands:r,renderAssistantAttachment:br,formatAssistantText:gr,renderToolActions:p,claimsToolMedia:m})})]})}export{Sr as ParakeetConversation};
|