@alva-ai/toolkit 0.21.0 → 0.23.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/browser.global.js +130 -3
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +209 -10
- package/dist/cli.js +817 -689
- package/dist/cli.js.map +1 -1
- package/dist/dispatch.d.ts +210 -11
- package/dist/dispatch.js +314 -81
- package/dist/dispatch.js.map +1 -1
- package/dist/index.cjs +506 -609
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +210 -11
- package/dist/index.d.ts +210 -11
- package/dist/index.js +505 -609
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -343,6 +343,8 @@ alva comments <create|pin|unpin>
|
|
|
343
343
|
alva notification-preferences <list|enable-session-completed|disable-session-completed>
|
|
344
344
|
alva remix --child-username <u> --child-name <n> --parents <json>
|
|
345
345
|
alva screenshot --url <url> [--selector <s>] [--xpath <x>] --out <file>
|
|
346
|
+
alva markets narrative --ticker <symbol>
|
|
347
|
+
alva markets earnings --ticker <symbol> [--event <latest-completed|next-confirmed> | --fiscal-year <year> --fiscal-quarter <Q1|Q2|Q3|Q4>]
|
|
346
348
|
alva trading <accounts|portfolio|orders|subscriptions|equity-history|risk-rules|subscribe|unsubscribe|execute|update-risk-rules>
|
|
347
349
|
```
|
|
348
350
|
|
package/dist/browser.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var AlvaToolkit=(()=>{var O=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var nt=Object.prototype.hasOwnProperty;var s=(t,e)=>O(t,"name",{value:e,configurable:!0});var ot=(t,e)=>{for(var r in e)O(t,r,{get:e[r],enumerable:!0})},at=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of st(e))!nt.call(t,n)&&n!==r&&O(t,n,{get:()=>e[n],enumerable:!(i=it(e,n))||i.enumerable});return t};var ct=t=>at(O({},"__esModule",{value:!0}),t);var jt={};ot(jt,{AlertsResource:()=>T,AlvaClient:()=>he,AlvaError:()=>c,AutomationResource:()=>q,CliUsageError:()=>$,PBSV_UPDATE_MESSAGE:()=>Ge,SUBSCRIBE_PROPOSE_MESSAGE:()=>Le,SUBSCRIBE_RESULT_MESSAGE:()=>je,UDF_AUTH_REQUIRED_MESSAGE:()=>Ne,UDF_CONSENT_REQUEST_MESSAGE:()=>Ie,UDF_CONSENT_RESPONSE_MESSAGE:()=>Ue,UdfAuthRequiredError:()=>P,UdfConsentDeniedError:()=>C,UdfConsentRequiredError:()=>A,UdfConsentTimeoutError:()=>x,UdfError:()=>p,UdfExecutionError:()=>N,UdfFunctionDisabledError:()=>I,UdfFunctionNotFoundError:()=>G,UdfInsufficientCredits:()=>F,UdfPidMismatchError:()=>g,UdfRateLimitedError:()=>U,UdfTokenExpiredError:()=>E,UdfTokenInvalidError:()=>w,UdfTransportError:()=>R,VERSION:()=>Lt,getViewerToken:()=>L,installPlaybookRuntime:()=>Se,mapUdfErrorResponse:()=>qe,playbookIdFromToken:()=>Re,subscribe:()=>We,udf:()=>Ve});var p=class extends Error{static{s(this,"UdfError")}code;metadata;status;constructor(e,{code:r,metadata:i={},status:n}){super(e),this.name=new.target.name,this.code=r,this.metadata=i,this.status=n}},P=class extends p{static{s(this,"UdfAuthRequiredError")}constructor(){super("Sign in to use this UDF.",{code:"AUTH_REQUIRED"})}},E=class extends p{static{s(this,"UdfTokenExpiredError")}},w=class extends p{static{s(this,"UdfTokenInvalidError")}},g=class extends p{static{s(this,"UdfPidMismatchError")}},A=class extends p{static{s(this,"UdfConsentRequiredError")}},C=class extends p{static{s(this,"UdfConsentDeniedError")}constructor(){super("UDF consent was denied.",{code:"CONSENT_DENIED"})}},x=class extends p{static{s(this,"UdfConsentTimeoutError")}constructor(){super("UDF consent timed out.",{code:"CONSENT_TIMEOUT"})}},F=class extends p{static{s(this,"UdfInsufficientCredits")}},G=class extends p{static{s(this,"UdfFunctionNotFoundError")}},I=class extends p{static{s(this,"UdfFunctionDisabledError")}},U=class extends p{static{s(this,"UdfRateLimitedError")}},N=class extends p{static{s(this,"UdfExecutionError")}},R=class extends p{static{s(this,"UdfTransportError")}},Ge="alva:pbsv:update",Ie="alva:udf:consent-request",Ue="alva:udf:consent-response",Ne="alva:udf:auth-required",Le="alva:subscribe:propose",je="alva:subscribe:result",De="https://api-llm.prd.alva.ai",Oe=300*1e3,S=null,y=null,Pe=De,h=null,m=null,Fe=!1,M=new Map,B=new Map,lt=s(t=>t==="subscribed"||t==="declined"||t==="timeout"?t:"error","normalizeProposalResult"),ut=s(t=>{let e=t.replace(/-/g,"+").replace(/_/g,"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return atob(r)},"decodeBase64Url"),Re=s(t=>{if(!t)return null;let[,e]=t.split(".");if(!e)return null;try{let r=JSON.parse(ut(e));if(typeof r.pid=="number")return String(r.pid);if(typeof r.pid=="string")return r.pid}catch{return null}return null},"playbookIdFromToken"),L=s(()=>S,"getViewerToken"),v=s(()=>!!L(),"isAuthenticated"),pt=s(t=>{let e=new URL(t.location.href);e.searchParams.delete("_pbsv"),t.history.replaceState(null,"",e.pathname+e.search+e.hash)},"stripPbsvFromUrl"),dt=s(t=>{let e=new URLSearchParams(t.location.search);S=e.get("_pbsv"),y=e.get("parent_origin"),Pe=(e.get("api_origin")||De).replace(/\/$/,""),h=Re(S),S&&pt(t)},"parseBootParams"),Me=s(async t=>{try{return await t.json()}catch{return{}}},"safeJson"),mt=s(t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}},"parseResultPayload"),ft=s(t=>{let e=t;return{...e,result:mt(e.result)}},"normalizeInvokeResponse"),Be=s(t=>t.error?.metadata||t.details?.metadata||{},"errorMetadata"),qe=s((t,e)=>{let r=t.error?.code||"TRANSPORT",i=t.error?.message||r,n=Be(t),o={code:r,metadata:n,status:e};switch(r){case"PBSV_EXPIRED":return new E(i,o);case"PBSV_INVALID":case"UNAUTHENTICATED":return new w(i,o);case"PBSV_PID_MISMATCH":return new g(i,o);case"CONSENT_REQUIRED":return new A(i,o);case"INSUFFICIENT_CREDITS":return new F(i,o);case"FUNCTION_NOT_FOUND":return new G(i,o);case"FUNCTION_DISABLED":return new I(i,o);case"RESOURCE_EXHAUSTED":return new U(i,o);case"EXECUTION_FAILED":return new N(i,o);default:return new R(i,o)}},"mapUdfErrorResponse"),_t=s(t=>{if(!m||!y||t.origin!==y||t.source!==m.parent||!t.data||typeof t.data!="object")return;let e=t.data;if(e.type===Ge){typeof e.token=="string"&&e.token.length>0&&(S=e.token,h=Re(e.token));return}if(e.type===je){if(typeof e.request_id!="string")return;let i=B.get(e.request_id);if(!i)return;clearTimeout(i.timer),B.delete(e.request_id),i.resolve(lt(e.status));return}if(e.type!==Ue||typeof e.request_id!="string")return;let r=M.get(e.request_id);r&&(clearTimeout(r.timer),M.delete(e.request_id),r.resolve(e.granted===!0?"granted":"denied"))},"onMessage"),$e=s(()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`,"randomRequestId"),yt=s(()=>{if(!h)return null;let t=Number(h);return Number.isSafeInteger(t)?t:null},"playbookIdForInvoke"),ht=s(async(t,e)=>{if(!m||!y)return"denied";let r=y,i=$e();return new Promise(n=>{let o=setTimeout(()=>{M.delete(i),n("timeout")},Oe);M.set(i,{resolve:n,timer:o}),m?.parent.postMessage({type:Ie,request_id:i,playbook_id:t,min_allowance:e},r)})},"requestConsent"),bt=s(async t=>{if(!m||!y)return"error";let e=typeof t?.feedOwner=="string"?t.feedOwner.trim():"",r=typeof t?.feedName=="string"?t.feedName.trim():"";if(!e||!r)return"error";let i=y,n=$e();return new Promise(o=>{let a=setTimeout(()=>{B.delete(n),o("timeout")},Oe);B.set(n,{resolve:o,timer:a}),m?.parent.postMessage({type:Le,request_id:n,playbook_id:h,feed:{owner:e,name:r}},i)})},"proposeSubscribe"),We={propose:bt},gt=s(t=>{!m||!y||m.parent.postMessage({type:Ne,function_name:t},y)},"requestAuthentication"),Te=s(async(t,e,r=!1)=>{let i=L();if(!i)throw new P;if(!h)throw new g("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let n=yt();if(!n)throw new g("Invalid playbook id.",{code:"PBSV_PID_MISMATCH"});let o;try{o=await fetch(`${Pe}/api/v1/service/invoke`,{method:"POST",headers:{Authorization:`Bearer ${i}`,"X-Pbsv":"1","Content-Type":"application/json"},body:JSON.stringify({playbook_id:n,function_name:t,parameters_json:JSON.stringify(e)})})}catch{throw new R("Network error while invoking UDF.",{code:"TRANSPORT"})}let a=await Me(o);if(o.ok)return ft(a);if(a.error?.code==="CONSENT_REQUIRED"&&!r){let l=Be(a),u=typeof l.playbook_id=="string"?l.playbook_id:h,d=typeof l.min_allowance_suggested=="number"?l.min_allowance_suggested:1,f=await ht(u,d);if(f==="granted")return Te(t,e,!0);throw f==="timeout"?new x:new C}throw qe(a,o.status)},"call"),kt=s(async()=>{let t=L();if(!t)throw new P;if(!h)throw new g("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let e=new URL(`${Pe}/api/v1/service/functions`);e.searchParams.set("playbook_id",h);let r=await fetch(e.toString(),{headers:{Authorization:`Bearer ${t}`,"X-Pbsv":"1"}}),i=await Me(r);if(!r.ok)throw qe(i,r.status);let n=i.functions;return Array.isArray(n)?n:[]},"list"),ve=s((t,e,r)=>{t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:r}))},"dispatchButtonEvent"),vt=s(t=>{if(typeof t!="string")return t;let r=m?.document?.querySelector(t);if(r&&"appendChild"in r)return r;throw new Error(`UDF button target not found: ${t}`)},"resolveButtonTarget"),Pt=s((t,e)=>{if(!m)throw new Error("Playbook runtime is not installed.");let r=vt(t),i=m.document.createElement("button"),n=e.label||e.functionName,o=e.loadingLabel||"Running...",a=e.disabledLabel||"Sign in to run";return i.type="button",i.className="alva-udf-button",i.textContent=v()?n:a,i.disabled=!1,i.setAttribute("data-function-name",e.functionName),v()||i.setAttribute("aria-disabled","true"),i.addEventListener("click",async()=>{if(!v()){gt(e.functionName);return}if(!i.disabled){i.disabled=!0,i.textContent=o,ve(i,"alva:udf-button:loading",{functionName:e.functionName});try{let l=await Te(e.functionName,e.params??{});ve(i,"alva:udf-button:result",{functionName:e.functionName,result:l})}catch(l){ve(i,"alva:udf-button:error",{functionName:e.functionName,error:l})}finally{i.disabled=!1,i.textContent=v()?n:a,v()||i.setAttribute("aria-disabled","true")}}}),r.appendChild(i),i},"renderButton"),Ve={call:Te,list:kt,getViewerToken:L,isAuthenticated:v,renderButton:Pt,UdfError:p,UdfAuthRequiredError:P,UdfTokenExpiredError:E,UdfTokenInvalidError:w,UdfPidMismatchError:g,UdfConsentRequiredError:A,UdfConsentDeniedError:C,UdfConsentTimeoutError:x,UdfInsufficientCredits:F,UdfFunctionNotFoundError:G,UdfFunctionDisabledError:I,UdfRateLimitedError:U,UdfExecutionError:N,UdfTransportError:R},Se=s(t=>{let e=t??(typeof window>"u"?void 0:window);if(!e||Fe)return;m=e,Fe=!0,dt(e),e.addEventListener("message",_t);let r=e,i=r.alva||{};r.alva={...i,udf:Ve,subscribe:We}},"installPlaybookRuntime");var c=class extends Error{static{s(this,"AlvaError")}code;status;details;constructor(e,r,i,n){super(r),this.name="AlvaError",this.code=e,this.status=i,this.details=n}},$=class extends Error{static{s(this,"CliUsageError")}command;constructor(e,r){super(e),this.name="CliUsageError",this.command=r}};function He(t){return Object.prototype.toString.call(t)==="[object ArrayBuffer]"}s(He,"isArrayBuffer");var Qe=1;function Rt(t){let e=0;for(;e<t.length;){let r=t[e];if(r<=127){e+=1;continue}let i=0,n=0,o=0;if(r>=194&&r<=223)i=1,n=128,o=r&31;else if(r>=224&&r<=239)i=2,n=2048,o=r&15;else if(r>=240&&r<=244)i=3,n=65536,o=r&7;else return!1;if(e+i>=t.length)return!1;for(let a=1;a<=i;a+=1){let l=t[e+a];if((l&192)!==128)return!1;o=o<<6|l&63}if(o<n||o>1114111||o>=55296&&o<=57343)return!1;e+=i+1}return!0}s(Rt,"isValidUtf8");var W=class{constructor(e){this.client=e}client;static{s(this,"FsResource")}async read(e){let r=await this.client._request("GET","/api/v1/fs/read",{query:{path:e.path,offset:e.offset,size:e.size}});if(!He(r)||!Rt(new Uint8Array(r)))return r;let i=new TextDecoder("utf-8").decode(r);try{return JSON.parse(i)}catch{return i}}async write(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/fs/write",{body:{path:e.path,data:e.data,mkdir_parents:e.mkdir_parents,...e.append?{flags:Qe}:{}}})}async rawWrite(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/fs/write",{query:{path:e.path,mkdir_parents:e.mkdir_parents,...e.append?{flags:Qe}:{}},rawBody:e.body})}async stat(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/stat",{query:{path:e.path}})}async readdir(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/readdir",{query:{path:e.path,recursive:e.recursive}})}async mkdir(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/mkdir",{body:{path:e.path}})}async remove(e){this.client._requireAuth(),await this.client._request("DELETE","/api/v1/fs/remove",{query:{path:e.path,recursive:e.recursive}})}async rename(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/rename",{body:{old_path:e.old_path,new_path:e.new_path}})}async copy(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/copy",{body:{src_path:e.src_path,dst_path:e.dst_path}})}async symlink(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/symlink",{body:{target_path:e.target_path,link_path:e.link_path}})}async readlink(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/readlink",{query:{path:e.path}})}async chmod(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/chmod",{body:{path:e.path,mode:e.mode}})}async grant(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/grant",{body:{path:e.path,subject:e.subject,permission:e.permission}})}async revoke(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/revoke",{body:{path:e.path,subject:e.subject,permission:e.permission}})}};var V=class{constructor(e){this.client=e}client;static{s(this,"RunResource")}async execute(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/run",{body:{code:e.code,entry_path:e.entry_path,working_dir:e.working_dir,args:e.args,max_heap_size_mb:e.max_heap_size_mb},timeoutMs:e.timeout_ms})}};var H=class{constructor(e){this.client=e}client;static{s(this,"DeployResource")}async create(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/deploy/cronjob",{body:{name:e.name,path:e.path,cron_expression:e.cron_expression,args:e.args,push_notify:e.push_notify,max_heap_size_mb:e.max_heap_size_mb,execution_timeout_seconds:e.execution_timeout_seconds,run_as_user_id:e.run_as_user_id,start_at:e.start_at,end_at:e.end_at,max_runs:e.max_runs}})}async list(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/deploy/cronjobs",{query:{limit:e?.limit,cursor:e?.cursor}})}async get(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.id}`)}async update(e){this.client._requireAuth();let{id:r,...i}=e;return this.client._request("PATCH",`/api/v1/deploy/cronjob/${r}`,{body:i})}async delete(e){this.client._requireAuth(),await this.client._request("DELETE",`/api/v1/deploy/cronjob/${e.id}`)}async pause(e){this.client._requireAuth(),await this.client._request("POST",`/api/v1/deploy/cronjob/${e.id}/pause`)}async resume(e){this.client._requireAuth(),await this.client._request("POST",`/api/v1/deploy/cronjob/${e.id}/resume`)}async trigger(e){return this.client._requireAuth(),this.client._request("POST",`/api/v1/deploy/cronjob/${e.id}/trigger`)}async listRuns(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.cronjob_id}/runs`,{query:{first:e.first,cursor:e.cursor}})}async getRunStatus(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.cronjob_id}/runs/by-workflow/${encodeURIComponent(e.workflow_run_id)}`)}async getRunLogs(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.cronjob_id}/runs/${e.run_id}/logs`)}};var Q=class{constructor(e){this.client=e}client;static{s(this,"ServiceAccountResource")}async create(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/service-account",{body:{display_name:e.display_name}})}async list(){return this.client._requireAuth(),this.client._request("GET","/api/v1/service-accounts")}async delete(e){this.client._requireAuth(),await this.client._request("DELETE",`/api/v1/service-account/${e.id}`)}async grant(e){this.client._requireAuth(),await this.client._request("POST",`/api/v1/service-account/${e.id}/grant`,{body:{path:e.path,permission:e.permission}})}async revoke(e){this.client._requireAuth(),await this.client._request("POST",`/api/v1/service-account/${e.id}/revoke`,{body:{path:e.path,permission:e.permission}})}};var J=class{constructor(e){this.client=e}client;static{s(this,"ReleaseResource")}async feed(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/release/feed",{body:{name:e.name,version:e.version,cronjob_id:e.cronjob_id,view_json:e.view_json,description:e.description,changelog:e.changelog,agent_type:e.agent_type,skip_auto_trigger:e.skip_auto_trigger}})}async playbookDraft(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/draft/playbook",{body:{name:e.name,display_name:e.display_name,description:e.description,feeds:e.feeds,trading_symbols:e.trading_symbols,skill_id:e.skill_id,tags:e.tags}})}async playbook(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/release/playbook",{body:{name:e.name,version:e.version,feeds:e.feeds,changelog:e.changelog,readme_url:e.readme_url}})}};var z=class{constructor(e){this.client=e}client;static{s(this,"FeedResource")}async list(e={}){return this.client._requireAuth(),this.client._request("GET","/api/v1/feed",{query:{limit:e.limit,cursor:e.cursor,status:e.status}})}async stop(e){this.client._requireAuth();let r=K(e.id);return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(r))}/stop`)}async resume(e){this.client._requireAuth();let r=K(e.id);return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(r))}/resume`)}async delete(e){this.client._requireAuth();let r=K(e.id);return this.client._request("DELETE",`/api/v1/feed/${encodeURIComponent(String(r))}`)}async setVisibility(e){this.client._requireAuth();let r=K(e.id);if(e.visibility!=="public"&&e.visibility!=="private")throw new Error("visibility must be 'public' or 'private'");return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(r))}/visibility`,{body:{visibility:e.visibility}})}};function K(t){if(!Number.isInteger(t)||t<=0)throw new Error("feed id must be a positive integer");return t}s(K,"requireFeedID");var q=class{constructor(e){this.client=e}client;static{s(this,"AutomationResource")}list(e={}){return this.client.feed.list(e)}async inspect(e){this.client._requireAuth();let r=qt(e.id);return this.client._request("GET",`/api/v1/automation/${encodeURIComponent(String(r))}`)}stop(e){return this.client.feed.stop(e)}resume(e){return this.client.feed.resume(e)}delete(e){return this.client.feed.delete(e)}publish(e){return this.client.release.feed(e)}};function qt(t){if(!Number.isInteger(t)||t<=0)throw new Error("automation id must be a positive integer");return t}s(qt,"requireAutomationID");var Je=["public","private","paid"],X=class{constructor(e){this.client=e}client;static{s(this,"PlaybooksResource")}async getByIds(e){return await this.client._request("GET","/api/v1/playbooks",{query:{ids:e.join(",")}})}async listByOwner(e){let r={owner:e.owner};return e.limit!==void 0&&e.limit>0&&(r.limit=String(e.limit)),e.cursor&&(r.cursor=e.cursor),await this.client._request("GET","/api/v1/playbooks",{query:r})}async get(e){if(e.id)return(await this.getByIds([e.id])).items[0]??null;if(e.ref){let r=e.ref.indexOf("/");if(r<=0||r===e.ref.length-1)throw new c("INVALID_ARGUMENT",`Invalid ref "${e.ref}". Expected "owner/name".`,400);let i=e.ref.slice(0,r),n=e.ref.slice(r+1),o;for(;;){let a=await this.listByOwner({owner:i,cursor:o,limit:100}),l=a.items.find(u=>u.name===n);if(l)return l;if(!a.has_next||!a.next_cursor)return null;o=a.next_cursor}}throw new c("INVALID_ARGUMENT","id or ref is required",400)}async trending(e={}){let r={};e.cursor&&(r.cursor=e.cursor),e.current&&(r.current=e.current),e.limit!==void 0&&(r.limit=e.limit),e.dir&&(r.dir=e.dir),e.sort&&(r.sort=e.sort),e.keyword&&(r.keyword=e.keyword),e.tags&&e.tags.length>0&&(r.tags=e.tags.join(","));let i=await this.client._request("GET","/api/v1/playbooks/trending",{query:r}),n=Tt(this.client.baseUrl);return{playbooks:(i.playbooks??[]).map(o=>St(o,n)),has_next:i.has_next??!1}}async setVisibility(e){if(!Je.includes(e.visibility))throw new c("INVALID_ARGUMENT",`Invalid visibility "${e.visibility}". Expected one of: ${Je.join(", ")}.`,400);return this.client._requireAuth(),await this.client._request("POST",`/api/v1/playbook/${encodeURIComponent(e.name)}/visibility`,{body:{visibility:e.visibility}})}};function Tt(t){try{let e=new URL(t).hostname,r=/^api-llm\.([a-z0-9-]+)\.alva\.ai$/i.exec(e);if(r){let i=r[1].toLowerCase();return i==="prd"?"https://alva.ai":`https://${i}.alva.ai`}}catch{}return"https://alva.ai"}s(Tt,"webOriginFromApiBase");function St(t,e){let r=t.creator?.name??"",i=t.name??"",n=r&&i?`${r}/${i}`:i,o=r&&i?`/u/${r}/playbooks/${i}`:"";return{id:t.id===void 0?"":String(t.id),ref:n,username:r,name:i,display_name:t.display_name??"",description:t.description??"",tags:t.tags??[],follow_count:t.follow_count??0,url_path:o,url:o?`${e}${o}`:"",...t.readme?{readme:t.readme}:{},cursor:t.cursor??""}}s(St,"toAgentPlaybook");var Y=class{constructor(e){this.client=e}client;static{s(this,"SecretsResource")}async create(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/secrets",{body:{name:e.name,value:e.value}})}async list(){return this.client._requireAuth(),this.client._request("GET","/api/v1/secrets")}async get(e){this.client._requireAuth();let r=encodeURIComponent(e.name);return this.client._request("GET",`/api/v1/secrets/${r}`)}async update(e){this.client._requireAuth();let r=encodeURIComponent(e.name);await this.client._request("PUT",`/api/v1/secrets/${r}`,{body:{value:e.value}})}async delete(e){this.client._requireAuth();let r=encodeURIComponent(e.name);await this.client._request("DELETE",`/api/v1/secrets/${r}`)}};var Z=class{constructor(e){this.client=e}client;static{s(this,"SdkDocsResource")}async doc(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/sdk/doc",{query:{name:e.name}})}async partitions(){return this.client._requireAuth(),this.client._request("GET","/api/v1/sdk/partitions")}async partitionSummary(e){this.client._requireAuth();let r=encodeURIComponent(e.partition);return this.client._request("GET",`/api/v1/sdk/partitions/${r}/summary`)}};var Ke=[{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-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-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:"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-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:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-options",file:"kline",method:"GET",path:"/api/v1/options/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-options",file:"greeks",method:"GET",path:"/api/v1/options/greeks",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-options",file:"chain",method:"GET",path:"/api/v1/options/chain",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{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},{skill:"arrays-data-api-semiconductor-price",file:"dram-spot-price",method:"GET",path:"/api/v1/other/semiconductor/dram-spot-price",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-semiconductor-price",file:"dram-contract-price",method:"GET",path:"/api/v1/other/semiconductor/dram-contract-price",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-semiconductor-price",file:"nand-flash-spot-price",method:"GET",path:"/api/v1/other/semiconductor/nand-flash-spot-price",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-semiconductor-price",file:"nand-flash-contract-price",method:"GET",path:"/api/v1/other/semiconductor/nand-flash-contract-price",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-semiconductor-price",file:"memory-card-price",method:"GET",path:"/api/v1/other/semiconductor/memory-card-price",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-semiconductor-price",file:"dxi-index",method:"GET",path:"/api/v1/other/semiconductor/dxi-index",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0}];function ze(t,e){return Ke.find(r=>r.skill===t&&r.file===e)}s(ze,"getSkillEndpointMetadata");function Ee(t){return Ke.filter(e=>e.skill===t)}s(Ee,"listSkillEndpointMetadata");var ee=class{constructor(e){this.client=e}client;static{s(this,"DataSkillsResource")}async list(){return{skills:((await this.client._request("GET","/api/v1/skills",{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data??[]).map(r=>({...r,...Xe(r.name)}))}}async summary(e){let r=encodeURIComponent(e.name),n=(await this.client._request("GET",`/api/v1/skills/${r}`,{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data?.[0];if(!n)throw new Error(`empty skills summary response for "${e.name}"`);let o=Ee(e.name);return{...n,...Xe(e.name),...o.length>0?{endpoint_metadata:o}:{}}}async endpoint(e){let r=encodeURIComponent(e.name),n=(await this.client._request("GET",`/api/v1/skills/${r}`,{baseUrl:this.client.arraysBaseUrl,noAuth:!0,query:{endpoint:e.file}})).data?.[0];if(!n)throw new Error(`empty skills endpoint response for "${e.name}" file "${e.file}"`);let o=ze(e.name,e.file);return{...n,...o?{metadata:o}:{}}}};function Xe(t){let e=Ee(t);if(e.length===0)return{};let r={},i=0;for(let n of e)r[n.tier]=(r[n.tier]??0)+1,n.pro_required&&(i+=1);return{endpoint_tier_counts:r,metadata:{endpoint_count:e.length,endpoint_tier_counts:r,pro_count:i}}}s(Xe,"metadataSummaryForSkill");function Ye(t){return{username:t.username,name:t.name,display_name:t.display_name,description:t.description,tags:t.tags,creator_uid:t.creator_uid,updated_at:t.updated_at}}s(Ye,"normalizePlaybookSkillSummary");function Ze(t){let e=t.split("/");if(e.length!==2||!e[0]||!e[1])throw new c("INVALID_ARGUMENT",`playbook skill identifier must be "<user>/<name>", got "${t}"`,0);return{username:e[0],name:e[1]}}s(Ze,"parsePlaybookSkillId");var te=class{constructor(e){this.client=e}client;static{s(this,"PlaybookSkillsResource")}async list(e){let r={};return e?.tag&&(r.tag=e.tag),e?.username&&(r.username=e.username),{skills:((await this.client._request("GET","/api/v1/skills",{query:r})).data??[]).map(Ye)}}async tags(){return{tags:(await this.client._request("GET","/api/v1/skills/tags")).data??[]}}async get(e){let{username:r,name:i}=Ze(e),n=encodeURIComponent(r),o=encodeURIComponent(i),l=(await this.client._request("GET",`/api/v1/skills/${n}/${o}`)).data?.[0];if(!l)throw new c("NOT_FOUND",`empty playbook skills get response for ${e}`,0);return{...Ye(l),files:l.files??[]}}async file(e,r){let{username:i,name:n}=Ze(e),o=encodeURIComponent(i),a=encodeURIComponent(n),l=r.split("/").map(encodeURIComponent).join("/"),d=(await this.client._request("GET",`/api/v1/skills/${o}/${a}/files/${l}`)).data?.[0];if(!d)throw new c("NOT_FOUND",`empty playbook skills file response for ${e} path ${r}`,0);return d}};var re=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 ie=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 se=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 ne=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 oe=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 ae=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 ce=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 le=class{constructor(e){this.client=e}client;static{s(this,"NotificationsResource")}async listFeed(e){this.client._requireAuth();let r=`/api/v1/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",r,{query:Et(e)})}};function Et(t){let e={};return t.channel&&(e.channel=t.channel),t.status&&(e.status=t.status),t.since_time!==void 0&&t.since_time>0&&(e.since_time=String(t.since_time)),t.first!==void 0&&t.first>0&&(e.first=String(t.first)),t.cursor&&(e.cursor=t.cursor),e}s(Et,"buildQuery");var ue=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 pe=class{constructor(e){this.client=e}client;static{s(this,"SubscriptionsResource")}async followPlaybook(e){this.client._requireAuth();let r=`/api/v1/follows/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",r)}async unfollowPlaybook(e){this.client._requireAuth();let r=`/api/v1/follows/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",r)}async subscribeFeed(e){this.client._requireAuth();let r=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return e.channelId===void 0?this.client._request("POST",r):this.client._request("POST",r,{body:{channel_id:e.channelId}})}async unsubscribeFeed(e){this.client._requireAuth();let r=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",r)}async list(e={}){this.client._requireAuth();let r={};return e.first!==void 0&&e.first>0&&(r.first=String(e.first)),e.cursor&&(r.cursor=e.cursor),this.client._request("GET","/api/v1/me/subscriptions",{query:r})}async follows(e={}){this.client._requireAuth();let r={};return e.limit!==void 0&&e.limit>0&&(r.limit=String(e.limit)),e.cursor&&(r.cursor=e.cursor),this.client._request("GET","/api/v1/me/follows",{query:r})}async subscribeBatch(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/subscriptions/subscribe-batch",{body:{feed_ids:e.feedIds,channel_id:e.channelId}})}async unsubscribeBatch(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/subscriptions/unsubscribe-batch",{body:{feed_ids:e.feedIds}})}};var T=class{constructor(e){this.client=e}client;static{s(this,"AlertsResource")}list(e={}){return this.client.subscriptions.list(e)}follows(e={}){return this.client.subscriptions.follows(e)}enableAutomation(e){return this.client.subscriptions.subscribeFeed(e)}disableAutomation(e){return this.client.subscriptions.unsubscribeFeed(e)}enableBatch(e){return this.client.subscriptions.subscribeBatch(e)}disableBatch(e){return this.client.subscriptions.unsubscribeBatch(e)}historyAutomation(e){return this.client.notifications.listFeed(e)}preferences(){return this.client.notificationPreferences.list()}updatePreference(e){return this.client.notificationPreferences.update(e)}};var de=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:et(e)})}async unsubscribe(e){return this.client._requireAuth(),this.client._request("DELETE","/api/v1/channel/group-subscriptions",{jsonBody:et(e)})}async getGroupChatHistory(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/channel/group-history",{query:{channel:e.channel,remote_chat_id:e.remote_chat_id,from_micros:String(e.from_micros),to_micros:String(e.to_micros)}})}};function et(t){return`{"session_id":${tt(t.session_id)},"target_type":${JSON.stringify(t.target_type)},"target_id":${tt(t.target_id)}}`}s(et,"mutationBody");function tt(t){if(typeof t=="number"){if(!Number.isInteger(t)||t<=0||!Number.isSafeInteger(t))throw new c("INVALID_ARGUMENT","channel group subscription ids must be positive safe integers; pass large int64 ids as strings",0);return String(t)}if(!/^[1-9]\d*$/.test(t))throw new c("INVALID_ARGUMENT","channel group subscription ids must be positive integer strings",0);return t}s(tt,"idLiteral");var me=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 fe=class{constructor(e){this.client=e}client;static{s(this,"FunctionsResource")}async register(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/service/functions",{body:{playbook_id:e.playbook_id,function_name:e.function_name,entry_script_path:e.entry_script_path,params_schema:e.params_schema,allow_charges:e.allow_charges,run_as_user_id:e.run_as_user_id}})}async list(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/service/functions",{query:{playbook_id:e.playbook_id}})}async delete(e){this.client._requireAuth(),await this.client._request("DELETE","/api/v1/service/functions",{query:{playbook_id:e.playbook_id,function_name:e.function_name}})}async invoke(e){this.client._requireAuth();let r=await this.client._request("POST","/api/v1/service/invoke",{body:{playbook_id:e.playbook_id,function_name:e.function_name,parameters_json:JSON.stringify(e.parameters??{})}});return{...r,result:At(r.result)}}async getAllowance(e){this.client._requireAuth();let r=await this.client._request("GET","/api/v1/service/allowance",{query:{playbook_id:e.playbook_id}});return we(r.allowance)}async listAllowances(){return this.client._requireAuth(),{allowances:((await this.client._request("GET","/api/v1/service/allowances")).allowances??[]).map(r=>we(r)).filter(r=>r!==null)}}async createAllowance(e){this.client._requireAuth();let r=await this.client._request("POST","/api/v1/service/allowance",{body:{playbook_id:e.playbook_id,amount:e.amount}});return{allowance:wt(r.allowance)}}async revokeAllowance(e){return this.client._requireAuth(),await this.client._request("DELETE","/api/v1/service/allowance",{query:{playbook_id:e.playbook_id}}),{ok:!0}}};function we(t){if(!t)return null;let e={id:t.id??"",consumer_uid:t.consumer_uid??t.consumerUid??"",playbook_id:t.playbook_id??t.playbookId??"",amount:t.amount??0,used:t.used??0,remaining:t.remaining??0},r=rt(t.created_at_ms??t.createdAtMs??t.created_at??t.createdAt),i=rt(t.updated_at_ms??t.updatedAtMs??t.updated_at??t.updatedAt);return r!==void 0&&(e.created_at_ms=r),i!==void 0&&(e.updated_at_ms=i),e}s(we,"normalizeAllowance");function wt(t){let e=we(t);if(!e)throw new Error("allowance response missing allowance");return e}s(wt,"requireAllowance");function rt(t){if(t==null)return;if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"){let n=Number(t);if(Number.isFinite(n))return n;let o=Date.parse(t);return Number.isNaN(o)?void 0:o}if(typeof t!="object")return;let e=t,r=typeof e.seconds=="number"?e.seconds:typeof e.seconds=="string"?Number(e.seconds):void 0,i=typeof e.nanos=="number"?e.nanos:typeof e.nanos=="string"?Number(e.nanos):0;if(!(r===void 0||!Number.isFinite(r)))return r*1e3+Math.floor((Number.isFinite(i)?i:0)/1e6)}s(rt,"timestampMs");function At(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}}s(At,"parseResultPayload");var Ct=`
|
|
1
|
+
"use strict";var AlvaToolkit=(()=>{var $=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var at=Object.prototype.hasOwnProperty;var r=(t,e)=>$(t,"name",{value:e,configurable:!0});var lt=(t,e)=>{for(var i in e)$(t,i,{get:e[i],enumerable:!0})},ct=(t,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ot(e))!at.call(t,n)&&n!==i&&$(t,n,{get:()=>e[n],enumerable:!(s=nt(e,n))||s.enumerable});return t};var ut=t=>ct($({},"__esModule",{value:!0}),t);var Kt={};lt(Kt,{AlertsResource:()=>w,AlvaClient:()=>_e,AlvaError:()=>a,AutomationResource:()=>S,CliUsageError:()=>V,MarketsResource:()=>A,PBSV_UPDATE_MESSAGE:()=>Ue,SUBSCRIBE_PROPOSE_MESSAGE:()=>De,SUBSCRIBE_RESULT_MESSAGE:()=>Me,UDF_AUTH_REQUIRED_MESSAGE:()=>Oe,UDF_CONSENT_REQUEST_MESSAGE:()=>Ne,UDF_CONSENT_RESPONSE_MESSAGE:()=>Le,UdfAuthRequiredError:()=>E,UdfConsentDeniedError:()=>G,UdfConsentRequiredError:()=>F,UdfConsentTimeoutError:()=>U,UdfError:()=>d,UdfExecutionError:()=>M,UdfFunctionDisabledError:()=>O,UdfFunctionNotFoundError:()=>L,UdfInsufficientCredits:()=>N,UdfPidMismatchError:()=>k,UdfRateLimitedError:()=>D,UdfTokenExpiredError:()=>x,UdfTokenInvalidError:()=>I,UdfTransportError:()=>T,VERSION:()=>Ht,getViewerToken:()=>j,installPlaybookRuntime:()=>we,mapUdfErrorResponse:()=>Te,playbookIdFromToken:()=>Ee,subscribe:()=>Ve,udf:()=>He});var d=class extends Error{static{r(this,"UdfError")}code;metadata;status;constructor(e,{code:i,metadata:s={},status:n}){super(e),this.name=new.target.name,this.code=i,this.metadata=s,this.status=n}},E=class extends d{static{r(this,"UdfAuthRequiredError")}constructor(){super("Sign in to use this UDF.",{code:"AUTH_REQUIRED"})}},x=class extends d{static{r(this,"UdfTokenExpiredError")}},I=class extends d{static{r(this,"UdfTokenInvalidError")}},k=class extends d{static{r(this,"UdfPidMismatchError")}},F=class extends d{static{r(this,"UdfConsentRequiredError")}},G=class extends d{static{r(this,"UdfConsentDeniedError")}constructor(){super("UDF consent was denied.",{code:"CONSENT_DENIED"})}},U=class extends d{static{r(this,"UdfConsentTimeoutError")}constructor(){super("UDF consent timed out.",{code:"CONSENT_TIMEOUT"})}},N=class extends d{static{r(this,"UdfInsufficientCredits")}},L=class extends d{static{r(this,"UdfFunctionNotFoundError")}},O=class extends d{static{r(this,"UdfFunctionDisabledError")}},D=class extends d{static{r(this,"UdfRateLimitedError")}},M=class extends d{static{r(this,"UdfExecutionError")}},T=class extends d{static{r(this,"UdfTransportError")}},Ue="alva:pbsv:update",Ne="alva:udf:consent-request",Le="alva:udf:consent-response",Oe="alva:udf:auth-required",De="alva:subscribe:propose",Me="alva:subscribe:result",je="https://api-llm.prd.alva.ai",Be=300*1e3,q=null,f=null,ve=je,g=null,y=null,Ge=!1,Q=new Map,W=new Map,pt=r(t=>t==="subscribed"||t==="declined"||t==="timeout"?t:"error","normalizeProposalResult"),dt=r(t=>{let e=t.replace(/-/g,"+").replace(/_/g,"/"),i=e.padEnd(Math.ceil(e.length/4)*4,"=");return atob(i)},"decodeBase64Url"),Ee=r(t=>{if(!t)return null;let[,e]=t.split(".");if(!e)return null;try{let i=JSON.parse(dt(e));if(typeof i.pid=="number")return String(i.pid);if(typeof i.pid=="string")return i.pid}catch{return null}return null},"playbookIdFromToken"),j=r(()=>q,"getViewerToken"),v=r(()=>!!j(),"isAuthenticated"),mt=r(t=>{let e=new URL(t.location.href);e.searchParams.delete("_pbsv"),t.history.replaceState(null,"",e.pathname+e.search+e.hash)},"stripPbsvFromUrl"),yt=r(t=>{let e=new URLSearchParams(t.location.search);q=e.get("_pbsv"),f=e.get("parent_origin"),ve=(e.get("api_origin")||je).replace(/\/$/,""),g=Ee(q),q&&mt(t)},"parseBootParams"),$e=r(async t=>{try{return await t.json()}catch{return{}}},"safeJson"),ht=r(t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}},"parseResultPayload"),ft=r(t=>{let e=t;return{...e,result:ht(e.result)}},"normalizeInvokeResponse"),Qe=r(t=>t.error?.metadata||t.details?.metadata||{},"errorMetadata"),Te=r((t,e)=>{let i=t.error?.code||"TRANSPORT",s=t.error?.message||i,n=Qe(t),o={code:i,metadata:n,status:e};switch(i){case"PBSV_EXPIRED":return new x(s,o);case"PBSV_INVALID":case"UNAUTHENTICATED":return new I(s,o);case"PBSV_PID_MISMATCH":return new k(s,o);case"CONSENT_REQUIRED":return new F(s,o);case"INSUFFICIENT_CREDITS":return new N(s,o);case"FUNCTION_NOT_FOUND":return new L(s,o);case"FUNCTION_DISABLED":return new O(s,o);case"RESOURCE_EXHAUSTED":return new D(s,o);case"EXECUTION_FAILED":return new M(s,o);default:return new T(s,o)}},"mapUdfErrorResponse"),gt=r(t=>{if(!y||!f||t.origin!==f||t.source!==y.parent||!t.data||typeof t.data!="object")return;let e=t.data;if(e.type===Ue){typeof e.token=="string"&&e.token.length>0&&(q=e.token,g=Ee(e.token));return}if(e.type===Me){if(typeof e.request_id!="string")return;let s=W.get(e.request_id);if(!s)return;clearTimeout(s.timer),W.delete(e.request_id),s.resolve(pt(e.status));return}if(e.type!==Le||typeof e.request_id!="string")return;let i=Q.get(e.request_id);i&&(clearTimeout(i.timer),Q.delete(e.request_id),i.resolve(e.granted===!0?"granted":"denied"))},"onMessage"),We=r(()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`,"randomRequestId"),bt=r(()=>{if(!g)return null;let t=Number(g);return Number.isSafeInteger(t)?t:null},"playbookIdForInvoke"),kt=r(async(t,e)=>{if(!y||!f)return"denied";let i=f,s=We();return new Promise(n=>{let o=setTimeout(()=>{Q.delete(s),n("timeout")},Be);Q.set(s,{resolve:n,timer:o}),y?.parent.postMessage({type:Ne,request_id:s,playbook_id:t,min_allowance:e},i)})},"requestConsent"),_t=r(async t=>{if(!y||!f)return"error";let e=typeof t?.feedOwner=="string"?t.feedOwner.trim():"",i=typeof t?.feedName=="string"?t.feedName.trim():"";if(!e||!i)return"error";let s=f,n=We();return new Promise(o=>{let l=setTimeout(()=>{W.delete(n),o("timeout")},Be);W.set(n,{resolve:o,timer:l}),y?.parent.postMessage({type:De,request_id:n,playbook_id:g,feed:{owner:e,name:i}},s)})},"proposeSubscribe"),Ve={propose:_t},Pt=r(t=>{!y||!f||y.parent.postMessage({type:Oe,function_name:t},f)},"requestAuthentication"),Se=r(async(t,e,i=!1)=>{let s=j();if(!s)throw new E;if(!g)throw new k("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let n=bt();if(!n)throw new k("Invalid playbook id.",{code:"PBSV_PID_MISMATCH"});let o;try{o=await fetch(`${ve}/api/v1/service/invoke`,{method:"POST",headers:{Authorization:`Bearer ${s}`,"X-Pbsv":"1","Content-Type":"application/json"},body:JSON.stringify({playbook_id:n,function_name:t,parameters_json:JSON.stringify(e)})})}catch{throw new T("Network error while invoking UDF.",{code:"TRANSPORT"})}let l=await $e(o);if(o.ok)return ft(l);if(l.error?.code==="CONSENT_REQUIRED"&&!i){let c=Qe(l),u=typeof c.playbook_id=="string"?c.playbook_id:g,m=typeof c.min_allowance_suggested=="number"?c.min_allowance_suggested:1,p=await kt(u,m);if(p==="granted")return Se(t,e,!0);throw p==="timeout"?new U:new G}throw Te(l,o.status)},"call"),Rt=r(async()=>{let t=j();if(!t)throw new E;if(!g)throw new k("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let e=new URL(`${ve}/api/v1/service/functions`);e.searchParams.set("playbook_id",g);let i=await fetch(e.toString(),{headers:{Authorization:`Bearer ${t}`,"X-Pbsv":"1"}}),s=await $e(i);if(!i.ok)throw Te(s,i.status);let n=s.functions;return Array.isArray(n)?n:[]},"list"),Re=r((t,e,i)=>{t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:i}))},"dispatchButtonEvent"),vt=r(t=>{if(typeof t!="string")return t;let i=y?.document?.querySelector(t);if(i&&"appendChild"in i)return i;throw new Error(`UDF button target not found: ${t}`)},"resolveButtonTarget"),Et=r((t,e)=>{if(!y)throw new Error("Playbook runtime is not installed.");let i=vt(t),s=y.document.createElement("button"),n=e.label||e.functionName,o=e.loadingLabel||"Running...",l=e.disabledLabel||"Sign in to run";return s.type="button",s.className="alva-udf-button",s.textContent=v()?n:l,s.disabled=!1,s.setAttribute("data-function-name",e.functionName),v()||s.setAttribute("aria-disabled","true"),s.addEventListener("click",async()=>{if(!v()){Pt(e.functionName);return}if(!s.disabled){s.disabled=!0,s.textContent=o,Re(s,"alva:udf-button:loading",{functionName:e.functionName});try{let c=await Se(e.functionName,e.params??{});Re(s,"alva:udf-button:result",{functionName:e.functionName,result:c})}catch(c){Re(s,"alva:udf-button:error",{functionName:e.functionName,error:c})}finally{s.disabled=!1,s.textContent=v()?n:l,v()||s.setAttribute("aria-disabled","true")}}}),i.appendChild(s),s},"renderButton"),He={call:Se,list:Rt,getViewerToken:j,isAuthenticated:v,renderButton:Et,UdfError:d,UdfAuthRequiredError:E,UdfTokenExpiredError:x,UdfTokenInvalidError:I,UdfPidMismatchError:k,UdfConsentRequiredError:F,UdfConsentDeniedError:G,UdfConsentTimeoutError:U,UdfInsufficientCredits:N,UdfFunctionNotFoundError:L,UdfFunctionDisabledError:O,UdfRateLimitedError:D,UdfExecutionError:M,UdfTransportError:T},we=r(t=>{let e=t??(typeof window>"u"?void 0:window);if(!e||Ge)return;y=e,Ge=!0,yt(e),e.addEventListener("message",gt);let i=e,s=i.alva||{};i.alva={...s,udf:He,subscribe:Ve}},"installPlaybookRuntime");var a=class extends Error{static{r(this,"AlvaError")}code;status;details;constructor(e,i,s,n){super(i),this.name="AlvaError",this.code=e,this.status=s,this.details=n}},V=class extends Error{static{r(this,"CliUsageError")}command;constructor(e,i){super(e),this.name="CliUsageError",this.command=i}};function Ke(t){return Object.prototype.toString.call(t)==="[object ArrayBuffer]"}r(Ke,"isArrayBuffer");var Ye=1;function Tt(t){let e=0;for(;e<t.length;){let i=t[e];if(i<=127){e+=1;continue}let s=0,n=0,o=0;if(i>=194&&i<=223)s=1,n=128,o=i&31;else if(i>=224&&i<=239)s=2,n=2048,o=i&15;else if(i>=240&&i<=244)s=3,n=65536,o=i&7;else return!1;if(e+s>=t.length)return!1;for(let l=1;l<=s;l+=1){let c=t[e+l];if((c&192)!==128)return!1;o=o<<6|c&63}if(o<n||o>1114111||o>=55296&&o<=57343)return!1;e+=s+1}return!0}r(Tt,"isValidUtf8");var H=class{constructor(e){this.client=e}client;static{r(this,"FsResource")}async read(e){let i=await this.client._request("GET","/api/v1/fs/read",{query:{path:e.path,offset:e.offset,size:e.size}});if(!Ke(i)||!Tt(new Uint8Array(i)))return i;let s=new TextDecoder("utf-8").decode(i);try{return JSON.parse(s)}catch{return s}}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,...e.append?{flags:Ye}:{}}})}async rawWrite(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/fs/write",{query:{path:e.path,mkdir_parents:e.mkdir_parents,...e.append?{flags:Ye}:{}},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 K=class{constructor(e){this.client=e}client;static{r(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 Y=class{constructor(e){this.client=e}client;static{r(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,execution_timeout_seconds:e.execution_timeout_seconds,run_as_user_id:e.run_as_user_id,start_at:e.start_at,end_at:e.end_at,max_runs:e.max_runs}})}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:i,...s}=e;return this.client._request("PATCH",`/api/v1/deploy/cronjob/${i}`,{body:s})}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 getRunStatus(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.cronjob_id}/runs/by-workflow/${encodeURIComponent(e.workflow_run_id)}`)}async getRunLogs(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.cronjob_id}/runs/${e.run_id}/logs`)}};var J=class{constructor(e){this.client=e}client;static{r(this,"ServiceAccountResource")}async create(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/service-account",{body:{display_name:e.display_name}})}async list(){return this.client._requireAuth(),this.client._request("GET","/api/v1/service-accounts")}async delete(e){this.client._requireAuth(),await this.client._request("DELETE",`/api/v1/service-account/${e.id}`)}async grant(e){this.client._requireAuth(),await this.client._request("POST",`/api/v1/service-account/${e.id}/grant`,{body:{path:e.path,permission:e.permission}})}async revoke(e){this.client._requireAuth(),await this.client._request("POST",`/api/v1/service-account/${e.id}/revoke`,{body:{path:e.path,permission:e.permission}})}};var z=class{constructor(e){this.client=e}client;static{r(this,"ReleaseResource")}async feed(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/release/feed",{body:{name:e.name,version:e.version,cronjob_id:e.cronjob_id,view_json:e.view_json,description:e.description,changelog:e.changelog,agent_type:e.agent_type,skip_auto_trigger:e.skip_auto_trigger}})}async playbookDraft(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/draft/playbook",{body:{name:e.name,display_name:e.display_name,description:e.description,feeds:e.feeds,trading_symbols:e.trading_symbols,skill_id:e.skill_id,tags:e.tags}})}async playbook(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/release/playbook",{body:{name:e.name,version:e.version,feeds:e.feeds,changelog:e.changelog,readme_url:e.readme_url}})}};var Z=class{constructor(e){this.client=e}client;static{r(this,"FeedResource")}async list(e={}){return this.client._requireAuth(),this.client._request("GET","/api/v1/feed",{query:{limit:e.limit,cursor:e.cursor,status:e.status}})}async stop(e){this.client._requireAuth();let i=X(e.id);return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(i))}/stop`)}async resume(e){this.client._requireAuth();let i=X(e.id);return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(i))}/resume`)}async delete(e){this.client._requireAuth();let i=X(e.id);return this.client._request("DELETE",`/api/v1/feed/${encodeURIComponent(String(i))}`)}async setVisibility(e){this.client._requireAuth();let i=X(e.id);if(e.visibility!=="public"&&e.visibility!=="private")throw new Error("visibility must be 'public' or 'private'");return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(i))}/visibility`,{body:{visibility:e.visibility}})}};function X(t){if(!Number.isInteger(t)||t<=0)throw new Error("feed id must be a positive integer");return t}r(X,"requireFeedID");var S=class{constructor(e){this.client=e}client;static{r(this,"AutomationResource")}list(e={}){return this.client.feed.list(e)}async inspect(e){this.client._requireAuth();let i=St(e.id);return this.client._request("GET",`/api/v1/automation/${encodeURIComponent(String(i))}`)}async update(e){this.client._requireAuth();let i=wt(e.id);if(!At(e))throw new Error("automation update requires at least one field or trigger=true");return this.client._request("PATCH",`/api/v1/automation/${encodeURIComponent(String(i))}`,{body:{version:e.version,cronjob_id:e.cronjob_id,description:e.description,changelog:e.changelog,agent_type:e.agent_type,trigger:e.trigger}})}stop(e){return this.client.feed.stop(e)}resume(e){return this.client.feed.resume(e)}delete(e){return this.client.feed.delete(e)}publish(e){return this.client.release.feed(e)}};function St(t){if(!Number.isInteger(t)||t<=0)throw new Error("automation id must be a positive integer");return t}r(St,"requireAutomationID");function wt(t){if(!/^[1-9]\d*$/.test(t))throw new Error("automation id must be a positive integer string");return t}r(wt,"requireAutomationIDString");function At(t){return t.version!==void 0||t.cronjob_id!==void 0||t.description!==void 0||t.changelog!==void 0||t.agent_type!==void 0||t.trigger===!0}r(At,"hasAutomationUpdate");var Je=["public","private","paid"];var ee=class{constructor(e){this.client=e}client;static{r(this,"PlaybooksResource")}async getByIds(e){return await this.client._request("GET","/api/v1/playbooks",{query:{ids:e.join(",")}})}async listByOwner(e){let i={owner:e.owner};return e.limit!==void 0&&e.limit>0&&(i.limit=String(e.limit)),e.cursor&&(i.cursor=e.cursor),await this.client._request("GET","/api/v1/playbooks",{query:i})}async listOwn(e={}){let i={};return e.filter&&(i.filter=e.filter),e.limit!==void 0&&e.limit>0&&(i.limit=String(e.limit)),e.cursor&&(i.cursor=e.cursor),await this.client._request("GET","/api/v1/playbook",{query:i})}async get(e){if(e.id)return(await this.getByIds([e.id])).items[0]??null;if(e.ref){let i=e.ref.indexOf("/");if(i<=0||i===e.ref.length-1)throw new a("INVALID_ARGUMENT",`Invalid ref "${e.ref}". Expected "owner/name".`,400);let s=e.ref.slice(0,i),n=e.ref.slice(i+1),o;for(;;){let l=await this.listByOwner({owner:s,cursor:o,limit:100}),c=l.items.find(u=>u.name===n);if(c)return c;if(!l.has_next||!l.next_cursor)return null;o=l.next_cursor}}throw new a("INVALID_ARGUMENT","id or ref is required",400)}async trending(e={}){let i={};e.cursor&&(i.cursor=e.cursor),e.current&&(i.current=e.current),e.limit!==void 0&&(i.limit=e.limit),e.dir&&(i.dir=e.dir),e.sort&&(i.sort=e.sort),e.keyword&&(i.keyword=e.keyword),e.tags&&e.tags.length>0&&(i.tags=e.tags.join(","));let s=await this.client._request("GET","/api/v1/playbooks/trending",{query:i}),n=Ct(this.client.baseUrl);return{playbooks:(s.playbooks??[]).map(o=>qt(o,n)),has_next:s.has_next??!1}}async setVisibility(e){if(!Je.includes(e.visibility))throw new a("INVALID_ARGUMENT",`Invalid visibility "${e.visibility}". Expected one of: ${Je.join(", ")}.`,400);return this.client._requireAuth(),await this.client._request("POST",`/api/v1/playbook/${encodeURIComponent(e.name)}/visibility`,{body:{visibility:e.visibility}})}};function Ct(t){try{let e=new URL(t).hostname,i=/^api-llm\.([a-z0-9-]+)\.alva\.ai$/i.exec(e);if(i){let s=i[1].toLowerCase();return s==="prd"?"https://alva.ai":`https://${s}.alva.ai`}}catch{}return"https://alva.ai"}r(Ct,"webOriginFromApiBase");function qt(t,e){let i=t.creator?.name??"",s=t.name??"",n=i&&s?`${i}/${s}`:s,o=i&&s?`/u/${i}/playbooks/${s}`:"";return{id:t.id===void 0?"":String(t.id),ref:n,username:i,name:s,display_name:t.display_name??"",description:t.description??"",tags:t.tags??[],follow_count:t.follow_count??0,url_path:o,url:o?`${e}${o}`:"",...t.readme?{readme:t.readme}:{},cursor:t.cursor??""}}r(qt,"toAgentPlaybook");var te=class{constructor(e){this.client=e}client;static{r(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 i=encodeURIComponent(e.name);return this.client._request("GET",`/api/v1/secrets/${i}`)}async update(e){this.client._requireAuth();let i=encodeURIComponent(e.name);await this.client._request("PUT",`/api/v1/secrets/${i}`,{body:{value:e.value}})}async delete(e){this.client._requireAuth();let i=encodeURIComponent(e.name);await this.client._request("DELETE",`/api/v1/secrets/${i}`)}};var ie=class{constructor(e){this.client=e}client;static{r(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 i=encodeURIComponent(e.partition);return this.client._request("GET",`/api/v1/sdk/partitions/${i}/summary`)}};var ze=[{skill:"arrays-data-api-crypto-futures-data",file:"binance-perp-usdt-kline",method:"GET",path:"/api/v1/crypto/binance/perp/usdt/kline"},{skill:"arrays-data-api-spot-market-price-and-volume",file:"binance-spot-usdt-kline",method:"GET",path:"/api/v1/crypto/binance/spot/usdt/kline"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"fear-greed-index",method:"GET",path:"/api/v1/crypto/fear-greed-index"},{skill:"arrays-data-api-crypto-futures-data",file:"funding-rate",method:"GET",path:"/api/v1/crypto/funding-rate"},{skill:"arrays-data-api-crypto-futures-data",file:"hyperliquid-perp-usdc-kline",method:"GET",path:"/api/v1/crypto/hyperliquid/perp/usdc/kline"},{skill:"arrays-data-api-spot-market-price-and-volume",file:"hyperliquid-spot-usdc-kline",method:"GET",path:"/api/v1/crypto/hyperliquid/spot/usdc/kline"},{skill:"arrays-data-api-crypto-futures-data",file:"long-short-ratio",method:"GET",path:"/api/v1/crypto/long-short-ratio"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"crypto-market-cap",method:"GET",path:"/api/v1/crypto/market-cap"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"market-metrics",method:"GET",path:"/api/v1/crypto/market-metrics"},{skill:"arrays-data-api-crypto-futures-data",file:"open-interest",method:"GET",path:"/api/v1/crypto/open-interest"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"screener-metrics",method:"GET",path:"/api/v1/crypto/screener/metrics"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"screener-metrics-timerange",method:"GET",path:"/api/v1/crypto/screener/metrics/timerange"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"crypto-detail",method:"GET",path:"/api/v1/crypto/detail"},{skill:"arrays-data-api-etf-fundamentals",file:"country-weightings",method:"GET",path:"/api/v1/etf/country-weightings"},{skill:"arrays-data-api-etf-fundamentals",file:"holdings",method:"GET",path:"/api/v1/etf/holdings"},{skill:"arrays-data-api-etf-fundamentals",file:"info",method:"GET",path:"/api/v1/etf/info"},{skill:"arrays-data-api-etf-fundamentals",file:"sector-weightings",method:"GET",path:"/api/v1/etf/sector-weightings"},{skill:"arrays-data-api-macro-and-economics",file:"macro-commodity-historical",method:"GET",path:"/api/v1/macro/commodity/historical"},{skill:"arrays-data-api-macro-and-economics",file:"macro-commodity-real-time",method:"GET",path:"/api/v1/macro/commodity/real-time"},{skill:"arrays-data-api-macro-and-economics",file:"macro-commodity-symbol-list",method:"GET",path:"/api/v1/macro/commodity/symbols"},{skill:"arrays-data-api-macro-and-economics",file:"economic-indicators",method:"GET",path:"/api/v1/macro/economic-indicators"},{skill:"arrays-data-api-macro-and-economics",file:"macro-forex-historical",method:"GET",path:"/api/v1/macro/forex/historical"},{skill:"arrays-data-api-macro-and-economics",file:"macro-forex-real-time",method:"GET",path:"/api/v1/macro/forex/real-time"},{skill:"arrays-data-api-macro-and-economics",file:"macro-forex-symbol-list",method:"GET",path:"/api/v1/macro/forex/symbols"},{skill:"arrays-data-api-macro-and-economics",file:"macro-index-historical",method:"GET",path:"/api/v1/macro/index/historical"},{skill:"arrays-data-api-macro-and-economics",file:"macro-index-real-time",method:"GET",path:"/api/v1/macro/index/real-time"},{skill:"arrays-data-api-macro-and-economics",file:"rates",method:"GET",path:"/api/v1/macro/treasury-rates"},{skill:"arrays-data-api-equity-fundamentals",file:"company-balance-sheets",method:"GET",path:"/api/v1/stocks/company/balance-sheets"},{skill:"arrays-data-api-equity-fundamentals",file:"company-cashflow-statements",method:"GET",path:"/api/v1/stocks/company/cashflow-statements"},{skill:"arrays-data-api-equity-fundamentals",file:"company-detail",method:"GET",path:"/api/v1/stocks/company/detail"},{skill:"arrays-data-api-equity-fundamentals",file:"company-income-statements",method:"GET",path:"/api/v1/stocks/company/income-statements"},{skill:"arrays-data-api-equity-fundamentals",file:"company-kpi",method:"GET",path:"/api/v1/stocks/company/kpi"},{skill:"arrays-data-api-equity-events",file:"crowdfunding-offerings",method:"GET",path:"/api/v1/stocks/crowdfunding/offerings"},{skill:"arrays-data-api-equity-events",file:"dividends",method:"GET",path:"/api/v1/stocks/dividends"},{skill:"arrays-data-api-equity-events",file:"earnings-calendar",method:"GET",path:"/api/v1/stocks/earnings-calendar"},{skill:"arrays-data-api-equity-events",file:"equity-offering",method:"GET",path:"/api/v1/stocks/equity-offering"},{skill:"arrays-data-api-stock-metrics",file:"financial-metrics",method:"GET",path:"/api/v1/stocks/financial-metrics"},{skill:"arrays-data-api-equity-fundamentals",file:"fiscal-dates",method:"GET",path:"/api/v1/stocks/fiscal-dates"},{skill:"arrays-data-api-equity-fundamentals",file:"fiscal-dates-range",method:"GET",path:"/api/v1/stocks/fiscal-dates/range"},{skill:"arrays-data-api-equity-events",file:"ipo-calendar",method:"GET",path:"/api/v1/stocks/ipo-calendar"},{skill:"arrays-data-api-equity-events",file:"ipo-confirmed-calendar",method:"GET",path:"/api/v1/stocks/ipo-confirmed-calendar"},{skill:"arrays-data-api-spot-market-price-and-volume",file:"stocks-kline",method:"GET",path:"/api/v1/stocks/kline"},{skill:"arrays-data-api-stock-metrics",file:"market-metrics",method:"GET",path:"/api/v1/stocks/market-metrics"},{skill:"arrays-data-api-equity-events",file:"mergers-acquisitions",method:"GET",path:"/api/v1/stocks/mergers-acquisitions"},{skill:"arrays-data-api-equity-fundamentals",file:"outstanding-shares",method:"GET",path:"/api/v1/stocks/outstanding-shares"},{skill:"arrays-data-api-stock-metrics",file:"ratings",method:"GET",path:"/api/v1/stocks/ratings"},{skill:"arrays-data-api-stock-screener",file:"basic-info-screener",method:"GET",path:"/api/v1/stocks/screener/basic-info/{sub}"},{skill:"arrays-data-api-stock-screener",file:"event-screener",method:"GET",path:"/api/v1/stocks/screener/events"},{skill:"arrays-data-api-stock-screener",file:"screener-financial-metrics",method:"GET",path:"/api/v1/stocks/screener/financial-metrics"},{skill:"arrays-data-api-stock-screener",file:"screener-financial-metrics-timerange",method:"GET",path:"/api/v1/stocks/screener/financial-metrics/timerange"},{skill:"arrays-data-api-stock-screener",file:"screener-technical-metrics",method:"GET",path:"/api/v1/stocks/screener/technical-metrics"},{skill:"arrays-data-api-stock-screener",file:"screener-technical-metrics-timerange",method:"GET",path:"/api/v1/stocks/screener/technical-metrics/timerange"},{skill:"arrays-data-api-equity-events",file:"sec-earnings-release",method:"GET",path:"/api/v1/stocks/sec-earnings-release"},{skill:"arrays-data-api-equity-fundamentals",file:"shares-float",method:"GET",path:"/api/v1/stocks/shares-float"},{skill:"arrays-data-api-equity-events",file:"splits",method:"GET",path:"/api/v1/stocks/splits"},{skill:"arrays-data-api-crypto-exchange-flow",file:"exchange-flows",method:"GET",path:"/api/v1/crypto/exchange-flows"},{skill:"arrays-data-api-company-crypto-holdings",file:"crypto-holdings",method:"GET",path:"/api/v1/crypto/holdings"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-inflow-cdd",method:"GET",path:"/api/v1/crypto/metrics/inflow-cdd"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-leverage-ratio",method:"GET",path:"/api/v1/crypto/metrics/leverage-ratio"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-miner-to-exchange",method:"GET",path:"/api/v1/crypto/metrics/miner-to-exchange"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-mvrv",method:"GET",path:"/api/v1/crypto/metrics/mvrv"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-nupl",method:"GET",path:"/api/v1/crypto/metrics/nupl"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-puell-multiple",method:"GET",path:"/api/v1/crypto/metrics/puell-multiple"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-realized-price",method:"GET",path:"/api/v1/crypto/metrics/realized-price"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-sopr",method:"GET",path:"/api/v1/crypto/metrics/sopr"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-ssr",method:"GET",path:"/api/v1/crypto/metrics/ssr"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-whale-ratio",method:"GET",path:"/api/v1/crypto/metrics/whale-ratio"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"crypto-supply",method:"GET",path:"/api/v1/crypto/supply"},{skill:"arrays-data-api-crypto-futures-data",file:"taker-buy-sell-volume",method:"GET",path:"/api/v1/crypto/taker-buy-sell-volume"},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"unlock-events",method:"GET",path:"/api/v1/crypto/unlock-events"},{skill:"arrays-data-api-etf-fundamentals",file:"flow",method:"GET",path:"/api/v1/etf/flow"},{skill:"arrays-data-api-options",file:"contracts",method:"GET",path:"/api/v1/options/contracts"},{skill:"arrays-data-api-options",file:"kline",method:"GET",path:"/api/v1/options/kline"},{skill:"arrays-data-api-options",file:"greeks",method:"GET",path:"/api/v1/options/greeks"},{skill:"arrays-data-api-options",file:"chain",method:"GET",path:"/api/v1/options/chain"},{skill:"arrays-data-api-equity-fundamentals",file:"company-executives",method:"GET",path:"/api/v1/stocks/company/executives"},{skill:"arrays-data-api-equity-estimates-and-targets",file:"company-price-target-consensus",method:"GET",path:"/api/v1/stocks/company/price-target-consensus"},{skill:"arrays-data-api-equity-estimates-and-targets",file:"company-price-target-news",method:"GET",path:"/api/v1/stocks/company/price-target-news"},{skill:"arrays-data-api-equity-estimates-and-targets",file:"company-price-target-summary",method:"GET",path:"/api/v1/stocks/company/price-target-summary"},{skill:"arrays-data-api-equity-ownership-and-flow",file:"congress-recent-trades",method:"GET",path:"/api/v1/stocks/congress/recent-trades"},{skill:"arrays-data-api-stock-metrics",file:"darkpool",method:"GET",path:"/api/v1/stocks/darkpool"},{skill:"arrays-data-api-equity-estimates-and-targets",file:"estimates-guidance",method:"GET",path:"/api/v1/stocks/estimates-guidance"},{skill:"arrays-data-api-equity-ownership-and-flow",file:"insider-transactions",method:"GET",path:"/api/v1/stocks/insider/transactions"},{skill:"arrays-data-api-equity-ownership-and-flow",file:"institution-holder",method:"GET",path:"/api/v1/stocks/institution-holder"},{skill:"arrays-data-api-polymarket",file:"activity",method:"GET",path:"polymarket:/activity"},{skill:"arrays-data-api-polymarket",file:"book",method:"GET",path:"polymarket:/book"},{skill:"arrays-data-api-polymarket",file:"closed-positions",method:"GET",path:"polymarket:/closed-positions"},{skill:"arrays-data-api-polymarket",file:"events",method:"GET",path:"polymarket:/events"},{skill:"arrays-data-api-polymarket",file:"holders",method:"GET",path:"polymarket:/holders"},{skill:"arrays-data-api-polymarket",file:"markets",method:"GET",path:"polymarket:/markets"},{skill:"arrays-data-api-polymarket",file:"midpoint",method:"GET",path:"polymarket:/midpoint"},{skill:"arrays-data-api-polymarket",file:"oi",method:"GET",path:"polymarket:/oi"},{skill:"arrays-data-api-polymarket",file:"positions",method:"GET",path:"polymarket:/positions"},{skill:"arrays-data-api-polymarket",file:"price",method:"GET",path:"polymarket:/price"},{skill:"arrays-data-api-polymarket",file:"prices-history",method:"GET",path:"polymarket:/prices-history"},{skill:"arrays-data-api-polymarket",file:"public-search",method:"GET",path:"polymarket:/public-search"},{skill:"arrays-data-api-polymarket",file:"series",method:"GET",path:"polymarket:/series"},{skill:"arrays-data-api-polymarket",file:"sports",method:"GET",path:"polymarket:/sports"},{skill:"arrays-data-api-polymarket",file:"spread",method:"GET",path:"polymarket:/spread"},{skill:"arrays-data-api-polymarket",file:"tags",method:"GET",path:"polymarket:/tags"},{skill:"arrays-data-api-polymarket",file:"trades",method:"GET",path:"polymarket:/trades"},{skill:"arrays-data-api-polymarket",file:"value",method:"GET",path:"polymarket:/value"},{skill:"arrays-data-api-equity-events",file:"earnings-transcript",method:"GET",path:"/api/v1/stocks/earnings-transcript"},{skill:"arrays-data-api-news",file:"market-news",method:"GET",path:"/api/v1/stocks/market-news"},{skill:"arrays-data-api-social-feeds",file:"x-by-handle",method:"GET",path:"/api/v1/social-feeds/x/by-handle"},{skill:"arrays-data-api-social-feeds",file:"x-by-url",method:"GET",path:"/api/v1/social-feeds/x/by-url"},{skill:"arrays-data-api-social-feeds",file:"x-entities-handle",method:"GET",path:"/api/v1/social-feeds/x/entities/handle/{twitter_handle}"},{skill:"arrays-data-api-social-feeds",file:"x-entities-handles",method:"GET",path:"/api/v1/social-feeds/x/entities/handles"},{skill:"arrays-data-api-equity-fundamentals",file:"company-detail-non-us",method:"GET",path:"/api/v1/stocks/non-us/company/detail"},{skill:"arrays-data-api-social-feeds",file:"x-search",method:"GET",path:"/api/v1/social-feeds/x/search"},{skill:"arrays-data-api-spot-market-price-and-volume",file:"stocks-non-us-kline",method:"GET",path:"/api/v1/stocks/non-us/kline"},{skill:"arrays-data-api-semiconductor-price",file:"dram-spot-price",method:"GET",path:"/api/v1/other/semiconductor/dram-spot-price"},{skill:"arrays-data-api-semiconductor-price",file:"dram-contract-price",method:"GET",path:"/api/v1/other/semiconductor/dram-contract-price"},{skill:"arrays-data-api-semiconductor-price",file:"nand-flash-spot-price",method:"GET",path:"/api/v1/other/semiconductor/nand-flash-spot-price"},{skill:"arrays-data-api-semiconductor-price",file:"nand-flash-contract-price",method:"GET",path:"/api/v1/other/semiconductor/nand-flash-contract-price"},{skill:"arrays-data-api-semiconductor-price",file:"memory-card-price",method:"GET",path:"/api/v1/other/semiconductor/memory-card-price"},{skill:"arrays-data-api-semiconductor-price",file:"dxi-index",method:"GET",path:"/api/v1/other/semiconductor/dxi-index"},{skill:"arrays-data-api-equity-ownership-and-flow",file:"short-interest",method:"GET",path:"/api/v1/stocks/short-interest"},{skill:"arrays-data-api-social-feeds",file:"x-handles",method:"POST",path:"/api/v1/social-feeds/x/handles"}];function Xe(t,e){return ze.find(i=>i.skill===t&&i.file===e)}r(Xe,"getSkillEndpointMetadata");function Ae(t){return ze.filter(e=>e.skill===t)}r(Ae,"listSkillEndpointMetadata");var se=class{constructor(e){this.client=e}client;static{r(this,"DataSkillsResource")}async list(){return{skills:((await this.client._request("GET","/api/v1/skills",{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data??[]).map(i=>({...i,...Ze(i.name)}))}}async summary(e){let i=encodeURIComponent(e.name),n=(await this.client._request("GET",`/api/v1/skills/${i}`,{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data?.[0];if(!n)throw new Error(`empty skills summary response for "${e.name}"`);let o=Ae(e.name);return{...n,...Ze(e.name),...o.length>0?{endpoint_metadata:o}:{}}}async endpoint(e){let i=encodeURIComponent(e.name),n=(await this.client._request("GET",`/api/v1/skills/${i}`,{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=Xe(e.name,e.file);return{...n,...o?{metadata:o}:{}}}};function Ze(t){let e=Ae(t).length;return e===0?{}:{metadata:{endpoint_count:e}}}r(Ze,"metadataSummaryForSkill");function et(t){return{username:t.username,name:t.name,display_name:t.display_name,description:t.description,tags:t.tags,creator_uid:t.creator_uid,updated_at:t.updated_at}}r(et,"normalizePlaybookSkillSummary");function tt(t){let e=t.split("/");if(e.length!==2||!e[0]||!e[1])throw new a("INVALID_ARGUMENT",`playbook skill identifier must be "<user>/<name>", got "${t}"`,0);return{username:e[0],name:e[1]}}r(tt,"parsePlaybookSkillId");var re=class{constructor(e){this.client=e}client;static{r(this,"PlaybookSkillsResource")}async list(e){let i={};return e?.tag&&(i.tag=e.tag),e?.username&&(i.username=e.username),{skills:((await this.client._request("GET","/api/v1/skills",{query:i})).data??[]).map(et)}}async tags(){return{tags:(await this.client._request("GET","/api/v1/skills/tags")).data??[]}}async get(e){let{username:i,name:s}=tt(e),n=encodeURIComponent(i),o=encodeURIComponent(s),c=(await this.client._request("GET",`/api/v1/skills/${n}/${o}`)).data?.[0];if(!c)throw new a("NOT_FOUND",`empty playbook skills get response for ${e}`,0);return{...et(c),files:c.files??[]}}async file(e,i){let{username:s,name:n}=tt(e),o=encodeURIComponent(s),l=encodeURIComponent(n),c=i.split("/").map(encodeURIComponent).join("/"),m=(await this.client._request("GET",`/api/v1/skills/${o}/${l}/files/${c}`)).data?.[0];if(!m)throw new a("NOT_FOUND",`empty playbook skills file response for ${e} path ${i}`,0);return m}};var ne=class{constructor(e){this.client=e}client;static{r(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 oe=class{constructor(e){this.client=e}client;static{r(this,"RemixResource")}async save(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/remix",{body:{child:e.child,parents:e.parents}})}};var ae=class{constructor(e){this.client=e}client;static{r(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 le=class{constructor(e){this.client=e}client;static{r(this,"UserResource")}async me(){return this.client._requireAuth(),this.client._request("GET","/api/v1/me")}};var ce=class{constructor(e){this.client=e}client;static{r(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 ue=class{constructor(e){this.client=e}client;static{r(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 pe=class{constructor(e){this.client=e}client;static{r(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 de=class{constructor(e){this.client=e}client;static{r(this,"NotificationsResource")}async listFeed(e){this.client._requireAuth();let i=`/api/v1/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",i,{query:xt(e)})}};function xt(t){let e={};return t.channel&&(e.channel=t.channel),t.status&&(e.status=t.status),t.since_time!==void 0&&t.since_time>0&&(e.since_time=String(t.since_time)),t.first!==void 0&&t.first>0&&(e.first=String(t.first)),t.cursor&&(e.cursor=t.cursor),e}r(xt,"buildQuery");var me=class{constructor(e){this.client=e}client;static{r(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 ye=class{constructor(e){this.client=e}client;static{r(this,"SubscriptionsResource")}async followPlaybook(e){this.client._requireAuth();let i=`/api/v1/follows/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",i)}async unfollowPlaybook(e){this.client._requireAuth();let i=`/api/v1/follows/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",i)}async subscribeFeed(e){this.client._requireAuth();let i=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return e.channelId===void 0?this.client._request("POST",i):this.client._request("POST",i,{body:{channel_id:e.channelId}})}async unsubscribeFeed(e){this.client._requireAuth();let i=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",i)}async list(e={}){this.client._requireAuth();let i={};return e.first!==void 0&&e.first>0&&(i.first=String(e.first)),e.cursor&&(i.cursor=e.cursor),this.client._request("GET","/api/v1/me/subscriptions",{query:i})}async follows(e={}){this.client._requireAuth();let i={};return e.limit!==void 0&&e.limit>0&&(i.limit=String(e.limit)),e.cursor&&(i.cursor=e.cursor),this.client._request("GET","/api/v1/me/follows",{query:i})}async subscribeBatch(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/subscriptions/subscribe-batch",{body:{feed_ids:e.feedIds,channel_id:e.channelId}})}async unsubscribeBatch(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/subscriptions/unsubscribe-batch",{body:{feed_ids:e.feedIds}})}};var w=class{constructor(e){this.client=e}client;static{r(this,"AlertsResource")}list(e={}){return this.client.subscriptions.list(e)}follows(e={}){return this.client.subscriptions.follows(e)}enableAutomation(e){return this.client.subscriptions.subscribeFeed(e)}disableAutomation(e){return this.client.subscriptions.unsubscribeFeed(e)}enableBatch(e){return this.client.subscriptions.subscribeBatch(e)}disableBatch(e){return this.client.subscriptions.unsubscribeBatch(e)}historyAutomation(e){return this.client.notifications.listFeed(e)}preferences(){return this.client.notificationPreferences.list()}updatePreference(e){return this.client.notificationPreferences.update(e)}};var he=class{constructor(e){this.client=e}client;static{r(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:it(e)})}async unsubscribe(e){return this.client._requireAuth(),this.client._request("DELETE","/api/v1/channel/group-subscriptions",{jsonBody:it(e)})}async getGroupChatHistory(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/channel/group-history",{query:{channel:e.channel,remote_chat_id:e.remote_chat_id,from_micros:String(e.from_micros),to_micros:String(e.to_micros)}})}};function it(t){return`{"session_id":${st(t.session_id)},"target_type":${JSON.stringify(t.target_type)},"target_id":${st(t.target_id)}}`}r(it,"mutationBody");function st(t){if(typeof t=="number"){if(!Number.isInteger(t)||t<=0||!Number.isSafeInteger(t))throw new a("INVALID_ARGUMENT","channel group subscription ids must be positive safe integers; pass large int64 ids as strings",0);return String(t)}if(!/^[1-9]\d*$/.test(t))throw new a("INVALID_ARGUMENT","channel group subscription ids must be positive integer strings",0);return t}r(st,"idLiteral");var fe=class{constructor(e){this.client=e}client;static{r(this,"FeedbackResource")}async submit(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/feedback",{body:e})}};var ge=class{constructor(e){this.client=e}client;static{r(this,"FunctionsResource")}async register(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/service/functions",{body:{playbook_id:e.playbook_id,function_name:e.function_name,entry_script_path:e.entry_script_path,params_schema:e.params_schema,allow_charges:e.allow_charges,run_as_user_id:e.run_as_user_id}})}async list(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/service/functions",{query:{playbook_id:e.playbook_id}})}async delete(e){this.client._requireAuth(),await this.client._request("DELETE","/api/v1/service/functions",{query:{playbook_id:e.playbook_id,function_name:e.function_name}})}async invoke(e){this.client._requireAuth();let i=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{...i,result:Ft(i.result)}}async getAllowance(e){this.client._requireAuth();let i=await this.client._request("GET","/api/v1/service/allowance",{query:{playbook_id:e.playbook_id}});return Ce(i.allowance)}async listAllowances(){return this.client._requireAuth(),{allowances:((await this.client._request("GET","/api/v1/service/allowances")).allowances??[]).map(i=>Ce(i)).filter(i=>i!==null)}}async createAllowance(e){this.client._requireAuth();let i=await this.client._request("POST","/api/v1/service/allowance",{body:{playbook_id:e.playbook_id,amount:e.amount}});return{allowance:It(i.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 Ce(t){if(!t)return null;let e={id:t.id??"",consumer_uid:t.consumer_uid??t.consumerUid??"",playbook_id:t.playbook_id??t.playbookId??"",amount:t.amount??0,used:t.used??0,remaining:t.remaining??0},i=rt(t.created_at_ms??t.createdAtMs??t.created_at??t.createdAt),s=rt(t.updated_at_ms??t.updatedAtMs??t.updated_at??t.updatedAt);return i!==void 0&&(e.created_at_ms=i),s!==void 0&&(e.updated_at_ms=s),e}r(Ce,"normalizeAllowance");function It(t){let e=Ce(t);if(!e)throw new Error("allowance response missing allowance");return e}r(It,"requireAllowance");function rt(t){if(t==null)return;if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"){let n=Number(t);if(Number.isFinite(n))return n;let o=Date.parse(t);return Number.isNaN(o)?void 0:o}if(typeof t!="object")return;let e=t,i=typeof e.seconds=="number"?e.seconds:typeof e.seconds=="string"?Number(e.seconds):void 0,s=typeof e.nanos=="number"?e.nanos:typeof e.nanos=="string"?Number(e.nanos):0;if(!(i===void 0||!Number.isFinite(i)))return i*1e3+Math.floor((Number.isFinite(s)?s:0)/1e6)}r(rt,"timestampMs");function Ft(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}}r(Ft,"parseResultPayload");var Gt=`
|
|
2
2
|
query ToolkitCreditWallet {
|
|
3
3
|
viewer {
|
|
4
4
|
creditWallet {
|
|
@@ -8,7 +8,7 @@ query ToolkitCreditWallet {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
`.trim(),
|
|
11
|
+
`.trim(),Ut=`
|
|
12
12
|
query ToolkitCreditWalletItems($input: CreditWalletItemConnectionInput!) {
|
|
13
13
|
viewer {
|
|
14
14
|
creditWallet {
|
|
@@ -40,5 +40,132 @@ query ToolkitCreditWalletItems($input: CreditWalletItemConnectionInput!) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
`.trim();function
|
|
43
|
+
`.trim();function Nt(t){let e=t.map(i=>typeof i.message=="string"&&i.message?i.message:void 0).filter(i=>!!i);return e.length>0?e.join("; "):"GraphQL request failed"}r(Nt,"graphQLErrorMessage");var be=class{constructor(e){this.client=e}client;static{r(this,"CreditsResource")}async wallet(){this.client._requireAuth();let i=(await this.graphql(Gt)).viewer?.creditWallet;if(!i)throw new a("GRAPHQL_EMPTY_RESPONSE","GraphQL response did not include viewer.creditWallet",502);return i}async items(e){this.client._requireAuth();let s=(await this.graphql(Ut,{input:{startAtMs:e.startAtMs,endAtMs:e.endAtMs,sessionId:e.sessionId,first:e.first,after:e.after}})).viewer?.creditWallet;if(!s)throw new a("GRAPHQL_EMPTY_RESPONSE","GraphQL response did not include viewer.creditWallet.items",502);return s}async graphql(e,i){let s=await this.client._request("POST","/query",{body:i===void 0?{query:e}:{query:e,variables:i}});if(s.errors&&s.errors.length>0)throw new a("GRAPHQL_ERROR",Nt(s.errors),400,{errors:s.errors});if(!s.data)throw new a("GRAPHQL_EMPTY_RESPONSE","GraphQL response did not include data",502);return s.data}};var Lt=["Q1","Q2","Q3","Q4"],Ot=["latest-completed","next-confirmed"],Dt=`
|
|
44
|
+
query ToolkitCompanyNarrative($ticker: String!) {
|
|
45
|
+
market {
|
|
46
|
+
entity(input: { ticker: $ticker, kind: STOCK }) {
|
|
47
|
+
ticker
|
|
48
|
+
companyInsight {
|
|
49
|
+
asOf
|
|
50
|
+
generatedAtMs
|
|
51
|
+
narrative
|
|
52
|
+
peers
|
|
53
|
+
}
|
|
54
|
+
companyInsightHistory {
|
|
55
|
+
snapshots {
|
|
56
|
+
asOf
|
|
57
|
+
generatedAtMs
|
|
58
|
+
narrative
|
|
59
|
+
}
|
|
60
|
+
changeLog {
|
|
61
|
+
asOf
|
|
62
|
+
generatedAtMs
|
|
63
|
+
narrativeChangeLog
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`.trim(),Mt=`
|
|
70
|
+
query ToolkitCompanyEarningsCatalog($ticker: String!) {
|
|
71
|
+
market {
|
|
72
|
+
entity(input: { ticker: $ticker, kind: STOCK }) {
|
|
73
|
+
ticker
|
|
74
|
+
earningsPeriods {
|
|
75
|
+
unresolvedEventCount
|
|
76
|
+
defaultPeriod {
|
|
77
|
+
fiscalYear
|
|
78
|
+
fiscalQuarter
|
|
79
|
+
label
|
|
80
|
+
fiscalDateEnding
|
|
81
|
+
earningsDate
|
|
82
|
+
session
|
|
83
|
+
status
|
|
84
|
+
isDefault
|
|
85
|
+
}
|
|
86
|
+
periods {
|
|
87
|
+
fiscalYear
|
|
88
|
+
fiscalQuarter
|
|
89
|
+
label
|
|
90
|
+
fiscalDateEnding
|
|
91
|
+
earningsDate
|
|
92
|
+
session
|
|
93
|
+
status
|
|
94
|
+
isDefault
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
`.trim(),jt=`
|
|
101
|
+
query ToolkitCompanyEarnings($ticker: String!, $input: CompanyEarningsInput) {
|
|
102
|
+
market {
|
|
103
|
+
entity(input: { ticker: $ticker, kind: STOCK }) {
|
|
104
|
+
ticker
|
|
105
|
+
earnings(input: $input) {
|
|
106
|
+
period {
|
|
107
|
+
fiscalYear
|
|
108
|
+
fiscalQuarter
|
|
109
|
+
label
|
|
110
|
+
fiscalDateEnding
|
|
111
|
+
earningsDate
|
|
112
|
+
session
|
|
113
|
+
status
|
|
114
|
+
isDefault
|
|
115
|
+
}
|
|
116
|
+
preEarningsAnalysis {
|
|
117
|
+
status
|
|
118
|
+
asOf
|
|
119
|
+
summary
|
|
120
|
+
whatWouldChangeView
|
|
121
|
+
mainQuestion
|
|
122
|
+
investorFocus
|
|
123
|
+
consensusAndGuidance
|
|
124
|
+
stockSetup
|
|
125
|
+
eventRisk
|
|
126
|
+
whatWouldDriveUpside
|
|
127
|
+
bullCase
|
|
128
|
+
baseCase
|
|
129
|
+
bearCase
|
|
130
|
+
keyAsymmetry
|
|
131
|
+
consensusN
|
|
132
|
+
consensusObservedAt
|
|
133
|
+
}
|
|
134
|
+
earningsRelease {
|
|
135
|
+
status
|
|
136
|
+
releaseDate
|
|
137
|
+
url
|
|
138
|
+
}
|
|
139
|
+
earningsTranscript {
|
|
140
|
+
status
|
|
141
|
+
date
|
|
142
|
+
publishedAtMs
|
|
143
|
+
sections {
|
|
144
|
+
name
|
|
145
|
+
entries {
|
|
146
|
+
speaker
|
|
147
|
+
title
|
|
148
|
+
content
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
postEarningsSummary {
|
|
153
|
+
status
|
|
154
|
+
asOf
|
|
155
|
+
reportedCurrency
|
|
156
|
+
evidenceState
|
|
157
|
+
openingQuote
|
|
158
|
+
openingQuoteSpeaker
|
|
159
|
+
openingQuoteTitle
|
|
160
|
+
openingQuoteNote
|
|
161
|
+
buriedSignals
|
|
162
|
+
whatYouShouldKnow
|
|
163
|
+
consensusN
|
|
164
|
+
consensusObservedAt
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
`.trim();function Bt(t){let e=t.map(i=>typeof i.message=="string"&&i.message?i.message:void 0).filter(i=>!!i);return e.length>0?e.join("; "):"GraphQL request failed"}r(Bt,"graphQLErrorMessage");function qe(t){let e=t.trim().toUpperCase();if(!e)throw new a("INVALID_ARGUMENT","ticker is required",400);return e}r(qe,"normalizedTicker");var A=class{constructor(e){this.client=e}client;static{r(this,"MarketsResource")}async narrative(e){this.client._requireAuth();let i=qe(e),n=(await this.graphql(Dt,{ticker:i})).market?.entity;if(!n)throw this.notFound(i);return{ticker:n.ticker,current:n.companyInsight,history:n.companyInsightHistory}}async earningsPeriods(e){this.client._requireAuth();let i=qe(e),n=(await this.graphql(Mt,{ticker:i})).market?.entity;if(!n)throw this.notFound(i);if(!n.earningsPeriods)throw new a("MARKETS_EARNINGS_NOT_COVERED",`No earnings periods are available for ${n.ticker}`,404,{ticker:n.ticker});return n.earningsPeriods}async earnings(e){this.client._requireAuth();let i=qe(e.ticker),s=e.event,n=e.fiscalYear,o=e.fiscalQuarter;if(s!==void 0&&(n!==void 0||o!==void 0))throw new a("INVALID_ARGUMENT","event cannot be combined with fiscalYear or fiscalQuarter",400);if(n===void 0!=(o===void 0))throw new a("INVALID_ARGUMENT","fiscalYear and fiscalQuarter must be provided together",400);if(s!==void 0&&!Ot.includes(s))throw new a("INVALID_ARGUMENT",`Unknown earnings event selector: ${s}`,400);if(n!==void 0&&(!Number.isInteger(n)||n<1900||n>9999))throw new a("INVALID_ARGUMENT","fiscalYear must be an integer between 1900 and 9999",400);if(o!==void 0&&!Lt.includes(o))throw new a("INVALID_ARGUMENT","fiscalQuarter must be Q1, Q2, Q3, or Q4",400);let c,u;if(n!==void 0&&o!==void 0)c=n,u=o;else{let _=s??"latest-completed",C=await this.earningsPeriods(i),P=this.selectPeriod(C,_,i);c=P.fiscalYear,u=P.fiscalQuarter}let p=(await this.graphql(jt,{ticker:i,input:{fiscalYear:c,fiscalQuarter:u}})).market?.entity;if(!p)throw this.notFound(i);if(!p.earnings)throw new a("MARKETS_EARNINGS_NOT_COVERED",`No earnings content is available for ${p.ticker} FY${c} ${u}`,404,{ticker:p.ticker,fiscalYear:c,fiscalQuarter:u});return{ticker:p.ticker,...p.earnings}}selectPeriod(e,i,s){if(i==="latest-completed"){if(e.defaultPeriod)return e.defaultPeriod}else{let n=e.periods.filter(o=>o.status==="UPCOMING").sort((o,l)=>o.earningsDate.localeCompare(l.earningsDate));if(n.length>0)return n[0]}throw new a("MARKETS_EARNINGS_EVENT_NOT_FOUND",`No ${i} earnings event is available for ${s}`,404,{ticker:s,event:i})}notFound(e){return new a("MARKETS_ENTITY_NOT_FOUND",`No stock entity was found for ${e}`,404,{ticker:e})}async graphql(e,i){let s=await this.client._request("POST","/query",{body:{query:e,variables:i}});if(s.errors&&s.errors.length>0)throw new a("GRAPHQL_ERROR",Bt(s.errors),400,{errors:s.errors});if(!s.data)throw new a("GRAPHQL_EMPTY_RESPONSE","GraphQL response did not include data",502);return s.data}};var $t="https://api-llm.prd.alva.ai",Qt="https://data-tools.prd.space.id";function xe(t){return typeof t=="object"&&t!==null}r(xe,"isRecord");function ke(t,e){if(!xe(t))return;let i=t[e];return typeof i=="string"&&i?i:void 0}r(ke,"stringField");function Wt(t){if(t==null)return{};let e={};if(t instanceof Error){t.name&&(e.name=t.name),t.message&&(e.message=t.message);let s=ke(t,"code");s&&(e.code=s)}else if(xe(t)){let s=ke(t,"code"),n=ke(t,"name"),o=ke(t,"message");s&&(e.code=s),n&&(e.name=n),o&&(e.message=o)}else e.message=String(t);let i=[e.code,e.name,e.message].filter(s=>!!s);return{message:i.length>0?i.join(": "):void 0,details:Object.keys(e).length>0?e:void 0}}r(Wt,"describeCause");function Vt(t){let e=t instanceof Error&&t.message?t.message:"Network request failed",i={};t instanceof Error?(i.name=t.name,i.message=t.message):i.message=String(t);let{message:s,details:n}=Wt(xe(t)?t.cause:void 0);return n&&(i.cause=n),{message:s?`${e}; cause: ${s}`:e,details:i}}r(Vt,"describeFetchFailure");var _e=class{static{r(this,"AlvaClient")}baseUrl;arraysBaseUrl;viewer_token;pbsvToken;apiKey;gaClientId;gaSessionId;utmParams;signal;originSessionId;originSessionKind;_fs;_run;_deploy;_serviceAccount;_release;_feed;_automation;_playbooks;_secrets;_sdk;_dataSkills;_playbookSkills;_comments;_remix;_screenshot;_user;_trading;_portfolio;_arraysJwt;_notifications;_notificationPreferences;_subscriptions;_alerts;_channelGroupSubscriptions;_feedback;_functions;_credits;_markets;constructor(e){this.baseUrl=e.baseUrl??$t,this.arraysBaseUrl=e.arraysBaseUrl??Qt,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,this.originSessionKind=e.originSessionKind}get fs(){return this._fs??=new H(this)}get run(){return this._run??=new K(this)}get deploy(){return this._deploy??=new Y(this)}get serviceAccount(){return this._serviceAccount??=new J(this)}get release(){return this._release??=new z(this)}get feed(){return this._feed??=new Z(this)}get automation(){return this._automation??=new S(this)}get playbooks(){return this._playbooks??=new ee(this)}get secrets(){return this._secrets??=new te(this)}get sdk(){return this._sdk??=new ie(this)}get dataSkills(){return this._dataSkills??=new se(this)}get playbookSkills(){return this._playbookSkills??=new re(this)}get comments(){return this._comments??=new ne(this)}get remix(){return this._remix??=new oe(this)}get screenshot(){return this._screenshot??=new ae(this)}get user(){return this._user??=new le(this)}get trading(){return this._trading??=new ce(this)}get portfolio(){return this._portfolio??=new ue(this)}get arraysJwt(){return this._arraysJwt??=new pe(this)}get notifications(){return this._notifications??=new de(this)}get notificationPreferences(){return this._notificationPreferences??=new me(this)}get subscriptions(){return this._subscriptions??=new ye(this)}get alerts(){return this._alerts??=new w(this)}get channelGroupSubscriptions(){return this._channelGroupSubscriptions??=new he(this)}get feedback(){return this._feedback??=new fe(this)}get functions(){return this._functions??=new ge(this)}get credits(){return this._credits??=new be(this)}get markets(){return this._markets??=new A(this)}_requireAuth(){if(!this.pbsvToken&&!this.viewer_token&&!this.apiKey)throw new a("UNAUTHENTICATED","Authentication is required. Pass pbsvToken, viewer_token, or apiKey in the constructor.",401)}async _request(e,i,s){let o=`${s?.baseUrl??this.baseUrl}${i}`;if(s?.query){let h=new URLSearchParams;for(let[b,Pe]of Object.entries(s.query))Pe!=null&&h.set(b,String(Pe));let R=h.toString();R&&(o+=`?${R}`)}let l={};s?.noAuth||(this.pbsvToken?(l.Authorization=`Bearer ${this.pbsvToken}`,l["X-Pbsv"]="1"):this.viewer_token?l["x-Playbook-Viewer"]=this.viewer_token:this.apiKey&&(l["X-Alva-Api-Key"]=this.apiKey)),this.gaClientId&&(l["X-Alva-GA-Client-ID"]=this.gaClientId),this.gaSessionId&&(l["X-Alva-GA-Session-ID"]=this.gaSessionId),this.utmParams&&(l["X-Alva-UTM-Params"]=this.utmParams),this.originSessionId&&!s?.noAuth&&(l["X-Alva-Origin-Session-Id"]=this.originSessionId);let c;s?.rawBody!==void 0?(l["Content-Type"]="application/octet-stream",c=s.rawBody):s?.jsonBody!==void 0?(l["Content-Type"]="application/json",c=s.jsonBody):s?.body!==void 0&&(l["Content-Type"]="application/json",c=JSON.stringify(s.body));let u,m=s?.timeoutMs,p=s?.signal??this.signal;if(p?.aborted)throw new a("NETWORK_ABORTED",`Request aborted while calling ${e} ${i}`,0,{method:e,path:i});let _=m!==void 0?new AbortController:void 0,C=!1,P,B;_&&m!==void 0&&(p&&(B=r(()=>_.abort(p.reason),"abortListener"),p.addEventListener("abort",B,{once:!0})),P=setTimeout(()=>{C=!0,_.abort(new Error(`Request timed out after ${m}ms while calling ${e} ${i}`))},m));let Ie={method:e,headers:l,body:c,signal:_?.signal??p};m!==void 0&&(Ie.timeout=m);try{u=await fetch(o,Ie)}catch(h){if(p?.aborted&&!C)throw new a("NETWORK_ABORTED",`Request aborted while calling ${e} ${i}`,0,{method:e,path:i});if(C)throw new a("NETWORK_TIMEOUT",`Request timed out after ${m}ms while calling ${e} ${i}`,0,{method:e,path:i,timeout_ms:m});let R=Vt(h);throw new a("NETWORK_ERROR",R.message,0,{method:e,path:i,...R.details})}finally{B&&p&&p.removeEventListener("abort",B),P!==void 0&&clearTimeout(P)}if(!u.ok){let h="";try{h=await Promise.resolve(u.text())}catch{h=""}if((u.headers.get("content-type")??"").includes("application/json")&&h)try{let b=JSON.parse(h);if(b.error)throw new a(b.error.code??"UNKNOWN",b.error.message??`HTTP ${u.status}`,u.status)}catch(b){if(b instanceof a)throw b}throw new a("UNKNOWN",`HTTP ${u.status}: ${h.slice(0,200)}`,u.status)}if(u.status===204)return;let Fe=(u.headers.get("content-type")??"").toLowerCase();return Fe.includes("application/json")||Fe.includes("+json")?u.json():u.arrayBuffer()}};var Ht="0.23.0-beta.0";we();return ut(Kt);})();
|
|
44
171
|
//# sourceMappingURL=browser.global.js.map
|