@vertesia/client 1.6.0-dev.20261008.064737Z → 1.6.0-dev.20261009.095813Z

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.
@@ -8,11 +8,6 @@ export declare class CostApi extends ApiTopic {
8
8
  * Covers all inference types: direct, agent, embedding.
9
9
  */
10
10
  getAnalytics(query?: CostAnalyticsQuery): Promise<CostAnalyticsResponse>;
11
- /**
12
- * Get platform-wide cost analytics across all customers.
13
- * Requires Vertesia staff privileges. Defaults to group_by='account'.
14
- */
15
- getGlobalAnalytics(query?: CostAnalyticsQuery): Promise<CostAnalyticsResponse>;
16
11
  /**
17
12
  * Get current list prices and effective prices for the selected period.
18
13
  */
@@ -1 +1 @@
1
- {"version":3,"file":"CostApi.d.ts","sourceRoot":"","sources":["../../src/store/CostApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EACR,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,4BAA4B,EAC/B,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,OAAQ,SAAQ,QAAQ;IACjC,YAAY,MAAM,EAAE,UAAU,EAE7B;IAED;;;;OAIG;IACH,YAAY,CAAC,KAAK,GAAE,kBAAuB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAE3E;IAED;;;OAGG;IACH,kBAAkB,CAAC,KAAK,GAAE,kBAAuB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAEjF;IAED;;OAEG;IACH,cAAc,CAAC,KAAK,GAAE,oBAAyB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAEtF;IAED;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAEnE;IAED;;OAEG;IACH,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAE7E;IAED;;OAEG;IACH,YAAY,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,CAc7C;CACJ"}
1
+ {"version":3,"file":"CostApi.d.ts","sourceRoot":"","sources":["../../src/store/CostApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EACR,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,4BAA4B,EAC/B,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,OAAQ,SAAQ,QAAQ;IACjC,YAAY,MAAM,EAAE,UAAU,EAE7B;IAED;;;;OAIG;IACH,YAAY,CAAC,KAAK,GAAE,kBAAuB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAE3E;IAED;;OAEG;IACH,cAAc,CAAC,KAAK,GAAE,oBAAyB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAEtF;IAED;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAEnE;IAED;;OAEG;IACH,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAE7E;IAED;;OAEG;IACH,YAAY,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,CAc7C;CACJ"}
@@ -11,13 +11,6 @@ export class CostApi extends ApiTopic {
11
11
  getAnalytics(query = {}) {
12
12
  return this.post('/analytics', { payload: query });
13
13
  }
14
- /**
15
- * Get platform-wide cost analytics across all customers.
16
- * Requires Vertesia staff privileges. Defaults to group_by='account'.
17
- */
18
- getGlobalAnalytics(query = {}) {
19
- return this.post('/analytics/global', { payload: query });
20
- }
21
14
  /**
22
15
  * Get current list prices and effective prices for the selected period.
23
16
  */
@@ -1 +1 @@
1
- {"version":3,"file":"CostApi.js","sourceRoot":"","sources":["../../src/store/CostApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAmB,MAAM,4BAA4B,CAAC;AAWvE,MAAM,OAAO,OAAQ,SAAQ,QAAQ;IACjC,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,KAAK,GAAuB,EAAE;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACvD,CAAC;IAED;;;OAGG;IACH,kBAAkB,CAAC,KAAK,GAAuB,EAAE;QAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,KAAK,GAAyB,EAAE;QAC3C,OAAO,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,KAAwB;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,qBAAqB,CAAC,KAAwB;QAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,KAAK,EAAE,0BAA0B,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IAChG,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,MAAwB;QACjC,MAAM,YAAY,GAAG,IAAI,eAAe,EAAE,CAAC;QAC3C,IAAI,MAAM,EAAE,IAAI;YACZ,YAAY,CAAC,GAAG,CACZ,MAAM,EACN,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CACtF,CAAC;QACN,IAAI,MAAM,EAAE,EAAE;YACV,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,MAAM,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC1G,IAAI,MAAM,EAAE,KAAK;YAAE,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3D,IAAI,MAAM,EAAE,UAAU;YAAE,YAAY,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;QAC1E,IAAI,MAAM,EAAE,WAAW;YAAE,YAAY,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAC7E,MAAM,EAAE,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;QACnC,OAAO,GAAG,IAAI,CAAC,OAAO,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACzD,CAAC;CACJ"}
1
+ {"version":3,"file":"CostApi.js","sourceRoot":"","sources":["../../src/store/CostApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAmB,MAAM,4BAA4B,CAAC;AAWvE,MAAM,OAAO,OAAQ,SAAQ,QAAQ;IACjC,YAAY,MAAkB;QAC1B,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,KAAK,GAAuB,EAAE;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,KAAK,GAAyB,EAAE;QAC3C,OAAO,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,KAAwB;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,qBAAqB,CAAC,KAAwB;QAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,KAAK,EAAE,0BAA0B,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IAChG,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,MAAwB;QACjC,MAAM,YAAY,GAAG,IAAI,eAAe,EAAE,CAAC;QAC3C,IAAI,MAAM,EAAE,IAAI;YACZ,YAAY,CAAC,GAAG,CACZ,MAAM,EACN,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CACtF,CAAC;QACN,IAAI,MAAM,EAAE,EAAE;YACV,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,MAAM,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC1G,IAAI,MAAM,EAAE,KAAK;YAAE,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3D,IAAI,MAAM,EAAE,UAAU;YAAE,YAAY,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;QAC1E,IAAI,MAAM,EAAE,WAAW;YAAE,YAAY,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAC7E,MAAM,EAAE,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;QACnC,OAAO,GAAG,IAAI,CAAC,OAAO,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACzD,CAAC;CACJ"}
@@ -9,5 +9,5 @@ Stack Trace: `}return a}var b=class extends Error{status;payload;request;request
9
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=/* @__PURE__ */ 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))}handleConnectionError(e){console.error(`Failed to connect to ${e.request.url}`,e.payload)}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);if(n||!d||!this.shouldRetryConnectionError(d,c,h,m)){let r=new S(e,he(t));n||this.handleConnectionError(r),this.throwError(r)}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;try{return await this.handleResponse(e,t,n)}catch(t){if(!ge(t))throw t;let n=new S(e,he(t));_e(t)||this.handleConnectionError(n),this.throwError(n)}}throw _&&this.throwError(new S(_,/* @__PURE__ */ 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.verboseErrors=e.verboseErrors}createRequest(e,t){return this.client.createRequest(e,t)}handleResponse(e,t,n){return this.client.handleResponse(e,t,n)}throwError(e){return this.client.throwError(e)}handleConnectionError(e){this.client.handleConnectionError(e)}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})}adoption(e={}){return this.post(`/adoption`,{payload:e})}usage(e={}){return this.post(`/usage`,{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})}runBudgetCapability(e,t){return this.get(`/${e}/run-budget-capability`,{query:t})}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}`)}},Re=class extends I{constructor(e){super(e,`/api/v1/inference-profiles`)}async getDefault(e,t){let n=e.inference,r=(t?n?.system?.[t]:void 0)??n?.default_profile;return r?this.retrieve(r):(t?e.defaults?.system?.[t]:void 0)??e.defaults?.base}list(){return this.get(`/`)}retrieve(e){return this.get(`/${encodeURIComponent(e)}`)}usage(e,t={}){return this.get(`/${encodeURIComponent(e)}/usage`,{query:t})}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${encodeURIComponent(e)}`,{payload:t})}delete(e){return this.del(`/${encodeURIComponent(e)}`)}},ze=class extends I{constructor(e){super(e,`/api/v1/interaction-configurations`)}retrieve(e){return this.get(`/${encodeURIComponent(e)}`)}update(e,t){return this.put(`/${encodeURIComponent(e)}`,{payload:t})}delete(e){return this.del(`/${encodeURIComponent(e)}`)}};const Be=(()=>{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 Ve(e,t,n={},r){let i=!!r,a=await e.runs.create({...n,interaction:t,stream:i},{timeoutMs:i?void 0:Be});return i?a.status===o.failed?a:Ue(e,a.id,r):a}async function He(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:Be)});return a?s.status===o.failed?s:Ue(e,s.id,r):s}function Ue(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){c.close(),i(e)}}),c.addEventListener(`close`,e=>{try{c.close(),r(JSON.parse(e.data))}catch(e){i(e)}}),c.addEventListener(`error`,()=>{c.readyState===a.CLOSED&&(c.close(),i(/* @__PURE__ */ Error(`Interaction result stream closed before completion`)))})}catch(e){i(e)}})()})}async function We(e,t){return await e.post(`/api/v1/execute/async`,{payload:t})}async function Ge(e,t){return await e.post(`/api/v1/execute/rate-limit/request`,{payload:t})}var Ke=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 qe(e){return e.result=B.from(e.result),e}var B=class{results;constructor(e){this.results=e}static from(e){return e?Je(e)?e:V(Array.isArray(e)?e:typeof e==`object`?[{type:`json`,value:e}]:[{type:`text`,value:String(e)}]):V([])}static isInteractionOutputArray(e){return Je(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
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:Ye(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 Je(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 Ye(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||=/* @__PURE__ */ Error(`No JSON result found and no text available to parse`),t}function Xe(e){return!!e&&typeof e==`object`&&`id`in e&&typeof e.id==`string`}var Ze=class extends I{catalog;constructor(e){super(e,`/api/v1/interactions`),this.catalog=new Ke(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 Ve(this.client,e,t,n).catch(e=>{throw e instanceof x&&Xe(e.payload)?e.updateDetails({run_id:e.payload.id}):e}))}async executeByName(e,t={},n,r){return z(await He(this.client,e,t,n,r).catch(e=>{throw e instanceof x&&Xe(e.payload)?e.updateDetails({run_id:e.payload.id}):e}))}executeAsync(e){return We(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 Ge(this.client,e)}resolve(e,t){return this.get(`/resolve/${encodeURIComponent(e)}`,{query:t})}},Qe=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 $e(e){if(e)return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)]))}var et=class extends I{constructor(e){super(e,`/api/v1/oauth-grants`)}list(e){return this.get(`/`,{query:$e(e)})}retrieve(e){return this.get(`/${e}`)}revoke(e,t){return this.del(`/${e}`,{query:t})}revokeBulk(e){return this.post(`/revoke`,{payload:e})}},tt=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`)}},nt=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(/* @__PURE__ */ 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:{}})}},rt=class extends I{integrations;constructor(e){super(e,`/api/v1/projects`),this.integrations=new it(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})}},it=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`)}},at=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`)}},ot=class extends I{constructor(e){super(e,`/api/v1/quota`)}standing(){return this.get(`/standing`)}tier(){return this.get(`/tier`)}},st=class extends I{constructor(e){super(e,`/api/v1/refs`)}resolve(e){return this.post(`/resolve`,{payload:{refs:e}})}},ct=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}})}},lt=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 qe(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})}},ut=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})}},dt=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 ft={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"},pt=/* @__PURE__ */ new Set;function mt(e,t,n){let r=Object.keys(t).filter(e=>!Object.hasOwn(n,e)&&!pt.has(e));if(r.length===0)return;for(let e of r)pt.add(e);let i=r.map(e=>Object.hasOwn(ft,e)?`${e} (${ft[e]})`:e);console.warn(`[${e}] Ignoring unknown constructor option(s): ${i.join(`; `)}. Unknown options have no effect.`)}const ht=/* @__PURE__ */ new Set([429,500,502,503,504]);function gt(e){try{return new URL(e).hostname.toLowerCase().endsWith(`.blob.core.windows.net`)}catch{return!1}}function _t(e,t){return!gt(e)||t&&Object.keys(t).some(e=>e.toLowerCase()===`x-ms-blob-type`)?t:{...t,"x-ms-blob-type":`BlockBlob`}}function vt(e){return new Promise(t=>setTimeout(t,e))}function yt(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 bt(e,t,n,r){let i=r?yt(r):void 0;if(i!==void 0)return i;let a=Math.min(n,t*2**e);return Math.floor(Math.random()*a)}const xt=new TextEncoder;function St(e){if(typeof e==`string`)return xt.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 Ct(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(St(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=ht}=t,c=await Ct(t.body),l=n.toUpperCase()===`PUT`?_t(e,r):r,u;for(let t=0;t<i;t++){let r=t===i-1;try{let i=await fetch(e,{method:n,headers:l,body:c});if(i.ok||!s.has(i.status)||r||(yt(i)??0)>6e4)return i;await i.body?.cancel().catch(()=>void 0),await vt(bt(t,a,o,i))}catch(e){if(u=e,r)throw e;await vt(bt(t,a,o))}}throw u instanceof Error?u:/* @__PURE__ */ Error(`Failed to fetch signed URL: ${e}`)}function wt(e){if(!e||typeof e!=`object`)return;let t=e.process_run_id;return typeof t==`string`?t:void 0}function Tt(e,t){let n=wt(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`?Tt(e.details,t):!1}function Et(e,t,r=!1){return e.t===n.TERMINATED||(e.t===n.COMPLETE||r&&e.t===n.IDLE)&&(e.w??`main`)===`main`?Tt(e.d,t):!1}function W(e){return e.replace(/#/g,`%23`).replace(/\?/g,`%3F`)}var Dt=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(Ot)}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`,{})}allocateBudget(e,t){return this.post(`/${e}/budget`,{payload:t})}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),d&&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=l,a=await this.retrieveMessages(e,r||void 0);n=!0;for(let n of a){if(d)return;let a=n.timestamp||0;if(!(a<=r)){if(l=Math.max(l,a),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(/* @__PURE__ */ 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),Et(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(/* @__PURE__ */ 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(/* @__PURE__ */ 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 Ot(e){return e.run_kind===`process`}var kt=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`)}},At=class extends I{constructor(e){super(e,`/api/v1/content`)}listSharedProjects(){return this.get(`/shared`)}sharedCollections(e,t){let n=t?`/shared/${e}/${t}`:`/shared/${e}`;return this.get(n,{query:{list:`collections`}})}sharedObjects(e,t,n){let r=t?`/shared/${e}/${t}`:`/shared/${e}`;return this.get(r,{query:{list:`objects`,from:n?.from,limit:n?.limit}})}getShared(e,t){return this.get(`/shared/${e}/${t}`)}getSharedRendition(e,t,n,r){return this.get(`/shared/${e}/${t}/renditions/${n}`,{query:{max_hw:r?.max_hw}})}getSharedFileUrl(e,t,n){return this.get(`/shared/${e}/${t}/file`,{query:{disposition:n}})}resolve(e){return this.get(`/resolve/${e}`)}search(e,t){return this.post(`/search`,{payload:e,query:{onlyShared:t?.onlyShared?`true`:void 0}})}managed(){return this.get(`/managed`)}},jt=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}`:``}`}},Mt=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()})}},Nt=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 Mt(this.client,e)}},Pt=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})}},Ft=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 It(e){return JSON.parse(e)}function Lt(e,t,n){let r=Math.min(t*2**e,n);return r+Math.random()*.1*r}function Rt(e,t){if(!t)return;let n=t.startsWith(`Bearer `)?t.slice(7):t;e.searchParams.set(`access_token`,n)}async function zt(e){let t=typeof e==`function`?await e():e;return t instanceof URL?new URL(t.href):new URL(t)}function Bt(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??It,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;m();let a=d?Date.now()-d:0;if(d=0,a>5e3&&(s=0),s>=n){h(),e.on_error?.(t);return}let c=Lt(s,r,i);s+=1,p(`reconnecting`),l=setTimeout(()=>{l=null,v(!0)},c)},_=(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 zt(e.url);if(f&&e.last_event_id_query_param&&i.searchParams.set(e.last_event_id_query_param,f),Rt(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 Vt(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 Ht=class extends I{constructor(e){super(e,`/api/v1/events/channels`)}list(e){return this.get(`/`,{query:Vt(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 Ut(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 Wt=class extends I{constructor(e){super(e,`/api/v1/events/subscriptions`)}list(e){return this.get(`/`,{query:Ut(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}`)}},Gt=class extends I{subscriptions;channels;constructor(e){super(e,`/api/v1/events`),this.subscriptions=new Wt(e),this.channels=new Ht(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 Bt({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(`,`))}},Kt=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 qt(e){return e?.split(`;`,1)[0]?.trim().toLowerCase()||void 0}function K(e){return qt(e)===`application/octet-stream`?void 0:e||void 0}function q(e,t){return K(e)||t||e||void 0}const Jt=`memories`,J=`agents`,Yt={attempts:3,methods:[`POST`],statuses:[502,503,504]};function Xt(e){try{let t=new URL(e);return`${t.protocol}//${t.host}${t.pathname}`}catch{return e.split(/[?#]/,1)[0]||`unknown file`}}function Zt(e){if(!(e instanceof Error))return;let t=e.message.replace(/https?:\/\/[^\s)\]}>"']+/g,e=>Xt(e)),n=Error(t);return n.name=e.name,n}function Qt(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=Xt(e),a=Qt(t,n);super(`File download ${a}: ${i}`,{cause:Zt(r)}),this.name=`FileDownloadError`,this.status=t}};function X(e){let t=e.endsWith(`.tar.gz`)?e:`${e}.tar.gz`;return`${Jt}/${t}`}function Z(e,t){return`${J}/${e}/${t}`}var $t=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:Yt})}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}},en=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,i){return this.zenoBulkPost(`/reindex/swap-alias`,{tenant_id:e,target_index:t,alias:n,backend:r,cleanup:i})}},tn=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??{}})}},nn=class extends I{constructor(e){super(e,`/api/v1/objects`)}analyze(e){return new tn(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})}},rn=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}`)}},an=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`,{})}},on=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}`)}},sn=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})}},cn=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 ln(n)}}};function ln(e){return new Promise(t=>setTimeout(t,e))}var un=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}})}},dn=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}`)}},fn=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}`)}},pn=class extends I{catalog;constructor(e){super(e,`/api/v1/types`),this.catalog=new fn(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}`)}},mn=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})}},hn=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),d&&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(/* @__PURE__ */ 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),Et(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,y(),s(/* @__PURE__ */ Error(`SSE connection failed after 10 reconnection attempts`))}}}catch(e){if(d)return;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 d=!0,y(),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(/* @__PURE__ */ 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(/* @__PURE__ */ 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 gn(this);definitions=new _n(this)},gn=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})}},_n=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 vn={serverUrl:!0,tokenServerUrl:!0,apikey:!0,onRequest:!0,onResponse:!0,retryPolicy:!0,timeout:!0,fetch:!0};function yn(e){if(!e)throw Error(`zeno client serverUrl is required`);return e}var bn=class extends Ce{constructor(e={}){mt(`ZenoClient`,e,vn),super(yn(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 Kt(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 Dt(this);cost=new jt(this);objects=new nn(this);content=new At(this);types=new pn(this);workflows=new hn(this);schedules=new un(this);processes=new an(this);processTestRuns=new on(this);tasks=new dn(this);files=new $t(this);collections=new kt(this);embeddings=new Ft(this);email=new Pt(this);events=new Gt(this);eventSubscriptions=this.events.subscriptions;pendingAsks=new rn(this);data=new Nt(this);indexing=new en(this);query=new sn(this);rendering=new cn(this);views=new mn(this)},xn=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}})}},Sn=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}})}},Cn=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}`)}},wn=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 Tn={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;static async fromAuthToken(t,n,r){if(!t?.trim())throw Error(`VertesiaClient.fromAuthToken requires a non-empty auth token`);n||=$(t);let i=r||jn(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`}){mt(`VertesiaClient`,e,Tn);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 bn({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 wn(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 Qe(this),this.oauthGrants=new et(this),this.oauthServer=new nt(this,this.tokenServerUrl),this.oauthProviders=new tt(this),this.remoteMcpConnections=new ct(this),this.secrets=new ut(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(!En(e))return`Bearer ${e}`;if(Dn(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 rt(this);interactionConfigurations=new ze(this);inferenceProfiles=new Re(this);environments=new Ne(this);interactions=new Ze(this);skills=new dt(this);prompts=new at(this);runs=new lt(this);account=new Te(this);accounts=new Ee(this);apikeys=new Oe(this);analytics=new De(this);auditTrail=new Ae(this);training=new Sn(this);delegationGrants=new Me(this);users=new Cn(this);iam=new Fe(this);refs=new st(this);commands=new je(this);apps=new ke(this);tools=new xn(this);quota=new ot(this);views};function En(e){return e.startsWith(`pk-`)||e.startsWith(`sk-`)}function Dn(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=An(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 On(){return globalThis.Buffer}function kn(){return globalThis.process?.env?.STS_URL}function An(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=On();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 jn(e){return e?typeof e==`string`?Mn(e):e:Mn(`api.vertesia.io`)}function Mn(e){if(e===`local`)return{studio:`http://localhost:8091`,store:`http://localhost:8092`,token:kn()??`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 Nn=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 Ve(this.client,this.id,e,t)}};export{e as APP_VERSION_HEADER,J as ARTIFACTS_PREFIX,Dt as AgentsApi,At as ContentApi,Nt as DataApi,Me as DelegationGrantsApi,Pt as EmailApi,Ft as EmbeddingsApi,Ht as EventIngestChannelsApi,Wt as EventSubscriptionsApi,Gt as EventsApi,Y as FileDownloadError,$t as FilesApi,R as IS_INTERACTION_OUTPUT,en as IndexingApi,Nn as InteractionBase,B as InteractionOutput,Jt as MEMORIES_PREFIX,Qe as OAuthClientsApi,et as OAuthGrantsApi,tt as OAuthProvidersApi,nt as OAuthServerApi,nn as ObjectsApi,rn as PendingAsksApi,s as Permission,an as ProcessApi,on as ProcessTestRunApi,sn as QueryApi,ct as RemoteMcpConnectionsApi,cn as RenderingApi,un as SchedulesApi,ut as SecretsApi,mn as StoreViewsApi,G as StreamSource,dn as TaskApi,fn as TypeCatalogApi,pn as TypesApi,Q as VertesiaClient,wn as ViewsApi,hn as WorkflowsApi,_n as WorkflowsDefinitionApi,gn as WorkflowsRulesApi,bn as ZenoClient,Kt as ZenoClientNotFoundError,u as canGenerateRendition,V as createInteractionOutput,jn as decodeEndpoints,$ as decodeJWT,qe as enhanceExecutionRun,z as enhanceInteractionExecutionResult,W as escapeArtifactPathDelimiters,H as fetchSignedUrl,Z as getAgentArtifactPath,X as getMemoryFilePath,d as getOAuthPermissionScopes,f as getSupportedRenditionFormats,gt as isAzureBlobUrl,Dn as isTokenExpired,Bt as openManagedEventSource,_t as signedUrlUploadHeaders,h as supportsVisualRendition};
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 Je(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 Ye(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||=/* @__PURE__ */ Error(`No JSON result found and no text available to parse`),t}function Xe(e){return!!e&&typeof e==`object`&&`id`in e&&typeof e.id==`string`}var Ze=class extends I{catalog;constructor(e){super(e,`/api/v1/interactions`),this.catalog=new Ke(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 Ve(this.client,e,t,n).catch(e=>{throw e instanceof x&&Xe(e.payload)?e.updateDetails({run_id:e.payload.id}):e}))}async executeByName(e,t={},n,r){return z(await He(this.client,e,t,n,r).catch(e=>{throw e instanceof x&&Xe(e.payload)?e.updateDetails({run_id:e.payload.id}):e}))}executeAsync(e){return We(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 Ge(this.client,e)}resolve(e,t){return this.get(`/resolve/${encodeURIComponent(e)}`,{query:t})}},Qe=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 $e(e){if(e)return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)]))}var et=class extends I{constructor(e){super(e,`/api/v1/oauth-grants`)}list(e){return this.get(`/`,{query:$e(e)})}retrieve(e){return this.get(`/${e}`)}revoke(e,t){return this.del(`/${e}`,{query:t})}revokeBulk(e){return this.post(`/revoke`,{payload:e})}},tt=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`)}},nt=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(/* @__PURE__ */ 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:{}})}},rt=class extends I{integrations;constructor(e){super(e,`/api/v1/projects`),this.integrations=new it(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})}},it=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`)}},at=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`)}},ot=class extends I{constructor(e){super(e,`/api/v1/quota`)}standing(){return this.get(`/standing`)}tier(){return this.get(`/tier`)}},st=class extends I{constructor(e){super(e,`/api/v1/refs`)}resolve(e){return this.post(`/resolve`,{payload:{refs:e}})}},ct=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}})}},lt=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 qe(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})}},ut=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})}},dt=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 ft={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"},pt=/* @__PURE__ */ new Set;function mt(e,t,n){let r=Object.keys(t).filter(e=>!Object.hasOwn(n,e)&&!pt.has(e));if(r.length===0)return;for(let e of r)pt.add(e);let i=r.map(e=>Object.hasOwn(ft,e)?`${e} (${ft[e]})`:e);console.warn(`[${e}] Ignoring unknown constructor option(s): ${i.join(`; `)}. Unknown options have no effect.`)}const ht=/* @__PURE__ */ new Set([429,500,502,503,504]);function gt(e){try{return new URL(e).hostname.toLowerCase().endsWith(`.blob.core.windows.net`)}catch{return!1}}function _t(e,t){return!gt(e)||t&&Object.keys(t).some(e=>e.toLowerCase()===`x-ms-blob-type`)?t:{...t,"x-ms-blob-type":`BlockBlob`}}function vt(e){return new Promise(t=>setTimeout(t,e))}function yt(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 bt(e,t,n,r){let i=r?yt(r):void 0;if(i!==void 0)return i;let a=Math.min(n,t*2**e);return Math.floor(Math.random()*a)}const xt=new TextEncoder;function St(e){if(typeof e==`string`)return xt.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 Ct(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(St(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=ht}=t,c=await Ct(t.body),l=n.toUpperCase()===`PUT`?_t(e,r):r,u;for(let t=0;t<i;t++){let r=t===i-1;try{let i=await fetch(e,{method:n,headers:l,body:c});if(i.ok||!s.has(i.status)||r||(yt(i)??0)>6e4)return i;await i.body?.cancel().catch(()=>void 0),await vt(bt(t,a,o,i))}catch(e){if(u=e,r)throw e;await vt(bt(t,a,o))}}throw u instanceof Error?u:/* @__PURE__ */ Error(`Failed to fetch signed URL: ${e}`)}function wt(e){if(!e||typeof e!=`object`)return;let t=e.process_run_id;return typeof t==`string`?t:void 0}function Tt(e,t){let n=wt(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`?Tt(e.details,t):!1}function Et(e,t,r=!1){return e.t===n.TERMINATED||(e.t===n.COMPLETE||r&&e.t===n.IDLE)&&(e.w??`main`)===`main`?Tt(e.d,t):!1}function W(e){return e.replace(/#/g,`%23`).replace(/\?/g,`%3F`)}var Dt=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(Ot)}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`,{})}allocateBudget(e,t){return this.post(`/${e}/budget`,{payload:t})}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),d&&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=l,a=await this.retrieveMessages(e,r||void 0);n=!0;for(let n of a){if(d)return;let a=n.timestamp||0;if(!(a<=r)){if(l=Math.max(l,a),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(/* @__PURE__ */ 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),Et(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(/* @__PURE__ */ 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(/* @__PURE__ */ 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 Ot(e){return e.run_kind===`process`}var kt=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`)}},At=class extends I{constructor(e){super(e,`/api/v1/content`)}listSharedProjects(){return this.get(`/shared`)}sharedCollections(e,t){let n=t?`/shared/${e}/${t}`:`/shared/${e}`;return this.get(n,{query:{list:`collections`}})}sharedObjects(e,t,n){let r=t?`/shared/${e}/${t}`:`/shared/${e}`;return this.get(r,{query:{list:`objects`,from:n?.from,limit:n?.limit}})}getShared(e,t){return this.get(`/shared/${e}/${t}`)}getSharedRendition(e,t,n,r){return this.get(`/shared/${e}/${t}/renditions/${n}`,{query:{max_hw:r?.max_hw}})}getSharedFileUrl(e,t,n){return this.get(`/shared/${e}/${t}/file`,{query:{disposition:n}})}resolve(e){return this.get(`/resolve/${e}`)}search(e,t){return this.post(`/search`,{payload:e,query:{onlyShared:t?.onlyShared?`true`:void 0}})}managed(){return this.get(`/managed`)}},jt=class extends I{constructor(e){super(e,`/api/v1/cost`)}getAnalytics(e={}){return this.post(`/analytics`,{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}`:``}`}},Mt=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()})}},Nt=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 Mt(this.client,e)}},Pt=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})}},Ft=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 It(e){return JSON.parse(e)}function Lt(e,t,n){let r=Math.min(t*2**e,n);return r+Math.random()*.1*r}function Rt(e,t){if(!t)return;let n=t.startsWith(`Bearer `)?t.slice(7):t;e.searchParams.set(`access_token`,n)}async function zt(e){let t=typeof e==`function`?await e():e;return t instanceof URL?new URL(t.href):new URL(t)}function Bt(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??It,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;m();let a=d?Date.now()-d:0;if(d=0,a>5e3&&(s=0),s>=n){h(),e.on_error?.(t);return}let c=Lt(s,r,i);s+=1,p(`reconnecting`),l=setTimeout(()=>{l=null,v(!0)},c)},_=(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 zt(e.url);if(f&&e.last_event_id_query_param&&i.searchParams.set(e.last_event_id_query_param,f),Rt(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 Vt(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 Ht=class extends I{constructor(e){super(e,`/api/v1/events/channels`)}list(e){return this.get(`/`,{query:Vt(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 Ut(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 Wt=class extends I{constructor(e){super(e,`/api/v1/events/subscriptions`)}list(e){return this.get(`/`,{query:Ut(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}`)}},Gt=class extends I{subscriptions;channels;constructor(e){super(e,`/api/v1/events`),this.subscriptions=new Wt(e),this.channels=new Ht(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 Bt({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(`,`))}},Kt=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 qt(e){return e?.split(`;`,1)[0]?.trim().toLowerCase()||void 0}function K(e){return qt(e)===`application/octet-stream`?void 0:e||void 0}function q(e,t){return K(e)||t||e||void 0}const Jt=`memories`,J=`agents`,Yt={attempts:3,methods:[`POST`],statuses:[502,503,504]};function Xt(e){try{let t=new URL(e);return`${t.protocol}//${t.host}${t.pathname}`}catch{return e.split(/[?#]/,1)[0]||`unknown file`}}function Zt(e){if(!(e instanceof Error))return;let t=e.message.replace(/https?:\/\/[^\s)\]}>"']+/g,e=>Xt(e)),n=Error(t);return n.name=e.name,n}function Qt(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=Xt(e),a=Qt(t,n);super(`File download ${a}: ${i}`,{cause:Zt(r)}),this.name=`FileDownloadError`,this.status=t}};function X(e){let t=e.endsWith(`.tar.gz`)?e:`${e}.tar.gz`;return`${Jt}/${t}`}function Z(e,t){return`${J}/${e}/${t}`}var $t=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:Yt})}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}},en=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,i){return this.zenoBulkPost(`/reindex/swap-alias`,{tenant_id:e,target_index:t,alias:n,backend:r,cleanup:i})}},tn=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??{}})}},nn=class extends I{constructor(e){super(e,`/api/v1/objects`)}analyze(e){return new tn(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})}},rn=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}`)}},an=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`,{})}},on=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}`)}},sn=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})}},cn=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 ln(n)}}};function ln(e){return new Promise(t=>setTimeout(t,e))}var un=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}})}},dn=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}`)}},fn=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}`)}},pn=class extends I{catalog;constructor(e){super(e,`/api/v1/types`),this.catalog=new fn(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}`)}},mn=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})}},hn=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),d&&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(/* @__PURE__ */ 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),Et(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,y(),s(/* @__PURE__ */ Error(`SSE connection failed after 10 reconnection attempts`))}}}catch(e){if(d)return;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 d=!0,y(),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(/* @__PURE__ */ 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(/* @__PURE__ */ 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 gn(this);definitions=new _n(this)},gn=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})}},_n=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 vn={serverUrl:!0,tokenServerUrl:!0,apikey:!0,onRequest:!0,onResponse:!0,retryPolicy:!0,timeout:!0,fetch:!0};function yn(e){if(!e)throw Error(`zeno client serverUrl is required`);return e}var bn=class extends Ce{constructor(e={}){mt(`ZenoClient`,e,vn),super(yn(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 Kt(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 Dt(this);cost=new jt(this);objects=new nn(this);content=new At(this);types=new pn(this);workflows=new hn(this);schedules=new un(this);processes=new an(this);processTestRuns=new on(this);tasks=new dn(this);files=new $t(this);collections=new kt(this);embeddings=new Ft(this);email=new Pt(this);events=new Gt(this);eventSubscriptions=this.events.subscriptions;pendingAsks=new rn(this);data=new Nt(this);indexing=new en(this);query=new sn(this);rendering=new cn(this);views=new mn(this)},xn=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}})}},Sn=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}})}},Cn=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}`)}},wn=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 Tn={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;static async fromAuthToken(t,n,r){if(!t?.trim())throw Error(`VertesiaClient.fromAuthToken requires a non-empty auth token`);n||=$(t);let i=r||jn(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`}){mt(`VertesiaClient`,e,Tn);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 bn({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 wn(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 Qe(this),this.oauthGrants=new et(this),this.oauthServer=new nt(this,this.tokenServerUrl),this.oauthProviders=new tt(this),this.remoteMcpConnections=new ct(this),this.secrets=new ut(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(!En(e))return`Bearer ${e}`;if(Dn(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 rt(this);interactionConfigurations=new ze(this);inferenceProfiles=new Re(this);environments=new Ne(this);interactions=new Ze(this);skills=new dt(this);prompts=new at(this);runs=new lt(this);account=new Te(this);accounts=new Ee(this);apikeys=new Oe(this);analytics=new De(this);auditTrail=new Ae(this);training=new Sn(this);delegationGrants=new Me(this);users=new Cn(this);iam=new Fe(this);refs=new st(this);commands=new je(this);apps=new ke(this);tools=new xn(this);quota=new ot(this);views};function En(e){return e.startsWith(`pk-`)||e.startsWith(`sk-`)}function Dn(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=An(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 On(){return globalThis.Buffer}function kn(){return globalThis.process?.env?.STS_URL}function An(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=On();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 jn(e){return e?typeof e==`string`?Mn(e):e:Mn(`api.vertesia.io`)}function Mn(e){if(e===`local`)return{studio:`http://localhost:8091`,store:`http://localhost:8092`,token:kn()??`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 Nn=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 Ve(this.client,this.id,e,t)}};export{e as APP_VERSION_HEADER,J as ARTIFACTS_PREFIX,Dt as AgentsApi,At as ContentApi,Nt as DataApi,Me as DelegationGrantsApi,Pt as EmailApi,Ft as EmbeddingsApi,Ht as EventIngestChannelsApi,Wt as EventSubscriptionsApi,Gt as EventsApi,Y as FileDownloadError,$t as FilesApi,R as IS_INTERACTION_OUTPUT,en as IndexingApi,Nn as InteractionBase,B as InteractionOutput,Jt as MEMORIES_PREFIX,Qe as OAuthClientsApi,et as OAuthGrantsApi,tt as OAuthProvidersApi,nt as OAuthServerApi,nn as ObjectsApi,rn as PendingAsksApi,s as Permission,an as ProcessApi,on as ProcessTestRunApi,sn as QueryApi,ct as RemoteMcpConnectionsApi,cn as RenderingApi,un as SchedulesApi,ut as SecretsApi,mn as StoreViewsApi,G as StreamSource,dn as TaskApi,fn as TypeCatalogApi,pn as TypesApi,Q as VertesiaClient,wn as ViewsApi,hn as WorkflowsApi,_n as WorkflowsDefinitionApi,gn as WorkflowsRulesApi,bn as ZenoClient,Kt as ZenoClientNotFoundError,u as canGenerateRendition,V as createInteractionOutput,jn as decodeEndpoints,$ as decodeJWT,qe as enhanceExecutionRun,z as enhanceInteractionExecutionResult,W as escapeArtifactPathDelimiters,H as fetchSignedUrl,Z as getAgentArtifactPath,X as getMemoryFilePath,d as getOAuthPermissionScopes,f as getSupportedRenditionFormats,gt as isAzureBlobUrl,Dn as isTokenExpired,Bt as openManagedEventSource,_t as signedUrlUploadHeaders,h as supportsVisualRendition};
13
13
  //# sourceMappingURL=vertesia-client.js.map