@rivet-dev/agentos 0.2.9 → 0.2.10
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/assets/inspector-tabs-app/assets/{badge-CkqYPoD9.js → badge-Dc8cdZEA.js} +1 -1
- package/assets/inspector-tabs-app/assets/{filesystem-DbXxNt-B.js → filesystem-VgTouyDr.js} +1 -1
- package/assets/inspector-tabs-app/assets/{index-nTg2hrne.js → index-Bapg8yic.js} +3 -3
- package/assets/inspector-tabs-app/assets/{mounts-BlNRslup.js → mounts-Blsl8Zt1.js} +1 -1
- package/assets/inspector-tabs-app/assets/{processes-CjHQ_o8t.js → processes-DXs6A0io.js} +1 -1
- package/assets/inspector-tabs-app/assets/{scroll-area-DE-oi7a2.js → scroll-area-BVREu3i3.js} +1 -1
- package/assets/inspector-tabs-app/assets/{software-2sjLheLb.js → software-d-8Y614w.js} +1 -1
- package/assets/inspector-tabs-app/assets/{transcript-Cz9DrFWK.js → transcript-8cHeR5Ok.js} +1 -1
- package/assets/inspector-tabs-app/assets/{useSuspenseQuery-V0HYenB_.js → useSuspenseQuery-BjjhFDMq.js} +1 -1
- package/assets/inspector-tabs-app/index.html +1 -1
- package/dist/index.js +9 -38
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as N}from"./index-
|
|
1
|
+
import{j as N}from"./index-Bapg8yic.js";import{k as j,f as k}from"./scroll-area-BVREu3i3.js";const m=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,f=j,C=(e,a)=>n=>{var s;if((a==null?void 0:a.variants)==null)return f(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:u,defaultVariants:i}=a,y=Object.keys(u).map(t=>{const r=n==null?void 0:n[t],o=i==null?void 0:i[t];if(r===null)return null;const l=m(r)||m(o);return u[t][l]}),c=n&&Object.entries(n).reduce((t,r)=>{let[o,l]=r;return l===void 0||(t[o]=l),t},{}),x=a==null||(s=a.compoundVariants)===null||s===void 0?void 0:s.reduce((t,r)=>{let{class:o,className:l,...V}=r;return Object.entries(V).every(b=>{let[v,d]=b;return Array.isArray(d)?d.includes({...i,...c}[v]):{...i,...c}[v]===d})?[...t,o,l]:t},[]);return f(e,y,x,n==null?void 0:n.class,n==null?void 0:n.className)},g=C("inline-flex items-center tracking-normal rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors whitespace-nowrap max-w-full overflow-hidden truncate",{variants:{variant:{secondary:"border-transparent bg-secondary text-secondary-foreground",outline:"text-foreground"}},defaultVariants:{variant:"secondary"}});function h({className:e,variant:a,...n}){return N.jsx("div",{className:k(g({variant:a}),e),...n})}export{h as B};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as f,j as t}from"./index-
|
|
1
|
+
import{r as f,j as t}from"./index-Bapg8yic.js";import{h as w,Q as C,e as j,S as N,A as c,C as S,f as p,F as k,i as g,r as Q}from"./scroll-area-BVREu3i3.js";function v(n,e){return w(n,C)}function b({actorId:n,entry:e,depth:r,selectedPath:i,onSelect:o}){const[x,h]=f.useState(!1),d=e.path===i,a=e.dir&&!e.virtual,u=v(j.listDirQueryOptions(n,e.path,a&&x));return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1",style:{paddingLeft:`${r*12}px`},children:[t.jsx("button",{type:"button",onClick:()=>a&&h(s=>!s),className:p("flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-muted/50",!a&&"pointer-events-none opacity-0"),disabled:!a,children:t.jsx(S,{className:p("size-3 transition-transform",x&&"rotate-90")})}),t.jsxs("button",{type:"button",onClick:()=>a?h(s=>!s):e.dir?void 0:o(e),className:p("flex min-w-0 flex-1 items-center gap-2 rounded px-2 py-1 text-left text-sm",d?"bg-muted text-foreground":"hover:bg-muted/50"),children:[t.jsx(k,{dir:e.dir,className:"size-3.5 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"flex-1 truncate",children:e.name}),!e.dir&&e.size!=null?t.jsx("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground/60",children:g(e.size)}):null]})]}),a&&x?u.isLoading?t.jsx("div",{className:"py-1 text-xs text-muted-foreground",style:{paddingLeft:`${(r+1)*12+28}px`},children:"loading…"}):(u.data??[]).map(s=>t.jsx(b,{actorId:n,entry:s,depth:r+1,selectedPath:i,onSelect:o},s.path)):null]})}function z({actorId:n,path:e}){const{data:r,error:i,isFetching:o}=v(j.fileContentQueryOptions(n,e));return e?i?t.jsxs(c,{children:["Failed to read ",e,": ",i.message]}):!r||o?t.jsxs(c,{children:["Loading ",e,"…"]}):t.jsxs("div",{className:"flex h-full flex-col",children:[t.jsxs("div",{className:"flex items-center gap-3 border-b px-4 py-3",children:[t.jsx("span",{className:"truncate font-mono text-sm",children:r.path}),t.jsx("span",{className:"ml-auto shrink-0 text-xs text-muted-foreground",children:g(r.sizeBytes)}),t.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Q(r.mtimeMs)})]}),t.jsx(N,{className:"min-h-0 flex-1",children:r.text===null?t.jsxs("div",{className:"flex h-full items-center justify-center p-8 text-center text-sm text-muted-foreground",children:["Binary file (",g(r.sizeBytes),") — preview unavailable."]}):t.jsx("pre",{className:"whitespace-pre-wrap break-words p-4 font-mono text-xs leading-relaxed",children:r.text})})]}):t.jsx(c,{children:"Select a file to view its contents."})}function y(n){let e=n.trim();return e===""?"/":(e.startsWith("/")||(e=`/${e}`),e=e.replace(/\/+/g,"/"),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e)}function E({actorId:n}){const[e,r]=f.useState("/"),[i,o]=f.useState("/"),[x,h]=f.useState(null),d=v(j.listDirQueryOptions(n,e)),a=d.data===null,u=d.data??[];return f.useEffect(()=>{const s=setTimeout(()=>{const l=y(i);r(m=>l!==m?l:m)},500);return()=>clearTimeout(s)},[i]),t.jsxs("div",{className:"flex h-full min-h-0",children:[t.jsxs("div",{className:"flex h-full w-2/5 flex-col border-r",children:[t.jsx("div",{className:"border-b px-3 py-1.5",children:t.jsx("input",{value:i,onChange:s=>o(s.target.value),onKeyDown:s=>{if(s.key==="Enter"){const l=y(i);o(l),r(m=>l!==m?l:m)}},spellCheck:!1,autoComplete:"off","aria-label":"Root directory",placeholder:"/",className:"w-full bg-transparent font-mono text-xs text-muted-foreground outline-none placeholder:text-muted-foreground/40 focus:text-foreground"})}),t.jsx(N,{className:"min-h-0 flex-1 p-2",children:d.isLoading?t.jsxs(c,{children:["Loading ",e,"…"]}):d.error?t.jsxs(c,{children:["Failed to list ",e,": ",d.error.message]}):a?t.jsxs(c,{children:["Not a directory, or does not exist: ",e]}):u.length===0?t.jsx(c,{children:"Empty directory."}):u.map(s=>t.jsx(b,{actorId:n,entry:s,depth:0,selectedPath:x,onSelect:l=>h(l.path)},s.path))})]}),t.jsx("div",{className:"min-h-0 w-3/5",children:t.jsx(z,{actorId:n,path:x})})]})}export{E as FilesystemTabConnected};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./software-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./software-d-8Y614w.js","./useSuspenseQuery-BjjhFDMq.js","./scroll-area-BVREu3i3.js","./badge-Dc8cdZEA.js","./processes-DXs6A0io.js","./filesystem-VgTouyDr.js","./mounts-Blsl8Zt1.js","./transcript-8cHeR5Ok.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var _A=Object.defineProperty;var Jy=e=>{throw TypeError(e)};var SA=(e,t,n)=>t in e?_A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var jt=(e,t,n)=>SA(e,typeof t!="symbol"?t+"":t,n),Yd=(e,t,n)=>t.has(e)||Jy("Cannot "+n);var d=(e,t,n)=>(Yd(e,t,"read from private field"),n?n.call(e):t.get(e)),R=(e,t,n)=>t.has(e)?Jy("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),D=(e,t,n,i)=>(Yd(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),T=(e,t,n)=>(Yd(e,t,"access private method"),n);var jc=(e,t,n,i)=>({set _(r){D(e,t,r,n)},get _(){return d(e,t,i)}});function wA(e,t){for(var n=0;n<t.length;n++){const i=t[n];if(typeof i!="string"&&!Array.isArray(i)){for(const r in i)if(r!=="default"&&!(r in e)){const a=Object.getOwnPropertyDescriptor(i,r);a&&Object.defineProperty(e,r,a.get?a:{enumerable:!0,get:()=>i[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function i(r){if(r.ep)return;r.ep=!0;const a=n(r);fetch(r.href,a)}})();const $A="modulepreload",zA=function(e,t){return new URL(e,t).href},Py={},_u=function(t,n,i){let r=Promise.resolve();if(n&&n.length>0){const o=document.getElementsByTagName("link"),u=document.querySelector("meta[property=csp-nonce]"),l=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));r=Promise.allSettled(n.map(c=>{if(c=zA(c,i),c in Py)return;Py[c]=!0;const s=c.endsWith(".css"),f=s?'[rel="stylesheet"]':"";if(!!i)for(let _=o.length-1;_>=0;_--){const S=o[_];if(S.href===c&&(!s||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${f}`))return;const h=document.createElement("link");if(h.rel=s?"stylesheet":$A,s||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),s)return new Promise((_,S)=>{h.addEventListener("load",_),h.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(o){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=o,window.dispatchEvent(u),!u.defaultPrevented)throw o}return r.then(o=>{for(const u of o||[])u.status==="rejected"&&a(u.reason);return t().catch(a)})};function xf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var G_={exports:{}},Uf={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -119,7 +119,7 @@ function Qd(e){return eR(e).buffer}function Jd(e,t){tR(e,new Uint8Array(t))}//!
|
|
|
119
119
|
function P(e){return rR(e,mk(e))}function Y(e,t){if(t.length<Jj){const n=oR(t);mg(e,n),Fd(e,n),aR(e,t)}else{const n=lR.encode(t);mg(e,n.length),hk(e,n)}}function rR(e,t){if(t<Qj)return iR(e,t);try{return uR.decode(gk(e,t))}catch{throw new le(e.offset,lk)}}function iR(e,t){Kd(e,t);let n="";const i=e.bytes;let r=e.offset;const a=r+t;for(;r<a;){let o=i[r++];if(o>127){let u=!0;const l=o;if(r<a&&o<224){const c=i[r++];o=(l&31)<<6|c&63,u=o>>7===0||l>>5!==6||c>>6!==2}else if(r+1<a&&o<240){const c=i[r++],s=i[r++];o=(l&15)<<12|(c&63)<<6|s&63,u=o>>11===0||o>>11===27||l>>4!==14||c>>6!==2||s>>6!==2}else if(r+2<a){const c=i[r++],s=i[r++],f=i[r++];o=(l&7)<<18|(c&63)<<12|(s&63)<<6|f&63,u=o>>16===0||o>1114111||l>>3!==30||c>>6!==2||s>>6!==2||f>>6!==2}if(u)throw new le(e.offset,lk)}n+=String.fromCodePoint(o)}return e.offset=r,n}function aR(e,t){const n=e.bytes;let i=e.offset,r=0;for(;r<t.length;){const a=t.codePointAt(r++);a<128?n[i++]=a:(a<2048?n[i++]=192|a>>6:(a<65536?n[i++]=224|a>>12:(n[i++]=240|a>>18,n[i++]=128|a>>12&63,r++),n[i++]=128|a>>6&63),n[i++]=128|a&63)}e.offset=i}function oR(e){let t=e.length;for(let n=0;n<e.length;n++){const i=e.codePointAt(n);i>127&&(t++,i>2047&&(t++,i>65535&&n++))}return t}const uR=new TextDecoder("utf-8",{fatal:!0}),lR=new TextEncoder;//! Copyright (c) 2022 Victorien Elvinger
|
|
120
120
|
//! Licensed under the MIT License (https://mit-license.org/)
|
|
121
121
|
function Pd({initialBufferLength:e=1024,maxBufferLength:t=1024*1024*32}){return{initialBufferLength:e,maxBufferLength:t}}var vk={};function In(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}var cR=In;In.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};In.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};In.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1;var i=this;return this._timer=setTimeout(function(){i._attempts++,i._operationTimeoutCb&&(i._timeout=setTimeout(function(){i._operationTimeoutCb(i._attempts)},i._operationTimeout),i._options.unref&&i._timeout.unref()),i._fn(i._attempts)},n),this._options.unref&&this._timer.unref(),!0};In.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};In.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};In.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};In.prototype.start=In.prototype.try;In.prototype.errors=function(){return this._errors};In.prototype.attempts=function(){return this._attempts};In.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,i=0;i<this._errors.length;i++){var r=this._errors[i],a=r.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=r,n=o)}return t};(function(e){var t=cR;e.operation=function(n){var i=e.timeouts(n);return new t(i,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(n){if(n instanceof Array)return[].concat(n);var i={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var r in n)i[r]=n[r];if(i.minTimeout>i.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var a=[],o=0;o<i.retries;o++)a.push(this.createTimeout(o,i));return n&&n.forever&&!a.length&&a.push(this.createTimeout(o,i)),a.sort(function(u,l){return u-l}),a},e.createTimeout=function(n,i){var r=i.randomize?Math.random()+1:1,a=Math.round(r*Math.max(i.minTimeout,1)*Math.pow(i.factor,n));return a=Math.min(a,i.maxTimeout),a},e.wrap=function(n,i,r){if(i instanceof Array&&(r=i,i=null),!r){r=[];for(var a in n)typeof n[a]=="function"&&r.push(a)}for(var o=0;o<r.length;o++){var u=r[o],l=n[u];n[u]=(function(s){var f=e.operation(i),m=Array.prototype.slice.call(arguments,1),h=m.pop();m.push(function(_){f.retry(_)||(_&&(arguments[0]=f.mainError()),h.apply(this,arguments))}),f.attempt(function(){s.apply(n,m)})}).bind(n,l),n[u].options=i}}})(vk);var sR=vk;const fR=xf(sR),dR=Object.prototype.toString,mR=e=>dR.call(e)==="[object Error]",hR=new Set(["network error","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]);function gR(e){if(!(e&&mR(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;const{message:n,stack:i}=e;return n==="Load failed"||n.startsWith("Load failed (")&&n.endsWith(")")?i===void 0||"__sentry_captured__"in e:n.startsWith("error sending request for url")||n==="Failed to fetch"||n.startsWith("Failed to fetch (")&&n.endsWith(")")?!0:hR.has(n)}class hg extends Error{constructor(t){super(),t instanceof Error?(this.originalError=t,{message:t}=t):(this.originalError=new Error(t),this.originalError.stack=this.stack),this.name="AbortError",this.message=t}}const g_=(e,t,n)=>{const i=n.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=i,e};async function pk(e,t){return new Promise((n,i)=>{t={...t},t.onFailedAttempt??(t.onFailedAttempt=()=>{}),t.shouldRetry??(t.shouldRetry=()=>!0),t.retries??(t.retries=10);const r=fR.operation(t),a=()=>{var u;r.stop(),i((u=t.signal)==null?void 0:u.reason)};t.signal&&!t.signal.aborted&&t.signal.addEventListener("abort",a,{once:!0});const o=()=>{var u;(u=t.signal)==null||u.removeEventListener("abort",a),r.stop()};r.attempt(async u=>{try{const l=await e(u);o(),n(l)}catch(l){try{if(!(l instanceof Error))throw new TypeError(`Non-error was thrown: "${l}". You should only throw errors.`);if(l instanceof hg)throw l.originalError;if(l instanceof TypeError&&!gR(l))throw l;if(g_(l,u,t),await t.shouldRetry(l)||(r.stop(),i(l)),await t.onFailedAttempt(l),!r.retry(l))throw r.mainError()}catch(c){g_(c,u,t),o(),i(c)}}})})}var yk={},gg="internal_error",vR="An internal error occurred";function pR(e){return typeof e=="object"&&e!==null&&("public"in e||"metadata"in e||"statusCode"in e||"actor"in e||"cause"in e)}function yR(e){return e==="ActorError"||e==="RivetError"}function bR(e,t=String(e)){return e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?e.message:t}function v_(e){return typeof e=="object"&&e!==null&&"group"in e&&typeof e.group=="string"&&"code"in e&&typeof e.code=="string"&&"message"in e&&typeof e.message=="string"&&(!("__type"in e)||yR(e.__type))}var Se=class extends Error{constructor(t,n,i,r){const a=pR(r)?r:{metadata:r};super(i,{cause:a.cause});jt(this,"__type","RivetError");jt(this,"public");jt(this,"metadata");jt(this,"statusCode");jt(this,"actor");jt(this,"group");jt(this,"code");this.name="RivetError",this.group=t,this.code=n,this.public=a.public??!1,this.metadata=a.metadata,this.statusCode=a.statusCode??(this.public?400:500),this.actor=a.actor}static isRivetError(t){return v_(t)}static isActorError(t){return v_(t)}toString(){return this.message}};function Iy(e){return new Se("request","invalid",`Invalid request: ${bR(e,String(e))}`,{public:!0,cause:e instanceof Error?e:void 0})}function _R(e){return new Se("actor","not_found",e?`Actor not found: ${e} (https://www.rivet.dev/docs/clients/javascript)`:"Actor not found (https://www.rivet.dev/docs/clients/javascript)",{public:!0})}function Dc(e){throw new Error(`Unreachable case: ${e}`)}function SR(e){return e instanceof Se||typeof e=="object"&&e!==null&&"__type"in e&&e.__type==="RivetError"&&"group"in e&&typeof e.group=="string"&&"code"in e&&typeof e.code=="string"&&"message"in e&&typeof e.message=="string"}function As(e,t=!1){let n,i,r,a,o,u,l;return SR(e)?(n=typeof e.statusCode=="number"?e.statusCode:e.public?400:500,i=e.public??!1,r=e.group,a=e.code,o=e.message,u=e.metadata,l=e.actor):Se.isActorError(e)&&e.public?(n="statusCode"in e&&e.statusCode?e.statusCode:400,i=!0,r=e.group,a=e.code,o=xs(e),u=e.metadata,l=e.actor):t?Se.isActorError(e)?(n=500,i=!1,r=e.group,a=e.code,o=xs(e),u=e.metadata,l=e.actor):(n=500,i=!1,r="rivetkit",a=gg,o=xs(e)):(n=500,i=!1,r="rivetkit",a=gg,o=vR,Se.isActorError(e)&&(l=e.actor),u={}),{__type:"ActorError",statusCode:n,public:i,group:r,code:a,message:o,metadata:u,actor:l}}function ht(e){if(e instanceof Error)if(typeof process<"u"&&LR()){let t;try{t=e.stack}catch{t=void 0}return`${e.name}: ${e.message}${t?`
|
|
122
|
-
${t}`:""}`}else return`${e.name}: ${e.message}`;else{if(typeof e=="string")return e;if(typeof e=="object"&&e!==null)try{return`${JSON.stringify(e)}`}catch{return"[cannot stringify error]"}else return`Unknown error: ${xs(e)}`}}function xs(e){return e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?e.message:String(e)}function wR(){return async()=>{}}var $R={version:"2.3.
|
|
122
|
+
${t}`:""}`}else return`${e.name}: ${e.message}`;else{if(typeof e=="string")return e;if(typeof e=="object"&&e!==null)try{return`${JSON.stringify(e)}`}catch{return"[cannot stringify error]"}else return`Unknown error: ${xs(e)}`}}function xs(e){return e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?e.message:String(e)}function wR(){return async()=>{}}var $R={version:"2.3.7"};function vg(e){if(typeof Buffer<"u")return Buffer.from(e).toString("base64");let t="";const n=e.byteLength;for(let i=0;i<n;i++)t+=String.fromCharCode(e[i]);return btoa(t)}function zR(e){if(e==="json")return"application/json";if(e==="cbor"||e==="bare")return"application/octet-stream";Dc(e)}function au(e){return uk(Ha(e))}function wi(e){return qr(Cj(e))}function bk(e,t,n,i,r,a,o){if(e==="json"){const u=a(t),l=r.parse(u);return Ek(l)}else if(e==="cbor"){const u=a(t),l=r.parse(u);return uk(l)}else if(e==="bare"){if(!n)throw new Error("VersionedDataHandler is required for 'bare' encoding");if(i===void 0)throw new Error("version is required for 'bare' encoding");const u=o(t);return n.serializeWithEmbeddedVersion(u,i)}else Dc(e)}function Tf(e,t,n,i,r,a){if(e==="json"){let o;if(typeof t=="string")o=p_(t);else{const c=new TextDecoder("utf-8").decode(t);o=p_(c)}const u=i.parse(o);return r(u)}else if(e==="cbor"){iu(typeof t!="string","buffer cannot be string for cbor encoding");const o=wi(t),u=i.parse(o);return r(u)}else if(e==="bare"){if(iu(typeof t!="string","buffer cannot be string for bare encoding"),!n)throw new Error("VersionedDataHandler is required for 'bare' encoding");const o=n.deserializeWithEmbeddedVersion(t);return a(o)}else Dc(e)}var Ny="$BigInt",jy="$ArrayBuffer",Ry="$Uint8Array",_k="$Undefined",Sk="$Set";function ER(e){return e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof BigUint64Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof BigInt64Array||e instanceof Float32Array||e instanceof Float64Array}var OR=Ta(["json","cbor","bare"]);async function TR(e){if(typeof e=="string")return e;if(e instanceof Blob)return new Uint8Array(await e.arrayBuffer());if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer||e instanceof SharedArrayBuffer)return new Uint8Array(e);throw new Error("Malformed message")}function Cy(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t)}function wk(e){return Cy(new Uint8Array(e))}function $k(e){if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Ha(e){var n;if(e===null)return e;if(e===void 0)return[_k,0];if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="bigint")return[Ny,e.toString()];if(e instanceof ArrayBuffer)return[jy,wk(e)];if(e instanceof Uint8Array)return[Ry,Cy(e)];if(ER(e)||e instanceof Date||e instanceof RegExp||e instanceof Error)return e;if(e instanceof Set){const i=[...e.values()].map(r=>Ha(r));return[Sk,i]}if(e instanceof Map){const i=new Map;for(const[r,a]of e.entries())i.set(Ha(r),Ha(a));return i}if(Array.isArray(e)){const i=e.map(r=>Ha(r));return i.length===2&&typeof i[0]=="string"&&i[0].startsWith("$")?[`$${i[0]}`,i[1]]:i}if($k(e)){const i={};for(const[r,a]of Object.entries(e))i[r]=Ha(a);return i}const t=typeof e=="object"&&e!==null?((n=e.constructor)==null?void 0:n.name)??typeof e:typeof e;throw new TypeError(`Value of type "${t}" is not CBOR serializable`)}function qr(e,t={}){if(typeof e=="bigint")return t.coerceSafeIntegerBigInts&&e>=BigInt(Number.MIN_SAFE_INTEGER)&&e<=BigInt(Number.MAX_SAFE_INTEGER)?Number(e):e;if(e instanceof Map){const n=new Map;for(const[i,r]of e.entries())n.set(qr(i,t),qr(r,t));return n}if(Array.isArray(e)){if(e.length===2&&typeof e[0]=="string"&&e[0].startsWith("$")){if(e[0]===Ny)return BigInt(e[1]);if(e[0]===jy)return kR(e[1]);if(e[0]===Ry)return zk(e[1]);if(e[0]===_k)return;if(e[0]===Sk){const n=e[1].map(i=>qr(i,t));return new Set(n)}if(e[0].startsWith("$$"))return[e[0].substring(1),qr(e[1],t)];throw new Error(`Unknown JSON encoding type: ${e[0]}. This may indicate corrupted data or a version mismatch.`)}return e.map(n=>qr(n,t))}if($k(e)){const n={};for(const[i,r]of Object.entries(e))n[i]=qr(r,t);return n}return e}function zk(e){if(typeof Buffer<"u")return new Uint8Array(Buffer.from(e,"base64"));const t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}function kR(e){return zk(e).buffer}function Ek(e,t){return JSON.stringify(e,(n,i)=>typeof i=="bigint"?[Ny,i.toString()]:i instanceof ArrayBuffer?[jy,wk(i)]:i instanceof Uint8Array?[Ry,Cy(i)]:Array.isArray(i)&&i.length===2&&typeof i[0]=="string"&&i[0].startsWith("$")?[`$${i[0]}`,i[1]]:i,t)}function p_(e){return qr(JSON.parse(e))}var AR=$R.version,Hm;function xR(){if(Hm!==void 0)return Hm;let e=`RivetKit/${AR}`;const t=typeof navigator<"u"?navigator:void 0;return t!=null&&t.userAgent&&(e+=` ${t.userAgent}`),Hm=e,e}function Nn(e){if(typeof Deno<"u")return Deno.env.get(e);if(typeof process<"u")return yk[e]}function us(e){let t,n;const i=new Promise((r,a)=>{t=r,n=a});return i.catch(e),{promise:i,resolve:t,reject:n}}function My(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function Il(e,t,n){const i=new URL(e),r=t.split("?"),a=r[0],o=r[1]||"",u=i.pathname.replace(/\/$/,""),l=a.startsWith("/")?a:`/${a}`,c=(u+l).replace(/\/\//g,"/"),s=[];if(o&&s.push(o),n)for(const[m,h]of Object.entries(n))h!==void 0&&s.push(`${encodeURIComponent(m)}=${encodeURIComponent(h)}`);const f=s.length>0?`?${s.join("&")}`:"";return`${i.protocol}//${i.host}${c}${f}`}var UR=()=>Nn("RIVET_ENGINE"),DR=()=>Nn("RIVET_ENDPOINT"),IR=()=>Nn("RIVET_TOKEN"),NR=()=>Nn("RIVET_NAMESPACE"),jR=()=>Nn("RIVET_POOL"),RR=()=>Nn("RIVET_LOG_LEVEL")??Nn("LOG_LEVEL"),CR=()=>Nn("RIVET_LOG_TARGET")==="1",MR=()=>Nn("RIVET_LOG_TIMESTAMP")==="1",ZR=()=>Nn("RIVET_LOG_MESSAGE")==="1",LR=()=>Nn("RIVET_LOG_ERROR_STACK")==="1",BR=()=>Nn("NEXT_PHASE"),pg,yg=new Map,qR=Ta(["trace","debug","info","warn","error","fatal","silent"]);function HR(e){const t=(RR()||"warn").toString().toLowerCase(),n=qR.safeParse(t);return n.success?n.data:"info"}function VR(){return CR()}function GR(e){return YU({level:HR(),messageKey:"msg",base:{},errorKey:"error",formatters:{level(t,n){return{level:n}}},timestamp:MR()?XU.stdTimeFunctions.epochTime:!1},JR())}function KR(e){pg=GR(),yg.clear()}function FR(){return pg||KR(),pg}function Zy(e="default"){const t=yg.get(e);if(t)return t;const n=FR(),i=VR()?n.child({target:e}):n;return yg.set(e,i),i}var QR={10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"};function JR(){return{write(e){var n;const t=PR(e);typeof process<"u"&&((n=process.stdout)!=null&&n.write)?process.stdout.write(`${t}
|
|
123
123
|
`):console.log(t)}}}function PR(e){let t;try{t=JSON.parse(e)}catch{return e.trimEnd()}const n=[];Vm(n,"level",YR(t.level)),t.time!==void 0&&Vm(n,"ts",t.time);for(const[i,r]of Object.entries(t))i==="level"||i==="time"||Vm(n,i,r);return n.join(" ")}function YR(e){return typeof e=="number"?QR[e]??e.toString():typeof e=="string"?e.toLowerCase():"info"}function Vm(e,t,n){const i=t.replace(/[\s="]/g,"");i.length!==0&&e.push(`${i}=${XR(n)}`)}function XR(e){return typeof e=="number"||typeof e=="boolean"?String(e):e==null?"null":y_(typeof e=="string"?e:JSON.stringify(e))}function y_(e){return/[\s="]/.test(e)?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n")}"`:e}function WR(){return Zy("devtools")}var b_="rivetkit-devtools-script";function e3(e){var t;if(!window){WR().warn("devtools not available outside browser environment");return}if(!document.getElementById(b_)){const n=`${(t=e.endpoint)==null?void 0:t.replace(/\/$/,"")}/devtools/mod.js`,i=document.createElement("script");i.id=b_,i.src=n,i.async=!0,document.head.appendChild(i)}window.__rivetkit=window.__rivetkit||[],window.__rivetkit.push(e)}var Ok="/",bg="/",Ly={PERSIST_DATA:Uint8Array.from([1]),CONN_PREFIX:Uint8Array.from([2]),INSPECTOR_TOKEN:Uint8Array.from([3]),KV:Uint8Array.from([4]),QUEUE_PREFIX:Uint8Array.from([5]),LAST_PUSHED_ALARM:Uint8Array.from([6]),WORKFLOW_PREFIX:Uint8Array.from([6]),TRACES_PREFIX:Uint8Array.from([7])},Gm={QUEUE:1,WORKFLOW:1,TRACES:1},By={QUEUE:Uint8Array.from([Gm.QUEUE]),WORKFLOW:Uint8Array.from([Gm.WORKFLOW]),TRACES:Uint8Array.from([Gm.TRACES])},Tk={METADATA:Uint8Array.from([1]),MESSAGES:Uint8Array.from([2])};function Ic(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}var kk=Ic(Ly.QUEUE_PREFIX,By.QUEUE);Ic(kk,Tk.METADATA);Ic(kk,Tk.MESSAGES);Ic(Ly.WORKFLOW_PREFIX,By.WORKFLOW);Ic(Ly.TRACES_PREFIX,By.TRACES);function _g(e){return e.length===0?Ok:e.map(n=>{if(n==="")return"\\0";let i=n.replace(/\\/g,"\\\\");return i=i.replace(/\//g,`\\${bg}`),i}).join(bg)}function t3(e){if(e==null||e===Ok)return[];const t=[];let n="",i=!1,r=!1;for(let a=0;a<e.length;a++){const o=e[a];i?(o==="0"?r=!0:n+=o,i=!1):o==="\\"?i=!0:o===bg?(r?(t.push(""),r=!1):t.push(n),n=""):n+=o}return i?t.push(`${n}\\`):r?t.push(""):(n!==""||t.length>0)&&t.push(n),t}var Ak="/connect",n3="/websocket",xk="/websocket/",Uk="x-rivet-encoding",qy="x-rivet-conn-params",r3="x-rivet-token",i3="x-rivet-target",a3="x-rivet-actor",o3="x-rivet-skip-ready-wait",u3="rivet",l3="rivet_target.",c3="rivet_actor.",s3="rivet_encoding.",f3="rivet_conn_params.",d3="rivet_token.",m3="rivet_skip_ready_wait",h3="rivet_test_ack_hook.";function po(e={}){return e.skipReadyWait===!0}async function __(e,t,n,i={}){let r=null;const a=v3(e,n,i);if(n.method!=="GET"&&n.method!=="HEAD"){if(n.bodyUsed)throw new Error("Request body has already been consumed");const u=await n.arrayBuffer();u.byteLength!==0&&(r=u,a.delete("transfer-encoding"),a.delete("content-length"))}const o=new Request(t,{method:n.method,headers:a,body:r,signal:n.signal});return g3(await fetch(o))}function g3(e){return new Response(e.body,e)}function v3(e,t,n){const i=new Headers;t.headers.forEach((r,a)=>{i.set(a,r)});for(const[r,a]of Object.entries(e.headers))i.set(r,a);return e.token&&i.set(r3,e.token),n.directActorId!==void 0&&(i.set(i3,"actor"),i.set(a3,n.directActorId)),po(n)&&i.set(o3,"1"),i}function p3(e,t){const{endpoint:n,path:i=["endpoint"],namespace:r,token:a}=t;let o;try{o=new URL(n)}catch{e.addIssue({code:"custom",message:`invalid URL: ${n}`,path:i});return}if(o.search){e.addIssue({code:"custom",message:"endpoint cannot contain a query string",path:i});return}if(o.hash){e.addIssue({code:"custom",message:"endpoint cannot contain a fragment",path:i});return}const u=o.username?decodeURIComponent(o.username):void 0,l=o.password?decodeURIComponent(o.password):void 0;if(l&&!u){e.addIssue({code:"custom",message:"endpoint cannot have a token without a namespace",path:i});return}return u&&r&&e.addIssue({code:"custom",message:"cannot specify namespace both in endpoint URL and as a separate config option",path:["namespace"]}),l&&a&&e.addIssue({code:"custom",message:"cannot specify token both in endpoint URL and as a separate config option",path:["token"]}),o.username="",o.password="",{endpoint:o.toString(),namespace:u,token:l}}var S_="http://localhost:6420",Dk=4*1024,w_=!1,y3=Mt.object({endpoint:Mt.string().optional().transform(e=>{const t=e??UR()??DR();return!t&&!w_&&(w_=!0,console.warn(`[rivetkit] No endpoint provided to client. Defaulting to ${S_}. Starting in 2.2.0, an explicit endpoint will be required. Pass an endpoint to createClient() or createRivetKit(), or set the RIVET_ENDPOINT environment variable.`)),t??S_}),token:Mt.string().optional().transform(e=>e??IR()),namespace:Mt.string().optional().transform(e=>e??NR()),poolName:Mt.string().default(()=>jR()??"default"),encoding:OR.default("bare"),headers:Mt.record(Mt.string(),Mt.string()).optional().default(()=>({})),gateway:Mt.object({skipReadyWait:Mt.boolean().optional().default(!1)}).optional().default(()=>({skipReadyWait:!1})),getUpgradeWebSocket:Mt.custom().optional(),disableMetadataLookup:Mt.boolean().optional().default(!1),maxInputSize:Mt.number().int().positive().default(Dk),devtools:Mt.boolean().default(()=>{var e,t;return typeof window<"u"&&(((e=window==null?void 0:window.location)==null?void 0:e.hostname)==="127.0.0.1"||((t=window.location)==null?void 0:t.hostname)==="localhost")})}),b3=y3.transform((e,t)=>_3(e,t));function _3(e,t){const n=p3(t,{endpoint:e.endpoint,path:["endpoint"],namespace:e.namespace,token:e.token});return{...e,endpoint:n==null?void 0:n.endpoint,namespace:(n==null?void 0:n.namespace)??e.namespace??"default",token:(n==null?void 0:n.token)??e.token}}function H(){return Zy("actor-client")}var ls=null;async function Ik(){return ls!==null||(ls=(async()=>{let e;if(typeof WebSocket<"u")e=WebSocket;else try{e=(await import("ws")).default,H().debug("using websocket from npm")}catch{e=class{constructor(){throw new Error('WebSocket support requires installing the "ws" peer dependency.')}},H().debug("using mock websocket")}return e})()),ls}new TextDecoder;var $_=new Map;function S3(e,t,n){const i=e;i.__rivetGetHibernatableAckState=t.getState,i.__rivetWaitForHibernatableAck=t.waitForAck}function w3(e,t,n){S3(e,{getState:()=>{const i=$_.get(t);if(!i)throw new Error(`remote hibernatable websocket ack hooks are unavailable for token ${t}`);return i.getState()},waitForAck:async i=>{const r=$_.get(t);if(!r)throw new Error(`remote hibernatable websocket ack hooks are unavailable for token ${t}`);await r.waitForAck(i)}})}function pe(){return Zy("engine-client")}var Zt,ei,ti,Pi,Yi,Xi,Wi,_t,Nk,Va,Sg,Us,M_,$3=(M_=class{constructor(e){R(this,_t);jt(this,"CONNECTING",0);jt(this,"OPEN",1);jt(this,"CLOSING",2);jt(this,"CLOSED",3);R(this,Zt);R(this,ei,new Map);R(this,ti,[]);R(this,Pi,null);R(this,Yi,null);R(this,Xi,null);R(this,Wi,null);D(this,Zt,e);for(const t of["open","message","close","error"])d(this,Zt).addEventListener(t,n=>{T(this,_t,Nk).call(this,t,n)})}get readyState(){return d(this,Zt).readyState}get binaryType(){return d(this,Zt).binaryType}set binaryType(e){d(this,Zt).binaryType=e}get bufferedAmount(){return d(this,Zt).bufferedAmount}get extensions(){return d(this,Zt).extensions}get protocol(){return d(this,Zt).protocol}get url(){return d(this,Zt).url}get onopen(){return d(this,Pi)}set onopen(e){D(this,Pi,e),T(this,_t,Va).call(this)}get onclose(){return d(this,Yi)}set onclose(e){D(this,Yi,e),T(this,_t,Va).call(this)}get onerror(){return d(this,Xi)}set onerror(e){D(this,Xi,e),T(this,_t,Va).call(this)}get onmessage(){return d(this,Wi)}set onmessage(e){D(this,Wi,e),T(this,_t,Va).call(this)}send(e){d(this,Zt).send(e)}close(e,t){d(this,Zt).close(e,t)}addEventListener(e,t){const n=d(this,ei).get(e)??new Set;n.add(t),d(this,ei).set(e,n),T(this,_t,Va).call(this)}removeEventListener(e,t){var n;(n=d(this,ei).get(e))==null||n.delete(t)}dispatchEvent(e){return T(this,_t,Us).call(this,e.type,e)}},Zt=new WeakMap,ei=new WeakMap,ti=new WeakMap,Pi=new WeakMap,Yi=new WeakMap,Xi=new WeakMap,Wi=new WeakMap,_t=new WeakSet,Nk=function(e,t){if(T(this,_t,Sg).call(this,e)){T(this,_t,Us).call(this,e,t);return}d(this,ti).push({type:e,event:t})},Va=function(){if(d(this,ti).length===0)return;const e=d(this,ti);D(this,ti,[]);for(const t of e){if(T(this,_t,Sg).call(this,t.type)){T(this,_t,Us).call(this,t.type,t.event);continue}d(this,ti).push(t)}},Sg=function(e){var n;return!!(e==="open"?d(this,Pi):e==="close"?d(this,Yi):e==="error"?d(this,Xi):e==="message"?d(this,Wi):null)||(((n=d(this,ei).get(e))==null?void 0:n.size)??0)>0},Us=function(e,t){const n=d(this,ei).get(e);if(n)for(const r of n)r(t);const i=e==="open"?d(this,Pi):e==="close"?d(this,Yi):e==="error"?d(this,Xi):e==="message"?d(this,Wi):null;return i==null||i(t),!0},M_);function z_(e,t,n,i=""){const r=n!==void 0?`@${encodeURIComponent(n)}`:"",a=`/gateway/${encodeURIComponent(t)}${r}${i}`;return Il(e,a)}function z3(e,t,n,i,r="",a=Dk,o=void 0,u,l={}){if(t.length===0)throw new Error("actor query namespace must not be empty");let c;const s=new URLSearchParams;if(s.append("rvt-namespace",t),"getForKey"in n){if(c=n.getForKey.name,s.append("rvt-method","get"),E_(s,n.getForKey.key),o!==void 0)throw new Error("Actor query method=get does not support crashPolicy.");if(u!==void 0)throw new Error("Actor query method=get does not support runnerName.")}else if("getOrCreateForKey"in n){if(c=n.getOrCreateForKey.name,s.append("rvt-method","getOrCreate"),u===void 0)throw new Error("Actor query method=getOrCreate requires runnerName.");s.append("rvt-runner",u),E_(s,n.getOrCreateForKey.key),E3(s,n.getOrCreateForKey.input,a),n.getOrCreateForKey.region!==void 0&&s.append("rvt-region",n.getOrCreateForKey.region),s.append("rvt-crash-policy",o??"sleep")}else throw new Error("Actor query gateway URLs only support get and getOrCreate.");if(c.length===0)throw new Error("actor query name must not be empty");i!==void 0&&s.append("rvt-token",i),po(l)&&s.append("rvt-skip-ready-wait","true");const f=s.toString();let m;r.endsWith("?")||r.endsWith("&")?m="":r.includes("?")?m="&":m="?";const h=`/gateway/${encodeURIComponent(c)}${r}${m}${f}`;return Il(e,h)}function E_(e,t){t.length>0&&e.append("rvt-key",t.join(","))}function E3(e,t,n){if(t===void 0)return;const i=au(t);if(i.byteLength>n)throw new Error(`Actor query input exceeds maxInputSize (${i.byteLength} > ${n} bytes). Increase client maxInputSize to allow larger query payloads.`);e.append("rvt-input",O3(i))}function O3(e){return vg(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}async function T3(e,t,n,i,r={}){const a=await Ik(),o=typeof process<"u"&&yk.VITEST?crypto.randomUUID():void 0;pe().debug({msg:"opening websocket to actor via guard",gatewayUrl:t});const u=new a(t,jk(e,n,i,o,r.directActorId?{target:"actor",actorId:r.directActorId}:void 0,r));u.binaryType="arraybuffer";const l=new $3(u);return o&&w3(l,o),l}function jk(e,t,n,i,r,a={}){const o=[];return o.push(u3),o.push(`${s3}${t}`),r&&(o.push(`${l3}${r.target}`),o.push(`${c3}${r.actorId}`),e.token&&o.push(`${d3}${e.token}`)),po(a)&&o.push(m3),n&&o.push(`${f3}${encodeURIComponent(JSON.stringify(n))}`),i&&o.push(`${h3}${encodeURIComponent(i)}`),o}var cr=Pd({});function vu(e){return Qd(e)}function pu(e,t){Jd(e,t)}function k3(e){return{actorId:P(e),connectionId:P(e),connectionToken:P(e)}}function A3(e,t){Y(e,t.actorId),Y(e,t.connectionId),Y(e,t.connectionToken)}function Rk(e){return Qe(e)?vu(e):null}function Ck(e,t){Je(e,t!=null),t!=null&&pu(e,t)}function x3(e){return Qe(e)?mn(e):null}function U3(e,t){Je(e,t!=null),t!=null&&hn(e,t)}function D3(e){return{group:P(e),code:P(e),message:P(e),metadata:Rk(e),actionId:x3(e)}}function I3(e,t){Y(e,t.group),Y(e,t.code),Y(e,t.message),Ck(e,t.metadata),U3(e,t.actionId)}function N3(e){return{id:mn(e),output:vu(e)}}function j3(e,t){hn(e,t.id),pu(e,t.output)}function R3(e){return{name:P(e),args:vu(e)}}function C3(e,t){Y(e,t.name),pu(e,t.args)}function M3(e){const t=e.offset;switch(Kt(e)){case 0:return{tag:"Init",val:k3(e)};case 1:return{tag:"Error",val:D3(e)};case 2:return{tag:"ActionResponse",val:N3(e)};case 3:return{tag:"Event",val:R3(e)};default:throw e.offset=t,new le(t,"invalid tag")}}function Z3(e,t){switch(t.tag){case"Init":{ze(e,0),A3(e,t.val);break}case"Error":{ze(e,1),I3(e,t.val);break}case"ActionResponse":{ze(e,2),j3(e,t.val);break}case"Event":{ze(e,3),C3(e,t.val);break}}}function L3(e){return{body:M3(e)}}function B3(e,t){Z3(e,t.body)}function q3(e,t){const n=cr,i=new te(new Uint8Array(n.initialBufferLength),n);return B3(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function H3(e){const t=new te(e,cr),n=L3(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function V3(e){return{id:mn(e),name:P(e),args:vu(e)}}function G3(e,t){hn(e,t.id),Y(e,t.name),pu(e,t.args)}function K3(e){return{eventName:P(e),subscribe:Qe(e)}}function F3(e,t){Y(e,t.eventName),Je(e,t.subscribe)}function Q3(e){const t=e.offset;switch(Kt(e)){case 0:return{tag:"ActionRequest",val:V3(e)};case 1:return{tag:"SubscriptionRequest",val:K3(e)};default:throw e.offset=t,new le(t,"invalid tag")}}function J3(e,t){switch(t.tag){case"ActionRequest":{ze(e,0),G3(e,t.val);break}case"SubscriptionRequest":{ze(e,1),F3(e,t.val);break}}}function P3(e){return{body:Q3(e)}}function Y3(e,t){J3(e,t.body)}function X3(e,t){const n=cr,i=new te(new Uint8Array(n.initialBufferLength),n);return Y3(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function W3(e){const t=new te(e,cr),n=P3(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function eC(e){return{args:vu(e)}}function tC(e,t){pu(e,t.args)}function nC(e,t){const n=cr,i=new te(new Uint8Array(n.initialBufferLength),n);return tC(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function rC(e){const t=new te(e,cr),n=eC(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function iC(e){return{output:vu(e)}}function aC(e,t){pu(e,t.output)}function oC(e,t){const n=cr,i=new te(new Uint8Array(n.initialBufferLength),n);return aC(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function uC(e){const t=new te(e,cr),n=iC(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function lC(e){return{group:P(e),code:P(e),message:P(e),metadata:Rk(e)}}function cC(e,t){Y(e,t.group),Y(e,t.code),Y(e,t.message),Ck(e,t.metadata)}function sC(e,t){const n=cr,i=new te(new Uint8Array(n.initialBufferLength),n);return cC(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function fC(e){const t=new te(e,cr),n=lC(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}var sr=Pd({});function yu(e){return Qd(e)}function bu(e,t){Jd(e,t)}function dC(e){return{actorId:P(e),connectionId:P(e)}}function mC(e,t){Y(e,t.actorId),Y(e,t.connectionId)}function Mk(e){return Qe(e)?yu(e):null}function Zk(e,t){Je(e,t!=null),t!=null&&bu(e,t)}function hC(e){return Qe(e)?mn(e):null}function gC(e,t){Je(e,t!=null),t!=null&&hn(e,t)}function vC(e){return{group:P(e),code:P(e),message:P(e),metadata:Mk(e),actionId:hC(e)}}function pC(e,t){Y(e,t.group),Y(e,t.code),Y(e,t.message),Zk(e,t.metadata),gC(e,t.actionId)}function yC(e){return{id:mn(e),output:yu(e)}}function bC(e,t){hn(e,t.id),bu(e,t.output)}function _C(e){return{name:P(e),args:yu(e)}}function SC(e,t){Y(e,t.name),bu(e,t.args)}function wC(e){const t=e.offset;switch(Kt(e)){case 0:return{tag:"Init",val:dC(e)};case 1:return{tag:"Error",val:vC(e)};case 2:return{tag:"ActionResponse",val:yC(e)};case 3:return{tag:"Event",val:_C(e)};default:throw e.offset=t,new le(t,"invalid tag")}}function $C(e,t){switch(t.tag){case"Init":{ze(e,0),mC(e,t.val);break}case"Error":{ze(e,1),pC(e,t.val);break}case"ActionResponse":{ze(e,2),bC(e,t.val);break}case"Event":{ze(e,3),SC(e,t.val);break}}}function zC(e){return{body:wC(e)}}function EC(e,t){$C(e,t.body)}function OC(e,t){const n=sr,i=new te(new Uint8Array(n.initialBufferLength),n);return EC(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function TC(e){const t=new te(e,sr),n=zC(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function kC(e){return{id:mn(e),name:P(e),args:yu(e)}}function AC(e,t){hn(e,t.id),Y(e,t.name),bu(e,t.args)}function xC(e){return{eventName:P(e),subscribe:Qe(e)}}function UC(e,t){Y(e,t.eventName),Je(e,t.subscribe)}function DC(e){const t=e.offset;switch(Kt(e)){case 0:return{tag:"ActionRequest",val:kC(e)};case 1:return{tag:"SubscriptionRequest",val:xC(e)};default:throw e.offset=t,new le(t,"invalid tag")}}function IC(e,t){switch(t.tag){case"ActionRequest":{ze(e,0),AC(e,t.val);break}case"SubscriptionRequest":{ze(e,1),UC(e,t.val);break}}}function NC(e){return{body:DC(e)}}function jC(e,t){IC(e,t.body)}function RC(e,t){const n=sr,i=new te(new Uint8Array(n.initialBufferLength),n);return jC(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function CC(e){const t=new te(e,sr),n=NC(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function MC(e){return{args:yu(e)}}function ZC(e,t){bu(e,t.args)}function LC(e,t){const n=sr,i=new te(new Uint8Array(n.initialBufferLength),n);return ZC(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function BC(e){const t=new te(e,sr),n=MC(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function qC(e){return{output:yu(e)}}function HC(e,t){bu(e,t.output)}function VC(e,t){const n=sr,i=new te(new Uint8Array(n.initialBufferLength),n);return HC(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function GC(e){const t=new te(e,sr),n=qC(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function KC(e){return{group:P(e),code:P(e),message:P(e),metadata:Mk(e)}}function FC(e,t){Y(e,t.group),Y(e,t.code),Y(e,t.message),Zk(e,t.metadata)}function QC(e,t){const n=sr,i=new te(new Uint8Array(n.initialBufferLength),n);return FC(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function JC(e){const t=new te(e,sr),n=KC(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}var Jt=Pd({});function Aa(e){return Qd(e)}function xa(e,t){Jd(e,t)}function PC(e){return{actorId:P(e),connectionId:P(e)}}function YC(e,t){Y(e,t.actorId),Y(e,t.connectionId)}function Hy(e){return Qe(e)?Aa(e):null}function Vy(e,t){Je(e,t!=null),t!=null&&xa(e,t)}function XC(e){return Qe(e)?mn(e):null}function WC(e,t){Je(e,t!=null),t!=null&&hn(e,t)}function e8(e){return{group:P(e),code:P(e),message:P(e),metadata:Hy(e),actionId:XC(e)}}function t8(e,t){Y(e,t.group),Y(e,t.code),Y(e,t.message),Vy(e,t.metadata),WC(e,t.actionId)}function n8(e){return{id:mn(e),output:Aa(e)}}function r8(e,t){hn(e,t.id),xa(e,t.output)}function i8(e){return{name:P(e),args:Aa(e)}}function a8(e,t){Y(e,t.name),xa(e,t.args)}function o8(e){const t=e.offset;switch(Kt(e)){case 0:return{tag:"Init",val:PC(e)};case 1:return{tag:"Error",val:e8(e)};case 2:return{tag:"ActionResponse",val:n8(e)};case 3:return{tag:"Event",val:i8(e)};default:throw e.offset=t,new le(t,"invalid tag")}}function u8(e,t){switch(t.tag){case"Init":{ze(e,0),YC(e,t.val);break}case"Error":{ze(e,1),t8(e,t.val);break}case"ActionResponse":{ze(e,2),r8(e,t.val);break}case"Event":{ze(e,3),a8(e,t.val);break}}}function l8(e){return{body:o8(e)}}function c8(e,t){u8(e,t.body)}function s8(e,t){const n=Jt,i=new te(new Uint8Array(n.initialBufferLength),n);return c8(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function f8(e){const t=new te(e,Jt),n=l8(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function d8(e){return{id:mn(e),name:P(e),args:Aa(e)}}function m8(e,t){hn(e,t.id),Y(e,t.name),xa(e,t.args)}function h8(e){return{eventName:P(e),subscribe:Qe(e)}}function g8(e,t){Y(e,t.eventName),Je(e,t.subscribe)}function v8(e){const t=e.offset;switch(Kt(e)){case 0:return{tag:"ActionRequest",val:d8(e)};case 1:return{tag:"SubscriptionRequest",val:h8(e)};default:throw e.offset=t,new le(t,"invalid tag")}}function p8(e,t){switch(t.tag){case"ActionRequest":{ze(e,0),m8(e,t.val);break}case"SubscriptionRequest":{ze(e,1),g8(e,t.val);break}}}function y8(e){return{body:v8(e)}}function b8(e,t){p8(e,t.body)}function _8(e,t){const n=Jt,i=new te(new Uint8Array(n.initialBufferLength),n);return b8(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function S8(e){const t=new te(e,Jt),n=y8(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function w8(e){return{args:Aa(e)}}function $8(e,t){xa(e,t.args)}function z8(e,t){const n=Jt,i=new te(new Uint8Array(n.initialBufferLength),n);return $8(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function E8(e){const t=new te(e,Jt),n=w8(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function O8(e){return{output:Aa(e)}}function T8(e,t){xa(e,t.output)}function k8(e,t){const n=Jt,i=new te(new Uint8Array(n.initialBufferLength),n);return T8(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function A8(e){const t=new te(e,Jt),n=O8(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function x8(e){return Qe(e)?P(e):null}function U8(e,t){Je(e,t!=null),t!=null&&Y(e,t)}function D8(e){return Qe(e)?Qe(e):null}function I8(e,t){Je(e,t!=null),t!=null&&Je(e,t)}function N8(e){return Qe(e)?fk(e):null}function j8(e,t){Je(e,t!=null),t!=null&&dk(e,t)}function R8(e){return{body:Aa(e),name:x8(e),wait:D8(e),timeout:N8(e)}}function C8(e,t){xa(e,t.body),U8(e,t.name),I8(e,t.wait),j8(e,t.timeout)}function M8(e,t){const n=Jt,i=new te(new Uint8Array(n.initialBufferLength),n);return C8(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function Z8(e){const t=new te(e,Jt),n=R8(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function L8(e){return{status:P(e),response:Hy(e)}}function B8(e,t){Y(e,t.status),Vy(e,t.response)}function q8(e,t){const n=Jt,i=new te(new Uint8Array(n.initialBufferLength),n);return B8(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function H8(e){const t=new te(e,Jt),n=L8(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function V8(e){return{group:P(e),code:P(e),message:P(e),metadata:Hy(e)}}function G8(e,t){Y(e,t.group),Y(e,t.code),Y(e,t.message),Vy(e,t.metadata)}function K8(e,t){const n=Jt,i=new te(new Uint8Array(n.initialBufferLength),n);return G8(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function F8(e){const t=new te(e,Jt),n=V8(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}var Pt=Pd({});function Ua(e){return Qd(e)}function Da(e,t){Jd(e,t)}function Lk(e){return Qe(e)?P(e):null}function Bk(e,t){Je(e,t!=null),t!=null&&Y(e,t)}function Q8(e){return{actorId:P(e),generation:mn(e),key:Lk(e)}}function J8(e,t){Y(e,t.actorId),hn(e,t.generation),Bk(e,t.key)}function P8(e){return{actorId:P(e),connectionId:P(e)}}function Y8(e,t){Y(e,t.actorId),Y(e,t.connectionId)}function Gy(e){return Qe(e)?Ua(e):null}function Ky(e,t){Je(e,t!=null),t!=null&&Da(e,t)}function X8(e){return Qe(e)?mn(e):null}function W8(e,t){Je(e,t!=null),t!=null&&hn(e,t)}function qk(e){return Qe(e)?Q8(e):null}function Hk(e,t){Je(e,t!=null),t!=null&&J8(e,t)}function eM(e){return{group:P(e),code:P(e),message:P(e),metadata:Gy(e),actionId:X8(e),actor:qk(e)}}function tM(e,t){Y(e,t.group),Y(e,t.code),Y(e,t.message),Ky(e,t.metadata),W8(e,t.actionId),Hk(e,t.actor)}function nM(e){return{id:mn(e),output:Ua(e)}}function rM(e,t){hn(e,t.id),Da(e,t.output)}function iM(e){return{name:P(e),args:Ua(e)}}function aM(e,t){Y(e,t.name),Da(e,t.args)}function oM(e){const t=e.offset;switch(Kt(e)){case 0:return{tag:"Init",val:P8(e)};case 1:return{tag:"Error",val:eM(e)};case 2:return{tag:"ActionResponse",val:nM(e)};case 3:return{tag:"Event",val:iM(e)};default:throw e.offset=t,new le(t,"invalid tag")}}function uM(e,t){switch(t.tag){case"Init":{ze(e,0),Y8(e,t.val);break}case"Error":{ze(e,1),tM(e,t.val);break}case"ActionResponse":{ze(e,2),rM(e,t.val);break}case"Event":{ze(e,3),aM(e,t.val);break}}}function lM(e){return{body:oM(e)}}function cM(e,t){uM(e,t.body)}function sM(e,t){const n=Pt,i=new te(new Uint8Array(n.initialBufferLength),n);return cM(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function fM(e){const t=new te(e,Pt),n=lM(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function dM(e){return{id:mn(e),name:P(e),args:Ua(e)}}function mM(e,t){hn(e,t.id),Y(e,t.name),Da(e,t.args)}function hM(e){return{eventName:P(e),subscribe:Qe(e)}}function gM(e,t){Y(e,t.eventName),Je(e,t.subscribe)}function vM(e){const t=e.offset;switch(Kt(e)){case 0:return{tag:"ActionRequest",val:dM(e)};case 1:return{tag:"SubscriptionRequest",val:hM(e)};default:throw e.offset=t,new le(t,"invalid tag")}}function pM(e,t){switch(t.tag){case"ActionRequest":{ze(e,0),mM(e,t.val);break}case"SubscriptionRequest":{ze(e,1),gM(e,t.val);break}}}function yM(e){return{body:vM(e)}}function bM(e,t){pM(e,t.body)}function _M(e,t){const n=Pt,i=new te(new Uint8Array(n.initialBufferLength),n);return bM(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function SM(e){const t=new te(e,Pt),n=yM(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function wM(e){return{args:Ua(e)}}function $M(e,t){Da(e,t.args)}function zM(e,t){const n=Pt,i=new te(new Uint8Array(n.initialBufferLength),n);return $M(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function EM(e){const t=new te(e,Pt),n=wM(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function OM(e){return{output:Ua(e)}}function TM(e,t){Da(e,t.output)}function kM(e,t){const n=Pt,i=new te(new Uint8Array(n.initialBufferLength),n);return TM(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function AM(e){const t=new te(e,Pt),n=OM(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function xM(e){return Qe(e)?Qe(e):null}function UM(e,t){Je(e,t!=null),t!=null&&Je(e,t)}function DM(e){return Qe(e)?fk(e):null}function IM(e,t){Je(e,t!=null),t!=null&&dk(e,t)}function NM(e){return{body:Ua(e),name:Lk(e),wait:xM(e),timeout:DM(e)}}function jM(e,t){Da(e,t.body),Bk(e,t.name),UM(e,t.wait),IM(e,t.timeout)}function RM(e,t){const n=Pt,i=new te(new Uint8Array(n.initialBufferLength),n);return jM(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function CM(e){const t=new te(e,Pt),n=NM(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function MM(e){return{status:P(e),response:Gy(e)}}function ZM(e,t){Y(e,t.status),Ky(e,t.response)}function LM(e,t){const n=Pt,i=new te(new Uint8Array(n.initialBufferLength),n);return ZM(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function BM(e){const t=new te(e,Pt),n=MM(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}function qM(e){return{group:P(e),code:P(e),message:P(e),metadata:Gy(e),actor:qk(e)}}function HM(e,t){Y(e,t.group),Y(e,t.code),Y(e,t.message),Ky(e,t.metadata),Hk(e,t.actor)}function VM(e,t){const n=Pt,i=new te(new Uint8Array(n.initialBufferLength),n);return HM(i,e),new Uint8Array(i.view.buffer,i.view.byteOffset,i.offset)}function GM(e){const t=new te(e,Pt),n=qM(t);if(t.offset<t.view.byteLength)throw new le(t.offset,"remaining bytes");return n}var Nl=4,KM=e=>{if(e.body.tag==="Init"){const{actorId:t,connectionId:n}=e.body.val;return{body:{tag:"Init",val:{actorId:t,connectionId:n}}}}return e},FM=e=>{if(e.body.tag==="Init"){const{actorId:t,connectionId:n}=e.body.val;return{body:{tag:"Init",val:{actorId:t,connectionId:n,connectionToken:""}}}}return e},QM=e=>e,JM=e=>e.body.tag==="Error"?{body:{tag:"Error",val:{...e.body.val,actor:null}}}:e,PM=e=>{if(e.body.tag==="Error"){const{actor:t,...n}=e.body.val;return{body:{tag:"Error",val:n}}}return e},YM=e=>e,XM=e=>e,WM=e=>e,eZ=e=>e,tZ=e=>e,nZ=e=>e,rZ=e=>e,iZ=e=>({...e,actor:null}),aZ=e=>{const{actor:t,...n}=e;return n},oZ=ka({deserializeVersion:(e,t)=>{switch(t){case 1:return W3(e);case 2:return CC(e);case 3:return S8(e);case 4:return SM(e);default:throw new Error(`Unknown version ${t}`)}},serializeVersion:(e,t)=>{switch(t){case 1:return X3(e);case 2:return RC(e);case 3:return _8(e);case 4:return _M(e);default:throw new Error(`Unknown version ${t}`)}},deserializeConverters:()=>[XM,WM,eZ],serializeConverters:()=>[tZ,nZ,rZ]}),uZ=ka({deserializeVersion:(e,t)=>{switch(t){case 1:return H3(e);case 2:return TC(e);case 3:return f8(e);case 4:return fM(e);default:throw new Error(`Unknown version ${t}`)}},serializeVersion:(e,t)=>{switch(t){case 1:return q3(e);case 2:return OC(e);case 3:return s8(e);case 4:return sM(e);default:throw new Error(`Unknown version ${t}`)}},deserializeConverters:()=>[KM,QM,JM],serializeConverters:()=>[PM,YM,FM]}),lZ=ka({deserializeVersion:(e,t)=>{switch(t){case 1:return rC(e);case 2:return BC(e);case 3:return E8(e);case 4:return EM(e);default:throw new Error(`Unknown version ${t}`)}},serializeVersion:(e,t)=>{switch(t){case 1:return nC(e);case 2:return LC(e);case 3:return z8(e);case 4:return zM(e);default:throw new Error(`Unknown version ${t}`)}},deserializeConverters:()=>[],serializeConverters:()=>[]}),cZ=ka({deserializeVersion:(e,t)=>{switch(t){case 1:return uC(e);case 2:return GC(e);case 3:return A8(e);case 4:return AM(e);default:throw new Error(`Unknown version ${t}`)}},serializeVersion:(e,t)=>{switch(t){case 1:return oC(e);case 2:return VC(e);case 3:return k8(e);case 4:return kM(e);default:throw new Error(`Unknown version ${t}`)}},deserializeConverters:()=>[],serializeConverters:()=>[]}),sZ=ka({deserializeVersion:(e,t)=>{switch(t){case 3:return Z8(e);case 4:return CM(e);default:throw new Error(`HttpQueueSendRequest only exists in version 3+, got version ${t}`)}},serializeVersion:(e,t)=>{switch(t){case 3:return M8(e);case 4:return RM(e);default:throw new Error(`HttpQueueSendRequest only exists in version 3+, got version ${t}`)}},deserializeConverters:()=>[],serializeConverters:()=>[]}),fZ=ka({deserializeVersion:(e,t)=>{switch(t){case 3:return H8(e);case 4:return BM(e);default:throw new Error(`HttpQueueSendResponse only exists in version 3+, got version ${t}`)}},serializeVersion:(e,t)=>{switch(t){case 3:return q8(e);case 4:return LM(e);default:throw new Error(`HttpQueueSendResponse only exists in version 3+, got version ${t}`)}},deserializeConverters:()=>[],serializeConverters:()=>[]}),Vk=ka({deserializeVersion:(e,t)=>{switch(t){case 1:return fC(e);case 2:return JC(e);case 3:return F8(e);case 4:return GM(e);default:throw new Error(`Unknown version ${t}`)}},serializeVersion:(e,t)=>{switch(t){case 1:return sC(e);case 2:return QC(e);case 3:return K8(e);case 4:return VM(e);default:throw new Error(`Unknown version ${t}`)}},deserializeConverters:()=>[e=>e,e=>e,iZ],serializeConverters:()=>[aZ,e=>e,e=>e]}),Fy=jd(),dZ=Fy.nullable(),Gk=Le({actorId:at(),generation:kc([Sc(),jd()]),key:at().optional()}),mZ=Le({actorId:at(),connectionId:at()}),hZ=Le({group:at(),code:at(),message:at(),metadata:Tt().optional(),actionId:dZ,actor:Gk.optional()}),gZ=Le({id:Fy,output:Tt()}),vZ=Le({name:at(),args:Tt()}),pZ=Zd("tag",[Le({tag:fi("Init"),val:mZ}),Le({tag:fi("Error"),val:hZ}),Le({tag:fi("ActionResponse"),val:gZ}),Le({tag:fi("Event"),val:vZ})]),yZ=Le({body:pZ}),bZ=Le({id:Fy,name:at(),args:Tt()}),_Z=Le({eventName:at(),subscribe:$c()}),SZ=Zd("tag",[Le({tag:fi("ActionRequest"),val:bZ}),Le({tag:fi("SubscriptionRequest"),val:_Z})]),wZ=Le({body:SZ}),$Z=Le({args:Tt()}),zZ=Le({output:Tt()}),EZ=Le({body:Tt(),name:at().optional(),wait:$c().optional(),timeout:Sc().optional()}),OZ=Le({status:Ta(["completed","timedOut"]),response:Tt().optional()}),Kk=Le({group:at(),code:at(),message:at(),metadata:Tt().optional(),actor:Gk.optional()});Le({actorId:at()});var Fk=class extends Error{},Zu=class extends Fk{constructor(e,t){super(`HTTP request error: ${e}`,{cause:t==null?void 0:t.cause})}},cs=class extends Fk{constructor(){super("Attempting to interact with a disposed actor connection.")}};function wg(e,t){return e==="guard"&&(t==="actor_ready_timeout"||t==="actor_runner_failed")}function TZ(e,t,n,i){return new Se(e,t,`Actor failed to start (${n}): ${JSON.stringify(i)}`,{metadata:{actorId:n,details:i}})}function kZ(e,t){return new Se("rivetkit",gg,e,{cause:t==null?void 0:t.cause})}function AZ(e){const[t,n]=e.split("#"),[i,r]=t.split(".");if(!i||!r){H().warn({msg:"failed to parse close reason",reason:e});return}return{group:i,code:r,rayId:n}}function xZ(e){if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer||e instanceof Uint8Array)return e.byteLength;if(typeof e=="string")return e.length;Dc(e)}async function Qy(e){var r,a,o;H().debug({msg:"sending http request",url:e.url,encoding:e.encoding});let t,n;(e.method==="POST"||e.method==="PUT")&&(iu(e.body!==void 0,"missing body"),t=zR(e.encoding),n=bk(e.encoding,e.body,e.requestVersionedDataHandler,e.requestVersion,e.requestZodSchema,e.requestToJson,e.requestToBare));let i;try{i=await(e.customFetch??fetch)(new globalThis.Request(e.url,{method:e.method,headers:{...e.headers,...t?{"Content-Type":t}:{},"User-Agent":xR()},body:n,credentials:"include",signal:e.signal}))}catch(u){throw new Zu(`Request failed: ${u}`,{cause:u})}if(!i.ok){const u=await i.arrayBuffer(),l=i.headers.get("content-type"),c=i.headers.get("x-rivet-ray-id"),s=l!=null&&l.includes("application/json")?"json":e.encoding;try{const f=Tf(s,new Uint8Array(u),Vk,Kk,m=>({...m,actor:m.actor?{...m.actor,generation:Number(m.actor.generation)}:void 0}),m=>({group:m.group,code:m.code,message:m.message,metadata:m.metadata?wi(new Uint8Array(m.metadata)):void 0,actor:m.actor?{actorId:m.actor.actorId,generation:Number(m.actor.generation),key:m.actor.key??void 0}:void 0}));throw H().warn({msg:"http error response",group:f.group,code:f.code,message:f.message,metadata:f.metadata,actorId:(r=f.actor)==null?void 0:r.actorId,generation:(a=f.actor)==null?void 0:a.generation,actorKey:(o=f.actor)==null?void 0:o.key}),new Se(f.group,f.code,f.message,{metadata:f.metadata,actor:f.actor})}catch(f){if(f instanceof Se)throw f;const m=new TextDecoder("utf-8",{fatal:!1}).decode(u);throw c?new Zu(`${i.statusText} (${i.status}) (Ray ID: ${c}):
|
|
124
124
|
${m}`):new Zu(`${i.statusText} (${i.status}):
|
|
125
|
-
${m}`)}}if(!e.skipParseResponse)try{const u=new Uint8Array(await i.arrayBuffer());return Tf(e.encoding,u,e.responseVersionedDataHandler,e.responseZodSchema,e.responseFromJson,e.responseFromBare)}catch(u){throw new Zu(`Failed to parse response: ${u}`,{cause:u})}}function kf(e){return e.endpoint??"http://127.0.0.1:6420"}async function Ia(e,t,n,i){const r=kf(e),a=Il(r,n,{namespace:e.namespace});pe().debug({msg:"making api call",method:t,url:a});const o={...e.headers};return e.token&&(o.Authorization=`Bearer ${e.token}`),await Qy({method:t,url:a,headers:o,body:i,encoding:"json",skipParseResponse:!1,requestVersionedDataHandler:void 0,requestVersion:void 0,responseVersionedDataHandler:void 0,responseVersion:void 0,requestZodSchema:$f(),responseZodSchema:$f(),requestToJson:u=>u,requestToBare:u=>u,responseFromJson:u=>u,responseFromBare:u=>u})}async function UZ(e,t,n){return Ia(e,"GET",`/actors?actor_ids=${encodeURIComponent(n)}`)}async function DZ(e,t,n){const i=_g(n);return Ia(e,"GET",`/actors?name=${encodeURIComponent(t)}&key=${encodeURIComponent(i)}`)}async function IZ(e,t){return Ia(e,"GET",`/actors?name=${encodeURIComponent(t)}`)}async function NZ(e,t){return Ia(e,"PUT","/actors",t)}async function jZ(e,t){return Ia(e,"POST","/actors",t)}async function RZ(e,t){return Ia(e,"DELETE",`/actors/${encodeURIComponent(t)}`)}async function CZ(e){return Ia(e,"GET","/metadata")}var O_=new Map;async function MZ(e){const t=kf(e),n=O_.get(t);if(n)return n;const i=pk(async()=>{pe().debug({msg:"fetching metadata",endpoint:t});const r=await CZ(e);return pe().debug({msg:"received metadata",endpoint:t,clientEndpoint:r.clientEndpoint}),r},{forever:!0,minTimeout:500,maxTimeout:15e3,onFailedAttempt:r=>{r.attemptNumber>1&&pe().warn({msg:"failed to fetch metadata, retrying",endpoint:t,attempt:r.attemptNumber,error:ht(r)})}});return O_.set(t,i),i}async function ZZ(e,t,n){const i=await Ik(),r={};return{onOpen:async(a,o)=>{if(pe().debug({msg:"client websocket connected",targetUrl:t}),o.readyState!==1){pe().warn({msg:"client websocket not open on connection",targetUrl:t,readyState:o.readyState});return}const u=new i(t,n);r.targetWs=u,r.connectPromise=new Promise((l,c)=>{u.addEventListener("open",()=>{if(pe().debug({msg:"target websocket connected",targetUrl:t}),o.readyState!==1){pe().warn({msg:"client websocket closed before target connected",targetUrl:t,clientReadyState:o.readyState}),u.close(1001,"Client disconnected"),c(new Error("Client disconnected"));return}l()}),u.addEventListener("error",s=>{pe().warn({msg:"target websocket error during connection",targetUrl:t}),c(s)})}),r.connectPromise.catch(()=>{}),r.targetWs.addEventListener("message",l=>{typeof l.data=="string"||l.data instanceof ArrayBuffer?o.send(l.data):l.data instanceof Blob&&l.data.arrayBuffer().then(c=>{o.send(c)})}),r.targetWs.addEventListener("close",l=>{pe().debug({msg:"target websocket closed",targetUrl:t,code:l.code,reason:l.reason}),Km(o,l.code,l.reason)}),r.targetWs.addEventListener("error",l=>{pe().error({msg:"target websocket error",targetUrl:t,error:ht(l)}),Km(o,1011,"Target WebSocket error")})},onMessage:async(a,o)=>{if(!r.targetWs||!r.connectPromise){pe().error({msg:"websocket state not initialized",targetUrl:t});return}try{await r.connectPromise,r.targetWs.readyState===i.OPEN?r.targetWs.send(a.data):pe().warn({msg:"target websocket not open",targetUrl:t,readyState:r.targetWs.readyState})}catch(u){pe().error({msg:"failed to connect to target websocket",targetUrl:t,error:u}),Km(o,1011,"Failed to connect to target")}},onClose:(a,o)=>{pe().debug({msg:"client websocket closed",targetUrl:t,code:a.code,reason:a.reason,wasClean:a.wasClean}),r.targetWs&&(r.targetWs.readyState===i.OPEN||r.targetWs.readyState===i.CONNECTING)&&r.targetWs.close(1e3,a.reason||"Client disconnected")},onError:(a,o)=>{pe().error({msg:"client websocket error",targetUrl:t,event:a}),r.targetWs&&(r.targetWs.readyState===i.OPEN?r.targetWs.close(1011,"Client WebSocket error"):r.targetWs.readyState===i.CONNECTING&&r.targetWs.close())}}}function Km(e,t,n){(e.readyState===1||"close"in e&&e.readyState===WebSocket.OPEN)&&e.close(t,n)}var _e,At,ea,Lu,Z_,LZ=(Z_=class{constructor(e){R(this,ea);R(this,_e);R(this,At);BR()==="phase-production-build"&&(pe().info("detected next.js build phase, disabling health check"),e.disableMetadataLookup=!0),D(this,_e,{...e}),e.disableMetadataLookup||D(this,At,MZ(d(this,_e)).then(t=>{t.clientEndpoint&&(d(this,_e).endpoint=t.clientEndpoint,t.clientNamespace&&(d(this,_e).namespace=t.clientNamespace),t.clientToken&&(d(this,_e).token=t.clientToken),pe().info({msg:"overriding client endpoint",endpoint:t.clientEndpoint,namespace:t.clientNamespace,token:t.clientToken})),pe().info({msg:"connected to rivetkit runtime",runtime:t.runtime,version:t.version,envoy:t.envoy})}))}async getForId({name:e,actorId:t}){await d(this,At);const i=(await UZ(d(this,_e),e,t)).actors[0];if(i){if(i.name!==e){pe().debug({msg:"actor name mismatch from api",actorId:t,apiName:i.name,requestedName:e});return}return xu(i)}}async getWithKey({name:e,key:t}){await d(this,At),pe().debug({msg:"getWithKey: searching for actor",name:e,key:t});try{const i=(await DZ(d(this,_e),e,t)).actors[0];return i?(pe().debug({msg:"getWithKey: found actor via api",actorId:i.actor_id,name:e,key:t}),xu(i)):void 0}catch(n){if(n instanceof Se&&n.group==="actor"&&n.code==="not_found")return;throw n}}async getOrCreateWithKey(e){await d(this,At);const{name:t,key:n,input:i,region:r,crashPolicy:a}=e;pe().info({msg:"getOrCreateWithKey: getting or creating actor via engine api",name:t,key:n});const{actor:o,created:u}=await NZ(d(this,_e),{datacenter:r,name:t,key:_g(n),runner_name_selector:d(this,_e).poolName,input:i?vg(au(i)):void 0,crash_policy:a??"sleep"});return pe().info({msg:"getOrCreateWithKey: actor ready",actorId:o.actor_id,name:t,key:n,created:u}),xu(o)}async createActor({name:e,key:t,input:n,region:i,crashPolicy:r}){await d(this,At),pe().info({msg:"creating actor via engine api",name:e,key:t});const a=await jZ(d(this,_e),{datacenter:i,name:e,runner_name_selector:d(this,_e).poolName,key:_g(t),input:n?vg(au(n)):void 0,crash_policy:r??"sleep"});return pe().info({msg:"actor created",actorId:a.actor.actor_id,name:e,key:t}),xu(a.actor)}async listActors({name:e}){return await d(this,At),pe().debug({msg:"listing actors via engine api",name:e}),(await IZ(d(this,_e),e)).actors.map(xu)}async destroyActor(e){await d(this,At),pe().info({msg:"destroying actor via engine api",actorId:e}),await RZ(d(this,_e),e),pe().info({msg:"actor destroyed",actorId:e})}async sendRequest(e,t,n={}){await d(this,At);const i=k_(t),r=T(this,ea,Lu).call(this,e,i,n),a={...n,directActorId:po(n)?Fm(e):void 0};return __(d(this,_e),r,t,a)}async openWebSocket(e,t,n,i,r={}){await d(this,At);const a=T(this,ea,Lu).call(this,t,e,r);return T3(d(this,_e),a,n,i,{...r,directActorId:po(r)?Fm(t):void 0})}async buildGatewayUrl(e,t={}){return await d(this,At),T(this,ea,Lu).call(this,e,"",t)}async proxyRequest(e,t,n){await d(this,At);const i=T(this,ea,Lu).call(this,{directId:n},k_(t));return __(d(this,_e),i,t)}async proxyWebSocket(e,t,n,i,r){var f,m;await d(this,At);const a=(m=(f=d(this,_e)).getUpgradeWebSocket)==null?void 0:m.call(f);iu(a,"missing getUpgradeWebSocket");const o=kf(d(this,_e)),u=Il(o,t),l=u.replace("http://","ws://");pe().debug({msg:"forwarding websocket to actor via guard",actorId:n,path:t,guardUrl:u});const c=jk(d(this,_e),i,r,void 0,{target:"actor",actorId:n}),s=await ZZ(e,l,c);return await a(()=>s)(e,wR())}displayInformation(){return{properties:{}}}setGetUpgradeWebSocket(e){d(this,_e).getUpgradeWebSocket=e}},_e=new WeakMap,At=new WeakMap,ea=new WeakSet,Lu=function(e,t,n={}){const i=kf(d(this,_e));if(po(n)&&Fm(e)&&BZ(t))return Il(i,t);if("directId"in e)return z_(i,e.directId,d(this,_e).token,t);if("getForId"in e)return z_(i,e.getForId.actorId,d(this,_e).token,t);if("getForKey"in e||"getOrCreateForKey"in e)return z3(i,d(this,_e).namespace,e,d(this,_e).token,t,d(this,_e).maxInputSize,void 0,"getOrCreateForKey"in e?d(this,_e).poolName:void 0,n);throw"create"in e?new Error("Gateway URLs only support direct actor IDs, get, and getOrCreate targets."):new Error("unreachable: unknown gateway target type")},Z_);function BZ(e){return qZ(e)||T_(e,Ak)||T_(e,n3)||e.startsWith(xk)}function T_(e,t){return e===t||e.startsWith(`${t}?`)}function qZ(e){const t=e.slice(8);return e.startsWith("/request")&&(t.length===0||t.startsWith("/")||t.startsWith("?"))}function Fm(e){if("directId"in e)return e.directId;if("getForId"in e)return e.getForId.actorId}function k_(e){const t=new URL(e.url);return`${t.pathname}${t.search}`}function xu(e){return{actorId:e.actor_id,name:e.name,key:t3(e.key),createTs:e.create_ts,startTs:e.start_ts??null,connectableTs:e.connectable_ts??null,sleepTs:e.sleep_ts??null,destroyTs:e.destroy_ts??null,error:e.error??void 0}}function Ga(e={},t){return{skipReadyWait:(t==null?void 0:t.skipReadyWait)??e.skipReadyWait??!1}}function Qk(e){if("getForId"in e)return e.getForId.name;if("getForKey"in e)return e.getForKey.name;if("getOrCreateForKey"in e)return e.getOrCreateForKey.name;if("create"in e)return e.create.name;throw Iy("Invalid query format")}function yr(e){return"getForKey"in e||"getOrCreateForKey"in e}function qi(e){if("getForId"in e)return{directId:e.getForId.actorId};if("create"in e)throw Iy("create queries cannot be used as gateway targets. Resolve to an actor ID first.");return e}function $g(e,t){return e==="actor"&&(t==="not_found"||t==="starting"||t==="stopping"||t==="not_configured"||t==="dropped_reply"||t.startsWith("destroyed_"))}async function zg(e,t,n,i,r){const a=Qk(i);try{const o=await r.getForId({name:a,actorId:n});if(o!=null&&o.error)return H().info({msg:"found actor scheduling error",actorId:n,error:o.error}),TZ(e,t,n,o.error)}catch(o){H().warn({msg:"failed to fetch actor details for scheduling error check",actorId:n,error:ht(o)})}return null}function*HZ(e,t=8){let n=e,i=0;for(;n!=null&&i<t;){if(yield n,typeof n=="object"&&"cause"in n&&n.cause!==n){n=n.cause,i+=1;continue}break}}function Hr(e,t,n,i){return{kind:e,source:t,group:i==null?void 0:i.group,code:i==null?void 0:i.code,message:n,legacy:(i==null?void 0:i.legacy)??!1}}function VZ(e){if(!(e.group==="actor"&&e.code==="stopping"&&e.message.includes("database accessed after actor stopped"))){if(e.group==="actor"&&e.code==="restarting")return Hr("request_retry","actor_error",e.message,{group:e.group,code:e.code});if(e.group==="guard"&&GZ(e.code))return Hr("request_retry","actor_error",e.message,{group:e.group,code:e.code});if(e.group==="actor"&&e.code==="internal_error"&&e.message==="Actor is stopping")return Hr("request_retry","actor_error",e.message,{group:e.group,code:e.code,legacy:!0});if(e.group==="actor"&&e.code==="stopping"&&e.message==="Actor stopping: Cannot accept new connections while actor is stopping")return Hr("request_retry","actor_error",e.message,{group:e.group,code:e.code,legacy:!0});if(e.group==="actor"&&e.code==="stopped")return Hr("reconnect_only","actor_error",e.message,{group:e.group,code:e.code,legacy:!0});if(e.group==="ws"&&e.code==="going_away")return Hr("reconnect_only","actor_error",e.message,{group:e.group,code:e.code,legacy:!0})}}function GZ(e){return e==="service_unavailable"||e==="actor_wake_retries_exceeded"||e==="actor_stopped_while_waiting"||e==="tunnel_request_aborted"||e==="tunnel_message_timeout"||e==="tunnel_response_closed"||e==="gateway_response_start_timeout"}function KZ(e){if(!e.message.includes("database accessed after actor stopped")){if(/^Actor [A-Za-z0-9-]+ stopped$/.test(e.message))return Hr("request_retry","transport_error",e.message,{legacy:!0});if(e.message==="WebSocket connection closed during shutdown"||e.message==="envoy shut down"||e.message==="envoy shutting down")return Hr("reconnect_only","transport_error",e.message,{legacy:!0})}}function Jk(e){for(const t of HZ(e)){if(t instanceof Se){const n=VZ(t);if(n)return n;continue}if(t instanceof Zu||t instanceof Error){const n=KZ(t);if(n)return n}}}function FZ(e){var t;return((t=Jk(e))==null?void 0:t.kind)==="request_retry"}function QZ(e){const t=Jk(e);return(t==null?void 0:t.kind)==="reconnect_only"||(t==null?void 0:t.kind)==="request_retry"}function Pk(e){if(e!=null&&e.aborted)throw e.reason??new Error("Operation aborted")}async function JZ(e,t){Pk(t),await new Promise((n,i)=>{const r=setTimeout(()=>{o(),n()},e),a=()=>{clearTimeout(r),o(),i((t==null?void 0:t.reason)??new Error("Operation aborted"))},o=()=>{t==null||t.removeEventListener("abort",a)};t==null||t.addEventListener("abort",a,{once:!0})})}async function PZ(e,t){const n=(t==null?void 0:t.maxAttempts)??5,i=(t==null?void 0:t.initialDelayMs)??25,r=(t==null?void 0:t.maxDelayMs)??200;let a;for(let o=0;o<n;o+=1){Pk(t==null?void 0:t.signal);try{return await e()}catch(u){if(!FZ(u))throw u;if(a=u,o===n-1)break;const l=Math.min(i*2**o,r);await JZ(l,t==null?void 0:t.signal)}}throw a}function Yk(e){async function t(n,i,r){const a=(r==null?void 0:r.wait)??!1,o=r==null?void 0:r.timeout,u=await Qy({url:`http://actor/queue/${encodeURIComponent(n)}`,method:"POST",headers:{[Uk]:e.encoding,...e.params!==void 0?{[qy]:JSON.stringify(e.params)}:{}},body:{body:i,wait:a,timeout:o},encoding:e.encoding,customFetch:e.customFetch,signal:r==null?void 0:r.signal,requestVersion:Nl,requestVersionedDataHandler:sZ,responseVersion:Nl,responseVersionedDataHandler:fZ,requestZodSchema:EZ,responseZodSchema:OZ,requestToJson:l=>({...l,name:n}),requestToBare:l=>({name:l.name??n,body:My(au(l.body)),wait:l.wait??!1,timeout:l.timeout!==void 0?BigInt(l.timeout):null}),responseFromJson:l=>l.response===void 0?{status:l.status}:{status:l.status,response:l.response},responseFromBare:l=>l.response===null||l.response===void 0?{status:l.status}:{status:l.status,response:wi(new Uint8Array(l.response))}});if(a)return u}return{send:t}}var Xk=Symbol("connect"),Bn,Ml,Xt,vn,zt,pn,gt,Pn,To,ta,ko,Ao,xo,Zl,Ll,Uo,Bl,vt,st,ql,ni,Do,Io,ri,Yn,No,B,Ds,Is,Ns,Wk,Ka,Eg,eA,Og,Tg,tA,nA,rA,iA,aA,Fa,oA,kg,uA,Bu,Ag,js,lA,Rs,L_,YZ=(L_=class{constructor(e,t,n,i,r,a,o={}){R(this,B);R(this,Bn,!1);R(this,Ml,new AbortController);R(this,Xt,"idle");R(this,vn);R(this,zt);R(this,pn,[]);R(this,gt,new Map);R(this,Pn,new Map);R(this,To,new Set);R(this,ta,new Set);R(this,ko,!1);R(this,Ao,new Set);R(this,xo,new Set);R(this,Zl,0);R(this,Ll);R(this,Uo);R(this,Bl);R(this,vt);R(this,st);R(this,ql);R(this,ni);R(this,Do);R(this,Io);R(this,ri);R(this,Yn);R(this,No);D(this,ql,e),D(this,ni,t),D(this,Do,n),D(this,Io,i),D(this,ri,r),D(this,Yn,a),D(this,No,Ga(o)),"getForId"in a&&D(this,vn,a.getForId.actorId),D(this,Uo,us(u=>H().warn({msg:"unhandled ready promise rejection",reason:u}))),D(this,Ll,Yk({encoding:d(this,ri),params:d(this,Do),customFetch:async u=>await d(this,ni).sendRequest(qi(d(this,Yn)),u,d(this,No))})),D(this,Bl,setInterval(()=>6e4))}send(e,t,n){return T(this,B,Wk).call(this,e,t,n)}async action(e){if(typeof e=="string"||typeof e!="object"||e===null||!("name"in e))throw new Error(`Invalid action call: expected an options object { name, args }, got ${typeof e}. Use conn.actionName(...args) for the shorthand API.`);H().debug({msg:"action",name:e.name,args:e.args});const t=d(this,Zl);D(this,Zl,d(this,Zl)+1);const{promise:n,resolve:i,reject:r}=us(u=>H().warn({msg:"unhandled action promise rejection",reason:u}));d(this,gt).set(t,{name:e.name,resolve:i,reject:r}),H().debug({msg:"added action to in-flight map",actionId:t,actionName:e.name,inFlightCount:d(this,gt).size}),T(this,B,js).call(this,{body:{tag:"ActionRequest",val:{id:BigInt(t),name:e.name,args:e.args}}});const{id:a,output:o}=await n;if(a!==BigInt(t))throw new Error(`Request ID ${t} does not match response ID ${a}`);return o}[Xk](){T(this,B,Eg).call(this)}on(e,t){return T(this,B,Ag).call(this,e,t,!1)}once(e,t){return T(this,B,Ag).call(this,e,t,!0)}onError(e){return d(this,To).add(e),()=>{d(this,To).delete(e)}}get connStatus(){return d(this,Xt)}get isConnected(){return d(this,Xt)==="connected"}get ready(){return d(this,Uo).promise}onOpen(e){return d(this,ta).add(e),d(this,Xt)==="connected"&&queueMicrotask(()=>{if(d(this,ta).has(e))try{e()}catch(t){H().error({msg:"error in open handler",error:ht(t)})}}),()=>{d(this,ta).delete(e)}}onClose(e){return d(this,Ao).add(e),()=>{d(this,Ao).delete(e)}}onStatusChange(e){return d(this,xo).add(e),()=>{d(this,xo).delete(e)}}get actorId(){return d(this,vn)}get connId(){return d(this,zt)}get connectionId(){return d(this,zt)}async dispose(){if(d(this,Bn)){H().warn({msg:"connection already disconnected"});return}if(D(this,Bn,!0),H().debug({msg:"disposing actor conn"}),T(this,B,Ka).call(this,"idle"),clearInterval(d(this,Bl)),d(this,Ml).abort(),d(this,ql)[Ms].delete(this),d(this,st)){const e=d(this,st);if(e.readyState!==2&&e.readyState!==3){const{promise:t,resolve:n}=us(i=>H().warn({msg:"unhandled websocket close promise rejection",reason:i}));e.addEventListener("close",()=>n(void 0)),e.close(1e3,"Disposed"),await t}}else T(this,B,Fa).call(this,new cs,!0);D(this,st,void 0)}},Bn=new WeakMap,Ml=new WeakMap,Xt=new WeakMap,vn=new WeakMap,zt=new WeakMap,pn=new WeakMap,gt=new WeakMap,Pn=new WeakMap,To=new WeakMap,ta=new WeakMap,ko=new WeakMap,Ao=new WeakMap,xo=new WeakMap,Zl=new WeakMap,Ll=new WeakMap,Uo=new WeakMap,Bl=new WeakMap,vt=new WeakMap,st=new WeakMap,ql=new WeakMap,ni=new WeakMap,Do=new WeakMap,Io=new WeakMap,ri=new WeakMap,Yn=new WeakMap,No=new WeakMap,B=new WeakSet,Ds=function(){D(this,vn,void 0),D(this,zt,void 0)},Is=function(e,t){return!yr(d(this,Yn))||!$g(e,t)?!1:(T(this,B,Ds).call(this),!0)},Ns=function(e,t){return yr(d(this,Yn))&&$g(e,t)&&d(this,vt)!==void 0&&d(this,Xt)!=="connected"},Wk=async function(e,t,n){return await d(this,Ll).send(e,t,n)},Ka=function(e){const t=d(this,Xt);if(t!==e){D(this,Xt,e);for(const n of[...d(this,xo)])try{n(e)}catch(i){H().error({msg:"error in status change handler",error:ht(i)})}if(e==="connected"){d(this,Uo).resolve(void 0);for(const n of[...d(this,ta)])try{n()}catch(i){H().error({msg:"error in open handler",error:ht(i)})}}if((e==="disconnected"||e==="idle")&&t==="connected")for(const n of[...d(this,Ao)])try{n()}catch(i){H().error({msg:"error in close handler",error:ht(i)})}}},Eg=function(){T(this,B,Ka).call(this,"connecting"),pk(T(this,B,eA).bind(this),{forever:!0,minTimeout:250,maxTimeout:3e4,onFailedAttempt:e=>{H().warn({msg:"failed to reconnect",attempt:e.attemptNumber,error:ht(e)})},signal:d(this,Ml).signal}).catch(e=>{e instanceof hg||e.name==="AbortError"||!T(this,B,Og).call(this,e)?H().info({msg:"connection retry aborted"}):H().error({msg:"unexpected error in connection retry",error:ht(e)})})},eA=async function(){try{if(d(this,vt))throw new Error("#onOpenPromise already defined");D(this,vt,us(e=>H().warn({msg:"unhandled open promise rejection",reason:e}))),await T(this,B,nA).call(this),await d(this,vt).promise}catch(e){if(T(this,B,Og).call(this,e))throw e;const t=e instanceof Se?e:new Se("client","connection_open_failed",`Failed to open connection: ${ht(e)}`,{error:ht(e)});throw T(this,B,Tg).call(this),T(this,B,Fa).call(this,t,!1),T(this,B,Bu).call(this,t),T(this,B,Ka).call(this,"idle"),new hg(e instanceof Error?e:new Error(ht(e)))}finally{D(this,vt,void 0)}},Og=function(e){return e instanceof cs?!1:e instanceof Se&&T(this,B,Ns).call(this,e.group,e.code)||e instanceof Se&&e.group==="client"&&e.code==="get_params_failed"?!0:QZ(e)},Tg=function(){d(this,pn).length!==0&&(H().debug({msg:"clearing queued connection messages",queueLength:d(this,pn).length}),D(this,pn,[]))},tA=async function(){if(!d(this,Io))return d(this,Do);try{return await d(this,Io).call(this)}catch(e){const t=ht(e),n=new Se("client","get_params_failed",`Failed to resolve connection params: ${t}`,{error:t});throw T(this,B,Tg).call(this),T(this,B,Fa).call(this,n,!1),T(this,B,Bu).call(this,n),n}},nA=async function(){const e=await T(this,B,tA).call(this),t=qi(d(this,Yn)),n=await d(this,ni).openWebSocket(Ak,t,d(this,ri),e,d(this,No));iu(n,"websocket should have been created"),H().debug({msg:"opened websocket",connId:d(this,zt),readyState:n.readyState,messageQueueLength:d(this,pn).length}),D(this,st,n),n.addEventListener("open",()=>{H().debug({msg:"client websocket open",connId:d(this,zt)})}),n.addEventListener("message",async i=>{try{await T(this,B,iA).call(this,i.data)}catch(r){H().error({msg:"error in websocket message handler",error:ht(r)})}}),n.addEventListener("close",async i=>{try{await T(this,B,aA).call(this,i)}catch(r){H().error({msg:"error in websocket close handler",error:ht(r)})}}),n.addEventListener("error",()=>{try{T(this,B,oA).call(this)}catch(i){H().error({msg:"error in websocket error handler",error:ht(i)})}})},rA=function(){if(d(this,Bn)){H().debug({msg:"handleOnOpen called after dispose, closing websocket"}),d(this,st)&&(d(this,st).close(1e3,"Disposed"),D(this,st,void 0));return}d(this,Xt)==="connected"||d(this,ko)||(D(this,ko,!0),queueMicrotask(()=>{if(D(this,ko,!1),d(this,Bn)){H().debug({msg:"handleOnOpen scheduled after dispose, closing websocket"}),d(this,st)&&(d(this,st).close(1e3,"Disposed"),D(this,st,void 0));return}H().debug({msg:"socket open",messageQueueLength:d(this,pn).length,connId:d(this,zt)}),T(this,B,Ka).call(this,"connected"),d(this,vt)?d(this,vt).resolve(void 0):H().warn({msg:"#onOpenPromise is undefined"});for(const t of d(this,Pn).keys())T(this,B,Rs).call(this,t,!0);const e=d(this,pn);D(this,pn,[]),H().debug({msg:"flushing message queue",queueLength:e.length});for(const t of e)T(this,B,js).call(this,t)}))},iA=async function(e){var n;H().trace({msg:"received message",dataType:typeof e,isBlob:e instanceof Blob,isArrayBuffer:e instanceof ArrayBuffer});const t=await T(this,B,lA).call(this,e);if(H().trace(ZR()?{msg:"parsed message",message:Ek(t).substring(0,100)+"..."}:{msg:"parsed message"}),t.body.tag==="Init")D(this,vn,t.body.val.actorId),D(this,zt,t.body.val.connectionId),H().trace({msg:"received init message",actorId:d(this,vn),connId:d(this,zt)}),T(this,B,rA).call(this);else if(t.body.tag==="Error"){const{group:i,code:r,message:a,metadata:o,actionId:u,actor:l}=t.body.val;if(u!==null){const c=T(this,B,kg).call(this,Number(u));T(this,B,Is).call(this,i,r),H().warn({msg:"action error",actionId:u,actionName:c==null?void 0:c.name,group:i,code:r,message:a,metadata:o,actorId:l==null?void 0:l.actorId,generation:l==null?void 0:l.generation,actorKey:l==null?void 0:l.key}),c.reject(new Se(i,r,a,{metadata:o,actor:l}))}else{if(H().warn({msg:"connection error",group:i,code:r,message:a,metadata:o,actorId:l==null?void 0:l.actorId,generation:l==null?void 0:l.generation,actorKey:l==null?void 0:l.key}),T(this,B,Ns).call(this,i,r)){T(this,B,Ds).call(this),(n=d(this,vt))==null||n.reject(new Se(i,r,a,{metadata:o,actor:l}));return}let c=new Se(i,r,a,{metadata:o,actor:l});if(wg(i,r)&&d(this,vn)){const s=await zg(i,r,d(this,vn),d(this,Yn),d(this,ni));s&&(c=s)}d(this,vt)&&d(this,vt).reject(c),T(this,B,Is).call(this,i,r);for(const[s,f]of d(this,gt).entries())f.reject(c),d(this,gt).delete(s);T(this,B,Bu).call(this,c)}}else if(t.body.tag==="ActionResponse"){const{id:i}=t.body.val;H().debug({msg:"received action response",actionId:Number(i),inFlightCount:d(this,gt).size,inFlightIds:Array.from(d(this,gt).keys())});const r=T(this,B,kg).call(this,Number(i));H().trace({msg:"resolving action promise",actionId:i,actionName:r==null?void 0:r.name}),r.resolve(t.body.val)}else t.body.tag==="Event"?(H().trace({msg:"received event",name:t.body.val.name}),T(this,B,uA).call(this,t.body.val)):Dc(t.body)},aA=async function(e){var r;const t=e,n=t.wasClean,i=d(this,Xt)==="connected";if(H().info({msg:"socket closed",code:t.code,reason:t.reason,wasClean:n,disposed:d(this,Bn),connId:d(this,zt)}),D(this,st,void 0),d(this,Bn))T(this,B,Fa).call(this,new cs,!0);else{T(this,B,Ka).call(this,"disconnected");let a;const o=t.reason||"",u=AZ(o);if(u){const{group:l,code:c}=u;if(T(this,B,Ns).call(this,l,c)){T(this,B,Ds).call(this),(r=d(this,vt))==null||r.reject(new Se(l,c,`Connection closed: ${o}`,void 0));return}if(wg(l,c)&&d(this,vn)){const s=await zg(l,c,d(this,vn),d(this,Yn),d(this,ni));s?a=s:a=new Se(l,c,`Connection closed: ${o}`,void 0)}else a=new Se(l,c,`Connection closed: ${o}`,void 0);T(this,B,Is).call(this,l,c)}else a=new Error(`${n?"Connection closed":"Connection lost"} (code: ${t.code}, reason: ${o})`);T(this,B,Fa).call(this,a,!1),a instanceof Se&&T(this,B,Bu).call(this,a),i&&(H().debug({msg:"triggering reconnect",connId:d(this,zt)}),T(this,B,Eg).call(this))}},Fa=function(e,t){d(this,vt)&&(t&&d(this,vt).promise.catch(()=>{}),d(this,vt).reject(e));for(const n of d(this,gt).values())n.reject(e);d(this,gt).clear()},oA=function(){d(this,Bn)||H().warn("socket error")},kg=function(e){const t=d(this,gt).get(e);if(!t)throw H().error({msg:"action not found in in-flight map",lookupId:e,inFlightCount:d(this,gt).size,inFlightIds:Array.from(d(this,gt).keys()),inFlightActions:Array.from(d(this,gt).entries()).map(([n,i])=>({id:n,name:i.name}))}),kZ(`No in flight response for ${e}`);return d(this,gt).delete(e),H().debug({msg:"removed action from in-flight map",actionId:e,actionName:t.name,inFlightCount:d(this,gt).size}),t},uA=function(e){const{name:t,args:n}=e,i=d(this,Pn).get(t);if(i){for(const r of[...i])r.callback(...n),r.once&&i.delete(r);i.size===0&&d(this,Pn).delete(t)}},Bu=function(e){for(const t of[...d(this,To)])try{t(e)}catch(n){H().error({msg:"error in connection error handler",error:ht(n)})}},Ag=function(e,t,n){const i={callback:t,once:n};let r=d(this,Pn).get(e);return r===void 0&&(r=new Set,d(this,Pn).set(e,r),T(this,B,Rs).call(this,e,!0)),r.add(i),()=>{const a=d(this,Pn).get(e);a&&(a.delete(i),a.size===0&&(d(this,Pn).delete(e),T(this,B,Rs).call(this,e,!1)))}},js=function(e,t){var i,r;if(d(this,Bn)){if(t!=null&&t.ephemeral)return;throw new cs}let n=!1;if(d(this,st)){const a=d(this,st).readyState;if(H().debug({msg:"websocket send attempt",readyState:a,readyStateString:a===0?"CONNECTING":a===1?"OPEN":a===2?"CLOSING":"CLOSED",connId:d(this,zt),messageType:e.body.tag,actionName:(i=e.body.val)==null?void 0:i.name}),d(this,Xt)!=="connected")H().debug({msg:"websocket init pending, queueing message",connStatus:d(this,Xt),messageType:e.body.tag}),n=!0;else if(a===1)try{const o=bk(d(this,ri),e,oZ,Nl,wZ,l=>l,l=>l.body.tag==="ActionRequest"?{body:{tag:"ActionRequest",val:{id:l.body.val.id,name:l.body.val.name,args:My(au(l.body.val.args))}}}:l);d(this,st).send(o);const u=xZ(o);H().trace({msg:"sent websocket message",len:u})}catch(o){H().warn({msg:"failed to send message, added to queue",error:o,connId:d(this,zt)}),n=!0}else H().debug({msg:"websocket not open, queueing message",readyState:a}),n=!0}else H().debug({msg:"no websocket, queueing message"}),n=!0;!(t!=null&&t.ephemeral)&&n&&(d(this,pn).push(e),H().debug({msg:"queued connection message",queueLength:d(this,pn).length,connId:d(this,zt),messageType:e.body.tag,actionName:(r=e.body.val)==null?void 0:r.name}))},lA=async function(e){iu(d(this,st),"websocket must be defined");const t=await TR(e);return Tf(d(this,ri),t,uZ,yZ,n=>n.body.tag!=="Error"||!n.body.val.actor?n:{body:{tag:"Error",val:{...n.body.val,actor:{...n.body.val.actor,generation:Number(n.body.val.actor.generation)}}}},n=>n.body.tag==="Error"?{body:{tag:"Error",val:{group:n.body.val.group,code:n.body.val.code,message:n.body.val.message,metadata:n.body.val.metadata?wi(new Uint8Array(n.body.val.metadata)):null,actionId:n.body.val.actionId,actor:n.body.val.actor?{actorId:n.body.val.actor.actorId,generation:Number(n.body.val.actor.generation),key:n.body.val.actor.key??void 0}:void 0}}}:n.body.tag==="ActionResponse"?{body:{tag:"ActionResponse",val:{id:n.body.val.id,output:wi(new Uint8Array(n.body.val.output))}}}:n.body.tag==="Event"?{body:{tag:"Event",val:{name:n.body.val.name,args:wi(new Uint8Array(n.body.val.args))}}}:n)},Rs=function(e,t){T(this,B,js).call(this,{body:{tag:"SubscriptionRequest",val:{eventName:e,subscribe:t}}},{ephemeral:!0})},L_),jo,Hl,B_,XZ=(B_=class{constructor(){R(this,jo,!1);R(this,Hl,[])}async acquire(){for(;d(this,jo);)await new Promise(e=>d(this,Hl).push(e));D(this,jo,!0)}release(){D(this,jo,!1);const e=d(this,Hl).shift();e&&e()}async run(e){await this.acquire();try{return await e()}finally{this.release()}}},jo=new WeakMap,Hl=new WeakMap,B_);async function WZ(e,t,n,i,r,a={}){let o,u=r||{};if(typeof i=="string")o=i;else if(i instanceof URL)o=i.pathname+i.search;else if(i instanceof Request){const l=new URL(i.url);o=l.pathname+l.search;const c=new Headers(i.headers),s=new Headers((r==null?void 0:r.headers)||{}),f=new Headers(c);s.forEach((m,h)=>{f.set(h,m)}),u={method:i.method,body:i.body,mode:i.mode,credentials:i.credentials,redirect:i.redirect,referrer:i.referrer,referrerPolicy:i.referrerPolicy,integrity:i.integrity,keepalive:i.keepalive,signal:i.signal,...u,headers:f},u.body&&(u.duplex="half")}else throw new TypeError("Invalid input type for fetch");try{H().debug("directId"in t?{msg:"sending raw http request to actor",actorId:t.directId}:{msg:"sending raw http request with actor query",query:t});const l=o.startsWith("/")?o.slice(1):o,c=new URL(`http://actor/request/${l}`),s=new Headers(u.headers);n&&s.set(qy,JSON.stringify(n));const f=new Request(c,{...u,headers:s});return e.sendRequest(t,f,a)}catch(l){const{group:c,code:s,message:f,metadata:m,actor:h}=As(l,!0);throw new Se(c,s,f,{metadata:m,actor:h})}}async function eL(e,t,n,i,r,a={}){const o="bare";let u="",l="";if(i){const f=i.indexOf("?");f!==-1?(u=i.substring(0,f),l=i.substring(f)):u=i,u.startsWith("/")&&(u=u.slice(1))}const c=`${xk}${u}${l}`;return H().debug({msg:"opening websocket",target:t,encoding:o,path:c}),await e.openWebSocket(c,t,o,n,a)}async function cA(e,t){if("directId"in t)return t.directId;if("getForId"in t)return t.getForId.actorId;if("getForKey"in t){const n=await e.getWithKey({name:t.getForKey.name,key:t.getForKey.key});if(!n)throw _R(`${t.getForKey.name}:${JSON.stringify(t.getForKey.key)}`);return n.actorId}if("getOrCreateForKey"in t)return(await e.getOrCreateWithKey({name:t.getOrCreateForKey.name,key:t.getOrCreateForKey.key,input:t.getOrCreateForKey.input,region:t.getOrCreateForKey.region})).actorId;if("create"in t)return(await e.createActor({name:t.create.name,key:t.create.key,input:t.create.input,region:t.create.region})).actorId;throw Iy("Invalid query format")}var Ro,Lt,Xn,ke,Wn,er,na,ra,ii,Af,F,sA,fA,dA,mA,Mn,Cs,qu,hA,Bi,Hu,Vu,xg,Gu,gA,vA,pA,q_,tL=(q_=class{constructor(e,t,n,i,r,a,o={}){R(this,F);R(this,Ro);R(this,Lt);R(this,Xn);R(this,ke);R(this,Wn);R(this,er);R(this,na);R(this,ra);R(this,ii);R(this,Af,new XZ);D(this,Ro,e),D(this,Lt,t),D(this,Xn,r),D(this,ke,a),D(this,Wn,o),D(this,er,n),D(this,na,i)}send(e,t,n){return T(this,F,fA).call(this,e,t,n)}async action(e){if(typeof e=="string"||typeof e!="object"||e===null||!("name"in e))throw new Error(`Invalid action call: expected an options object { name, args }, got ${typeof e}. Use handle.actionName(...args) for the shorthand API.`);const t=async()=>await T(this,F,dA).call(this,e);return e.name==="destroy"?await t():await PZ(t,{signal:e.signal})}connect(e,t={}){H().debug({msg:"establishing connection from handle",query:d(this,ke)});const n=e===void 0?d(this,er):e,i=e===void 0?d(this,na):void 0,r=new YZ(d(this,Ro),d(this,Lt),n,i,d(this,Xn),d(this,ke),Ga(d(this,Wn),t));return d(this,Ro)[yA](r)}fetch(e,t){return T(this,F,gA).call(this,e,t)}async webSocket(e,t,n={}){const i=await T(this,F,sA).call(this),r=Ga(d(this,Wn),n),a=yr(d(this,ke)),o=await T(this,F,Gu).call(this,a,r);return await eL(d(this,Lt),o,i,e,t,r)}async resolve(){if("getForId"in d(this,ke))return d(this,ke).getForId.actorId;const e=await T(this,F,xg).call(this,!1);if("directId"in e)return e.directId;throw new Error("dynamic actor resolution did not produce a direct actor id")}async getGatewayUrl(){return await d(this,Lt).buildGatewayUrl(qi(d(this,ke)),d(this,Wn))}async reload(){const e=qi(d(this,ke)),t=new Request("http://actor/dynamic/reload",{method:"PUT"}),n=await d(this,Lt).sendRequest(e,t);if(!n.ok){const i=await n.text().catch(()=>"");throw new Se("actor","reload_failed",`reload failed with status ${n.status}: ${i}`,{})}}},Ro=new WeakMap,Lt=new WeakMap,Xn=new WeakMap,ke=new WeakMap,Wn=new WeakMap,er=new WeakMap,na=new WeakMap,ra=new WeakMap,ii=new WeakMap,Af=new WeakMap,F=new WeakSet,sA=async function(){return d(this,na)?await d(this,na).call(this):d(this,er)},fA=async function(e,t,n){return await d(this,Af).run(async()=>{const i=T(this,F,Cs).call(this);let r=!1;for(let a=0;a<i;a++){let o;try{const u=Ga(d(this,Wn)),l=await T(this,F,Gu).call(this,r,u);return o="directId"in l?l.directId:void 0,await Yk({encoding:d(this,Xn),params:d(this,er),customFetch:async c=>await d(this,Lt).sendRequest(l,c,u)}).send(e,t,n)}catch(u){const{group:l,code:c,message:s,metadata:f,actor:m}=As(u,!0);if(T(this,F,hA).call(this,l,c,f,a,i)){await T(this,F,Mn).call(this);continue}if(await T(this,F,Hu).call(this,l,c,o,a,i)){r=!0,await T(this,F,Mn).call(this);continue}if(T(this,F,qu).call(this,l,c,a,i)){T(this,F,Bi).call(this),r=!0,await T(this,F,Mn).call(this);continue}if(T(this,F,Vu).call(this,l,c)&&a<i-1){r=c==="starting"||c==="stopping"||c.startsWith("destroyed_"),r&&await T(this,F,Mn).call(this);continue}throw new Se(l,c,s,{metadata:f,actor:m})}}throw new Error("unreachable queue retry state")})},dA=async function(e){const t=T(this,F,Cs).call(this);let n=!1;const i=Ga(d(this,Wn),e);for(let r=0;r<t;r++){let a;try{const o=await T(this,F,Gu).call(this,n,i);a="directId"in o?o.directId:void 0,H().debug(a?{msg:"using direct actor gateway target",actorId:a}:{msg:"using query gateway target for action",query:d(this,ke)}),H().debug({msg:"handling action",name:e.name,encoding:d(this,Xn)});const u=await Qy({url:`http://actor/action/${encodeURIComponent(e.name)}`,method:"POST",headers:{[Uk]:d(this,Xn),...d(this,er)!==void 0?{[qy]:JSON.stringify(d(this,er))}:{}},body:e.args,encoding:d(this,Xn),customFetch:async l=>await d(this,Lt).sendRequest(o,l,i),signal:e==null?void 0:e.signal,requestVersion:Nl,requestVersionedDataHandler:lZ,responseVersion:Nl,responseVersionedDataHandler:cZ,requestZodSchema:$Z,responseZodSchema:zZ,requestToJson:l=>({args:l}),requestToBare:l=>({args:My(au(l))}),responseFromJson:l=>l.output,responseFromBare:l=>wi(new Uint8Array(l.output))});return e.name==="destroy"&&a&&await T(this,F,mA).call(this,a),u}catch(o){const{group:u,code:l,message:c,metadata:s,actor:f}=As(o,!0);if(await T(this,F,Hu).call(this,u,l,a,r,t)){n=!0,await T(this,F,Mn).call(this);continue}if(e.name!=="destroy"&&T(this,F,qu).call(this,u,l,r,t)){T(this,F,Bi).call(this),n=!0,await T(this,F,Mn).call(this);continue}if(u==="actor"&&l==="destroyed_while_waiting_for_ready"&&"getForId"in d(this,ke))throw new Se("actor","not_found","The actor does not exist or was destroyed.",{metadata:s,actor:f});if(T(this,F,Vu).call(this,u,l)&&r<t-1){u==="actor"&&(l==="starting"||l==="stopping")&&(n=!0,await new Promise(h=>setTimeout(h,100)));continue}throw new Se(u,l,c,{metadata:s,actor:f})}}throw new Error("unreachable action retry state")},mA=async function(e){const t=Qk(d(this,ke)),n=Date.now()+1e3;for(;Date.now()<n;){if(!await d(this,Lt).getForId({name:t,actorId:e}))return;await new Promise(r=>setTimeout(r,25))}},Mn=async function(){await new Promise(e=>setTimeout(e,100))},Cs=function(){return yr(d(this,ke))?"getOrCreateForKey"in d(this,ke)?60:24:1},qu=function(e,t,n,i){return!yr(d(this,ke))||n>=i-1||e!=="actor"?!1:t==="not_found"||t==="starting"||t==="stopping"||t==="not_configured"||t==="dropped_reply"||t==="destroying"||t.startsWith("destroyed_")},hA=function(e,t,n,i,r){if(!yr(d(this,ke))||i>=r-1||e!=="actor"||t!=="overloaded"||n===null||typeof n!="object")return!1;const a=n;return a.channel==="dispatch_inbox"&&a.operation==="dispatch_queue_send"},Bi=function(){D(this,ra,void 0),D(this,ii,void 0)},Hu=async function(e,t,n,i,r){if(!yr(d(this,ke))||!wg(e,t)||i>=r-1)return!1;if(n){const a=await zg(e,t,n,d(this,ke),d(this,Lt));if(a)throw a}return T(this,F,Bi).call(this),!0},Vu=function(e,t){return!yr(d(this,ke))||!$g(e,t)?!1:(T(this,F,Bi).call(this),!0)},xg=async function(e){if("getForId"in d(this,ke))return qi(d(this,ke));if(e)return qi(d(this,ke));if(d(this,ra))return{directId:d(this,ra)};d(this,ii)||D(this,ii,cA(d(this,Lt),d(this,ke)).then(t=>(D(this,ra,t),t)));try{return{directId:await d(this,ii)}}finally{D(this,ii,void 0)}},Gu=async function(e,t){return t.skipReadyWait?qi(d(this,ke)):await T(this,F,xg).call(this,e)},gA=async function(e,t){const n=T(this,F,Cs).call(this);let i=!1;const{skipReadyWait:r,...a}=t??{},o=Ga(d(this,Wn),{skipReadyWait:r});for(let u=0;u<n;u++){let l;try{const c=await T(this,F,Gu).call(this,i,o);l="directId"in c?c.directId:void 0;const s=await WZ(d(this,Lt),c,d(this,er),e,a,o),f=await T(this,F,vA).call(this,s,l,u,n);if(f){i=f.useQueryTarget,f.waitForRetryWindow&&await T(this,F,Mn).call(this);continue}return s}catch(c){const{group:s,code:f,message:m,metadata:h,actor:_}=As(c,!0);if(await T(this,F,Hu).call(this,s,f,l,u,n)){i=!0,await T(this,F,Mn).call(this);continue}if(T(this,F,qu).call(this,s,f,u,n)){T(this,F,Bi).call(this),i=!0,await T(this,F,Mn).call(this);continue}if(T(this,F,Vu).call(this,s,f)&&u<n-1){i=f==="starting"||f==="stopping"||f.startsWith("destroyed_"),i&&await T(this,F,Mn).call(this);continue}throw new Se(s,f,m,{metadata:h,actor:_})}}throw new Error("unreachable fetch retry state")},vA=async function(e,t,n,i){if(e.ok||!yr(d(this,ke)))return null;const r=await T(this,F,pA).call(this,e);if(!r)return null;const{group:a,code:o}=r;if(await T(this,F,Hu).call(this,a,o,t,n,i))return{useQueryTarget:!0,waitForRetryWindow:!0};if(T(this,F,qu).call(this,a,o,n,i))return T(this,F,Bi).call(this),{useQueryTarget:!0,waitForRetryWindow:!0};if(T(this,F,Vu).call(this,a,o)&&n<i-1){const l=o==="starting"||o==="stopping"||o.startsWith("destroyed_");return{useQueryTarget:l,waitForRetryWindow:l}}return null},pA=async function(e){if(e.ok)return null;const t=e.headers.get("content-type"),n=t!=null&&t.includes("application/json")?"json":d(this,Xn);try{return Tf(n,new Uint8Array(await e.clone().arrayBuffer()),Vk,Kk,i=>({...i,actor:i.actor?{...i.actor,generation:Number(i.actor.generation)}:void 0}),i=>({group:i.group,code:i.code,message:i.message,metadata:i.metadata?wi(new Uint8Array(i.metadata)):void 0,actor:i.actor?{actorId:i.actor.actorId,generation:Number(i.actor.generation),key:i.actor.key??void 0}:void 0}))}catch{return null}},q_),Ms=Symbol("actorConns"),yA=Symbol("createActorConnProxy"),H_,Vl,Co,Gl,Kl,ia,Ku,V_,nL=(V_=class{constructor(e,t,n={}){R(this,ia);R(this,Vl,!1);jt(this,H_,new Set);R(this,Co);R(this,Gl);R(this,Kl);D(this,Co,e),D(this,Gl,t??"bare"),D(this,Kl,n)}getForId(e,t,n){H().debug({msg:"get handle to actor with id",name:e,actorId:t,params:n==null?void 0:n.params});const i={getForId:{name:e,actorId:t}},r=T(this,ia,Ku).call(this,n==null?void 0:n.params,n==null?void 0:n.getParams,i);return Uu(r)}get(e,t,n){const i=typeof t=="string"?[t]:t||[];H().debug({msg:"get handle to actor",name:e,key:i,parameters:n==null?void 0:n.params});const r={getForKey:{name:e,key:i}},a=T(this,ia,Ku).call(this,n==null?void 0:n.params,n==null?void 0:n.getParams,r);return Uu(a)}getOrCreate(e,t,n){const i=typeof t=="string"?[t]:t||[];H().debug({msg:"get or create handle to actor",name:e,key:i,parameters:n==null?void 0:n.params,createInRegion:n==null?void 0:n.createInRegion});const r={getOrCreateForKey:{name:e,key:i,input:n==null?void 0:n.createWithInput,region:n==null?void 0:n.createInRegion}},a=T(this,ia,Ku).call(this,n==null?void 0:n.params,n==null?void 0:n.getParams,r);return Uu(a)}async create(e,t,n){const i=typeof t=="string"?[t]:t||[],r={create:{...n,name:e,key:i}};H().debug({msg:"create actor handle",name:e,key:i,parameters:n==null?void 0:n.params,create:r.create});const a=await cA(d(this,Co),r);H().debug({msg:"created actor with ID",name:e,key:i,actorId:a});const o={getForId:{name:e,actorId:a}},u=T(this,ia,Ku).call(this,n==null?void 0:n.params,n==null?void 0:n.getParams,o);return Uu(u)}[(H_=Ms,yA)](e){return this[Ms].add(e),e[Xk](),Uu(e)}async dispose(){if(d(this,Vl)){H().warn({msg:"client already disconnected"});return}D(this,Vl,!0),H().debug({msg:"disposing client"});const e=[];for(const t of this[Ms].values())e.push(t.dispose());await Promise.all(e)}},Vl=new WeakMap,Co=new WeakMap,Gl=new WeakMap,Kl=new WeakMap,ia=new WeakSet,Ku=function(e,t,n){return new tL(this,d(this,Co),e,t,d(this,Gl),n,d(this,Kl))},V_);function rL(e,t={}){const n=new nL(e,t.encoding,t.gateway);return new Proxy(n,{get:(i,r,a)=>{if(typeof r=="symbol"||r in i){const o=Reflect.get(i,r,a);return typeof o=="function"?o.bind(i):o}if(typeof r=="string")return{get:(o,u)=>i.get(r,o,u),getOrCreate:(o,u)=>i.getOrCreate(r,o,u),getForId:(o,u)=>i.getForId(r,o,u),create:async(o,u={})=>await i.create(r,o,u)}}})}function Uu(e){const t=new Map;return new Proxy(e,{get(n,i,r){if(typeof i=="symbol")return Reflect.get(n,i,r);if(i==="constructor"||i in n){const a=Reflect.get(n,i,n);return typeof a=="function"?a.bind(n):a}if(typeof i=="string"){if(i==="then")return;let a=t.get(i);return a||(a=(...o)=>n.action({name:i,args:o}),t.set(i,a)),a}},has(n,i){return typeof i=="string"?!0:Reflect.has(n,i)},getPrototypeOf(n){return Reflect.getPrototypeOf(n)},ownKeys(n){return Reflect.ownKeys(n)},getOwnPropertyDescriptor(n,i){const r=Reflect.getOwnPropertyDescriptor(n,i);if(r)return r;if(typeof i=="string")return{configurable:!0,enumerable:!1,writable:!1,value:(...a)=>n.action({name:i,args:a})}}})}function iL(e){const t=e===void 0?{}:typeof e=="string"?{endpoint:e}:e,n=b3.parse(t),i=new LZ(n);return n.devtools&&e3(n),rL(i,n)}function aL(e,t={}){const{getOrCreateActor:n}=cU(e,t);function i(r){const{mount:a,state:o}=n(r);return Ge.useEffect(()=>a(),[a]),{...I0(o),useEvent:(c,s)=>{const f=Ge.useRef(s),m=I0(o);Ge.useEffect(()=>{f.current=s},[s]),Ge.useEffect(()=>{const h=m.connection;if(!h)return;function _(...S){f.current(...S)}return h.on(c,_)},[m.connection,m.connStatus,m.hash,c])}}}return{useActor:i}}function oL(e){const t=iL({endpoint:window.location.origin,token:e,encoding:"json",disableMetadataLookup:!0});return{client:t,...aL(t)}}const bA=Ge.createContext(null);function uL({actorId:e,authToken:t,children:n}){const i=Ge.useMemo(()=>{const r=oL(t);return W2(r.client,e),{bundle:r,actorId:e}},[e,t]);return nt.jsx(bA.Provider,{value:i,children:n})}function SL(){const e=Ge.useContext(bA);if(!e)throw new Error("useAgentOsActor must be used within <RivetProvider>");return e.bundle.useActor({name:n1,id:e.actorId})}function lL(){return nt.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-8 text-sm text-muted-foreground",children:nt.jsxs("span",{className:"inline-flex items-center gap-2",children:[nt.jsxs("svg",{className:"size-4 animate-spin text-muted-foreground",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[nt.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),nt.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M12 2a10 10 0 0 1 10 10h-3a7 7 0 0 0-7-7z"})]}),"Loading…"]})})}class cL extends Ge.Component{constructor(){super(...arguments);jt(this,"state",{})}static getDerivedStateFromError(n){return{error:n}}render(){return this.state.error?nt.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-8 text-center text-sm text-destructive",children:this.state.error.message||"Failed to load."}):this.props.children}}function sL({children:e}){return nt.jsx(cL,{children:nt.jsx(Ge.Suspense,{fallback:nt.jsx(lL,{}),children:e})})}const fL={software:()=>_u(()=>import("./software-2sjLheLb.js"),__vite__mapDeps([0,1,2,3]),import.meta.url).then(e=>({default:e.SoftwareTabConnected})),processes:()=>_u(()=>import("./processes-CjHQ_o8t.js"),__vite__mapDeps([4,1,2]),import.meta.url).then(e=>({default:e.ProcessesTabConnected})),filesystem:()=>_u(()=>import("./filesystem-DbXxNt-B.js"),__vite__mapDeps([5,2]),import.meta.url).then(e=>({default:e.FilesystemTabConnected})),mounts:()=>_u(()=>import("./mounts-BlNRslup.js"),__vite__mapDeps([6,1,2,3]),import.meta.url).then(e=>({default:e.MountsTabConnected})),transcript:()=>_u(()=>import("./transcript-Cz9DrFWK.js"),__vite__mapDeps([7,1,2]),import.meta.url).then(e=>({default:e.TranscriptTabConnected}))},dL=new t6({defaultOptions:{queries:{retry:3,retryDelay:e=>Math.min(1500*2**e,8e3),refetchOnWindowFocus:!1,staleTime:5e3}}});function mL(){const[e,t]=Ge.useState();Ge.useEffect(()=>{parent.postMessage({type:"ready",v:1},"*");const a=o=>{const u=o.data||{};u.type==="init"&&u.actorId&&u.authToken&&t({actorId:u.actorId,authToken:u.authToken})};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[]);const n=eU(),i=n?fL[n]:void 0;if(!i)return nt.jsxs("div",{style:{padding:16},children:["Unknown inspector tab: ",String(n)]});if(!e)return nt.jsx("div",{style:{padding:16,color:"#8a8a90"},children:"Connecting…"});const r=Ge.lazy(i);return nt.jsx(uL,{actorId:e.actorId,authToken:e.authToken,children:nt.jsx(sL,{children:nt.jsx(r,{actorId:e.actorId})})})}X2.createRoot(document.getElementById("root")).render(nt.jsx(Ge.StrictMode,{children:nt.jsx(b6,{client:dL,children:nt.jsx(mL,{})})}));export{pL as R,Df as S,jA as a,Jm as b,Qm as c,PA as d,P_ as e,F_ as f,MA as g,Dt as h,IA as i,nt as j,vL as k,yL as l,bL as m,Zn as n,qA as p,Ge as r,gL as s,NA as t,SL as u};
|
|
125
|
+
${m}`)}}if(!e.skipParseResponse)try{const u=new Uint8Array(await i.arrayBuffer());return Tf(e.encoding,u,e.responseVersionedDataHandler,e.responseZodSchema,e.responseFromJson,e.responseFromBare)}catch(u){throw new Zu(`Failed to parse response: ${u}`,{cause:u})}}function kf(e){return e.endpoint??"http://127.0.0.1:6420"}async function Ia(e,t,n,i){const r=kf(e),a=Il(r,n,{namespace:e.namespace});pe().debug({msg:"making api call",method:t,url:a});const o={...e.headers};return e.token&&(o.Authorization=`Bearer ${e.token}`),await Qy({method:t,url:a,headers:o,body:i,encoding:"json",skipParseResponse:!1,requestVersionedDataHandler:void 0,requestVersion:void 0,responseVersionedDataHandler:void 0,responseVersion:void 0,requestZodSchema:$f(),responseZodSchema:$f(),requestToJson:u=>u,requestToBare:u=>u,responseFromJson:u=>u,responseFromBare:u=>u})}async function UZ(e,t,n){return Ia(e,"GET",`/actors?actor_ids=${encodeURIComponent(n)}`)}async function DZ(e,t,n){const i=_g(n);return Ia(e,"GET",`/actors?name=${encodeURIComponent(t)}&key=${encodeURIComponent(i)}`)}async function IZ(e,t){return Ia(e,"GET",`/actors?name=${encodeURIComponent(t)}`)}async function NZ(e,t){return Ia(e,"PUT","/actors",t)}async function jZ(e,t){return Ia(e,"POST","/actors",t)}async function RZ(e,t){return Ia(e,"DELETE",`/actors/${encodeURIComponent(t)}`)}async function CZ(e){return Ia(e,"GET","/metadata")}var O_=new Map;async function MZ(e){const t=kf(e),n=O_.get(t);if(n)return n;const i=pk(async()=>{pe().debug({msg:"fetching metadata",endpoint:t});const r=await CZ(e);return pe().debug({msg:"received metadata",endpoint:t,clientEndpoint:r.clientEndpoint}),r},{forever:!0,minTimeout:500,maxTimeout:15e3,onFailedAttempt:r=>{r.attemptNumber>1&&pe().warn({msg:"failed to fetch metadata, retrying",endpoint:t,attempt:r.attemptNumber,error:ht(r)})}});return O_.set(t,i),i}async function ZZ(e,t,n){const i=await Ik(),r={};return{onOpen:async(a,o)=>{if(pe().debug({msg:"client websocket connected",targetUrl:t}),o.readyState!==1){pe().warn({msg:"client websocket not open on connection",targetUrl:t,readyState:o.readyState});return}const u=new i(t,n);r.targetWs=u,r.connectPromise=new Promise((l,c)=>{u.addEventListener("open",()=>{if(pe().debug({msg:"target websocket connected",targetUrl:t}),o.readyState!==1){pe().warn({msg:"client websocket closed before target connected",targetUrl:t,clientReadyState:o.readyState}),u.close(1001,"Client disconnected"),c(new Error("Client disconnected"));return}l()}),u.addEventListener("error",s=>{pe().warn({msg:"target websocket error during connection",targetUrl:t}),c(s)})}),r.connectPromise.catch(()=>{}),r.targetWs.addEventListener("message",l=>{typeof l.data=="string"||l.data instanceof ArrayBuffer?o.send(l.data):l.data instanceof Blob&&l.data.arrayBuffer().then(c=>{o.send(c)})}),r.targetWs.addEventListener("close",l=>{pe().debug({msg:"target websocket closed",targetUrl:t,code:l.code,reason:l.reason}),Km(o,l.code,l.reason)}),r.targetWs.addEventListener("error",l=>{pe().error({msg:"target websocket error",targetUrl:t,error:ht(l)}),Km(o,1011,"Target WebSocket error")})},onMessage:async(a,o)=>{if(!r.targetWs||!r.connectPromise){pe().error({msg:"websocket state not initialized",targetUrl:t});return}try{await r.connectPromise,r.targetWs.readyState===i.OPEN?r.targetWs.send(a.data):pe().warn({msg:"target websocket not open",targetUrl:t,readyState:r.targetWs.readyState})}catch(u){pe().error({msg:"failed to connect to target websocket",targetUrl:t,error:u}),Km(o,1011,"Failed to connect to target")}},onClose:(a,o)=>{pe().debug({msg:"client websocket closed",targetUrl:t,code:a.code,reason:a.reason,wasClean:a.wasClean}),r.targetWs&&(r.targetWs.readyState===i.OPEN||r.targetWs.readyState===i.CONNECTING)&&r.targetWs.close(1e3,a.reason||"Client disconnected")},onError:(a,o)=>{pe().error({msg:"client websocket error",targetUrl:t,event:a}),r.targetWs&&(r.targetWs.readyState===i.OPEN?r.targetWs.close(1011,"Client WebSocket error"):r.targetWs.readyState===i.CONNECTING&&r.targetWs.close())}}}function Km(e,t,n){(e.readyState===1||"close"in e&&e.readyState===WebSocket.OPEN)&&e.close(t,n)}var _e,At,ea,Lu,Z_,LZ=(Z_=class{constructor(e){R(this,ea);R(this,_e);R(this,At);BR()==="phase-production-build"&&(pe().info("detected next.js build phase, disabling health check"),e.disableMetadataLookup=!0),D(this,_e,{...e}),e.disableMetadataLookup||D(this,At,MZ(d(this,_e)).then(t=>{t.clientEndpoint&&(d(this,_e).endpoint=t.clientEndpoint,t.clientNamespace&&(d(this,_e).namespace=t.clientNamespace),t.clientToken&&(d(this,_e).token=t.clientToken),pe().info({msg:"overriding client endpoint",endpoint:t.clientEndpoint,namespace:t.clientNamespace,token:t.clientToken})),pe().info({msg:"connected to rivetkit runtime",runtime:t.runtime,version:t.version,envoy:t.envoy})}))}async getForId({name:e,actorId:t}){await d(this,At);const i=(await UZ(d(this,_e),e,t)).actors[0];if(i){if(i.name!==e){pe().debug({msg:"actor name mismatch from api",actorId:t,apiName:i.name,requestedName:e});return}return xu(i)}}async getWithKey({name:e,key:t}){await d(this,At),pe().debug({msg:"getWithKey: searching for actor",name:e,key:t});try{const i=(await DZ(d(this,_e),e,t)).actors[0];return i?(pe().debug({msg:"getWithKey: found actor via api",actorId:i.actor_id,name:e,key:t}),xu(i)):void 0}catch(n){if(n instanceof Se&&n.group==="actor"&&n.code==="not_found")return;throw n}}async getOrCreateWithKey(e){await d(this,At);const{name:t,key:n,input:i,region:r,crashPolicy:a}=e;pe().info({msg:"getOrCreateWithKey: getting or creating actor via engine api",name:t,key:n});const{actor:o,created:u}=await NZ(d(this,_e),{datacenter:r,name:t,key:_g(n),runner_name_selector:d(this,_e).poolName,input:i?vg(au(i)):void 0,crash_policy:a??"sleep"});return pe().info({msg:"getOrCreateWithKey: actor ready",actorId:o.actor_id,name:t,key:n,created:u}),xu(o)}async createActor({name:e,key:t,input:n,region:i,crashPolicy:r}){await d(this,At),pe().info({msg:"creating actor via engine api",name:e,key:t});const a=await jZ(d(this,_e),{datacenter:i,name:e,runner_name_selector:d(this,_e).poolName,key:_g(t),input:n?vg(au(n)):void 0,crash_policy:r??"sleep"});return pe().info({msg:"actor created",actorId:a.actor.actor_id,name:e,key:t}),xu(a.actor)}async listActors({name:e}){return await d(this,At),pe().debug({msg:"listing actors via engine api",name:e}),(await IZ(d(this,_e),e)).actors.map(xu)}async destroyActor(e){await d(this,At),pe().info({msg:"destroying actor via engine api",actorId:e}),await RZ(d(this,_e),e),pe().info({msg:"actor destroyed",actorId:e})}async sendRequest(e,t,n={}){await d(this,At);const i=k_(t),r=T(this,ea,Lu).call(this,e,i,n),a={...n,directActorId:po(n)?Fm(e):void 0};return __(d(this,_e),r,t,a)}async openWebSocket(e,t,n,i,r={}){await d(this,At);const a=T(this,ea,Lu).call(this,t,e,r);return T3(d(this,_e),a,n,i,{...r,directActorId:po(r)?Fm(t):void 0})}async buildGatewayUrl(e,t={}){return await d(this,At),T(this,ea,Lu).call(this,e,"",t)}async proxyRequest(e,t,n){await d(this,At);const i=T(this,ea,Lu).call(this,{directId:n},k_(t));return __(d(this,_e),i,t)}async proxyWebSocket(e,t,n,i,r){var f,m;await d(this,At);const a=(m=(f=d(this,_e)).getUpgradeWebSocket)==null?void 0:m.call(f);iu(a,"missing getUpgradeWebSocket");const o=kf(d(this,_e)),u=Il(o,t),l=u.replace("http://","ws://");pe().debug({msg:"forwarding websocket to actor via guard",actorId:n,path:t,guardUrl:u});const c=jk(d(this,_e),i,r,void 0,{target:"actor",actorId:n}),s=await ZZ(e,l,c);return await a(()=>s)(e,wR())}displayInformation(){return{properties:{}}}setGetUpgradeWebSocket(e){d(this,_e).getUpgradeWebSocket=e}},_e=new WeakMap,At=new WeakMap,ea=new WeakSet,Lu=function(e,t,n={}){const i=kf(d(this,_e));if(po(n)&&Fm(e)&&BZ(t))return Il(i,t);if("directId"in e)return z_(i,e.directId,d(this,_e).token,t);if("getForId"in e)return z_(i,e.getForId.actorId,d(this,_e).token,t);if("getForKey"in e||"getOrCreateForKey"in e)return z3(i,d(this,_e).namespace,e,d(this,_e).token,t,d(this,_e).maxInputSize,void 0,"getOrCreateForKey"in e?d(this,_e).poolName:void 0,n);throw"create"in e?new Error("Gateway URLs only support direct actor IDs, get, and getOrCreate targets."):new Error("unreachable: unknown gateway target type")},Z_);function BZ(e){return qZ(e)||T_(e,Ak)||T_(e,n3)||e.startsWith(xk)}function T_(e,t){return e===t||e.startsWith(`${t}?`)}function qZ(e){const t=e.slice(8);return e.startsWith("/request")&&(t.length===0||t.startsWith("/")||t.startsWith("?"))}function Fm(e){if("directId"in e)return e.directId;if("getForId"in e)return e.getForId.actorId}function k_(e){const t=new URL(e.url);return`${t.pathname}${t.search}`}function xu(e){return{actorId:e.actor_id,name:e.name,key:t3(e.key),createTs:e.create_ts,startTs:e.start_ts??null,connectableTs:e.connectable_ts??null,sleepTs:e.sleep_ts??null,destroyTs:e.destroy_ts??null,error:e.error??void 0}}function Ga(e={},t){return{skipReadyWait:(t==null?void 0:t.skipReadyWait)??e.skipReadyWait??!1}}function Qk(e){if("getForId"in e)return e.getForId.name;if("getForKey"in e)return e.getForKey.name;if("getOrCreateForKey"in e)return e.getOrCreateForKey.name;if("create"in e)return e.create.name;throw Iy("Invalid query format")}function yr(e){return"getForKey"in e||"getOrCreateForKey"in e}function qi(e){if("getForId"in e)return{directId:e.getForId.actorId};if("create"in e)throw Iy("create queries cannot be used as gateway targets. Resolve to an actor ID first.");return e}function $g(e,t){return e==="actor"&&(t==="not_found"||t==="starting"||t==="stopping"||t==="not_configured"||t==="dropped_reply"||t.startsWith("destroyed_"))}async function zg(e,t,n,i,r){const a=Qk(i);try{const o=await r.getForId({name:a,actorId:n});if(o!=null&&o.error)return H().info({msg:"found actor scheduling error",actorId:n,error:o.error}),TZ(e,t,n,o.error)}catch(o){H().warn({msg:"failed to fetch actor details for scheduling error check",actorId:n,error:ht(o)})}return null}function*HZ(e,t=8){let n=e,i=0;for(;n!=null&&i<t;){if(yield n,typeof n=="object"&&"cause"in n&&n.cause!==n){n=n.cause,i+=1;continue}break}}function Hr(e,t,n,i){return{kind:e,source:t,group:i==null?void 0:i.group,code:i==null?void 0:i.code,message:n,legacy:(i==null?void 0:i.legacy)??!1}}function VZ(e){if(!(e.group==="actor"&&e.code==="stopping"&&e.message.includes("database accessed after actor stopped"))){if(e.group==="actor"&&e.code==="restarting")return Hr("request_retry","actor_error",e.message,{group:e.group,code:e.code});if(e.group==="guard"&&GZ(e.code))return Hr("request_retry","actor_error",e.message,{group:e.group,code:e.code});if(e.group==="actor"&&e.code==="internal_error"&&e.message==="Actor is stopping")return Hr("request_retry","actor_error",e.message,{group:e.group,code:e.code,legacy:!0});if(e.group==="actor"&&e.code==="stopping"&&e.message==="Actor stopping: Cannot accept new connections while actor is stopping")return Hr("request_retry","actor_error",e.message,{group:e.group,code:e.code,legacy:!0});if(e.group==="actor"&&e.code==="stopped")return Hr("reconnect_only","actor_error",e.message,{group:e.group,code:e.code,legacy:!0});if(e.group==="ws"&&e.code==="going_away")return Hr("reconnect_only","actor_error",e.message,{group:e.group,code:e.code,legacy:!0})}}function GZ(e){return e==="service_unavailable"||e==="actor_wake_retries_exceeded"||e==="actor_stopped_while_waiting"||e==="tunnel_request_aborted"||e==="tunnel_message_timeout"||e==="tunnel_response_closed"||e==="gateway_response_start_timeout"}function KZ(e){if(!e.message.includes("database accessed after actor stopped")){if(/^Actor [A-Za-z0-9-]+ stopped$/.test(e.message))return Hr("request_retry","transport_error",e.message,{legacy:!0});if(e.message==="WebSocket connection closed during shutdown"||e.message==="envoy shut down"||e.message==="envoy shutting down")return Hr("reconnect_only","transport_error",e.message,{legacy:!0})}}function Jk(e){for(const t of HZ(e)){if(t instanceof Se){const n=VZ(t);if(n)return n;continue}if(t instanceof Zu||t instanceof Error){const n=KZ(t);if(n)return n}}}function FZ(e){var t;return((t=Jk(e))==null?void 0:t.kind)==="request_retry"}function QZ(e){const t=Jk(e);return(t==null?void 0:t.kind)==="reconnect_only"||(t==null?void 0:t.kind)==="request_retry"}function Pk(e){if(e!=null&&e.aborted)throw e.reason??new Error("Operation aborted")}async function JZ(e,t){Pk(t),await new Promise((n,i)=>{const r=setTimeout(()=>{o(),n()},e),a=()=>{clearTimeout(r),o(),i((t==null?void 0:t.reason)??new Error("Operation aborted"))},o=()=>{t==null||t.removeEventListener("abort",a)};t==null||t.addEventListener("abort",a,{once:!0})})}async function PZ(e,t){const n=(t==null?void 0:t.maxAttempts)??5,i=(t==null?void 0:t.initialDelayMs)??25,r=(t==null?void 0:t.maxDelayMs)??200;let a;for(let o=0;o<n;o+=1){Pk(t==null?void 0:t.signal);try{return await e()}catch(u){if(!FZ(u))throw u;if(a=u,o===n-1)break;const l=Math.min(i*2**o,r);await JZ(l,t==null?void 0:t.signal)}}throw a}function Yk(e){async function t(n,i,r){const a=(r==null?void 0:r.wait)??!1,o=r==null?void 0:r.timeout,u=await Qy({url:`http://actor/queue/${encodeURIComponent(n)}`,method:"POST",headers:{[Uk]:e.encoding,...e.params!==void 0?{[qy]:JSON.stringify(e.params)}:{}},body:{body:i,wait:a,timeout:o},encoding:e.encoding,customFetch:e.customFetch,signal:r==null?void 0:r.signal,requestVersion:Nl,requestVersionedDataHandler:sZ,responseVersion:Nl,responseVersionedDataHandler:fZ,requestZodSchema:EZ,responseZodSchema:OZ,requestToJson:l=>({...l,name:n}),requestToBare:l=>({name:l.name??n,body:My(au(l.body)),wait:l.wait??!1,timeout:l.timeout!==void 0?BigInt(l.timeout):null}),responseFromJson:l=>l.response===void 0?{status:l.status}:{status:l.status,response:l.response},responseFromBare:l=>l.response===null||l.response===void 0?{status:l.status}:{status:l.status,response:wi(new Uint8Array(l.response))}});if(a)return u}return{send:t}}var Xk=Symbol("connect"),Bn,Ml,Xt,vn,zt,pn,gt,Pn,To,ta,ko,Ao,xo,Zl,Ll,Uo,Bl,vt,st,ql,ni,Do,Io,ri,Yn,No,B,Ds,Is,Ns,Wk,Ka,Eg,eA,Og,Tg,tA,nA,rA,iA,aA,Fa,oA,kg,uA,Bu,Ag,js,lA,Rs,L_,YZ=(L_=class{constructor(e,t,n,i,r,a,o={}){R(this,B);R(this,Bn,!1);R(this,Ml,new AbortController);R(this,Xt,"idle");R(this,vn);R(this,zt);R(this,pn,[]);R(this,gt,new Map);R(this,Pn,new Map);R(this,To,new Set);R(this,ta,new Set);R(this,ko,!1);R(this,Ao,new Set);R(this,xo,new Set);R(this,Zl,0);R(this,Ll);R(this,Uo);R(this,Bl);R(this,vt);R(this,st);R(this,ql);R(this,ni);R(this,Do);R(this,Io);R(this,ri);R(this,Yn);R(this,No);D(this,ql,e),D(this,ni,t),D(this,Do,n),D(this,Io,i),D(this,ri,r),D(this,Yn,a),D(this,No,Ga(o)),"getForId"in a&&D(this,vn,a.getForId.actorId),D(this,Uo,us(u=>H().warn({msg:"unhandled ready promise rejection",reason:u}))),D(this,Ll,Yk({encoding:d(this,ri),params:d(this,Do),customFetch:async u=>await d(this,ni).sendRequest(qi(d(this,Yn)),u,d(this,No))})),D(this,Bl,setInterval(()=>6e4))}send(e,t,n){return T(this,B,Wk).call(this,e,t,n)}async action(e){if(typeof e=="string"||typeof e!="object"||e===null||!("name"in e))throw new Error(`Invalid action call: expected an options object { name, args }, got ${typeof e}. Use conn.actionName(...args) for the shorthand API.`);H().debug({msg:"action",name:e.name,args:e.args});const t=d(this,Zl);D(this,Zl,d(this,Zl)+1);const{promise:n,resolve:i,reject:r}=us(u=>H().warn({msg:"unhandled action promise rejection",reason:u}));d(this,gt).set(t,{name:e.name,resolve:i,reject:r}),H().debug({msg:"added action to in-flight map",actionId:t,actionName:e.name,inFlightCount:d(this,gt).size}),T(this,B,js).call(this,{body:{tag:"ActionRequest",val:{id:BigInt(t),name:e.name,args:e.args}}});const{id:a,output:o}=await n;if(a!==BigInt(t))throw new Error(`Request ID ${t} does not match response ID ${a}`);return o}[Xk](){T(this,B,Eg).call(this)}on(e,t){return T(this,B,Ag).call(this,e,t,!1)}once(e,t){return T(this,B,Ag).call(this,e,t,!0)}onError(e){return d(this,To).add(e),()=>{d(this,To).delete(e)}}get connStatus(){return d(this,Xt)}get isConnected(){return d(this,Xt)==="connected"}get ready(){return d(this,Uo).promise}onOpen(e){return d(this,ta).add(e),d(this,Xt)==="connected"&&queueMicrotask(()=>{if(d(this,ta).has(e))try{e()}catch(t){H().error({msg:"error in open handler",error:ht(t)})}}),()=>{d(this,ta).delete(e)}}onClose(e){return d(this,Ao).add(e),()=>{d(this,Ao).delete(e)}}onStatusChange(e){return d(this,xo).add(e),()=>{d(this,xo).delete(e)}}get actorId(){return d(this,vn)}get connId(){return d(this,zt)}get connectionId(){return d(this,zt)}async dispose(){if(d(this,Bn)){H().warn({msg:"connection already disconnected"});return}if(D(this,Bn,!0),H().debug({msg:"disposing actor conn"}),T(this,B,Ka).call(this,"idle"),clearInterval(d(this,Bl)),d(this,Ml).abort(),d(this,ql)[Ms].delete(this),d(this,st)){const e=d(this,st);if(e.readyState!==2&&e.readyState!==3){const{promise:t,resolve:n}=us(i=>H().warn({msg:"unhandled websocket close promise rejection",reason:i}));e.addEventListener("close",()=>n(void 0)),e.close(1e3,"Disposed"),await t}}else T(this,B,Fa).call(this,new cs,!0);D(this,st,void 0)}},Bn=new WeakMap,Ml=new WeakMap,Xt=new WeakMap,vn=new WeakMap,zt=new WeakMap,pn=new WeakMap,gt=new WeakMap,Pn=new WeakMap,To=new WeakMap,ta=new WeakMap,ko=new WeakMap,Ao=new WeakMap,xo=new WeakMap,Zl=new WeakMap,Ll=new WeakMap,Uo=new WeakMap,Bl=new WeakMap,vt=new WeakMap,st=new WeakMap,ql=new WeakMap,ni=new WeakMap,Do=new WeakMap,Io=new WeakMap,ri=new WeakMap,Yn=new WeakMap,No=new WeakMap,B=new WeakSet,Ds=function(){D(this,vn,void 0),D(this,zt,void 0)},Is=function(e,t){return!yr(d(this,Yn))||!$g(e,t)?!1:(T(this,B,Ds).call(this),!0)},Ns=function(e,t){return yr(d(this,Yn))&&$g(e,t)&&d(this,vt)!==void 0&&d(this,Xt)!=="connected"},Wk=async function(e,t,n){return await d(this,Ll).send(e,t,n)},Ka=function(e){const t=d(this,Xt);if(t!==e){D(this,Xt,e);for(const n of[...d(this,xo)])try{n(e)}catch(i){H().error({msg:"error in status change handler",error:ht(i)})}if(e==="connected"){d(this,Uo).resolve(void 0);for(const n of[...d(this,ta)])try{n()}catch(i){H().error({msg:"error in open handler",error:ht(i)})}}if((e==="disconnected"||e==="idle")&&t==="connected")for(const n of[...d(this,Ao)])try{n()}catch(i){H().error({msg:"error in close handler",error:ht(i)})}}},Eg=function(){T(this,B,Ka).call(this,"connecting"),pk(T(this,B,eA).bind(this),{forever:!0,minTimeout:250,maxTimeout:3e4,onFailedAttempt:e=>{H().warn({msg:"failed to reconnect",attempt:e.attemptNumber,error:ht(e)})},signal:d(this,Ml).signal}).catch(e=>{e instanceof hg||e.name==="AbortError"||!T(this,B,Og).call(this,e)?H().info({msg:"connection retry aborted"}):H().error({msg:"unexpected error in connection retry",error:ht(e)})})},eA=async function(){try{if(d(this,vt))throw new Error("#onOpenPromise already defined");D(this,vt,us(e=>H().warn({msg:"unhandled open promise rejection",reason:e}))),await T(this,B,nA).call(this),await d(this,vt).promise}catch(e){if(T(this,B,Og).call(this,e))throw e;const t=e instanceof Se?e:new Se("client","connection_open_failed",`Failed to open connection: ${ht(e)}`,{error:ht(e)});throw T(this,B,Tg).call(this),T(this,B,Fa).call(this,t,!1),T(this,B,Bu).call(this,t),T(this,B,Ka).call(this,"idle"),new hg(e instanceof Error?e:new Error(ht(e)))}finally{D(this,vt,void 0)}},Og=function(e){return e instanceof cs?!1:e instanceof Se&&T(this,B,Ns).call(this,e.group,e.code)||e instanceof Se&&e.group==="client"&&e.code==="get_params_failed"?!0:QZ(e)},Tg=function(){d(this,pn).length!==0&&(H().debug({msg:"clearing queued connection messages",queueLength:d(this,pn).length}),D(this,pn,[]))},tA=async function(){if(!d(this,Io))return d(this,Do);try{return await d(this,Io).call(this)}catch(e){const t=ht(e),n=new Se("client","get_params_failed",`Failed to resolve connection params: ${t}`,{error:t});throw T(this,B,Tg).call(this),T(this,B,Fa).call(this,n,!1),T(this,B,Bu).call(this,n),n}},nA=async function(){const e=await T(this,B,tA).call(this),t=qi(d(this,Yn)),n=await d(this,ni).openWebSocket(Ak,t,d(this,ri),e,d(this,No));iu(n,"websocket should have been created"),H().debug({msg:"opened websocket",connId:d(this,zt),readyState:n.readyState,messageQueueLength:d(this,pn).length}),D(this,st,n),n.addEventListener("open",()=>{H().debug({msg:"client websocket open",connId:d(this,zt)})}),n.addEventListener("message",async i=>{try{await T(this,B,iA).call(this,i.data)}catch(r){H().error({msg:"error in websocket message handler",error:ht(r)})}}),n.addEventListener("close",async i=>{try{await T(this,B,aA).call(this,i)}catch(r){H().error({msg:"error in websocket close handler",error:ht(r)})}}),n.addEventListener("error",()=>{try{T(this,B,oA).call(this)}catch(i){H().error({msg:"error in websocket error handler",error:ht(i)})}})},rA=function(){if(d(this,Bn)){H().debug({msg:"handleOnOpen called after dispose, closing websocket"}),d(this,st)&&(d(this,st).close(1e3,"Disposed"),D(this,st,void 0));return}d(this,Xt)==="connected"||d(this,ko)||(D(this,ko,!0),queueMicrotask(()=>{if(D(this,ko,!1),d(this,Bn)){H().debug({msg:"handleOnOpen scheduled after dispose, closing websocket"}),d(this,st)&&(d(this,st).close(1e3,"Disposed"),D(this,st,void 0));return}H().debug({msg:"socket open",messageQueueLength:d(this,pn).length,connId:d(this,zt)}),T(this,B,Ka).call(this,"connected"),d(this,vt)?d(this,vt).resolve(void 0):H().warn({msg:"#onOpenPromise is undefined"});for(const t of d(this,Pn).keys())T(this,B,Rs).call(this,t,!0);const e=d(this,pn);D(this,pn,[]),H().debug({msg:"flushing message queue",queueLength:e.length});for(const t of e)T(this,B,js).call(this,t)}))},iA=async function(e){var n;H().trace({msg:"received message",dataType:typeof e,isBlob:e instanceof Blob,isArrayBuffer:e instanceof ArrayBuffer});const t=await T(this,B,lA).call(this,e);if(H().trace(ZR()?{msg:"parsed message",message:Ek(t).substring(0,100)+"..."}:{msg:"parsed message"}),t.body.tag==="Init")D(this,vn,t.body.val.actorId),D(this,zt,t.body.val.connectionId),H().trace({msg:"received init message",actorId:d(this,vn),connId:d(this,zt)}),T(this,B,rA).call(this);else if(t.body.tag==="Error"){const{group:i,code:r,message:a,metadata:o,actionId:u,actor:l}=t.body.val;if(u!==null){const c=T(this,B,kg).call(this,Number(u));T(this,B,Is).call(this,i,r),H().warn({msg:"action error",actionId:u,actionName:c==null?void 0:c.name,group:i,code:r,message:a,metadata:o,actorId:l==null?void 0:l.actorId,generation:l==null?void 0:l.generation,actorKey:l==null?void 0:l.key}),c.reject(new Se(i,r,a,{metadata:o,actor:l}))}else{if(H().warn({msg:"connection error",group:i,code:r,message:a,metadata:o,actorId:l==null?void 0:l.actorId,generation:l==null?void 0:l.generation,actorKey:l==null?void 0:l.key}),T(this,B,Ns).call(this,i,r)){T(this,B,Ds).call(this),(n=d(this,vt))==null||n.reject(new Se(i,r,a,{metadata:o,actor:l}));return}let c=new Se(i,r,a,{metadata:o,actor:l});if(wg(i,r)&&d(this,vn)){const s=await zg(i,r,d(this,vn),d(this,Yn),d(this,ni));s&&(c=s)}d(this,vt)&&d(this,vt).reject(c),T(this,B,Is).call(this,i,r);for(const[s,f]of d(this,gt).entries())f.reject(c),d(this,gt).delete(s);T(this,B,Bu).call(this,c)}}else if(t.body.tag==="ActionResponse"){const{id:i}=t.body.val;H().debug({msg:"received action response",actionId:Number(i),inFlightCount:d(this,gt).size,inFlightIds:Array.from(d(this,gt).keys())});const r=T(this,B,kg).call(this,Number(i));H().trace({msg:"resolving action promise",actionId:i,actionName:r==null?void 0:r.name}),r.resolve(t.body.val)}else t.body.tag==="Event"?(H().trace({msg:"received event",name:t.body.val.name}),T(this,B,uA).call(this,t.body.val)):Dc(t.body)},aA=async function(e){var r;const t=e,n=t.wasClean,i=d(this,Xt)==="connected";if(H().info({msg:"socket closed",code:t.code,reason:t.reason,wasClean:n,disposed:d(this,Bn),connId:d(this,zt)}),D(this,st,void 0),d(this,Bn))T(this,B,Fa).call(this,new cs,!0);else{T(this,B,Ka).call(this,"disconnected");let a;const o=t.reason||"",u=AZ(o);if(u){const{group:l,code:c}=u;if(T(this,B,Ns).call(this,l,c)){T(this,B,Ds).call(this),(r=d(this,vt))==null||r.reject(new Se(l,c,`Connection closed: ${o}`,void 0));return}if(wg(l,c)&&d(this,vn)){const s=await zg(l,c,d(this,vn),d(this,Yn),d(this,ni));s?a=s:a=new Se(l,c,`Connection closed: ${o}`,void 0)}else a=new Se(l,c,`Connection closed: ${o}`,void 0);T(this,B,Is).call(this,l,c)}else a=new Error(`${n?"Connection closed":"Connection lost"} (code: ${t.code}, reason: ${o})`);T(this,B,Fa).call(this,a,!1),a instanceof Se&&T(this,B,Bu).call(this,a),i&&(H().debug({msg:"triggering reconnect",connId:d(this,zt)}),T(this,B,Eg).call(this))}},Fa=function(e,t){d(this,vt)&&(t&&d(this,vt).promise.catch(()=>{}),d(this,vt).reject(e));for(const n of d(this,gt).values())n.reject(e);d(this,gt).clear()},oA=function(){d(this,Bn)||H().warn("socket error")},kg=function(e){const t=d(this,gt).get(e);if(!t)throw H().error({msg:"action not found in in-flight map",lookupId:e,inFlightCount:d(this,gt).size,inFlightIds:Array.from(d(this,gt).keys()),inFlightActions:Array.from(d(this,gt).entries()).map(([n,i])=>({id:n,name:i.name}))}),kZ(`No in flight response for ${e}`);return d(this,gt).delete(e),H().debug({msg:"removed action from in-flight map",actionId:e,actionName:t.name,inFlightCount:d(this,gt).size}),t},uA=function(e){const{name:t,args:n}=e,i=d(this,Pn).get(t);if(i){for(const r of[...i])r.callback(...n),r.once&&i.delete(r);i.size===0&&d(this,Pn).delete(t)}},Bu=function(e){for(const t of[...d(this,To)])try{t(e)}catch(n){H().error({msg:"error in connection error handler",error:ht(n)})}},Ag=function(e,t,n){const i={callback:t,once:n};let r=d(this,Pn).get(e);return r===void 0&&(r=new Set,d(this,Pn).set(e,r),T(this,B,Rs).call(this,e,!0)),r.add(i),()=>{const a=d(this,Pn).get(e);a&&(a.delete(i),a.size===0&&(d(this,Pn).delete(e),T(this,B,Rs).call(this,e,!1)))}},js=function(e,t){var i,r;if(d(this,Bn)){if(t!=null&&t.ephemeral)return;throw new cs}let n=!1;if(d(this,st)){const a=d(this,st).readyState;if(H().debug({msg:"websocket send attempt",readyState:a,readyStateString:a===0?"CONNECTING":a===1?"OPEN":a===2?"CLOSING":"CLOSED",connId:d(this,zt),messageType:e.body.tag,actionName:(i=e.body.val)==null?void 0:i.name}),d(this,Xt)!=="connected")H().debug({msg:"websocket init pending, queueing message",connStatus:d(this,Xt),messageType:e.body.tag}),n=!0;else if(a===1)try{const o=bk(d(this,ri),e,oZ,Nl,wZ,l=>l,l=>l.body.tag==="ActionRequest"?{body:{tag:"ActionRequest",val:{id:l.body.val.id,name:l.body.val.name,args:My(au(l.body.val.args))}}}:l);d(this,st).send(o);const u=xZ(o);H().trace({msg:"sent websocket message",len:u})}catch(o){H().warn({msg:"failed to send message, added to queue",error:o,connId:d(this,zt)}),n=!0}else H().debug({msg:"websocket not open, queueing message",readyState:a}),n=!0}else H().debug({msg:"no websocket, queueing message"}),n=!0;!(t!=null&&t.ephemeral)&&n&&(d(this,pn).push(e),H().debug({msg:"queued connection message",queueLength:d(this,pn).length,connId:d(this,zt),messageType:e.body.tag,actionName:(r=e.body.val)==null?void 0:r.name}))},lA=async function(e){iu(d(this,st),"websocket must be defined");const t=await TR(e);return Tf(d(this,ri),t,uZ,yZ,n=>n.body.tag!=="Error"||!n.body.val.actor?n:{body:{tag:"Error",val:{...n.body.val,actor:{...n.body.val.actor,generation:Number(n.body.val.actor.generation)}}}},n=>n.body.tag==="Error"?{body:{tag:"Error",val:{group:n.body.val.group,code:n.body.val.code,message:n.body.val.message,metadata:n.body.val.metadata?wi(new Uint8Array(n.body.val.metadata)):null,actionId:n.body.val.actionId,actor:n.body.val.actor?{actorId:n.body.val.actor.actorId,generation:Number(n.body.val.actor.generation),key:n.body.val.actor.key??void 0}:void 0}}}:n.body.tag==="ActionResponse"?{body:{tag:"ActionResponse",val:{id:n.body.val.id,output:wi(new Uint8Array(n.body.val.output))}}}:n.body.tag==="Event"?{body:{tag:"Event",val:{name:n.body.val.name,args:wi(new Uint8Array(n.body.val.args))}}}:n)},Rs=function(e,t){T(this,B,js).call(this,{body:{tag:"SubscriptionRequest",val:{eventName:e,subscribe:t}}},{ephemeral:!0})},L_),jo,Hl,B_,XZ=(B_=class{constructor(){R(this,jo,!1);R(this,Hl,[])}async acquire(){for(;d(this,jo);)await new Promise(e=>d(this,Hl).push(e));D(this,jo,!0)}release(){D(this,jo,!1);const e=d(this,Hl).shift();e&&e()}async run(e){await this.acquire();try{return await e()}finally{this.release()}}},jo=new WeakMap,Hl=new WeakMap,B_);async function WZ(e,t,n,i,r,a={}){let o,u=r||{};if(typeof i=="string")o=i;else if(i instanceof URL)o=i.pathname+i.search;else if(i instanceof Request){const l=new URL(i.url);o=l.pathname+l.search;const c=new Headers(i.headers),s=new Headers((r==null?void 0:r.headers)||{}),f=new Headers(c);s.forEach((m,h)=>{f.set(h,m)}),u={method:i.method,body:i.body,mode:i.mode,credentials:i.credentials,redirect:i.redirect,referrer:i.referrer,referrerPolicy:i.referrerPolicy,integrity:i.integrity,keepalive:i.keepalive,signal:i.signal,...u,headers:f},u.body&&(u.duplex="half")}else throw new TypeError("Invalid input type for fetch");try{H().debug("directId"in t?{msg:"sending raw http request to actor",actorId:t.directId}:{msg:"sending raw http request with actor query",query:t});const l=o.startsWith("/")?o.slice(1):o,c=new URL(`http://actor/request/${l}`),s=new Headers(u.headers);n&&s.set(qy,JSON.stringify(n));const f=new Request(c,{...u,headers:s});return e.sendRequest(t,f,a)}catch(l){const{group:c,code:s,message:f,metadata:m,actor:h}=As(l,!0);throw new Se(c,s,f,{metadata:m,actor:h})}}async function eL(e,t,n,i,r,a={}){const o="bare";let u="",l="";if(i){const f=i.indexOf("?");f!==-1?(u=i.substring(0,f),l=i.substring(f)):u=i,u.startsWith("/")&&(u=u.slice(1))}const c=`${xk}${u}${l}`;return H().debug({msg:"opening websocket",target:t,encoding:o,path:c}),await e.openWebSocket(c,t,o,n,a)}async function cA(e,t){if("directId"in t)return t.directId;if("getForId"in t)return t.getForId.actorId;if("getForKey"in t){const n=await e.getWithKey({name:t.getForKey.name,key:t.getForKey.key});if(!n)throw _R(`${t.getForKey.name}:${JSON.stringify(t.getForKey.key)}`);return n.actorId}if("getOrCreateForKey"in t)return(await e.getOrCreateWithKey({name:t.getOrCreateForKey.name,key:t.getOrCreateForKey.key,input:t.getOrCreateForKey.input,region:t.getOrCreateForKey.region})).actorId;if("create"in t)return(await e.createActor({name:t.create.name,key:t.create.key,input:t.create.input,region:t.create.region})).actorId;throw Iy("Invalid query format")}var Ro,Lt,Xn,ke,Wn,er,na,ra,ii,Af,F,sA,fA,dA,mA,Mn,Cs,qu,hA,Bi,Hu,Vu,xg,Gu,gA,vA,pA,q_,tL=(q_=class{constructor(e,t,n,i,r,a,o={}){R(this,F);R(this,Ro);R(this,Lt);R(this,Xn);R(this,ke);R(this,Wn);R(this,er);R(this,na);R(this,ra);R(this,ii);R(this,Af,new XZ);D(this,Ro,e),D(this,Lt,t),D(this,Xn,r),D(this,ke,a),D(this,Wn,o),D(this,er,n),D(this,na,i)}send(e,t,n){return T(this,F,fA).call(this,e,t,n)}async action(e){if(typeof e=="string"||typeof e!="object"||e===null||!("name"in e))throw new Error(`Invalid action call: expected an options object { name, args }, got ${typeof e}. Use handle.actionName(...args) for the shorthand API.`);const t=async()=>await T(this,F,dA).call(this,e);return e.name==="destroy"?await t():await PZ(t,{signal:e.signal})}connect(e,t={}){H().debug({msg:"establishing connection from handle",query:d(this,ke)});const n=e===void 0?d(this,er):e,i=e===void 0?d(this,na):void 0,r=new YZ(d(this,Ro),d(this,Lt),n,i,d(this,Xn),d(this,ke),Ga(d(this,Wn),t));return d(this,Ro)[yA](r)}fetch(e,t){return T(this,F,gA).call(this,e,t)}async webSocket(e,t,n={}){const i=await T(this,F,sA).call(this),r=Ga(d(this,Wn),n),a=yr(d(this,ke)),o=await T(this,F,Gu).call(this,a,r);return await eL(d(this,Lt),o,i,e,t,r)}async resolve(){if("getForId"in d(this,ke))return d(this,ke).getForId.actorId;const e=await T(this,F,xg).call(this,!1);if("directId"in e)return e.directId;throw new Error("dynamic actor resolution did not produce a direct actor id")}async getGatewayUrl(){return await d(this,Lt).buildGatewayUrl(qi(d(this,ke)),d(this,Wn))}async reload(){const e=qi(d(this,ke)),t=new Request("http://actor/dynamic/reload",{method:"PUT"}),n=await d(this,Lt).sendRequest(e,t);if(!n.ok){const i=await n.text().catch(()=>"");throw new Se("actor","reload_failed",`reload failed with status ${n.status}: ${i}`,{})}}},Ro=new WeakMap,Lt=new WeakMap,Xn=new WeakMap,ke=new WeakMap,Wn=new WeakMap,er=new WeakMap,na=new WeakMap,ra=new WeakMap,ii=new WeakMap,Af=new WeakMap,F=new WeakSet,sA=async function(){return d(this,na)?await d(this,na).call(this):d(this,er)},fA=async function(e,t,n){return await d(this,Af).run(async()=>{const i=T(this,F,Cs).call(this);let r=!1;for(let a=0;a<i;a++){let o;try{const u=Ga(d(this,Wn)),l=await T(this,F,Gu).call(this,r,u);return o="directId"in l?l.directId:void 0,await Yk({encoding:d(this,Xn),params:d(this,er),customFetch:async c=>await d(this,Lt).sendRequest(l,c,u)}).send(e,t,n)}catch(u){const{group:l,code:c,message:s,metadata:f,actor:m}=As(u,!0);if(T(this,F,hA).call(this,l,c,f,a,i)){await T(this,F,Mn).call(this);continue}if(await T(this,F,Hu).call(this,l,c,o,a,i)){r=!0,await T(this,F,Mn).call(this);continue}if(T(this,F,qu).call(this,l,c,a,i)){T(this,F,Bi).call(this),r=!0,await T(this,F,Mn).call(this);continue}if(T(this,F,Vu).call(this,l,c)&&a<i-1){r=c==="starting"||c==="stopping"||c.startsWith("destroyed_"),r&&await T(this,F,Mn).call(this);continue}throw new Se(l,c,s,{metadata:f,actor:m})}}throw new Error("unreachable queue retry state")})},dA=async function(e){const t=T(this,F,Cs).call(this);let n=!1;const i=Ga(d(this,Wn),e);for(let r=0;r<t;r++){let a;try{const o=await T(this,F,Gu).call(this,n,i);a="directId"in o?o.directId:void 0,H().debug(a?{msg:"using direct actor gateway target",actorId:a}:{msg:"using query gateway target for action",query:d(this,ke)}),H().debug({msg:"handling action",name:e.name,encoding:d(this,Xn)});const u=await Qy({url:`http://actor/action/${encodeURIComponent(e.name)}`,method:"POST",headers:{[Uk]:d(this,Xn),...d(this,er)!==void 0?{[qy]:JSON.stringify(d(this,er))}:{}},body:e.args,encoding:d(this,Xn),customFetch:async l=>await d(this,Lt).sendRequest(o,l,i),signal:e==null?void 0:e.signal,requestVersion:Nl,requestVersionedDataHandler:lZ,responseVersion:Nl,responseVersionedDataHandler:cZ,requestZodSchema:$Z,responseZodSchema:zZ,requestToJson:l=>({args:l}),requestToBare:l=>({args:My(au(l))}),responseFromJson:l=>l.output,responseFromBare:l=>wi(new Uint8Array(l.output))});return e.name==="destroy"&&a&&await T(this,F,mA).call(this,a),u}catch(o){const{group:u,code:l,message:c,metadata:s,actor:f}=As(o,!0);if(await T(this,F,Hu).call(this,u,l,a,r,t)){n=!0,await T(this,F,Mn).call(this);continue}if(e.name!=="destroy"&&T(this,F,qu).call(this,u,l,r,t)){T(this,F,Bi).call(this),n=!0,await T(this,F,Mn).call(this);continue}if(u==="actor"&&l==="destroyed_while_waiting_for_ready"&&"getForId"in d(this,ke))throw new Se("actor","not_found","The actor does not exist or was destroyed.",{metadata:s,actor:f});if(T(this,F,Vu).call(this,u,l)&&r<t-1){u==="actor"&&(l==="starting"||l==="stopping")&&(n=!0,await new Promise(h=>setTimeout(h,100)));continue}throw new Se(u,l,c,{metadata:s,actor:f})}}throw new Error("unreachable action retry state")},mA=async function(e){const t=Qk(d(this,ke)),n=Date.now()+1e3;for(;Date.now()<n;){if(!await d(this,Lt).getForId({name:t,actorId:e}))return;await new Promise(r=>setTimeout(r,25))}},Mn=async function(){await new Promise(e=>setTimeout(e,100))},Cs=function(){return yr(d(this,ke))?"getOrCreateForKey"in d(this,ke)?60:24:1},qu=function(e,t,n,i){return!yr(d(this,ke))||n>=i-1||e!=="actor"?!1:t==="not_found"||t==="starting"||t==="stopping"||t==="not_configured"||t==="dropped_reply"||t==="destroying"||t.startsWith("destroyed_")},hA=function(e,t,n,i,r){if(!yr(d(this,ke))||i>=r-1||e!=="actor"||t!=="overloaded"||n===null||typeof n!="object")return!1;const a=n;return a.channel==="dispatch_inbox"&&a.operation==="dispatch_queue_send"},Bi=function(){D(this,ra,void 0),D(this,ii,void 0)},Hu=async function(e,t,n,i,r){if(!yr(d(this,ke))||!wg(e,t)||i>=r-1)return!1;if(n){const a=await zg(e,t,n,d(this,ke),d(this,Lt));if(a)throw a}return T(this,F,Bi).call(this),!0},Vu=function(e,t){return!yr(d(this,ke))||!$g(e,t)?!1:(T(this,F,Bi).call(this),!0)},xg=async function(e){if("getForId"in d(this,ke))return qi(d(this,ke));if(e)return qi(d(this,ke));if(d(this,ra))return{directId:d(this,ra)};d(this,ii)||D(this,ii,cA(d(this,Lt),d(this,ke)).then(t=>(D(this,ra,t),t)));try{return{directId:await d(this,ii)}}finally{D(this,ii,void 0)}},Gu=async function(e,t){return t.skipReadyWait?qi(d(this,ke)):await T(this,F,xg).call(this,e)},gA=async function(e,t){const n=T(this,F,Cs).call(this);let i=!1;const{skipReadyWait:r,...a}=t??{},o=Ga(d(this,Wn),{skipReadyWait:r});for(let u=0;u<n;u++){let l;try{const c=await T(this,F,Gu).call(this,i,o);l="directId"in c?c.directId:void 0;const s=await WZ(d(this,Lt),c,d(this,er),e,a,o),f=await T(this,F,vA).call(this,s,l,u,n);if(f){i=f.useQueryTarget,f.waitForRetryWindow&&await T(this,F,Mn).call(this);continue}return s}catch(c){const{group:s,code:f,message:m,metadata:h,actor:_}=As(c,!0);if(await T(this,F,Hu).call(this,s,f,l,u,n)){i=!0,await T(this,F,Mn).call(this);continue}if(T(this,F,qu).call(this,s,f,u,n)){T(this,F,Bi).call(this),i=!0,await T(this,F,Mn).call(this);continue}if(T(this,F,Vu).call(this,s,f)&&u<n-1){i=f==="starting"||f==="stopping"||f.startsWith("destroyed_"),i&&await T(this,F,Mn).call(this);continue}throw new Se(s,f,m,{metadata:h,actor:_})}}throw new Error("unreachable fetch retry state")},vA=async function(e,t,n,i){if(e.ok||!yr(d(this,ke)))return null;const r=await T(this,F,pA).call(this,e);if(!r)return null;const{group:a,code:o}=r;if(await T(this,F,Hu).call(this,a,o,t,n,i))return{useQueryTarget:!0,waitForRetryWindow:!0};if(T(this,F,qu).call(this,a,o,n,i))return T(this,F,Bi).call(this),{useQueryTarget:!0,waitForRetryWindow:!0};if(T(this,F,Vu).call(this,a,o)&&n<i-1){const l=o==="starting"||o==="stopping"||o.startsWith("destroyed_");return{useQueryTarget:l,waitForRetryWindow:l}}return null},pA=async function(e){if(e.ok)return null;const t=e.headers.get("content-type"),n=t!=null&&t.includes("application/json")?"json":d(this,Xn);try{return Tf(n,new Uint8Array(await e.clone().arrayBuffer()),Vk,Kk,i=>({...i,actor:i.actor?{...i.actor,generation:Number(i.actor.generation)}:void 0}),i=>({group:i.group,code:i.code,message:i.message,metadata:i.metadata?wi(new Uint8Array(i.metadata)):void 0,actor:i.actor?{actorId:i.actor.actorId,generation:Number(i.actor.generation),key:i.actor.key??void 0}:void 0}))}catch{return null}},q_),Ms=Symbol("actorConns"),yA=Symbol("createActorConnProxy"),H_,Vl,Co,Gl,Kl,ia,Ku,V_,nL=(V_=class{constructor(e,t,n={}){R(this,ia);R(this,Vl,!1);jt(this,H_,new Set);R(this,Co);R(this,Gl);R(this,Kl);D(this,Co,e),D(this,Gl,t??"bare"),D(this,Kl,n)}getForId(e,t,n){H().debug({msg:"get handle to actor with id",name:e,actorId:t,params:n==null?void 0:n.params});const i={getForId:{name:e,actorId:t}},r=T(this,ia,Ku).call(this,n==null?void 0:n.params,n==null?void 0:n.getParams,i);return Uu(r)}get(e,t,n){const i=typeof t=="string"?[t]:t||[];H().debug({msg:"get handle to actor",name:e,key:i,parameters:n==null?void 0:n.params});const r={getForKey:{name:e,key:i}},a=T(this,ia,Ku).call(this,n==null?void 0:n.params,n==null?void 0:n.getParams,r);return Uu(a)}getOrCreate(e,t,n){const i=typeof t=="string"?[t]:t||[];H().debug({msg:"get or create handle to actor",name:e,key:i,parameters:n==null?void 0:n.params,createInRegion:n==null?void 0:n.createInRegion});const r={getOrCreateForKey:{name:e,key:i,input:n==null?void 0:n.createWithInput,region:n==null?void 0:n.createInRegion}},a=T(this,ia,Ku).call(this,n==null?void 0:n.params,n==null?void 0:n.getParams,r);return Uu(a)}async create(e,t,n){const i=typeof t=="string"?[t]:t||[],r={create:{...n,name:e,key:i}};H().debug({msg:"create actor handle",name:e,key:i,parameters:n==null?void 0:n.params,create:r.create});const a=await cA(d(this,Co),r);H().debug({msg:"created actor with ID",name:e,key:i,actorId:a});const o={getForId:{name:e,actorId:a}},u=T(this,ia,Ku).call(this,n==null?void 0:n.params,n==null?void 0:n.getParams,o);return Uu(u)}[(H_=Ms,yA)](e){return this[Ms].add(e),e[Xk](),Uu(e)}async dispose(){if(d(this,Vl)){H().warn({msg:"client already disconnected"});return}D(this,Vl,!0),H().debug({msg:"disposing client"});const e=[];for(const t of this[Ms].values())e.push(t.dispose());await Promise.all(e)}},Vl=new WeakMap,Co=new WeakMap,Gl=new WeakMap,Kl=new WeakMap,ia=new WeakSet,Ku=function(e,t,n){return new tL(this,d(this,Co),e,t,d(this,Gl),n,d(this,Kl))},V_);function rL(e,t={}){const n=new nL(e,t.encoding,t.gateway);return new Proxy(n,{get:(i,r,a)=>{if(typeof r=="symbol"||r in i){const o=Reflect.get(i,r,a);return typeof o=="function"?o.bind(i):o}if(typeof r=="string")return{get:(o,u)=>i.get(r,o,u),getOrCreate:(o,u)=>i.getOrCreate(r,o,u),getForId:(o,u)=>i.getForId(r,o,u),create:async(o,u={})=>await i.create(r,o,u)}}})}function Uu(e){const t=new Map,n=i=>{let r=t.get(i);return r||(r=new Proxy((...a)=>e.action({name:i,args:a}),{get(a,o){if(typeof o=="symbol")return Reflect.get(a,o);if(o!=="then")return n(`${i}.${o}`)}}),t.set(i,r),r)};return new Proxy(e,{get(i,r,a){if(typeof r=="symbol")return Reflect.get(i,r,a);if(r==="constructor"||r in i){const o=Reflect.get(i,r,i);return typeof o=="function"?o.bind(i):o}if(typeof r=="string")return r==="then"?void 0:n(r)},has(i,r){return typeof r=="string"?!0:Reflect.has(i,r)},getPrototypeOf(i){return Reflect.getPrototypeOf(i)},ownKeys(i){return Reflect.ownKeys(i)},getOwnPropertyDescriptor(i,r){if(r==="then")return;const a=Reflect.getOwnPropertyDescriptor(i,r);if(a)return a;if(typeof r=="string")return{configurable:!0,enumerable:!1,writable:!1,value:n(r)}}})}function iL(e){const t=e===void 0?{}:typeof e=="string"?{endpoint:e}:e,n=b3.parse(t),i=new LZ(n);return n.devtools&&e3(n),rL(i,n)}function aL(e,t={}){const{getOrCreateActor:n}=cU(e,t);function i(r){const{mount:a,state:o}=n(r);return Ge.useEffect(()=>a(),[a]),{...I0(o),useEvent:(c,s)=>{const f=Ge.useRef(s),m=I0(o);Ge.useEffect(()=>{f.current=s},[s]),Ge.useEffect(()=>{const h=m.connection;if(!h)return;function _(...S){f.current(...S)}return h.on(c,_)},[m.connection,m.connStatus,m.hash,c])}}}return{useActor:i}}function oL(e){const t=iL({endpoint:window.location.origin,token:e,encoding:"json",disableMetadataLookup:!0});return{client:t,...aL(t)}}const bA=Ge.createContext(null);function uL({actorId:e,authToken:t,children:n}){const i=Ge.useMemo(()=>{const r=oL(t);return W2(r.client,e),{bundle:r,actorId:e}},[e,t]);return nt.jsx(bA.Provider,{value:i,children:n})}function SL(){const e=Ge.useContext(bA);if(!e)throw new Error("useAgentOsActor must be used within <RivetProvider>");return e.bundle.useActor({name:n1,id:e.actorId})}function lL(){return nt.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-8 text-sm text-muted-foreground",children:nt.jsxs("span",{className:"inline-flex items-center gap-2",children:[nt.jsxs("svg",{className:"size-4 animate-spin text-muted-foreground",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[nt.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),nt.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M12 2a10 10 0 0 1 10 10h-3a7 7 0 0 0-7-7z"})]}),"Loading…"]})})}class cL extends Ge.Component{constructor(){super(...arguments);jt(this,"state",{})}static getDerivedStateFromError(n){return{error:n}}render(){return this.state.error?nt.jsx("div",{className:"flex h-full flex-1 items-center justify-center p-8 text-center text-sm text-destructive",children:this.state.error.message||"Failed to load."}):this.props.children}}function sL({children:e}){return nt.jsx(cL,{children:nt.jsx(Ge.Suspense,{fallback:nt.jsx(lL,{}),children:e})})}const fL={software:()=>_u(()=>import("./software-d-8Y614w.js"),__vite__mapDeps([0,1,2,3]),import.meta.url).then(e=>({default:e.SoftwareTabConnected})),processes:()=>_u(()=>import("./processes-DXs6A0io.js"),__vite__mapDeps([4,1,2]),import.meta.url).then(e=>({default:e.ProcessesTabConnected})),filesystem:()=>_u(()=>import("./filesystem-VgTouyDr.js"),__vite__mapDeps([5,2]),import.meta.url).then(e=>({default:e.FilesystemTabConnected})),mounts:()=>_u(()=>import("./mounts-Blsl8Zt1.js"),__vite__mapDeps([6,1,2,3]),import.meta.url).then(e=>({default:e.MountsTabConnected})),transcript:()=>_u(()=>import("./transcript-8cHeR5Ok.js"),__vite__mapDeps([7,1,2]),import.meta.url).then(e=>({default:e.TranscriptTabConnected}))},dL=new t6({defaultOptions:{queries:{retry:3,retryDelay:e=>Math.min(1500*2**e,8e3),refetchOnWindowFocus:!1,staleTime:5e3}}});function mL(){const[e,t]=Ge.useState();Ge.useEffect(()=>{parent.postMessage({type:"ready",v:1},"*");const a=o=>{const u=o.data||{};u.type==="init"&&u.actorId&&u.authToken&&t({actorId:u.actorId,authToken:u.authToken})};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[]);const n=eU(),i=n?fL[n]:void 0;if(!i)return nt.jsxs("div",{style:{padding:16},children:["Unknown inspector tab: ",String(n)]});if(!e)return nt.jsx("div",{style:{padding:16,color:"#8a8a90"},children:"Connecting…"});const r=Ge.lazy(i);return nt.jsx(uL,{actorId:e.actorId,authToken:e.authToken,children:nt.jsx(sL,{children:nt.jsx(r,{actorId:e.actorId})})})}X2.createRoot(document.getElementById("root")).render(nt.jsx(Ge.StrictMode,{children:nt.jsx(b6,{client:dL,children:nt.jsx(mL,{})})}));export{pL as R,Df as S,jA as a,Jm as b,Qm as c,PA as d,P_ as e,F_ as f,MA as g,Dt as h,IA as i,nt as j,vL as k,yL as l,bL as m,Zn as n,qA as p,Ge as r,gL as s,NA as t,SL as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./index-
|
|
1
|
+
import{j as e}from"./index-Bapg8yic.js";import{u as r}from"./useSuspenseQuery-BjjhFDMq.js";import{A as n,S as a,j as o,e as l}from"./scroll-area-BVREu3i3.js";import{B as d}from"./badge-Dc8cdZEA.js";const c=s=>typeof s>"u"||s===null||Object.keys(s).length===0;function i({mounts:s}){return e.jsx("div",{className:"flex h-full flex-col",children:s.length===0?e.jsx(n,{children:"No mounts configured on this actor."}):e.jsx(a,{className:"min-h-0 flex-1",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Path"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Kind"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Access"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Config"})]})}),e.jsx("tbody",{children:s.map(t=>e.jsxs("tr",{className:"border-b border-foreground/[0.06] align-top hover:bg-muted/50",children:[e.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:t.path}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(d,{variant:"secondary",className:"font-mono",children:t.kind})}),e.jsx("td",{className:"px-3 py-2 text-xs text-muted-foreground",children:t.readOnly?"read-only":"read-write"}),e.jsx("td",{className:"px-3 py-2",children:c(t.config)?e.jsx("span",{className:"text-muted-foreground/60",children:"—"}):e.jsxs("div",{className:"group relative max-w-[20rem]",children:[e.jsx("code",{className:"block overflow-x-auto whitespace-nowrap rounded bg-muted/30 py-1.5 pl-2 pr-7 font-mono text-xs text-muted-foreground",children:JSON.stringify(t.config)}),e.jsx(o,{value:JSON.stringify(t.config,null,2),className:"absolute right-1 top-1 bg-background/70 backdrop-blur-sm"})]})})]},t.path))})]})})})}function f({actorId:s}){const{data:t}=r(l.mountsQueryOptions(s));return e.jsx(i,{mounts:t})}export{i as MountsTab,f as MountsTabConnected};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e}from"./index-
|
|
1
|
+
import{r as c,j as e}from"./index-Bapg8yic.js";import{u as x}from"./useSuspenseQuery-BjjhFDMq.js";import{e as m,A as i,S as l,g as u}from"./scroll-area-BVREu3i3.js";function o(s){return s?new Date(s).toLocaleTimeString():"—"}function f({p:s}){const n=[["pid",String(s.pid)],["command",s.command],["args",s.args.join(" ")||"—"],["status",s.running?"running":"exited"],["exit code",s.exitCode==null?"—":String(s.exitCode)],["started",o(s.startedAt)]];return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b px-4 py-3",children:[e.jsxs("span",{className:"font-mono text-sm",children:["pid ",s.pid]}),e.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:s.command})]}),e.jsx(l,{className:"min-h-0 flex-1",children:e.jsx("dl",{className:"px-4 py-2 text-xs",children:n.map(([d,a])=>e.jsxs("div",{className:"flex gap-3 border-b border-foreground/[0.06] py-2 last:border-0",children:[e.jsx("dt",{className:"w-24 shrink-0 text-muted-foreground",children:d}),e.jsx("dd",{className:"min-w-0 flex-1 break-words font-mono",children:a})]},d))})})]})}function g({actorId:s}){const{data:n}=x(m.processesQueryOptions(s)),[d,a]=c.useState(),r=n.find(t=>t.pid===d)??n[0];return e.jsx("div",{className:"flex h-full flex-col",children:n.length===0?e.jsx(i,{children:"No processes running."}):e.jsxs("div",{className:"flex min-h-0 flex-1",children:[e.jsx(l,{className:"min-h-0 w-3/5 border-r",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"PID"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Command"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Started"}),e.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Status"})]})}),e.jsx("tbody",{children:n.map(t=>e.jsxs("tr",{onClick:()=>a(t.pid),className:`cursor-pointer border-b border-foreground/[0.06] hover:bg-muted/50 ${(r==null?void 0:r.pid)===t.pid?"bg-muted/50":""}`,children:[e.jsx("td",{className:"px-3 py-2 font-mono",children:t.pid}),e.jsxs("td",{className:"px-3 py-2 font-mono text-xs",children:[t.command," ",t.args.join(" ")]}),e.jsx("td",{className:"px-3 py-2 font-mono text-xs text-muted-foreground",children:o(t.startedAt)}),e.jsx("td",{className:"px-3 py-2",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs",children:[e.jsx(u,{color:t.running?"green":"red"}),t.running?"running":"exited"]})})]},t.pid))})]})}),e.jsx("div",{className:"min-h-0 w-2/5",children:r?e.jsx(f,{p:r}):e.jsx(i,{children:"Select a process."})})]})})}export{g as ProcessesTabConnected};
|