@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,220 @@
1
+ /**
2
+ * Manifest parsing, creation, and resolution for Swarm deployments.
3
+ */
4
+ import { SwarmValidationError } from '../errors.js';
5
+ const CANONICAL_REPO = 'https://github.com/swarm-agent/swarm';
6
+ /**
7
+ * Creates a well-formed SwarmDeployManifest using proven best-practice presets.
8
+ */
9
+ export function createDeployManifest(options = {}) {
10
+ const preset = options.preset || 'latency-optimized';
11
+ const name = options.name || 'swarm-agent-service';
12
+ // Base source defaults to canonical GitHub repo
13
+ const source = {
14
+ type: 'github',
15
+ repository: CANONICAL_REPO,
16
+ branch: 'main',
17
+ buildStrategy: 'distroless',
18
+ ...options.source,
19
+ };
20
+ let target = options.target;
21
+ let gcpCloudRun;
22
+ let gcpCompute;
23
+ switch (preset) {
24
+ case 'latency-optimized':
25
+ target = target || 'gcp-cloud-run';
26
+ gcpCloudRun = {
27
+ projectId: '${PROJECT_ID}',
28
+ region: 'us-central1',
29
+ serviceName: 'swarmd',
30
+ cpu: '1',
31
+ memory: '512Mi',
32
+ minInstances: 0,
33
+ maxInstances: 10,
34
+ concurrency: 80,
35
+ port: 18080,
36
+ cpuBoost: true,
37
+ executionEnvironment: 'gen2',
38
+ allowUnauthenticated: false,
39
+ timeoutSeconds: 300,
40
+ ingress: 'all',
41
+ ...options.gcpCloudRun,
42
+ };
43
+ break;
44
+ case 'zero-idle-cost':
45
+ target = target || 'gcp-cloud-run';
46
+ gcpCloudRun = {
47
+ projectId: '${PROJECT_ID}',
48
+ region: 'us-central1',
49
+ serviceName: 'swarmd-serverless',
50
+ cpu: '1',
51
+ memory: '512Mi',
52
+ minInstances: 0,
53
+ maxInstances: 5,
54
+ concurrency: 80,
55
+ port: 18080,
56
+ cpuBoost: true,
57
+ executionEnvironment: 'gen2',
58
+ allowUnauthenticated: false,
59
+ timeoutSeconds: 300,
60
+ ingress: 'all',
61
+ ...options.gcpCloudRun,
62
+ };
63
+ break;
64
+ case 'always-on':
65
+ target = target || 'gcp-cloud-run';
66
+ gcpCloudRun = {
67
+ projectId: '${PROJECT_ID}',
68
+ region: 'us-central1',
69
+ serviceName: 'swarmd-always-on',
70
+ cpu: '1',
71
+ memory: '512Mi',
72
+ minInstances: 1,
73
+ maxInstances: 20,
74
+ concurrency: 80,
75
+ port: 18080,
76
+ cpuBoost: true,
77
+ executionEnvironment: 'gen2',
78
+ allowUnauthenticated: false,
79
+ timeoutSeconds: 300,
80
+ ingress: 'all',
81
+ ...options.gcpCloudRun,
82
+ };
83
+ break;
84
+ case 'free-tier-vm':
85
+ target = target || 'gcp-compute-engine';
86
+ gcpCompute = {
87
+ projectId: '${PROJECT_ID}',
88
+ zone: 'us-central1-a',
89
+ instanceName: 'swarm-free-vm',
90
+ machineType: 'e2-micro',
91
+ diskSizeGb: 30,
92
+ diskType: 'pd-standard',
93
+ preemptible: false,
94
+ port: 18080,
95
+ tags: ['swarm-agent', 'http-server'],
96
+ ...options.gcpCompute,
97
+ };
98
+ break;
99
+ case 'high-concurrency-vm':
100
+ target = target || 'gcp-compute-engine';
101
+ gcpCompute = {
102
+ projectId: '${PROJECT_ID}',
103
+ zone: 'us-central1-a',
104
+ instanceName: 'swarm-cluster-node',
105
+ machineType: 'e2-small',
106
+ diskSizeGb: 50,
107
+ diskType: 'pd-balanced',
108
+ preemptible: false,
109
+ port: 18080,
110
+ tags: ['swarm-agent', 'http-server'],
111
+ ...options.gcpCompute,
112
+ };
113
+ break;
114
+ default:
115
+ target = target || 'gcp-cloud-run';
116
+ gcpCloudRun = {
117
+ projectId: '${PROJECT_ID}',
118
+ region: 'us-central1',
119
+ serviceName: 'swarmd',
120
+ cpu: '1',
121
+ memory: '512Mi',
122
+ minInstances: 0,
123
+ maxInstances: 10,
124
+ concurrency: 80,
125
+ port: 18080,
126
+ cpuBoost: true,
127
+ executionEnvironment: 'gen2',
128
+ allowUnauthenticated: false,
129
+ ...options.gcpCloudRun,
130
+ };
131
+ }
132
+ // Ensure default target if not set
133
+ if (!target) {
134
+ target = 'gcp-cloud-run';
135
+ }
136
+ return {
137
+ version: '1.0',
138
+ name,
139
+ target,
140
+ source,
141
+ ...(options.context ? { context: options.context } : {}),
142
+ ...(gcpCloudRun ? { gcpCloudRun } : {}),
143
+ ...(gcpCompute ? { gcpCompute } : {}),
144
+ env: options.env || { SWARM_ENV: 'production' },
145
+ secrets: options.secrets || {},
146
+ labels: options.labels || { managed_by: 'swarm_sdk' },
147
+ };
148
+ }
149
+ /**
150
+ * Loads, validates, and resolves a SwarmDeployManifest from a JSON string or raw object.
151
+ * Automatically expands ${VAR_NAME} placeholders using environment variables or optional dictionary.
152
+ */
153
+ export function loadDeployManifest(input, envLookup) {
154
+ let raw;
155
+ if (typeof input === 'string') {
156
+ try {
157
+ raw = JSON.parse(input);
158
+ }
159
+ catch (err) {
160
+ throw new SwarmValidationError(`Failed to parse Swarm deployment manifest JSON: ${err.message}`);
161
+ }
162
+ }
163
+ else if (typeof input === 'object' && input !== null) {
164
+ raw = { ...input };
165
+ }
166
+ else {
167
+ throw new SwarmValidationError('Deployment manifest must be a JSON string or an object');
168
+ }
169
+ // Interpolate ${VAR} placeholders
170
+ const resolved = interpolateEnvVars(raw, envLookup);
171
+ // Validate core schema
172
+ if (resolved.version !== '1.0') {
173
+ throw new SwarmValidationError(`Invalid manifest version: expected '1.0', got '${String(resolved.version)}'`);
174
+ }
175
+ if (!resolved.name || typeof resolved.name !== 'string') {
176
+ throw new SwarmValidationError("Deployment manifest requires a non-empty string 'name'");
177
+ }
178
+ if (!resolved.target || typeof resolved.target !== 'string') {
179
+ throw new SwarmValidationError("Deployment manifest requires a non-empty string 'target'");
180
+ }
181
+ if (!resolved.source || typeof resolved.source !== 'object') {
182
+ throw new SwarmValidationError("Deployment manifest requires a 'source' object");
183
+ }
184
+ const source = resolved.source;
185
+ if (!source.type || !['github', 'local', 'binary'].includes(String(source.type))) {
186
+ throw new SwarmValidationError("Manifest source.type must be one of: 'github', 'local', 'binary'");
187
+ }
188
+ return resolved;
189
+ }
190
+ /**
191
+ * Serializes a deployment manifest to formatted JSON.
192
+ */
193
+ export function serializeDeployManifest(manifest, indent = 2) {
194
+ return JSON.stringify(manifest, null, indent);
195
+ }
196
+ function interpolateEnvVars(val, envLookup) {
197
+ if (typeof val === 'string') {
198
+ return val.replace(/\$\{([a-zA-Z0-9_]+)\}/g, (_, varName) => {
199
+ if (envLookup && varName in envLookup) {
200
+ return envLookup[varName];
201
+ }
202
+ if (typeof process !== 'undefined' && process?.env && varName in process.env) {
203
+ return process.env[varName] || '';
204
+ }
205
+ // Retain placeholder if unresolved so command generators can use shell variables
206
+ return `\${${varName}}`;
207
+ });
208
+ }
209
+ if (Array.isArray(val)) {
210
+ return val.map((item) => interpolateEnvVars(item, envLookup));
211
+ }
212
+ if (typeof val === 'object' && val !== null) {
213
+ const res = {};
214
+ for (const [k, v] of Object.entries(val)) {
215
+ res[k] = interpolateEnvVars(v, envLookup);
216
+ }
217
+ return res;
218
+ }
219
+ return val;
220
+ }
@@ -0,0 +1,9 @@
1
+ import type { CloudDeployProvider, DeployCommand, DeployPlan, SwarmDeployManifest, ValidationResult } from '../types.js';
2
+ /** Retained only to give existing callers an explicit migration error. */
3
+ export declare class GcpCloudRunProvider implements CloudDeployProvider {
4
+ readonly target = "gcp-cloud-run";
5
+ validate(_manifest: SwarmDeployManifest): ValidationResult;
6
+ generateArtifacts(_manifest: SwarmDeployManifest): Record<string, string>;
7
+ generateCommands(_manifest: SwarmDeployManifest): DeployCommand[];
8
+ plan(_manifest: SwarmDeployManifest): DeployPlan;
9
+ }
@@ -0,0 +1,12 @@
1
+ import { SwarmValidationError } from '../../errors.js';
2
+ const reason = 'Cloud Run deployment is unsupported: ephemeral/scaled instances cannot own the single-writer durable Swarm store. Use a qualified immutable headless image with persistent volumes and a private same-container BFF. Worker deployment requires Swarm Orchestrator approval.';
3
+ /** Retained only to give existing callers an explicit migration error. */
4
+ export class GcpCloudRunProvider {
5
+ target = 'gcp-cloud-run';
6
+ validate(_manifest) {
7
+ return { valid: false, errors: [reason], warnings: [] };
8
+ }
9
+ generateArtifacts(_manifest) { throw new SwarmValidationError(reason); }
10
+ generateCommands(_manifest) { throw new SwarmValidationError(reason); }
11
+ plan(_manifest) { throw new SwarmValidationError(reason); }
12
+ }
@@ -0,0 +1,9 @@
1
+ import type { CloudDeployProvider, DeployCommand, DeployPlan, SwarmDeployManifest, ValidationResult } from '../types.js';
2
+ /** No second daemon installer or implicit cloud provisioning authority. */
3
+ export declare class GcpComputeEngineProvider implements CloudDeployProvider {
4
+ readonly target = "gcp-compute-engine";
5
+ validate(_manifest: SwarmDeployManifest): ValidationResult;
6
+ generateArtifacts(_manifest: SwarmDeployManifest): Record<string, string>;
7
+ generateCommands(_manifest: SwarmDeployManifest): DeployCommand[];
8
+ plan(_manifest: SwarmDeployManifest): DeployPlan;
9
+ }
@@ -0,0 +1,12 @@
1
+ import { SwarmValidationError } from '../../errors.js';
2
+ const reason = 'Legacy Compute Engine provisioning is unsupported: its source build, public daemon and storage paths do not match the canonical runtime. Provision an approved single-writer host separately and use the qualified immutable headless image with persistent volumes and a private same-container BFF.';
3
+ /** No second daemon installer or implicit cloud provisioning authority. */
4
+ export class GcpComputeEngineProvider {
5
+ target = 'gcp-compute-engine';
6
+ validate(_manifest) {
7
+ return { valid: false, errors: [reason], warnings: [] };
8
+ }
9
+ generateArtifacts(_manifest) { throw new SwarmValidationError(reason); }
10
+ generateCommands(_manifest) { throw new SwarmValidationError(reason); }
11
+ plan(_manifest) { throw new SwarmValidationError(reason); }
12
+ }
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Types and interfaces for Swarm multi-cloud deployment automation.
3
+ */
4
+ export type CloudTarget = 'gcp-cloud-run' | 'gcp-compute-engine' | 'docker' | string;
5
+ export type BuildStrategy = 'distroless' | 'scratch' | 'alpine' | 'prebuilt-binary';
6
+ export interface SourceConfig {
7
+ /** Source location type: 'github' clone, 'local' directory, or 'binary' download */
8
+ type: 'github' | 'local' | 'binary';
9
+ /** Canonical Git repository URL (defaults to https://github.com/swarm-agent/swarm) */
10
+ repository?: string;
11
+ /** Git branch, tag, or ref to build (defaults to 'main') */
12
+ branch?: string;
13
+ /** Specific Git commit SHA to checkout */
14
+ commit?: string;
15
+ /** Direct URL to precompiled swarmd binary if type is 'binary' */
16
+ binaryUrl?: string;
17
+ /** Workspace-relative or absolute path if type is 'local' */
18
+ localPath?: string;
19
+ /** Container build strategy (defaults to 'distroless' for optimal cold start) */
20
+ buildStrategy?: BuildStrategy;
21
+ }
22
+ export interface AgentContextConfig {
23
+ /** System instructions or AGENTS.md content to guide the headless agent */
24
+ instructions?: string;
25
+ /** Initial task, mission, or prompt to execute on startup */
26
+ prompt?: string;
27
+ /** Target AI model identifier (e.g. 'gemini-3.8-flash') */
28
+ model?: string;
29
+ /** Thinking level ('low' | 'medium' | 'high') */
30
+ thinking?: 'low' | 'medium' | 'high';
31
+ /** Target workspace Git repository URL or path */
32
+ workspaceUrl?: string;
33
+ /** Workspace Git branch (defaults to 'main') */
34
+ workspaceBranch?: string;
35
+ /** Optional custom shell hook script to run during boot/context reload */
36
+ bootHook?: string;
37
+ }
38
+ export interface GcpCloudRunConfig {
39
+ /** Target GCP project ID (defaults to ${PROJECT_ID} placeholder or GCP_PROJECT env) */
40
+ projectId?: string;
41
+ /** GCP region (defaults to 'us-central1') */
42
+ region?: string;
43
+ /** Cloud Run service name (defaults to 'swarm-daemon') */
44
+ serviceName?: string;
45
+ /** Container CPU allocation (e.g. '1', '2') */
46
+ cpu?: string;
47
+ /** Container memory limit (e.g. '512Mi', '1Gi', '2Gi') - 512Mi is optimal for low cold start */
48
+ memory?: string;
49
+ /** Minimum instances (0 for pure scale-to-zero, $0 idle cost; 1 for zero cold-start warm pool) */
50
+ minInstances?: number;
51
+ /** Maximum instances (e.g. 10, 50, 100) */
52
+ maxInstances?: number;
53
+ /** Maximum concurrent requests per instance (default: 80) */
54
+ concurrency?: number;
55
+ /** Container listen port (default: 18080 or Cloud Run $PORT) */
56
+ port?: number;
57
+ /** Enable Startup CPU Boost for <1.5s cold-start latency (default: true) */
58
+ cpuBoost?: boolean;
59
+ /** Cloud Run execution environment: 'gen2' (recommended) or 'gen1' */
60
+ executionEnvironment?: 'gen1' | 'gen2';
61
+ /** Allow unauthenticated public invocations (default: false) */
62
+ allowUnauthenticated?: boolean;
63
+ /** Attached service account email */
64
+ serviceAccount?: string;
65
+ /** Network ingress traffic filter: 'all' | 'internal' | 'internal-and-cloud-load-balancing' */
66
+ ingress?: 'all' | 'internal' | 'internal-and-cloud-load-balancing';
67
+ /** Request timeout in seconds (default: 300) */
68
+ timeoutSeconds?: number;
69
+ /** Additional container image tag or Artifact Registry URL */
70
+ imageUri?: string;
71
+ }
72
+ export interface GcpComputeEngineConfig {
73
+ /** Target GCP project ID */
74
+ projectId?: string;
75
+ /** GCP compute zone (defaults to 'us-central1-a') */
76
+ zone?: string;
77
+ /** Compute instance name (defaults to 'swarm-vm') */
78
+ instanceName?: string;
79
+ /** GCE machine type (e.g. 'e2-micro' for free tier, 'e2-small' for 100 agents, 'e2-standard-4') */
80
+ machineType?: string;
81
+ /** Boot disk size in GB (default: 30 for GCP Free Tier) */
82
+ diskSizeGb?: number;
83
+ /** Boot disk type: 'pd-standard' | 'pd-ssd' | 'pd-balanced' */
84
+ diskType?: 'pd-standard' | 'pd-ssd' | 'pd-balanced';
85
+ /** Use preemptible/spot instance for lowest cost */
86
+ preemptible?: boolean;
87
+ /** Attached service account email */
88
+ serviceAccount?: string;
89
+ /** Network tags */
90
+ tags?: string[];
91
+ /** Listen port (default: 18080) */
92
+ port?: number;
93
+ /** Enable dynamic GCP metadata context syncing (/usr/local/bin/swarm-sync-context) */
94
+ enableMetadataSync?: boolean;
95
+ }
96
+ export interface SwarmDeployManifest {
97
+ /** Schema specification version (e.g. '1.0') */
98
+ version: '1.0';
99
+ /** Human-readable deployment name or service title */
100
+ name: string;
101
+ /** Target deployment platform */
102
+ target: CloudTarget;
103
+ /** Source code and binary build configuration */
104
+ source: SourceConfig;
105
+ /** Agent role, instructions, prompt, and workspace context */
106
+ context?: AgentContextConfig;
107
+ /** GCP Cloud Run specific configuration (when target is 'gcp-cloud-run') */
108
+ gcpCloudRun?: GcpCloudRunConfig;
109
+ /** GCP Compute Engine specific configuration (when target is 'gcp-compute-engine') */
110
+ gcpCompute?: GcpComputeEngineConfig;
111
+ /** Environment variables to inject into the deployment */
112
+ env?: Record<string, string>;
113
+ /** Secret Manager secret references (env var -> secret resource name) */
114
+ secrets?: Record<string, string>;
115
+ /** Resource metadata labels */
116
+ labels?: Record<string, string>;
117
+ }
118
+ export type DeploymentPreset = 'latency-optimized' | 'zero-idle-cost' | 'always-on' | 'free-tier-vm' | 'high-concurrency-vm';
119
+ export interface CreateManifestOptions {
120
+ /** Deployment preset providing pre-tuned performance and cost defaults */
121
+ preset?: DeploymentPreset;
122
+ /** Deployment name */
123
+ name?: string;
124
+ /** Target platform override */
125
+ target?: CloudTarget;
126
+ /** Source configuration overrides */
127
+ source?: Partial<SourceConfig>;
128
+ /** Agent role, instructions, prompt, and workspace context */
129
+ context?: Partial<AgentContextConfig>;
130
+ /** GCP Cloud Run configuration overrides */
131
+ gcpCloudRun?: Partial<GcpCloudRunConfig>;
132
+ /** GCP Compute Engine configuration overrides */
133
+ gcpCompute?: Partial<GcpComputeEngineConfig>;
134
+ /** Environment variables */
135
+ env?: Record<string, string>;
136
+ /** Secrets */
137
+ secrets?: Record<string, string>;
138
+ /** Labels */
139
+ labels?: Record<string, string>;
140
+ }
141
+ export interface DeployCommand {
142
+ /** Cosmetic step title */
143
+ title: string;
144
+ /** Shell command to execute */
145
+ command: string;
146
+ /** Plain-English explanation of the command's effect */
147
+ explanation: string;
148
+ /** Pipeline phase */
149
+ phase: 'build' | 'deploy' | 'verify' | 'cleanup';
150
+ }
151
+ export interface ValidationResult {
152
+ valid: boolean;
153
+ errors: string[];
154
+ warnings: string[];
155
+ }
156
+ export interface DeployPlan {
157
+ /** Canonical resolved deployment manifest */
158
+ manifest: SwarmDeployManifest;
159
+ /** Target platform */
160
+ target: CloudTarget;
161
+ /** High-level summary of the deployment architecture and cost profile */
162
+ summary: string;
163
+ /** Generated deployment artifacts (filename -> content) such as Dockerfile, scripts */
164
+ artifacts: Record<string, string>;
165
+ /** Sequential commands to build, deploy, and verify */
166
+ commands: DeployCommand[];
167
+ /** Recommended settings applied */
168
+ recommendations: string[];
169
+ /** Actionable warnings or prerequisites */
170
+ warnings: string[];
171
+ }
172
+ export interface CloudDeployProvider {
173
+ /** Supported cloud target identifier */
174
+ readonly target: CloudTarget;
175
+ /** Validates manifest configuration against provider requirements */
176
+ validate(manifest: SwarmDeployManifest): ValidationResult;
177
+ /** Generates a complete structured deployment plan */
178
+ plan(manifest: SwarmDeployManifest): DeployPlan;
179
+ /** Generates standalone file artifacts (Dockerfile, scripts, config) */
180
+ generateArtifacts(manifest: SwarmDeployManifest): Record<string, string>;
181
+ /** Generates shell commands required to execute the deployment */
182
+ generateCommands(manifest: SwarmDeployManifest): DeployCommand[];
183
+ }
184
+ export interface ExecuteDeployOptions {
185
+ /** Target directory to write artifacts before execution (defaults to temporary directory) */
186
+ outputDir?: string;
187
+ /** Dry-run mode: generates artifacts and validates commands without executing shell operations */
188
+ dryRun?: boolean;
189
+ /** Custom logger function for streaming command execution stdout/stderr */
190
+ onLog?: (line: string, phase: string) => void;
191
+ /** Additional environment variable overrides for execution processes */
192
+ env?: Record<string, string>;
193
+ }
194
+ export interface DeployExecutionResult {
195
+ /** Whether the deployment completed successfully */
196
+ success: boolean;
197
+ /** Target deployment platform */
198
+ target: CloudTarget;
199
+ /** Total elapsed time in milliseconds */
200
+ durationMs: number;
201
+ /** Captured outputs by step title */
202
+ stepOutputs: Record<string, string>;
203
+ /** Deployed service URL (if Cloud Run) */
204
+ serviceUrl?: string;
205
+ /** External/NAT IP address (if Compute Engine) */
206
+ externalIp?: string;
207
+ /** Path to output directory containing written artifacts */
208
+ outputDir: string;
209
+ /** Error message if deployment failed */
210
+ error?: string;
211
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Types and interfaces for Swarm multi-cloud deployment automation.
3
+ */
4
+ export {};
@@ -0,0 +1,33 @@
1
+ import type { WorkerStorageHub } from '../storage/hub.js';
2
+ import type { WorkerActorSpec } from '../storage/types.js';
3
+ export interface WorkerDeployValidationResult {
4
+ valid: boolean;
5
+ errors: string[];
6
+ warnings: string[];
7
+ }
8
+ export interface CloudRunJobDeployCommands {
9
+ jobDeployCommand: string;
10
+ jobDeployArgs: string[];
11
+ schedulerCommand?: string;
12
+ schedulerArgs?: string[];
13
+ }
14
+ export interface TaskExecuteCommand {
15
+ executeCommand: string;
16
+ executeArgs: string[];
17
+ }
18
+ /** Compatibility tombstone: never provision a parallel worker runtime. */
19
+ export declare class WorkerCloudDeployer {
20
+ static validate(_spec: WorkerActorSpec): WorkerDeployValidationResult;
21
+ static createDefaultSpec(_params: {
22
+ id: string;
23
+ name: string;
24
+ description?: string;
25
+ instructions: string;
26
+ model?: string;
27
+ gcpProject?: string;
28
+ cronSchedule?: string;
29
+ }): WorkerActorSpec;
30
+ static uploadToBucket(_spec: WorkerActorSpec, _hub: WorkerStorageHub): Promise<void>;
31
+ static generateDeployCommands(_spec: WorkerActorSpec, _bucketName: string): CloudRunJobDeployCommands;
32
+ static generateTaskExecuteCommand(_spec: WorkerActorSpec, _taskId: string): TaskExecuteCommand;
33
+ }
@@ -0,0 +1,14 @@
1
+ import { SwarmValidationError } from '../errors.js';
2
+ const reason = 'Cloud worker actor deployment is unsupported. Object storage is not a worker executor or the durable daemon store. Use canonical workers through Swarm Orchestrator deployment and approval.';
3
+ /** Compatibility tombstone: never provision a parallel worker runtime. */
4
+ export class WorkerCloudDeployer {
5
+ static validate(_spec) {
6
+ return { valid: false, errors: [reason], warnings: [] };
7
+ }
8
+ static createDefaultSpec(_params) {
9
+ throw new SwarmValidationError(reason);
10
+ }
11
+ static async uploadToBucket(_spec, _hub) { throw new SwarmValidationError(reason); }
12
+ static generateDeployCommands(_spec, _bucketName) { throw new SwarmValidationError(reason); }
13
+ static generateTaskExecuteCommand(_spec, _taskId) { throw new SwarmValidationError(reason); }
14
+ }
@@ -0,0 +1,36 @@
1
+ export interface SwarmApiErrorOptions {
2
+ status: number;
3
+ code?: string;
4
+ details?: unknown;
5
+ responseBody?: string;
6
+ }
7
+ export declare class SwarmError extends Error {
8
+ constructor(message: string);
9
+ }
10
+ export declare class SwarmApiError extends SwarmError {
11
+ readonly status: number;
12
+ readonly code?: string;
13
+ readonly details?: unknown;
14
+ readonly responseBody?: string;
15
+ constructor(message: string, options: SwarmApiErrorOptions);
16
+ }
17
+ export declare class SwarmAuthError extends SwarmApiError {
18
+ constructor(message: string, options: Omit<SwarmApiErrorOptions, 'status'>);
19
+ }
20
+ export declare class SwarmForbiddenError extends SwarmApiError {
21
+ constructor(message: string, options: Omit<SwarmApiErrorOptions, 'status'>);
22
+ }
23
+ export declare class SwarmNotFoundError extends SwarmApiError {
24
+ constructor(message: string, options: Omit<SwarmApiErrorOptions, 'status'>);
25
+ }
26
+ export declare class SwarmConflictError extends SwarmApiError {
27
+ constructor(message: string, options: Omit<SwarmApiErrorOptions, 'status'>);
28
+ }
29
+ export declare class SwarmTimeoutError extends SwarmError {
30
+ readonly timeoutMs: number;
31
+ constructor(message: string, timeoutMs: number);
32
+ }
33
+ export declare class SwarmValidationError extends SwarmError {
34
+ readonly details?: unknown;
35
+ constructor(message: string, details?: unknown);
36
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,68 @@
1
+ export class SwarmError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = 'SwarmError';
5
+ Object.setPrototypeOf(this, new.target.prototype);
6
+ }
7
+ }
8
+ export class SwarmApiError extends SwarmError {
9
+ status;
10
+ code;
11
+ details;
12
+ responseBody;
13
+ constructor(message, options) {
14
+ super(message);
15
+ this.name = 'SwarmApiError';
16
+ this.status = options.status;
17
+ this.code = options.code;
18
+ this.details = options.details;
19
+ this.responseBody = options.responseBody;
20
+ Object.setPrototypeOf(this, new.target.prototype);
21
+ }
22
+ }
23
+ export class SwarmAuthError extends SwarmApiError {
24
+ constructor(message, options) {
25
+ super(message, { ...options, status: 401 });
26
+ this.name = 'SwarmAuthError';
27
+ Object.setPrototypeOf(this, new.target.prototype);
28
+ }
29
+ }
30
+ export class SwarmForbiddenError extends SwarmApiError {
31
+ constructor(message, options) {
32
+ super(message, { ...options, status: 403 });
33
+ this.name = 'SwarmForbiddenError';
34
+ Object.setPrototypeOf(this, new.target.prototype);
35
+ }
36
+ }
37
+ export class SwarmNotFoundError extends SwarmApiError {
38
+ constructor(message, options) {
39
+ super(message, { ...options, status: 404 });
40
+ this.name = 'SwarmNotFoundError';
41
+ Object.setPrototypeOf(this, new.target.prototype);
42
+ }
43
+ }
44
+ export class SwarmConflictError extends SwarmApiError {
45
+ constructor(message, options) {
46
+ super(message, { ...options, status: 409 });
47
+ this.name = 'SwarmConflictError';
48
+ Object.setPrototypeOf(this, new.target.prototype);
49
+ }
50
+ }
51
+ export class SwarmTimeoutError extends SwarmError {
52
+ timeoutMs;
53
+ constructor(message, timeoutMs) {
54
+ super(message);
55
+ this.name = 'SwarmTimeoutError';
56
+ this.timeoutMs = timeoutMs;
57
+ Object.setPrototypeOf(this, new.target.prototype);
58
+ }
59
+ }
60
+ export class SwarmValidationError extends SwarmError {
61
+ details;
62
+ constructor(message, details) {
63
+ super(message);
64
+ this.name = 'SwarmValidationError';
65
+ this.details = details;
66
+ Object.setPrototypeOf(this, new.target.prototype);
67
+ }
68
+ }
@@ -0,0 +1,23 @@
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 type { UsageScope, UsageScopeTotal, UsageScopeUpdatedPayload, UsageScopeRepairResult, WorkerBudgetPolicy, WorkerBudgetUpdate, WorkerBudgetStatus } from './usage.js';
18
+ export { SwarmAppsNamespace } from './apps.js';
19
+ export type { ApplicationAgent, ApplicationAgentWrite, ApplicationConversationParams, ApplicationConversationSnapshot } from './apps.js';
20
+ export * from './settings.js';
21
+ export * from './provider-auth.js';
22
+ export * from './realtime.js';
23
+ export type { ApplicationResults, ApplicationResultsOptions } from './app-results.js';