@mastra/sprites 0.1.2 → 0.1.3

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.
package/dist/index.cjs CHANGED
@@ -334,5 +334,3 @@ const spritesSandboxProvider = {
334
334
  exports.SpritesProcessManager = SpritesProcessManager;
335
335
  exports.SpritesSandbox = SpritesSandbox;
336
336
  exports.spritesSandboxProvider = spritesSandboxProvider;
337
-
338
- //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -331,5 +331,3 @@ const spritesSandboxProvider = {
331
331
  })
332
332
  };
333
333
  export { SpritesProcessManager, SpritesSandbox, spritesSandboxProvider };
334
-
335
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/sprites",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Fly.io Sprites sandbox provider for Mastra workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,22 +24,23 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "22.19.15",
27
- "@vitest/coverage-v8": "4.1.12",
28
- "@vitest/ui": "4.1.12",
29
- "dotenv": "^17.4.2",
27
+ "@vitest/coverage-v8": "5.1.0",
28
+ "@vitest/ui": "5.1.0",
29
+ "dotenv": "^18.0.9",
30
30
  "tsdown": "0.23.1",
31
31
  "typescript": "^7.0.2",
32
- "vitest": "4.1.12",
33
- "@internal/lint": "0.0.146",
34
- "@internal/types-builder": "0.0.121",
35
- "@internal/workspace-test-utils": "0.0.90",
36
- "@mastra/core": "1.80.0"
32
+ "vitest": "5.1.0",
33
+ "@internal/lint": "0.0.152",
34
+ "@internal/workspace-test-utils": "0.0.96",
35
+ "@mastra/core": "1.86.0",
36
+ "@internal/types-builder": "0.0.127"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@mastra/core": ">=1.68.0-0 <2.0.0-0"
40
40
  },
41
41
  "files": [
42
- "dist"
42
+ "dist",
43
+ "!dist/**/*.d.*ts.map"
43
44
  ],
44
45
  "homepage": "https://mastra.ai",
