@alva-ai/toolkit 0.20.0 → 0.21.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.
@@ -0,0 +1,1943 @@
1
+ interface AlvaClientConfig {
2
+ viewer_token?: string;
3
+ pbsvToken?: string;
4
+ apiKey?: string;
5
+ baseUrl?: string;
6
+ arraysBaseUrl?: string;
7
+ gaClientId?: string;
8
+ gaSessionId?: string;
9
+ utmParams?: string;
10
+ /** Optional default AbortSignal applied to every request from this client. */
11
+ signal?: AbortSignal;
12
+ /** Alva chat session owning produced artifacts; sent as X-Alva-Origin-Session-Id. */
13
+ originSessionId?: string;
14
+ /** Session profile kind used to gate attached-context CLI commands. */
15
+ originSessionKind?: string;
16
+ }
17
+ interface UserProfile {
18
+ id: string;
19
+ username: string;
20
+ subscription_tier: 'free' | 'pro' | 'max';
21
+ telegram_username: string;
22
+ discord_username: string;
23
+ slack_username: string;
24
+ whatsapp_username: string;
25
+ imessage_username: string;
26
+ active_channel: string;
27
+ toolkit_min_version: string;
28
+ /** Caller's alfs home directory, e.g. `/alva/home/<username>`. */
29
+ home_path: string;
30
+ }
31
+ interface CreditWallet {
32
+ balance: number;
33
+ totalRemaining: number;
34
+ todayUsed: number;
35
+ }
36
+ interface CreditWalletItemsParams {
37
+ /** Inclusive UTC lower bound, Unix milliseconds. */
38
+ startAtMs: number;
39
+ /** Exclusive UTC upper bound, Unix milliseconds. */
40
+ endAtMs: number;
41
+ /** Optional chat/session id to filter consumption records. */
42
+ sessionId?: string;
43
+ /** Page size, defaulted and capped by the gateway. */
44
+ first?: number;
45
+ /** Opaque cursor from a previous page's `pageInfo.endCursor`. */
46
+ after?: string;
47
+ }
48
+ interface CreditWalletItem {
49
+ id: string;
50
+ sessionId: string | null;
51
+ playbookId: string | null;
52
+ feedId: string | null;
53
+ op: string;
54
+ source: string;
55
+ amount: number;
56
+ extras?: unknown;
57
+ /** Creation timestamp, Unix milliseconds. */
58
+ createdAtMs: number;
59
+ }
60
+ interface CreditWalletPageInfo {
61
+ hasNextPage: boolean;
62
+ hasPreviousPage: boolean;
63
+ startCursor: string | null;
64
+ endCursor: string | null;
65
+ }
66
+ interface CreditWalletItemEdge {
67
+ cursor: string;
68
+ node: CreditWalletItem;
69
+ }
70
+ interface CreditWalletItemConnection {
71
+ pageInfo: CreditWalletPageInfo;
72
+ edges: CreditWalletItemEdge[];
73
+ }
74
+ interface CreditWalletItemsResponse extends CreditWallet {
75
+ items: CreditWalletItemConnection;
76
+ }
77
+ type SubscriptionTier = 'SUBSCRIPTION_TIER_UNSPECIFIED' | 'SUBSCRIPTION_TIER_FREE' | 'SUBSCRIPTION_TIER_PRO';
78
+ interface EnsureArraysJwtResponse {
79
+ expires_at: number;
80
+ tier: SubscriptionTier;
81
+ renewed: boolean;
82
+ }
83
+ interface ArraysJwtStatusResponse {
84
+ exists: boolean;
85
+ expires_at: number;
86
+ tier: SubscriptionTier;
87
+ renewal_needed: boolean;
88
+ }
89
+ interface FsReadParams {
90
+ path: string;
91
+ offset?: number;
92
+ size?: number;
93
+ }
94
+ interface FsWriteParams {
95
+ path: string;
96
+ data: string;
97
+ mkdir_parents?: boolean;
98
+ /** Append to the existing file instead of overwriting it. */
99
+ append?: boolean;
100
+ }
101
+ interface FsRawWriteParams {
102
+ path: string;
103
+ /** Raw file content: string, ArrayBuffer, Uint8Array, Blob, etc. */
104
+ body: BodyInit;
105
+ mkdir_parents?: boolean;
106
+ /** Append to the existing file instead of overwriting it. */
107
+ append?: boolean;
108
+ }
109
+ interface FsWriteResponse {
110
+ bytes_written: number;
111
+ }
112
+ interface FsStat {
113
+ name: string;
114
+ size: number;
115
+ mode: number;
116
+ mod_time: string;
117
+ is_dir: boolean;
118
+ }
119
+ interface FsReaddirParams {
120
+ path: string;
121
+ recursive?: boolean;
122
+ }
123
+ interface FsEntry {
124
+ name: string;
125
+ size: number;
126
+ is_dir: boolean;
127
+ mod_time?: string;
128
+ mode?: number;
129
+ }
130
+ interface FsReaddirResponse {
131
+ entries: FsEntry[];
132
+ }
133
+ interface FsMkdirParams {
134
+ path: string;
135
+ }
136
+ interface FsRemoveParams {
137
+ path: string;
138
+ recursive?: boolean;
139
+ }
140
+ interface FsRenameParams {
141
+ old_path: string;
142
+ new_path: string;
143
+ }
144
+ interface FsCopyParams {
145
+ src_path: string;
146
+ dst_path: string;
147
+ }
148
+ interface FsSymlinkParams {
149
+ target_path: string;
150
+ link_path: string;
151
+ }
152
+ interface FsReadlinkParams {
153
+ path: string;
154
+ }
155
+ interface FsChmodParams {
156
+ path: string;
157
+ mode: number;
158
+ }
159
+ interface FsGrantParams {
160
+ path: string;
161
+ subject: string;
162
+ permission: string;
163
+ }
164
+ interface FsRevokeParams {
165
+ path: string;
166
+ subject: string;
167
+ permission: string;
168
+ }
169
+ interface RunRequest {
170
+ code?: string;
171
+ entry_path?: string;
172
+ working_dir?: string;
173
+ args?: Record<string, unknown>;
174
+ /**
175
+ * Override the server's default V8 heap limit, in MB. Valid range is
176
+ * 1–2048. Omitted means the server uses its default heap (256 MB).
177
+ */
178
+ max_heap_size_mb?: number;
179
+ /**
180
+ * Client-side HTTP timeout for waiting on POST /api/v1/run, in
181
+ * milliseconds. This is not sent to the server.
182
+ */
183
+ timeout_ms?: number;
184
+ }
185
+ interface RunResponse {
186
+ result: string;
187
+ logs: string;
188
+ stats: {
189
+ duration_ms: number;
190
+ };
191
+ status: 'completed' | 'failed';
192
+ error?: string;
193
+ }
194
+ interface CronjobCreateRequest {
195
+ path: string;
196
+ cron_expression: string;
197
+ name: string;
198
+ args?: Record<string, unknown>;
199
+ /**
200
+ * Let successful scheduled and manually triggered Feed runs deliver declared
201
+ * alert outputs to eligible subscribers. Does not create subscriptions.
202
+ */
203
+ push_notify?: boolean;
204
+ /** Override per-cronjob V8 heap limit (MB). Valid range 1–2046. */
205
+ max_heap_size_mb?: number;
206
+ /**
207
+ * Maximum wall-clock execution time in seconds. Valid range 1–3600.
208
+ * Omitted means the server uses its default (1800 seconds).
209
+ */
210
+ execution_timeout_seconds?: number;
211
+ /**
212
+ * Run the cronjob under a restricted service-account identity (an SA id
213
+ * owned by the caller) instead of the owner (#602). Omitted ⇒ runs as owner.
214
+ * A string: SA ids are snowflake int64s that overflow JS number precision.
215
+ */
216
+ run_as_user_id?: string;
217
+ /** Inclusive RFC3339 lower bound. Omitted means start now (server clock). */
218
+ start_at?: string;
219
+ /**
220
+ * Exclusive RFC3339 upper bound. A run is admitted only while now < end_at.
221
+ */
222
+ end_at?: string;
223
+ /** Maximum number of admitted runs. */
224
+ max_runs?: number;
225
+ }
226
+ interface Cronjob {
227
+ id: number;
228
+ name: string;
229
+ path: string;
230
+ cron_expression: string;
231
+ status: string;
232
+ args: Record<string, unknown>;
233
+ /** Whether successful Feed runs may deliver alerts to subscribers. */
234
+ push_notify: boolean;
235
+ /** Per-cronjob V8 heap cap (MB). null when using the server default. */
236
+ max_heap_size_mb: number | null;
237
+ /** Effective wall-clock execution timeout in seconds. */
238
+ execution_timeout_seconds: number;
239
+ /**
240
+ * SA id the cronjob runs as, or "0" when it runs as the owner (#602).
241
+ * A string: snowflake int64 ids overflow JS number precision.
242
+ */
243
+ run_as_user_id: string;
244
+ /** Inclusive eligibility lower bound, resolved by the server on create. */
245
+ start_at?: string | null;
246
+ /**
247
+ * Lifetime ceiling (RFC3339), or null/omitted when the cronjob has no expiry.
248
+ * Set by `alva loop create`; unset for feeds and other crons.
249
+ */
250
+ end_at?: string | null;
251
+ /** Maximum admitted runs, or null when unbounded by count. */
252
+ max_runs?: number | null;
253
+ /** Number of runs admitted so far. */
254
+ run_count: number;
255
+ created_at: string;
256
+ updated_at: string;
257
+ }
258
+ interface CronjobListParams {
259
+ limit?: number;
260
+ cursor?: string;
261
+ }
262
+ interface CronjobListResponse {
263
+ cronjobs: Cronjob[];
264
+ next_cursor?: string;
265
+ }
266
+ interface CronjobUpdateRequest {
267
+ id: number;
268
+ name?: string;
269
+ cron_expression?: string;
270
+ args?: Record<string, unknown>;
271
+ /** Enable or disable delivery of declared Feed alert outputs. */
272
+ push_notify?: boolean;
273
+ /** Override per-cronjob V8 heap limit (MB). Valid range 1–2046. */
274
+ max_heap_size_mb?: number;
275
+ /**
276
+ * Maximum wall-clock execution time in seconds. Valid range 1–3600.
277
+ * Omitted means the existing value is preserved.
278
+ */
279
+ execution_timeout_seconds?: number;
280
+ /**
281
+ * Re-point the cronjob at a service-account identity, or "0" to clear it back
282
+ * to the owner (#602). Omitted ⇒ run_as unchanged.
283
+ * A string: SA ids are snowflake int64s that overflow JS number precision.
284
+ */
285
+ run_as_user_id?: string;
286
+ }
287
+ interface CronjobRunsListParams {
288
+ cronjob_id: number;
289
+ first?: number;
290
+ cursor?: string;
291
+ }
292
+ interface CronjobRun {
293
+ id: number;
294
+ cronjob_id: number;
295
+ status: string;
296
+ error: string;
297
+ duration_ms: number;
298
+ credits_used: number;
299
+ created_at: string;
300
+ /**
301
+ * Hatchet workflow run id captured at trigger time. Populated for runs
302
+ * persisted by recent worker binaries (both naturally-scheduled ticks and
303
+ * triggered runs); empty for older rows. External callers that issued
304
+ * `deploy.trigger()` filter by this field to find the run their request
305
+ * produced.
306
+ */
307
+ workflow_run_id?: string;
308
+ }
309
+ interface CronjobRunStats {
310
+ total_runs: number;
311
+ success_count: number;
312
+ fail_count: number;
313
+ last_run_at?: string;
314
+ last_success_at?: string;
315
+ }
316
+ interface CronjobRunsListResponse {
317
+ runs: CronjobRun[];
318
+ stats?: CronjobRunStats;
319
+ next_cursor?: number;
320
+ }
321
+ interface CronjobRunStatusParams {
322
+ cronjob_id: number;
323
+ workflow_run_id: string;
324
+ }
325
+ interface CronjobRunStatusResponse {
326
+ workflow_run_id: string;
327
+ /**
328
+ * PENDING means no cronjob_runs row exists yet. It is not falsifiable:
329
+ * a mistyped workflow_run_id, a workflow_run_id from another cronjob, or
330
+ * a workflow that failed before persistence can remain PENDING forever.
331
+ * DISPATCHED and RUNNING mean an in-flight row exists. Pollers must stop
332
+ * on their own deadline if the run never reaches a terminal state.
333
+ */
334
+ state: 'PENDING' | 'DISPATCHED' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'SKIPPED' | 'UNSPECIFIED' | string;
335
+ run?: CronjobRun;
336
+ }
337
+ interface CronjobRunLogsResponse {
338
+ logs: string;
339
+ }
340
+ interface CronjobTriggerResponse {
341
+ /**
342
+ * Hatchet workflow run id at enqueue. Async — the persisted
343
+ * `cronjob_runs` row appears only after the worker finishes the run.
344
+ * Callers verify completion by polling
345
+ * `deploy.getRunStatus({cronjob_id, workflow_run_id})` with their own
346
+ * timeout/deadline.
347
+ */
348
+ workflow_run_id: string;
349
+ }
350
+ interface FeedReleaseRequest {
351
+ name: string;
352
+ version: string;
353
+ cronjob_id: number;
354
+ view_json?: Record<string, unknown>;
355
+ description?: string;
356
+ changelog?: string;
357
+ /**
358
+ * Agent kind that produces this feed (e.g. "alpi"). Optional. Marks the feed
359
+ * as an agent feed whose prompt is editable; an empty/omitted value means a
360
+ * regular (non-agent) feed. The backend validates it against its catalog.
361
+ */
362
+ agent_type?: string;
363
+ /** Suppress ReleaseFeed's default publish-time first run. */
364
+ skip_auto_trigger?: boolean;
365
+ }
366
+ interface FeedReleaseResponse {
367
+ feed_id: number;
368
+ name: string;
369
+ feed_major: number;
370
+ /** Canonical alfs path: `/alva/home/<username>/feeds/<name>`. */
371
+ feed_path: string;
372
+ }
373
+ interface FeedDeleteRequest {
374
+ /** Numeric feed id to delete. */
375
+ id: number;
376
+ }
377
+ type FeedListStatus = 'active' | 'paused' | 'all';
378
+ interface FeedListParams {
379
+ /** Page size, default 50, max 100 server-side. */
380
+ limit?: number;
381
+ /** Opaque cursor token from the previous page. */
382
+ cursor?: string;
383
+ /** Runtime status filter; defaults to active on the gateway. */
384
+ status?: FeedListStatus;
385
+ }
386
+ interface FeedListItem {
387
+ /** Numeric feed id encoded as a string, matching the gateway response. */
388
+ id: string;
389
+ name: string;
390
+ /** Feed runtime status. */
391
+ status: 'ACTIVE' | 'PAUSED' | 'UNSPECIFIED' | (string & {});
392
+ cron_expression?: string;
393
+ total_runs: number;
394
+ used_by_total: number;
395
+ }
396
+ interface FeedListResponse {
397
+ feeds: FeedListItem[];
398
+ next_cursor?: string;
399
+ has_more: boolean;
400
+ }
401
+ interface AutomationInspectRequest {
402
+ /** Numeric automation id. Currently the same underlying feed id. */
403
+ id: number;
404
+ }
405
+ interface AutomationInspectResponse {
406
+ /** Numeric automation id encoded as a string, matching the gateway response. */
407
+ id: string;
408
+ /** Backing feed id encoded as a string. */
409
+ feed_id: string;
410
+ name: string;
411
+ description?: string;
412
+ /** Automation runtime status. */
413
+ status: 'ACTIVE' | 'PAUSED' | 'UNSPECIFIED' | (string & {});
414
+ cron_expression?: string;
415
+ total_runs: number;
416
+ /**
417
+ * Backend product-flow registry id. Null for ordinary non-flow automations.
418
+ */
419
+ flow_id: string | null;
420
+ /**
421
+ * Absolute ALFS config path for caller-owned product-flow automations.
422
+ * Null for ordinary automations and product-flow automations not owned by
423
+ * the caller.
424
+ */
425
+ flow_config_path: string | null;
426
+ }
427
+ interface FeedStatusUpdateRequest {
428
+ /** Numeric feed id to stop/resume. */
429
+ id: number;
430
+ }
431
+ interface FeedStatusUpdateResponse {
432
+ /** Echoed feed id (string form, matching gateway response). */
433
+ id: string;
434
+ /** Feed runtime status after the update. */
435
+ status: 'ACTIVE' | 'PAUSED' | 'UNSPECIFIED' | (string & {});
436
+ }
437
+ interface FeedDeleteResponse {
438
+ /** Echoed feed id (string form, matching gateway response). */
439
+ id: string;
440
+ }
441
+ /** Feed visibility: 'public' publishes the feed, 'private' unpublishes it. */
442
+ type FeedVisibility = 'public' | 'private';
443
+ interface FeedSetVisibilityRequest {
444
+ /** Numeric feed id to publish/unpublish. */
445
+ id: number;
446
+ /** Target visibility. */
447
+ visibility: FeedVisibility;
448
+ }
449
+ interface FeedSetVisibilityResponse {
450
+ /** Echoed feed id (string form, matching gateway response). */
451
+ id: string;
452
+ /** Feed visibility after the update. */
453
+ visibility: FeedVisibility;
454
+ }
455
+ interface PlaybookDraftRequest {
456
+ name: string;
457
+ display_name: string;
458
+ description?: string;
459
+ feeds: Array<{
460
+ feed_id: number;
461
+ feed_major?: number;
462
+ }>;
463
+ trading_symbols?: string[];
464
+ /**
465
+ * Optional source-skill reference in "username/name" form (e.g.
466
+ * "alva/screener"). The value identifies a playbook skill published to
467
+ * Skillhub; discover available skills via `alva skillhub list`.
468
+ * Persisted set-once on the playbook's first draft; subsequent drafts
469
+ * ignore the field.
470
+ */
471
+ skill_id?: string;
472
+ /**
473
+ * Optional discovery tags (max 10, each up to 32 characters). On a
474
+ * playbook's first draft these merge with any template-inherited tags;
475
+ * on a re-draft of an existing playbook they replace the current tag
476
+ * set. Omitted/empty leaves tags unchanged.
477
+ */
478
+ tags?: string[];
479
+ }
480
+ interface PlaybookDraftResponse {
481
+ playbook_id: number;
482
+ playbook_version_id: number;
483
+ /** Canonical alfs path: `/alva/home/<username>/playbooks/<name>`. */
484
+ playbook_path: string;
485
+ }
486
+ interface PlaybookReleaseRequest {
487
+ name: string;
488
+ version: string;
489
+ feeds: Array<{
490
+ feed_id: number;
491
+ feed_major?: number;
492
+ }>;
493
+ changelog: string;
494
+ /**
495
+ * Owner-attested README location. Server validates the value is one of:
496
+ * - relative: `<name>/README.md`
497
+ * - absolute: `/alva/home/<username>/playbooks/<name>/README.md`
498
+ * The owner is responsible for placing the README at that path on ALFS
499
+ * before publish; the server does not write the file.
500
+ */
501
+ readme_url: string;
502
+ }
503
+ interface PlaybookReleaseResponse {
504
+ playbook_id: number;
505
+ version: string;
506
+ published_url: string;
507
+ /** Canonical alfs path: `/alva/home/<username>/playbooks/<name>`. */
508
+ playbook_path: string;
509
+ }
510
+ interface CreateSecretRequest {
511
+ name: string;
512
+ value: string;
513
+ }
514
+ interface SecretMetadata {
515
+ name: string;
516
+ keyVersion: number;
517
+ createdAt: string;
518
+ updatedAt: string;
519
+ valueLength: number;
520
+ keyPrefix: string;
521
+ }
522
+ interface Secret {
523
+ name: string;
524
+ value: string;
525
+ createdAt: string;
526
+ updatedAt: string;
527
+ }
528
+ interface ModuleDoc {
529
+ name: string;
530
+ doc: string;
531
+ }
532
+ interface PartitionsResponse {
533
+ partitions: string[];
534
+ }
535
+ interface PartitionSummaryResponse {
536
+ summary: string;
537
+ }
538
+ interface CreateCommentRequest {
539
+ username: string;
540
+ name: string;
541
+ content: string;
542
+ parent_id?: number;
543
+ }
544
+ interface Comment {
545
+ id: number;
546
+ playbook_id: number;
547
+ content: string;
548
+ pin_at: number | null;
549
+ created_at: number;
550
+ updated_at: number;
551
+ creator?: {
552
+ id: string;
553
+ name: string;
554
+ avatar: string;
555
+ };
556
+ agent?: {
557
+ name: string;
558
+ };
559
+ }
560
+ interface RemixRequest {
561
+ child: {
562
+ username: string;
563
+ name: string;
564
+ };
565
+ parents: Array<{
566
+ username: string;
567
+ name: string;
568
+ }>;
569
+ }
570
+ interface ScreenshotParams {
571
+ url: string;
572
+ selector?: string;
573
+ xpath?: string;
574
+ compress?: boolean;
575
+ compressQuality?: number;
576
+ compressMaxWidth?: number;
577
+ }
578
+ interface TradingAccount {
579
+ id: string;
580
+ name: string;
581
+ exchange: string;
582
+ paper: boolean;
583
+ identifier: string;
584
+ createdAtMs: number;
585
+ subscriptions: AccountSubscription[];
586
+ }
587
+ interface AccountSubscription {
588
+ id: string;
589
+ sourceUsername: string;
590
+ sourceFeed: string;
591
+ playbookId: string;
592
+ playbookName: string;
593
+ active: boolean;
594
+ }
595
+ interface TradingSubscription {
596
+ id: string;
597
+ accountId: string;
598
+ sourceUsername: string;
599
+ sourceFeed: string;
600
+ active: boolean;
601
+ deactivateReason?: string;
602
+ playbookId: string;
603
+ playbookVersion: string;
604
+ createdAtMs: number;
605
+ watermark: number;
606
+ }
607
+ interface TradingOrder {
608
+ orderId: string;
609
+ symbol: string;
610
+ side: string;
611
+ requestedQty: number;
612
+ filledQty: number;
613
+ price: number;
614
+ status: string;
615
+ rejectReason?: string;
616
+ source: string;
617
+ sourcePlaybook: string;
618
+ subscriptionId?: string;
619
+ dryRun: boolean;
620
+ createdAtMs: number;
621
+ }
622
+ interface PortfolioAsset {
623
+ symbol: string;
624
+ side: string;
625
+ quantity: number;
626
+ entryPrice: number;
627
+ currentPrice?: number;
628
+ marketValue?: number;
629
+ unrealizedPnl?: number;
630
+ allocation?: number;
631
+ }
632
+ interface TradingPortfolio {
633
+ equity: number;
634
+ cash: number;
635
+ unrealizedPnl?: number;
636
+ assets: PortfolioAsset[];
637
+ }
638
+ interface EquityPoint {
639
+ timestamp: number;
640
+ equity: number;
641
+ pnl: number;
642
+ pnlPct: number;
643
+ }
644
+ interface RiskRuleEntry {
645
+ value: number;
646
+ enabled: boolean;
647
+ }
648
+ interface TradingRiskRule {
649
+ maxSingleOrder: RiskRuleEntry;
650
+ maxDailyTurnover: RiskRuleEntry;
651
+ maxDailyOrders: RiskRuleEntry;
652
+ }
653
+ type TradingRiskRuleInput = TradingRiskRule;
654
+ interface ExecuteSignalOrder {
655
+ orderId: string;
656
+ symbol: string;
657
+ side: string;
658
+ requestedQty: number;
659
+ filledQty: number;
660
+ price: number;
661
+ status: string;
662
+ rejectReason?: string;
663
+ }
664
+ interface ExecuteSignalResult {
665
+ status: string;
666
+ orders: ExecuteSignalOrder[];
667
+ error?: string;
668
+ }
669
+ interface PortfolioAccount {
670
+ id: string;
671
+ provider: 'TREX' | 'SNAPTRADE';
672
+ name: string;
673
+ institution: string;
674
+ identifier?: string;
675
+ readOnly: boolean;
676
+ paper: boolean;
677
+ exchange?: string;
678
+ createdAtMs?: number;
679
+ subscriptions: PortfolioAccountSubscription[];
680
+ status?: string;
681
+ statusReason?: string;
682
+ lastSyncedAtMs?: number;
683
+ connectionId?: string;
684
+ }
685
+ interface PortfolioAccountSubscription {
686
+ id: string;
687
+ sourceUsername: string;
688
+ sourceFeed: string;
689
+ playbookId: string;
690
+ playbookName: string;
691
+ playbookVersion: string;
692
+ active: boolean;
693
+ deactivateReason?: string;
694
+ createdAt: number;
695
+ watermark: number;
696
+ }
697
+ interface PortfolioMoney {
698
+ amount: number;
699
+ currency: string;
700
+ currencySymbol: string;
701
+ }
702
+ interface PortfolioHolding {
703
+ symbol: string;
704
+ side?: string;
705
+ quantity: number;
706
+ avgCost?: PortfolioMoney;
707
+ currentPrice?: PortfolioMoney;
708
+ marketValue?: PortfolioMoney;
709
+ unrealizedPnl?: PortfolioMoney;
710
+ allocation?: number;
711
+ }
712
+ interface PortfolioSummary {
713
+ totalValue?: PortfolioMoney;
714
+ cash?: PortfolioMoney;
715
+ unrealizedPnl?: PortfolioMoney;
716
+ holdings: PortfolioHolding[];
717
+ asOfMs?: number;
718
+ }
719
+ interface PortfolioActivity {
720
+ id: string;
721
+ kind: string;
722
+ type: string;
723
+ occurredAtMs?: number;
724
+ symbol?: string;
725
+ side?: string;
726
+ quantity?: number;
727
+ price?: PortfolioMoney;
728
+ amount?: PortfolioMoney;
729
+ fee?: PortfolioMoney;
730
+ status?: string;
731
+ sourceLabel?: string;
732
+ description?: string;
733
+ externalReferenceId?: string;
734
+ }
735
+ interface PortfolioActivityConnection {
736
+ activities: PortfolioActivity[];
737
+ nextPageToken?: string;
738
+ }
739
+ interface NotificationListParams {
740
+ username: string;
741
+ name: string;
742
+ channel?: string;
743
+ /** `sent` / `failed` / `filtered`. */
744
+ status?: string;
745
+ /** Unix seconds; only notifications newer than this. */
746
+ since_time?: number;
747
+ /** Page size, default 50, max 200. */
748
+ first?: number;
749
+ /** Opaque cursor token from previous page's `next_cursor`. */
750
+ cursor?: string;
751
+ }
752
+ interface NotificationEvent {
753
+ id: string;
754
+ event_type: string;
755
+ user_id: string;
756
+ channel: string;
757
+ /** `sent` / `failed` / `filtered`. */
758
+ status: string;
759
+ /** Unix seconds. */
760
+ created_at: number;
761
+ message?: string;
762
+ error_msg?: string;
763
+ feed_id: string;
764
+ }
765
+ interface FeedNotificationListResponse {
766
+ items: NotificationEvent[];
767
+ next_cursor: string;
768
+ /** Canonical alfs path: `/alva/home/<username>/feeds/<name>`. */
769
+ feed_path: string;
770
+ }
771
+ type NotificationPreferenceKey = 'session_completed';
772
+ interface NotificationPreference {
773
+ key: NotificationPreferenceKey;
774
+ enabled: boolean;
775
+ }
776
+ interface NotificationPreferencesResponse {
777
+ settings: NotificationPreference[];
778
+ }
779
+ interface NotificationPreferenceUpdateParams {
780
+ key: NotificationPreferenceKey;
781
+ enabled: boolean;
782
+ }
783
+ interface NotificationPreferenceUpdateResponse {
784
+ setting: NotificationPreference;
785
+ }
786
+ interface SubmitFeedbackRequest {
787
+ /** Defaults to "agent_detected" on the server. */
788
+ source?: 'agent_detected' | 'user_reported' | 'system_detected' | string;
789
+ /** Defaults to "other" on the server. */
790
+ category?: 'api_error' | 'data_quality' | 'docs' | 'runtime' | 'auth' | 'billing' | 'other' | string;
791
+ /** Defaults to "medium" on the server. */
792
+ severity?: 'low' | 'medium' | 'high' | 'critical' | string;
793
+ summary: string;
794
+ details?: string;
795
+ /** Optional structured diagnostics; omit unless the agent has useful metadata. */
796
+ evidence?: Record<string, unknown>;
797
+ /** Optional structured session metadata; omit unless relevant to triage. */
798
+ context?: Record<string, unknown>;
799
+ }
800
+ interface SubmitFeedbackResponse {
801
+ feedback_id: number;
802
+ notion_page_id: string;
803
+ notion_url: string;
804
+ }
805
+ /** Personal alert subscriptions are keyed only to feeds. */
806
+ type PushTargetType = 'FEED';
807
+ interface PushTarget {
808
+ type: PushTargetType;
809
+ /** Numeric id encoded as a string (matches the rest of the SDK). */
810
+ id: string;
811
+ }
812
+ interface PushSubscription {
813
+ target: PushTarget;
814
+ created_at_ms: number;
815
+ updated_at_ms: number;
816
+ /** Alva delivery channel id. "0" denotes the agent/home channel. */
817
+ channel_id?: string;
818
+ /** Present on list responses. */
819
+ cursor?: string;
820
+ /** Feed metadata is present for FEED targets when available. */
821
+ feed_name?: string;
822
+ feed_status?: 'ACTIVE' | 'PAUSED' | 'UNSPECIFIED' | string;
823
+ /** Unix milliseconds of the latest successful delivery for this user+target. */
824
+ last_pushed_at_ms?: number;
825
+ /** Playbooks whose latest release currently references this feed. */
826
+ used_by?: PushSubscriptionUsedBy[];
827
+ used_by_total?: number;
828
+ /** Row-shape discriminator. */
829
+ kind?: 'FEED_ALERT';
830
+ /**
831
+ * Target lifecycle. TARGET_DELETED marks a feed row whose target was
832
+ * deleted; clear it with unsubscribeBatch by target id.
833
+ */
834
+ target_status?: 'ACTIVE' | 'TARGET_DELETED' | 'PAUSED' | 'UNSPECIFIED' | string;
835
+ }
836
+ interface PushSubscriptionUsedBy {
837
+ playbook_id: string;
838
+ owner_username: string;
839
+ playbook_name: string;
840
+ display_name: string;
841
+ owner_avatar_url: string;
842
+ }
843
+ interface PlaybookFollowParams {
844
+ username: string;
845
+ name: string;
846
+ }
847
+ interface PushSubscriptionFeedParams {
848
+ username: string;
849
+ name: string;
850
+ }
851
+ interface SubscribeFeedParams extends PushSubscriptionFeedParams {
852
+ /** Delivery channel id. Omit for the user's agent/home channel. */
853
+ channelId?: string;
854
+ }
855
+ interface PushSubscriptionListParams {
856
+ /** Page size, default 50, max 200 server-side. */
857
+ first?: number;
858
+ /** Opaque cursor token from previous page's `next_cursor`. */
859
+ cursor?: string;
860
+ }
861
+ interface PushSubscriptionListResponse {
862
+ items: PushSubscription[];
863
+ /** Empty when there is no next page. */
864
+ next_cursor?: string;
865
+ /**
866
+ * Total active subscription rows independent of pagination — when
867
+ * items.length < total_count, the page is truncated; keep paginating.
868
+ */
869
+ total_count?: number;
870
+ }
871
+ interface FollowsListParams {
872
+ /** Page size, default 50, max 100 server-side. */
873
+ limit?: number;
874
+ /** Opaque cursor from the previous page's `next_cursor`. */
875
+ cursor?: string;
876
+ }
877
+ interface PlaybookFollowItem {
878
+ playbook_id: string;
879
+ owner_username: string;
880
+ name: string;
881
+ display_name: string;
882
+ followed_at_ms: number;
883
+ cursor: string;
884
+ }
885
+ interface FollowsListResponse {
886
+ items: PlaybookFollowItem[];
887
+ has_next: boolean;
888
+ next_cursor?: string;
889
+ }
890
+ interface UnsubscribeBatchParams {
891
+ /** Feed target ids (strings — snowflake ids exceed JS safe integers). */
892
+ feedIds: string[];
893
+ }
894
+ interface SubscribeBatchParams {
895
+ /** Feed target ids (strings — snowflake ids exceed JS safe integers). */
896
+ feedIds: string[];
897
+ /** Delivery channel id. Omit for the user's agent/home channel. */
898
+ channelId?: string;
899
+ }
900
+ interface SubscribeBatchResponse {
901
+ subscriptions: PushSubscription[];
902
+ }
903
+ interface UnsubscribeBatchResult {
904
+ id: string;
905
+ kind: 'FEED';
906
+ ok: boolean;
907
+ status: 'UNSUBSCRIBED' | 'INVALID_ID' | string;
908
+ }
909
+ interface UnsubscribeBatchResponse {
910
+ results: UnsubscribeBatchResult[];
911
+ ok_count: number;
912
+ }
913
+ interface PlaybookFollow {
914
+ id: string;
915
+ user_id: string;
916
+ playbook_id: string;
917
+ created_at_ms: number;
918
+ updated_at_ms: number;
919
+ }
920
+ interface FollowPlaybookResponse {
921
+ /** The social follow row created or confirmed by this operation. */
922
+ follow: PlaybookFollow;
923
+ /** Canonical alfs path: `/alva/home/<username>/playbooks/<name>`. */
924
+ playbook_path: string;
925
+ }
926
+ interface UnfollowPlaybookResponse {
927
+ ok: true;
928
+ unfollowed: boolean;
929
+ }
930
+ interface SubscribeFeedResponse {
931
+ subscription: PushSubscription;
932
+ /** Canonical alfs path: `/alva/home/<username>/feeds/<name>`. */
933
+ feed_path: string;
934
+ }
935
+ interface UnsubscribeResponse {
936
+ ok: true;
937
+ }
938
+ type ChannelGroupSubscriptionTargetType = 'feed';
939
+ interface ChannelGroupSubscriptionTarget {
940
+ type: ChannelGroupSubscriptionTargetType;
941
+ id: number;
942
+ }
943
+ interface ChannelGroupSubscription {
944
+ event_type: string;
945
+ target: ChannelGroupSubscriptionTarget | null;
946
+ subscribed_by_user_id: number;
947
+ enabled: boolean;
948
+ created_at_ms: number;
949
+ updated_at_ms: number;
950
+ }
951
+ interface ChannelGroupCallerInfo {
952
+ user_id: number;
953
+ is_admin: boolean;
954
+ }
955
+ interface ChannelGroupAdminInfo {
956
+ user_id: number;
957
+ username: string;
958
+ telegram_user_id: string;
959
+ telegram_username: string;
960
+ }
961
+ interface ChannelGroupSubscriptionSessionParams {
962
+ session_id: number | string;
963
+ }
964
+ interface ChannelGroupSubscriptionMutationParams extends ChannelGroupSubscriptionSessionParams {
965
+ target_type: 'feed';
966
+ target_id: number | string;
967
+ }
968
+ interface ChannelGroupSubscriptionContextResponse {
969
+ channel_id: string;
970
+ remote_chat_id: string;
971
+ caller: ChannelGroupCallerInfo;
972
+ admin: ChannelGroupAdminInfo | null;
973
+ subscriptions: ChannelGroupSubscription[];
974
+ }
975
+ interface ChannelGroupSubscriptionListResponse {
976
+ subscriptions: ChannelGroupSubscription[];
977
+ }
978
+ interface ChannelGroupSubscriptionMutationResponse {
979
+ ok: boolean;
980
+ reason: string;
981
+ caller: ChannelGroupCallerInfo;
982
+ admin: ChannelGroupAdminInfo | null;
983
+ subscriptions: ChannelGroupSubscription[];
984
+ }
985
+ /** Params for reading a group's buffered chat history (group-chat digest). */
986
+ interface ChannelGroupHistoryParams {
987
+ /** Platform: "telegram" | "discord" | "slack". */
988
+ channel: string;
989
+ /** Platform group/channel id. */
990
+ remote_chat_id: string;
991
+ /** Window start, message-origin timestamp in microseconds (inclusive). */
992
+ from_micros: number | string;
993
+ /** Window end, message-origin timestamp in microseconds (inclusive). */
994
+ to_micros: number | string;
995
+ }
996
+ /** One buffered group message, projected for the digest. */
997
+ interface GroupChatMessage {
998
+ sender_username: string;
999
+ content: string;
1000
+ /** "[photo]" etc. when the message carried media. */
1001
+ media_summary: string;
1002
+ ts_micros: number;
1003
+ /** Deep link back to the original message; empty when unavailable. */
1004
+ permalink: string;
1005
+ /** "user" | "assistant" (bot replies). */
1006
+ role: string;
1007
+ }
1008
+ interface ChannelGroupHistoryResponse {
1009
+ /** Chronological (ts ascending). */
1010
+ messages: GroupChatMessage[];
1011
+ }
1012
+ interface ServiceAccount {
1013
+ id: string;
1014
+ display_name: string;
1015
+ username: string;
1016
+ parent_user_id: string;
1017
+ created_at?: number;
1018
+ }
1019
+ interface ServiceAccountCreateRequest {
1020
+ display_name: string;
1021
+ }
1022
+ interface ServiceAccountCreateResponse {
1023
+ service_account: ServiceAccount;
1024
+ }
1025
+ interface ServiceAccountListResponse {
1026
+ service_accounts: ServiceAccount[];
1027
+ }
1028
+ interface ServiceAccountGrantRequest {
1029
+ id: string;
1030
+ path: string;
1031
+ permission: string;
1032
+ }
1033
+
1034
+ declare class FsResource {
1035
+ private client;
1036
+ constructor(client: AlvaClient);
1037
+ /** Returns `ArrayBuffer` for binary files, or parsed JSON for time-series virtual paths. */
1038
+ read(params: FsReadParams): Promise<ArrayBuffer | unknown>;
1039
+ /** Write file using JSON body (Mode 2). For text content. */
1040
+ write(params: FsWriteParams): Promise<FsWriteResponse>;
1041
+ /** Write file using raw body (Mode 1). Supports binary data. Path and options are query params. */
1042
+ rawWrite(params: FsRawWriteParams): Promise<FsWriteResponse>;
1043
+ stat(params: {
1044
+ path: string;
1045
+ }): Promise<FsStat>;
1046
+ readdir(params: FsReaddirParams): Promise<FsReaddirResponse>;
1047
+ mkdir(params: FsMkdirParams): Promise<void>;
1048
+ remove(params: FsRemoveParams): Promise<void>;
1049
+ rename(params: FsRenameParams): Promise<void>;
1050
+ copy(params: FsCopyParams): Promise<void>;
1051
+ symlink(params: FsSymlinkParams): Promise<void>;
1052
+ readlink(params: FsReadlinkParams): Promise<{
1053
+ target: string;
1054
+ }>;
1055
+ chmod(params: FsChmodParams): Promise<void>;
1056
+ grant(params: FsGrantParams): Promise<void>;
1057
+ revoke(params: FsRevokeParams): Promise<void>;
1058
+ }
1059
+
1060
+ declare class RunResource {
1061
+ private client;
1062
+ constructor(client: AlvaClient);
1063
+ execute(params: RunRequest): Promise<RunResponse>;
1064
+ }
1065
+
1066
+ declare class DeployResource {
1067
+ private client;
1068
+ constructor(client: AlvaClient);
1069
+ create(params: CronjobCreateRequest): Promise<Cronjob>;
1070
+ list(params?: CronjobListParams): Promise<CronjobListResponse>;
1071
+ get(params: {
1072
+ id: number;
1073
+ }): Promise<Cronjob>;
1074
+ update(params: CronjobUpdateRequest): Promise<Cronjob>;
1075
+ delete(params: {
1076
+ id: number;
1077
+ }): Promise<void>;
1078
+ pause(params: {
1079
+ id: number;
1080
+ }): Promise<void>;
1081
+ resume(params: {
1082
+ id: number;
1083
+ }): Promise<void>;
1084
+ /**
1085
+ * Fire the cronjob workflow once, immediately, bypassing the schedule.
1086
+ * This is not a dry run: when publisher push and subscriber alert bindings
1087
+ * are enabled, a successful Feed execution may send real notifications.
1088
+ * Async — returns the Hatchet workflow run id at enqueue. The
1089
+ * `cronjob_runs` row can appear as DISPATCHED/RUNNING before it reaches a
1090
+ * terminal status; callers verify completion by polling
1091
+ * `getRunStatus({cronjob_id, workflow_run_id})` with their own
1092
+ * timeout/deadline.
1093
+ *
1094
+ * Surfaces backend status as HTTP errors (handled by AlvaClient):
1095
+ * - 404 not found / cross-user
1096
+ * - 412 cronjob is paused (resume before triggering)
1097
+ * - 503 worker workflow handle not yet connected (startup race)
1098
+ */
1099
+ trigger(params: {
1100
+ id: number;
1101
+ }): Promise<CronjobTriggerResponse>;
1102
+ listRuns(params: CronjobRunsListParams): Promise<CronjobRunsListResponse>;
1103
+ getRunStatus(params: CronjobRunStatusParams): Promise<CronjobRunStatusResponse>;
1104
+ getRunLogs(params: {
1105
+ cronjob_id: number;
1106
+ run_id: number;
1107
+ }): Promise<CronjobRunLogsResponse>;
1108
+ }
1109
+
1110
+ /**
1111
+ * Service-account lifecycle: create a restricted run-as identity, list/delete
1112
+ * the ones you own, and grant/revoke its ALFS paths. Set the resulting id as
1113
+ * `--run-as-service-account` on a UDF or cronjob to run it under that scoped
1114
+ * identity (billing/audit stay with you). See the service-accounts skill
1115
+ * reference. Owner-gated by the backend — an SA cannot manage SAs.
1116
+ */
1117
+ declare class ServiceAccountResource {
1118
+ private client;
1119
+ constructor(client: AlvaClient);
1120
+ create(params: ServiceAccountCreateRequest): Promise<ServiceAccountCreateResponse>;
1121
+ list(): Promise<ServiceAccountListResponse>;
1122
+ delete(params: {
1123
+ id: string;
1124
+ }): Promise<void>;
1125
+ grant(params: ServiceAccountGrantRequest): Promise<void>;
1126
+ revoke(params: ServiceAccountGrantRequest): Promise<void>;
1127
+ }
1128
+
1129
+ declare class ReleaseResource {
1130
+ private client;
1131
+ constructor(client: AlvaClient);
1132
+ feed(params: FeedReleaseRequest): Promise<FeedReleaseResponse>;
1133
+ playbookDraft(params: PlaybookDraftRequest): Promise<PlaybookDraftResponse>;
1134
+ playbook(params: PlaybookReleaseRequest): Promise<PlaybookReleaseResponse>;
1135
+ }
1136
+
1137
+ /**
1138
+ * Feed lifecycle management. Backed by alva-gateway REST (mirrors the
1139
+ * GraphQL surface in `pkg/schema/feed.graphql`).
1140
+ */
1141
+ declare class FeedResource {
1142
+ private client;
1143
+ constructor(client: AlvaClient);
1144
+ /**
1145
+ * List feeds owned by the caller. Backed by GET /api/v1/feed.
1146
+ */
1147
+ list(params?: FeedListParams): Promise<FeedListResponse>;
1148
+ /**
1149
+ * Stop a feed's producer cronjob. This pauses future scheduled runs while
1150
+ * preserving the feed and its existing data.
1151
+ *
1152
+ * Auth: caller must own the feed (uid match), enforced by the backend.
1153
+ */
1154
+ stop(params: FeedStatusUpdateRequest): Promise<FeedStatusUpdateResponse>;
1155
+ /**
1156
+ * Resume a stopped feed's producer cronjob.
1157
+ *
1158
+ * Auth: caller must own the feed (uid match), enforced by the backend.
1159
+ */
1160
+ resume(params: FeedStatusUpdateRequest): Promise<FeedStatusUpdateResponse>;
1161
+ /**
1162
+ * Soft-delete a feed and all its active majors. Cascades:
1163
+ * - all active feed_majors are soft-deleted in the same transaction
1164
+ * - associated producer cronjobs are removed best-effort (the cronjob
1165
+ * scavenger reconciles any leftover rows on its next sweep)
1166
+ *
1167
+ * Auth: caller must own the feed (uid match), enforced by the backend.
1168
+ */
1169
+ delete(params: FeedDeleteRequest): Promise<FeedDeleteResponse>;
1170
+ /**
1171
+ * Publish or unpublish a feed. Backed by POST /api/v1/feed/:id/visibility.
1172
+ *
1173
+ * Setting visibility to 'public' publishes the feed (the backend sets
1174
+ * feeds.is_public and projects the ALFS public read grant in the same
1175
+ * transaction); 'private' unpublishes it. Prefer this over granting the
1176
+ * ALFS public read subject directly (e.g. `alva fs grant`), which bypasses
1177
+ * the is_public flag and causes drift.
1178
+ *
1179
+ * Auth: caller must own the feed (uid match), enforced by the backend.
1180
+ */
1181
+ setVisibility(params: FeedSetVisibilityRequest): Promise<FeedSetVisibilityResponse>;
1182
+ }
1183
+
1184
+ /**
1185
+ * Product-facing automation API. Backed by the existing feed/release gateway
1186
+ * surfaces while those lower-level names remain on the wire for compatibility.
1187
+ */
1188
+ declare class AutomationResource {
1189
+ private client;
1190
+ constructor(client: AlvaClient);
1191
+ list(params?: FeedListParams): Promise<FeedListResponse>;
1192
+ /**
1193
+ * Inspect one automation. Backed by GET /api/v1/automation/:id.
1194
+ */
1195
+ inspect(params: AutomationInspectRequest): Promise<AutomationInspectResponse>;
1196
+ stop(params: FeedStatusUpdateRequest): Promise<FeedStatusUpdateResponse>;
1197
+ resume(params: FeedStatusUpdateRequest): Promise<FeedStatusUpdateResponse>;
1198
+ delete(params: FeedDeleteRequest): Promise<FeedDeleteResponse>;
1199
+ publish(params: FeedReleaseRequest): Promise<FeedReleaseResponse>;
1200
+ }
1201
+
1202
+ /** Playbook visibility states understood by the gateway. */
1203
+ type PlaybookVisibility = 'public' | 'private' | 'paid';
1204
+ interface SetVisibilityParams {
1205
+ /** URL-safe playbook name. The owner is derived server-side from auth. */
1206
+ name: string;
1207
+ /** Target visibility: public, private, or paid. */
1208
+ visibility: PlaybookVisibility;
1209
+ }
1210
+ interface SetVisibilityResponse {
1211
+ /** ALFS-style "<owner>/<name>" path echoed back by the gateway. */
1212
+ playbook_path: string;
1213
+ }
1214
+ type TrendingPlaybooksSort = 'FOLLOWS' | 'RECENT';
1215
+ type TrendingPlaybooksDir = 'FORWARD' | 'BACKWARD';
1216
+ interface TrendingPlaybooksParams {
1217
+ /** Opaque cursor returned on a previous item. Alias of `current`. */
1218
+ cursor?: string;
1219
+ /** GraphQL-compatible cursor field name. Alias of `cursor`. */
1220
+ current?: string;
1221
+ /** Page size, default 50, max 100 server-side. */
1222
+ limit?: number;
1223
+ /** Only FORWARD is supported by the gateway today. */
1224
+ dir?: TrendingPlaybooksDir;
1225
+ /** FOLLOWS = most followed, RECENT = newest first. */
1226
+ sort?: TrendingPlaybooksSort;
1227
+ /** Optional AND-filter tags. */
1228
+ tags?: string[];
1229
+ /** Optional weighted search across playbook and creator fields. */
1230
+ keyword?: string;
1231
+ }
1232
+ interface TrendingPlaybookItem {
1233
+ /** Numeric playbook id encoded as a string. */
1234
+ id: string;
1235
+ /** Stable "owner/name" handle, useful for follow-up tool calls. */
1236
+ ref: string;
1237
+ /** Owner username. */
1238
+ username: string;
1239
+ /** URL-safe playbook name. */
1240
+ name: string;
1241
+ display_name: string;
1242
+ description: string;
1243
+ tags: string[];
1244
+ follow_count: number;
1245
+ /** Relative web path for opening or citing the playbook, e.g. `/u/alice/playbooks/btc`. */
1246
+ url_path: string;
1247
+ /** Absolute, clickable web URL, e.g. `https://alva.ai/u/alice/playbooks/btc`. */
1248
+ url: string;
1249
+ /** README ALFS path when available. */
1250
+ readme?: string;
1251
+ /** Cursor to pass as `cursor` / `current` for pagination. */
1252
+ cursor: string;
1253
+ }
1254
+ interface TrendingPlaybooksResponse {
1255
+ playbooks: TrendingPlaybookItem[];
1256
+ has_next: boolean;
1257
+ }
1258
+ /**
1259
+ * Public playbook discovery. Backed by alva-gateway REST and mirrors the
1260
+ * GraphQL `trendingPlaybooks(cursor, sort, tags, keyword)` query.
1261
+ */
1262
+ /** Compact discovery record returned by getByIds / listByOwner / get. */
1263
+ interface PlaybookDiscoveryItem {
1264
+ /** Numeric playbook id encoded as a string. */
1265
+ id: string;
1266
+ /** Owner username (empty when not resolvable). */
1267
+ owner_username: string;
1268
+ /** URL-safe playbook name. */
1269
+ name: string;
1270
+ display_name: string;
1271
+ visibility: string;
1272
+ /** Stable "owner/name" handle for name-addressed operations. */
1273
+ ref?: string;
1274
+ /** Present on listByOwner rows. */
1275
+ cursor?: string;
1276
+ }
1277
+ interface DiscoveryByIDsResponse {
1278
+ items: PlaybookDiscoveryItem[];
1279
+ }
1280
+ interface ListByOwnerParams {
1281
+ owner: string;
1282
+ /** Page size, default 50, max 100 server-side. */
1283
+ limit?: number;
1284
+ cursor?: string;
1285
+ }
1286
+ interface ListByOwnerResponse {
1287
+ items: PlaybookDiscoveryItem[];
1288
+ has_next: boolean;
1289
+ next_cursor?: string;
1290
+ }
1291
+ declare class PlaybooksResource {
1292
+ private client;
1293
+ constructor(client: AlvaClient);
1294
+ /**
1295
+ * Resolve playbook ids to named, addressable records (mono-meta#584 A2).
1296
+ * Visibility-gated server-side; ids the caller cannot see — and DELETED
1297
+ * playbook ids — return no row. Treat a missing id as "deleted or not
1298
+ * visible" (the subscriptions list's `target_status` distinguishes ghosts).
1299
+ * Ids are strings (snowflake-safe). Max 100 per call.
1300
+ *
1301
+ * Auth is optional (like `trending`): with an API key, private/paid
1302
+ * visibility is evaluated for the caller; without one, only public
1303
+ * playbooks resolve. The server decides — no client-side gate.
1304
+ */
1305
+ getByIds(ids: string[]): Promise<DiscoveryByIDsResponse>;
1306
+ /**
1307
+ * List a user's playbooks by owner username (mono-meta#584 C10).
1308
+ * Visibility-gated: another user's private playbooks are omitted.
1309
+ * Auth is optional (like `trending`); without credentials only public
1310
+ * playbooks are listed.
1311
+ */
1312
+ listByOwner(params: ListByOwnerParams): Promise<ListByOwnerResponse>;
1313
+ /**
1314
+ * Get one playbook by numeric id or by "owner/name" ref. Returns null when
1315
+ * not found / not visible / deleted.
1316
+ */
1317
+ get(params: {
1318
+ id?: string;
1319
+ ref?: string;
1320
+ }): Promise<PlaybookDiscoveryItem | null>;
1321
+ /**
1322
+ * List trending / searchable playbooks. Auth is optional: when the client
1323
+ * has an API key it is forwarded, otherwise this uses the public surface.
1324
+ *
1325
+ * The gateway returns a frontend-oriented preview payload; this SDK projects
1326
+ * it into a smaller, agent-friendly shape.
1327
+ */
1328
+ trending(params?: TrendingPlaybooksParams): Promise<TrendingPlaybooksResponse>;
1329
+ /**
1330
+ * Set a playbook's visibility. Requires authentication; the owner is
1331
+ * resolved server-side from the authenticated user, so only the playbook
1332
+ * `name` is needed.
1333
+ *
1334
+ * Note: `private` and `paid` are paid-tier capabilities. A free-tier user
1335
+ * receives a `PERMISSION_DENIED` error from the gateway, which is surfaced
1336
+ * here unchanged.
1337
+ */
1338
+ setVisibility(params: SetVisibilityParams): Promise<SetVisibilityResponse>;
1339
+ }
1340
+
1341
+ declare class SecretsResource {
1342
+ private client;
1343
+ constructor(client: AlvaClient);
1344
+ create(params: CreateSecretRequest): Promise<void>;
1345
+ list(): Promise<{
1346
+ secrets: SecretMetadata[];
1347
+ }>;
1348
+ get(params: {
1349
+ name: string;
1350
+ }): Promise<Secret>;
1351
+ update(params: {
1352
+ name: string;
1353
+ value: string;
1354
+ }): Promise<void>;
1355
+ delete(params: {
1356
+ name: string;
1357
+ }): Promise<void>;
1358
+ }
1359
+
1360
+ declare class SdkDocsResource {
1361
+ private client;
1362
+ constructor(client: AlvaClient);
1363
+ doc(params: {
1364
+ name: string;
1365
+ }): Promise<ModuleDoc>;
1366
+ partitions(): Promise<PartitionsResponse>;
1367
+ partitionSummary(params: {
1368
+ partition: string;
1369
+ }): Promise<PartitionSummaryResponse>;
1370
+ }
1371
+
1372
+ type SkillEndpointTier = 'public' | 'alternative' | 'unstructured';
1373
+ interface SkillEndpointMetadata {
1374
+ skill: string;
1375
+ file: string;
1376
+ method: string;
1377
+ path: string;
1378
+ tier: SkillEndpointTier;
1379
+ required_subscription_tier: 'free' | 'pro';
1380
+ access: 'free_and_pro' | 'pro_only';
1381
+ pro_required: boolean;
1382
+ }
1383
+
1384
+ type SkillTierCounts = Partial<Record<SkillEndpointTier, number>>;
1385
+
1386
+ interface SkillMetadata {
1387
+ endpoint_count: number;
1388
+ endpoint_tier_counts: SkillTierCounts;
1389
+ pro_count: number;
1390
+ }
1391
+ interface SkillSummary {
1392
+ name: string;
1393
+ description: string;
1394
+ metadata?: SkillMetadata;
1395
+ endpoint_tier_counts?: SkillTierCounts;
1396
+ }
1397
+ interface SkillDoc {
1398
+ name: string;
1399
+ description: string;
1400
+ content: string;
1401
+ metadata?: SkillMetadata | SkillEndpointMetadata;
1402
+ endpoint_metadata?: SkillEndpointMetadata[];
1403
+ endpoint_tier_counts?: SkillTierCounts;
1404
+ }
1405
+ declare class DataSkillsResource {
1406
+ private client;
1407
+ constructor(client: AlvaClient);
1408
+ list(): Promise<{
1409
+ skills: SkillSummary[];
1410
+ }>;
1411
+ summary(params: {
1412
+ name: string;
1413
+ }): Promise<SkillDoc>;
1414
+ endpoint(params: {
1415
+ name: string;
1416
+ file: string;
1417
+ }): Promise<SkillDoc>;
1418
+ }
1419
+
1420
+ interface PlaybookSkillSummary {
1421
+ username: string;
1422
+ name: string;
1423
+ display_name: string;
1424
+ description: string;
1425
+ tags: string[];
1426
+ creator_uid: number;
1427
+ updated_at: string;
1428
+ }
1429
+ interface PlaybookSkillFileMeta {
1430
+ path: string;
1431
+ size_bytes: number;
1432
+ }
1433
+ interface PlaybookSkillMeta extends PlaybookSkillSummary {
1434
+ files: PlaybookSkillFileMeta[];
1435
+ }
1436
+ interface PlaybookSkillFile {
1437
+ username: string;
1438
+ name: string;
1439
+ path: string;
1440
+ content: string;
1441
+ updated_at: string;
1442
+ }
1443
+ interface PlaybookSkillTagEntry {
1444
+ name: string;
1445
+ }
1446
+ declare class PlaybookSkillsResource {
1447
+ private client;
1448
+ constructor(client: AlvaClient);
1449
+ list(params?: {
1450
+ tag?: string;
1451
+ username?: string;
1452
+ }): Promise<{
1453
+ skills: PlaybookSkillSummary[];
1454
+ }>;
1455
+ tags(): Promise<{
1456
+ tags: PlaybookSkillTagEntry[];
1457
+ }>;
1458
+ get(id: string): Promise<PlaybookSkillMeta>;
1459
+ file(id: string, path: string): Promise<PlaybookSkillFile>;
1460
+ }
1461
+
1462
+ declare class CommentsResource {
1463
+ private client;
1464
+ constructor(client: AlvaClient);
1465
+ create(params: CreateCommentRequest): Promise<Comment>;
1466
+ pin(params: {
1467
+ comment_id: number;
1468
+ }): Promise<Comment>;
1469
+ unpin(params: {
1470
+ comment_id: number;
1471
+ }): Promise<Comment>;
1472
+ }
1473
+
1474
+ declare class RemixResource {
1475
+ private client;
1476
+ constructor(client: AlvaClient);
1477
+ save(params: RemixRequest): Promise<void>;
1478
+ }
1479
+
1480
+ declare class ScreenshotResource {
1481
+ private client;
1482
+ constructor(client: AlvaClient);
1483
+ capture(params: ScreenshotParams): Promise<ArrayBuffer>;
1484
+ }
1485
+
1486
+ declare class UserResource {
1487
+ private client;
1488
+ constructor(client: AlvaClient);
1489
+ me(): Promise<UserProfile>;
1490
+ }
1491
+
1492
+ declare class TradingResource {
1493
+ private client;
1494
+ constructor(client: AlvaClient);
1495
+ accounts(): Promise<TradingAccount[]>;
1496
+ portfolio(accountId: string): Promise<TradingPortfolio>;
1497
+ orders(params: {
1498
+ accountId: string;
1499
+ source?: string;
1500
+ since?: number;
1501
+ limit?: number;
1502
+ }): Promise<TradingOrder[]>;
1503
+ subscriptions(accountId: string): Promise<TradingSubscription[]>;
1504
+ equityHistory(params: {
1505
+ accountId: string;
1506
+ timeframe?: string;
1507
+ sinceMs?: number;
1508
+ untilMs?: number;
1509
+ }): Promise<EquityPoint[]>;
1510
+ riskRules(): Promise<TradingRiskRule>;
1511
+ subscribe(params: {
1512
+ accountId: string;
1513
+ sourceUsername: string;
1514
+ sourceFeed: string;
1515
+ playbookId: string;
1516
+ playbookVersion: string;
1517
+ executeLatest?: boolean;
1518
+ }): Promise<TradingSubscription>;
1519
+ unsubscribe(subscriptionId: string): Promise<{
1520
+ unsubscribedId: string;
1521
+ }>;
1522
+ execute(params: {
1523
+ accountId: string;
1524
+ signalJson: string;
1525
+ dryRun: boolean;
1526
+ sourceUsername?: string;
1527
+ sourceFeed?: string;
1528
+ }): Promise<ExecuteSignalResult>;
1529
+ updateRiskRules(rules: TradingRiskRuleInput): Promise<TradingRiskRule>;
1530
+ }
1531
+
1532
+ declare class PortfolioResource {
1533
+ private client;
1534
+ constructor(client: AlvaClient);
1535
+ accounts(): Promise<PortfolioAccount[]>;
1536
+ summary(accountId: string): Promise<PortfolioSummary>;
1537
+ activities(params: {
1538
+ accountId: string;
1539
+ limit?: number;
1540
+ pageToken?: string;
1541
+ }): Promise<PortfolioActivityConnection>;
1542
+ }
1543
+
1544
+ declare class ArraysJwtResource {
1545
+ private client;
1546
+ constructor(client: AlvaClient);
1547
+ /** Idempotently sign-or-renew the Arrays JWT server-side. */
1548
+ ensure(): Promise<EnsureArraysJwtResponse>;
1549
+ /** Report the current Arrays JWT state for the authenticated user. */
1550
+ status(): Promise<ArraysJwtStatusResponse>;
1551
+ }
1552
+
1553
+ declare class NotificationsResource {
1554
+ private client;
1555
+ constructor(client: AlvaClient);
1556
+ /**
1557
+ * List the caller's notification history for one feed
1558
+ * `(username, name)`. Authorization is alfs read on
1559
+ * `/alva/home/<username>/feeds/<name>`.
1560
+ */
1561
+ listFeed(params: NotificationListParams): Promise<FeedNotificationListResponse>;
1562
+ }
1563
+
1564
+ declare class NotificationPreferencesResource {
1565
+ private client;
1566
+ constructor(client: AlvaClient);
1567
+ /**
1568
+ * List the caller's notification preference settings. Server defaults
1569
+ * are included even when the caller has not explicitly stored a setting.
1570
+ */
1571
+ list(): Promise<NotificationPreferencesResponse>;
1572
+ /**
1573
+ * Enable or disable one notification preference.
1574
+ */
1575
+ update(params: NotificationPreferenceUpdateParams): Promise<NotificationPreferenceUpdateResponse>;
1576
+ }
1577
+
1578
+ /**
1579
+ * Playbook follows and FEED alert subscriptions.
1580
+ *
1581
+ * Three DISTINCT concepts share the word "subscribe" in the product; this
1582
+ * resource touches the first two and never the third:
1583
+ *
1584
+ * - **follow** — the social relation ("Subscribed Playbooks" in the UI).
1585
+ * Enumerate with `follows()`.
1586
+ * - **alerts** — push/notification opt-ins (what `list()` returns).
1587
+ * - **purchase** — paid playbook access / the SaaS plan. NOT this resource.
1588
+ *
1589
+ * Operations:
1590
+ * - `followPlaybook` / `unfollowPlaybook` change only the social follow.
1591
+ * - `subscribeFeed` / `unsubscribeFeed` toggle personal push for ONE feed
1592
+ * (a single automation's alert) without touching the playbook follow.
1593
+ * - `subscribeBatch` / `unsubscribeBatch` toggle FEED alerts by target id.
1594
+ *
1595
+ * Backed by alva-gateway REST under `/api/v1/follows/...` and
1596
+ * `/api/v1/subscriptions/...`.
1597
+ */
1598
+ declare class SubscriptionsResource {
1599
+ private client;
1600
+ constructor(client: AlvaClient);
1601
+ /**
1602
+ * Follow a playbook `(username, name)`. Alerts are independent and require
1603
+ * explicit FEED subscriptions. Idempotent.
1604
+ */
1605
+ followPlaybook(params: PlaybookFollowParams): Promise<FollowPlaybookResponse>;
1606
+ /**
1607
+ * Unfollow a playbook `(username, name)` without changing FEED alerts.
1608
+ */
1609
+ unfollowPlaybook(params: PlaybookFollowParams): Promise<UnfollowPlaybookResponse>;
1610
+ /**
1611
+ * Subscribe to one feed `(username, name)` — enable personal push for that
1612
+ * single automation's alerts, regardless of which playbook(s) consume it.
1613
+ * Does NOT follow any playbook. Idempotent.
1614
+ */
1615
+ subscribeFeed(params: SubscribeFeedParams): Promise<SubscribeFeedResponse>;
1616
+ /**
1617
+ * Unsubscribe from one feed `(username, name)` — disable that automation's
1618
+ * alerts for the caller. Idempotent.
1619
+ */
1620
+ unsubscribeFeed(params: PushSubscriptionFeedParams): Promise<UnsubscribeResponse>;
1621
+ /**
1622
+ * List the caller's currently active subscriptions.
1623
+ * Results are cursor-paginated.
1624
+ */
1625
+ list(params?: PushSubscriptionListParams): Promise<PushSubscriptionListResponse>;
1626
+ /**
1627
+ * List the playbooks the caller FOLLOWS (the social relation — the UI's
1628
+ * "Subscribed Playbooks"). Rows carry the playbook identity; follows of
1629
+ * deleted playbooks are filtered server-side. Cursor-paginated.
1630
+ */
1631
+ follows(params?: FollowsListParams): Promise<FollowsListResponse>;
1632
+ /** Atomically enable alerts for FEED target ids (max 100). */
1633
+ subscribeBatch(params: SubscribeBatchParams): Promise<SubscribeBatchResponse>;
1634
+ /**
1635
+ * Disable alerts for many FEED targets by id in one idempotent call (max
1636
+ * 100 ids). The per-id results report `INVALID_ID` for malformed entries.
1637
+ */
1638
+ unsubscribeBatch(params: UnsubscribeBatchParams): Promise<UnsubscribeBatchResponse>;
1639
+ }
1640
+
1641
+ /**
1642
+ * Product-facing alert API. The current transport still calls the legacy
1643
+ * subscription and notification-history endpoints.
1644
+ */
1645
+ declare class AlertsResource {
1646
+ private client;
1647
+ constructor(client: AlvaClient);
1648
+ list(params?: PushSubscriptionListParams): Promise<PushSubscriptionListResponse>;
1649
+ follows(params?: FollowsListParams): Promise<FollowsListResponse>;
1650
+ enableAutomation(params: SubscribeFeedParams): Promise<SubscribeFeedResponse>;
1651
+ disableAutomation(params: PushSubscriptionFeedParams): Promise<UnsubscribeResponse>;
1652
+ enableBatch(params: SubscribeBatchParams): Promise<SubscribeBatchResponse>;
1653
+ disableBatch(params: UnsubscribeBatchParams): Promise<UnsubscribeBatchResponse>;
1654
+ historyAutomation(params: NotificationListParams): Promise<FeedNotificationListResponse>;
1655
+ preferences(): Promise<NotificationPreferencesResponse>;
1656
+ updatePreference(params: NotificationPreferenceUpdateParams): Promise<NotificationPreferenceUpdateResponse>;
1657
+ }
1658
+
1659
+ /**
1660
+ * Group push subscriptions for an external channel session.
1661
+ *
1662
+ * These APIs subscribe the Telegram/Discord group attached to `session_id`
1663
+ * to feed push events the group admin may read. Mutations are idempotent no-ops
1664
+ * unless the authenticated caller is that group's Alva admin.
1665
+ */
1666
+ declare class ChannelGroupSubscriptionsResource {
1667
+ private client;
1668
+ constructor(client: AlvaClient);
1669
+ context(params: ChannelGroupSubscriptionSessionParams): Promise<ChannelGroupSubscriptionContextResponse>;
1670
+ list(params: ChannelGroupSubscriptionSessionParams): Promise<ChannelGroupSubscriptionListResponse>;
1671
+ subscribe(params: ChannelGroupSubscriptionMutationParams): Promise<ChannelGroupSubscriptionMutationResponse>;
1672
+ unsubscribe(params: ChannelGroupSubscriptionMutationParams): Promise<ChannelGroupSubscriptionMutationResponse>;
1673
+ /**
1674
+ * Read a group's buffered chat messages in a time window, for the group-chat
1675
+ * digest automation. Admin-gated: the authenticated caller must be that
1676
+ * group's Alva admin (a digest feed runs as that admin). Each message carries
1677
+ * a `permalink` deep-link back to the original message for "jump to original".
1678
+ * `from_micros`/`to_micros` are message-origin timestamps in microseconds.
1679
+ */
1680
+ getGroupChatHistory(params: ChannelGroupHistoryParams): Promise<ChannelGroupHistoryResponse>;
1681
+ }
1682
+
1683
+ declare class FeedbackResource {
1684
+ private client;
1685
+ constructor(client: AlvaClient);
1686
+ submit(params: SubmitFeedbackRequest): Promise<SubmitFeedbackResponse>;
1687
+ }
1688
+
1689
+ interface PlaybookFunction {
1690
+ id: string | number;
1691
+ playbook_id: string | number;
1692
+ function_name: string;
1693
+ entry_script_path: string;
1694
+ created_at?: string;
1695
+ updated_at?: string;
1696
+ disabled?: boolean;
1697
+ params_schema?: string;
1698
+ allow_charges?: boolean;
1699
+ }
1700
+ interface RegisterFunctionParams {
1701
+ playbook_id: number;
1702
+ function_name: string;
1703
+ entry_script_path: string;
1704
+ params_schema?: string;
1705
+ allow_charges?: boolean;
1706
+ /**
1707
+ * Run invocations of this function under a restricted service-account
1708
+ * identity (an SA id owned by the caller) instead of the owner (#602).
1709
+ * Omitted ⇒ runs as the owner. A string: SA ids are snowflake int64s that
1710
+ * overflow JS number precision.
1711
+ */
1712
+ run_as_user_id?: string;
1713
+ }
1714
+ interface RegisterFunctionResponse {
1715
+ function?: PlaybookFunction;
1716
+ }
1717
+ interface ListFunctionsParams {
1718
+ playbook_id: number;
1719
+ }
1720
+ interface ListFunctionsResponse {
1721
+ functions: PlaybookFunction[];
1722
+ }
1723
+ interface DeleteFunctionParams {
1724
+ playbook_id: number;
1725
+ function_name: string;
1726
+ }
1727
+ interface InvokeFunctionParams {
1728
+ playbook_id: number;
1729
+ function_name: string;
1730
+ parameters?: unknown;
1731
+ }
1732
+ interface InvokeFunctionResponse<TResult = unknown> {
1733
+ result: TResult;
1734
+ logs: string;
1735
+ credits_used_total: number;
1736
+ credits_charged_owner: number;
1737
+ credits_charged_consumer: number;
1738
+ }
1739
+ interface CreditAllowance {
1740
+ id: string | number;
1741
+ consumer_uid: string | number;
1742
+ playbook_id: string | number;
1743
+ amount: number;
1744
+ used: number;
1745
+ remaining: number;
1746
+ created_at_ms?: number;
1747
+ updated_at_ms?: number;
1748
+ }
1749
+ interface GetAllowanceParams {
1750
+ playbook_id: number;
1751
+ }
1752
+ interface ListAllowancesResponse {
1753
+ allowances: CreditAllowance[];
1754
+ }
1755
+ interface CreateAllowanceParams {
1756
+ playbook_id: number;
1757
+ amount: number;
1758
+ }
1759
+ interface CreateAllowanceResponse {
1760
+ allowance: CreditAllowance;
1761
+ }
1762
+ interface RevokeAllowanceParams {
1763
+ playbook_id: number;
1764
+ }
1765
+ interface RevokeAllowanceResponse {
1766
+ ok: boolean;
1767
+ }
1768
+ /**
1769
+ * Playbook function management. These functions are registered by a playbook
1770
+ * creator and invoked by released playbook UI through the browser UDF runtime.
1771
+ */
1772
+ declare class FunctionsResource {
1773
+ private client;
1774
+ constructor(client: AlvaClient);
1775
+ register(params: RegisterFunctionParams): Promise<RegisterFunctionResponse>;
1776
+ list(params: ListFunctionsParams): Promise<ListFunctionsResponse>;
1777
+ delete(params: DeleteFunctionParams): Promise<void>;
1778
+ invoke<TResult = unknown>(params: InvokeFunctionParams): Promise<InvokeFunctionResponse<TResult>>;
1779
+ getAllowance(params: GetAllowanceParams): Promise<CreditAllowance | null>;
1780
+ listAllowances(): Promise<ListAllowancesResponse>;
1781
+ createAllowance(params: CreateAllowanceParams): Promise<CreateAllowanceResponse>;
1782
+ revokeAllowance(params: RevokeAllowanceParams): Promise<RevokeAllowanceResponse>;
1783
+ }
1784
+
1785
+ declare class CreditsResource {
1786
+ private client;
1787
+ constructor(client: AlvaClient);
1788
+ wallet(): Promise<CreditWallet>;
1789
+ items(params: CreditWalletItemsParams): Promise<CreditWalletItemsResponse>;
1790
+ private graphql;
1791
+ }
1792
+
1793
+ interface RequestOptions {
1794
+ query?: Record<string, unknown>;
1795
+ body?: unknown;
1796
+ /** Raw JSON body, used when callers must preserve int64 numeric literals. */
1797
+ jsonBody?: string;
1798
+ /** Send raw body with application/octet-stream content type (for binary writes). */
1799
+ rawBody?: BodyInit;
1800
+ /** Override the base URL for this request (e.g. the Arrays data-tools endpoint). */
1801
+ baseUrl?: string;
1802
+ /** If true, skip attaching any Alva auth header (X-Alva-Api-Key / x-Playbook-Viewer). */
1803
+ noAuth?: boolean;
1804
+ /** Client-side HTTP timeout in milliseconds. */
1805
+ timeoutMs?: number;
1806
+ /** Optional AbortSignal for this request. Defaults to the client-level signal. */
1807
+ signal?: AbortSignal;
1808
+ }
1809
+ declare class AlvaClient {
1810
+ readonly baseUrl: string;
1811
+ readonly arraysBaseUrl: string;
1812
+ readonly viewer_token?: string;
1813
+ readonly pbsvToken?: string;
1814
+ readonly apiKey?: string;
1815
+ readonly gaClientId?: string;
1816
+ readonly gaSessionId?: string;
1817
+ readonly utmParams?: string;
1818
+ readonly signal?: AbortSignal;
1819
+ /**
1820
+ * Alva chat session that owns work produced through this client (playbooks,
1821
+ * feeds, uploaded files). Forwarded as `X-Alva-Origin-Session-Id` so the
1822
+ * backend can attribute created artifacts to the originating session. This
1823
+ * is a request-context hint, NOT auth — the backend still verifies the
1824
+ * session belongs to the authenticated user before honoring it. Distinct
1825
+ * from `gaSessionId` (browser analytics).
1826
+ */
1827
+ readonly originSessionId?: string;
1828
+ /** Session profile kind associated with originSessionId. */
1829
+ readonly originSessionKind?: string;
1830
+ private _fs?;
1831
+ private _run?;
1832
+ private _deploy?;
1833
+ private _serviceAccount?;
1834
+ private _release?;
1835
+ private _feed?;
1836
+ private _automation?;
1837
+ private _playbooks?;
1838
+ private _secrets?;
1839
+ private _sdk?;
1840
+ private _dataSkills?;
1841
+ private _playbookSkills?;
1842
+ private _comments?;
1843
+ private _remix?;
1844
+ private _screenshot?;
1845
+ private _user?;
1846
+ private _trading?;
1847
+ private _portfolio?;
1848
+ private _arraysJwt?;
1849
+ private _notifications?;
1850
+ private _notificationPreferences?;
1851
+ private _subscriptions?;
1852
+ private _alerts?;
1853
+ private _channelGroupSubscriptions?;
1854
+ private _feedback?;
1855
+ private _functions?;
1856
+ private _credits?;
1857
+ constructor(config: AlvaClientConfig);
1858
+ get fs(): FsResource;
1859
+ get run(): RunResource;
1860
+ get deploy(): DeployResource;
1861
+ get serviceAccount(): ServiceAccountResource;
1862
+ get release(): ReleaseResource;
1863
+ get feed(): FeedResource;
1864
+ get automation(): AutomationResource;
1865
+ get playbooks(): PlaybooksResource;
1866
+ get secrets(): SecretsResource;
1867
+ get sdk(): SdkDocsResource;
1868
+ get dataSkills(): DataSkillsResource;
1869
+ get playbookSkills(): PlaybookSkillsResource;
1870
+ get comments(): CommentsResource;
1871
+ get remix(): RemixResource;
1872
+ get screenshot(): ScreenshotResource;
1873
+ get user(): UserResource;
1874
+ get trading(): TradingResource;
1875
+ get portfolio(): PortfolioResource;
1876
+ get arraysJwt(): ArraysJwtResource;
1877
+ get notifications(): NotificationsResource;
1878
+ get notificationPreferences(): NotificationPreferencesResource;
1879
+ get subscriptions(): SubscriptionsResource;
1880
+ get alerts(): AlertsResource;
1881
+ get channelGroupSubscriptions(): ChannelGroupSubscriptionsResource;
1882
+ get feedback(): FeedbackResource;
1883
+ get functions(): FunctionsResource;
1884
+ get credits(): CreditsResource;
1885
+ _requireAuth(): void;
1886
+ _request(method: string, path: string, options?: RequestOptions): Promise<unknown>;
1887
+ }
1888
+
1889
+ declare class CliUsageError extends Error {
1890
+ readonly command?: string;
1891
+ constructor(message: string, command?: string);
1892
+ }
1893
+
1894
+ declare const CLI_VERSION: string;
1895
+ declare const DEFAULT_RUN_TIMEOUT_MS = 600000;
1896
+ /**
1897
+ * @deprecated Internal command handling uses the strict declarative parser.
1898
+ * Retained for compatibility with existing `@alva-ai/toolkit/cli` consumers.
1899
+ */
1900
+ declare const BOOLEAN_FLAGS: Set<string>;
1901
+ /**
1902
+ * Returns true if version `a` is strictly older than version `b`.
1903
+ * Compares major.minor.patch as integers. Returns false on malformed input.
1904
+ */
1905
+ declare function isVersionOlderThan(a: string, b: string): boolean;
1906
+ declare const HELP_TEXT = "Usage: alva <command> [options]\n\nCommands:\n configure Save API key and endpoint to a named profile\n whoami Verify credentials and show current identity\n user User profile operations (me)\n fs Filesystem operations (read, write, stat, readdir, mkdir, remove, rename, copy, symlink, readlink, chmod, grant, revoke)\n run Execute code in the Alva runtime\n deploy Cronjob management (create, list, get, update, delete, pause, resume, runs, run-logs)\n loop Self-scheduled in-channel goal loops (create)\n service-account Restricted run-as identities (create, list, delete, grant, revoke)\n release Feed and playbook releases (feed, playbook-draft, playbook)\n lint Design-system lint (playbook)\n automation Automation management (list, inspect, publish, stop, resume, delete)\n alert Alert management (list, follows, enable, disable, history, preferences, enable-session-completed, disable-session-completed)\n feed Legacy automation alias (list, stop, resume, delete, set-visibility)\n playbooks Playbook discovery (trending, get, list) and visibility\n functions Playbook UDF function management (register, list, delete, invoke, allowance)\n credits Credit wallet and self-scoped usage history (wallet, items)\n secrets Secret management (create, list, get, update, delete)\n sdk SDK documentation (doc, partitions, partition-summary)\n skillhub Playbook skills (list, tags, get, file)\n data-skills Data-skill documentation from the Arrays backend (list, summary, endpoint)\n comments Playbook comments (create, pin, unpin)\n notification-history Feed notification delivery history (list-feed)\n notification-preferences Notification preferences (list, enable-session-completed, disable-session-completed)\n feedback Submit user-confirmed Alva platform feedback (submit)\n subscriptions Playbook follows and feed alert subscriptions\n remix Save playbook remix lineage\n portfolio Connected-account portfolio (accounts, summary, activities)\n trading Trading operations (accounts, portfolio, orders, subscriptions, equity-history, risk-rules, subscribe, unsubscribe, execute, update-risk-rules)\n broker Agentic order execution \u2014 venue-native passthrough to trex (accounts, quote, order, balance, positions, ...; run 'alva broker describe')\n auth Authentication (login)\n screenshot Capture a web screenshot as PNG\n arrays Arrays backend operations (token ensure, token status)\n\nGlobal options:\n --api-key <key> API key (overrides env and config file)\n --base-url <url> API base URL (overrides env and config file)\n --profile <name> Named profile to use (default: \"default\")\n --arrays-endpoint <url> Arrays backend URL (or ARRAYS_ENDPOINT env; default: https://data-tools.prd.space.id)\n -v, --version Show CLI version\n --help Show help (use 'alva <command> --help' for command details)\n\nConfig resolution: --api-key flag > ALVA_API_KEY env > profile in ~/.config/alva/config.json\nProfile resolution: --profile flag > ALVA_PROFILE env > \"default\"\n\nQuick start:\n npm install -g @alva-ai/toolkit\n alva configure --api-key alva_your_key_here\n alva whoami";
1907
+ declare const COMMAND_HELP: Record<string, string>;
1908
+ type AlvaCliRuntimeMode = 'nodejs' | 'jagent';
1909
+ interface DispatchLocalFiles {
1910
+ readText(path: string): string;
1911
+ readBytes(path: string): BodyInit;
1912
+ writeBytes(path: string, data: Uint8Array): void;
1913
+ }
1914
+ interface DispatchRuntimeDeps {
1915
+ mode?: AlvaCliRuntimeMode;
1916
+ env?: Record<string, string | undefined>;
1917
+ stderr?: {
1918
+ write(value: string): unknown;
1919
+ };
1920
+ localFiles?: DispatchLocalFiles;
1921
+ readStdin?: () => Promise<string>;
1922
+ randomUUID?: () => string;
1923
+ configureFetchTimeout?: (timeoutMs: number) => void;
1924
+ writeBrokerResult?: (envelope: unknown, exitCode: number) => Promise<void>;
1925
+ }
1926
+ /**
1927
+ * @deprecated Use `dispatch()` for validated command execution. This permissive
1928
+ * parser remains available only to preserve the existing `./cli` export.
1929
+ */
1930
+ declare function parseFlags(argv: string[]): Record<string, string>;
1931
+ declare function dispatch(client: AlvaClient, args: string[], meta?: {
1932
+ profile?: string;
1933
+ baseUrl?: string;
1934
+ cliVersion?: string;
1935
+ }, deps?: DispatchRuntimeDeps): Promise<unknown>;
1936
+ /**
1937
+ * Strips global flags (--api-key, --base-url, --profile, --arrays-endpoint)
1938
+ * and their associated values from an argv list. Supports both
1939
+ * `--flag value` and `--flag=value` forms.
1940
+ */
1941
+ declare function stripGlobalFlags(argv: string[]): string[];
1942
+
1943
+ export { type AlvaCliRuntimeMode, BOOLEAN_FLAGS, CLI_VERSION, COMMAND_HELP, CliUsageError, DEFAULT_RUN_TIMEOUT_MS, type DispatchLocalFiles, type DispatchRuntimeDeps, HELP_TEXT, dispatch, isVersionOlderThan, parseFlags, stripGlobalFlags };