@vertesia/client 1.6.0-dev.20260918.115658Z → 1.6.0-dev.20260923.085325Z
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/lib/AppsApi.d.ts +5 -0
- package/lib/AppsApi.d.ts.map +1 -1
- package/lib/AppsApi.js +9 -0
- package/lib/AppsApi.js.map +1 -1
- package/lib/InteractionBase.d.ts +138 -62
- package/lib/InteractionBase.d.ts.map +1 -1
- package/lib/InteractionOutput.d.ts +4 -0
- package/lib/InteractionOutput.d.ts.map +1 -1
- package/lib/InteractionOutput.js +13 -0
- package/lib/InteractionOutput.js.map +1 -1
- package/lib/InternalAccountsApi.d.ts +7 -0
- package/lib/InternalAccountsApi.d.ts.map +1 -0
- package/lib/InternalAccountsApi.js +10 -0
- package/lib/InternalAccountsApi.js.map +1 -0
- package/lib/OAuthServerApi.d.ts +2 -1
- package/lib/OAuthServerApi.d.ts.map +1 -1
- package/lib/OAuthServerApi.js +3 -0
- package/lib/OAuthServerApi.js.map +1 -1
- package/lib/client.d.ts +2 -0
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +3 -0
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/store/AgentsApi.d.ts.map +1 -1
- package/lib/store/AgentsApi.js +15 -0
- package/lib/store/AgentsApi.js.map +1 -1
- package/lib/vertesia-client.js +4 -4
- package/lib/vertesia-client.js.map +1 -1
- package/package.json +7 -7
- package/src/AppsApi.ts +11 -0
- package/src/InteractionOutput.test.ts +14 -0
- package/src/InteractionOutput.ts +15 -0
- package/src/InternalAccountsApi.ts +12 -0
- package/src/OAuthServerApi.ts +6 -0
- package/src/app-session.test.ts +23 -0
- package/src/client.ts +5 -0
- package/src/index.ts +1 -0
- package/src/store/AgentsApi.stream.test.ts +33 -1
- package/src/store/AgentsApi.ts +17 -0
- package/src/store/FilesApi.test.ts +13 -0
package/lib/vertesia-client.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import{APP_VERSION_HEADER as e,APP_VERSION_HEADER as t,AgentMessageType as n,CURRENT_API_VERSION_HEADER_VALUE as r,ContentObjectApiHeaders as i,DataStoreApiHeaders as a,ExecutionRunStatus as o,Permission as s,VERSION_HEADER as c,WorkflowExecutionStatus as l,canGenerateRendition as u,getOAuthPermissionScopes as d,getSupportedRenditionFormats as f,isWorkflowTerminalStatus as p,parseMessage as m,supportsVisualRendition as h,toAgentMessage as g}from"@vertesia/common";function _(e){return typeof e==`object`&&!!e}function v(e){if(_(e))return e.details?e.details:_(e.error)?e.error.details:void 0}function y(e,t,n,r,i){let a=e;if(i){a+=`\nRequest: ${t.method} ${t.url} => ${n}`;let e=v(r);if(e){let t=typeof e;t===`string`?a+=`\nDetails: ${e}`:t===`object`&&(a+=`\nDetails: ${JSON.stringify(e,void 0,2)}`)}a+=`
|
|
2
|
-
Stack Trace: `}return a}var b=class extends Error{status;payload;request;request_info;displayDetails;original_message;rateLimit;retryAfterMs;constructor(e,t,n,r,i=!0,a,o){super(y(e,t,n,r,i)),this.original_message=e,this.request=t,this.status=n,this.payload=r,this.request_info=`${t.method} ${t.url} => ${n}`,this.displayDetails=i,this.rateLimit=a,this.retryAfterMs=o}get details(){return v(this.payload)}},x=class e extends b{constructor(e,t,n,r,i=!0,a,o){super(e,t,n,r,i,a,o)}updateDetails(t){if(t!==this.details){let n=_(this.payload)?{...this.payload,details:t}:{details:t};return new e(this.original_message,this.request,this.status,n,this.displayDetails,this.rateLimit,this.retryAfterMs)}return this}},S=class extends b{constructor(e,t){super(`Failed to connect to server: ${t.message}`,e,0,t)}},C=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function w(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{maxBufferSize:t,onComment:n,onError:r,onEvent:i,onId:a,onRetry:o}=e,s=[],c=0,l
|
|
2
|
+
Stack Trace: `}return a}var b=class extends Error{status;payload;request;request_info;displayDetails;original_message;rateLimit;retryAfterMs;constructor(e,t,n,r,i=!0,a,o){super(y(e,t,n,r,i)),this.original_message=e,this.request=t,this.status=n,this.payload=r,this.request_info=`${t.method} ${t.url} => ${n}`,this.displayDetails=i,this.rateLimit=a,this.retryAfterMs=o}get details(){return v(this.payload)}},x=class e extends b{constructor(e,t,n,r,i=!0,a,o){super(e,t,n,r,i,a,o)}updateDetails(t){if(t!==this.details){let n=_(this.payload)?{...this.payload,details:t}:{details:t};return new e(this.original_message,this.request,this.status,n,this.displayDetails,this.rateLimit,this.retryAfterMs)}return this}},S=class extends b{constructor(e,t){super(`Failed to connect to server: ${t.message}`,e,0,t)}},C=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function w(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{maxBufferSize:t,onComment:n,onError:r,onEvent:i,onId:a,onRetry:o}=e,s=[],c=0,l=``,u,d=``,f=0,p,m=!1,h=!1,g=!1;function _(e){if(m)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(l!==void 0){if(e=l+e,e===``||e===`ï`||e===`ï»`){l=e;return}l=void 0,e=e.replace(/^(?:\uFEFF|\xEF\xBB\xBF)/,``)}if((h||g)&&(e=v(e),!e))return;if(!s.length){let t=S(e);t!==``&&y(t),x();return}if(e.indexOf(`
|
|
3
3
|
`)===-1&&e.indexOf(`\r`)===-1){if(c<6&&!b(s.join(``)+e.slice(0,6-c))){s.length=0,c=0,h=!0;return}s.push(e),c+=e.length,x();return}s.push(e);let t=s.join(``);s.length=0,c=0,y(S(t)),x()}function v(e){if(e.length===0)return e;if(g)return g=!1,e.charCodeAt(0)===10?e.slice(1):e;let t=e.indexOf(`\r`),n=e.indexOf(`
|
|
4
4
|
`),r=t===-1?n:n===-1||t<n?t:n;return r===-1?``:r===e.length-1&&e.charCodeAt(r)===13?(h=!1,g=!0,``):(h=!1,e.slice(r+(e.charCodeAt(r)===13&&e.charCodeAt(r+1)===10?2:1)))}function y(e){if(e){if(e.charCodeAt(e.length-1)===13){w(e,0,e.length-1),g=!0;return}if(b(e)){s.push(e),c=e.length;return}h=!0}}function b(e){let t=e.charCodeAt(0);return t===58&&!!n||t===100&&D(e,`data`)||t===101&&D(e,`event`)||t===105&&D(e,`id`)||t===114&&D(e,`retry`)}function x(){t!==void 0&&(c+d.length<=t||(m=!0,s.length=0,c=0,u=void 0,d=``,f=0,p=void 0,h=!1,g=!1,r?.(new C(`Buffered data exceeded max buffer size of ${t} characters`,{type:`max-buffer-size-exceeded`}))))}function S(e){let t=0;if(e.indexOf(`\r`)===-1){let n=e.indexOf(`
|
|
5
5
|
`,t);for(;n!==-1;){if(t===n){u!==void 0&&a?.(u),f>0&&i?.({id:u,event:p,data:d}),u=void 0,d=``,f=0,p=void 0,t=n+1,n=e.indexOf(`
|
|
6
6
|
`,t);continue}let r=e.charCodeAt(t);if(T(e,t,r)){let r=e.charCodeAt(t+5)===32?t+6:t+5,o=e.slice(r,n);if(f===0&&e.charCodeAt(n+1)===10){u!==void 0&&a?.(u),i?.({id:u,event:p,data:o}),u=void 0,d=``,p=void 0,t=n+2,n=e.indexOf(`
|
|
7
7
|
`,t);continue}d=f===0?o:`${d}\n${o}`,f++}else E(e,t,r)?p=e.slice(e.charCodeAt(t+6)===32?t+7:t+6,n)||void 0:w(e,t,n);t=n+1,n=e.indexOf(`
|
|
8
8
|
`,t)}return e.slice(t)}for(;t<e.length;){let n=e.indexOf(`\r`,t),r=e.indexOf(`
|
|
9
|
-
`,t),i=-1;if(n!==-1&&r!==-1?i=n<r?n:r:n===-1?r!==-1&&(i=r):i=n===e.length-1?-1:n,i===-1)break;w(e,t,i),t=i+1,e.charCodeAt(t-1)===13&&e.charCodeAt(t)===10&&t++}return e.slice(t)}function w(e,t,r){if(t===r){k();return}let i=e.charCodeAt(t);if(T(e,t,i)){let n=e.charCodeAt(t+5)===32?t+6:t+5,i=e.slice(n,r);d=f===0?i:`${d}\n${i}`,f++;return}if(E(e,t,i)){p=e.slice(e.charCodeAt(t+6)===32?t+7:t+6,r)||void 0;return}if(i===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let n=e.slice(e.charCodeAt(t+3)===32?t+4:t+3,r);n.includes(`\0`)||(u=n);return}if(i===58){if(n){let i=e.slice(t,r);n(i.slice(e.charCodeAt(t+1)===32?2:1))}return}let a=e.slice(t,r),o=a.indexOf(`:`);if(o===-1){O(a,``,a);return}let s=a.slice(0,o),c=a.charCodeAt(o+1)===32?2:1;O(s,a.slice(o+c),a)}function O(e,t,n){switch(e){case`event`:p=t||void 0;break;case`data`:d=f===0?t:`${d}\n${t}`,f++;break;case`id`:t.includes(`\0`)||(u=t);break;case`retry`:/^\d+$/.test(t)?o?.(parseInt(t,10)):r?.(new C(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:n}));break;default:r?.(new C(`Unknown field "${e.length>20?`${e.slice(0,20)}…`:e}"`,{type:`unknown-field`,field:e,value:t,line:n}))}}function k(){u!==void 0&&a?.(u),f>0&&i?.({id:u,event:p,data:d}),u=void 0,d=``,f=0,p=void 0}function A(e={}){if(e.consume&&s.length>0){let e=s.join(``);w(e,0,e.length)}l=!0,u=void 0,d=``,f=0,p=void 0,s.length=0,c=0,m=!1,h=!1,g=!1}return{feed:_,reset:A}}function T(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function E(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}function D(e,t){let n=1;for(;n<e.length&&n<t.length;){if(e.charCodeAt(n)!==t.charCodeAt(n))return!1;n++}return e.length<=t.length||e.charCodeAt(t.length)===58}var O=class extends TransformStream{constructor(){let e;super({start(t){e=w({onEvent(e){let n={type:`event`,...e};t.enqueue(n)}})},transform(t){e.feed(t)}})}};let k;if(globalThis.TextDecoderStream&&typeof globalThis.TextDecoderStream==`function`)k=globalThis.TextDecoderStream;else{class e extends TransformStream{_options;constructor(e=`utf-8`,{fatal:n=!1,ignoreBOM:r=!1}={}){super(new t(new TextDecoder(e,{fatal:n,ignoreBOM:r}))),this._options={fatal:n,ignoreBOM:r,encoding:e}}get encoding(){return this._options.encoding}get fatal(){return this._options.fatal}get ignoreBOM(){return this._options.ignoreBOM}}class t{decoder;constructor(e){this.decoder=e}transform(e,t){if(!(e instanceof ArrayBuffer||ArrayBuffer.isView(e)))throw TypeError(`Input must be a compatible with: ArrayBuffer | Uint8Array`);let n=this.decoder.decode(e,{stream:!0});n.length!==0&&t.enqueue(n)}flush(e){let t=this.decoder.decode();t.length!==0&&e.enqueue(t)}}k=e}async function A(e){if(!e.ok){let t=await e.text(),n=Error(`SSE error: ${e.status}. Content:\n${t}`);throw n.status=e.status,n}if(!e.body)throw Error(`No body in response`);return e.body.pipeThrough(new k).pipeThrough(new O)}function j(e){let t=[];for(let n of Object.keys(e)){let r=e[n];if(r==null)continue;let i=encodeURIComponent(n);for(let e of Array.isArray(r)?r:[r])e!=null&&t.push(`${i}=${encodeURIComponent(String(e))}`)}return t.join(`&`)}function M(e,t){return e.endsWith(`/`)?t.startsWith(`/`)?e+t.substring(1):e+t:t.startsWith(`/`)?e+t:`${e}/${t}`}function N(e){return e[e.length-1]===`/`?e.slice(0,-1):e}const ee=`x-ratelimit-reason`,te=`x-ratelimit-retry-ms`;function ne(e){if(e!==!1&&e!==null&&e?.enabled!==!1)return{maxWaitMs:Math.max(0,e?.maxWaitMs??3e3),attempts:Math.max(0,Math.floor(e?.attempts??2))}}const re=[`GET`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`],ie=[502,503,504];function P(e){return typeof e==`object`&&!!e}function ae(e){return e?Promise.resolve(e):typeof globalThis.fetch==`function`?Promise.resolve(globalThis.fetch):Promise.resolve(()=>{throw Error(`No Fetch implementation found`)})}function oe(e){return P(e)&&e.error===`Not a valid JSON payload`&&typeof e.text==`string`}function se(e){return!e||typeof ReadableStream>`u`||!(e instanceof ReadableStream)}function ce(e){return e.status<500?!1:!(e.headers.get(`content-type`)??``).toLowerCase().includes(`json`)}function le(e){let t=Math.max(1,Math.floor(e.attempts??3)),n=Math.max(0,e.baseDelayMs??250),r=Math.max(n,e.maxDelayMs??4e3);return{attempts:t,methods:new Set((e.methods??re).map(e=>e.toUpperCase())),statuses:new Set(e.statuses??ie),retryNonJsonServerErrors:e.retryNonJsonServerErrors??!0,retryOnConnectionError:e.retryOnConnectionError??!0,baseDelayMs:n,maxDelayMs:r,jitter:e.jitter??!0}}function F(e){let t=e.headers.get(`x-retry-after-ms`);if(t){let e=Number(t);if(Number.isFinite(e)&&e>=0)return e}let n=e.headers.get(`retry-after`);if(!n)return;let r=Number(n);if(Number.isFinite(r)&&r>=0)return r*1e3;let i=Date.parse(n);if(!Number.isNaN(i))return Math.max(0,i-Date.now())}function ue(e,t){if(e.status!==429||e.headers.get(ee)!==`pacing`)return;let n=e.headers.get(te),r=n?Number(n):NaN,i=Number.isFinite(r)&&r>=0?r:F(e);if(!(i===void 0||i>t.maxWaitMs))return i}function de(e){if(e.status!==429)return;let t=e.headers.get(ee);if(t!==`pacing`&&t!==`quota`)return;let n=e.headers.get(te),r=n?Number(n):NaN,i=Number.isFinite(r)&&r>=0?r:F(e);if(i!==void 0)return{reason:t,retryAfterMs:i,resource:e.headers.get(`x-ratelimit-resource`)??void 0,window:e.headers.get(`x-ratelimit-window`)??void 0}}function fe(e){return new Promise(t=>setTimeout(t,e))}function pe(e,t,n){let r=(n?F(n):void 0)??Math.min(e.maxDelayMs,e.baseDelayMs*2**t);return e.jitter?Math.floor(Math.random()*r):r}function me(e){return e instanceof Error?e:Error(String(e))}function he(e){return typeof e==`object`&&!!e&&`name`in e&&(e.name===`TimeoutError`||e.name===`AbortError`)}function ge(e){let t=AbortSignal.timeout;if(typeof t==`function`)return t(e);let n=new AbortController;return setTimeout(()=>n.abort(new DOMException(`The operation timed out`,`TimeoutError`)),e),n.signal}function _e(e){let t=e.filter(e=>!!e);if(t.length===0)return;if(t.length===1)return t[0];let n=AbortSignal.any;if(typeof n==`function`)return n(t);let r=new AbortController;for(let e of t){if(e.aborted){r.abort(e.reason);break}e.addEventListener(`abort`,()=>r.abort(e.reason),{once:!0})}return r.signal}async function ve(e){try{await e.body?.cancel()}catch{}}var I=class{_fetch;baseUrl;errorFactory=e=>e;verboseErrors=!0;retryPolicy;pacingRetry;defaultTimeoutMs;constructor(e,t){this.baseUrl=N(e),this._fetch=ae(t)}throwError(e){throw this.errorFactory(e)}withPacingRetry(e){return this.pacingRetry=e===null?void 0:e,this}withRetryPolicy(e){return this.retryPolicy=e||void 0,this}getRetryPolicy(){return this.retryPolicy}withTimeout(e){return this.defaultTimeoutMs=typeof e==`number`&&e>0?e:void 0,this}getTimeout(){return this.defaultTimeoutMs}resolveTimeout(e){if(e?.reader===`sse`)return;let t=e?.timeoutMs;if(t===!1||t===null)return;if(typeof t==`number`)return t>0?t:void 0;let n=this.getTimeout();return n&&n>0?n:void 0}getUrl(e){return e.startsWith(`http://`)||e.startsWith(`https://`)?N(e):N(M(this.baseUrl,e))}get(e,t){return this.request(`GET`,e,t)}del(e,t){return this.request(`DELETE`,e,t)}delete(e,t){return this.request(`DELETE`,e,t)}post(e,t){return this.request(`POST`,e,t)}put(e,t){return this.request(`PUT`,e,t)}jsonParse(e){return JSON.parse(e)}createRequest(e,t){return Promise.resolve(new Request(e,t))}handleFetchResponse(e,t){}createServerError(e,t,n){let r=`Server Error: ${t.status}`;return n&&(oe(n)?(r+=t.statusText?` ${t.statusText}`:``,r+=`: non-JSON response`):P(n)&&n.message?r=String(n.message):P(n)&&n.error&&(typeof n.error==`string`?r=String(n.error):P(n.error)&&typeof n.error.message==`string`&&(r=n.error.message))),new x(r,e,t.status,n,this.verboseErrors,de(t),F(t))}async readJSONPayload(e){return e.text().then(t=>{if(t)try{return this.jsonParse(t)}catch(n){return{status:e.status,error:`Not a valid JSON payload`,message:n instanceof Error?n.message:String(n),text:t}}}).catch(t=>{if(he(t))throw t;return{status:e.status,error:`Unable to load response content`,message:t instanceof Error?t.message:String(t)}})}handleResponse(e,t,n){return n?.reader?n.reader===`sse`?A(t):n.reader.call(this,t):this.readJSONPayload(t).then(n=>{if(t.ok)return n;this.throwError(this.createServerError(e,t,n))})}async request(e,t,n){let r=this.getUrl(t);n?.query&&(r+=`?${j(n.query)}`);let i=this.headers?Object.assign({},this.headers):{},a=n?.headers;if(a)for(let e in a)i[e.toLowerCase()]=a[e];let o,s=n?.payload;s&&(n&&n.jsonPayload===!1?o=s:(o=typeof s==`string`?s:JSON.stringify(s),`content-type`in i||(i[`content-type`]=`application/json`))),n?.reader===`sse`&&(i.accept=`text/event-stream`);let c=e.toUpperCase(),l=this.resolveTimeout(n),u=()=>{let e=_e([n?.signal,l?ge(l):void 0]),t={method:c,headers:Object.assign({},i),body:o};return e&&(t.signal=e),t},d=this.resolveRetryPolicy(n),f=n?.reader===`sse`?void 0:ne(n?.pacingRetry??this.pacingRetry),p=await this._fetch,m=se(o),h=0,g=0,_;for(;;){let e=await this.createRequest(r,u());_=e;let t;try{t=await p(e)}catch(t){(!d||!this.shouldRetryConnectionError(d,c,h,m))&&(console.error(`Failed to connect to ${r}`,t),this.throwError(new S(e,me(t)))),await this.waitBeforeRetry(d,h),h++;continue}if(this.handleFetchResponse(e,t),f&&g<f.attempts&&m){let e=ue(t,f);if(e!==void 0){await ve(t),await fe(e),g++;continue}}if(d&&this.shouldRetryResponse(d,c,h,m,t)){await ve(t),await this.waitBeforeRetry(d,h,t),h++;continue}if(d&&h>=d.attempts)break;return this.handleResponse(e,t,n)}throw _&&this.throwError(new S(_,Error(`Retry attempts exhausted for ${c} ${r}`))),Error(`Retry attempts exhausted for ${c} ${r}`)}resolveRetryPolicy(e){if(e?.reader===`sse`||e?.retryPolicy===!1||e?.retryPolicy===null)return;let t=e?.retryPolicy,n=this.getRetryPolicy();if(!t&&!n)return;let r=le({...n,...t});return r.attempts>1?r:void 0}shouldRetryResponse(e,t,n,r,i){let a=e.statuses.has(i.status)||e.retryNonJsonServerErrors&&ce(i);return n<e.attempts-1&&r&&e.methods.has(t)&&a}shouldRetryConnectionError(e,t,n,r){return n<e.attempts-1&&r&&e.retryOnConnectionError&&e.methods.has(t)}waitBeforeRetry(e,t,n){let r=pe(e,t,n);return new Promise(e=>setTimeout(e,r))}async sseRequest(e,t,n,r){let i=(await this.request(e,t,{...n,reader:`sse`})).getReader(),a;try{for(;;){let{done:e,value:t}=await i.read();if(e)break;a=t,r(t)}}finally{i.releaseLock()}return a}fetch(e,t){return this._fetch.then(n=>n(e,t))}};function ye(e){return e?`authorization`in e:!1}function be(){let e=globalThis;return e.window===void 0&&(typeof e.process?.versions?.node==`string`||typeof e.process?.versions?.bun==`string`||e.Bun!==void 0)}var xe=class extends I{headers;_auth;onRequest;onResponse;response;constructor(e,t){super(e,t),this.baseUrl=e[e.length-1]===`/`?e.substring(0,e.length-1):e,this.headers=this.initialHeaders}get initialHeaders(){let e={accept:`application/json`};return be()&&(e[`accept-encoding`]=`br, gzip, deflate`),e}withAuthCallback(e){return this._auth=e||void 0,this}withErrorFactory(e){return this.errorFactory=e,this}withLang(e){return e?this.headers[`accept-language`]=e:delete this.headers[`accept-language`],this}withHeaders(e){let t=this.headers;for(let n in e){let r=e[n];r!=null&&(t[n.toLowerCase()]=r)}return this}setHeader(e,t){t?this.headers[e.toLowerCase()]=t:delete this.headers[e.toLowerCase()]}async createRequest(e,t){if(this._auth&&!ye(t.headers)){t.headers=t.headers?t.headers:{};let e=await this._auth();e&&(t.headers.authorization=e)}this.response=void 0;let n=await super.createRequest(e,t);return this.onRequest?.(n),n}handleFetchResponse(e,t){this.response=t,this.onResponse?.(t,e)}},L=class extends I{client;constructor(e,t){super(e.getUrl(t),e._fetch),this.client=e,this.createServerError=e.createServerError,this.errorFactory=e.errorFactory,this.verboseErrors=e.verboseErrors}createRequest(e,t){return this.client.createRequest(e,t)}handleResponse(e,t,n){return this.client.handleResponse(e,t,n)}handleFetchResponse(e,t){this.client.handleFetchResponse(e,t)}getRetryPolicy(){return this.client.getRetryPolicy()}getTimeout(){return this.client.getTimeout()}get headers(){return this.client.headers}},Se=class extends L{constructor(e){super(e,`/api/v1/account/apikeys`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}},Ce=class extends L{apikeys;constructor(e){super(e,`/api/v1/account`),this.apikeys=new Se(e)}info(){return this.get(`/`)}update(e){return this.put(`/`,{payload:e})}projects(){return this.get(`/projects`).then(e=>e.data)}members(){return this.get(`/members`)}inviteUser(e){return this.post(`/invites`,{payload:e})}listInvites(){return this.get(`/invites`)}listInvitation(e=`project`){return this.get(`/invites/${e}`)}acceptInvite(e){return this.put(`/invites/${e}`)}rejectInvite(e){return this.del(`/invites/${e}`)}onboardingProgress(){return this.get(`/onboarding`)}getStripeBillingStatus(){return this.get(`/stripe-billing-status`)}},we=class extends L{constructor(e){super(e,`/api/v1/accounts`)}create(e){return this.post(`/`,{payload:{name:e}})}list(){return this.get(`/`)}},Te=class extends L{constructor(e){super(e,`/api/v1/analytics`)}runsSummary(e,t){let n=new URLSearchParams;e?.start&&n.set(`start`,e.start),e?.end&&n.set(`end`,e.end),t&&n.set(`environment`,t);let r=n.toString();return this.get(`/runs/summary${r?`?${r}`:``}`)}runsTimeSeries(e,t){let n=new URLSearchParams;e?.start&&n.set(`start`,e.start),e?.end&&n.set(`end`,e.end),t&&n.set(`environment`,t);let r=n.toString();return this.get(`/runs/time-series${r?`?${r}`:``}`)}runsTokenUsage(e,t){let n=new URLSearchParams;e?.start&&n.set(`start`,e.start),e?.end&&n.set(`end`,e.end),t&&n.set(`environment`,t);let r=n.toString();return this.get(`/runs/token-usage${r?`?${r}`:``}`)}},Ee=class extends L{constructor(e){super(e,`/api/v1/apikeys`)}list(e=`account`){return this.get(`/`,{query:{level:e}})}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}retrieve(e,t=!1){return t?this.get(`/${e}`,{query:{withValue:!0}}):this.get(`/${e}`)}delete(e){return this.del(`/${e}`)}getToken(e){return this.get(`/${e}/token`)}requestPublicKey(e={}){return this.get(`/pk`,{query:e})}},De=class extends L{constructor(e){super(e,`/api/v1/apps`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}previewDelete(e){return this.del(`/${e}`)}setMcpCollectionApiKey(e,t,n){return this.put(`/${encodeURIComponent(e)}/collections/${encodeURIComponent(t)}/api-key`,{payload:{api_key:n}})}getMcpCollectionApiKeyStatus(e,t){return this.get(`/${encodeURIComponent(e)}/collections/${encodeURIComponent(t)}/api-key`)}deleteMcpCollectionApiKey(e,t){return this.del(`/${encodeURIComponent(e)}/collections/${encodeURIComponent(t)}/api-key`)}deleteApp(e){return this.del(`/${e}`,{query:{confirm:`true`}})}listVersions(e){return this.get(`/versions`,{query:{...e?.app_id&&{app_id:e.app_id},...e?.kind&&{kind:e.kind},...e?.include_expired!==void 0&&{include_expired:e.include_expired},...e?.limit!==void 0&&{limit:e.limit}}})}upsertVersion(e){return this.post(`/versions`,{payload:e})}getVersion(e){return this.get(`/versions/${e}`)}promoteVersion(e){return this.post(`/versions/${e}/promote`)}rebuildVersion(e){return this.post(`/versions/${e}/rebuild`)}deleteVersion(e){return this.del(`/versions/${e}`)}startBuild(e,t){return this.post(`/${encodeURIComponent(e)}/builds`,{payload:t})}getBuildProgress(e,t,n){return this.get(`/${encodeURIComponent(e)}/builds/${encodeURIComponent(t)}/${encodeURIComponent(n)}/progress`)}startScaffold(e){return this.post(`/scaffolds`,{payload:e})}getScaffoldProgress(e,t){return this.get(`/scaffolds/${encodeURIComponent(e)}/${encodeURIComponent(t)}/progress`)}listAppInstallationTools(e){return this.get(`/installations/${e}/tools`)}inspect(e){return this.get(`/${e}/inspect`)}getRepoTree(e,t){return this.get(`/${encodeURIComponent(e)}/repo/tree`,{query:{prefix:t?.prefix,ref:t?.ref}})}async getRepoFile(e,t,n){let r=`/${encodeURIComponent(e)}/repo/file`,i=await this.get(r,{query:{path:t,ref:n?.ref},reader:e=>e});if(!i.ok){let e=await this.readJSONPayload(i),t=await this.createRequest(i.url||this.getUrl(r),{method:`GET`});throw this.createServerError(t,i,e)}return i}commitRepoDocuments(e,t,n){let r=new FormData,i={ref:n.ref,expected_head:n.expectedHead,message:n.message||`Upload documentation`,files:t.map((e,t)=>({field:`file_${t}`,path:e.path}))};return r.append(`metadata`,JSON.stringify(i)),t.forEach((e,t)=>{r.append(`file_${t}`,e.content,e.fileName||e.path.split(`/`).pop()||`document`)}),this.post(`/${encodeURIComponent(e)}/repo/documents`,{payload:r,jsonPayload:!1,timeoutMs:12e4})}getRepoCommits(e,t,n){return this.get(`/${encodeURIComponent(e)}/repo/commits`,{query:{path:t,ref:n?.ref,limit:n?.limit,cursor:n?.cursor}})}getRepoRefs(e){return this.get(`/${encodeURIComponent(e)}/repo/refs`)}listDevelopmentTasks(e){return this.get(`/${encodeURIComponent(e)}/development-tasks`)}getDevelopmentTask(e,t){return this.get(`/${encodeURIComponent(e)}/development-tasks/${encodeURIComponent(t)}`)}startDevelopmentTask(e,t,n){return this.post(`/${encodeURIComponent(e)}/development-tasks/${encodeURIComponent(t)}/runs`,{payload:n})}createRepoBranch(e,t){return this.post(`/${encodeURIComponent(e)}/repo/branches`,{payload:t})}getAppPackage(e,t=`all`){return this.get(`/${encodeURIComponent(e)}/package`,{query:{scope:Array.isArray(t)?t.join(`,`):t}})}getAppInstallationPackage(e,t=`all`){return this.get(`/installations/${e}/package`,{query:{scope:Array.isArray(t)?t.join(`,`):t}})}getSystemToolsPackage(e=`tools`){return this.get(`/studio-tools/package`,{query:{scope:e}})}list(e){return this.get(`/`,{query:{...e?.scope&&{scope:e.scope}}})}install(e,t,n,r,i){return this.post(`/install`,{payload:{app_id:e,settings:t,oauth_params:n,oauth_provider_params:r,api_key_params:i}})}uninstall(e){return this.del(`/install/${e}`)}getAppInstallationByName(e){return this.get(`/installations/name/${e}`).catch(e=>{if(e.status===404)return null;throw e})}getAppInstallationProjects(e){if(!e.id&&!e.name)throw Error(`Invalid arguments: appId or appName must be specified`);let t=e.id?{id:e.id}:{name:e.name};return this.get(`/installations/projects`,{query:t})}getInstalledApps(e){return this.get(`/installations`,{query:{kind:e}})}getAllAppInstallations(){return this.get(`/installations/all`)}listInstallations(){return this.get(`/installations/refs`)}updateInstallationSettings(e){return this.put(`/installations/settings/${e.app_id}`,{payload:{app_id:e.app_id,settings:e.settings,...`access_control`in e?{access_control:e.access_control}:{}}})}updateToolAllowlist(e,t){return this.put(`/installations/${e}/tool-allowlist`,{payload:{tool_allowlist:t}})}validateUrl(e){return this.post(`/validate-url`,{payload:{url:e}})}},Oe=class extends L{constructor(e){super(e,`/api/v1/audit-trail`)}list(e){let t=new URLSearchParams;e?.actions?.length&&t.set(`actions`,e.actions.join(`,`)),e?.resourceTypes?.length&&t.set(`resourceTypes`,e.resourceTypes.join(`,`)),e?.resourceId&&t.set(`resourceId`,e.resourceId),e?.principalId&&t.set(`principalId`,e.principalId),e?.principalType&&t.set(`principalType`,e.principalType),e?.effectivePrincipalId&&t.set(`effectivePrincipalId`,e.effectivePrincipalId),e?.hasEffectivePrincipal!==void 0&&t.set(`hasEffectivePrincipal`,String(e.hasEffectivePrincipal)),e?.projectId&&t.set(`projectId`,e.projectId),e?.from&&t.set(`from`,e.from),e?.to&&t.set(`to`,e.to),e?.limit&&t.set(`limit`,String(e.limit)),e?.offset&&t.set(`offset`,String(e.offset));let n=t.toString();return this.get(`/${n?`?${n}`:``}`)}aggregate(e){return this.post(`/aggregate`,{payload:e})}},ke=class extends L{constructor(e){super(e,`/api/v1/commands`)}async isNamespaceAvailable(e){return this.get(`/namespaces/${e}/is_available`).then(e=>e.available)}async initSamples(){return this.post(`/onboarding/init-samples`)}},Ae=class extends L{constructor(e){super(e,`/api/v1/iam/delegation-grants`)}create(e){return this.post(`/`,{payload:e})}list(){return this.get(`/`)}mine(){return this.get(`/me`)}retrieve(e){return this.get(`/${e}`)}revoke(e){return this.post(`/${e}/revoke`)}},je=class extends L{constructor(e){super(e,`/api/v1/environments`)}list(e=!1){let t=e?{all:!0}:void 0;return this.get(`/`,{query:t})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}updateConfig(e,t){return this.put(`/${e}/config`,{payload:t})}listModels(e,t){return this.get(`/${e}/models`,{query:t?{...t}:void 0})}enableModel(e,t){return this.post(`/${e}/models/enabled`,{payload:t})}disableModel(e,t){return this.del(`/${e}/models/enabled/${encodeURIComponent(t)}`)}listTrainableModels(e){return this.get(`/${e}/trainable-models`)}embeddings(e,t){return this.post(`/${e}/embeddings`,{payload:t})}embeddingBatchCapability(e,t){return this.post(`/${e}/embedding-batches/capability`,{payload:t})}createEmbeddingBatch(e,t){return this.post(`/${e}/embedding-batches`,{payload:t})}getEmbeddingBatch(e,t){return this.post(`/${e}/embedding-batches/get`,{payload:t})}cancelEmbeddingBatch(e,t){return this.post(`/${e}/embedding-batches/cancel`,{payload:t})}deleteEmbeddingBatch(e,t){return this.post(`/${e}/embedding-batches/delete`,{payload:t})}migrateInteractions(e){return this.post(`/migrate-interactions`,{payload:e})}},Me=class extends L{constructor(e){super(e,`/groups`)}list(e){return this.get(`/`,{query:e})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}listMembers(e){return this.get(`/${e}/members`)}addMember(e,t){return this.post(`/${e}/members/${t}`)}removeMember(e,t){return this.del(`/${e}/members/${t}`)}syncMembers(){return this.post(`/sync-members`)}},Ne=class extends L{constructor(e){super(e,`/api/v1/iam`)}aces=new Fe(this);roles=new Pe(this);groups=new Me(this);getPrincipalIdentity(){return this.get(`/users/identity`)}},Pe=class extends L{constructor(e){super(e,`/roles`)}list(){return this.get(`/`)}listSystem(e){return this.get(`/system`,e)}},Fe=class extends L{constructor(e){super(e,`/aces`)}list(e){return this.get(`/`,{query:{...e}})}listProjectAces(){return this.get(`/project`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}};const Ie=(()=>{let e=typeof process<`u`?process.env?.VERTESIA_INTERACTION_TIMEOUT_MS:void 0,t=e?Number.parseInt(e,10):NaN;return Number.isFinite(t)&&t>0?t:18e5})();async function R(){return typeof globalThis.EventSource==`function`?globalThis.EventSource:(await import(`eventsource`)).EventSource}async function Le(e,t,n={},r){let i=!!r,a=await e.runs.create({...n,interaction:t,stream:i},{timeoutMs:i?void 0:Ie});if(i){if(a.status===o.failed)return a;await ze(e,a.id,r)}return a}async function Re(e,t,n={},r,i){let a=!!r,s=await e.post(`/api/v1/execute`,{...i,payload:{...n,interaction:t,stream:a},timeoutMs:i?.timeoutMs??(a?void 0:Ie)});if(a){if(s.status===o.failed)return s;await ze(e,s.id,r)}return s}function ze(e,t,n){return new Promise((r,i)=>{(async()=>{try{let a=await R(),o=new URL(`${e.runs.baseUrl}/${t}/stream`),s=e._auth?await e._auth():void 0;if(s){let e=s.split(` `)[1];o.searchParams.set(`access_token`,e)}else throw Error(`No auth token available`);let c=new a(o.href);c.addEventListener(`message`,e=>{try{let t=JSON.parse(e.data);t&&n?.(t)}catch(e){i(e)}}),c.addEventListener(`close`,e=>{try{c.close(),r(JSON.parse(e.data))}catch(e){i(e)}})}catch(e){i(e)}})()})}async function Be(e,t){return await e.post(`/api/v1/execute/async`,{payload:t})}async function Ve(e,t){return await e.post(`/api/v1/execute/rate-limit/request`,{payload:t})}var He=class extends L{constructor(e){super(e,`/api/v1/interactions/catalog`)}list(e={}){return this.get(`/`,{query:e})}listStoredInteractions(e={}){return this.get(`/stored`,{query:e})}listSysInteractions(e){return this.get(`/sys`,{query:{tag:e}})}listAppInteractions(e,t){return this.get(`/apps/${e}`,{query:{tag:t}})}listAllAppInteractions(e){return this.get(`/apps`,{query:{tag:e}})}resolve(e){return this.get(`/resolve/${e}`)}};const z=Symbol(`InteractionOutput`);function B(e){return e.result=V.from(e.result),e}function Ue(e){return e.result=V.from(e.result),e}var V=class{results;constructor(e){this.results=e}static from(e){return e?We(e)?e:H(Array.isArray(e)?e:typeof e==`object`?[{type:`json`,value:e}]:[{type:`text`,value:String(e)}]):H([])}static isInteractionOutputArray(e){return We(e)}get isEmpty(){return this.results.length===0}hasObject(){return this.results.some(e=>e.type===`json`)}hasText(){return this.results.some(e=>e.type===`text`)}hasThoughts(){return this.results.some(e=>e.type===`thoughts`)}hasImage(){return this.results.some(e=>e.type===`image`)}hasVideo(){return this.results.some(e=>e.type===`video`)}text(e=`
|
|
9
|
+
`,t),i=-1;if(n!==-1&&r!==-1?i=n<r?n:r:n===-1?r!==-1&&(i=r):i=n===e.length-1?-1:n,i===-1)break;w(e,t,i),t=i+1,e.charCodeAt(t-1)===13&&e.charCodeAt(t)===10&&t++}return e.slice(t)}function w(e,t,r){if(t===r){k();return}let i=e.charCodeAt(t);if(T(e,t,i)){let n=e.charCodeAt(t+5)===32?t+6:t+5,i=e.slice(n,r);d=f===0?i:`${d}\n${i}`,f++;return}if(E(e,t,i)){p=e.slice(e.charCodeAt(t+6)===32?t+7:t+6,r)||void 0;return}if(i===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let n=e.slice(e.charCodeAt(t+3)===32?t+4:t+3,r);n.includes(`\0`)||(u=n);return}if(i===58){if(n){let i=e.slice(t,r);n(i.slice(e.charCodeAt(t+1)===32?2:1))}return}let a=e.slice(t,r),o=a.indexOf(`:`);if(o===-1){O(a,``,a);return}let s=a.slice(0,o),c=a.charCodeAt(o+1)===32?2:1;O(s,a.slice(o+c),a)}function O(e,t,n){switch(e){case`event`:p=t||void 0;break;case`data`:d=f===0?t:`${d}\n${t}`,f++;break;case`id`:t.includes(`\0`)||(u=t);break;case`retry`:/^\d+$/.test(t)?o?.(parseInt(t,10)):r?.(new C(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:n}));break;default:r?.(new C(`Unknown field "${e.length>20?`${e.slice(0,20)}…`:e}"`,{type:`unknown-field`,field:e,value:t,line:n}))}}function k(){u!==void 0&&a?.(u),f>0&&i?.({id:u,event:p,data:d}),u=void 0,d=``,f=0,p=void 0}function A(e={}){if(e.consume&&s.length>0){let e=s.join(``);w(e,0,e.length)}l=``,u=void 0,d=``,f=0,p=void 0,s.length=0,c=0,m=!1,h=!1,g=!1}return{feed:_,reset:A}}function T(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function E(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}function D(e,t){let n=1;for(;n<e.length&&n<t.length;){if(e.charCodeAt(n)!==t.charCodeAt(n))return!1;n++}return e.length<=t.length||e.charCodeAt(t.length)===58}var O=class extends TransformStream{constructor(){let e;super({start(t){e=w({onEvent(e){let n={type:`event`,...e};t.enqueue(n)}})},transform(t){e.feed(t)}})}};let k;if(globalThis.TextDecoderStream&&typeof globalThis.TextDecoderStream==`function`)k=globalThis.TextDecoderStream;else{class e extends TransformStream{_options;constructor(e=`utf-8`,{fatal:n=!1,ignoreBOM:r=!1}={}){super(new t(new TextDecoder(e,{fatal:n,ignoreBOM:r}))),this._options={fatal:n,ignoreBOM:r,encoding:e}}get encoding(){return this._options.encoding}get fatal(){return this._options.fatal}get ignoreBOM(){return this._options.ignoreBOM}}class t{decoder;constructor(e){this.decoder=e}transform(e,t){if(!(e instanceof ArrayBuffer||ArrayBuffer.isView(e)))throw TypeError(`Input must be a compatible with: ArrayBuffer | Uint8Array`);let n=this.decoder.decode(e,{stream:!0});n.length!==0&&t.enqueue(n)}flush(e){let t=this.decoder.decode();t.length!==0&&e.enqueue(t)}}k=e}async function A(e){if(!e.ok){let t=await e.text(),n=Error(`SSE error: ${e.status}. Content:\n${t}`);throw n.status=e.status,n}if(!e.body)throw Error(`No body in response`);return e.body.pipeThrough(new k).pipeThrough(new O)}function ee(e){let t=[];for(let n of Object.keys(e)){let r=e[n];if(r==null)continue;let i=encodeURIComponent(n);for(let e of Array.isArray(r)?r:[r])e!=null&&t.push(`${i}=${encodeURIComponent(String(e))}`)}return t.join(`&`)}function te(e,t){return e.endsWith(`/`)?t.startsWith(`/`)?e+t.substring(1):e+t:t.startsWith(`/`)?e+t:`${e}/${t}`}function j(e){return e[e.length-1]===`/`?e.slice(0,-1):e}const M=`x-ratelimit-reason`,ne=`x-ratelimit-retry-ms`;function re(e){if(e!==!1&&e!==null&&e?.enabled!==!1)return{maxWaitMs:Math.max(0,e?.maxWaitMs??3e3),attempts:Math.max(0,Math.floor(e?.attempts??2))}}const ie=[`GET`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`],ae=[502,503,504];function N(e){return typeof e==`object`&&!!e}function oe(e){return e?Promise.resolve(e):typeof globalThis.fetch==`function`?Promise.resolve(globalThis.fetch):Promise.resolve(()=>{throw Error(`No Fetch implementation found`)})}function se(e){return N(e)&&e.error===`Not a valid JSON payload`&&typeof e.text==`string`}function ce(e){return!e||typeof ReadableStream>`u`||!(e instanceof ReadableStream)}function le(e){return e.status<500?!1:!(e.headers.get(`content-type`)??``).toLowerCase().includes(`json`)}function ue(e){let t=Math.max(1,Math.floor(e.attempts??3)),n=Math.max(0,e.baseDelayMs??250),r=Math.max(n,e.maxDelayMs??4e3);return{attempts:t,methods:new Set((e.methods??ie).map(e=>e.toUpperCase())),statuses:new Set(e.statuses??ae),retryNonJsonServerErrors:e.retryNonJsonServerErrors??!0,retryOnConnectionError:e.retryOnConnectionError??!0,baseDelayMs:n,maxDelayMs:r,jitter:e.jitter??!0}}function P(e){let t=e.headers.get(`x-retry-after-ms`);if(t){let e=Number(t);if(Number.isFinite(e)&&e>=0)return e}let n=e.headers.get(`retry-after`);if(!n)return;let r=Number(n);if(Number.isFinite(r)&&r>=0)return r*1e3;let i=Date.parse(n);if(!Number.isNaN(i))return Math.max(0,i-Date.now())}function de(e,t){if(e.status!==429||e.headers.get(M)!==`pacing`)return;let n=e.headers.get(ne),r=n?Number(n):NaN,i=Number.isFinite(r)&&r>=0?r:P(e);if(!(i===void 0||i>t.maxWaitMs))return i}function fe(e){if(e.status!==429)return;let t=e.headers.get(M);if(t!==`pacing`&&t!==`quota`)return;let n=e.headers.get(ne),r=n?Number(n):NaN,i=Number.isFinite(r)&&r>=0?r:P(e);if(i!==void 0)return{reason:t,retryAfterMs:i,resource:e.headers.get(`x-ratelimit-resource`)??void 0,window:e.headers.get(`x-ratelimit-window`)??void 0}}function pe(e){return new Promise(t=>setTimeout(t,e))}function me(e,t,n){let r=(n?P(n):void 0)??Math.min(e.maxDelayMs,e.baseDelayMs*2**t);return e.jitter?Math.floor(Math.random()*r):r}function he(e){return e instanceof Error?e:Error(String(e))}function ge(e){return typeof e==`object`&&!!e&&`name`in e&&(e.name===`TimeoutError`||e.name===`AbortError`)}function _e(e){return typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`}function ve(e){let t=AbortSignal.timeout;if(typeof t==`function`)return t(e);let n=new AbortController;return setTimeout(()=>n.abort(new DOMException(`The operation timed out`,`TimeoutError`)),e),n.signal}function ye(e){let t=e.filter(e=>!!e);if(t.length===0)return;if(t.length===1)return t[0];let n=AbortSignal.any;if(typeof n==`function`)return n(t);let r=new AbortController;for(let e of t){if(e.aborted){r.abort(e.reason);break}e.addEventListener(`abort`,()=>r.abort(e.reason),{once:!0})}return r.signal}async function be(e){try{await e.body?.cancel()}catch{}}var F=class{_fetch;baseUrl;errorFactory=e=>e;verboseErrors=!0;retryPolicy;pacingRetry;defaultTimeoutMs;constructor(e,t){this.baseUrl=j(e),this._fetch=oe(t)}throwError(e){throw this.errorFactory(e)}withPacingRetry(e){return this.pacingRetry=e===null?void 0:e,this}withRetryPolicy(e){return this.retryPolicy=e||void 0,this}getRetryPolicy(){return this.retryPolicy}withTimeout(e){return this.defaultTimeoutMs=typeof e==`number`&&e>0?e:void 0,this}getTimeout(){return this.defaultTimeoutMs}resolveTimeout(e){if(e?.reader===`sse`)return;let t=e?.timeoutMs;if(t===!1||t===null)return;if(typeof t==`number`)return t>0?t:void 0;let n=this.getTimeout();return n&&n>0?n:void 0}getUrl(e){return e.startsWith(`http://`)||e.startsWith(`https://`)?j(e):j(te(this.baseUrl,e))}get(e,t){return this.request(`GET`,e,t)}del(e,t){return this.request(`DELETE`,e,t)}delete(e,t){return this.request(`DELETE`,e,t)}post(e,t){return this.request(`POST`,e,t)}put(e,t){return this.request(`PUT`,e,t)}jsonParse(e){return JSON.parse(e)}createRequest(e,t){return Promise.resolve(new Request(e,t))}handleFetchResponse(e,t){}createServerError(e,t,n){let r=`Server Error: ${t.status}`;return n&&(se(n)?(r+=t.statusText?` ${t.statusText}`:``,r+=`: non-JSON response`):N(n)&&n.message?r=String(n.message):N(n)&&n.error&&(typeof n.error==`string`?r=String(n.error):N(n.error)&&typeof n.error.message==`string`&&(r=n.error.message))),new x(r,e,t.status,n,this.verboseErrors,fe(t),P(t))}async readJSONPayload(e){return e.text().then(t=>{if(t)try{return this.jsonParse(t)}catch(n){return{status:e.status,error:`Not a valid JSON payload`,message:n instanceof Error?n.message:String(n),text:t}}}).catch(t=>{if(ge(t))throw t;return{status:e.status,error:`Unable to load response content`,message:t instanceof Error?t.message:String(t)}})}handleResponse(e,t,n){return n?.reader?n.reader===`sse`?A(t):n.reader.call(this,t):this.readJSONPayload(t).then(n=>{if(t.ok)return n;this.throwError(this.createServerError(e,t,n))})}async request(e,t,n){let r=this.getUrl(t);n?.query&&(r+=`?${ee(n.query)}`);let i=this.headers?Object.assign({},this.headers):{},a=n?.headers;if(a)for(let e in a)i[e.toLowerCase()]=a[e];let o,s=n?.payload;s&&(n&&n.jsonPayload===!1?o=s:(o=typeof s==`string`?s:JSON.stringify(s),`content-type`in i||(i[`content-type`]=`application/json`))),n?.reader===`sse`&&(i.accept=`text/event-stream`);let c=e.toUpperCase(),l=this.resolveTimeout(n),u=()=>{let e=ye([n?.signal,l?ve(l):void 0]),t={method:c,headers:Object.assign({},i),body:o};return e&&(t.signal=e),t},d=this.resolveRetryPolicy(n),f=n?.reader===`sse`?void 0:re(n?.pacingRetry??this.pacingRetry),p=await this._fetch,m=ce(o),h=0,g=0,_;for(;;){let e=await this.createRequest(r,u());_=e;let t;try{t=await p(e)}catch(t){let n=_e(t);(n||!d||!this.shouldRetryConnectionError(d,c,h,m))&&(n||console.error(`Failed to connect to ${r}`,t),this.throwError(new S(e,he(t)))),await this.waitBeforeRetry(d,h),h++;continue}if(this.handleFetchResponse(e,t),f&&g<f.attempts&&m){let e=de(t,f);if(e!==void 0){await be(t),await pe(e),g++;continue}}if(d&&this.shouldRetryResponse(d,c,h,m,t)){await be(t),await this.waitBeforeRetry(d,h,t),h++;continue}if(d&&h>=d.attempts)break;return this.handleResponse(e,t,n)}throw _&&this.throwError(new S(_,Error(`Retry attempts exhausted for ${c} ${r}`))),Error(`Retry attempts exhausted for ${c} ${r}`)}resolveRetryPolicy(e){if(e?.reader===`sse`||e?.retryPolicy===!1||e?.retryPolicy===null)return;let t=e?.retryPolicy,n=this.getRetryPolicy();if(!t&&!n)return;let r=ue({...n,...t});return r.attempts>1?r:void 0}shouldRetryResponse(e,t,n,r,i){let a=e.statuses.has(i.status)||e.retryNonJsonServerErrors&&le(i);return n<e.attempts-1&&r&&e.methods.has(t)&&a}shouldRetryConnectionError(e,t,n,r){return n<e.attempts-1&&r&&e.retryOnConnectionError&&e.methods.has(t)}waitBeforeRetry(e,t,n){let r=me(e,t,n);return new Promise(e=>setTimeout(e,r))}async sseRequest(e,t,n,r){let i=(await this.request(e,t,{...n,reader:`sse`})).getReader(),a;try{for(;;){let{done:e,value:t}=await i.read();if(e)break;a=t,r(t)}}finally{i.releaseLock()}return a}fetch(e,t){return this._fetch.then(n=>n(e,t))}};function xe(e){return e?`authorization`in e:!1}function Se(){let e=globalThis;return e.window===void 0&&(typeof e.process?.versions?.node==`string`||typeof e.process?.versions?.bun==`string`||e.Bun!==void 0)}var Ce=class extends F{headers;_auth;onRequest;onResponse;response;constructor(e,t){super(e,t),this.baseUrl=e[e.length-1]===`/`?e.substring(0,e.length-1):e,this.headers=this.initialHeaders}get initialHeaders(){let e={accept:`application/json`};return Se()&&(e[`accept-encoding`]=`br, gzip, deflate`),e}withAuthCallback(e){return this._auth=e||void 0,this}withErrorFactory(e){return this.errorFactory=e,this}withLang(e){return e?this.headers[`accept-language`]=e:delete this.headers[`accept-language`],this}withHeaders(e){let t=this.headers;for(let n in e){let r=e[n];r!=null&&(t[n.toLowerCase()]=r)}return this}setHeader(e,t){t?this.headers[e.toLowerCase()]=t:delete this.headers[e.toLowerCase()]}async createRequest(e,t){if(this._auth&&!xe(t.headers)){t.headers=t.headers?t.headers:{};let e=await this._auth();e&&(t.headers.authorization=e)}this.response=void 0;let n=await super.createRequest(e,t);return this.onRequest?.(n),n}handleFetchResponse(e,t){this.response=t,this.onResponse?.(t,e)}},I=class extends F{client;constructor(e,t){super(e.getUrl(t),e._fetch),this.client=e,this.createServerError=e.createServerError,this.errorFactory=e.errorFactory,this.verboseErrors=e.verboseErrors}createRequest(e,t){return this.client.createRequest(e,t)}handleResponse(e,t,n){return this.client.handleResponse(e,t,n)}handleFetchResponse(e,t){this.client.handleFetchResponse(e,t)}getRetryPolicy(){return this.client.getRetryPolicy()}getTimeout(){return this.client.getTimeout()}get headers(){return this.client.headers}},we=class extends I{constructor(e){super(e,`/api/v1/account/apikeys`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}},Te=class extends I{apikeys;constructor(e){super(e,`/api/v1/account`),this.apikeys=new we(e)}info(){return this.get(`/`)}update(e){return this.put(`/`,{payload:e})}projects(){return this.get(`/projects`).then(e=>e.data)}members(){return this.get(`/members`)}inviteUser(e){return this.post(`/invites`,{payload:e})}listInvites(){return this.get(`/invites`)}listInvitation(e=`project`){return this.get(`/invites/${e}`)}acceptInvite(e){return this.put(`/invites/${e}`)}rejectInvite(e){return this.del(`/invites/${e}`)}onboardingProgress(){return this.get(`/onboarding`)}getStripeBillingStatus(){return this.get(`/stripe-billing-status`)}},Ee=class extends I{constructor(e){super(e,`/api/v1/accounts`)}create(e){return this.post(`/`,{payload:{name:e}})}list(){return this.get(`/`)}},De=class extends I{constructor(e){super(e,`/api/v1/analytics`)}runsSummary(e,t){let n=new URLSearchParams;e?.start&&n.set(`start`,e.start),e?.end&&n.set(`end`,e.end),t&&n.set(`environment`,t);let r=n.toString();return this.get(`/runs/summary${r?`?${r}`:``}`)}runsTimeSeries(e,t){let n=new URLSearchParams;e?.start&&n.set(`start`,e.start),e?.end&&n.set(`end`,e.end),t&&n.set(`environment`,t);let r=n.toString();return this.get(`/runs/time-series${r?`?${r}`:``}`)}runsTokenUsage(e,t){let n=new URLSearchParams;e?.start&&n.set(`start`,e.start),e?.end&&n.set(`end`,e.end),t&&n.set(`environment`,t);let r=n.toString();return this.get(`/runs/token-usage${r?`?${r}`:``}`)}},Oe=class extends I{constructor(e){super(e,`/api/v1/apikeys`)}list(e=`account`){return this.get(`/`,{query:{level:e}})}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}retrieve(e,t=!1){return t?this.get(`/${e}`,{query:{withValue:!0}}):this.get(`/${e}`)}delete(e){return this.del(`/${e}`)}getToken(e){return this.get(`/${e}/token`)}requestPublicKey(e={}){return this.get(`/pk`,{query:e})}},ke=class extends I{constructor(e){super(e,`/api/v1/apps`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}previewDelete(e){return this.del(`/${e}`)}setMcpCollectionApiKey(e,t,n){return this.put(`/${encodeURIComponent(e)}/collections/${encodeURIComponent(t)}/api-key`,{payload:{api_key:n}})}getMcpCollectionApiKeyStatus(e,t){return this.get(`/${encodeURIComponent(e)}/collections/${encodeURIComponent(t)}/api-key`)}deleteMcpCollectionApiKey(e,t){return this.del(`/${encodeURIComponent(e)}/collections/${encodeURIComponent(t)}/api-key`)}deleteApp(e){return this.del(`/${e}`,{query:{confirm:`true`}})}listVersions(e){return this.get(`/versions`,{query:{...e?.app_id&&{app_id:e.app_id},...e?.kind&&{kind:e.kind},...e?.include_expired!==void 0&&{include_expired:e.include_expired},...e?.limit!==void 0&&{limit:e.limit}}})}upsertVersion(e){return this.post(`/versions`,{payload:e})}getVersion(e){return this.get(`/versions/${e}`)}promoteVersion(e){return this.post(`/versions/${e}/promote`)}rebuildVersion(e){return this.post(`/versions/${e}/rebuild`)}deleteVersion(e){return this.del(`/versions/${e}`)}startBuild(e,t){return this.post(`/${encodeURIComponent(e)}/builds`,{payload:t})}getBuildProgress(e,t,n){return this.get(`/${encodeURIComponent(e)}/builds/${encodeURIComponent(t)}/${encodeURIComponent(n)}/progress`)}startScaffold(e){return this.post(`/scaffolds`,{payload:e})}getScaffoldProgress(e,t){return this.get(`/scaffolds/${encodeURIComponent(e)}/${encodeURIComponent(t)}/progress`)}listAppInstallationTools(e){return this.get(`/installations/${e}/tools`)}inspect(e){return this.get(`/${e}/inspect`)}getRepoTree(e,t){return this.get(`/${encodeURIComponent(e)}/repo/tree`,{query:{prefix:t?.prefix,ref:t?.ref}})}async getRepoFile(e,t,n){let r=`/${encodeURIComponent(e)}/repo/file`,i=await this.get(r,{query:{path:t,ref:n?.ref},reader:e=>e});if(!i.ok){let e=await this.readJSONPayload(i),t=await this.createRequest(i.url||this.getUrl(r),{method:`GET`});throw this.createServerError(t,i,e)}return i}commitRepoDocuments(e,t,n){let r=new FormData,i={ref:n.ref,expected_head:n.expectedHead,message:n.message||`Upload documentation`,files:t.map((e,t)=>({field:`file_${t}`,path:e.path}))};return r.append(`metadata`,JSON.stringify(i)),t.forEach((e,t)=>{r.append(`file_${t}`,e.content,e.fileName||e.path.split(`/`).pop()||`document`)}),this.post(`/${encodeURIComponent(e)}/repo/documents`,{payload:r,jsonPayload:!1,timeoutMs:12e4})}getRepoCommits(e,t,n){return this.get(`/${encodeURIComponent(e)}/repo/commits`,{query:{path:t,ref:n?.ref,limit:n?.limit,cursor:n?.cursor}})}getRepoRefs(e){return this.get(`/${encodeURIComponent(e)}/repo/refs`)}listDevelopmentTasks(e){return this.get(`/${encodeURIComponent(e)}/development-tasks`)}getDevelopmentTask(e,t){return this.get(`/${encodeURIComponent(e)}/development-tasks/${encodeURIComponent(t)}`)}startDevelopmentTask(e,t,n){return this.post(`/${encodeURIComponent(e)}/development-tasks/${encodeURIComponent(t)}/runs`,{payload:n})}createRepoBranch(e,t){return this.post(`/${encodeURIComponent(e)}/repo/branches`,{payload:t})}getAppPackage(e,t=`all`){return this.get(`/${encodeURIComponent(e)}/package`,{query:{scope:Array.isArray(t)?t.join(`,`):t}})}getAppInstallationPackage(e,t=`all`){return this.get(`/installations/${e}/package`,{query:{scope:Array.isArray(t)?t.join(`,`):t}})}getSystemToolsPackage(e=`tools`){return this.get(`/studio-tools/package`,{query:{scope:e}})}list(e){return this.get(`/`,{query:{...e?.scope&&{scope:e.scope}}})}install(e,t,n,r,i){return this.post(`/install`,{payload:{app_id:e,settings:t,oauth_params:n,oauth_provider_params:r,api_key_params:i}})}uninstall(e){return this.del(`/install/${e}`)}getAppInstallationByName(e){return this.get(`/installations/name/${e}`).catch(e=>{if(e.status===404)return null;throw e})}getAppInstallationProjects(e){if(!e.id&&!e.name)throw Error(`Invalid arguments: appId or appName must be specified`);let t=e.id?{id:e.id}:{name:e.name};return this.get(`/installations/projects`,{query:t})}getInstalledApps(e){return this.get(`/installations`,{query:{kind:e}})}getAllAppInstallations(){return this.get(`/installations/all`)}listInstallations(){return this.get(`/installations/refs`)}updateInstallationSettings(e){return this.put(`/installations/settings/${e.app_id}`,{payload:{app_id:e.app_id,settings:e.settings,...`access_control`in e?{access_control:e.access_control}:{}}})}updateOAuthApproval(e,t){return this.put(`/installations/${e}/oauth-approval`,{payload:{approved_scopes:t}})}updateToolAllowlist(e,t){return this.put(`/installations/${e}/tool-allowlist`,{payload:{tool_allowlist:t}})}validateUrl(e){return this.post(`/validate-url`,{payload:{url:e}})}},Ae=class extends I{constructor(e){super(e,`/api/v1/audit-trail`)}list(e){let t=new URLSearchParams;e?.actions?.length&&t.set(`actions`,e.actions.join(`,`)),e?.resourceTypes?.length&&t.set(`resourceTypes`,e.resourceTypes.join(`,`)),e?.resourceId&&t.set(`resourceId`,e.resourceId),e?.principalId&&t.set(`principalId`,e.principalId),e?.principalType&&t.set(`principalType`,e.principalType),e?.effectivePrincipalId&&t.set(`effectivePrincipalId`,e.effectivePrincipalId),e?.hasEffectivePrincipal!==void 0&&t.set(`hasEffectivePrincipal`,String(e.hasEffectivePrincipal)),e?.projectId&&t.set(`projectId`,e.projectId),e?.from&&t.set(`from`,e.from),e?.to&&t.set(`to`,e.to),e?.limit&&t.set(`limit`,String(e.limit)),e?.offset&&t.set(`offset`,String(e.offset));let n=t.toString();return this.get(`/${n?`?${n}`:``}`)}aggregate(e){return this.post(`/aggregate`,{payload:e})}},je=class extends I{constructor(e){super(e,`/api/v1/commands`)}async isNamespaceAvailable(e){return this.get(`/namespaces/${e}/is_available`).then(e=>e.available)}async initSamples(){return this.post(`/onboarding/init-samples`)}},Me=class extends I{constructor(e){super(e,`/api/v1/iam/delegation-grants`)}create(e){return this.post(`/`,{payload:e})}list(){return this.get(`/`)}mine(){return this.get(`/me`)}retrieve(e){return this.get(`/${e}`)}revoke(e){return this.post(`/${e}/revoke`)}},Ne=class extends I{constructor(e){super(e,`/api/v1/environments`)}list(e=!1){let t=e?{all:!0}:void 0;return this.get(`/`,{query:t})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}updateConfig(e,t){return this.put(`/${e}/config`,{payload:t})}listModels(e,t){return this.get(`/${e}/models`,{query:t?{...t}:void 0})}enableModel(e,t){return this.post(`/${e}/models/enabled`,{payload:t})}disableModel(e,t){return this.del(`/${e}/models/enabled/${encodeURIComponent(t)}`)}listTrainableModels(e){return this.get(`/${e}/trainable-models`)}embeddings(e,t){return this.post(`/${e}/embeddings`,{payload:t})}embeddingBatchCapability(e,t){return this.post(`/${e}/embedding-batches/capability`,{payload:t})}createEmbeddingBatch(e,t){return this.post(`/${e}/embedding-batches`,{payload:t})}getEmbeddingBatch(e,t){return this.post(`/${e}/embedding-batches/get`,{payload:t})}cancelEmbeddingBatch(e,t){return this.post(`/${e}/embedding-batches/cancel`,{payload:t})}deleteEmbeddingBatch(e,t){return this.post(`/${e}/embedding-batches/delete`,{payload:t})}migrateInteractions(e){return this.post(`/migrate-interactions`,{payload:e})}},Pe=class extends I{constructor(e){super(e,`/groups`)}list(e){return this.get(`/`,{query:e})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}listMembers(e){return this.get(`/${e}/members`)}addMember(e,t){return this.post(`/${e}/members/${t}`)}removeMember(e,t){return this.del(`/${e}/members/${t}`)}syncMembers(){return this.post(`/sync-members`)}},Fe=class extends I{constructor(e){super(e,`/api/v1/iam`)}aces=new Le(this);roles=new Ie(this);groups=new Pe(this);getPrincipalIdentity(){return this.get(`/users/identity`)}},Ie=class extends I{constructor(e){super(e,`/roles`)}list(){return this.get(`/`)}listSystem(e){return this.get(`/system`,e)}},Le=class extends I{constructor(e){super(e,`/aces`)}list(e){return this.get(`/`,{query:{...e}})}listProjectAces(){return this.get(`/project`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}};const Re=(()=>{let e=typeof process<`u`?process.env?.VERTESIA_INTERACTION_TIMEOUT_MS:void 0,t=e?Number.parseInt(e,10):NaN;return Number.isFinite(t)&&t>0?t:18e5})();async function L(){return typeof globalThis.EventSource==`function`?globalThis.EventSource:(await import(`eventsource`)).EventSource}async function ze(e,t,n={},r){let i=!!r,a=await e.runs.create({...n,interaction:t,stream:i},{timeoutMs:i?void 0:Re});if(i){if(a.status===o.failed)return a;await Ve(e,a.id,r)}return a}async function Be(e,t,n={},r,i){let a=!!r,s=await e.post(`/api/v1/execute`,{...i,payload:{...n,interaction:t,stream:a},timeoutMs:i?.timeoutMs??(a?void 0:Re)});if(a){if(s.status===o.failed)return s;await Ve(e,s.id,r)}return s}function Ve(e,t,n){return new Promise((r,i)=>{(async()=>{try{let a=await L(),o=new URL(`${e.runs.baseUrl}/${t}/stream`),s=e._auth?await e._auth():void 0;if(s){let e=s.split(` `)[1];o.searchParams.set(`access_token`,e)}else throw Error(`No auth token available`);let c=new a(o.href);c.addEventListener(`message`,e=>{try{let t=JSON.parse(e.data);t&&n?.(t)}catch(e){i(e)}}),c.addEventListener(`close`,e=>{try{c.close(),r(JSON.parse(e.data))}catch(e){i(e)}})}catch(e){i(e)}})()})}async function He(e,t){return await e.post(`/api/v1/execute/async`,{payload:t})}async function Ue(e,t){return await e.post(`/api/v1/execute/rate-limit/request`,{payload:t})}var We=class extends I{constructor(e){super(e,`/api/v1/interactions/catalog`)}list(e={}){return this.get(`/`,{query:e})}listStoredInteractions(e={}){return this.get(`/stored`,{query:e})}listSysInteractions(e){return this.get(`/sys`,{query:{tag:e}})}listAppInteractions(e,t){return this.get(`/apps/${e}`,{query:{tag:t}})}listAllAppInteractions(e){return this.get(`/apps`,{query:{tag:e}})}resolve(e){return this.get(`/resolve/${e}`)}};const R=Symbol(`InteractionOutput`);function z(e){return e.result=B.from(e.result),e}function Ge(e){return e.result=B.from(e.result),e}var B=class{results;constructor(e){this.results=e}static from(e){return e?Ke(e)?e:V(Array.isArray(e)?e:typeof e==`object`?[{type:`json`,value:e}]:[{type:`text`,value:String(e)}]):V([])}static isInteractionOutputArray(e){return Ke(e)}get isEmpty(){return this.results.length===0}hasObject(){return this.results.some(e=>e.type===`json`)}hasText(){return this.results.some(e=>e.type===`text`)}hasThoughts(){return this.results.some(e=>e.type===`thoughts`)}hasImage(){return this.results.some(e=>e.type===`image`)}hasVideo(){return this.results.some(e=>e.type===`video`)}text(e=`
|
|
10
10
|
`){return this.results.filter(e=>e.type===`text`).map(e=>e.value).join(e)}texts(){return this.results.filter(e=>e.type===`text`).map(e=>e.value)}thoughts(e=`
|
|
11
|
-
`){return this.results.filter(e=>e.type===`thoughts`).map(e=>e.value).join(e)}thoughtParts(){return this.results.filter(e=>e.type===`thoughts`).map(e=>e.value)}object(){let e=this.results.find(e=>e.type===`json`);return e?e.value:
|
|
12
|
-
`,t=2){return this.results.filter(e=>e.type!==`thoughts`).map(e=>{switch(e.type){case`json`:return JSON.stringify(e.value,null,t);default:return String(e.value)}}).join(e)}toString(){return this.text()}toJSON(){return this.results}};function We(e){return!!e&&typeof e==`object`&&e[z]===!0}function H(e){let t=new V(e);return new Proxy(e,{get(e,n,r){if(n===z)return!0;if(n in t){let e=Reflect.get(t,n,t);return typeof e==`function`?e.bind(t):e}return Reflect.get(e,n,r)}})}function Ge(e){let t;for(let n of e)if(n.type===`text`){let e=n.value.trim();try{return JSON.parse(e)}catch(e){t=e instanceof Error?e:Error(String(e))}}throw t||=Error(`No JSON result found and no text available to parse`),t}function Ke(e){return!!e&&typeof e==`object`&&`id`in e&&typeof e.id==`string`}var qe=class extends L{catalog;constructor(e){super(e,`/api/v1/interactions`),this.catalog=new He(e)}list(e={}){let t=e.query||{};return this.get(`/`,{query:{...t}})}listEndpoints(e){return this.post(`/endpoints`,{payload:e})}listVersionsByName(e){return this.get(`/versions/${e}`)}listTags(e){return this.get(`/tags`,{query:{...e}})}computeFacets(e){return this.post(`/facets`,{payload:e})}listNames(){return this.get(`/names`)}export(e){return this.post(`/export`,{payload:e})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e,t){let{cascade:n,query:r,...i}=t??{},a=n?{...r??{},cascade:`true`}:r??void 0;return super.delete(`/${e}`,{...i,query:a})}async execute(e,t={},n){return B(await Le(this.client,e,t,n).catch(e=>{throw e instanceof x&&Ke(e.payload)?e.updateDetails({run_id:e.payload.id}):e}))}async executeByName(e,t={},n,r){return B(await Re(this.client,e,t,n,r).catch(e=>{throw e instanceof x&&Ke(e.payload)?e.updateDetails({run_id:e.payload.id}):e}))}executeAsync(e){return Be(this.client,e)}publish(e,t){return this.post(`/${e}/publish`,{payload:t})}fork(e,t){return this.post(`/${e}/fork`,{payload:t})}generateInteraction(e,t){return this.post(`${e}/generate-interaction`,{payload:t})}generateTestData(e,t){return this.post(`${e}/generate-test-data`,{payload:t})}suggestImprovements(e,t){return this.post(`${e}/suggest-prompt-improvements`,{payload:t})}suggestPromptImprovements(e){return this.post(`/improve`,{payload:e})}listVersions(e){return this.get(`/${e}/versions`)}listForks(e){return this.get(`/${e}/forks`)}requestSlot(e){return Ve(this.client,e)}resolve(e,t){return this.get(`/resolve/${encodeURIComponent(e)}`,{query:t})}},Je=class extends L{constructor(e){super(e,`/internal/secrets`)}rotateEventWebhookSigningSecret(e,t){return this.post(`/event-webhooks/${e}/rotate`,{payload:t})}deleteEventWebhookSigningSecret(e,t){return this.post(`/event-webhooks/${e}/delete`,{payload:t})}signEventWebhook(e,t){return this.post(`/event-webhooks/${e}/sign`,{payload:t})}rotateEventIngestChannelSigningSecret(e,t){return this.post(`/event-ingest-channels/${e}/rotate`,{payload:t})}deleteEventIngestChannelSigningSecret(e,t){return this.post(`/event-ingest-channels/${e}/delete`,{payload:t})}verifyEventIngestSignature(e,t){return this.post(`/event-ingest-channels/${e}/verify`,{payload:t})}mintGithubInstallationToken(e){return this.post(`/github/installation-token`,{payload:e})}},Ye=class extends L{constructor(e){super(e,`/api/v1/oauth-clients`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}scopeMetadata(){return this.get(`/scope-metadata`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}remove(e){return this.del(`/${e}`)}};function Xe(e){if(e)return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)]))}var Ze=class extends L{constructor(e){super(e,`/api/v1/oauth-grants`)}list(e){return this.get(`/`,{query:Xe(e)})}retrieve(e){return this.get(`/${e}`)}revoke(e,t){return this.del(`/${e}`,{query:t})}revokeBulk(e){return this.post(`/revoke`,{payload:e})}},Qe=class extends L{constructor(e){super(e,`/api/v1/oauth-providers`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}remove(e){return this.del(`/${e}`)}authorize(e){return this.get(`/${e}/authorize`)}exchange(e,t){return this.post(`/exchange`,{payload:{code:e,state:t}})}getStatus(e){return this.get(`/${e}/status`)}connect(e){return this.post(`/${e}/connect`,{payload:{}})}getToken(e){return this.post(`/${e}/token`,{payload:{}})}disconnect(e){return this.del(`/${e}/disconnect`)}},$e=class extends I{parent;constructor(e,t){super(new URL(`/oauth`,`${t||e.baseUrl}/`).toString(),e._fetch),this.parent=e,this.createServerError=e.createServerError,this.errorFactory=e.errorFactory,this.verboseErrors=e.verboseErrors}get headers(){return this.parent.headers}createRequest(e,t){return this.parent.createRequest(e,t)}handleResponse(e,t,n){return this.parent.handleResponse(e,t,n)}handleFetchResponse(e,t){this.parent.handleFetchResponse(e,t)}getRetryPolicy(){return this.parent.getRetryPolicy()}createAuthorizationRequest(e,t){if(!t)return this.post(`/requests`,{payload:e});if(!/^\/env\/[a-z][a-z0-9-]{1,15}\/dev-[a-z0-9-]+$/.test(t))return Promise.reject(Error(`Invalid OAuth authorization server path`));let n=new URL(`${t}/requests`,this.baseUrl).toString();return this.post(n,{payload:e})}createDeviceAuthorization(e){return this.post(`/device_authorization`,{payload:e})}retrieveDeviceRequest(e){return this.get(`/device/${encodeURIComponent(e)}`)}retrieveRequest(e){return this.get(`/requests/${e}`)}retrieveGrantableScopes(e,t){return this.get(`/requests/${e}/grantable-scopes`,{query:{project_id:t}})}approveRequest(e,t){return this.post(`/requests/${e}/approve`,{payload:t})}denyRequest(e){return this.post(`/requests/${e}/deny`,{payload:{}})}},et=class extends L{integrations;constructor(e){super(e,`/api/v1/projects`),this.integrations=new tt(this)}list(e){return this.get(`/`,{query:{account:e}})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}updateConfiguration(e,t){return this.put(`/${e}/configuration`,{payload:t})}getTools(e){return this.get(`/${e}/tools`)}getToolByName(e,t){return this.get(`/${e}/tools/${t}`).catch(e=>{if(e.status===404)return null;throw e})}listAppContentTypes(e,t){return this.get(`/${encodeURIComponent(e)}/app-types`,{query:{tag:t}})}getAppContentType(e,t){return this.get(`/${encodeURIComponent(e)}/app-types/${encodeURIComponent(t)}`)}listAppProcesses(e,t){return this.get(`/${encodeURIComponent(e)}/app-processes`,{query:{tag:t}})}getAppProcess(e,t){return this.get(`/${encodeURIComponent(e)}/app-processes/${encodeURIComponent(t)}`)}listAppViews(e,t){return this.get(`/${encodeURIComponent(e)}/app-views`,{query:{tag:t}})}getAppView(e,t){return this.get(`/${encodeURIComponent(e)}/app-views/${encodeURIComponent(t)}`)}listAppRenderingTemplates(e,t){return this.get(`/${encodeURIComponent(e)}/app-templates`,{query:{tag:t}})}getAppRenderingTemplate(e,t){return this.get(`/${encodeURIComponent(e)}/app-templates/${encodeURIComponent(t)}`)}getCompositeAppConfiguration(e){return this.get(`/${encodeURIComponent(e)}/composite-app`)}updateCompositeAppConfiguration(e,t){return this.put(`/${encodeURIComponent(e)}/composite-app`,{payload:t})}},tt=class extends L{constructor(e){super(e,`/`)}list(e){return this.get(`/${e}/integrations`).then(e=>e.integrations)}retrieve(e,t){return this.get(`/${e}/integrations/${t}`).catch(e=>{if(e.status!==404)throw e})}update(e,t,n){return this.put(`/${e}/integrations/${t}`,{payload:n})}updatePlugins(e,t){return this.post(`/${e}/plugins`,{payload:{plugins:t}})}listPlugins(e){return this.get(`/${e}/plugins`)}},nt=class extends L{constructor(e){super(e,`/api/v1/prompts`)}list(e={}){let t=e.query||{};return this.get(`/`,{query:{...t}})}computeFacets(e){return this.post(`/facets`,{payload:e})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}fork(e,t){return this.post(`/${e}/fork`,{payload:t})}render(e,t){return this.post(`/${e}/render`,{payload:t})}options(e){return this.get(`/options/${e}`)}listVersions(e){return this.get(`/${e}/versions`)}listInteractions(e){return this.get(`/${e}/interactions`)}listForks(e){return this.get(`/${e}/forks`)}},rt=class extends L{constructor(e){super(e,`/api/v1/quota`)}standing(){return this.get(`/standing`)}tier(){return this.get(`/tier`)}},it=class extends L{constructor(e){super(e,`/api/v1/refs`)}resolve(e){return this.post(`/resolve`,{payload:{refs:e}})}},at=class extends L{constructor(e){super(e,`/api/v1/remote-mcp-connections`)}getStatus(e){return this.get(`/status/${e}`)}getCollectionStatus(e,t){return this.get(`/status/${e}/${t}`)}getMetadata(e,t){return this.get(`/metadata/${e}/${t}`)}authorize(e,t){return this.get(`/authorize/${e}/${t}`)}exchange(e,t){return this.post(`/exchange`,{payload:{code:e,state:t}})}connect(e,t){return this.post(`/connect/${e}/${t}`,{})}disconnect(e,t){return this.del(`/disconnect/${e}/${t}`)}getCollectionToken(e,t){return this.post(`/token`,{payload:{app_install_id:e,collection_id:t}})}getToken(e){return this.post(`/token`,{payload:{mcp_server_url:e}})}},ot=class extends L{constructor(e){super(e,`/api/v1/runs`)}list({limit:e,offset:t,filters:n}){let r={limit:e,offset:t,...n};return this.get(`/`,{query:r})}find(e){return this.post(`/find`,{payload:e})}async retrieve(e){return Ue(await this.get(`/${e}`))}retrievePopulated(e){return this.get(`/${e}`,{query:{populate:`true`}})}filterOptions(e,t){let n={...t};return this.get(`/filter-options/${e}`,{query:n})}async create(e,t){let n=this.client.sessionTags;if(n){let t=Array.isArray(n)?n:[n];Array.isArray(e.tags)?t=t.concat(e.tags):e.tags&&(t=t.concat([e.tags])),e={...e,tags:t}}return B(await this.post(`/`,{payload:e,timeoutMs:t?.timeoutMs,signal:t?.signal}))}sendToolResults(e,t){return this.post(`/tool-results`,{payload:e,headers:t?.headers,timeoutMs:t?.timeoutMs,signal:t?.signal})}sendUserMessage(e,t){return this.post(`/user-message`,{payload:e,headers:t?.headers,timeoutMs:t?.timeoutMs,signal:t?.signal})}computeFacets(e){return this.post(`/facets`,{payload:e})}search(e){return this.post(`/search`,{payload:e})}clone(e){return this.post(`/clone`,{payload:e})}},st=class extends L{constructor(e){super(e,`/api/v1/secrets`)}list(e,t){return this.get(`/`,{query:{...t,project_id:e}}).then(e=>e.secrets)}retrieve(e,t,n){return this.get(`/${t}`,{query:{...n,project_id:e}}).catch(e=>{if(e.status!==404)throw e})}create(e,t){return this.post(`/`,{query:{project_id:e},payload:t})}update(e,t,n,r){return this.put(`/${t}`,{query:{...r,project_id:e},payload:n})}remove(e,t,n){return this.del(`/${t}`,{query:{...n,project_id:e}})}fillWebsiteCredential(e,t,n){return this.post(`/${t}/actions/fill-browser`,{query:{project_id:e},payload:n})}},ct=class extends L{constructor(e){super(e,`/api/v1/skills`)}findRelevant(e,t){let n={context:e,limit:t};return this.post(`/find-relevant`,{payload:n})}findRelevantForTask(e,t){return this.findRelevant({task_description:e,tool_names:t})}};const lt={token:"pass the credential as `apikey`, or build the client with `VertesiaClient.fromAuthToken(token)`",accessToken:"pass the credential as `apikey`, or build the client with `VertesiaClient.fromAuthToken(token)`",authToken:"pass the credential as `apikey`, or build the client with `VertesiaClient.fromAuthToken(token)`",apiKey:"the option is spelled `apikey`, all lowercase",api_key:"the option is spelled `apikey`, all lowercase",appVersion:"pin the app version with the `withAppVersion(version)` method after construction",apiVersion:"pin the API version with the `withApiVersion(version)` method after construction",projectId:`the project is determined by the credential; this option was never read`,baseUrl:"use `serverUrl` for studio and `storeUrl` for the store"},ut=new Set;function dt(e,t,n){let r=Object.keys(t).filter(e=>!Object.hasOwn(n,e)&&!ut.has(e));if(r.length===0)return;for(let e of r)ut.add(e);let i=r.map(e=>Object.hasOwn(lt,e)?`${e} (${lt[e]})`:e);console.warn(`[${e}] Ignoring unknown constructor option(s): ${i.join(`; `)}. Unknown options have no effect.`)}const ft=new Set([429,500,502,503,504]);function pt(e){return new Promise(t=>setTimeout(t,e))}function mt(e){let t=e.headers.get(`retry-after`);if(!t)return;let n=Number(t);if(Number.isFinite(n)&&n>=0)return n*1e3;let r=Date.parse(t);if(!Number.isNaN(r))return Math.max(0,r-Date.now())}function ht(e,t,n,r){let i=r?mt(r):void 0;if(i!==void 0)return i;let a=Math.min(n,t*2**e);return Math.floor(Math.random()*a)}const gt=new TextEncoder;function _t(e){if(typeof e==`string`)return gt.encode(e);if(e instanceof Blob)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`Unsupported signed-URL upload chunk of type "${typeof e}"; body streams must yield string or binary (Uint8Array/ArrayBuffer/DataView/Blob) chunks.`)}async function vt(e){if(e!=null){if(typeof ReadableStream<`u`&&e instanceof ReadableStream){let t=e.getReader(),n=[];try{for(;;){let{done:e,value:r}=await t.read();if(e)break;n.push(_t(r))}}catch(e){throw await t.cancel(e).catch(()=>void 0),e}finally{t.releaseLock()}return new Blob(n)}return e}}async function U(e,t={}){let{method:n=`GET`,headers:r,attempts:i=4,baseDelayMs:a=500,maxDelayMs:o=8e3,retryableStatuses:s=ft}=t,c=await vt(t.body),l;for(let t=0;t<i;t++){let u=t===i-1;try{let i=await fetch(e,{method:n,headers:r,body:c});if(i.ok||!s.has(i.status)||u||(mt(i)??0)>6e4)return i;await i.body?.cancel().catch(()=>void 0),await pt(ht(t,a,o,i))}catch(e){if(l=e,u)throw e;await pt(ht(t,a,o))}}throw l instanceof Error?l:Error(`Failed to fetch signed URL: ${e}`)}function yt(e){if(!e||typeof e!=`object`)return;let t=e.process_run_id;return typeof t==`string`?t:void 0}function bt(e,t){let n=yt(e);return!n||n===t}function W(e,t,r=!1){return e.type===n.TERMINATED||(e.type===n.COMPLETE||r&&e.type===n.IDLE)&&(e.workstream_id??`main`)===`main`?bt(e.details,t):!1}function xt(e,t,r=!1){return e.t===n.TERMINATED||(e.t===n.COMPLETE||r&&e.t===n.IDLE)&&(e.w??`main`)===`main`?bt(e.d,t):!1}function G(e){return e.replace(/#/g,`%23`).replace(/\?/g,`%3F`)}var St=class extends L{constructor(e){super(e,`/api/v1/agents`)}start(e){return this.post(`/`,{payload:e})}recordRun(e){return this.post(`/record`,{payload:e})}createRecord(e){return this.recordRun(e)}retrieve(e){return this.get(`/${e}`)}retrieveRun(e){return this.get(`/${e}`)}retrieveProcess(e){return this.get(`/${e}`)}list(e){return this.get(`/`,{query:this.buildListQueryParams(e)})}async listProcessRuns(e){return(await this.get(`/`,{query:this.buildListQueryParams({...e,run_kind:`process`})})).items.filter(Ct)}buildListQueryParams(e){let t={};return e?.id&&(t.id=e.id),e?.status&&(t.status=Array.isArray(e.status)?e.status.join(`,`):e.status),e?.interaction&&(t.interaction=e.interaction),e?.started_by&&(t.started_by=e.started_by),e?.since&&(t.since=e.since),e?.until&&(t.until=e.until),e?.schedule_id&&(t.schedule_id=e.schedule_id),e?.type&&(t.type=e.type),e?.run_type&&(t.run_type=Array.isArray(e.run_type)?e.run_type.join(`,`):e.run_type),e?.run_kind&&(t.run_kind=e.run_kind),e?.limit&&(t.limit=String(e.limit)),e?.offset&&(t.offset=String(e.offset)),e?.cursor&&(t.cursor=e.cursor),e?.sort&&(t.sort=e.sort),e?.order&&(t.order=e.order),e?.evaluation_severity?.length&&(t.evaluation_severity=e.evaluation_severity.join(`,`)),e?.evaluation_flag?.length&&(t.evaluation_flag=e.evaluation_flag.join(`,`)),e?.feedback_rating&&(t.feedback_rating=e.feedback_rating),e?.contradicted!==void 0&&(t.contradicted=String(e.contradicted)),t}recordFeedback(e,t){return this.post(`/${e}/feedback`,{payload:t})}search(e){let t={};return e?.query&&(t.query=e.query),e?.status&&(t.status=Array.isArray(e.status)?e.status.join(`,`):e.status),e?.interaction&&(t.interaction=e.interaction),e?.started_by&&(t.started_by=e.started_by),e?.categories?.length&&(t.categories=e.categories.join(`,`)),e?.tags?.length&&(t.tags=e.tags.join(`,`)),e?.content_type_name&&(t.content_type_name=e.content_type_name),e?.since&&(t.since=e.since),e?.until&&(t.until=e.until),e?.limit&&(t.limit=String(e.limit)),e?.offset&&(t.offset=String(e.offset)),e?.sort?.length&&(t.sort=e.sort.join(`,`)),this.get(`/search`,{query:t})}terminate(e,t){let n=t?{reason:t}:void 0;return this.del(`/${e}`,{query:n})}restart(e){return this.post(`/${e}/restart`,{})}fork(e){return this.post(`/${e}/fork`,{})}getContext(e){return this.get(`/${e}/context`)}getHistory(e){return this.get(`/${e}/history`)}advance(e,t){return this.post(`/${e}/advance`,{payload:t??{}})}retryNode(e,t){return this.post(`/${e}/retry-node`,{payload:t??{}})}answerTask(e,t,n){return this.post(`/${e}/answer-task`,{payload:{task_id:t,result:n}})}updateStatus(e,t){return this.post(`/${e}/status`,{payload:t})}bindWorkflowRun(e,t){return this.post(`/${e}/workflow`,{payload:t})}sendSignal(e,t,n){return this.post(`/${e}/signal/${t}`,{payload:n})}query(e,t){return this.get(`/${e}/query/${t}`)}getActiveWorkstreams(e){return this.query(e,`ActiveWorkstreams`)}async retrieveMessages(e,t){let n=t?{since:t}:void 0;return(await this.get(`/${e}/updates`,{query:n})).messages.map(t=>g(m(t),e))}postMessage(e,t){return this.post(`/${e}/updates`,{payload:t})}async streamMessages(e,t,n,r,i){let a=()=>{},o=()=>{},s=new Promise((e,t)=>{a=e,o=t}),c=0,l=n||0,u=Date.now(),d=!1,f=null,p=null,h=null,_=null,v=null,y=!1,b=0,x=null,S=e=>{let t=Math.min(1e3*2**e,3e4);return t+Math.random()*.1*t},C=()=>{y=!1,_&&=(clearTimeout(_),null),v&&=(clearTimeout(v),null)},w=()=>{h&&=(clearTimeout(h),null),C(),p&&=(clearInterval(p),null),f&&=(f.close(),null),r&&x&&(r.removeEventListener(`abort`,x),x=null)},T=e=>{d||(d=!0,w(),a(e))},E=e=>typeof e==`string`&&[`completed`,`failed`,`cancelled`].includes(e),D=(t,n)=>{b++,console.warn(`Agent stream ${e}: ${t} failed while polling (consecutive failures: ${b}); retrying in 5s:`,n instanceof Error?n.message:n)},O=async()=>{if(d||!y)return;let n=!1;try{let r=await this.retrieveMessages(e,l||void 0);n=!0;for(let n of r){if(d)return;let r=n.timestamp||0;if(!(r<=l)){if(l=r,t&&t(n,T),d)return;if(W(n,e,i?.closeOnIdle)){T(null);return}}}}catch(e){D(`GET /updates`,e)}if(!d&&y){try{let t=await this.get(`/${e}`);if(E(t?.status)){T(null);return}n&&(b=0)}catch(e){D(`run status check`,e)}!d&&y&&(_=setTimeout(()=>{_=null,O()},5e3))}},k=()=>{v=null,!d&&y&&(C(),c=0,console.log(`Agent stream ${e}: retrying the SSE connection after the polling fallback.`),M(`resume`))},A=t=>{d||y||(w(),y=!0,b=0,console.warn(`Agent stream ${e}: SSE unavailable after 10 attempts; falling back to GET /updates polling every 5s (SSE retried every 60s).`,t instanceof Error?t.message:t),v=setTimeout(k,6e4),O())},j=e=>{if(d)return;if(c>=10){A(e);return}let t=S(c);c++,h=setTimeout(()=>{h=null,d||M(`reconnect`)},t)};if(r){if(r.aborted)return d=!0,w(),a(null),s;x=()=>{T(null)},r.addEventListener(`abort`,x,{once:!0})}try{if(!d){let r=await this.retrieveMessages(e,n);i?.onHistoryLoaded?.(r);let a=!1;for(let n=0;n<r.length;n++){let o=r[n];if(d||(l=Math.max(l,o.timestamp||0),t&&t(o,T),d))break;a=n===r.length-1&&W(o,e,i?.closeOnIdle)}if(a)return T(null),s}}catch(e){d||(i?.onHistoryError?.(e),console.warn(`Failed to fetch historical messages, continuing with SSE:`,e))}!d&&l<=0&&(l=Math.max(1,u-1));let M=async(n=`initial`)=>{if(!d)try{let r=await R();if(d)return;let a=this.client,s=new URL(`${a.agents.baseUrl}/${e}/stream`);l>0&&s.searchParams.set(`since`,l.toString()),s.searchParams.set(`skipHistory`,`true`);let u=a._auth?await a._auth():void 0;if(d)return;if(!u){d=!0,w(),o(Error(`No auth token available`));return}let h=u.split(` `)[1];if(s.searchParams.set(`access_token`,h),n===`reconnect`&&console.log(`Reconnecting to agent stream ${e} (attempt ${c}/10)`),d)return;let _=new r(s.href);f=_,p=setInterval(()=>{},1e3);let v=0;_.onopen=()=>{n!==`initial`&&console.log(`Reconnected to agent stream ${e}`),v=Date.now()},_.onmessage=n=>{if(!d&&n.data&&!n.data.startsWith(`:`))try{let r=m(n.data);l=r.ts?Math.max(l,r.ts):Date.now(),t&&t(g(r,e),T),xt(r,e,i?.closeOnIdle)&&T(null)}catch(e){console.error(`Failed to parse SSE message:`,e,n.data)}},_.onerror=e=>{d||(w(),(v?Date.now()-v:0)>5e3&&(c=0),j(Error(`SSE connection failed after 10 reconnection attempts`)))}}catch(e){if(d)return;j(e)}};return M(`initial`),s}getInternals(e){return this.get(`/${e}/internals`)}getRunDetails(e,t){let n={};return t?.includeHistory&&(n.include_history=`true`),t?.hydratePayloads&&(n.hydrate_payloads=`true`),t?.from!==void 0&&(n.from=t.from),this.get(`/${e}/details`,{query:n})}async streamRunDetails(e,t,n){let r=await R(),i=this.client,a=new URL(`${i.agents.baseUrl}/${e}/details/stream`),o=i._auth?await i._auth():void 0;if(!o)throw Error(`No auth token available`);let s=o.split(` `)[1];return a.searchParams.set(`access_token`,s),new Promise((e,i)=>{let o=new r(a.href),s=null,c=()=>{o.close(),n&&s&&(n.removeEventListener(`abort`,s),s=null)};if(n){if(n.aborted){c(),e();return}s=()=>{c(),e()},n.addEventListener(`abort`,s,{once:!0})}o.addEventListener(`history`,e=>{try{let n=JSON.parse(e.data);t&&t({type:`history`,data:n})}catch{}}),o.addEventListener(`control`,n=>{try{let r=JSON.parse(n.data);t&&t({type:`control`,data:r}),`type`in r&&r.type===`done`&&(c(),e())}catch{}}),o.addEventListener(`error`,e=>{try{let n=JSON.parse(e.data);t&&t({type:`error`,data:n})}catch{}}),o.onerror=e=>{c(),i(Error(`SSE connection failed for details stream`))}})}listChildren(e){return this.get(`/${e}/children`)}getChildDetails(e,t,n){let r={};return n?.includeHistory&&(r.include_history=`true`),n?.hydratePayloads&&(r.hydrate_payloads=`true`),n?.from!==void 0&&(r.from=n.from),this.get(`/${e}/children/${t}/details`,{query:r})}listArtifacts(e,t){let n=t?.visibility?{visibility:t.visibility}:void 0;return this.get(`/${e}/artifacts`,{query:n})}getArtifactContent(e,t){return this.get(`/${e}/artifact-content/${G(t)}`)}updateArtifactContent(e,t,n){return this.put(`/${e}/artifact-content/${G(t)}`,{payload:n})}getArtifactUrl(e,t,n,r){let i={url:`1`};return n&&(i.disposition=n),r&&(i.filename=r),this.get(`/${e}/artifacts/${G(t)}`,{query:i})}async uploadArtifact(e,t,n,r){let i=r||`application/octet-stream`,a=await this.put(`/${e}/artifacts/${G(t)}`,{headers:{"Content-Type":i}}),o=await U(a.url,{method:`PUT`,body:n,headers:{"Content-Type":i}});if(!o.ok)throw Error(`Failed to upload artifact: ${o.statusText}`);return a}async downloadArtifact(e,t){let{url:n}=await this.getArtifactUrl(e,t,`attachment`),r=await U(n);if(!r.ok)throw Error(`Failed to download artifact: ${r.statusText}`);if(!r.body)throw Error(`No body in artifact download response`);return r.body}ingestEvents(e,t){let n={events:t};return this.post(`/${e}/events`,{payload:n})}getAnalyticsSummary(e={}){return this.post(`/analytics/summary`,{payload:e})}getTokenUsageAnalytics(e={}){return this.post(`/analytics/tokens`,{payload:e})}getLlmLatencyAnalytics(e={}){return this.post(`/analytics/latency/llm`,{payload:e})}getToolLatencyAnalytics(e={}){return this.post(`/analytics/latency/tools`,{payload:e})}getAgentLatencyAnalytics(e={}){return this.post(`/analytics/latency/agents`,{payload:e})}getErrorAnalytics(e={}){return this.post(`/analytics/errors`,{payload:e})}getToolAnalytics(e={}){return this.post(`/analytics/tools`,{payload:e})}getToolParameterAnalytics(e){return this.post(`/analytics/tools/parameters`,{payload:e})}getAnalyticsFilterOptions(e={}){return this.post(`/analytics/filter-options`,{payload:e})}getPromptSizeAnalytics(e={}){return this.post(`/analytics/prompt-size`,{payload:e})}getTopPrincipalsAnalytics(e={}){return this.post(`/analytics/top-principals`,{payload:e})}getRunsByAgentAnalytics(e={}){return this.post(`/analytics/runs-by-agent`,{payload:e})}getTimeToFirstResponseAnalytics(e={}){return this.post(`/analytics/time-to-first-response`,{payload:e})}getFirstResponseBehaviorAnalytics(e={}){return this.post(`/analytics/first-response-behavior`,{payload:e})}};function Ct(e){return e.run_kind===`process`}var wt=class extends L{constructor(e){super(e,`/api/v1/collections`)}search(e){return this.post(`/search`,{payload:e})}computeListFacets(e){return this.post(`/facets`,{payload:e})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}addMembers(e,t){return this.post(`/${e}/members`,{payload:{action:`add`,members:t}})}listMembers(e,t){return this.get(`/${e}/members`,{query:{...t}})}computeFacets(e,t){return this.post(`/${e}/facets`,{payload:t})}searchMembers(e,t){return this.post(`/${e}/search`,{payload:t})}deleteMembers(e,t){return this.post(`/${e}/members`,{payload:{action:`delete`,members:t}})}addChildren(e,t){return this.post(`/${e}/children`,{payload:{action:`add`,children:t}})}deleteChildren(e,t){return this.post(`/${e}/children`,{payload:{action:`delete`,children:t}})}searchChildren(e,t={}){return this.post(`/${e}/children/search`,{payload:t})}delete(e){return this.del(`/${e}`)}updatePermissions(e,t){return this.put(`/${e}/permissions`,{payload:t})}propagatePermissions(e){return this.post(`/${e}/propagate-permissions`)}propagateSharedProperties(e){return this.post(`/${e}/propagate-shared-props`)}},Tt=class extends L{constructor(e){super(e,`/api/v1/cost`)}getAnalytics(e={}){return this.post(`/analytics`,{payload:e})}getGlobalAnalytics(e={}){return this.post(`/analytics/global`,{payload:e})}getModelPrices(e={}){return this.get(`/model-prices`,{query:{...e}})}getRunPrice(e){return this.post(`/run-price`,{payload:e})}getRunPriceComparison(e){return this.post(`/run-price`,{payload:{...e,include_comparison_pricing:!0}})}getExportUrl(e){let t=new URLSearchParams;e?.from&&t.set(`from`,typeof e.from==`number`?new Date(e.from).toISOString():e.from),e?.to&&t.set(`to`,typeof e.to==`number`?new Date(e.to).toISOString():e.to),e?.scope&&t.set(`scope`,e.scope),e?.project_id&&t.set(`project_id`,e.project_id),e?.workflow_id&&t.set(`workflow_id`,e.workflow_id);let n=t.toString();return`${this.baseUrl}/export${n?`?${n}`:``}`}},Et=class extends L{storeId;constructor(e,t){super(e,`/api/v1/data/${t}/dashboards`),this.storeId=t}storeHeaders(){return{[a.DATA_STORE_ID]:this.storeId}}list(e){let t=e?`?status=${e}`:``;return this.get(`/${t}`,{headers:this.storeHeaders()})}create(e){return this.post(`/`,{payload:e,headers:this.storeHeaders()})}retrieve(e){return this.get(`/${e}`,{headers:this.storeHeaders()})}update(e,t){return this.put(`/${e}`,{payload:t,headers:this.storeHeaders()})}delete(e){return this.del(`/${e}`,{headers:this.storeHeaders()})}bulkArchive(e){return this.post(`/bulk/archive`,{payload:{ids:e},headers:this.storeHeaders()})}bulkDelete(e){return this.post(`/bulk/delete`,{payload:{ids:e},headers:this.storeHeaders()})}listVersions(e,t){let n=new URLSearchParams;t?.snapshotsOnly&&n.set(`snapshots_only`,`true`),t?.limit&&n.set(`limit`,String(t.limit));let r=n.toString()?`?${n}`:``;return this.get(`/${e}/versions${r}`,{headers:this.storeHeaders()})}getVersion(e,t){return this.get(`/${e}/versions/${t}`,{headers:this.storeHeaders()})}createSnapshot(e,t){return this.post(`/${e}/versions`,{payload:t,headers:this.storeHeaders()})}promoteVersion(e,t,n){return this.post(`/${e}/versions/${t}/promote`,{payload:n||{},headers:this.storeHeaders()})}setVersioningEnabled(e,t){return this.put(`/${e}/versioning`,{payload:{enabled:t},headers:this.storeHeaders()})}},Dt=class extends L{constructor(e){super(e,`/api/v1/data`)}storeHeaders(e){return{[a.DATA_STORE_ID]:e}}list(){return this.get(`/`)}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`,{headers:this.storeHeaders(e)})}delete(e){return this.del(`/${e}`,{headers:this.storeHeaders(e)})}getSchema(e,t){let n=t?`?format=${t}`:``;return this.get(`/${e}/schema${n}`,{headers:this.storeHeaders(e)})}updateSchema(e,t){return this.put(`/${e}/schema`,{payload:t,headers:this.storeHeaders(e)})}getSchemaHistory(e){return this.get(`/${e}/schema/history`,{headers:this.storeHeaders(e)})}listTables(e){return this.get(`/${e}/tables`,{headers:this.storeHeaders(e)})}createTables(e,t){return this.post(`/${e}/tables`,{payload:t,headers:this.storeHeaders(e)})}getTable(e,t,n){let r=n?`?sample=true`:``;return this.get(`/${e}/tables/${t}${r}`,{headers:this.storeHeaders(e)})}alterTable(e,t,n){return this.put(`/${e}/tables/${t}`,{payload:n,headers:this.storeHeaders(e)})}dropTable(e,t){return this.del(`/${e}/tables/${t}`,{headers:this.storeHeaders(e)})}import(e,t){return this.post(`/${e}/import`,{payload:t,headers:this.storeHeaders(e)})}getImportStatus(e,t){return this.get(`/${e}/import/${t}`,{headers:this.storeHeaders(e)})}listVersions(e,t){let n=t?`?snapshots_only=true`:``;return this.get(`/${e}/versions${n}`,{headers:this.storeHeaders(e)})}createSnapshot(e,t){return this.post(`/${e}/versions`,{payload:t,headers:this.storeHeaders(e)})}rollback(e,t){return this.post(`/${e}/versions/${t}/rollback`,{headers:this.storeHeaders(e)})}queryVersion(e,t,n){return this.post(`/${e}/versions/${t}/query`,{payload:n,headers:this.storeHeaders(e)})}query(e,t){return this.post(`/${e}/query`,{payload:t,headers:this.storeHeaders(e)})}queryBatch(e,t){return this.post(`/${e}/query/batch`,{payload:{queries:t},headers:this.storeHeaders(e)})}mutateRows(e,t){return this.post(`/${e}/mutate`,{payload:t,headers:this.storeHeaders(e)})}validateQueries(e,t){return this.post(`/${e}/query/validate`,{payload:{queries:t},headers:this.storeHeaders(e)})}getDownloadInfo(e,t){let n=t?`?version_id=${t}`:``;return this.get(`/${e}/download${n}`,{headers:this.storeHeaders(e)})}dashboards(e){return new Et(this.client,e)}},Ot=class extends L{constructor(e){super(e,`/api/v1/email`)}send(e){return this.post(`/send`,{payload:e})}resolveRoute(e){return this.post(`/resolve-route`,{payload:{route_key:e}})}createRoute(e){return this.post(`/routes`,{payload:e})}getRoute(e){return this.get(`/routes/${e}`)}updateRoute(e,t){return this.put(`/routes/${e}`,{payload:t})}forwardEmail(e,t){return this.post(`/routes/${e}/forward`,{payload:t})}},kt=class extends L{constructor(e,t=`/api/v1/embeddings`){super(e,t)}async status(e){return this.get(`${e}/status`)}async activate(e,t){if(!t.environment)throw Error(`Invalid configuration: select environment`);return this.post(`${e}/enable`,{payload:t})}async disable(e){return this.post(`${e}/disable`)}async recalculate(e,t={}){return this.post(`${e}/recalculate`,Object.keys(t).length?{query:t}:void 0)}async prepareBatch(e,t=!1){return this.post(`/batch/prepare`,{payload:e,timeoutMs:t})}async updateBatch(e){return this.post(`/batch/update`,{payload:e})}async prepareBatchRenditionPage(e){return this.post(`/batch/renditions/prepare`,{payload:e})}async pollBatchRenditionPage(e){return this.post(`/batch/renditions/status`,{payload:e})}async cancelBatchRenditionPage(e){return this.post(`/batch/renditions/cancel`,{payload:e})}async applyBatch(e,t=!1){return this.post(`/batch/apply`,{payload:e,timeoutMs:t})}};function At(e){return JSON.parse(e)}function jt(e,t,n){let r=Math.min(t*2**e,n);return r+Math.random()*.1*r}function Mt(e,t){if(!t)return;let n=t.startsWith(`Bearer `)?t.slice(7):t;e.searchParams.set(`access_token`,n)}async function Nt(e){let t=typeof e==`function`?await e():e;return t instanceof URL?new URL(t.href):new URL(t)}function Pt(e){let t=e.event_types?.length?e.event_types:[`message`],n=e.max_reconnect_attempts??10,r=e.base_reconnect_delay_ms??1e3,i=e.max_reconnect_delay_ms??3e4,a=e.parse??At,o=!1,s=0,c=null,l=null,u=null,d=0,f,p=t=>{e.on_status?.(t)},m=()=>{c&&=(c.close(),null),l&&=(clearTimeout(l),null)},h=()=>{o||(o=!0,m(),e.signal&&u&&(e.signal.removeEventListener(`abort`,u),u=null),p(`closed`))},g=t=>{if(o)return;if(m(),(d?Date.now()-d:0)>5e3&&(s=0),s>=n){h(),e.on_error?.(t);return}let a=jt(s,r,i);s+=1,p(`reconnecting`),l=setTimeout(()=>{l=null,v(!0)},a)},_=(t,n)=>{if(!(o||!n.data||String(n.data).startsWith(`:`)))try{let r=a(String(n.data),t),i=e.get_cursor?.(r);f=n.lastEventId||i||f,e.on_event({data:r,event_type:t,event_id:n.lastEventId||i})}catch(t){e.on_error?.(t)}},v=async n=>{if(!o)try{p(n?`reconnecting`:`connecting`);let r=await R();if(o)return;let i=await Nt(e.url);if(f&&e.last_event_id_query_param&&!i.searchParams.has(e.last_event_id_query_param)&&i.searchParams.set(e.last_event_id_query_param,f),Mt(i,await e.get_access_token?.()),o)return;let a=new r(i.href);c=a,d=0,a.onopen=()=>{d=Date.now(),p(`open`)};for(let e of t)a.addEventListener(e,t=>_(e,t));a.onerror=e=>{g(e)}}catch(e){g(e)}};if(e.signal){if(e.signal.aborted)return o=!0,p(`closed`),{get closed(){return o},close:h};u=h,e.signal.addEventListener(`abort`,u,{once:!0})}return v(!1),{get closed(){return o},close:h}}function Ft(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))if(r!=null){if(Array.isArray(r)){if(r.length===0)continue;t[n]=r.join(`,`)}else t[n]=String(r)}return Object.keys(t).length?t:void 0}var It=class extends L{constructor(e){super(e,`/api/v1/events/channels`)}list(e){return this.get(`/`,{query:Ft(e)})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}};function Lt(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))if(r!=null){if(Array.isArray(r)){if(r.length===0)continue;t[n]=r.join(`,`)}else t[n]=String(r)}return Object.keys(t).length?t:void 0}var Rt=class extends L{constructor(e){super(e,`/api/v1/events/subscriptions`)}list(e){return this.get(`/`,{query:Lt(e)})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}},zt=class extends L{subscriptions;channels;constructor(e){super(e,`/api/v1/events`),this.subscriptions=new Rt(e),this.channels=new It(e)}searchDeliveries(e={}){return this.post(`/deliveries/search`,{payload:e})}queueSummary(e={}){return this.post(`/deliveries/queue-summary`,{payload:e})}cancelQueuedDeliveries(e={}){return this.post(`/deliveries/cancel`,{payload:e})}subscribeDeliveries(e){let{signal:t,max_reconnect_attempts:n,on_snapshot:r,on_delivery:i,on_envelope:a,on_error:o,on_status:s,...c}=e;return Pt({url:()=>this.buildStreamUrl(c),event_types:[`snapshot`,`event`,`heartbeat`,`error`],signal:t,max_reconnect_attempts:n,last_event_id_query_param:`since_event_id`,get_access_token:async()=>{let e=this.client;return e._auth?await e._auth():void 0},get_cursor:e=>e.cursor,on_status:s,on_error:o,on_event:({data:e})=>{a?.(e),e.type===`snapshot`?r?.(e.deliveries,e):e.type===`event`?i?.(e.item,e):e.type===`error`&&o?.(Error(e.error))}})}buildStreamUrl(e){let t=new URL(`${this.baseUrl}/stream`);return this.setStreamParam(t,`limit`,e.limit),this.setStreamParam(t,`event_id`,e.event_id),this.setStreamParam(t,`resource_id`,e.resource_id),this.setStreamListParam(t,`resource_type`,e.resource_type),this.setStreamListParam(t,`event_category`,e.event_category),this.setStreamListParam(t,`action`,e.action),this.setStreamListParam(t,`outbox_status`,e.outbox_status),this.setStreamParam(t,`since_event_id`,e.since_event_id),this.setStreamParam(t,`since_created_at`,e.since_created_at),this.setStreamParam(t,`include_event`,e.include_event),this.setStreamParam(t,`poll_interval_ms`,e.poll_interval_ms),t}setStreamParam(e,t,n){n!=null&&n!==``&&e.searchParams.set(t,String(n))}setStreamListParam(e,t,n){n?.length&&e.searchParams.set(t,n.join(`,`))}},Bt=class extends b{constructor(e,t){super(`Resource not found: ${t.message}`,e,404,t.payload)}},K=class{stream;name;type;id;constructor(e,t,n,r){this.stream=e,this.name=t,this.type=n,this.id=r}};function Vt(e){return e?.split(`;`,1)[0]?.trim().toLowerCase()||void 0}function q(e){return Vt(e)===`application/octet-stream`?void 0:e||void 0}function J(e,t){return q(e)||t||e||void 0}const Ht=`memories`,Y=`agents`,Ut={attempts:3,methods:[`POST`],statuses:[502,503,504]};function Wt(e){try{let t=new URL(e);return`${t.protocol}//${t.host}${t.pathname}`}catch{return e.split(/[?#]/,1)[0]||`unknown file`}}function Gt(e){if(!(e instanceof Error))return;let t=e.message.replace(/https?:\/\/[^\s)\]}>"']+/g,e=>Wt(e)),n=Error(t);return n.name=e.name,n}function Kt(e,t){return e===404?`not found`:e===403?`forbidden`:e?`failed with status ${e}${t?` ${t}`:``}`:`failed`}var X=class extends Error{status;constructor(e,t,n,r){let i=Wt(e),a=Kt(t,n);super(`File download ${a}: ${i}`,{cause:Gt(r)}),this.name=`FileDownloadError`,this.status=t}};function Z(e){let t=e.endsWith(`.tar.gz`)?e:`${e}.tar.gz`;return`${Ht}/${t}`}function Q(e,t){return`${Y}/${e}/${t}`}var qt=class extends L{constructor(e){super(e,`/api/v1/files`)}async deleteFile(e,t){return this.del(`/${e}`,{query:{prefix:t}})}getMetadata(e){return this.get(`/metadata`,{query:{file:e}})}setFileMetadata(e,t){let n={file:e,metadata:t};return this.put(`/metadata`,{payload:n})}getOrCreateBucket(){return this.post(`/bucket`)}ensureBucketReadAccess(e){let t={principal:e};return this.post(`/bucket/read-access`,{payload:t})}getBucketReadAccessStatus(e){return this.get(`/bucket/read-access`,{query:{principal:e}})}ensureBucketCreateAccess(e){let t={principal:e};return this.post(`/bucket/create-access`,{payload:t})}getBucketCreateAccessStatus(e){return this.get(`/bucket/create-access`,{query:{principal:e}})}list(e){return this.get(`/list`,{query:{prefix:e}})}getUploadUrl(e){return this.post(`/upload-url`,{payload:e,retryPolicy:Ut})}getDownloadUrl(e,t,n){let r={file:e,name:t,disposition:n};return this.post(`/download-url`,{payload:r})}getDownloadUrlWithOptions(e){return this.post(`/download-url`,{payload:e})}bulkGetUploadUrls(e){return this.post(`/bulk-upload-urls`,{payload:e})}async bulkUpload(e,t=10){let n=e.map(e=>({name:e.name,mime_type:q(e.type),id:e instanceof K?e.id:void 0})),{files:r}=await this.bulkGetUploadUrls({files:n}),i=Array(e.length);for(let n=0;n<e.length;n+=t){let a=e.slice(n,n+t);await Promise.all(a.map(async(e,t)=>{let a=n+t,{url:o,id:s,mime_type:c}=r[a],l=e instanceof K,u=J(e.type,c),d=await U(o,{method:`PUT`,body:l?e.stream:e,headers:u?{"Content-Type":u}:void 0});if(!d.ok)throw Error(`Failed to upload file ${e.name}: ${d.statusText}`);let f=d.headers.get(`etag`)?.replace(/^"(.*)"$/,`$1`);i[a]={source:s,name:e.name,type:u,etag:f}}))}return i}async uploadFile(e){return(await this.uploadFileWithPath(e)).id}async uploadFileWithPath(e){let t=e instanceof K,{url:n,id:r,path:i,mime_type:a}=await this.getUploadUrl({id:t?e.id:void 0,name:e.name,mime_type:q(e.type)}),o=J(e.type,a)||`application/gzip`,s=await U(n,{method:`PUT`,body:t?e.stream:e,headers:{"Content-Type":o}}).catch(e=>{throw console.error(`Failed to upload file`,{err:e,url:n,id:r,path:i}),e});if(!s.ok)throw console.log(s),Error(`Failed to upload file: ${s.statusText}`);return{id:r,path:i}}async downloadFile(e){let{url:t}=e.startsWith(`https:`)?{url:e}:await this.getDownloadUrl(e),n;try{n=await U(t,{method:`GET`})}catch(t){throw new X(e,void 0,void 0,t)}if(!n.ok)throw new X(e,n.status,n.statusText);if(!n.body)throw new X(e);return n.body}async copyFile(e,t){return(await this.post(`/copy`,{payload:{source:e,dest:t}})).dest}async uploadMemoryPack(e){let t=Z(e.name),n=e.name.endsWith(`.tar.gz`)?e.name:`${e.name}.tar.gz`;if(e instanceof File){let r=e;return this.uploadFile(new K(r.stream(),n,r.type,t))}return this.uploadFile(new K(e.stream,n,e.type,t))}async downloadMemoryPack(e,t=!1){let n=await this.downloadFile(Z(e));if(t){let e=new DecompressionStream(`gzip`);n=n.pipeThrough(e)}return n}listByPrefix(e){return this.get(`/list`,{query:{prefix:e}})}async uploadArtifact(e,t,n){let r=Q(e,t);if(n instanceof File){let e=n;return this.uploadFile(new K(e.stream(),t,e.type,r))}return this.uploadFile(new K(n.stream,t,n.type,r))}async downloadArtifact(e,t){let n=Q(e,t);return this.downloadFile(n)}getArtifactDownloadUrl(e,t,n){let r=Q(e,t);return this.getDownloadUrl(r,t,n)}async listArtifacts(e){let t=`${Y}/${e}/`;return(await this.listByPrefix(t)).files}},Jt=class extends L{constructor(e,t=`/api/v1/indexing`){super(e,t)}async status(){return this.get(`/status`)}async reindex(e){return this.post(`/reindex`,{payload:e})}async reindexAgentRuns(e){return this.post(`/agent-runs/reindex`,{payload:e})}async analyzeDrift(){return this.post(`/analyze-drift`,{payload:{}})}async getDriftAnalysis(){return this.get(`/drift-analysis`)}async enableIndexing(){return this.post(`/enable-indexing`)}async disableIndexing(){return this.post(`/disable-indexing`)}async enableQueries(){return this.post(`/enable-queries`)}async disableQueries(){return this.post(`/disable-queries`)}index(e,t){return this.post(`/internal/index`,{payload:{object_id:e,document:t}})}delete(e){return this.post(`/internal/delete`,{payload:{object_id:e}})}bulkIndex(e,t){return this.post(`/internal/bulk-index`,{payload:{documents:e,target_index:t}})}ensureIndex(e){return this.post(`/internal/ensure-index`,{payload:{recreate:e}})}createReindexTarget(){return this.post(`/internal/create-reindex-target`,{payload:{}})}getStats(){return this.post(`/internal/stats`,{payload:{}})}fetchBatch(e,t){return this.post(`/internal/fetch-batch`,{payload:{cursor:e,limit:t}})}getNextIndexCursor(e,t,n){return this.post(`/internal/next-cursor`,{payload:{cursor:e,limit:t,count:n}})}analyzeDriftBatch(e,t){return this.post(`/internal/analyze-drift-batch`,{payload:{cursor:e,limit:t}})}triggerReindex(e){return this.post(`/internal/trigger-reindex`,{payload:e?{full_reindex:e.fullReindex,object_ids:e.objectIds,recreate_index:e.recreateIndex}:{}})}fetchDocumentsByIds(e){return this.post(`/internal/fetch-by-ids`,{payload:{object_ids:e}})}bulkDelete(e){return this.post(`/internal/bulk-delete`,{payload:{object_ids:e}})}getConfiguration(){return this.post(`/internal/configuration`,{payload:{}})}get zenoBulkBaseUrl(){let e=this.client.baseUrl;return e.includes(`localhost:`)||e.includes(`127.0.0.1:`)?`https://zeno-bulk-dev-main.api.dev1.vertesia.io`:e.includes(`zeno-server`)?e.replace(/zeno-server/,`zeno-bulk`):e}zenoBulkPost(e,t){return this.client.post(this.zenoBulkBaseUrl+e,{payload:t})}computeShards(e,t,n,r){return this.zenoBulkPost(`/reindex/compute-shards`,{tenant_id:e,shard_size:t??25e4,updated_since:n,backend:r})}indexShard(e){return this.zenoBulkPost(`/reindex/shard`,{params:e})}swapAlias(e,t,n,r){return this.zenoBulkPost(`/reindex/swap-alias`,{tenant_id:e,target_index:t,alias:n,backend:r})}},Yt=class extends L{objectId;constructor(e,t){super(e,`/${t}/analyze`),this.objectId=t}async start(e){return this.post(`/`,{payload:e})}async getStatus(){return this.get(`/status`)}async startGroundedExtraction(e){return this.post(`/grounded`,{payload:e??{}})}async getGroundedExtractionResult(){return this.get(`/grounded/result`)}async startGroundedAssistant(e){return this.post(`/grounded/assistant`,{payload:e??{}})}},Xt=class extends L{constructor(e){super(e,`/api/v1/objects`)}analyze(e){return new Yt(this,e)}getUploadUrl(e){return this.post(`/upload-url`,{payload:e})}getDownloadUrl(e,t,n){return this.post(`/download-url`,{payload:{file:e,name:t,disposition:n}})}getDownloadUrlWithOptions(e){return this.post(`/download-url`,{payload:e})}getContentSource(e){return this.get(`/${e}/content-source`)}list(e={}){let t=e.limit||100,n=e.offset||0,r=e.query||{};return this.get(`/`,{query:{limit:t,offset:n,select:e.select,...r,all_revisions:e.all_revisions,from_root:e.from_root||void 0}})}computeFacets(e){return this.post(`/facets`,{payload:e})}startExport(e={}){return this.post(`/export/bulk`,{payload:e})}listExports(){return this.get(`/export/bulk/artifacts`)}deleteExport(e){return this.del(`/export/bulk/artifacts/${encodeURIComponent(e)}`)}getExportStatus(e,t){return this.get(`/export/bulk/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}getExportDownloadUrl(e,t){return this.get(`/export/bulk/artifacts/${encodeURIComponent(e)}/${t}/download-url`)}async downloadExportFile(e,t){let{url:n}=await this.getExportDownloadUrl(e,t),r=await U(n,{method:`GET`}).then(e=>{if(!e.ok)throw Error(`Failed to download export file: ${e.status} ${e.statusText}`);return e});if(!r.body)throw Error(`No response body received when downloading export file`);return r.body}exportToBucketViaBulk(e,t=!1){return this.zenoBulkPost(`/export`,e,t)}planContentObjectExportViaBulk(e,t=!1){return this.zenoBulkPost(`/export/plan`,e,t)}exportContentObjectShardViaBulk(e,t=!1){return this.zenoBulkPost(`/export/shard`,e,t)}splitContentObjectExportShardViaBulk(e,t=!1){return this.zenoBulkPost(`/export/shard/split`,e,t)}composeContentObjectExportViaBulk(e,t=!1){return this.zenoBulkPost(`/export/compose`,e,t)}get zenoBulkBaseUrl(){let e=this.client.baseUrl;return e.includes(`localhost:`)||e.includes(`127.0.0.1:`)?`https://zeno-bulk-dev-main.api.dev1.vertesia.io`:e.includes(`zeno-server`)?e.replace(/zeno-server/,`zeno-bulk`):e}zenoBulkPost(e,t,n){return this.client.post(this.zenoBulkBaseUrl+e,{payload:t,timeoutMs:n})}listFolders(e=`/`){throw Error(`Not implemented yet`)}find(e){return this.post(`/find`,{payload:e})}count(e){return this.post(`/count`,{payload:e})}search(e){return this.post(`/search`,{payload:e})}retrieve(e,t){return this.get(`/${e}`,{query:{select:t}})}getObjectText(e){return this.get(`/${e}/text`)}async upload(e){let t=e instanceof K,{url:n,id:r,mime_type:i}=await this.getUploadUrl({id:t?e.id:void 0,name:e.name,mime_type:q(e.type)}),a=J(e.type,i),o=await U(n,{method:`PUT`,body:t?e.stream:e,headers:a?{"Content-Type":a}:void 0}).catch(e=>{throw console.error(`Failed to upload file`,e),e});if(!o.ok)throw console.error(`Failed to upload file`,{status:o.status,statusText:o.statusText,url:n}),Error(`Failed to upload file: ${o.statusText}`);let s=o.headers.get(`etag`)?.replace(/^"(.*)"$/,`$1`);return{source:r,name:e.name,type:a,etag:s}}async create(e,t){let{content:n,...r}=e,a={...r};a.content=n instanceof K||n instanceof File?await this.upload(n):n;let o={};return t?.processing_priority&&(o[i.PROCESSING_PRIORITY]=t.processing_priority),t?.collection_id&&(o[i.COLLECTION_ID]=t.collection_id),await this.post(`/`,{payload:a,headers:o})}async createFromExternalSource(e,t={},n){let r=await this.client.files.getMetadata(e),a={...t,content:{source:e,name:r.name,type:r.contentType,etag:r.etag}},o={};return n?.processing_priority&&(o[i.PROCESSING_PRIORITY]=n.processing_priority),n?.collection_id&&(o[i.COLLECTION_ID]=n.collection_id),await this.post(`/`,{payload:a,headers:o})}async update(e,t,n){let{content:r,...a}=t,o={...a};o.content=r instanceof K||r instanceof File?await this.upload(r):r;let s={};return n?.ifMatch&&(s[`if-match`]=n.ifMatch),n?.processing_priority&&(s[i.PROCESSING_PRIORITY]=n.processing_priority),n?.createRevision&&(s[i.CREATE_REVISION]=`true`),n?.suppressWorkflows&&(s[i.SUPPRESS_WORKFLOWS]=`true`),this.put(`/${e}`,{payload:o,query:n?.createRevision&&n.revisionLabel?{revision_label:n.revisionLabel}:void 0,headers:s})}getRevisions(e){return this.get(`/${e}/revisions`)}getCollections(e){return this.get(`/${e}/collections`)}delete(e){return Array.isArray(e)?this.client.runOperation({name:`delete`,ids:e,params:{}}):this.del(`/${e}`)}bulkUpdate(e,t){let n=Object.keys(e);return this.client.runOperation({name:`update`,ids:n,params:t?{updates:e,...t}:e})}bulkCreate(e,t){return this.client.runOperation({name:`create`,ids:[],params:{objects:e,...t}})}listWorkflowRuns(e){return this.get(`/${e}/workflow-runs`)}listRenditions(e){return this.get(`/${e}/renditions`)}getRendition(e,t){let n={max_hw:t.max_hw,generate_if_missing:t.generate_if_missing,sign_url:t.sign_url,block_on_generation:t.block_on_generation};return this.get(`/${e}/renditions/${t.format}`,{query:n})}getRenditionSafe(e,t,n){return u(t,n.format)?this.getRendition(e,n):Promise.resolve(null)}exportProperties(e){return this.post(`/export`,{payload:e})}setEmbedding(e,t,n){return this.put(`/${e}/embeddings/${t}`,{payload:n})}},Zt=class extends L{constructor(e){super(e,`/api/v1/pending-asks`)}register(e){return this.post(`/`,{payload:e})}resolve(e,t){return this.post(`/${e}/resolve`,{payload:t})}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}},Qt=class extends L{constructor(e){super(e,`/api/v1/processes`)}list(e){let t={};return e?.status&&(t.status=e.status),e?.process&&(t.process=e.process),e?.limit!=null&&(t.limit=String(e.limit)),e?.offset!=null&&(t.offset=String(e.offset)),(e?.all_versions||e?.allVersions)&&(t.all_versions=`true`),this.get(`/`,{query:t})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}listVersions(e){return this.get(`/${e}/versions`)}publish(e,t){return this.post(`/${e}/publish`,{payload:t})}revert(e,t){return this.post(`/${e}/revert`,{payload:t})}delete(e){return this.del(`/${e}`)}listTestSuites(e){return this.get(`/${e}/test-suites`)}createTestSuite(e,t){return this.post(`/${e}/test-suites`,{payload:t})}updateTestSuite(e,t,n){return this.put(`/${e}/test-suites/${t}`,{payload:n})}deleteTestSuite(e,t){return this.del(`/${e}/test-suites/${t}`)}startTestRun(e,t){return this.post(`/${e}/test-runs`,{payload:t})}listTestRuns(e,t){return this.get(`/${e}/test-runs`,{query:t?.limit==null?void 0:{limit:String(t.limit)}})}retrieveTestRun(e,t){return this.get(`/${e}/test-runs/${t}`)}cancelTestRun(e,t){return this.post(`/${e}/test-runs/${t}/cancel`,{})}},$t=class extends L{constructor(e){super(e,`/api/v1/process-test-runs`)}submit(e){return this.post(`/`,{payload:e,retryPolicy:!1})}retrieve(e){return this.get(`/${e}`)}cancel(e){return this.post(`/${e}/cancel`,{})}delete(e){return this.del(`/${e}`)}},en=class extends L{constructor(e,t=`/api/v1/query`){super(e,t)}async execute(e){return this.post(`/`,{payload:e})}async sql(e){return this.execute({sql:e})}async esql(e){return this.execute({esql:e})}async dsl(e){return this.execute({dsl:e})}},tn=class extends L{constructor(e){super(e,`/api/v1/rendering`)}start(e){return this.post(`/jobs`,{payload:e})}getStatus(e,t){return this.get(`/jobs/status`,{query:{workflow_id:e,workflow_run_id:t}})}async render(e,t={}){let n=t.pollIntervalMs??1500,r=t.timeoutMs??6e5,i=await this.start(e);if(!i.workflow_id||!i.workflow_run_id)throw Error(`Failed to start rendering workflow`);let a=Date.now();for(;;){let t=await this.getStatus(i.workflow_id,i.workflow_run_id);if(t.status===l.COMPLETED){if(!t.download_url&&!t.file_uri)throw Error(t.error||`Rendering completed but no output file was produced`);return{status:`success`,format:e.format,download_url:t.download_url,file_uri:t.file_uri}}if(p(t.status)){let e=l[t.status]||String(t.status);throw Error(t.error||`Rendering failed with status: ${e}`)}if(Date.now()-a>=r)throw Error(`Rendering timed out after ${r}ms`);await nn(n)}}};function nn(e){return new Promise(t=>setTimeout(t,e))}var rn=class extends L{constructor(e){super(e,`/api/v1/schedules`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}trigger(e){return this.post(`/${e}/trigger`,{})}pause(e,t){return this.post(`/${e}/pause`,{payload:{note:t}})}resume(e,t){return this.post(`/${e}/resume`,{payload:{note:t}})}},an=class extends L{constructor(e){super(e,`/api/v1/tasks`)}list(e={}){return this.get(`/`,{query:e})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}complete(e,t){return this.post(`/${e}/complete`,{payload:t})}cancel(e){return this.post(`/${e}/cancel`,{})}delete(e){return this.del(`/${e}`)}},on=class extends L{constructor(e){super(e,`/api/v1/types/catalog`)}list(e={}){return this.get(`/`,{query:e})}listSysTypes(e){return this.get(`/sys`,{query:{tag:e}})}listAppTypes(e){return this.get(`/apps`,{query:{tag:e}})}listStoredTypes(e={}){return this.get(`/stored`,{query:e})}resolve(e){let t=typeof e==`string`?e:e.id;return this.get(`/resolve/${t}`)}},sn=class extends L{catalog;constructor(e){super(e,`/api/v1/types`),this.catalog=new on(e)}list(e={},t){let n=e.limit||2e3,r=e.offset||0,i=e.query||{};return this.get(`/`,{query:{limit:n,offset:r,layout:!!t?.layout,schema:!!t?.schema,...i}})}find(e){return this.post(`/find`,{payload:e})}retrieve(e){return this.get(`/${e}`)}getTypeByName(e){return this.get(`/name/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}create(e){return this.post(`/`,{payload:e})}delete(e){return this.del(`/${e}`)}},cn=class extends L{constructor(e){super(e,`/api/v1/view-executions`)}execute(e,t={}){return this.post(`/${encodeURIComponent(e)}/execute`,{payload:t})}preview(e){return this.post(`/preview`,{payload:e})}},ln=class extends L{constructor(e){super(e,`/api/v1/workflows`)}getActivityCatalog(){return this.get(`/activity-catalog`)}listRuns(e,t,n){return this.post(`/runs`,{payload:{documentId:e,eventName:t,ruleId:n}})}listConversations(e){return this.post(`/conversations`,{payload:e})}searchRuns(e){return this.post(`/runs`,{payload:e})}sendSignal(e,t,n,r){return this.post(`/runs/${e}/${t}/signal/${n}`,{payload:r})}getRunDetails(e,t,n){let r={};return n?.includeHistory!==void 0&&(r.include_history=n.includeHistory),n?.historyFormat!==void 0&&(r.history_format=n.historyFormat),n?.hydratePayloads!==void 0&&(r.hydrate_payloads=n.hydratePayloads),this.get(`/runs/${t}/${e}`,{query:r})}getRunInteraction(e,t){return this.get(`/runs/${e}/${t}/interaction`)}terminate(e,t,n){let r={reason:n};return this.post(`/runs/${e}/${t}/actions/terminate`,{payload:r})}cancel(e,t,n){let r={reason:n};return this.post(`/runs/${e}/${t}/actions/cancel`,{payload:r})}query(e,t,n){return this.get(`/runs/${e}/${t}/query/${n}`)}execute(e,t={}){return this.post(`/execute/${e}`,{payload:t})}postMessage(e,t){if(!e)throw Error(`runId is required`);return this.post(`/runs/${e}/updates`,{payload:t})}async retrieveMessages(e,t,n){let r={since:n};return(await this.get(`/runs/${e}/${t}/updates`,{query:r})).messages.map(e=>g(m(e),t))}async streamMessages(e,t,r,i,a){return new Promise((o,s)=>{let c=0,l=i||0,u=Date.now(),d=!1,f=null,p=null,h=null,_=null,v=e=>{let t=Math.min(1e3*2**e,3e4);return t+Math.random()*.1*t},y=()=>{h&&=(clearTimeout(h),null),p&&=(clearInterval(p),null),f&&=(f.close(),null),a&&_&&(a.removeEventListener(`abort`,_),_=null)},b=e=>{d||(d=!0,y(),o(e))};if(a){if(a.aborted){b(null);return}_=()=>b(null),a.addEventListener(`abort`,_,{once:!0})}let x=async(i=!1)=>{if(!d)try{let a=await R(),u=this.client,_=new URL(`${u.workflows.baseUrl}/runs/${e}/${t}/stream`);l>0&&_.searchParams.set(`since`,l.toString()),_.searchParams.set(`skipHistory`,`true`);let S=u._auth?await u._auth():void 0;if(d)return;if(!S){d=!0,y(),s(Error(`No auth token available`));return}let C=S.split(` `)[1];_.searchParams.set(`access_token`,C),i&&console.log(`Reconnecting to SSE stream for run ${t} (attempt ${c+1}/10)`);let w=new a(_.href);f=w,p=setInterval(()=>{},1e3),w.onopen=()=>{i&&console.log(`Successfully reconnected to SSE stream for run ${t}`),c=0},w.onmessage=e=>{if(!e.data||e.data.startsWith(`:`)){console.log(`Received comment or heartbeat; ignoring it.: `,e.data);return}try{let i=m(e.data);l=i.ts?Math.max(l,i.ts):Date.now(),r&&r(g(i,t),b),xt(i,t)?(console.log(`Closing stream due to COMPLETE message from main workstream`),d||(d=!0,y(),o(null))):i.t===n.COMPLETE&&console.log(`Received COMPLETE message that does not close the root stream for run ${t}`)}catch(t){console.error(`Failed to parse SSE message:`,t,e.data)}},w.onerror=e=>{if(!d){if(console.warn(`SSE stream error for run ${t}:`,e),y(),c<10){let e=v(c);console.log(`Attempting to reconnect in ${e}ms (attempt ${c+1}/10)`),c++,h=setTimeout(()=>{h=null,d||x(!0)},e)}else console.error(`Failed to reconnect to SSE stream for run ${t} after 10 attempts`),d=!0,s(Error(`SSE connection failed after 10 reconnection attempts`))}}}catch(e){if(console.error(`Error setting up SSE stream:`,e),c<10){let e=v(c);c++,h=setTimeout(()=>{h=null,d||x(!0)},e)}else s(e)}};(async()=>{try{let n=await this.retrieveMessages(e,t,i),a=!1;for(let e=0;e<n.length;e++){let i=n[e];l=Math.max(l,i.timestamp||0),r&&r(i,b),a=e===n.length-1&&W(i,t)}if(a){b(null);return}}catch(e){console.warn(`Failed to fetch historical messages, continuing with SSE:`,e)}!d&&l<=0&&(l=Math.max(1,u-1)),x(!1)})().catch(s)})}async streamMessagesWS(e,t,r,i){return new Promise((a,o)=>{let s=0,c=null,l=i||0,u=!1,d=e=>{let t=Math.min(1e3*2**e,3e4);return t+Math.random()*.1*t},f=async()=>{if(!u)try{let i=this.client,p=new URL(`${i.workflows.baseUrl}/runs/${e}/${t}/ws`);p.protocol=p.protocol.replace(`http`,`ws`),l>0&&p.searchParams.set(`since`,l.toString());let h=i._auth?await i._auth():void 0;if(!h){o(Error(`No auth token available`));return}let g=h.split(` `)[1];p.searchParams.set(`access_token`,g),s>0&&console.log(`Reconnecting to WebSocket for run ${t} (attempt ${s+1}/10)`),c=new WebSocket(p.href),c.onopen=()=>{s>0&&console.log(`Successfully reconnected to WebSocket for run ${t}`),s=0,u||a({cleanup:()=>{u=!0,c&&=(c.close(),null)},sendSignal:(e,t)=>{if(c?.readyState===WebSocket.OPEN){let n={type:`signal`,signalName:e,data:t,requestId:Date.now()};c.send(JSON.stringify(n))}else console.warn(`WebSocket not open, cannot send signal`)}})},c.onmessage=e=>{try{let t=JSON.parse(e.data);if(`type`in t&&typeof t.type==`string`){if(t.type===`pong`){console.debug(`Received pong`);return}if(t.type===`ack`){console.debug(`Signal acknowledged`,t);return}if(t.type===`error`){console.error(`WebSocket error message`,t);return}}let i=m(t);l=i.ts?Math.max(l,i.ts):Date.now(),r&&r(i);let a=i.w||`main`;(i.t===n.TERMINATED||i.t===n.COMPLETE&&a===`main`)&&(console.log(`Closing WebSocket due to workflow completion`),u=!0,c&&=(c.close(),null))}catch(e){console.error(`Failed to parse WebSocket message`,e)}},c.onerror=e=>{console.error(`WebSocket error`,e)},c.onclose=()=>{if(!u&&s<10){let e=d(s);console.log(`WebSocket closed, reconnecting in ${e}ms (attempt ${s+1}/10)`),s++,setTimeout(f,e)}else s>=10&&o(Error(`WebSocket connection failed after 10 attempts`))}}catch(e){if(console.error(`Error setting up WebSocket`,e),s<10){let e=d(s);s++,setTimeout(f,e)}else o(e)}};f()})}ingestEvents(e,t,n){return this.post(`/runs/${e}/${t}/events`,{payload:{events:n}})}getAnalyticsSummary(e={}){return this.post(`/analytics/summary`,{payload:e})}getTokenUsageAnalytics(e={}){return this.post(`/analytics/tokens`,{payload:e})}getLlmLatencyAnalytics(e={}){return this.post(`/analytics/latency/llm`,{payload:e})}getToolLatencyAnalytics(e={}){return this.post(`/analytics/latency/tools`,{payload:e})}getAgentLatencyAnalytics(e={}){return this.post(`/analytics/latency/agents`,{payload:e})}getErrorAnalytics(e={}){return this.post(`/analytics/errors`,{payload:e})}getToolAnalytics(e={}){return this.post(`/analytics/tools`,{payload:e})}getToolParameterAnalytics(e){return this.post(`/analytics/tools/parameters`,{payload:e})}getAnalyticsFilterOptions(e={}){return this.post(`/analytics/filter-options`,{payload:e})}getPromptSizeAnalytics(e={}){return this.post(`/analytics/prompt-size`,{payload:e})}getTopPrincipalsAnalytics(e={}){return this.post(`/analytics/top-principals`,{payload:e})}getRunsByAgentAnalytics(e={}){return this.post(`/analytics/runs-by-agent`,{payload:e})}getTimeToFirstResponseAnalytics(e={}){return this.post(`/analytics/time-to-first-response`,{payload:e})}getFirstResponseBehaviorAnalytics(e={}){return this.post(`/analytics/first-response-behavior`,{payload:e})}rules=new un(this);definitions=new dn(this)},un=class extends L{constructor(e){super(e,`/rules`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}create(e){return this.post(`/`,{payload:e})}delete(e){return this.del(`/${e}`)}execute(e,t,n){let r={objectIds:t,vars:n};return this.post(`/${e}/execute`,{payload:r})}},dn=class extends L{constructor(e){super(e,`/definitions`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}create(e){return this.post(`/`,{payload:e})}delete(e){return this.del(`/${e}`)}};const fn={serverUrl:!0,tokenServerUrl:!0,apikey:!0,onRequest:!0,onResponse:!0,retryPolicy:!0,timeout:!0,fetch:!0};function pn(e){if(!e)throw Error(`zeno client serverUrl is required`);return e}var mn=class extends xe{constructor(e={}){dt(`ZenoClient`,e,fn),super(pn(e.serverUrl),e.fetch),e.apikey&&this.withApiKey(e.apikey),e.retryPolicy&&this.withRetryPolicy(e.retryPolicy),e.timeout!==void 0&&this.withTimeout(e.timeout),this.onRequest=e.onRequest,this.onResponse=e.onResponse,this.errorFactory=e=>e.status===404?new Bt(e.request,e):e}withApiVersion(e){return e?this.headers[c]=String(e):delete this.headers[c],this}withAppVersion(e){return e?this.headers[t]=String(e):delete this.headers[t],this}withApiKey(e){return this.withAuthCallback(e?()=>Promise.resolve(`Bearer ${e}`):void 0)}runOperation(e){return this.post(`/api/v1/operations`,{payload:e})}get initialHeaders(){return{...super.initialHeaders,[c]:r}}agents=new St(this);cost=new Tt(this);objects=new Xt(this);types=new sn(this);workflows=new ln(this);schedules=new rn(this);processes=new Qt(this);processTestRuns=new $t(this);tasks=new an(this);files=new qt(this);collections=new wt(this);embeddings=new kt(this);email=new Ot(this);events=new zt(this);eventSubscriptions=this.events.subscriptions;pendingAsks=new Zt(this);data=new Dt(this);indexing=new Jt(this);query=new en(this);rendering=new tn(this);views=new cn(this)},hn=class extends L{constructor(e){super(e,`/api/v1/tools`)}list(e){let t={};return e?.sources?.length&&(t.sources=e.sources.join(`,`)),e?.exclude?.length&&(t.exclude=e.exclude.join(`,`)),e?.context&&(t.context=e.context),this.get(`/`,{query:Object.keys(t).length>0?t:void 0})}inspect(e,t){if(!e.trim())throw Error(`Tool name must not be empty`);return this.get(`/${encodeURIComponent(e)}`,{query:t?.context?{context:t.context}:void 0})}listBuiltins(){return this.list({sources:[`builtin`]})}validate(e){return this.post(`/validate`,{payload:{names:e}})}},gn=class extends L{constructor(e){super(e,`/api/v1/training`)}listSessions(e={}){return this.get(`/`,{query:{...e}})}listSessionNames(e={}){return this.get(`/names`,{query:{...e}})}createSession(e){return this.post(`/`,{payload:e})}getSession(e){return this.get(`/${e}`)}addToSession(e,t){return this.post(`/${e}/add`,{payload:{runs:t}})}listSessionRuns(e,t=100,n=0){return this.get(`/${e}/runs`,{query:{limit:t,offset:n}})}buildSession(e){return this.post(`/${e}/build`)}getDataUrl(e){return this.get(`/${e}/url`)}getDataUploadUrl(e,t=!1){return this.get(`/${e}/upload-url`,t?{query:{resumable:`true`}}:{})}startTraining(e){return this.post(`/${e}/start`)}cancelTraining(e){return this.post(`/${e}/cancel`)}getTrainingJob(e){return this.get(`/job/${e}`)}getAndSyncTrainingJob(e){return this.get(`/job/${e}`,{query:{sync:`true`}})}setDataset(e,t=`default`){return this.post(`/${e}/dataset`,{payload:{dataset:t}})}},_n=class extends L{constructor(e){super(e,`/api/v1/users`)}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}},vn=class extends L{executionApi;constructor(e,t){super(e,`/api/v1/views`),this.executionApi=t}list(e={}){return this.get(`/`,{query:{limit:e.limit,offset:e.offset}})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${encodeURIComponent(e)}`)}update(e,t){return this.put(`/${encodeURIComponent(e)}`,{payload:t})}delete(e){return this.del(`/${encodeURIComponent(e)}`)}execute(e,t={}){return this.executionApi.execute(e,t)}preview(e){return this.executionApi.preview(e)}};const yn={site:!0,serverUrl:!0,storeUrl:!0,tokenServerUrl:!0,apikey:!0,sessionTags:!0,onRequest:!0,onResponse:!0,retryPolicy:!0,timeout:!0,fetch:!0};var bn=class e extends xe{_jwt=null;store;sessionTags;tokenServerUrl;oauthClients;oauthGrants;oauthServer;oauthProviders;remoteMcpConnections;secrets;internalSecrets;static async fromAuthToken(t,n,r){if(!t?.trim())throw Error(`VertesiaClient.fromAuthToken requires a non-empty auth token`);n||=$(t);let i=r||En(n.endpoints);return await new e({serverUrl:i.studio,storeUrl:i.store,tokenServerUrl:i.token||n.iss}).withApiKey(t)}static decodeEndpoints(){}constructor(e={site:`api.vertesia.io`}){dt(`VertesiaClient`,e,yn);let t,n;if(e.serverUrl)t=e.serverUrl;else if(e.site)t=`https://${e.site}`;else throw Error(`Parameter 'site' or 'serverUrl' is required for VertesiaClient`);if(e.storeUrl)n=e.storeUrl;else if(e.site)n=`https://${e.site}`;else throw Error(`Parameter 'site' or 'storeUrl' is required for VertesiaClient`);if(super(t,e.fetch),e.tokenServerUrl)this.tokenServerUrl=e.tokenServerUrl;else if(e.site){let t=e.site.replace(/^api/,`sts`);this.tokenServerUrl=`https://${t}`}else if(e.serverUrl||e.storeUrl){let t=e.serverUrl||e.storeUrl||``;try{let e=new URL(t);if(e.hostname.startsWith(`api`)){let t=e.hostname.replace(/^api/,`sts`);this.tokenServerUrl=`https://${t}`}else this.tokenServerUrl=`https://sts.dev1.vertesia.io`}catch{this.tokenServerUrl=`https://sts.dev1.vertesia.io`}}else this.tokenServerUrl=`https://sts.dev1.vertesia.io`;this.store=new mn({serverUrl:n,tokenServerUrl:this.tokenServerUrl,apikey:e.apikey,onRequest:e.onRequest,onResponse:e.onResponse,retryPolicy:e.retryPolicy,timeout:e.timeout,fetch:e.fetch}),this.views=new vn(this,this.store.views),e.retryPolicy&&this.withRetryPolicy(e.retryPolicy),e.timeout!==void 0&&this.withTimeout(e.timeout),e.apikey&&this.withApiKey(e.apikey),this.onRequest=e.onRequest,this.onResponse=e.onResponse,this.sessionTags=e.sessionTags,this.oauthClients=new Ye(this),this.oauthGrants=new Ze(this),this.oauthServer=new $e(this,this.tokenServerUrl),this.oauthProviders=new Qe(this),this.remoteMcpConnections=new at(this),this.secrets=new st(this),this.internalSecrets=new Je(this)}withApiVersion(e){return e?this.headers[c]=String(e):delete this.headers[c],this}withAppVersion(e){return this.store.withAppVersion(e),e?this.headers[t]=String(e):delete this.headers[t],this}withAuthCallback(e){return this.store.withAuthCallback(e),super.withAuthCallback(e)}withRetryPolicy(e){return this.store.withRetryPolicy(e),super.withRetryPolicy(e)}withTimeout(e){return this.store.withTimeout(e),super.withTimeout(e)}async withApiKey(e){return this.withAuthCallback(e?async()=>{if(!xn(e))return`Bearer ${e}`;if(Sn(this._jwt)){let t=await this.getAuthToken(e);this._jwt=t.token}return`Bearer ${this._jwt}`}:void 0)}async getRawJWT(){if(!this._jwt&&this._auth){let e=await this._auth();this._jwt||=e.trim().split(` `)[1]}return this._jwt||null}async getDecodedJWT(){let e=await this.getRawJWT();return e?$(e):null}async getProject(){return(await this.getDecodedJWT())?.project||null}async getAccount(){return(await this.getDecodedJWT())?.account||null}get agents(){return this.store.agents}get workflows(){return this.store.workflows}get objects(){return this.store.objects}get files(){return this.store.files}get processes(){return this.store.processes}get processTestRuns(){return this.store.processTestRuns}get tasks(){return this.store.tasks}get types(){return this.store.types}get data(){return this.store.data}get events(){return this.store.events}get storeUrl(){return this.store.baseUrl}async getAuthToken(e){return this.post(`${this.tokenServerUrl}/token/issue`,{headers:{"content-type":`application/json`,authorization:`Bearer ${e}`},retryPolicy:{attempts:4,methods:[`POST`],statuses:[429,500,502,503,504]}}).catch(e=>{throw console.error(`Error fetching token from ${this.tokenServerUrl}:`,{error:e}),e})}get initialHeaders(){return{...super.initialHeaders,[c]:r}}projects=new et(this);environments=new je(this);interactions=new qe(this);skills=new ct(this);prompts=new nt(this);runs=new ot(this);account=new Ce(this);accounts=new we(this);apikeys=new Ee(this);analytics=new Te(this);auditTrail=new Oe(this);training=new gn(this);delegationGrants=new Ae(this);users=new _n(this);iam=new Ne(this);refs=new it(this);commands=new ke(this);apps=new De(this);tools=new hn(this);quota=new rt(this);views};function xn(e){return e.startsWith(`pk-`)||e.startsWith(`sk-`)}function Sn(e){if(!e)return!0;let t=$(e).exp;return Date.now()>=t*1e3-6e4}function $(e){let t=typeof e==`string`?e.split(`.`):[];if(t.length!==3||!t[1])throw Error(`Invalid auth token: expected a JWT of three dot-separated segments, got ${t.length||`none`}`);let n;try{n=Tn(t[1])}catch(e){throw Error(`Invalid auth token: payload segment is not base64url (${e.message})`)}try{return JSON.parse(n)}catch{throw Error(`Invalid auth token: payload segment is not JSON`)}}function Cn(){return globalThis.Buffer}function wn(){return globalThis.process?.env?.STS_URL}function Tn(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=Cn();if(n)return n.from(t,`base64`).toString(`utf-8`);if(typeof atob<`u`&&typeof TextDecoder<`u`){let e=atob(t),n=Uint8Array.from(e,e=>e.charCodeAt(0));return new TextDecoder().decode(n)}throw Error(`No base64 decoder available`)}function En(e){return e?typeof e==`string`?Dn(e):e:Dn(`api.vertesia.io`)}function Dn(e){if(e===`local`)return{studio:`http://localhost:8091`,store:`http://localhost:8092`,token:wn()??`https://sts.dev1.vertesia.io`,git:`https://git.dev1.vertesia.io`};{let t=`https://${e}`;return{studio:t,store:t,token:t.replace(`api`,`sts`),git:t.replace(`api`,`git`)}}}var On=class{id;client;constructor(e,t){this.id=e,this.client=t instanceof bn?t:new bn(t)}retrieve(){return this.client.interactions.retrieve(this.id)}update(e){return this.client.interactions.update(this.id,e)}render(e){throw Error(`Not implemented`)}async execute(e={},t){return Le(this.client,this.id,e,t)}};export{e as APP_VERSION_HEADER,Y as ARTIFACTS_PREFIX,St as AgentsApi,Dt as DataApi,Ae as DelegationGrantsApi,Ot as EmailApi,kt as EmbeddingsApi,It as EventIngestChannelsApi,Rt as EventSubscriptionsApi,zt as EventsApi,X as FileDownloadError,qt as FilesApi,z as IS_INTERACTION_OUTPUT,Jt as IndexingApi,On as InteractionBase,V as InteractionOutput,Je as InternalSecretsApi,Ht as MEMORIES_PREFIX,Ye as OAuthClientsApi,Ze as OAuthGrantsApi,Qe as OAuthProvidersApi,$e as OAuthServerApi,Xt as ObjectsApi,Zt as PendingAsksApi,s as Permission,Qt as ProcessApi,$t as ProcessTestRunApi,en as QueryApi,at as RemoteMcpConnectionsApi,tn as RenderingApi,rn as SchedulesApi,st as SecretsApi,cn as StoreViewsApi,K as StreamSource,an as TaskApi,on as TypeCatalogApi,sn as TypesApi,bn as VertesiaClient,vn as ViewsApi,ln as WorkflowsApi,dn as WorkflowsDefinitionApi,un as WorkflowsRulesApi,mn as ZenoClient,Bt as ZenoClientNotFoundError,u as canGenerateRendition,H as createInteractionOutput,En as decodeEndpoints,$ as decodeJWT,Ue as enhanceExecutionRun,B as enhanceInteractionExecutionResult,G as escapeArtifactPathDelimiters,U as fetchSignedUrl,Q as getAgentArtifactPath,Z as getMemoryFilePath,d as getOAuthPermissionScopes,f as getSupportedRenditionFormats,Sn as isTokenExpired,Pt as openManagedEventSource,h as supportsVisualRendition};
|
|
11
|
+
`){return this.results.filter(e=>e.type===`thoughts`).map(e=>e.value).join(e)}thoughtParts(){return this.results.filter(e=>e.type===`thoughts`).map(e=>e.value)}object(){let e=this.results.find(e=>e.type===`json`);return e?e.value:qe(this.results)}objects(){return this.results.filter(e=>e.type===`json`).map(e=>e.value)}objectAt(e){let t=0;for(let n of this.results)if(n.type===`json`){if(t===e)return n.value;t++}throw Error(`Object at index ${e} not found`)}image(){let e=this.results.find(e=>e.type===`image`);if(!e)throw Error(`No image result found`);return e.value}images(){return this.results.filter(e=>e.type===`image`).map(e=>e.value)}hasAudio(){return this.results.some(e=>e.type===`audio`)}audios(){return this.results.filter(e=>e.type===`audio`)}audio(){let e=this.audios()[0];if(!e)throw Error(`No audio result found`);return e}video(){let e=this.results.find(e=>e.type===`video`);if(!e)throw Error(`No video result found`);return e.value}videos(){return this.results.filter(e=>e.type===`video`).map(e=>e.value)}stringify(e=`
|
|
12
|
+
`,t=2){return this.results.filter(e=>e.type!==`thoughts`).map(e=>{switch(e.type){case`json`:return JSON.stringify(e.value,null,t);default:return String(e.value)}}).join(e)}toString(){return this.text()}toJSON(){return this.results}};function Ke(e){return!!e&&typeof e==`object`&&e[R]===!0}function V(e){let t=new B(e);return new Proxy(e,{get(e,n,r){if(n===R)return!0;if(n in t){let e=Reflect.get(t,n,t);return typeof e==`function`?e.bind(t):e}return Reflect.get(e,n,r)}})}function qe(e){let t;for(let n of e)if(n.type===`text`){let e=n.value.trim();try{return JSON.parse(e)}catch(e){t=e instanceof Error?e:Error(String(e))}}throw t||=Error(`No JSON result found and no text available to parse`),t}function Je(e){return!!e&&typeof e==`object`&&`id`in e&&typeof e.id==`string`}var Ye=class extends I{catalog;constructor(e){super(e,`/api/v1/interactions`),this.catalog=new We(e)}list(e={}){let t=e.query||{};return this.get(`/`,{query:{...t}})}listEndpoints(e){return this.post(`/endpoints`,{payload:e})}listVersionsByName(e){return this.get(`/versions/${e}`)}listTags(e){return this.get(`/tags`,{query:{...e}})}computeFacets(e){return this.post(`/facets`,{payload:e})}listNames(){return this.get(`/names`)}export(e){return this.post(`/export`,{payload:e})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e,t){let{cascade:n,query:r,...i}=t??{},a=n?{...r??{},cascade:`true`}:r??void 0;return super.delete(`/${e}`,{...i,query:a})}async execute(e,t={},n){return z(await ze(this.client,e,t,n).catch(e=>{throw e instanceof x&&Je(e.payload)?e.updateDetails({run_id:e.payload.id}):e}))}async executeByName(e,t={},n,r){return z(await Be(this.client,e,t,n,r).catch(e=>{throw e instanceof x&&Je(e.payload)?e.updateDetails({run_id:e.payload.id}):e}))}executeAsync(e){return He(this.client,e)}publish(e,t){return this.post(`/${e}/publish`,{payload:t})}fork(e,t){return this.post(`/${e}/fork`,{payload:t})}generateInteraction(e,t){return this.post(`${e}/generate-interaction`,{payload:t})}generateTestData(e,t){return this.post(`${e}/generate-test-data`,{payload:t})}suggestImprovements(e,t){return this.post(`${e}/suggest-prompt-improvements`,{payload:t})}suggestPromptImprovements(e){return this.post(`/improve`,{payload:e})}listVersions(e){return this.get(`/${e}/versions`)}listForks(e){return this.get(`/${e}/forks`)}requestSlot(e){return Ue(this.client,e)}resolve(e,t){return this.get(`/resolve/${encodeURIComponent(e)}`,{query:t})}},Xe=class extends I{constructor(e){super(e,`/internal/secrets`)}rotateEventWebhookSigningSecret(e,t){return this.post(`/event-webhooks/${e}/rotate`,{payload:t})}deleteEventWebhookSigningSecret(e,t){return this.post(`/event-webhooks/${e}/delete`,{payload:t})}signEventWebhook(e,t){return this.post(`/event-webhooks/${e}/sign`,{payload:t})}rotateEventIngestChannelSigningSecret(e,t){return this.post(`/event-ingest-channels/${e}/rotate`,{payload:t})}deleteEventIngestChannelSigningSecret(e,t){return this.post(`/event-ingest-channels/${e}/delete`,{payload:t})}verifyEventIngestSignature(e,t){return this.post(`/event-ingest-channels/${e}/verify`,{payload:t})}mintGithubInstallationToken(e){return this.post(`/github/installation-token`,{payload:e})}},Ze=class extends I{constructor(e){super(e,`/api/v1/oauth-clients`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}scopeMetadata(){return this.get(`/scope-metadata`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}remove(e){return this.del(`/${e}`)}};function Qe(e){if(e)return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)]))}var $e=class extends I{constructor(e){super(e,`/api/v1/oauth-grants`)}list(e){return this.get(`/`,{query:Qe(e)})}retrieve(e){return this.get(`/${e}`)}revoke(e,t){return this.del(`/${e}`,{query:t})}revokeBulk(e){return this.post(`/revoke`,{payload:e})}},et=class extends I{constructor(e){super(e,`/api/v1/oauth-providers`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}remove(e){return this.del(`/${e}`)}authorize(e){return this.get(`/${e}/authorize`)}exchange(e,t){return this.post(`/exchange`,{payload:{code:e,state:t}})}getStatus(e){return this.get(`/${e}/status`)}connect(e){return this.post(`/${e}/connect`,{payload:{}})}getToken(e){return this.post(`/${e}/token`,{payload:{}})}disconnect(e){return this.del(`/${e}/disconnect`)}},tt=class extends F{parent;constructor(e,t){super(new URL(`/oauth`,`${t||e.baseUrl}/`).toString(),e._fetch),this.parent=e,this.createServerError=e.createServerError,this.errorFactory=e.errorFactory,this.verboseErrors=e.verboseErrors}login(e,t){return this.post(`/requests/${encodeURIComponent(e)}/login`,{payload:t})}get headers(){return this.parent.headers}createRequest(e,t){return this.parent.createRequest(e,t)}handleResponse(e,t,n){return this.parent.handleResponse(e,t,n)}handleFetchResponse(e,t){this.parent.handleFetchResponse(e,t)}getRetryPolicy(){return this.parent.getRetryPolicy()}createAuthorizationRequest(e,t){if(!t)return this.post(`/requests`,{payload:e});if(!/^\/env\/[a-z][a-z0-9-]{1,15}\/dev-[a-z0-9-]+$/.test(t))return Promise.reject(Error(`Invalid OAuth authorization server path`));let n=new URL(`${t}/requests`,this.baseUrl).toString();return this.post(n,{payload:e})}createDeviceAuthorization(e){return this.post(`/device_authorization`,{payload:e})}retrieveDeviceRequest(e){return this.get(`/device/${encodeURIComponent(e)}`)}retrieveRequest(e){return this.get(`/requests/${e}`)}retrieveGrantableScopes(e,t){return this.get(`/requests/${e}/grantable-scopes`,{query:{project_id:t}})}approveRequest(e,t){return this.post(`/requests/${e}/approve`,{payload:t})}denyRequest(e){return this.post(`/requests/${e}/deny`,{payload:{}})}},nt=class extends I{integrations;constructor(e){super(e,`/api/v1/projects`),this.integrations=new rt(this)}list(e){return this.get(`/`,{query:{account:e}})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}updateConfiguration(e,t){return this.put(`/${e}/configuration`,{payload:t})}getTools(e){return this.get(`/${e}/tools`)}getToolByName(e,t){return this.get(`/${e}/tools/${t}`).catch(e=>{if(e.status===404)return null;throw e})}listAppContentTypes(e,t){return this.get(`/${encodeURIComponent(e)}/app-types`,{query:{tag:t}})}getAppContentType(e,t){return this.get(`/${encodeURIComponent(e)}/app-types/${encodeURIComponent(t)}`)}listAppProcesses(e,t){return this.get(`/${encodeURIComponent(e)}/app-processes`,{query:{tag:t}})}getAppProcess(e,t){return this.get(`/${encodeURIComponent(e)}/app-processes/${encodeURIComponent(t)}`)}listAppViews(e,t){return this.get(`/${encodeURIComponent(e)}/app-views`,{query:{tag:t}})}getAppView(e,t){return this.get(`/${encodeURIComponent(e)}/app-views/${encodeURIComponent(t)}`)}listAppRenderingTemplates(e,t){return this.get(`/${encodeURIComponent(e)}/app-templates`,{query:{tag:t}})}getAppRenderingTemplate(e,t){return this.get(`/${encodeURIComponent(e)}/app-templates/${encodeURIComponent(t)}`)}getCompositeAppConfiguration(e){return this.get(`/${encodeURIComponent(e)}/composite-app`)}updateCompositeAppConfiguration(e,t){return this.put(`/${encodeURIComponent(e)}/composite-app`,{payload:t})}},rt=class extends I{constructor(e){super(e,`/`)}list(e){return this.get(`/${e}/integrations`).then(e=>e.integrations)}retrieve(e,t){return this.get(`/${e}/integrations/${t}`).catch(e=>{if(e.status!==404)throw e})}update(e,t,n){return this.put(`/${e}/integrations/${t}`,{payload:n})}updatePlugins(e,t){return this.post(`/${e}/plugins`,{payload:{plugins:t}})}listPlugins(e){return this.get(`/${e}/plugins`)}},it=class extends I{constructor(e){super(e,`/api/v1/prompts`)}list(e={}){let t=e.query||{};return this.get(`/`,{query:{...t}})}computeFacets(e){return this.post(`/facets`,{payload:e})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}fork(e,t){return this.post(`/${e}/fork`,{payload:t})}render(e,t){return this.post(`/${e}/render`,{payload:t})}options(e){return this.get(`/options/${e}`)}listVersions(e){return this.get(`/${e}/versions`)}listInteractions(e){return this.get(`/${e}/interactions`)}listForks(e){return this.get(`/${e}/forks`)}},at=class extends I{constructor(e){super(e,`/api/v1/quota`)}standing(){return this.get(`/standing`)}tier(){return this.get(`/tier`)}},ot=class extends I{constructor(e){super(e,`/api/v1/refs`)}resolve(e){return this.post(`/resolve`,{payload:{refs:e}})}},st=class extends I{constructor(e){super(e,`/api/v1/remote-mcp-connections`)}getStatus(e){return this.get(`/status/${e}`)}getCollectionStatus(e,t){return this.get(`/status/${e}/${t}`)}getMetadata(e,t){return this.get(`/metadata/${e}/${t}`)}authorize(e,t){return this.get(`/authorize/${e}/${t}`)}exchange(e,t){return this.post(`/exchange`,{payload:{code:e,state:t}})}connect(e,t){return this.post(`/connect/${e}/${t}`,{})}disconnect(e,t){return this.del(`/disconnect/${e}/${t}`)}getCollectionToken(e,t){return this.post(`/token`,{payload:{app_install_id:e,collection_id:t}})}getToken(e){return this.post(`/token`,{payload:{mcp_server_url:e}})}},ct=class extends I{constructor(e){super(e,`/api/v1/runs`)}list({limit:e,offset:t,filters:n}){let r={limit:e,offset:t,...n};return this.get(`/`,{query:r})}find(e){return this.post(`/find`,{payload:e})}async retrieve(e){return Ge(await this.get(`/${e}`))}retrievePopulated(e){return this.get(`/${e}`,{query:{populate:`true`}})}filterOptions(e,t){let n={...t};return this.get(`/filter-options/${e}`,{query:n})}async create(e,t){let n=this.client.sessionTags;if(n){let t=Array.isArray(n)?n:[n];Array.isArray(e.tags)?t=t.concat(e.tags):e.tags&&(t=t.concat([e.tags])),e={...e,tags:t}}return z(await this.post(`/`,{payload:e,timeoutMs:t?.timeoutMs,signal:t?.signal}))}sendToolResults(e,t){return this.post(`/tool-results`,{payload:e,headers:t?.headers,timeoutMs:t?.timeoutMs,signal:t?.signal})}sendUserMessage(e,t){return this.post(`/user-message`,{payload:e,headers:t?.headers,timeoutMs:t?.timeoutMs,signal:t?.signal})}computeFacets(e){return this.post(`/facets`,{payload:e})}search(e){return this.post(`/search`,{payload:e})}clone(e){return this.post(`/clone`,{payload:e})}},lt=class extends I{constructor(e){super(e,`/api/v1/secrets`)}list(e,t){return this.get(`/`,{query:{...t,project_id:e}}).then(e=>e.secrets)}retrieve(e,t,n){return this.get(`/${t}`,{query:{...n,project_id:e}}).catch(e=>{if(e.status!==404)throw e})}create(e,t){return this.post(`/`,{query:{project_id:e},payload:t})}update(e,t,n,r){return this.put(`/${t}`,{query:{...r,project_id:e},payload:n})}remove(e,t,n){return this.del(`/${t}`,{query:{...n,project_id:e}})}fillWebsiteCredential(e,t,n){return this.post(`/${t}/actions/fill-browser`,{query:{project_id:e},payload:n})}},ut=class extends I{constructor(e){super(e,`/api/v1/skills`)}findRelevant(e,t){let n={context:e,limit:t};return this.post(`/find-relevant`,{payload:n})}findRelevantForTask(e,t){return this.findRelevant({task_description:e,tool_names:t})}};const dt={token:"pass the credential as `apikey`, or build the client with `VertesiaClient.fromAuthToken(token)`",accessToken:"pass the credential as `apikey`, or build the client with `VertesiaClient.fromAuthToken(token)`",authToken:"pass the credential as `apikey`, or build the client with `VertesiaClient.fromAuthToken(token)`",apiKey:"the option is spelled `apikey`, all lowercase",api_key:"the option is spelled `apikey`, all lowercase",appVersion:"pin the app version with the `withAppVersion(version)` method after construction",apiVersion:"pin the API version with the `withApiVersion(version)` method after construction",projectId:`the project is determined by the credential; this option was never read`,baseUrl:"use `serverUrl` for studio and `storeUrl` for the store"},ft=new Set;function pt(e,t,n){let r=Object.keys(t).filter(e=>!Object.hasOwn(n,e)&&!ft.has(e));if(r.length===0)return;for(let e of r)ft.add(e);let i=r.map(e=>Object.hasOwn(dt,e)?`${e} (${dt[e]})`:e);console.warn(`[${e}] Ignoring unknown constructor option(s): ${i.join(`; `)}. Unknown options have no effect.`)}const mt=new Set([429,500,502,503,504]);function ht(e){return new Promise(t=>setTimeout(t,e))}function gt(e){let t=e.headers.get(`retry-after`);if(!t)return;let n=Number(t);if(Number.isFinite(n)&&n>=0)return n*1e3;let r=Date.parse(t);if(!Number.isNaN(r))return Math.max(0,r-Date.now())}function _t(e,t,n,r){let i=r?gt(r):void 0;if(i!==void 0)return i;let a=Math.min(n,t*2**e);return Math.floor(Math.random()*a)}const vt=new TextEncoder;function yt(e){if(typeof e==`string`)return vt.encode(e);if(e instanceof Blob)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`Unsupported signed-URL upload chunk of type "${typeof e}"; body streams must yield string or binary (Uint8Array/ArrayBuffer/DataView/Blob) chunks.`)}async function bt(e){if(e!=null){if(typeof ReadableStream<`u`&&e instanceof ReadableStream){let t=e.getReader(),n=[];try{for(;;){let{done:e,value:r}=await t.read();if(e)break;n.push(yt(r))}}catch(e){throw await t.cancel(e).catch(()=>void 0),e}finally{t.releaseLock()}return new Blob(n)}return e}}async function H(e,t={}){let{method:n=`GET`,headers:r,attempts:i=4,baseDelayMs:a=500,maxDelayMs:o=8e3,retryableStatuses:s=mt}=t,c=await bt(t.body),l;for(let t=0;t<i;t++){let u=t===i-1;try{let i=await fetch(e,{method:n,headers:r,body:c});if(i.ok||!s.has(i.status)||u||(gt(i)??0)>6e4)return i;await i.body?.cancel().catch(()=>void 0),await ht(_t(t,a,o,i))}catch(e){if(l=e,u)throw e;await ht(_t(t,a,o))}}throw l instanceof Error?l:Error(`Failed to fetch signed URL: ${e}`)}function xt(e){if(!e||typeof e!=`object`)return;let t=e.process_run_id;return typeof t==`string`?t:void 0}function St(e,t){let n=xt(e);return!n||n===t}function U(e,t,r=!1){return e.type===n.TERMINATED||(e.type===n.COMPLETE||r&&e.type===n.IDLE)&&(e.workstream_id??`main`)===`main`?St(e.details,t):!1}function Ct(e,t,r=!1){return e.t===n.TERMINATED||(e.t===n.COMPLETE||r&&e.t===n.IDLE)&&(e.w??`main`)===`main`?St(e.d,t):!1}function W(e){return e.replace(/#/g,`%23`).replace(/\?/g,`%3F`)}var wt=class extends I{constructor(e){super(e,`/api/v1/agents`)}start(e){return this.post(`/`,{payload:e})}recordRun(e){return this.post(`/record`,{payload:e})}createRecord(e){return this.recordRun(e)}retrieve(e){return this.get(`/${e}`)}retrieveRun(e){return this.get(`/${e}`)}retrieveProcess(e){return this.get(`/${e}`)}list(e){return this.get(`/`,{query:this.buildListQueryParams(e)})}async listProcessRuns(e){return(await this.get(`/`,{query:this.buildListQueryParams({...e,run_kind:`process`})})).items.filter(Tt)}buildListQueryParams(e){let t={};return e?.id&&(t.id=e.id),e?.status&&(t.status=Array.isArray(e.status)?e.status.join(`,`):e.status),e?.interaction&&(t.interaction=e.interaction),e?.started_by&&(t.started_by=e.started_by),e?.since&&(t.since=e.since),e?.until&&(t.until=e.until),e?.schedule_id&&(t.schedule_id=e.schedule_id),e?.type&&(t.type=e.type),e?.run_type&&(t.run_type=Array.isArray(e.run_type)?e.run_type.join(`,`):e.run_type),e?.run_kind&&(t.run_kind=e.run_kind),e?.limit&&(t.limit=String(e.limit)),e?.offset&&(t.offset=String(e.offset)),e?.cursor&&(t.cursor=e.cursor),e?.sort&&(t.sort=e.sort),e?.order&&(t.order=e.order),e?.evaluation_severity?.length&&(t.evaluation_severity=e.evaluation_severity.join(`,`)),e?.evaluation_flag?.length&&(t.evaluation_flag=e.evaluation_flag.join(`,`)),e?.feedback_rating&&(t.feedback_rating=e.feedback_rating),e?.contradicted!==void 0&&(t.contradicted=String(e.contradicted)),t}recordFeedback(e,t){return this.post(`/${e}/feedback`,{payload:t})}search(e){let t={};return e?.query&&(t.query=e.query),e?.status&&(t.status=Array.isArray(e.status)?e.status.join(`,`):e.status),e?.interaction&&(t.interaction=e.interaction),e?.started_by&&(t.started_by=e.started_by),e?.categories?.length&&(t.categories=e.categories.join(`,`)),e?.tags?.length&&(t.tags=e.tags.join(`,`)),e?.content_type_name&&(t.content_type_name=e.content_type_name),e?.since&&(t.since=e.since),e?.until&&(t.until=e.until),e?.limit&&(t.limit=String(e.limit)),e?.offset&&(t.offset=String(e.offset)),e?.sort?.length&&(t.sort=e.sort.join(`,`)),this.get(`/search`,{query:t})}terminate(e,t){let n=t?{reason:t}:void 0;return this.del(`/${e}`,{query:n})}restart(e){return this.post(`/${e}/restart`,{})}fork(e){return this.post(`/${e}/fork`,{})}getContext(e){return this.get(`/${e}/context`)}getHistory(e){return this.get(`/${e}/history`)}advance(e,t){return this.post(`/${e}/advance`,{payload:t??{}})}retryNode(e,t){return this.post(`/${e}/retry-node`,{payload:t??{}})}answerTask(e,t,n){return this.post(`/${e}/answer-task`,{payload:{task_id:t,result:n}})}updateStatus(e,t){return this.post(`/${e}/status`,{payload:t})}bindWorkflowRun(e,t){return this.post(`/${e}/workflow`,{payload:t})}sendSignal(e,t,n){return this.post(`/${e}/signal/${t}`,{payload:n})}query(e,t){return this.get(`/${e}/query/${t}`)}getActiveWorkstreams(e){return this.query(e,`ActiveWorkstreams`)}async retrieveMessages(e,t){let n=t?{since:t}:void 0;return(await this.get(`/${e}/updates`,{query:n})).messages.map(t=>g(m(t),e))}postMessage(e,t){return this.post(`/${e}/updates`,{payload:t})}async streamMessages(e,t,n,r,i){let a=()=>{},o=()=>{},s=new Promise((e,t)=>{a=e,o=t}),c=0,l=n||0,u=Date.now(),d=!1,f=null,p=null,h=null,_=null,v=null,y=!1,b=0,x=null,S=e=>{let t=Math.min(1e3*2**e,3e4);return t+Math.random()*.1*t},C=()=>{y=!1,_&&=(clearTimeout(_),null),v&&=(clearTimeout(v),null)},w=()=>{h&&=(clearTimeout(h),null),C(),p&&=(clearInterval(p),null),f&&=(f.close(),null),r&&x&&(r.removeEventListener(`abort`,x),x=null)},T=e=>{d||(d=!0,w(),a(e))},E=e=>typeof e==`string`&&[`completed`,`failed`,`cancelled`].includes(e),D=(t,n)=>{b++,console.warn(`Agent stream ${e}: ${t} failed while polling (consecutive failures: ${b}); retrying in 5s:`,n instanceof Error?n.message:n)},O=e=>typeof e==`object`&&!!e&&e.status===404,k=()=>{console.warn(`Agent stream ${e}: the run no longer exists (404); stopping the polling fallback.`),T(null)},A=async()=>{if(d||!y)return;let n=!1;try{let r=await this.retrieveMessages(e,l||void 0);n=!0;for(let n of r){if(d)return;let r=n.timestamp||0;if(!(r<=l)){if(l=r,t&&t(n,T),d)return;if(U(n,e,i?.closeOnIdle)){T(null);return}}}}catch(e){if(O(e)){k();return}D(`GET /updates`,e)}if(!d&&y){try{let t=await this.get(`/${e}`);if(E(t?.status)){T(null);return}n&&(b=0)}catch(e){if(O(e)){k();return}D(`run status check`,e)}!d&&y&&(_=setTimeout(()=>{_=null,A()},5e3))}},ee=()=>{v=null,!d&&y&&(C(),c=0,console.log(`Agent stream ${e}: retrying the SSE connection after the polling fallback.`),M(`resume`))},te=t=>{d||y||(w(),y=!0,b=0,console.warn(`Agent stream ${e}: SSE unavailable after 10 attempts; falling back to GET /updates polling every 5s (SSE retried every 60s).`,t instanceof Error?t.message:t),v=setTimeout(ee,6e4),A())},j=e=>{if(d)return;if(c>=10){te(e);return}let t=S(c);c++,h=setTimeout(()=>{h=null,d||M(`reconnect`)},t)};if(r){if(r.aborted)return d=!0,w(),a(null),s;x=()=>{T(null)},r.addEventListener(`abort`,x,{once:!0})}try{if(!d){let r=await this.retrieveMessages(e,n);i?.onHistoryLoaded?.(r);let a=!1;for(let n=0;n<r.length;n++){let o=r[n];if(d||(l=Math.max(l,o.timestamp||0),t&&t(o,T),d))break;a=n===r.length-1&&U(o,e,i?.closeOnIdle)}if(a)return T(null),s}}catch(e){d||(i?.onHistoryError?.(e),console.warn(`Failed to fetch historical messages, continuing with SSE:`,e))}!d&&l<=0&&(l=Math.max(1,u-1));let M=async(n=`initial`)=>{if(!d)try{let r=await L();if(d)return;let a=this.client,s=new URL(`${a.agents.baseUrl}/${e}/stream`);l>0&&s.searchParams.set(`since`,l.toString()),s.searchParams.set(`skipHistory`,`true`);let u=a._auth?await a._auth():void 0;if(d)return;if(!u){d=!0,w(),o(Error(`No auth token available`));return}let h=u.split(` `)[1];if(s.searchParams.set(`access_token`,h),n===`reconnect`&&console.log(`Reconnecting to agent stream ${e} (attempt ${c}/10)`),d)return;let _=new r(s.href);f=_,p=setInterval(()=>{},1e3);let v=0;_.onopen=()=>{n!==`initial`&&console.log(`Reconnected to agent stream ${e}`),v=Date.now()},_.onmessage=n=>{if(!d&&n.data&&!n.data.startsWith(`:`))try{let r=m(n.data);l=r.ts?Math.max(l,r.ts):Date.now(),t&&t(g(r,e),T),Ct(r,e,i?.closeOnIdle)&&T(null)}catch(e){console.error(`Failed to parse SSE message:`,e,n.data)}},_.onerror=e=>{d||(w(),(v?Date.now()-v:0)>5e3&&(c=0),j(Error(`SSE connection failed after 10 reconnection attempts`)))}}catch(e){if(d)return;j(e)}};return M(`initial`),s}getInternals(e){return this.get(`/${e}/internals`)}getRunDetails(e,t){let n={};return t?.includeHistory&&(n.include_history=`true`),t?.hydratePayloads&&(n.hydrate_payloads=`true`),t?.from!==void 0&&(n.from=t.from),this.get(`/${e}/details`,{query:n})}async streamRunDetails(e,t,n){let r=await L(),i=this.client,a=new URL(`${i.agents.baseUrl}/${e}/details/stream`),o=i._auth?await i._auth():void 0;if(!o)throw Error(`No auth token available`);let s=o.split(` `)[1];return a.searchParams.set(`access_token`,s),new Promise((e,i)=>{let o=new r(a.href),s=null,c=()=>{o.close(),n&&s&&(n.removeEventListener(`abort`,s),s=null)};if(n){if(n.aborted){c(),e();return}s=()=>{c(),e()},n.addEventListener(`abort`,s,{once:!0})}o.addEventListener(`history`,e=>{try{let n=JSON.parse(e.data);t&&t({type:`history`,data:n})}catch{}}),o.addEventListener(`control`,n=>{try{let r=JSON.parse(n.data);t&&t({type:`control`,data:r}),`type`in r&&r.type===`done`&&(c(),e())}catch{}}),o.addEventListener(`error`,e=>{try{let n=JSON.parse(e.data);t&&t({type:`error`,data:n})}catch{}}),o.onerror=e=>{c(),i(Error(`SSE connection failed for details stream`))}})}listChildren(e){return this.get(`/${e}/children`)}getChildDetails(e,t,n){let r={};return n?.includeHistory&&(r.include_history=`true`),n?.hydratePayloads&&(r.hydrate_payloads=`true`),n?.from!==void 0&&(r.from=n.from),this.get(`/${e}/children/${t}/details`,{query:r})}listArtifacts(e,t){let n=t?.visibility?{visibility:t.visibility}:void 0;return this.get(`/${e}/artifacts`,{query:n})}getArtifactContent(e,t){return this.get(`/${e}/artifact-content/${W(t)}`)}updateArtifactContent(e,t,n){return this.put(`/${e}/artifact-content/${W(t)}`,{payload:n})}getArtifactUrl(e,t,n,r){let i={url:`1`};return n&&(i.disposition=n),r&&(i.filename=r),this.get(`/${e}/artifacts/${W(t)}`,{query:i})}async uploadArtifact(e,t,n,r){let i=r||`application/octet-stream`,a=await this.put(`/${e}/artifacts/${W(t)}`,{headers:{"Content-Type":i}}),o=await H(a.url,{method:`PUT`,body:n,headers:{"Content-Type":i}});if(!o.ok)throw Error(`Failed to upload artifact: ${o.statusText}`);return a}async downloadArtifact(e,t){let{url:n}=await this.getArtifactUrl(e,t,`attachment`),r=await H(n);if(!r.ok)throw Error(`Failed to download artifact: ${r.statusText}`);if(!r.body)throw Error(`No body in artifact download response`);return r.body}ingestEvents(e,t){let n={events:t};return this.post(`/${e}/events`,{payload:n})}getAnalyticsSummary(e={}){return this.post(`/analytics/summary`,{payload:e})}getTokenUsageAnalytics(e={}){return this.post(`/analytics/tokens`,{payload:e})}getLlmLatencyAnalytics(e={}){return this.post(`/analytics/latency/llm`,{payload:e})}getToolLatencyAnalytics(e={}){return this.post(`/analytics/latency/tools`,{payload:e})}getAgentLatencyAnalytics(e={}){return this.post(`/analytics/latency/agents`,{payload:e})}getErrorAnalytics(e={}){return this.post(`/analytics/errors`,{payload:e})}getToolAnalytics(e={}){return this.post(`/analytics/tools`,{payload:e})}getToolParameterAnalytics(e){return this.post(`/analytics/tools/parameters`,{payload:e})}getAnalyticsFilterOptions(e={}){return this.post(`/analytics/filter-options`,{payload:e})}getPromptSizeAnalytics(e={}){return this.post(`/analytics/prompt-size`,{payload:e})}getTopPrincipalsAnalytics(e={}){return this.post(`/analytics/top-principals`,{payload:e})}getRunsByAgentAnalytics(e={}){return this.post(`/analytics/runs-by-agent`,{payload:e})}getTimeToFirstResponseAnalytics(e={}){return this.post(`/analytics/time-to-first-response`,{payload:e})}getFirstResponseBehaviorAnalytics(e={}){return this.post(`/analytics/first-response-behavior`,{payload:e})}};function Tt(e){return e.run_kind===`process`}var Et=class extends I{constructor(e){super(e,`/api/v1/collections`)}search(e){return this.post(`/search`,{payload:e})}computeListFacets(e){return this.post(`/facets`,{payload:e})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}addMembers(e,t){return this.post(`/${e}/members`,{payload:{action:`add`,members:t}})}listMembers(e,t){return this.get(`/${e}/members`,{query:{...t}})}computeFacets(e,t){return this.post(`/${e}/facets`,{payload:t})}searchMembers(e,t){return this.post(`/${e}/search`,{payload:t})}deleteMembers(e,t){return this.post(`/${e}/members`,{payload:{action:`delete`,members:t}})}addChildren(e,t){return this.post(`/${e}/children`,{payload:{action:`add`,children:t}})}deleteChildren(e,t){return this.post(`/${e}/children`,{payload:{action:`delete`,children:t}})}searchChildren(e,t={}){return this.post(`/${e}/children/search`,{payload:t})}delete(e){return this.del(`/${e}`)}updatePermissions(e,t){return this.put(`/${e}/permissions`,{payload:t})}propagatePermissions(e){return this.post(`/${e}/propagate-permissions`)}propagateSharedProperties(e){return this.post(`/${e}/propagate-shared-props`)}},Dt=class extends I{constructor(e){super(e,`/api/v1/cost`)}getAnalytics(e={}){return this.post(`/analytics`,{payload:e})}getGlobalAnalytics(e={}){return this.post(`/analytics/global`,{payload:e})}getModelPrices(e={}){return this.get(`/model-prices`,{query:{...e}})}getRunPrice(e){return this.post(`/run-price`,{payload:e})}getRunPriceComparison(e){return this.post(`/run-price`,{payload:{...e,include_comparison_pricing:!0}})}getExportUrl(e){let t=new URLSearchParams;e?.from&&t.set(`from`,typeof e.from==`number`?new Date(e.from).toISOString():e.from),e?.to&&t.set(`to`,typeof e.to==`number`?new Date(e.to).toISOString():e.to),e?.scope&&t.set(`scope`,e.scope),e?.project_id&&t.set(`project_id`,e.project_id),e?.workflow_id&&t.set(`workflow_id`,e.workflow_id);let n=t.toString();return`${this.baseUrl}/export${n?`?${n}`:``}`}},Ot=class extends I{storeId;constructor(e,t){super(e,`/api/v1/data/${t}/dashboards`),this.storeId=t}storeHeaders(){return{[a.DATA_STORE_ID]:this.storeId}}list(e){let t=e?`?status=${e}`:``;return this.get(`/${t}`,{headers:this.storeHeaders()})}create(e){return this.post(`/`,{payload:e,headers:this.storeHeaders()})}retrieve(e){return this.get(`/${e}`,{headers:this.storeHeaders()})}update(e,t){return this.put(`/${e}`,{payload:t,headers:this.storeHeaders()})}delete(e){return this.del(`/${e}`,{headers:this.storeHeaders()})}bulkArchive(e){return this.post(`/bulk/archive`,{payload:{ids:e},headers:this.storeHeaders()})}bulkDelete(e){return this.post(`/bulk/delete`,{payload:{ids:e},headers:this.storeHeaders()})}listVersions(e,t){let n=new URLSearchParams;t?.snapshotsOnly&&n.set(`snapshots_only`,`true`),t?.limit&&n.set(`limit`,String(t.limit));let r=n.toString()?`?${n}`:``;return this.get(`/${e}/versions${r}`,{headers:this.storeHeaders()})}getVersion(e,t){return this.get(`/${e}/versions/${t}`,{headers:this.storeHeaders()})}createSnapshot(e,t){return this.post(`/${e}/versions`,{payload:t,headers:this.storeHeaders()})}promoteVersion(e,t,n){return this.post(`/${e}/versions/${t}/promote`,{payload:n||{},headers:this.storeHeaders()})}setVersioningEnabled(e,t){return this.put(`/${e}/versioning`,{payload:{enabled:t},headers:this.storeHeaders()})}},kt=class extends I{constructor(e){super(e,`/api/v1/data`)}storeHeaders(e){return{[a.DATA_STORE_ID]:e}}list(){return this.get(`/`)}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`,{headers:this.storeHeaders(e)})}delete(e){return this.del(`/${e}`,{headers:this.storeHeaders(e)})}getSchema(e,t){let n=t?`?format=${t}`:``;return this.get(`/${e}/schema${n}`,{headers:this.storeHeaders(e)})}updateSchema(e,t){return this.put(`/${e}/schema`,{payload:t,headers:this.storeHeaders(e)})}getSchemaHistory(e){return this.get(`/${e}/schema/history`,{headers:this.storeHeaders(e)})}listTables(e){return this.get(`/${e}/tables`,{headers:this.storeHeaders(e)})}createTables(e,t){return this.post(`/${e}/tables`,{payload:t,headers:this.storeHeaders(e)})}getTable(e,t,n){let r=n?`?sample=true`:``;return this.get(`/${e}/tables/${t}${r}`,{headers:this.storeHeaders(e)})}alterTable(e,t,n){return this.put(`/${e}/tables/${t}`,{payload:n,headers:this.storeHeaders(e)})}dropTable(e,t){return this.del(`/${e}/tables/${t}`,{headers:this.storeHeaders(e)})}import(e,t){return this.post(`/${e}/import`,{payload:t,headers:this.storeHeaders(e)})}getImportStatus(e,t){return this.get(`/${e}/import/${t}`,{headers:this.storeHeaders(e)})}listVersions(e,t){let n=t?`?snapshots_only=true`:``;return this.get(`/${e}/versions${n}`,{headers:this.storeHeaders(e)})}createSnapshot(e,t){return this.post(`/${e}/versions`,{payload:t,headers:this.storeHeaders(e)})}rollback(e,t){return this.post(`/${e}/versions/${t}/rollback`,{headers:this.storeHeaders(e)})}queryVersion(e,t,n){return this.post(`/${e}/versions/${t}/query`,{payload:n,headers:this.storeHeaders(e)})}query(e,t){return this.post(`/${e}/query`,{payload:t,headers:this.storeHeaders(e)})}queryBatch(e,t){return this.post(`/${e}/query/batch`,{payload:{queries:t},headers:this.storeHeaders(e)})}mutateRows(e,t){return this.post(`/${e}/mutate`,{payload:t,headers:this.storeHeaders(e)})}validateQueries(e,t){return this.post(`/${e}/query/validate`,{payload:{queries:t},headers:this.storeHeaders(e)})}getDownloadInfo(e,t){let n=t?`?version_id=${t}`:``;return this.get(`/${e}/download${n}`,{headers:this.storeHeaders(e)})}dashboards(e){return new Ot(this.client,e)}},At=class extends I{constructor(e){super(e,`/api/v1/email`)}send(e){return this.post(`/send`,{payload:e})}resolveRoute(e){return this.post(`/resolve-route`,{payload:{route_key:e}})}createRoute(e){return this.post(`/routes`,{payload:e})}getRoute(e){return this.get(`/routes/${e}`)}updateRoute(e,t){return this.put(`/routes/${e}`,{payload:t})}forwardEmail(e,t){return this.post(`/routes/${e}/forward`,{payload:t})}},jt=class extends I{constructor(e,t=`/api/v1/embeddings`){super(e,t)}async status(e){return this.get(`${e}/status`)}async activate(e,t){if(!t.environment)throw Error(`Invalid configuration: select environment`);return this.post(`${e}/enable`,{payload:t})}async disable(e){return this.post(`${e}/disable`)}async recalculate(e,t={}){return this.post(`${e}/recalculate`,Object.keys(t).length?{query:t}:void 0)}async prepareBatch(e,t=!1){return this.post(`/batch/prepare`,{payload:e,timeoutMs:t})}async updateBatch(e){return this.post(`/batch/update`,{payload:e})}async prepareBatchRenditionPage(e){return this.post(`/batch/renditions/prepare`,{payload:e})}async pollBatchRenditionPage(e){return this.post(`/batch/renditions/status`,{payload:e})}async cancelBatchRenditionPage(e){return this.post(`/batch/renditions/cancel`,{payload:e})}async applyBatch(e,t=!1){return this.post(`/batch/apply`,{payload:e,timeoutMs:t})}};function Mt(e){return JSON.parse(e)}function Nt(e,t,n){let r=Math.min(t*2**e,n);return r+Math.random()*.1*r}function Pt(e,t){if(!t)return;let n=t.startsWith(`Bearer `)?t.slice(7):t;e.searchParams.set(`access_token`,n)}async function Ft(e){let t=typeof e==`function`?await e():e;return t instanceof URL?new URL(t.href):new URL(t)}function It(e){let t=e.event_types?.length?e.event_types:[`message`],n=e.max_reconnect_attempts??10,r=e.base_reconnect_delay_ms??1e3,i=e.max_reconnect_delay_ms??3e4,a=e.parse??Mt,o=!1,s=0,c=null,l=null,u=null,d=0,f,p=t=>{e.on_status?.(t)},m=()=>{c&&=(c.close(),null),l&&=(clearTimeout(l),null)},h=()=>{o||(o=!0,m(),e.signal&&u&&(e.signal.removeEventListener(`abort`,u),u=null),p(`closed`))},g=t=>{if(o)return;if(m(),(d?Date.now()-d:0)>5e3&&(s=0),s>=n){h(),e.on_error?.(t);return}let a=Nt(s,r,i);s+=1,p(`reconnecting`),l=setTimeout(()=>{l=null,v(!0)},a)},_=(t,n)=>{if(!(o||!n.data||String(n.data).startsWith(`:`)))try{let r=a(String(n.data),t),i=e.get_cursor?.(r);f=n.lastEventId||i||f,e.on_event({data:r,event_type:t,event_id:n.lastEventId||i})}catch(t){e.on_error?.(t)}},v=async n=>{if(!o)try{p(n?`reconnecting`:`connecting`);let r=await L();if(o)return;let i=await Ft(e.url);if(f&&e.last_event_id_query_param&&!i.searchParams.has(e.last_event_id_query_param)&&i.searchParams.set(e.last_event_id_query_param,f),Pt(i,await e.get_access_token?.()),o)return;let a=new r(i.href);c=a,d=0,a.onopen=()=>{d=Date.now(),p(`open`)};for(let e of t)a.addEventListener(e,t=>_(e,t));a.onerror=e=>{g(e)}}catch(e){g(e)}};if(e.signal){if(e.signal.aborted)return o=!0,p(`closed`),{get closed(){return o},close:h};u=h,e.signal.addEventListener(`abort`,u,{once:!0})}return v(!1),{get closed(){return o},close:h}}function Lt(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))if(r!=null){if(Array.isArray(r)){if(r.length===0)continue;t[n]=r.join(`,`)}else t[n]=String(r)}return Object.keys(t).length?t:void 0}var Rt=class extends I{constructor(e){super(e,`/api/v1/events/channels`)}list(e){return this.get(`/`,{query:Lt(e)})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}};function zt(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))if(r!=null){if(Array.isArray(r)){if(r.length===0)continue;t[n]=r.join(`,`)}else t[n]=String(r)}return Object.keys(t).length?t:void 0}var Bt=class extends I{constructor(e){super(e,`/api/v1/events/subscriptions`)}list(e){return this.get(`/`,{query:zt(e)})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}},Vt=class extends I{subscriptions;channels;constructor(e){super(e,`/api/v1/events`),this.subscriptions=new Bt(e),this.channels=new Rt(e)}searchDeliveries(e={}){return this.post(`/deliveries/search`,{payload:e})}queueSummary(e={}){return this.post(`/deliveries/queue-summary`,{payload:e})}cancelQueuedDeliveries(e={}){return this.post(`/deliveries/cancel`,{payload:e})}subscribeDeliveries(e){let{signal:t,max_reconnect_attempts:n,on_snapshot:r,on_delivery:i,on_envelope:a,on_error:o,on_status:s,...c}=e;return It({url:()=>this.buildStreamUrl(c),event_types:[`snapshot`,`event`,`heartbeat`,`error`],signal:t,max_reconnect_attempts:n,last_event_id_query_param:`since_event_id`,get_access_token:async()=>{let e=this.client;return e._auth?await e._auth():void 0},get_cursor:e=>e.cursor,on_status:s,on_error:o,on_event:({data:e})=>{a?.(e),e.type===`snapshot`?r?.(e.deliveries,e):e.type===`event`?i?.(e.item,e):e.type===`error`&&o?.(Error(e.error))}})}buildStreamUrl(e){let t=new URL(`${this.baseUrl}/stream`);return this.setStreamParam(t,`limit`,e.limit),this.setStreamParam(t,`event_id`,e.event_id),this.setStreamParam(t,`resource_id`,e.resource_id),this.setStreamListParam(t,`resource_type`,e.resource_type),this.setStreamListParam(t,`event_category`,e.event_category),this.setStreamListParam(t,`action`,e.action),this.setStreamListParam(t,`outbox_status`,e.outbox_status),this.setStreamParam(t,`since_event_id`,e.since_event_id),this.setStreamParam(t,`since_created_at`,e.since_created_at),this.setStreamParam(t,`include_event`,e.include_event),this.setStreamParam(t,`poll_interval_ms`,e.poll_interval_ms),t}setStreamParam(e,t,n){n!=null&&n!==``&&e.searchParams.set(t,String(n))}setStreamListParam(e,t,n){n?.length&&e.searchParams.set(t,n.join(`,`))}},Ht=class extends b{constructor(e,t){super(`Resource not found: ${t.message}`,e,404,t.payload)}},G=class{stream;name;type;id;constructor(e,t,n,r){this.stream=e,this.name=t,this.type=n,this.id=r}};function Ut(e){return e?.split(`;`,1)[0]?.trim().toLowerCase()||void 0}function K(e){return Ut(e)===`application/octet-stream`?void 0:e||void 0}function q(e,t){return K(e)||t||e||void 0}const Wt=`memories`,J=`agents`,Gt={attempts:3,methods:[`POST`],statuses:[502,503,504]};function Kt(e){try{let t=new URL(e);return`${t.protocol}//${t.host}${t.pathname}`}catch{return e.split(/[?#]/,1)[0]||`unknown file`}}function qt(e){if(!(e instanceof Error))return;let t=e.message.replace(/https?:\/\/[^\s)\]}>"']+/g,e=>Kt(e)),n=Error(t);return n.name=e.name,n}function Jt(e,t){return e===404?`not found`:e===403?`forbidden`:e?`failed with status ${e}${t?` ${t}`:``}`:`failed`}var Y=class extends Error{status;constructor(e,t,n,r){let i=Kt(e),a=Jt(t,n);super(`File download ${a}: ${i}`,{cause:qt(r)}),this.name=`FileDownloadError`,this.status=t}};function X(e){let t=e.endsWith(`.tar.gz`)?e:`${e}.tar.gz`;return`${Wt}/${t}`}function Z(e,t){return`${J}/${e}/${t}`}var Yt=class extends I{constructor(e){super(e,`/api/v1/files`)}async deleteFile(e,t){return this.del(`/${e}`,{query:{prefix:t}})}getMetadata(e){return this.get(`/metadata`,{query:{file:e}})}setFileMetadata(e,t){let n={file:e,metadata:t};return this.put(`/metadata`,{payload:n})}getOrCreateBucket(){return this.post(`/bucket`)}ensureBucketReadAccess(e){let t={principal:e};return this.post(`/bucket/read-access`,{payload:t})}getBucketReadAccessStatus(e){return this.get(`/bucket/read-access`,{query:{principal:e}})}ensureBucketCreateAccess(e){let t={principal:e};return this.post(`/bucket/create-access`,{payload:t})}getBucketCreateAccessStatus(e){return this.get(`/bucket/create-access`,{query:{principal:e}})}list(e){return this.get(`/list`,{query:{prefix:e}})}getUploadUrl(e){return this.post(`/upload-url`,{payload:e,retryPolicy:Gt})}getDownloadUrl(e,t,n){let r={file:e,name:t,disposition:n};return this.post(`/download-url`,{payload:r})}getDownloadUrlWithOptions(e){return this.post(`/download-url`,{payload:e})}bulkGetUploadUrls(e){return this.post(`/bulk-upload-urls`,{payload:e})}async bulkUpload(e,t=10){let n=e.map(e=>({name:e.name,mime_type:K(e.type),id:e instanceof G?e.id:void 0})),{files:r}=await this.bulkGetUploadUrls({files:n}),i=Array(e.length);for(let n=0;n<e.length;n+=t){let a=e.slice(n,n+t);await Promise.all(a.map(async(e,t)=>{let a=n+t,{url:o,id:s,mime_type:c}=r[a],l=e instanceof G,u=q(e.type,c),d=await H(o,{method:`PUT`,body:l?e.stream:e,headers:u?{"Content-Type":u}:void 0});if(!d.ok)throw Error(`Failed to upload file ${e.name}: ${d.statusText}`);let f=d.headers.get(`etag`)?.replace(/^"(.*)"$/,`$1`);i[a]={source:s,name:e.name,type:u,etag:f}}))}return i}async uploadFile(e){return(await this.uploadFileWithPath(e)).id}async uploadFileWithPath(e){let t=e instanceof G,{url:n,id:r,path:i,mime_type:a}=await this.getUploadUrl({id:t?e.id:void 0,name:e.name,mime_type:K(e.type)}),o=q(e.type,a)||`application/gzip`,s=await H(n,{method:`PUT`,body:t?e.stream:e,headers:{"Content-Type":o}}).catch(e=>{throw console.error(`Failed to upload file`,{err:e,url:n,id:r,path:i}),e});if(!s.ok)throw console.log(s),Error(`Failed to upload file: ${s.statusText}`);return{id:r,path:i}}async downloadFile(e){let{url:t}=e.startsWith(`https:`)?{url:e}:await this.getDownloadUrl(e),n;try{n=await H(t,{method:`GET`})}catch(t){throw new Y(e,void 0,void 0,t)}if(!n.ok)throw new Y(e,n.status,n.statusText);if(!n.body)throw new Y(e);return n.body}async copyFile(e,t){return(await this.post(`/copy`,{payload:{source:e,dest:t}})).dest}async uploadMemoryPack(e){let t=X(e.name),n=e.name.endsWith(`.tar.gz`)?e.name:`${e.name}.tar.gz`;if(e instanceof File){let r=e;return this.uploadFile(new G(r.stream(),n,r.type,t))}return this.uploadFile(new G(e.stream,n,e.type,t))}async downloadMemoryPack(e,t=!1){let n=await this.downloadFile(X(e));if(t){let e=new DecompressionStream(`gzip`);n=n.pipeThrough(e)}return n}listByPrefix(e){return this.get(`/list`,{query:{prefix:e}})}async uploadArtifact(e,t,n){let r=Z(e,t);if(n instanceof File){let e=n;return this.uploadFile(new G(e.stream(),t,e.type,r))}return this.uploadFile(new G(n.stream,t,n.type,r))}async downloadArtifact(e,t){let n=Z(e,t);return this.downloadFile(n)}getArtifactDownloadUrl(e,t,n){let r=Z(e,t);return this.getDownloadUrl(r,t,n)}async listArtifacts(e){let t=`${J}/${e}/`;return(await this.listByPrefix(t)).files}},Xt=class extends I{constructor(e,t=`/api/v1/indexing`){super(e,t)}async status(){return this.get(`/status`)}async reindex(e){return this.post(`/reindex`,{payload:e})}async reindexAgentRuns(e){return this.post(`/agent-runs/reindex`,{payload:e})}async analyzeDrift(){return this.post(`/analyze-drift`,{payload:{}})}async getDriftAnalysis(){return this.get(`/drift-analysis`)}async enableIndexing(){return this.post(`/enable-indexing`)}async disableIndexing(){return this.post(`/disable-indexing`)}async enableQueries(){return this.post(`/enable-queries`)}async disableQueries(){return this.post(`/disable-queries`)}index(e,t){return this.post(`/internal/index`,{payload:{object_id:e,document:t}})}delete(e){return this.post(`/internal/delete`,{payload:{object_id:e}})}bulkIndex(e,t){return this.post(`/internal/bulk-index`,{payload:{documents:e,target_index:t}})}ensureIndex(e){return this.post(`/internal/ensure-index`,{payload:{recreate:e}})}createReindexTarget(){return this.post(`/internal/create-reindex-target`,{payload:{}})}getStats(){return this.post(`/internal/stats`,{payload:{}})}fetchBatch(e,t){return this.post(`/internal/fetch-batch`,{payload:{cursor:e,limit:t}})}getNextIndexCursor(e,t,n){return this.post(`/internal/next-cursor`,{payload:{cursor:e,limit:t,count:n}})}analyzeDriftBatch(e,t){return this.post(`/internal/analyze-drift-batch`,{payload:{cursor:e,limit:t}})}triggerReindex(e){return this.post(`/internal/trigger-reindex`,{payload:e?{full_reindex:e.fullReindex,object_ids:e.objectIds,recreate_index:e.recreateIndex}:{}})}fetchDocumentsByIds(e){return this.post(`/internal/fetch-by-ids`,{payload:{object_ids:e}})}bulkDelete(e){return this.post(`/internal/bulk-delete`,{payload:{object_ids:e}})}getConfiguration(){return this.post(`/internal/configuration`,{payload:{}})}get zenoBulkBaseUrl(){let e=this.client.baseUrl;return e.includes(`localhost:`)||e.includes(`127.0.0.1:`)?`https://zeno-bulk-dev-main.api.dev1.vertesia.io`:e.includes(`zeno-server`)?e.replace(/zeno-server/,`zeno-bulk`):e}zenoBulkPost(e,t){return this.client.post(this.zenoBulkBaseUrl+e,{payload:t})}computeShards(e,t,n,r){return this.zenoBulkPost(`/reindex/compute-shards`,{tenant_id:e,shard_size:t??25e4,updated_since:n,backend:r})}indexShard(e){return this.zenoBulkPost(`/reindex/shard`,{params:e})}swapAlias(e,t,n,r){return this.zenoBulkPost(`/reindex/swap-alias`,{tenant_id:e,target_index:t,alias:n,backend:r})}},Zt=class extends I{objectId;constructor(e,t){super(e,`/${t}/analyze`),this.objectId=t}async start(e){return this.post(`/`,{payload:e})}async getStatus(){return this.get(`/status`)}async startGroundedExtraction(e){return this.post(`/grounded`,{payload:e??{}})}async getGroundedExtractionResult(){return this.get(`/grounded/result`)}async startGroundedAssistant(e){return this.post(`/grounded/assistant`,{payload:e??{}})}},Qt=class extends I{constructor(e){super(e,`/api/v1/objects`)}analyze(e){return new Zt(this,e)}getUploadUrl(e){return this.post(`/upload-url`,{payload:e})}getDownloadUrl(e,t,n){return this.post(`/download-url`,{payload:{file:e,name:t,disposition:n}})}getDownloadUrlWithOptions(e){return this.post(`/download-url`,{payload:e})}getContentSource(e){return this.get(`/${e}/content-source`)}list(e={}){let t=e.limit||100,n=e.offset||0,r=e.query||{};return this.get(`/`,{query:{limit:t,offset:n,select:e.select,...r,all_revisions:e.all_revisions,from_root:e.from_root||void 0}})}computeFacets(e){return this.post(`/facets`,{payload:e})}startExport(e={}){return this.post(`/export/bulk`,{payload:e})}listExports(){return this.get(`/export/bulk/artifacts`)}deleteExport(e){return this.del(`/export/bulk/artifacts/${encodeURIComponent(e)}`)}getExportStatus(e,t){return this.get(`/export/bulk/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}getExportDownloadUrl(e,t){return this.get(`/export/bulk/artifacts/${encodeURIComponent(e)}/${t}/download-url`)}async downloadExportFile(e,t){let{url:n}=await this.getExportDownloadUrl(e,t),r=await H(n,{method:`GET`}).then(e=>{if(!e.ok)throw Error(`Failed to download export file: ${e.status} ${e.statusText}`);return e});if(!r.body)throw Error(`No response body received when downloading export file`);return r.body}exportToBucketViaBulk(e,t=!1){return this.zenoBulkPost(`/export`,e,t)}planContentObjectExportViaBulk(e,t=!1){return this.zenoBulkPost(`/export/plan`,e,t)}exportContentObjectShardViaBulk(e,t=!1){return this.zenoBulkPost(`/export/shard`,e,t)}splitContentObjectExportShardViaBulk(e,t=!1){return this.zenoBulkPost(`/export/shard/split`,e,t)}composeContentObjectExportViaBulk(e,t=!1){return this.zenoBulkPost(`/export/compose`,e,t)}get zenoBulkBaseUrl(){let e=this.client.baseUrl;return e.includes(`localhost:`)||e.includes(`127.0.0.1:`)?`https://zeno-bulk-dev-main.api.dev1.vertesia.io`:e.includes(`zeno-server`)?e.replace(/zeno-server/,`zeno-bulk`):e}zenoBulkPost(e,t,n){return this.client.post(this.zenoBulkBaseUrl+e,{payload:t,timeoutMs:n})}listFolders(e=`/`){throw Error(`Not implemented yet`)}find(e){return this.post(`/find`,{payload:e})}count(e){return this.post(`/count`,{payload:e})}search(e){return this.post(`/search`,{payload:e})}retrieve(e,t){return this.get(`/${e}`,{query:{select:t}})}getObjectText(e){return this.get(`/${e}/text`)}async upload(e){let t=e instanceof G,{url:n,id:r,mime_type:i}=await this.getUploadUrl({id:t?e.id:void 0,name:e.name,mime_type:K(e.type)}),a=q(e.type,i),o=await H(n,{method:`PUT`,body:t?e.stream:e,headers:a?{"Content-Type":a}:void 0}).catch(e=>{throw console.error(`Failed to upload file`,e),e});if(!o.ok)throw console.error(`Failed to upload file`,{status:o.status,statusText:o.statusText,url:n}),Error(`Failed to upload file: ${o.statusText}`);let s=o.headers.get(`etag`)?.replace(/^"(.*)"$/,`$1`);return{source:r,name:e.name,type:a,etag:s}}async create(e,t){let{content:n,...r}=e,a={...r};a.content=n instanceof G||n instanceof File?await this.upload(n):n;let o={};return t?.processing_priority&&(o[i.PROCESSING_PRIORITY]=t.processing_priority),t?.collection_id&&(o[i.COLLECTION_ID]=t.collection_id),await this.post(`/`,{payload:a,headers:o})}async createFromExternalSource(e,t={},n){let r=await this.client.files.getMetadata(e),a={...t,content:{source:e,name:r.name,type:r.contentType,etag:r.etag}},o={};return n?.processing_priority&&(o[i.PROCESSING_PRIORITY]=n.processing_priority),n?.collection_id&&(o[i.COLLECTION_ID]=n.collection_id),await this.post(`/`,{payload:a,headers:o})}async update(e,t,n){let{content:r,...a}=t,o={...a};o.content=r instanceof G||r instanceof File?await this.upload(r):r;let s={};return n?.ifMatch&&(s[`if-match`]=n.ifMatch),n?.processing_priority&&(s[i.PROCESSING_PRIORITY]=n.processing_priority),n?.createRevision&&(s[i.CREATE_REVISION]=`true`),n?.suppressWorkflows&&(s[i.SUPPRESS_WORKFLOWS]=`true`),this.put(`/${e}`,{payload:o,query:n?.createRevision&&n.revisionLabel?{revision_label:n.revisionLabel}:void 0,headers:s})}getRevisions(e){return this.get(`/${e}/revisions`)}getCollections(e){return this.get(`/${e}/collections`)}delete(e){return Array.isArray(e)?this.client.runOperation({name:`delete`,ids:e,params:{}}):this.del(`/${e}`)}bulkUpdate(e,t){let n=Object.keys(e);return this.client.runOperation({name:`update`,ids:n,params:t?{updates:e,...t}:e})}bulkCreate(e,t){return this.client.runOperation({name:`create`,ids:[],params:{objects:e,...t}})}listWorkflowRuns(e){return this.get(`/${e}/workflow-runs`)}listRenditions(e){return this.get(`/${e}/renditions`)}getRendition(e,t){let n={max_hw:t.max_hw,generate_if_missing:t.generate_if_missing,sign_url:t.sign_url,block_on_generation:t.block_on_generation};return this.get(`/${e}/renditions/${t.format}`,{query:n})}getRenditionSafe(e,t,n){return u(t,n.format)?this.getRendition(e,n):Promise.resolve(null)}exportProperties(e){return this.post(`/export`,{payload:e})}setEmbedding(e,t,n){return this.put(`/${e}/embeddings/${t}`,{payload:n})}},$t=class extends I{constructor(e){super(e,`/api/v1/pending-asks`)}register(e){return this.post(`/`,{payload:e})}resolve(e,t){return this.post(`/${e}/resolve`,{payload:t})}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}},en=class extends I{constructor(e){super(e,`/api/v1/processes`)}list(e){let t={};return e?.status&&(t.status=e.status),e?.process&&(t.process=e.process),e?.limit!=null&&(t.limit=String(e.limit)),e?.offset!=null&&(t.offset=String(e.offset)),(e?.all_versions||e?.allVersions)&&(t.all_versions=`true`),this.get(`/`,{query:t})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}listVersions(e){return this.get(`/${e}/versions`)}publish(e,t){return this.post(`/${e}/publish`,{payload:t})}revert(e,t){return this.post(`/${e}/revert`,{payload:t})}delete(e){return this.del(`/${e}`)}listTestSuites(e){return this.get(`/${e}/test-suites`)}createTestSuite(e,t){return this.post(`/${e}/test-suites`,{payload:t})}updateTestSuite(e,t,n){return this.put(`/${e}/test-suites/${t}`,{payload:n})}deleteTestSuite(e,t){return this.del(`/${e}/test-suites/${t}`)}startTestRun(e,t){return this.post(`/${e}/test-runs`,{payload:t})}listTestRuns(e,t){return this.get(`/${e}/test-runs`,{query:t?.limit==null?void 0:{limit:String(t.limit)}})}retrieveTestRun(e,t){return this.get(`/${e}/test-runs/${t}`)}cancelTestRun(e,t){return this.post(`/${e}/test-runs/${t}/cancel`,{})}},tn=class extends I{constructor(e){super(e,`/api/v1/process-test-runs`)}submit(e){return this.post(`/`,{payload:e,retryPolicy:!1})}retrieve(e){return this.get(`/${e}`)}cancel(e){return this.post(`/${e}/cancel`,{})}delete(e){return this.del(`/${e}`)}},nn=class extends I{constructor(e,t=`/api/v1/query`){super(e,t)}async execute(e){return this.post(`/`,{payload:e})}async sql(e){return this.execute({sql:e})}async esql(e){return this.execute({esql:e})}async dsl(e){return this.execute({dsl:e})}},rn=class extends I{constructor(e){super(e,`/api/v1/rendering`)}start(e){return this.post(`/jobs`,{payload:e})}getStatus(e,t){return this.get(`/jobs/status`,{query:{workflow_id:e,workflow_run_id:t}})}async render(e,t={}){let n=t.pollIntervalMs??1500,r=t.timeoutMs??6e5,i=await this.start(e);if(!i.workflow_id||!i.workflow_run_id)throw Error(`Failed to start rendering workflow`);let a=Date.now();for(;;){let t=await this.getStatus(i.workflow_id,i.workflow_run_id);if(t.status===l.COMPLETED){if(!t.download_url&&!t.file_uri)throw Error(t.error||`Rendering completed but no output file was produced`);return{status:`success`,format:e.format,download_url:t.download_url,file_uri:t.file_uri}}if(p(t.status)){let e=l[t.status]||String(t.status);throw Error(t.error||`Rendering failed with status: ${e}`)}if(Date.now()-a>=r)throw Error(`Rendering timed out after ${r}ms`);await an(n)}}};function an(e){return new Promise(t=>setTimeout(t,e))}var on=class extends I{constructor(e){super(e,`/api/v1/schedules`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}trigger(e){return this.post(`/${e}/trigger`,{})}pause(e,t){return this.post(`/${e}/pause`,{payload:{note:t}})}resume(e,t){return this.post(`/${e}/resume`,{payload:{note:t}})}},sn=class extends I{constructor(e){super(e,`/api/v1/tasks`)}list(e={}){return this.get(`/`,{query:e})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}complete(e,t){return this.post(`/${e}/complete`,{payload:t})}cancel(e){return this.post(`/${e}/cancel`,{})}delete(e){return this.del(`/${e}`)}},cn=class extends I{constructor(e){super(e,`/api/v1/types/catalog`)}list(e={}){return this.get(`/`,{query:e})}listSysTypes(e){return this.get(`/sys`,{query:{tag:e}})}listAppTypes(e){return this.get(`/apps`,{query:{tag:e}})}listStoredTypes(e={}){return this.get(`/stored`,{query:e})}resolve(e){let t=typeof e==`string`?e:e.id;return this.get(`/resolve/${t}`)}},ln=class extends I{catalog;constructor(e){super(e,`/api/v1/types`),this.catalog=new cn(e)}list(e={},t){let n=e.limit||2e3,r=e.offset||0,i=e.query||{};return this.get(`/`,{query:{limit:n,offset:r,layout:!!t?.layout,schema:!!t?.schema,...i}})}find(e){return this.post(`/find`,{payload:e})}retrieve(e){return this.get(`/${e}`)}getTypeByName(e){return this.get(`/name/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}create(e){return this.post(`/`,{payload:e})}delete(e){return this.del(`/${e}`)}},un=class extends I{constructor(e){super(e,`/api/v1/view-executions`)}execute(e,t={}){return this.post(`/${encodeURIComponent(e)}/execute`,{payload:t})}preview(e){return this.post(`/preview`,{payload:e})}},dn=class extends I{constructor(e){super(e,`/api/v1/workflows`)}getActivityCatalog(){return this.get(`/activity-catalog`)}listRuns(e,t,n){return this.post(`/runs`,{payload:{documentId:e,eventName:t,ruleId:n}})}listConversations(e){return this.post(`/conversations`,{payload:e})}searchRuns(e){return this.post(`/runs`,{payload:e})}sendSignal(e,t,n,r){return this.post(`/runs/${e}/${t}/signal/${n}`,{payload:r})}getRunDetails(e,t,n){let r={};return n?.includeHistory!==void 0&&(r.include_history=n.includeHistory),n?.historyFormat!==void 0&&(r.history_format=n.historyFormat),n?.hydratePayloads!==void 0&&(r.hydrate_payloads=n.hydratePayloads),this.get(`/runs/${t}/${e}`,{query:r})}getRunInteraction(e,t){return this.get(`/runs/${e}/${t}/interaction`)}terminate(e,t,n){let r={reason:n};return this.post(`/runs/${e}/${t}/actions/terminate`,{payload:r})}cancel(e,t,n){let r={reason:n};return this.post(`/runs/${e}/${t}/actions/cancel`,{payload:r})}query(e,t,n){return this.get(`/runs/${e}/${t}/query/${n}`)}execute(e,t={}){return this.post(`/execute/${e}`,{payload:t})}postMessage(e,t){if(!e)throw Error(`runId is required`);return this.post(`/runs/${e}/updates`,{payload:t})}async retrieveMessages(e,t,n){let r={since:n};return(await this.get(`/runs/${e}/${t}/updates`,{query:r})).messages.map(e=>g(m(e),t))}async streamMessages(e,t,r,i,a){return new Promise((o,s)=>{let c=0,l=i||0,u=Date.now(),d=!1,f=null,p=null,h=null,_=null,v=e=>{let t=Math.min(1e3*2**e,3e4);return t+Math.random()*.1*t},y=()=>{h&&=(clearTimeout(h),null),p&&=(clearInterval(p),null),f&&=(f.close(),null),a&&_&&(a.removeEventListener(`abort`,_),_=null)},b=e=>{d||(d=!0,y(),o(e))};if(a){if(a.aborted){b(null);return}_=()=>b(null),a.addEventListener(`abort`,_,{once:!0})}let x=async(i=!1)=>{if(!d)try{let a=await L(),u=this.client,_=new URL(`${u.workflows.baseUrl}/runs/${e}/${t}/stream`);l>0&&_.searchParams.set(`since`,l.toString()),_.searchParams.set(`skipHistory`,`true`);let S=u._auth?await u._auth():void 0;if(d)return;if(!S){d=!0,y(),s(Error(`No auth token available`));return}let C=S.split(` `)[1];_.searchParams.set(`access_token`,C),i&&console.log(`Reconnecting to SSE stream for run ${t} (attempt ${c+1}/10)`);let w=new a(_.href);f=w,p=setInterval(()=>{},1e3),w.onopen=()=>{i&&console.log(`Successfully reconnected to SSE stream for run ${t}`),c=0},w.onmessage=e=>{if(!e.data||e.data.startsWith(`:`)){console.log(`Received comment or heartbeat; ignoring it.: `,e.data);return}try{let i=m(e.data);l=i.ts?Math.max(l,i.ts):Date.now(),r&&r(g(i,t),b),Ct(i,t)?(console.log(`Closing stream due to COMPLETE message from main workstream`),d||(d=!0,y(),o(null))):i.t===n.COMPLETE&&console.log(`Received COMPLETE message that does not close the root stream for run ${t}`)}catch(t){console.error(`Failed to parse SSE message:`,t,e.data)}},w.onerror=e=>{if(!d){if(console.warn(`SSE stream error for run ${t}:`,e),y(),c<10){let e=v(c);console.log(`Attempting to reconnect in ${e}ms (attempt ${c+1}/10)`),c++,h=setTimeout(()=>{h=null,d||x(!0)},e)}else console.error(`Failed to reconnect to SSE stream for run ${t} after 10 attempts`),d=!0,s(Error(`SSE connection failed after 10 reconnection attempts`))}}}catch(e){if(console.error(`Error setting up SSE stream:`,e),c<10){let e=v(c);c++,h=setTimeout(()=>{h=null,d||x(!0)},e)}else s(e)}};(async()=>{try{let n=await this.retrieveMessages(e,t,i),a=!1;for(let e=0;e<n.length;e++){let i=n[e];l=Math.max(l,i.timestamp||0),r&&r(i,b),a=e===n.length-1&&U(i,t)}if(a){b(null);return}}catch(e){console.warn(`Failed to fetch historical messages, continuing with SSE:`,e)}!d&&l<=0&&(l=Math.max(1,u-1)),x(!1)})().catch(s)})}async streamMessagesWS(e,t,r,i){return new Promise((a,o)=>{let s=0,c=null,l=i||0,u=!1,d=e=>{let t=Math.min(1e3*2**e,3e4);return t+Math.random()*.1*t},f=async()=>{if(!u)try{let i=this.client,p=new URL(`${i.workflows.baseUrl}/runs/${e}/${t}/ws`);p.protocol=p.protocol.replace(`http`,`ws`),l>0&&p.searchParams.set(`since`,l.toString());let h=i._auth?await i._auth():void 0;if(!h){o(Error(`No auth token available`));return}let g=h.split(` `)[1];p.searchParams.set(`access_token`,g),s>0&&console.log(`Reconnecting to WebSocket for run ${t} (attempt ${s+1}/10)`),c=new WebSocket(p.href),c.onopen=()=>{s>0&&console.log(`Successfully reconnected to WebSocket for run ${t}`),s=0,u||a({cleanup:()=>{u=!0,c&&=(c.close(),null)},sendSignal:(e,t)=>{if(c?.readyState===WebSocket.OPEN){let n={type:`signal`,signalName:e,data:t,requestId:Date.now()};c.send(JSON.stringify(n))}else console.warn(`WebSocket not open, cannot send signal`)}})},c.onmessage=e=>{try{let t=JSON.parse(e.data);if(`type`in t&&typeof t.type==`string`){if(t.type===`pong`){console.debug(`Received pong`);return}if(t.type===`ack`){console.debug(`Signal acknowledged`,t);return}if(t.type===`error`){console.error(`WebSocket error message`,t);return}}let i=m(t);l=i.ts?Math.max(l,i.ts):Date.now(),r&&r(i);let a=i.w||`main`;(i.t===n.TERMINATED||i.t===n.COMPLETE&&a===`main`)&&(console.log(`Closing WebSocket due to workflow completion`),u=!0,c&&=(c.close(),null))}catch(e){console.error(`Failed to parse WebSocket message`,e)}},c.onerror=e=>{console.error(`WebSocket error`,e)},c.onclose=()=>{if(!u&&s<10){let e=d(s);console.log(`WebSocket closed, reconnecting in ${e}ms (attempt ${s+1}/10)`),s++,setTimeout(f,e)}else s>=10&&o(Error(`WebSocket connection failed after 10 attempts`))}}catch(e){if(console.error(`Error setting up WebSocket`,e),s<10){let e=d(s);s++,setTimeout(f,e)}else o(e)}};f()})}ingestEvents(e,t,n){return this.post(`/runs/${e}/${t}/events`,{payload:{events:n}})}getAnalyticsSummary(e={}){return this.post(`/analytics/summary`,{payload:e})}getTokenUsageAnalytics(e={}){return this.post(`/analytics/tokens`,{payload:e})}getLlmLatencyAnalytics(e={}){return this.post(`/analytics/latency/llm`,{payload:e})}getToolLatencyAnalytics(e={}){return this.post(`/analytics/latency/tools`,{payload:e})}getAgentLatencyAnalytics(e={}){return this.post(`/analytics/latency/agents`,{payload:e})}getErrorAnalytics(e={}){return this.post(`/analytics/errors`,{payload:e})}getToolAnalytics(e={}){return this.post(`/analytics/tools`,{payload:e})}getToolParameterAnalytics(e){return this.post(`/analytics/tools/parameters`,{payload:e})}getAnalyticsFilterOptions(e={}){return this.post(`/analytics/filter-options`,{payload:e})}getPromptSizeAnalytics(e={}){return this.post(`/analytics/prompt-size`,{payload:e})}getTopPrincipalsAnalytics(e={}){return this.post(`/analytics/top-principals`,{payload:e})}getRunsByAgentAnalytics(e={}){return this.post(`/analytics/runs-by-agent`,{payload:e})}getTimeToFirstResponseAnalytics(e={}){return this.post(`/analytics/time-to-first-response`,{payload:e})}getFirstResponseBehaviorAnalytics(e={}){return this.post(`/analytics/first-response-behavior`,{payload:e})}rules=new fn(this);definitions=new pn(this)},fn=class extends I{constructor(e){super(e,`/rules`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}create(e){return this.post(`/`,{payload:e})}delete(e){return this.del(`/${e}`)}execute(e,t,n){let r={objectIds:t,vars:n};return this.post(`/${e}/execute`,{payload:r})}},pn=class extends I{constructor(e){super(e,`/definitions`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}create(e){return this.post(`/`,{payload:e})}delete(e){return this.del(`/${e}`)}};const mn={serverUrl:!0,tokenServerUrl:!0,apikey:!0,onRequest:!0,onResponse:!0,retryPolicy:!0,timeout:!0,fetch:!0};function hn(e){if(!e)throw Error(`zeno client serverUrl is required`);return e}var gn=class extends Ce{constructor(e={}){pt(`ZenoClient`,e,mn),super(hn(e.serverUrl),e.fetch),e.apikey&&this.withApiKey(e.apikey),e.retryPolicy&&this.withRetryPolicy(e.retryPolicy),e.timeout!==void 0&&this.withTimeout(e.timeout),this.onRequest=e.onRequest,this.onResponse=e.onResponse,this.errorFactory=e=>e.status===404?new Ht(e.request,e):e}withApiVersion(e){return e?this.headers[c]=String(e):delete this.headers[c],this}withAppVersion(e){return e?this.headers[t]=String(e):delete this.headers[t],this}withApiKey(e){return this.withAuthCallback(e?()=>Promise.resolve(`Bearer ${e}`):void 0)}runOperation(e){return this.post(`/api/v1/operations`,{payload:e})}get initialHeaders(){return{...super.initialHeaders,[c]:r}}agents=new wt(this);cost=new Dt(this);objects=new Qt(this);types=new ln(this);workflows=new dn(this);schedules=new on(this);processes=new en(this);processTestRuns=new tn(this);tasks=new sn(this);files=new Yt(this);collections=new Et(this);embeddings=new jt(this);email=new At(this);events=new Vt(this);eventSubscriptions=this.events.subscriptions;pendingAsks=new $t(this);data=new kt(this);indexing=new Xt(this);query=new nn(this);rendering=new rn(this);views=new un(this)},_n=class extends I{constructor(e){super(e,`/api/v1/tools`)}list(e){let t={};return e?.sources?.length&&(t.sources=e.sources.join(`,`)),e?.exclude?.length&&(t.exclude=e.exclude.join(`,`)),e?.context&&(t.context=e.context),this.get(`/`,{query:Object.keys(t).length>0?t:void 0})}inspect(e,t){if(!e.trim())throw Error(`Tool name must not be empty`);return this.get(`/${encodeURIComponent(e)}`,{query:t?.context?{context:t.context}:void 0})}listBuiltins(){return this.list({sources:[`builtin`]})}validate(e){return this.post(`/validate`,{payload:{names:e}})}},vn=class extends I{constructor(e){super(e,`/api/v1/training`)}listSessions(e={}){return this.get(`/`,{query:{...e}})}listSessionNames(e={}){return this.get(`/names`,{query:{...e}})}createSession(e){return this.post(`/`,{payload:e})}getSession(e){return this.get(`/${e}`)}addToSession(e,t){return this.post(`/${e}/add`,{payload:{runs:t}})}listSessionRuns(e,t=100,n=0){return this.get(`/${e}/runs`,{query:{limit:t,offset:n}})}buildSession(e){return this.post(`/${e}/build`)}getDataUrl(e){return this.get(`/${e}/url`)}getDataUploadUrl(e,t=!1){return this.get(`/${e}/upload-url`,t?{query:{resumable:`true`}}:{})}startTraining(e){return this.post(`/${e}/start`)}cancelTraining(e){return this.post(`/${e}/cancel`)}getTrainingJob(e){return this.get(`/job/${e}`)}getAndSyncTrainingJob(e){return this.get(`/job/${e}`,{query:{sync:`true`}})}setDataset(e,t=`default`){return this.post(`/${e}/dataset`,{payload:{dataset:t}})}},yn=class extends I{constructor(e){super(e,`/api/v1/users`)}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}},bn=class extends I{executionApi;constructor(e,t){super(e,`/api/v1/views`),this.executionApi=t}list(e={}){return this.get(`/`,{query:{limit:e.limit,offset:e.offset}})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${encodeURIComponent(e)}`)}update(e,t){return this.put(`/${encodeURIComponent(e)}`,{payload:t})}delete(e){return this.del(`/${encodeURIComponent(e)}`)}execute(e,t={}){return this.executionApi.execute(e,t)}preview(e){return this.executionApi.preview(e)}};const xn={site:!0,serverUrl:!0,storeUrl:!0,tokenServerUrl:!0,apikey:!0,sessionTags:!0,onRequest:!0,onResponse:!0,retryPolicy:!0,timeout:!0,fetch:!0};var Q=class e extends Ce{_jwt=null;store;sessionTags;tokenServerUrl;oauthClients;oauthGrants;oauthServer;oauthProviders;remoteMcpConnections;secrets;internalSecrets;static async fromAuthToken(t,n,r){if(!t?.trim())throw Error(`VertesiaClient.fromAuthToken requires a non-empty auth token`);n||=$(t);let i=r||Dn(n.endpoints);return await new e({serverUrl:i.studio,storeUrl:i.store,tokenServerUrl:i.token||n.iss}).withApiKey(t)}static decodeEndpoints(){}constructor(e={site:`api.vertesia.io`}){pt(`VertesiaClient`,e,xn);let t,n;if(e.serverUrl)t=e.serverUrl;else if(e.site)t=`https://${e.site}`;else throw Error(`Parameter 'site' or 'serverUrl' is required for VertesiaClient`);if(e.storeUrl)n=e.storeUrl;else if(e.site)n=`https://${e.site}`;else throw Error(`Parameter 'site' or 'storeUrl' is required for VertesiaClient`);if(super(t,e.fetch),e.tokenServerUrl)this.tokenServerUrl=e.tokenServerUrl;else if(e.site){let t=e.site.replace(/^api/,`sts`);this.tokenServerUrl=`https://${t}`}else if(e.serverUrl||e.storeUrl){let t=e.serverUrl||e.storeUrl||``;try{let e=new URL(t);if(e.hostname.startsWith(`api`)){let t=e.hostname.replace(/^api/,`sts`);this.tokenServerUrl=`https://${t}`}else this.tokenServerUrl=`https://sts.dev1.vertesia.io`}catch{this.tokenServerUrl=`https://sts.dev1.vertesia.io`}}else this.tokenServerUrl=`https://sts.dev1.vertesia.io`;this.store=new gn({serverUrl:n,tokenServerUrl:this.tokenServerUrl,apikey:e.apikey,onRequest:e.onRequest,onResponse:e.onResponse,retryPolicy:e.retryPolicy,timeout:e.timeout,fetch:e.fetch}),this.views=new bn(this,this.store.views),e.retryPolicy&&this.withRetryPolicy(e.retryPolicy),e.timeout!==void 0&&this.withTimeout(e.timeout),e.apikey&&this.withApiKey(e.apikey),this.onRequest=e.onRequest,this.onResponse=e.onResponse,this.sessionTags=e.sessionTags,this.oauthClients=new Ze(this),this.oauthGrants=new $e(this),this.oauthServer=new tt(this,this.tokenServerUrl),this.oauthProviders=new et(this),this.remoteMcpConnections=new st(this),this.secrets=new lt(this),this.internalSecrets=new Xe(this)}withApiVersion(e){return e?this.headers[c]=String(e):delete this.headers[c],this}withAppVersion(e){return this.store.withAppVersion(e),e?this.headers[t]=String(e):delete this.headers[t],this}withAuthCallback(e){return this.store.withAuthCallback(e),super.withAuthCallback(e)}withRetryPolicy(e){return this.store.withRetryPolicy(e),super.withRetryPolicy(e)}withTimeout(e){return this.store.withTimeout(e),super.withTimeout(e)}async withApiKey(e){return this.withAuthCallback(e?async()=>{if(!Sn(e))return`Bearer ${e}`;if(Cn(this._jwt)){let t=await this.getAuthToken(e);this._jwt=t.token}return`Bearer ${this._jwt}`}:void 0)}async getRawJWT(){if(!this._jwt&&this._auth){let e=await this._auth();this._jwt||=e.trim().split(` `)[1]}return this._jwt||null}async getDecodedJWT(){let e=await this.getRawJWT();return e?$(e):null}async getProject(){return(await this.getDecodedJWT())?.project||null}async getAccount(){return(await this.getDecodedJWT())?.account||null}get agents(){return this.store.agents}get workflows(){return this.store.workflows}get objects(){return this.store.objects}get files(){return this.store.files}get processes(){return this.store.processes}get processTestRuns(){return this.store.processTestRuns}get tasks(){return this.store.tasks}get types(){return this.store.types}get data(){return this.store.data}get events(){return this.store.events}get storeUrl(){return this.store.baseUrl}async mintAppSessionToken(e){return this.post(`${this.tokenServerUrl}/token/app-session`,{payload:e})}async getAuthToken(e){return this.post(`${this.tokenServerUrl}/token/issue`,{headers:{"content-type":`application/json`,authorization:`Bearer ${e}`},retryPolicy:{attempts:4,methods:[`POST`],statuses:[429,500,502,503,504]}}).catch(e=>{throw console.error(`Error fetching token from ${this.tokenServerUrl}:`,{error:e}),e})}get initialHeaders(){return{...super.initialHeaders,[c]:r}}projects=new nt(this);environments=new Ne(this);interactions=new Ye(this);skills=new ut(this);prompts=new it(this);runs=new ct(this);account=new Te(this);accounts=new Ee(this);apikeys=new Oe(this);analytics=new De(this);auditTrail=new Ae(this);training=new vn(this);delegationGrants=new Me(this);users=new yn(this);iam=new Fe(this);refs=new ot(this);commands=new je(this);apps=new ke(this);tools=new _n(this);quota=new at(this);views};function Sn(e){return e.startsWith(`pk-`)||e.startsWith(`sk-`)}function Cn(e){if(!e)return!0;let t=$(e).exp;return Date.now()>=t*1e3-6e4}function $(e){let t=typeof e==`string`?e.split(`.`):[];if(t.length!==3||!t[1])throw Error(`Invalid auth token: expected a JWT of three dot-separated segments, got ${t.length||`none`}`);let n;try{n=En(t[1])}catch(e){throw Error(`Invalid auth token: payload segment is not base64url (${e.message})`)}try{return JSON.parse(n)}catch{throw Error(`Invalid auth token: payload segment is not JSON`)}}function wn(){return globalThis.Buffer}function Tn(){return globalThis.process?.env?.STS_URL}function En(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=wn();if(n)return n.from(t,`base64`).toString(`utf-8`);if(typeof atob<`u`&&typeof TextDecoder<`u`){let e=atob(t),n=Uint8Array.from(e,e=>e.charCodeAt(0));return new TextDecoder().decode(n)}throw Error(`No base64 decoder available`)}function Dn(e){return e?typeof e==`string`?On(e):e:On(`api.vertesia.io`)}function On(e){if(e===`local`)return{studio:`http://localhost:8091`,store:`http://localhost:8092`,token:Tn()??`https://sts.dev1.vertesia.io`,git:`https://git.dev1.vertesia.io`};{let t=`https://${e}`;return{studio:t,store:t,token:t.replace(`api`,`sts`),git:t.replace(`api`,`git`)}}}var kn=class{id;client;constructor(e,t){this.id=e,this.client=t instanceof Q?t:new Q(t)}retrieve(){return this.client.interactions.retrieve(this.id)}update(e){return this.client.interactions.update(this.id,e)}render(e){throw Error(`Not implemented`)}async execute(e={},t){return ze(this.client,this.id,e,t)}},An=class extends I{constructor(e){super(e,`/internal/accounts`)}getApiVersionPolicy(e){return this.get(`/${encodeURIComponent(e)}/api-version-policy`)}};export{e as APP_VERSION_HEADER,J as ARTIFACTS_PREFIX,wt as AgentsApi,kt as DataApi,Me as DelegationGrantsApi,At as EmailApi,jt as EmbeddingsApi,Rt as EventIngestChannelsApi,Bt as EventSubscriptionsApi,Vt as EventsApi,Y as FileDownloadError,Yt as FilesApi,R as IS_INTERACTION_OUTPUT,Xt as IndexingApi,kn as InteractionBase,B as InteractionOutput,An as InternalAccountsApi,Xe as InternalSecretsApi,Wt as MEMORIES_PREFIX,Ze as OAuthClientsApi,$e as OAuthGrantsApi,et as OAuthProvidersApi,tt as OAuthServerApi,Qt as ObjectsApi,$t as PendingAsksApi,s as Permission,en as ProcessApi,tn as ProcessTestRunApi,nn as QueryApi,st as RemoteMcpConnectionsApi,rn as RenderingApi,on as SchedulesApi,lt as SecretsApi,un as StoreViewsApi,G as StreamSource,sn as TaskApi,cn as TypeCatalogApi,ln as TypesApi,Q as VertesiaClient,bn as ViewsApi,dn as WorkflowsApi,pn as WorkflowsDefinitionApi,fn as WorkflowsRulesApi,gn as ZenoClient,Ht as ZenoClientNotFoundError,u as canGenerateRendition,V as createInteractionOutput,Dn as decodeEndpoints,$ as decodeJWT,Ge as enhanceExecutionRun,z as enhanceInteractionExecutionResult,W as escapeArtifactPathDelimiters,H as fetchSignedUrl,Z as getAgentArtifactPath,X as getMemoryFilePath,d as getOAuthPermissionScopes,f as getSupportedRenditionFormats,Cn as isTokenExpired,It as openManagedEventSource,h as supportsVisualRendition};
|
|
13
13
|
//# sourceMappingURL=vertesia-client.js.map
|