45
46
  "repository": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":["ProcessHandle","SandboxProcessManager","MastraSandbox","SandboxNotReadyError","SpritesClient","APIError"],"sources":["../src/sandbox/process-manager.ts","../src/sandbox/index.ts","../src/provider.ts"],"sourcesContent":["/**\n * Sprites Process Manager\n *\n * Runs each spawned command as its own `SpriteCommand` (a WebSocket exec\n * session on the Sprite) and streams stdout/stderr into the core\n * `ProcessHandle` buffers as chunks arrive.\n */\n\nimport type { SpriteCommand } from '@fly/sprites';\nimport type { CommandResult, ProcessInfo, SpawnProcessOptions } from '@mastra/core/workspace';\nimport { ProcessHandle, SandboxProcessManager } from '@mastra/core/workspace';\nimport type { SpritesSandbox } from './index';\n\nexport const LOG_PREFIX = '[SpritesSandbox]';\n\n/** Exit code reported for processes terminated by `kill()` or a timeout. */\nconst KILLED_EXIT_CODE = 137;\n\nclass SpritesProcessHandle extends ProcessHandle {\n readonly pid: string;\n\n private readonly _cmd: SpriteCommand;\n private readonly _startTime = Date.now();\n private readonly _done: Promise<void>;\n private _exitCode: number | undefined;\n private _killed = false;\n private _timedOut = false;\n private _timeoutId: ReturnType<typeof setTimeout> | undefined;\n private _error: Error | undefined;\n\n constructor(pid: string, cmd: SpriteCommand, options: SpawnProcessOptions, timeout: number | undefined) {\n super(options);\n this.pid = pid;\n this._cmd = cmd;\n\n cmd.stdout.setEncoding('utf8');\n cmd.stderr.setEncoding('utf8');\n cmd.stdout.on('data', (chunk: string) => this.emitStdout(chunk));\n cmd.stderr.on('data', (chunk: string) => this.emitStderr(chunk));\n // SpriteCommand is an EventEmitter: an unhandled 'error' would crash the process.\n cmd.on('error', (error: Error) => {\n this._error ??= error;\n });\n\n // Output streams end right after the exit frame, so waiting for both\n // guarantees every chunk has been emitted before the exit code is published.\n this._done = Promise.all([cmd.wait(), streamEnded(cmd.stdout), streamEnded(cmd.stderr)]).then(([code]) => {\n clearTimeout(this._timeoutId);\n this._exitCode = this._killed ? KILLED_EXIT_CODE : code < 0 ? 1 : code;\n });\n\n if (timeout !== undefined && timeout > 0) {\n this._timeoutId = setTimeout(() => {\n this._timedOut = true;\n void this.kill();\n }, timeout);\n }\n }\n\n get exitCode(): number | undefined {\n return this._exitCode;\n }\n\n async wait(): Promise<CommandResult> {\n await this._done;\n const exitCode = this._exitCode!;\n let stderr = this.stderr;\n if (exitCode !== 0 && !stderr && this._error && !this._killed) {\n stderr = this._error.message;\n }\n return {\n success: exitCode === 0,\n exitCode,\n stdout: this.stdout,\n stderr,\n executionTimeMs: Date.now() - this._startTime,\n ...(this._killed && { killed: true }),\n ...(this._timedOut && { timedOut: true }),\n };\n }\n\n async kill(): Promise<boolean> {\n if (this._exitCode !== undefined || this._killed) return false;\n this._killed = true;\n clearTimeout(this._timeoutId);\n // Signal the remote process, then drop the connection. Closing the\n // (non-detachable) exec session makes the server reap the process even if\n // the signal could not be delivered.\n this._cmd.kill('SIGKILL');\n this._cmd.close();\n return true;\n }\n\n async sendStdin(data: string): Promise<void> {\n if (this._exitCode !== undefined) {\n throw new Error(`${LOG_PREFIX} Cannot write to stdin: process ${this.pid} has exited`);\n }\n await new Promise<void>((resolve, reject) => {\n this._cmd.stdin.write(data, error => (error ? reject(error) : resolve()));\n });\n }\n\n async closeStdin(): Promise<void> {\n this._cmd.stdin.end();\n }\n}\n\nexport class SpritesProcessManager extends SandboxProcessManager<SpritesSandbox> {\n private _spawnCounter = 0;\n\n async spawn(command: string, options: SpawnProcessOptions = {}): Promise<ProcessHandle> {\n // The base spawn wrapper has already merged the sandbox env into options.env.\n const env = Object.fromEntries(\n Object.entries(options.env ?? {}).filter((entry): entry is [string, string] => entry[1] !== undefined),\n );\n const cwd = options.cwd ?? this.sandbox.workingDirectory;\n\n const cmd = this.sandbox.sprite.spawn('sh', ['-c', command], {\n ...(cwd && { cwd }),\n ...(Object.keys(env).length > 0 && { env }),\n });\n try {\n await waitForSpawn(cmd);\n } catch (error) {\n // Drop any half-opened exec connection so failed spawns don't leak sockets.\n cmd.close();\n throw error;\n }\n\n if (options.stdinMode === 'ignore') {\n cmd.stdin.end();\n }\n\n const pid = `sprites-proc-${Date.now().toString(36)}-${(++this._spawnCounter).toString(36)}`;\n const handle = new SpritesProcessHandle(pid, cmd, options, options.timeout ?? this.sandbox.defaultTimeout);\n this._tracked.set(pid, handle);\n return handle;\n }\n\n /**\n * Lists processes spawned by this instance. The Sprites exec API has no\n * listing for non-detachable commands, so processes started elsewhere are\n * not included.\n */\n async list(): Promise<ProcessInfo[]> {\n return [...this._tracked.values()].map(handle => ({\n pid: handle.pid,\n command: handle.command,\n running: handle.exitCode === undefined,\n ...(handle.exitCode !== undefined && { exitCode: handle.exitCode }),\n }));\n }\n\n /** Kill every running process spawned by this instance. Does not start the sandbox. */\n async killAll(): Promise<void> {\n const running = [...this._tracked.values()].filter(handle => handle.exitCode === undefined);\n await Promise.all(running.map(handle => this.kill(handle.pid)));\n }\n}\n\nfunction waitForSpawn(cmd: SpriteCommand): Promise<void> {\n return new Promise((resolve, reject) => {\n const onSpawn = () => {\n cmd.off('error', onError);\n resolve();\n };\n const onError = (error: Error) => {\n cmd.off('spawn', onSpawn);\n reject(error);\n };\n cmd.once('spawn', onSpawn);\n cmd.once('error', onError);\n });\n}\n\nfunction streamEnded(stream: NodeJS.ReadableStream): Promise<void> {\n return new Promise(resolve => {\n stream.once('end', () => resolve());\n stream.once('close', () => resolve());\n });\n}\n","/**\n * Fly.io Sprites Sandbox Provider\n *\n * A Sprites sandbox implementation for Mastra workspaces. Gets or creates a\n * persistent Fly.io Sprite by name and runs commands in it through the\n * official `@fly/sprites` SDK. Sprites keep their filesystem between runs and\n * hibernate on their own when idle.\n *\n * @see https://sprites.dev\n */\n\nimport { APIError, SpritesClient } from '@fly/sprites';\nimport type { Sprite, SpriteConfig } from '@fly/sprites';\nimport type {\n InstructionsOption,\n MastraSandboxOptions,\n ProviderStatus,\n SandboxInfo,\n SandboxStartResult,\n} from '@mastra/core/workspace';\nimport { MastraSandbox, SandboxNotReadyError } from '@mastra/core/workspace';\nimport { LOG_PREFIX, SpritesProcessManager } from './process-manager';\n\nexport interface SpritesSandboxOptions extends Omit<MastraSandboxOptions, 'processes'> {\n /**\n * Sprite name, also used as the sandbox id. An existing Sprite with this\n * name is reused (including its filesystem); otherwise one is created.\n * Generated when omitted.\n */\n id?: string;\n /** Sprites API token. Falls back to the `SPRITES_TOKEN` environment variable. */\n token?: string;\n /** Sprites API base URL. Defaults to the SDK default (`https://api.sprites.dev`). */\n baseURL?: string;\n /** Machine configuration applied only when the Sprite is created. */\n spriteConfig?: SpriteConfig;\n /** Default command timeout in milliseconds. Per-command `timeout` wins. */\n timeout?: number;\n /** Override or extend the default agent instructions for this sandbox. */\n instructions?: InstructionsOption;\n}\n\nexport class SpritesSandbox extends MastraSandbox {\n readonly id: string;\n readonly name = 'SpritesSandbox';\n readonly provider = 'sprites';\n status: ProviderStatus = 'pending';\n\n declare readonly processes: SpritesProcessManager;\n\n private _client: SpritesClient | null = null;\n private _sprite: Sprite | null = null;\n private _createdAt: Date | null = null;\n private readonly _token?: string;\n private readonly _baseURL?: string;\n private readonly _spriteConfig?: SpriteConfig;\n private readonly _timeout?: number;\n private readonly _instructionsOverride?: InstructionsOption;\n\n constructor(options: SpritesSandboxOptions = {}) {\n super({ ...options, name: 'SpritesSandbox', processes: new SpritesProcessManager() });\n\n this.id = options.id ?? `mastra-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;\n this._token = options.token ?? process.env.SPRITES_TOKEN;\n this._baseURL = options.baseURL;\n this._spriteConfig = options.spriteConfig;\n this._timeout = options.timeout;\n this._instructionsOverride = options.instructions;\n }\n\n /** The underlying SDK `Sprite`. Throws if the sandbox has not been started. */\n get sprite(): Sprite {\n if (!this._sprite) {\n throw new SandboxNotReadyError(this.id);\n }\n return this._sprite;\n }\n\n /** Default command timeout in milliseconds, if configured. */\n get defaultTimeout(): number | undefined {\n return this._timeout;\n }\n\n private get client(): SpritesClient {\n if (!this._client) {\n if (!this._token) {\n throw new Error(\n `${LOG_PREFIX} Missing Sprites API token. Pass \\`token\\` or set the SPRITES_TOKEN environment variable.`,\n );\n }\n this._client = new SpritesClient(this._token, this._baseURL ? { baseURL: this._baseURL } : undefined);\n }\n return this._client;\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n /**\n * Get the Sprite named `id`, creating it when it does not exist.\n * Reports `outcome: 'created'` only when a new Sprite was provisioned.\n */\n async start(): Promise<SandboxStartResult> {\n if (this._sprite) {\n return { outcome: 'connected' };\n }\n\n const client = this.client;\n let outcome: SandboxStartResult['outcome'] = 'connected';\n let sprite: Sprite;\n\n try {\n sprite = await client.getSprite(this.id);\n } catch (error) {\n if (!isStatus(error, 404)) throw error;\n try {\n sprite = await client.createSprite(this.id, this._spriteConfig);\n outcome = 'created';\n } catch (createError) {\n // Another process created the same Sprite between our get and create.\n if (!isStatus(createError, 409)) throw createError;\n sprite = await client.getSprite(this.id);\n }\n }\n\n this._sprite = sprite;\n this._createdAt = sprite.createdAt ?? new Date();\n this.logger.debug(`${LOG_PREFIX} Sprite ready`, { id: this.id, outcome });\n return { outcome };\n }\n\n /**\n * Release local resources: kill background processes started by this\n * instance and close the SDK control connection.\n *\n * The Sprite itself is NOT deleted or suspended. Sprites hibernate on their\n * own when idle, and `start()` reconnects to the same filesystem.\n */\n async stop(): Promise<void> {\n await this._killTrackedProcesses();\n this._sprite?.closeControlConnection();\n this._sprite = null;\n }\n\n /**\n * Permanently delete the Sprite and its filesystem. A Sprite that no longer\n * exists is treated as already destroyed.\n */\n async destroy(): Promise<void> {\n await this._killTrackedProcesses();\n const sprite = this._sprite ?? this.client.sprite(this.id);\n sprite.closeControlConnection();\n this._sprite = null;\n\n try {\n await sprite.delete();\n } catch (error) {\n if (!isStatus(error, 404)) throw error;\n }\n }\n\n /**\n * Capture a checkpoint of the Sprite's current state.\n *\n * Checkpoints live inside this Sprite only and cannot seed other sandboxes,\n * so `supportsCheckpoints` stays `false`.\n */\n async snapshot(): Promise<void> {\n await this.ensureRunning();\n const stream = await this.sprite.createCheckpoint('mastra snapshot');\n await stream.processAll(message => {\n if (message.type === 'error') {\n throw new Error(`${LOG_PREFIX} Checkpoint failed: ${message.error ?? message.data ?? 'unknown error'}`);\n }\n });\n }\n\n private async _killTrackedProcesses(): Promise<void> {\n await this.processes.killAll().catch(error => {\n this.logger.warn(`${LOG_PREFIX} Failed to kill background processes`, { error });\n });\n }\n\n // ---------------------------------------------------------------------------\n // Info & Instructions\n // ---------------------------------------------------------------------------\n\n async getInfo(): Promise<SandboxInfo> {\n const sprite = this._sprite;\n return {\n id: this.id,\n name: this.name,\n provider: this.provider,\n status: this.status,\n createdAt: this._createdAt ?? new Date(),\n metadata: {\n ...(sprite && {\n ...(sprite.id && { spriteId: sprite.id }),\n ...(sprite.status && { spriteStatus: sprite.status }),\n ...(sprite.url && { url: sprite.url }),\n ...(sprite.primaryRegion && { region: sprite.primaryRegion }),\n }),\n },\n };\n }\n\n getInstructions(): string {\n const defaultInstructions = this._buildDefaultInstructions();\n\n if (typeof this._instructionsOverride === 'string') {\n return this._instructionsOverride;\n }\n if (typeof this._instructionsOverride === 'function') {\n return this._instructionsOverride({ defaultInstructions });\n }\n return defaultInstructions;\n }\n\n private _buildDefaultInstructions(): string {\n const parts = [\n 'Fly.io Sprite: a persistent Linux VM. Files written to disk survive between sessions.',\n this.workingDirectory\n ? `Commands run in ${this.workingDirectory} by default.`\n : 'Commands run in the Sprite user home directory by default.',\n ];\n if (this._timeout !== undefined) {\n parts.push(`Default command timeout: ${Math.ceil(this._timeout / 1000)}s.`);\n }\n return parts.join(' ');\n }\n}\n\nfunction isStatus(error: unknown, statusCode: number): boolean {\n return error instanceof APIError && error.statusCode === statusCode;\n}\n","/**\n * Fly.io Sprites sandbox provider descriptor for MastraEditor.\n *\n * @example\n * ```typescript\n * import { spritesSandboxProvider } from '@mastra/sprites';\n *\n * const editor = new MastraEditor({\n * sandboxes: { [spritesSandboxProvider.id]: spritesSandboxProvider },\n * });\n * ```\n */\nimport type { SandboxProvider } from '@mastra/core/editor';\nimport { SpritesSandbox } from './sandbox';\n\n/**\n * Serializable subset of SpritesSandboxOptions for editor storage.\n *\n * `baseURL` is deliberately excluded: the sandbox falls back to the server's\n * SPRITES_TOKEN, so a stored API host could redirect that token elsewhere.\n */\ninterface SpritesProviderConfig {\n id?: string;\n token?: string;\n env?: Record<string, string>;\n timeout?: number;\n workingDirectory?: string;\n}\n\nexport const spritesSandboxProvider: SandboxProvider<SpritesProviderConfig> = {\n id: 'sprites',\n name: 'Fly.io Sprites',\n description: 'Persistent Linux VM powered by Fly.io Sprites',\n configSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Sprite name. An existing Sprite with this name is reused.' },\n token: { type: 'string', description: 'Sprites API token (falls back to SPRITES_TOKEN)' },\n env: {\n type: 'object',\n description: 'Environment variables',\n additionalProperties: { type: 'string' },\n },\n timeout: { type: 'number', description: 'Default command timeout in ms' },\n workingDirectory: { type: 'string', description: 'Default working directory for commands' },\n },\n },\n // Pick known fields so extra stored keys (such as baseURL) never reach the sandbox.\n createSandbox: ({ id, token, env, timeout, workingDirectory }) =>\n new SpritesSandbox({ id, token, env, timeout, workingDirectory }),\n};\n"],"mappings":";;;;AAaA,MAAa,aAAa;;AAG1B,MAAM,mBAAmB;AAEzB,IAAM,uBAAN,cAAmCA,uBAAAA,cAAc;CAC/C;CAEA;CACA,aAA8B,KAAK,IAAI;CACvC;CACA;CACA,UAAkB;CAClB,YAAoB;CACpB;CACA;CAEA,YAAY,KAAa,KAAoB,SAA8B,SAA6B;EACtG,MAAM,OAAO;EACb,KAAK,MAAM;EACX,KAAK,OAAO;EAEZ,IAAI,OAAO,YAAY,MAAM;EAC7B,IAAI,OAAO,YAAY,MAAM;EAC7B,IAAI,OAAO,GAAG,SAAS,UAAkB,KAAK,WAAW,KAAK,C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FACA,KAAK,mBACD,mBAAmB,KAAK,iBAAiB,gBACzC,4DACN;EACA,IAAI,KAAK,aAAa,KAAA,GACpB,MAAM,KAAK,4BAA4B,KAAK,KAAK,KAAK,WAAW,GAAI,EAAE,GAAG;EAE5E,OAAO,MAAM,KAAK,GAAG;CACvB;AACF;AAEA,SAAS,SAAS,OAAgB,YAA6B;CAC7D,OAAO,iBAAiBC,aAAAA,YAAY,MAAM,eAAe;AAC3D;;AC9MA,MAAa,yBAAiE;CAC5E,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;EACZ,MAAM;EACN,YAAY;GACV,IAAI;IAAE,MAAM;IAAU,aAAa;GAA4D;GAC/F,OAAO;IAAE,MAAM;IAAU,aAAa;GAAkD;GACxF,KAAK;IACH,MAAM;IACN,aAAa;IACb,sBAAsB,EAAE,MAAM,SAAS;GACzC;GACA,SAAS;IAAE,MAAM;IAAU,aAAa;GAAgC;GACxE,kBAAkB;IAAE,MAAM;IAAU,aAAa;GAAyC;EAC5F;CACF;CAEA,gBAAgB,EAAE,IAAI,OAAO,KAAK,SAAS,uBACzC,IAAI,eAAe;EAAE;EAAI;EAAO;EAAK;EAAS;CAAiB,CAAC;AACpE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/sandbox/process-manager.ts","../src/sandbox/index.ts","../src/provider.ts"],"sourcesContent":["/**\n * Sprites Process Manager\n *\n * Runs each spawned command as its own `SpriteCommand` (a WebSocket exec\n * session on the Sprite) and streams stdout/stderr into the core\n * `ProcessHandle` buffers as chunks arrive.\n */\n\nimport type { SpriteCommand } from '@fly/sprites';\nimport type { CommandResult, ProcessInfo, SpawnProcessOptions } from '@mastra/core/workspace';\nimport { ProcessHandle, SandboxProcessManager } from '@mastra/core/workspace';\nimport type { SpritesSandbox } from './index';\n\nexport const LOG_PREFIX = '[SpritesSandbox]';\n\n/** Exit code reported for processes terminated by `kill()` or a timeout. */\nconst KILLED_EXIT_CODE = 137;\n\nclass SpritesProcessHandle extends ProcessHandle {\n readonly pid: string;\n\n private readonly _cmd: SpriteCommand;\n private readonly _startTime = Date.now();\n private readonly _done: Promise<void>;\n private _exitCode: number | undefined;\n private _killed = false;\n private _timedOut = false;\n private _timeoutId: ReturnType<typeof setTimeout> | undefined;\n private _error: Error | undefined;\n\n constructor(pid: string, cmd: SpriteCommand, options: SpawnProcessOptions, timeout: number | undefined) {\n super(options);\n this.pid = pid;\n this._cmd = cmd;\n\n cmd.stdout.setEncoding('utf8');\n cmd.stderr.setEncoding('utf8');\n cmd.stdout.on('data', (chunk: string) => this.emitStdout(chunk));\n cmd.stderr.on('data', (chunk: string) => this.emitStderr(chunk));\n // SpriteCommand is an EventEmitter: an unhandled 'error' would crash the process.\n cmd.on('error', (error: Error) => {\n this._error ??= error;\n });\n\n // Output streams end right after the exit frame, so waiting for both\n // guarantees every chunk has been emitted before the exit code is published.\n this._done = Promise.all([cmd.wait(), streamEnded(cmd.stdout), streamEnded(cmd.stderr)]).then(([code]) => {\n clearTimeout(this._timeoutId);\n this._exitCode = this._killed ? KILLED_EXIT_CODE : code < 0 ? 1 : code;\n });\n\n if (timeout !== undefined && timeout > 0) {\n this._timeoutId = setTimeout(() => {\n this._timedOut = true;\n void this.kill();\n }, timeout);\n }\n }\n\n get exitCode(): number | undefined {\n return this._exitCode;\n }\n\n async wait(): Promise<CommandResult> {\n await this._done;\n const exitCode = this._exitCode!;\n let stderr = this.stderr;\n if (exitCode !== 0 && !stderr && this._error && !this._killed) {\n stderr = this._error.message;\n }\n return {\n success: exitCode === 0,\n exitCode,\n stdout: this.stdout,\n stderr,\n executionTimeMs: Date.now() - this._startTime,\n ...(this._killed && { killed: true }),\n ...(this._timedOut && { timedOut: true }),\n };\n }\n\n async kill(): Promise<boolean> {\n if (this._exitCode !== undefined || this._killed) return false;\n this._killed = true;\n clearTimeout(this._timeoutId);\n // Signal the remote process, then drop the connection. Closing the\n // (non-detachable) exec session makes the server reap the process even if\n // the signal could not be delivered.\n this._cmd.kill('SIGKILL');\n this._cmd.close();\n return true;\n }\n\n async sendStdin(data: string): Promise<void> {\n if (this._exitCode !== undefined) {\n throw new Error(`${LOG_PREFIX} Cannot write to stdin: process ${this.pid} has exited`);\n }\n await new Promise<void>((resolve, reject) => {\n this._cmd.stdin.write(data, error => (error ? reject(error) : resolve()));\n });\n }\n\n async closeStdin(): Promise<void> {\n this._cmd.stdin.end();\n }\n}\n\nexport class SpritesProcessManager extends SandboxProcessManager<SpritesSandbox> {\n private _spawnCounter = 0;\n\n async spawn(command: string, options: SpawnProcessOptions = {}): Promise<ProcessHandle> {\n // The base spawn wrapper has already merged the sandbox env into options.env.\n const env = Object.fromEntries(\n Object.entries(options.env ?? {}).filter((entry): entry is [string, string] => entry[1] !== undefined),\n );\n const cwd = options.cwd ?? this.sandbox.workingDirectory;\n\n const cmd = this.sandbox.sprite.spawn('sh', ['-c', command], {\n ...(cwd && { cwd }),\n ...(Object.keys(env).length > 0 && { env }),\n });\n try {\n await waitForSpawn(cmd);\n } catch (error) {\n // Drop any half-opened exec connection so failed spawns don't leak sockets.\n cmd.close();\n throw error;\n }\n\n if (options.stdinMode === 'ignore') {\n cmd.stdin.end();\n }\n\n const pid = `sprites-proc-${Date.now().toString(36)}-${(++this._spawnCounter).toString(36)}`;\n const handle = new SpritesProcessHandle(pid, cmd, options, options.timeout ?? this.sandbox.defaultTimeout);\n this._tracked.set(pid, handle);\n return handle;\n }\n\n /**\n * Lists processes spawned by this instance. The Sprites exec API has no\n * listing for non-detachable commands, so processes started elsewhere are\n * not included.\n */\n async list(): Promise<ProcessInfo[]> {\n return [...this._tracked.values()].map(handle => ({\n pid: handle.pid,\n command: handle.command,\n running: handle.exitCode === undefined,\n ...(handle.exitCode !== undefined && { exitCode: handle.exitCode }),\n }));\n }\n\n /** Kill every running process spawned by this instance. Does not start the sandbox. */\n async killAll(): Promise<void> {\n const running = [...this._tracked.values()].filter(handle => handle.exitCode === undefined);\n await Promise.all(running.map(handle => this.kill(handle.pid)));\n }\n}\n\nfunction waitForSpawn(cmd: SpriteCommand): Promise<void> {\n return new Promise((resolve, reject) => {\n const onSpawn = () => {\n cmd.off('error', onError);\n resolve();\n };\n const onError = (error: Error) => {\n cmd.off('spawn', onSpawn);\n reject(error);\n };\n cmd.once('spawn', onSpawn);\n cmd.once('error', onError);\n });\n}\n\nfunction streamEnded(stream: NodeJS.ReadableStream): Promise<void> {\n return new Promise(resolve => {\n stream.once('end', () => resolve());\n stream.once('close', () => resolve());\n });\n}\n","/**\n * Fly.io Sprites Sandbox Provider\n *\n * A Sprites sandbox implementation for Mastra workspaces. Gets or creates a\n * persistent Fly.io Sprite by name and runs commands in it through the\n * official `@fly/sprites` SDK. Sprites keep their filesystem between runs and\n * hibernate on their own when idle.\n *\n * @see https://sprites.dev\n */\n\nimport { APIError, SpritesClient } from '@fly/sprites';\nimport type { Sprite, SpriteConfig } from '@fly/sprites';\nimport type {\n InstructionsOption,\n MastraSandboxOptions,\n ProviderStatus,\n SandboxInfo,\n SandboxStartResult,\n} from '@mastra/core/workspace';\nimport { MastraSandbox, SandboxNotReadyError } from '@mastra/core/workspace';\nimport { LOG_PREFIX, SpritesProcessManager } from './process-manager';\n\nexport interface SpritesSandboxOptions extends Omit<MastraSandboxOptions, 'processes'> {\n /**\n * Sprite name, also used as the sandbox id. An existing Sprite with this\n * name is reused (including its filesystem); otherwise one is created.\n * Generated when omitted.\n */\n id?: string;\n /** Sprites API token. Falls back to the `SPRITES_TOKEN` environment variable. */\n token?: string;\n /** Sprites API base URL. Defaults to the SDK default (`https://api.sprites.dev`). */\n baseURL?: string;\n /** Machine configuration applied only when the Sprite is created. */\n spriteConfig?: SpriteConfig;\n /** Default command timeout in milliseconds. Per-command `timeout` wins. */\n timeout?: number;\n /** Override or extend the default agent instructions for this sandbox. */\n instructions?: InstructionsOption;\n}\n\nexport class SpritesSandbox extends MastraSandbox {\n readonly id: string;\n readonly name = 'SpritesSandbox';\n readonly provider = 'sprites';\n status: ProviderStatus = 'pending';\n\n declare readonly processes: SpritesProcessManager;\n\n private _client: SpritesClient | null = null;\n private _sprite: Sprite | null = null;\n private _createdAt: Date | null = null;\n private readonly _token?: string;\n private readonly _baseURL?: string;\n private readonly _spriteConfig?: SpriteConfig;\n private readonly _timeout?: number;\n private readonly _instructionsOverride?: InstructionsOption;\n\n constructor(options: SpritesSandboxOptions = {}) {\n super({ ...options, name: 'SpritesSandbox', processes: new SpritesProcessManager() });\n\n this.id = options.id ?? `mastra-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;\n this._token = options.token ?? process.env.SPRITES_TOKEN;\n this._baseURL = options.baseURL;\n this._spriteConfig = options.spriteConfig;\n this._timeout = options.timeout;\n this._instructionsOverride = options.instructions;\n }\n\n /** The underlying SDK `Sprite`. Throws if the sandbox has not been started. */\n get sprite(): Sprite {\n if (!this._sprite) {\n throw new SandboxNotReadyError(this.id);\n }\n return this._sprite;\n }\n\n /** Default command timeout in milliseconds, if configured. */\n get defaultTimeout(): number | undefined {\n return this._timeout;\n }\n\n private get client(): SpritesClient {\n if (!this._client) {\n if (!this._token) {\n throw new Error(\n `${LOG_PREFIX} Missing Sprites API token. Pass \\`token\\` or set the SPRITES_TOKEN environment variable.`,\n );\n }\n this._client = new SpritesClient(this._token, this._baseURL ? { baseURL: this._baseURL } : undefined);\n }\n return this._client;\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n /**\n * Get the Sprite named `id`, creating it when it does not exist.\n * Reports `outcome: 'created'` only when a new Sprite was provisioned.\n */\n async start(): Promise<SandboxStartResult> {\n if (this._sprite) {\n return { outcome: 'connected' };\n }\n\n const client = this.client;\n let outcome: SandboxStartResult['outcome'] = 'connected';\n let sprite: Sprite;\n\n try {\n sprite = await client.getSprite(this.id);\n } catch (error) {\n if (!isStatus(error, 404)) throw error;\n try {\n sprite = await client.createSprite(this.id, this._spriteConfig);\n outcome = 'created';\n } catch (createError) {\n // Another process created the same Sprite between our get and create.\n if (!isStatus(createError, 409)) throw createError;\n sprite = await client.getSprite(this.id);\n }\n }\n\n this._sprite = sprite;\n this._createdAt = sprite.createdAt ?? new Date();\n this.logger.debug(`${LOG_PREFIX} Sprite ready`, { id: this.id, outcome });\n return { outcome };\n }\n\n /**\n * Release local resources: kill background processes started by this\n * instance and close the SDK control connection.\n *\n * The Sprite itself is NOT deleted or suspended. Sprites hibernate on their\n * own when idle, and `start()` reconnects to the same filesystem.\n */\n async stop(): Promise<void> {\n await this._killTrackedProcesses();\n this._sprite?.closeControlConnection();\n this._sprite = null;\n }\n\n /**\n * Permanently delete the Sprite and its filesystem. A Sprite that no longer\n * exists is treated as already destroyed.\n */\n async destroy(): Promise<void> {\n await this._killTrackedProcesses();\n const sprite = this._sprite ?? this.client.sprite(this.id);\n sprite.closeControlConnection();\n this._sprite = null;\n\n try {\n await sprite.delete();\n } catch (error) {\n if (!isStatus(error, 404)) throw error;\n }\n }\n\n /**\n * Capture a checkpoint of the Sprite's current state.\n *\n * Checkpoints live inside this Sprite only and cannot seed other sandboxes,\n * so `supportsCheckpoints` stays `false`.\n */\n async snapshot(): Promise<void> {\n await this.ensureRunning();\n const stream = await this.sprite.createCheckpoint('mastra snapshot');\n await stream.processAll(message => {\n if (message.type === 'error') {\n throw new Error(`${LOG_PREFIX} Checkpoint failed: ${message.error ?? message.data ?? 'unknown error'}`);\n }\n });\n }\n\n private async _killTrackedProcesses(): Promise<void> {\n await this.processes.killAll().catch(error => {\n this.logger.warn(`${LOG_PREFIX} Failed to kill background processes`, { error });\n });\n }\n\n // ---------------------------------------------------------------------------\n // Info & Instructions\n // ---------------------------------------------------------------------------\n\n async getInfo(): Promise<SandboxInfo> {\n const sprite = this._sprite;\n return {\n id: this.id,\n name: this.name,\n provider: this.provider,\n status: this.status,\n createdAt: this._createdAt ?? new Date(),\n metadata: {\n ...(sprite && {\n ...(sprite.id && { spriteId: sprite.id }),\n ...(sprite.status && { spriteStatus: sprite.status }),\n ...(sprite.url && { url: sprite.url }),\n ...(sprite.primaryRegion && { region: sprite.primaryRegion }),\n }),\n },\n };\n }\n\n getInstructions(): string {\n const defaultInstructions = this._buildDefaultInstructions();\n\n if (typeof this._instructionsOverride === 'string') {\n return this._instructionsOverride;\n }\n if (typeof this._instructionsOverride === 'function') {\n return this._instructionsOverride({ defaultInstructions });\n }\n return defaultInstructions;\n }\n\n private _buildDefaultInstructions(): string {\n const parts = [\n 'Fly.io Sprite: a persistent Linux VM. Files written to disk survive between sessions.',\n this.workingDirectory\n ? `Commands run in ${this.workingDirectory} by default.`\n : 'Commands run in the Sprite user home directory by default.',\n ];\n if (this._timeout !== undefined) {\n parts.push(`Default command timeout: ${Math.ceil(this._timeout / 1000)}s.`);\n }\n return parts.join(' ');\n }\n}\n\nfunction isStatus(error: unknown, statusCode: number): boolean {\n return error instanceof APIError && error.statusCode === statusCode;\n}\n","/**\n * Fly.io Sprites sandbox provider descriptor for MastraEditor.\n *\n * @example\n * ```typescript\n * import { spritesSandboxProvider } from '@mastra/sprites';\n *\n * const editor = new MastraEditor({\n * sandboxes: { [spritesSandboxProvider.id]: spritesSandboxProvider },\n * });\n * ```\n */\nimport type { SandboxProvider } from '@mastra/core/editor';\nimport { SpritesSandbox } from './sandbox';\n\n/**\n * Serializable subset of SpritesSandboxOptions for editor storage.\n *\n * `baseURL` is deliberately excluded: the sandbox falls back to the server's\n * SPRITES_TOKEN, so a stored API host could redirect that token elsewhere.\n */\ninterface SpritesProviderConfig {\n id?: string;\n token?: string;\n env?: Record<string, string>;\n timeout?: number;\n workingDirectory?: string;\n}\n\nexport const spritesSandboxProvider: SandboxProvider<SpritesProviderConfig> = {\n id: 'sprites',\n name: 'Fly.io Sprites',\n description: 'Persistent Linux VM powered by Fly.io Sprites',\n configSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Sprite name. An existing Sprite with this name is reused.' },\n token: { type: 'string', description: 'Sprites API token (falls back to SPRITES_TOKEN)' },\n env: {\n type: 'object',\n description: 'Environment variables',\n additionalProperties: { type: 'string' },\n },\n timeout: { type: 'number', description: 'Default command timeout in ms' },\n workingDirectory: { type: 'string', description: 'Default working directory for commands' },\n },\n },\n // Pick known fields so extra stored keys (such as baseURL) never reach the sandbox.\n createSandbox: ({ id, token, env, timeout, workingDirectory }) =>\n new SpritesSandbox({ id, token, env, timeout, workingDirectory }),\n};\n"],"mappings":";;;AAaA,MAAa,aAAa;;AAG1B,MAAM,mBAAmB;AAEzB,IAAM,uBAAN,cAAmC,cAAc;CAC/C;CAEA;CACA,aAA8B,KAAK,IAAI;CACvC;CACA;CACA,UAAkB;CAClB,YAAoB;CACpB;CACA;CAEA,YAAY,KAAa,KAAoB,SAA8B,SAA6B;EACtG,MAAM,OAAO;EACb,KAAK,MAAM;EACX,KAAK,OAAO;EAEZ,IAAI,OAAO,YAAY,MAAM;EAC7B,IAAI,OAAO,YAAY,MAAM;EAC7B,IAAI,OAAO,GAAG,SAAS,UAAkB,KAAK,WAAW,KAAK,CAAC;EAC/D,IAAI,OAAO,GAAG,SAAS,UAAkB,KAAK,WAAW,KAAK,CAAC;EAE/D,IAAI,GAAG,UAAU,UAAiB;GAChC,KAAK,WAAW;EAClB,CAAC;EAID,KAAK,QAAQ,QAAQ,IAAI;GAAC,IAAI,KAAK;GAAG,YAAY,IAAI,MAAM;GAAG,YAAY,IAAI,MAAM;EAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU;GACxG,aAAa,KAAK,UAAU;GAC5B,KAAK,YAAY,KAAK,UAAU,mBAAmB,OAAO,IAAI,IAAI;EACpE,CAAC;EAED,I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GAC/F,OAAO;IAAE,MAAM;IAAU,aAAa;GAAkD;GACxF,KAAK;IACH,MAAM;IACN,aAAa;IACb,sBAAsB,EAAE,MAAM,SAAS;GACzC;GACA,SAAS;IAAE,MAAM;IAAU,aAAa;GAAgC;GACxE,kBAAkB;IAAE,MAAM;IAAU,aAAa;GAAyC;EAC5F;CACF;CAEA,gBAAgB,EAAE,IAAI,OAAO,KAAK,SAAS,uBACzC,IAAI,eAAe;EAAE;EAAI;EAAO;EAAK;EAAS;CAAiB,CAAC;AACpE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D;;;;;GAKG;AACH,UAAU,qBAAqB;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,sBAAsB,EAAE,eAAe,CAAC,qBAAqB,CAqBzE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAwB,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAc,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEtE,MAAM,WAAW,qBA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