@rivet-dev/agentos 0.2.15 → 0.2.16-rc.2

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 (29) hide show
  1. package/assets/inspector-tabs-app/assets/__vite-browser-external-2447137e-BIHI7g3E.js +1 -0
  2. package/assets/inspector-tabs-app/assets/agentos-hero-logo-E3fapwXM.svg +74 -0
  3. package/assets/inspector-tabs-app/assets/filesystem-DQPPvVO9.js +1 -0
  4. package/assets/inspector-tabs-app/assets/hooks-CdZ_23e1.js +1 -0
  5. package/assets/inspector-tabs-app/assets/index-CvS46tYl.js +110 -0
  6. package/assets/inspector-tabs-app/assets/index-DG_s1YoH.css +1 -0
  7. package/assets/inspector-tabs-app/assets/scroll-area-D0TYc2jF.js +1 -0
  8. package/assets/inspector-tabs-app/assets/sed-BwsOyU9v.svg +1 -0
  9. package/assets/inspector-tabs-app/assets/system-C1DTBU1d.js +2 -0
  10. package/assets/inspector-tabs-app/assets/terminal-DhW76lRS.js +13 -0
  11. package/assets/inspector-tabs-app/assets/transcript-OolSpSiF.js +1 -0
  12. package/assets/inspector-tabs-app/assets/useSuspenseQuery-j2bgzu1R.js +1 -0
  13. package/assets/inspector-tabs-app/assets/vm-boot-gate-DG5U7SkD.js +1 -0
  14. package/assets/inspector-tabs-app/assets/vm-status-badges-CKabwPpS.js +5 -0
  15. package/assets/inspector-tabs-app/index.html +2 -2
  16. package/dist/index.d.ts +98 -2
  17. package/dist/index.js +445 -5
  18. package/dist/index.js.map +1 -1
  19. package/package.json +5 -4
  20. package/assets/inspector-tabs-app/assets/badge-BmCA5T7W.js +0 -1
  21. package/assets/inspector-tabs-app/assets/filesystem-Ddl1E2J2.js +0 -1
  22. package/assets/inspector-tabs-app/assets/index-BGua85-g.js +0 -125
  23. package/assets/inspector-tabs-app/assets/index-Dt5XhJ9h.css +0 -1
  24. package/assets/inspector-tabs-app/assets/mounts-DGpRABb5.js +0 -1
  25. package/assets/inspector-tabs-app/assets/processes-kG2x8aAp.js +0 -1
  26. package/assets/inspector-tabs-app/assets/scroll-area-DzEUZzTZ.js +0 -1
  27. package/assets/inspector-tabs-app/assets/software-CIIxhwyc.js +0 -1
  28. package/assets/inspector-tabs-app/assets/transcript-DEti4eM2.js +0 -1
  29. package/assets/inspector-tabs-app/assets/useSuspenseQuery-DmE5ZTv0.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as f,u as te,r as l,l as ne,b as Y,c as re,m as oe,j as e,I as F,S as ae,P as ie,A as le,d as K,e as P,C as ce,f as de,g as H,h as U,i as W,k as ue,n as pe}from"./index-CvS46tYl.js";import{u as xe}from"./useSuspenseQuery-j2bgzu1R.js";import{S as G}from"./scroll-area-D0TYc2jF.js";import{V as me}from"./vm-status-badges-CKabwPpS.js";function fe({event:n}){var r,u;switch(n.kind){case"user":return e.jsx("div",{className:"flex justify-end",children:e.jsx("div",{className:"max-w-[80%] whitespace-pre-wrap rounded-2xl rounded-br-md bg-muted px-3.5 py-2 text-sm",children:n.text||"—"})});case"assistant":return e.jsx("div",{className:"flex",children:e.jsx("div",{className:"max-w-[85%] whitespace-pre-wrap text-sm leading-relaxed",children:n.text||"—"})});case"thinking":return e.jsx("div",{className:"flex",children:e.jsx("div",{className:"max-w-[85%] whitespace-pre-wrap text-xs italic leading-relaxed text-muted-foreground/70",children:n.text||"—"})});case"tool":{const a=n.input!==void 0||n.output!==void 0||!!((r=n.locations)!=null&&r.length),o=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono",children:n.tool}),n.status?e.jsx("span",{className:"rounded-full border px-1.5 py-px text-[10px]",children:n.status}):null]});return a?e.jsxs("details",{className:"group rounded-lg border border-foreground/10 bg-muted/20 text-xs text-muted-foreground",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-2 px-2.5 py-1.5 [&::-webkit-details-marker]:hidden",children:[e.jsx(W,{className:"size-3 shrink-0 transition-transform group-open:rotate-90"}),o]}),e.jsxs("div",{className:"flex flex-col gap-2 border-t border-foreground/10 px-2.5 py-2",children:[n.input!==void 0?e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 text-[10px] text-muted-foreground/70",children:"Input"}),e.jsx("pre",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words rounded bg-muted/50 p-2 font-mono text-[11px] leading-relaxed",children:JSON.stringify(n.input,null,2)})]}):null,n.output!==void 0?e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 text-[10px] text-muted-foreground/70",children:"Output"}),e.jsx("pre",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words rounded bg-muted/50 p-2 font-mono text-[11px] leading-relaxed",children:n.output})]}):null,(u=n.locations)!=null&&u.length?e.jsx("div",{className:"font-mono text-[11px] text-muted-foreground/70",children:n.locations.join(" ")}):null]})]}):e.jsx("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:o})}case"plan":return e.jsxs("div",{className:"rounded-lg border border-foreground/10 bg-muted/20 px-2.5 py-2 text-xs text-muted-foreground",children:[e.jsx("div",{className:"mb-1 text-[10px] text-muted-foreground/70",children:"Plan"}),e.jsx("ul",{className:"flex flex-col gap-1",children:n.entries.map((a,o)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(P,{color:a.status==="completed"?"green":a.status==="in_progress"?"amber":"muted",className:"mt-1"}),e.jsx("span",{className:H("min-w-0 flex-1",a.status==="completed"&&"text-muted-foreground/60 line-through"),children:a.content})]},`${o}-${a.content.slice(0,24)}`))})]});case"notice":return e.jsx("div",{className:"text-center text-[11px] text-muted-foreground/60",children:n.text});case"permission":return e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-amber-500/30 bg-amber-500/5 px-2.5 py-1.5 text-xs text-amber-500/90",children:[e.jsx(P,{color:"amber",className:"size-1.5"}),n.text]});case"error":return e.jsx("div",{className:"whitespace-pre-wrap text-sm text-destructive",children:n.text});default:return e.jsxs("details",{className:"group text-xs text-muted-foreground/70",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 [&::-webkit-details-marker]:hidden",children:[e.jsx(W,{className:"size-3 shrink-0 transition-transform group-open:rotate-90"}),e.jsx("span",{className:"font-mono",children:n.label})]}),e.jsx("pre",{className:"mt-1.5 max-h-48 overflow-y-auto whitespace-pre-wrap break-words rounded bg-muted/50 p-2 font-mono text-[11px] leading-relaxed",children:JSON.stringify(n.json,null,2)})]})}}function he({count:n}){const r=l.useRef(null),u=l.useRef(!0);return l.useEffect(()=>{const a=r.current,o=a==null?void 0:a.closest("[data-radix-scroll-area-viewport]");if(!a||!o)return;const c=new IntersectionObserver(([x])=>{u.current=x.isIntersecting},{root:o,rootMargin:"0px 0px 96px 0px"});return c.observe(a),()=>c.disconnect()},[]),l.useEffect(()=>{var a;u.current&&((a=r.current)==null||a.scrollIntoView({block:"end"}))},[n]),e.jsx("div",{ref:r,className:"h-px"})}function ge(n){const r=[],u=new Map;let a=null;for(const o of n){const c=r[r.length-1];if((o.kind==="user"||o.kind==="assistant"||o.kind==="thinking")&&(c==null?void 0:c.kind)===o.kind){r[r.length-1]={...c,text:c.text+o.text};continue}if(o.kind==="tool"&&o.toolCallId){const x=u.get(o.toolCallId);if(x!==void 0){const p=r[x];r[x]={...p,tool:o.tool!==o.toolCallId?o.tool:p.tool,status:o.status??p.status,input:o.input??p.input,output:o.output??p.output,locations:o.locations??p.locations};continue}u.set(o.toolCallId,r.length)}if(o.kind==="plan"){if(a!==null){r[a]={...r[a],entries:o.entries};continue}a=r.length}r.push(o)}return r}function ye(){return e.jsx("div",{className:"flex items-center gap-1 px-1 py-0.5","aria-label":"Turn in progress",children:[0,1,2].map(n=>e.jsx("span",{className:"size-1.5 animate-pulse rounded-full bg-muted-foreground/50",style:{animationDelay:`${n*200}ms`}},n))})}const D="agentos-inspector:composer-agent-type",L="agentos-inspector:composer-env",J=n=>`agentos-inspector:transcript:${n}`,X=JSON.stringify({ANTHROPIC_API_KEY:"",OPENCODE_CONFIG_CONTENT:JSON.stringify({model:"anthropic/claude-haiku-4-5-20251001"})},null,2);function ve(){const n=(localStorage.getItem(D)??"opencode").trim()||"opencode",r=localStorage.getItem(L)??X;let u;try{u=JSON.parse(r)}catch(a){throw new Error(`Session env is not valid JSON: ${a.message}`)}return{agentType:n,env:u}}function Ne({actorId:n,sessionId:r,sessionStatus:u,onSessionCreated:a,onErrorEvent:o,onBusyChange:c}){const[x,p]=l.useState(""),[g,R]=l.useState(!1),S=i=>{R(i),c==null||c(i)},[v,N]=l.useState(!1),[j,k]=l.useState(!1),[C,O]=l.useState(()=>localStorage.getItem(D)??"opencode"),[b,A]=l.useState(()=>localStorage.getItem(L)??X),E=l.useRef(null),T=(Y({...f.softwareQueryOptions(n),enabled:j}).data??[]).filter(i=>i.name.endsWith("· agent")).map(i=>{var d;return((d=i.name.split(" · ")[0])==null?void 0:d.split("/").pop())??""}).filter(Boolean),w=async()=>{const i=x.trim();if(!(!i||g)){S(!0),p("");try{let d=r;if(!d){let h;try{h=JSON.parse(b)}catch(_){throw new Error(`Session env is not valid JSON: ${_.message}`)}d=await f.createSession(C.trim()||"opencode",{env:h}),a(d)}E.current=d,await f.sendPrompt(d,i)}catch(d){let h=ue(d)?` — ${d.hint}`:"";r&&u!=="running"&&(h=" — this session is idle (not live in the current VM boot). Send without a selection to start a fresh session, or resume it from a client."),o(`${d instanceof Error?d.message:String(d)}${h}`)}finally{E.current=null,S(!1)}}},I=async()=>{const i=E.current??r;if(i)try{await pe(i)||(N(!0),o("Stop is not supported by this runtime (no cancelPrompt action)."))}catch(d){o(d instanceof Error?d.message:String(d))}};return e.jsx("div",{className:"shrink-0",children:e.jsxs("div",{className:"mx-auto w-full max-w-3xl px-3 pb-3",children:[j&&!r?e.jsxs("div",{className:"mb-2 flex flex-col gap-2 rounded-xl border bg-muted/30 p-3 text-xs",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-24 shrink-0 text-muted-foreground",children:"Agent type"}),e.jsx("input",{value:C,onChange:i=>{O(i.target.value),localStorage.setItem(D,i.target.value)},list:"agentos-composer-agent-types",className:"flex-1 rounded border bg-background px-2 py-1 font-mono"}),e.jsx("datalist",{id:"agentos-composer-agent-types",children:T.map(i=>e.jsx("option",{value:i},i))})]}),e.jsxs("label",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-24 shrink-0 pt-1 text-muted-foreground",children:"Session env"}),e.jsx("textarea",{value:b,onChange:i=>{A(i.target.value),localStorage.setItem(L,i.target.value)},rows:4,spellCheck:!1,className:"flex-1 resize-y rounded border bg-background px-2 py-1 font-mono"})]}),e.jsx("div",{className:"text-muted-foreground/70",children:"Used when sending without a session: creates one with these options. Values stay in this browser."})]}):null,e.jsxs("div",{className:"rounded-2xl border bg-muted/40 transition-colors focus-within:border-ring/60",children:[e.jsx("textarea",{value:x,onChange:i=>p(i.target.value),onKeyDown:i=>{i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),w())},placeholder:r?"Prompt this session…":"Prompt a new session…",rows:2,className:"max-h-48 min-h-[3.25rem] w-full resize-none bg-transparent px-4 pt-3 text-sm placeholder:text-muted-foreground/50 focus:outline-none"}),e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 pb-2.5",children:[r?null:e.jsxs("button",{type:"button",onClick:()=>k(i=>!i),title:"New-session options (agent, env)",className:"inline-flex items-center gap-1 rounded px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[e.jsx("span",{"aria-hidden":"true",className:"text-sm leading-none",children:"+"}),"Options"]}),e.jsx("span",{className:"ml-auto"}),g?e.jsx("button",{type:"button",onClick:()=>void I(),disabled:v,title:v?"This runtime has no cancelPrompt action":"Stop the running turn",className:"inline-flex size-8 items-center justify-center rounded-md bg-foreground/90 text-background transition-opacity hover:opacity-80 disabled:opacity-40",children:e.jsx("span",{"aria-hidden":"true",className:"block size-2.5 rounded-[2px] bg-current"})}):e.jsx("button",{type:"button",onClick:()=>void w(),disabled:!x.trim(),title:"Send (⏎)",className:"inline-flex size-8 items-center justify-center rounded-md bg-primary text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-40",children:e.jsx("svg",{viewBox:"0 0 16 16",className:"size-4",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M8 13V3M4 7l4-4 4 4"})})})]})]})]})})}function Ce({actorId:n}){var V;const{data:r}=xe(f.sessionsQueryOptions(n)),u=te(),[a,o]=l.useState(()=>{try{const s=sessionStorage.getItem(J(n));if(!s)return;const t=JSON.parse(s);return t.selected===null||typeof t.selected=="string"?t.selected:void 0}catch{return}});l.useEffect(()=>{try{a===void 0?sessionStorage.removeItem(J(n)):sessionStorage.setItem(J(n),JSON.stringify({selected:a}))}catch(s){console.warn("agentos inspector: failed to persist transcript state",s)}},[n,a]);const c=a===void 0||typeof a=="string"&&!r.some(s=>s.sessionId===a)?((V=r[0])==null?void 0:V.sessionId)??null:a,x=l.useMemo(()=>ne(r),[r]),p=s=>x.has(s.sessionId),{data:g=[]}=Y(f.transcriptQueryOptions(n,c)),S=re().useEvent,[v,N]=l.useState([]),j=l.useRef(0),k=l.useRef(c);k.current=c,l.useEffect(()=>{N([])},[c]),S("sessionEvent",s=>{const t=s,y=k.current;if(!y||!(t!=null&&t.sessionId)||t.sessionId!==y)return;let m=oe(t);t.type==="permission_request"&&m.kind==="permission"&&(m={...m,text:`${m.text} (answer in the banner above)`});const q=j.current++;N(B=>{if(t.durability==="durable"){const se=t.type==="agent_message_chunk"||t.type==="agent_thought_chunk";return[...B.filter($=>$.seq!==m.seq&&!(se&&$.kind===m.kind&&!Number.isInteger($.seq)&&$.seq<m.seq)),{...m,liveKey:q}]}return[...B,{...m,liveKey:q}]})}),S("agentExit",s=>{const t=s,y=k.current;if(!y||(t==null?void 0:t.sessionId)!==y)return;const m=j.current++;N(q=>[...q,{kind:"error",seq:-1-m,liveKey:m,text:`Agent crashed (exit ${t.exitCode??"?"}) — restart: ${t.restart}${t.restartCount?` (attempt ${t.restartCount})`:""}`}])});const C=s=>{const t=j.current++;N(y=>[...y,{kind:"error",seq:-1-t,liveKey:t,text:s}])},O=s=>{o(s),u.invalidateQueries({queryKey:f.sessionsQueryOptions(n).queryKey})},[b,A]=l.useState(!1),[E,z]=l.useState(!1),[T,w]=l.useState(""),I=T.trim().toLowerCase(),i=I?r.filter(s=>s.sessionId.toLowerCase().includes(I)||s.agent.toLowerCase().includes(I)):r,[d,h]=l.useState(null),_=async()=>{if(!b){A(!0),h(null);try{const{agentType:s,env:t}=ve();O(await f.createSession(s,{env:t}))}catch(s){h(s)}finally{A(!1)}}},[M,Z]=l.useState(!1),ee=async s=>{try{await f.closeSession(s)}catch(t){C(t instanceof Error?t.message:String(t))}o(void 0),u.invalidateQueries({queryKey:f.sessionsQueryOptions(n).queryKey})},Q=l.useMemo(()=>{const s=new Set(g.map(t=>t.seq));return ge([...g.map(t=>({...t,key:`b-${t.seq}`})),...v.filter(t=>!s.has(t.seq)).map(t=>({...t,key:`l-${t.liveKey}`}))])},[g,v]);return e.jsxs("div",{className:"flex h-full min-h-0",children:[e.jsxs("div",{className:"flex h-full w-64 shrink-0 flex-col border-r",children:[e.jsxs("div",{className:"flex items-center px-3 pb-1 pt-2.5",children:[e.jsxs("span",{className:"text-[11px] font-medium text-muted-foreground",children:["Sessions",x.size>0?` · ${x.size} live`:""]}),e.jsx("span",{className:"ml-auto"}),e.jsx(F,{title:"Search sessions by id",onClick:()=>z(s=>(s&&w(""),!s)),className:"mr-1",children:e.jsx(ae,{className:"size-3.5"})}),e.jsx(F,{title:b?"Creating session…":"New session",onClick:()=>void _(),disabled:b,children:e.jsx(ie,{className:"size-3.5"})})]}),E?e.jsx("div",{className:"px-3 pb-1.5",children:e.jsx("input",{value:T,onChange:s=>w(s.target.value),onKeyDown:s=>{s.key==="Escape"&&(w(""),z(!1))},spellCheck:!1,autoFocus:!0,"aria-label":"Search sessions",placeholder:"session id or agent",className:"w-full rounded border bg-background px-2 py-1 font-mono text-xs focus:outline-none"})}):null,d?e.jsx(le,{error:d,className:"border-b py-2"}):null,r.length===0?e.jsx(K,{children:"No sessions yet."}):e.jsx(G,{className:"min-h-0 flex-1",children:e.jsxs("div",{className:"p-1.5",children:[i.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No sessions match."}):null,i.map(s=>e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>o(s.sessionId),onKeyDown:t=>{(t.key==="Enter"||t.key===" ")&&o(s.sessionId)},className:H("group flex w-full cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-left",s.sessionId===c?"bg-muted":"hover:bg-muted/50"),children:[e.jsx(P,{color:p(s)?"green":"muted"}),e.jsxs("div",{className:"min-w-0 flex-1",title:p(s)?"Live in the current VM":"Idle — persisted, not loaded in the current VM",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsxs("span",{className:"truncate font-mono",children:["…",s.sessionId.slice(-12)]}),e.jsx(ce,{value:s.sessionId,className:"opacity-0 focus:opacity-100 group-hover:opacity-100"})]}),e.jsxs("div",{className:"truncate text-[10px] text-muted-foreground/60",children:[s.agent," · ",de(Date.parse(s.createdAt))]})]}),p(s)?e.jsx("button",{type:"button",onClick:t=>{t.stopPropagation(),ee(s.sessionId)},title:"End the live agent process; the transcript stays","aria-label":"Close session",className:"text-muted-foreground/40 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 group-hover:opacity-100",children:e.jsx("svg",{viewBox:"0 0 12 12",className:"size-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round","aria-hidden":"true",children:e.jsx("path",{d:"M3 3l6 6M9 3l-6 6"})})}):null]},s.sessionId))]})})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[e.jsx("div",{className:"absolute right-3 top-2 z-10",children:e.jsx(me,{actorId:n})}),c?e.jsx(e.Fragment,{children:Q.length===0&&!M?e.jsx(K,{children:e.jsxs("div",{className:"flex flex-col items-center gap-5",children:[e.jsx(U,{className:"w-44"}),e.jsx("span",{children:"No activity yet — send a prompt below."})]})}):e.jsx(G,{className:"min-h-0 flex-1",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-3 px-4 py-4",children:[Q.map(s=>e.jsx(fe,{event:s},s.key)),M?e.jsx(ye,{}):null,e.jsx(he,{count:g.length+v.length})]})})}):e.jsx(K,{children:e.jsxs("div",{className:"flex flex-col items-center gap-5",children:[e.jsx(U,{className:"w-44"}),e.jsx("span",{children:"No session selected — press + or send a prompt below to start one."})]})}),e.jsx(Ne,{actorId:n,sessionId:c,sessionStatus:c?(()=>{const s=r.find(t=>t.sessionId===c);return s&&p(s)?"running":"idle"})():void 0,onSessionCreated:O,onErrorEvent:C,onBusyChange:Z})]})]})}export{Ce as TranscriptTabConnected};
