@vertesia/client 1.0.0-dev.20260225.024852Z → 1.0.0-dev.20260227.112605Z
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/ProjectsApi.js +8 -0
- package/lib/cjs/ProjectsApi.js.map +1 -1
- package/lib/esm/ProjectsApi.js +8 -0
- package/lib/esm/ProjectsApi.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/ProjectsApi.d.ts +3 -1
- package/lib/types/ProjectsApi.d.ts.map +1 -1
- package/lib/vertesia-client.js +1 -1
- package/lib/vertesia-client.js.map +1 -1
- package/package.json +5 -5
- package/src/ProjectsApi.ts +11 -1
package/lib/vertesia-client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ExecutionRunStatus as t,DataStoreApiHeaders as e,ContentObjectApiHeaders as s,canGenerateRendition as r,WorkflowExecutionStatus as n,isWorkflowTerminalStatus as i,toAgentMessage as a,AgentMessageType as o,parseMessage as l}from"@vertesia/common";export{canGenerateRendition,getSupportedRenditionFormats,supportsVisualRendition}from"@vertesia/common";class u extends Error{constructor(t,e,s,r,n=!0){super(function(t,e,s,r,n){let i=t;if(n){i+="\nRequest: "+e.method+" "+e.url+" => "+s;const t=r?.details||r?.error?.details;if(t){const e=typeof t;"string"===e?i+="\nDetails: "+t:"object"===e&&(i+="\nDetails: "+JSON.stringify(t,void 0,2))}i+="\nStack Trace: "}return i}(t,e,s,r,n)),this.original_message=t,this.request=e,this.status=s,this.payload=r,this.request_info=e.method+" "+e.url+" => "+s,this.displayDetails=n}get details(){return this.payload?.details||this.payload?.error?.details}}class c extends u{constructor(t,e,s,r,n=!0){super(t,e,s,r,n)}updateDetails(t){return t!==this.details?new c(this.original_message,this.request,this.status,{...this.payload,details:t},this.displayDetails):this}}class h extends u{constructor(t,e){super("Failed to connect to server: "+e.message,t,0,e)}}let p;if(globalThis.TextDecoderStream&&"function"==typeof globalThis.TextDecoderStream)p=globalThis.TextDecoderStream;else{class t extends TransformStream{constructor(t="utf-8",{fatal:s=!1,ignoreBOM:r=!1}={}){super(new e(new TextDecoder(t,{fatal:s,ignoreBOM:r}))),this._options={fatal:s,ignoreBOM:r,encoding:t}}get encoding(){return this._options.encoding}get fatal(){return this._options.fatal}get ignoreBOM(){return this._options.ignoreBOM}}class e{constructor(t){this.decoder=t}transform(t,e){if(!(t instanceof ArrayBuffer||ArrayBuffer.isView(t)))throw new TypeError("Input must be a compatible with: ArrayBuffer | Uint8Array");const s=this.decoder.decode(t,{stream:!0});0!==s.length&&e.enqueue(s)}flush(t){const e=this.decoder.decode();0!==e.length&&t.enqueue(e)}}p=t}const d=[239,187,191];class g extends TransformStream{constructor(){let t;super({start(e){t=function(t){let e,s,r,n,i,a,o;return l(),{feed:function(t){s=s?s+t:t,e&&function(t){return d.every((e,s)=>t.charCodeAt(s)===e)}(s)&&(s=s.slice(d.length)),e=!1;const i=s.length;let a=0,o=!1;for(;a<i;){o&&("\n"===s[a]&&++a,o=!1);let t,e=-1,l=n;for(let n=r;e<0&&n<i;++n)t=s[n],":"===t&&l<0?l=n-a:"\r"===t?(o=!0,e=n-a):"\n"===t&&(e=n-a);if(e<0){r=i-a,n=l;break}r=0,n=-1,u(s,a,l,e),a+=e+1}a===i?s="":a>0&&(s=s.slice(a))},reset:l};function l(){e=!0,s="",r=0,n=-1,i=void 0,a=void 0,o=""}function u(e,s,r,n){if(0===n)return o.length>0&&(t({type:"event",id:i,event:a||void 0,data:o.slice(0,-1)}),o="",i=void 0),void(a=void 0);const l=r<0,u=e.slice(s,s+(l?n:r));let c=0;c=l?n:" "===e[s+r+1]?r+2:r+1;const h=s+c,p=n-c,d=e.slice(h,h+p).toString();if("data"===u)o+=d?"".concat(d,"\n"):"\n";else if("event"===u)a=d;else if("id"!==u||d.includes("\0")){if("retry"===u){const e=parseInt(d,10);Number.isNaN(e)||t({type:"reconnect-interval",value:e})}}else i=d}}(t=>{"event"===t.type&&e.enqueue(t)})},transform(e){t.feed(e)}})}}function y(t){return"/"===t[t.length-1]?t.slice(0,-1):t}class m{constructor(t,e){this.errorFactory=t=>t,this.verboseErrors=!0,this.baseUrl=y(t),this._fetch=function(t){return t?Promise.resolve(t):"function"==typeof globalThis.fetch?Promise.resolve(globalThis.fetch):Promise.resolve(()=>{throw new Error("No Fetch implementation found")})}(e)}throwError(t){throw this.errorFactory(t)}getUrl(t){return y((e=this.baseUrl,s=t,e.endsWith("/")?s.startsWith("/")?e+s.substring(1):e+s:s.startsWith("/")?e+s:e+"/"+s));var e,s}get(t,e){return this.request("GET",t,e)}del(t,e){return this.request("DELETE",t,e)}delete(t,e){return this.request("DELETE",t,e)}post(t,e){return this.request("POST",t,e)}put(t,e){return this.request("PUT",t,e)}jsonParse(t){return JSON.parse(t)}createRequest(t,e){return Promise.resolve(new Request(t,e))}createServerError(t,e,s){let r="Server Error: "+e.status;return s&&(s.message?r=String(s.message):s.error&&("string"==typeof s.error?r=String(s.error):"string"==typeof s.error.message&&(r=String(s.error.message)))),new c(r,t,e.status,s,this.verboseErrors)}async readJSONPayload(t){return t.text().then(e=>{if(e)try{return this.jsonParse(e)}catch(s){return{status:t.status,error:"Not a valid JSON payload",message:s.message,text:e}}}).catch(e=>({status:t.status,error:"Unable to load response content",message:e.message}))}handleResponse(t,e,s){return e.url,s&&s.reader?"sse"===s.reader?async function(t){if(!t.ok){const e=await t.text(),s=new Error("SSE error: "+t.status+". Content:\n"+e);throw s.status=t.status,s}if(!t.body)throw new Error("No body in response");return t.body.pipeThrough(new p).pipeThrough(new g)}(e):s.reader.call(this,e):this.readJSONPayload(e).then(s=>{if(e.ok)return s;this.throwError(this.createServerError(t,e,s))})}async request(t,e,s){let r=this.getUrl(e);s?.query&&(r+="?"+function(t){const e=[];for(const s of Object.keys(t)){const r=t[s];null!=r&&e.push(encodeURIComponent(s)+"="+encodeURIComponent(String(r)))}return e.join("&")}(s.query));const n=this.headers?Object.assign({},this.headers):{},i=s?.headers;if(i)for(const t in i)n[t.toLowerCase()]=i[t];let a;const o=s?.payload;o&&(s&&!1===s.jsonPayload?a=o:(a="string"!=typeof o?JSON.stringify(o):o,"content-type"in n||(n["content-type"]="application/json")));const l={method:t,headers:n,body:a},u=await this.createRequest(r,l);return this._fetch.then(t=>t(u).catch(t=>{console.error(`Failed to connect to ${r}`,t),this.throwError(new h(u,t))}).then(t=>this.handleResponse(u,t,s)))}fetch(t,e){return this._fetch.then(s=>s(t,e))}}class f extends m{constructor(t,e){super(t,e),this.baseUrl="/"===t[t.length-1]?t.substring(0,t.length-1):t,this.headers=this.initialHeaders}get initialHeaders(){return{accept:"application/json"}}withAuthCallback(t){return this._auth=t||void 0,this}withErrorFactory(t){return this.errorFactory=t,this}withLang(t){return t?this.headers["accept-language"]=t:delete this.headers["accept-language"],this}withHeaders(t){const e=this.headers;for(const s in t){const r=t[s];null!=r&&(e[s.toLowerCase()]=r)}return this}setHeader(t,e){e?this.headers[t.toLowerCase()]=e:delete this.headers[t.toLowerCase()]}async createRequest(t,e){if(this._auth&&(!(s=e.headers)||!("authorization"in s))){const t=e.headers?e.headers:{};e.headers=t;const s=await this._auth();s&&(e.headers.authorization=s)}var s;this.response=void 0;const r=await super.createRequest(t,e);return this.onRequest&&this.onRequest(r),r}async handleResponse(t,e,s){return this.response=e,this.onResponse&&this.onResponse(e,t),super.handleResponse(t,e,s)}}class w extends m{constructor(t,e){super(t.getUrl(e),t._fetch),this.client=t,this.createServerError=t.createServerError,this.errorFactory=t.errorFactory,this.verboseErrors=t.verboseErrors}createRequest(t,e){return this.client.createRequest(t,e)}handleResponse(t,e,s){return this.client.handleResponse(t,e,s)}get headers(){return this.client.headers}}class v extends w{constructor(t){super(t,"/api/v1/account")}info(){return this.get("/")}update(t){return this.put("/",{payload:t})}projects(){return this.get("/projects").then(t=>t.data)}members(){return this.get("/members")}inviteUser(t){return this.post("/invites",{payload:t})}listInvites(){return this.get("/invites")}listInvitation(t="project"){return this.get(`/invites/${t}`)}acceptInvite(t){return this.put(`/invites/${t}`)}rejectInvite(t){return this.delete(`/invites/${t}`)}onboardingProgress(){return this.get("/onboarding")}getGoogleToken(){return this.get("/google-token")}getStripeBillingStatus(){return this.get("/stripe-billing-status")}}class $ extends w{constructor(t){super(t,"/api/v1/accounts")}create(t){return this.post("/",{payload:{name:t}})}list(){return this.get("/")}}class b extends w{constructor(t){super(t,"/api/v1/analytics")}runsSummary(t,e){const s=new URLSearchParams;t?.start&&s.set("start",t.start),t?.end&&s.set("end",t.end),e&&s.set("environment",e);const r=s.toString();return this.get("/runs/summary"+(r?"?"+r:""))}runsTimeSeries(t,e){const s=new URLSearchParams;t?.start&&s.set("start",t.start),t?.end&&s.set("end",t.end),e&&s.set("environment",e);const r=s.toString();return this.get("/runs/time-series"+(r?"?"+r:""))}runsTokenUsage(t){const e=new URLSearchParams;t?.start&&e.set("start",t.start),t?.end&&e.set("end",t.end);const s=e.toString();return this.get("/runs/token-usage"+(s?"?"+s:""))}}class S extends w{constructor(t){super(t,"/api/v1/audit-trail")}list(t){const e=new URLSearchParams;t?.actions?.length&&e.set("actions",t.actions.join(",")),t?.resourceTypes?.length&&e.set("resourceTypes",t.resourceTypes.join(",")),t?.resourceId&&e.set("resourceId",t.resourceId),t?.principalId&&e.set("principalId",t.principalId),t?.principalUserId&&e.set("principalUserId",t.principalUserId),t?.projectId&&e.set("projectId",t.projectId),t?.from&&e.set("from",t.from),t?.to&&e.set("to",t.to),t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset));const s=e.toString();return this.get("/"+(s?"?"+s:""))}}class x extends w{constructor(t){super(t,"/api/v1/apikeys")}list(t="account"){return this.get("/",{query:{level:t}})}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}retrieve(t,e=!1){return e?this.get(`/${t}`,{query:{withValue:!0}}):this.get(`/${t}`)}requestPublicKey(t={}){return this.get("/pk",{query:t})}}class k extends w{constructor(t){super(t,"/api/v1/apps")}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}listAppInstallationTools(t){return this.get(`/installations/${t}/tools`)}list(){return this.get("/")}install(t,e){return this.post("/install",{payload:{app_id:t,settings:e}})}uninstall(t){return this.del(`/install/${t}`)}getAppInstallationByName(t){return this.get(`/installations/name/${t}`).catch(t=>{if(404===t.status)return null;throw t})}getAppInstallationProjects(t){if(!t.id&&!t.name)throw new Error("Invalid arguments: appId or appName must be specified");const e=t.id?{id:t.id}:{name:t.name};return this.get("/installations/projects",{query:e})}getInstalledApps(t){return this.get("/installations",{query:{kind:t}})}getAllAppInstallations(){return this.get("/installations/all")}listInstallations(){return this.get("/installations/refs")}updateInstallationSettings(t){return this.put(`/installations/settings/${t.app_id}`,{payload:{app_id:t.app_id,settings:t.settings}})}}let T=class extends w{constructor(t){super(t,"/api/v1/commands")}async isNamespaceAvailable(t){return this.get(`/namespaces/${t}/is_available`).then(t=>t.available)}async initSamples(){return this.post("/onboarding/init-samples")}};class _ extends w{constructor(t){super(t,"/api/v1/environments")}list(t=!1){const e=t?{all:!0}:void 0;return this.get("/",{query:e})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get("/"+t)}update(t,e){return this.put("/"+t,{payload:e})}updateConfig(t,e){return this.put("/"+t+"/config",{payload:e})}listModels(t,e){return this.get("/"+t+"/models",{query:e?{...e}:void 0})}listTrainableModels(t){return this.get(`/${t}/trainable-models`)}embeddings(t,e){return this.post("/"+t+"/embeddings",{payload:e})}migrateInteractions(t){return this.post("/migrate-interactions",{payload:t})}}class E extends w{constructor(t){super(t,"/groups")}list(t){return this.get("/",{query:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get("/"+t)}update(t,e){return this.put("/"+t,{payload:e})}delete(t){return this.del("/"+t)}listMembers(t){return this.get("/"+t+"/members")}addMember(t,e){return this.post("/"+t+"/members/"+e)}removeMember(t,e){return this.del("/"+t+"/members/"+e)}}class R extends w{constructor(t){super(t,"/api/v1/iam"),this.aces=new I(this),this.roles=new q(this),this.groups=new E(this)}}class q extends w{constructor(t){super(t,"/roles")}list(){return this.get("/")}}class I extends w{constructor(t){super(t,"/aces")}list(t){return this.get("/",{query:{...t}})}retrieve(t){return this.get("/"+t)}create(t){return this.post("/",{payload:t})}delete(t){return this.del("/"+t)}}async function U(){return"function"==typeof globalThis.EventSource?globalThis.EventSource:(await import("eventsource")).EventSource}async function A(e,s,r={},n){const i=!!n,a=await e.runs.create({...r,interaction:s,stream:i});if(i){if(a.status===t.failed)return a;await P(e,a.id,n)}return a}function P(t,e,s){return new Promise(async(r,n)=>{try{const i=await U(),a=new URL(t.runs.baseUrl+"/"+e+"/stream"),o=t._auth?await t._auth():void 0;if(!o)throw new Error("No auth token available");{const t=o.split(" ")[1];a.searchParams.set("access_token",t)}const l=new i(a.href);l.addEventListener("message",t=>{try{const e=JSON.parse(t.data);e&&s&&s(e)}catch(t){n(t)}}),l.addEventListener("close",t=>{try{l.close();const e=JSON.parse(t.data);r(e)}catch(t){n(t)}})}catch(t){n(t)}})}class j extends w{constructor(t){super(t,"/api/v1/interactions/catalog")}list(t={}){return this.get("/",{query:t})}listStoredInteractions(t={}){return this.get("/stored",{query:t})}listSysInteractions(t){return this.get("/sys",{query:{tag:t}})}listAppInteractions(t,e){return this.get(`/apps/${t}`,{query:{tag:e}})}listAllAppInteractions(t){return this.get("/apps",{query:{tag:t}})}resolve(t){return this.get(`/resolve/${t}`)}}const O=Symbol("InteractionOutput");function C(t){return t.result=D.from(t.result),t}function F(t){return t.result=D.from(t.result),t}class D{constructor(t){this.results=t}static from(t){return t?t[O]?t:Array.isArray(t)?M(t):M("object"==typeof t?[{type:"json",value:t}]:[{type:"text",value:String(t)}]):M([])}static isInteractionOutputArray(t){return t&&!0===t[O]}get isEmpty(){return 0===this.results.length}hasObject(){return this.results.some(t=>"json"===t.type)}hasText(){return this.results.some(t=>"text"===t.type)}hasImage(){return this.results.some(t=>"image"===t.type)}text(t="\n"){return this.results.filter(t=>"text"===t.type).map(t=>t.value).join(t)}texts(){return this.results.filter(t=>"text"===t.type).map(t=>t.value)}object(){const t=this.results.find(t=>"json"===t.type);return t?t.value:function(t){let e;for(const s of t)if("text"===s.type){const t=s.value.trim();try{return JSON.parse(t)}catch(t){e=t}}e||(e=new Error("No JSON result found and no text available to parse"));throw e}(this.results)}objects(){return this.results.filter(t=>"json"===t.type).map(t=>t.value)}objectAt(t){let e=0;for(const s of this.results)if("json"===s.type){if(e===t)return s.value;e++}throw new Error(`Object at index ${t} not found`)}image(){const t=this.results.find(t=>"image"===t.type);if(!t)throw new Error("No image result found");return t.value}images(){return this.results.filter(t=>"image"===t.type).map(t=>t.value)}stringify(t="\n",e=2){return this.results.map(t=>"json"===t.type?JSON.stringify(t.value,null,e):String(t.value)).join(t)}toString(){return this.text()}toJSON(){return this.results}}function M(t){const e=new D(t);return new Proxy(t,{get(t,s,r){if(s===O)return!0;if(s in e){const t=e[s];return"function"==typeof t?t.bind(e):t}return Reflect.get(t,s,r)}})}class N extends w{constructor(t){super(t,"/api/v1/interactions"),this.catalog=new j(t)}list(t={}){const e=t.query||{};return this.get("/",{query:{...e}})}listEndpoints(t){return this.post("/endpoints",{payload:t})}listVersionsByName(t){return this.get(`/versions/${t}`)}listTags(t){return this.get("/tags",{query:{...t}})}computeFacets(t){return this.post("/facets",{payload:t})}listNames(){return this.get("/names")}export(t){return this.post("/export",{payload:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}async execute(t,e={},s){return C(await A(this.client,t,e,s).catch(t=>{throw t instanceof c&&t.payload?.id?t.updateDetails({run_id:t.payload.id}):t}))}async executeByName(e,s={},r){const n=await async function(e,s,r={},n){const i=!!n,a=await e.post("/api/v1/execute",{payload:{...r,interaction:s,stream:i}});if(i){if(a.status===t.failed)return a;await P(e,a.id,n)}return a}(this.client,e,s,r).catch(t=>{throw t instanceof c&&t.payload?.id?t.updateDetails({run_id:t.payload.id}):t});return C(n)}executeAsync(t){return async function(t,e){return await t.post("/api/v1/execute/async",{payload:e})}(this.client,t)}publish(t,e){return this.post(`/${t}/publish`,{payload:e})}fork(t,e){return this.post(`/${t}/fork`,{payload:e})}generateInteraction(t,e){return this.post(`${t}/generate-interaction`,{payload:e})}generateTestData(t,e){return this.post(`${t}/generate-test-data`,{payload:e})}async suggestImprovements(t,e){return F(await this.post(`${t}/suggest-prompt-improvements`,{payload:e}))}async suggestPromptImprovements(t){return C(await this.post("/improve",{payload:t}))}listVersions(t){return this.get(`/${t}/versions`)}listForks(t){return this.get(`/${t}/forks`)}requestSlot(t){return async function(t,e){return await t.post("/api/v1/execute/rate-limit/request",{payload:e})}(this.client,t)}resolve(t,e){return this.get(`/resolve/${encodeURIComponent(t)}`,{query:e})}}class H extends w{constructor(t){super(t,"/api/v1/mcp/oauth")}getStatus(t){return this.get(`/status/${t}`)}getCollectionStatus(t,e){return this.get(`/status/${t}/${e}`)}getMetadata(t,e){return this.get(`/metadata/${t}/${e}`)}authorize(t,e){return this.get(`/authorize/${t}/${e}`)}disconnect(t){return this.del(`/disconnect/${encodeURIComponent(t)}`)}getToken(t){return this.post("/token",{payload:{mcp_server_url:t}})}}class L extends w{constructor(t){super(t,"/api/v1/projects"),this.integrations=new W(this)}list(t){return this.get("/",{query:{account:t}})}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}updateConfiguration(t,e){return this.put(`/${t}/configuration`,{payload:e})}getTools(t){return this.get(`/${t}/tools`)}getToolByName(t,e){return this.get(`/${t}/tools/${e}`).catch(t=>{if(404===t.status)return null;throw t})}listAppContentTypes(t,e){return this.get(`/${t}/app-types`,{query:{tag:e}})}getAppContentType(t,e){return this.get(`/${t}/app-types/${e}`)}getCompositeAppConfiguration(t){return this.get(`/${t}/composite-app`)}updateCompositeAppConfiguration(t,e){return this.put(`/${t}/composite-app`,{payload:e})}}class W extends w{constructor(t){super(t,"/")}list(t){return this.get(`/${t}/integrations`).then(t=>t.integrations)}retrieve(t,e){return this.get(`/${t}/integrations/${e}`).catch(t=>{if(404!==t.status)throw t})}update(t,e,s){return this.put(`/${t}/integrations/${e}`,{payload:s})}}class B extends w{constructor(t){super(t,"/api/v1/skills")}findRelevant(t,e){const s={context:t,limit:e};return this.post("/find-relevant",{payload:s})}findRelevantForTask(t,e){return this.findRelevant({task_description:t,tool_names:e})}}class J extends w{constructor(t){super(t,"/api/v1/prompts")}list(t={}){const e=t.query||{};return this.get("/",{query:{...e}})}computeFacets(t){return this.post("/facets",{payload:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}fork(t,e){return this.post(`/${t}/fork`,{payload:e})}render(t,e){return this.post(`/${t}/render`,{payload:e})}options(t){return this.get(`/options/${t}`)}listVersions(t){return this.get(`/${t}/versions`)}listInteractions(t){return this.get(`/${t}/interactions`)}listForks(t){return this.get(`/${t}/forks`)}}class V extends w{constructor(t){super(t,"/api/v1/refs")}resolve(t){return this.post("/resolve",{payload:{refs:t}})}}class z extends w{constructor(t){super(t,"/api/v1/runs")}list({limit:t,offset:e,filters:s}){const r={limit:t,offset:e,...s};return this.get("/",{query:r})}find(t){return this.post("/find",{payload:t})}async retrieve(t){return F(await this.get("/"+t))}retrievePopulated(t){return this.get("/"+t,{query:{populate:"true"}})}filterOptions(t,e){const s={...e};return this.get(`/filter-options/${t}`,{query:s})}async create(t){const e=this.client.sessionTags;if(e){let s=Array.isArray(e)?e:[e];Array.isArray(t.tags)?s=s.concat(t.tags):t.tags&&(s=s.concat([t.tags])),t={...t,tags:s}}return F(await this.post("/",{payload:t}))}sendToolResults(t){return this.post("/tool-results",{payload:t})}sendUserMessage(t){return this.post("/user-message",{payload:t})}computeFacets(t){return this.post("/facets",{payload:t})}search(t){return this.post("/search",{payload:t})}}class G extends w{constructor(t){super(t,"/api/v1/collections")}search(t){return this.post("/search",{payload:t})}computeListFacets(t){return this.post("/facets",{payload:t})}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}addMembers(t,e){return this.post(`/${t}/members`,{payload:{action:"add",members:e}})}listMembers(t,e){return this.get(`/${t}/members`,{query:{...e}})}computeFacets(t,e){return this.post(`/${t}/facets`,{payload:e})}searchMembers(t,e){return this.post(`/${t}/search`,{payload:e})}deleteMembers(t,e){return this.post(`/${t}/members`,{payload:{action:"delete",members:e}})}addChildren(t,e){return this.post(`/${t}/children`,{payload:{action:"add",children:e}})}deleteChildren(t,e){return this.post(`/${t}/children`,{payload:{action:"delete",children:e}})}searchChildren(t,e={}){return this.post(`/${t}/children/search`,{payload:e})}delete(t){return this.del(`/${t}`)}updatePermissions(t,e){return this.put(`/${t}/permissions`,{payload:e})}propagatePermissions(t){return this.post(`/${t}/propagate-permissions`)}propagateSharedProperties(t){return this.post(`/${t}/propagate-shared-props`)}}class K extends w{constructor(t,e="/api/v1/embeddings"){super(t,e)}async status(t){return this.get(t+"/status")}async activate(t,e){if(!e.environment)throw new Error("Invalid configuration: select environment");return this.post(t+"/enable",{payload:e})}async disable(t){return this.post(t+"/disable")}async recalculate(t){return this.post(t+"/recalculate")}}class Q extends w{constructor(t){super(t,"/api/v1/commands"),this.embeddings=new K(this,"/embeddings")}}class Y extends w{constructor(t,e){super(t,`/api/v1/data/${e}/dashboards`),this.storeId=e}storeHeaders(){return{[e.DATA_STORE_ID]:this.storeId}}list(t){const e=t?`?status=${t}`:"";return this.get(`/${e}`,{headers:this.storeHeaders()})}create(t){return this.post("/",{payload:t,headers:this.storeHeaders()})}retrieve(t){return this.get(`/${t}`,{headers:this.storeHeaders()})}update(t,e){return this.put(`/${t}`,{payload:e,headers:this.storeHeaders()})}delete(t){return this.del(`/${t}`,{headers:this.storeHeaders()})}bulkArchive(t){return this.post("/bulk/archive",{payload:{ids:t},headers:this.storeHeaders()})}bulkDelete(t){return this.post("/bulk/delete",{payload:{ids:t},headers:this.storeHeaders()})}listVersions(t,e){const s=new URLSearchParams;e?.snapshotsOnly&&s.set("snapshots_only","true"),e?.limit&&s.set("limit",String(e.limit));const r=s.toString()?`?${s}`:"";return this.get(`/${t}/versions${r}`,{headers:this.storeHeaders()})}getVersion(t,e){return this.get(`/${t}/versions/${e}`,{headers:this.storeHeaders()})}createSnapshot(t,e){return this.post(`/${t}/versions`,{payload:e,headers:this.storeHeaders()})}promoteVersion(t,e,s){return this.post(`/${t}/versions/${e}/promote`,{payload:s||{},headers:this.storeHeaders()})}setVersioningEnabled(t,e){return this.put(`/${t}/versioning`,{payload:{enabled:e},headers:this.storeHeaders()})}}class X extends w{constructor(t){super(t,"/api/v1/data")}storeHeaders(t){return{[e.DATA_STORE_ID]:t}}list(){return this.get("/")}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`,{headers:this.storeHeaders(t)})}delete(t){return this.del(`/${t}`,{headers:this.storeHeaders(t)})}getSchema(t,e){const s=e?`?format=${e}`:"";return this.get(`/${t}/schema${s}`,{headers:this.storeHeaders(t)})}updateSchema(t,e){return this.put(`/${t}/schema`,{payload:e,headers:this.storeHeaders(t)})}getSchemaHistory(t){return this.get(`/${t}/schema/history`,{headers:this.storeHeaders(t)})}listTables(t){return this.get(`/${t}/tables`,{headers:this.storeHeaders(t)})}createTables(t,e){return this.post(`/${t}/tables`,{payload:e,headers:this.storeHeaders(t)})}getTable(t,e,s){const r=s?"?sample=true":"";return this.get(`/${t}/tables/${e}${r}`,{headers:this.storeHeaders(t)})}alterTable(t,e,s){return this.put(`/${t}/tables/${e}`,{payload:s,headers:this.storeHeaders(t)})}dropTable(t,e){return this.del(`/${t}/tables/${e}`,{headers:this.storeHeaders(t)})}import(t,e){return this.post(`/${t}/import`,{payload:e,headers:this.storeHeaders(t)})}getImportStatus(t,e){return this.get(`/${t}/import/${e}`,{headers:this.storeHeaders(t)})}listVersions(t,e){const s=e?"?snapshots_only=true":"";return this.get(`/${t}/versions${s}`,{headers:this.storeHeaders(t)})}createSnapshot(t,e){return this.post(`/${t}/versions`,{payload:e,headers:this.storeHeaders(t)})}rollback(t,e){return this.post(`/${t}/versions/${e}/rollback`,{headers:this.storeHeaders(t)})}queryVersion(t,e,s){return this.post(`/${t}/versions/${e}/query`,{payload:s,headers:this.storeHeaders(t)})}query(t,e){return this.post(`/${t}/query`,{payload:e,headers:this.storeHeaders(t)})}validateQueries(t,e){return this.post(`/${t}/query/validate`,{payload:{queries:e},headers:this.storeHeaders(t)})}getDownloadInfo(t,e){const s=e?`?version_id=${e}`:"";return this.get(`/${t}/download${s}`,{headers:this.storeHeaders(t)})}dashboards(t){return new Y(this.client,t)}}class Z extends w{constructor(t){super(t,"/api/v1/email")}send(t){return this.post("/send",{payload:t})}resolveRoute(t){return this.post("/resolve-route",{payload:{route_key:t}})}createRoute(t){return this.post("/routes",{payload:t})}getRoute(t){return this.get(`/routes/${t}`)}updateRoute(t,e){return this.put(`/routes/${t}`,{payload:e})}forwardEmail(t,e){return this.post(`/routes/${t}/forward`,{payload:e})}}class tt extends w{constructor(t,e="/api/v1/indexing"){super(t,e)}async status(){return this.get("/status")}async reindex(t){return this.post("/reindex",{payload:{recreateIndex:t}})}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(t,e){return this.post("/internal/index",{payload:{objectId:t,document:e}})}delete(t){return this.post("/internal/delete",{payload:{objectId:t}})}bulkIndex(t,e){return this.post("/internal/bulk-index",{payload:{documents:t,targetIndex:e}})}ensureIndex(t){return this.post("/internal/ensure-index",{payload:{recreate:t}})}createReindexTarget(){return this.post("/internal/create-reindex-target",{payload:{}})}swapAlias(t,e){return this.post("/internal/swap-alias",{payload:{newIndexName:t,deleteOld:e}})}getStats(){return this.post("/internal/stats",{payload:{}})}getReindexRange(){return this.post("/internal/reindex-range",{payload:{}})}fetchBatch(t,e){return this.post("/internal/fetch-batch",{payload:{cursor:t,limit:e}})}indexBatch(t,e,s,r){return this.post("/internal/index-batch",{payload:{cursor:t,limit:e,targetIndex:s,since:r}})}triggerReindex(t){return this.post("/internal/trigger-reindex",{payload:t??{}})}fetchDocumentsByIds(t){return this.post("/internal/fetch-by-ids",{payload:{objectIds:t}})}bulkDelete(t){return this.post("/internal/bulk-delete",{payload:{objectIds:t}})}getConfiguration(){return this.post("/internal/configuration",{payload:{}})}}class et extends u{constructor(t,e){super("Resource not found: "+e.message,t,404,e.payload)}}class st{constructor(t,e,s,r){this.stream=t,this.name=e,this.type=s,this.id=r}}const rt="memories",nt="agents";function it(t){const e=t.endsWith(".tar.gz")?t:t+".tar.gz";return`${rt}/${e}`}function at(t,e){return`${nt}/${t}/${e}`}class ot extends w{constructor(t){super(t,"/api/v1/files")}async deleteFile(t,e){return(await this.delete(`/${t}`,{query:{prefix:e}})).count}getMetadata(t){return this.get("/metadata",{query:{file:t}})}setFileMetadata(t,e){const s={file:t,metadata:e};return this.put("/metadata",{payload:s})}getOrCreateBucket(){return this.post("/bucket")}getUploadUrl(t){return this.post("/upload-url",{payload:t})}getDownloadUrl(t,e,s){const r={file:t,name:e,disposition:s};return this.post("/download-url",{payload:r})}getDownloadUrlWithOptions(t){return this.post("/download-url",{payload:t})}async uploadFile(t){const e=t instanceof st,{url:s,id:r,path:n}=await this.getUploadUrl(t);return await fetch(s,{method:"PUT",body:e?t.stream:t,duplex:e?"half":void 0,headers:{"Content-Type":t.type||"application/gzip"}}).then(t=>{if(t.ok)return t;throw console.log(t),new Error(`Failed to upload file: ${t.statusText}`)}).catch(t=>{throw console.error("Failed to upload file",{err:t,url:s,id:r,path:n}),t}),r}async downloadFile(t){const e=!t.startsWith("https:"),{url:s}=e?await this.getDownloadUrl(t):{url:t},r=await fetch(s,{method:"GET"}).then(e=>{if(e.ok)return e;throw 404===e.status?new Error(`File at ${s} not found`):403===e.status?new Error(`File at ${s} is forbidden`):(console.log(e),new Error(`Failed to download file ${t}: ${e.statusText}`))}).catch(e=>{throw console.error(`Failed to download file ${t}.`,e),e});if(!r.body)throw new Error(`No body in response while downloading file ${t}`);return r.body}async copyFile(t,e){return(await this.post("/copy",{payload:{source:t,dest:e}})).dest}async uploadMemoryPack(t){const e=it(t.name),s=t.name.endsWith(".tar.gz")?t.name:t.name+".tar.gz";if(t instanceof File){let r=t;return this.uploadFile(new st(r.stream(),s,r.type,e))}return this.uploadFile(new st(t.stream,s,t.type,e))}async downloadMemoryPack(t,e=!1){let s=await this.downloadFile(it(t));if(e){const t=new DecompressionStream("gzip");s=s.pipeThrough(t)}return s}listByPrefix(t){return this.get("/list",{query:{prefix:t}})}async uploadArtifact(t,e,s){const r=at(t,e);if(s instanceof File){const t=s;return this.uploadFile(new st(t.stream(),e,t.type,r))}return this.uploadFile(new st(s.stream,e,s.type,r))}async downloadArtifact(t,e){const s=at(t,e);return this.downloadFile(s)}getArtifactDownloadUrl(t,e,s){const r=at(t,e);return this.getDownloadUrl(r,e,s)}async listArtifacts(t){const e=`${nt}/${t}/`;return(await this.listByPrefix(e)).files}}class lt extends w{constructor(t){super(t,"/api/v1/hive-memory")}list(t){const e=new URLSearchParams;t?.category&&e.set("category",t.category),t?.scope&&e.set("scope",t.scope),t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset));const s=e.toString();return this.get(s?`/?${s}`:"/")}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}search(t){return this.post("/search",{payload:t})}recall(t,e){return this.post("/recall",{payload:{task_description:t,tools:e?.tools,category:e?.category,max_results:e?.maxResults}})}getFormatted(t){return this.get(`/${t}/formatted`)}recordUsage(t){return this.post(`/${t}/usage`,{})}getByCategory(t,e){const s=new URLSearchParams;e?.limit&&s.set("limit",String(e.limit)),e?.offset&&s.set("offset",String(e.offset));const r=s.toString();return this.get(`/category/${t}${r?`?${r}`:""}`)}getStats(){return this.get("/stats")}applyDecay(t){return this.post("/admin/decay",{payload:{days_threshold:t?.daysThreshold,decay_rate:t?.decayRate}})}archiveLowConfidence(t){return this.post("/admin/archive",{payload:{threshold:t}})}}class ut extends w{constructor(t,e){super(t,`/${e}/analyze`),this.objectId=e}async start(t){return this.post("/",{payload:t})}async getStatus(){return this.get("/status")}async getResults(){return this.get("/results")}async adaptTables(t){return this.post("/adapt_tables",{payload:t})}async getAdaptedTables(t,e){const s=t?`/adapt_tables/${t}`:"/adapt_tables",r={};e?.format&&(r.format=e.format),void 0!==e?.raw&&(r.raw=e.raw);const n={query:r};return"csv"===e?.format&&(n.responseType="text"),this.get(s,n)}async getXml(){return this.get("/xml")}async getTables(t){const e={};return t&&(e.query={format:t}),this.get("/tables",e)}async getImages(){return this.get("/images")}async getAnnotated(){return this.get("/annotated")}}class ct extends w{constructor(t){super(t,"/api/v1/objects")}analyze(t){return new ut(this,t)}getUploadUrl(t){return this.post("/upload-url",{payload:t})}getDownloadUrl(t,e,s){return this.post("/download-url",{payload:{file:t,name:e,disposition:s}})}getDownloadUrlWithOptions(t){return this.post("/download-url",{payload:t})}getContentSource(t){return this.get(`/${t}/content-source`)}list(t={}){const e=t.limit||100,s=t.offset||0,r=t.query||{};return this.get("/",{query:{limit:e,offset:s,...r,all_revisions:t.all_revisions,from_root:t.from_root||void 0}})}computeFacets(t){return this.post("/facets",{payload:t})}listFolders(t="/"){}find(t){return this.post("/find",{payload:t})}count(t){return this.post("/count",{payload:t})}search(t){return this.post("/search",{payload:t})}retrieve(t,e){return this.get(`/${t}`,{query:{select:e}})}getObjectText(t){return this.get(`/${t}/text`)}async upload(t){const e=t instanceof st,{url:s,id:r,mime_type:n}=await this.getUploadUrl({id:e?t.id:void 0,name:t.name,mime_type:t.type}),i=t.type||n,a=await fetch(s,{method:"PUT",body:e?t.stream:t,duplex:e?"half":void 0,headers:i?{"Content-Type":i}:void 0}).then(t=>{if(t.ok)return t;throw console.log(t),new Error(`Failed to upload file: ${t.statusText}`)}).catch(t=>{throw console.error("Failed to upload file",t),t}),o=a.headers.get("etag")?.replace(/^"(.*)"$/,"$1");return{source:r,name:t.name,type:i,etag:o}}async create(t,e){const r={...t};(t.content instanceof st||t.content instanceof File)&&(r.content=await this.upload(t.content));const n={};return e?.processing_priority&&(n[s.PROCESSING_PRIORITY]=e.processing_priority),e?.collection_id&&(n[s.COLLECTION_ID]=e.collection_id),await this.post("/",{payload:r,headers:n})}async createFromExternalSource(t,e={},r){const n=await this.client.files.getMetadata(t),i={...e,content:{source:t,name:n.name,type:n.contentType,etag:n.etag}},a={};return r?.processing_priority&&(a[s.PROCESSING_PRIORITY]=r.processing_priority),r?.collection_id&&(a[s.COLLECTION_ID]=r.collection_id),await this.post("/",{payload:i,headers:a})}async update(t,e,r){const n={...e};(e.content instanceof st||e.content instanceof File)&&(n.content=await this.upload(e.content));const i={};return r?.ifMatch&&(i["if-match"]=r.ifMatch),r?.processing_priority&&(i[s.PROCESSING_PRIORITY]=r.processing_priority),r?.createRevision&&(i[s.CREATE_REVISION]="true",r.revisionLabel&&(i[s.REVISION_LABEL]=r.revisionLabel)),r?.suppressWorkflows&&(i[s.SUPPRESS_WORKFLOWS]="true"),this.put(`/${t}`,{payload:n,headers:i})}getRevisions(t){return this.get(`/${t}/revisions`)}getCollections(t){return this.get(`/${t}/collections`)}delete(t){return this.del(`/${t}`)}listWorkflowRuns(t){return this.get(`/${t}/workflow-runs`)}listRenditions(t){return this.get(`/${t}/renditions`)}getRendition(t,e){const s={max_hw:e.max_hw,generate_if_missing:e.generate_if_missing,sign_url:e.sign_url,block_on_generation:e.block_on_generation};return this.get(`/${t}/renditions/${e.format}`,{query:s})}getRenditionSafe(t,e,s){return r(e,s.format)?this.getRendition(t,s):Promise.resolve(null)}exportProperties(t){return this.post("/export",{payload:t})}setEmbedding(t,e,s){return this.put(`/${t}/embeddings/${e}`,{payload:s})}}class ht extends w{constructor(t){super(t,"/api/v1/pending-asks")}register(t){return this.post("/",{payload:t})}resolve(t,e){return this.post(`/${t}/resolve`,{payload:e})}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}}class pt extends w{constructor(t,e="/api/v1/query"){super(t,e)}async execute(t){return this.post("/",{payload:t})}async sql(t){return this.execute({sql:t})}async esql(t){return this.execute({esql:t})}async dsl(t){return this.execute({dsl:t})}}class dt extends w{constructor(t){super(t,"/api/v1/rendering")}start(t){return this.post("/jobs",{payload:t})}getStatus(t,e){return this.get("/jobs/status",{query:{workflow_id:t,workflow_run_id:e}})}async render(t,e={}){const s=e.pollIntervalMs??1500,r=e.timeoutMs??6e5,a=await this.start(t);if(!a.workflow_id||!a.workflow_run_id)throw new Error("Failed to start rendering workflow");const o=Date.now();for(;;){const e=await this.getStatus(a.workflow_id,a.workflow_run_id);if(e.status===n.COMPLETED){if(!e.download_url&&!e.file_uri)throw new Error(e.error||"Rendering completed but no output file was produced");return{status:"success",format:t.format,download_url:e.download_url,file_uri:e.file_uri}}if(i(e.status)){const t=n[e.status]||String(e.status);throw new Error(e.error||`Rendering failed with status: ${t}`)}if(Date.now()-o>=r)throw new Error(`Rendering timed out after ${r}ms`);await gt(s)}}}function gt(t){return new Promise(e=>setTimeout(e,t))}class yt extends w{constructor(t){super(t,"/api/v1/schedules")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}trigger(t){return this.post(`/${t}/trigger`,{})}pause(t,e){return this.post(`/${t}/pause`,{payload:{note:e}})}resume(t,e){return this.post(`/${t}/resume`,{payload:{note:e}})}}class mt extends w{constructor(t){super(t,"/api/v1/tools")}getBuiltinCatalog(){return this.get("/")}}class ft extends w{constructor(t){super(t,"/api/v1/types/catalog")}list(t={}){return this.get("/",{query:t})}listSysTypes(t){return this.get("/sys",{query:{tag:t}})}listAppTypes(t){return this.get("/apps",{query:{tag:t}})}listStoredTypes(t={}){return this.get("/stored",{query:t})}resolve(t){const e="string"==typeof t?t:t.code||t.id;return this.get(`/resolve/${e}`)}}class wt extends w{constructor(t){super(t,"/api/v1/types"),this.catalog=new ft(t)}list(t={},e){const s=t.limit||2e3,r=t.offset||0,n=t.query||{};return this.get("/",{query:{limit:s,offset:r,layout:!!e?.layout,schema:!!e?.schema,...n}})}find(t){return this.post("/find",{payload:t})}retrieve(t){return this.get(`/${t}`)}getTypeByName(t){return this.get(`/name/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}}const vt="20260210",$t="x-api-version";class bt extends w{constructor(t){super(t,"/api/v1/workers")}async deploy(t){return this.post("/",{payload:t})}}class St extends w{constructor(t){super(t,"/api/v1/workflows"),this.rules=new xt(this),this.definitions=new kt(this)}getActivityCatalog(){return this.get("/activity-catalog")}listRuns(t,e,s){return this.post("/runs",{payload:{documentId:t,eventName:e,ruleId:s}})}listConversations(t){return this.post("/conversations",{payload:t})}searchRuns(t){return this.post("/runs",{payload:t})}sendSignal(t,e,s,r){return this.post(`/runs/${t}/${e}/signal/${s}`,{payload:r})}getRunDetails(t,e,s){const r={};return void 0!==s?.includeHistory&&(r.include_history=s.includeHistory),void 0!==s?.historyFormat&&(r.history_format=s.historyFormat),this.get(`/runs/${e}/${t}`,{query:r})}getRunInteraction(t,e){return this.get(`/runs/${t}/${e}/interaction`)}terminate(t,e,s){const r={reason:s};return this.post(`/runs/${t}/${e}/actions/terminate`,{payload:r})}cancel(t,e,s){const r={reason:s};return this.post(`/runs/${t}/${e}/actions/cancel`,{payload:r})}query(t,e,s){return this.get(`/runs/${t}/${e}/query/${s}`)}execute(t,e={}){return this.post(`/execute/${t}`,{payload:e})}postMessage(t,e){if(!t)throw new Error("runId is required");return this.post(`/runs/${t}/updates`,{payload:e})}async retrieveMessages(t,e,s){const r={since:s};return(await this.get(`/runs/${t}/${e}/updates`,{query:r})).messages.map(t=>a(t,e))}async streamMessages(t,e,s,r){return new Promise(async(n,i)=>{let u=0,c=r||0,h=!1,p=null,d=null;const g=10,y=t=>{const e=Math.min(1e3*Math.pow(2,t),3e4);return e+.1*Math.random()*e},m=()=>{d&&(clearInterval(d),d=null),p&&(p.close(),p=null)},f=t=>{h||(h=!0,m(),n(t))};try{const i=await this.retrieveMessages(t,e,r);for(const t of i){c=Math.max(c,t.timestamp||0),s&&s(t,f);const e=t.workstream_id||"main";if(t.type===o.TERMINATED||t.type===o.COMPLETE&&"main"===e)return console.log("Workflow already completed in historical messages"),void n(null)}}catch(t){console.warn("Failed to fetch historical messages, continuing with SSE:",t)}const w=async(r=!1)=>{if(!h)try{const v=await U(),$=this.client,b=new URL($.workflows.baseUrl+`/runs/${t}/${e}/stream`);c>0&&b.searchParams.set("since",c.toString()),b.searchParams.set("skipHistory","true");const S=$._auth?await $._auth():void 0;if(!S)return void i(new Error("No auth token available"));const x=S.split(" ")[1];b.searchParams.set("access_token",x),r&&console.log(`Reconnecting to SSE stream for run ${e} (attempt ${u+1}/10)`);const k=new v(b.href);p=k,d=setInterval(()=>{},1e3),k.onopen=()=>{r&&console.log(`Successfully reconnected to SSE stream for run ${e}`),u=0},k.onmessage=t=>{if(t.data&&!t.data.startsWith(":"))try{const r=l(t.data);if(c=r.ts?Math.max(c,r.ts):Date.now(),s){const t=a(r,e);s(t,f)}const i=r.w||"main";r.t===o.TERMINATED||r.t===o.COMPLETE&&"main"===i?(console.log("Closing stream due to COMPLETE message from main workstream"),h||(h=!0,m(),n(null))):r.t===o.COMPLETE&&console.log(`Received COMPLETE message from non-main workstream: ${i}, keeping stream open`)}catch(e){console.error("Failed to parse SSE message:",e,t.data)}else console.log("Received comment or heartbeat; ignoring it.: ",t.data)},k.onerror=t=>{if(!h)if(console.warn(`SSE stream error for run ${e}:`,t),m(),u<g){const t=y(u);console.log(`Attempting to reconnect in ${t}ms (attempt ${u+1}/10)`),u++,setTimeout(()=>{h||w(!0)},t)}else console.error(`Failed to reconnect to SSE stream for run ${e} after 10 attempts`),h=!0,i(new Error("SSE connection failed after 10 reconnection attempts"))}}catch(t){if(console.error("Error setting up SSE stream:",t),u<g){const t=y(u);u++,setTimeout(()=>{h||w(!0)},t)}else i(t)}};return w(!1),()=>{h=!0,m()}})}async streamMessagesWS(t,e,s,r){return new Promise((n,i)=>{let a=0;const u=10;let c=null,h=r||0,p=!1;const d=t=>{const e=Math.min(1e3*Math.pow(2,t),3e4);return e+.1*Math.random()*e},g=async()=>{if(!p)try{const r=this.client,y=new URL(r.workflows.baseUrl+`/runs/${t}/${e}/ws`);y.protocol=y.protocol.replace("http","ws"),h>0&&y.searchParams.set("since",h.toString());const m=r._auth?await r._auth():void 0;if(!m)return void i(new Error("No auth token available"));const f=m.split(" ")[1];y.searchParams.set("access_token",f),a>0&&console.log(`Reconnecting to WebSocket for run ${e} (attempt ${a+1}/10)`),c=new WebSocket(y.href),c.onopen=()=>{a>0&&console.log(`Successfully reconnected to WebSocket for run ${e}`),a=0,p||n({cleanup:()=>{p=!0,c&&(c.close(),c=null)},sendSignal:(t,e)=>{if(c?.readyState===WebSocket.OPEN){const s={type:"signal",signalName:t,data:e,requestId:Date.now()};c.send(JSON.stringify(s))}else console.warn("WebSocket not open, cannot send signal")}})},c.onmessage=t=>{try{const e=JSON.parse(t.data);if("type"in e&&"string"==typeof e.type){if("pong"===e.type)return void console.debug("Received pong");if("ack"===e.type)return void console.debug("Signal acknowledged",e);if("error"===e.type)return void console.error("WebSocket error message",e)}const r=l(e);h=r.ts?Math.max(h,r.ts):Date.now(),s&&s(r);const n=r.w||"main";(r.t===o.TERMINATED||r.t===o.COMPLETE&&"main"===n)&&(console.log("Closing WebSocket due to workflow completion"),p=!0,c&&(c.close(),c=null))}catch(t){console.error("Failed to parse WebSocket message",t)}},c.onerror=t=>{console.error("WebSocket error",t)},c.onclose=()=>{if(!p&&a<u){const t=d(a);console.log(`WebSocket closed, reconnecting in ${t}ms (attempt ${a+1}/10)`),a++,setTimeout(g,t)}else a>=u&&i(new Error("WebSocket connection failed after 10 attempts"))}}catch(t){if(console.error("Error setting up WebSocket",t),a<u){const t=d(a);a++,setTimeout(g,t)}else i(t)}};g()})}ingestEvents(t,e,s){return this.post(`/runs/${t}/${e}/events`,{payload:{events:s}})}getAnalyticsSummary(t={}){return this.post("/analytics/summary",{payload:t})}getTokenUsageAnalytics(t={}){return this.post("/analytics/tokens",{payload:t})}getLlmLatencyAnalytics(t={}){return this.post("/analytics/latency/llm",{payload:t})}getToolLatencyAnalytics(t={}){return this.post("/analytics/latency/tools",{payload:t})}getAgentLatencyAnalytics(t={}){return this.post("/analytics/latency/agents",{payload:t})}getErrorAnalytics(t={}){return this.post("/analytics/errors",{payload:t})}getToolAnalytics(t={}){return this.post("/analytics/tools",{payload:t})}getToolParameterAnalytics(t){return this.post("/analytics/tools/parameters",{payload:t})}getAnalyticsFilterOptions(t={}){return this.post("/analytics/filter-options",{payload:t})}getPromptSizeAnalytics(t={}){return this.post("/analytics/prompt-size",{payload:t})}getTopPrincipalsAnalytics(t={}){return this.post("/analytics/top-principals",{payload:t})}getRunsByAgentAnalytics(t={}){return this.post("/analytics/runs-by-agent",{payload:t})}getTimeToFirstResponseAnalytics(t={}){return this.post("/analytics/time-to-first-response",{payload:t})}getFirstResponseBehaviorAnalytics(t={}){return this.post("/analytics/first-response-behavior",{payload:t})}}class xt extends w{constructor(t){super(t,"/rules")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}execute(t,e,s){const r={objectIds:e,vars:s};return this.post(`/${t}/execute`,{payload:r})}}class kt extends w{constructor(t){super(t,"/definitions")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}}class Tt extends f{constructor(t={}){super(function(t){if(!t)throw new Error("zeno client serverUrl is required");return t}(t.serverUrl)),this.objects=new ct(this),this.types=new wt(this),this.workflows=new St(this),this.schedules=new yt(this),this.files=new ot(this),this.commands=new Q(this),this.workers=new bt(this),this.collections=new G(this),this.embeddings=new K(this),this.email=new Z(this),this.pendingAsks=new ht(this),this.data=new X(this),this.tools=new mt(this),this.indexing=new tt(this),this.query=new pt(this),this.hiveMemory=new lt(this),this.rendering=new dt(this),t.apikey&&this.withApiKey(t.apikey),this.onRequest=t.onRequest,this.onResponse=t.onResponse,this.errorFactory=t=>404===t.status?new et(t.request,t):t}withApiVersion(t){return t?this.headers[$t]=String(t):delete this.headers[$t],this}withApiKey(t){return this.withAuthCallback(t?()=>Promise.resolve(`Bearer ${t}`):void 0)}runOperation(t){return this.post("/api/v1/operations",{payload:t})}get initialHeaders(){return{...super.initialHeaders,[$t]:vt}}}class _t extends w{constructor(t){super(t,"/api/v1/training")}listSessions(t={}){return this.get("/",{query:t})}listSessionNames(t={}){return this.get("/names",{query:t})}createSession(t){return this.post("/",{payload:t})}getSession(t){return this.get("/"+t)}addToSession(t,e){return this.post("/"+t+"/add",{payload:{runs:e}})}listSessionRuns(t,e=100,s=0){return this.get("/"+t+"/runs",{query:{limit:e,offset:s}})}buildSession(t){return this.post("/"+t+"/build")}getDataUrl(t){return this.get("/"+t+"/url")}getDataUploadUrl(t,e=!1){return this.get("/"+t+"/upload-url",e?{query:{resumable:"true"}}:{})}startTraining(t){return this.post("/"+t+"/start")}cancelTraining(t){return this.post("/"+t+"/cancel")}getTrainingJob(t){return this.get(`/job/${t}`)}getAndSyncTrainingJob(t){return this.get(`/job/${t}`,{query:{sync:"true"}})}setDataset(t,e="default"){return this.post("/"+t+"/dataset",{payload:{dataset:e}})}}class Et extends w{constructor(t){super(t,"/api/v1/users")}retrieve(t){return this.get("/"+t)}update(t,e){return this.put("/"+t,{payload:e})}delete(t){return this.del("/"+t)}}class Rt extends f{static async fromAuthToken(t,e,s){e||(e=qt(t));const r=s||It(e.endpoints);return await new Rt({serverUrl:r.studio,storeUrl:r.store,tokenServerUrl:r.token||e.iss}).withApiKey(t)}static decodeEndpoints(){}constructor(t={site:"api.vertesia.io"}){let e,s;if(t.serverUrl)e=t.serverUrl;else{if(!t.site)throw new Error("Parameter 'site' or 'serverUrl' is required for VertesiaClient");e=`https://${t.site}`}if(t.storeUrl)s=t.storeUrl;else{if(!t.site)throw new Error("Parameter 'site' or 'storeUrl' is required for VertesiaClient");s=`https://${t.site}`}if(super(e),this._jwt=null,this.projects=new L(this),this.environments=new _(this),this.interactions=new N(this),this.skills=new B(this),this.prompts=new J(this),this.runs=new z(this),this.account=new v(this),this.accounts=new $(this),this.apikeys=new x(this),this.analytics=new b(this),this.auditTrail=new S(this),this.training=new _t(this),this.users=new Et(this),this.iam=new R(this),this.refs=new V(this),this.commands=new T(this),this.apps=new k(this),this.mcpOAuth=new H(this),t.tokenServerUrl)this.tokenServerUrl=t.tokenServerUrl;else if(t.site)"api-preview.vertesia.io"===t.site||"api.vertesia.io"===t.site?this.tokenServerUrl="https://sts.vertesia.io":this.tokenServerUrl=`https://${t.site.replace(/^api/,"sts")}`;else if(t.serverUrl||t.storeUrl){const e=t.serverUrl||t.storeUrl||"";try{const t=new URL(e);t.hostname.includes("-production.")||t.hostname.includes("-preview.")||"api.vertesia.io"===t.hostname||"api-preview.vertesia.io"===t.hostname?this.tokenServerUrl="https://sts.vertesia.io":"api-staging.vertesia.io"===t.hostname?this.tokenServerUrl="https://sts-staging.vertesia.io":t.hostname.startsWith("api")?(t.hostname=t.hostname.replace(/^api/,"sts"),this.tokenServerUrl=t.toString()):this.tokenServerUrl="https://sts-staging.vertesia.io"}catch(t){this.tokenServerUrl="https://sts-staging.vertesia.io"}}else this.tokenServerUrl="https://sts-staging.vertesia.io";this.store=new Tt({serverUrl:s,tokenServerUrl:this.tokenServerUrl,apikey:t.apikey,onRequest:t.onRequest,onResponse:t.onResponse}),t.apikey&&this.withApiKey(t.apikey),this.onRequest=t.onRequest,this.onResponse=t.onResponse,this.sessionTags=t.sessionTags}withApiVersion(t){return t?this.headers[$t]=String(t):delete this.headers[$t],this}withAuthCallback(t){return this.store.withAuthCallback(t),super.withAuthCallback(t)}async withApiKey(t){return this.withAuthCallback(t?async()=>{if(!function(t){return t.startsWith("pk-")||t.startsWith("sk-")}(t))return`Bearer ${t}`;if(function(t){if(!t)return!0;const e=qt(t).exp;return Date.now()<=1e3*e-6e4}(this._jwt)){const e=await this.getAuthToken(t);this._jwt=e.token}return`Bearer ${this._jwt}`}:void 0)}async getRawJWT(){if(!this._jwt&&this._auth){const t=await this._auth();this._jwt||(this._jwt=t.trim().split(" ")[1])}return this._jwt||null}async getDecodedJWT(){const t=await this.getRawJWT();return t?qt(t):null}async getProject(){const t=await this.getDecodedJWT();return t?.project||null}async getAccount(){const t=await this.getDecodedJWT();return t?.account||null}get workflows(){return this.store.workflows}get objects(){return this.store.objects}get files(){return this.store.files}get types(){return this.store.types}get data(){return this.store.data}get storeUrl(){return this.store.baseUrl}async getAuthToken(t){return fetch(`${this.tokenServerUrl}/token/issue`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}}).then(t=>t.json()).then(t=>t).catch(t=>{throw console.error(`Error fetching token from ${this.tokenServerUrl}:`,{error:t}),t})}get initialHeaders(){return{...super.initialHeaders,[$t]:vt}}}function qt(t){const e=function(t){const e=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(4*Math.ceil(t.length/4),"=");if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("utf-8");if("undefined"!=typeof atob&&"undefined"!=typeof TextDecoder){const t=atob(e),s=Uint8Array.from(t,t=>t.charCodeAt(0));return(new TextDecoder).decode(s)}throw new Error("No base64 decoder available")}(t.split(".")[1]);return JSON.parse(e)}function It(t){return t?"string"==typeof t?Ut(t):t:Ut("api.vertesia.io")}function Ut(t){if("local"===t)return{studio:"http://localhost:8091",store:"http://localhost:8092",token:process.env.STS_URL??"https://sts-staging.vertesia.io"};{const e=`https://${t}`;return{studio:e,store:e,token:e.replace("api","sts")}}}class At{constructor(t,e){this.id=t,this.client=e instanceof Rt?e:new Rt(e)}retrieve(){return this.client.interactions.retrieve(this.id)}update(t){return this.client.interactions.update(this.id,t)}render(t){}async execute(t={},e){return A(this.client,this.id,t,e)}}export{nt as ARTIFACTS_PREFIX,Q as CommandsApi,X as DataApi,Z as EmailApi,ot as FilesApi,lt as HiveMemoryApi,O as IS_INTERACTION_OUTPUT,tt as IndexingApi,At as InteractionBase,D as InteractionOutput,rt as MEMORIES_PREFIX,ct as ObjectsApi,ht as PendingAsksApi,pt as QueryApi,dt as RenderingApi,yt as SchedulesApi,st as StreamSource,ft as TypeCatalogApi,wt as TypesApi,Rt as VertesiaClient,St as WorkflowsApi,kt as WorkflowsDefinitionApi,xt as WorkflowsRulesApi,Tt as ZenoClient,et as ZenoClientNotFoundError,M as createInteractionOutput,It as decodeEndpoints,qt as decodeJWT,F as enhanceExecutionRun,C as enhanceInteractionExecutionResult,at as getAgentArtifactPath,it as getMemoryFilePath};
|
|
1
|
+
import{ExecutionRunStatus as t,DataStoreApiHeaders as e,ContentObjectApiHeaders as s,canGenerateRendition as r,WorkflowExecutionStatus as n,isWorkflowTerminalStatus as i,toAgentMessage as a,AgentMessageType as o,parseMessage as l}from"@vertesia/common";export{canGenerateRendition,getSupportedRenditionFormats,supportsVisualRendition}from"@vertesia/common";class u extends Error{constructor(t,e,s,r,n=!0){super(function(t,e,s,r,n){let i=t;if(n){i+="\nRequest: "+e.method+" "+e.url+" => "+s;const t=r?.details||r?.error?.details;if(t){const e=typeof t;"string"===e?i+="\nDetails: "+t:"object"===e&&(i+="\nDetails: "+JSON.stringify(t,void 0,2))}i+="\nStack Trace: "}return i}(t,e,s,r,n)),this.original_message=t,this.request=e,this.status=s,this.payload=r,this.request_info=e.method+" "+e.url+" => "+s,this.displayDetails=n}get details(){return this.payload?.details||this.payload?.error?.details}}class c extends u{constructor(t,e,s,r,n=!0){super(t,e,s,r,n)}updateDetails(t){return t!==this.details?new c(this.original_message,this.request,this.status,{...this.payload,details:t},this.displayDetails):this}}class h extends u{constructor(t,e){super("Failed to connect to server: "+e.message,t,0,e)}}let p;if(globalThis.TextDecoderStream&&"function"==typeof globalThis.TextDecoderStream)p=globalThis.TextDecoderStream;else{class t extends TransformStream{constructor(t="utf-8",{fatal:s=!1,ignoreBOM:r=!1}={}){super(new e(new TextDecoder(t,{fatal:s,ignoreBOM:r}))),this._options={fatal:s,ignoreBOM:r,encoding:t}}get encoding(){return this._options.encoding}get fatal(){return this._options.fatal}get ignoreBOM(){return this._options.ignoreBOM}}class e{constructor(t){this.decoder=t}transform(t,e){if(!(t instanceof ArrayBuffer||ArrayBuffer.isView(t)))throw new TypeError("Input must be a compatible with: ArrayBuffer | Uint8Array");const s=this.decoder.decode(t,{stream:!0});0!==s.length&&e.enqueue(s)}flush(t){const e=this.decoder.decode();0!==e.length&&t.enqueue(e)}}p=t}const d=[239,187,191];class g extends TransformStream{constructor(){let t;super({start(e){t=function(t){let e,s,r,n,i,a,o;return l(),{feed:function(t){s=s?s+t:t,e&&function(t){return d.every((e,s)=>t.charCodeAt(s)===e)}(s)&&(s=s.slice(d.length)),e=!1;const i=s.length;let a=0,o=!1;for(;a<i;){o&&("\n"===s[a]&&++a,o=!1);let t,e=-1,l=n;for(let n=r;e<0&&n<i;++n)t=s[n],":"===t&&l<0?l=n-a:"\r"===t?(o=!0,e=n-a):"\n"===t&&(e=n-a);if(e<0){r=i-a,n=l;break}r=0,n=-1,u(s,a,l,e),a+=e+1}a===i?s="":a>0&&(s=s.slice(a))},reset:l};function l(){e=!0,s="",r=0,n=-1,i=void 0,a=void 0,o=""}function u(e,s,r,n){if(0===n)return o.length>0&&(t({type:"event",id:i,event:a||void 0,data:o.slice(0,-1)}),o="",i=void 0),void(a=void 0);const l=r<0,u=e.slice(s,s+(l?n:r));let c=0;c=l?n:" "===e[s+r+1]?r+2:r+1;const h=s+c,p=n-c,d=e.slice(h,h+p).toString();if("data"===u)o+=d?"".concat(d,"\n"):"\n";else if("event"===u)a=d;else if("id"!==u||d.includes("\0")){if("retry"===u){const e=parseInt(d,10);Number.isNaN(e)||t({type:"reconnect-interval",value:e})}}else i=d}}(t=>{"event"===t.type&&e.enqueue(t)})},transform(e){t.feed(e)}})}}function y(t){return"/"===t[t.length-1]?t.slice(0,-1):t}class m{constructor(t,e){this.errorFactory=t=>t,this.verboseErrors=!0,this.baseUrl=y(t),this._fetch=function(t){return t?Promise.resolve(t):"function"==typeof globalThis.fetch?Promise.resolve(globalThis.fetch):Promise.resolve(()=>{throw new Error("No Fetch implementation found")})}(e)}throwError(t){throw this.errorFactory(t)}getUrl(t){return y((e=this.baseUrl,s=t,e.endsWith("/")?s.startsWith("/")?e+s.substring(1):e+s:s.startsWith("/")?e+s:e+"/"+s));var e,s}get(t,e){return this.request("GET",t,e)}del(t,e){return this.request("DELETE",t,e)}delete(t,e){return this.request("DELETE",t,e)}post(t,e){return this.request("POST",t,e)}put(t,e){return this.request("PUT",t,e)}jsonParse(t){return JSON.parse(t)}createRequest(t,e){return Promise.resolve(new Request(t,e))}createServerError(t,e,s){let r="Server Error: "+e.status;return s&&(s.message?r=String(s.message):s.error&&("string"==typeof s.error?r=String(s.error):"string"==typeof s.error.message&&(r=String(s.error.message)))),new c(r,t,e.status,s,this.verboseErrors)}async readJSONPayload(t){return t.text().then(e=>{if(e)try{return this.jsonParse(e)}catch(s){return{status:t.status,error:"Not a valid JSON payload",message:s.message,text:e}}}).catch(e=>({status:t.status,error:"Unable to load response content",message:e.message}))}handleResponse(t,e,s){return e.url,s&&s.reader?"sse"===s.reader?async function(t){if(!t.ok){const e=await t.text(),s=new Error("SSE error: "+t.status+". Content:\n"+e);throw s.status=t.status,s}if(!t.body)throw new Error("No body in response");return t.body.pipeThrough(new p).pipeThrough(new g)}(e):s.reader.call(this,e):this.readJSONPayload(e).then(s=>{if(e.ok)return s;this.throwError(this.createServerError(t,e,s))})}async request(t,e,s){let r=this.getUrl(e);s?.query&&(r+="?"+function(t){const e=[];for(const s of Object.keys(t)){const r=t[s];null!=r&&e.push(encodeURIComponent(s)+"="+encodeURIComponent(String(r)))}return e.join("&")}(s.query));const n=this.headers?Object.assign({},this.headers):{},i=s?.headers;if(i)for(const t in i)n[t.toLowerCase()]=i[t];let a;const o=s?.payload;o&&(s&&!1===s.jsonPayload?a=o:(a="string"!=typeof o?JSON.stringify(o):o,"content-type"in n||(n["content-type"]="application/json")));const l={method:t,headers:n,body:a},u=await this.createRequest(r,l);return this._fetch.then(t=>t(u).catch(t=>{console.error(`Failed to connect to ${r}`,t),this.throwError(new h(u,t))}).then(t=>this.handleResponse(u,t,s)))}fetch(t,e){return this._fetch.then(s=>s(t,e))}}class f extends m{constructor(t,e){super(t,e),this.baseUrl="/"===t[t.length-1]?t.substring(0,t.length-1):t,this.headers=this.initialHeaders}get initialHeaders(){return{accept:"application/json"}}withAuthCallback(t){return this._auth=t||void 0,this}withErrorFactory(t){return this.errorFactory=t,this}withLang(t){return t?this.headers["accept-language"]=t:delete this.headers["accept-language"],this}withHeaders(t){const e=this.headers;for(const s in t){const r=t[s];null!=r&&(e[s.toLowerCase()]=r)}return this}setHeader(t,e){e?this.headers[t.toLowerCase()]=e:delete this.headers[t.toLowerCase()]}async createRequest(t,e){if(this._auth&&(!(s=e.headers)||!("authorization"in s))){const t=e.headers?e.headers:{};e.headers=t;const s=await this._auth();s&&(e.headers.authorization=s)}var s;this.response=void 0;const r=await super.createRequest(t,e);return this.onRequest&&this.onRequest(r),r}async handleResponse(t,e,s){return this.response=e,this.onResponse&&this.onResponse(e,t),super.handleResponse(t,e,s)}}class w extends m{constructor(t,e){super(t.getUrl(e),t._fetch),this.client=t,this.createServerError=t.createServerError,this.errorFactory=t.errorFactory,this.verboseErrors=t.verboseErrors}createRequest(t,e){return this.client.createRequest(t,e)}handleResponse(t,e,s){return this.client.handleResponse(t,e,s)}get headers(){return this.client.headers}}class v extends w{constructor(t){super(t,"/api/v1/account")}info(){return this.get("/")}update(t){return this.put("/",{payload:t})}projects(){return this.get("/projects").then(t=>t.data)}members(){return this.get("/members")}inviteUser(t){return this.post("/invites",{payload:t})}listInvites(){return this.get("/invites")}listInvitation(t="project"){return this.get(`/invites/${t}`)}acceptInvite(t){return this.put(`/invites/${t}`)}rejectInvite(t){return this.delete(`/invites/${t}`)}onboardingProgress(){return this.get("/onboarding")}getGoogleToken(){return this.get("/google-token")}getStripeBillingStatus(){return this.get("/stripe-billing-status")}}class $ extends w{constructor(t){super(t,"/api/v1/accounts")}create(t){return this.post("/",{payload:{name:t}})}list(){return this.get("/")}}class b extends w{constructor(t){super(t,"/api/v1/analytics")}runsSummary(t,e){const s=new URLSearchParams;t?.start&&s.set("start",t.start),t?.end&&s.set("end",t.end),e&&s.set("environment",e);const r=s.toString();return this.get("/runs/summary"+(r?"?"+r:""))}runsTimeSeries(t,e){const s=new URLSearchParams;t?.start&&s.set("start",t.start),t?.end&&s.set("end",t.end),e&&s.set("environment",e);const r=s.toString();return this.get("/runs/time-series"+(r?"?"+r:""))}runsTokenUsage(t){const e=new URLSearchParams;t?.start&&e.set("start",t.start),t?.end&&e.set("end",t.end);const s=e.toString();return this.get("/runs/token-usage"+(s?"?"+s:""))}}class S extends w{constructor(t){super(t,"/api/v1/audit-trail")}list(t){const e=new URLSearchParams;t?.actions?.length&&e.set("actions",t.actions.join(",")),t?.resourceTypes?.length&&e.set("resourceTypes",t.resourceTypes.join(",")),t?.resourceId&&e.set("resourceId",t.resourceId),t?.principalId&&e.set("principalId",t.principalId),t?.principalUserId&&e.set("principalUserId",t.principalUserId),t?.projectId&&e.set("projectId",t.projectId),t?.from&&e.set("from",t.from),t?.to&&e.set("to",t.to),t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset));const s=e.toString();return this.get("/"+(s?"?"+s:""))}}class x extends w{constructor(t){super(t,"/api/v1/apikeys")}list(t="account"){return this.get("/",{query:{level:t}})}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}retrieve(t,e=!1){return e?this.get(`/${t}`,{query:{withValue:!0}}):this.get(`/${t}`)}requestPublicKey(t={}){return this.get("/pk",{query:t})}}class k extends w{constructor(t){super(t,"/api/v1/apps")}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}listAppInstallationTools(t){return this.get(`/installations/${t}/tools`)}list(){return this.get("/")}install(t,e){return this.post("/install",{payload:{app_id:t,settings:e}})}uninstall(t){return this.del(`/install/${t}`)}getAppInstallationByName(t){return this.get(`/installations/name/${t}`).catch(t=>{if(404===t.status)return null;throw t})}getAppInstallationProjects(t){if(!t.id&&!t.name)throw new Error("Invalid arguments: appId or appName must be specified");const e=t.id?{id:t.id}:{name:t.name};return this.get("/installations/projects",{query:e})}getInstalledApps(t){return this.get("/installations",{query:{kind:t}})}getAllAppInstallations(){return this.get("/installations/all")}listInstallations(){return this.get("/installations/refs")}updateInstallationSettings(t){return this.put(`/installations/settings/${t.app_id}`,{payload:{app_id:t.app_id,settings:t.settings}})}}let T=class extends w{constructor(t){super(t,"/api/v1/commands")}async isNamespaceAvailable(t){return this.get(`/namespaces/${t}/is_available`).then(t=>t.available)}async initSamples(){return this.post("/onboarding/init-samples")}};class _ extends w{constructor(t){super(t,"/api/v1/environments")}list(t=!1){const e=t?{all:!0}:void 0;return this.get("/",{query:e})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get("/"+t)}update(t,e){return this.put("/"+t,{payload:e})}updateConfig(t,e){return this.put("/"+t+"/config",{payload:e})}listModels(t,e){return this.get("/"+t+"/models",{query:e?{...e}:void 0})}listTrainableModels(t){return this.get(`/${t}/trainable-models`)}embeddings(t,e){return this.post("/"+t+"/embeddings",{payload:e})}migrateInteractions(t){return this.post("/migrate-interactions",{payload:t})}}class E extends w{constructor(t){super(t,"/groups")}list(t){return this.get("/",{query:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get("/"+t)}update(t,e){return this.put("/"+t,{payload:e})}delete(t){return this.del("/"+t)}listMembers(t){return this.get("/"+t+"/members")}addMember(t,e){return this.post("/"+t+"/members/"+e)}removeMember(t,e){return this.del("/"+t+"/members/"+e)}}class R extends w{constructor(t){super(t,"/api/v1/iam"),this.aces=new I(this),this.roles=new q(this),this.groups=new E(this)}}class q extends w{constructor(t){super(t,"/roles")}list(){return this.get("/")}}class I extends w{constructor(t){super(t,"/aces")}list(t){return this.get("/",{query:{...t}})}retrieve(t){return this.get("/"+t)}create(t){return this.post("/",{payload:t})}delete(t){return this.del("/"+t)}}async function U(){return"function"==typeof globalThis.EventSource?globalThis.EventSource:(await import("eventsource")).EventSource}async function A(e,s,r={},n){const i=!!n,a=await e.runs.create({...r,interaction:s,stream:i});if(i){if(a.status===t.failed)return a;await P(e,a.id,n)}return a}function P(t,e,s){return new Promise(async(r,n)=>{try{const i=await U(),a=new URL(t.runs.baseUrl+"/"+e+"/stream"),o=t._auth?await t._auth():void 0;if(!o)throw new Error("No auth token available");{const t=o.split(" ")[1];a.searchParams.set("access_token",t)}const l=new i(a.href);l.addEventListener("message",t=>{try{const e=JSON.parse(t.data);e&&s&&s(e)}catch(t){n(t)}}),l.addEventListener("close",t=>{try{l.close();const e=JSON.parse(t.data);r(e)}catch(t){n(t)}})}catch(t){n(t)}})}class j extends w{constructor(t){super(t,"/api/v1/interactions/catalog")}list(t={}){return this.get("/",{query:t})}listStoredInteractions(t={}){return this.get("/stored",{query:t})}listSysInteractions(t){return this.get("/sys",{query:{tag:t}})}listAppInteractions(t,e){return this.get(`/apps/${t}`,{query:{tag:e}})}listAllAppInteractions(t){return this.get("/apps",{query:{tag:t}})}resolve(t){return this.get(`/resolve/${t}`)}}const O=Symbol("InteractionOutput");function C(t){return t.result=D.from(t.result),t}function F(t){return t.result=D.from(t.result),t}class D{constructor(t){this.results=t}static from(t){return t?t[O]?t:Array.isArray(t)?M(t):M("object"==typeof t?[{type:"json",value:t}]:[{type:"text",value:String(t)}]):M([])}static isInteractionOutputArray(t){return t&&!0===t[O]}get isEmpty(){return 0===this.results.length}hasObject(){return this.results.some(t=>"json"===t.type)}hasText(){return this.results.some(t=>"text"===t.type)}hasImage(){return this.results.some(t=>"image"===t.type)}text(t="\n"){return this.results.filter(t=>"text"===t.type).map(t=>t.value).join(t)}texts(){return this.results.filter(t=>"text"===t.type).map(t=>t.value)}object(){const t=this.results.find(t=>"json"===t.type);return t?t.value:function(t){let e;for(const s of t)if("text"===s.type){const t=s.value.trim();try{return JSON.parse(t)}catch(t){e=t}}e||(e=new Error("No JSON result found and no text available to parse"));throw e}(this.results)}objects(){return this.results.filter(t=>"json"===t.type).map(t=>t.value)}objectAt(t){let e=0;for(const s of this.results)if("json"===s.type){if(e===t)return s.value;e++}throw new Error(`Object at index ${t} not found`)}image(){const t=this.results.find(t=>"image"===t.type);if(!t)throw new Error("No image result found");return t.value}images(){return this.results.filter(t=>"image"===t.type).map(t=>t.value)}stringify(t="\n",e=2){return this.results.map(t=>"json"===t.type?JSON.stringify(t.value,null,e):String(t.value)).join(t)}toString(){return this.text()}toJSON(){return this.results}}function M(t){const e=new D(t);return new Proxy(t,{get(t,s,r){if(s===O)return!0;if(s in e){const t=e[s];return"function"==typeof t?t.bind(e):t}return Reflect.get(t,s,r)}})}class N extends w{constructor(t){super(t,"/api/v1/interactions"),this.catalog=new j(t)}list(t={}){const e=t.query||{};return this.get("/",{query:{...e}})}listEndpoints(t){return this.post("/endpoints",{payload:t})}listVersionsByName(t){return this.get(`/versions/${t}`)}listTags(t){return this.get("/tags",{query:{...t}})}computeFacets(t){return this.post("/facets",{payload:t})}listNames(){return this.get("/names")}export(t){return this.post("/export",{payload:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}async execute(t,e={},s){return C(await A(this.client,t,e,s).catch(t=>{throw t instanceof c&&t.payload?.id?t.updateDetails({run_id:t.payload.id}):t}))}async executeByName(e,s={},r){const n=await async function(e,s,r={},n){const i=!!n,a=await e.post("/api/v1/execute",{payload:{...r,interaction:s,stream:i}});if(i){if(a.status===t.failed)return a;await P(e,a.id,n)}return a}(this.client,e,s,r).catch(t=>{throw t instanceof c&&t.payload?.id?t.updateDetails({run_id:t.payload.id}):t});return C(n)}executeAsync(t){return async function(t,e){return await t.post("/api/v1/execute/async",{payload:e})}(this.client,t)}publish(t,e){return this.post(`/${t}/publish`,{payload:e})}fork(t,e){return this.post(`/${t}/fork`,{payload:e})}generateInteraction(t,e){return this.post(`${t}/generate-interaction`,{payload:e})}generateTestData(t,e){return this.post(`${t}/generate-test-data`,{payload:e})}async suggestImprovements(t,e){return F(await this.post(`${t}/suggest-prompt-improvements`,{payload:e}))}async suggestPromptImprovements(t){return C(await this.post("/improve",{payload:t}))}listVersions(t){return this.get(`/${t}/versions`)}listForks(t){return this.get(`/${t}/forks`)}requestSlot(t){return async function(t,e){return await t.post("/api/v1/execute/rate-limit/request",{payload:e})}(this.client,t)}resolve(t,e){return this.get(`/resolve/${encodeURIComponent(t)}`,{query:e})}}class H extends w{constructor(t){super(t,"/api/v1/mcp/oauth")}getStatus(t){return this.get(`/status/${t}`)}getCollectionStatus(t,e){return this.get(`/status/${t}/${e}`)}getMetadata(t,e){return this.get(`/metadata/${t}/${e}`)}authorize(t,e){return this.get(`/authorize/${t}/${e}`)}disconnect(t){return this.del(`/disconnect/${encodeURIComponent(t)}`)}getToken(t){return this.post("/token",{payload:{mcp_server_url:t}})}}class L extends w{constructor(t){super(t,"/api/v1/projects"),this.integrations=new W(this)}list(t){return this.get("/",{query:{account:t}})}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}updateConfiguration(t,e){return this.put(`/${t}/configuration`,{payload:e})}getTools(t){return this.get(`/${t}/tools`)}getToolByName(t,e){return this.get(`/${t}/tools/${e}`).catch(t=>{if(404===t.status)return null;throw t})}listAppContentTypes(t,e){return this.get(`/${t}/app-types`,{query:{tag:e}})}getAppContentType(t,e){return this.get(`/${t}/app-types/${e}`)}listAppRenderingTemplates(t,e){return this.get(`/${t}/app-templates`,{query:{tag:e}})}getAppRenderingTemplate(t,e){return this.get(`/${t}/app-templates/${e}`)}getCompositeAppConfiguration(t){return this.get(`/${t}/composite-app`)}updateCompositeAppConfiguration(t,e){return this.put(`/${t}/composite-app`,{payload:e})}}class W extends w{constructor(t){super(t,"/")}list(t){return this.get(`/${t}/integrations`).then(t=>t.integrations)}retrieve(t,e){return this.get(`/${t}/integrations/${e}`).catch(t=>{if(404!==t.status)throw t})}update(t,e,s){return this.put(`/${t}/integrations/${e}`,{payload:s})}}class B extends w{constructor(t){super(t,"/api/v1/skills")}findRelevant(t,e){const s={context:t,limit:e};return this.post("/find-relevant",{payload:s})}findRelevantForTask(t,e){return this.findRelevant({task_description:t,tool_names:e})}}class J extends w{constructor(t){super(t,"/api/v1/prompts")}list(t={}){const e=t.query||{};return this.get("/",{query:{...e}})}computeFacets(t){return this.post("/facets",{payload:t})}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}fork(t,e){return this.post(`/${t}/fork`,{payload:e})}render(t,e){return this.post(`/${t}/render`,{payload:e})}options(t){return this.get(`/options/${t}`)}listVersions(t){return this.get(`/${t}/versions`)}listInteractions(t){return this.get(`/${t}/interactions`)}listForks(t){return this.get(`/${t}/forks`)}}class V extends w{constructor(t){super(t,"/api/v1/refs")}resolve(t){return this.post("/resolve",{payload:{refs:t}})}}class z extends w{constructor(t){super(t,"/api/v1/runs")}list({limit:t,offset:e,filters:s}){const r={limit:t,offset:e,...s};return this.get("/",{query:r})}find(t){return this.post("/find",{payload:t})}async retrieve(t){return F(await this.get("/"+t))}retrievePopulated(t){return this.get("/"+t,{query:{populate:"true"}})}filterOptions(t,e){const s={...e};return this.get(`/filter-options/${t}`,{query:s})}async create(t){const e=this.client.sessionTags;if(e){let s=Array.isArray(e)?e:[e];Array.isArray(t.tags)?s=s.concat(t.tags):t.tags&&(s=s.concat([t.tags])),t={...t,tags:s}}return F(await this.post("/",{payload:t}))}sendToolResults(t){return this.post("/tool-results",{payload:t})}sendUserMessage(t){return this.post("/user-message",{payload:t})}computeFacets(t){return this.post("/facets",{payload:t})}search(t){return this.post("/search",{payload:t})}}class G extends w{constructor(t){super(t,"/api/v1/collections")}search(t){return this.post("/search",{payload:t})}computeListFacets(t){return this.post("/facets",{payload:t})}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}addMembers(t,e){return this.post(`/${t}/members`,{payload:{action:"add",members:e}})}listMembers(t,e){return this.get(`/${t}/members`,{query:{...e}})}computeFacets(t,e){return this.post(`/${t}/facets`,{payload:e})}searchMembers(t,e){return this.post(`/${t}/search`,{payload:e})}deleteMembers(t,e){return this.post(`/${t}/members`,{payload:{action:"delete",members:e}})}addChildren(t,e){return this.post(`/${t}/children`,{payload:{action:"add",children:e}})}deleteChildren(t,e){return this.post(`/${t}/children`,{payload:{action:"delete",children:e}})}searchChildren(t,e={}){return this.post(`/${t}/children/search`,{payload:e})}delete(t){return this.del(`/${t}`)}updatePermissions(t,e){return this.put(`/${t}/permissions`,{payload:e})}propagatePermissions(t){return this.post(`/${t}/propagate-permissions`)}propagateSharedProperties(t){return this.post(`/${t}/propagate-shared-props`)}}class K extends w{constructor(t,e="/api/v1/embeddings"){super(t,e)}async status(t){return this.get(t+"/status")}async activate(t,e){if(!e.environment)throw new Error("Invalid configuration: select environment");return this.post(t+"/enable",{payload:e})}async disable(t){return this.post(t+"/disable")}async recalculate(t){return this.post(t+"/recalculate")}}class Q extends w{constructor(t){super(t,"/api/v1/commands"),this.embeddings=new K(this,"/embeddings")}}class Y extends w{constructor(t,e){super(t,`/api/v1/data/${e}/dashboards`),this.storeId=e}storeHeaders(){return{[e.DATA_STORE_ID]:this.storeId}}list(t){const e=t?`?status=${t}`:"";return this.get(`/${e}`,{headers:this.storeHeaders()})}create(t){return this.post("/",{payload:t,headers:this.storeHeaders()})}retrieve(t){return this.get(`/${t}`,{headers:this.storeHeaders()})}update(t,e){return this.put(`/${t}`,{payload:e,headers:this.storeHeaders()})}delete(t){return this.del(`/${t}`,{headers:this.storeHeaders()})}bulkArchive(t){return this.post("/bulk/archive",{payload:{ids:t},headers:this.storeHeaders()})}bulkDelete(t){return this.post("/bulk/delete",{payload:{ids:t},headers:this.storeHeaders()})}listVersions(t,e){const s=new URLSearchParams;e?.snapshotsOnly&&s.set("snapshots_only","true"),e?.limit&&s.set("limit",String(e.limit));const r=s.toString()?`?${s}`:"";return this.get(`/${t}/versions${r}`,{headers:this.storeHeaders()})}getVersion(t,e){return this.get(`/${t}/versions/${e}`,{headers:this.storeHeaders()})}createSnapshot(t,e){return this.post(`/${t}/versions`,{payload:e,headers:this.storeHeaders()})}promoteVersion(t,e,s){return this.post(`/${t}/versions/${e}/promote`,{payload:s||{},headers:this.storeHeaders()})}setVersioningEnabled(t,e){return this.put(`/${t}/versioning`,{payload:{enabled:e},headers:this.storeHeaders()})}}class X extends w{constructor(t){super(t,"/api/v1/data")}storeHeaders(t){return{[e.DATA_STORE_ID]:t}}list(){return this.get("/")}create(t){return this.post("/",{payload:t})}retrieve(t){return this.get(`/${t}`,{headers:this.storeHeaders(t)})}delete(t){return this.del(`/${t}`,{headers:this.storeHeaders(t)})}getSchema(t,e){const s=e?`?format=${e}`:"";return this.get(`/${t}/schema${s}`,{headers:this.storeHeaders(t)})}updateSchema(t,e){return this.put(`/${t}/schema`,{payload:e,headers:this.storeHeaders(t)})}getSchemaHistory(t){return this.get(`/${t}/schema/history`,{headers:this.storeHeaders(t)})}listTables(t){return this.get(`/${t}/tables`,{headers:this.storeHeaders(t)})}createTables(t,e){return this.post(`/${t}/tables`,{payload:e,headers:this.storeHeaders(t)})}getTable(t,e,s){const r=s?"?sample=true":"";return this.get(`/${t}/tables/${e}${r}`,{headers:this.storeHeaders(t)})}alterTable(t,e,s){return this.put(`/${t}/tables/${e}`,{payload:s,headers:this.storeHeaders(t)})}dropTable(t,e){return this.del(`/${t}/tables/${e}`,{headers:this.storeHeaders(t)})}import(t,e){return this.post(`/${t}/import`,{payload:e,headers:this.storeHeaders(t)})}getImportStatus(t,e){return this.get(`/${t}/import/${e}`,{headers:this.storeHeaders(t)})}listVersions(t,e){const s=e?"?snapshots_only=true":"";return this.get(`/${t}/versions${s}`,{headers:this.storeHeaders(t)})}createSnapshot(t,e){return this.post(`/${t}/versions`,{payload:e,headers:this.storeHeaders(t)})}rollback(t,e){return this.post(`/${t}/versions/${e}/rollback`,{headers:this.storeHeaders(t)})}queryVersion(t,e,s){return this.post(`/${t}/versions/${e}/query`,{payload:s,headers:this.storeHeaders(t)})}query(t,e){return this.post(`/${t}/query`,{payload:e,headers:this.storeHeaders(t)})}validateQueries(t,e){return this.post(`/${t}/query/validate`,{payload:{queries:e},headers:this.storeHeaders(t)})}getDownloadInfo(t,e){const s=e?`?version_id=${e}`:"";return this.get(`/${t}/download${s}`,{headers:this.storeHeaders(t)})}dashboards(t){return new Y(this.client,t)}}class Z extends w{constructor(t){super(t,"/api/v1/email")}send(t){return this.post("/send",{payload:t})}resolveRoute(t){return this.post("/resolve-route",{payload:{route_key:t}})}createRoute(t){return this.post("/routes",{payload:t})}getRoute(t){return this.get(`/routes/${t}`)}updateRoute(t,e){return this.put(`/routes/${t}`,{payload:e})}forwardEmail(t,e){return this.post(`/routes/${t}/forward`,{payload:e})}}class tt extends w{constructor(t,e="/api/v1/indexing"){super(t,e)}async status(){return this.get("/status")}async reindex(t){return this.post("/reindex",{payload:{recreateIndex:t}})}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(t,e){return this.post("/internal/index",{payload:{objectId:t,document:e}})}delete(t){return this.post("/internal/delete",{payload:{objectId:t}})}bulkIndex(t,e){return this.post("/internal/bulk-index",{payload:{documents:t,targetIndex:e}})}ensureIndex(t){return this.post("/internal/ensure-index",{payload:{recreate:t}})}createReindexTarget(){return this.post("/internal/create-reindex-target",{payload:{}})}swapAlias(t,e){return this.post("/internal/swap-alias",{payload:{newIndexName:t,deleteOld:e}})}getStats(){return this.post("/internal/stats",{payload:{}})}getReindexRange(){return this.post("/internal/reindex-range",{payload:{}})}fetchBatch(t,e){return this.post("/internal/fetch-batch",{payload:{cursor:t,limit:e}})}indexBatch(t,e,s,r){return this.post("/internal/index-batch",{payload:{cursor:t,limit:e,targetIndex:s,since:r}})}triggerReindex(t){return this.post("/internal/trigger-reindex",{payload:t??{}})}fetchDocumentsByIds(t){return this.post("/internal/fetch-by-ids",{payload:{objectIds:t}})}bulkDelete(t){return this.post("/internal/bulk-delete",{payload:{objectIds:t}})}getConfiguration(){return this.post("/internal/configuration",{payload:{}})}}class et extends u{constructor(t,e){super("Resource not found: "+e.message,t,404,e.payload)}}class st{constructor(t,e,s,r){this.stream=t,this.name=e,this.type=s,this.id=r}}const rt="memories",nt="agents";function it(t){const e=t.endsWith(".tar.gz")?t:t+".tar.gz";return`${rt}/${e}`}function at(t,e){return`${nt}/${t}/${e}`}class ot extends w{constructor(t){super(t,"/api/v1/files")}async deleteFile(t,e){return(await this.delete(`/${t}`,{query:{prefix:e}})).count}getMetadata(t){return this.get("/metadata",{query:{file:t}})}setFileMetadata(t,e){const s={file:t,metadata:e};return this.put("/metadata",{payload:s})}getOrCreateBucket(){return this.post("/bucket")}getUploadUrl(t){return this.post("/upload-url",{payload:t})}getDownloadUrl(t,e,s){const r={file:t,name:e,disposition:s};return this.post("/download-url",{payload:r})}getDownloadUrlWithOptions(t){return this.post("/download-url",{payload:t})}async uploadFile(t){const e=t instanceof st,{url:s,id:r,path:n}=await this.getUploadUrl(t);return await fetch(s,{method:"PUT",body:e?t.stream:t,duplex:e?"half":void 0,headers:{"Content-Type":t.type||"application/gzip"}}).then(t=>{if(t.ok)return t;throw console.log(t),new Error(`Failed to upload file: ${t.statusText}`)}).catch(t=>{throw console.error("Failed to upload file",{err:t,url:s,id:r,path:n}),t}),r}async downloadFile(t){const e=!t.startsWith("https:"),{url:s}=e?await this.getDownloadUrl(t):{url:t},r=await fetch(s,{method:"GET"}).then(e=>{if(e.ok)return e;throw 404===e.status?new Error(`File at ${s} not found`):403===e.status?new Error(`File at ${s} is forbidden`):(console.log(e),new Error(`Failed to download file ${t}: ${e.statusText}`))}).catch(e=>{throw console.error(`Failed to download file ${t}.`,e),e});if(!r.body)throw new Error(`No body in response while downloading file ${t}`);return r.body}async copyFile(t,e){return(await this.post("/copy",{payload:{source:t,dest:e}})).dest}async uploadMemoryPack(t){const e=it(t.name),s=t.name.endsWith(".tar.gz")?t.name:t.name+".tar.gz";if(t instanceof File){let r=t;return this.uploadFile(new st(r.stream(),s,r.type,e))}return this.uploadFile(new st(t.stream,s,t.type,e))}async downloadMemoryPack(t,e=!1){let s=await this.downloadFile(it(t));if(e){const t=new DecompressionStream("gzip");s=s.pipeThrough(t)}return s}listByPrefix(t){return this.get("/list",{query:{prefix:t}})}async uploadArtifact(t,e,s){const r=at(t,e);if(s instanceof File){const t=s;return this.uploadFile(new st(t.stream(),e,t.type,r))}return this.uploadFile(new st(s.stream,e,s.type,r))}async downloadArtifact(t,e){const s=at(t,e);return this.downloadFile(s)}getArtifactDownloadUrl(t,e,s){const r=at(t,e);return this.getDownloadUrl(r,e,s)}async listArtifacts(t){const e=`${nt}/${t}/`;return(await this.listByPrefix(e)).files}}class lt extends w{constructor(t){super(t,"/api/v1/hive-memory")}list(t){const e=new URLSearchParams;t?.category&&e.set("category",t.category),t?.scope&&e.set("scope",t.scope),t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset));const s=e.toString();return this.get(s?`/?${s}`:"/")}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}search(t){return this.post("/search",{payload:t})}recall(t,e){return this.post("/recall",{payload:{task_description:t,tools:e?.tools,category:e?.category,max_results:e?.maxResults}})}getFormatted(t){return this.get(`/${t}/formatted`)}recordUsage(t){return this.post(`/${t}/usage`,{})}getByCategory(t,e){const s=new URLSearchParams;e?.limit&&s.set("limit",String(e.limit)),e?.offset&&s.set("offset",String(e.offset));const r=s.toString();return this.get(`/category/${t}${r?`?${r}`:""}`)}getStats(){return this.get("/stats")}applyDecay(t){return this.post("/admin/decay",{payload:{days_threshold:t?.daysThreshold,decay_rate:t?.decayRate}})}archiveLowConfidence(t){return this.post("/admin/archive",{payload:{threshold:t}})}}class ut extends w{constructor(t,e){super(t,`/${e}/analyze`),this.objectId=e}async start(t){return this.post("/",{payload:t})}async getStatus(){return this.get("/status")}async getResults(){return this.get("/results")}async adaptTables(t){return this.post("/adapt_tables",{payload:t})}async getAdaptedTables(t,e){const s=t?`/adapt_tables/${t}`:"/adapt_tables",r={};e?.format&&(r.format=e.format),void 0!==e?.raw&&(r.raw=e.raw);const n={query:r};return"csv"===e?.format&&(n.responseType="text"),this.get(s,n)}async getXml(){return this.get("/xml")}async getTables(t){const e={};return t&&(e.query={format:t}),this.get("/tables",e)}async getImages(){return this.get("/images")}async getAnnotated(){return this.get("/annotated")}}class ct extends w{constructor(t){super(t,"/api/v1/objects")}analyze(t){return new ut(this,t)}getUploadUrl(t){return this.post("/upload-url",{payload:t})}getDownloadUrl(t,e,s){return this.post("/download-url",{payload:{file:t,name:e,disposition:s}})}getDownloadUrlWithOptions(t){return this.post("/download-url",{payload:t})}getContentSource(t){return this.get(`/${t}/content-source`)}list(t={}){const e=t.limit||100,s=t.offset||0,r=t.query||{};return this.get("/",{query:{limit:e,offset:s,...r,all_revisions:t.all_revisions,from_root:t.from_root||void 0}})}computeFacets(t){return this.post("/facets",{payload:t})}listFolders(t="/"){}find(t){return this.post("/find",{payload:t})}count(t){return this.post("/count",{payload:t})}search(t){return this.post("/search",{payload:t})}retrieve(t,e){return this.get(`/${t}`,{query:{select:e}})}getObjectText(t){return this.get(`/${t}/text`)}async upload(t){const e=t instanceof st,{url:s,id:r,mime_type:n}=await this.getUploadUrl({id:e?t.id:void 0,name:t.name,mime_type:t.type}),i=t.type||n,a=await fetch(s,{method:"PUT",body:e?t.stream:t,duplex:e?"half":void 0,headers:i?{"Content-Type":i}:void 0}).then(t=>{if(t.ok)return t;throw console.log(t),new Error(`Failed to upload file: ${t.statusText}`)}).catch(t=>{throw console.error("Failed to upload file",t),t}),o=a.headers.get("etag")?.replace(/^"(.*)"$/,"$1");return{source:r,name:t.name,type:i,etag:o}}async create(t,e){const r={...t};(t.content instanceof st||t.content instanceof File)&&(r.content=await this.upload(t.content));const n={};return e?.processing_priority&&(n[s.PROCESSING_PRIORITY]=e.processing_priority),e?.collection_id&&(n[s.COLLECTION_ID]=e.collection_id),await this.post("/",{payload:r,headers:n})}async createFromExternalSource(t,e={},r){const n=await this.client.files.getMetadata(t),i={...e,content:{source:t,name:n.name,type:n.contentType,etag:n.etag}},a={};return r?.processing_priority&&(a[s.PROCESSING_PRIORITY]=r.processing_priority),r?.collection_id&&(a[s.COLLECTION_ID]=r.collection_id),await this.post("/",{payload:i,headers:a})}async update(t,e,r){const n={...e};(e.content instanceof st||e.content instanceof File)&&(n.content=await this.upload(e.content));const i={};return r?.ifMatch&&(i["if-match"]=r.ifMatch),r?.processing_priority&&(i[s.PROCESSING_PRIORITY]=r.processing_priority),r?.createRevision&&(i[s.CREATE_REVISION]="true",r.revisionLabel&&(i[s.REVISION_LABEL]=r.revisionLabel)),r?.suppressWorkflows&&(i[s.SUPPRESS_WORKFLOWS]="true"),this.put(`/${t}`,{payload:n,headers:i})}getRevisions(t){return this.get(`/${t}/revisions`)}getCollections(t){return this.get(`/${t}/collections`)}delete(t){return this.del(`/${t}`)}listWorkflowRuns(t){return this.get(`/${t}/workflow-runs`)}listRenditions(t){return this.get(`/${t}/renditions`)}getRendition(t,e){const s={max_hw:e.max_hw,generate_if_missing:e.generate_if_missing,sign_url:e.sign_url,block_on_generation:e.block_on_generation};return this.get(`/${t}/renditions/${e.format}`,{query:s})}getRenditionSafe(t,e,s){return r(e,s.format)?this.getRendition(t,s):Promise.resolve(null)}exportProperties(t){return this.post("/export",{payload:t})}setEmbedding(t,e,s){return this.put(`/${t}/embeddings/${e}`,{payload:s})}}class ht extends w{constructor(t){super(t,"/api/v1/pending-asks")}register(t){return this.post("/",{payload:t})}resolve(t,e){return this.post(`/${t}/resolve`,{payload:e})}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}}class pt extends w{constructor(t,e="/api/v1/query"){super(t,e)}async execute(t){return this.post("/",{payload:t})}async sql(t){return this.execute({sql:t})}async esql(t){return this.execute({esql:t})}async dsl(t){return this.execute({dsl:t})}}class dt extends w{constructor(t){super(t,"/api/v1/rendering")}start(t){return this.post("/jobs",{payload:t})}getStatus(t,e){return this.get("/jobs/status",{query:{workflow_id:t,workflow_run_id:e}})}async render(t,e={}){const s=e.pollIntervalMs??1500,r=e.timeoutMs??6e5,a=await this.start(t);if(!a.workflow_id||!a.workflow_run_id)throw new Error("Failed to start rendering workflow");const o=Date.now();for(;;){const e=await this.getStatus(a.workflow_id,a.workflow_run_id);if(e.status===n.COMPLETED){if(!e.download_url&&!e.file_uri)throw new Error(e.error||"Rendering completed but no output file was produced");return{status:"success",format:t.format,download_url:e.download_url,file_uri:e.file_uri}}if(i(e.status)){const t=n[e.status]||String(e.status);throw new Error(e.error||`Rendering failed with status: ${t}`)}if(Date.now()-o>=r)throw new Error(`Rendering timed out after ${r}ms`);await gt(s)}}}function gt(t){return new Promise(e=>setTimeout(e,t))}class yt extends w{constructor(t){super(t,"/api/v1/schedules")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}create(t){return this.post("/",{payload:t})}update(t,e){return this.put(`/${t}`,{payload:e})}delete(t){return this.del(`/${t}`)}trigger(t){return this.post(`/${t}/trigger`,{})}pause(t,e){return this.post(`/${t}/pause`,{payload:{note:e}})}resume(t,e){return this.post(`/${t}/resume`,{payload:{note:e}})}}class mt extends w{constructor(t){super(t,"/api/v1/tools")}getBuiltinCatalog(){return this.get("/")}}class ft extends w{constructor(t){super(t,"/api/v1/types/catalog")}list(t={}){return this.get("/",{query:t})}listSysTypes(t){return this.get("/sys",{query:{tag:t}})}listAppTypes(t){return this.get("/apps",{query:{tag:t}})}listStoredTypes(t={}){return this.get("/stored",{query:t})}resolve(t){const e="string"==typeof t?t:t.code||t.id;return this.get(`/resolve/${e}`)}}class wt extends w{constructor(t){super(t,"/api/v1/types"),this.catalog=new ft(t)}list(t={},e){const s=t.limit||2e3,r=t.offset||0,n=t.query||{};return this.get("/",{query:{limit:s,offset:r,layout:!!e?.layout,schema:!!e?.schema,...n}})}find(t){return this.post("/find",{payload:t})}retrieve(t){return this.get(`/${t}`)}getTypeByName(t){return this.get(`/name/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}}const vt="20260210",$t="x-api-version";class bt extends w{constructor(t){super(t,"/api/v1/workers")}async deploy(t){return this.post("/",{payload:t})}}class St extends w{constructor(t){super(t,"/api/v1/workflows"),this.rules=new xt(this),this.definitions=new kt(this)}getActivityCatalog(){return this.get("/activity-catalog")}listRuns(t,e,s){return this.post("/runs",{payload:{documentId:t,eventName:e,ruleId:s}})}listConversations(t){return this.post("/conversations",{payload:t})}searchRuns(t){return this.post("/runs",{payload:t})}sendSignal(t,e,s,r){return this.post(`/runs/${t}/${e}/signal/${s}`,{payload:r})}getRunDetails(t,e,s){const r={};return void 0!==s?.includeHistory&&(r.include_history=s.includeHistory),void 0!==s?.historyFormat&&(r.history_format=s.historyFormat),this.get(`/runs/${e}/${t}`,{query:r})}getRunInteraction(t,e){return this.get(`/runs/${t}/${e}/interaction`)}terminate(t,e,s){const r={reason:s};return this.post(`/runs/${t}/${e}/actions/terminate`,{payload:r})}cancel(t,e,s){const r={reason:s};return this.post(`/runs/${t}/${e}/actions/cancel`,{payload:r})}query(t,e,s){return this.get(`/runs/${t}/${e}/query/${s}`)}execute(t,e={}){return this.post(`/execute/${t}`,{payload:e})}postMessage(t,e){if(!t)throw new Error("runId is required");return this.post(`/runs/${t}/updates`,{payload:e})}async retrieveMessages(t,e,s){const r={since:s};return(await this.get(`/runs/${t}/${e}/updates`,{query:r})).messages.map(t=>a(t,e))}async streamMessages(t,e,s,r){return new Promise(async(n,i)=>{let u=0,c=r||0,h=!1,p=null,d=null;const g=10,y=t=>{const e=Math.min(1e3*Math.pow(2,t),3e4);return e+.1*Math.random()*e},m=()=>{d&&(clearInterval(d),d=null),p&&(p.close(),p=null)},f=t=>{h||(h=!0,m(),n(t))};try{const i=await this.retrieveMessages(t,e,r);for(const t of i){c=Math.max(c,t.timestamp||0),s&&s(t,f);const e=t.workstream_id||"main";if(t.type===o.TERMINATED||t.type===o.COMPLETE&&"main"===e)return console.log("Workflow already completed in historical messages"),void n(null)}}catch(t){console.warn("Failed to fetch historical messages, continuing with SSE:",t)}const w=async(r=!1)=>{if(!h)try{const v=await U(),$=this.client,b=new URL($.workflows.baseUrl+`/runs/${t}/${e}/stream`);c>0&&b.searchParams.set("since",c.toString()),b.searchParams.set("skipHistory","true");const S=$._auth?await $._auth():void 0;if(!S)return void i(new Error("No auth token available"));const x=S.split(" ")[1];b.searchParams.set("access_token",x),r&&console.log(`Reconnecting to SSE stream for run ${e} (attempt ${u+1}/10)`);const k=new v(b.href);p=k,d=setInterval(()=>{},1e3),k.onopen=()=>{r&&console.log(`Successfully reconnected to SSE stream for run ${e}`),u=0},k.onmessage=t=>{if(t.data&&!t.data.startsWith(":"))try{const r=l(t.data);if(c=r.ts?Math.max(c,r.ts):Date.now(),s){const t=a(r,e);s(t,f)}const i=r.w||"main";r.t===o.TERMINATED||r.t===o.COMPLETE&&"main"===i?(console.log("Closing stream due to COMPLETE message from main workstream"),h||(h=!0,m(),n(null))):r.t===o.COMPLETE&&console.log(`Received COMPLETE message from non-main workstream: ${i}, keeping stream open`)}catch(e){console.error("Failed to parse SSE message:",e,t.data)}else console.log("Received comment or heartbeat; ignoring it.: ",t.data)},k.onerror=t=>{if(!h)if(console.warn(`SSE stream error for run ${e}:`,t),m(),u<g){const t=y(u);console.log(`Attempting to reconnect in ${t}ms (attempt ${u+1}/10)`),u++,setTimeout(()=>{h||w(!0)},t)}else console.error(`Failed to reconnect to SSE stream for run ${e} after 10 attempts`),h=!0,i(new Error("SSE connection failed after 10 reconnection attempts"))}}catch(t){if(console.error("Error setting up SSE stream:",t),u<g){const t=y(u);u++,setTimeout(()=>{h||w(!0)},t)}else i(t)}};return w(!1),()=>{h=!0,m()}})}async streamMessagesWS(t,e,s,r){return new Promise((n,i)=>{let a=0;const u=10;let c=null,h=r||0,p=!1;const d=t=>{const e=Math.min(1e3*Math.pow(2,t),3e4);return e+.1*Math.random()*e},g=async()=>{if(!p)try{const r=this.client,y=new URL(r.workflows.baseUrl+`/runs/${t}/${e}/ws`);y.protocol=y.protocol.replace("http","ws"),h>0&&y.searchParams.set("since",h.toString());const m=r._auth?await r._auth():void 0;if(!m)return void i(new Error("No auth token available"));const f=m.split(" ")[1];y.searchParams.set("access_token",f),a>0&&console.log(`Reconnecting to WebSocket for run ${e} (attempt ${a+1}/10)`),c=new WebSocket(y.href),c.onopen=()=>{a>0&&console.log(`Successfully reconnected to WebSocket for run ${e}`),a=0,p||n({cleanup:()=>{p=!0,c&&(c.close(),c=null)},sendSignal:(t,e)=>{if(c?.readyState===WebSocket.OPEN){const s={type:"signal",signalName:t,data:e,requestId:Date.now()};c.send(JSON.stringify(s))}else console.warn("WebSocket not open, cannot send signal")}})},c.onmessage=t=>{try{const e=JSON.parse(t.data);if("type"in e&&"string"==typeof e.type){if("pong"===e.type)return void console.debug("Received pong");if("ack"===e.type)return void console.debug("Signal acknowledged",e);if("error"===e.type)return void console.error("WebSocket error message",e)}const r=l(e);h=r.ts?Math.max(h,r.ts):Date.now(),s&&s(r);const n=r.w||"main";(r.t===o.TERMINATED||r.t===o.COMPLETE&&"main"===n)&&(console.log("Closing WebSocket due to workflow completion"),p=!0,c&&(c.close(),c=null))}catch(t){console.error("Failed to parse WebSocket message",t)}},c.onerror=t=>{console.error("WebSocket error",t)},c.onclose=()=>{if(!p&&a<u){const t=d(a);console.log(`WebSocket closed, reconnecting in ${t}ms (attempt ${a+1}/10)`),a++,setTimeout(g,t)}else a>=u&&i(new Error("WebSocket connection failed after 10 attempts"))}}catch(t){if(console.error("Error setting up WebSocket",t),a<u){const t=d(a);a++,setTimeout(g,t)}else i(t)}};g()})}ingestEvents(t,e,s){return this.post(`/runs/${t}/${e}/events`,{payload:{events:s}})}getAnalyticsSummary(t={}){return this.post("/analytics/summary",{payload:t})}getTokenUsageAnalytics(t={}){return this.post("/analytics/tokens",{payload:t})}getLlmLatencyAnalytics(t={}){return this.post("/analytics/latency/llm",{payload:t})}getToolLatencyAnalytics(t={}){return this.post("/analytics/latency/tools",{payload:t})}getAgentLatencyAnalytics(t={}){return this.post("/analytics/latency/agents",{payload:t})}getErrorAnalytics(t={}){return this.post("/analytics/errors",{payload:t})}getToolAnalytics(t={}){return this.post("/analytics/tools",{payload:t})}getToolParameterAnalytics(t){return this.post("/analytics/tools/parameters",{payload:t})}getAnalyticsFilterOptions(t={}){return this.post("/analytics/filter-options",{payload:t})}getPromptSizeAnalytics(t={}){return this.post("/analytics/prompt-size",{payload:t})}getTopPrincipalsAnalytics(t={}){return this.post("/analytics/top-principals",{payload:t})}getRunsByAgentAnalytics(t={}){return this.post("/analytics/runs-by-agent",{payload:t})}getTimeToFirstResponseAnalytics(t={}){return this.post("/analytics/time-to-first-response",{payload:t})}getFirstResponseBehaviorAnalytics(t={}){return this.post("/analytics/first-response-behavior",{payload:t})}}class xt extends w{constructor(t){super(t,"/rules")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}execute(t,e,s){const r={objectIds:e,vars:s};return this.post(`/${t}/execute`,{payload:r})}}class kt extends w{constructor(t){super(t,"/definitions")}list(){return this.get("/")}retrieve(t){return this.get(`/${t}`)}update(t,e){return this.put(`/${t}`,{payload:e})}create(t){return this.post("/",{payload:t})}delete(t){return this.del(`/${t}`)}}class Tt extends f{constructor(t={}){super(function(t){if(!t)throw new Error("zeno client serverUrl is required");return t}(t.serverUrl)),this.objects=new ct(this),this.types=new wt(this),this.workflows=new St(this),this.schedules=new yt(this),this.files=new ot(this),this.commands=new Q(this),this.workers=new bt(this),this.collections=new G(this),this.embeddings=new K(this),this.email=new Z(this),this.pendingAsks=new ht(this),this.data=new X(this),this.tools=new mt(this),this.indexing=new tt(this),this.query=new pt(this),this.hiveMemory=new lt(this),this.rendering=new dt(this),t.apikey&&this.withApiKey(t.apikey),this.onRequest=t.onRequest,this.onResponse=t.onResponse,this.errorFactory=t=>404===t.status?new et(t.request,t):t}withApiVersion(t){return t?this.headers[$t]=String(t):delete this.headers[$t],this}withApiKey(t){return this.withAuthCallback(t?()=>Promise.resolve(`Bearer ${t}`):void 0)}runOperation(t){return this.post("/api/v1/operations",{payload:t})}get initialHeaders(){return{...super.initialHeaders,[$t]:vt}}}class _t extends w{constructor(t){super(t,"/api/v1/training")}listSessions(t={}){return this.get("/",{query:t})}listSessionNames(t={}){return this.get("/names",{query:t})}createSession(t){return this.post("/",{payload:t})}getSession(t){return this.get("/"+t)}addToSession(t,e){return this.post("/"+t+"/add",{payload:{runs:e}})}listSessionRuns(t,e=100,s=0){return this.get("/"+t+"/runs",{query:{limit:e,offset:s}})}buildSession(t){return this.post("/"+t+"/build")}getDataUrl(t){return this.get("/"+t+"/url")}getDataUploadUrl(t,e=!1){return this.get("/"+t+"/upload-url",e?{query:{resumable:"true"}}:{})}startTraining(t){return this.post("/"+t+"/start")}cancelTraining(t){return this.post("/"+t+"/cancel")}getTrainingJob(t){return this.get(`/job/${t}`)}getAndSyncTrainingJob(t){return this.get(`/job/${t}`,{query:{sync:"true"}})}setDataset(t,e="default"){return this.post("/"+t+"/dataset",{payload:{dataset:e}})}}class Et extends w{constructor(t){super(t,"/api/v1/users")}retrieve(t){return this.get("/"+t)}update(t,e){return this.put("/"+t,{payload:e})}delete(t){return this.del("/"+t)}}class Rt extends f{static async fromAuthToken(t,e,s){e||(e=qt(t));const r=s||It(e.endpoints);return await new Rt({serverUrl:r.studio,storeUrl:r.store,tokenServerUrl:r.token||e.iss}).withApiKey(t)}static decodeEndpoints(){}constructor(t={site:"api.vertesia.io"}){let e,s;if(t.serverUrl)e=t.serverUrl;else{if(!t.site)throw new Error("Parameter 'site' or 'serverUrl' is required for VertesiaClient");e=`https://${t.site}`}if(t.storeUrl)s=t.storeUrl;else{if(!t.site)throw new Error("Parameter 'site' or 'storeUrl' is required for VertesiaClient");s=`https://${t.site}`}if(super(e),this._jwt=null,this.projects=new L(this),this.environments=new _(this),this.interactions=new N(this),this.skills=new B(this),this.prompts=new J(this),this.runs=new z(this),this.account=new v(this),this.accounts=new $(this),this.apikeys=new x(this),this.analytics=new b(this),this.auditTrail=new S(this),this.training=new _t(this),this.users=new Et(this),this.iam=new R(this),this.refs=new V(this),this.commands=new T(this),this.apps=new k(this),this.mcpOAuth=new H(this),t.tokenServerUrl)this.tokenServerUrl=t.tokenServerUrl;else if(t.site)"api-preview.vertesia.io"===t.site||"api.vertesia.io"===t.site?this.tokenServerUrl="https://sts.vertesia.io":this.tokenServerUrl=`https://${t.site.replace(/^api/,"sts")}`;else if(t.serverUrl||t.storeUrl){const e=t.serverUrl||t.storeUrl||"";try{const t=new URL(e);t.hostname.includes("-production.")||t.hostname.includes("-preview.")||"api.vertesia.io"===t.hostname||"api-preview.vertesia.io"===t.hostname?this.tokenServerUrl="https://sts.vertesia.io":"api-staging.vertesia.io"===t.hostname?this.tokenServerUrl="https://sts-staging.vertesia.io":t.hostname.startsWith("api")?(t.hostname=t.hostname.replace(/^api/,"sts"),this.tokenServerUrl=t.toString()):this.tokenServerUrl="https://sts-staging.vertesia.io"}catch(t){this.tokenServerUrl="https://sts-staging.vertesia.io"}}else this.tokenServerUrl="https://sts-staging.vertesia.io";this.store=new Tt({serverUrl:s,tokenServerUrl:this.tokenServerUrl,apikey:t.apikey,onRequest:t.onRequest,onResponse:t.onResponse}),t.apikey&&this.withApiKey(t.apikey),this.onRequest=t.onRequest,this.onResponse=t.onResponse,this.sessionTags=t.sessionTags}withApiVersion(t){return t?this.headers[$t]=String(t):delete this.headers[$t],this}withAuthCallback(t){return this.store.withAuthCallback(t),super.withAuthCallback(t)}async withApiKey(t){return this.withAuthCallback(t?async()=>{if(!function(t){return t.startsWith("pk-")||t.startsWith("sk-")}(t))return`Bearer ${t}`;if(function(t){if(!t)return!0;const e=qt(t).exp;return Date.now()<=1e3*e-6e4}(this._jwt)){const e=await this.getAuthToken(t);this._jwt=e.token}return`Bearer ${this._jwt}`}:void 0)}async getRawJWT(){if(!this._jwt&&this._auth){const t=await this._auth();this._jwt||(this._jwt=t.trim().split(" ")[1])}return this._jwt||null}async getDecodedJWT(){const t=await this.getRawJWT();return t?qt(t):null}async getProject(){const t=await this.getDecodedJWT();return t?.project||null}async getAccount(){const t=await this.getDecodedJWT();return t?.account||null}get workflows(){return this.store.workflows}get objects(){return this.store.objects}get files(){return this.store.files}get types(){return this.store.types}get data(){return this.store.data}get storeUrl(){return this.store.baseUrl}async getAuthToken(t){return fetch(`${this.tokenServerUrl}/token/issue`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}}).then(t=>t.json()).then(t=>t).catch(t=>{throw console.error(`Error fetching token from ${this.tokenServerUrl}:`,{error:t}),t})}get initialHeaders(){return{...super.initialHeaders,[$t]:vt}}}function qt(t){const e=function(t){const e=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(4*Math.ceil(t.length/4),"=");if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("utf-8");if("undefined"!=typeof atob&&"undefined"!=typeof TextDecoder){const t=atob(e),s=Uint8Array.from(t,t=>t.charCodeAt(0));return(new TextDecoder).decode(s)}throw new Error("No base64 decoder available")}(t.split(".")[1]);return JSON.parse(e)}function It(t){return t?"string"==typeof t?Ut(t):t:Ut("api.vertesia.io")}function Ut(t){if("local"===t)return{studio:"http://localhost:8091",store:"http://localhost:8092",token:process.env.STS_URL??"https://sts-staging.vertesia.io"};{const e=`https://${t}`;return{studio:e,store:e,token:e.replace("api","sts")}}}class At{constructor(t,e){this.id=t,this.client=e instanceof Rt?e:new Rt(e)}retrieve(){return this.client.interactions.retrieve(this.id)}update(t){return this.client.interactions.update(this.id,t)}render(t){}async execute(t={},e){return A(this.client,this.id,t,e)}}export{nt as ARTIFACTS_PREFIX,Q as CommandsApi,X as DataApi,Z as EmailApi,ot as FilesApi,lt as HiveMemoryApi,O as IS_INTERACTION_OUTPUT,tt as IndexingApi,At as InteractionBase,D as InteractionOutput,rt as MEMORIES_PREFIX,ct as ObjectsApi,ht as PendingAsksApi,pt as QueryApi,dt as RenderingApi,yt as SchedulesApi,st as StreamSource,ft as TypeCatalogApi,wt as TypesApi,Rt as VertesiaClient,St as WorkflowsApi,kt as WorkflowsDefinitionApi,xt as WorkflowsRulesApi,Tt as ZenoClient,et as ZenoClientNotFoundError,M as createInteractionOutput,It as decodeEndpoints,qt as decodeJWT,F as enhanceExecutionRun,C as enhanceInteractionExecutionResult,at as getAgentArtifactPath,it as getMemoryFilePath};
|
|
2
2
|
//# sourceMappingURL=vertesia-client.js.map
|