@alva-ai/toolkit 0.9.3 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.js +85 -11
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +73 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -2
- package/dist/index.d.ts +39 -2
- package/dist/index.js +72 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -199,7 +199,8 @@ UDF calls.
|
|
|
199
199
|
<script src="https://unpkg.com/@alva-ai/toolkit/dist/browser.global.js"></script>
|
|
200
200
|
<script>
|
|
201
201
|
(async () => {
|
|
202
|
-
const
|
|
202
|
+
const response = await window.alva.udf.call('analyze', { ticker: 'AAPL' });
|
|
203
|
+
console.log(response.result, response.credits_charged_consumer);
|
|
203
204
|
const functions = await window.alva.udf.list();
|
|
204
205
|
})();
|
|
205
206
|
</script>
|
|
@@ -219,7 +220,7 @@ result, and error states.
|
|
|
219
220
|
});
|
|
220
221
|
|
|
221
222
|
button.addEventListener('alva:udf-button:result', (event) => {
|
|
222
|
-
console.log(event.detail.result);
|
|
223
|
+
console.log(event.detail.result.result);
|
|
223
224
|
});
|
|
224
225
|
</script>
|
|
225
226
|
```
|
|
@@ -230,7 +231,7 @@ For module users, the same runtime is available from the package root:
|
|
|
230
231
|
import { installPlaybookRuntime, udf } from '@alva-ai/toolkit';
|
|
231
232
|
|
|
232
233
|
installPlaybookRuntime();
|
|
233
|
-
const
|
|
234
|
+
const response = await udf.call('analyze', { ticker: 'AAPL' });
|
|
234
235
|
```
|
|
235
236
|
|
|
236
237
|
## API Reference
|
package/dist/browser.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var AlvaToolkit=(()=>{var U=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var i=(r,e)=>U(r,"name",{value:e,configurable:!0});var Ae=(r,e)=>{for(var t in e)U(r,t,{get:e[t],enumerable:!0})},Ge=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of we(e))!Ce.call(r,o)&&o!==t&&U(r,o,{get:()=>e[o],enumerable:!(s=Se(e,o))||s.enumerable});return r};var xe=r=>Ge(U({},"__esModule",{value:!0}),r);var Ke={};Ae(Ke,{AlvaClient:()=>te,AlvaError:()=>p,PBSV_UPDATE_MESSAGE:()=>me,UDF_CONSENT_REQUEST_MESSAGE:()=>_e,UDF_CONSENT_RESPONSE_MESSAGE:()=>ye,UdfAuthRequiredError:()=>k,UdfConsentDeniedError:()=>R,UdfConsentRequiredError:()=>T,UdfConsentTimeoutError:()=>E,UdfError:()=>l,UdfExecutionError:()=>G,UdfFunctionDisabledError:()=>C,UdfFunctionNotFoundError:()=>w,UdfInsufficientCredits:()=>S,UdfPidMismatchError:()=>_,UdfRateLimitedError:()=>A,UdfTokenExpiredError:()=>v,UdfTokenInvalidError:()=>P,UdfTransportError:()=>g,VERSION:()=>Je,getViewerToken:()=>b,installPlaybookRuntime:()=>pe,mapUdfErrorResponse:()=>ce,playbookIdFromToken:()=>ae,udf:()=>ke});var l=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}},k=class extends l{static{i(this,"UdfAuthRequiredError")}constructor(){super("Sign in to use this UDF.",{code:"AUTH_REQUIRED"})}},v=class extends l{static{i(this,"UdfTokenExpiredError")}},P=class extends l{static{i(this,"UdfTokenInvalidError")}},_=class extends l{static{i(this,"UdfPidMismatchError")}},T=class extends l{static{i(this,"UdfConsentRequiredError")}},R=class extends l{static{i(this,"UdfConsentDeniedError")}constructor(){super("UDF consent was denied.",{code:"CONSENT_DENIED"})}},E=class extends l{static{i(this,"UdfConsentTimeoutError")}constructor(){super("UDF consent timed out.",{code:"CONSENT_TIMEOUT"})}},S=class extends l{static{i(this,"UdfInsufficientCredits")}},w=class extends l{static{i(this,"UdfFunctionNotFoundError")}},C=class extends l{static{i(this,"UdfFunctionDisabledError")}},A=class extends l{static{i(this,"UdfRateLimitedError")}},G=class extends l{static{i(this,"UdfExecutionError")}},g=class extends l{static{i(this,"UdfTransportError")}},me="alva:pbsv:update",_e="alva:udf:consent-request",ye="alva:udf:consent-response",fe="https://api-llm.prd.alva.ai",Ue=300*1e3,q=null,x=null,ne=fe,y=null,f=null,de=!1,I=new Map,Ie=i(r=>{let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return atob(t)},"decodeBase64Url"),ae=i(r=>{if(!r)return null;let[,e]=r.split(".");if(!e)return null;try{let t=JSON.parse(Ie(e));if(typeof t.pid=="number")return String(t.pid);if(typeof t.pid=="string")return t.pid}catch{return null}return null},"playbookIdFromToken"),b=i(()=>q,"getViewerToken"),Ne=i(r=>{let e=new URL(r.location.href);e.searchParams.delete("_pbsv"),r.history.replaceState(null,"",e.pathname+e.search+e.hash)},"stripPbsvFromUrl"),Fe=i(r=>{let e=new URLSearchParams(r.location.search);q=e.get("_pbsv"),x=e.get("parent_origin"),ne=(e.get("api_origin")||fe).replace(/\/$/,""),y=ae(q),q&&Ne(r)},"parseBootParams"),he=i(async r=>{try{return await r.json()}catch{return{}}},"safeJson"),be=i(r=>r.error?.metadata||r.details?.metadata||{},"errorMetadata"),ce=i((r,e)=>{let t=r.error?.code||"TRANSPORT",s=r.error?.message||t,o=be(r),n={code:t,metadata:o,status:e};switch(t){case"PBSV_EXPIRED":return new v(s,n);case"PBSV_INVALID":case"UNAUTHENTICATED":return new P(s,n);case"PBSV_PID_MISMATCH":return new _(s,n);case"CONSENT_REQUIRED":return new T(s,n);case"INSUFFICIENT_CREDITS":return new S(s,n);case"FUNCTION_NOT_FOUND":return new w(s,n);case"FUNCTION_DISABLED":return new C(s,n);case"RESOURCE_EXHAUSTED":return new A(s,n);case"EXECUTION_FAILED":return new G(s,n);default:return new g(s,n)}},"mapUdfErrorResponse"),je=i(r=>{if(!f||!x||r.origin!==x||r.source!==f.parent||!r.data||typeof r.data!="object")return;let e=r.data;if(e.type===me){typeof e.token=="string"&&e.token.length>0&&(q=e.token,y=ae(e.token));return}if(e.type!==ye||typeof e.request_id!="string")return;let t=I.get(e.request_id);t&&(clearTimeout(t.timer),I.delete(e.request_id),t.resolve(e.granted===!0?"granted":"denied"))},"onMessage"),De=i(()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`,"randomRequestId"),Me=i(()=>{if(!y)return null;let r=Number(y);return Number.isSafeInteger(r)?r:null},"playbookIdForInvoke"),Oe=i(async(r,e)=>{if(!f||!x)return"denied";let t=x,s=De();return new Promise(o=>{let n=setTimeout(()=>{I.delete(s),o("timeout")},Ue);I.set(s,{resolve:o,timer:n}),f?.parent.postMessage({type:_e,request_id:s,playbook_id:r,min_allowance:e},t)})},"requestConsent"),le=i(async(r,e,t=!1)=>{let s=b();if(!s)throw new k;if(!y)throw new _("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let o=Me();if(!o)throw new _("Invalid playbook id.",{code:"PBSV_PID_MISMATCH"});let n;try{n=await fetch(`${ne}/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 g("Network error while invoking UDF.",{code:"TRANSPORT"})}let a=await he(n);if(n.ok)return a.result;if(a.error?.code==="CONSENT_REQUIRED"&&!t){let c=be(a),u=typeof c.playbook_id=="string"?c.playbook_id:y,h=typeof c.min_allowance_suggested=="number"?c.min_allowance_suggested:1,d=await Oe(u,h);if(d==="granted")return le(r,e,!0);throw d==="timeout"?new E:new R}throw ce(a,n.status)},"call"),Le=i(async()=>{let r=b();if(!r)throw new k;if(!y)throw new _("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let e=new URL(`${ne}/api/v1/service/functions`);e.searchParams.set("playbook_id",y);let t=await fetch(e.toString(),{headers:{Authorization:`Bearer ${r}`,"X-Pbsv":"1"}}),s=await he(t);if(!t.ok)throw ce(s,t.status);let o=s.functions;return Array.isArray(o)?o:[]},"list"),oe=i((r,e,t)=>{r.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))},"dispatchButtonEvent"),$e=i(r=>{if(typeof r!="string")return r;let t=f?.document?.querySelector(r);if(t&&"appendChild"in t)return t;throw new Error(`UDF button target not found: ${r}`)},"resolveButtonTarget"),Be=i((r,e)=>{if(!f)throw new Error("Playbook runtime is not installed.");let t=$e(r),s=f.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=b()?o:a,s.disabled=!b(),s.setAttribute("data-function-name",e.functionName),s.disabled&&s.setAttribute("aria-disabled","true"),s.addEventListener("click",async()=>{if(!s.disabled){s.disabled=!0,s.textContent=n,oe(s,"alva:udf-button:loading",{functionName:e.functionName});try{let c=await le(e.functionName,e.params??{});oe(s,"alva:udf-button:result",{functionName:e.functionName,result:c})}catch(c){oe(s,"alva:udf-button:error",{functionName:e.functionName,error:c})}finally{s.disabled=!b(),s.textContent=s.disabled?a:o}}}),t.appendChild(s),s},"renderButton"),ke={call:le,list:Le,getViewerToken:b,renderButton:Be,UdfError:l,UdfAuthRequiredError:k,UdfTokenExpiredError:v,UdfTokenInvalidError:P,UdfPidMismatchError:_,UdfConsentRequiredError:T,UdfConsentDeniedError:R,UdfConsentTimeoutError:E,UdfInsufficientCredits:S,UdfFunctionNotFoundError:w,UdfFunctionDisabledError:C,UdfRateLimitedError:A,UdfExecutionError:G,UdfTransportError:g},pe=i(r=>{let e=r??(typeof window>"u"?void 0:window);if(!e||de)return;f=e,de=!0,Fe(e),e.addEventListener("message",je);let t=e,s=t.alva||{};t.alva={...s,udf:ke}},"installPlaybookRuntime");var p=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 F=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 j=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}})}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 D=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 M=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 O=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(We),has_next:s.has_next??!1}}};function We(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(We,"toAgentPlaybook");var L=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 $=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 ge=[{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 qe(r,e){return ge.find(t=>t.skill===r&&t.file===e)}i(qe,"getSkillEndpointMetadata");function ue(r){return ge.filter(e=>e.skill===r)}i(ue,"listSkillEndpointMetadata");var B=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,...ve(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=ue(e.name);return{...o,...ve(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=qe(e.name,e.file);return{...o,...n?{metadata:n}:{}}}};function ve(r){let e=ue(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(ve,"metadataSummaryForSkill");function Pe(r){let e=r.split("/");if(e.length!==2||!e[0]||!e[1])throw new p("INVALID_ARGUMENT",`playbook skill identifier must be "<user>/<name>", got "${r}"`,0);return{username:e[0],name:e[1]}}i(Pe,"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??[]}}async tags(){return{tags:(await this.client._request("GET","/api/v1/skills/tags")).data??[]}}async get(e){let{username:t,name:s}=Pe(e),o=encodeURIComponent(t),n=encodeURIComponent(s),c=(await this.client._request("GET",`/api/v1/skills/${o}/${n}`)).data?.[0];if(!c)throw new p("NOT_FOUND",`empty playbook skills get response for ${e}`,0);return c}async file(e,t){let{username:s,name:o}=Pe(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 p("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 V=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 J=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 z=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 Q=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 Y=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:Te(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:Te(e)})}};function Te(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(Te,"buildQuery");var Z=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 ee=class{constructor(e){this.client=e}client;static{i(this,"PushSubscriptionsResource")}async subscribePlaybook(e){this.client._requireAuth();let t=`/api/v1/push-subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",t)}async unsubscribePlaybook(e){this.client._requireAuth();let t=`/api/v1/push-subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",t)}async subscribeFeed(e){this.client._requireAuth();let t=`/api/v1/push-subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",t)}async unsubscribeFeed(e){this.client._requireAuth();let t=`/api/v1/push-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/push-subscriptions",{query:t})}};var re=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:Re(e)})}async unsubscribe(e){return this.client._requireAuth(),this.client._request("DELETE","/api/v1/channel/group-subscriptions",{jsonBody:Re(e)})}};function Re(r){return`{"session_id":${Ee(r.session_id)},"target_type":${JSON.stringify(r.target_type)},"target_id":${Ee(r.target_id)}}`}i(Re,"mutationBody");function Ee(r){if(typeof r=="number"){if(!Number.isInteger(r)||r<=0||!Number.isSafeInteger(r))throw new p("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 p("INVALID_ARGUMENT","channel group subscription ids must be positive integer strings",0);return r}i(Ee,"idLiteral");var He="https://api-llm.prd.alva.ai",Ve="https://data-tools.prd.space.id",te=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;_pushSubscriptions;_channelGroupSubscriptions;constructor(e){this.baseUrl=e.baseUrl??He,this.arraysBaseUrl=e.arraysBaseUrl??Ve,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 F(this)}get deploy(){return this._deploy??=new j(this)}get release(){return this._release??=new D(this)}get feed(){return this._feed??=new M(this)}get playbooks(){return this._playbooks??=new O(this)}get secrets(){return this._secrets??=new L(this)}get sdk(){return this._sdk??=new $(this)}get dataSkills(){return this._dataSkills??=new B(this)}get playbookSkills(){return this._playbookSkills??=new W(this)}get comments(){return this._comments??=new H(this)}get remix(){return this._remix??=new V(this)}get screenshot(){return this._screenshot??=new J(this)}get user(){return this._user??=new K(this)}get trading(){return this._trading??=new X(this)}get portfolio(){return this._portfolio??=new z(this)}get arraysJwt(){return this._arraysJwt??=new Q(this)}get notifications(){return this._notifications??=new Y(this)}get notificationPreferences(){return this._notificationPreferences??=new Z(this)}get pushSubscriptions(){return this._pushSubscriptions??=new ee(this)}get channelGroupSubscriptions(){return this._channelGroupSubscriptions??=new re(this)}_requireAuth(){if(!this.pbsvToken&&!this.viewer_token&&!this.apiKey)throw new p("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[m,se]of Object.entries(s.query))se!=null&&d.set(m,String(se));let ie=d.toString();ie&&(n+=`?${ie}`)}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 p("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 m=JSON.parse(d);if(m.error)throw new p(m.error.code??"UNKNOWN",m.error.message??`HTTP ${u.status}`,u.status)}catch(m){if(m instanceof p)throw m}throw new p("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 Je="0.9.3";pe();return xe(Ke);})();
|
|
1
|
+
"use strict";var AlvaToolkit=(()=>{var I=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var xe=Object.prototype.hasOwnProperty;var i=(r,e)=>I(r,"name",{value:e,configurable:!0});var Ue=(r,e)=>{for(var t in e)I(r,t,{get:e[t],enumerable:!0})},Ie=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ge(e))!xe.call(r,o)&&o!==t&&I(r,o,{get:()=>e[o],enumerable:!(s=Ce(e,o))||s.enumerable});return r};var Ne=r=>Ie(I({},"__esModule",{value:!0}),r);var er={};Ue(er,{AlvaClient:()=>ie,AlvaError:()=>c,PBSV_UPDATE_MESSAGE:()=>_e,UDF_AUTH_REQUIRED_MESSAGE:()=>he,UDF_CONSENT_REQUEST_MESSAGE:()=>ye,UDF_CONSENT_RESPONSE_MESSAGE:()=>fe,UdfAuthRequiredError:()=>g,UdfConsentDeniedError:()=>E,UdfConsentRequiredError:()=>R,UdfConsentTimeoutError:()=>S,UdfError:()=>p,UdfExecutionError:()=>x,UdfFunctionDisabledError:()=>C,UdfFunctionNotFoundError:()=>A,UdfInsufficientCredits:()=>w,UdfPidMismatchError:()=>y,UdfRateLimitedError:()=>G,UdfTokenExpiredError:()=>P,UdfTokenInvalidError:()=>T,UdfTransportError:()=>q,VERSION:()=>Ze,getViewerToken:()=>U,installPlaybookRuntime:()=>ue,mapUdfErrorResponse:()=>le,playbookIdFromToken:()=>ce,udf:()=>qe});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")}},y=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",ye="alva:udf:consent-request",fe="alva:udf:consent-response",he="alva:udf:auth-required",be="https://api-llm.prd.alva.ai",Fe=300*1e3,v=null,b=null,ae=be,f=null,m=null,me=!1,N=new Map,je=i(r=>{let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return atob(t)},"decodeBase64Url"),ce=i(r=>{if(!r)return null;let[,e]=r.split(".");if(!e)return null;try{let t=JSON.parse(je(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"),De=i(r=>{let e=new URL(r.location.href);e.searchParams.delete("_pbsv"),r.history.replaceState(null,"",e.pathname+e.search+e.hash)},"stripPbsvFromUrl"),Me=i(r=>{let e=new URLSearchParams(r.location.search);v=e.get("_pbsv"),b=e.get("parent_origin"),ae=(e.get("api_origin")||be).replace(/\/$/,""),f=ce(v),v&&De(r)},"parseBootParams"),ke=i(async r=>{try{return await r.json()}catch{return{}}},"safeJson"),Oe=i(r=>{if(typeof r!="string")return r;try{return JSON.parse(r)}catch{return r}},"parseResultPayload"),Le=i(r=>{let e=r;return{...e,result:Oe(e.result)}},"normalizeInvokeResponse"),ge=i(r=>r.error?.metadata||r.details?.metadata||{},"errorMetadata"),le=i((r,e)=>{let t=r.error?.code||"TRANSPORT",s=r.error?.message||t,o=ge(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 y(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"),$e=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=ce(e.token));return}if(e.type!==fe||typeof e.request_id!="string")return;let t=N.get(e.request_id);t&&(clearTimeout(t.timer),N.delete(e.request_id),t.resolve(e.granted===!0?"granted":"denied"))},"onMessage"),Be=i(()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`,"randomRequestId"),Ve=i(()=>{if(!f)return null;let r=Number(f);return Number.isSafeInteger(r)?r:null},"playbookIdForInvoke"),We=i(async(r,e)=>{if(!m||!b)return"denied";let t=b,s=Be();return new Promise(o=>{let n=setTimeout(()=>{N.delete(s),o("timeout")},Fe);N.set(s,{resolve:o,timer:n}),m?.parent.postMessage({type:ye,request_id:s,playbook_id:r,min_allowance:e},t)})},"requestConsent"),He=i(r=>{!m||!b||m.parent.postMessage({type:he,function_name:r},b)},"requestAuthentication"),pe=i(async(r,e,t=!1)=>{let s=U();if(!s)throw new g;if(!f)throw new y("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let o=Ve();if(!o)throw new y("Invalid playbook id.",{code:"PBSV_PID_MISMATCH"});let n;try{n=await fetch(`${ae}/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 ke(n);if(n.ok)return Le(a);if(a.error?.code==="CONSENT_REQUIRED"&&!t){let l=ge(a),u=typeof l.playbook_id=="string"?l.playbook_id:f,h=typeof l.min_allowance_suggested=="number"?l.min_allowance_suggested:1,d=await We(u,h);if(d==="granted")return pe(r,e,!0);throw d==="timeout"?new S:new E}throw le(a,n.status)},"call"),Je=i(async()=>{let r=U();if(!r)throw new g;if(!f)throw new y("Missing playbook id.",{code:"PBSV_PID_MISMATCH"});let e=new URL(`${ae}/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 ke(t);if(!t.ok)throw le(s,t.status);let o=s.functions;return Array.isArray(o)?o:[]},"list"),ne=i((r,e,t)=>{r.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))},"dispatchButtonEvent"),Ke=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"),ze=i((r,e)=>{if(!m)throw new Error("Playbook runtime is not installed.");let t=Ke(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()){He(e.functionName);return}if(!s.disabled){s.disabled=!0,s.textContent=n,ne(s,"alva:udf-button:loading",{functionName:e.functionName});try{let l=await pe(e.functionName,e.params??{});ne(s,"alva:udf-button:result",{functionName:e.functionName,result:l})}catch(l){ne(s,"alva:udf-button:error",{functionName:e.functionName,error:l})}finally{s.disabled=!1,s.textContent=k()?o:a,k()||s.setAttribute("aria-disabled","true")}}}),t.appendChild(s),s},"renderButton"),qe={call:pe,list:Je,getViewerToken:U,isAuthenticated:k,renderButton:ze,UdfError:p,UdfAuthRequiredError:g,UdfTokenExpiredError:P,UdfTokenInvalidError:T,UdfPidMismatchError:y,UdfConsentRequiredError:R,UdfConsentDeniedError:E,UdfConsentTimeoutError:S,UdfInsufficientCredits:w,UdfFunctionNotFoundError:A,UdfFunctionDisabledError:C,UdfRateLimitedError:G,UdfExecutionError:x,UdfTransportError:q},ue=i(r=>{let e=r??(typeof window>"u"?void 0:window);if(!e||me)return;m=e,me=!0,Me(e),e.addEventListener("message",$e);let t=e,s=t.alva||{};t.alva={...s,udf:qe}},"installPlaybookRuntime");var c=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 F=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 ve=["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(Xe),has_next:s.has_next??!1}}async setVisibility(e){if(!ve.includes(e.visibility))throw new c("INVALID_ARGUMENT",`Invalid visibility "${e.visibility}". Expected one of: ${ve.join(", ")}.`,400);return this.client._requireAuth(),await this.client._request("POST",`/api/v1/playbook/${encodeURIComponent(e.name)}/visibility`,{body:{visibility:e.visibility}})}};function Xe(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(Xe,"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 Pe=[{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 Te(r,e){return Pe.find(t=>t.skill===r&&t.file===e)}i(Te,"getSkillEndpointMetadata");function de(r){return Pe.filter(e=>e.skill===r)}i(de,"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,...Re(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=de(e.name);return{...o,...Re(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=Te(e.name,e.file);return{...o,...n?{metadata:n}:{}}}};function Re(r){let e=de(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(Re,"metadataSummaryForSkill");function Ee(r){let e=r.split("/");if(e.length!==2||!e[0]||!e[1])throw new c("INVALID_ARGUMENT",`playbook skill identifier must be "<user>/<name>", got "${r}"`,0);return{username:e[0],name:e[1]}}i(Ee,"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??[]}}async tags(){return{tags:(await this.client._request("GET","/api/v1/skills/tags")).data??[]}}async get(e){let{username:t,name:s}=Ee(e),o=encodeURIComponent(t),n=encodeURIComponent(s),l=(await this.client._request("GET",`/api/v1/skills/${o}/${n}`)).data?.[0];if(!l)throw new c("NOT_FOUND",`empty playbook skills get response for ${e}`,0);return l}async file(e,t){let{username:s,name:o}=Ee(e),n=encodeURIComponent(s),a=encodeURIComponent(o),l=t.split("/").map(encodeURIComponent).join("/"),h=(await this.client._request("GET",`/api/v1/skills/${n}/${a}/files/${l}`)).data?.[0];if(!h)throw new c("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 K=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 z=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:Se(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:Se(e)})}};function Se(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(Se,"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,"PushSubscriptionsResource")}async subscribePlaybook(e){this.client._requireAuth();let t=`/api/v1/push-subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",t)}async unsubscribePlaybook(e){this.client._requireAuth();let t=`/api/v1/push-subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",t)}async subscribeFeed(e){this.client._requireAuth();let t=`/api/v1/push-subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",t)}async unsubscribeFeed(e){this.client._requireAuth();let t=`/api/v1/push-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/push-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:we(e)})}async unsubscribe(e){return this.client._requireAuth(),this.client._request("DELETE","/api/v1/channel/group-subscriptions",{jsonBody:we(e)})}};function we(r){return`{"session_id":${Ae(r.session_id)},"target_type":${JSON.stringify(r.target_type)},"target_id":${Ae(r.target_id)}}`}i(we,"mutationBody");function Ae(r){if(typeof r=="number"){if(!Number.isInteger(r)||r<=0||!Number.isSafeInteger(r))throw new c("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 c("INVALID_ARGUMENT","channel group subscription ids must be positive integer strings",0);return r}i(Ae,"idLiteral");var Qe="https://api-llm.prd.alva.ai",Ye="https://data-tools.prd.space.id",ie=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;_pushSubscriptions;_channelGroupSubscriptions;constructor(e){this.baseUrl=e.baseUrl??Qe,this.arraysBaseUrl=e.arraysBaseUrl??Ye,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 F(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 K(this)}get user(){return this._user??=new z(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 pushSubscriptions(){return this._pushSubscriptions??=new re(this)}get channelGroupSubscriptions(){return this._channelGroupSubscriptions??=new te(this)}_requireAuth(){if(!this.pbsvToken&&!this.viewer_token&&!this.apiKey)throw new c("UNAUTHENTICATED","Authentication is required. Pass pbsvToken, viewer_token, or apiKey in the constructor.",401)}async _request(e,t,s){let n=`${s?.baseUrl??this.baseUrl}${t}`;if(s?.query){let d=new URLSearchParams;for(let[_,oe]of Object.entries(s.query))oe!=null&&d.set(_,String(oe));let se=d.toString();se&&(n+=`?${se}`)}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 l;s?.rawBody!==void 0?(a["Content-Type"]="application/octet-stream",l=s.rawBody):s?.jsonBody!==void 0?(a["Content-Type"]="application/json",l=s.jsonBody):s?.body!==void 0&&(a["Content-Type"]="application/json",l=JSON.stringify(s.body));let u;try{u=await fetch(n,{method:e,headers:a,body:l})}catch(d){throw new c("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 _=JSON.parse(d);if(_.error)throw new c(_.error.code??"UNKNOWN",_.error.message??`HTTP ${u.status}`,u.status)}catch(_){if(_ instanceof c)throw _}throw new c("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 Ze="0.9.5";ue();return Ne(er);})();
|
|
2
2
|
//# sourceMappingURL=browser.global.js.map
|