@@ -0,0 +1 @@
1
+ import{Y as r,Q as u,N as s}from"./index-CvS46tYl.js";function t(e,a){return r({...e,enabled:!0,suspense:!0,throwOnError:s,placeholderData:void 0},u)}export{t as u};
@@ -0,0 +1 @@
1
+ var K=e=>{throw TypeError(e)};var E=(e,t,s)=>t.has(e)||K("Cannot "+s);var r=(e,t,s)=>(E(e,t,"read from private field"),s?s.call(e):t.get(e)),y=(e,t,s)=>t.has(e)?K("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),f=(e,t,s,i)=>(E(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s),v=(e,t,s)=>(E(e,t,"access private method"),s);import{v as A,x as N,a0 as R,a1 as Q,w as k,u as U,r as x,J as q,a2 as L,b as V,a3 as B,j as m,d as D,h as F}from"./index-CvS46tYl.js";var n,l,o,h,u,C,M,P,G=(P=class extends A{constructor(t,s){super();y(this,u);y(this,n);y(this,l);y(this,o);y(this,h);f(this,n,t),this.setOptions(s),this.bindMethods(),v(this,u,C).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var i;const s=this.options;this.options=r(this,n).defaultMutationOptions(t),N(this.options,s)||r(this,n).getMutationCache().notify({type:"observerOptionsUpdated",mutation:r(this,o),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&R(s.mutationKey)!==R(this.options.mutationKey)?this.reset():((i=r(this,o))==null?void 0:i.state.status)==="pending"&&r(this,o).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=r(this,o))==null||t.removeObserver(this)}onMutationUpdate(t){v(this,u,C).call(this),v(this,u,M).call(this,t)}getCurrentResult(){return r(this,l)}reset(){var t;(t=r(this,o))==null||t.removeObserver(this),f(this,o,void 0),v(this,u,C).call(this),v(this,u,M).call(this)}mutate(t,s){var i;return f(this,h,s),(i=r(this,o))==null||i.removeObserver(this),f(this,o,r(this,n).getMutationCache().build(r(this,n),this.options)),r(this,o).addObserver(this),r(this,o).execute(t)}},n=new WeakMap,l=new WeakMap,o=new WeakMap,h=new WeakMap,u=new WeakSet,C=function(){var s;const t=((s=r(this,o))==null?void 0:s.state)??Q();f(this,l,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},M=function(t){k.batch(()=>{var s,i,a,p,c,g,S,w;if(r(this,h)&&this.hasListeners()){const b=r(this,l).variables,O=r(this,l).context,j={client:r(this,n),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(i=(s=r(this,h)).onSuccess)==null||i.call(s,t.data,b,O,j)}catch(d){Promise.reject(d)}try{(p=(a=r(this,h)).onSettled)==null||p.call(a,t.data,null,b,O,j)}catch(d){Promise.reject(d)}}else if((t==null?void 0:t.type)==="error"){try{(g=(c=r(this,h)).onError)==null||g.call(c,t.error,b,O,j)}catch(d){Promise.reject(d)}try{(w=(S=r(this,h)).onSettled)==null||w.call(S,void 0,t.error,b,O,j)}catch(d){Promise.reject(d)}}}this.listeners.forEach(b=>{b(r(this,l))})})},P);function T(e,t){const s=U(),[i]=x.useState(()=>new G(s,e));x.useEffect(()=>{i.setOptions(e)},[i,e]);const a=x.useSyncExternalStore(x.useCallback(c=>i.subscribe(k.batchCalls(c)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),p=x.useCallback((c,g)=>{i.mutate(c,g).catch(q)},[i]);if(a.error&&L(i.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:p,mutateAsync:a.mutate}}function W({actorId:e,note:t,actionLabel:s,children:i}){const a=V(B(e)),[p,c]=x.useState(!1);return a.data&&!a.data.booted&&!p?m.jsx(D,{children:m.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[m.jsx(F,{className:"mb-3 w-44"}),m.jsx("span",{children:t}),m.jsx("button",{type:"button",onClick:()=>c(!0),className:"rounded-md border px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:s})]})}):m.jsx(m.Fragment,{children:i})}export{W as V,T as u};
@@ -0,0 +1,5 @@
1
+ import{k as h,b,a3 as j,r as x,c as v,j as t,e as $,g as N,i as w,C as d,f as g}from"./index-CvS46tYl.js";function k(s){return h(s)&&s.layer==="contract"}function C(s,r){if((r==null?void 0:r.kind)==="shutdown"){const a=r.reason??"unknown";return a==="error"?{tone:"red",label:"VM shut down after an error"}:{tone:"muted",label:`VM shut down (${a})`}}return s?s.sidecar&&s.sidecar.state!=="ready"?{tone:"red",label:`sidecar ${s.sidecar.state}`}:!s.booted&&(r==null?void 0:r.kind)!=="booted"?{tone:"muted",label:"VM not booted"}:null:null}function S({actorId:s,align:r="right"}){const a=b(j(s)),[p,c]=x.useState(null),[u,f]=x.useState(!1),m=v().useEvent;if(m("vmBooted",()=>{c({kind:"booted"}),a.refetch()}),m("vmShutdown",e=>{c({kind:"shutdown",reason:e==null?void 0:e.reason}),a.refetch()}),a.error&&k(a.error))return null;const n=a.data,o=a.error?{tone:"muted",label:"health unavailable"}:C(n,p),i=((n==null?void 0:n.warnings.length)??0)+((n==null?void 0:n.agentExits.length)??0);return!o&&i===0?null:t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-xs",children:[o?t.jsxs("span",{className:N("inline-flex items-center gap-1.5 rounded border px-2 py-0.5 text-[11px]",o.tone==="red"?"border-destructive/40 text-destructive":"border-foreground/15 text-muted-foreground"),children:[t.jsx($,{color:o.tone==="red"?"red":"muted"}),o.label]}):null,i>0?t.jsxs("span",{className:"relative",children:[t.jsxs("button",{type:"button",onClick:()=>f(e=>!e),className:"inline-flex items-center gap-1 rounded border border-amber-500/40 px-2 py-0.5 text-[11px] text-amber-500 transition-colors hover:bg-amber-500/10",children:[i," warning",i===1?"":"s",t.jsx(w,{className:`size-2.5 transition-transform ${u?"rotate-90":""}`})]}),u&&n?t.jsxs("div",{className:`absolute top-full z-20 mt-1 max-h-64 w-80 overflow-y-auto rounded-md border bg-background p-2 text-[11px] leading-relaxed shadow-lg ${r==="right"?"right-0":"left-0"}`,children:[n.warnings.length>0?t.jsxs("div",{className:"mb-2",children:[t.jsxs("div",{className:"mb-1 flex items-center gap-1 font-medium text-muted-foreground",children:["Limit warnings",t.jsx(d,{value:n.warnings.map(e=>`${new Date(e.ts).toISOString()} ${e.limit} ${e.observed}/${e.capacity} · ${e.fillPercent}%`).join(`
2
+ `)})]}),n.warnings.map((e,l)=>t.jsxs("div",{className:"flex items-center gap-2 font-mono",children:[t.jsxs("span",{children:[e.limit," ",e.observed,"/",e.capacity," · ",e.fillPercent,"%"]}),t.jsx("span",{className:"ml-auto text-muted-foreground",children:g(e.ts)})]},`w-${l}`))]}):null,n.agentExits.length>0?t.jsxs("div",{className:"mb-2",children:[t.jsxs("div",{className:"mb-1 flex items-center gap-1 font-medium text-muted-foreground",children:["Agent exits",t.jsx(d,{value:n.agentExits.map(e=>`${new Date(e.ts).toISOString()} ${e.agentType} session=${e.sessionId} exit=${e.exitCode??"?"} restart=${e.restart} (${e.restartCount})`).join(`
3
+ `)})]}),n.agentExits.map((e,l)=>t.jsxs("div",{className:"flex items-center gap-2 font-mono",children:[t.jsxs("span",{children:[e.agentType," exit ",e.exitCode??"?"," · ",e.restart," (",e.restartCount,")"]}),t.jsx("span",{className:"ml-auto text-muted-foreground",children:g(e.ts)})]},`e-${l}`))]}):null,n.stderrTail.length>0?t.jsxs("div",{children:[t.jsxs("div",{className:"mb-1 flex items-center gap-1 font-medium text-muted-foreground",children:["Adapter stderr (tail)",t.jsx(d,{value:n.stderrTail.map(e=>e.line).join(`
4
+ `)})]}),t.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-muted-foreground",children:n.stderrTail.map(e=>e.line).join(`
5
+ `)})]}):null]}):null]}):null]})}export{S as V};
@@ -4,8 +4,8 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>agentOS inspector</title>
7
- <script type="module" crossorigin src="./assets/index-BGua85-g.js"></script>
8
- <link rel="stylesheet" crossorigin href="./assets/index-Dt5XhJ9h.css">
7
+ <script type="module" crossorigin src="./assets/index-CvS46tYl.js"></script>
8
+ <link rel="stylesheet" crossorigin href="./assets/index-DG_s1YoH.css">
9
9
  </head>
10
10
  <body>
11
11
  <div id="root"></div>
package/dist/index.d.ts CHANGED
@@ -13,7 +13,11 @@ interface VmShutdownPayload {
13
13
  }
14
14
  type ProcessOutputPayload = ProcessOutput;
15
15
  type ProcessExitPayload = ProcessExit;
16
- type ShellDataPayload = ShellData;
16
+ /** `seq` orders this chunk against `ShellSnapshot.seq`; it is 0 when the shell
17
+ * has no server-side emulator and therefore no replay. */
18
+ type ShellDataPayload = ShellData & {
19
+ seq: number;
20
+ };
17
21
  type ShellExitPayload = ShellExit;
18
22
  type SerializableCronEvent = CronEvent;
19
23
  type ActorData = {
@@ -63,6 +67,93 @@ interface AgentOsEvents {
63
67
  shellExit: ShellExitPayload;
64
68
  cronEvent: SerializableCronEvent;
65
69
  }
70
+ /** One buffered near-capacity limit warning (`RuntimeHealth.warnings`). */
71
+ interface RuntimeLimitWarning {
72
+ /** Epoch milliseconds when the warning was observed host-side. */
73
+ ts: number;
74
+ limit: string;
75
+ category: string;
76
+ observed: number;
77
+ capacity: number;
78
+ fillPercent: number;
79
+ }
80
+ /** One buffered unexpected adapter exit (`RuntimeHealth.agentExits`). */
81
+ interface RuntimeAgentExit {
82
+ /** Epoch milliseconds when the exit was observed host-side. */
83
+ ts: number;
84
+ sessionId: string;
85
+ agentType: string;
86
+ exitCode: number | null;
87
+ restart: string;
88
+ restartCount: number;
89
+ }
90
+ /**
91
+ * One buffered adapter stderr line (`RuntimeHealth.stderrTail`). Always empty
92
+ * today; kept in the reply shape so consumers stay stable when a stderr feed
93
+ * lands.
94
+ */
95
+ interface RuntimeStderrLine {
96
+ ts: number;
97
+ line: string;
98
+ }
99
+ /** `RuntimeHealth.sidecar`: the non-waking sidecar descriptor subset. */
100
+ interface RuntimeSidecarInfo {
101
+ state: string;
102
+ activeVmCount: number;
103
+ }
104
+ /**
105
+ * Reply of the observe-only `health` action. Reading it never boots the VM;
106
+ * the post-mortem buffers survive VM sleep so warnings and crash exits stay
107
+ * readable while `booted` is false.
108
+ */
109
+ interface RuntimeHealth {
110
+ booted: boolean;
111
+ /**
112
+ * Count of sessions with live event subscriptions through this actor since
113
+ * the last wake (not total loaded sessions); `null` while the VM is down.
114
+ */
115
+ sessions: number | null;
116
+ /** Sidecar descriptor; `null` while the VM is down. */
117
+ sidecar: RuntimeSidecarInfo | null;
118
+ warnings: RuntimeLimitWarning[];
119
+ agentExits: RuntimeAgentExit[];
120
+ stderrTail: RuntimeStderrLine[];
121
+ }
122
+ /**
123
+ * One live shell from the observe-only `listShells` action. A shell outlives
124
+ * the page that opened it and keeps the VM awake until closed, so enumeration
125
+ * is server-owned rather than tracked per client.
126
+ */
127
+ interface ShellInfo {
128
+ shellId: string;
129
+ /** Epoch ms when the shell was opened through this actor. */
130
+ openedAt: number;
131
+ }
132
+ /**
133
+ * How much of a shell's history a snapshot repaints.
134
+ *
135
+ * - `none` — sequence number only; the caller repaints nothing.
136
+ * - `screen` — the visible viewport, cursor, and terminal modes.
137
+ * - `scrollback` — the retained scrollback above the viewport, then `screen`.
138
+ */
139
+ type ShellReplayMode = "none" | "screen" | "scrollback";
140
+ /**
141
+ * Server-rendered repaint for a shell that is already running. `data` is an
142
+ * ANSI stream to write verbatim into a fresh terminal.
143
+ */
144
+ interface ShellSnapshot {
145
+ shellId: string;
146
+ mode: ShellReplayMode;
147
+ /**
148
+ * Sequence of the last `shellData` chunk folded into this snapshot.
149
+ * Broadcasts carry the same counter, so a client applies the snapshot and
150
+ * then only the chunks whose `seq` is greater — no gap, no double-render.
151
+ */
152
+ seq: number;
153
+ cols: number;
154
+ rows: number;
155
+ data: string;
156
+ }
66
157
  type SerializableCronAction = {
67
158
  type: "session";
68
159
  agentType: string;
@@ -148,6 +239,8 @@ declare function createAgentOsActions(options?: AgentOsOptions, hooks?: AgentOsE
148
239
  openShell: (c: AnyContext, options?: _rivet_dev_agentos_core.ShellOptions | undefined) => Promise<{
149
240
  shellId: string;
150
241
  }>;
242
+ listShells: (c: AnyContext) => Promise<ShellInfo[]>;
243
+ shellSnapshot: (c: AnyContext, shellId: string, mode?: ShellReplayMode) => Promise<ShellSnapshot | null>;
151
244
  writeShell: (c: AnyContext, shellId: string, data: string | Uint8Array<ArrayBufferLike>) => Promise<void>;
152
245
  resizeShell: (c: AnyContext, shellId: string, cols: number, rows: number) => Promise<void>;
153
246
  closeShell: (c: AnyContext, shellId: string) => Promise<void>;
@@ -188,6 +281,7 @@ declare function createAgentOsActions(options?: AgentOsOptions, hooks?: AgentOsE
188
281
  expiresAt: number;
189
282
  }>;
190
283
  expirePreviewUrl: (c: AnyContext, token: string) => Promise<void>;
284
+ health: (c: AnyContext) => Promise<RuntimeHealth>;
191
285
  createContext: (c: AnyContext, contextId: string) => Promise<void>;
192
286
  process: {
193
287
  exec: (c: AnyContext, command: string, actorOptions?: ActorLanguageExecutionOptions) => Promise<CodeExecutionResult>;
@@ -267,6 +361,8 @@ declare function createAgentOsActions(options?: AgentOsOptions, hooks?: AgentOsE
267
361
  open: (c: AnyContext, options?: _rivet_dev_agentos_core.ShellOptions | undefined) => Promise<{
268
362
  shellId: string;
269
363
  }>;
364
+ list: (c: AnyContext) => Promise<ShellInfo[]>;
365
+ snapshot: (c: AnyContext, shellId: string, mode?: ShellReplayMode) => Promise<ShellSnapshot | null>;
270
366
  write: (c: AnyContext, shellId: string, data: string | Uint8Array<ArrayBufferLike>) => Promise<void>;
271
367
  resize: (c: AnyContext, shellId: string, cols: number, rows: number) => Promise<void>;
272
368
  wait: (c: AnyContext, shellId: string) => Promise<number>;
@@ -366,4 +462,4 @@ declare function createAgentOS<TState = undefined, TConnParams = undefined, TCon
366
462
  */
367
463
  declare const setup: typeof setup$1;
368
464
 
369
- export { type ActorData, type ActorLanguageSpawnOptions, type ActorSpawnOptions, type AgentOsActorConfigInput as AgentOSActorConfigInput, type AgentOsActorConfigInput as AgentOSConfigInput, type AgentOsActions, type AgentOsActorConfigInput, type AgentOsActorExtras, type AgentOsEventHooks, type AgentOsEvents, type ProcessExitPayload, type ProcessOutputPayload, type SerializableCronAction, type SerializableCronEvent, type SerializableCronJobInfo, type SerializableCronJobOptions, type ShellDataPayload, type ShellExitPayload, type VmBootedPayload, type VmFetchOptions, type VmFetchResponse, type VmFetchStreamChunk, type VmFetchStreamHead, type VmShutdownPayload, createAgentOS as agentOS, createAgentOS, createAgentOsActions, setup };
465
+ export { type ActorData, type ActorLanguageSpawnOptions, type ActorSpawnOptions, type AgentOsActorConfigInput as AgentOSActorConfigInput, type AgentOsActorConfigInput as AgentOSConfigInput, type AgentOsActions, type AgentOsActorConfigInput, type AgentOsActorExtras, type AgentOsEventHooks, type AgentOsEvents, type ProcessExitPayload, type ProcessOutputPayload, type RuntimeAgentExit, type RuntimeHealth, type RuntimeLimitWarning, type RuntimeSidecarInfo, type RuntimeStderrLine, type SerializableCronAction, type SerializableCronEvent, type SerializableCronJobInfo, type SerializableCronJobOptions, type ShellDataPayload, type ShellExitPayload, type ShellInfo, type ShellReplayMode, type ShellSnapshot, type VmBootedPayload, type VmFetchOptions, type VmFetchResponse, type VmFetchStreamChunk, type VmFetchStreamHead, type VmShutdownPayload, createAgentOS as agentOS, createAgentOS, createAgentOsActions, setup };