@alva-ai/toolkit 0.1.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,402 @@
1
+ interface AlvaClientConfig {
2
+ apiKey?: string;
3
+ baseUrl?: string;
4
+ }
5
+ interface UserProfile {
6
+ id: number;
7
+ username: string;
8
+ subscription_tier: 'free' | 'pro';
9
+ telegram_username: string | null;
10
+ }
11
+ interface FsReadParams {
12
+ path: string;
13
+ offset?: number;
14
+ size?: number;
15
+ }
16
+ interface FsWriteParams {
17
+ path: string;
18
+ data: string;
19
+ mkdir_parents?: boolean;
20
+ }
21
+ interface FsRawWriteParams {
22
+ path: string;
23
+ /** Raw file content: string, ArrayBuffer, Uint8Array, Blob, etc. */
24
+ body: BodyInit;
25
+ mkdir_parents?: boolean;
26
+ }
27
+ interface FsWriteResponse {
28
+ bytes_written: number;
29
+ }
30
+ interface FsStat {
31
+ name: string;
32
+ size: number;
33
+ mode: number;
34
+ mod_time: string;
35
+ is_dir: boolean;
36
+ }
37
+ interface FsReaddirParams {
38
+ path: string;
39
+ recursive?: boolean;
40
+ }
41
+ interface FsEntry {
42
+ name: string;
43
+ size: number;
44
+ is_dir: boolean;
45
+ mod_time?: string;
46
+ mode?: number;
47
+ }
48
+ interface FsReaddirResponse {
49
+ entries: FsEntry[];
50
+ }
51
+ interface FsMkdirParams {
52
+ path: string;
53
+ }
54
+ interface FsRemoveParams {
55
+ path: string;
56
+ recursive?: boolean;
57
+ }
58
+ interface FsRenameParams {
59
+ old_path: string;
60
+ new_path: string;
61
+ }
62
+ interface FsCopyParams {
63
+ src_path: string;
64
+ dst_path: string;
65
+ }
66
+ interface FsSymlinkParams {
67
+ target_path: string;
68
+ link_path: string;
69
+ }
70
+ interface FsReadlinkParams {
71
+ path: string;
72
+ }
73
+ interface FsChmodParams {
74
+ path: string;
75
+ mode: number;
76
+ }
77
+ interface FsGrantParams {
78
+ path: string;
79
+ subject: string;
80
+ permission: string;
81
+ }
82
+ interface FsRevokeParams {
83
+ path: string;
84
+ subject: string;
85
+ permission: string;
86
+ }
87
+ interface RunRequest {
88
+ code?: string;
89
+ entry_path?: string;
90
+ working_dir?: string;
91
+ args?: Record<string, unknown>;
92
+ }
93
+ interface RunResponse {
94
+ result: string;
95
+ logs: string;
96
+ stats: {
97
+ duration_ms: number;
98
+ };
99
+ status: 'completed' | 'failed';
100
+ error?: string;
101
+ }
102
+ interface CronjobCreateRequest {
103
+ path: string;
104
+ cron_expression: string;
105
+ name: string;
106
+ args?: Record<string, unknown>;
107
+ push_notify?: boolean;
108
+ }
109
+ interface Cronjob {
110
+ id: number;
111
+ name: string;
112
+ path: string;
113
+ cron_expression: string;
114
+ status: string;
115
+ args: Record<string, unknown>;
116
+ push_notify: boolean;
117
+ created_at: string;
118
+ updated_at: string;
119
+ }
120
+ interface CronjobListParams {
121
+ limit?: number;
122
+ cursor?: string;
123
+ }
124
+ interface CronjobListResponse {
125
+ cronjobs: Cronjob[];
126
+ next_cursor?: string;
127
+ }
128
+ interface CronjobUpdateRequest {
129
+ id: number;
130
+ name?: string;
131
+ cron_expression?: string;
132
+ args?: Record<string, unknown>;
133
+ push_notify?: boolean;
134
+ }
135
+ interface FeedReleaseRequest {
136
+ name: string;
137
+ version: string;
138
+ cronjob_id: number;
139
+ view_json?: Record<string, unknown>;
140
+ description?: string;
141
+ }
142
+ interface FeedReleaseResponse {
143
+ feed_id: number;
144
+ name: string;
145
+ feed_major: number;
146
+ }
147
+ interface PlaybookDraftRequest {
148
+ name: string;
149
+ display_name: string;
150
+ description?: string;
151
+ feeds: Array<{
152
+ feed_id: number;
153
+ feed_major?: number;
154
+ }>;
155
+ trading_symbols?: string[];
156
+ }
157
+ interface PlaybookDraftResponse {
158
+ playbook_id: number;
159
+ playbook_version_id: number;
160
+ }
161
+ interface PlaybookReleaseRequest {
162
+ name: string;
163
+ version: string;
164
+ feeds: Array<{
165
+ feed_id: number;
166
+ feed_major?: number;
167
+ }>;
168
+ changelog: string;
169
+ }
170
+ interface PlaybookReleaseResponse {
171
+ playbook_id: number;
172
+ version: string;
173
+ published_url: string;
174
+ }
175
+ interface CreateSecretRequest {
176
+ name: string;
177
+ value: string;
178
+ }
179
+ interface SecretMetadata {
180
+ name: string;
181
+ keyVersion: number;
182
+ createdAt: string;
183
+ updatedAt: string;
184
+ valueLength: number;
185
+ keyPrefix: string;
186
+ }
187
+ interface Secret {
188
+ name: string;
189
+ value: string;
190
+ createdAt: string;
191
+ updatedAt: string;
192
+ }
193
+ interface ModuleDoc {
194
+ name: string;
195
+ doc: string;
196
+ }
197
+ interface PartitionsResponse {
198
+ partitions: string[];
199
+ }
200
+ interface PartitionSummaryResponse {
201
+ summary: string;
202
+ }
203
+ interface CreateCommentRequest {
204
+ username: string;
205
+ name: string;
206
+ content: string;
207
+ parent_id?: number;
208
+ }
209
+ interface Comment {
210
+ id: number;
211
+ playbook_id: number;
212
+ content: string;
213
+ pin_at: number | null;
214
+ created_at: number;
215
+ updated_at: number;
216
+ creator?: {
217
+ id: string;
218
+ name: string;
219
+ avatar: string;
220
+ };
221
+ agent?: {
222
+ name: string;
223
+ };
224
+ }
225
+ interface RemixRequest {
226
+ child: {
227
+ username: string;
228
+ name: string;
229
+ };
230
+ parents: Array<{
231
+ username: string;
232
+ name: string;
233
+ }>;
234
+ }
235
+ interface ScreenshotParams {
236
+ url: string;
237
+ selector?: string;
238
+ xpath?: string;
239
+ }
240
+
241
+ declare class FsResource {
242
+ private client;
243
+ constructor(client: AlvaClient);
244
+ /** Returns `ArrayBuffer` for binary files, or parsed JSON for time-series virtual paths. */
245
+ read(params: FsReadParams): Promise<ArrayBuffer | unknown>;
246
+ /** Write file using JSON body (Mode 2). For text content. */
247
+ write(params: FsWriteParams): Promise<FsWriteResponse>;
248
+ /** Write file using raw body (Mode 1). Supports binary data. Path and options are query params. */
249
+ rawWrite(params: FsRawWriteParams): Promise<FsWriteResponse>;
250
+ stat(params: {
251
+ path: string;
252
+ }): Promise<FsStat>;
253
+ readdir(params: FsReaddirParams): Promise<FsReaddirResponse>;
254
+ mkdir(params: FsMkdirParams): Promise<void>;
255
+ remove(params: FsRemoveParams): Promise<void>;
256
+ rename(params: FsRenameParams): Promise<void>;
257
+ copy(params: FsCopyParams): Promise<void>;
258
+ symlink(params: FsSymlinkParams): Promise<void>;
259
+ readlink(params: FsReadlinkParams): Promise<{
260
+ target: string;
261
+ }>;
262
+ chmod(params: FsChmodParams): Promise<void>;
263
+ grant(params: FsGrantParams): Promise<void>;
264
+ revoke(params: FsRevokeParams): Promise<void>;
265
+ }
266
+
267
+ declare class RunResource {
268
+ private client;
269
+ constructor(client: AlvaClient);
270
+ execute(params: RunRequest): Promise<RunResponse>;
271
+ }
272
+
273
+ declare class DeployResource {
274
+ private client;
275
+ constructor(client: AlvaClient);
276
+ create(params: CronjobCreateRequest): Promise<Cronjob>;
277
+ list(params?: CronjobListParams): Promise<CronjobListResponse>;
278
+ get(params: {
279
+ id: number;
280
+ }): Promise<Cronjob>;
281
+ update(params: CronjobUpdateRequest): Promise<Cronjob>;
282
+ delete(params: {
283
+ id: number;
284
+ }): Promise<void>;
285
+ pause(params: {
286
+ id: number;
287
+ }): Promise<void>;
288
+ resume(params: {
289
+ id: number;
290
+ }): Promise<void>;
291
+ }
292
+
293
+ declare class ReleaseResource {
294
+ private client;
295
+ constructor(client: AlvaClient);
296
+ feed(params: FeedReleaseRequest): Promise<FeedReleaseResponse>;
297
+ playbookDraft(params: PlaybookDraftRequest): Promise<PlaybookDraftResponse>;
298
+ playbook(params: PlaybookReleaseRequest): Promise<PlaybookReleaseResponse>;
299
+ }
300
+
301
+ declare class SecretsResource {
302
+ private client;
303
+ constructor(client: AlvaClient);
304
+ create(params: CreateSecretRequest): Promise<void>;
305
+ list(): Promise<{
306
+ secrets: SecretMetadata[];
307
+ }>;
308
+ get(params: {
309
+ name: string;
310
+ }): Promise<Secret>;
311
+ update(params: {
312
+ name: string;
313
+ value: string;
314
+ }): Promise<void>;
315
+ delete(params: {
316
+ name: string;
317
+ }): Promise<void>;
318
+ }
319
+
320
+ declare class SdkDocsResource {
321
+ private client;
322
+ constructor(client: AlvaClient);
323
+ doc(params: {
324
+ name: string;
325
+ }): Promise<ModuleDoc>;
326
+ partitions(): Promise<PartitionsResponse>;
327
+ partitionSummary(params: {
328
+ partition: string;
329
+ }): Promise<PartitionSummaryResponse>;
330
+ }
331
+
332
+ declare class CommentsResource {
333
+ private client;
334
+ constructor(client: AlvaClient);
335
+ create(params: CreateCommentRequest): Promise<Comment>;
336
+ pin(params: {
337
+ comment_id: number;
338
+ }): Promise<Comment>;
339
+ unpin(params: {
340
+ comment_id: number;
341
+ }): Promise<Comment>;
342
+ }
343
+
344
+ declare class RemixResource {
345
+ private client;
346
+ constructor(client: AlvaClient);
347
+ save(params: RemixRequest): Promise<void>;
348
+ }
349
+
350
+ declare class ScreenshotResource {
351
+ private client;
352
+ constructor(client: AlvaClient);
353
+ capture(params: ScreenshotParams): Promise<ArrayBuffer>;
354
+ }
355
+
356
+ declare class UserResource {
357
+ private client;
358
+ constructor(client: AlvaClient);
359
+ me(): Promise<UserProfile>;
360
+ }
361
+
362
+ interface RequestOptions {
363
+ query?: Record<string, unknown>;
364
+ body?: unknown;
365
+ /** Send raw body with application/octet-stream content type (for binary writes). */
366
+ rawBody?: BodyInit;
367
+ }
368
+ declare class AlvaClient {
369
+ readonly baseUrl: string;
370
+ readonly apiKey?: string;
371
+ private _fs?;
372
+ private _run?;
373
+ private _deploy?;
374
+ private _release?;
375
+ private _secrets?;
376
+ private _sdk?;
377
+ private _comments?;
378
+ private _remix?;
379
+ private _screenshot?;
380
+ private _user?;
381
+ constructor(config: AlvaClientConfig);
382
+ get fs(): FsResource;
383
+ get run(): RunResource;
384
+ get deploy(): DeployResource;
385
+ get release(): ReleaseResource;
386
+ get secrets(): SecretsResource;
387
+ get sdk(): SdkDocsResource;
388
+ get comments(): CommentsResource;
389
+ get remix(): RemixResource;
390
+ get screenshot(): ScreenshotResource;
391
+ get user(): UserResource;
392
+ _requireAuth(): void;
393
+ _request(method: string, path: string, options?: RequestOptions): Promise<unknown>;
394
+ }
395
+
396
+ declare class AlvaError extends Error {
397
+ readonly code: string;
398
+ readonly status: number;
399
+ constructor(code: string, message: string, status: number);
400
+ }
401
+
402
+ export { AlvaClient, type AlvaClientConfig, AlvaError, type Comment, type CreateCommentRequest, type CreateSecretRequest, type Cronjob, type CronjobCreateRequest, type CronjobListParams, type CronjobListResponse, type CronjobUpdateRequest, type FeedReleaseRequest, type FeedReleaseResponse, type FsChmodParams, type FsCopyParams, type FsEntry, type FsGrantParams, type FsMkdirParams, type FsRawWriteParams, type FsReadParams, type FsReaddirParams, type FsReaddirResponse, type FsReadlinkParams, type FsRemoveParams, type FsRenameParams, type FsRevokeParams, type FsStat, type FsSymlinkParams, type FsWriteParams, type FsWriteResponse, type ModuleDoc, type PartitionSummaryResponse, type PartitionsResponse, type PlaybookDraftRequest, type PlaybookDraftResponse, type PlaybookReleaseRequest, type PlaybookReleaseResponse, type RemixRequest, type RunRequest, type RunResponse, type ScreenshotParams, type Secret, type SecretMetadata, type UserProfile };