@swarm-agent/sdk 0.1.47

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.
Files changed (74) hide show
  1. package/APPLICATIONS.md +133 -0
  2. package/HEADLESS_UI.md +97 -0
  3. package/LICENSE +201 -0
  4. package/README.md +473 -0
  5. package/dist/app-results.d.ts +24 -0
  6. package/dist/app-results.js +167 -0
  7. package/dist/apps.d.ts +82 -0
  8. package/dist/apps.js +89 -0
  9. package/dist/auth.d.ts +45 -0
  10. package/dist/auth.js +89 -0
  11. package/dist/automations.d.ts +74 -0
  12. package/dist/automations.js +159 -0
  13. package/dist/client.d.ts +61 -0
  14. package/dist/client.js +103 -0
  15. package/dist/deliverables.d.ts +42 -0
  16. package/dist/deliverables.js +83 -0
  17. package/dist/deploy/dockerfile.d.ts +14 -0
  18. package/dist/deploy/dockerfile.js +14 -0
  19. package/dist/deploy/index.d.ts +67 -0
  20. package/dist/deploy/index.js +226 -0
  21. package/dist/deploy/manifest.d.ts +17 -0
  22. package/dist/deploy/manifest.js +220 -0
  23. package/dist/deploy/providers/gcp-cloud-run.d.ts +9 -0
  24. package/dist/deploy/providers/gcp-cloud-run.js +12 -0
  25. package/dist/deploy/providers/gcp-compute.d.ts +9 -0
  26. package/dist/deploy/providers/gcp-compute.js +12 -0
  27. package/dist/deploy/types.d.ts +211 -0
  28. package/dist/deploy/types.js +4 -0
  29. package/dist/deploy/worker-cloud-deployer.d.ts +33 -0
  30. package/dist/deploy/worker-cloud-deployer.js +14 -0
  31. package/dist/errors.d.ts +36 -0
  32. package/dist/errors.js +68 -0
  33. package/dist/index.d.ts +23 -0
  34. package/dist/index.js +20 -0
  35. package/dist/notifications.d.ts +28 -0
  36. package/dist/notifications.js +65 -0
  37. package/dist/projects.d.ts +147 -0
  38. package/dist/projects.js +513 -0
  39. package/dist/provider-auth.d.ts +160 -0
  40. package/dist/provider-auth.js +54 -0
  41. package/dist/realtime.d.ts +240 -0
  42. package/dist/realtime.js +312 -0
  43. package/dist/sessions.d.ts +60 -0
  44. package/dist/sessions.js +194 -0
  45. package/dist/settings.d.ts +85 -0
  46. package/dist/settings.js +26 -0
  47. package/dist/storage/adapters/memory.d.ts +13 -0
  48. package/dist/storage/adapters/memory.js +35 -0
  49. package/dist/storage/adapters/s3.d.ts +31 -0
  50. package/dist/storage/adapters/s3.js +171 -0
  51. package/dist/storage/client.d.ts +174 -0
  52. package/dist/storage/client.js +121 -0
  53. package/dist/storage/hub.d.ts +30 -0
  54. package/dist/storage/hub.js +372 -0
  55. package/dist/storage/index.d.ts +6 -0
  56. package/dist/storage/index.js +6 -0
  57. package/dist/storage/runner.d.ts +48 -0
  58. package/dist/storage/runner.js +233 -0
  59. package/dist/storage/types.d.ts +198 -0
  60. package/dist/storage/types.js +1 -0
  61. package/dist/system.d.ts +14 -0
  62. package/dist/system.js +52 -0
  63. package/dist/transport.d.ts +17 -0
  64. package/dist/transport.js +243 -0
  65. package/dist/types.d.ts +1137 -0
  66. package/dist/types.js +1 -0
  67. package/dist/usage.d.ts +106 -0
  68. package/dist/usage.js +82 -0
  69. package/dist/workers.d.ts +146 -0
  70. package/dist/workers.js +822 -0
  71. package/dist/workspaces.d.ts +81 -0
  72. package/dist/workspaces.js +58 -0
  73. package/examples/headless-session.ts +85 -0
  74. package/package.json +56 -0
