@alva-ai/toolkit 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -3
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.js +10408 -148
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +619 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +277 -18
- package/dist/index.d.ts +277 -18
- package/dist/index.js +596 -37
- package/dist/index.js.map +1 -1
- package/package.json +10 -1
package/README.md
CHANGED
|
@@ -20,13 +20,37 @@ npm install -g @alva-ai/toolkit
|
|
|
20
20
|
|
|
21
21
|
## CLI Quick Start
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Sign in with your Alva account (opens a browser, falls back to a paste-code
|
|
24
|
+
flow for SSH / containers / headless machines):
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
alva auth login
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`auth login` runs an OAuth 2.0 Authorization Code + PKCE flow. The CLI prints
|
|
31
|
+
a URL you can open on any device; if a local default browser opens
|
|
32
|
+
automatically the listener finishes the login with no extra step, otherwise
|
|
33
|
+
copy the URL to another device, log in, and paste the code shown on the page
|
|
34
|
+
back into the terminal.
|
|
35
|
+
|
|
36
|
+
Headless / no-browser environments (SSH, containers, devcontainers, etc.)
|
|
37
|
+
are auto-detected; pass `--no-browser` to force the paste-code flow or
|
|
38
|
+
`--browser` to force the listener flow.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
alva auth login --no-browser # force paste-code flow
|
|
42
|
+
alva auth login --profile staging # save under a named profile
|
|
43
|
+
alva auth login --auth-url https://stg.alva.xyz --base-url https://api-llm.stg.alva.ai # point at stg
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or, if you already have an API key from [alva.ai/apikey](https://alva.ai/apikey),
|
|
47
|
+
skip the OAuth flow and store the key directly:
|
|
24
48
|
|
|
25
49
|
```bash
|
|
26
50
|
alva configure --api-key alva_your_key_here
|
|
27
51
|
```
|
|
28
52
|
|
|
29
|
-
|
|
53
|
+
Either path writes your credentials to `~/.config/alva/config.json`.
|
|
30
54
|
|
|
31
55
|
Now use any command:
|
|
32
56
|
|
|
@@ -94,6 +118,17 @@ alva skillhub file alva/ai-digest references/api/example.md > out.md
|
|
|
94
118
|
By default output is pretty-printed for humans. Pass `--json` to get the
|
|
95
119
|
raw `{success, data}` envelope (e.g. for piping into `jq`).
|
|
96
120
|
|
|
121
|
+
### Playbook Discovery
|
|
122
|
+
|
|
123
|
+
Discover public playbooks with a compact, agent-friendly result shape. The
|
|
124
|
+
trending endpoint returns identifiers and ranking context, omitting
|
|
125
|
+
frontend-only preview fields.
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
alva playbooks trending --keyword scanner --tags macro,ai --sort recent --limit 5
|
|
129
|
+
alva playbooks trending --tag btc --cursor <cursor>
|
|
130
|
+
```
|
|
131
|
+
|
|
97
132
|
### Data Skills
|
|
98
133
|
|
|
99
134
|
Browse the Arrays backend's data-skill documentation. These endpoints are
|
|
@@ -152,6 +187,52 @@ Add the browser bundle via a CDN:
|
|
|
152
187
|
|
|
153
188
|
> **Note:** The Alva API must have CORS headers configured for browser requests to work from your origin.
|
|
154
189
|
|
|
190
|
+
### Playbook Runtime UDFs
|
|
191
|
+
|
|
192
|
+
When the browser bundle is loaded inside an Alva playbook iframe, it also
|
|
193
|
+
installs `window.alva.udf`. The runtime reads the playbook-scoped viewer
|
|
194
|
+
token (`_pbsv`) from the iframe URL, removes only that sensitive query
|
|
195
|
+
parameter, accepts parent-pushed token refreshes, and uses PBSV headers for
|
|
196
|
+
UDF calls.
|
|
197
|
+
|
|
198
|
+
```html
|
|
199
|
+
<script src="https://unpkg.com/@alva-ai/toolkit/dist/browser.global.js"></script>
|
|
200
|
+
<script>
|
|
201
|
+
(async () => {
|
|
202
|
+
const result = await window.alva.udf.call('analyze', { ticker: 'AAPL' });
|
|
203
|
+
const functions = await window.alva.udf.list();
|
|
204
|
+
})();
|
|
205
|
+
</script>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
For quick interactive controls, mount a runtime-managed UDF button. The button
|
|
209
|
+
is disabled until a PBSV token is present and emits DOM events for loading,
|
|
210
|
+
result, and error states.
|
|
211
|
+
|
|
212
|
+
```html
|
|
213
|
+
<div id="analyze"></div>
|
|
214
|
+
<script>
|
|
215
|
+
const button = window.alva.udf.renderButton('#analyze', {
|
|
216
|
+
functionName: 'analyze',
|
|
217
|
+
params: { ticker: 'AAPL' },
|
|
218
|
+
label: 'Run analysis',
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
button.addEventListener('alva:udf-button:result', (event) => {
|
|
222
|
+
console.log(event.detail.result);
|
|
223
|
+
});
|
|
224
|
+
</script>
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
For module users, the same runtime is available from the package root:
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
import { installPlaybookRuntime, udf } from '@alva-ai/toolkit';
|
|
231
|
+
|
|
232
|
+
installPlaybookRuntime();
|
|
233
|
+
const result = await udf.call('analyze', { ticker: 'AAPL' });
|
|
234
|
+
```
|
|
235
|
+
|
|
155
236
|
## API Reference
|
|
156
237
|
|
|
157
238
|
### Resources
|
|
@@ -163,6 +244,7 @@ Add the browser bundle via a CDN:
|
|
|
163
244
|
| `client.run` | `execute()` |
|
|
164
245
|
| `client.deploy` | `create()`, `list()`, `get()`, `update()`, `delete()`, `pause()`, `resume()` |
|
|
165
246
|
| `client.release` | `feed()`, `playbookDraft()`, `playbook()` |
|
|
247
|
+
| `client.playbooks` | `trending()` |
|
|
166
248
|
| `client.secrets` | `create()`, `list()`, `get()`, `update()`, `delete()` |
|
|
167
249
|
| `client.sdk` | `doc()`, `partitions()`, `partitionSummary()` |
|
|
168
250
|
| `client.comments` | `create()`, `pin()`, `unpin()` |
|
|
@@ -190,17 +272,19 @@ try {
|
|
|
190
272
|
```text
|
|
191
273
|
alva configure --api-key <key> [--base-url <url>] [--profile <name>]
|
|
192
274
|
alva whoami [--profile <name>]
|
|
193
|
-
alva auth login [--profile <name>]
|
|
275
|
+
alva auth login [--browser | --no-browser] [--profile <name>]
|
|
194
276
|
alva user me
|
|
195
277
|
alva fs <read|write|stat|readdir|mkdir|remove|rename|copy|symlink|readlink|chmod|grant|revoke>
|
|
196
278
|
alva run --code <code> [--entry-path <path>] [--working-dir <dir>] [--args <json>]
|
|
197
279
|
alva deploy <create|list|get|update|delete|pause|resume|runs|run-logs>
|
|
198
280
|
alva release <feed|playbook-draft|playbook>
|
|
281
|
+
alva playbooks <trending>
|
|
199
282
|
alva secrets <create|list|get|update|delete>
|
|
200
283
|
alva sdk <doc|partitions|partition-summary>
|
|
201
284
|
alva skillhub <list|tags|get|file> [<user>/<name>] [<file>] [--tag <t>] [--username <u>] [--json]
|
|
202
285
|
alva data-skills <list|summary|endpoint> [<skill>] [<file>] [--json]
|
|
203
286
|
alva comments <create|pin|unpin>
|
|
287
|
+
alva notification-preferences <list|enable-session-completed|disable-session-completed>
|
|
204
288
|
alva remix --child-username <u> --child-name <n> --parents <json>
|
|
205
289
|
alva screenshot --url <url> [--selector <s>] [--xpath <x>] --out <file>
|
|
206
290
|
alva trading <accounts|portfolio|orders|subscriptions|equity-history|risk-rules|subscribe|unsubscribe|execute|update-risk-rules>
|
package/dist/browser.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var AlvaToolkit=(()=>{var x=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var J=(t,e)=>{for(var r in e)x(t,r,{get:e[r],enumerable:!0})},K=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of B(e))!W.call(t,s)&&s!==r&&x(t,s,{get:()=>e[s],enumerable:!(i=D(e,s))||i.enumerable});return t};var V=t=>K(x({},"__esModule",{value:!0}),t);var X={};J(X,{AlvaClient:()=>A,AlvaError:()=>a,VERSION:()=>Q});var a=class extends Error{code;status;constructor(e,r,i){super(r),this.name="AlvaError",this.code=e,this.status=i}};var m=class{constructor(e){this.client=e}client;async read(e){let r=await this.client._request("GET","/api/v1/fs/read",{query:{path:e.path,offset:e.offset,size:e.size}});if(!(r instanceof ArrayBuffer))return r;try{let i=new TextDecoder("utf-8",{fatal:!0}).decode(r);try{return JSON.parse(i)}catch{return i}}catch{return r}}async write(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/fs/write",{body:{path:e.path,data:e.data,mkdir_parents:e.mkdir_parents}})}async rawWrite(e){return this.client._requireAuth(),this.client._request("POST","/api/v1/fs/write",{query:{path:e.path,mkdir_parents:e.mkdir_parents},rawBody:e.body})}async stat(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/stat",{query:{path:e.path}})}async readdir(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/readdir",{query:{path:e.path,recursive:e.recursive}})}async mkdir(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/mkdir",{body:{path:e.path}})}async remove(e){this.client._requireAuth(),await this.client._request("DELETE","/api/v1/fs/remove",{query:{path:e.path,recursive:e.recursive}})}async rename(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/rename",{body:{old_path:e.old_path,new_path:e.new_path}})}async copy(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/copy",{body:{src_path:e.src_path,dst_path:e.dst_path}})}async symlink(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/symlink",{body:{target_path:e.target_path,link_path:e.link_path}})}async readlink(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/fs/readlink",{query:{path:e.path}})}async chmod(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/chmod",{body:{path:e.path,mode:e.mode}})}async grant(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/grant",{body:{path:e.path,subject:e.subject,permission:e.permission}})}async revoke(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/fs/revoke",{body:{path:e.path,subject:e.subject,permission:e.permission}})}};var _=class{constructor(e){this.client=e}client;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}})}};var y=class{constructor(e){this.client=e}client;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:r,...i}=e;return this.client._request("PATCH",`/api/v1/deploy/cronjob/${r}`,{body:i})}async delete(e){this.client._requireAuth(),await this.client._request("DELETE",`/api/v1/deploy/cronjob/${e.id}`)}async pause(e){this.client._requireAuth(),await this.client._request("POST",`/api/v1/deploy/cronjob/${e.id}/pause`)}async resume(e){this.client._requireAuth(),await this.client._request("POST",`/api/v1/deploy/cronjob/${e.id}/resume`)}async trigger(e){return this.client._requireAuth(),this.client._request("POST",`/api/v1/deploy/cronjob/${e.id}/trigger`)}async listRuns(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.cronjob_id}/runs`,{query:{first:e.first,cursor:e.cursor}})}async getRunLogs(e){return this.client._requireAuth(),this.client._request("GET",`/api/v1/deploy/cronjob/${e.cronjob_id}/runs/${e.run_id}/logs`)}};var h=class{constructor(e){this.client=e}client;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,template_id:e.template_id}})}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 f=class{constructor(e){this.client=e}client;async create(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/secrets",{body:{name:e.name,value:e.value}})}async list(){return this.client._requireAuth(),this.client._request("GET","/api/v1/secrets")}async get(e){this.client._requireAuth();let r=encodeURIComponent(e.name);return this.client._request("GET",`/api/v1/secrets/${r}`)}async update(e){this.client._requireAuth();let r=encodeURIComponent(e.name);await this.client._request("PUT",`/api/v1/secrets/${r}`,{body:{value:e.value}})}async delete(e){this.client._requireAuth();let r=encodeURIComponent(e.name);await this.client._request("DELETE",`/api/v1/secrets/${r}`)}};var b=class{constructor(e){this.client=e}client;async doc(e){return this.client._requireAuth(),this.client._request("GET","/api/v1/sdk/doc",{query:{name:e.name}})}async partitions(){return this.client._requireAuth(),this.client._request("GET","/api/v1/sdk/partitions")}async partitionSummary(e){this.client._requireAuth();let r=encodeURIComponent(e.partition);return this.client._request("GET",`/api/v1/sdk/partitions/${r}/summary`)}};var U=[{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-spot-market-price-and-volume",file:"crypto-futures-ohlcv",method:"GET",path:"/api/v1/crypto/futures/ohlcv",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"crypto-kline",method:"GET",path:"/api/v1/crypto/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-spot-market-price-and-volume",file:"crypto-ohlcv",method:"GET",path:"/api/v1/crypto/ohlcv",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-equity-ownership-and-flow",file:"senate-trade",method:"GET",path:"/api/v1/stocks/company/senate-trade",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}];function M(t,e){return U.find(r=>r.skill===t&&r.file===e)}function F(t){return U.filter(e=>e.skill===t)}var q=class{constructor(e){this.client=e}client;async list(){return{skills:((await this.client._request("GET","/api/v1/skills",{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data??[]).map(r=>({...r,...I(r.name)}))}}async summary(e){let r=encodeURIComponent(e.name),s=(await this.client._request("GET",`/api/v1/skills/${r}`,{baseUrl:this.client.arraysBaseUrl,noAuth:!0})).data?.[0];if(!s)throw new Error(`empty skills summary response for "${e.name}"`);let n=F(e.name);return{...s,...I(e.name),...n.length>0?{endpoint_metadata:n}:{}}}async endpoint(e){let r=encodeURIComponent(e.name),s=(await this.client._request("GET",`/api/v1/skills/${r}`,{baseUrl:this.client.arraysBaseUrl,noAuth:!0,query:{endpoint:e.file}})).data?.[0];if(!s)throw new Error(`empty skills endpoint response for "${e.name}" file "${e.file}"`);let n=M(e.name,e.file);return{...s,...n?{metadata:n}:{}}}};function I(t){let e=F(t);if(e.length===0)return{};let r={},i=0;for(let s of e)r[s.tier]=(r[s.tier]??0)+1,s.pro_required&&(i+=1);return{endpoint_tier_counts:r,metadata:{endpoint_count:e.length,endpoint_tier_counts:r,pro_count:i}}}function O(t){let e=t.split("/");if(e.length!==2||!e[0]||!e[1])throw new a("INVALID_ARGUMENT",`playbook skill identifier must be "<user>/<name>", got "${t}"`,0);return{username:e[0],name:e[1]}}var k=class{constructor(e){this.client=e}client;async list(e){let r={};return e?.tag&&(r.tag=e.tag),e?.username&&(r.username=e.username),{skills:(await this.client._request("GET","/api/v1/skills",{query:r})).data??[]}}async tags(){return{tags:(await this.client._request("GET","/api/v1/skills/tags")).data??[]}}async get(e){let{username:r,name:i}=O(e),s=encodeURIComponent(r),n=encodeURIComponent(i),p=(await this.client._request("GET",`/api/v1/skills/${s}/${n}`)).data?.[0];if(!p)throw new a("NOT_FOUND",`empty playbook skills get response for ${e}`,0);return p}async file(e,r){let{username:i,name:s}=O(e),n=encodeURIComponent(i),c=encodeURIComponent(s),p=r.split("/").map(encodeURIComponent).join("/"),d=(await this.client._request("GET",`/api/v1/skills/${n}/${c}/files/${p}`)).data?.[0];if(!d)throw new a("NOT_FOUND",`empty playbook skills file response for ${e} path ${r}`,0);return d}};var v=class{constructor(e){this.client=e}client;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 g=class{constructor(e){this.client=e}client;async save(e){this.client._requireAuth(),await this.client._request("POST","/api/v1/remix",{body:{child:e.child,parents:e.parents}})}};var P=class{constructor(e){this.client=e}client;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 T=class{constructor(e){this.client=e}client;async me(){return this.client._requireAuth(),this.client._request("GET","/api/v1/me")}};var R=class{constructor(e){this.client=e}client;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 E=class{constructor(e){this.client=e}client;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 S=class{constructor(e){this.client=e}client;async listPlaybook(e){this.client._requireAuth();let r=`/api/v1/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",r,{query:L(e)})}async listFeed(e){this.client._requireAuth();let r=`/api/v1/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}/notifications`;return this.client._request("GET",r,{query:L(e)})}};function L(t){let e={};return t.channel&&(e.channel=t.channel),t.status&&(e.status=t.status),t.since_time!==void 0&&t.since_time>0&&(e.since_time=String(t.since_time)),t.first!==void 0&&t.first>0&&(e.first=String(t.first)),t.cursor&&(e.cursor=t.cursor),e}var G=class{constructor(e){this.client=e}client;async subscribePlaybook(e){this.client._requireAuth();let r=`/api/v1/push-subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",r)}async unsubscribePlaybook(e){this.client._requireAuth();let r=`/api/v1/push-subscriptions/playbook/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",r)}async subscribeFeed(e){this.client._requireAuth();let r=`/api/v1/push-subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("POST",r)}async unsubscribeFeed(e){this.client._requireAuth();let r=`/api/v1/push-subscriptions/feed/${encodeURIComponent(e.username)}/${encodeURIComponent(e.name)}`;return this.client._request("DELETE",r)}async list(e={}){this.client._requireAuth();let r={};return e.include_history!==void 0&&(r.include_history=String(e.include_history)),this.client._request("GET","/api/v1/me/push-subscriptions",{query:r})}};var C=class{constructor(e){this.client=e}client;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:$(e)})}async unsubscribe(e){return this.client._requireAuth(),this.client._request("DELETE","/api/v1/channel/group-subscriptions",{jsonBody:$(e)})}};function $(t){return`{"session_id":${N(t.session_id)},"target_type":${JSON.stringify(t.target_type)},"target_id":${N(t.target_id)}}`}function N(t){if(typeof t=="number"){if(!Number.isInteger(t)||t<=0||!Number.isSafeInteger(t))throw new a("INVALID_ARGUMENT","channel group subscription ids must be positive safe integers; pass large int64 ids as strings",0);return String(t)}if(!/^[1-9]\d*$/.test(t))throw new a("INVALID_ARGUMENT","channel group subscription ids must be positive integer strings",0);return t}var z="https://api-llm.prd.alva.ai",H="https://data-tools.prd.space.id",A=class{baseUrl;arraysBaseUrl;viewer_token;apiKey;_fs;_run;_deploy;_release;_secrets;_sdk;_dataSkills;_playbookSkills;_comments;_remix;_screenshot;_user;_trading;_arraysJwt;_notifications;_pushSubscriptions;_channelGroupSubscriptions;constructor(e){this.baseUrl=e.baseUrl??z,this.arraysBaseUrl=e.arraysBaseUrl??H,this.viewer_token=e.viewer_token,this.apiKey=e.apiKey}get fs(){return this._fs??=new m(this)}get run(){return this._run??=new _(this)}get deploy(){return this._deploy??=new y(this)}get release(){return this._release??=new h(this)}get secrets(){return this._secrets??=new f(this)}get sdk(){return this._sdk??=new b(this)}get dataSkills(){return this._dataSkills??=new q(this)}get playbookSkills(){return this._playbookSkills??=new k(this)}get comments(){return this._comments??=new v(this)}get remix(){return this._remix??=new g(this)}get screenshot(){return this._screenshot??=new P(this)}get user(){return this._user??=new T(this)}get trading(){return this._trading??=new R(this)}get arraysJwt(){return this._arraysJwt??=new E(this)}get notifications(){return this._notifications??=new S(this)}get pushSubscriptions(){return this._pushSubscriptions??=new G(this)}get channelGroupSubscriptions(){return this._channelGroupSubscriptions??=new C(this)}_requireAuth(){if(!this.viewer_token&&!this.apiKey)throw new a("UNAUTHENTICATED","Authentication is required. Pass viewer_token or apiKey in the constructor.",401)}async _request(e,r,i){let n=`${i?.baseUrl??this.baseUrl}${r}`;if(i?.query){let l=new URLSearchParams;for(let[u,j]of Object.entries(i.query))j!=null&&l.set(u,String(j));let w=l.toString();w&&(n+=`?${w}`)}let c={};i?.noAuth||(this.viewer_token?c["x-Playbook-Viewer"]=this.viewer_token:this.apiKey&&(c["X-Alva-Api-Key"]=this.apiKey));let p;i?.rawBody!==void 0?(c["Content-Type"]="application/octet-stream",p=i.rawBody):i?.jsonBody!==void 0?(c["Content-Type"]="application/json",p=i.jsonBody):i?.body!==void 0&&(c["Content-Type"]="application/json",p=JSON.stringify(i.body));let o;try{o=await fetch(n,{method:e,headers:c,body:p})}catch(l){throw new a("NETWORK_ERROR",l instanceof Error?l.message:"Network request failed",0)}if(!o.ok){let l=await o.text().catch(()=>"");if((o.headers.get("content-type")??"").includes("application/json")&&l)try{let u=JSON.parse(l);if(u.error)throw new a(u.error.code??"UNKNOWN",u.error.message??`HTTP ${o.status}`,o.status)}catch(u){if(u instanceof a)throw u}throw new a("UNKNOWN",`HTTP ${o.status}: ${l.slice(0,200)}`,o.status)}if(o.status===204)return;let d=o.headers.get("content-type")??"";return d.includes("application/octet-stream")||d.includes("image/")?o.arrayBuffer():o.json()}};var Q="0.7.0";return V(X);})();
|
|
1
|
+
"use strict";var AlvaToolkit=(()=>{var U=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var we=Object.prototype.hasOwnProperty;var i=(r,e)=>U(r,"name",{value:e,configurable:!0});var Ce=(r,e)=>{for(var t in e)U(r,t,{get:e[t],enumerable:!0})},Ae=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Se(e))!we.call(r,o)&&o!==t&&U(r,o,{get:()=>e[o],enumerable:!(s=Ee(e,o))||s.enumerable});return r};var Ge=r=>Ae(U({},"__esModule",{value:!0}),r);var Je={};Ce(Je,{AlvaClient:()=>re,AlvaError:()=>p,PBSV_UPDATE_MESSAGE:()=>de,UDF_CONSENT_REQUEST_MESSAGE:()=>me,UDF_CONSENT_RESPONSE_MESSAGE:()=>_e,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:()=>Ve,getViewerToken:()=>b,installPlaybookRuntime:()=>le,mapUdfErrorResponse:()=>ae,playbookIdFromToken:()=>ne,udf:()=>be});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")}},de="alva:pbsv:update",me="alva:udf:consent-request",_e="alva:udf:consent-response",ye="https://api.alva.ai",xe=300*1e3,q=null,x=null,oe=ye,y=null,f=null,ue=!1,I=new Map,Ue=i(r=>{let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return atob(t)},"decodeBase64Url"),ne=i(r=>{if(!r)return null;let[,e]=r.split(".");if(!e)return null;try{let t=JSON.parse(Ue(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"),Ie=i(r=>{let e=new URL(r.location.href);e.searchParams.delete("_pbsv"),r.history.replaceState(null,"",e.pathname+e.search+e.hash)},"stripPbsvFromUrl"),Ne=i(r=>{let e=new URLSearchParams(r.location.search);q=e.get("_pbsv"),x=e.get("parent_origin"),oe=(e.get("api_origin")||ye).replace(/\/$/,""),y=ne(q),q&&Ie(r)},"parseBootParams"),fe=i(async r=>{try{return await r.json()}catch{return{}}},"safeJson"),he=i(r=>r.error?.metadata||r.details?.metadata||{},"errorMetadata"),ae=i((r,e)=>{let t=r.error?.code||"TRANSPORT",s=r.error?.message||t,o=he(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"),Fe=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===de){typeof e.token=="string"&&e.token.length>0&&(q=e.token,y=ne(e.token));return}if(e.type!==_e||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"),je=i(()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`,"randomRequestId"),De=i(()=>{if(!y)return null;let r=Number(y);return Number.isSafeInteger(r)?r:null},"playbookIdForInvoke"),Me=i(async(r,e)=>{if(!f||!x)return"denied";let t=x,s=je();return new Promise(o=>{let n=setTimeout(()=>{I.delete(s),o("timeout")},xe);I.set(s,{resolve:o,timer:n}),f?.parent.postMessage({type:me,request_id:s,playbook_id:r,min_allowance:e},t)})},"requestConsent"),ce=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=De();if(!o)throw new _("Invalid playbook id.",{code:"PBSV_PID_MISMATCH"});let n;try{n=await fetch(`${oe}/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 fe(n);if(n.ok)return a.result;if(a.error?.code==="CONSENT_REQUIRED"&&!t){let c=he(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 Me(u,h);if(d==="granted")return ce(r,e,!0);throw d==="timeout"?new E:new R}throw ae(a,n.status)},"call"),Oe=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(`${oe}/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 fe(t);if(!t.ok)throw ae(s,t.status);let o=s.functions;return Array.isArray(o)?o:[]},"list"),se=i((r,e,t)=>{r.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))},"dispatchButtonEvent"),Le=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"),$e=i((r,e)=>{if(!f)throw new Error("Playbook runtime is not installed.");let t=Le(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,se(s,"alva:udf-button:loading",{functionName:e.functionName});try{let c=await ce(e.functionName,e.params??{});se(s,"alva:udf-button:result",{functionName:e.functionName,result:c})}catch(c){se(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"),be={call:ce,list:Oe,getViewerToken:b,renderButton:$e,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},le=i(r=>{let e=r??(typeof window>"u"?void 0:window);if(!e||ue)return;f=e,ue=!0,Ne(e),e.addEventListener("message",Fe);let t=e,s=t.alva||{};t.alva={...s,udf:be}},"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(Be),has_next:s.has_next??!1}}};function Be(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(Be,"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 ke=[{skill:"arrays-data-api-crypto-futures-data",file:"binance-perp-usdt-kline",method:"GET",path:"/api/v1/crypto/binance/perp/usdt/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-spot-market-price-and-volume",file:"binance-spot-usdt-kline",method:"GET",path:"/api/v1/crypto/binance/spot/usdt/kline",tier:"public",required_subscription_tier:"free",access:"free_and_pro",pro_required:!1},{skill:"arrays-data-api-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 ge(r,e){return ke.find(t=>t.skill===r&&t.file===e)}i(ge,"getSkillEndpointMetadata");function pe(r){return ke.filter(e=>e.skill===r)}i(pe,"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,...qe(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=pe(e.name);return{...o,...qe(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=ge(e.name,e.file);return{...o,...n?{metadata:n}:{}}}};function qe(r){let e=pe(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(qe,"metadataSummaryForSkill");function ve(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(ve,"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}=ve(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}=ve(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,"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 Q=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:Pe(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:Pe(e)})}};function Pe(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(Pe,"buildQuery");var Y=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 Z=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 ee=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:Te(e)})}async unsubscribe(e){return this.client._requireAuth(),this.client._request("DELETE","/api/v1/channel/group-subscriptions",{jsonBody:Te(e)})}};function Te(r){return`{"session_id":${Re(r.session_id)},"target_type":${JSON.stringify(r.target_type)},"target_id":${Re(r.target_id)}}`}i(Te,"mutationBody");function Re(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(Re,"idLiteral");var We="https://api-llm.prd.alva.ai",He="https://data-tools.prd.space.id",re=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;_arraysJwt;_notifications;_notificationPreferences;_pushSubscriptions;_channelGroupSubscriptions;constructor(e){this.baseUrl=e.baseUrl??We,this.arraysBaseUrl=e.arraysBaseUrl??He,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 arraysJwt(){return this._arraysJwt??=new z(this)}get notifications(){return this._notifications??=new Q(this)}get notificationPreferences(){return this._notificationPreferences??=new Y(this)}get pushSubscriptions(){return this._pushSubscriptions??=new Z(this)}get channelGroupSubscriptions(){return this._channelGroupSubscriptions??=new ee(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,ie]of Object.entries(s.query))ie!=null&&d.set(m,String(ie));let te=d.toString();te&&(n+=`?${te}`)}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 Ve="0.9.0";le();return Ge(Je);})();
|
|
2
2
|
//# sourceMappingURL=browser.global.js.map
|