@alva-ai/toolkit 0.13.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -173,7 +173,7 @@ the `alva` binary:
173
173
 
174
174
  ```typescript
175
175
  import { AlvaClient } from '@alva-ai/toolkit';
176
- import { dispatch } from '@alva-ai/toolkit/cli';
176
+ import { CliUsageError, dispatch } from '@alva-ai/toolkit/cli';
177
177
 
178
178
  const client = new AlvaClient({ apiKey: process.env.ALVA_API_KEY });
179
179
  const result = await dispatch(
@@ -187,7 +187,9 @@ const result = await dispatch(
187
187
  `mode: 'jagent'` keeps the command surface aligned with ALFS-native agent
188
188
  tools: flags that read or write local files, such as `--local-file`, `--file`,
189
189
  `--params-schema-file`, and screenshot `--out`, are rejected. Use inline data
190
- or prepare content in ALFS before dispatching the CLI command.
190
+ or prepare content in ALFS before dispatching the CLI command. `dispatch()`
191
+ throws `CliUsageError` for command-line usage errors and `AlvaError` for API
192
+ errors.
191
193
 
192
194
  ## SDK Usage (Node.js)
193
195
 
@@ -1,2 +1,2 @@
1
- "use strict";var AlvaToolkit=(()=>{var O=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var Ze=Object.prototype.hasOwnProperty;var s=(r,e)=>O(r,"name",{value:e,configurable:!0});var er=(r,e)=>{for(var t in e)O(r,t,{get:e[t],enumerable:!0})},rr=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ye(e))!Ze.call(r,n)&&n!==t&&O(r,n,{get:()=>e[n],enumerable:!(i=Qe(e,n))||i.enumerable});return r};var tr=r=>rr(O({},"__esModule",{value:!0}),r);var Er={};er(Er,{AlvaClient:()=>pe,AlvaError:()=>l,PBSV_UPDATE_MESSAGE:()=>we,SUBSCRIBE_PROPOSE_MESSAGE:()=>Ge,SUBSCRIBE_RESULT_MESSAGE:()=>Ie,UDF_AUTH_REQUIRED_MESSAGE:()=>xe,UDF_CONSENT_REQUEST_MESSAGE:()=>Ae,UDF_CONSENT_RESPONSE_MESSAGE:()=>Ce,UdfAuthRequiredError:()=>v,UdfConsentDeniedError:()=>w,UdfConsentRequiredError:()=>S,UdfConsentTimeoutError:()=>A,UdfError:()=>p,UdfExecutionError:()=>U,UdfFunctionDisabledError:()=>G,UdfFunctionNotFoundError:()=>x,UdfInsufficientCredits:()=>C,UdfPidMismatchError:()=>k,UdfRateLimitedError:()=>I,UdfTokenExpiredError:()=>T,UdfTokenInvalidError:()=>E,UdfTransportError:()=>P,VERSION:()=>Tr,getViewerToken:()=>F,installPlaybookRuntime:()=>ge,mapUdfErrorResponse:()=>be,playbookIdFromToken:()=>he,subscribe:()=>je,udf:()=>Me});var p=class extends Error{static{s(this,"UdfError")}code;metadata;status;constructor(e,{code:t,metadata:i={},status:n}){super(e),this.name=new.target.name,this.code=t,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"})}},T=class extends p{static{s(this,"UdfTokenExpiredError")}},E=class extends p{static{s(this,"UdfTokenInvalidError")}},k=class extends p{static{s(this,"UdfPidMismatchError")}},S=class extends p{static{s(this,"UdfConsentRequiredError")}},w=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")}},G=class extends p{static{s(this,"UdfFunctionDisabledError")}},I=class extends p{static{s(this,"UdfRateLimitedError")}},U=class extends p{static{s(this,"UdfExecutionError")}},P=class extends p{static{s(this,"UdfTransportError")}},we="alva:pbsv:update",Ae="alva:udf:consent-request",Ce="alva:udf:consent-response",xe="alva:udf:auth-required",Ge="alva:subscribe:propose",Ie="alva:subscribe:result",Ue="https://api-llm.prd.alva.ai",Fe=300*1e3,R=null,y=null,ye=Ue,h=null,m=null,Se=!1,j=new Map,M=new Map,ir=s(r=>r==="subscribed"||r==="declined"||r==="timeout"?r:"error","normalizeProposalResult"),sr=s(r=>{let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return atob(t)},"decodeBase64Url"),he=s(r=>{if(!r)return null;let[,e]=r.split(".");if(!e)return null;try{let t=JSON.parse(sr(e));if(typeof t.pid=="number")return String(t.pid);if(typeof t.pid=="string")return t.pid}catch{return null}return null},"playbookIdFromToken"),F=s(()=>R,"getViewerToken"),q=s(()=>!!F(),"isAuthenticated"),nr=s(r=>{let e=new URL(r.location.href);e.searchParams.delete("_pbsv"),r.history.replaceState(null,"",e.pathname+e.search+e.hash)},"stripPbsvFromUrl"),or=s(r=>{let e=new URLSearchParams(r.location.search);R=e.get("_pbsv"),y=e.get("parent_origin"),ye=(e.get("api_origin")||Ue).replace(/\/$/,""),h=he(R),R&&nr(r)},"parseBootParams"),Ne=s(async r=>{try{return await r.json()}catch{return{}}},"safeJson"),ar=s(r=>{if(typeof r!="string")return r;try{return JSON.parse(r)}catch{return r}},"parseResultPayload"),cr=s(r=>{let e=r;return{...e,result:ar(e.result)}},"normalizeInvokeResponse"),De=s(r=>r.error?.metadata||r.details?.metadata||{},"errorMetadata"),be=s((r,e)=>{let t=r.error?.code||"TRANSPORT",i=r.error?.message||t,n=De(r),o={code:t,metadata:n,status:e};switch(t){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 S(i,o);case"INSUFFICIENT_CREDITS":return new C(i,o);case"FUNCTION_NOT_FOUND":return new x(i,o);case"FUNCTION_DISABLED":return new G(i,o);case"RESOURCE_EXHAUSTED":return new I(i,o);case"EXECUTION_FAILED":return new U(i,o);default:return new P(i,o)}},"mapUdfErrorResponse"),lr=s(r=>{if(!m||!y||r.origin!==y||r.source!==m.parent||!r.data||typeof r.data!="object")return;let e=r.data;if(e.type===we){typeof e.token=="string"&&e.token.length>0&&(R=e.token,h=he(e.token));return}if(e.type===Ie){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(ir(e.status));return}if(e.type!==Ce||typeof e.request_id!="string")return;let t=j.get(e.request_id);t&&(clearTimeout(t.timer),j.delete(e.request_id),t.resolve(e.granted===!0?"granted":"denied"))},"onMessage"),Oe=s(()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`,"randomRequestId"),ur=s(()=>{if(!h)return null;let r=Number(h);return Number.isSafeInteger(r)?r:null},"playbookIdForInvoke"),pr=s(async(r,e)=>{if(!m||!y)return"denied";let t=y,i=Oe();return new Promise(n=>{let o=setTimeout(()=>{j.delete(i),n("timeout")},Fe);j.set(i,{resolve:n,timer:o}),m?.parent.postMessage({type:Ae,request_id:i,playbook_id:r,min_allowance:e},t)})},"requestConsent"),dr=s(async r=>{if(!m||!y)return"error";let e=typeof r?.feedOwner=="string"?r.feedOwner.trim():"",t=typeof r?.feedName=="string"?r.feedName.trim():"";if(!e||!t)return"error";let i=y,n=Oe();return new Promise(o=>{let a=setTimeout(()=>{M.delete(n),o("timeout")},Fe);M.set(n,{resolve:o,timer:a}),m?.parent.postMessage({type:Ge,request_id:n,playbook_id:h,feed:{owner:e,name:t}},i)})},"proposeSubscribe"),je={propose:dr},mr=s(r=>{!m||!y||m.parent.postMessage({type:xe,function_name:r},y)},"requestAuthentication"),ke=s(async(r,e,t=!1)=>{let i=F();if(!i)throw new v;if(!h)throw new k("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let n=ur();if(!n)throw new k("Invalid playbook id.",{code:"PBSV_PID_MISMATCH"});let o;try{o=await fetch(`${ye}/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:r,parameters_json:JSON.stringify(e)})})}catch{throw new P("Network error while invoking UDF.",{code:"TRANSPORT"})}let a=await Ne(o);if(o.ok)return cr(a);if(a.error?.code==="CONSENT_REQUIRED"&&!t){let c=De(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 pr(u,d);if(f==="granted")return ke(r,e,!0);throw f==="timeout"?new A:new w}throw be(a,o.status)},"call"),fr=s(async()=>{let r=F();if(!r)throw new v;if(!h)throw new k("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let e=new URL(`${ye}/api/v1/service/functions`);e.searchParams.set("playbook_id",h);let t=await fetch(e.toString(),{headers:{Authorization:`Bearer ${r}`,"X-Pbsv":"1"}}),i=await Ne(t);if(!t.ok)throw be(i,t.status);let n=i.functions;return Array.isArray(n)?n:[]},"list"),_e=s((r,e,t)=>{r.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))},"dispatchButtonEvent"),_r=s(r=>{if(typeof r!="string")return r;let t=m?.document?.querySelector(r);if(t&&"appendChild"in t)return t;throw new Error(`UDF button target not found: ${r}`)},"resolveButtonTarget"),yr=s((r,e)=>{if(!m)throw new Error("Playbook runtime is not installed.");let t=_r(r),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=q()?n:a,i.disabled=!1,i.setAttribute("data-function-name",e.functionName),q()||i.setAttribute("aria-disabled","true"),i.addEventListener("click",async()=>{if(!q()){mr(e.functionName);return}if(!i.disabled){i.disabled=!0,i.textContent=o,_e(i,"alva:udf-button:loading",{functionName:e.functionName});try{let c=await ke(e.functionName,e.params??{});_e(i,"alva:udf-button:result",{functionName:e.functionName,result:c})}catch(c){_e(i,"alva:udf-button:error",{functionName:e.functionName,error:c})}finally{i.disabled=!1,i.textContent=q()?n:a,q()||i.setAttribute("aria-disabled","true")}}}),t.appendChild(i),i},"renderButton"),Me={call:ke,list:fr,getViewerToken:F,isAuthenticated:q,renderButton:yr,UdfError:p,UdfAuthRequiredError:v,UdfTokenExpiredError:T,UdfTokenInvalidError:E,UdfPidMismatchError:k,UdfConsentRequiredError:S,UdfConsentDeniedError:w,UdfConsentTimeoutError:A,UdfInsufficientCredits:C,UdfFunctionNotFoundError:x,UdfFunctionDisabledError:G,UdfRateLimitedError:I,UdfExecutionError:U,UdfTransportError:P},ge=s(r=>{let e=r??(typeof window>"u"?void 0:window);if(!e||Se)return;m=e,Se=!0,or(e),e.addEventListener("message",lr);let t=e,i=t.alva||{};t.alva={...i,udf:Me,subscribe:je}},"installPlaybookRuntime");var l=class extends Error{static{s(this,"AlvaError")}code;status;details;constructor(e,t,i,n){super(t),this.name="AlvaError",this.code=e,this.status=i,this.details=n}};function hr(r){let e=0;for(;e<r.length;){let t=r[e];if(t<=127){e+=1;continue}let i=0,n=0,o=0;if(t>=194&&t<=223)i=1,n=128,o=t&31;else if(t>=224&&t<=239)i=2,n=2048,o=t&15;else if(t>=240&&t<=244)i=3,n=65536,o=t&7;else return!1;if(e+i>=r.length)return!1;for(let a=1;a<=i;a+=1){let c=r[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(hr,"isValidUtf8");var L=class{constructor(e){this.client=e}client;static{s(this,"FsResource")}async read(e){let t=await this.client._request("GET","/api/v1/fs/read",{query:{path:e.path,offset:e.offset,size:e.size}});if(!(t instanceof ArrayBuffer)||!hr(new Uint8Array(t)))return t;let i=new TextDecoder("utf-8").decode(t);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 B=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 $=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:t,...i}=e;return this.client._request("PATCH",`/api/v1/deploy/cronjob/${t}`,{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}})}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 W=class{constructor(e){this.client=e}client;static{s(this,"FeedResource")}async stop(e){this.client._requireAuth();let t=qe(e.id);return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(t))}/stop`)}async resume(e){this.client._requireAuth();let t=qe(e.id);return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(t))}/resume`)}async delete(e){this.client._requireAuth();let t=qe(e.id);return this.client._request("DELETE",`/api/v1/feed/${encodeURIComponent(String(t))}`)}};function qe(r){if(!Number.isInteger(r)||r<=0)throw new Error("feed id must be a positive integer");return r}s(qe,"requireFeedID");var Le=["public","private","paid"],H=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 t={owner:e.owner};return e.limit!==void 0&&e.limit>0&&(t.limit=String(e.limit)),e.cursor&&(t.cursor=e.cursor),await this.client._request("GET","/api/v1/playbooks",{query:t})}async get(e){if(e.id)return(await this.getByIds([e.id])).items[0]??null;if(e.ref){let t=e.ref.indexOf("/");if(t<=0||t===e.ref.length-1)throw new l("INVALID_ARGUMENT",`Invalid ref "${e.ref}". Expected "owner/name".`,400);let i=e.ref.slice(0,t),n=e.ref.slice(t+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 t={};e.cursor&&(t.cursor=e.cursor),e.current&&(t.current=e.current),e.limit!==void 0&&(t.limit=e.limit),e.dir&&(t.dir=e.dir),e.sort&&(t.sort=e.sort),e.keyword&&(t.keyword=e.keyword),e.tags&&e.tags.length>0&&(t.tags=e.tags.join(","));let i=await this.client._request("GET","/api/v1/playbooks/trending",{query:t});return{playbooks:(i.playbooks??[]).map(br),has_next:i.has_next??!1}}async setVisibility(e){if(!Le.includes(e.visibility))throw new l("INVALID_ARGUMENT",`Invalid visibility "${e.visibility}". Expected one of: ${Le.join(", ")}.`,400);return this.client._requireAuth(),await this.client._request("POST",`/api/v1/playbook/${encodeURIComponent(e.name)}/visibility`,{body:{visibility:e.visibility}})}};function br(r){let e=r.creator?.name??"",t=r.name??"",i=e&&t?`${e}/${t}`:t;return{id:r.id===void 0?"":String(r.id),ref:i,username:e,name:t,display_name:r.display_name??"",description:r.description??"",tags:r.tags??[],follow_count:r.follow_count??0,url_path:e&&t?`/${e}/playbooks/${t}`:"",...r.readme?{readme:r.readme}:{},cursor:r.cursor??""}}s(br,"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 t=encodeURIComponent(e.name);return this.client._request("GET",`/api/v1/secrets/${t}`)}async update(e){this.client._requireAuth();let t=encodeURIComponent(e.name);await this.client._request("PUT",`/api/v1/secrets/${t}`,{body:{value:e.value}})}async delete(e){this.client._requireAuth();let t=encodeURIComponent(e.name);await this.client._request("DELETE",`/api/v1/secrets/${t}`)}};var K=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 t=encodeURIComponent(e.partition);return this.client._request("GET",`/api/v1/sdk/partitions/${t}/summary`)}};var Be=[{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 $e(r,e){return Be.find(t=>t.skill===r&&t.file===e)}s($e,"getSkillEndpointMetadata");function ve(r){return Be.filter(e=>e.skill===r)}s(ve,"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(t=>({...t,...Ve(t.name)}))}}async summary(e){let t=encodeURIComponent(e.name),n=(await this.client._request("GET",`/api/v1/skills/${t}`,{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data?.[0];if(!n)throw new Error(`empty skills summary response for "${e.name}"`);let o=ve(e.name);return{...n,...Ve(e.name),...o.length>0?{endpoint_metadata:o}:{}}}async endpoint(e){let t=encodeURIComponent(e.name),n=(await this.client._request("GET",`/api/v1/skills/${t}`,{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=$e(e.name,e.file);return{...n,...o?{metadata:o}:{}}}};function Ve(r){let e=ve(r);if(e.length===0)return{};let t={},i=0;for(let n of e)t[n.tier]=(t[n.tier]??0)+1,n.pro_required&&(i+=1);return{endpoint_tier_counts:t,metadata:{endpoint_count:e.length,endpoint_tier_counts:t,pro_count:i}}}s(Ve,"metadataSummaryForSkill");function We(r){return{username:r.username,name:r.name,display_name:r.display_name,description:r.description,tags:r.tags,creator_uid:r.creator_uid,updated_at:r.updated_at}}s(We,"normalizePlaybookSkillSummary");function He(r){let e=r.split("/");if(e.length!==2||!e[0]||!e[1])throw new l("INVALID_ARGUMENT",`playbook skill identifier must be "<user>/<name>", got "${r}"`,0);return{username:e[0],name:e[1]}}s(He,"parsePlaybookSkillId");var X=class{constructor(e){this.client=e}client;static{s(this,"PlaybookSkillsResource")}async list(e){let t={};return e?.tag&&(t.tag=e.tag),e?.username&&(t.username=e.username),{skills:((await this.client._request("GET","/api/v1/skills",{query:t})).data??[]).map(We)}}async tags(){return{tags:(await this.client._request("GET","/api/v1/skills/tags")).data??[]}}async get(e){let{username:t,name:i}=He(e),n=encodeURIComponent(t),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{...We(c),files:c.files??[]}}async file(e,t){let{username:i,name:n}=He(e),o=encodeURIComponent(i),a=encodeURIComponent(n),c=t.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 ${t}`,0);return d}};var Q=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 Y=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 Z=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 ee=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 te=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 ie=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 se=class{constructor(e){this.client=e}client;static{s(this,"NotificationsResource")}async listPlaybook(e){this.client._requireAuth();let t=`/api/v1/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",t,{query:Je(e)})}async listFeed(e){this.client._requireAuth();let t=`/api/v1/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",t,{query:Je(e)})}};function Je(r){let e={};return r.channel&&(e.channel=r.channel),r.status&&(e.status=r.status),r.since_time!==void 0&&r.since_time>0&&(e.since_time=String(r.since_time)),r.first!==void 0&&r.first>0&&(e.first=String(r.first)),r.cursor&&(e.cursor=r.cursor),e}s(Je,"buildQuery");var ne=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 oe=class{constructor(e){this.client=e}client;static{s(this,"SubscriptionsResource")}async subscribePlaybook(e){this.client._requireAuth();let t=`/api/v1/subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",t)}async unsubscribePlaybook(e){this.client._requireAuth();let t=`/api/v1/subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",t)}async subscribeFeed(e){this.client._requireAuth();let t=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",t)}async unsubscribeFeed(e){this.client._requireAuth();let t=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",t)}async list(e={}){this.client._requireAuth();let t={};return e.first!==void 0&&e.first>0&&(t.first=String(e.first)),e.cursor&&(t.cursor=e.cursor),this.client._request("GET","/api/v1/me/subscriptions",{query:t})}async follows(e={}){this.client._requireAuth();let t={};return e.limit!==void 0&&e.limit>0&&(t.limit=String(e.limit)),e.cursor&&(t.cursor=e.cursor),this.client._request("GET","/api/v1/me/follows",{query:t})}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 ae=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(r){return`{"session_id":${ze(r.session_id)},"target_type":${JSON.stringify(r.target_type)},"target_id":${ze(r.target_id)}}`}s(Ke,"mutationBody");function ze(r){if(typeof r=="number"){if(!Number.isInteger(r)||r<=0||!Number.isSafeInteger(r))throw new l("INVALID_ARGUMENT","channel group subscription ids must be positive safe integers; pass large int64 ids as strings",0);return String(r)}if(!/^[1-9]\d*$/.test(r))throw new l("INVALID_ARGUMENT","channel group subscription ids must be positive integer strings",0);return r}s(ze,"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 le=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 t=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{...t,result:gr(t.result)}}async getAllowance(e){this.client._requireAuth();let t=await this.client._request("GET","/api/v1/service/allowance",{query:{playbook_id:e.playbook_id}});return Pe(t.allowance)}async listAllowances(){return this.client._requireAuth(),{allowances:((await this.client._request("GET","/api/v1/service/allowances")).allowances??[]).map(t=>Pe(t)).filter(t=>t!==null)}}async createAllowance(e){this.client._requireAuth();let t=await this.client._request("POST","/api/v1/service/allowance",{body:{playbook_id:e.playbook_id,amount:e.amount}});return{allowance:kr(t.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 Pe(r){if(!r)return null;let e={id:r.id??"",consumer_uid:r.consumer_uid??r.consumerUid??"",playbook_id:r.playbook_id??r.playbookId??"",amount:r.amount??0,used:r.used??0,remaining:r.remaining??0},t=Xe(r.created_at_ms??r.createdAtMs??r.created_at??r.createdAt),i=Xe(r.updated_at_ms??r.updatedAtMs??r.updated_at??r.updatedAt);return t!==void 0&&(e.created_at_ms=t),i!==void 0&&(e.updated_at_ms=i),e}s(Pe,"normalizeAllowance");function kr(r){let e=Pe(r);if(!e)throw new Error("allowance response missing allowance");return e}s(kr,"requireAllowance");function Xe(r){if(r==null)return;if(typeof r=="number"&&Number.isFinite(r))return r;if(typeof r=="string"){let n=Number(r);if(Number.isFinite(n))return n;let o=Date.parse(r);return Number.isNaN(o)?void 0:o}if(typeof r!="object")return;let e=r,t=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(!(t===void 0||!Number.isFinite(t)))return t*1e3+Math.floor((Number.isFinite(i)?i:0)/1e6)}s(Xe,"timestampMs");function gr(r){if(typeof r!="string")return r;try{return JSON.parse(r)}catch{return r}}s(gr,"parseResultPayload");var qr="https://api-llm.prd.alva.ai",vr="https://data-tools.prd.space.id";function Re(r){return typeof r=="object"&&r!==null}s(Re,"isRecord");function ue(r,e){if(!Re(r))return;let t=r[e];return typeof t=="string"&&t?t:void 0}s(ue,"stringField");function Pr(r){if(r==null)return{};let e={};if(r instanceof Error){r.name&&(e.name=r.name),r.message&&(e.message=r.message);let i=ue(r,"code");i&&(e.code=i)}else if(Re(r)){let i=ue(r,"code"),n=ue(r,"name"),o=ue(r,"message");i&&(e.code=i),n&&(e.name=n),o&&(e.message=o)}else e.message=String(r);let t=[e.code,e.name,e.message].filter(i=>!!i);return{message:t.length>0?t.join(": "):void 0,details:Object.keys(e).length>0?e:void 0}}s(Pr,"describeCause");function Rr(r){let e=r instanceof Error&&r.message?r.message:"Network request failed",t={};r instanceof Error?(t.name=r.name,t.message=r.message):t.message=String(r);let{message:i,details:n}=Pr(Re(r)?r.cause:void 0);return n&&(t.cause=n),{message:i?`${e}; cause: ${i}`:e,details:t}}s(Rr,"describeFetchFailure");var pe=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;constructor(e){this.baseUrl=e.baseUrl??qr,this.arraysBaseUrl=e.arraysBaseUrl??vr,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 L(this)}get run(){return this._run??=new B(this)}get deploy(){return this._deploy??=new $(this)}get release(){return this._release??=new V(this)}get feed(){return this._feed??=new W(this)}get playbooks(){return this._playbooks??=new H(this)}get secrets(){return this._secrets??=new J(this)}get sdk(){return this._sdk??=new K(this)}get dataSkills(){return this._dataSkills??=new z(this)}get playbookSkills(){return this._playbookSkills??=new X(this)}get comments(){return this._comments??=new Q(this)}get remix(){return this._remix??=new Y(this)}get screenshot(){return this._screenshot??=new Z(this)}get user(){return this._user??=new ee(this)}get trading(){return this._trading??=new re(this)}get portfolio(){return this._portfolio??=new te(this)}get arraysJwt(){return this._arraysJwt??=new ie(this)}get notifications(){return this._notifications??=new se(this)}get notificationPreferences(){return this._notificationPreferences??=new ne(this)}get subscriptions(){return this._subscriptions??=new oe(this)}get channelGroupSubscriptions(){return this._channelGroupSubscriptions??=new ae(this)}get feedback(){return this._feedback??=new ce(this)}get functions(){return this._functions??=new le(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,t,i){let o=`${i?.baseUrl??this.baseUrl}${t}`;if(i?.query){let _=new URLSearchParams;for(let[b,fe]of Object.entries(i.query))fe!=null&&_.set(b,String(fe));let g=_.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} ${t}`,0,{method:e,path:t});let N=d!==void 0?new AbortController:void 0,de=!1,me,D;N&&d!==void 0&&(f&&(D=s(()=>N.abort(f.reason),"abortListener"),f.addEventListener("abort",D,{once:!0})),me=setTimeout(()=>{de=!0,N.abort(new Error(`Request timed out after ${d}ms while calling ${e} ${t}`))},d));let Te={method:e,headers:a,body:c,signal:N?.signal??f};d!==void 0&&(Te.timeout=d);try{u=await fetch(o,Te)}catch(_){if(f?.aborted&&!de)throw new l("NETWORK_ABORTED",`Request aborted while calling ${e} ${t}`,0,{method:e,path:t});if(de)throw new l("NETWORK_TIMEOUT",`Request timed out after ${d}ms while calling ${e} ${t}`,0,{method:e,path:t,timeout_ms:d});let g=Rr(_);throw new l("NETWORK_ERROR",g.message,0,{method:e,path:t,...g.details})}finally{D&&f&&f.removeEventListener("abort",D),me!==void 0&&clearTimeout(me)}if(!u.ok){let _="";try{_=await Promise.resolve(u.text())}catch{_=""}if((u.headers.get("content-type")??"").includes("application/json")&&_)try{let b=JSON.parse(_);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}: ${_.slice(0,200)}`,u.status)}if(u.status===204)return;let Ee=u.headers.get("content-type")??"";return Ee.includes("application/octet-stream")||Ee.includes("image/")?u.arrayBuffer():u.json()}};var Tr="0.13.0";ge();return tr(Er);})();
1
+ "use strict";var AlvaToolkit=(()=>{var O=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var er=Object.prototype.hasOwnProperty;var s=(r,e)=>O(r,"name",{value:e,configurable:!0});var rr=(r,e)=>{for(var t in e)O(r,t,{get:e[t],enumerable:!0})},tr=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ze(e))!er.call(r,n)&&n!==t&&O(r,n,{get:()=>e[n],enumerable:!(i=Ye(e,n))||i.enumerable});return r};var ir=r=>tr(O({},"__esModule",{value:!0}),r);var Sr={};rr(Sr,{AlvaClient:()=>de,AlvaError:()=>l,CliUsageError:()=>L,PBSV_UPDATE_MESSAGE:()=>Ae,SUBSCRIBE_PROPOSE_MESSAGE:()=>Ie,SUBSCRIBE_RESULT_MESSAGE:()=>Ue,UDF_AUTH_REQUIRED_MESSAGE:()=>Ge,UDF_CONSENT_REQUEST_MESSAGE:()=>Ce,UDF_CONSENT_RESPONSE_MESSAGE:()=>xe,UdfAuthRequiredError:()=>v,UdfConsentDeniedError:()=>w,UdfConsentRequiredError:()=>S,UdfConsentTimeoutError:()=>A,UdfError:()=>p,UdfExecutionError:()=>U,UdfFunctionDisabledError:()=>G,UdfFunctionNotFoundError:()=>x,UdfInsufficientCredits:()=>C,UdfPidMismatchError:()=>k,UdfRateLimitedError:()=>I,UdfTokenExpiredError:()=>T,UdfTokenInvalidError:()=>E,UdfTransportError:()=>P,VERSION:()=>Er,getViewerToken:()=>F,installPlaybookRuntime:()=>qe,mapUdfErrorResponse:()=>ke,playbookIdFromToken:()=>be,subscribe:()=>Me,udf:()=>Le});var p=class extends Error{static{s(this,"UdfError")}code;metadata;status;constructor(e,{code:t,metadata:i={},status:n}){super(e),this.name=new.target.name,this.code=t,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"})}},T=class extends p{static{s(this,"UdfTokenExpiredError")}},E=class extends p{static{s(this,"UdfTokenInvalidError")}},k=class extends p{static{s(this,"UdfPidMismatchError")}},S=class extends p{static{s(this,"UdfConsentRequiredError")}},w=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")}},G=class extends p{static{s(this,"UdfFunctionDisabledError")}},I=class extends p{static{s(this,"UdfRateLimitedError")}},U=class extends p{static{s(this,"UdfExecutionError")}},P=class extends p{static{s(this,"UdfTransportError")}},Ae="alva:pbsv:update",Ce="alva:udf:consent-request",xe="alva:udf:consent-response",Ge="alva:udf:auth-required",Ie="alva:subscribe:propose",Ue="alva:subscribe:result",Fe="https://api-llm.prd.alva.ai",Ne=300*1e3,R=null,y=null,he=Fe,h=null,m=null,we=!1,j=new Map,M=new Map,sr=s(r=>r==="subscribed"||r==="declined"||r==="timeout"?r:"error","normalizeProposalResult"),nr=s(r=>{let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return atob(t)},"decodeBase64Url"),be=s(r=>{if(!r)return null;let[,e]=r.split(".");if(!e)return null;try{let t=JSON.parse(nr(e));if(typeof t.pid=="number")return String(t.pid);if(typeof t.pid=="string")return t.pid}catch{return null}return null},"playbookIdFromToken"),F=s(()=>R,"getViewerToken"),q=s(()=>!!F(),"isAuthenticated"),or=s(r=>{let e=new URL(r.location.href);e.searchParams.delete("_pbsv"),r.history.replaceState(null,"",e.pathname+e.search+e.hash)},"stripPbsvFromUrl"),ar=s(r=>{let e=new URLSearchParams(r.location.search);R=e.get("_pbsv"),y=e.get("parent_origin"),he=(e.get("api_origin")||Fe).replace(/\/$/,""),h=be(R),R&&or(r)},"parseBootParams"),De=s(async r=>{try{return await r.json()}catch{return{}}},"safeJson"),cr=s(r=>{if(typeof r!="string")return r;try{return JSON.parse(r)}catch{return r}},"parseResultPayload"),lr=s(r=>{let e=r;return{...e,result:cr(e.result)}},"normalizeInvokeResponse"),Oe=s(r=>r.error?.metadata||r.details?.metadata||{},"errorMetadata"),ke=s((r,e)=>{let t=r.error?.code||"TRANSPORT",i=r.error?.message||t,n=Oe(r),o={code:t,metadata:n,status:e};switch(t){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 S(i,o);case"INSUFFICIENT_CREDITS":return new C(i,o);case"FUNCTION_NOT_FOUND":return new x(i,o);case"FUNCTION_DISABLED":return new G(i,o);case"RESOURCE_EXHAUSTED":return new I(i,o);case"EXECUTION_FAILED":return new U(i,o);default:return new P(i,o)}},"mapUdfErrorResponse"),ur=s(r=>{if(!m||!y||r.origin!==y||r.source!==m.parent||!r.data||typeof r.data!="object")return;let e=r.data;if(e.type===Ae){typeof e.token=="string"&&e.token.length>0&&(R=e.token,h=be(e.token));return}if(e.type===Ue){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(sr(e.status));return}if(e.type!==xe||typeof e.request_id!="string")return;let t=j.get(e.request_id);t&&(clearTimeout(t.timer),j.delete(e.request_id),t.resolve(e.granted===!0?"granted":"denied"))},"onMessage"),je=s(()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`,"randomRequestId"),pr=s(()=>{if(!h)return null;let r=Number(h);return Number.isSafeInteger(r)?r:null},"playbookIdForInvoke"),dr=s(async(r,e)=>{if(!m||!y)return"denied";let t=y,i=je();return new Promise(n=>{let o=setTimeout(()=>{j.delete(i),n("timeout")},Ne);j.set(i,{resolve:n,timer:o}),m?.parent.postMessage({type:Ce,request_id:i,playbook_id:r,min_allowance:e},t)})},"requestConsent"),mr=s(async r=>{if(!m||!y)return"error";let e=typeof r?.feedOwner=="string"?r.feedOwner.trim():"",t=typeof r?.feedName=="string"?r.feedName.trim():"";if(!e||!t)return"error";let i=y,n=je();return new Promise(o=>{let a=setTimeout(()=>{M.delete(n),o("timeout")},Ne);M.set(n,{resolve:o,timer:a}),m?.parent.postMessage({type:Ie,request_id:n,playbook_id:h,feed:{owner:e,name:t}},i)})},"proposeSubscribe"),Me={propose:mr},fr=s(r=>{!m||!y||m.parent.postMessage({type:Ge,function_name:r},y)},"requestAuthentication"),ge=s(async(r,e,t=!1)=>{let i=F();if(!i)throw new v;if(!h)throw new k("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let n=pr();if(!n)throw new k("Invalid playbook id.",{code:"PBSV_PID_MISMATCH"});let o;try{o=await fetch(`${he}/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:r,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 lr(a);if(a.error?.code==="CONSENT_REQUIRED"&&!t){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 dr(u,d);if(f==="granted")return ge(r,e,!0);throw f==="timeout"?new A:new w}throw ke(a,o.status)},"call"),_r=s(async()=>{let r=F();if(!r)throw new v;if(!h)throw new k("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let e=new URL(`${he}/api/v1/service/functions`);e.searchParams.set("playbook_id",h);let t=await fetch(e.toString(),{headers:{Authorization:`Bearer ${r}`,"X-Pbsv":"1"}}),i=await De(t);if(!t.ok)throw ke(i,t.status);let n=i.functions;return Array.isArray(n)?n:[]},"list"),ye=s((r,e,t)=>{r.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))},"dispatchButtonEvent"),yr=s(r=>{if(typeof r!="string")return r;let t=m?.document?.querySelector(r);if(t&&"appendChild"in t)return t;throw new Error(`UDF button target not found: ${r}`)},"resolveButtonTarget"),hr=s((r,e)=>{if(!m)throw new Error("Playbook runtime is not installed.");let t=yr(r),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=q()?n:a,i.disabled=!1,i.setAttribute("data-function-name",e.functionName),q()||i.setAttribute("aria-disabled","true"),i.addEventListener("click",async()=>{if(!q()){fr(e.functionName);return}if(!i.disabled){i.disabled=!0,i.textContent=o,ye(i,"alva:udf-button:loading",{functionName:e.functionName});try{let c=await ge(e.functionName,e.params??{});ye(i,"alva:udf-button:result",{functionName:e.functionName,result:c})}catch(c){ye(i,"alva:udf-button:error",{functionName:e.functionName,error:c})}finally{i.disabled=!1,i.textContent=q()?n:a,q()||i.setAttribute("aria-disabled","true")}}}),t.appendChild(i),i},"renderButton"),Le={call:ge,list:_r,getViewerToken:F,isAuthenticated:q,renderButton:hr,UdfError:p,UdfAuthRequiredError:v,UdfTokenExpiredError:T,UdfTokenInvalidError:E,UdfPidMismatchError:k,UdfConsentRequiredError:S,UdfConsentDeniedError:w,UdfConsentTimeoutError:A,UdfInsufficientCredits:C,UdfFunctionNotFoundError:x,UdfFunctionDisabledError:G,UdfRateLimitedError:I,UdfExecutionError:U,UdfTransportError:P},qe=s(r=>{let e=r??(typeof window>"u"?void 0:window);if(!e||we)return;m=e,we=!0,ar(e),e.addEventListener("message",ur);let t=e,i=t.alva||{};t.alva={...i,udf:Le,subscribe:Me}},"installPlaybookRuntime");var l=class extends Error{static{s(this,"AlvaError")}code;status;details;constructor(e,t,i,n){super(t),this.name="AlvaError",this.code=e,this.status=i,this.details=n}},L=class extends Error{static{s(this,"CliUsageError")}command;constructor(e,t){super(e),this.name="CliUsageError",this.command=t}};function br(r){let e=0;for(;e<r.length;){let t=r[e];if(t<=127){e+=1;continue}let i=0,n=0,o=0;if(t>=194&&t<=223)i=1,n=128,o=t&31;else if(t>=224&&t<=239)i=2,n=2048,o=t&15;else if(t>=240&&t<=244)i=3,n=65536,o=t&7;else return!1;if(e+i>=r.length)return!1;for(let a=1;a<=i;a+=1){let c=r[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(br,"isValidUtf8");var B=class{constructor(e){this.client=e}client;static{s(this,"FsResource")}async read(e){let t=await this.client._request("GET","/api/v1/fs/read",{query:{path:e.path,offset:e.offset,size:e.size}});if(!(t instanceof ArrayBuffer)||!br(new Uint8Array(t)))return t;let i=new TextDecoder("utf-8").decode(t);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 V=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:t,...i}=e;return this.client._request("PATCH",`/api/v1/deploy/cronjob/${t}`,{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 W=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}})}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 t=ve(e.id);return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(t))}/stop`)}async resume(e){this.client._requireAuth();let t=ve(e.id);return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(t))}/resume`)}async delete(e){this.client._requireAuth();let t=ve(e.id);return this.client._request("DELETE",`/api/v1/feed/${encodeURIComponent(String(t))}`)}};function ve(r){if(!Number.isInteger(r)||r<=0)throw new Error("feed id must be a positive integer");return r}s(ve,"requireFeedID");var Be=["public","private","paid"],J=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 t={owner:e.owner};return e.limit!==void 0&&e.limit>0&&(t.limit=String(e.limit)),e.cursor&&(t.cursor=e.cursor),await this.client._request("GET","/api/v1/playbooks",{query:t})}async get(e){if(e.id)return(await this.getByIds([e.id])).items[0]??null;if(e.ref){let t=e.ref.indexOf("/");if(t<=0||t===e.ref.length-1)throw new l("INVALID_ARGUMENT",`Invalid ref "${e.ref}". Expected "owner/name".`,400);let i=e.ref.slice(0,t),n=e.ref.slice(t+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 t={};e.cursor&&(t.cursor=e.cursor),e.current&&(t.current=e.current),e.limit!==void 0&&(t.limit=e.limit),e.dir&&(t.dir=e.dir),e.sort&&(t.sort=e.sort),e.keyword&&(t.keyword=e.keyword),e.tags&&e.tags.length>0&&(t.tags=e.tags.join(","));let i=await this.client._request("GET","/api/v1/playbooks/trending",{query:t});return{playbooks:(i.playbooks??[]).map(kr),has_next:i.has_next??!1}}async setVisibility(e){if(!Be.includes(e.visibility))throw new l("INVALID_ARGUMENT",`Invalid visibility "${e.visibility}". Expected one of: ${Be.join(", ")}.`,400);return this.client._requireAuth(),await this.client._request("POST",`/api/v1/playbook/${encodeURIComponent(e.name)}/visibility`,{body:{visibility:e.visibility}})}};function kr(r){let e=r.creator?.name??"",t=r.name??"",i=e&&t?`${e}/${t}`:t;return{id:r.id===void 0?"":String(r.id),ref:i,username:e,name:t,display_name:r.display_name??"",description:r.description??"",tags:r.tags??[],follow_count:r.follow_count??0,url_path:e&&t?`/${e}/playbooks/${t}`:"",...r.readme?{readme:r.readme}:{},cursor:r.cursor??""}}s(kr,"toAgentPlaybook");var K=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 t=encodeURIComponent(e.name);return this.client._request("GET",`/api/v1/secrets/${t}`)}async update(e){this.client._requireAuth();let t=encodeURIComponent(e.name);await this.client._request("PUT",`/api/v1/secrets/${t}`,{body:{value:e.value}})}async delete(e){this.client._requireAuth();let t=encodeURIComponent(e.name);await this.client._request("DELETE",`/api/v1/secrets/${t}`)}};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 t=encodeURIComponent(e.partition);return this.client._request("GET",`/api/v1/sdk/partitions/${t}/summary`)}};var $e=[{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(r,e){return $e.find(t=>t.skill===r&&t.file===e)}s(Ve,"getSkillEndpointMetadata");function Pe(r){return $e.filter(e=>e.skill===r)}s(Pe,"listSkillEndpointMetadata");var X=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(t=>({...t,...We(t.name)}))}}async summary(e){let t=encodeURIComponent(e.name),n=(await this.client._request("GET",`/api/v1/skills/${t}`,{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data?.[0];if(!n)throw new Error(`empty skills summary response for "${e.name}"`);let o=Pe(e.name);return{...n,...We(e.name),...o.length>0?{endpoint_metadata:o}:{}}}async endpoint(e){let t=encodeURIComponent(e.name),n=(await this.client._request("GET",`/api/v1/skills/${t}`,{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 We(r){let e=Pe(r);if(e.length===0)return{};let t={},i=0;for(let n of e)t[n.tier]=(t[n.tier]??0)+1,n.pro_required&&(i+=1);return{endpoint_tier_counts:t,metadata:{endpoint_count:e.length,endpoint_tier_counts:t,pro_count:i}}}s(We,"metadataSummaryForSkill");function He(r){return{username:r.username,name:r.name,display_name:r.display_name,description:r.description,tags:r.tags,creator_uid:r.creator_uid,updated_at:r.updated_at}}s(He,"normalizePlaybookSkillSummary");function Je(r){let e=r.split("/");if(e.length!==2||!e[0]||!e[1])throw new l("INVALID_ARGUMENT",`playbook skill identifier must be "<user>/<name>", got "${r}"`,0);return{username:e[0],name:e[1]}}s(Je,"parsePlaybookSkillId");var Q=class{constructor(e){this.client=e}client;static{s(this,"PlaybookSkillsResource")}async list(e){let t={};return e?.tag&&(t.tag=e.tag),e?.username&&(t.username=e.username),{skills:((await this.client._request("GET","/api/v1/skills",{query:t})).data??[]).map(He)}}async tags(){return{tags:(await this.client._request("GET","/api/v1/skills/tags")).data??[]}}async get(e){let{username:t,name:i}=Je(e),n=encodeURIComponent(t),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{...He(c),files:c.files??[]}}async file(e,t){let{username:i,name:n}=Je(e),o=encodeURIComponent(i),a=encodeURIComponent(n),c=t.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 ${t}`,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 re=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 te=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 t=`/api/v1/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",t,{query:Ke(e)})}async listFeed(e){this.client._requireAuth();let t=`/api/v1/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",t,{query:Ke(e)})}};function Ke(r){let e={};return r.channel&&(e.channel=r.channel),r.status&&(e.status=r.status),r.since_time!==void 0&&r.since_time>0&&(e.since_time=String(r.since_time)),r.first!==void 0&&r.first>0&&(e.first=String(r.first)),r.cursor&&(e.cursor=r.cursor),e}s(Ke,"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 t=`/api/v1/subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",t)}async unsubscribePlaybook(e){this.client._requireAuth();let t=`/api/v1/subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",t)}async subscribeFeed(e){this.client._requireAuth();let t=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",t)}async unsubscribeFeed(e){this.client._requireAuth();let t=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",t)}async list(e={}){this.client._requireAuth();let t={};return e.first!==void 0&&e.first>0&&(t.first=String(e.first)),e.cursor&&(t.cursor=e.cursor),this.client._request("GET","/api/v1/me/subscriptions",{query:t})}async follows(e={}){this.client._requireAuth();let t={};return e.limit!==void 0&&e.limit>0&&(t.limit=String(e.limit)),e.cursor&&(t.cursor=e.cursor),this.client._request("GET","/api/v1/me/follows",{query:t})}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 ce=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(r){return`{"session_id":${Xe(r.session_id)},"target_type":${JSON.stringify(r.target_type)},"target_id":${Xe(r.target_id)}}`}s(ze,"mutationBody");function Xe(r){if(typeof r=="number"){if(!Number.isInteger(r)||r<=0||!Number.isSafeInteger(r))throw new l("INVALID_ARGUMENT","channel group subscription ids must be positive safe integers; pass large int64 ids as strings",0);return String(r)}if(!/^[1-9]\d*$/.test(r))throw new l("INVALID_ARGUMENT","channel group subscription ids must be positive integer strings",0);return r}s(Xe,"idLiteral");var le=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 t=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{...t,result:qr(t.result)}}async getAllowance(e){this.client._requireAuth();let t=await this.client._request("GET","/api/v1/service/allowance",{query:{playbook_id:e.playbook_id}});return Re(t.allowance)}async listAllowances(){return this.client._requireAuth(),{allowances:((await this.client._request("GET","/api/v1/service/allowances")).allowances??[]).map(t=>Re(t)).filter(t=>t!==null)}}async createAllowance(e){this.client._requireAuth();let t=await this.client._request("POST","/api/v1/service/allowance",{body:{playbook_id:e.playbook_id,amount:e.amount}});return{allowance:gr(t.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 Re(r){if(!r)return null;let e={id:r.id??"",consumer_uid:r.consumer_uid??r.consumerUid??"",playbook_id:r.playbook_id??r.playbookId??"",amount:r.amount??0,used:r.used??0,remaining:r.remaining??0},t=Qe(r.created_at_ms??r.createdAtMs??r.created_at??r.createdAt),i=Qe(r.updated_at_ms??r.updatedAtMs??r.updated_at??r.updatedAt);return t!==void 0&&(e.created_at_ms=t),i!==void 0&&(e.updated_at_ms=i),e}s(Re,"normalizeAllowance");function gr(r){let e=Re(r);if(!e)throw new Error("allowance response missing allowance");return e}s(gr,"requireAllowance");function Qe(r){if(r==null)return;if(typeof r=="number"&&Number.isFinite(r))return r;if(typeof r=="string"){let n=Number(r);if(Number.isFinite(n))return n;let o=Date.parse(r);return Number.isNaN(o)?void 0:o}if(typeof r!="object")return;let e=r,t=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(!(t===void 0||!Number.isFinite(t)))return t*1e3+Math.floor((Number.isFinite(i)?i:0)/1e6)}s(Qe,"timestampMs");function qr(r){if(typeof r!="string")return r;try{return JSON.parse(r)}catch{return r}}s(qr,"parseResultPayload");var vr="https://api-llm.prd.alva.ai",Pr="https://data-tools.prd.space.id";function Te(r){return typeof r=="object"&&r!==null}s(Te,"isRecord");function pe(r,e){if(!Te(r))return;let t=r[e];return typeof t=="string"&&t?t:void 0}s(pe,"stringField");function Rr(r){if(r==null)return{};let e={};if(r instanceof Error){r.name&&(e.name=r.name),r.message&&(e.message=r.message);let i=pe(r,"code");i&&(e.code=i)}else if(Te(r)){let i=pe(r,"code"),n=pe(r,"name"),o=pe(r,"message");i&&(e.code=i),n&&(e.name=n),o&&(e.message=o)}else e.message=String(r);let t=[e.code,e.name,e.message].filter(i=>!!i);return{message:t.length>0?t.join(": "):void 0,details:Object.keys(e).length>0?e:void 0}}s(Rr,"describeCause");function Tr(r){let e=r instanceof Error&&r.message?r.message:"Network request failed",t={};r instanceof Error?(t.name=r.name,t.message=r.message):t.message=String(r);let{message:i,details:n}=Rr(Te(r)?r.cause:void 0);return n&&(t.cause=n),{message:i?`${e}; cause: ${i}`:e,details:t}}s(Tr,"describeFetchFailure");var de=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;constructor(e){this.baseUrl=e.baseUrl??vr,this.arraysBaseUrl=e.arraysBaseUrl??Pr,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 V(this)}get release(){return this._release??=new W(this)}get feed(){return this._feed??=new H(this)}get playbooks(){return this._playbooks??=new J(this)}get secrets(){return this._secrets??=new K(this)}get sdk(){return this._sdk??=new z(this)}get dataSkills(){return this._dataSkills??=new X(this)}get playbookSkills(){return this._playbookSkills??=new Q(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 re(this)}get trading(){return this._trading??=new te(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 ce(this)}get feedback(){return this._feedback??=new le(this)}get functions(){return this._functions??=new ue(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,t,i){let o=`${i?.baseUrl??this.baseUrl}${t}`;if(i?.query){let _=new URLSearchParams;for(let[b,_e]of Object.entries(i.query))_e!=null&&_.set(b,String(_e));let g=_.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} ${t}`,0,{method:e,path:t});let N=d!==void 0?new AbortController:void 0,me=!1,fe,D;N&&d!==void 0&&(f&&(D=s(()=>N.abort(f.reason),"abortListener"),f.addEventListener("abort",D,{once:!0})),fe=setTimeout(()=>{me=!0,N.abort(new Error(`Request timed out after ${d}ms while calling ${e} ${t}`))},d));let Ee={method:e,headers:a,body:c,signal:N?.signal??f};d!==void 0&&(Ee.timeout=d);try{u=await fetch(o,Ee)}catch(_){if(f?.aborted&&!me)throw new l("NETWORK_ABORTED",`Request aborted while calling ${e} ${t}`,0,{method:e,path:t});if(me)throw new l("NETWORK_TIMEOUT",`Request timed out after ${d}ms while calling ${e} ${t}`,0,{method:e,path:t,timeout_ms:d});let g=Tr(_);throw new l("NETWORK_ERROR",g.message,0,{method:e,path:t,...g.details})}finally{D&&f&&f.removeEventListener("abort",D),fe!==void 0&&clearTimeout(fe)}if(!u.ok){let _="";try{_=await Promise.resolve(u.text())}catch{_=""}if((u.headers.get("content-type")??"").includes("application/json")&&_)try{let b=JSON.parse(_);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}: ${_.slice(0,200)}`,u.status)}if(u.status===204)return;let Se=u.headers.get("content-type")??"";return Se.includes("application/octet-stream")||Se.includes("image/")?u.arrayBuffer():u.json()}};var Er="0.13.1";qe();return ir(Sr);})();
2
2
  //# sourceMappingURL=browser.global.js.map