@alva-ai/toolkit 0.12.0 → 0.13.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/dist/cli.d.ts ADDED
@@ -0,0 +1,1607 @@
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
+ }
15
+ interface UserProfile {
16
+ id: string;
17
+ username: string;
18
+ subscription_tier: 'free' | 'pro';
19
+ telegram_username: string | null;
20
+ slack_username: string | null;
21
+ /** Caller's alfs home directory, e.g. `/alva/home/<username>`. */
22
+ home_path: string;
23
+ }
24
+ type SubscriptionTier = 'SUBSCRIPTION_TIER_UNSPECIFIED' | 'SUBSCRIPTION_TIER_FREE' | 'SUBSCRIPTION_TIER_PRO';
25
+ interface EnsureArraysJwtResponse {
26
+ expires_at: number;
27
+ tier: SubscriptionTier;
28
+ renewed: boolean;
29
+ }
30
+ interface ArraysJwtStatusResponse {
31
+ exists: boolean;
32
+ expires_at: number;
33
+ tier: SubscriptionTier;
34
+ renewal_needed: boolean;
35
+ }
36
+ interface FsReadParams {
37
+ path: string;
38
+ offset?: number;
39
+ size?: number;
40
+ }
41
+ interface FsWriteParams {
42
+ path: string;
43
+ data: string;
44
+ mkdir_parents?: boolean;
45
+ }
46
+ interface FsRawWriteParams {
47
+ path: string;
48
+ /** Raw file content: string, ArrayBuffer, Uint8Array, Blob, etc. */
49
+ body: BodyInit;
50
+ mkdir_parents?: boolean;
51
+ }
52
+ interface FsWriteResponse {
53
+ bytes_written: number;
54
+ }
55
+ interface FsStat {
56
+ name: string;
57
+ size: number;
58
+ mode: number;
59
+ mod_time: string;
60
+ is_dir: boolean;
61
+ }
62
+ interface FsReaddirParams {
63
+ path: string;
64
+ recursive?: boolean;
65
+ }
66
+ interface FsEntry {
67
+ name: string;
68
+ size: number;
69
+ is_dir: boolean;
70
+ mod_time?: string;
71
+ mode?: number;
72
+ }
73
+ interface FsReaddirResponse {
74
+ entries: FsEntry[];
75
+ }
76
+ interface FsMkdirParams {
77
+ path: string;
78
+ }
79
+ interface FsRemoveParams {
80
+ path: string;
81
+ recursive?: boolean;
82
+ }
83
+ interface FsRenameParams {
84
+ old_path: string;
85
+ new_path: string;
86
+ }
87
+ interface FsCopyParams {
88
+ src_path: string;
89
+ dst_path: string;
90
+ }
91
+ interface FsSymlinkParams {
92
+ target_path: string;
93
+ link_path: string;
94
+ }
95
+ interface FsReadlinkParams {
96
+ path: string;
97
+ }
98
+ interface FsChmodParams {
99
+ path: string;
100
+ mode: number;
101
+ }
102
+ interface FsGrantParams {
103
+ path: string;
104
+ subject: string;
105
+ permission: string;
106
+ }
107
+ interface FsRevokeParams {
108
+ path: string;
109
+ subject: string;
110
+ permission: string;
111
+ }
112
+ interface RunRequest {
113
+ code?: string;
114
+ entry_path?: string;
115
+ working_dir?: string;
116
+ args?: Record<string, unknown>;
117
+ /**
118
+ * Override the server's default V8 heap limit, in MB. Valid range is
119
+ * 1–2048. Omitted means the server uses its default heap (256 MB).
120
+ */
121
+ max_heap_size_mb?: number;
122
+ /**
123
+ * Client-side HTTP timeout for waiting on POST /api/v1/run, in
124
+ * milliseconds. This is not sent to the server.
125
+ */
126
+ timeout_ms?: number;
127
+ }
128
+ interface RunResponse {
129
+ result: string;
130
+ logs: string;
131
+ stats: {
132
+ duration_ms: number;
133
+ };
134
+ status: 'completed' | 'failed';
135
+ error?: string;
136
+ }
137
+ interface CronjobCreateRequest {
138
+ path: string;
139
+ cron_expression: string;
140
+ name: string;
141
+ args?: Record<string, unknown>;
142
+ push_notify?: boolean;
143
+ /** Override per-cronjob V8 heap limit (MB). Valid range 1–2046. */
144
+ max_heap_size_mb?: number;
145
+ }
146
+ interface Cronjob {
147
+ id: number;
148
+ name: string;
149
+ path: string;
150
+ cron_expression: string;
151
+ status: string;
152
+ args: Record<string, unknown>;
153
+ push_notify: boolean;
154
+ /** Per-cronjob V8 heap cap (MB). null when using the server default. */
155
+ max_heap_size_mb: number | null;
156
+ created_at: string;
157
+ updated_at: string;
158
+ }
159
+ interface CronjobListParams {
160
+ limit?: number;
161
+ cursor?: string;
162
+ }
163
+ interface CronjobListResponse {
164
+ cronjobs: Cronjob[];
165
+ next_cursor?: string;
166
+ }
167
+ interface CronjobUpdateRequest {
168
+ id: number;
169
+ name?: string;
170
+ cron_expression?: string;
171
+ args?: Record<string, unknown>;
172
+ push_notify?: boolean;
173
+ /** Override per-cronjob V8 heap limit (MB). Valid range 1–2046. */
174
+ max_heap_size_mb?: number;
175
+ }
176
+ interface CronjobRunsListParams {
177
+ cronjob_id: number;
178
+ first?: number;
179
+ cursor?: string;
180
+ }
181
+ interface CronjobRun {
182
+ id: number;
183
+ cronjob_id: number;
184
+ status: string;
185
+ error: string;
186
+ duration_ms: number;
187
+ credits_used: number;
188
+ created_at: string;
189
+ /**
190
+ * Hatchet workflow run id captured at trigger time. Populated for runs
191
+ * persisted by recent worker binaries (both naturally-scheduled ticks and
192
+ * triggered runs); empty for older rows. External callers that issued
193
+ * `deploy.trigger()` filter by this field to find the run their request
194
+ * produced.
195
+ */
196
+ workflow_run_id?: string;
197
+ }
198
+ interface CronjobRunStats {
199
+ total_runs: number;
200
+ success_count: number;
201
+ fail_count: number;
202
+ last_run_at?: string;
203
+ last_success_at?: string;
204
+ }
205
+ interface CronjobRunsListResponse {
206
+ runs: CronjobRun[];
207
+ stats?: CronjobRunStats;
208
+ next_cursor?: number;
209
+ }
210
+ interface CronjobRunLogsResponse {
211
+ logs: string;
212
+ }
213
+ interface CronjobTriggerResponse {
214
+ /**
215
+ * Hatchet workflow run id at enqueue. Async — the persisted
216
+ * `cronjob_runs` row appears only after the worker finishes the run.
217
+ * Callers verify completion by polling `deploy.listRuns({cronjob_id})`
218
+ * and matching `runs[].workflow_run_id` against this value.
219
+ */
220
+ workflow_run_id: string;
221
+ }
222
+ interface FeedReleaseRequest {
223
+ name: string;
224
+ version: string;
225
+ cronjob_id: number;
226
+ view_json?: Record<string, unknown>;
227
+ description?: string;
228
+ changelog?: string;
229
+ }
230
+ interface FeedReleaseResponse {
231
+ feed_id: number;
232
+ name: string;
233
+ feed_major: number;
234
+ /** Canonical alfs path: `/alva/home/<username>/feeds/<name>`. */
235
+ feed_path: string;
236
+ }
237
+ interface FeedDeleteRequest {
238
+ /** Numeric feed id to delete. */
239
+ id: number;
240
+ }
241
+ interface FeedStatusUpdateRequest {
242
+ /** Numeric feed id to stop/resume. */
243
+ id: number;
244
+ }
245
+ interface FeedStatusUpdateResponse {
246
+ /** Echoed feed id (string form, matching gateway response). */
247
+ id: string;
248
+ /** Feed runtime status after the update. */
249
+ status: 'ACTIVE' | 'PAUSED' | 'UNSPECIFIED' | string;
250
+ }
251
+ interface FeedDeleteResponse {
252
+ /** Echoed feed id (string form, matching gateway response). */
253
+ id: string;
254
+ }
255
+ interface PlaybookDraftRequest {
256
+ name: string;
257
+ display_name: string;
258
+ description?: string;
259
+ feeds: Array<{
260
+ feed_id: number;
261
+ feed_major?: number;
262
+ }>;
263
+ trading_symbols?: string[];
264
+ /**
265
+ * Optional source-skill reference in "username/name" form (e.g.
266
+ * "alva/screener"). The value identifies a playbook skill published to
267
+ * Skillhub; discover available skills via `alva skillhub list`.
268
+ * Persisted set-once on the playbook's first draft; subsequent drafts
269
+ * ignore the field.
270
+ */
271
+ skill_id?: string;
272
+ /**
273
+ * Optional discovery tags (max 10, each up to 32 characters). On a
274
+ * playbook's first draft these merge with any template-inherited tags;
275
+ * on a re-draft of an existing playbook they replace the current tag
276
+ * set. Omitted/empty leaves tags unchanged.
277
+ */
278
+ tags?: string[];
279
+ }
280
+ interface PlaybookDraftResponse {
281
+ playbook_id: number;
282
+ playbook_version_id: number;
283
+ /** Canonical alfs path: `/alva/home/<username>/playbooks/<name>`. */
284
+ playbook_path: string;
285
+ }
286
+ interface PlaybookReleaseRequest {
287
+ name: string;
288
+ version: string;
289
+ feeds: Array<{
290
+ feed_id: number;
291
+ feed_major?: number;
292
+ }>;
293
+ changelog: string;
294
+ /**
295
+ * Owner-attested README location. Server validates the value is one of:
296
+ * - relative: `<name>/README.md`
297
+ * - absolute: `/alva/home/<username>/playbooks/<name>/README.md`
298
+ * The owner is responsible for placing the README at that path on ALFS
299
+ * before publish; the server does not write the file.
300
+ */
301
+ readme_url: string;
302
+ }
303
+ interface PlaybookReleaseResponse {
304
+ playbook_id: number;
305
+ version: string;
306
+ published_url: string;
307
+ /** Canonical alfs path: `/alva/home/<username>/playbooks/<name>`. */
308
+ playbook_path: string;
309
+ }
310
+ interface CreateSecretRequest {
311
+ name: string;
312
+ value: string;
313
+ }
314
+ interface SecretMetadata {
315
+ name: string;
316
+ keyVersion: number;
317
+ createdAt: string;
318
+ updatedAt: string;
319
+ valueLength: number;
320
+ keyPrefix: string;
321
+ }
322
+ interface Secret {
323
+ name: string;
324
+ value: string;
325
+ createdAt: string;
326
+ updatedAt: string;
327
+ }
328
+ interface ModuleDoc {
329
+ name: string;
330
+ doc: string;
331
+ }
332
+ interface PartitionsResponse {
333
+ partitions: string[];
334
+ }
335
+ interface PartitionSummaryResponse {
336
+ summary: string;
337
+ }
338
+ interface CreateCommentRequest {
339
+ username: string;
340
+ name: string;
341
+ content: string;
342
+ parent_id?: number;
343
+ }
344
+ interface Comment {
345
+ id: number;
346
+ playbook_id: number;
347
+ content: string;
348
+ pin_at: number | null;
349
+ created_at: number;
350
+ updated_at: number;
351
+ creator?: {
352
+ id: string;
353
+ name: string;
354
+ avatar: string;
355
+ };
356
+ agent?: {
357
+ name: string;
358
+ };
359
+ }
360
+ interface RemixRequest {
361
+ child: {
362
+ username: string;
363
+ name: string;
364
+ };
365
+ parents: Array<{
366
+ username: string;
367
+ name: string;
368
+ }>;
369
+ }
370
+ interface ScreenshotParams {
371
+ url: string;
372
+ selector?: string;
373
+ xpath?: string;
374
+ compress?: boolean;
375
+ compressQuality?: number;
376
+ compressMaxWidth?: number;
377
+ }
378
+ interface TradingAccount {
379
+ id: string;
380
+ name: string;
381
+ exchange: string;
382
+ paper: boolean;
383
+ identifier: string;
384
+ createdAtMs: number;
385
+ subscriptions: AccountSubscription[];
386
+ }
387
+ interface AccountSubscription {
388
+ id: string;
389
+ sourceUsername: string;
390
+ sourceFeed: string;
391
+ playbookId: string;
392
+ playbookName: string;
393
+ active: boolean;
394
+ }
395
+ interface TradingSubscription {
396
+ id: string;
397
+ accountId: string;
398
+ sourceUsername: string;
399
+ sourceFeed: string;
400
+ active: boolean;
401
+ deactivateReason?: string;
402
+ playbookId: string;
403
+ playbookVersion: string;
404
+ createdAtMs: number;
405
+ watermark: number;
406
+ }
407
+ interface TradingOrder {
408
+ orderId: string;
409
+ symbol: string;
410
+ side: string;
411
+ requestedQty: number;
412
+ filledQty: number;
413
+ price: number;
414
+ status: string;
415
+ rejectReason?: string;
416
+ source: string;
417
+ sourcePlaybook: string;
418
+ subscriptionId?: string;
419
+ dryRun: boolean;
420
+ createdAtMs: number;
421
+ }
422
+ interface PortfolioAsset {
423
+ symbol: string;
424
+ side: string;
425
+ quantity: number;
426
+ entryPrice: number;
427
+ currentPrice?: number;
428
+ marketValue?: number;
429
+ unrealizedPnl?: number;
430
+ allocation?: number;
431
+ }
432
+ interface TradingPortfolio {
433
+ equity: number;
434
+ cash: number;
435
+ unrealizedPnl?: number;
436
+ assets: PortfolioAsset[];
437
+ }
438
+ interface EquityPoint {
439
+ timestamp: number;
440
+ equity: number;
441
+ pnl: number;
442
+ pnlPct: number;
443
+ }
444
+ interface RiskRuleEntry {
445
+ value: number;
446
+ enabled: boolean;
447
+ }
448
+ interface TradingRiskRule {
449
+ maxSingleOrder: RiskRuleEntry;
450
+ maxDailyTurnover: RiskRuleEntry;
451
+ maxDailyOrders: RiskRuleEntry;
452
+ }
453
+ type TradingRiskRuleInput = TradingRiskRule;
454
+ interface ExecuteSignalOrder {
455
+ orderId: string;
456
+ symbol: string;
457
+ side: string;
458
+ requestedQty: number;
459
+ filledQty: number;
460
+ price: number;
461
+ status: string;
462
+ rejectReason?: string;
463
+ }
464
+ interface ExecuteSignalResult {
465
+ status: string;
466
+ orders: ExecuteSignalOrder[];
467
+ error?: string;
468
+ }
469
+ interface PortfolioAccount {
470
+ id: string;
471
+ provider: 'TREX' | 'SNAPTRADE';
472
+ name: string;
473
+ institution: string;
474
+ identifier?: string;
475
+ readOnly: boolean;
476
+ paper: boolean;
477
+ exchange?: string;
478
+ createdAtMs?: number;
479
+ subscriptions: PortfolioAccountSubscription[];
480
+ status?: string;
481
+ statusReason?: string;
482
+ lastSyncedAtMs?: number;
483
+ connectionId?: string;
484
+ }
485
+ interface PortfolioAccountSubscription {
486
+ id: string;
487
+ sourceUsername: string;
488
+ sourceFeed: string;
489
+ playbookId: string;
490
+ playbookName: string;
491
+ playbookVersion: string;
492
+ active: boolean;
493
+ deactivateReason?: string;
494
+ createdAt: number;
495
+ watermark: number;
496
+ }
497
+ interface PortfolioMoney {
498
+ amount: number;
499
+ currency: string;
500
+ currencySymbol: string;
501
+ }
502
+ interface PortfolioHolding {
503
+ symbol: string;
504
+ side?: string;
505
+ quantity: number;
506
+ avgCost?: PortfolioMoney;
507
+ currentPrice?: PortfolioMoney;
508
+ marketValue?: PortfolioMoney;
509
+ unrealizedPnl?: PortfolioMoney;
510
+ allocation?: number;
511
+ }
512
+ interface PortfolioSummary {
513
+ totalValue?: PortfolioMoney;
514
+ cash?: PortfolioMoney;
515
+ unrealizedPnl?: PortfolioMoney;
516
+ holdings: PortfolioHolding[];
517
+ asOfMs?: number;
518
+ }
519
+ interface PortfolioActivity {
520
+ id: string;
521
+ kind: string;
522
+ type: string;
523
+ occurredAtMs?: number;
524
+ symbol?: string;
525
+ side?: string;
526
+ quantity?: number;
527
+ price?: PortfolioMoney;
528
+ amount?: PortfolioMoney;
529
+ fee?: PortfolioMoney;
530
+ status?: string;
531
+ sourceLabel?: string;
532
+ description?: string;
533
+ externalReferenceId?: string;
534
+ }
535
+ interface PortfolioActivityConnection {
536
+ activities: PortfolioActivity[];
537
+ nextPageToken?: string;
538
+ }
539
+ interface NotificationListParams {
540
+ username: string;
541
+ name: string;
542
+ channel?: string;
543
+ /** `sent` / `failed` / `filtered`. */
544
+ status?: string;
545
+ /** Unix seconds; only notifications newer than this. */
546
+ since_time?: number;
547
+ /** Page size, default 50, max 200. */
548
+ first?: number;
549
+ /** Opaque cursor token from previous page's `next_cursor`. */
550
+ cursor?: string;
551
+ }
552
+ interface NotificationEvent {
553
+ id: string;
554
+ event_type: string;
555
+ user_id: string;
556
+ channel: string;
557
+ /** `sent` / `failed` / `filtered`. */
558
+ status: string;
559
+ /** Unix seconds. */
560
+ created_at: number;
561
+ message?: string;
562
+ error_msg?: string;
563
+ /** Present when notification is playbook-scoped. */
564
+ playbook_id?: string;
565
+ /** Present when notification is feed-scoped. */
566
+ feed_id?: string;
567
+ }
568
+ interface PlaybookNotificationListResponse {
569
+ items: NotificationEvent[];
570
+ /** Empty when there is no next page. */
571
+ next_cursor: string;
572
+ /** Canonical alfs path: `/alva/home/<username>/playbooks/<name>`. */
573
+ playbook_path: string;
574
+ }
575
+ interface FeedNotificationListResponse {
576
+ items: NotificationEvent[];
577
+ next_cursor: string;
578
+ /** Canonical alfs path: `/alva/home/<username>/feeds/<name>`. */
579
+ feed_path: string;
580
+ }
581
+ type NotificationPreferenceKey = 'session_completed';
582
+ interface NotificationPreference {
583
+ key: NotificationPreferenceKey;
584
+ enabled: boolean;
585
+ }
586
+ interface NotificationPreferencesResponse {
587
+ settings: NotificationPreference[];
588
+ }
589
+ interface NotificationPreferenceUpdateParams {
590
+ key: NotificationPreferenceKey;
591
+ enabled: boolean;
592
+ }
593
+ interface NotificationPreferenceUpdateResponse {
594
+ setting: NotificationPreference;
595
+ }
596
+ interface SubmitFeedbackRequest {
597
+ /** Defaults to "agent_detected" on the server. */
598
+ source?: 'agent_detected' | 'user_reported' | 'system_detected' | string;
599
+ /** Defaults to "other" on the server. */
600
+ category?: 'api_error' | 'data_quality' | 'docs' | 'runtime' | 'auth' | 'billing' | 'other' | string;
601
+ /** Defaults to "medium" on the server. */
602
+ severity?: 'low' | 'medium' | 'high' | 'critical' | string;
603
+ summary: string;
604
+ details?: string;
605
+ /** Optional structured diagnostics; omit unless the agent has useful metadata. */
606
+ evidence?: Record<string, unknown>;
607
+ /** Optional structured session metadata; omit unless relevant to triage. */
608
+ context?: Record<string, unknown>;
609
+ }
610
+ interface SubmitFeedbackResponse {
611
+ feedback_id: number;
612
+ notion_page_id: string;
613
+ notion_url: string;
614
+ }
615
+ /**
616
+ * Identifies the asset a personal push subscription is keyed to.
617
+ * `PLAYBOOK` is the only target supported today; `FEED` is reserved for
618
+ * a future phase where users can subscribe to a feed independent of any
619
+ * playbook that consumes it.
620
+ */
621
+ type PushTargetType = 'PLAYBOOK' | 'FEED' | 'UNSPECIFIED';
622
+ interface PushTarget {
623
+ type: PushTargetType;
624
+ /** Numeric id encoded as a string (matches the rest of the SDK). */
625
+ id: string;
626
+ }
627
+ interface PushSubscription {
628
+ target: PushTarget;
629
+ created_at_ms: number;
630
+ updated_at_ms: number;
631
+ /** Present on list responses. */
632
+ cursor?: string;
633
+ /** Feed metadata is present for FEED targets when available. */
634
+ feed_name?: string;
635
+ feed_status?: 'ACTIVE' | 'PAUSED' | 'UNSPECIFIED' | string;
636
+ /** Unix milliseconds of the latest successful delivery for this user+target. */
637
+ last_pushed_at_ms?: number;
638
+ /** Playbooks whose latest release currently references this feed. */
639
+ used_by?: PushSubscriptionUsedBy[];
640
+ used_by_total?: number;
641
+ /**
642
+ * Row-shape discriminator: PLAYBOOK_ALERTS = a playbook-level wildcard
643
+ * (alerts for every push-enabled automation of the playbook);
644
+ * FEED_ALERT = a single feed's alert.
645
+ */
646
+ kind?: 'PLAYBOOK_ALERTS' | 'FEED_ALERT' | 'UNSPECIFIED' | string;
647
+ /**
648
+ * Whether the caller also FOLLOWS the target playbook — the social
649
+ * relation, distinct from this alert row. Always false for FEED targets.
650
+ */
651
+ following?: boolean;
652
+ /**
653
+ * Target lifecycle: TARGET_DELETED marks a ghost row (the playbook/feed
654
+ * was deleted) — clear it with unsubscribeBatch by target id.
655
+ */
656
+ target_status?: 'ACTIVE' | 'TARGET_DELETED' | 'PAUSED' | 'UNSPECIFIED' | string;
657
+ /** Playbook identity, present for PLAYBOOK targets on list responses. */
658
+ playbook?: PushSubscriptionPlaybookInfo;
659
+ }
660
+ interface PushSubscriptionPlaybookInfo {
661
+ owner_username: string;
662
+ name: string;
663
+ display_name: string;
664
+ }
665
+ interface PushSubscriptionUsedBy {
666
+ playbook_id: string;
667
+ owner_username: string;
668
+ playbook_name: string;
669
+ display_name: string;
670
+ owner_avatar_url: string;
671
+ }
672
+ interface PushSubscriptionPlaybookParams {
673
+ username: string;
674
+ name: string;
675
+ }
676
+ interface PushSubscriptionFeedParams {
677
+ username: string;
678
+ name: string;
679
+ }
680
+ interface PushSubscriptionListParams {
681
+ /** Page size, default 50, max 200 server-side. */
682
+ first?: number;
683
+ /** Opaque cursor token from previous page's `next_cursor`. */
684
+ cursor?: string;
685
+ }
686
+ interface PushSubscriptionListResponse {
687
+ items: PushSubscription[];
688
+ /** Empty when there is no next page. */
689
+ next_cursor?: string;
690
+ /**
691
+ * Total active subscription rows independent of pagination — when
692
+ * items.length < total_count, the page is truncated; keep paginating.
693
+ */
694
+ total_count?: number;
695
+ }
696
+ interface FollowsListParams {
697
+ /** Page size, default 50, max 100 server-side. */
698
+ limit?: number;
699
+ /** Opaque cursor from the previous page's `next_cursor`. */
700
+ cursor?: string;
701
+ }
702
+ interface PlaybookFollowItem {
703
+ playbook_id: string;
704
+ owner_username: string;
705
+ name: string;
706
+ display_name: string;
707
+ followed_at_ms: number;
708
+ cursor: string;
709
+ }
710
+ interface FollowsListResponse {
711
+ items: PlaybookFollowItem[];
712
+ has_next: boolean;
713
+ next_cursor?: string;
714
+ }
715
+ interface UnsubscribeBatchParams {
716
+ /** Playbook target ids (strings — snowflake ids exceed JS safe integers). */
717
+ playbookIds?: string[];
718
+ /** Feed target ids (strings). */
719
+ feedIds?: string[];
720
+ }
721
+ interface UnsubscribeBatchResult {
722
+ id: string;
723
+ kind: 'PLAYBOOK' | 'FEED' | string;
724
+ ok: boolean;
725
+ status: 'UNSUBSCRIBED' | 'INVALID_ID' | string;
726
+ }
727
+ interface UnsubscribeBatchResponse {
728
+ results: UnsubscribeBatchResult[];
729
+ ok_count: number;
730
+ }
731
+ interface PlaybookFollow {
732
+ id: string;
733
+ user_id: string;
734
+ playbook_id: string;
735
+ created_at_ms: number;
736
+ updated_at_ms: number;
737
+ }
738
+ interface SubscribePlaybookResponse {
739
+ /** The follow row created (or confirmed) by the cascade subscribe. */
740
+ follow: PlaybookFollow;
741
+ /** Feed ids whose alert this subscribe enabled (push-enabled automations). */
742
+ subscribed_feed_ids: string[];
743
+ /** Canonical alfs path: `/alva/home/<username>/playbooks/<name>`. */
744
+ playbook_path: string;
745
+ }
746
+ interface SubscribeFeedResponse {
747
+ subscription: PushSubscription;
748
+ /** Canonical alfs path: `/alva/home/<username>/feeds/<name>`. */
749
+ feed_path: string;
750
+ }
751
+ interface UnsubscribeResponse {
752
+ ok: true;
753
+ }
754
+ type ChannelGroupSubscriptionTargetType = 'feed' | 'playbook';
755
+ interface ChannelGroupSubscriptionTarget {
756
+ type: ChannelGroupSubscriptionTargetType | '';
757
+ id: number;
758
+ }
759
+ interface ChannelGroupSubscription {
760
+ event_type: string;
761
+ target: ChannelGroupSubscriptionTarget | null;
762
+ subscribed_by_user_id: number;
763
+ enabled: boolean;
764
+ created_at_ms: number;
765
+ updated_at_ms: number;
766
+ }
767
+ interface ChannelGroupCallerInfo {
768
+ user_id: number;
769
+ is_admin: boolean;
770
+ }
771
+ interface ChannelGroupAdminInfo {
772
+ user_id: number;
773
+ username: string;
774
+ telegram_user_id: string;
775
+ telegram_username: string;
776
+ }
777
+ interface ChannelGroupSubscriptionSessionParams {
778
+ session_id: number | string;
779
+ }
780
+ interface ChannelGroupSubscriptionMutationParams extends ChannelGroupSubscriptionSessionParams {
781
+ target_type: ChannelGroupSubscriptionTargetType;
782
+ target_id: number | string;
783
+ }
784
+ interface ChannelGroupSubscriptionContextResponse {
785
+ channel_id: string;
786
+ remote_chat_id: string;
787
+ caller: ChannelGroupCallerInfo;
788
+ admin: ChannelGroupAdminInfo | null;
789
+ subscriptions: ChannelGroupSubscription[];
790
+ }
791
+ interface ChannelGroupSubscriptionListResponse {
792
+ subscriptions: ChannelGroupSubscription[];
793
+ }
794
+ interface ChannelGroupSubscriptionMutationResponse {
795
+ ok: boolean;
796
+ reason: string;
797
+ caller: ChannelGroupCallerInfo;
798
+ admin: ChannelGroupAdminInfo | null;
799
+ subscriptions: ChannelGroupSubscription[];
800
+ }
801
+
802
+ declare class FsResource {
803
+ private client;
804
+ constructor(client: AlvaClient);
805
+ /** Returns `ArrayBuffer` for binary files, or parsed JSON for time-series virtual paths. */
806
+ read(params: FsReadParams): Promise<ArrayBuffer | unknown>;
807
+ /** Write file using JSON body (Mode 2). For text content. */
808
+ write(params: FsWriteParams): Promise<FsWriteResponse>;
809
+ /** Write file using raw body (Mode 1). Supports binary data. Path and options are query params. */
810
+ rawWrite(params: FsRawWriteParams): Promise<FsWriteResponse>;
811
+ stat(params: {
812
+ path: string;
813
+ }): Promise<FsStat>;
814
+ readdir(params: FsReaddirParams): Promise<FsReaddirResponse>;
815
+ mkdir(params: FsMkdirParams): Promise<void>;
816
+ remove(params: FsRemoveParams): Promise<void>;
817
+ rename(params: FsRenameParams): Promise<void>;
818
+ copy(params: FsCopyParams): Promise<void>;
819
+ symlink(params: FsSymlinkParams): Promise<void>;
820
+ readlink(params: FsReadlinkParams): Promise<{
821
+ target: string;
822
+ }>;
823
+ chmod(params: FsChmodParams): Promise<void>;
824
+ grant(params: FsGrantParams): Promise<void>;
825
+ revoke(params: FsRevokeParams): Promise<void>;
826
+ }
827
+
828
+ declare class RunResource {
829
+ private client;
830
+ constructor(client: AlvaClient);
831
+ execute(params: RunRequest): Promise<RunResponse>;
832
+ }
833
+
834
+ declare class DeployResource {
835
+ private client;
836
+ constructor(client: AlvaClient);
837
+ create(params: CronjobCreateRequest): Promise<Cronjob>;
838
+ list(params?: CronjobListParams): Promise<CronjobListResponse>;
839
+ get(params: {
840
+ id: number;
841
+ }): Promise<Cronjob>;
842
+ update(params: CronjobUpdateRequest): Promise<Cronjob>;
843
+ delete(params: {
844
+ id: number;
845
+ }): Promise<void>;
846
+ pause(params: {
847
+ id: number;
848
+ }): Promise<void>;
849
+ resume(params: {
850
+ id: number;
851
+ }): Promise<void>;
852
+ /**
853
+ * Fire the cronjob workflow once, immediately, bypassing the schedule.
854
+ * Async — returns the Hatchet workflow run id at enqueue. The
855
+ * `cronjob_runs` row appears only after the worker finishes the run;
856
+ * callers verify completion by polling `listRuns({cronjob_id})` and
857
+ * matching `runs[].workflow_run_id` against the returned id.
858
+ *
859
+ * Surfaces backend status as HTTP errors (handled by AlvaClient):
860
+ * - 404 not found / cross-user
861
+ * - 412 cronjob is paused (resume before triggering)
862
+ * - 503 worker workflow handle not yet connected (startup race)
863
+ */
864
+ trigger(params: {
865
+ id: number;
866
+ }): Promise<CronjobTriggerResponse>;
867
+ listRuns(params: CronjobRunsListParams): Promise<CronjobRunsListResponse>;
868
+ getRunLogs(params: {
869
+ cronjob_id: number;
870
+ run_id: number;
871
+ }): Promise<CronjobRunLogsResponse>;
872
+ }
873
+
874
+ declare class ReleaseResource {
875
+ private client;
876
+ constructor(client: AlvaClient);
877
+ feed(params: FeedReleaseRequest): Promise<FeedReleaseResponse>;
878
+ playbookDraft(params: PlaybookDraftRequest): Promise<PlaybookDraftResponse>;
879
+ playbook(params: PlaybookReleaseRequest): Promise<PlaybookReleaseResponse>;
880
+ }
881
+
882
+ /**
883
+ * Feed lifecycle management. Backed by alva-gateway REST (mirrors the
884
+ * GraphQL surface in `pkg/schema/feed.graphql`).
885
+ */
886
+ declare class FeedResource {
887
+ private client;
888
+ constructor(client: AlvaClient);
889
+ /**
890
+ * Stop a feed's producer cronjob. This pauses future scheduled runs while
891
+ * preserving the feed and its existing data.
892
+ *
893
+ * Auth: caller must own the feed (uid match), enforced by the backend.
894
+ */
895
+ stop(params: FeedStatusUpdateRequest): Promise<FeedStatusUpdateResponse>;
896
+ /**
897
+ * Resume a stopped feed's producer cronjob.
898
+ *
899
+ * Auth: caller must own the feed (uid match), enforced by the backend.
900
+ */
901
+ resume(params: FeedStatusUpdateRequest): Promise<FeedStatusUpdateResponse>;
902
+ /**
903
+ * Soft-delete a feed and all its active majors. Cascades:
904
+ * - all active feed_majors are soft-deleted in the same transaction
905
+ * - associated producer cronjobs are removed best-effort (the cronjob
906
+ * scavenger reconciles any leftover rows on its next sweep)
907
+ *
908
+ * Auth: caller must own the feed (uid match), enforced by the backend.
909
+ */
910
+ delete(params: FeedDeleteRequest): Promise<FeedDeleteResponse>;
911
+ }
912
+
913
+ /** Playbook visibility states understood by the gateway. */
914
+ type PlaybookVisibility = 'public' | 'private' | 'paid';
915
+ interface SetVisibilityParams {
916
+ /** URL-safe playbook name. The owner is derived server-side from auth. */
917
+ name: string;
918
+ /** Target visibility: public, private, or paid. */
919
+ visibility: PlaybookVisibility;
920
+ }
921
+ interface SetVisibilityResponse {
922
+ /** ALFS-style "<owner>/<name>" path echoed back by the gateway. */
923
+ playbook_path: string;
924
+ }
925
+ type TrendingPlaybooksSort = 'FOLLOWS' | 'RECENT';
926
+ type TrendingPlaybooksDir = 'FORWARD' | 'BACKWARD';
927
+ interface TrendingPlaybooksParams {
928
+ /** Opaque cursor returned on a previous item. Alias of `current`. */
929
+ cursor?: string;
930
+ /** GraphQL-compatible cursor field name. Alias of `cursor`. */
931
+ current?: string;
932
+ /** Page size, default 50, max 100 server-side. */
933
+ limit?: number;
934
+ /** Only FORWARD is supported by the gateway today. */
935
+ dir?: TrendingPlaybooksDir;
936
+ /** FOLLOWS = most followed, RECENT = newest first. */
937
+ sort?: TrendingPlaybooksSort;
938
+ /** Optional AND-filter tags. */
939
+ tags?: string[];
940
+ /** Optional weighted search across playbook and creator fields. */
941
+ keyword?: string;
942
+ }
943
+ interface TrendingPlaybookItem {
944
+ /** Numeric playbook id encoded as a string. */
945
+ id: string;
946
+ /** Stable "owner/name" handle, useful for follow-up tool calls. */
947
+ ref: string;
948
+ /** Owner username. */
949
+ username: string;
950
+ /** URL-safe playbook name. */
951
+ name: string;
952
+ display_name: string;
953
+ description: string;
954
+ tags: string[];
955
+ follow_count: number;
956
+ /** Relative web path for opening or citing the playbook. */
957
+ url_path: string;
958
+ /** README ALFS path when available. */
959
+ readme?: string;
960
+ /** Cursor to pass as `cursor` / `current` for pagination. */
961
+ cursor: string;
962
+ }
963
+ interface TrendingPlaybooksResponse {
964
+ playbooks: TrendingPlaybookItem[];
965
+ has_next: boolean;
966
+ }
967
+ /**
968
+ * Public playbook discovery. Backed by alva-gateway REST and mirrors the
969
+ * GraphQL `trendingPlaybooks(cursor, sort, tags, keyword)` query.
970
+ */
971
+ /** Compact discovery record returned by getByIds / listByOwner / get. */
972
+ interface PlaybookDiscoveryItem {
973
+ /** Numeric playbook id encoded as a string. */
974
+ id: string;
975
+ /** Owner username (empty when not resolvable). */
976
+ owner_username: string;
977
+ /** URL-safe playbook name. */
978
+ name: string;
979
+ display_name: string;
980
+ visibility: string;
981
+ /** Stable "owner/name" handle for name-addressed operations. */
982
+ ref?: string;
983
+ /** Present on listByOwner rows. */
984
+ cursor?: string;
985
+ }
986
+ interface DiscoveryByIDsResponse {
987
+ items: PlaybookDiscoveryItem[];
988
+ }
989
+ interface ListByOwnerParams {
990
+ owner: string;
991
+ /** Page size, default 50, max 100 server-side. */
992
+ limit?: number;
993
+ cursor?: string;
994
+ }
995
+ interface ListByOwnerResponse {
996
+ items: PlaybookDiscoveryItem[];
997
+ has_next: boolean;
998
+ next_cursor?: string;
999
+ }
1000
+ declare class PlaybooksResource {
1001
+ private client;
1002
+ constructor(client: AlvaClient);
1003
+ /**
1004
+ * Resolve playbook ids to named, addressable records (mono-meta#584 A2).
1005
+ * Visibility-gated server-side; ids the caller cannot see — and DELETED
1006
+ * playbook ids — return no row. Treat a missing id as "deleted or not
1007
+ * visible" (the subscriptions list's `target_status` distinguishes ghosts).
1008
+ * Ids are strings (snowflake-safe). Max 100 per call.
1009
+ *
1010
+ * Auth is optional (like `trending`): with an API key, private/paid
1011
+ * visibility is evaluated for the caller; without one, only public
1012
+ * playbooks resolve. The server decides — no client-side gate.
1013
+ */
1014
+ getByIds(ids: string[]): Promise<DiscoveryByIDsResponse>;
1015
+ /**
1016
+ * List a user's playbooks by owner username (mono-meta#584 C10).
1017
+ * Visibility-gated: another user's private playbooks are omitted.
1018
+ * Auth is optional (like `trending`); without credentials only public
1019
+ * playbooks are listed.
1020
+ */
1021
+ listByOwner(params: ListByOwnerParams): Promise<ListByOwnerResponse>;
1022
+ /**
1023
+ * Get one playbook by numeric id or by "owner/name" ref. Returns null when
1024
+ * not found / not visible / deleted.
1025
+ */
1026
+ get(params: {
1027
+ id?: string;
1028
+ ref?: string;
1029
+ }): Promise<PlaybookDiscoveryItem | null>;
1030
+ /**
1031
+ * List trending / searchable playbooks. Auth is optional: when the client
1032
+ * has an API key it is forwarded, otherwise this uses the public surface.
1033
+ *
1034
+ * The gateway returns a frontend-oriented preview payload; this SDK projects
1035
+ * it into a smaller, agent-friendly shape.
1036
+ */
1037
+ trending(params?: TrendingPlaybooksParams): Promise<TrendingPlaybooksResponse>;
1038
+ /**
1039
+ * Set a playbook's visibility. Requires authentication; the owner is
1040
+ * resolved server-side from the authenticated user, so only the playbook
1041
+ * `name` is needed.
1042
+ *
1043
+ * Note: `private` and `paid` are paid-tier capabilities. A free-tier user
1044
+ * receives a `PERMISSION_DENIED` error from the gateway, which is surfaced
1045
+ * here unchanged.
1046
+ */
1047
+ setVisibility(params: SetVisibilityParams): Promise<SetVisibilityResponse>;
1048
+ }
1049
+
1050
+ declare class SecretsResource {
1051
+ private client;
1052
+ constructor(client: AlvaClient);
1053
+ create(params: CreateSecretRequest): Promise<void>;
1054
+ list(): Promise<{
1055
+ secrets: SecretMetadata[];
1056
+ }>;
1057
+ get(params: {
1058
+ name: string;
1059
+ }): Promise<Secret>;
1060
+ update(params: {
1061
+ name: string;
1062
+ value: string;
1063
+ }): Promise<void>;
1064
+ delete(params: {
1065
+ name: string;
1066
+ }): Promise<void>;
1067
+ }
1068
+
1069
+ declare class SdkDocsResource {
1070
+ private client;
1071
+ constructor(client: AlvaClient);
1072
+ doc(params: {
1073
+ name: string;
1074
+ }): Promise<ModuleDoc>;
1075
+ partitions(): Promise<PartitionsResponse>;
1076
+ partitionSummary(params: {
1077
+ partition: string;
1078
+ }): Promise<PartitionSummaryResponse>;
1079
+ }
1080
+
1081
+ type SkillEndpointTier = 'public' | 'alternative' | 'unstructured';
1082
+ interface SkillEndpointMetadata {
1083
+ skill: string;
1084
+ file: string;
1085
+ method: string;
1086
+ path: string;
1087
+ tier: SkillEndpointTier;
1088
+ required_subscription_tier: 'free' | 'pro';
1089
+ access: 'free_and_pro' | 'pro_only';
1090
+ pro_required: boolean;
1091
+ }
1092
+
1093
+ type SkillTierCounts = Partial<Record<SkillEndpointTier, number>>;
1094
+
1095
+ interface SkillMetadata {
1096
+ endpoint_count: number;
1097
+ endpoint_tier_counts: SkillTierCounts;
1098
+ pro_count: number;
1099
+ }
1100
+ interface SkillSummary {
1101
+ name: string;
1102
+ description: string;
1103
+ metadata?: SkillMetadata;
1104
+ endpoint_tier_counts?: SkillTierCounts;
1105
+ }
1106
+ interface SkillDoc {
1107
+ name: string;
1108
+ description: string;
1109
+ content: string;
1110
+ metadata?: SkillMetadata | SkillEndpointMetadata;
1111
+ endpoint_metadata?: SkillEndpointMetadata[];
1112
+ endpoint_tier_counts?: SkillTierCounts;
1113
+ }
1114
+ declare class DataSkillsResource {
1115
+ private client;
1116
+ constructor(client: AlvaClient);
1117
+ list(): Promise<{
1118
+ skills: SkillSummary[];
1119
+ }>;
1120
+ summary(params: {
1121
+ name: string;
1122
+ }): Promise<SkillDoc>;
1123
+ endpoint(params: {
1124
+ name: string;
1125
+ file: string;
1126
+ }): Promise<SkillDoc>;
1127
+ }
1128
+
1129
+ interface PlaybookSkillSummary {
1130
+ username: string;
1131
+ name: string;
1132
+ display_name: string;
1133
+ description: string;
1134
+ tags: string[];
1135
+ creator_uid: number;
1136
+ updated_at: string;
1137
+ }
1138
+ interface PlaybookSkillFileMeta {
1139
+ path: string;
1140
+ size_bytes: number;
1141
+ }
1142
+ interface PlaybookSkillMeta extends PlaybookSkillSummary {
1143
+ files: PlaybookSkillFileMeta[];
1144
+ }
1145
+ interface PlaybookSkillFile {
1146
+ username: string;
1147
+ name: string;
1148
+ path: string;
1149
+ content: string;
1150
+ updated_at: string;
1151
+ }
1152
+ interface PlaybookSkillTagEntry {
1153
+ name: string;
1154
+ }
1155
+ declare class PlaybookSkillsResource {
1156
+ private client;
1157
+ constructor(client: AlvaClient);
1158
+ list(params?: {
1159
+ tag?: string;
1160
+ username?: string;
1161
+ }): Promise<{
1162
+ skills: PlaybookSkillSummary[];
1163
+ }>;
1164
+ tags(): Promise<{
1165
+ tags: PlaybookSkillTagEntry[];
1166
+ }>;
1167
+ get(id: string): Promise<PlaybookSkillMeta>;
1168
+ file(id: string, path: string): Promise<PlaybookSkillFile>;
1169
+ }
1170
+
1171
+ declare class CommentsResource {
1172
+ private client;
1173
+ constructor(client: AlvaClient);
1174
+ create(params: CreateCommentRequest): Promise<Comment>;
1175
+ pin(params: {
1176
+ comment_id: number;
1177
+ }): Promise<Comment>;
1178
+ unpin(params: {
1179
+ comment_id: number;
1180
+ }): Promise<Comment>;
1181
+ }
1182
+
1183
+ declare class RemixResource {
1184
+ private client;
1185
+ constructor(client: AlvaClient);
1186
+ save(params: RemixRequest): Promise<void>;
1187
+ }
1188
+
1189
+ declare class ScreenshotResource {
1190
+ private client;
1191
+ constructor(client: AlvaClient);
1192
+ capture(params: ScreenshotParams): Promise<ArrayBuffer>;
1193
+ }
1194
+
1195
+ declare class UserResource {
1196
+ private client;
1197
+ constructor(client: AlvaClient);
1198
+ me(): Promise<UserProfile>;
1199
+ }
1200
+
1201
+ declare class TradingResource {
1202
+ private client;
1203
+ constructor(client: AlvaClient);
1204
+ accounts(): Promise<TradingAccount[]>;
1205
+ portfolio(accountId: string): Promise<TradingPortfolio>;
1206
+ orders(params: {
1207
+ accountId: string;
1208
+ source?: string;
1209
+ since?: number;
1210
+ limit?: number;
1211
+ }): Promise<TradingOrder[]>;
1212
+ subscriptions(accountId: string): Promise<TradingSubscription[]>;
1213
+ equityHistory(params: {
1214
+ accountId: string;
1215
+ timeframe?: string;
1216
+ sinceMs?: number;
1217
+ untilMs?: number;
1218
+ }): Promise<EquityPoint[]>;
1219
+ riskRules(): Promise<TradingRiskRule>;
1220
+ subscribe(params: {
1221
+ accountId: string;
1222
+ sourceUsername: string;
1223
+ sourceFeed: string;
1224
+ playbookId: string;
1225
+ playbookVersion: string;
1226
+ executeLatest?: boolean;
1227
+ }): Promise<TradingSubscription>;
1228
+ unsubscribe(subscriptionId: string): Promise<{
1229
+ unsubscribedId: string;
1230
+ }>;
1231
+ execute(params: {
1232
+ accountId: string;
1233
+ signalJson: string;
1234
+ dryRun: boolean;
1235
+ sourceUsername?: string;
1236
+ sourceFeed?: string;
1237
+ }): Promise<ExecuteSignalResult>;
1238
+ updateRiskRules(rules: TradingRiskRuleInput): Promise<TradingRiskRule>;
1239
+ }
1240
+
1241
+ declare class PortfolioResource {
1242
+ private client;
1243
+ constructor(client: AlvaClient);
1244
+ accounts(): Promise<PortfolioAccount[]>;
1245
+ summary(accountId: string): Promise<PortfolioSummary>;
1246
+ activities(params: {
1247
+ accountId: string;
1248
+ limit?: number;
1249
+ pageToken?: string;
1250
+ }): Promise<PortfolioActivityConnection>;
1251
+ }
1252
+
1253
+ declare class ArraysJwtResource {
1254
+ private client;
1255
+ constructor(client: AlvaClient);
1256
+ /** Idempotently sign-or-renew the Arrays JWT server-side. */
1257
+ ensure(): Promise<EnsureArraysJwtResponse>;
1258
+ /** Report the current Arrays JWT state for the authenticated user. */
1259
+ status(): Promise<ArraysJwtStatusResponse>;
1260
+ }
1261
+
1262
+ declare class NotificationsResource {
1263
+ private client;
1264
+ constructor(client: AlvaClient);
1265
+ /**
1266
+ * List the caller's notification history for one playbook
1267
+ * `(username, name)`. Returns `NOT_FOUND` when the playbook is
1268
+ * private or does not exist (the two cases are deliberately
1269
+ * indistinguishable to prevent namespace enumeration).
1270
+ */
1271
+ listPlaybook(params: NotificationListParams): Promise<PlaybookNotificationListResponse>;
1272
+ /**
1273
+ * List the caller's notification history for one feed
1274
+ * `(username, name)`. Authorization is alfs read on
1275
+ * `/alva/home/<username>/feeds/<name>`.
1276
+ */
1277
+ listFeed(params: NotificationListParams): Promise<FeedNotificationListResponse>;
1278
+ }
1279
+
1280
+ declare class NotificationPreferencesResource {
1281
+ private client;
1282
+ constructor(client: AlvaClient);
1283
+ /**
1284
+ * List the caller's notification preference settings. Server defaults
1285
+ * are included even when the caller has not explicitly stored a setting.
1286
+ */
1287
+ list(): Promise<NotificationPreferencesResponse>;
1288
+ /**
1289
+ * Enable or disable one notification preference.
1290
+ */
1291
+ update(params: NotificationPreferenceUpdateParams): Promise<NotificationPreferenceUpdateResponse>;
1292
+ }
1293
+
1294
+ /**
1295
+ * Subscriptions — subscribe the caller to playbooks and feeds.
1296
+ *
1297
+ * Three DISTINCT concepts share the word "subscribe" in the product; this
1298
+ * resource touches the first two and never the third:
1299
+ *
1300
+ * - **follow** — the social relation ("Subscribed Playbooks" in the UI).
1301
+ * Enumerate with `follows()`.
1302
+ * - **alerts** — push/notification opt-ins (what `list()` returns).
1303
+ * - **purchase** — paid playbook access / the SaaS plan. NOT this resource.
1304
+ *
1305
+ * Operations:
1306
+ * - `subscribePlaybook` is a CASCADE: it follows the playbook AND enables
1307
+ * personal push for every push-enabled automation of its latest release,
1308
+ * in one call. `unsubscribePlaybook` reverses both (unfollow + disable
1309
+ * the playbook-level alert) and reports exactly what it changed.
1310
+ * - `subscribeFeed` / `unsubscribeFeed` toggle personal push for ONE feed
1311
+ * (a single automation's alert) without touching the playbook follow.
1312
+ * - `unsubscribeBatch` disables alerts by TARGET ID — bulk, idempotent,
1313
+ * and the only way to clear ghost rows whose target was deleted
1314
+ * (name-addressed unsubscribe 404s on deleted playbooks).
1315
+ *
1316
+ * Backed by alva-gateway REST under `/api/v1/subscriptions/...`.
1317
+ */
1318
+ declare class SubscriptionsResource {
1319
+ private client;
1320
+ constructor(client: AlvaClient);
1321
+ /**
1322
+ * Subscribe to a playbook `(username, name)`: follow it and enable alerts
1323
+ * on all its push-enabled automations. Idempotent. Auth: the caller must be
1324
+ * able to read the playbook — public passes; paid requires an active unlock;
1325
+ * private requires owner/admin.
1326
+ */
1327
+ subscribePlaybook(params: PushSubscriptionPlaybookParams): Promise<SubscribePlaybookResponse>;
1328
+ /**
1329
+ * Unsubscribe from a playbook `(username, name)`: unfollow it and disable
1330
+ * all of its push alerts for the caller. Idempotent.
1331
+ */
1332
+ unsubscribePlaybook(params: PushSubscriptionPlaybookParams): Promise<UnsubscribeResponse>;
1333
+ /**
1334
+ * Subscribe to one feed `(username, name)` — enable personal push for that
1335
+ * single automation's alerts, regardless of which playbook(s) consume it.
1336
+ * Does NOT follow any playbook. Idempotent.
1337
+ */
1338
+ subscribeFeed(params: PushSubscriptionFeedParams): Promise<SubscribeFeedResponse>;
1339
+ /**
1340
+ * Unsubscribe from one feed `(username, name)` — disable that automation's
1341
+ * alerts for the caller. Idempotent.
1342
+ */
1343
+ unsubscribeFeed(params: PushSubscriptionFeedParams): Promise<UnsubscribeResponse>;
1344
+ /**
1345
+ * List the caller's currently active subscriptions.
1346
+ * Results are cursor-paginated.
1347
+ */
1348
+ list(params?: PushSubscriptionListParams): Promise<PushSubscriptionListResponse>;
1349
+ /**
1350
+ * List the playbooks the caller FOLLOWS (the social relation — the UI's
1351
+ * "Subscribed Playbooks"). Rows carry the playbook identity; follows of
1352
+ * deleted playbooks are filtered server-side. Cursor-paginated.
1353
+ */
1354
+ follows(params?: FollowsListParams): Promise<FollowsListResponse>;
1355
+ /**
1356
+ * Disable alerts for many playbook/feed targets BY TARGET ID in one
1357
+ * idempotent call (max 100 ids). Ids are strings (snowflake-safe). Works
1358
+ * for ghost rows (deleted targets) because no name resolution happens —
1359
+ * the per-id results report `INVALID_ID` for malformed entries while
1360
+ * valid ones proceed. Safe to re-run: already-gone rows are no-ops.
1361
+ */
1362
+ unsubscribeBatch(params: UnsubscribeBatchParams): Promise<UnsubscribeBatchResponse>;
1363
+ }
1364
+
1365
+ /**
1366
+ * Group push subscriptions for an external channel session.
1367
+ *
1368
+ * These APIs subscribe the Telegram/Discord group attached to `session_id`
1369
+ * to public feed/playbook push events. Mutations are idempotent no-ops unless
1370
+ * the authenticated caller is that group's Alva admin.
1371
+ */
1372
+ declare class ChannelGroupSubscriptionsResource {
1373
+ private client;
1374
+ constructor(client: AlvaClient);
1375
+ context(params: ChannelGroupSubscriptionSessionParams): Promise<ChannelGroupSubscriptionContextResponse>;
1376
+ list(params: ChannelGroupSubscriptionSessionParams): Promise<ChannelGroupSubscriptionListResponse>;
1377
+ subscribe(params: ChannelGroupSubscriptionMutationParams): Promise<ChannelGroupSubscriptionMutationResponse>;
1378
+ unsubscribe(params: ChannelGroupSubscriptionMutationParams): Promise<ChannelGroupSubscriptionMutationResponse>;
1379
+ }
1380
+
1381
+ declare class FeedbackResource {
1382
+ private client;
1383
+ constructor(client: AlvaClient);
1384
+ submit(params: SubmitFeedbackRequest): Promise<SubmitFeedbackResponse>;
1385
+ }
1386
+
1387
+ interface PlaybookFunction {
1388
+ id: string | number;
1389
+ playbook_id: string | number;
1390
+ function_name: string;
1391
+ entry_script_path: string;
1392
+ created_at?: string;
1393
+ updated_at?: string;
1394
+ disabled?: boolean;
1395
+ params_schema?: string;
1396
+ allow_charges?: boolean;
1397
+ }
1398
+ interface RegisterFunctionParams {
1399
+ playbook_id: number;
1400
+ function_name: string;
1401
+ entry_script_path: string;
1402
+ params_schema?: string;
1403
+ allow_charges?: boolean;
1404
+ }
1405
+ interface RegisterFunctionResponse {
1406
+ function?: PlaybookFunction;
1407
+ }
1408
+ interface ListFunctionsParams {
1409
+ playbook_id: number;
1410
+ }
1411
+ interface ListFunctionsResponse {
1412
+ functions: PlaybookFunction[];
1413
+ }
1414
+ interface DeleteFunctionParams {
1415
+ playbook_id: number;
1416
+ function_name: string;
1417
+ }
1418
+ interface InvokeFunctionParams {
1419
+ playbook_id: number;
1420
+ function_name: string;
1421
+ parameters?: unknown;
1422
+ }
1423
+ interface InvokeFunctionResponse<TResult = unknown> {
1424
+ result: TResult;
1425
+ logs: string;
1426
+ credits_used_total: number;
1427
+ credits_charged_owner: number;
1428
+ credits_charged_consumer: number;
1429
+ }
1430
+ interface CreditAllowance {
1431
+ id: string | number;
1432
+ consumer_uid: string | number;
1433
+ playbook_id: string | number;
1434
+ amount: number;
1435
+ used: number;
1436
+ remaining: number;
1437
+ created_at_ms?: number;
1438
+ updated_at_ms?: number;
1439
+ }
1440
+ interface GetAllowanceParams {
1441
+ playbook_id: number;
1442
+ }
1443
+ interface ListAllowancesResponse {
1444
+ allowances: CreditAllowance[];
1445
+ }
1446
+ interface CreateAllowanceParams {
1447
+ playbook_id: number;
1448
+ amount: number;
1449
+ }
1450
+ interface CreateAllowanceResponse {
1451
+ allowance: CreditAllowance;
1452
+ }
1453
+ interface RevokeAllowanceParams {
1454
+ playbook_id: number;
1455
+ }
1456
+ interface RevokeAllowanceResponse {
1457
+ ok: boolean;
1458
+ }
1459
+ /**
1460
+ * Playbook function management. These functions are registered by a playbook
1461
+ * creator and invoked by released playbook UI through the browser UDF runtime.
1462
+ */
1463
+ declare class FunctionsResource {
1464
+ private client;
1465
+ constructor(client: AlvaClient);
1466
+ register(params: RegisterFunctionParams): Promise<RegisterFunctionResponse>;
1467
+ list(params: ListFunctionsParams): Promise<ListFunctionsResponse>;
1468
+ delete(params: DeleteFunctionParams): Promise<void>;
1469
+ invoke<TResult = unknown>(params: InvokeFunctionParams): Promise<InvokeFunctionResponse<TResult>>;
1470
+ getAllowance(params: GetAllowanceParams): Promise<CreditAllowance | null>;
1471
+ listAllowances(): Promise<ListAllowancesResponse>;
1472
+ createAllowance(params: CreateAllowanceParams): Promise<CreateAllowanceResponse>;
1473
+ revokeAllowance(params: RevokeAllowanceParams): Promise<RevokeAllowanceResponse>;
1474
+ }
1475
+
1476
+ interface RequestOptions {
1477
+ query?: Record<string, unknown>;
1478
+ body?: unknown;
1479
+ /** Raw JSON body, used when callers must preserve int64 numeric literals. */
1480
+ jsonBody?: string;
1481
+ /** Send raw body with application/octet-stream content type (for binary writes). */
1482
+ rawBody?: BodyInit;
1483
+ /** Override the base URL for this request (e.g. the Arrays data-tools endpoint). */
1484
+ baseUrl?: string;
1485
+ /** If true, skip attaching any Alva auth header (X-Alva-Api-Key / x-Playbook-Viewer). */
1486
+ noAuth?: boolean;
1487
+ /** Client-side HTTP timeout in milliseconds. */
1488
+ timeoutMs?: number;
1489
+ /** Optional AbortSignal for this request. Defaults to the client-level signal. */
1490
+ signal?: AbortSignal;
1491
+ }
1492
+ declare class AlvaClient {
1493
+ readonly baseUrl: string;
1494
+ readonly arraysBaseUrl: string;
1495
+ readonly viewer_token?: string;
1496
+ readonly pbsvToken?: string;
1497
+ readonly apiKey?: string;
1498
+ readonly gaClientId?: string;
1499
+ readonly gaSessionId?: string;
1500
+ readonly utmParams?: string;
1501
+ readonly signal?: AbortSignal;
1502
+ /**
1503
+ * Alva chat session that owns work produced through this client (playbooks,
1504
+ * feeds, uploaded files). Forwarded as `X-Alva-Origin-Session-Id` so the
1505
+ * backend can attribute created artifacts to the originating session. This
1506
+ * is a request-context hint, NOT auth — the backend still verifies the
1507
+ * session belongs to the authenticated user before honoring it. Distinct
1508
+ * from `gaSessionId` (browser analytics).
1509
+ */
1510
+ readonly originSessionId?: string;
1511
+ private _fs?;
1512
+ private _run?;
1513
+ private _deploy?;
1514
+ private _release?;
1515
+ private _feed?;
1516
+ private _playbooks?;
1517
+ private _secrets?;
1518
+ private _sdk?;
1519
+ private _dataSkills?;
1520
+ private _playbookSkills?;
1521
+ private _comments?;
1522
+ private _remix?;
1523
+ private _screenshot?;
1524
+ private _user?;
1525
+ private _trading?;
1526
+ private _portfolio?;
1527
+ private _arraysJwt?;
1528
+ private _notifications?;
1529
+ private _notificationPreferences?;
1530
+ private _subscriptions?;
1531
+ private _channelGroupSubscriptions?;
1532
+ private _feedback?;
1533
+ private _functions?;
1534
+ constructor(config: AlvaClientConfig);
1535
+ get fs(): FsResource;
1536
+ get run(): RunResource;
1537
+ get deploy(): DeployResource;
1538
+ get release(): ReleaseResource;
1539
+ get feed(): FeedResource;
1540
+ get playbooks(): PlaybooksResource;
1541
+ get secrets(): SecretsResource;
1542
+ get sdk(): SdkDocsResource;
1543
+ get dataSkills(): DataSkillsResource;
1544
+ get playbookSkills(): PlaybookSkillsResource;
1545
+ get comments(): CommentsResource;
1546
+ get remix(): RemixResource;
1547
+ get screenshot(): ScreenshotResource;
1548
+ get user(): UserResource;
1549
+ get trading(): TradingResource;
1550
+ get portfolio(): PortfolioResource;
1551
+ get arraysJwt(): ArraysJwtResource;
1552
+ get notifications(): NotificationsResource;
1553
+ get notificationPreferences(): NotificationPreferencesResource;
1554
+ get subscriptions(): SubscriptionsResource;
1555
+ get channelGroupSubscriptions(): ChannelGroupSubscriptionsResource;
1556
+ get feedback(): FeedbackResource;
1557
+ get functions(): FunctionsResource;
1558
+ _requireAuth(): void;
1559
+ _request(method: string, path: string, options?: RequestOptions): Promise<unknown>;
1560
+ }
1561
+
1562
+ declare const CLI_VERSION: string;
1563
+ declare const DEFAULT_RUN_TIMEOUT_MS = 600000;
1564
+ /**
1565
+ * Returns true if version `a` is strictly older than version `b`.
1566
+ * Compares major.minor.patch as integers. Returns false on malformed input.
1567
+ */
1568
+ declare function isVersionOlderThan(a: string, b: string): boolean;
1569
+ interface WriteConfigDeps {
1570
+ env: Record<string, string | undefined>;
1571
+ homedir: () => string;
1572
+ mkdir: (path: string, options: {
1573
+ recursive: boolean;
1574
+ }) => Promise<void>;
1575
+ writeFile: (path: string, data: string, options: {
1576
+ mode: number;
1577
+ }) => Promise<void>;
1578
+ readFile: (path: string) => Promise<string>;
1579
+ runHooks?: (client: AlvaClient) => Promise<void>;
1580
+ }
1581
+ type AlvaCliRuntimeMode = 'nodejs' | 'jagent';
1582
+ interface DispatchRuntimeDeps {
1583
+ mode?: AlvaCliRuntimeMode;
1584
+ env?: Record<string, string | undefined>;
1585
+ stderr?: Pick<typeof process.stderr, 'write'>;
1586
+ }
1587
+ declare function handleConfigure(args: string[], deps?: WriteConfigDeps): Promise<{
1588
+ status: string;
1589
+ apiKey: string;
1590
+ baseUrl?: string;
1591
+ profile: string;
1592
+ }>;
1593
+ declare const BOOLEAN_FLAGS: Set<string>;
1594
+ declare function parseFlags(argv: string[]): Record<string, string>;
1595
+ declare function dispatch(client: AlvaClient, args: string[], meta?: {
1596
+ profile?: string;
1597
+ baseUrl?: string;
1598
+ cliVersion?: string;
1599
+ }, deps?: DispatchRuntimeDeps): Promise<unknown>;
1600
+ /**
1601
+ * Strips global flags (--api-key, --base-url, --profile, --arrays-endpoint)
1602
+ * and their associated values from an argv list. Supports both
1603
+ * `--flag value` and `--flag=value` forms.
1604
+ */
1605
+ declare function stripGlobalFlags(argv: string[]): string[];
1606
+
1607
+ export { type AlvaCliRuntimeMode, BOOLEAN_FLAGS, CLI_VERSION, DEFAULT_RUN_TIMEOUT_MS, type DispatchRuntimeDeps, dispatch, handleConfigure, isVersionOlderThan, parseFlags, stripGlobalFlags };