@alva-ai/toolkit 0.14.1-beta.0 → 0.15.1-beta.0

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.
@@ -1,4 +1,4 @@
1
- "use strict";var AlvaToolkit=(()=>{var D=Object.defineProperty;var Ze=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var tt=Object.prototype.hasOwnProperty;var s=(t,e)=>D(t,"name",{value:e,configurable:!0});var rt=(t,e)=>{for(var r in e)D(t,r,{get:e[r],enumerable:!0})},it=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of et(e))!tt.call(t,n)&&n!==r&&D(t,n,{get:()=>e[n],enumerable:!(i=Ze(e,n))||i.enumerable});return t};var st=t=>it(D({},"__esModule",{value:!0}),t);var It={};rt(It,{AlvaClient:()=>me,AlvaError:()=>l,CliUsageError:()=>j,PBSV_UPDATE_MESSAGE:()=>Ce,SUBSCRIBE_PROPOSE_MESSAGE:()=>Ue,SUBSCRIBE_RESULT_MESSAGE:()=>Fe,UDF_AUTH_REQUIRED_MESSAGE:()=>Ge,UDF_CONSENT_REQUEST_MESSAGE:()=>xe,UDF_CONSENT_RESPONSE_MESSAGE:()=>Ie,UdfAuthRequiredError:()=>q,UdfConsentDeniedError:()=>S,UdfConsentRequiredError:()=>w,UdfConsentTimeoutError:()=>A,UdfError:()=>p,UdfExecutionError:()=>U,UdfFunctionDisabledError:()=>I,UdfFunctionNotFoundError:()=>x,UdfInsufficientCredits:()=>C,UdfPidMismatchError:()=>k,UdfRateLimitedError:()=>G,UdfTokenExpiredError:()=>T,UdfTokenInvalidError:()=>E,UdfTransportError:()=>P,VERSION:()=>xt,getViewerToken:()=>F,installPlaybookRuntime:()=>qe,mapUdfErrorResponse:()=>ge,playbookIdFromToken:()=>ke,subscribe:()=>je,udf:()=>Be});var p=class extends Error{static{s(this,"UdfError")}code;metadata;status;constructor(e,{code:r,metadata:i={},status:n}){super(e),this.name=new.target.name,this.code=r,this.metadata=i,this.status=n}},q=class extends p{static{s(this,"UdfAuthRequiredError")}constructor(){super("Sign in to use this UDF.",{code:"AUTH_REQUIRED"})}},T=class extends p{static{s(this,"UdfTokenExpiredError")}},E=class extends p{static{s(this,"UdfTokenInvalidError")}},k=class extends p{static{s(this,"UdfPidMismatchError")}},w=class extends p{static{s(this,"UdfConsentRequiredError")}},S=class extends p{static{s(this,"UdfConsentDeniedError")}constructor(){super("UDF consent was denied.",{code:"CONSENT_DENIED"})}},A=class extends p{static{s(this,"UdfConsentTimeoutError")}constructor(){super("UDF consent timed out.",{code:"CONSENT_TIMEOUT"})}},C=class extends p{static{s(this,"UdfInsufficientCredits")}},x=class extends p{static{s(this,"UdfFunctionNotFoundError")}},I=class extends p{static{s(this,"UdfFunctionDisabledError")}},G=class extends p{static{s(this,"UdfRateLimitedError")}},U=class extends p{static{s(this,"UdfExecutionError")}},P=class extends p{static{s(this,"UdfTransportError")}},Ce="alva:pbsv:update",xe="alva:udf:consent-request",Ie="alva:udf:consent-response",Ge="alva:udf:auth-required",Ue="alva:subscribe:propose",Fe="alva:subscribe:result",Ne="https://api-llm.prd.alva.ai",Le=300*1e3,R=null,_=null,be=Ne,h=null,m=null,Ae=!1,O=new Map,M=new Map,nt=s(t=>t==="subscribed"||t==="declined"||t==="timeout"?t:"error","normalizeProposalResult"),ot=s(t=>{let e=t.replace(/-/g,"+").replace(/_/g,"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return atob(r)},"decodeBase64Url"),ke=s(t=>{if(!t)return null;let[,e]=t.split(".");if(!e)return null;try{let r=JSON.parse(ot(e));if(typeof r.pid=="number")return String(r.pid);if(typeof r.pid=="string")return r.pid}catch{return null}return null},"playbookIdFromToken"),F=s(()=>R,"getViewerToken"),v=s(()=>!!F(),"isAuthenticated"),at=s(t=>{let e=new URL(t.location.href);e.searchParams.delete("_pbsv"),t.history.replaceState(null,"",e.pathname+e.search+e.hash)},"stripPbsvFromUrl"),lt=s(t=>{let e=new URLSearchParams(t.location.search);R=e.get("_pbsv"),_=e.get("parent_origin"),be=(e.get("api_origin")||Ne).replace(/\/$/,""),h=ke(R),R&&at(t)},"parseBootParams"),De=s(async t=>{try{return await t.json()}catch{return{}}},"safeJson"),ct=s(t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}},"parseResultPayload"),ut=s(t=>{let e=t;return{...e,result:ct(e.result)}},"normalizeInvokeResponse"),Oe=s(t=>t.error?.metadata||t.details?.metadata||{},"errorMetadata"),ge=s((t,e)=>{let r=t.error?.code||"TRANSPORT",i=t.error?.message||r,n=Oe(t),o={code:r,metadata:n,status:e};switch(r){case"PBSV_EXPIRED":return new T(i,o);case"PBSV_INVALID":case"UNAUTHENTICATED":return new E(i,o);case"PBSV_PID_MISMATCH":return new k(i,o);case"CONSENT_REQUIRED":return new w(i,o);case"INSUFFICIENT_CREDITS":return new C(i,o);case"FUNCTION_NOT_FOUND":return new x(i,o);case"FUNCTION_DISABLED":return new I(i,o);case"RESOURCE_EXHAUSTED":return new G(i,o);case"EXECUTION_FAILED":return new U(i,o);default:return new P(i,o)}},"mapUdfErrorResponse"),pt=s(t=>{if(!m||!_||t.origin!==_||t.source!==m.parent||!t.data||typeof t.data!="object")return;let e=t.data;if(e.type===Ce){typeof e.token=="string"&&e.token.length>0&&(R=e.token,h=ke(e.token));return}if(e.type===Fe){if(typeof e.request_id!="string")return;let i=M.get(e.request_id);if(!i)return;clearTimeout(i.timer),M.delete(e.request_id),i.resolve(nt(e.status));return}if(e.type!==Ie||typeof e.request_id!="string")return;let r=O.get(e.request_id);r&&(clearTimeout(r.timer),O.delete(e.request_id),r.resolve(e.granted===!0?"granted":"denied"))},"onMessage"),Me=s(()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`,"randomRequestId"),dt=s(()=>{if(!h)return null;let t=Number(h);return Number.isSafeInteger(t)?t:null},"playbookIdForInvoke"),mt=s(async(t,e)=>{if(!m||!_)return"denied";let r=_,i=Me();return new Promise(n=>{let o=setTimeout(()=>{O.delete(i),n("timeout")},Le);O.set(i,{resolve:n,timer:o}),m?.parent.postMessage({type:xe,request_id:i,playbook_id:t,min_allowance:e},r)})},"requestConsent"),ft=s(async t=>{if(!m||!_)return"error";let e=typeof t?.feedOwner=="string"?t.feedOwner.trim():"",r=typeof t?.feedName=="string"?t.feedName.trim():"";if(!e||!r)return"error";let i=_,n=Me();return new Promise(o=>{let a=setTimeout(()=>{M.delete(n),o("timeout")},Le);M.set(n,{resolve:o,timer:a}),m?.parent.postMessage({type:Ue,request_id:n,playbook_id:h,feed:{owner:e,name:r}},i)})},"proposeSubscribe"),je={propose:ft},yt=s(t=>{!m||!_||m.parent.postMessage({type:Ge,function_name:t},_)},"requestAuthentication"),ve=s(async(t,e,r=!1)=>{let i=F();if(!i)throw new q;if(!h)throw new k("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let n=dt();if(!n)throw new k("Invalid playbook id.",{code:"PBSV_PID_MISMATCH"});let o;try{o=await fetch(`${be}/api/v1/service/invoke`,{method:"POST",headers:{Authorization:`Bearer ${i}`,"X-Pbsv":"1","Content-Type":"application/json"},body:JSON.stringify({playbook_id:n,function_name:t,parameters_json:JSON.stringify(e)})})}catch{throw new P("Network error while invoking UDF.",{code:"TRANSPORT"})}let a=await De(o);if(o.ok)return ut(a);if(a.error?.code==="CONSENT_REQUIRED"&&!r){let c=Oe(a),u=typeof c.playbook_id=="string"?c.playbook_id:h,d=typeof c.min_allowance_suggested=="number"?c.min_allowance_suggested:1,f=await mt(u,d);if(f==="granted")return ve(t,e,!0);throw f==="timeout"?new A:new S}throw ge(a,o.status)},"call"),_t=s(async()=>{let t=F();if(!t)throw new q;if(!h)throw new k("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let e=new URL(`${be}/api/v1/service/functions`);e.searchParams.set("playbook_id",h);let r=await fetch(e.toString(),{headers:{Authorization:`Bearer ${t}`,"X-Pbsv":"1"}}),i=await De(r);if(!r.ok)throw ge(i,r.status);let n=i.functions;return Array.isArray(n)?n:[]},"list"),he=s((t,e,r)=>{t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:r}))},"dispatchButtonEvent"),ht=s(t=>{if(typeof t!="string")return t;let r=m?.document?.querySelector(t);if(r&&"appendChild"in r)return r;throw new Error(`UDF button target not found: ${t}`)},"resolveButtonTarget"),bt=s((t,e)=>{if(!m)throw new Error("Playbook runtime is not installed.");let r=ht(t),i=m.document.createElement("button"),n=e.label||e.functionName,o=e.loadingLabel||"Running...",a=e.disabledLabel||"Sign in to run";return i.type="button",i.className="alva-udf-button",i.textContent=v()?n:a,i.disabled=!1,i.setAttribute("data-function-name",e.functionName),v()||i.setAttribute("aria-disabled","true"),i.addEventListener("click",async()=>{if(!v()){yt(e.functionName);return}if(!i.disabled){i.disabled=!0,i.textContent=o,he(i,"alva:udf-button:loading",{functionName:e.functionName});try{let c=await ve(e.functionName,e.params??{});he(i,"alva:udf-button:result",{functionName:e.functionName,result:c})}catch(c){he(i,"alva:udf-button:error",{functionName:e.functionName,error:c})}finally{i.disabled=!1,i.textContent=v()?n:a,v()||i.setAttribute("aria-disabled","true")}}}),r.appendChild(i),i},"renderButton"),Be={call:ve,list:_t,getViewerToken:F,isAuthenticated:v,renderButton:bt,UdfError:p,UdfAuthRequiredError:q,UdfTokenExpiredError:T,UdfTokenInvalidError:E,UdfPidMismatchError:k,UdfConsentRequiredError:w,UdfConsentDeniedError:S,UdfConsentTimeoutError:A,UdfInsufficientCredits:C,UdfFunctionNotFoundError:x,UdfFunctionDisabledError:I,UdfRateLimitedError:G,UdfExecutionError:U,UdfTransportError:P},qe=s(t=>{let e=t??(typeof window>"u"?void 0:window);if(!e||Ae)return;m=e,Ae=!0,lt(e),e.addEventListener("message",pt);let r=e,i=r.alva||{};r.alva={...i,udf:Be,subscribe:je}},"installPlaybookRuntime");var l=class extends Error{static{s(this,"AlvaError")}code;status;details;constructor(e,r,i,n){super(r),this.name="AlvaError",this.code=e,this.status=i,this.details=n}},j=class extends Error{static{s(this,"CliUsageError")}command;constructor(e,r){super(e),this.name="CliUsageError",this.command=r}};function kt(t){let e=0;for(;e<t.length;){let r=t[e];if(r<=127){e+=1;continue}let i=0,n=0,o=0;if(r>=194&&r<=223)i=1,n=128,o=r&31;else if(r>=224&&r<=239)i=2,n=2048,o=r&15;else if(r>=240&&r<=244)i=3,n=65536,o=r&7;else return!1;if(e+i>=t.length)return!1;for(let a=1;a<=i;a+=1){let c=t[e+a];if((c&192)!==128)return!1;o=o<<6|c&63}if(o<n||o>1114111||o>=55296&&o<=57343)return!1;e+=i+1}return!0}s(kt,"isValidUtf8");var B=class{constructor(e){this.client=e}client;static{s(this,"FsResource")}async read(e){let r=await this.client._request("GET","/api/v1/fs/read",{query:{path:e.path,offset:e.offset,size:e.size}});if(!(r instanceof ArrayBuffer)||!kt(new Uint8Array(r)))return r;let i=new TextDecoder("utf-8").decode(r);try{return JSON.parse(i)}catch{return i}}async write(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/fs/write",{body:{path:e.path,data:e.data,mkdir_parents:e.mkdir_parents}})}async rawWrite(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/fs/write",{query:{path:e.path,mkdir_parents:e.mkdir_parents},rawBody:e.body})}async stat(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/stat",{query:{path:e.path}})}async readdir(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/readdir",{query:{path:e.path,recursive:e.recursive}})}async mkdir(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/mkdir",{body:{path:e.path}})}async remove(e){this.client._requireAuth(),await this.client._request("DELETE","/api/v1/fs/remove",{query:{path:e.path,recursive:e.recursive}})}async rename(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/rename",{body:{old_path:e.old_path,new_path:e.new_path}})}async copy(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/copy",{body:{src_path:e.src_path,dst_path:e.dst_path}})}async symlink(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/symlink",{body:{target_path:e.target_path,link_path:e.link_path}})}async readlink(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/readlink",{query:{path:e.path}})}async chmod(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/chmod",{body:{path:e.path,mode:e.mode}})}async grant(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/grant",{body:{path:e.path,subject:e.subject,permission:e.permission}})}async revoke(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/revoke",{body:{path:e.path,subject:e.subject,permission:e.permission}})}};var $=class{constructor(e){this.client=e}client;static{s(this,"RunResource")}async execute(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/run",{body:{code:e.code,entry_path:e.entry_path,working_dir:e.working_dir,args:e.args,max_heap_size_mb:e.max_heap_size_mb},timeoutMs:e.timeout_ms})}};var W=class{constructor(e){this.client=e}client;static{s(this,"DeployResource")}async create(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/deploy/cronjob",{body:{name:e.name,path:e.path,cron_expression:e.cron_expression,args:e.args,push_notify:e.push_notify,max_heap_size_mb:e.max_heap_size_mb}})}async list(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/deploy/cronjobs",{query:{limit:e?.limit,cursor:e?.cursor}})}async get(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.id}`)}async update(e){this.client._requireAuth();let{id:r,...i}=e;return this.client._request("PATCH",`/api/v1/deploy/cronjob/${r}`,{body:i})}async delete(e){this.client._requireAuth(),await this.client._request("DELETE",`/api/v1/deploy/cronjob/${e.id}`)}async pause(e){this.client._requireAuth(),await this.client._request("POST",`/api/v1/deploy/cronjob/${e.id}/pause`)}async resume(e){this.client._requireAuth(),await this.client._request("POST",`/api/v1/deploy/cronjob/${e.id}/resume`)}async trigger(e){return this.client._requireAuth(),this.client._request("POST",`/api/v1/deploy/cronjob/${e.id}/trigger`)}async listRuns(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.cronjob_id}/runs`,{query:{first:e.first,cursor:e.cursor}})}async getRunLogs(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.cronjob_id}/runs/${e.run_id}/logs`)}};var V=class{constructor(e){this.client=e}client;static{s(this,"ReleaseResource")}async feed(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/release/feed",{body:{name:e.name,version:e.version,cronjob_id:e.cronjob_id,view_json:e.view_json,description:e.description,changelog:e.changelog,agent_type:e.agent_type}})}async playbookDraft(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/draft/playbook",{body:{name:e.name,display_name:e.display_name,description:e.description,feeds:e.feeds,trading_symbols:e.trading_symbols,skill_id:e.skill_id,tags:e.tags}})}async playbook(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/release/playbook",{body:{name:e.name,version:e.version,feeds:e.feeds,changelog:e.changelog,readme_url:e.readme_url}})}};var H=class{constructor(e){this.client=e}client;static{s(this,"FeedResource")}async stop(e){this.client._requireAuth();let r=Pe(e.id);return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(r))}/stop`)}async resume(e){this.client._requireAuth();let r=Pe(e.id);return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(r))}/resume`)}async delete(e){this.client._requireAuth();let r=Pe(e.id);return this.client._request("DELETE",`/api/v1/feed/${encodeURIComponent(String(r))}`)}};function Pe(t){if(!Number.isInteger(t)||t<=0)throw new Error("feed id must be a positive integer");return t}s(Pe,"requireFeedID");var $e=["public","private","paid"],Q=class{constructor(e){this.client=e}client;static{s(this,"PlaybooksResource")}async getByIds(e){return await this.client._request("GET","/api/v1/playbooks",{query:{ids:e.join(",")}})}async listByOwner(e){let r={owner:e.owner};return e.limit!==void 0&&e.limit>0&&(r.limit=String(e.limit)),e.cursor&&(r.cursor=e.cursor),await this.client._request("GET","/api/v1/playbooks",{query:r})}async get(e){if(e.id)return(await this.getByIds([e.id])).items[0]??null;if(e.ref){let r=e.ref.indexOf("/");if(r<=0||r===e.ref.length-1)throw new l("INVALID_ARGUMENT",`Invalid ref "${e.ref}". Expected "owner/name".`,400);let i=e.ref.slice(0,r),n=e.ref.slice(r+1),o;for(;;){let a=await this.listByOwner({owner:i,cursor:o,limit:100}),c=a.items.find(u=>u.name===n);if(c)return c;if(!a.has_next||!a.next_cursor)return null;o=a.next_cursor}}throw new l("INVALID_ARGUMENT","id or ref is required",400)}async trending(e={}){let r={};e.cursor&&(r.cursor=e.cursor),e.current&&(r.current=e.current),e.limit!==void 0&&(r.limit=e.limit),e.dir&&(r.dir=e.dir),e.sort&&(r.sort=e.sort),e.keyword&&(r.keyword=e.keyword),e.tags&&e.tags.length>0&&(r.tags=e.tags.join(","));let i=await this.client._request("GET","/api/v1/playbooks/trending",{query:r}),n=gt(this.client.baseUrl);return{playbooks:(i.playbooks??[]).map(o=>vt(o,n)),has_next:i.has_next??!1}}async setVisibility(e){if(!$e.includes(e.visibility))throw new l("INVALID_ARGUMENT",`Invalid visibility "${e.visibility}". Expected one of: ${$e.join(", ")}.`,400);return this.client._requireAuth(),await this.client._request("POST",`/api/v1/playbook/${encodeURIComponent(e.name)}/visibility`,{body:{visibility:e.visibility}})}};function gt(t){try{let e=new URL(t).hostname,r=/^api-llm\.([a-z0-9-]+)\.alva\.ai$/i.exec(e);if(r){let i=r[1].toLowerCase();return i==="prd"?"https://alva.ai":`https://${i}.alva.ai`}}catch{}return"https://alva.ai"}s(gt,"webOriginFromApiBase");function vt(t,e){let r=t.creator?.name??"",i=t.name??"",n=r&&i?`${r}/${i}`:i,o=r&&i?`/u/${r}/playbooks/${i}`:"";return{id:t.id===void 0?"":String(t.id),ref:n,username:r,name:i,display_name:t.display_name??"",description:t.description??"",tags:t.tags??[],follow_count:t.follow_count??0,url_path:o,url:o?`${e}${o}`:"",...t.readme?{readme:t.readme}:{},cursor:t.cursor??""}}s(vt,"toAgentPlaybook");var J=class{constructor(e){this.client=e}client;static{s(this,"SecretsResource")}async create(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/secrets",{body:{name:e.name,value:e.value}})}async list(){return this.client._requireAuth(),this.client._request("GET","/api/v1/secrets")}async get(e){this.client._requireAuth();let r=encodeURIComponent(e.name);return this.client._request("GET",`/api/v1/secrets/${r}`)}async update(e){this.client._requireAuth();let r=encodeURIComponent(e.name);await this.client._request("PUT",`/api/v1/secrets/${r}`,{body:{value:e.value}})}async delete(e){this.client._requireAuth();let r=encodeURIComponent(e.name);await this.client._request("DELETE",`/api/v1/secrets/${r}`)}};var z=class{constructor(e){this.client=e}client;static{s(this,"SdkDocsResource")}async doc(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/sdk/doc",{query:{name:e.name}})}async partitions(){return this.client._requireAuth(),this.client._request("GET","/api/v1/sdk/partitions")}async partitionSummary(e){this.client._requireAuth();let r=encodeURIComponent(e.partition);return this.client._request("GET",`/api/v1/sdk/partitions/${r}/summary`)}};var We=[{skill:"arrays-data-api-crypto-futures-data",file:"binance-perp-usdt-kline",method:"GET",path:"/api/v1/crypto/binance/perp/usdt/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"binance-spot-usdt-kline",method:"GET",path:"/api/v1/crypto/binance/spot/usdt/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"crypto-detail",method:"GET",path:"/api/v1/crypto/detail",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"fear-greed-index",method:"GET",path:"/api/v1/crypto/fear-greed-index",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"funding-rate",method:"GET",path:"/api/v1/crypto/funding-rate",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"hyperliquid-perp-usdc-kline",method:"GET",path:"/api/v1/crypto/hyperliquid/perp/usdc/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"hyperliquid-spot-usdc-kline",method:"GET",path:"/api/v1/crypto/hyperliquid/spot/usdc/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"list",method:"GET",path:"/api/v1/crypto/list",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"long-short-ratio",method:"GET",path:"/api/v1/crypto/long-short-ratio",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"crypto-market-cap",method:"GET",path:"/api/v1/crypto/market-cap",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"market-metrics",method:"GET",path:"/api/v1/crypto/market-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"open-interest",method:"GET",path:"/api/v1/crypto/open-interest",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"screener-metrics",method:"GET",path:"/api/v1/crypto/screener/metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"screener-metrics-timerange",method:"GET",path:"/api/v1/crypto/screener/metrics/timerange",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"trading-pair",method:"GET",path:"/api/v1/crypto/trading-pair",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"country-weightings",method:"GET",path:"/api/v1/etf/country-weightings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"holdings",method:"GET",path:"/api/v1/etf/holdings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"info",method:"GET",path:"/api/v1/etf/info",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"sector-weightings",method:"GET",path:"/api/v1/etf/sector-weightings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-commodity-historical",method:"GET",path:"/api/v1/macro/commodity/historical",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-commodity-real-time",method:"GET",path:"/api/v1/macro/commodity/real-time",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-commodity-symbol-list",method:"GET",path:"/api/v1/macro/commodity/symbols",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"economic-indicators",method:"GET",path:"/api/v1/macro/economic-indicators",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-forex-historical",method:"GET",path:"/api/v1/macro/forex/historical",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-forex-real-time",method:"GET",path:"/api/v1/macro/forex/real-time",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-forex-symbol-list",method:"GET",path:"/api/v1/macro/forex/symbols",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-index-historical",method:"GET",path:"/api/v1/macro/index/historical",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-index-real-time",method:"GET",path:"/api/v1/macro/index/real-time",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"rates",method:"GET",path:"/api/v1/macro/treasury-rates",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-balance-sheets",method:"GET",path:"/api/v1/stocks/company/balance-sheets",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-cashflow-statements",method:"GET",path:"/api/v1/stocks/company/cashflow-statements",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-detail",method:"GET",path:"/api/v1/stocks/company/detail",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-income-statements",method:"GET",path:"/api/v1/stocks/company/income-statements",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-kpi",method:"GET",path:"/api/v1/stocks/company/kpi",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"crowdfunding-offerings",method:"GET",path:"/api/v1/stocks/crowdfunding/offerings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"dividends",method:"GET",path:"/api/v1/stocks/dividends",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"earnings-calendar",method:"GET",path:"/api/v1/stocks/earnings-calendar",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"equity-offering",method:"GET",path:"/api/v1/stocks/equity-offering",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-metrics",file:"financial-metrics",method:"GET",path:"/api/v1/stocks/financial-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"fiscal-dates",method:"GET",path:"/api/v1/stocks/fiscal-dates",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"fiscal-dates-range",method:"GET",path:"/api/v1/stocks/fiscal-dates/range",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"ipo-calendar",method:"GET",path:"/api/v1/stocks/ipo-calendar",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"ipo-confirmed-calendar",method:"GET",path:"/api/v1/stocks/ipo-confirmed-calendar",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"stocks-kline",method:"GET",path:"/api/v1/stocks/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-metrics",file:"market-metrics",method:"GET",path:"/api/v1/stocks/market-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"mergers-acquisitions",method:"GET",path:"/api/v1/stocks/mergers-acquisitions",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"outstanding-shares",method:"GET",path:"/api/v1/stocks/outstanding-shares",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-metrics",file:"ratings",method:"GET",path:"/api/v1/stocks/ratings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"basic-info-screener",method:"GET",path:"/api/v1/stocks/screener/basic-info/{sub}",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"event-screener",method:"GET",path:"/api/v1/stocks/screener/events",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-financial-metrics",method:"GET",path:"/api/v1/stocks/screener/financial-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-financial-metrics-timerange",method:"GET",path:"/api/v1/stocks/screener/financial-metrics/timerange",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-technical-metrics",method:"GET",path:"/api/v1/stocks/screener/technical-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-technical-metrics-timerange",method:"GET",path:"/api/v1/stocks/screener/technical-metrics/timerange",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"sec-earnings-release",method:"GET",path:"/api/v1/stocks/sec-earnings-release",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"shares-float",method:"GET",path:"/api/v1/stocks/shares-float",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"splits",method:"GET",path:"/api/v1/stocks/splits",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-exchange-flow",file:"exchange-flows",method:"GET",path:"/api/v1/crypto/exchange-flows",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-company-crypto-holdings",file:"crypto-holdings",method:"GET",path:"/api/v1/crypto/holdings",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-inflow-cdd",method:"GET",path:"/api/v1/crypto/metrics/inflow-cdd",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-leverage-ratio",method:"GET",path:"/api/v1/crypto/metrics/leverage-ratio",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-miner-to-exchange",method:"GET",path:"/api/v1/crypto/metrics/miner-to-exchange",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-mvrv",method:"GET",path:"/api/v1/crypto/metrics/mvrv",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-nupl",method:"GET",path:"/api/v1/crypto/metrics/nupl",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-puell-multiple",method:"GET",path:"/api/v1/crypto/metrics/puell-multiple",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-realized-price",method:"GET",path:"/api/v1/crypto/metrics/realized-price",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-sopr",method:"GET",path:"/api/v1/crypto/metrics/sopr",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-ssr",method:"GET",path:"/api/v1/crypto/metrics/ssr",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-whale-ratio",method:"GET",path:"/api/v1/crypto/metrics/whale-ratio",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"crypto-supply",method:"GET",path:"/api/v1/crypto/supply",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-futures-data",file:"taker-buy-sell-volume",method:"GET",path:"/api/v1/crypto/taker-buy-sell-volume",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"unlock-events",method:"GET",path:"/api/v1/crypto/unlock-events",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-etf-fundamentals",file:"flow",method:"GET",path:"/api/v1/etf/flow",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-options",file:"contracts",method:"GET",path:"/api/v1/options/contracts",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-options",file:"kline",method:"GET",path:"/api/v1/options/kline",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-fundamentals",file:"company-executives",method:"GET",path:"/api/v1/stocks/company/executives",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"company-price-target-consensus",method:"GET",path:"/api/v1/stocks/company/price-target-consensus",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"company-price-target-news",method:"GET",path:"/api/v1/stocks/company/price-target-news",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"company-price-target-summary",method:"GET",path:"/api/v1/stocks/company/price-target-summary",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-ownership-and-flow",file:"congress-recent-trades",method:"GET",path:"/api/v1/stocks/congress/recent-trades",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-stock-metrics",file:"darkpool",method:"GET",path:"/api/v1/stocks/darkpool",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"estimates-guidance",method:"GET",path:"/api/v1/stocks/estimates-guidance",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-ownership-and-flow",file:"insider-transactions",method:"GET",path:"/api/v1/stocks/insider/transactions",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-ownership-and-flow",file:"institution-holder",method:"GET",path:"/api/v1/stocks/institution-holder",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"activity",method:"GET",path:"polymarket:/activity",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"book",method:"GET",path:"polymarket:/book",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"closed-positions",method:"GET",path:"polymarket:/closed-positions",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"events",method:"GET",path:"polymarket:/events",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"holders",method:"GET",path:"polymarket:/holders",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"markets",method:"GET",path:"polymarket:/markets",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"midpoint",method:"GET",path:"polymarket:/midpoint",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"oi",method:"GET",path:"polymarket:/oi",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"positions",method:"GET",path:"polymarket:/positions",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"price",method:"GET",path:"polymarket:/price",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"prices-history",method:"GET",path:"polymarket:/prices-history",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"public-search",method:"GET",path:"polymarket:/public-search",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"series",method:"GET",path:"polymarket:/series",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"sports",method:"GET",path:"polymarket:/sports",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"spread",method:"GET",path:"polymarket:/spread",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"tags",method:"GET",path:"polymarket:/tags",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"trades",method:"GET",path:"polymarket:/trades",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"value",method:"GET",path:"polymarket:/value",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-events",file:"earnings-transcript",method:"GET",path:"/api/v1/stocks/earnings-transcript",tier:"unstructured",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-news",file:"market-news",method:"GET",path:"/api/v1/stocks/market-news",tier:"unstructured",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-by-handle",method:"GET",path:"/api/v1/social-feeds/x/by-handle",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-by-url",method:"GET",path:"/api/v1/social-feeds/x/by-url",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-entities-handle",method:"GET",path:"/api/v1/social-feeds/x/entities/handle/{twitter_handle}",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-entities-handles",method:"GET",path:"/api/v1/social-feeds/x/entities/handles",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-fundamentals",file:"company-detail-non-us",method:"GET",path:"/api/v1/stocks/non-us/company/detail",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-social-feeds",file:"x-search",method:"GET",path:"/api/v1/social-feeds/x/search",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-spot-market-price-and-volume",file:"stocks-non-us-kline",method:"GET",path:"/api/v1/stocks/non-us/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1}];function Ve(t,e){return We.find(r=>r.skill===t&&r.file===e)}s(Ve,"getSkillEndpointMetadata");function Re(t){return We.filter(e=>e.skill===t)}s(Re,"listSkillEndpointMetadata");var K=class{constructor(e){this.client=e}client;static{s(this,"DataSkillsResource")}async list(){return{skills:((await this.client._request("GET","/api/v1/skills",{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data??[]).map(r=>({...r,...He(r.name)}))}}async summary(e){let r=encodeURIComponent(e.name),n=(await this.client._request("GET",`/api/v1/skills/${r}`,{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data?.[0];if(!n)throw new Error(`empty skills summary response for "${e.name}"`);let o=Re(e.name);return{...n,...He(e.name),...o.length>0?{endpoint_metadata:o}:{}}}async endpoint(e){let r=encodeURIComponent(e.name),n=(await this.client._request("GET",`/api/v1/skills/${r}`,{baseUrl:this.client.arraysBaseUrl,noAuth:!0,query:{endpoint:e.file}})).data?.[0];if(!n)throw new Error(`empty skills endpoint response for "${e.name}" file "${e.file}"`);let o=Ve(e.name,e.file);return{...n,...o?{metadata:o}:{}}}};function He(t){let e=Re(t);if(e.length===0)return{};let r={},i=0;for(let n of e)r[n.tier]=(r[n.tier]??0)+1,n.pro_required&&(i+=1);return{endpoint_tier_counts:r,metadata:{endpoint_count:e.length,endpoint_tier_counts:r,pro_count:i}}}s(He,"metadataSummaryForSkill");function Qe(t){return{username:t.username,name:t.name,display_name:t.display_name,description:t.description,tags:t.tags,creator_uid:t.creator_uid,updated_at:t.updated_at}}s(Qe,"normalizePlaybookSkillSummary");function Je(t){let e=t.split("/");if(e.length!==2||!e[0]||!e[1])throw new l("INVALID_ARGUMENT",`playbook skill identifier must be "<user>/<name>", got "${t}"`,0);return{username:e[0],name:e[1]}}s(Je,"parsePlaybookSkillId");var X=class{constructor(e){this.client=e}client;static{s(this,"PlaybookSkillsResource")}async list(e){let r={};return e?.tag&&(r.tag=e.tag),e?.username&&(r.username=e.username),{skills:((await this.client._request("GET","/api/v1/skills",{query:r})).data??[]).map(Qe)}}async tags(){return{tags:(await this.client._request("GET","/api/v1/skills/tags")).data??[]}}async get(e){let{username:r,name:i}=Je(e),n=encodeURIComponent(r),o=encodeURIComponent(i),c=(await this.client._request("GET",`/api/v1/skills/${n}/${o}`)).data?.[0];if(!c)throw new l("NOT_FOUND",`empty playbook skills get response for ${e}`,0);return{...Qe(c),files:c.files??[]}}async file(e,r){let{username:i,name:n}=Je(e),o=encodeURIComponent(i),a=encodeURIComponent(n),c=r.split("/").map(encodeURIComponent).join("/"),d=(await this.client._request("GET",`/api/v1/skills/${o}/${a}/files/${c}`)).data?.[0];if(!d)throw new l("NOT_FOUND",`empty playbook skills file response for ${e} path ${r}`,0);return d}};var Y=class{constructor(e){this.client=e}client;static{s(this,"CommentsResource")}async create(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/playbook/comment",{body:{username:e.username,name:e.name,content:e.content,parent_id:e.parent_id}})}async pin(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/playbook/comment/pin",{body:{comment_id:e.comment_id}})}async unpin(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/playbook/comment/unpin",{body:{comment_id:e.comment_id}})}};var Z=class{constructor(e){this.client=e}client;static{s(this,"RemixResource")}async save(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/remix",{body:{child:e.child,parents:e.parents}})}};var ee=class{constructor(e){this.client=e}client;static{s(this,"ScreenshotResource")}async capture(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/screenshot",{query:{url:e.url,selector:e.selector,xpath:e.xpath,compress:e.compress,compress_quality:e.compressQuality,compress_max_width:e.compressMaxWidth}})}};var te=class{constructor(e){this.client=e}client;static{s(this,"UserResource")}async me(){return this.client._requireAuth(),this.client._request("GET","/api/v1/me")}};var re=class{constructor(e){this.client=e}client;static{s(this,"TradingResource")}async accounts(){return this.client._requireAuth(),this.client._request("GET","/api/v1/trading/accounts")}async portfolio(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/trading/portfolio",{query:{accountId:e}})}async orders(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/trading/orders",{query:{accountId:e.accountId,source:e.source,since:e.since,limit:e.limit}})}async subscriptions(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/trading/subscriptions",{query:{accountId:e}})}async equityHistory(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/trading/equity-history",{query:{accountId:e.accountId,timeframe:e.timeframe,sinceMs:e.sinceMs,untilMs:e.untilMs}})}async riskRules(){return this.client._requireAuth(),this.client._request("GET","/api/v1/trading/risk-rules")}async subscribe(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/trading/subscribe",{body:e})}async unsubscribe(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/trading/unsubscribe",{body:{subscriptionId:e}})}async execute(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/trading/execute",{body:e})}async updateRiskRules(e){return this.client._requireAuth(),this.client._request("PUT","/api/v1/trading/risk-rules",{body:e})}};var ie=class{constructor(e){this.client=e}client;static{s(this,"PortfolioResource")}async accounts(){return this.client._requireAuth(),this.client._request("GET","/api/v1/portfolio/accounts")}async summary(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/portfolio/summary",{query:{accountId:e}})}async activities(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/portfolio/activities",{query:{accountId:e.accountId,limit:e.limit,pageToken:e.pageToken}})}};var se=class{constructor(e){this.client=e}client;static{s(this,"ArraysJwtResource")}async ensure(){return this.client._requireAuth(),this.client._request("POST","/api/v1/arrays-jwt/ensure")}async status(){return this.client._requireAuth(),this.client._request("GET","/api/v1/arrays-jwt/status")}};var ne=class{constructor(e){this.client=e}client;static{s(this,"NotificationsResource")}async listPlaybook(e){this.client._requireAuth();let r=`/api/v1/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",r,{query:ze(e)})}async listFeed(e){this.client._requireAuth();let r=`/api/v1/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",r,{query:ze(e)})}};function ze(t){let e={};return t.channel&&(e.channel=t.channel),t.status&&(e.status=t.status),t.since_time!==void 0&&t.since_time>0&&(e.since_time=String(t.since_time)),t.first!==void 0&&t.first>0&&(e.first=String(t.first)),t.cursor&&(e.cursor=t.cursor),e}s(ze,"buildQuery");var oe=class{constructor(e){this.client=e}client;static{s(this,"NotificationPreferencesResource")}async list(){return this.client._requireAuth(),this.client._request("GET","/api/v1/me/notifications/preferences")}async update(e){return this.client._requireAuth(),this.client._request("PATCH",`/api/v1/me/notifications/preferences/${encodeURIComponent(e.key)}`,{body:{enabled:e.enabled}})}};var ae=class{constructor(e){this.client=e}client;static{s(this,"SubscriptionsResource")}async subscribePlaybook(e){this.client._requireAuth();let r=`/api/v1/subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",r)}async unsubscribePlaybook(e){this.client._requireAuth();let r=`/api/v1/subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",r)}async subscribeFeed(e){this.client._requireAuth();let r=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",r)}async unsubscribeFeed(e){this.client._requireAuth();let r=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",r)}async list(e={}){this.client._requireAuth();let r={};return e.first!==void 0&&e.first>0&&(r.first=String(e.first)),e.cursor&&(r.cursor=e.cursor),this.client._request("GET","/api/v1/me/subscriptions",{query:r})}async follows(e={}){this.client._requireAuth();let r={};return e.limit!==void 0&&e.limit>0&&(r.limit=String(e.limit)),e.cursor&&(r.cursor=e.cursor),this.client._request("GET","/api/v1/me/follows",{query:r})}async unsubscribeBatch(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/subscriptions/unsubscribe-batch",{body:{playbook_ids:e.playbookIds??[],feed_ids:e.feedIds??[]}})}};var le=class{constructor(e){this.client=e}client;static{s(this,"ChannelGroupSubscriptionsResource")}async context(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/channel/group-subscriptions/context",{query:{session_id:e.session_id}})}async list(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/channel/group-subscriptions",{query:{session_id:e.session_id}})}async subscribe(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/channel/group-subscriptions",{jsonBody:Ke(e)})}async unsubscribe(e){return this.client._requireAuth(),this.client._request("DELETE","/api/v1/channel/group-subscriptions",{jsonBody:Ke(e)})}};function Ke(t){return`{"session_id":${Xe(t.session_id)},"target_type":${JSON.stringify(t.target_type)},"target_id":${Xe(t.target_id)}}`}s(Ke,"mutationBody");function Xe(t){if(typeof t=="number"){if(!Number.isInteger(t)||t<=0||!Number.isSafeInteger(t))throw new l("INVALID_ARGUMENT","channel group subscription ids must be positive safe integers; pass large int64 ids as strings",0);return String(t)}if(!/^[1-9]\d*$/.test(t))throw new l("INVALID_ARGUMENT","channel group subscription ids must be positive integer strings",0);return t}s(Xe,"idLiteral");var ce=class{constructor(e){this.client=e}client;static{s(this,"FeedbackResource")}async submit(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/feedback",{body:e})}};var ue=class{constructor(e){this.client=e}client;static{s(this,"FunctionsResource")}async register(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/service/functions",{body:{playbook_id:e.playbook_id,function_name:e.function_name,entry_script_path:e.entry_script_path,params_schema:e.params_schema,allow_charges:e.allow_charges}})}async list(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/service/functions",{query:{playbook_id:e.playbook_id}})}async delete(e){this.client._requireAuth(),await this.client._request("DELETE","/api/v1/service/functions",{query:{playbook_id:e.playbook_id,function_name:e.function_name}})}async invoke(e){this.client._requireAuth();let r=await this.client._request("POST","/api/v1/service/invoke",{body:{playbook_id:e.playbook_id,function_name:e.function_name,parameters_json:JSON.stringify(e.parameters??{})}});return{...r,result:Pt(r.result)}}async getAllowance(e){this.client._requireAuth();let r=await this.client._request("GET","/api/v1/service/allowance",{query:{playbook_id:e.playbook_id}});return Te(r.allowance)}async listAllowances(){return this.client._requireAuth(),{allowances:((await this.client._request("GET","/api/v1/service/allowances")).allowances??[]).map(r=>Te(r)).filter(r=>r!==null)}}async createAllowance(e){this.client._requireAuth();let r=await this.client._request("POST","/api/v1/service/allowance",{body:{playbook_id:e.playbook_id,amount:e.amount}});return{allowance:qt(r.allowance)}}async revokeAllowance(e){return this.client._requireAuth(),await this.client._request("DELETE","/api/v1/service/allowance",{query:{playbook_id:e.playbook_id}}),{ok:!0}}};function Te(t){if(!t)return null;let e={id:t.id??"",consumer_uid:t.consumer_uid??t.consumerUid??"",playbook_id:t.playbook_id??t.playbookId??"",amount:t.amount??0,used:t.used??0,remaining:t.remaining??0},r=Ye(t.created_at_ms??t.createdAtMs??t.created_at??t.createdAt),i=Ye(t.updated_at_ms??t.updatedAtMs??t.updated_at??t.updatedAt);return r!==void 0&&(e.created_at_ms=r),i!==void 0&&(e.updated_at_ms=i),e}s(Te,"normalizeAllowance");function qt(t){let e=Te(t);if(!e)throw new Error("allowance response missing allowance");return e}s(qt,"requireAllowance");function Ye(t){if(t==null)return;if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"){let n=Number(t);if(Number.isFinite(n))return n;let o=Date.parse(t);return Number.isNaN(o)?void 0:o}if(typeof t!="object")return;let e=t,r=typeof e.seconds=="number"?e.seconds:typeof e.seconds=="string"?Number(e.seconds):void 0,i=typeof e.nanos=="number"?e.nanos:typeof e.nanos=="string"?Number(e.nanos):0;if(!(r===void 0||!Number.isFinite(r)))return r*1e3+Math.floor((Number.isFinite(i)?i:0)/1e6)}s(Ye,"timestampMs");function Pt(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}}s(Pt,"parseResultPayload");var Rt=`
1
+ "use strict";var AlvaToolkit=(()=>{var j=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var st=Object.prototype.hasOwnProperty;var s=(t,e)=>j(t,"name",{value:e,configurable:!0});var nt=(t,e)=>{for(var r in e)j(t,r,{get:e[r],enumerable:!0})},ot=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of it(e))!st.call(t,n)&&n!==r&&j(t,n,{get:()=>e[n],enumerable:!(i=rt(e,n))||i.enumerable});return t};var at=t=>ot(j({},"__esModule",{value:!0}),t);var Nt={};nt(Nt,{AlertsResource:()=>T,AlvaClient:()=>_e,AlvaError:()=>c,AutomationResource:()=>q,CliUsageError:()=>$,PBSV_UPDATE_MESSAGE:()=>Fe,SUBSCRIBE_PROPOSE_MESSAGE:()=>Le,SUBSCRIBE_RESULT_MESSAGE:()=>De,UDF_AUTH_REQUIRED_MESSAGE:()=>Ne,UDF_CONSENT_REQUEST_MESSAGE:()=>Ge,UDF_CONSENT_RESPONSE_MESSAGE:()=>Ue,UdfAuthRequiredError:()=>v,UdfConsentDeniedError:()=>C,UdfConsentRequiredError:()=>A,UdfConsentTimeoutError:()=>x,UdfError:()=>p,UdfExecutionError:()=>N,UdfFunctionDisabledError:()=>G,UdfFunctionNotFoundError:()=>F,UdfInsufficientCredits:()=>I,UdfPidMismatchError:()=>k,UdfRateLimitedError:()=>U,UdfTokenExpiredError:()=>E,UdfTokenInvalidError:()=>w,UdfTransportError:()=>R,VERSION:()=>Ut,getViewerToken:()=>L,installPlaybookRuntime:()=>Te,mapUdfErrorResponse:()=>Re,playbookIdFromToken:()=>ve,subscribe:()=>We,udf:()=>Ve});var p=class extends Error{static{s(this,"UdfError")}code;metadata;status;constructor(e,{code:r,metadata:i={},status:n}){super(e),this.name=new.target.name,this.code=r,this.metadata=i,this.status=n}},v=class extends p{static{s(this,"UdfAuthRequiredError")}constructor(){super("Sign in to use this UDF.",{code:"AUTH_REQUIRED"})}},E=class extends p{static{s(this,"UdfTokenExpiredError")}},w=class extends p{static{s(this,"UdfTokenInvalidError")}},k=class extends p{static{s(this,"UdfPidMismatchError")}},A=class extends p{static{s(this,"UdfConsentRequiredError")}},C=class extends p{static{s(this,"UdfConsentDeniedError")}constructor(){super("UDF consent was denied.",{code:"CONSENT_DENIED"})}},x=class extends p{static{s(this,"UdfConsentTimeoutError")}constructor(){super("UDF consent timed out.",{code:"CONSENT_TIMEOUT"})}},I=class extends p{static{s(this,"UdfInsufficientCredits")}},F=class extends p{static{s(this,"UdfFunctionNotFoundError")}},G=class extends p{static{s(this,"UdfFunctionDisabledError")}},U=class extends p{static{s(this,"UdfRateLimitedError")}},N=class extends p{static{s(this,"UdfExecutionError")}},R=class extends p{static{s(this,"UdfTransportError")}},Fe="alva:pbsv:update",Ge="alva:udf:consent-request",Ue="alva:udf:consent-response",Ne="alva:udf:auth-required",Le="alva:subscribe:propose",De="alva:subscribe:result",Oe="https://api-llm.prd.alva.ai",je=300*1e3,S=null,_=null,Pe=Oe,h=null,m=null,Ie=!1,M=new Map,B=new Map,ct=s(t=>t==="subscribed"||t==="declined"||t==="timeout"?t:"error","normalizeProposalResult"),lt=s(t=>{let e=t.replace(/-/g,"+").replace(/_/g,"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return atob(r)},"decodeBase64Url"),ve=s(t=>{if(!t)return null;let[,e]=t.split(".");if(!e)return null;try{let r=JSON.parse(lt(e));if(typeof r.pid=="number")return String(r.pid);if(typeof r.pid=="string")return r.pid}catch{return null}return null},"playbookIdFromToken"),L=s(()=>S,"getViewerToken"),P=s(()=>!!L(),"isAuthenticated"),ut=s(t=>{let e=new URL(t.location.href);e.searchParams.delete("_pbsv"),t.history.replaceState(null,"",e.pathname+e.search+e.hash)},"stripPbsvFromUrl"),pt=s(t=>{let e=new URLSearchParams(t.location.search);S=e.get("_pbsv"),_=e.get("parent_origin"),Pe=(e.get("api_origin")||Oe).replace(/\/$/,""),h=ve(S),S&&ut(t)},"parseBootParams"),Me=s(async t=>{try{return await t.json()}catch{return{}}},"safeJson"),dt=s(t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}},"parseResultPayload"),mt=s(t=>{let e=t;return{...e,result:dt(e.result)}},"normalizeInvokeResponse"),Be=s(t=>t.error?.metadata||t.details?.metadata||{},"errorMetadata"),Re=s((t,e)=>{let r=t.error?.code||"TRANSPORT",i=t.error?.message||r,n=Be(t),o={code:r,metadata:n,status:e};switch(r){case"PBSV_EXPIRED":return new E(i,o);case"PBSV_INVALID":case"UNAUTHENTICATED":return new w(i,o);case"PBSV_PID_MISMATCH":return new k(i,o);case"CONSENT_REQUIRED":return new A(i,o);case"INSUFFICIENT_CREDITS":return new I(i,o);case"FUNCTION_NOT_FOUND":return new F(i,o);case"FUNCTION_DISABLED":return new G(i,o);case"RESOURCE_EXHAUSTED":return new U(i,o);case"EXECUTION_FAILED":return new N(i,o);default:return new R(i,o)}},"mapUdfErrorResponse"),ft=s(t=>{if(!m||!_||t.origin!==_||t.source!==m.parent||!t.data||typeof t.data!="object")return;let e=t.data;if(e.type===Fe){typeof e.token=="string"&&e.token.length>0&&(S=e.token,h=ve(e.token));return}if(e.type===De){if(typeof e.request_id!="string")return;let i=B.get(e.request_id);if(!i)return;clearTimeout(i.timer),B.delete(e.request_id),i.resolve(ct(e.status));return}if(e.type!==Ue||typeof e.request_id!="string")return;let r=M.get(e.request_id);r&&(clearTimeout(r.timer),M.delete(e.request_id),r.resolve(e.granted===!0?"granted":"denied"))},"onMessage"),$e=s(()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`,"randomRequestId"),yt=s(()=>{if(!h)return null;let t=Number(h);return Number.isSafeInteger(t)?t:null},"playbookIdForInvoke"),_t=s(async(t,e)=>{if(!m||!_)return"denied";let r=_,i=$e();return new Promise(n=>{let o=setTimeout(()=>{M.delete(i),n("timeout")},je);M.set(i,{resolve:n,timer:o}),m?.parent.postMessage({type:Ge,request_id:i,playbook_id:t,min_allowance:e},r)})},"requestConsent"),ht=s(async t=>{if(!m||!_)return"error";let e=typeof t?.feedOwner=="string"?t.feedOwner.trim():"",r=typeof t?.feedName=="string"?t.feedName.trim():"";if(!e||!r)return"error";let i=_,n=$e();return new Promise(o=>{let a=setTimeout(()=>{B.delete(n),o("timeout")},je);B.set(n,{resolve:o,timer:a}),m?.parent.postMessage({type:Le,request_id:n,playbook_id:h,feed:{owner:e,name:r}},i)})},"proposeSubscribe"),We={propose:ht},bt=s(t=>{!m||!_||m.parent.postMessage({type:Ne,function_name:t},_)},"requestAuthentication"),qe=s(async(t,e,r=!1)=>{let i=L();if(!i)throw new v;if(!h)throw new k("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let n=yt();if(!n)throw new k("Invalid playbook id.",{code:"PBSV_PID_MISMATCH"});let o;try{o=await fetch(`${Pe}/api/v1/service/invoke`,{method:"POST",headers:{Authorization:`Bearer ${i}`,"X-Pbsv":"1","Content-Type":"application/json"},body:JSON.stringify({playbook_id:n,function_name:t,parameters_json:JSON.stringify(e)})})}catch{throw new R("Network error while invoking UDF.",{code:"TRANSPORT"})}let a=await Me(o);if(o.ok)return mt(a);if(a.error?.code==="CONSENT_REQUIRED"&&!r){let l=Be(a),u=typeof l.playbook_id=="string"?l.playbook_id:h,d=typeof l.min_allowance_suggested=="number"?l.min_allowance_suggested:1,f=await _t(u,d);if(f==="granted")return qe(t,e,!0);throw f==="timeout"?new x:new C}throw Re(a,o.status)},"call"),kt=s(async()=>{let t=L();if(!t)throw new v;if(!h)throw new k("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let e=new URL(`${Pe}/api/v1/service/functions`);e.searchParams.set("playbook_id",h);let r=await fetch(e.toString(),{headers:{Authorization:`Bearer ${t}`,"X-Pbsv":"1"}}),i=await Me(r);if(!r.ok)throw Re(i,r.status);let n=i.functions;return Array.isArray(n)?n:[]},"list"),ge=s((t,e,r)=>{t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:r}))},"dispatchButtonEvent"),gt=s(t=>{if(typeof t!="string")return t;let r=m?.document?.querySelector(t);if(r&&"appendChild"in r)return r;throw new Error(`UDF button target not found: ${t}`)},"resolveButtonTarget"),Pt=s((t,e)=>{if(!m)throw new Error("Playbook runtime is not installed.");let r=gt(t),i=m.document.createElement("button"),n=e.label||e.functionName,o=e.loadingLabel||"Running...",a=e.disabledLabel||"Sign in to run";return i.type="button",i.className="alva-udf-button",i.textContent=P()?n:a,i.disabled=!1,i.setAttribute("data-function-name",e.functionName),P()||i.setAttribute("aria-disabled","true"),i.addEventListener("click",async()=>{if(!P()){bt(e.functionName);return}if(!i.disabled){i.disabled=!0,i.textContent=o,ge(i,"alva:udf-button:loading",{functionName:e.functionName});try{let l=await qe(e.functionName,e.params??{});ge(i,"alva:udf-button:result",{functionName:e.functionName,result:l})}catch(l){ge(i,"alva:udf-button:error",{functionName:e.functionName,error:l})}finally{i.disabled=!1,i.textContent=P()?n:a,P()||i.setAttribute("aria-disabled","true")}}}),r.appendChild(i),i},"renderButton"),Ve={call:qe,list:kt,getViewerToken:L,isAuthenticated:P,renderButton:Pt,UdfError:p,UdfAuthRequiredError:v,UdfTokenExpiredError:E,UdfTokenInvalidError:w,UdfPidMismatchError:k,UdfConsentRequiredError:A,UdfConsentDeniedError:C,UdfConsentTimeoutError:x,UdfInsufficientCredits:I,UdfFunctionNotFoundError:F,UdfFunctionDisabledError:G,UdfRateLimitedError:U,UdfExecutionError:N,UdfTransportError:R},Te=s(t=>{let e=t??(typeof window>"u"?void 0:window);if(!e||Ie)return;m=e,Ie=!0,pt(e),e.addEventListener("message",ft);let r=e,i=r.alva||{};r.alva={...i,udf:Ve,subscribe:We}},"installPlaybookRuntime");var c=class extends Error{static{s(this,"AlvaError")}code;status;details;constructor(e,r,i,n){super(r),this.name="AlvaError",this.code=e,this.status=i,this.details=n}},$=class extends Error{static{s(this,"CliUsageError")}command;constructor(e,r){super(e),this.name="CliUsageError",this.command=r}};function vt(t){let e=0;for(;e<t.length;){let r=t[e];if(r<=127){e+=1;continue}let i=0,n=0,o=0;if(r>=194&&r<=223)i=1,n=128,o=r&31;else if(r>=224&&r<=239)i=2,n=2048,o=r&15;else if(r>=240&&r<=244)i=3,n=65536,o=r&7;else return!1;if(e+i>=t.length)return!1;for(let a=1;a<=i;a+=1){let l=t[e+a];if((l&192)!==128)return!1;o=o<<6|l&63}if(o<n||o>1114111||o>=55296&&o<=57343)return!1;e+=i+1}return!0}s(vt,"isValidUtf8");var W=class{constructor(e){this.client=e}client;static{s(this,"FsResource")}async read(e){let r=await this.client._request("GET","/api/v1/fs/read",{query:{path:e.path,offset:e.offset,size:e.size}});if(!(r instanceof ArrayBuffer)||!vt(new Uint8Array(r)))return r;let i=new TextDecoder("utf-8").decode(r);try{return JSON.parse(i)}catch{return i}}async write(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/fs/write",{body:{path:e.path,data:e.data,mkdir_parents:e.mkdir_parents}})}async rawWrite(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/fs/write",{query:{path:e.path,mkdir_parents:e.mkdir_parents},rawBody:e.body})}async stat(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/stat",{query:{path:e.path}})}async readdir(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/readdir",{query:{path:e.path,recursive:e.recursive}})}async mkdir(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/mkdir",{body:{path:e.path}})}async remove(e){this.client._requireAuth(),await this.client._request("DELETE","/api/v1/fs/remove",{query:{path:e.path,recursive:e.recursive}})}async rename(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/rename",{body:{old_path:e.old_path,new_path:e.new_path}})}async copy(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/copy",{body:{src_path:e.src_path,dst_path:e.dst_path}})}async symlink(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/symlink",{body:{target_path:e.target_path,link_path:e.link_path}})}async readlink(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/readlink",{query:{path:e.path}})}async chmod(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/chmod",{body:{path:e.path,mode:e.mode}})}async grant(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/grant",{body:{path:e.path,subject:e.subject,permission:e.permission}})}async revoke(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/revoke",{body:{path:e.path,subject:e.subject,permission:e.permission}})}};var V=class{constructor(e){this.client=e}client;static{s(this,"RunResource")}async execute(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/run",{body:{code:e.code,entry_path:e.entry_path,working_dir:e.working_dir,args:e.args,max_heap_size_mb:e.max_heap_size_mb},timeoutMs:e.timeout_ms})}};var H=class{constructor(e){this.client=e}client;static{s(this,"DeployResource")}async create(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/deploy/cronjob",{body:{name:e.name,path:e.path,cron_expression:e.cron_expression,args:e.args,push_notify:e.push_notify,max_heap_size_mb:e.max_heap_size_mb,run_as_user_id:e.run_as_user_id}})}async list(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/deploy/cronjobs",{query:{limit:e?.limit,cursor:e?.cursor}})}async get(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.id}`)}async update(e){this.client._requireAuth();let{id:r,...i}=e;return this.client._request("PATCH",`/api/v1/deploy/cronjob/${r}`,{body:i})}async delete(e){this.client._requireAuth(),await this.client._request("DELETE",`/api/v1/deploy/cronjob/${e.id}`)}async pause(e){this.client._requireAuth(),await this.client._request("POST",`/api/v1/deploy/cronjob/${e.id}/pause`)}async resume(e){this.client._requireAuth(),await this.client._request("POST",`/api/v1/deploy/cronjob/${e.id}/resume`)}async trigger(e){return this.client._requireAuth(),this.client._request("POST",`/api/v1/deploy/cronjob/${e.id}/trigger`)}async listRuns(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.cronjob_id}/runs`,{query:{first:e.first,cursor:e.cursor}})}async getRunLogs(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.cronjob_id}/runs/${e.run_id}/logs`)}};var Q=class{constructor(e){this.client=e}client;static{s(this,"ServiceAccountResource")}async create(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/service-account",{body:{display_name:e.display_name}})}async list(){return this.client._requireAuth(),this.client._request("GET","/api/v1/service-accounts")}async delete(e){this.client._requireAuth(),await this.client._request("DELETE",`/api/v1/service-account/${e.id}`)}async grant(e){this.client._requireAuth(),await this.client._request("POST",`/api/v1/service-account/${e.id}/grant`,{body:{path:e.path,permission:e.permission}})}async revoke(e){this.client._requireAuth(),await this.client._request("POST",`/api/v1/service-account/${e.id}/revoke`,{body:{path:e.path,permission:e.permission}})}};var J=class{constructor(e){this.client=e}client;static{s(this,"ReleaseResource")}async feed(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/release/feed",{body:{name:e.name,version:e.version,cronjob_id:e.cronjob_id,view_json:e.view_json,description:e.description,changelog:e.changelog,agent_type:e.agent_type}})}async playbookDraft(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/draft/playbook",{body:{name:e.name,display_name:e.display_name,description:e.description,feeds:e.feeds,trading_symbols:e.trading_symbols,skill_id:e.skill_id,tags:e.tags}})}async playbook(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/release/playbook",{body:{name:e.name,version:e.version,feeds:e.feeds,changelog:e.changelog,readme_url:e.readme_url}})}};var z=class{constructor(e){this.client=e}client;static{s(this,"FeedResource")}async list(e={}){return this.client._requireAuth(),this.client._request("GET","/api/v1/feed",{query:{limit:e.limit,cursor:e.cursor,status:e.status}})}async stop(e){this.client._requireAuth();let r=Se(e.id);return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(r))}/stop`)}async resume(e){this.client._requireAuth();let r=Se(e.id);return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(r))}/resume`)}async delete(e){this.client._requireAuth();let r=Se(e.id);return this.client._request("DELETE",`/api/v1/feed/${encodeURIComponent(String(r))}`)}};function Se(t){if(!Number.isInteger(t)||t<=0)throw new Error("feed id must be a positive integer");return t}s(Se,"requireFeedID");var q=class{constructor(e){this.client=e}client;static{s(this,"AutomationResource")}list(e={}){return this.client.feed.list(e)}async inspect(e){this.client._requireAuth();let r=Rt(e.id);return this.client._request("GET",`/api/v1/automation/${encodeURIComponent(String(r))}`)}stop(e){return this.client.feed.stop(e)}resume(e){return this.client.feed.resume(e)}delete(e){return this.client.feed.delete(e)}publish(e){return this.client.release.feed(e)}};function Rt(t){if(!Number.isInteger(t)||t<=0)throw new Error("automation id must be a positive integer");return t}s(Rt,"requireAutomationID");var He=["public","private","paid"],K=class{constructor(e){this.client=e}client;static{s(this,"PlaybooksResource")}async getByIds(e){return await this.client._request("GET","/api/v1/playbooks",{query:{ids:e.join(",")}})}async listByOwner(e){let r={owner:e.owner};return e.limit!==void 0&&e.limit>0&&(r.limit=String(e.limit)),e.cursor&&(r.cursor=e.cursor),await this.client._request("GET","/api/v1/playbooks",{query:r})}async get(e){if(e.id)return(await this.getByIds([e.id])).items[0]??null;if(e.ref){let r=e.ref.indexOf("/");if(r<=0||r===e.ref.length-1)throw new c("INVALID_ARGUMENT",`Invalid ref "${e.ref}". Expected "owner/name".`,400);let i=e.ref.slice(0,r),n=e.ref.slice(r+1),o;for(;;){let a=await this.listByOwner({owner:i,cursor:o,limit:100}),l=a.items.find(u=>u.name===n);if(l)return l;if(!a.has_next||!a.next_cursor)return null;o=a.next_cursor}}throw new c("INVALID_ARGUMENT","id or ref is required",400)}async trending(e={}){let r={};e.cursor&&(r.cursor=e.cursor),e.current&&(r.current=e.current),e.limit!==void 0&&(r.limit=e.limit),e.dir&&(r.dir=e.dir),e.sort&&(r.sort=e.sort),e.keyword&&(r.keyword=e.keyword),e.tags&&e.tags.length>0&&(r.tags=e.tags.join(","));let i=await this.client._request("GET","/api/v1/playbooks/trending",{query:r}),n=qt(this.client.baseUrl);return{playbooks:(i.playbooks??[]).map(o=>Tt(o,n)),has_next:i.has_next??!1}}async setVisibility(e){if(!He.includes(e.visibility))throw new c("INVALID_ARGUMENT",`Invalid visibility "${e.visibility}". Expected one of: ${He.join(", ")}.`,400);return this.client._requireAuth(),await this.client._request("POST",`/api/v1/playbook/${encodeURIComponent(e.name)}/visibility`,{body:{visibility:e.visibility}})}};function qt(t){try{let e=new URL(t).hostname,r=/^api-llm\.([a-z0-9-]+)\.alva\.ai$/i.exec(e);if(r){let i=r[1].toLowerCase();return i==="prd"?"https://alva.ai":`https://${i}.alva.ai`}}catch{}return"https://alva.ai"}s(qt,"webOriginFromApiBase");function Tt(t,e){let r=t.creator?.name??"",i=t.name??"",n=r&&i?`${r}/${i}`:i,o=r&&i?`/u/${r}/playbooks/${i}`:"";return{id:t.id===void 0?"":String(t.id),ref:n,username:r,name:i,display_name:t.display_name??"",description:t.description??"",tags:t.tags??[],follow_count:t.follow_count??0,url_path:o,url:o?`${e}${o}`:"",...t.readme?{readme:t.readme}:{},cursor:t.cursor??""}}s(Tt,"toAgentPlaybook");var X=class{constructor(e){this.client=e}client;static{s(this,"SecretsResource")}async create(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/secrets",{body:{name:e.name,value:e.value}})}async list(){return this.client._requireAuth(),this.client._request("GET","/api/v1/secrets")}async get(e){this.client._requireAuth();let r=encodeURIComponent(e.name);return this.client._request("GET",`/api/v1/secrets/${r}`)}async update(e){this.client._requireAuth();let r=encodeURIComponent(e.name);await this.client._request("PUT",`/api/v1/secrets/${r}`,{body:{value:e.value}})}async delete(e){this.client._requireAuth();let r=encodeURIComponent(e.name);await this.client._request("DELETE",`/api/v1/secrets/${r}`)}};var Y=class{constructor(e){this.client=e}client;static{s(this,"SdkDocsResource")}async doc(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/sdk/doc",{query:{name:e.name}})}async partitions(){return this.client._requireAuth(),this.client._request("GET","/api/v1/sdk/partitions")}async partitionSummary(e){this.client._requireAuth();let r=encodeURIComponent(e.partition);return this.client._request("GET",`/api/v1/sdk/partitions/${r}/summary`)}};var Qe=[{skill:"arrays-data-api-crypto-futures-data",file:"binance-perp-usdt-kline",method:"GET",path:"/api/v1/crypto/binance/perp/usdt/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"binance-spot-usdt-kline",method:"GET",path:"/api/v1/crypto/binance/spot/usdt/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"crypto-detail",method:"GET",path:"/api/v1/crypto/detail",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"fear-greed-index",method:"GET",path:"/api/v1/crypto/fear-greed-index",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"funding-rate",method:"GET",path:"/api/v1/crypto/funding-rate",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"hyperliquid-perp-usdc-kline",method:"GET",path:"/api/v1/crypto/hyperliquid/perp/usdc/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"hyperliquid-spot-usdc-kline",method:"GET",path:"/api/v1/crypto/hyperliquid/spot/usdc/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"list",method:"GET",path:"/api/v1/crypto/list",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"long-short-ratio",method:"GET",path:"/api/v1/crypto/long-short-ratio",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"crypto-market-cap",method:"GET",path:"/api/v1/crypto/market-cap",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"market-metrics",method:"GET",path:"/api/v1/crypto/market-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"open-interest",method:"GET",path:"/api/v1/crypto/open-interest",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"screener-metrics",method:"GET",path:"/api/v1/crypto/screener/metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"screener-metrics-timerange",method:"GET",path:"/api/v1/crypto/screener/metrics/timerange",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"trading-pair",method:"GET",path:"/api/v1/crypto/trading-pair",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"country-weightings",method:"GET",path:"/api/v1/etf/country-weightings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"holdings",method:"GET",path:"/api/v1/etf/holdings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"info",method:"GET",path:"/api/v1/etf/info",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"sector-weightings",method:"GET",path:"/api/v1/etf/sector-weightings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-commodity-historical",method:"GET",path:"/api/v1/macro/commodity/historical",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-commodity-real-time",method:"GET",path:"/api/v1/macro/commodity/real-time",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-commodity-symbol-list",method:"GET",path:"/api/v1/macro/commodity/symbols",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"economic-indicators",method:"GET",path:"/api/v1/macro/economic-indicators",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-forex-historical",method:"GET",path:"/api/v1/macro/forex/historical",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-forex-real-time",method:"GET",path:"/api/v1/macro/forex/real-time",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-forex-symbol-list",method:"GET",path:"/api/v1/macro/forex/symbols",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-index-historical",method:"GET",path:"/api/v1/macro/index/historical",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-index-real-time",method:"GET",path:"/api/v1/macro/index/real-time",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"rates",method:"GET",path:"/api/v1/macro/treasury-rates",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-balance-sheets",method:"GET",path:"/api/v1/stocks/company/balance-sheets",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-cashflow-statements",method:"GET",path:"/api/v1/stocks/company/cashflow-statements",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-detail",method:"GET",path:"/api/v1/stocks/company/detail",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-income-statements",method:"GET",path:"/api/v1/stocks/company/income-statements",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-kpi",method:"GET",path:"/api/v1/stocks/company/kpi",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"crowdfunding-offerings",method:"GET",path:"/api/v1/stocks/crowdfunding/offerings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"dividends",method:"GET",path:"/api/v1/stocks/dividends",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"earnings-calendar",method:"GET",path:"/api/v1/stocks/earnings-calendar",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"equity-offering",method:"GET",path:"/api/v1/stocks/equity-offering",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-metrics",file:"financial-metrics",method:"GET",path:"/api/v1/stocks/financial-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"fiscal-dates",method:"GET",path:"/api/v1/stocks/fiscal-dates",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"fiscal-dates-range",method:"GET",path:"/api/v1/stocks/fiscal-dates/range",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"ipo-calendar",method:"GET",path:"/api/v1/stocks/ipo-calendar",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"ipo-confirmed-calendar",method:"GET",path:"/api/v1/stocks/ipo-confirmed-calendar",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"stocks-kline",method:"GET",path:"/api/v1/stocks/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-metrics",file:"market-metrics",method:"GET",path:"/api/v1/stocks/market-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"mergers-acquisitions",method:"GET",path:"/api/v1/stocks/mergers-acquisitions",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"outstanding-shares",method:"GET",path:"/api/v1/stocks/outstanding-shares",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-metrics",file:"ratings",method:"GET",path:"/api/v1/stocks/ratings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"basic-info-screener",method:"GET",path:"/api/v1/stocks/screener/basic-info/{sub}",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"event-screener",method:"GET",path:"/api/v1/stocks/screener/events",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-financial-metrics",method:"GET",path:"/api/v1/stocks/screener/financial-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-financial-metrics-timerange",method:"GET",path:"/api/v1/stocks/screener/financial-metrics/timerange",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-technical-metrics",method:"GET",path:"/api/v1/stocks/screener/technical-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-technical-metrics-timerange",method:"GET",path:"/api/v1/stocks/screener/technical-metrics/timerange",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"sec-earnings-release",method:"GET",path:"/api/v1/stocks/sec-earnings-release",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"shares-float",method:"GET",path:"/api/v1/stocks/shares-float",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"splits",method:"GET",path:"/api/v1/stocks/splits",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-exchange-flow",file:"exchange-flows",method:"GET",path:"/api/v1/crypto/exchange-flows",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-company-crypto-holdings",file:"crypto-holdings",method:"GET",path:"/api/v1/crypto/holdings",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-inflow-cdd",method:"GET",path:"/api/v1/crypto/metrics/inflow-cdd",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-leverage-ratio",method:"GET",path:"/api/v1/crypto/metrics/leverage-ratio",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-miner-to-exchange",method:"GET",path:"/api/v1/crypto/metrics/miner-to-exchange",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-mvrv",method:"GET",path:"/api/v1/crypto/metrics/mvrv",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-nupl",method:"GET",path:"/api/v1/crypto/metrics/nupl",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-puell-multiple",method:"GET",path:"/api/v1/crypto/metrics/puell-multiple",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-realized-price",method:"GET",path:"/api/v1/crypto/metrics/realized-price",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-sopr",method:"GET",path:"/api/v1/crypto/metrics/sopr",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-ssr",method:"GET",path:"/api/v1/crypto/metrics/ssr",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-whale-ratio",method:"GET",path:"/api/v1/crypto/metrics/whale-ratio",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"crypto-supply",method:"GET",path:"/api/v1/crypto/supply",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-futures-data",file:"taker-buy-sell-volume",method:"GET",path:"/api/v1/crypto/taker-buy-sell-volume",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"unlock-events",method:"GET",path:"/api/v1/crypto/unlock-events",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-etf-fundamentals",file:"flow",method:"GET",path:"/api/v1/etf/flow",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-options",file:"contracts",method:"GET",path:"/api/v1/options/contracts",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-options",file:"kline",method:"GET",path:"/api/v1/options/kline",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-fundamentals",file:"company-executives",method:"GET",path:"/api/v1/stocks/company/executives",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"company-price-target-consensus",method:"GET",path:"/api/v1/stocks/company/price-target-consensus",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"company-price-target-news",method:"GET",path:"/api/v1/stocks/company/price-target-news",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"company-price-target-summary",method:"GET",path:"/api/v1/stocks/company/price-target-summary",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-ownership-and-flow",file:"congress-recent-trades",method:"GET",path:"/api/v1/stocks/congress/recent-trades",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-stock-metrics",file:"darkpool",method:"GET",path:"/api/v1/stocks/darkpool",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"estimates-guidance",method:"GET",path:"/api/v1/stocks/estimates-guidance",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-ownership-and-flow",file:"insider-transactions",method:"GET",path:"/api/v1/stocks/insider/transactions",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-ownership-and-flow",file:"institution-holder",method:"GET",path:"/api/v1/stocks/institution-holder",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"activity",method:"GET",path:"polymarket:/activity",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"book",method:"GET",path:"polymarket:/book",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"closed-positions",method:"GET",path:"polymarket:/closed-positions",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"events",method:"GET",path:"polymarket:/events",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"holders",method:"GET",path:"polymarket:/holders",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"markets",method:"GET",path:"polymarket:/markets",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"midpoint",method:"GET",path:"polymarket:/midpoint",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"oi",method:"GET",path:"polymarket:/oi",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"positions",method:"GET",path:"polymarket:/positions",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"price",method:"GET",path:"polymarket:/price",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"prices-history",method:"GET",path:"polymarket:/prices-history",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"public-search",method:"GET",path:"polymarket:/public-search",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"series",method:"GET",path:"polymarket:/series",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"sports",method:"GET",path:"polymarket:/sports",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"spread",method:"GET",path:"polymarket:/spread",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"tags",method:"GET",path:"polymarket:/tags",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"trades",method:"GET",path:"polymarket:/trades",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"value",method:"GET",path:"polymarket:/value",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-events",file:"earnings-transcript",method:"GET",path:"/api/v1/stocks/earnings-transcript",tier:"unstructured",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-news",file:"market-news",method:"GET",path:"/api/v1/stocks/market-news",tier:"unstructured",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-by-handle",method:"GET",path:"/api/v1/social-feeds/x/by-handle",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-by-url",method:"GET",path:"/api/v1/social-feeds/x/by-url",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-entities-handle",method:"GET",path:"/api/v1/social-feeds/x/entities/handle/{twitter_handle}",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-entities-handles",method:"GET",path:"/api/v1/social-feeds/x/entities/handles",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-fundamentals",file:"company-detail-non-us",method:"GET",path:"/api/v1/stocks/non-us/company/detail",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-social-feeds",file:"x-search",method:"GET",path:"/api/v1/social-feeds/x/search",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-spot-market-price-and-volume",file:"stocks-non-us-kline",method:"GET",path:"/api/v1/stocks/non-us/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1}];function Je(t,e){return Qe.find(r=>r.skill===t&&r.file===e)}s(Je,"getSkillEndpointMetadata");function Ee(t){return Qe.filter(e=>e.skill===t)}s(Ee,"listSkillEndpointMetadata");var Z=class{constructor(e){this.client=e}client;static{s(this,"DataSkillsResource")}async list(){return{skills:((await this.client._request("GET","/api/v1/skills",{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data??[]).map(r=>({...r,...ze(r.name)}))}}async summary(e){let r=encodeURIComponent(e.name),n=(await this.client._request("GET",`/api/v1/skills/${r}`,{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data?.[0];if(!n)throw new Error(`empty skills summary response for "${e.name}"`);let o=Ee(e.name);return{...n,...ze(e.name),...o.length>0?{endpoint_metadata:o}:{}}}async endpoint(e){let r=encodeURIComponent(e.name),n=(await this.client._request("GET",`/api/v1/skills/${r}`,{baseUrl:this.client.arraysBaseUrl,noAuth:!0,query:{endpoint:e.file}})).data?.[0];if(!n)throw new Error(`empty skills endpoint response for "${e.name}" file "${e.file}"`);let o=Je(e.name,e.file);return{...n,...o?{metadata:o}:{}}}};function ze(t){let e=Ee(t);if(e.length===0)return{};let r={},i=0;for(let n of e)r[n.tier]=(r[n.tier]??0)+1,n.pro_required&&(i+=1);return{endpoint_tier_counts:r,metadata:{endpoint_count:e.length,endpoint_tier_counts:r,pro_count:i}}}s(ze,"metadataSummaryForSkill");function Ke(t){return{username:t.username,name:t.name,display_name:t.display_name,description:t.description,tags:t.tags,creator_uid:t.creator_uid,updated_at:t.updated_at}}s(Ke,"normalizePlaybookSkillSummary");function Xe(t){let e=t.split("/");if(e.length!==2||!e[0]||!e[1])throw new c("INVALID_ARGUMENT",`playbook skill identifier must be "<user>/<name>", got "${t}"`,0);return{username:e[0],name:e[1]}}s(Xe,"parsePlaybookSkillId");var ee=class{constructor(e){this.client=e}client;static{s(this,"PlaybookSkillsResource")}async list(e){let r={};return e?.tag&&(r.tag=e.tag),e?.username&&(r.username=e.username),{skills:((await this.client._request("GET","/api/v1/skills",{query:r})).data??[]).map(Ke)}}async tags(){return{tags:(await this.client._request("GET","/api/v1/skills/tags")).data??[]}}async get(e){let{username:r,name:i}=Xe(e),n=encodeURIComponent(r),o=encodeURIComponent(i),l=(await this.client._request("GET",`/api/v1/skills/${n}/${o}`)).data?.[0];if(!l)throw new c("NOT_FOUND",`empty playbook skills get response for ${e}`,0);return{...Ke(l),files:l.files??[]}}async file(e,r){let{username:i,name:n}=Xe(e),o=encodeURIComponent(i),a=encodeURIComponent(n),l=r.split("/").map(encodeURIComponent).join("/"),d=(await this.client._request("GET",`/api/v1/skills/${o}/${a}/files/${l}`)).data?.[0];if(!d)throw new c("NOT_FOUND",`empty playbook skills file response for ${e} path ${r}`,0);return d}};var te=class{constructor(e){this.client=e}client;static{s(this,"CommentsResource")}async create(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/playbook/comment",{body:{username:e.username,name:e.name,content:e.content,parent_id:e.parent_id}})}async pin(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/playbook/comment/pin",{body:{comment_id:e.comment_id}})}async unpin(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/playbook/comment/unpin",{body:{comment_id:e.comment_id}})}};var re=class{constructor(e){this.client=e}client;static{s(this,"RemixResource")}async save(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/remix",{body:{child:e.child,parents:e.parents}})}};var ie=class{constructor(e){this.client=e}client;static{s(this,"ScreenshotResource")}async capture(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/screenshot",{query:{url:e.url,selector:e.selector,xpath:e.xpath,compress:e.compress,compress_quality:e.compressQuality,compress_max_width:e.compressMaxWidth}})}};var se=class{constructor(e){this.client=e}client;static{s(this,"UserResource")}async me(){return this.client._requireAuth(),this.client._request("GET","/api/v1/me")}};var ne=class{constructor(e){this.client=e}client;static{s(this,"TradingResource")}async accounts(){return this.client._requireAuth(),this.client._request("GET","/api/v1/trading/accounts")}async portfolio(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/trading/portfolio",{query:{accountId:e}})}async orders(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/trading/orders",{query:{accountId:e.accountId,source:e.source,since:e.since,limit:e.limit}})}async subscriptions(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/trading/subscriptions",{query:{accountId:e}})}async equityHistory(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/trading/equity-history",{query:{accountId:e.accountId,timeframe:e.timeframe,sinceMs:e.sinceMs,untilMs:e.untilMs}})}async riskRules(){return this.client._requireAuth(),this.client._request("GET","/api/v1/trading/risk-rules")}async subscribe(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/trading/subscribe",{body:e})}async unsubscribe(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/trading/unsubscribe",{body:{subscriptionId:e}})}async execute(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/trading/execute",{body:e})}async updateRiskRules(e){return this.client._requireAuth(),this.client._request("PUT","/api/v1/trading/risk-rules",{body:e})}};var oe=class{constructor(e){this.client=e}client;static{s(this,"PortfolioResource")}async accounts(){return this.client._requireAuth(),this.client._request("GET","/api/v1/portfolio/accounts")}async summary(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/portfolio/summary",{query:{accountId:e}})}async activities(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/portfolio/activities",{query:{accountId:e.accountId,limit:e.limit,pageToken:e.pageToken}})}};var ae=class{constructor(e){this.client=e}client;static{s(this,"ArraysJwtResource")}async ensure(){return this.client._requireAuth(),this.client._request("POST","/api/v1/arrays-jwt/ensure")}async status(){return this.client._requireAuth(),this.client._request("GET","/api/v1/arrays-jwt/status")}};var ce=class{constructor(e){this.client=e}client;static{s(this,"NotificationsResource")}async listPlaybook(e){this.client._requireAuth();let r=`/api/v1/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",r,{query:Ye(e)})}async listFeed(e){this.client._requireAuth();let r=`/api/v1/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",r,{query:Ye(e)})}};function Ye(t){let e={};return t.channel&&(e.channel=t.channel),t.status&&(e.status=t.status),t.since_time!==void 0&&t.since_time>0&&(e.since_time=String(t.since_time)),t.first!==void 0&&t.first>0&&(e.first=String(t.first)),t.cursor&&(e.cursor=t.cursor),e}s(Ye,"buildQuery");var le=class{constructor(e){this.client=e}client;static{s(this,"NotificationPreferencesResource")}async list(){return this.client._requireAuth(),this.client._request("GET","/api/v1/me/notifications/preferences")}async update(e){return this.client._requireAuth(),this.client._request("PATCH",`/api/v1/me/notifications/preferences/${encodeURIComponent(e.key)}`,{body:{enabled:e.enabled}})}};var ue=class{constructor(e){this.client=e}client;static{s(this,"SubscriptionsResource")}async subscribePlaybook(e){this.client._requireAuth();let r=`/api/v1/subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",r)}async unsubscribePlaybook(e){this.client._requireAuth();let r=`/api/v1/subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",r)}async subscribeFeed(e){this.client._requireAuth();let r=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",r)}async unsubscribeFeed(e){this.client._requireAuth();let r=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",r)}async list(e={}){this.client._requireAuth();let r={};return e.first!==void 0&&e.first>0&&(r.first=String(e.first)),e.cursor&&(r.cursor=e.cursor),this.client._request("GET","/api/v1/me/subscriptions",{query:r})}async follows(e={}){this.client._requireAuth();let r={};return e.limit!==void 0&&e.limit>0&&(r.limit=String(e.limit)),e.cursor&&(r.cursor=e.cursor),this.client._request("GET","/api/v1/me/follows",{query:r})}async unsubscribeBatch(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/subscriptions/unsubscribe-batch",{body:{playbook_ids:e.playbookIds??[],feed_ids:e.feedIds??[]}})}};var T=class{constructor(e){this.client=e}client;static{s(this,"AlertsResource")}list(e={}){return this.client.subscriptions.list(e)}enableAutomation(e){return this.client.subscriptions.subscribeFeed(e)}disableAutomation(e){return this.client.subscriptions.unsubscribeFeed(e)}enablePlaybook(e){return this.client.subscriptions.subscribePlaybook(e)}disablePlaybook(e){return this.client.subscriptions.unsubscribePlaybook(e)}disableBatch(e){return this.client.subscriptions.unsubscribeBatch(e)}historyAutomation(e){return this.client.notifications.listFeed(e)}historyPlaybook(e){return this.client.notifications.listPlaybook(e)}preferences(){return this.client.notificationPreferences.list()}updatePreference(e){return this.client.notificationPreferences.update(e)}};var pe=class{constructor(e){this.client=e}client;static{s(this,"ChannelGroupSubscriptionsResource")}async context(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/channel/group-subscriptions/context",{query:{session_id:e.session_id}})}async list(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/channel/group-subscriptions",{query:{session_id:e.session_id}})}async subscribe(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/channel/group-subscriptions",{jsonBody:Ze(e)})}async unsubscribe(e){return this.client._requireAuth(),this.client._request("DELETE","/api/v1/channel/group-subscriptions",{jsonBody:Ze(e)})}};function Ze(t){return`{"session_id":${et(t.session_id)},"target_type":${JSON.stringify(t.target_type)},"target_id":${et(t.target_id)}}`}s(Ze,"mutationBody");function et(t){if(typeof t=="number"){if(!Number.isInteger(t)||t<=0||!Number.isSafeInteger(t))throw new c("INVALID_ARGUMENT","channel group subscription ids must be positive safe integers; pass large int64 ids as strings",0);return String(t)}if(!/^[1-9]\d*$/.test(t))throw new c("INVALID_ARGUMENT","channel group subscription ids must be positive integer strings",0);return t}s(et,"idLiteral");var de=class{constructor(e){this.client=e}client;static{s(this,"FeedbackResource")}async submit(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/feedback",{body:e})}};var me=class{constructor(e){this.client=e}client;static{s(this,"FunctionsResource")}async register(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/service/functions",{body:{playbook_id:e.playbook_id,function_name:e.function_name,entry_script_path:e.entry_script_path,params_schema:e.params_schema,allow_charges:e.allow_charges,run_as_user_id:e.run_as_user_id}})}async list(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/service/functions",{query:{playbook_id:e.playbook_id}})}async delete(e){this.client._requireAuth(),await this.client._request("DELETE","/api/v1/service/functions",{query:{playbook_id:e.playbook_id,function_name:e.function_name}})}async invoke(e){this.client._requireAuth();let r=await this.client._request("POST","/api/v1/service/invoke",{body:{playbook_id:e.playbook_id,function_name:e.function_name,parameters_json:JSON.stringify(e.parameters??{})}});return{...r,result:Et(r.result)}}async getAllowance(e){this.client._requireAuth();let r=await this.client._request("GET","/api/v1/service/allowance",{query:{playbook_id:e.playbook_id}});return we(r.allowance)}async listAllowances(){return this.client._requireAuth(),{allowances:((await this.client._request("GET","/api/v1/service/allowances")).allowances??[]).map(r=>we(r)).filter(r=>r!==null)}}async createAllowance(e){this.client._requireAuth();let r=await this.client._request("POST","/api/v1/service/allowance",{body:{playbook_id:e.playbook_id,amount:e.amount}});return{allowance:St(r.allowance)}}async revokeAllowance(e){return this.client._requireAuth(),await this.client._request("DELETE","/api/v1/service/allowance",{query:{playbook_id:e.playbook_id}}),{ok:!0}}};function we(t){if(!t)return null;let e={id:t.id??"",consumer_uid:t.consumer_uid??t.consumerUid??"",playbook_id:t.playbook_id??t.playbookId??"",amount:t.amount??0,used:t.used??0,remaining:t.remaining??0},r=tt(t.created_at_ms??t.createdAtMs??t.created_at??t.createdAt),i=tt(t.updated_at_ms??t.updatedAtMs??t.updated_at??t.updatedAt);return r!==void 0&&(e.created_at_ms=r),i!==void 0&&(e.updated_at_ms=i),e}s(we,"normalizeAllowance");function St(t){let e=we(t);if(!e)throw new Error("allowance response missing allowance");return e}s(St,"requireAllowance");function tt(t){if(t==null)return;if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"){let n=Number(t);if(Number.isFinite(n))return n;let o=Date.parse(t);return Number.isNaN(o)?void 0:o}if(typeof t!="object")return;let e=t,r=typeof e.seconds=="number"?e.seconds:typeof e.seconds=="string"?Number(e.seconds):void 0,i=typeof e.nanos=="number"?e.nanos:typeof e.nanos=="string"?Number(e.nanos):0;if(!(r===void 0||!Number.isFinite(r)))return r*1e3+Math.floor((Number.isFinite(i)?i:0)/1e6)}s(tt,"timestampMs");function Et(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}}s(Et,"parseResultPayload");var wt=`
2
2
  query ToolkitCreditWallet {
3
3
  viewer {
4
4
  creditWallet {
@@ -8,7 +8,7 @@ query ToolkitCreditWallet {
8
8
  }
9
9
  }
10
10
  }
11
- `.trim(),Tt=`
11
+ `.trim(),At=`
12
12
  query ToolkitCreditWalletItems($input: CreditWalletItemConnectionInput!) {
13
13
  viewer {
14
14
  creditWallet {
@@ -40,5 +40,5 @@ query ToolkitCreditWalletItems($input: CreditWalletItemConnectionInput!) {
40
40
  }
41
41
  }
42
42
  }
43
- `.trim();function Et(t){let e=t.map(r=>typeof r.message=="string"&&r.message?r.message:void 0).filter(r=>!!r);return e.length>0?e.join("; "):"GraphQL request failed"}s(Et,"graphQLErrorMessage");var pe=class{constructor(e){this.client=e}client;static{s(this,"CreditsResource")}async wallet(){this.client._requireAuth();let r=(await this.graphql(Rt)).viewer?.creditWallet;if(!r)throw new l("GRAPHQL_EMPTY_RESPONSE","GraphQL response did not include viewer.creditWallet",502);return r}async items(e){this.client._requireAuth();let i=(await this.graphql(Tt,{input:{startAtMs:e.startAtMs,endAtMs:e.endAtMs,sessionId:e.sessionId,first:e.first,after:e.after}})).viewer?.creditWallet;if(!i)throw new l("GRAPHQL_EMPTY_RESPONSE","GraphQL response did not include viewer.creditWallet.items",502);return i}async graphql(e,r){let i=await this.client._request("POST","/query",{body:r===void 0?{query:e}:{query:e,variables:r}});if(i.errors&&i.errors.length>0)throw new l("GRAPHQL_ERROR",Et(i.errors),400,{errors:i.errors});if(!i.data)throw new l("GRAPHQL_EMPTY_RESPONSE","GraphQL response did not include data",502);return i.data}};var wt="https://api-llm.prd.alva.ai",St="https://data-tools.prd.space.id";function Ee(t){return typeof t=="object"&&t!==null}s(Ee,"isRecord");function de(t,e){if(!Ee(t))return;let r=t[e];return typeof r=="string"&&r?r:void 0}s(de,"stringField");function At(t){if(t==null)return{};let e={};if(t instanceof Error){t.name&&(e.name=t.name),t.message&&(e.message=t.message);let i=de(t,"code");i&&(e.code=i)}else if(Ee(t)){let i=de(t,"code"),n=de(t,"name"),o=de(t,"message");i&&(e.code=i),n&&(e.name=n),o&&(e.message=o)}else e.message=String(t);let r=[e.code,e.name,e.message].filter(i=>!!i);return{message:r.length>0?r.join(": "):void 0,details:Object.keys(e).length>0?e:void 0}}s(At,"describeCause");function Ct(t){let e=t instanceof Error&&t.message?t.message:"Network request failed",r={};t instanceof Error?(r.name=t.name,r.message=t.message):r.message=String(t);let{message:i,details:n}=At(Ee(t)?t.cause:void 0);return n&&(r.cause=n),{message:i?`${e}; cause: ${i}`:e,details:r}}s(Ct,"describeFetchFailure");var me=class{static{s(this,"AlvaClient")}baseUrl;arraysBaseUrl;viewer_token;pbsvToken;apiKey;gaClientId;gaSessionId;utmParams;signal;originSessionId;_fs;_run;_deploy;_release;_feed;_playbooks;_secrets;_sdk;_dataSkills;_playbookSkills;_comments;_remix;_screenshot;_user;_trading;_portfolio;_arraysJwt;_notifications;_notificationPreferences;_subscriptions;_channelGroupSubscriptions;_feedback;_functions;_credits;constructor(e){this.baseUrl=e.baseUrl??wt,this.arraysBaseUrl=e.arraysBaseUrl??St,this.viewer_token=e.viewer_token,this.pbsvToken=e.pbsvToken,this.apiKey=e.apiKey,this.gaClientId=e.gaClientId,this.gaSessionId=e.gaSessionId,this.utmParams=e.utmParams,this.signal=e.signal,this.originSessionId=e.originSessionId}get fs(){return this._fs??=new B(this)}get run(){return this._run??=new $(this)}get deploy(){return this._deploy??=new W(this)}get release(){return this._release??=new V(this)}get feed(){return this._feed??=new H(this)}get playbooks(){return this._playbooks??=new Q(this)}get secrets(){return this._secrets??=new J(this)}get sdk(){return this._sdk??=new z(this)}get dataSkills(){return this._dataSkills??=new K(this)}get playbookSkills(){return this._playbookSkills??=new X(this)}get comments(){return this._comments??=new Y(this)}get remix(){return this._remix??=new Z(this)}get screenshot(){return this._screenshot??=new ee(this)}get user(){return this._user??=new te(this)}get trading(){return this._trading??=new re(this)}get portfolio(){return this._portfolio??=new ie(this)}get arraysJwt(){return this._arraysJwt??=new se(this)}get notifications(){return this._notifications??=new ne(this)}get notificationPreferences(){return this._notificationPreferences??=new oe(this)}get subscriptions(){return this._subscriptions??=new ae(this)}get channelGroupSubscriptions(){return this._channelGroupSubscriptions??=new le(this)}get feedback(){return this._feedback??=new ce(this)}get functions(){return this._functions??=new ue(this)}get credits(){return this._credits??=new pe(this)}_requireAuth(){if(!this.pbsvToken&&!this.viewer_token&&!this.apiKey)throw new l("UNAUTHENTICATED","Authentication is required. Pass pbsvToken, viewer_token, or apiKey in the constructor.",401)}async _request(e,r,i){let o=`${i?.baseUrl??this.baseUrl}${r}`;if(i?.query){let y=new URLSearchParams;for(let[b,_e]of Object.entries(i.query))_e!=null&&y.set(b,String(_e));let g=y.toString();g&&(o+=`?${g}`)}let a={};i?.noAuth||(this.pbsvToken?(a.Authorization=`Bearer ${this.pbsvToken}`,a["X-Pbsv"]="1"):this.viewer_token?a["x-Playbook-Viewer"]=this.viewer_token:this.apiKey&&(a["X-Alva-Api-Key"]=this.apiKey)),this.gaClientId&&(a["X-Alva-GA-Client-ID"]=this.gaClientId),this.gaSessionId&&(a["X-Alva-GA-Session-ID"]=this.gaSessionId),this.utmParams&&(a["X-Alva-UTM-Params"]=this.utmParams),this.originSessionId&&!i?.noAuth&&(a["X-Alva-Origin-Session-Id"]=this.originSessionId);let c;i?.rawBody!==void 0?(a["Content-Type"]="application/octet-stream",c=i.rawBody):i?.jsonBody!==void 0?(a["Content-Type"]="application/json",c=i.jsonBody):i?.body!==void 0&&(a["Content-Type"]="application/json",c=JSON.stringify(i.body));let u,d=i?.timeoutMs,f=i?.signal??this.signal;if(f?.aborted)throw new l("NETWORK_ABORTED",`Request aborted while calling ${e} ${r}`,0,{method:e,path:r});let N=d!==void 0?new AbortController:void 0,fe=!1,ye,L;N&&d!==void 0&&(f&&(L=s(()=>N.abort(f.reason),"abortListener"),f.addEventListener("abort",L,{once:!0})),ye=setTimeout(()=>{fe=!0,N.abort(new Error(`Request timed out after ${d}ms while calling ${e} ${r}`))},d));let we={method:e,headers:a,body:c,signal:N?.signal??f};d!==void 0&&(we.timeout=d);try{u=await fetch(o,we)}catch(y){if(f?.aborted&&!fe)throw new l("NETWORK_ABORTED",`Request aborted while calling ${e} ${r}`,0,{method:e,path:r});if(fe)throw new l("NETWORK_TIMEOUT",`Request timed out after ${d}ms while calling ${e} ${r}`,0,{method:e,path:r,timeout_ms:d});let g=Ct(y);throw new l("NETWORK_ERROR",g.message,0,{method:e,path:r,...g.details})}finally{L&&f&&f.removeEventListener("abort",L),ye!==void 0&&clearTimeout(ye)}if(!u.ok){let y="";try{y=await Promise.resolve(u.text())}catch{y=""}if((u.headers.get("content-type")??"").includes("application/json")&&y)try{let b=JSON.parse(y);if(b.error)throw new l(b.error.code??"UNKNOWN",b.error.message??`HTTP ${u.status}`,u.status)}catch(b){if(b instanceof l)throw b}throw new l("UNKNOWN",`HTTP ${u.status}: ${y.slice(0,200)}`,u.status)}if(u.status===204)return;let Se=(u.headers.get("content-type")??"").toLowerCase();return Se.includes("application/json")||Se.includes("+json")?u.json():u.arrayBuffer()}};var xt="0.14.1-beta.0";qe();return st(It);})();
43
+ `.trim();function Ct(t){let e=t.map(r=>typeof r.message=="string"&&r.message?r.message:void 0).filter(r=>!!r);return e.length>0?e.join("; "):"GraphQL request failed"}s(Ct,"graphQLErrorMessage");var fe=class{constructor(e){this.client=e}client;static{s(this,"CreditsResource")}async wallet(){this.client._requireAuth();let r=(await this.graphql(wt)).viewer?.creditWallet;if(!r)throw new c("GRAPHQL_EMPTY_RESPONSE","GraphQL response did not include viewer.creditWallet",502);return r}async items(e){this.client._requireAuth();let i=(await this.graphql(At,{input:{startAtMs:e.startAtMs,endAtMs:e.endAtMs,sessionId:e.sessionId,first:e.first,after:e.after}})).viewer?.creditWallet;if(!i)throw new c("GRAPHQL_EMPTY_RESPONSE","GraphQL response did not include viewer.creditWallet.items",502);return i}async graphql(e,r){let i=await this.client._request("POST","/query",{body:r===void 0?{query:e}:{query:e,variables:r}});if(i.errors&&i.errors.length>0)throw new c("GRAPHQL_ERROR",Ct(i.errors),400,{errors:i.errors});if(!i.data)throw new c("GRAPHQL_EMPTY_RESPONSE","GraphQL response did not include data",502);return i.data}};var xt="https://api-llm.prd.alva.ai",It="https://data-tools.prd.space.id";function Ae(t){return typeof t=="object"&&t!==null}s(Ae,"isRecord");function ye(t,e){if(!Ae(t))return;let r=t[e];return typeof r=="string"&&r?r:void 0}s(ye,"stringField");function Ft(t){if(t==null)return{};let e={};if(t instanceof Error){t.name&&(e.name=t.name),t.message&&(e.message=t.message);let i=ye(t,"code");i&&(e.code=i)}else if(Ae(t)){let i=ye(t,"code"),n=ye(t,"name"),o=ye(t,"message");i&&(e.code=i),n&&(e.name=n),o&&(e.message=o)}else e.message=String(t);let r=[e.code,e.name,e.message].filter(i=>!!i);return{message:r.length>0?r.join(": "):void 0,details:Object.keys(e).length>0?e:void 0}}s(Ft,"describeCause");function Gt(t){let e=t instanceof Error&&t.message?t.message:"Network request failed",r={};t instanceof Error?(r.name=t.name,r.message=t.message):r.message=String(t);let{message:i,details:n}=Ft(Ae(t)?t.cause:void 0);return n&&(r.cause=n),{message:i?`${e}; cause: ${i}`:e,details:r}}s(Gt,"describeFetchFailure");var _e=class{static{s(this,"AlvaClient")}baseUrl;arraysBaseUrl;viewer_token;pbsvToken;apiKey;gaClientId;gaSessionId;utmParams;signal;originSessionId;_fs;_run;_deploy;_serviceAccount;_release;_feed;_automation;_playbooks;_secrets;_sdk;_dataSkills;_playbookSkills;_comments;_remix;_screenshot;_user;_trading;_portfolio;_arraysJwt;_notifications;_notificationPreferences;_subscriptions;_alerts;_channelGroupSubscriptions;_feedback;_functions;_credits;constructor(e){this.baseUrl=e.baseUrl??xt,this.arraysBaseUrl=e.arraysBaseUrl??It,this.viewer_token=e.viewer_token,this.pbsvToken=e.pbsvToken,this.apiKey=e.apiKey,this.gaClientId=e.gaClientId,this.gaSessionId=e.gaSessionId,this.utmParams=e.utmParams,this.signal=e.signal,this.originSessionId=e.originSessionId}get fs(){return this._fs??=new W(this)}get run(){return this._run??=new V(this)}get deploy(){return this._deploy??=new H(this)}get serviceAccount(){return this._serviceAccount??=new Q(this)}get release(){return this._release??=new J(this)}get feed(){return this._feed??=new z(this)}get automation(){return this._automation??=new q(this)}get playbooks(){return this._playbooks??=new K(this)}get secrets(){return this._secrets??=new X(this)}get sdk(){return this._sdk??=new Y(this)}get dataSkills(){return this._dataSkills??=new Z(this)}get playbookSkills(){return this._playbookSkills??=new ee(this)}get comments(){return this._comments??=new te(this)}get remix(){return this._remix??=new re(this)}get screenshot(){return this._screenshot??=new ie(this)}get user(){return this._user??=new se(this)}get trading(){return this._trading??=new ne(this)}get portfolio(){return this._portfolio??=new oe(this)}get arraysJwt(){return this._arraysJwt??=new ae(this)}get notifications(){return this._notifications??=new ce(this)}get notificationPreferences(){return this._notificationPreferences??=new le(this)}get subscriptions(){return this._subscriptions??=new ue(this)}get alerts(){return this._alerts??=new T(this)}get channelGroupSubscriptions(){return this._channelGroupSubscriptions??=new pe(this)}get feedback(){return this._feedback??=new de(this)}get functions(){return this._functions??=new me(this)}get credits(){return this._credits??=new fe(this)}_requireAuth(){if(!this.pbsvToken&&!this.viewer_token&&!this.apiKey)throw new c("UNAUTHENTICATED","Authentication is required. Pass pbsvToken, viewer_token, or apiKey in the constructor.",401)}async _request(e,r,i){let o=`${i?.baseUrl??this.baseUrl}${r}`;if(i?.query){let y=new URLSearchParams;for(let[b,ke]of Object.entries(i.query))ke!=null&&y.set(b,String(ke));let g=y.toString();g&&(o+=`?${g}`)}let a={};i?.noAuth||(this.pbsvToken?(a.Authorization=`Bearer ${this.pbsvToken}`,a["X-Pbsv"]="1"):this.viewer_token?a["x-Playbook-Viewer"]=this.viewer_token:this.apiKey&&(a["X-Alva-Api-Key"]=this.apiKey)),this.gaClientId&&(a["X-Alva-GA-Client-ID"]=this.gaClientId),this.gaSessionId&&(a["X-Alva-GA-Session-ID"]=this.gaSessionId),this.utmParams&&(a["X-Alva-UTM-Params"]=this.utmParams),this.originSessionId&&!i?.noAuth&&(a["X-Alva-Origin-Session-Id"]=this.originSessionId);let l;i?.rawBody!==void 0?(a["Content-Type"]="application/octet-stream",l=i.rawBody):i?.jsonBody!==void 0?(a["Content-Type"]="application/json",l=i.jsonBody):i?.body!==void 0&&(a["Content-Type"]="application/json",l=JSON.stringify(i.body));let u,d=i?.timeoutMs,f=i?.signal??this.signal;if(f?.aborted)throw new c("NETWORK_ABORTED",`Request aborted while calling ${e} ${r}`,0,{method:e,path:r});let D=d!==void 0?new AbortController:void 0,he=!1,be,O;D&&d!==void 0&&(f&&(O=s(()=>D.abort(f.reason),"abortListener"),f.addEventListener("abort",O,{once:!0})),be=setTimeout(()=>{he=!0,D.abort(new Error(`Request timed out after ${d}ms while calling ${e} ${r}`))},d));let Ce={method:e,headers:a,body:l,signal:D?.signal??f};d!==void 0&&(Ce.timeout=d);try{u=await fetch(o,Ce)}catch(y){if(f?.aborted&&!he)throw new c("NETWORK_ABORTED",`Request aborted while calling ${e} ${r}`,0,{method:e,path:r});if(he)throw new c("NETWORK_TIMEOUT",`Request timed out after ${d}ms while calling ${e} ${r}`,0,{method:e,path:r,timeout_ms:d});let g=Gt(y);throw new c("NETWORK_ERROR",g.message,0,{method:e,path:r,...g.details})}finally{O&&f&&f.removeEventListener("abort",O),be!==void 0&&clearTimeout(be)}if(!u.ok){let y="";try{y=await Promise.resolve(u.text())}catch{y=""}if((u.headers.get("content-type")??"").includes("application/json")&&y)try{let b=JSON.parse(y);if(b.error)throw new c(b.error.code??"UNKNOWN",b.error.message??`HTTP ${u.status}`,u.status)}catch(b){if(b instanceof c)throw b}throw new c("UNKNOWN",`HTTP ${u.status}: ${y.slice(0,200)}`,u.status)}if(u.status===204)return;let xe=(u.headers.get("content-type")??"").toLowerCase();return xe.includes("application/json")||xe.includes("+json")?u.json():u.arrayBuffer()}};var Ut="0.15.1-beta.0";Te();return at(Nt);})();
44
44
  //# sourceMappingURL=browser.global.js.map