@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
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ export * from './client.js';
2
+ export * from './auth.js';
3
+ export * from './automations.js';
4
+ export * from './workers.js';
5
+ export * from './deliverables.js';
6
+ export * from './deploy/index.js';
7
+ export * from './notifications.js';
8
+ export * from './sessions.js';
9
+ export * from './projects.js';
10
+ export * from './workspaces.js';
11
+ export * from './system.js';
12
+ export * from './transport.js';
13
+ export * from './errors.js';
14
+ export * from './types.js';
15
+ export * from './storage/index.js';
16
+ export { SwarmUsageNamespace } from './usage.js';
17
+ export { SwarmAppsNamespace } from './apps.js';
18
+ export * from './settings.js';
19
+ export * from './provider-auth.js';
20
+ export * from './realtime.js';
@@ -0,0 +1,28 @@
1
+ import type { SwarmTransport } from './transport.js';
2
+ import type { NotificationListFilter, NotificationRecord, NotificationSummary, SubmitNotificationParams, UpdateNotificationParams } from './types.js';
3
+ export declare class SwarmNotificationsNamespace {
4
+ private readonly transport;
5
+ constructor(transport: SwarmTransport);
6
+ /**
7
+ * Submits a new notification to the Swarm Inbox (e.g. AI deliverable, pairing request, background job alert).
8
+ */
9
+ submit(params: SubmitNotificationParams): Promise<NotificationRecord>;
10
+ /**
11
+ * Lists notifications across the account/swarm, optionally filtered by limit and swarm_id.
12
+ */
13
+ list(filter?: NotificationListFilter): Promise<NotificationRecord[]>;
14
+ /**
15
+ * Gets the notification summary count (total, unread, active).
16
+ */
17
+ summary(swarmId?: string): Promise<NotificationSummary>;
18
+ /**
19
+ * Updates a notification (mark as read, acknowledged, muted, or update status).
20
+ */
21
+ update(id: string, params?: UpdateNotificationParams): Promise<NotificationRecord>;
22
+ /**
23
+ * Clears (deletes) resolved notifications.
24
+ */
25
+ clear(swarmId?: string): Promise<{
26
+ deleted: number;
27
+ }>;
28
+ }
@@ -0,0 +1,65 @@
1
+ export class SwarmNotificationsNamespace {
2
+ transport;
3
+ constructor(transport) {
4
+ this.transport = transport;
5
+ }
6
+ /**
7
+ * Submits a new notification to the Swarm Inbox (e.g. AI deliverable, pairing request, background job alert).
8
+ */
9
+ async submit(params) {
10
+ const res = await this.transport.request('/v1/notifications/inbox', {
11
+ method: 'POST',
12
+ body: params,
13
+ });
14
+ return res.data.notification;
15
+ }
16
+ /**
17
+ * Lists notifications across the account/swarm, optionally filtered by limit and swarm_id.
18
+ */
19
+ async list(filter = {}) {
20
+ const q = new URLSearchParams();
21
+ if (typeof filter.limit === 'number')
22
+ q.set('limit', String(filter.limit));
23
+ if (filter.swarm_id)
24
+ q.set('swarm_id', filter.swarm_id);
25
+ const path = q.toString() ? `/v1/notifications?${q.toString()}` : '/v1/notifications';
26
+ const res = await this.transport.request(path, {
27
+ method: 'GET',
28
+ });
29
+ return res.data.notifications || [];
30
+ }
31
+ /**
32
+ * Gets the notification summary count (total, unread, active).
33
+ */
34
+ async summary(swarmId) {
35
+ const path = swarmId
36
+ ? `/v1/notifications/summary?swarm_id=${encodeURIComponent(swarmId)}`
37
+ : '/v1/notifications/summary';
38
+ const res = await this.transport.request(path, {
39
+ method: 'GET',
40
+ });
41
+ return res.data.summary;
42
+ }
43
+ /**
44
+ * Updates a notification (mark as read, acknowledged, muted, or update status).
45
+ */
46
+ async update(id, params = {}) {
47
+ const res = await this.transport.request(`/v1/notifications/${encodeURIComponent(id)}`, {
48
+ method: 'POST',
49
+ body: params,
50
+ });
51
+ return res.data.notification;
52
+ }
53
+ /**
54
+ * Clears (deletes) resolved notifications.
55
+ */
56
+ async clear(swarmId) {
57
+ const path = swarmId
58
+ ? `/v1/notifications/clear?swarm_id=${encodeURIComponent(swarmId)}`
59
+ : '/v1/notifications/clear';
60
+ const res = await this.transport.request(path, {
61
+ method: 'POST',
62
+ });
63
+ return { deleted: res.data.result?.deleted ?? 0 };
64
+ }
65
+ }
@@ -0,0 +1,147 @@
1
+ import type { SwarmTransport } from './transport.js';
2
+ import type { ApproveProjectTaskResult, ClearProjectContextResult, CompleteProjectTaskResult, CreateProjectParams, CreateProjectTaskParams, CreateProjectTaskResult, DeleteProjectMediaResult, DeleteProjectResult, DeleteProjectTaskResult, DeployProjectTaskProgramResult, GetProjectTaskProgramResult, GetProjectTaskResult, IntegrateProjectTaskResult, ListProjectsParams, PreviewProjectTaskParams, ProjectRecord, ProjectTaskApprovalGuards, ProjectTaskMediaRef, ProjectTaskModelPreviewResult, ProjectTaskPreviewResult, ProjectTaskRecord, RedeployProjectTaskJobResult, RefineProjectTaskParams, RefineProjectTaskResult, RejectProjectTaskResult, ReopenProjectTaskResult, RequestOptions, SyncStreamParams, SyncStreamResult, SynthesizeProjectContextParams, UpdateProjectParams, UpdateProjectTaskParams } from './types.js';
3
+ export declare class SwarmProjectsNamespace {
4
+ private readonly transport;
5
+ constructor(transport: SwarmTransport);
6
+ /**
7
+ * Lists projects across the active account.
8
+ */
9
+ list(params?: ListProjectsParams, options?: RequestOptions): Promise<ProjectRecord[]>;
10
+ /**
11
+ * Creates a new project in the active account.
12
+ */
13
+ create(params: CreateProjectParams, options?: RequestOptions): Promise<ProjectRecord>;
14
+ /**
15
+ * Retrieves a single project by ID.
16
+ */
17
+ get(projectId: string, options?: RequestOptions): Promise<ProjectRecord>;
18
+ /**
19
+ * Updates an existing project's metadata, context, or bound workspaces.
20
+ */
21
+ update(projectId: string, params: UpdateProjectParams, options?: RequestOptions): Promise<ProjectRecord>;
22
+ /**
23
+ * Deletes a project by ID.
24
+ */
25
+ delete(projectId: string, options?: RequestOptions): Promise<DeleteProjectResult>;
26
+ /**
27
+ * Synthesizes Markdown project context from project name and linked workspaces.
28
+ */
29
+ synthesizeContext(params: SynthesizeProjectContextParams, options?: RequestOptions): Promise<string>;
30
+ /**
31
+ * Clears orchestrator context for a project, archiving old session and provisioning replacement.
32
+ */
33
+ clearContext(projectId: string, options?: RequestOptions): Promise<ClearProjectContextResult>;
34
+ /**
35
+ * Lists media items attached to a project.
36
+ */
37
+ listMedia(projectId: string, options?: RequestOptions): Promise<ProjectTaskMediaRef[]>;
38
+ /**
39
+ * Uploads or attaches a media item to a project.
40
+ */
41
+ uploadMedia(projectId: string, media: Partial<ProjectTaskMediaRef>, options?: RequestOptions): Promise<ProjectTaskMediaRef>;
42
+ /**
43
+ * Removes an attached media item from a project.
44
+ */
45
+ deleteMedia(projectId: string, mediaId: string, options?: RequestOptions): Promise<DeleteProjectMediaResult>;
46
+ /**
47
+ * Lists tasks associated with a project.
48
+ */
49
+ listTasks(projectId: string, options?: RequestOptions, view?: 'active' | 'archived'): Promise<ProjectTaskRecord[]>;
50
+ /**
51
+ * Creates a new autonomous task inside a project.
52
+ */
53
+ createTask(projectId: string, params: CreateProjectTaskParams, options?: RequestOptions): Promise<CreateProjectTaskResult>;
54
+ /**
55
+ * Retrieves a single task by ID within a project, including model preview.
56
+ */
57
+ getTask(projectId: string, taskId: string, options?: RequestOptions): Promise<GetProjectTaskResult>;
58
+ /**
59
+ * Updates an existing pending or queued task in a project.
60
+ */
61
+ updateTask(projectId: string, taskId: string, params: UpdateProjectTaskParams, options?: RequestOptions): Promise<ProjectTaskRecord>;
62
+ /** Archives a task only at the supplied revision. */
63
+ archiveTask(projectId: string, taskId: string, revision: number, options?: RequestOptions): Promise<ProjectTaskRecord>;
64
+ /** Deletes only an archived, unlaunched task at the supplied revision. */
65
+ deleteTask(projectId: string, taskId: string, revision: number, options?: RequestOptions): Promise<DeleteProjectTaskResult>;
66
+ /**
67
+ * Previews how a task will be routed, planned, and modeled before creating it.
68
+ */
69
+ previewTask(projectId: string, params: PreviewProjectTaskParams, options?: RequestOptions): Promise<ProjectTaskPreviewResult>;
70
+ /**
71
+ * Retrieves the authoritative model preview for an existing task.
72
+ */
73
+ getTaskModelPreview(projectId: string, taskId: string, options?: RequestOptions): Promise<ProjectTaskModelPreviewResult>;
74
+ /**
75
+ * Approves a task session with optional exact revision guards.
76
+ * If the task is bound to a structured plan, exact session_id, plan_id, and definition_revision
77
+ * guards are enforced by the backend to prevent stale approvals.
78
+ */
79
+ approveTask(projectId: string, taskId: string, guards?: ProjectTaskApprovalGuards, options?: RequestOptions): Promise<ApproveProjectTaskResult>;
80
+ /**
81
+ * Convenient alias for approveTask.
82
+ */
83
+ acceptTask(projectId: string, taskId: string, guards?: ProjectTaskApprovalGuards, options?: RequestOptions): Promise<ApproveProjectTaskResult>;
84
+ /**
85
+ * Rejects a task and marks its bound plan as rejected.
86
+ */
87
+ rejectTask(projectId: string, taskId: string, guards?: ProjectTaskApprovalGuards, options?: RequestOptions): Promise<RejectProjectTaskResult>;
88
+ /**
89
+ * Reopens a completed or needs_review task with optional feedback instructions.
90
+ */
91
+ reopenTask(projectId: string, taskId: string, params?: ProjectTaskApprovalGuards & {
92
+ feedback?: string;
93
+ }, options?: RequestOptions): Promise<ReopenProjectTaskResult>;
94
+ /**
95
+ * Marks a task as accepted and completed by the user.
96
+ */
97
+ completeTask(projectId: string, taskId: string, options?: RequestOptions): Promise<CompleteProjectTaskResult>;
98
+ /**
99
+ * Refines a task plan based on user feedback directives or error recovery strategy.
100
+ */
101
+ refineTask(projectId: string, taskId: string, params: RefineProjectTaskParams, options?: RequestOptions): Promise<RefineProjectTaskResult>;
102
+ /**
103
+ * Integrates task commits into the parent workspace repository.
104
+ */
105
+ integrateTask(projectId: string, taskId: string, options?: RequestOptions): Promise<IntegrateProjectTaskResult>;
106
+ /**
107
+ * Deploys a task program for staged multi-agent execution.
108
+ */
109
+ deployTaskProgram(projectId: string, taskId: string, options?: RequestOptions): Promise<DeployProjectTaskProgramResult>;
110
+ /**
111
+ * Redeploys a failed or rejected job within a deployed task program.
112
+ */
113
+ redeployTaskProgramJob(projectId: string, taskId: string, params: {
114
+ job_id: string;
115
+ feedback?: string;
116
+ }, options?: RequestOptions): Promise<RedeployProjectTaskJobResult>;
117
+ /**
118
+ * Inspects the durable TaskProgramRecord for a deployed task program.
119
+ */
120
+ getTaskProgram(projectId: string, taskId: string, options?: RequestOptions): Promise<GetProjectTaskProgramResult>;
121
+ /**
122
+ * Streams outbox events after an opaque endpoint cursor via HTTP POST /v3/sync/stream.
123
+ * Cursors remain strictly opaque strings.
124
+ */
125
+ syncStream<TEvent = any>(params: SyncStreamParams, options?: RequestOptions): Promise<SyncStreamResult<TEvent>>;
126
+ /**
127
+ * Replays events starting after an opaque endpoint cursor.
128
+ */
129
+ replayEvents<TEvent = any>(cursor: string, params?: Omit<SyncStreamParams, 'endpoint_cursor'>, options?: RequestOptions): Promise<SyncStreamResult<TEvent>>;
130
+ /**
131
+ * Polls a task until a predicate condition is satisfied, or times out/aborts.
132
+ */
133
+ waitForTask(projectId: string, taskId: string, predicate: (task: ProjectTaskRecord) => boolean, options?: {
134
+ timeoutMs?: number;
135
+ pollIntervalMs?: number;
136
+ signal?: AbortSignal;
137
+ }): Promise<ProjectTaskRecord>;
138
+ /**
139
+ * Async generator yielding sync stream events starting after an opaque cursor,
140
+ * respecting cancellation via AbortSignal.
141
+ */
142
+ streamEvents<TEvent = any>(initialCursor: string, params?: Omit<SyncStreamParams, 'endpoint_cursor'>, options?: {
143
+ pollIntervalMs?: number;
144
+ signal?: AbortSignal;
145
+ timeoutMs?: number;
146
+ }): AsyncIterableIterator<TEvent>;
147
+ }