@@ -0,0 +1,1137 @@
1
+ export type TokenScope = 'automations:trigger' | 'automations:read' | 'automations:write' | 'sessions:read' | 'sessions:write' | 'projects:read' | 'projects:write' | 'admin' | string;
2
+ export interface SwarmClientConfig {
3
+ /** Base URL for the Swarm API/Desktop daemon (e.g. http://127.0.0.1:18080 or http://127.0.0.1:7781) */
4
+ baseUrl?: string;
5
+ /** Bearer authentication token (attach token or scoped token starting with 'swk_') */
6
+ token?: string;
7
+ /** Unix domain socket path for zero-conf local IPC (e.g. /run/swarmd/swarmd.sock) */
8
+ socketPath?: string;
9
+ /** Custom default HTTP headers */
10
+ defaultHeaders?: Record<string, string>;
11
+ /** Request timeout in milliseconds (default: 30,000ms) */
12
+ timeoutMs?: number;
13
+ }
14
+ export interface ResolvedSwarmClientConfig {
15
+ baseUrl: string;
16
+ token?: string;
17
+ socketPath?: string;
18
+ defaultHeaders: Record<string, string>;
19
+ timeoutMs: number;
20
+ }
21
+ export interface RequestOptions {
22
+ method?: string;
23
+ headers?: Record<string, string>;
24
+ body?: unknown;
25
+ signal?: AbortSignal;
26
+ timeoutMs?: number;
27
+ }
28
+ export interface ScopedTokenRecord {
29
+ id: string;
30
+ name: string;
31
+ token_hint: string;
32
+ scopes: TokenScope[];
33
+ worker_id?: string;
34
+ worker_name?: string;
35
+ expires_at?: number;
36
+ last_used_at?: number;
37
+ created_at: number;
38
+ revoked?: boolean;
39
+ revoked_at?: number;
40
+ }
41
+ export interface CreateScopedTokenParams {
42
+ name: string;
43
+ scopes: TokenScope[];
44
+ worker_id?: string;
45
+ worker_name?: string;
46
+ expires_in_seconds?: number;
47
+ }
48
+ export interface CreateScopedTokenResult {
49
+ ok: boolean;
50
+ token: string;
51
+ record: ScopedTokenRecord;
52
+ }
53
+ export interface DesktopSessionBootstrap {
54
+ ok?: boolean;
55
+ token: string;
56
+ user_id: string;
57
+ account_scope_id: string;
58
+ mode?: string;
59
+ }
60
+ export interface AutomationV2TriggerParams {
61
+ workspace_id?: string;
62
+ worker_id?: string;
63
+ session_id?: string;
64
+ automation_id?: string;
65
+ context?: Record<string, unknown>;
66
+ }
67
+ export interface AutomationV2TriggerResult {
68
+ ok: boolean;
69
+ occurrence: AutomationV2Occurrence;
70
+ message?: string;
71
+ }
72
+ export interface AutomationV2Settings {
73
+ schema_version: 2;
74
+ schedule: {
75
+ kind: 'interval' | 'cron' | 'trigger';
76
+ interval_seconds?: number;
77
+ cron?: string;
78
+ timezone?: string;
79
+ };
80
+ expiration?: {
81
+ kind: 'indefinite' | 'at';
82
+ expires_at?: number;
83
+ };
84
+ missed?: 'skip' | 'coalesce';
85
+ overlap?: 'serialize' | 'independent';
86
+ daily_run_cap?: number;
87
+ webhooks?: Array<{
88
+ id?: string;
89
+ url: string;
90
+ secret?: string;
91
+ format?: 'generic' | 'slack' | 'discord' | 'telegram';
92
+ events?: string[];
93
+ enabled?: boolean;
94
+ }>;
95
+ }
96
+ export interface AutomationV2Record {
97
+ automation_id: string;
98
+ account_id: string;
99
+ workspace_id: string;
100
+ session_id: string;
101
+ generation: number;
102
+ enabled: boolean;
103
+ cancelled: boolean;
104
+ archived?: boolean;
105
+ archived_at?: number;
106
+ accepted_at?: number;
107
+ next_due_at?: number;
108
+ document?: {
109
+ title: string;
110
+ info: {
111
+ goal: string;
112
+ [key: string]: unknown;
113
+ };
114
+ checkpoints: Array<{
115
+ id: string;
116
+ title: string;
117
+ tasks?: string[];
118
+ acceptance_criteria?: string[];
119
+ [key: string]: unknown;
120
+ }>;
121
+ automation_v2?: AutomationV2Settings;
122
+ worker_v2?: AutomationV2Settings;
123
+ [key: string]: unknown;
124
+ };
125
+ }
126
+ export interface AutomationV2Occurrence {
127
+ id: string;
128
+ state: string;
129
+ due_at: number;
130
+ session_id: string;
131
+ accepted?: AutomationV2Record;
132
+ run_id?: string;
133
+ admitted_at?: number;
134
+ observed_at?: number;
135
+ closing_state?: string;
136
+ summary?: string;
137
+ result?: string;
138
+ report?: string;
139
+ trigger_context?: Record<string, unknown>;
140
+ deliverables?: Array<{
141
+ label?: string;
142
+ path?: string;
143
+ media_type?: string;
144
+ filename?: string;
145
+ artifact_id?: string;
146
+ revision_ref?: string;
147
+ [key: string]: unknown;
148
+ }>;
149
+ }
150
+ export interface AutomationV2Progress {
151
+ record: AutomationV2Record;
152
+ observed_at: number;
153
+ timezone: string;
154
+ forecast: number[];
155
+ forecast_is_admission: boolean;
156
+ no_next_reason?: string;
157
+ complete: boolean;
158
+ next_cursor?: string;
159
+ occurrences: AutomationV2Occurrence[];
160
+ }
161
+ export interface AutomationV2ListParams {
162
+ workspace_id?: string;
163
+ archived_mode?: 'exclude' | 'include' | 'only';
164
+ cursor?: string;
165
+ limit?: number;
166
+ }
167
+ export interface DeliverableActionContract {
168
+ action: string;
169
+ target_url?: string;
170
+ target_secret_ref?: string;
171
+ parameters?: Record<string, unknown>;
172
+ }
173
+ export interface DeliverableRevisionFeedback {
174
+ requested_at: number;
175
+ requested_by?: string;
176
+ notes: string;
177
+ tags?: string[];
178
+ }
179
+ export interface DeliverableRecord {
180
+ id: string;
181
+ account_id: string;
182
+ workspace_id?: string;
183
+ workspace_path?: string;
184
+ worker_id?: string;
185
+ occurrence_id?: string;
186
+ session_id?: string;
187
+ title: string;
188
+ kind: 'social_post' | 'alert' | 'report' | 'pr_patch' | 'media_bundle' | 'code_patch' | 'media' | 'custom' | string;
189
+ status: 'pending_review' | 'approved' | 'rejected' | 'published' | 'dismissed' | 'needs_revision' | string;
190
+ summary?: string;
191
+ payload?: Record<string, unknown>;
192
+ media_refs?: Array<{
193
+ label?: string;
194
+ path?: string;
195
+ media_type?: string;
196
+ filename?: string;
197
+ artifact_id?: string;
198
+ revision_ref?: string;
199
+ [key: string]: unknown;
200
+ }>;
201
+ action_contract?: DeliverableActionContract;
202
+ action_result?: Record<string, unknown>;
203
+ revision_feedback?: DeliverableRevisionFeedback;
204
+ revision_history?: DeliverableRevisionFeedback[];
205
+ created_at: number;
206
+ updated_at: number;
207
+ reviewed_at?: number;
208
+ reviewed_by?: string;
209
+ }
210
+ export interface CreateDeliverableParams {
211
+ id?: string;
212
+ workspace_id?: string;
213
+ workspace_path?: string;
214
+ worker_id?: string;
215
+ occurrence_id?: string;
216
+ session_id?: string;
217
+ title: string;
218
+ kind?: string;
219
+ status?: string;
220
+ summary?: string;
221
+ payload?: Record<string, unknown>;
222
+ media_refs?: DeliverableRecord['media_refs'];
223
+ action_contract?: DeliverableActionContract;
224
+ }
225
+ export interface DeliverableFilter {
226
+ status?: string;
227
+ worker_id?: string;
228
+ kind?: string;
229
+ workspace_id?: string;
230
+ limit?: number;
231
+ }
232
+ export interface AutomationV2WebhookRecord {
233
+ id: string;
234
+ account_id?: string;
235
+ workspace_id?: string;
236
+ worker_id?: string;
237
+ url: string;
238
+ secret?: string;
239
+ format?: 'generic' | 'slack' | 'discord' | 'telegram';
240
+ events?: string[];
241
+ enabled: boolean;
242
+ created_at?: number;
243
+ updated_at?: number;
244
+ }
245
+ export interface CreateWebhookParams {
246
+ id?: string;
247
+ workspace_id?: string;
248
+ worker_id?: string;
249
+ url: string;
250
+ secret?: string;
251
+ format?: 'generic' | 'slack' | 'discord' | 'telegram';
252
+ events?: string[];
253
+ enabled?: boolean;
254
+ }
255
+ export interface WebhookTestParams {
256
+ id?: string;
257
+ url?: string;
258
+ secret?: string;
259
+ format?: 'generic' | 'slack' | 'discord' | 'telegram';
260
+ events?: string[];
261
+ worker_id?: string;
262
+ worker_title?: string;
263
+ }
264
+ export interface WebhookTestResult {
265
+ ok: boolean;
266
+ error?: string;
267
+ result?: {
268
+ status_code: number;
269
+ status: string;
270
+ duration_ms: number;
271
+ body?: string;
272
+ signature?: string;
273
+ };
274
+ }
275
+ export interface SessionRecord {
276
+ id: string;
277
+ title: string;
278
+ workspace_id?: string;
279
+ workspace_path?: string;
280
+ user_id?: string;
281
+ account_scope_id?: string;
282
+ state?: string;
283
+ mode?: 'auto' | 'plan';
284
+ agent_name?: string;
285
+ created_at?: number;
286
+ updated_at?: number;
287
+ archived?: boolean;
288
+ archived_at?: number;
289
+ last_run_id?: string;
290
+ }
291
+ export interface CreateSessionParams {
292
+ title?: string;
293
+ workspace_id?: string;
294
+ workspace_path?: string;
295
+ agent_name?: string;
296
+ agent?: string;
297
+ mode?: 'auto' | 'plan';
298
+ client_request_id?: string;
299
+ metadata?: Record<string, unknown>;
300
+ }
301
+ export interface ListSessionsParams {
302
+ limit?: number;
303
+ state?: string;
304
+ workspace_id?: string;
305
+ category?: 'video' | 'needs_review' | 'blocked' | 'in_progress' | 'active_chats' | 'archived';
306
+ cursor?: string;
307
+ }
308
+ export interface SessionMessage {
309
+ id?: string;
310
+ role: 'user' | 'assistant' | 'system';
311
+ content: string;
312
+ created_at?: number;
313
+ }
314
+ export interface SessionDetail {
315
+ id: string;
316
+ title: string;
317
+ workspace_id?: string;
318
+ workspace_path?: string;
319
+ state?: string;
320
+ mode?: 'auto' | 'plan';
321
+ agent_name?: string;
322
+ created_at: number;
323
+ updated_at: number;
324
+ archived?: boolean;
325
+ messages?: SessionMessage[];
326
+ last_run_id?: string;
327
+ active_plan?: unknown;
328
+ raw?: Record<string, unknown>;
329
+ }
330
+ export interface WorkspaceRecord {
331
+ workspace_id: string;
332
+ workspace_name?: string;
333
+ name?: string;
334
+ path: string;
335
+ state?: string;
336
+ is_git_repo?: boolean;
337
+ worktree_enabled?: boolean;
338
+ directories?: string[];
339
+ created_at?: number;
340
+ updated_at?: number;
341
+ is_default?: boolean;
342
+ active?: boolean;
343
+ git?: {
344
+ branch?: string;
345
+ clean?: boolean;
346
+ dirty_files?: number;
347
+ };
348
+ }
349
+ export interface SystemHealth {
350
+ ok: boolean;
351
+ status?: string;
352
+ version?: string;
353
+ uptime_seconds?: number;
354
+ }
355
+ export type NotificationKind = 'system' | 'ai_request' | 'ai_deliverable' | string;
356
+ export type NotificationSeverity = 'info' | 'warning' | 'error' | string;
357
+ export type NotificationStatus = 'active' | 'resolved' | string;
358
+ export interface NotificationAction {
359
+ id: string;
360
+ label: string;
361
+ action_type?: string;
362
+ endpoint?: string;
363
+ variant?: 'primary' | 'secondary' | 'danger' | string;
364
+ }
365
+ export interface NotificationRecord {
366
+ id: string;
367
+ swarm_id: string;
368
+ origin_swarm_id?: string;
369
+ session_id?: string;
370
+ run_id?: string;
371
+ category: string;
372
+ kind?: NotificationKind;
373
+ severity: NotificationSeverity;
374
+ title: string;
375
+ body: string;
376
+ status: NotificationStatus;
377
+ source_event_type?: string;
378
+ permission_id?: string;
379
+ tool_name?: string;
380
+ requirement?: string;
381
+ session_title?: string;
382
+ session_label?: string;
383
+ workspace_path?: string;
384
+ workspace_name?: string;
385
+ origin_label?: string;
386
+ worker_id?: string;
387
+ verified?: boolean;
388
+ action_url?: string;
389
+ payload?: Record<string, unknown>;
390
+ actions?: NotificationAction[];
391
+ read_at?: number;
392
+ acked_at?: number;
393
+ muted_at?: number;
394
+ created_at: number;
395
+ updated_at: number;
396
+ }
397
+ export interface NotificationSummary {
398
+ swarm_id: string;
399
+ total_count: number;
400
+ unread_count: number;
401
+ active_count: number;
402
+ updated_at: number;
403
+ }
404
+ export interface SubmitNotificationParams {
405
+ id?: string;
406
+ swarm_id?: string;
407
+ origin_swarm_id?: string;
408
+ session_id?: string;
409
+ run_id?: string;
410
+ category?: string;
411
+ kind?: NotificationKind;
412
+ severity?: NotificationSeverity;
413
+ title: string;
414
+ body?: string;
415
+ status?: NotificationStatus;
416
+ action_url?: string;
417
+ worker_id?: string;
418
+ origin_label?: string;
419
+ payload?: Record<string, unknown>;
420
+ actions?: NotificationAction[];
421
+ }
422
+ export interface NotificationListFilter {
423
+ limit?: number;
424
+ swarm_id?: string;
425
+ }
426
+ export interface UpdateNotificationParams {
427
+ read?: boolean;
428
+ acked?: boolean;
429
+ muted?: boolean;
430
+ status?: string;
431
+ swarm_id?: string;
432
+ }
433
+ export interface ProjectWorkspaceRef {
434
+ workspace_id?: string;
435
+ path: string;
436
+ role?: 'primary_code' | 'auxiliary' | 'docs' | string;
437
+ label?: string;
438
+ }
439
+ export interface ProjectTaskMediaRef {
440
+ id: string;
441
+ title?: string;
442
+ url?: string;
443
+ media_type?: string;
444
+ kind?: 'image' | 'video' | 'audio' | 'doc' | string;
445
+ filename?: string;
446
+ data?: string;
447
+ size_bytes?: number;
448
+ created_at?: number;
449
+ }
450
+ export interface ProjectRecord {
451
+ id: string;
452
+ account_id?: string;
453
+ name: string;
454
+ description?: string;
455
+ workspaces?: ProjectWorkspaceRef[];
456
+ project_context?: string;
457
+ active_task_ids?: string[];
458
+ automation_ids?: string[];
459
+ primary_session_id?: string;
460
+ uploaded_media?: ProjectTaskMediaRef[];
461
+ created_at: number;
462
+ updated_at: number;
463
+ }
464
+ export interface CreateProjectParams {
465
+ id?: string;
466
+ name: string;
467
+ description?: string;
468
+ workspaces?: ProjectWorkspaceRef[];
469
+ project_context?: string;
470
+ active_task_ids?: string[];
471
+ automation_ids?: string[];
472
+ primary_session_id?: string;
473
+ uploaded_media?: ProjectTaskMediaRef[];
474
+ }
475
+ export interface UpdateProjectParams {
476
+ name?: string;
477
+ description?: string;
478
+ project_context?: string;
479
+ primary_session_id?: string;
480
+ workspaces?: ProjectWorkspaceRef[];
481
+ active_task_ids?: string[];
482
+ automation_ids?: string[];
483
+ }
484
+ export interface ListProjectsParams {
485
+ limit?: number;
486
+ }
487
+ export interface SynthesizeProjectContextParams {
488
+ name: string;
489
+ workspaces: string[];
490
+ }
491
+ export interface DeleteProjectResult {
492
+ status: string;
493
+ id: string;
494
+ }
495
+ export interface ClearProjectContextResult {
496
+ status: string;
497
+ [key: string]: unknown;
498
+ }
499
+ export interface ProjectTaskDeliverable {
500
+ id: string;
501
+ title: string;
502
+ kind: 'video' | 'code_diff' | 'artifact' | 'report' | string;
503
+ status: 'ready' | 'accepted' | 'in_progress' | string;
504
+ duration?: string;
505
+ thumbnail?: string;
506
+ description?: string;
507
+ artifact_ref?: string;
508
+ code_diff?: string;
509
+ media_url?: string;
510
+ parent_deliverable_id?: string;
511
+ source_media_ref?: string;
512
+ }
513
+ export interface ProjectTaskScene {
514
+ scene_number: number;
515
+ title: string;
516
+ duration_sec: number;
517
+ prompt: string;
518
+ visual_notes?: string;
519
+ }
520
+ export interface ProjectTaskPlanBinding {
521
+ plan_id?: string;
522
+ definition_revision?: number;
523
+ session_id?: string;
524
+ receipt?: string;
525
+ }
526
+ export interface ProjectTaskRecord {
527
+ id: string;
528
+ project_id: string;
529
+ account_id?: string;
530
+ title: string;
531
+ description?: string;
532
+ status: 'queued' | 'in_progress' | 'needs_review' | 'completed' | 'failed' | 'pending_approval' | 'planning' | 'rejected' | string;
533
+ session_id?: string;
534
+ agent?: string;
535
+ worker_name?: string;
536
+ outcome_type?: string;
537
+ workspace_path?: string;
538
+ worktree_branch?: string;
539
+ worktree_name?: string;
540
+ base_branch?: string;
541
+ base_commit?: string;
542
+ git_status?: 'clean' | 'dirty' | 'diverged' | 'unknown' | 'stale' | string;
543
+ unintegrated_commits?: number;
544
+ behind_commits?: number;
545
+ is_integrated?: boolean;
546
+ diff_summary?: string;
547
+ is_dirty?: boolean;
548
+ dirty_count?: number;
549
+ sync_warning?: string;
550
+ action_needed?: string;
551
+ what_did_do?: string[];
552
+ what_not_done?: string[];
553
+ pipeline_stages?: string[];
554
+ current_stage_index?: number;
555
+ deliverables?: ProjectTaskDeliverable[];
556
+ workspaces_involved?: string[];
557
+ context_pool_summary?: string;
558
+ plan_summary?: string;
559
+ full_plan_markdown?: string;
560
+ tier?: string;
561
+ feature_size?: 'small' | 'big' | string;
562
+ revision?: number;
563
+ last_error?: string;
564
+ feedback_history?: string[];
565
+ aspect_ratio?: string;
566
+ resolution?: string;
567
+ variant_count?: number;
568
+ duration_seconds?: number;
569
+ model?: string;
570
+ provider?: string;
571
+ thinking?: string;
572
+ service_tier?: string;
573
+ context_mode?: string;
574
+ scenes?: ProjectTaskScene[];
575
+ soundtrack?: string;
576
+ auto_approve?: boolean;
577
+ router_alert?: string;
578
+ attached_media?: ProjectTaskMediaRef[];
579
+ plan_binding?: ProjectTaskPlanBinding;
580
+ plan_document?: any;
581
+ task_program?: any;
582
+ task_program_id?: string;
583
+ task_program_status?: any;
584
+ created_at: number;
585
+ updated_at: number;
586
+ }
587
+ export interface CreateProjectTaskParams {
588
+ id?: string;
589
+ title: string;
590
+ description?: string;
591
+ prompt?: string;
592
+ agent?: string;
593
+ worker_name?: string;
594
+ feature_size?: 'small' | 'big' | string;
595
+ workspace_path?: string;
596
+ worktree_branch?: string;
597
+ outcome_type?: string;
598
+ tier?: string;
599
+ aspect_ratio?: string;
600
+ resolution?: string;
601
+ variant_count?: number;
602
+ deliverable_count?: number;
603
+ duration_seconds?: number;
604
+ model?: string;
605
+ provider?: string;
606
+ thinking?: string;
607
+ service_tier?: string;
608
+ context_mode?: string;
609
+ soundtrack?: string;
610
+ auto_approve?: boolean;
611
+ pipeline_stages?: string[];
612
+ deliverables?: ProjectTaskDeliverable[];
613
+ what_did_do?: string[];
614
+ what_not_done?: string[];
615
+ attached_media?: ProjectTaskMediaRef[];
616
+ document?: any;
617
+ plan_document?: any;
618
+ task_program?: any;
619
+ task_program_id?: string;
620
+ plan_summary?: string;
621
+ full_plan_markdown?: string;
622
+ diff_summary?: string;
623
+ intent?: string;
624
+ video_type?: string;
625
+ enhance_prompt?: boolean;
626
+ scenes_count?: number;
627
+ }
628
+ export interface UpdateProjectTaskParams {
629
+ title?: string;
630
+ description?: string;
631
+ agent?: string;
632
+ worker_name?: string;
633
+ outcome_type?: string;
634
+ workspace_path?: string;
635
+ worktree_branch?: string;
636
+ worktree_name?: string;
637
+ base_branch?: string;
638
+ behind_commits?: number;
639
+ is_integrated?: boolean;
640
+ dirty_count?: number;
641
+ sync_warning?: string;
642
+ unintegrated_commits?: number;
643
+ diff_summary?: string;
644
+ is_dirty?: boolean;
645
+ action_needed?: string;
646
+ what_did_do?: string[];
647
+ what_not_done?: string[];
648
+ pipeline_stages?: string[];
649
+ current_stage_index?: number;
650
+ deliverables?: ProjectTaskDeliverable[];
651
+ workspaces_involved?: string[];
652
+ plan_summary?: string;
653
+ full_plan_markdown?: string;
654
+ tier?: string;
655
+ feature_size?: string;
656
+ last_error?: string;
657
+ revision?: number;
658
+ task_program?: any;
659
+ task_program_id?: string;
660
+ model?: string;
661
+ provider?: string;
662
+ thinking?: string;
663
+ service_tier?: string;
664
+ context_mode?: string;
665
+ }
666
+ export interface CreateProjectTaskResult {
667
+ task: ProjectTaskRecord;
668
+ model_preview?: any;
669
+ }
670
+ export interface GetProjectTaskResult {
671
+ task: ProjectTaskRecord;
672
+ model_preview?: any;
673
+ }
674
+ export interface DeleteProjectTaskResult {
675
+ status: string;
676
+ task_id: string;
677
+ }
678
+ export interface PreviewProjectTaskParams {
679
+ prompt?: string;
680
+ title?: string;
681
+ intent?: string;
682
+ feature_size?: string;
683
+ agent?: string;
684
+ outcome_type?: string;
685
+ tier?: string;
686
+ model?: string;
687
+ provider?: string;
688
+ thinking?: string;
689
+ service_tier?: string;
690
+ context_mode?: string;
691
+ workspace_path?: string;
692
+ }
693
+ export interface ProjectTaskPreviewResult {
694
+ task_plan: any;
695
+ model_preview?: any;
696
+ }
697
+ export interface ProjectTaskModelPreviewResult {
698
+ task: ProjectTaskRecord;
699
+ model_preview: any;
700
+ }
701
+ export interface ProjectTaskApprovalGuards {
702
+ session_id?: string;
703
+ plan_id?: string;
704
+ definition_revision?: number;
705
+ }
706
+ export interface ApproveProjectTaskResult {
707
+ status: 'approved' | 'already_approved' | string;
708
+ task: ProjectTaskRecord;
709
+ }
710
+ export interface RejectProjectTaskResult {
711
+ status: 'rejected' | string;
712
+ task: ProjectTaskRecord;
713
+ }
714
+ export interface ReopenProjectTaskResult {
715
+ status: 'reopened' | string;
716
+ task: ProjectTaskRecord;
717
+ }
718
+ export interface CompleteProjectTaskResult {
719
+ status: 'completed' | string;
720
+ task: ProjectTaskRecord;
721
+ }
722
+ export interface RefineProjectTaskParams extends ProjectTaskApprovalGuards {
723
+ feedback?: string;
724
+ error_summary?: string;
725
+ agent?: string;
726
+ feature_size?: string;
727
+ outcome_type?: string;
728
+ tier?: string;
729
+ model?: string;
730
+ }
731
+ export interface RefineProjectTaskResult {
732
+ status: 'refined' | string;
733
+ task: ProjectTaskRecord;
734
+ }
735
+ export interface IntegrateProjectTaskResult {
736
+ status: 'integrated' | 'already_integrated' | string;
737
+ message?: string;
738
+ task?: ProjectTaskRecord;
739
+ integration_plan?: any;
740
+ resulting_target_head?: string;
741
+ [key: string]: unknown;
742
+ }
743
+ export interface DeployProjectTaskProgramResult {
744
+ status: 'deployed' | string;
745
+ task: ProjectTaskRecord;
746
+ }
747
+ export interface RedeployProjectTaskJobResult {
748
+ status: 'redeploying' | string;
749
+ task: ProjectTaskRecord;
750
+ }
751
+ export interface GetProjectTaskProgramResult {
752
+ program: any;
753
+ }
754
+ export interface DeleteProjectMediaResult {
755
+ removed: boolean;
756
+ media_id: string;
757
+ uploaded_media: ProjectTaskMediaRef[];
758
+ }
759
+ export interface SyncStreamParams {
760
+ endpoint_cursor: string;
761
+ session_ids?: string[];
762
+ surface?: string;
763
+ selector_kind?: string;
764
+ global?: boolean;
765
+ limit?: number;
766
+ include_active?: boolean;
767
+ resources?: {
768
+ notifications?: boolean;
769
+ notification_summary?: boolean;
770
+ tasks?: boolean;
771
+ auth?: boolean;
772
+ };
773
+ }
774
+ export interface SyncStreamResult<TEvent = any> {
775
+ ok: boolean;
776
+ endpoint_cursor: string;
777
+ events: TEvent[];
778
+ has_more: boolean;
779
+ selector?: any;
780
+ replay_instructions?: Record<string, unknown>;
781
+ }
782
+ export type WorkerLifecycleState = 'idle' | 'active' | 'stopping' | 'paused' | 'archived' | 'deleted';
783
+ export interface WorkerCapabilityRequest {
784
+ type: string;
785
+ name: string;
786
+ description?: string;
787
+ required: boolean;
788
+ }
789
+ export interface WorkerWorkspaceRequirement {
790
+ role: string;
791
+ description?: string;
792
+ required: boolean;
793
+ }
794
+ export interface WorkerInputRequirement {
795
+ name: string;
796
+ kind: string;
797
+ description?: string;
798
+ required: boolean;
799
+ default?: unknown;
800
+ }
801
+ export interface WorkerDeliverableRequirement {
802
+ name: string;
803
+ kind: string;
804
+ description?: string;
805
+ required: boolean;
806
+ }
807
+ export interface WorkerProvenance {
808
+ source_worker_id?: string;
809
+ source_revision?: number;
810
+ source_session_id?: string;
811
+ source_proposal_id?: string;
812
+ imported_at?: number;
813
+ migrated_at?: number;
814
+ exported_at?: number;
815
+ author?: string;
816
+ }
817
+ export interface WorkerTriggerConfig {
818
+ trigger_kind: string;
819
+ format?: string;
820
+ secret_ref?: string;
821
+ }
822
+ export interface SessionPlanSubtask {
823
+ id: string;
824
+ title: string;
825
+ status?: string;
826
+ started_at?: number;
827
+ completed_at?: number;
828
+ result?: string;
829
+ notes?: string;
830
+ }
831
+ export interface SessionPlanCheckpoint {
832
+ id: string;
833
+ title?: string;
834
+ status?: string;
835
+ objective?: string;
836
+ tasks?: string[];
837
+ subtasks?: SessionPlanSubtask[];
838
+ active_subtask_id?: string;
839
+ acceptance_criteria?: string[];
840
+ source_message_id?: string;
841
+ notes?: string;
842
+ report?: string;
843
+ result?: string;
844
+ [key: string]: unknown;
845
+ }
846
+ export interface SessionPlanInfo {
847
+ goal?: string;
848
+ scope?: string;
849
+ context?: string;
850
+ decisions?: string[];
851
+ constraints?: string[];
852
+ assumptions?: string[];
853
+ open_questions?: string[];
854
+ relevant_files?: string[];
855
+ success_criteria?: string[];
856
+ validation_strategy?: string[];
857
+ }
858
+ export interface SessionPlanArtifactReference {
859
+ session_id?: string;
860
+ artifact_id?: string;
861
+ revision_ref?: string;
862
+ collection_id?: string;
863
+ variant_id?: string;
864
+ event_seq?: number;
865
+ source_ref?: string;
866
+ label?: string;
867
+ path?: string;
868
+ role?: string;
869
+ description?: string;
870
+ media_type?: string;
871
+ }
872
+ export interface SessionPlanDocument {
873
+ id?: string;
874
+ title: string;
875
+ status?: string;
876
+ schema_version?: string;
877
+ revision_id?: string;
878
+ info?: SessionPlanInfo;
879
+ checkpoints?: SessionPlanCheckpoint[];
880
+ original_checkpoints?: SessionPlanCheckpoint[];
881
+ active_checkpoint_id?: string;
882
+ rendered_text?: string;
883
+ display_text?: string;
884
+ execution_origin?: string;
885
+ artifacts?: SessionPlanArtifactReference[];
886
+ [key: string]: unknown;
887
+ }
888
+ export interface WorkerAutomationDefinition {
889
+ id: string;
890
+ worker_id: string;
891
+ name: string;
892
+ description?: string | null;
893
+ activation_mode: 'manual' | 'interval' | 'cron' | 'external_trigger' | string;
894
+ schedule?: {
895
+ kind: 'interval' | 'cron' | 'trigger';
896
+ interval_seconds?: number;
897
+ cron?: string;
898
+ timezone?: string;
899
+ } | null;
900
+ trigger?: WorkerTriggerConfig | null;
901
+ enabled: boolean;
902
+ plan_document: SessionPlanDocument;
903
+ input_requirements?: WorkerInputRequirement[] | null;
904
+ deliverable_requirements?: WorkerDeliverableRequirement[] | null;
905
+ revision: number;
906
+ created_at: number;
907
+ updated_at: number;
908
+ }
909
+ export interface WorkerAutomationInput {
910
+ name: string;
911
+ description?: string;
912
+ activation_mode: 'manual' | 'interval' | 'cron' | 'external_trigger' | string;
913
+ schedule?: {
914
+ kind: 'interval' | 'cron' | 'trigger';
915
+ interval_seconds?: number;
916
+ cron?: string;
917
+ timezone?: string;
918
+ };
919
+ trigger?: WorkerTriggerConfig;
920
+ enabled?: boolean;
921
+ plan_document: SessionPlanDocument;
922
+ input_requirements?: WorkerInputRequirement[];
923
+ deliverable_requirements?: WorkerDeliverableRequirement[];
924
+ }
925
+ export interface WorkerRecord {
926
+ id: string;
927
+ account_scope_id: string;
928
+ name: string;
929
+ description?: string | null;
930
+ instructions: string;
931
+ lifecycle_state: WorkerLifecycleState;
932
+ revision: number;
933
+ requested_capabilities?: WorkerCapabilityRequest[] | null;
934
+ workspace_requirements?: WorkerWorkspaceRequirement[] | null;
935
+ local_bindings?: Record<string, string> | null;
936
+ automations?: WorkerAutomationDefinition[] | null;
937
+ metadata?: Record<string, unknown> | null;
938
+ provenance?: WorkerProvenance | null;
939
+ created_at: number;
940
+ updated_at: number;
941
+ }
942
+ export interface WorkerRevisionRecord {
943
+ worker_id: string;
944
+ account_scope_id: string;
945
+ revision: number;
946
+ worker: WorkerRecord;
947
+ committed_at: number;
948
+ committed_by?: string;
949
+ change_summary?: string;
950
+ }
951
+ export interface WorkerRunRecord {
952
+ cancel_requested?: boolean;
953
+ id: string;
954
+ account_scope_id: string;
955
+ worker_id: string;
956
+ worker_revision: number;
957
+ automation_id?: string;
958
+ automation_revision?: number;
959
+ occurrence_id?: string;
960
+ session_id?: string;
961
+ request_source: 'direct' | 'schedule' | 'trigger' | 'test_run' | 'orchestrator' | string;
962
+ input?: Record<string, unknown>;
963
+ status: 'admitted' | 'running' | 'succeeded' | 'failed' | 'cancelled' | string;
964
+ error?: string;
965
+ deliverables?: SessionPlanArtifactReference[];
966
+ started_at?: number;
967
+ completed_at?: number;
968
+ created_at: number;
969
+ }
970
+ export interface PortableAutomationDefinition {
971
+ name: string;
972
+ description?: string;
973
+ activation_mode: 'manual' | 'interval' | 'cron' | 'external_trigger' | string;
974
+ schedule?: {
975
+ kind: 'interval' | 'cron' | 'trigger';
976
+ interval_seconds?: number;
977
+ cron?: string;
978
+ timezone?: string;
979
+ };
980
+ trigger?: WorkerTriggerConfig;
981
+ enabled: boolean;
982
+ plan: SessionPlanDocument;
983
+ input_requirements?: WorkerInputRequirement[];
984
+ deliverable_requirements?: WorkerDeliverableRequirement[];
985
+ }
986
+ export interface PortableWorkerProvenance {
987
+ source_worker_id?: string;
988
+ source_revision?: number;
989
+ exported_at?: number;
990
+ }
991
+ export interface PortableWorkerDefinition {
992
+ schema_version: 1;
993
+ name: string;
994
+ description?: string | null;
995
+ instructions: string;
996
+ metadata?: Record<string, unknown> | null;
997
+ capabilities?: WorkerCapabilityRequest[] | null;
998
+ workspace_requirements?: WorkerWorkspaceRequirement[] | null;
999
+ automations?: PortableAutomationDefinition[] | null;
1000
+ provenance?: PortableWorkerProvenance | null;
1001
+ }
1002
+ export interface CreateWorkerParams {
1003
+ name: string;
1004
+ description?: string;
1005
+ instructions?: string;
1006
+ requested_capabilities?: WorkerCapabilityRequest[];
1007
+ workspace_requirements?: WorkerWorkspaceRequirement[];
1008
+ automations?: WorkerAutomationInput[];
1009
+ metadata?: Record<string, unknown>;
1010
+ idempotency_key: string;
1011
+ }
1012
+ export interface UpdateWorkerParams {
1013
+ name?: string;
1014
+ description?: string;
1015
+ instructions?: string;
1016
+ requested_capabilities?: WorkerCapabilityRequest[];
1017
+ workspace_requirements?: WorkerWorkspaceRequirement[];
1018
+ automations?: (WorkerAutomationInput & {
1019
+ id?: string;
1020
+ })[];
1021
+ metadata?: Record<string, unknown>;
1022
+ change_summary?: string;
1023
+ }
1024
+ export interface ListWorkersParams {
1025
+ limit?: number;
1026
+ cursor?: string;
1027
+ lifecycle_state?: WorkerLifecycleState;
1028
+ include_deleted?: boolean;
1029
+ }
1030
+ export interface ListWorkersResult {
1031
+ workers: WorkerRecord[];
1032
+ next_cursor?: string;
1033
+ }
1034
+ export interface AttachWorkerAutomationParams {
1035
+ worker_id: string;
1036
+ expected_worker_revision: number;
1037
+ automation: WorkerAutomationInput;
1038
+ }
1039
+ export interface UpdateWorkerAutomationParams {
1040
+ worker_id: string;
1041
+ automation_id: string;
1042
+ expected_worker_revision: number;
1043
+ automation: WorkerAutomationInput;
1044
+ }
1045
+ export interface RemoveWorkerAutomationParams {
1046
+ worker_id: string;
1047
+ automation_id: string;
1048
+ expected_worker_revision: number;
1049
+ }
1050
+ export interface WorkerValidateResult {
1051
+ valid: boolean;
1052
+ worker: PortableWorkerDefinition;
1053
+ }
1054
+ export interface WorkerExportResult {
1055
+ worker: PortableWorkerDefinition;
1056
+ }
1057
+ export interface ImportWorkerOptions {
1058
+ mode?: 'new' | 'update';
1059
+ idempotencyKey?: string;
1060
+ targetWorkerId?: string;
1061
+ expectedRevision?: number;
1062
+ }
1063
+ export interface ActivateWorkerParams {
1064
+ /** Set false to approve local bindings for an idle test without enabling schedules. */
1065
+ activate?: boolean;
1066
+ worker_id: string;
1067
+ expected_revision: number;
1068
+ local_bindings: Record<string, string>;
1069
+ }
1070
+ export interface PauseWorkerParams {
1071
+ worker_id: string;
1072
+ expected_revision: number;
1073
+ }
1074
+ export interface ResumeWorkerParams {
1075
+ worker_id: string;
1076
+ expected_revision: number;
1077
+ }
1078
+ export interface ArchiveWorkerParams {
1079
+ worker_id: string;
1080
+ expected_revision: number;
1081
+ }
1082
+ export interface DeleteWorkerParams {
1083
+ worker_id: string;
1084
+ expected_revision: number;
1085
+ }
1086
+ export interface SetWorkerAutomationEnabledParams {
1087
+ worker_id: string;
1088
+ automation_id: string;
1089
+ expected_worker_revision: number;
1090
+ }
1091
+ export interface DirectWorkerRequestParams {
1092
+ worker_id: string;
1093
+ prompt?: string;
1094
+ input?: Record<string, unknown>;
1095
+ idempotency_key?: string;
1096
+ }
1097
+ export interface TestWorkerRunParams {
1098
+ worker_id: string;
1099
+ automation_id?: string;
1100
+ prompt?: string;
1101
+ input?: Record<string, unknown>;
1102
+ idempotency_key?: string;
1103
+ }
1104
+ export interface TriggerWorkerParams {
1105
+ worker_id: string;
1106
+ automation_id?: string;
1107
+ payload?: Record<string, unknown>;
1108
+ idempotency_key?: string;
1109
+ }
1110
+ export interface MintWorkerTriggerTokenParams {
1111
+ worker_id: string;
1112
+ name?: string;
1113
+ save_to_secrets?: boolean;
1114
+ }
1115
+ export interface MintWorkerTriggerTokenResult {
1116
+ ok: boolean;
1117
+ token: string;
1118
+ worker_id: string;
1119
+ scopes?: string[];
1120
+ }
1121
+ export interface ListWorkerRunsParams {
1122
+ worker_id: string;
1123
+ limit?: number;
1124
+ cursor?: string;
1125
+ }
1126
+ export interface ListWorkerRunsResult {
1127
+ runs: WorkerRunRecord[];
1128
+ next_cursor?: string;
1129
+ }
1130
+ export interface GetWorkerRunParams {
1131
+ worker_id: string;
1132
+ run_id: string;
1133
+ }
1134
+ export interface CancelWorkerRunParams {
1135
+ worker_id: string;
1136
+ run_id: string;
1137
+ }