@alva-ai/toolkit 0.11.1 → 0.11.2
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/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.js +53 -9
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +36 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +36 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/browser.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var AlvaToolkit=(()=>{var I=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Ie=Object.prototype.hasOwnProperty;var i=(r,e)=>I(r,"name",{value:e,configurable:!0});var Fe=(r,e)=>{for(var t in e)I(r,t,{get:e[t],enumerable:!0})},Ne=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ue(e))!Ie.call(r,o)&&o!==t&&I(r,o,{get:()=>e[o],enumerable:!(s=xe(e,o))||s.enumerable});return r};var je=r=>Ne(I({},"__esModule",{value:!0}),r);var tr={};Fe(tr,{AlvaClient:()=>se,AlvaError:()=>l,PBSV_UPDATE_MESSAGE:()=>_e,UDF_AUTH_REQUIRED_MESSAGE:()=>be,UDF_CONSENT_REQUEST_MESSAGE:()=>fe,UDF_CONSENT_RESPONSE_MESSAGE:()=>he,UdfAuthRequiredError:()=>g,UdfConsentDeniedError:()=>E,UdfConsentRequiredError:()=>R,UdfConsentTimeoutError:()=>S,UdfError:()=>p,UdfExecutionError:()=>x,UdfFunctionDisabledError:()=>C,UdfFunctionNotFoundError:()=>A,UdfInsufficientCredits:()=>w,UdfPidMismatchError:()=>_,UdfRateLimitedError:()=>G,UdfTokenExpiredError:()=>P,UdfTokenInvalidError:()=>T,UdfTransportError:()=>q,VERSION:()=>rr,getViewerToken:()=>U,installPlaybookRuntime:()=>de,mapUdfErrorResponse:()=>pe,playbookIdFromToken:()=>le,udf:()=>ve});var p=class extends Error{static{i(this,"UdfError")}code;metadata;status;constructor(e,{code:t,metadata:s={},status:o}){super(e),this.name=new.target.name,this.code=t,this.metadata=s,this.status=o}},g=class extends p{static{i(this,"UdfAuthRequiredError")}constructor(){super("Sign in to use this UDF.",{code:"AUTH_REQUIRED"})}},P=class extends p{static{i(this,"UdfTokenExpiredError")}},T=class extends p{static{i(this,"UdfTokenInvalidError")}},_=class extends p{static{i(this,"UdfPidMismatchError")}},R=class extends p{static{i(this,"UdfConsentRequiredError")}},E=class extends p{static{i(this,"UdfConsentDeniedError")}constructor(){super("UDF consent was denied.",{code:"CONSENT_DENIED"})}},S=class extends p{static{i(this,"UdfConsentTimeoutError")}constructor(){super("UDF consent timed out.",{code:"CONSENT_TIMEOUT"})}},w=class extends p{static{i(this,"UdfInsufficientCredits")}},A=class extends p{static{i(this,"UdfFunctionNotFoundError")}},C=class extends p{static{i(this,"UdfFunctionDisabledError")}},G=class extends p{static{i(this,"UdfRateLimitedError")}},x=class extends p{static{i(this,"UdfExecutionError")}},q=class extends p{static{i(this,"UdfTransportError")}},_e="alva:pbsv:update",fe="alva:udf:consent-request",he="alva:udf:consent-response",be="alva:udf:auth-required",ke="https://api-llm.prd.alva.ai",De=300*1e3,v=null,b=null,ce=ke,f=null,m=null,ye=!1,F=new Map,Me=i(r=>{let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return atob(t)},"decodeBase64Url"),le=i(r=>{if(!r)return null;let[,e]=r.split(".");if(!e)return null;try{let t=JSON.parse(Me(e));if(typeof t.pid=="number")return String(t.pid);if(typeof t.pid=="string")return t.pid}catch{return null}return null},"playbookIdFromToken"),U=i(()=>v,"getViewerToken"),k=i(()=>!!U(),"isAuthenticated"),Oe=i(r=>{let e=new URL(r.location.href);e.searchParams.delete("_pbsv"),r.history.replaceState(null,"",e.pathname+e.search+e.hash)},"stripPbsvFromUrl"),Le=i(r=>{let e=new URLSearchParams(r.location.search);v=e.get("_pbsv"),b=e.get("parent_origin"),ce=(e.get("api_origin")||ke).replace(/\/$/,""),f=le(v),v&&Oe(r)},"parseBootParams"),ge=i(async r=>{try{return await r.json()}catch{return{}}},"safeJson"),$e=i(r=>{if(typeof r!="string")return r;try{return JSON.parse(r)}catch{return r}},"parseResultPayload"),Be=i(r=>{let e=r;return{...e,result:$e(e.result)}},"normalizeInvokeResponse"),qe=i(r=>r.error?.metadata||r.details?.metadata||{},"errorMetadata"),pe=i((r,e)=>{let t=r.error?.code||"TRANSPORT",s=r.error?.message||t,o=qe(r),n={code:t,metadata:o,status:e};switch(t){case"PBSV_EXPIRED":return new P(s,n);case"PBSV_INVALID":case"UNAUTHENTICATED":return new T(s,n);case"PBSV_PID_MISMATCH":return new _(s,n);case"CONSENT_REQUIRED":return new R(s,n);case"INSUFFICIENT_CREDITS":return new w(s,n);case"FUNCTION_NOT_FOUND":return new A(s,n);case"FUNCTION_DISABLED":return new C(s,n);case"RESOURCE_EXHAUSTED":return new G(s,n);case"EXECUTION_FAILED":return new x(s,n);default:return new q(s,n)}},"mapUdfErrorResponse"),Ve=i(r=>{if(!m||!b||r.origin!==b||r.source!==m.parent||!r.data||typeof r.data!="object")return;let e=r.data;if(e.type===_e){typeof e.token=="string"&&e.token.length>0&&(v=e.token,f=le(e.token));return}if(e.type!==he||typeof e.request_id!="string")return;let t=F.get(e.request_id);t&&(clearTimeout(t.timer),F.delete(e.request_id),t.resolve(e.granted===!0?"granted":"denied"))},"onMessage"),We=i(()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`,"randomRequestId"),He=i(()=>{if(!f)return null;let r=Number(f);return Number.isSafeInteger(r)?r:null},"playbookIdForInvoke"),Je=i(async(r,e)=>{if(!m||!b)return"denied";let t=b,s=We();return new Promise(o=>{let n=setTimeout(()=>{F.delete(s),o("timeout")},De);F.set(s,{resolve:o,timer:n}),m?.parent.postMessage({type:fe,request_id:s,playbook_id:r,min_allowance:e},t)})},"requestConsent"),ze=i(r=>{!m||!b||m.parent.postMessage({type:be,function_name:r},b)},"requestAuthentication"),ue=i(async(r,e,t=!1)=>{let s=U();if(!s)throw new g;if(!f)throw new _("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let o=He();if(!o)throw new _("Invalid playbook id.",{code:"PBSV_PID_MISMATCH"});let n;try{n=await fetch(`${ce}/api/v1/service/invoke`,{method:"POST",headers:{Authorization:`Bearer ${s}`,"X-Pbsv":"1","Content-Type":"application/json"},body:JSON.stringify({playbook_id:o,function_name:r,parameters_json:JSON.stringify(e)})})}catch{throw new q("Network error while invoking UDF.",{code:"TRANSPORT"})}let a=await ge(n);if(n.ok)return Be(a);if(a.error?.code==="CONSENT_REQUIRED"&&!t){let c=qe(a),u=typeof c.playbook_id=="string"?c.playbook_id:f,h=typeof c.min_allowance_suggested=="number"?c.min_allowance_suggested:1,d=await Je(u,h);if(d==="granted")return ue(r,e,!0);throw d==="timeout"?new S:new E}throw pe(a,n.status)},"call"),Ke=i(async()=>{let r=U();if(!r)throw new g;if(!f)throw new _("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let e=new URL(`${ce}/api/v1/service/functions`);e.searchParams.set("playbook_id",f);let t=await fetch(e.toString(),{headers:{Authorization:`Bearer ${r}`,"X-Pbsv":"1"}}),s=await ge(t);if(!t.ok)throw pe(s,t.status);let o=s.functions;return Array.isArray(o)?o:[]},"list"),ae=i((r,e,t)=>{r.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))},"dispatchButtonEvent"),Xe=i(r=>{if(typeof r!="string")return r;let t=m?.document?.querySelector(r);if(t&&"appendChild"in t)return t;throw new Error(`UDF button target not found: ${r}`)},"resolveButtonTarget"),Qe=i((r,e)=>{if(!m)throw new Error("Playbook runtime is not installed.");let t=Xe(r),s=m.document.createElement("button"),o=e.label||e.functionName,n=e.loadingLabel||"Running...",a=e.disabledLabel||"Sign in to run";return s.type="button",s.className="alva-udf-button",s.textContent=k()?o:a,s.disabled=!1,s.setAttribute("data-function-name",e.functionName),k()||s.setAttribute("aria-disabled","true"),s.addEventListener("click",async()=>{if(!k()){ze(e.functionName);return}if(!s.disabled){s.disabled=!0,s.textContent=n,ae(s,"alva:udf-button:loading",{functionName:e.functionName});try{let c=await ue(e.functionName,e.params??{});ae(s,"alva:udf-button:result",{functionName:e.functionName,result:c})}catch(c){ae(s,"alva:udf-button:error",{functionName:e.functionName,error:c})}finally{s.disabled=!1,s.textContent=k()?o:a,k()||s.setAttribute("aria-disabled","true")}}}),t.appendChild(s),s},"renderButton"),ve={call:ue,list:Ke,getViewerToken:U,isAuthenticated:k,renderButton:Qe,UdfError:p,UdfAuthRequiredError:g,UdfTokenExpiredError:P,UdfTokenInvalidError:T,UdfPidMismatchError:_,UdfConsentRequiredError:R,UdfConsentDeniedError:E,UdfConsentTimeoutError:S,UdfInsufficientCredits:w,UdfFunctionNotFoundError:A,UdfFunctionDisabledError:C,UdfRateLimitedError:G,UdfExecutionError:x,UdfTransportError:q},de=i(r=>{let e=r??(typeof window>"u"?void 0:window);if(!e||ye)return;m=e,ye=!0,Le(e),e.addEventListener("message",Ve);let t=e,s=t.alva||{};t.alva={...s,udf:ve}},"installPlaybookRuntime");var l=class extends Error{static{i(this,"AlvaError")}code;status;constructor(e,t,s){super(t),this.name="AlvaError",this.code=e,this.status=s}};var N=class{constructor(e){this.client=e}client;static{i(this,"FsResource")}async read(e){let t=await this.client._request("GET","/api/v1/fs/read",{query:{path:e.path,offset:e.offset,size:e.size}});if(!(t instanceof ArrayBuffer))return t;try{let s=new TextDecoder("utf-8",{fatal:!0}).decode(t);try{return JSON.parse(s)}catch{return s}}catch{return t}}async write(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/fs/write",{body:{path:e.path,data:e.data,mkdir_parents:e.mkdir_parents}})}async rawWrite(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/fs/write",{query:{path:e.path,mkdir_parents:e.mkdir_parents},rawBody:e.body})}async stat(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/stat",{query:{path:e.path}})}async readdir(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/readdir",{query:{path:e.path,recursive:e.recursive}})}async mkdir(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/mkdir",{body:{path:e.path}})}async remove(e){this.client._requireAuth(),await this.client._request("DELETE","/api/v1/fs/remove",{query:{path:e.path,recursive:e.recursive}})}async rename(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/rename",{body:{old_path:e.old_path,new_path:e.new_path}})}async copy(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/copy",{body:{src_path:e.src_path,dst_path:e.dst_path}})}async symlink(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/symlink",{body:{target_path:e.target_path,link_path:e.link_path}})}async readlink(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/readlink",{query:{path:e.path}})}async chmod(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/chmod",{body:{path:e.path,mode:e.mode}})}async grant(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/grant",{body:{path:e.path,subject:e.subject,permission:e.permission}})}async revoke(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/revoke",{body:{path:e.path,subject:e.subject,permission:e.permission}})}};var j=class{constructor(e){this.client=e}client;static{i(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}})}};var D=class{constructor(e){this.client=e}client;static{i(this,"DeployResource")}async create(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/deploy/cronjob",{body:{name:e.name,path:e.path,cron_expression:e.cron_expression,args:e.args,push_notify:e.push_notify,max_heap_size_mb:e.max_heap_size_mb}})}async list(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/deploy/cronjobs",{query:{limit:e?.limit,cursor:e?.cursor}})}async get(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.id}`)}async update(e){this.client._requireAuth();let{id:t,...s}=e;return this.client._request("PATCH",`/api/v1/deploy/cronjob/${t}`,{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 getRunLogs(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.cronjob_id}/runs/${e.run_id}/logs`)}};var M=class{constructor(e){this.client=e}client;static{i(this,"ReleaseResource")}async feed(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/release/feed",{body:{name:e.name,version:e.version,cronjob_id:e.cronjob_id,view_json:e.view_json,description:e.description,changelog:e.changelog}})}async playbookDraft(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/draft/playbook",{body:{name:e.name,display_name:e.display_name,description:e.description,feeds:e.feeds,trading_symbols:e.trading_symbols,skill_id:e.skill_id,tags:e.tags}})}async playbook(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/release/playbook",{body:{name:e.name,version:e.version,feeds:e.feeds,changelog:e.changelog,readme_url:e.readme_url}})}};var O=class{constructor(e){this.client=e}client;static{i(this,"FeedResource")}async delete(e){if(this.client._requireAuth(),!Number.isInteger(e.id)||e.id<=0)throw new Error("feed id must be a positive integer");return this.client._request("DELETE",`/api/v1/feed/${encodeURIComponent(String(e.id))}`)}};var Pe=["public","private","paid"],L=class{constructor(e){this.client=e}client;static{i(this,"PlaybooksResource")}async trending(e={}){let t={};e.cursor&&(t.cursor=e.cursor),e.current&&(t.current=e.current),e.limit!==void 0&&(t.limit=e.limit),e.dir&&(t.dir=e.dir),e.sort&&(t.sort=e.sort),e.keyword&&(t.keyword=e.keyword),e.tags&&e.tags.length>0&&(t.tags=e.tags.join(","));let s=await this.client._request("GET","/api/v1/playbooks/trending",{query:t});return{playbooks:(s.playbooks??[]).map(Ye),has_next:s.has_next??!1}}async setVisibility(e){if(!Pe.includes(e.visibility))throw new l("INVALID_ARGUMENT",`Invalid visibility "${e.visibility}". Expected one of: ${Pe.join(", ")}.`,400);return this.client._requireAuth(),await this.client._request("POST",`/api/v1/playbook/${encodeURIComponent(e.name)}/visibility`,{body:{visibility:e.visibility}})}};function Ye(r){let e=r.creator?.name??"",t=r.name??"",s=e&&t?`${e}/${t}`:t;return{id:r.id===void 0?"":String(r.id),ref:s,username:e,name:t,display_name:r.display_name??"",description:r.description??"",tags:r.tags??[],follow_count:r.follow_count??0,url_path:e&&t?`/${e}/playbooks/${t}`:"",...r.readme?{readme:r.readme}:{},cursor:r.cursor??""}}i(Ye,"toAgentPlaybook");var $=class{constructor(e){this.client=e}client;static{i(this,"SecretsResource")}async create(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/secrets",{body:{name:e.name,value:e.value}})}async list(){return this.client._requireAuth(),this.client._request("GET","/api/v1/secrets")}async get(e){this.client._requireAuth();let t=encodeURIComponent(e.name);return this.client._request("GET",`/api/v1/secrets/${t}`)}async update(e){this.client._requireAuth();let t=encodeURIComponent(e.name);await this.client._request("PUT",`/api/v1/secrets/${t}`,{body:{value:e.value}})}async delete(e){this.client._requireAuth();let t=encodeURIComponent(e.name);await this.client._request("DELETE",`/api/v1/secrets/${t}`)}};var B=class{constructor(e){this.client=e}client;static{i(this,"SdkDocsResource")}async doc(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/sdk/doc",{query:{name:e.name}})}async partitions(){return this.client._requireAuth(),this.client._request("GET","/api/v1/sdk/partitions")}async partitionSummary(e){this.client._requireAuth();let t=encodeURIComponent(e.partition);return this.client._request("GET",`/api/v1/sdk/partitions/${t}/summary`)}};var Te=[{skill:"arrays-data-api-crypto-futures-data",file:"binance-perp-usdt-kline",method:"GET",path:"/api/v1/crypto/binance/perp/usdt/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"binance-spot-usdt-kline",method:"GET",path:"/api/v1/crypto/binance/spot/usdt/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"crypto-detail",method:"GET",path:"/api/v1/crypto/detail",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"fear-greed-index",method:"GET",path:"/api/v1/crypto/fear-greed-index",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"funding-rate",method:"GET",path:"/api/v1/crypto/funding-rate",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"hyperliquid-perp-usdc-kline",method:"GET",path:"/api/v1/crypto/hyperliquid/perp/usdc/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"hyperliquid-spot-usdc-kline",method:"GET",path:"/api/v1/crypto/hyperliquid/spot/usdc/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"list",method:"GET",path:"/api/v1/crypto/list",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"long-short-ratio",method:"GET",path:"/api/v1/crypto/long-short-ratio",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"crypto-market-cap",method:"GET",path:"/api/v1/crypto/market-cap",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"market-metrics",method:"GET",path:"/api/v1/crypto/market-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"open-interest",method:"GET",path:"/api/v1/crypto/open-interest",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"screener-metrics",method:"GET",path:"/api/v1/crypto/screener/metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"screener-metrics-timerange",method:"GET",path:"/api/v1/crypto/screener/metrics/timerange",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"trading-pair",method:"GET",path:"/api/v1/crypto/trading-pair",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"country-weightings",method:"GET",path:"/api/v1/etf/country-weightings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"holdings",method:"GET",path:"/api/v1/etf/holdings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"info",method:"GET",path:"/api/v1/etf/info",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"sector-weightings",method:"GET",path:"/api/v1/etf/sector-weightings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-commodity-historical",method:"GET",path:"/api/v1/macro/commodity/historical",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-commodity-real-time",method:"GET",path:"/api/v1/macro/commodity/real-time",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-commodity-symbol-list",method:"GET",path:"/api/v1/macro/commodity/symbols",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"economic-indicators",method:"GET",path:"/api/v1/macro/economic-indicators",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-forex-historical",method:"GET",path:"/api/v1/macro/forex/historical",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-forex-real-time",method:"GET",path:"/api/v1/macro/forex/real-time",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-forex-symbol-list",method:"GET",path:"/api/v1/macro/forex/symbols",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-index-historical",method:"GET",path:"/api/v1/macro/index/historical",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-index-real-time",method:"GET",path:"/api/v1/macro/index/real-time",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"rates",method:"GET",path:"/api/v1/macro/treasury-rates",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-balance-sheets",method:"GET",path:"/api/v1/stocks/company/balance-sheets",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-cashflow-statements",method:"GET",path:"/api/v1/stocks/company/cashflow-statements",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-detail",method:"GET",path:"/api/v1/stocks/company/detail",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-income-statements",method:"GET",path:"/api/v1/stocks/company/income-statements",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-kpi",method:"GET",path:"/api/v1/stocks/company/kpi",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"crowdfunding-offerings",method:"GET",path:"/api/v1/stocks/crowdfunding/offerings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"dividends",method:"GET",path:"/api/v1/stocks/dividends",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"earnings-calendar",method:"GET",path:"/api/v1/stocks/earnings-calendar",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"equity-offering",method:"GET",path:"/api/v1/stocks/equity-offering",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-metrics",file:"financial-metrics",method:"GET",path:"/api/v1/stocks/financial-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"fiscal-dates",method:"GET",path:"/api/v1/stocks/fiscal-dates",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"fiscal-dates-range",method:"GET",path:"/api/v1/stocks/fiscal-dates/range",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"ipo-calendar",method:"GET",path:"/api/v1/stocks/ipo-calendar",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"ipo-confirmed-calendar",method:"GET",path:"/api/v1/stocks/ipo-confirmed-calendar",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"stocks-kline",method:"GET",path:"/api/v1/stocks/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-metrics",file:"market-metrics",method:"GET",path:"/api/v1/stocks/market-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"mergers-acquisitions",method:"GET",path:"/api/v1/stocks/mergers-acquisitions",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"outstanding-shares",method:"GET",path:"/api/v1/stocks/outstanding-shares",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-metrics",file:"ratings",method:"GET",path:"/api/v1/stocks/ratings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"basic-info-screener",method:"GET",path:"/api/v1/stocks/screener/basic-info/{sub}",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"event-screener",method:"GET",path:"/api/v1/stocks/screener/events",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-financial-metrics",method:"GET",path:"/api/v1/stocks/screener/financial-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-financial-metrics-timerange",method:"GET",path:"/api/v1/stocks/screener/financial-metrics/timerange",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-technical-metrics",method:"GET",path:"/api/v1/stocks/screener/technical-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-technical-metrics-timerange",method:"GET",path:"/api/v1/stocks/screener/technical-metrics/timerange",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"sec-earnings-release",method:"GET",path:"/api/v1/stocks/sec-earnings-release",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"shares-float",method:"GET",path:"/api/v1/stocks/shares-float",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"splits",method:"GET",path:"/api/v1/stocks/splits",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-exchange-flow",file:"exchange-flows",method:"GET",path:"/api/v1/crypto/exchange-flows",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-company-crypto-holdings",file:"crypto-holdings",method:"GET",path:"/api/v1/crypto/holdings",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-inflow-cdd",method:"GET",path:"/api/v1/crypto/metrics/inflow-cdd",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-leverage-ratio",method:"GET",path:"/api/v1/crypto/metrics/leverage-ratio",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-miner-to-exchange",method:"GET",path:"/api/v1/crypto/metrics/miner-to-exchange",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-mvrv",method:"GET",path:"/api/v1/crypto/metrics/mvrv",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-nupl",method:"GET",path:"/api/v1/crypto/metrics/nupl",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-puell-multiple",method:"GET",path:"/api/v1/crypto/metrics/puell-multiple",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-realized-price",method:"GET",path:"/api/v1/crypto/metrics/realized-price",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-sopr",method:"GET",path:"/api/v1/crypto/metrics/sopr",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-ssr",method:"GET",path:"/api/v1/crypto/metrics/ssr",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-whale-ratio",method:"GET",path:"/api/v1/crypto/metrics/whale-ratio",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"crypto-supply",method:"GET",path:"/api/v1/crypto/supply",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-futures-data",file:"taker-buy-sell-volume",method:"GET",path:"/api/v1/crypto/taker-buy-sell-volume",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"unlock-events",method:"GET",path:"/api/v1/crypto/unlock-events",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-etf-fundamentals",file:"flow",method:"GET",path:"/api/v1/etf/flow",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-options",file:"contracts",method:"GET",path:"/api/v1/options/contracts",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-options",file:"kline",method:"GET",path:"/api/v1/options/kline",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-fundamentals",file:"company-executives",method:"GET",path:"/api/v1/stocks/company/executives",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"company-price-target-consensus",method:"GET",path:"/api/v1/stocks/company/price-target-consensus",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"company-price-target-news",method:"GET",path:"/api/v1/stocks/company/price-target-news",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"company-price-target-summary",method:"GET",path:"/api/v1/stocks/company/price-target-summary",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-ownership-and-flow",file:"congress-recent-trades",method:"GET",path:"/api/v1/stocks/congress/recent-trades",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-stock-metrics",file:"darkpool",method:"GET",path:"/api/v1/stocks/darkpool",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"estimates-guidance",method:"GET",path:"/api/v1/stocks/estimates-guidance",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-ownership-and-flow",file:"insider-transactions",method:"GET",path:"/api/v1/stocks/insider/transactions",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-ownership-and-flow",file:"institution-holder",method:"GET",path:"/api/v1/stocks/institution-holder",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"activity",method:"GET",path:"polymarket:/activity",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"book",method:"GET",path:"polymarket:/book",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"closed-positions",method:"GET",path:"polymarket:/closed-positions",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"events",method:"GET",path:"polymarket:/events",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"holders",method:"GET",path:"polymarket:/holders",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"markets",method:"GET",path:"polymarket:/markets",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"midpoint",method:"GET",path:"polymarket:/midpoint",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"oi",method:"GET",path:"polymarket:/oi",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"positions",method:"GET",path:"polymarket:/positions",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"price",method:"GET",path:"polymarket:/price",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"prices-history",method:"GET",path:"polymarket:/prices-history",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"public-search",method:"GET",path:"polymarket:/public-search",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"series",method:"GET",path:"polymarket:/series",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"sports",method:"GET",path:"polymarket:/sports",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"spread",method:"GET",path:"polymarket:/spread",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"tags",method:"GET",path:"polymarket:/tags",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"trades",method:"GET",path:"polymarket:/trades",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"value",method:"GET",path:"polymarket:/value",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-events",file:"earnings-transcript",method:"GET",path:"/api/v1/stocks/earnings-transcript",tier:"unstructured",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-news",file:"market-news",method:"GET",path:"/api/v1/stocks/market-news",tier:"unstructured",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-by-handle",method:"GET",path:"/api/v1/social-feeds/x/by-handle",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-by-url",method:"GET",path:"/api/v1/social-feeds/x/by-url",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-entities-handle",method:"GET",path:"/api/v1/social-feeds/x/entities/handle/{twitter_handle}",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-entities-handles",method:"GET",path:"/api/v1/social-feeds/x/entities/handles",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0}];function Re(r,e){return Te.find(t=>t.skill===r&&t.file===e)}i(Re,"getSkillEndpointMetadata");function me(r){return Te.filter(e=>e.skill===r)}i(me,"listSkillEndpointMetadata");var V=class{constructor(e){this.client=e}client;static{i(this,"DataSkillsResource")}async list(){return{skills:((await this.client._request("GET","/api/v1/skills",{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data??[]).map(t=>({...t,...Ee(t.name)}))}}async summary(e){let t=encodeURIComponent(e.name),o=(await this.client._request("GET",`/api/v1/skills/${t}`,{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data?.[0];if(!o)throw new Error(`empty skills summary response for "${e.name}"`);let n=me(e.name);return{...o,...Ee(e.name),...n.length>0?{endpoint_metadata:n}:{}}}async endpoint(e){let t=encodeURIComponent(e.name),o=(await this.client._request("GET",`/api/v1/skills/${t}`,{baseUrl:this.client.arraysBaseUrl,noAuth:!0,query:{endpoint:e.file}})).data?.[0];if(!o)throw new Error(`empty skills endpoint response for "${e.name}" file "${e.file}"`);let n=Re(e.name,e.file);return{...o,...n?{metadata:n}:{}}}};function Ee(r){let e=me(r);if(e.length===0)return{};let t={},s=0;for(let o of e)t[o.tier]=(t[o.tier]??0)+1,o.pro_required&&(s+=1);return{endpoint_tier_counts:t,metadata:{endpoint_count:e.length,endpoint_tier_counts:t,pro_count:s}}}i(Ee,"metadataSummaryForSkill");function Se(r){return{username:r.username,name:r.name,display_name:r.display_name,description:r.description,tags:r.tags,creator_uid:r.creator_uid,updated_at:r.updated_at}}i(Se,"normalizePlaybookSkillSummary");function we(r){let e=r.split("/");if(e.length!==2||!e[0]||!e[1])throw new l("INVALID_ARGUMENT",`playbook skill identifier must be "<user>/<name>", got "${r}"`,0);return{username:e[0],name:e[1]}}i(we,"parsePlaybookSkillId");var W=class{constructor(e){this.client=e}client;static{i(this,"PlaybookSkillsResource")}async list(e){let t={};return e?.tag&&(t.tag=e.tag),e?.username&&(t.username=e.username),{skills:((await this.client._request("GET","/api/v1/skills",{query:t})).data??[]).map(Se)}}async tags(){return{tags:(await this.client._request("GET","/api/v1/skills/tags")).data??[]}}async get(e){let{username:t,name:s}=we(e),o=encodeURIComponent(t),n=encodeURIComponent(s),c=(await this.client._request("GET",`/api/v1/skills/${o}/${n}`)).data?.[0];if(!c)throw new l("NOT_FOUND",`empty playbook skills get response for ${e}`,0);return{...Se(c),files:c.files??[]}}async file(e,t){let{username:s,name:o}=we(e),n=encodeURIComponent(s),a=encodeURIComponent(o),c=t.split("/").map(encodeURIComponent).join("/"),h=(await this.client._request("GET",`/api/v1/skills/${n}/${a}/files/${c}`)).data?.[0];if(!h)throw new l("NOT_FOUND",`empty playbook skills file response for ${e} path ${t}`,0);return h}};var H=class{constructor(e){this.client=e}client;static{i(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 J=class{constructor(e){this.client=e}client;static{i(this,"RemixResource")}async save(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/remix",{body:{child:e.child,parents:e.parents}})}};var z=class{constructor(e){this.client=e}client;static{i(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 K=class{constructor(e){this.client=e}client;static{i(this,"UserResource")}async me(){return this.client._requireAuth(),this.client._request("GET","/api/v1/me")}};var X=class{constructor(e){this.client=e}client;static{i(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 Q=class{constructor(e){this.client=e}client;static{i(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 Y=class{constructor(e){this.client=e}client;static{i(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 Z=class{constructor(e){this.client=e}client;static{i(this,"NotificationsResource")}async listPlaybook(e){this.client._requireAuth();let t=`/api/v1/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",t,{query:Ae(e)})}async listFeed(e){this.client._requireAuth();let t=`/api/v1/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",t,{query:Ae(e)})}};function Ae(r){let e={};return r.channel&&(e.channel=r.channel),r.status&&(e.status=r.status),r.since_time!==void 0&&r.since_time>0&&(e.since_time=String(r.since_time)),r.first!==void 0&&r.first>0&&(e.first=String(r.first)),r.cursor&&(e.cursor=r.cursor),e}i(Ae,"buildQuery");var ee=class{constructor(e){this.client=e}client;static{i(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 re=class{constructor(e){this.client=e}client;static{i(this,"SubscriptionsResource")}async subscribePlaybook(e){this.client._requireAuth();let t=`/api/v1/subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",t)}async unsubscribePlaybook(e){this.client._requireAuth();let t=`/api/v1/subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",t)}async subscribeFeed(e){this.client._requireAuth();let t=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",t)}async unsubscribeFeed(e){this.client._requireAuth();let t=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",t)}async list(e={}){this.client._requireAuth();let t={};return e.first!==void 0&&e.first>0&&(t.first=String(e.first)),e.cursor&&(t.cursor=e.cursor),this.client._request("GET","/api/v1/me/subscriptions",{query:t})}};var te=class{constructor(e){this.client=e}client;static{i(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:Ce(e)})}async unsubscribe(e){return this.client._requireAuth(),this.client._request("DELETE","/api/v1/channel/group-subscriptions",{jsonBody:Ce(e)})}};function Ce(r){return`{"session_id":${Ge(r.session_id)},"target_type":${JSON.stringify(r.target_type)},"target_id":${Ge(r.target_id)}}`}i(Ce,"mutationBody");function Ge(r){if(typeof r=="number"){if(!Number.isInteger(r)||r<=0||!Number.isSafeInteger(r))throw new l("INVALID_ARGUMENT","channel group subscription ids must be positive safe integers; pass large int64 ids as strings",0);return String(r)}if(!/^[1-9]\d*$/.test(r))throw new l("INVALID_ARGUMENT","channel group subscription ids must be positive integer strings",0);return r}i(Ge,"idLiteral");var ie=class{constructor(e){this.client=e}client;static{i(this,"FeedbackResource")}async submit(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/feedback",{body:e})}};var Ze="https://api-llm.prd.alva.ai",er="https://data-tools.prd.space.id",se=class{static{i(this,"AlvaClient")}baseUrl;arraysBaseUrl;viewer_token;pbsvToken;apiKey;gaClientId;gaSessionId;utmParams;_fs;_run;_deploy;_release;_feed;_playbooks;_secrets;_sdk;_dataSkills;_playbookSkills;_comments;_remix;_screenshot;_user;_trading;_portfolio;_arraysJwt;_notifications;_notificationPreferences;_subscriptions;_channelGroupSubscriptions;_feedback;constructor(e){this.baseUrl=e.baseUrl??Ze,this.arraysBaseUrl=e.arraysBaseUrl??er,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}get fs(){return this._fs??=new N(this)}get run(){return this._run??=new j(this)}get deploy(){return this._deploy??=new D(this)}get release(){return this._release??=new M(this)}get feed(){return this._feed??=new O(this)}get playbooks(){return this._playbooks??=new L(this)}get secrets(){return this._secrets??=new $(this)}get sdk(){return this._sdk??=new B(this)}get dataSkills(){return this._dataSkills??=new V(this)}get playbookSkills(){return this._playbookSkills??=new W(this)}get comments(){return this._comments??=new H(this)}get remix(){return this._remix??=new J(this)}get screenshot(){return this._screenshot??=new z(this)}get user(){return this._user??=new K(this)}get trading(){return this._trading??=new X(this)}get portfolio(){return this._portfolio??=new Q(this)}get arraysJwt(){return this._arraysJwt??=new Y(this)}get notifications(){return this._notifications??=new Z(this)}get notificationPreferences(){return this._notificationPreferences??=new ee(this)}get subscriptions(){return this._subscriptions??=new re(this)}get channelGroupSubscriptions(){return this._channelGroupSubscriptions??=new te(this)}get feedback(){return this._feedback??=new ie(this)}_requireAuth(){if(!this.pbsvToken&&!this.viewer_token&&!this.apiKey)throw new l("UNAUTHENTICATED","Authentication is required. Pass pbsvToken, viewer_token, or apiKey in the constructor.",401)}async _request(e,t,s){let n=`${s?.baseUrl??this.baseUrl}${t}`;if(s?.query){let d=new URLSearchParams;for(let[y,ne]of Object.entries(s.query))ne!=null&&d.set(y,String(ne));let oe=d.toString();oe&&(n+=`?${oe}`)}let a={};s?.noAuth||(this.pbsvToken?(a.Authorization=`Bearer ${this.pbsvToken}`,a["X-Pbsv"]="1"):this.viewer_token?a["x-Playbook-Viewer"]=this.viewer_token:this.apiKey&&(a["X-Alva-Api-Key"]=this.apiKey)),this.gaClientId&&(a["X-Alva-GA-Client-ID"]=this.gaClientId),this.gaSessionId&&(a["X-Alva-GA-Session-ID"]=this.gaSessionId),this.utmParams&&(a["X-Alva-UTM-Params"]=this.utmParams);let c;s?.rawBody!==void 0?(a["Content-Type"]="application/octet-stream",c=s.rawBody):s?.jsonBody!==void 0?(a["Content-Type"]="application/json",c=s.jsonBody):s?.body!==void 0&&(a["Content-Type"]="application/json",c=JSON.stringify(s.body));let u;try{u=await fetch(n,{method:e,headers:a,body:c})}catch(d){throw new l("NETWORK_ERROR",d instanceof Error?d.message:"Network request failed",0)}if(!u.ok){let d=await u.text().catch(()=>"");if((u.headers.get("content-type")??"").includes("application/json")&&d)try{let y=JSON.parse(d);if(y.error)throw new l(y.error.code??"UNKNOWN",y.error.message??`HTTP ${u.status}`,u.status)}catch(y){if(y instanceof l)throw y}throw new l("UNKNOWN",`HTTP ${u.status}: ${d.slice(0,200)}`,u.status)}if(u.status===204)return;let h=u.headers.get("content-type")??"";return h.includes("application/octet-stream")||h.includes("image/")?u.arrayBuffer():u.json()}};var rr="0.11.1";de();return je(tr);})();
|
|
1
|
+
"use strict";var AlvaToolkit=(()=>{var I=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var Fe=Object.prototype.hasOwnProperty;var i=(r,e)=>I(r,"name",{value:e,configurable:!0});var Ne=(r,e)=>{for(var t in e)I(r,t,{get:e[t],enumerable:!0})},je=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ie(e))!Fe.call(r,o)&&o!==t&&I(r,o,{get:()=>e[o],enumerable:!(s=xe(e,o))||s.enumerable});return r};var De=r=>je(I({},"__esModule",{value:!0}),r);var ir={};Ne(ir,{AlvaClient:()=>se,AlvaError:()=>l,PBSV_UPDATE_MESSAGE:()=>fe,UDF_AUTH_REQUIRED_MESSAGE:()=>ke,UDF_CONSENT_REQUEST_MESSAGE:()=>he,UDF_CONSENT_RESPONSE_MESSAGE:()=>be,UdfAuthRequiredError:()=>g,UdfConsentDeniedError:()=>E,UdfConsentRequiredError:()=>T,UdfConsentTimeoutError:()=>S,UdfError:()=>p,UdfExecutionError:()=>U,UdfFunctionDisabledError:()=>C,UdfFunctionNotFoundError:()=>A,UdfInsufficientCredits:()=>w,UdfPidMismatchError:()=>_,UdfRateLimitedError:()=>G,UdfTokenExpiredError:()=>P,UdfTokenInvalidError:()=>R,UdfTransportError:()=>q,VERSION:()=>tr,getViewerToken:()=>x,installPlaybookRuntime:()=>de,mapUdfErrorResponse:()=>pe,playbookIdFromToken:()=>le,udf:()=>Pe});var p=class extends Error{static{i(this,"UdfError")}code;metadata;status;constructor(e,{code:t,metadata:s={},status:o}){super(e),this.name=new.target.name,this.code=t,this.metadata=s,this.status=o}},g=class extends p{static{i(this,"UdfAuthRequiredError")}constructor(){super("Sign in to use this UDF.",{code:"AUTH_REQUIRED"})}},P=class extends p{static{i(this,"UdfTokenExpiredError")}},R=class extends p{static{i(this,"UdfTokenInvalidError")}},_=class extends p{static{i(this,"UdfPidMismatchError")}},T=class extends p{static{i(this,"UdfConsentRequiredError")}},E=class extends p{static{i(this,"UdfConsentDeniedError")}constructor(){super("UDF consent was denied.",{code:"CONSENT_DENIED"})}},S=class extends p{static{i(this,"UdfConsentTimeoutError")}constructor(){super("UDF consent timed out.",{code:"CONSENT_TIMEOUT"})}},w=class extends p{static{i(this,"UdfInsufficientCredits")}},A=class extends p{static{i(this,"UdfFunctionNotFoundError")}},C=class extends p{static{i(this,"UdfFunctionDisabledError")}},G=class extends p{static{i(this,"UdfRateLimitedError")}},U=class extends p{static{i(this,"UdfExecutionError")}},q=class extends p{static{i(this,"UdfTransportError")}},fe="alva:pbsv:update",he="alva:udf:consent-request",be="alva:udf:consent-response",ke="alva:udf:auth-required",ge="https://api-llm.prd.alva.ai",Me=300*1e3,v=null,b=null,ce=ge,f=null,m=null,_e=!1,F=new Map,Oe=i(r=>{let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return atob(t)},"decodeBase64Url"),le=i(r=>{if(!r)return null;let[,e]=r.split(".");if(!e)return null;try{let t=JSON.parse(Oe(e));if(typeof t.pid=="number")return String(t.pid);if(typeof t.pid=="string")return t.pid}catch{return null}return null},"playbookIdFromToken"),x=i(()=>v,"getViewerToken"),k=i(()=>!!x(),"isAuthenticated"),Le=i(r=>{let e=new URL(r.location.href);e.searchParams.delete("_pbsv"),r.history.replaceState(null,"",e.pathname+e.search+e.hash)},"stripPbsvFromUrl"),$e=i(r=>{let e=new URLSearchParams(r.location.search);v=e.get("_pbsv"),b=e.get("parent_origin"),ce=(e.get("api_origin")||ge).replace(/\/$/,""),f=le(v),v&&Le(r)},"parseBootParams"),qe=i(async r=>{try{return await r.json()}catch{return{}}},"safeJson"),Be=i(r=>{if(typeof r!="string")return r;try{return JSON.parse(r)}catch{return r}},"parseResultPayload"),Ve=i(r=>{let e=r;return{...e,result:Be(e.result)}},"normalizeInvokeResponse"),ve=i(r=>r.error?.metadata||r.details?.metadata||{},"errorMetadata"),pe=i((r,e)=>{let t=r.error?.code||"TRANSPORT",s=r.error?.message||t,o=ve(r),n={code:t,metadata:o,status:e};switch(t){case"PBSV_EXPIRED":return new P(s,n);case"PBSV_INVALID":case"UNAUTHENTICATED":return new R(s,n);case"PBSV_PID_MISMATCH":return new _(s,n);case"CONSENT_REQUIRED":return new T(s,n);case"INSUFFICIENT_CREDITS":return new w(s,n);case"FUNCTION_NOT_FOUND":return new A(s,n);case"FUNCTION_DISABLED":return new C(s,n);case"RESOURCE_EXHAUSTED":return new G(s,n);case"EXECUTION_FAILED":return new U(s,n);default:return new q(s,n)}},"mapUdfErrorResponse"),We=i(r=>{if(!m||!b||r.origin!==b||r.source!==m.parent||!r.data||typeof r.data!="object")return;let e=r.data;if(e.type===fe){typeof e.token=="string"&&e.token.length>0&&(v=e.token,f=le(e.token));return}if(e.type!==be||typeof e.request_id!="string")return;let t=F.get(e.request_id);t&&(clearTimeout(t.timer),F.delete(e.request_id),t.resolve(e.granted===!0?"granted":"denied"))},"onMessage"),He=i(()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`,"randomRequestId"),Je=i(()=>{if(!f)return null;let r=Number(f);return Number.isSafeInteger(r)?r:null},"playbookIdForInvoke"),ze=i(async(r,e)=>{if(!m||!b)return"denied";let t=b,s=He();return new Promise(o=>{let n=setTimeout(()=>{F.delete(s),o("timeout")},Me);F.set(s,{resolve:o,timer:n}),m?.parent.postMessage({type:he,request_id:s,playbook_id:r,min_allowance:e},t)})},"requestConsent"),Ke=i(r=>{!m||!b||m.parent.postMessage({type:ke,function_name:r},b)},"requestAuthentication"),ue=i(async(r,e,t=!1)=>{let s=x();if(!s)throw new g;if(!f)throw new _("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let o=Je();if(!o)throw new _("Invalid playbook id.",{code:"PBSV_PID_MISMATCH"});let n;try{n=await fetch(`${ce}/api/v1/service/invoke`,{method:"POST",headers:{Authorization:`Bearer ${s}`,"X-Pbsv":"1","Content-Type":"application/json"},body:JSON.stringify({playbook_id:o,function_name:r,parameters_json:JSON.stringify(e)})})}catch{throw new q("Network error while invoking UDF.",{code:"TRANSPORT"})}let a=await qe(n);if(n.ok)return Ve(a);if(a.error?.code==="CONSENT_REQUIRED"&&!t){let c=ve(a),u=typeof c.playbook_id=="string"?c.playbook_id:f,h=typeof c.min_allowance_suggested=="number"?c.min_allowance_suggested:1,d=await ze(u,h);if(d==="granted")return ue(r,e,!0);throw d==="timeout"?new S:new E}throw pe(a,n.status)},"call"),Xe=i(async()=>{let r=x();if(!r)throw new g;if(!f)throw new _("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let e=new URL(`${ce}/api/v1/service/functions`);e.searchParams.set("playbook_id",f);let t=await fetch(e.toString(),{headers:{Authorization:`Bearer ${r}`,"X-Pbsv":"1"}}),s=await qe(t);if(!t.ok)throw pe(s,t.status);let o=s.functions;return Array.isArray(o)?o:[]},"list"),ae=i((r,e,t)=>{r.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))},"dispatchButtonEvent"),Qe=i(r=>{if(typeof r!="string")return r;let t=m?.document?.querySelector(r);if(t&&"appendChild"in t)return t;throw new Error(`UDF button target not found: ${r}`)},"resolveButtonTarget"),Ye=i((r,e)=>{if(!m)throw new Error("Playbook runtime is not installed.");let t=Qe(r),s=m.document.createElement("button"),o=e.label||e.functionName,n=e.loadingLabel||"Running...",a=e.disabledLabel||"Sign in to run";return s.type="button",s.className="alva-udf-button",s.textContent=k()?o:a,s.disabled=!1,s.setAttribute("data-function-name",e.functionName),k()||s.setAttribute("aria-disabled","true"),s.addEventListener("click",async()=>{if(!k()){Ke(e.functionName);return}if(!s.disabled){s.disabled=!0,s.textContent=n,ae(s,"alva:udf-button:loading",{functionName:e.functionName});try{let c=await ue(e.functionName,e.params??{});ae(s,"alva:udf-button:result",{functionName:e.functionName,result:c})}catch(c){ae(s,"alva:udf-button:error",{functionName:e.functionName,error:c})}finally{s.disabled=!1,s.textContent=k()?o:a,k()||s.setAttribute("aria-disabled","true")}}}),t.appendChild(s),s},"renderButton"),Pe={call:ue,list:Xe,getViewerToken:x,isAuthenticated:k,renderButton:Ye,UdfError:p,UdfAuthRequiredError:g,UdfTokenExpiredError:P,UdfTokenInvalidError:R,UdfPidMismatchError:_,UdfConsentRequiredError:T,UdfConsentDeniedError:E,UdfConsentTimeoutError:S,UdfInsufficientCredits:w,UdfFunctionNotFoundError:A,UdfFunctionDisabledError:C,UdfRateLimitedError:G,UdfExecutionError:U,UdfTransportError:q},de=i(r=>{let e=r??(typeof window>"u"?void 0:window);if(!e||_e)return;m=e,_e=!0,$e(e),e.addEventListener("message",We);let t=e,s=t.alva||{};t.alva={...s,udf:Pe}},"installPlaybookRuntime");var l=class extends Error{static{i(this,"AlvaError")}code;status;constructor(e,t,s){super(t),this.name="AlvaError",this.code=e,this.status=s}};var N=class{constructor(e){this.client=e}client;static{i(this,"FsResource")}async read(e){let t=await this.client._request("GET","/api/v1/fs/read",{query:{path:e.path,offset:e.offset,size:e.size}});if(!(t instanceof ArrayBuffer))return t;try{let s=new TextDecoder("utf-8",{fatal:!0}).decode(t);try{return JSON.parse(s)}catch{return s}}catch{return t}}async write(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/fs/write",{body:{path:e.path,data:e.data,mkdir_parents:e.mkdir_parents}})}async rawWrite(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/fs/write",{query:{path:e.path,mkdir_parents:e.mkdir_parents},rawBody:e.body})}async stat(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/stat",{query:{path:e.path}})}async readdir(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/readdir",{query:{path:e.path,recursive:e.recursive}})}async mkdir(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/mkdir",{body:{path:e.path}})}async remove(e){this.client._requireAuth(),await this.client._request("DELETE","/api/v1/fs/remove",{query:{path:e.path,recursive:e.recursive}})}async rename(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/rename",{body:{old_path:e.old_path,new_path:e.new_path}})}async copy(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/copy",{body:{src_path:e.src_path,dst_path:e.dst_path}})}async symlink(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/symlink",{body:{target_path:e.target_path,link_path:e.link_path}})}async readlink(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/readlink",{query:{path:e.path}})}async chmod(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/chmod",{body:{path:e.path,mode:e.mode}})}async grant(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/grant",{body:{path:e.path,subject:e.subject,permission:e.permission}})}async revoke(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/revoke",{body:{path:e.path,subject:e.subject,permission:e.permission}})}};var j=class{constructor(e){this.client=e}client;static{i(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}})}};var D=class{constructor(e){this.client=e}client;static{i(this,"DeployResource")}async create(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/deploy/cronjob",{body:{name:e.name,path:e.path,cron_expression:e.cron_expression,args:e.args,push_notify:e.push_notify,max_heap_size_mb:e.max_heap_size_mb}})}async list(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/deploy/cronjobs",{query:{limit:e?.limit,cursor:e?.cursor}})}async get(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.id}`)}async update(e){this.client._requireAuth();let{id:t,...s}=e;return this.client._request("PATCH",`/api/v1/deploy/cronjob/${t}`,{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 getRunLogs(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.cronjob_id}/runs/${e.run_id}/logs`)}};var M=class{constructor(e){this.client=e}client;static{i(this,"ReleaseResource")}async feed(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/release/feed",{body:{name:e.name,version:e.version,cronjob_id:e.cronjob_id,view_json:e.view_json,description:e.description,changelog:e.changelog}})}async playbookDraft(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/draft/playbook",{body:{name:e.name,display_name:e.display_name,description:e.description,feeds:e.feeds,trading_symbols:e.trading_symbols,skill_id:e.skill_id,tags:e.tags}})}async playbook(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/release/playbook",{body:{name:e.name,version:e.version,feeds:e.feeds,changelog:e.changelog,readme_url:e.readme_url}})}};var O=class{constructor(e){this.client=e}client;static{i(this,"FeedResource")}async stop(e){this.client._requireAuth();let t=me(e.id);return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(t))}/stop`)}async resume(e){this.client._requireAuth();let t=me(e.id);return this.client._request("POST",`/api/v1/feed/${encodeURIComponent(String(t))}/resume`)}async delete(e){this.client._requireAuth();let t=me(e.id);return this.client._request("DELETE",`/api/v1/feed/${encodeURIComponent(String(t))}`)}};function me(r){if(!Number.isInteger(r)||r<=0)throw new Error("feed id must be a positive integer");return r}i(me,"requireFeedID");var Re=["public","private","paid"],L=class{constructor(e){this.client=e}client;static{i(this,"PlaybooksResource")}async trending(e={}){let t={};e.cursor&&(t.cursor=e.cursor),e.current&&(t.current=e.current),e.limit!==void 0&&(t.limit=e.limit),e.dir&&(t.dir=e.dir),e.sort&&(t.sort=e.sort),e.keyword&&(t.keyword=e.keyword),e.tags&&e.tags.length>0&&(t.tags=e.tags.join(","));let s=await this.client._request("GET","/api/v1/playbooks/trending",{query:t});return{playbooks:(s.playbooks??[]).map(Ze),has_next:s.has_next??!1}}async setVisibility(e){if(!Re.includes(e.visibility))throw new l("INVALID_ARGUMENT",`Invalid visibility "${e.visibility}". Expected one of: ${Re.join(", ")}.`,400);return this.client._requireAuth(),await this.client._request("POST",`/api/v1/playbook/${encodeURIComponent(e.name)}/visibility`,{body:{visibility:e.visibility}})}};function Ze(r){let e=r.creator?.name??"",t=r.name??"",s=e&&t?`${e}/${t}`:t;return{id:r.id===void 0?"":String(r.id),ref:s,username:e,name:t,display_name:r.display_name??"",description:r.description??"",tags:r.tags??[],follow_count:r.follow_count??0,url_path:e&&t?`/${e}/playbooks/${t}`:"",...r.readme?{readme:r.readme}:{},cursor:r.cursor??""}}i(Ze,"toAgentPlaybook");var $=class{constructor(e){this.client=e}client;static{i(this,"SecretsResource")}async create(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/secrets",{body:{name:e.name,value:e.value}})}async list(){return this.client._requireAuth(),this.client._request("GET","/api/v1/secrets")}async get(e){this.client._requireAuth();let t=encodeURIComponent(e.name);return this.client._request("GET",`/api/v1/secrets/${t}`)}async update(e){this.client._requireAuth();let t=encodeURIComponent(e.name);await this.client._request("PUT",`/api/v1/secrets/${t}`,{body:{value:e.value}})}async delete(e){this.client._requireAuth();let t=encodeURIComponent(e.name);await this.client._request("DELETE",`/api/v1/secrets/${t}`)}};var B=class{constructor(e){this.client=e}client;static{i(this,"SdkDocsResource")}async doc(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/sdk/doc",{query:{name:e.name}})}async partitions(){return this.client._requireAuth(),this.client._request("GET","/api/v1/sdk/partitions")}async partitionSummary(e){this.client._requireAuth();let t=encodeURIComponent(e.partition);return this.client._request("GET",`/api/v1/sdk/partitions/${t}/summary`)}};var Te=[{skill:"arrays-data-api-crypto-futures-data",file:"binance-perp-usdt-kline",method:"GET",path:"/api/v1/crypto/binance/perp/usdt/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"binance-spot-usdt-kline",method:"GET",path:"/api/v1/crypto/binance/spot/usdt/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"crypto-detail",method:"GET",path:"/api/v1/crypto/detail",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"fear-greed-index",method:"GET",path:"/api/v1/crypto/fear-greed-index",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"funding-rate",method:"GET",path:"/api/v1/crypto/funding-rate",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"hyperliquid-perp-usdc-kline",method:"GET",path:"/api/v1/crypto/hyperliquid/perp/usdc/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"hyperliquid-spot-usdc-kline",method:"GET",path:"/api/v1/crypto/hyperliquid/spot/usdc/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"list",method:"GET",path:"/api/v1/crypto/list",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"long-short-ratio",method:"GET",path:"/api/v1/crypto/long-short-ratio",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"crypto-market-cap",method:"GET",path:"/api/v1/crypto/market-cap",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"market-metrics",method:"GET",path:"/api/v1/crypto/market-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-futures-data",file:"open-interest",method:"GET",path:"/api/v1/crypto/open-interest",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"screener-metrics",method:"GET",path:"/api/v1/crypto/screener/metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"screener-metrics-timerange",method:"GET",path:"/api/v1/crypto/screener/metrics/timerange",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"trading-pair",method:"GET",path:"/api/v1/crypto/trading-pair",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"country-weightings",method:"GET",path:"/api/v1/etf/country-weightings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"holdings",method:"GET",path:"/api/v1/etf/holdings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"info",method:"GET",path:"/api/v1/etf/info",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-etf-fundamentals",file:"sector-weightings",method:"GET",path:"/api/v1/etf/sector-weightings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-commodity-historical",method:"GET",path:"/api/v1/macro/commodity/historical",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-commodity-real-time",method:"GET",path:"/api/v1/macro/commodity/real-time",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-commodity-symbol-list",method:"GET",path:"/api/v1/macro/commodity/symbols",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"economic-indicators",method:"GET",path:"/api/v1/macro/economic-indicators",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-forex-historical",method:"GET",path:"/api/v1/macro/forex/historical",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-forex-real-time",method:"GET",path:"/api/v1/macro/forex/real-time",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-forex-symbol-list",method:"GET",path:"/api/v1/macro/forex/symbols",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-index-historical",method:"GET",path:"/api/v1/macro/index/historical",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"macro-index-real-time",method:"GET",path:"/api/v1/macro/index/real-time",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-macro-and-economics",file:"rates",method:"GET",path:"/api/v1/macro/treasury-rates",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-balance-sheets",method:"GET",path:"/api/v1/stocks/company/balance-sheets",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-cashflow-statements",method:"GET",path:"/api/v1/stocks/company/cashflow-statements",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-detail",method:"GET",path:"/api/v1/stocks/company/detail",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-income-statements",method:"GET",path:"/api/v1/stocks/company/income-statements",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"company-kpi",method:"GET",path:"/api/v1/stocks/company/kpi",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"crowdfunding-offerings",method:"GET",path:"/api/v1/stocks/crowdfunding/offerings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"dividends",method:"GET",path:"/api/v1/stocks/dividends",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"earnings-calendar",method:"GET",path:"/api/v1/stocks/earnings-calendar",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"equity-offering",method:"GET",path:"/api/v1/stocks/equity-offering",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-metrics",file:"financial-metrics",method:"GET",path:"/api/v1/stocks/financial-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"fiscal-dates",method:"GET",path:"/api/v1/stocks/fiscal-dates",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"fiscal-dates-range",method:"GET",path:"/api/v1/stocks/fiscal-dates/range",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"ipo-calendar",method:"GET",path:"/api/v1/stocks/ipo-calendar",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"ipo-confirmed-calendar",method:"GET",path:"/api/v1/stocks/ipo-confirmed-calendar",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"stocks-kline",method:"GET",path:"/api/v1/stocks/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-metrics",file:"market-metrics",method:"GET",path:"/api/v1/stocks/market-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"mergers-acquisitions",method:"GET",path:"/api/v1/stocks/mergers-acquisitions",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"outstanding-shares",method:"GET",path:"/api/v1/stocks/outstanding-shares",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-metrics",file:"ratings",method:"GET",path:"/api/v1/stocks/ratings",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"basic-info-screener",method:"GET",path:"/api/v1/stocks/screener/basic-info/{sub}",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"event-screener",method:"GET",path:"/api/v1/stocks/screener/events",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-financial-metrics",method:"GET",path:"/api/v1/stocks/screener/financial-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-financial-metrics-timerange",method:"GET",path:"/api/v1/stocks/screener/financial-metrics/timerange",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-technical-metrics",method:"GET",path:"/api/v1/stocks/screener/technical-metrics",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-stock-screener",file:"screener-technical-metrics-timerange",method:"GET",path:"/api/v1/stocks/screener/technical-metrics/timerange",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"sec-earnings-release",method:"GET",path:"/api/v1/stocks/sec-earnings-release",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-fundamentals",file:"shares-float",method:"GET",path:"/api/v1/stocks/shares-float",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-equity-events",file:"splits",method:"GET",path:"/api/v1/stocks/splits",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-crypto-exchange-flow",file:"exchange-flows",method:"GET",path:"/api/v1/crypto/exchange-flows",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-company-crypto-holdings",file:"crypto-holdings",method:"GET",path:"/api/v1/crypto/holdings",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-inflow-cdd",method:"GET",path:"/api/v1/crypto/metrics/inflow-cdd",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-leverage-ratio",method:"GET",path:"/api/v1/crypto/metrics/leverage-ratio",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-miner-to-exchange",method:"GET",path:"/api/v1/crypto/metrics/miner-to-exchange",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-mvrv",method:"GET",path:"/api/v1/crypto/metrics/mvrv",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-nupl",method:"GET",path:"/api/v1/crypto/metrics/nupl",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-puell-multiple",method:"GET",path:"/api/v1/crypto/metrics/puell-multiple",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-realized-price",method:"GET",path:"/api/v1/crypto/metrics/realized-price",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-sopr",method:"GET",path:"/api/v1/crypto/metrics/sopr",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-ssr",method:"GET",path:"/api/v1/crypto/metrics/ssr",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"metrics-whale-ratio",method:"GET",path:"/api/v1/crypto/metrics/whale-ratio",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"crypto-supply",method:"GET",path:"/api/v1/crypto/supply",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-futures-data",file:"taker-buy-sell-volume",method:"GET",path:"/api/v1/crypto/taker-buy-sell-volume",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-crypto-metrics-and-screener",file:"unlock-events",method:"GET",path:"/api/v1/crypto/unlock-events",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-etf-fundamentals",file:"flow",method:"GET",path:"/api/v1/etf/flow",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-options",file:"contracts",method:"GET",path:"/api/v1/options/contracts",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-options",file:"kline",method:"GET",path:"/api/v1/options/kline",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-fundamentals",file:"company-executives",method:"GET",path:"/api/v1/stocks/company/executives",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"company-price-target-consensus",method:"GET",path:"/api/v1/stocks/company/price-target-consensus",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"company-price-target-news",method:"GET",path:"/api/v1/stocks/company/price-target-news",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"company-price-target-summary",method:"GET",path:"/api/v1/stocks/company/price-target-summary",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-ownership-and-flow",file:"congress-recent-trades",method:"GET",path:"/api/v1/stocks/congress/recent-trades",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-stock-metrics",file:"darkpool",method:"GET",path:"/api/v1/stocks/darkpool",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-estimates-and-targets",file:"estimates-guidance",method:"GET",path:"/api/v1/stocks/estimates-guidance",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-ownership-and-flow",file:"insider-transactions",method:"GET",path:"/api/v1/stocks/insider/transactions",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-ownership-and-flow",file:"institution-holder",method:"GET",path:"/api/v1/stocks/institution-holder",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"activity",method:"GET",path:"polymarket:/activity",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"book",method:"GET",path:"polymarket:/book",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"closed-positions",method:"GET",path:"polymarket:/closed-positions",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"events",method:"GET",path:"polymarket:/events",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"holders",method:"GET",path:"polymarket:/holders",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"markets",method:"GET",path:"polymarket:/markets",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"midpoint",method:"GET",path:"polymarket:/midpoint",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"oi",method:"GET",path:"polymarket:/oi",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"positions",method:"GET",path:"polymarket:/positions",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"price",method:"GET",path:"polymarket:/price",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"prices-history",method:"GET",path:"polymarket:/prices-history",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"public-search",method:"GET",path:"polymarket:/public-search",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"series",method:"GET",path:"polymarket:/series",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"sports",method:"GET",path:"polymarket:/sports",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"spread",method:"GET",path:"polymarket:/spread",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"tags",method:"GET",path:"polymarket:/tags",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"trades",method:"GET",path:"polymarket:/trades",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-polymarket",file:"value",method:"GET",path:"polymarket:/value",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-equity-events",file:"earnings-transcript",method:"GET",path:"/api/v1/stocks/earnings-transcript",tier:"unstructured",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-news",file:"market-news",method:"GET",path:"/api/v1/stocks/market-news",tier:"unstructured",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-by-handle",method:"GET",path:"/api/v1/social-feeds/x/by-handle",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-by-url",method:"GET",path:"/api/v1/social-feeds/x/by-url",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-entities-handle",method:"GET",path:"/api/v1/social-feeds/x/entities/handle/{twitter_handle}",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0},{skill:"arrays-data-api-social-feeds",file:"x-entities-handles",method:"GET",path:"/api/v1/social-feeds/x/entities/handles",tier:"alternative",required_subscription_tier:"pro",access:"pro_only",pro_required:!0}];function Ee(r,e){return Te.find(t=>t.skill===r&&t.file===e)}i(Ee,"getSkillEndpointMetadata");function ye(r){return Te.filter(e=>e.skill===r)}i(ye,"listSkillEndpointMetadata");var V=class{constructor(e){this.client=e}client;static{i(this,"DataSkillsResource")}async list(){return{skills:((await this.client._request("GET","/api/v1/skills",{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data??[]).map(t=>({...t,...Se(t.name)}))}}async summary(e){let t=encodeURIComponent(e.name),o=(await this.client._request("GET",`/api/v1/skills/${t}`,{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data?.[0];if(!o)throw new Error(`empty skills summary response for "${e.name}"`);let n=ye(e.name);return{...o,...Se(e.name),...n.length>0?{endpoint_metadata:n}:{}}}async endpoint(e){let t=encodeURIComponent(e.name),o=(await this.client._request("GET",`/api/v1/skills/${t}`,{baseUrl:this.client.arraysBaseUrl,noAuth:!0,query:{endpoint:e.file}})).data?.[0];if(!o)throw new Error(`empty skills endpoint response for "${e.name}" file "${e.file}"`);let n=Ee(e.name,e.file);return{...o,...n?{metadata:n}:{}}}};function Se(r){let e=ye(r);if(e.length===0)return{};let t={},s=0;for(let o of e)t[o.tier]=(t[o.tier]??0)+1,o.pro_required&&(s+=1);return{endpoint_tier_counts:t,metadata:{endpoint_count:e.length,endpoint_tier_counts:t,pro_count:s}}}i(Se,"metadataSummaryForSkill");function we(r){return{username:r.username,name:r.name,display_name:r.display_name,description:r.description,tags:r.tags,creator_uid:r.creator_uid,updated_at:r.updated_at}}i(we,"normalizePlaybookSkillSummary");function Ae(r){let e=r.split("/");if(e.length!==2||!e[0]||!e[1])throw new l("INVALID_ARGUMENT",`playbook skill identifier must be "<user>/<name>", got "${r}"`,0);return{username:e[0],name:e[1]}}i(Ae,"parsePlaybookSkillId");var W=class{constructor(e){this.client=e}client;static{i(this,"PlaybookSkillsResource")}async list(e){let t={};return e?.tag&&(t.tag=e.tag),e?.username&&(t.username=e.username),{skills:((await this.client._request("GET","/api/v1/skills",{query:t})).data??[]).map(we)}}async tags(){return{tags:(await this.client._request("GET","/api/v1/skills/tags")).data??[]}}async get(e){let{username:t,name:s}=Ae(e),o=encodeURIComponent(t),n=encodeURIComponent(s),c=(await this.client._request("GET",`/api/v1/skills/${o}/${n}`)).data?.[0];if(!c)throw new l("NOT_FOUND",`empty playbook skills get response for ${e}`,0);return{...we(c),files:c.files??[]}}async file(e,t){let{username:s,name:o}=Ae(e),n=encodeURIComponent(s),a=encodeURIComponent(o),c=t.split("/").map(encodeURIComponent).join("/"),h=(await this.client._request("GET",`/api/v1/skills/${n}/${a}/files/${c}`)).data?.[0];if(!h)throw new l("NOT_FOUND",`empty playbook skills file response for ${e} path ${t}`,0);return h}};var H=class{constructor(e){this.client=e}client;static{i(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 J=class{constructor(e){this.client=e}client;static{i(this,"RemixResource")}async save(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/remix",{body:{child:e.child,parents:e.parents}})}};var z=class{constructor(e){this.client=e}client;static{i(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 K=class{constructor(e){this.client=e}client;static{i(this,"UserResource")}async me(){return this.client._requireAuth(),this.client._request("GET","/api/v1/me")}};var X=class{constructor(e){this.client=e}client;static{i(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 Q=class{constructor(e){this.client=e}client;static{i(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 Y=class{constructor(e){this.client=e}client;static{i(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 Z=class{constructor(e){this.client=e}client;static{i(this,"NotificationsResource")}async listPlaybook(e){this.client._requireAuth();let t=`/api/v1/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",t,{query:Ce(e)})}async listFeed(e){this.client._requireAuth();let t=`/api/v1/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",t,{query:Ce(e)})}};function Ce(r){let e={};return r.channel&&(e.channel=r.channel),r.status&&(e.status=r.status),r.since_time!==void 0&&r.since_time>0&&(e.since_time=String(r.since_time)),r.first!==void 0&&r.first>0&&(e.first=String(r.first)),r.cursor&&(e.cursor=r.cursor),e}i(Ce,"buildQuery");var ee=class{constructor(e){this.client=e}client;static{i(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 re=class{constructor(e){this.client=e}client;static{i(this,"SubscriptionsResource")}async subscribePlaybook(e){this.client._requireAuth();let t=`/api/v1/subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",t)}async unsubscribePlaybook(e){this.client._requireAuth();let t=`/api/v1/subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",t)}async subscribeFeed(e){this.client._requireAuth();let t=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",t)}async unsubscribeFeed(e){this.client._requireAuth();let t=`/api/v1/subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",t)}async list(e={}){this.client._requireAuth();let t={};return e.first!==void 0&&e.first>0&&(t.first=String(e.first)),e.cursor&&(t.cursor=e.cursor),this.client._request("GET","/api/v1/me/subscriptions",{query:t})}};var te=class{constructor(e){this.client=e}client;static{i(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:Ge(e)})}async unsubscribe(e){return this.client._requireAuth(),this.client._request("DELETE","/api/v1/channel/group-subscriptions",{jsonBody:Ge(e)})}};function Ge(r){return`{"session_id":${Ue(r.session_id)},"target_type":${JSON.stringify(r.target_type)},"target_id":${Ue(r.target_id)}}`}i(Ge,"mutationBody");function Ue(r){if(typeof r=="number"){if(!Number.isInteger(r)||r<=0||!Number.isSafeInteger(r))throw new l("INVALID_ARGUMENT","channel group subscription ids must be positive safe integers; pass large int64 ids as strings",0);return String(r)}if(!/^[1-9]\d*$/.test(r))throw new l("INVALID_ARGUMENT","channel group subscription ids must be positive integer strings",0);return r}i(Ue,"idLiteral");var ie=class{constructor(e){this.client=e}client;static{i(this,"FeedbackResource")}async submit(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/feedback",{body:e})}};var er="https://api-llm.prd.alva.ai",rr="https://data-tools.prd.space.id",se=class{static{i(this,"AlvaClient")}baseUrl;arraysBaseUrl;viewer_token;pbsvToken;apiKey;gaClientId;gaSessionId;utmParams;_fs;_run;_deploy;_release;_feed;_playbooks;_secrets;_sdk;_dataSkills;_playbookSkills;_comments;_remix;_screenshot;_user;_trading;_portfolio;_arraysJwt;_notifications;_notificationPreferences;_subscriptions;_channelGroupSubscriptions;_feedback;constructor(e){this.baseUrl=e.baseUrl??er,this.arraysBaseUrl=e.arraysBaseUrl??rr,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}get fs(){return this._fs??=new N(this)}get run(){return this._run??=new j(this)}get deploy(){return this._deploy??=new D(this)}get release(){return this._release??=new M(this)}get feed(){return this._feed??=new O(this)}get playbooks(){return this._playbooks??=new L(this)}get secrets(){return this._secrets??=new $(this)}get sdk(){return this._sdk??=new B(this)}get dataSkills(){return this._dataSkills??=new V(this)}get playbookSkills(){return this._playbookSkills??=new W(this)}get comments(){return this._comments??=new H(this)}get remix(){return this._remix??=new J(this)}get screenshot(){return this._screenshot??=new z(this)}get user(){return this._user??=new K(this)}get trading(){return this._trading??=new X(this)}get portfolio(){return this._portfolio??=new Q(this)}get arraysJwt(){return this._arraysJwt??=new Y(this)}get notifications(){return this._notifications??=new Z(this)}get notificationPreferences(){return this._notificationPreferences??=new ee(this)}get subscriptions(){return this._subscriptions??=new re(this)}get channelGroupSubscriptions(){return this._channelGroupSubscriptions??=new te(this)}get feedback(){return this._feedback??=new ie(this)}_requireAuth(){if(!this.pbsvToken&&!this.viewer_token&&!this.apiKey)throw new l("UNAUTHENTICATED","Authentication is required. Pass pbsvToken, viewer_token, or apiKey in the constructor.",401)}async _request(e,t,s){let n=`${s?.baseUrl??this.baseUrl}${t}`;if(s?.query){let d=new URLSearchParams;for(let[y,ne]of Object.entries(s.query))ne!=null&&d.set(y,String(ne));let oe=d.toString();oe&&(n+=`?${oe}`)}let a={};s?.noAuth||(this.pbsvToken?(a.Authorization=`Bearer ${this.pbsvToken}`,a["X-Pbsv"]="1"):this.viewer_token?a["x-Playbook-Viewer"]=this.viewer_token:this.apiKey&&(a["X-Alva-Api-Key"]=this.apiKey)),this.gaClientId&&(a["X-Alva-GA-Client-ID"]=this.gaClientId),this.gaSessionId&&(a["X-Alva-GA-Session-ID"]=this.gaSessionId),this.utmParams&&(a["X-Alva-UTM-Params"]=this.utmParams);let c;s?.rawBody!==void 0?(a["Content-Type"]="application/octet-stream",c=s.rawBody):s?.jsonBody!==void 0?(a["Content-Type"]="application/json",c=s.jsonBody):s?.body!==void 0&&(a["Content-Type"]="application/json",c=JSON.stringify(s.body));let u;try{u=await fetch(n,{method:e,headers:a,body:c})}catch(d){throw new l("NETWORK_ERROR",d instanceof Error?d.message:"Network request failed",0)}if(!u.ok){let d=await u.text().catch(()=>"");if((u.headers.get("content-type")??"").includes("application/json")&&d)try{let y=JSON.parse(d);if(y.error)throw new l(y.error.code??"UNKNOWN",y.error.message??`HTTP ${u.status}`,u.status)}catch(y){if(y instanceof l)throw y}throw new l("UNKNOWN",`HTTP ${u.status}: ${d.slice(0,200)}`,u.status)}if(u.status===204)return;let h=u.headers.get("content-type")??"";return h.includes("application/octet-stream")||h.includes("image/")?u.arrayBuffer():u.json()}};var tr="0.11.2";de();return De(ir);})();
|
|
2
2
|
//# sourceMappingURL=browser.global.js.map
|