@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/apps.d.ts ADDED
@@ -0,0 +1,82 @@
1
+ import type { ApplicationResultsOptions } from './app-results.js';
2
+ import type { SessionWatchOptions, SessionWatch } from './realtime.js';
3
+ import type { WorkerAutomationInput, TriggerWorkerParams } from './types.js';
4
+ import type { SwarmTransport } from './transport.js';
5
+ import type { SessionRecord, CreateSessionParams, CreateProjectTaskParams, ProjectTaskRecord, WorkerRecord, WorkerRunRecord } from './types.js';
6
+ export interface ApplicationAgent {
7
+ id: string;
8
+ name: string;
9
+ instructions: string;
10
+ context: string;
11
+ revision: number;
12
+ project_id?: string;
13
+ worker_ids?: string[];
14
+ }
15
+ export type ApplicationAgentWrite = Omit<ApplicationAgent, 'id' | 'revision'> & {
16
+ expected_revision: number;
17
+ };
18
+ export type ApplicationConversationParams = CreateSessionParams & {
19
+ client_request_id: string;
20
+ revision: number;
21
+ };
22
+ export interface ApplicationConversationSnapshot {
23
+ session: SessionRecord;
24
+ messages?: Array<{
25
+ id: string;
26
+ role: string;
27
+ content: string;
28
+ }>;
29
+ [key: string]: unknown;
30
+ }
31
+ /** Application context and owned conversations; not a second execution engine. */
32
+ export declare class SwarmAppsNamespace {
33
+ private readonly transport;
34
+ constructor(transport: SwarmTransport);
35
+ watchResults(id: string, options: ApplicationResultsOptions): SessionWatch;
36
+ private path;
37
+ list(params?: {
38
+ limit?: number;
39
+ cursor?: string;
40
+ }): Promise<{
41
+ agents: ApplicationAgent[];
42
+ next_cursor?: string;
43
+ }>;
44
+ tasks(id: string, signal?: AbortSignal): Promise<{
45
+ tasks: ProjectTaskRecord[];
46
+ }>;
47
+ createTask(id: string, input: CreateProjectTaskParams): Promise<{
48
+ task: ProjectTaskRecord;
49
+ }>;
50
+ worker(id: string, workerId: string, signal?: AbortSignal): Promise<{
51
+ worker: WorkerRecord;
52
+ }>;
53
+ runs(id: string, workerId: string, signal?: AbortSignal): Promise<{
54
+ runs: WorkerRunRecord[];
55
+ }>;
56
+ /** Configuration changes retain canonical worker review/approval gates. */
57
+ configureAutomation(id: string, workerId: string, expectedRevision: number, automation: WorkerAutomationInput, automationId?: string): Promise<{
58
+ worker: WorkerRecord;
59
+ }>;
60
+ trigger(id: string, input: TriggerWorkerParams & {
61
+ idempotency_key: string;
62
+ }): Promise<Record<string, unknown>>;
63
+ /** Ownership is checked before opening the canonical V3 session stream. */
64
+ watchConversation(id: string, sessionId: string, options: SessionWatchOptions): Promise<SessionWatch>;
65
+ /** Create with expected_revision=0; update with the revision last read. */
66
+ put(id: string, input: ApplicationAgentWrite): Promise<ApplicationAgent>;
67
+ get(id: string, signal?: AbortSignal): Promise<ApplicationAgent>;
68
+ /** Context is pinned for the lifetime of this conversation, including restart. */
69
+ createConversation(id: string, input: ApplicationConversationParams): Promise<SessionRecord>;
70
+ conversations(id: string): Promise<{
71
+ sessions: SessionRecord[];
72
+ scan_limit: number;
73
+ scan_limit_reached: boolean;
74
+ }>;
75
+ /** Reopen by durable id, with server-side agent ownership validation. */
76
+ conversation(id: string, sessionId: string): Promise<ApplicationConversationSnapshot>;
77
+ /** Event IDs should be stable across delivery retries. Content is a user message, not instructions. */
78
+ send(id: string, sessionId: string, input: {
79
+ content: string;
80
+ client_request_id: string;
81
+ }): Promise<Record<string, unknown>>;
82
+ }
package/dist/apps.js ADDED
@@ -0,0 +1,89 @@
1
+ import { watchApplicationResults } from './app-results.js';
2
+ import { SwarmRealtimeNamespace } from './realtime.js';
3
+ function segment(value) {
4
+ if (!value.trim() || value === '.' || value === '..' || /[/\\]/.test(value))
5
+ throw new Error('A nonempty resource id without path separators is required');
6
+ return encodeURIComponent(value);
7
+ }
8
+ /** Application context and owned conversations; not a second execution engine. */
9
+ export class SwarmAppsNamespace {
10
+ transport;
11
+ constructor(transport) {
12
+ this.transport = transport;
13
+ }
14
+ watchResults(id, options) {
15
+ segment(id);
16
+ return watchApplicationResults(this, this.transport, id, options);
17
+ }
18
+ path(id) { return `/v3/application-agents/${segment(id)}`; }
19
+ async list(params = {}) {
20
+ const q = new URLSearchParams();
21
+ if (params.limit !== undefined)
22
+ q.set('limit', String(params.limit));
23
+ if (params.cursor)
24
+ q.set('cursor', params.cursor);
25
+ return (await this.transport.request(`/v3/application-agents?${q}`, { method: 'GET' })).data;
26
+ }
27
+ async tasks(id, signal) {
28
+ return (await this.transport.request(`${this.path(id)}/tasks`, { method: 'GET', signal })).data;
29
+ }
30
+ async createTask(id, input) {
31
+ return (await this.transport.request(`${this.path(id)}/tasks`, { method: 'POST', body: input })).data;
32
+ }
33
+ async worker(id, workerId, signal) {
34
+ return (await this.transport.request(`${this.path(id)}/workers/${segment(workerId)}`, { method: 'GET', signal })).data;
35
+ }
36
+ async runs(id, workerId, signal) {
37
+ return (await this.transport.request(`${this.path(id)}/workers/${segment(workerId)}/runs`, { method: 'GET', signal })).data;
38
+ }
39
+ /** Configuration changes retain canonical worker review/approval gates. */
40
+ async configureAutomation(id, workerId, expectedRevision, automation, automationId) {
41
+ if (!Number.isSafeInteger(expectedRevision) || expectedRevision < 1)
42
+ throw new Error('A positive worker revision is required');
43
+ const path = `${this.path(id)}/workers/${segment(workerId)}/automations${automationId === undefined ? '' : `/${segment(automationId)}`}`;
44
+ return (await this.transport.request(path, { method: automationId === undefined ? 'POST' : 'PUT', body: { expected_worker_revision: expectedRevision, automation } })).data;
45
+ }
46
+ async trigger(id, input) {
47
+ if (!input.idempotency_key.trim())
48
+ throw new Error('A stable delivery id is required');
49
+ const suffix = input.automation_id === undefined ? '/trigger' : `/automations/${segment(input.automation_id)}/trigger`;
50
+ return (await this.transport.request(`${this.path(id)}/workers/${segment(input.worker_id)}${suffix}`, {
51
+ method: 'POST', body: { payload: input.payload, idempotency_key: input.idempotency_key },
52
+ })).data;
53
+ }
54
+ /** Ownership is checked before opening the canonical V3 session stream. */
55
+ async watchConversation(id, sessionId, options) {
56
+ await this.conversation(id, sessionId);
57
+ return new SwarmRealtimeNamespace(this.transport).watchSession(sessionId, options);
58
+ }
59
+ /** Create with expected_revision=0; update with the revision last read. */
60
+ async put(id, input) {
61
+ return (await this.transport.request(this.path(id), { method: 'PUT', body: input })).data;
62
+ }
63
+ async get(id, signal) {
64
+ return (await this.transport.request(this.path(id), { method: 'GET', signal })).data;
65
+ }
66
+ /** Context is pinned for the lifetime of this conversation, including restart. */
67
+ async createConversation(id, input) {
68
+ const { revision, ...params } = input;
69
+ if (!Number.isSafeInteger(revision) || revision < 1)
70
+ throw new Error('A positive agent revision is required');
71
+ const response = await this.transport.request(`${this.path(id)}/conversations?revision=${revision}`, {
72
+ method: 'POST', body: { ...params, agent_name: params.agent_name ?? params.agent ?? 'swarm' },
73
+ });
74
+ return response.data.session;
75
+ }
76
+ async conversations(id) {
77
+ return (await this.transport.request(`${this.path(id)}/conversations`, { method: 'GET' })).data;
78
+ }
79
+ /** Reopen by durable id, with server-side agent ownership validation. */
80
+ async conversation(id, sessionId) {
81
+ return (await this.transport.request(`${this.path(id)}/conversations/${segment(sessionId)}`, { method: 'GET' })).data;
82
+ }
83
+ /** Event IDs should be stable across delivery retries. Content is a user message, not instructions. */
84
+ async send(id, sessionId, input) {
85
+ return (await this.transport.request(`${this.path(id)}/conversations/${segment(sessionId)}/messages`, {
86
+ method: 'POST', body: { ...input, role: 'user' },
87
+ })).data;
88
+ }
89
+ }
package/dist/auth.d.ts ADDED
@@ -0,0 +1,45 @@
1
+ import { SwarmCredentialsNamespace, SwarmCodexAuthNamespace } from './provider-auth.js';
2
+ import type { SwarmTransport } from './transport.js';
3
+ import type { CreateScopedTokenParams, CreateScopedTokenResult, DesktopSessionBootstrap, ScopedTokenRecord } from './types.js';
4
+ export declare class SwarmAuthNamespace {
5
+ readonly credentials: SwarmCredentialsNamespace;
6
+ readonly codex: SwarmCodexAuthNamespace;
7
+ private transport;
8
+ private onTokenUpdate?;
9
+ constructor(transport: SwarmTransport, onTokenUpdate?: (token: string) => void);
10
+ /**
11
+ * Bootstraps local desktop session credentials.
12
+ * Useful in local development or testbench environments to obtain administrative tokens.
13
+ * By default, automatically updates the client's bearer token with the returned token.
14
+ */
15
+ bootstrapDesktopSession(options?: {
16
+ origin?: string;
17
+ updateClientToken?: boolean;
18
+ }): Promise<DesktopSessionBootstrap>;
19
+ /**
20
+ * Creates a new scoped deploy token with granular permission scopes.
21
+ * Returns the plaintext token (prefixed with 'swk_') along with the token record.
22
+ * Store the token securely—it cannot be retrieved again in plaintext!
23
+ */
24
+ createScopedToken(params: CreateScopedTokenParams): Promise<CreateScopedTokenResult>;
25
+ /**
26
+ * Lists all scoped deploy tokens for the active account.
27
+ * Secret hashes are masked; hints (e.g. 'swk_...abcd') are displayed.
28
+ */
29
+ listScopedTokens(): Promise<ScopedTokenRecord[]>;
30
+ /**
31
+ * Revokes a scoped token by ID.
32
+ * The token immediately ceases to authenticate requests.
33
+ */
34
+ revokeScopedToken(tokenId: string): Promise<ScopedTokenRecord>;
35
+ /**
36
+ * Deletes or purges a scoped token.
37
+ * If purge is true, the token record and index are permanently deleted from store.
38
+ */
39
+ deleteScopedToken(tokenId: string, options?: {
40
+ purge?: boolean;
41
+ }): Promise<{
42
+ ok: boolean;
43
+ deleted: boolean;
44
+ }>;
45
+ }
package/dist/auth.js ADDED
@@ -0,0 +1,89 @@
1
+ import { SwarmCredentialsNamespace, SwarmCodexAuthNamespace } from './provider-auth.js';
2
+ export class SwarmAuthNamespace {
3
+ credentials;
4
+ codex;
5
+ transport;
6
+ onTokenUpdate;
7
+ constructor(transport, onTokenUpdate) {
8
+ this.transport = transport;
9
+ this.credentials = new SwarmCredentialsNamespace(transport);
10
+ this.codex = new SwarmCodexAuthNamespace(transport);
11
+ this.onTokenUpdate = onTokenUpdate;
12
+ }
13
+ /**
14
+ * Bootstraps local desktop session credentials.
15
+ * Useful in local development or testbench environments to obtain administrative tokens.
16
+ * By default, automatically updates the client's bearer token with the returned token.
17
+ */
18
+ async bootstrapDesktopSession(options = {}) {
19
+ const baseUrl = this.transport.getConfig().baseUrl.replace(/\/+$/, '');
20
+ const origin = options.origin ?? baseUrl;
21
+ const res = await this.transport.request('/v1/auth/desktop/session', {
22
+ method: 'GET',
23
+ headers: {
24
+ 'Origin': origin,
25
+ 'Referer': `${origin}/app`,
26
+ 'Sec-Fetch-Site': 'same-origin',
27
+ },
28
+ });
29
+ const data = res.data;
30
+ if (options.updateClientToken !== false && data?.token) {
31
+ this.transport.setConfig({ token: data.token });
32
+ if (this.onTokenUpdate) {
33
+ this.onTokenUpdate(data.token);
34
+ }
35
+ }
36
+ return data;
37
+ }
38
+ /**
39
+ * Creates a new scoped deploy token with granular permission scopes.
40
+ * Returns the plaintext token (prefixed with 'swk_') along with the token record.
41
+ * Store the token securely—it cannot be retrieved again in plaintext!
42
+ */
43
+ async createScopedToken(params) {
44
+ const res = await this.transport.request('/v3/auth/tokens', {
45
+ method: 'POST',
46
+ body: {
47
+ name: params.name,
48
+ scopes: params.scopes,
49
+ worker_id: params.worker_id,
50
+ worker_name: params.worker_name,
51
+ expires_in_seconds: params.expires_in_seconds,
52
+ },
53
+ });
54
+ return res.data;
55
+ }
56
+ /**
57
+ * Lists all scoped deploy tokens for the active account.
58
+ * Secret hashes are masked; hints (e.g. 'swk_...abcd') are displayed.
59
+ */
60
+ async listScopedTokens() {
61
+ const res = await this.transport.request('/v3/auth/tokens', {
62
+ method: 'GET',
63
+ });
64
+ return res.data?.tokens ?? [];
65
+ }
66
+ /**
67
+ * Revokes a scoped token by ID.
68
+ * The token immediately ceases to authenticate requests.
69
+ */
70
+ async revokeScopedToken(tokenId) {
71
+ const id = encodeURIComponent(tokenId.trim());
72
+ const res = await this.transport.request(`/v3/auth/tokens/${id}/revoke`, {
73
+ method: 'POST',
74
+ });
75
+ return res.data.record;
76
+ }
77
+ /**
78
+ * Deletes or purges a scoped token.
79
+ * If purge is true, the token record and index are permanently deleted from store.
80
+ */
81
+ async deleteScopedToken(tokenId, options = {}) {
82
+ const id = encodeURIComponent(tokenId.trim());
83
+ const query = options.purge ? '?purge=true' : '';
84
+ const res = await this.transport.request(`/v3/auth/tokens/${id}${query}`, {
85
+ method: 'DELETE',
86
+ });
87
+ return res.data;
88
+ }
89
+ }
@@ -0,0 +1,74 @@
1
+ import type { SwarmTransport } from './transport.js';
2
+ import type { AutomationV2ListParams, AutomationV2Progress, AutomationV2Record, AutomationV2TriggerParams, AutomationV2TriggerResult, AutomationV2WebhookRecord, CreateWebhookParams, WebhookTestParams, WebhookTestResult } from './types.js';
3
+ export declare class SwarmAutomationsNamespace {
4
+ private transport;
5
+ constructor(transport: SwarmTransport);
6
+ /**
7
+ * Immediately triggers an on-demand worker execution with caller-supplied context.
8
+ * Admitted occurrences execute in an isolated Git worktree with runtime context
9
+ * injected into the agent's goal and execution metadata.
10
+ */
11
+ trigger(params: AutomationV2TriggerParams): Promise<AutomationV2TriggerResult>;
12
+ /**
13
+ * Lists all automations/workers in the specified workspace.
14
+ */
15
+ list(params?: AutomationV2ListParams): Promise<AutomationV2Record[]>;
16
+ /**
17
+ * Retrieves an automation review/definition for a given worker_id or session_id.
18
+ */
19
+ get(params: {
20
+ workspace_id: string;
21
+ worker_id?: string;
22
+ session_id?: string;
23
+ }): Promise<AutomationV2Record | null>;
24
+ /**
25
+ * Fetches the current progress, execution history, and upcoming forecast for a worker.
26
+ */
27
+ getProgress(params: {
28
+ workspace_id: string;
29
+ worker_id?: string;
30
+ session_id?: string;
31
+ timezone?: string;
32
+ cursor?: string;
33
+ }): Promise<AutomationV2Progress>;
34
+ /**
35
+ * Deletes an automation permanently, cancelling pending runs and purging accepted records.
36
+ */
37
+ delete(params: {
38
+ workspace_id: string;
39
+ session_id: string;
40
+ generation?: number;
41
+ }): Promise<boolean>;
42
+ /**
43
+ * Pauses an active automation schedule.
44
+ */
45
+ pause(params: {
46
+ workspace_id: string;
47
+ session_id: string;
48
+ generation: number;
49
+ }): Promise<boolean>;
50
+ /**
51
+ * Resumes a paused automation schedule.
52
+ */
53
+ resume(params: {
54
+ workspace_id: string;
55
+ session_id: string;
56
+ generation: number;
57
+ }): Promise<boolean>;
58
+ /**
59
+ * Lists all configured push alert webhooks for the account.
60
+ */
61
+ listWebhooks(): Promise<AutomationV2WebhookRecord[]>;
62
+ /**
63
+ * Creates or updates a push alert webhook destination.
64
+ */
65
+ createWebhook(params: CreateWebhookParams): Promise<AutomationV2WebhookRecord>;
66
+ /**
67
+ * Deletes a push alert webhook destination by ID.
68
+ */
69
+ deleteWebhook(id: string): Promise<boolean>;
70
+ /**
71
+ * Sends a synchronous test notification ping to a webhook destination.
72
+ */
73
+ testWebhook(params: WebhookTestParams): Promise<WebhookTestResult>;
74
+ }
@@ -0,0 +1,159 @@
1
+ export class SwarmAutomationsNamespace {
2
+ transport;
3
+ constructor(transport) {
4
+ this.transport = transport;
5
+ }
6
+ /**
7
+ * Immediately triggers an on-demand worker execution with caller-supplied context.
8
+ * Admitted occurrences execute in an isolated Git worktree with runtime context
9
+ * injected into the agent's goal and execution metadata.
10
+ */
11
+ async trigger(params) {
12
+ const res = await this.transport.request('/v3/automations/v2/trigger', {
13
+ method: 'POST',
14
+ body: {
15
+ workspace_id: params.workspace_id,
16
+ worker_id: params.worker_id,
17
+ session_id: params.session_id,
18
+ automation_id: params.automation_id,
19
+ context: params.context ?? {},
20
+ },
21
+ });
22
+ return res.data;
23
+ }
24
+ /**
25
+ * Lists all automations/workers in the specified workspace.
26
+ */
27
+ async list(params) {
28
+ const q = new URLSearchParams();
29
+ if (params?.workspace_id)
30
+ q.set('workspace_id', params.workspace_id);
31
+ q.set('action', 'list');
32
+ if (params?.archived_mode)
33
+ q.set('archived_mode', params.archived_mode);
34
+ if (params?.cursor)
35
+ q.set('cursor', params.cursor);
36
+ if (params?.limit)
37
+ q.set('limit', params.limit.toString());
38
+ const res = await this.transport.request(`/v3/automations/v2?${q.toString()}`, { method: 'GET' });
39
+ return res.data?.records ?? [];
40
+ }
41
+ /**
42
+ * Retrieves an automation review/definition for a given worker_id or session_id.
43
+ */
44
+ async get(params) {
45
+ const q = new URLSearchParams();
46
+ q.set('workspace_id', params.workspace_id);
47
+ if (params.worker_id)
48
+ q.set('worker_id', params.worker_id);
49
+ if (params.session_id)
50
+ q.set('session_id', params.session_id);
51
+ const res = await this.transport.request(`/v3/automations/v2/review?${q.toString()}`, { method: 'GET' });
52
+ return res.data?.record ?? null;
53
+ }
54
+ /**
55
+ * Fetches the current progress, execution history, and upcoming forecast for a worker.
56
+ */
57
+ async getProgress(params) {
58
+ const q = new URLSearchParams();
59
+ q.set('workspace_id', params.workspace_id);
60
+ if (params.worker_id)
61
+ q.set('worker_id', params.worker_id);
62
+ if (params.session_id)
63
+ q.set('session_id', params.session_id);
64
+ if (params.timezone)
65
+ q.set('timezone', params.timezone);
66
+ if (params.cursor)
67
+ q.set('cursor', params.cursor);
68
+ const res = await this.transport.request(`/v3/automations/v2/progress?${q.toString()}`, { method: 'GET' });
69
+ return res.data;
70
+ }
71
+ /**
72
+ * Deletes an automation permanently, cancelling pending runs and purging accepted records.
73
+ */
74
+ async delete(params) {
75
+ const res = await this.transport.request('/v3/automations/v2/control', {
76
+ method: 'POST',
77
+ body: {
78
+ action: 'delete_automation',
79
+ workspace_id: params.workspace_id,
80
+ session_id: params.session_id,
81
+ generation: params.generation ?? 1,
82
+ },
83
+ });
84
+ return Boolean(res.data);
85
+ }
86
+ /**
87
+ * Pauses an active automation schedule.
88
+ */
89
+ async pause(params) {
90
+ const res = await this.transport.request('/v3/automations/v2/control', {
91
+ method: 'POST',
92
+ body: {
93
+ action: 'pause',
94
+ workspace_id: params.workspace_id,
95
+ session_id: params.session_id,
96
+ generation: params.generation,
97
+ },
98
+ });
99
+ return res.data?.ok === true;
100
+ }
101
+ /**
102
+ * Resumes a paused automation schedule.
103
+ */
104
+ async resume(params) {
105
+ const res = await this.transport.request('/v3/automations/v2/control', {
106
+ method: 'POST',
107
+ body: {
108
+ action: 'resume',
109
+ workspace_id: params.workspace_id,
110
+ session_id: params.session_id,
111
+ generation: params.generation,
112
+ },
113
+ });
114
+ return res.data?.ok === true;
115
+ }
116
+ /**
117
+ * Lists all configured push alert webhooks for the account.
118
+ */
119
+ async listWebhooks() {
120
+ const res = await this.transport.request('/v3/automations/v2/webhooks', { method: 'GET' });
121
+ return res.data?.webhooks ?? [];
122
+ }
123
+ /**
124
+ * Creates or updates a push alert webhook destination.
125
+ */
126
+ async createWebhook(params) {
127
+ const res = await this.transport.request('/v3/automations/v2/webhooks', {
128
+ method: 'POST',
129
+ body: {
130
+ id: params.id,
131
+ workspace_id: params.workspace_id,
132
+ worker_id: params.worker_id,
133
+ url: params.url,
134
+ secret: params.secret,
135
+ format: params.format ?? 'generic',
136
+ events: params.events ?? ['*'],
137
+ enabled: params.enabled ?? true,
138
+ },
139
+ });
140
+ return res.data.webhook;
141
+ }
142
+ /**
143
+ * Deletes a push alert webhook destination by ID.
144
+ */
145
+ async deleteWebhook(id) {
146
+ const res = await this.transport.request(`/v3/automations/v2/webhooks/${encodeURIComponent(id)}`, { method: 'DELETE' });
147
+ return res.data?.ok === true;
148
+ }
149
+ /**
150
+ * Sends a synchronous test notification ping to a webhook destination.
151
+ */
152
+ async testWebhook(params) {
153
+ const res = await this.transport.request('/v3/automations/v2/webhooks/test', {
154
+ method: 'POST',
155
+ body: params,
156
+ });
157
+ return res.data;
158
+ }
159
+ }
@@ -0,0 +1,61 @@
1
+ import { SwarmAppsNamespace } from './apps.js';
2
+ import { SwarmSettingsNamespace } from './settings.js';
3
+ import { SwarmOnboardingNamespace } from './provider-auth.js';
4
+ import { SwarmRealtimeNamespace } from './realtime.js';
5
+ import { SwarmUsageNamespace } from './usage.js';
6
+ import { SwarmAuthNamespace } from './auth.js';
7
+ import { SwarmAutomationsNamespace } from './automations.js';
8
+ import { SwarmWorkersNamespace } from './workers.js';
9
+ import { SwarmDeliverablesNamespace } from './deliverables.js';
10
+ import { SwarmDeployNamespace } from './deploy/index.js';
11
+ import { SwarmNotificationsNamespace } from './notifications.js';
12
+ import { SwarmProjectsNamespace } from './projects.js';
13
+ import { SwarmSessionsNamespace } from './sessions.js';
14
+ import { SwarmSystemNamespace } from './system.js';
15
+ import { SwarmStorageNamespace } from './storage/index.js';
16
+ import { SwarmTransport } from './transport.js';
17
+ import type { ResolvedSwarmClientConfig, SwarmClientConfig } from './types.js';
18
+ import { SwarmWorkspacesNamespace } from './workspaces.js';
19
+ export declare class SwarmClient {
20
+ readonly config: ResolvedSwarmClientConfig;
21
+ readonly transport: SwarmTransport;
22
+ readonly auth: SwarmAuthNamespace;
23
+ readonly settings: SwarmSettingsNamespace;
24
+ readonly onboarding: SwarmOnboardingNamespace;
25
+ readonly realtime: SwarmRealtimeNamespace;
26
+ /**
27
+ * Legacy automations namespace targeting /v3/automations/v2.
28
+ * Note: This is legacy automation API, not the canonical durable worker identity authority.
29
+ */
30
+ readonly automations: SwarmAutomationsNamespace;
31
+ /**
32
+ * Canonical durable worker namespace managing account-owned workers,
33
+ * revisions, attached automations, and portable import/export definitions over /v3/workers.
34
+ */
35
+ readonly workers: SwarmWorkersNamespace;
36
+ readonly usage: SwarmUsageNamespace;
37
+ readonly deliverables: SwarmDeliverablesNamespace;
38
+ /** Convenient alias for deliverables namespace: mailbox */
39
+ readonly mailbox: SwarmDeliverablesNamespace;
40
+ readonly workspaces: SwarmWorkspacesNamespace;
41
+ readonly projects: SwarmProjectsNamespace;
42
+ readonly sessions: SwarmSessionsNamespace;
43
+ readonly apps: SwarmAppsNamespace;
44
+ readonly system: SwarmSystemNamespace;
45
+ readonly deploy: SwarmDeployNamespace;
46
+ readonly notifications: SwarmNotificationsNamespace;
47
+ /** Convenient alias for notifications namespace: inbox */
48
+ readonly inbox: SwarmNotificationsNamespace;
49
+ readonly storage: SwarmStorageNamespace;
50
+ /** Convenient alias for cloud storage connections: cloud */
51
+ readonly cloud: SwarmStorageNamespace;
52
+ constructor(config?: SwarmClientConfig);
53
+ /**
54
+ * Updates the bearer authentication token for all subsequent client requests.
55
+ */
56
+ setToken(token: string): void;
57
+ }
58
+ /**
59
+ * Factory function to create a new SwarmClient instance.
60
+ */
61
+ export declare function createSwarmClient(config?: SwarmClientConfig): SwarmClient;