@mastra/agentcore 0.3.1 → 0.4.0-alpha.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @mastra/agentcore
2
2
 
3
+ ## 0.4.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added `ProcessHandle.closeStdin()` to signal end-of-file to background processes. Local and Docker sandboxes support closing stdin, while providers without an available stdin-close API return a provider-specific unsupported-operation error. Providers signal the unsupported case with the new `UnsupportedStdinCloseError`, and the base class supplies that behavior by default so existing `ProcessHandle` subclasses keep compiling. Calling `handle.writer.end()` also closes stdin, and finishes without an error when the provider cannot close stdin. ([#21606](https://github.com/mastra-ai/mastra/pull/21606))
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`4e7a421`](https://github.com/mastra-ai/mastra/commit/4e7a421dce8a48742f785d1e93ad2f43a572b282), [`242e324`](https://github.com/mastra-ai/mastra/commit/242e3241e73cbd5c9bb86a31ebb49ca0256488d4), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`d774e89`](https://github.com/mastra-ai/mastra/commit/d774e8930c781df8c9effe3763e6b501c099b6cc), [`9c27a53`](https://github.com/mastra-ai/mastra/commit/9c27a53cd9d3de4f3f025bc387d94ce371c33f95), [`dff25a1`](https://github.com/mastra-ai/mastra/commit/dff25a1103fa72ee082a9b6f805ebeb5ce400753), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`7f78585`](https://github.com/mastra-ai/mastra/commit/7f785857e401570e2ffb316911f126ed363aa537), [`f2a4afd`](https://github.com/mastra-ai/mastra/commit/f2a4afd7e37e809669001ed17724b341a5c1f45e), [`d438148`](https://github.com/mastra-ai/mastra/commit/d438148e222c1e2fb3c652725ce75680962ebec4), [`ba05fe0`](https://github.com/mastra-ai/mastra/commit/ba05fe0738f70cb686777546e968237d09269142), [`d26a8d4`](https://github.com/mastra-ai/mastra/commit/d26a8d4281f28414715b333c85bedaf70d0b2890), [`677cdc6`](https://github.com/mastra-ai/mastra/commit/677cdc6af564dec29a13464d12b7ab2a4efc22e9), [`a318490`](https://github.com/mastra-ai/mastra/commit/a318490e17da32f338d50929c770d901a9b3dd72), [`763e0c6`](https://github.com/mastra-ai/mastra/commit/763e0c61e04d76ad9a9efd301aa57525ca0cbea9), [`23e0be2`](https://github.com/mastra-ai/mastra/commit/23e0be261381e49534b4ff3101c60ee64a946cbf), [`7fc8806`](https://github.com/mastra-ai/mastra/commit/7fc880627d3cbf995d31ea0e8b807bf15417e651), [`0e02eac`](https://github.com/mastra-ai/mastra/commit/0e02eacdb2e30e1697a41910b41163742a181dc1), [`4df174c`](https://github.com/mastra-ai/mastra/commit/4df174c32bddf093a82f273070b8380aef7c9e90), [`f7c25b5`](https://github.com/mastra-ai/mastra/commit/f7c25b5106ddfb48e591f98df7a51e0f2dd01dba), [`dc09cc1`](https://github.com/mastra-ai/mastra/commit/dc09cc1083d861cde192c1cd235324dc75b8c731), [`36b4649`](https://github.com/mastra-ai/mastra/commit/36b4649045a3a380cbab8ceca866db4086223aff), [`377eb81`](https://github.com/mastra-ai/mastra/commit/377eb81ce43b964e3a6b541df172da74a8ff3716)]:
12
+ - @mastra/core@1.60.0-alpha.8
13
+
3
14
  ## 0.3.1
4
15
 
5
16
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -27,6 +27,9 @@ var CommandOutputAccumulator = class extends _mastra_core_workspace.ProcessHandl
27
27
  async sendStdin() {
28
28
  throw new Error("AgentCore Runtime command execution does not support stdin");
29
29
  }
30
+ async closeStdin() {
31
+ throw new _mastra_core_workspace.UnsupportedStdinCloseError("AgentCore Runtime command execution does not support closing stdin");
32
+ }
30
33
  async wait() {
31
34
  return {
32
35
  success: this.exitCode === 0,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["ProcessHandle","MastraSandbox","StopRuntimeSessionCommand","InvokeAgentRuntimeCommandCommand","BedrockAgentCoreClient"],"sources":["../src/sandbox/index.ts","../src/provider.ts"],"sourcesContent":["/**\n * AWS Bedrock AgentCore Runtime sandbox provider.\n *\n * This provider maps Mastra's one-shot command execution contract to\n * InvokeAgentRuntimeCommand. It intentionally does not expose process\n * management or filesystem mounts because AgentCore Runtime command execution\n * does not provide those WorkspaceSandbox semantics.\n *\n * @see https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-execute-command.html\n */\n\nimport { randomUUID } from 'node:crypto';\nimport {\n BedrockAgentCoreClient,\n InvokeAgentRuntimeCommandCommand,\n StopRuntimeSessionCommand,\n} from '@aws-sdk/client-bedrock-agentcore';\nimport type { RequestContext } from '@mastra/core/di';\nimport type {\n CommandResult,\n ExecuteCommandOptions,\n MastraSandboxOptions,\n ProviderStatus,\n SandboxInfo,\n} from '@mastra/core/workspace';\nimport { MastraSandbox, ProcessHandle } from '@mastra/core/workspace';\n\nconst LOG_PREFIX = '[AgentCoreRuntimeSandbox]';\nconst DEFAULT_COMMAND_TIMEOUT_MS = 300_000;\nconst MAX_AGENTCORE_TIMEOUT_SECONDS = 3600;\nconst DEFAULT_ACCEPT = 'application/vnd.amazon.eventstream';\nconst DEFAULT_CONTENT_TYPE = 'application/json';\n\ntype AgentCoreRuntimeClient = Pick<BedrockAgentCoreClient, 'send' | 'destroy'>;\ntype InstructionsOption = string | ((opts: { defaultInstructions: string; requestContext?: RequestContext }) => string);\ntype AgentCoreStreamException = {\n name?: string;\n message?: string;\n};\n\ntype AgentCoreStreamEvent = {\n chunk?: {\n contentStart?: unknown;\n contentDelta?: {\n stdout?: string;\n stderr?: string;\n };\n contentStop?: {\n exitCode?: number;\n status?: string;\n };\n };\n accessDeniedException?: AgentCoreStreamException;\n internalServerException?: AgentCoreStreamException;\n resourceNotFoundException?: AgentCoreStreamException;\n serviceQuotaExceededException?: AgentCoreStreamException;\n throttlingException?: AgentCoreStreamException;\n validationException?: AgentCoreStreamException;\n runtimeClientError?: AgentCoreStreamException;\n $unknown?: [string, unknown];\n};\n\nclass CommandOutputAccumulator extends ProcessHandle {\n readonly pid = 'agentcore-command';\n exitCode: number | undefined;\n\n async kill(): Promise<boolean> {\n return false;\n }\n\n async sendStdin(): Promise<void> {\n throw new Error('AgentCore Runtime command execution does not support stdin');\n }\n\n async wait(): Promise<CommandResult> {\n return {\n success: this.exitCode === 0,\n exitCode: this.exitCode ?? 1,\n stdout: this.stdout,\n stderr: this.stderr,\n executionTimeMs: 0,\n };\n }\n}\n\nfunction shellQuote(arg: string): string {\n if (/^[a-zA-Z0-9._\\-\\/=:@]+$/.test(arg)) return arg;\n return `'${arg.replace(/'/g, \"'\\\\''\")}'`;\n}\n\nfunction safeEnvName(name: string): boolean {\n return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name);\n}\n\nfunction buildCommand(command: string, args: string[] | undefined, options: ExecuteCommandOptions | undefined): string {\n const baseCommand = args?.length ? `${command} ${args.map(arg => shellQuote(arg)).join(' ')}` : command;\n const parts: string[] = [];\n\n if (options?.cwd) {\n parts.push(`cd ${shellQuote(options.cwd)}`);\n }\n\n const env = options?.env ?? {};\n const envAssignments = Object.entries(env)\n .filter((entry): entry is [string, string] => entry[1] !== undefined)\n .map(([key, value]) => {\n if (!safeEnvName(key)) {\n throw new Error(`Invalid environment variable name for AgentCore Runtime command: ${key}`);\n }\n return `${key}=${shellQuote(value)}`;\n });\n\n parts.push(`${envAssignments.length ? `${envAssignments.join(' ')} ` : ''}${baseCommand}`);\n return parts.join(' && ');\n}\n\nfunction toAgentCoreTimeoutSeconds(timeoutMs: number): number {\n if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {\n throw new RangeError('AgentCore Runtime command timeout must be a positive number of milliseconds');\n }\n\n const timeoutSeconds = Math.ceil(timeoutMs / 1000);\n if (timeoutSeconds > MAX_AGENTCORE_TIMEOUT_SECONDS) {\n throw new RangeError(`AgentCore Runtime command timeout must be at most ${MAX_AGENTCORE_TIMEOUT_SECONDS} seconds`);\n }\n\n return timeoutSeconds;\n}\n\nfunction generateSessionId(): string {\n return randomUUID();\n}\n\nfunction getStreamException(event: AgentCoreStreamEvent): { key: string; value: unknown } | undefined {\n const exceptionKeys = [\n 'accessDeniedException',\n 'internalServerException',\n 'resourceNotFoundException',\n 'serviceQuotaExceededException',\n 'throttlingException',\n 'validationException',\n 'runtimeClientError',\n ] as const;\n\n for (const key of exceptionKeys) {\n const value = event[key];\n if (value) return { key, value };\n }\n\n if (event.$unknown) {\n return { key: event.$unknown[0], value: event.$unknown[1] };\n }\n\n return undefined;\n}\n\nfunction formatStreamException(key: string, value: unknown): string {\n if (value && typeof value === 'object') {\n const exception = value as AgentCoreStreamException;\n const name = exception.name ?? key;\n return exception.message ? `${name}: ${exception.message}` : name;\n }\n\n return `${key}: ${String(value)}`;\n}\n\n// =============================================================================\n// Options\n// =============================================================================\n\nexport interface AgentCoreRuntimeSandboxOptions extends Omit<MastraSandboxOptions, 'processes'> {\n /** AWS region for the Bedrock AgentCore client. Falls back to the AWS SDK default region chain. */\n region?: string;\n /** AgentCore Runtime ARN where commands should execute. */\n agentRuntimeArn: string;\n /** Runtime session ID. Defaults to a generated UUID, which satisfies AgentCore's 33 character minimum. */\n runtimeSessionId?: string;\n /** Agent runtime qualifier/endpoint. Defaults to AWS AgentCore's DEFAULT qualifier. */\n qualifier?: string;\n /** MIME type sent for command requests. */\n contentType?: string;\n /** Accept header for command event streams. */\n accept?: string;\n /** Default command timeout in milliseconds. */\n commandTimeout?: number;\n /**\n * Stop the AgentCore Runtime session during stop()/destroy().\n *\n * Defaults to false because sessions are often shared with agent invocations\n * outside the WorkspaceSandbox instance.\n */\n stopSessionOnLifecycle?: boolean;\n /** Client token used for StopRuntimeSession. Defaults to a generated UUID when needed. */\n stopClientToken?: string;\n /** Optional preconfigured AWS SDK client, primarily for advanced credential setup and tests. */\n client?: AgentCoreRuntimeClient;\n /** Custom instructions for getInstructions(). String replaces the default; function receives it. */\n instructions?: InstructionsOption;\n}\n\n// =============================================================================\n// Implementation\n// =============================================================================\n\nexport class AgentCoreRuntimeSandbox extends MastraSandbox {\n readonly id: string;\n readonly name = 'AgentCoreRuntimeSandbox';\n readonly provider = 'agentcore';\n status: ProviderStatus = 'pending';\n\n private _client?: AgentCoreRuntimeClient;\n private readonly _ownsClient: boolean;\n private readonly _region?: string;\n private readonly _agentRuntimeArn: string;\n private readonly _runtimeSessionId: string;\n private readonly _qualifier?: string;\n private readonly _contentType: string;\n private readonly _accept: string;\n private readonly _commandTimeout: number;\n private readonly _stopSessionOnLifecycle: boolean;\n private readonly _stopClientToken?: string;\n private readonly _instructionsOverride?: InstructionsOption;\n private readonly _createdAt = new Date();\n private _lastUsedAt?: Date;\n\n constructor(options: AgentCoreRuntimeSandboxOptions) {\n super({ ...options, name: 'AgentCoreRuntimeSandbox' });\n\n if (!options.agentRuntimeArn) {\n throw new Error(`${LOG_PREFIX} agentRuntimeArn is required`);\n }\n\n this.id = options.runtimeSessionId ?? generateSessionId();\n this._agentRuntimeArn = options.agentRuntimeArn;\n this._runtimeSessionId = this.id;\n this._qualifier = options.qualifier;\n this._contentType = options.contentType ?? DEFAULT_CONTENT_TYPE;\n this._accept = options.accept ?? DEFAULT_ACCEPT;\n this._commandTimeout = options.commandTimeout ?? DEFAULT_COMMAND_TIMEOUT_MS;\n this._stopSessionOnLifecycle = options.stopSessionOnLifecycle ?? false;\n this._stopClientToken = options.stopClientToken;\n this._instructionsOverride = options.instructions;\n this._client = options.client;\n this._ownsClient = !options.client;\n this._region = options.region;\n }\n\n get runtimeSessionId(): string {\n return this._runtimeSessionId;\n }\n\n get agentRuntimeArn(): string {\n return this._agentRuntimeArn;\n }\n\n async start(): Promise<void> {\n this.logger.debug(`${LOG_PREFIX} Using AgentCore Runtime session ${this._runtimeSessionId}`);\n }\n\n async stop(): Promise<void> {\n if (!this._stopSessionOnLifecycle) return;\n await this.stopRuntimeSession();\n }\n\n async destroy(): Promise<void> {\n if (this._stopSessionOnLifecycle) {\n await this.stopRuntimeSession();\n }\n\n if (this._ownsClient && this._client) {\n this._client.destroy();\n this._client = undefined;\n }\n }\n\n /**\n * Explicitly stops the AgentCore Runtime session used by this sandbox.\n *\n * This is separate from destroy() because AgentCore Runtime sessions can be\n * shared with agent invocations outside the WorkspaceSandbox lifecycle.\n */\n async stopRuntimeSession(): Promise<void> {\n await this._getClient().send(\n new StopRuntimeSessionCommand({\n agentRuntimeArn: this._agentRuntimeArn,\n runtimeSessionId: this._runtimeSessionId,\n qualifier: this._qualifier,\n clientToken: this._stopClientToken ?? generateSessionId(),\n }),\n );\n }\n\n async executeCommand(command: string, args?: string[], options?: ExecuteCommandOptions): Promise<CommandResult> {\n await this.ensureRunning();\n\n const fullCommand = buildCommand(command, args, options);\n const timeoutMs = options?.timeout ?? this._commandTimeout;\n const timeoutSeconds = toAgentCoreTimeoutSeconds(timeoutMs);\n const startTime = Date.now();\n const output = new CommandOutputAccumulator({\n maxRetainedBytes: options?.maxRetainedBytes ?? Infinity,\n onStdout: options?.onStdout,\n onStderr: options?.onStderr,\n });\n let stopStatus: string | undefined;\n\n this.logger.debug(`${LOG_PREFIX} Executing command`, {\n runtimeSessionId: this._runtimeSessionId,\n command: fullCommand,\n timeoutSeconds,\n });\n\n const response = await this._getClient().send(\n new InvokeAgentRuntimeCommandCommand({\n agentRuntimeArn: this._agentRuntimeArn,\n runtimeSessionId: this._runtimeSessionId,\n qualifier: this._qualifier,\n contentType: this._contentType,\n accept: this._accept,\n body: {\n command: fullCommand,\n timeout: timeoutSeconds,\n },\n }),\n { abortSignal: options?.abortSignal },\n );\n\n for await (const event of response.stream ?? []) {\n const streamEvent = event as AgentCoreStreamEvent;\n const streamException = getStreamException(streamEvent);\n if (streamException) {\n throw new Error(`${LOG_PREFIX} ${formatStreamException(streamException.key, streamException.value)}`);\n }\n\n const chunk = streamEvent.chunk;\n if (!chunk) continue;\n\n if (chunk.contentDelta?.stdout) {\n output.emitStdout(chunk.contentDelta.stdout);\n }\n\n if (chunk.contentDelta?.stderr) {\n output.emitStderr(chunk.contentDelta.stderr);\n }\n\n if (chunk.contentStop) {\n output.exitCode = chunk.contentStop.exitCode ?? 1;\n stopStatus = chunk.contentStop.status;\n }\n }\n\n const executionTimeMs = Date.now() - startTime;\n const exitCode = output.exitCode ?? 1;\n const timedOut = stopStatus === 'TIMED_OUT';\n const finalExitCode = timedOut ? 124 : exitCode;\n this._lastUsedAt = new Date();\n\n return {\n command: fullCommand,\n args,\n success: finalExitCode === 0 && !timedOut,\n exitCode: finalExitCode,\n stdout: output.stdout,\n stderr: output.stderr,\n executionTimeMs,\n timedOut,\n stdoutTruncated: output.stdoutTruncated,\n stderrTruncated: output.stderrTruncated,\n stdoutDroppedBytes: output.stdoutDroppedBytes,\n stderrDroppedBytes: output.stderrDroppedBytes,\n };\n }\n\n getInstructions(opts?: { requestContext?: RequestContext }): string {\n const defaultInstructions = this._getDefaultInstructions();\n if (this._instructionsOverride === undefined) return defaultInstructions;\n if (typeof this._instructionsOverride === 'string') return this._instructionsOverride;\n return this._instructionsOverride({ defaultInstructions, requestContext: opts?.requestContext });\n }\n\n async getInfo(): Promise<SandboxInfo> {\n return {\n id: this.id,\n name: this.name,\n provider: this.provider,\n status: this.status,\n createdAt: this._createdAt,\n lastUsedAt: this._lastUsedAt,\n metadata: {\n agentRuntimeArn: this._agentRuntimeArn,\n runtimeSessionId: this._runtimeSessionId,\n qualifier: this._qualifier ?? 'DEFAULT',\n stopSessionOnLifecycle: this._stopSessionOnLifecycle,\n },\n };\n }\n\n private _getDefaultInstructions(): string {\n return [\n 'AWS Bedrock AgentCore Runtime sandbox.',\n 'Commands run inside the configured AgentCore Runtime session container.',\n 'Command output streams from AgentCore Runtime as stdout and stderr.',\n 'Limitations:',\n '- Commands are one-shot and non-interactive.',\n '- There is no persistent shell session between commands.',\n '- Background process management is not exposed by this provider.',\n '- Filesystem mounts are not exposed by this provider.',\n '- Developer tools such as git, npm, Python, or Node must exist in the AgentCore container image.',\n '- AgentCore Code Interpreter is a separate service and is not part of this runtime sandbox.',\n ].join('\\n');\n }\n\n private _getClient(): AgentCoreRuntimeClient {\n if (!this._client) {\n this._client = new BedrockAgentCoreClient({ region: this._region });\n }\n return this._client;\n }\n}\n","/**\n * AWS Bedrock AgentCore Runtime sandbox provider descriptor.\n *\n * Enables registration with MastraEditor for UI-driven sandbox configuration.\n */\n\nimport type { SandboxProvider } from '@mastra/core/editor';\nimport { AgentCoreRuntimeSandbox } from './sandbox';\n\nexport interface AgentCoreRuntimeProviderConfig {\n /** AWS region for the Bedrock AgentCore client */\n region?: string;\n /** AgentCore Runtime ARN where commands should execute */\n agentRuntimeArn: string;\n /** Runtime session ID */\n runtimeSessionId?: string;\n /** Agent runtime qualifier/endpoint */\n qualifier?: string;\n /** Default command timeout in milliseconds */\n commandTimeout?: number;\n /** Stop the runtime session during stop()/destroy() */\n stopSessionOnLifecycle?: boolean;\n}\n\nexport const agentCoreRuntimeSandboxProvider: SandboxProvider<AgentCoreRuntimeProviderConfig> = {\n id: 'agentcore',\n name: 'AgentCore Runtime Sandbox',\n description: 'AWS Bedrock AgentCore Runtime command execution sandbox',\n configSchema: {\n type: 'object',\n required: ['agentRuntimeArn'],\n properties: {\n region: {\n type: 'string',\n description: 'AWS region for Bedrock AgentCore',\n },\n agentRuntimeArn: {\n type: 'string',\n description: 'AgentCore Runtime ARN',\n },\n runtimeSessionId: {\n type: 'string',\n description: 'Runtime session ID. Defaults to a generated UUID.',\n },\n qualifier: {\n type: 'string',\n description: 'Agent runtime qualifier/endpoint',\n default: 'DEFAULT',\n },\n commandTimeout: {\n type: 'number',\n description: 'Default command timeout in milliseconds. Must be between 1 and 3,600,000.',\n default: 300_000,\n minimum: 1,\n maximum: 3_600_000,\n },\n stopSessionOnLifecycle: {\n type: 'boolean',\n description: 'Stop the AgentCore Runtime session during stop()/destroy()',\n default: false,\n },\n },\n },\n createSandbox: config => new AgentCoreRuntimeSandbox(config),\n};\n"],"mappings":";;;;;;;;;;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supportedStdinCloseError","MastraSandbox","StopRuntimeSessionCommand","InvokeAgentRuntimeCommandCommand","BedrockAgentCoreClient"],"sources":["../src/sandbox/index.ts","../src/provider.ts"],"sourcesContent":["/**\n * AWS Bedrock AgentCore Runtime sandbox provider.\n *\n * This provider maps Mastra's one-shot command execution contract to\n * InvokeAgentRuntimeCommand. It intentionally does not expose process\n * management or filesystem mounts because AgentCore Runtime command execution\n * does not provide those WorkspaceSandbox semantics.\n *\n * @see https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-execute-command.html\n */\n\nimport { randomUUID } from 'node:crypto';\nimport {\n BedrockAgentCoreClient,\n InvokeAgentRuntimeCommandCommand,\n StopRuntimeSessionCommand,\n} from '@aws-sdk/client-bedrock-agentcore';\nimport type { RequestContext } from '@mastra/core/di';\nimport type {\n CommandResult,\n ExecuteCommandOptions,\n MastraSandboxOptions,\n ProviderStatus,\n SandboxInfo,\n} from '@mastra/core/workspace';\nimport { MastraSandbox, ProcessHandle, UnsupportedStdinCloseError } from '@mastra/core/workspace';\n\nconst LOG_PREFIX = '[AgentCoreRuntimeSandbox]';\nconst DEFAULT_COMMAND_TIMEOUT_MS = 300_000;\nconst MAX_AGENTCORE_TIMEOUT_SECONDS = 3600;\nconst DEFAULT_ACCEPT = 'application/vnd.amazon.eventstream';\nconst DEFAULT_CONTENT_TYPE = 'application/json';\n\ntype AgentCoreRuntimeClient = Pick<BedrockAgentCoreClient, 'send' | 'destroy'>;\ntype InstructionsOption = string | ((opts: { defaultInstructions: string; requestContext?: RequestContext }) => string);\ntype AgentCoreStreamException = {\n name?: string;\n message?: string;\n};\n\ntype AgentCoreStreamEvent = {\n chunk?: {\n contentStart?: unknown;\n contentDelta?: {\n stdout?: string;\n stderr?: string;\n };\n contentStop?: {\n exitCode?: number;\n status?: string;\n };\n };\n accessDeniedException?: AgentCoreStreamException;\n internalServerException?: AgentCoreStreamException;\n resourceNotFoundException?: AgentCoreStreamException;\n serviceQuotaExceededException?: AgentCoreStreamException;\n throttlingException?: AgentCoreStreamException;\n validationException?: AgentCoreStreamException;\n runtimeClientError?: AgentCoreStreamException;\n $unknown?: [string, unknown];\n};\n\nclass CommandOutputAccumulator extends ProcessHandle {\n readonly pid = 'agentcore-command';\n exitCode: number | undefined;\n\n async kill(): Promise<boolean> {\n return false;\n }\n\n async sendStdin(): Promise<void> {\n throw new Error('AgentCore Runtime command execution does not support stdin');\n }\n\n async closeStdin(): Promise<void> {\n throw new UnsupportedStdinCloseError('AgentCore Runtime command execution does not support closing stdin');\n }\n\n async wait(): Promise<CommandResult> {\n return {\n success: this.exitCode === 0,\n exitCode: this.exitCode ?? 1,\n stdout: this.stdout,\n stderr: this.stderr,\n executionTimeMs: 0,\n };\n }\n}\n\nfunction shellQuote(arg: string): string {\n if (/^[a-zA-Z0-9._\\-\\/=:@]+$/.test(arg)) return arg;\n return `'${arg.replace(/'/g, \"'\\\\''\")}'`;\n}\n\nfunction safeEnvName(name: string): boolean {\n return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name);\n}\n\nfunction buildCommand(command: string, args: string[] | undefined, options: ExecuteCommandOptions | undefined): string {\n const baseCommand = args?.length ? `${command} ${args.map(arg => shellQuote(arg)).join(' ')}` : command;\n const parts: string[] = [];\n\n if (options?.cwd) {\n parts.push(`cd ${shellQuote(options.cwd)}`);\n }\n\n const env = options?.env ?? {};\n const envAssignments = Object.entries(env)\n .filter((entry): entry is [string, string] => entry[1] !== undefined)\n .map(([key, value]) => {\n if (!safeEnvName(key)) {\n throw new Error(`Invalid environment variable name for AgentCore Runtime command: ${key}`);\n }\n return `${key}=${shellQuote(value)}`;\n });\n\n parts.push(`${envAssignments.length ? `${envAssignments.join(' ')} ` : ''}${baseCommand}`);\n return parts.join(' && ');\n}\n\nfunction toAgentCoreTimeoutSeconds(timeoutMs: number): number {\n if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {\n throw new RangeError('AgentCore Runtime command timeout must be a positive number of milliseconds');\n }\n\n const timeoutSeconds = Math.ceil(timeoutMs / 1000);\n if (timeoutSeconds > MAX_AGENTCORE_TIMEOUT_SECONDS) {\n throw new RangeError(`AgentCore Runtime command timeout must be at most ${MAX_AGENTCORE_TIMEOUT_SECONDS} seconds`);\n }\n\n return timeoutSeconds;\n}\n\nfunction generateSessionId(): string {\n return randomUUID();\n}\n\nfunction getStreamException(event: AgentCoreStreamEvent): { key: string; value: unknown } | undefined {\n const exceptionKeys = [\n 'accessDeniedException',\n 'internalServerException',\n 'resourceNotFoundException',\n 'serviceQuotaExceededException',\n 'throttlingException',\n 'validationException',\n 'runtimeClientError',\n ] as const;\n\n for (const key of exceptionKeys) {\n const value = event[key];\n if (value) return { key, value };\n }\n\n if (event.$unknown) {\n return { key: event.$unknown[0], value: event.$unknown[1] };\n }\n\n return undefined;\n}\n\nfunction formatStreamException(key: string, value: unknown): string {\n if (value && typeof value === 'object') {\n const exception = value as AgentCoreStreamException;\n const name = exception.name ?? key;\n return exception.message ? `${name}: ${exception.message}` : name;\n }\n\n return `${key}: ${String(value)}`;\n}\n\n// =============================================================================\n// Options\n// =============================================================================\n\nexport interface AgentCoreRuntimeSandboxOptions extends Omit<MastraSandboxOptions, 'processes'> {\n /** AWS region for the Bedrock AgentCore client. Falls back to the AWS SDK default region chain. */\n region?: string;\n /** AgentCore Runtime ARN where commands should execute. */\n agentRuntimeArn: string;\n /** Runtime session ID. Defaults to a generated UUID, which satisfies AgentCore's 33 character minimum. */\n runtimeSessionId?: string;\n /** Agent runtime qualifier/endpoint. Defaults to AWS AgentCore's DEFAULT qualifier. */\n qualifier?: string;\n /** MIME type sent for command requests. */\n contentType?: string;\n /** Accept header for command event streams. */\n accept?: string;\n /** Default command timeout in milliseconds. */\n commandTimeout?: number;\n /**\n * Stop the AgentCore Runtime session during stop()/destroy().\n *\n * Defaults to false because sessions are often shared with agent invocations\n * outside the WorkspaceSandbox instance.\n */\n stopSessionOnLifecycle?: boolean;\n /** Client token used for StopRuntimeSession. Defaults to a generated UUID when needed. */\n stopClientToken?: string;\n /** Optional preconfigured AWS SDK client, primarily for advanced credential setup and tests. */\n client?: AgentCoreRuntimeClient;\n /** Custom instructions for getInstructions(). String replaces the default; function receives it. */\n instructions?: InstructionsOption;\n}\n\n// =============================================================================\n// Implementation\n// =============================================================================\n\nexport class AgentCoreRuntimeSandbox extends MastraSandbox {\n readonly id: string;\n readonly name = 'AgentCoreRuntimeSandbox';\n readonly provider = 'agentcore';\n status: ProviderStatus = 'pending';\n\n private _client?: AgentCoreRuntimeClient;\n private readonly _ownsClient: boolean;\n private readonly _region?: string;\n private readonly _agentRuntimeArn: string;\n private readonly _runtimeSessionId: string;\n private readonly _qualifier?: string;\n private readonly _contentType: string;\n private readonly _accept: string;\n private readonly _commandTimeout: number;\n private readonly _stopSessionOnLifecycle: boolean;\n private readonly _stopClientToken?: string;\n private readonly _instructionsOverride?: InstructionsOption;\n private readonly _createdAt = new Date();\n private _lastUsedAt?: Date;\n\n constructor(options: AgentCoreRuntimeSandboxOptions) {\n super({ ...options, name: 'AgentCoreRuntimeSandbox' });\n\n if (!options.agentRuntimeArn) {\n throw new Error(`${LOG_PREFIX} agentRuntimeArn is required`);\n }\n\n this.id = options.runtimeSessionId ?? generateSessionId();\n this._agentRuntimeArn = options.agentRuntimeArn;\n this._runtimeSessionId = this.id;\n this._qualifier = options.qualifier;\n this._contentType = options.contentType ?? DEFAULT_CONTENT_TYPE;\n this._accept = options.accept ?? DEFAULT_ACCEPT;\n this._commandTimeout = options.commandTimeout ?? DEFAULT_COMMAND_TIMEOUT_MS;\n this._stopSessionOnLifecycle = options.stopSessionOnLifecycle ?? false;\n this._stopClientToken = options.stopClientToken;\n this._instructionsOverride = options.instructions;\n this._client = options.client;\n this._ownsClient = !options.client;\n this._region = options.region;\n }\n\n get runtimeSessionId(): string {\n return this._runtimeSessionId;\n }\n\n get agentRuntimeArn(): string {\n return this._agentRuntimeArn;\n }\n\n async start(): Promise<void> {\n this.logger.debug(`${LOG_PREFIX} Using AgentCore Runtime session ${this._runtimeSessionId}`);\n }\n\n async stop(): Promise<void> {\n if (!this._stopSessionOnLifecycle) return;\n await this.stopRuntimeSession();\n }\n\n async destroy(): Promise<void> {\n if (this._stopSessionOnLifecycle) {\n await this.stopRuntimeSession();\n }\n\n if (this._ownsClient && this._client) {\n this._client.destroy();\n this._client = undefined;\n }\n }\n\n /**\n * Explicitly stops the AgentCore Runtime session used by this sandbox.\n *\n * This is separate from destroy() because AgentCore Runtime sessions can be\n * shared with agent invocations outside the WorkspaceSandbox lifecycle.\n */\n async stopRuntimeSession(): Promise<void> {\n await this._getClient().send(\n new StopRuntimeSessionCommand({\n agentRuntimeArn: this._agentRuntimeArn,\n runtimeSessionId: this._runtimeSessionId,\n qualifier: this._qualifier,\n clientToken: this._stopClientToken ?? generateSessionId(),\n }),\n );\n }\n\n async executeCommand(command: string, args?: string[], options?: ExecuteCommandOptions): Promise<CommandResult> {\n await this.ensureRunning();\n\n const fullCommand = buildCommand(command, args, options);\n const timeoutMs = options?.timeout ?? this._commandTimeout;\n const timeoutSeconds = toAgentCoreTimeoutSeconds(timeoutMs);\n const startTime = Date.now();\n const output = new CommandOutputAccumulator({\n maxRetainedBytes: options?.maxRetainedBytes ?? Infinity,\n onStdout: options?.onStdout,\n onStderr: options?.onStderr,\n });\n let stopStatus: string | undefined;\n\n this.logger.debug(`${LOG_PREFIX} Executing command`, {\n runtimeSessionId: this._runtimeSessionId,\n command: fullCommand,\n timeoutSeconds,\n });\n\n const response = await this._getClient().send(\n new InvokeAgentRuntimeCommandCommand({\n agentRuntimeArn: this._agentRuntimeArn,\n runtimeSessionId: this._runtimeSessionId,\n qualifier: this._qualifier,\n contentType: this._contentType,\n accept: this._accept,\n body: {\n command: fullCommand,\n timeout: timeoutSeconds,\n },\n }),\n { abortSignal: options?.abortSignal },\n );\n\n for await (const event of response.stream ?? []) {\n const streamEvent = event as AgentCoreStreamEvent;\n const streamException = getStreamException(streamEvent);\n if (streamException) {\n throw new Error(`${LOG_PREFIX} ${formatStreamException(streamException.key, streamException.value)}`);\n }\n\n const chunk = streamEvent.chunk;\n if (!chunk) continue;\n\n if (chunk.contentDelta?.stdout) {\n output.emitStdout(chunk.contentDelta.stdout);\n }\n\n if (chunk.contentDelta?.stderr) {\n output.emitStderr(chunk.contentDelta.stderr);\n }\n\n if (chunk.contentStop) {\n output.exitCode = chunk.contentStop.exitCode ?? 1;\n stopStatus = chunk.contentStop.status;\n }\n }\n\n const executionTimeMs = Date.now() - startTime;\n const exitCode = output.exitCode ?? 1;\n const timedOut = stopStatus === 'TIMED_OUT';\n const finalExitCode = timedOut ? 124 : exitCode;\n this._lastUsedAt = new Date();\n\n return {\n command: fullCommand,\n args,\n success: finalExitCode === 0 && !timedOut,\n exitCode: finalExitCode,\n stdout: output.stdout,\n stderr: output.stderr,\n executionTimeMs,\n timedOut,\n stdoutTruncated: output.stdoutTruncated,\n stderrTruncated: output.stderrTruncated,\n stdoutDroppedBytes: output.stdoutDroppedBytes,\n stderrDroppedBytes: output.stderrDroppedBytes,\n };\n }\n\n getInstructions(opts?: { requestContext?: RequestContext }): string {\n const defaultInstructions = this._getDefaultInstructions();\n if (this._instructionsOverride === undefined) return defaultInstructions;\n if (typeof this._instructionsOverride === 'string') return this._instructionsOverride;\n return this._instructionsOverride({ defaultInstructions, requestContext: opts?.requestContext });\n }\n\n async getInfo(): Promise<SandboxInfo> {\n return {\n id: this.id,\n name: this.name,\n provider: this.provider,\n status: this.status,\n createdAt: this._createdAt,\n lastUsedAt: this._lastUsedAt,\n metadata: {\n agentRuntimeArn: this._agentRuntimeArn,\n runtimeSessionId: this._runtimeSessionId,\n qualifier: this._qualifier ?? 'DEFAULT',\n stopSessionOnLifecycle: this._stopSessionOnLifecycle,\n },\n };\n }\n\n private _getDefaultInstructions(): string {\n return [\n 'AWS Bedrock AgentCore Runtime sandbox.',\n 'Commands run inside the configured AgentCore Runtime session container.',\n 'Command output streams from AgentCore Runtime as stdout and stderr.',\n 'Limitations:',\n '- Commands are one-shot and non-interactive.',\n '- There is no persistent shell session between commands.',\n '- Background process management is not exposed by this provider.',\n '- Filesystem mounts are not exposed by this provider.',\n '- Developer tools such as git, npm, Python, or Node must exist in the AgentCore container image.',\n '- AgentCore Code Interpreter is a separate service and is not part of this runtime sandbox.',\n ].join('\\n');\n }\n\n private _getClient(): AgentCoreRuntimeClient {\n if (!this._client) {\n this._client = new BedrockAgentCoreClient({ region: this._region });\n }\n return this._client;\n }\n}\n","/**\n * AWS Bedrock AgentCore Runtime sandbox provider descriptor.\n *\n * Enables registration with MastraEditor for UI-driven sandbox configuration.\n */\n\nimport type { SandboxProvider } from '@mastra/core/editor';\nimport { AgentCoreRuntimeSandbox } from './sandbox';\n\nexport interface AgentCoreRuntimeProviderConfig {\n /** AWS region for the Bedrock AgentCore client */\n region?: string;\n /** AgentCore Runtime ARN where commands should execute */\n agentRuntimeArn: string;\n /** Runtime session ID */\n runtimeSessionId?: string;\n /** Agent runtime qualifier/endpoint */\n qualifier?: string;\n /** Default command timeout in milliseconds */\n commandTimeout?: number;\n /** Stop the runtime session during stop()/destroy() */\n stopSessionOnLifecycle?: boolean;\n}\n\nexport const agentCoreRuntimeSandboxProvider: SandboxProvider<AgentCoreRuntimeProviderConfig> = {\n id: 'agentcore',\n name: 'AgentCore Runtime Sandbox',\n description: 'AWS Bedrock AgentCore Runtime command execution sandbox',\n configSchema: {\n type: 'object',\n required: ['agentRuntimeArn'],\n properties: {\n region: {\n type: 'string',\n description: 'AWS region for Bedrock AgentCore',\n },\n agentRuntimeArn: {\n type: 'string',\n description: 'AgentCore Runtime ARN',\n },\n runtimeSessionId: {\n type: 'string',\n description: 'Runtime session ID. Defaults to a generated UUID.',\n },\n qualifier: {\n type: 'string',\n description: 'Agent runtime qualifier/endpoint',\n default: 'DEFAULT',\n },\n commandTimeout: {\n type: 'number',\n description: 'Default command timeout in milliseconds. Must be between 1 and 3,600,000.',\n default: 300_000,\n minimum: 1,\n maximum: 3_600_000,\n },\n stopSessionOnLifecycle: {\n type: 'boolean',\n description: 'Stop the AgentCore Runtime session during stop()/destroy()',\n default: false,\n },\n },\n },\n createSandbox: config => new AgentCoreRuntimeSandbox(config),\n};\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,MAAM,aAAa;AACnB,MAAM,6BAA6B;AACnC,MAAM,gCAAgC;AACtC,MAAM,iBAAiB;AACvB,MAAM,uBAAuB;AA+B7B,IAAM,2BAAN,cAAuCA,uBAAAA,cAAc;CACnD,MAAe;CACf;CAEA,MAAM,OAAyB;EAC7B,OAAO;CACT;CAEA,MAAM,YAA2B;EAC/B,MAAM,IAAI,MAAM,4DAA4D;CAC9E;CAEA,MAAM,aAA4B;EAChC,MAAM,IAAIC,uBAAAA,2BAA2B,oEAAoE;CAC3G;CAEA,MAAM,OAA+B;EACnC,OAAO;GACL,SAAS,KAAK,aAAa;GAC3B,UAAU,KAAK,YAAY;GAC3B,QAAQ,KAAK;GACb,QAAQ,KAAK;GACb,iBAAiB;EACnB;CACF;AACF;AAEA,SAAS,WAAW,KAAqB;CACvC,IAAI,0BAA0B,KAAK,GAAG,GAAG,OAAO;CAChD,OAAO,IAAI,IAAI,QAAQ,MAAM,OAAO,EAAE;AACxC;AAEA,SAAS,YAAY,MAAuB;CAC1C,OAAO,2BAA2B,KAAK,IAAI;AAC7C;AAEA,SAAS,aAAa,SAAiB,MAA4B,SAAoD;CACrH,MAAM,cAAc,MAAM,SAAS,GAAG,QAAQ,GAAG,KAAK,KAAI,QAAO,WAAW,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM;CAChG,MAAM,QAAkB,CAAC;CAEzB,IAAI,SAAS,KACX,MAAM,KAAK,MAAM,WAAW,QAAQ,GAAG,GAAG;CAG5C,MAAM,MAAM,SAAS,OAAO,CAAC;CAC7B,MAAM,iBAAiB,OAAO,QAAQ,GAAG,CAAC,CACvC,QAAQ,UAAqC,MAAM,OAAO,KAAA,CAAS,CAAC,CACpE,KAAK,CAAC,KAAK,WAAW;EACrB,IAAI,CAAC,YAAY,GAAG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IACb,SAAS;IACT,SAAS;IACT,SAAS;GACX;GACA,wBAAwB;IACtB,MAAM;IACN,aAAa;IACb,SAAS;GACX;EACF;CACF;CACA,gBAAe,WAAU,IAAI,wBAAwB,MAAM;AAC7D"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from "crypto";
2
2
  import { BedrockAgentCoreClient, InvokeAgentRuntimeCommandCommand, StopRuntimeSessionCommand } from "@aws-sdk/client-bedrock-agentcore";
3
- import { MastraSandbox, ProcessHandle } from "@mastra/core/workspace";
3
+ import { MastraSandbox, ProcessHandle, UnsupportedStdinCloseError } from "@mastra/core/workspace";
4
4
  //#region src/sandbox/index.ts
5
5
  /**
6
6
  * AWS Bedrock AgentCore Runtime sandbox provider.
@@ -26,6 +26,9 @@ var CommandOutputAccumulator = class extends ProcessHandle {
26
26
  async sendStdin() {
27
27
  throw new Error("AgentCore Runtime command execution does not support stdin");
28
28
  }
29
+ async closeStdin() {
30
+ throw new UnsupportedStdinCloseError("AgentCore Runtime command execution does not support closing stdin");
31
+ }
29
32
  async wait() {
30
33
  return {
31
34
  success: this.exitCode === 0,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/sandbox/index.ts","../src/provider.ts"],"sourcesContent":["/**\n * AWS Bedrock AgentCore Runtime sandbox provider.\n *\n * This provider maps Mastra's one-shot command execution contract to\n * InvokeAgentRuntimeCommand. It intentionally does not expose process\n * management or filesystem mounts because AgentCore Runtime command execution\n * does not provide those WorkspaceSandbox semantics.\n *\n * @see https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-execute-command.html\n */\n\nimport { randomUUID } from 'node:crypto';\nimport {\n BedrockAgentCoreClient,\n InvokeAgentRuntimeCommandCommand,\n StopRuntimeSessionCommand,\n} from '@aws-sdk/client-bedrock-agentcore';\nimport type { RequestContext } from '@mastra/core/di';\nimport type {\n CommandResult,\n ExecuteCommandOptions,\n MastraSandboxOptions,\n ProviderStatus,\n SandboxInfo,\n} from '@mastra/core/workspace';\nimport { MastraSandbox, ProcessHandle } from '@mastra/core/workspace';\n\nconst LOG_PREFIX = '[AgentCoreRuntimeSandbox]';\nconst DEFAULT_COMMAND_TIMEOUT_MS = 300_000;\nconst MAX_AGENTCORE_TIMEOUT_SECONDS = 3600;\nconst DEFAULT_ACCEPT = 'application/vnd.amazon.eventstream';\nconst DEFAULT_CONTENT_TYPE = 'application/json';\n\ntype AgentCoreRuntimeClient = Pick<BedrockAgentCoreClient, 'send' | 'destroy'>;\ntype InstructionsOption = string | ((opts: { defaultInstructions: string; requestContext?: RequestContext }) => string);\ntype AgentCoreStreamException = {\n name?: string;\n message?: string;\n};\n\ntype AgentCoreStreamEvent = {\n chunk?: {\n contentStart?: unknown;\n contentDelta?: {\n stdout?: string;\n stderr?: string;\n };\n contentStop?: {\n exitCode?: number;\n status?: string;\n };\n };\n accessDeniedException?: AgentCoreStreamException;\n internalServerException?: AgentCoreStreamException;\n resourceNotFoundException?: AgentCoreStreamException;\n serviceQuotaExceededException?: AgentCoreStreamException;\n throttlingException?: AgentCoreStreamException;\n validationException?: AgentCoreStreamException;\n runtimeClientError?: AgentCoreStreamException;\n $unknown?: [string, unknown];\n};\n\nclass CommandOutputAccumulator extends ProcessHandle {\n readonly pid = 'agentcore-command';\n exitCode: number | undefined;\n\n async kill(): Promise<boolean> {\n return false;\n }\n\n async sendStdin(): Promise<void> {\n throw new Error('AgentCore Runtime command execution does not support stdin');\n }\n\n async wait(): Promise<CommandResult> {\n return {\n success: this.exitCode === 0,\n exitCode: this.exitCode ?? 1,\n stdout: this.stdout,\n stderr: this.stderr,\n executionTimeMs: 0,\n };\n }\n}\n\nfunction shellQuote(arg: string): string {\n if (/^[a-zA-Z0-9._\\-\\/=:@]+$/.test(arg)) return arg;\n return `'${arg.replace(/'/g, \"'\\\\''\")}'`;\n}\n\nfunction safeEnvName(name: string): boolean {\n return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name);\n}\n\nfunction buildCommand(command: string, args: string[] | undefined, options: ExecuteCommandOptions | undefined): string {\n const baseCommand = args?.length ? `${command} ${args.map(arg => shellQuote(arg)).join(' ')}` : command;\n const parts: string[] = [];\n\n if (options?.cwd) {\n parts.push(`cd ${shellQuote(options.cwd)}`);\n }\n\n const env = options?.env ?? {};\n const envAssignments = Object.entries(env)\n .filter((entry): entry is [string, string] => entry[1] !== undefined)\n .map(([key, value]) => {\n if (!safeEnvName(key)) {\n throw new Error(`Invalid environment variable name for AgentCore Runtime command: ${key}`);\n }\n return `${key}=${shellQuote(value)}`;\n });\n\n parts.push(`${envAssignments.length ? `${envAssignments.join(' ')} ` : ''}${baseCommand}`);\n return parts.join(' && ');\n}\n\nfunction toAgentCoreTimeoutSeconds(timeoutMs: number): number {\n if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {\n throw new RangeError('AgentCore Runtime command timeout must be a positive number of milliseconds');\n }\n\n const timeoutSeconds = Math.ceil(timeoutMs / 1000);\n if (timeoutSeconds > MAX_AGENTCORE_TIMEOUT_SECONDS) {\n throw new RangeError(`AgentCore Runtime command timeout must be at most ${MAX_AGENTCORE_TIMEOUT_SECONDS} seconds`);\n }\n\n return timeoutSeconds;\n}\n\nfunction generateSessionId(): string {\n return randomUUID();\n}\n\nfunction getStreamException(event: AgentCoreStreamEvent): { key: string; value: unknown } | undefined {\n const exceptionKeys = [\n 'accessDeniedException',\n 'internalServerException',\n 'resourceNotFoundException',\n 'serviceQuotaExceededException',\n 'throttlingException',\n 'validationException',\n 'runtimeClientError',\n ] as const;\n\n for (const key of exceptionKeys) {\n const value = event[key];\n if (value) return { key, value };\n }\n\n if (event.$unknown) {\n return { key: event.$unknown[0], value: event.$unknown[1] };\n }\n\n return undefined;\n}\n\nfunction formatStreamException(key: string, value: unknown): string {\n if (value && typeof value === 'object') {\n const exception = value as AgentCoreStreamException;\n const name = exception.name ?? key;\n return exception.message ? `${name}: ${exception.message}` : name;\n }\n\n return `${key}: ${String(value)}`;\n}\n\n// =============================================================================\n// Options\n// =============================================================================\n\nexport interface AgentCoreRuntimeSandboxOptions extends Omit<MastraSandboxOptions, 'processes'> {\n /** AWS region for the Bedrock AgentCore client. Falls back to the AWS SDK default region chain. */\n region?: string;\n /** AgentCore Runtime ARN where commands should execute. */\n agentRuntimeArn: string;\n /** Runtime session ID. Defaults to a generated UUID, which satisfies AgentCore's 33 character minimum. */\n runtimeSessionId?: string;\n /** Agent runtime qualifier/endpoint. Defaults to AWS AgentCore's DEFAULT qualifier. */\n qualifier?: string;\n /** MIME type sent for command requests. */\n contentType?: string;\n /** Accept header for command event streams. */\n accept?: string;\n /** Default command timeout in milliseconds. */\n commandTimeout?: number;\n /**\n * Stop the AgentCore Runtime session during stop()/destroy().\n *\n * Defaults to false because sessions are often shared with agent invocations\n * outside the WorkspaceSandbox instance.\n */\n stopSessionOnLifecycle?: boolean;\n /** Client token used for StopRuntimeSession. Defaults to a generated UUID when needed. */\n stopClientToken?: string;\n /** Optional preconfigured AWS SDK client, primarily for advanced credential setup and tests. */\n client?: AgentCoreRuntimeClient;\n /** Custom instructions for getInstructions(). String replaces the default; function receives it. */\n instructions?: InstructionsOption;\n}\n\n// =============================================================================\n// Implementation\n// =============================================================================\n\nexport class AgentCoreRuntimeSandbox extends MastraSandbox {\n readonly id: string;\n readonly name = 'AgentCoreRuntimeSandbox';\n readonly provider = 'agentcore';\n status: ProviderStatus = 'pending';\n\n private _client?: AgentCoreRuntimeClient;\n private readonly _ownsClient: boolean;\n private readonly _region?: string;\n private readonly _agentRuntimeArn: string;\n private readonly _runtimeSessionId: string;\n private readonly _qualifier?: string;\n private readonly _contentType: string;\n private readonly _accept: string;\n private readonly _commandTimeout: number;\n private readonly _stopSessionOnLifecycle: boolean;\n private readonly _stopClientToken?: string;\n private readonly _instructionsOverride?: InstructionsOption;\n private readonly _createdAt = new Date();\n private _lastUsedAt?: Date;\n\n constructor(options: AgentCoreRuntimeSandboxOptions) {\n super({ ...options, name: 'AgentCoreRuntimeSandbox' });\n\n if (!options.agentRuntimeArn) {\n throw new Error(`${LOG_PREFIX} agentRuntimeArn is required`);\n }\n\n this.id = options.runtimeSessionId ?? generateSessionId();\n this._agentRuntimeArn = options.agentRuntimeArn;\n this._runtimeSessionId = this.id;\n this._qualifier = options.qualifier;\n this._contentType = options.contentType ?? DEFAULT_CONTENT_TYPE;\n this._accept = options.accept ?? DEFAULT_ACCEPT;\n this._commandTimeout = options.commandTimeout ?? DEFAULT_COMMAND_TIMEOUT_MS;\n this._stopSessionOnLifecycle = options.stopSessionOnLifecycle ?? false;\n this._stopClientToken = options.stopClientToken;\n this._instructionsOverride = options.instructions;\n this._client = options.client;\n this._ownsClient = !options.client;\n this._region = options.region;\n }\n\n get runtimeSessionId(): string {\n return this._runtimeSessionId;\n }\n\n get agentRuntimeArn(): string {\n return this._agentRuntimeArn;\n }\n\n async start(): Promise<void> {\n this.logger.debug(`${LOG_PREFIX} Using AgentCore Runtime session ${this._runtimeSessionId}`);\n }\n\n async stop(): Promise<void> {\n if (!this._stopSessionOnLifecycle) return;\n await this.stopRuntimeSession();\n }\n\n async destroy(): Promise<void> {\n if (this._stopSessionOnLifecycle) {\n await this.stopRuntimeSession();\n }\n\n if (this._ownsClient && this._client) {\n this._client.destroy();\n this._client = undefined;\n }\n }\n\n /**\n * Explicitly stops the AgentCore Runtime session used by this sandbox.\n *\n * This is separate from destroy() because AgentCore Runtime sessions can be\n * shared with agent invocations outside the WorkspaceSandbox lifecycle.\n */\n async stopRuntimeSession(): Promise<void> {\n await this._getClient().send(\n new StopRuntimeSessionCommand({\n agentRuntimeArn: this._agentRuntimeArn,\n runtimeSessionId: this._runtimeSessionId,\n qualifier: this._qualifier,\n clientToken: this._stopClientToken ?? generateSessionId(),\n }),\n );\n }\n\n async executeCommand(command: string, args?: string[], options?: ExecuteCommandOptions): Promise<CommandResult> {\n await this.ensureRunning();\n\n const fullCommand = buildCommand(command, args, options);\n const timeoutMs = options?.timeout ?? this._commandTimeout;\n const timeoutSeconds = toAgentCoreTimeoutSeconds(timeoutMs);\n const startTime = Date.now();\n const output = new CommandOutputAccumulator({\n maxRetainedBytes: options?.maxRetainedBytes ?? Infinity,\n onStdout: options?.onStdout,\n onStderr: options?.onStderr,\n });\n let stopStatus: string | undefined;\n\n this.logger.debug(`${LOG_PREFIX} Executing command`, {\n runtimeSessionId: this._runtimeSessionId,\n command: fullCommand,\n timeoutSeconds,\n });\n\n const response = await this._getClient().send(\n new InvokeAgentRuntimeCommandCommand({\n agentRuntimeArn: this._agentRuntimeArn,\n runtimeSessionId: this._runtimeSessionId,\n qualifier: this._qualifier,\n contentType: this._contentType,\n accept: this._accept,\n body: {\n command: fullCommand,\n timeout: timeoutSeconds,\n },\n }),\n { abortSignal: options?.abortSignal },\n );\n\n for await (const event of response.stream ?? []) {\n const streamEvent = event as AgentCoreStreamEvent;\n const streamException = getStreamException(streamEvent);\n if (streamException) {\n throw new Error(`${LOG_PREFIX} ${formatStreamException(streamException.key, streamException.value)}`);\n }\n\n const chunk = streamEvent.chunk;\n if (!chunk) continue;\n\n if (chunk.contentDelta?.stdout) {\n output.emitStdout(chunk.contentDelta.stdout);\n }\n\n if (chunk.contentDelta?.stderr) {\n output.emitStderr(chunk.contentDelta.stderr);\n }\n\n if (chunk.contentStop) {\n output.exitCode = chunk.contentStop.exitCode ?? 1;\n stopStatus = chunk.contentStop.status;\n }\n }\n\n const executionTimeMs = Date.now() - startTime;\n const exitCode = output.exitCode ?? 1;\n const timedOut = stopStatus === 'TIMED_OUT';\n const finalExitCode = timedOut ? 124 : exitCode;\n this._lastUsedAt = new Date();\n\n return {\n command: fullCommand,\n args,\n success: finalExitCode === 0 && !timedOut,\n exitCode: finalExitCode,\n stdout: output.stdout,\n stderr: output.stderr,\n executionTimeMs,\n timedOut,\n stdoutTruncated: output.stdoutTruncated,\n stderrTruncated: output.stderrTruncated,\n stdoutDroppedBytes: output.stdoutDroppedBytes,\n stderrDroppedBytes: output.stderrDroppedBytes,\n };\n }\n\n getInstructions(opts?: { requestContext?: RequestContext }): string {\n const defaultInstructions = this._getDefaultInstructions();\n if (this._instructionsOverride === undefined) return defaultInstructions;\n if (typeof this._instructionsOverride === 'string') return this._instructionsOverride;\n return this._instructionsOverride({ defaultInstructions, requestContext: opts?.requestContext });\n }\n\n async getInfo(): Promise<SandboxInfo> {\n return {\n id: this.id,\n name: this.name,\n provider: this.provider,\n status: this.status,\n createdAt: this._createdAt,\n lastUsedAt: this._lastUsedAt,\n metadata: {\n agentRuntimeArn: this._agentRuntimeArn,\n runtimeSessionId: this._runtimeSessionId,\n qualifier: this._qualifier ?? 'DEFAULT',\n stopSessionOnLifecycle: this._stopSessionOnLifecycle,\n },\n };\n }\n\n private _getDefaultInstructions(): string {\n return [\n 'AWS Bedrock AgentCore Runtime sandbox.',\n 'Commands run inside the configured AgentCore Runtime session container.',\n 'Command output streams from AgentCore Runtime as stdout and stderr.',\n 'Limitations:',\n '- Commands are one-shot and non-interactive.',\n '- There is no persistent shell session between commands.',\n '- Background process management is not exposed by this provider.',\n '- Filesystem mounts are not exposed by this provider.',\n '- Developer tools such as git, npm, Python, or Node must exist in the AgentCore container image.',\n '- AgentCore Code Interpreter is a separate service and is not part of this runtime sandbox.',\n ].join('\\n');\n }\n\n private _getClient(): AgentCoreRuntimeClient {\n if (!this._client) {\n this._client = new BedrockAgentCoreClient({ region: this._region });\n }\n return this._client;\n }\n}\n","/**\n * AWS Bedrock AgentCore Runtime sandbox provider descriptor.\n *\n * Enables registration with MastraEditor for UI-driven sandbox configuration.\n */\n\nimport type { SandboxProvider } from '@mastra/core/editor';\nimport { AgentCoreRuntimeSandbox } from './sandbox';\n\nexport interface AgentCoreRuntimeProviderConfig {\n /** AWS region for the Bedrock AgentCore client */\n region?: string;\n /** AgentCore Runtime ARN where commands should execute */\n agentRuntimeArn: string;\n /** Runtime session ID */\n runtimeSessionId?: string;\n /** Agent runtime qualifier/endpoint */\n qualifier?: string;\n /** Default command timeout in milliseconds */\n commandTimeout?: number;\n /** Stop the runtime session during stop()/destroy() */\n stopSessionOnLifecycle?: boolean;\n}\n\nexport const agentCoreRuntimeSandboxProvider: SandboxProvider<AgentCoreRuntimeProviderConfig> = {\n id: 'agentcore',\n name: 'AgentCore Runtime Sandbox',\n description: 'AWS Bedrock AgentCore Runtime command execution sandbox',\n configSchema: {\n type: 'object',\n required: ['agentRuntimeArn'],\n properties: {\n region: {\n type: 'string',\n description: 'AWS region for Bedrock AgentCore',\n },\n agentRuntimeArn: {\n type: 'string',\n description: 'AgentCore Runtime ARN',\n },\n runtimeSessionId: {\n type: 'string',\n description: 'Runtime session ID. Defaults to a generated UUID.',\n },\n qualifier: {\n type: 'string',\n description: 'Agent runtime qualifier/endpoint',\n default: 'DEFAULT',\n },\n commandTimeout: {\n type: 'number',\n description: 'Default command timeout in milliseconds. Must be between 1 and 3,600,000.',\n default: 300_000,\n minimum: 1,\n maximum: 3_600_000,\n },\n stopSessionOnLifecycle: {\n type: 'boolean',\n description: 'Stop the AgentCore Runtime session during stop()/destroy()',\n default: false,\n },\n },\n },\n createSandbox: config => new AgentCoreRuntimeSandbox(config),\n};\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAM,aAAa;AACnB,MAAM,6BAA6B;AACnC,MAAM,gCAAgC;AACtC,MAAM,iBAAiB;AACvB,MAAM,uBAAuB;AA+B7B,IAAM,2BAAN,cAAuC,cAAc;CACnD,MAAe;CACf;CAEA,MAAM,OAAyB;EAC7B,OAAO;CACT;CAEA,MAAM,YAA2B;EAC/B,MAAM,IAAI,MAAM,4DAA4D;CAC9E;CAEA,MAAM,OAA+B;EACnC,OAAO;GACL,SAAS,KAAK,aAAa;GAC3B,UAAU,KAAK,YAAY;GAC3B,QAAQ,KAAK;GACb,QAAQ,KAAK;GACb,iBAAiB;EACnB;CACF;AACF;AAEA,SAAS,WAAW,KAAqB;CACvC,IAAI,0BAA0B,KAAK,GAAG,GAAG,OAAO;CAChD,OAAO,IAAI,IAAI,QAAQ,MAAM,OAAO,EAAE;AACxC;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,aAA6C;EAC3C,IAAI,CAAC,KAAK,SACR,KAAK,UAAU,IAAI,uBAAuB,EAAE,QAAQ,KAAK,QAAQ,CAAC;EAEpE,OAAO,KAAK;CACd;AACF;;;AC1YA,MAAa,kCAAmF;CAC9F,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;EACZ,MAAM;EACN,UAAU,CAAC,iBAAiB;EAC5B,YAAY;GACV,QAAQ;IACN,MAAM;IACN,aAAa;GACf;GACA,iBAAiB;IACf,MAAM;IACN,aAAa;GACf;GACA,kBAAkB;IAChB,MAAM;IACN,aAAa;GACf;GACA,WAAW;IACT,MAAM;IACN,aAAa;IACb,SAAS;GACX;GACA,gBAAgB;IACd,MAAM;IACN,aAAa;IACb,SAAS;IACT,SAAS;IACT,SAAS;GACX;GACA,wBAAwB;IACtB,MAAM;IACN,aAAa;IACb,SAAS;GACX;EACF;CACF;CACA,gBAAe,WAAU,IAAI,wBAAwB,MAAM;AAC7D"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/sandbox/index.ts","../src/provider.ts"],"sourcesContent":["/**\n * AWS Bedrock AgentCore Runtime sandbox provider.\n *\n * This provider maps Mastra's one-shot command execution contract to\n * InvokeAgentRuntimeCommand. It intentionally does not expose process\n * management or filesystem mounts because AgentCore Runtime command execution\n * does not provide those WorkspaceSandbox semantics.\n *\n * @see https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-execute-command.html\n */\n\nimport { randomUUID } from 'node:crypto';\nimport {\n BedrockAgentCoreClient,\n InvokeAgentRuntimeCommandCommand,\n StopRuntimeSessionCommand,\n} from '@aws-sdk/client-bedrock-agentcore';\nimport type { RequestContext } from '@mastra/core/di';\nimport type {\n CommandResult,\n ExecuteCommandOptions,\n MastraSandboxOptions,\n ProviderStatus,\n SandboxInfo,\n} from '@mastra/core/workspace';\nimport { MastraSandbox, ProcessHandle, UnsupportedStdinCloseError } from '@mastra/core/workspace';\n\nconst LOG_PREFIX = '[AgentCoreRuntimeSandbox]';\nconst DEFAULT_COMMAND_TIMEOUT_MS = 300_000;\nconst MAX_AGENTCORE_TIMEOUT_SECONDS = 3600;\nconst DEFAULT_ACCEPT = 'application/vnd.amazon.eventstream';\nconst DEFAULT_CONTENT_TYPE = 'application/json';\n\ntype AgentCoreRuntimeClient = Pick<BedrockAgentCoreClient, 'send' | 'destroy'>;\ntype InstructionsOption = string | ((opts: { defaultInstructions: string; requestContext?: RequestContext }) => string);\ntype AgentCoreStreamException = {\n name?: string;\n message?: string;\n};\n\ntype AgentCoreStreamEvent = {\n chunk?: {\n contentStart?: unknown;\n contentDelta?: {\n stdout?: string;\n stderr?: string;\n };\n contentStop?: {\n exitCode?: number;\n status?: string;\n };\n };\n accessDeniedException?: AgentCoreStreamException;\n internalServerException?: AgentCoreStreamException;\n resourceNotFoundException?: AgentCoreStreamException;\n serviceQuotaExceededException?: AgentCoreStreamException;\n throttlingException?: AgentCoreStreamException;\n validationException?: AgentCoreStreamException;\n runtimeClientError?: AgentCoreStreamException;\n $unknown?: [string, unknown];\n};\n\nclass CommandOutputAccumulator extends ProcessHandle {\n readonly pid = 'agentcore-command';\n exitCode: number | undefined;\n\n async kill(): Promise<boolean> {\n return false;\n }\n\n async sendStdin(): Promise<void> {\n throw new Error('AgentCore Runtime command execution does not support stdin');\n }\n\n async closeStdin(): Promise<void> {\n throw new UnsupportedStdinCloseError('AgentCore Runtime command execution does not support closing stdin');\n }\n\n async wait(): Promise<CommandResult> {\n return {\n success: this.exitCode === 0,\n exitCode: this.exitCode ?? 1,\n stdout: this.stdout,\n stderr: this.stderr,\n executionTimeMs: 0,\n };\n }\n}\n\nfunction shellQuote(arg: string): string {\n if (/^[a-zA-Z0-9._\\-\\/=:@]+$/.test(arg)) return arg;\n return `'${arg.replace(/'/g, \"'\\\\''\")}'`;\n}\n\nfunction safeEnvName(name: string): boolean {\n return /^[A-Za-z_][A-Za-z0-9_]*$/.test(name);\n}\n\nfunction buildCommand(command: string, args: string[] | undefined, options: ExecuteCommandOptions | undefined): string {\n const baseCommand = args?.length ? `${command} ${args.map(arg => shellQuote(arg)).join(' ')}` : command;\n const parts: string[] = [];\n\n if (options?.cwd) {\n parts.push(`cd ${shellQuote(options.cwd)}`);\n }\n\n const env = options?.env ?? {};\n const envAssignments = Object.entries(env)\n .filter((entry): entry is [string, string] => entry[1] !== undefined)\n .map(([key, value]) => {\n if (!safeEnvName(key)) {\n throw new Error(`Invalid environment variable name for AgentCore Runtime command: ${key}`);\n }\n return `${key}=${shellQuote(value)}`;\n });\n\n parts.push(`${envAssignments.length ? `${envAssignments.join(' ')} ` : ''}${baseCommand}`);\n return parts.join(' && ');\n}\n\nfunction toAgentCoreTimeoutSeconds(timeoutMs: number): number {\n if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {\n throw new RangeError('AgentCore Runtime command timeout must be a positive number of milliseconds');\n }\n\n const timeoutSeconds = Math.ceil(timeoutMs / 1000);\n if (timeoutSeconds > MAX_AGENTCORE_TIMEOUT_SECONDS) {\n throw new RangeError(`AgentCore Runtime command timeout must be at most ${MAX_AGENTCORE_TIMEOUT_SECONDS} seconds`);\n }\n\n return timeoutSeconds;\n}\n\nfunction generateSessionId(): string {\n return randomUUID();\n}\n\nfunction getStreamException(event: AgentCoreStreamEvent): { key: string; value: unknown } | undefined {\n const exceptionKeys = [\n 'accessDeniedException',\n 'internalServerException',\n 'resourceNotFoundException',\n 'serviceQuotaExceededException',\n 'throttlingException',\n 'validationException',\n 'runtimeClientError',\n ] as const;\n\n for (const key of exceptionKeys) {\n const value = event[key];\n if (value) return { key, value };\n }\n\n if (event.$unknown) {\n return { key: event.$unknown[0], value: event.$unknown[1] };\n }\n\n return undefined;\n}\n\nfunction formatStreamException(key: string, value: unknown): string {\n if (value && typeof value === 'object') {\n const exception = value as AgentCoreStreamException;\n const name = exception.name ?? key;\n return exception.message ? `${name}: ${exception.message}` : name;\n }\n\n return `${key}: ${String(value)}`;\n}\n\n// =============================================================================\n// Options\n// =============================================================================\n\nexport interface AgentCoreRuntimeSandboxOptions extends Omit<MastraSandboxOptions, 'processes'> {\n /** AWS region for the Bedrock AgentCore client. Falls back to the AWS SDK default region chain. */\n region?: string;\n /** AgentCore Runtime ARN where commands should execute. */\n agentRuntimeArn: string;\n /** Runtime session ID. Defaults to a generated UUID, which satisfies AgentCore's 33 character minimum. */\n runtimeSessionId?: string;\n /** Agent runtime qualifier/endpoint. Defaults to AWS AgentCore's DEFAULT qualifier. */\n qualifier?: string;\n /** MIME type sent for command requests. */\n contentType?: string;\n /** Accept header for command event streams. */\n accept?: string;\n /** Default command timeout in milliseconds. */\n commandTimeout?: number;\n /**\n * Stop the AgentCore Runtime session during stop()/destroy().\n *\n * Defaults to false because sessions are often shared with agent invocations\n * outside the WorkspaceSandbox instance.\n */\n stopSessionOnLifecycle?: boolean;\n /** Client token used for StopRuntimeSession. Defaults to a generated UUID when needed. */\n stopClientToken?: string;\n /** Optional preconfigured AWS SDK client, primarily for advanced credential setup and tests. */\n client?: AgentCoreRuntimeClient;\n /** Custom instructions for getInstructions(). String replaces the default; function receives it. */\n instructions?: InstructionsOption;\n}\n\n// =============================================================================\n// Implementation\n// =============================================================================\n\nexport class AgentCoreRuntimeSandbox extends MastraSandbox {\n readonly id: string;\n readonly name = 'AgentCoreRuntimeSandbox';\n readonly provider = 'agentcore';\n status: ProviderStatus = 'pending';\n\n private _client?: AgentCoreRuntimeClient;\n private readonly _ownsClient: boolean;\n private readonly _region?: string;\n private readonly _agentRuntimeArn: string;\n private readonly _runtimeSessionId: string;\n private readonly _qualifier?: string;\n private readonly _contentType: string;\n private readonly _accept: string;\n private readonly _commandTimeout: number;\n private readonly _stopSessionOnLifecycle: boolean;\n private readonly _stopClientToken?: string;\n private readonly _instructionsOverride?: InstructionsOption;\n private readonly _createdAt = new Date();\n private _lastUsedAt?: Date;\n\n constructor(options: AgentCoreRuntimeSandboxOptions) {\n super({ ...options, name: 'AgentCoreRuntimeSandbox' });\n\n if (!options.agentRuntimeArn) {\n throw new Error(`${LOG_PREFIX} agentRuntimeArn is required`);\n }\n\n this.id = options.runtimeSessionId ?? generateSessionId();\n this._agentRuntimeArn = options.agentRuntimeArn;\n this._runtimeSessionId = this.id;\n this._qualifier = options.qualifier;\n this._contentType = options.contentType ?? DEFAULT_CONTENT_TYPE;\n this._accept = options.accept ?? DEFAULT_ACCEPT;\n this._commandTimeout = options.commandTimeout ?? DEFAULT_COMMAND_TIMEOUT_MS;\n this._stopSessionOnLifecycle = options.stopSessionOnLifecycle ?? false;\n this._stopClientToken = options.stopClientToken;\n this._instructionsOverride = options.instructions;\n this._client = options.client;\n this._ownsClient = !options.client;\n this._region = options.region;\n }\n\n get runtimeSessionId(): string {\n return this._runtimeSessionId;\n }\n\n get agentRuntimeArn(): string {\n return this._agentRuntimeArn;\n }\n\n async start(): Promise<void> {\n this.logger.debug(`${LOG_PREFIX} Using AgentCore Runtime session ${this._runtimeSessionId}`);\n }\n\n async stop(): Promise<void> {\n if (!this._stopSessionOnLifecycle) return;\n await this.stopRuntimeSession();\n }\n\n async destroy(): Promise<void> {\n if (this._stopSessionOnLifecycle) {\n await this.stopRuntimeSession();\n }\n\n if (this._ownsClient && this._client) {\n this._client.destroy();\n this._client = undefined;\n }\n }\n\n /**\n * Explicitly stops the AgentCore Runtime session used by this sandbox.\n *\n * This is separate from destroy() because AgentCore Runtime sessions can be\n * shared with agent invocations outside the WorkspaceSandbox lifecycle.\n */\n async stopRuntimeSession(): Promise<void> {\n await this._getClient().send(\n new StopRuntimeSessionCommand({\n agentRuntimeArn: this._agentRuntimeArn,\n runtimeSessionId: this._runtimeSessionId,\n qualifier: this._qualifier,\n clientToken: this._stopClientToken ?? generateSessionId(),\n }),\n );\n }\n\n async executeCommand(command: string, args?: string[], options?: ExecuteCommandOptions): Promise<CommandResult> {\n await this.ensureRunning();\n\n const fullCommand = buildCommand(command, args, options);\n const timeoutMs = options?.timeout ?? this._commandTimeout;\n const timeoutSeconds = toAgentCoreTimeoutSeconds(timeoutMs);\n const startTime = Date.now();\n const output = new CommandOutputAccumulator({\n maxRetainedBytes: options?.maxRetainedBytes ?? Infinity,\n onStdout: options?.onStdout,\n onStderr: options?.onStderr,\n });\n let stopStatus: string | undefined;\n\n this.logger.debug(`${LOG_PREFIX} Executing command`, {\n runtimeSessionId: this._runtimeSessionId,\n command: fullCommand,\n timeoutSeconds,\n });\n\n const response = await this._getClient().send(\n new InvokeAgentRuntimeCommandCommand({\n agentRuntimeArn: this._agentRuntimeArn,\n runtimeSessionId: this._runtimeSessionId,\n qualifier: this._qualifier,\n contentType: this._contentType,\n accept: this._accept,\n body: {\n command: fullCommand,\n timeout: timeoutSeconds,\n },\n }),\n { abortSignal: options?.abortSignal },\n );\n\n for await (const event of response.stream ?? []) {\n const streamEvent = event as AgentCoreStreamEvent;\n const streamException = getStreamException(streamEvent);\n if (streamException) {\n throw new Error(`${LOG_PREFIX} ${formatStreamException(streamException.key, streamException.value)}`);\n }\n\n const chunk = streamEvent.chunk;\n if (!chunk) continue;\n\n if (chunk.contentDelta?.stdout) {\n output.emitStdout(chunk.contentDelta.stdout);\n }\n\n if (chunk.contentDelta?.stderr) {\n output.emitStderr(chunk.contentDelta.stderr);\n }\n\n if (chunk.contentStop) {\n output.exitCode = chunk.contentStop.exitCode ?? 1;\n stopStatus = chunk.contentStop.status;\n }\n }\n\n const executionTimeMs = Date.now() - startTime;\n const exitCode = output.exitCode ?? 1;\n const timedOut = stopStatus === 'TIMED_OUT';\n const finalExitCode = timedOut ? 124 : exitCode;\n this._lastUsedAt = new Date();\n\n return {\n command: fullCommand,\n args,\n success: finalExitCode === 0 && !timedOut,\n exitCode: finalExitCode,\n stdout: output.stdout,\n stderr: output.stderr,\n executionTimeMs,\n timedOut,\n stdoutTruncated: output.stdoutTruncated,\n stderrTruncated: output.stderrTruncated,\n stdoutDroppedBytes: output.stdoutDroppedBytes,\n stderrDroppedBytes: output.stderrDroppedBytes,\n };\n }\n\n getInstructions(opts?: { requestContext?: RequestContext }): string {\n const defaultInstructions = this._getDefaultInstructions();\n if (this._instructionsOverride === undefined) return defaultInstructions;\n if (typeof this._instructionsOverride === 'string') return this._instructionsOverride;\n return this._instructionsOverride({ defaultInstructions, requestContext: opts?.requestContext });\n }\n\n async getInfo(): Promise<SandboxInfo> {\n return {\n id: this.id,\n name: this.name,\n provider: this.provider,\n status: this.status,\n createdAt: this._createdAt,\n lastUsedAt: this._lastUsedAt,\n metadata: {\n agentRuntimeArn: this._agentRuntimeArn,\n runtimeSessionId: this._runtimeSessionId,\n qualifier: this._qualifier ?? 'DEFAULT',\n stopSessionOnLifecycle: this._stopSessionOnLifecycle,\n },\n };\n }\n\n private _getDefaultInstructions(): string {\n return [\n 'AWS Bedrock AgentCore Runtime sandbox.',\n 'Commands run inside the configured AgentCore Runtime session container.',\n 'Command output streams from AgentCore Runtime as stdout and stderr.',\n 'Limitations:',\n '- Commands are one-shot and non-interactive.',\n '- There is no persistent shell session between commands.',\n '- Background process management is not exposed by this provider.',\n '- Filesystem mounts are not exposed by this provider.',\n '- Developer tools such as git, npm, Python, or Node must exist in the AgentCore container image.',\n '- AgentCore Code Interpreter is a separate service and is not part of this runtime sandbox.',\n ].join('\\n');\n }\n\n private _getClient(): AgentCoreRuntimeClient {\n if (!this._client) {\n this._client = new BedrockAgentCoreClient({ region: this._region });\n }\n return this._client;\n }\n}\n","/**\n * AWS Bedrock AgentCore Runtime sandbox provider descriptor.\n *\n * Enables registration with MastraEditor for UI-driven sandbox configuration.\n */\n\nimport type { SandboxProvider } from '@mastra/core/editor';\nimport { AgentCoreRuntimeSandbox } from './sandbox';\n\nexport interface AgentCoreRuntimeProviderConfig {\n /** AWS region for the Bedrock AgentCore client */\n region?: string;\n /** AgentCore Runtime ARN where commands should execute */\n agentRuntimeArn: string;\n /** Runtime session ID */\n runtimeSessionId?: string;\n /** Agent runtime qualifier/endpoint */\n qualifier?: string;\n /** Default command timeout in milliseconds */\n commandTimeout?: number;\n /** Stop the runtime session during stop()/destroy() */\n stopSessionOnLifecycle?: boolean;\n}\n\nexport const agentCoreRuntimeSandboxProvider: SandboxProvider<AgentCoreRuntimeProviderConfig> = {\n id: 'agentcore',\n name: 'AgentCore Runtime Sandbox',\n description: 'AWS Bedrock AgentCore Runtime command execution sandbox',\n configSchema: {\n type: 'object',\n required: ['agentRuntimeArn'],\n properties: {\n region: {\n type: 'string',\n description: 'AWS region for Bedrock AgentCore',\n },\n agentRuntimeArn: {\n type: 'string',\n description: 'AgentCore Runtime ARN',\n },\n runtimeSessionId: {\n type: 'string',\n description: 'Runtime session ID. Defaults to a generated UUID.',\n },\n qualifier: {\n type: 'string',\n description: 'Agent runtime qualifier/endpoint',\n default: 'DEFAULT',\n },\n commandTimeout: {\n type: 'number',\n description: 'Default command timeout in milliseconds. Must be between 1 and 3,600,000.',\n default: 300_000,\n minimum: 1,\n maximum: 3_600_000,\n },\n stopSessionOnLifecycle: {\n type: 'boolean',\n description: 'Stop the AgentCore Runtime session during stop()/destroy()',\n default: false,\n },\n },\n },\n createSandbox: config => new AgentCoreRuntimeSandbox(config),\n};\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAM,aAAa;AACnB,MAAM,6BAA6B;AACnC,MAAM,gCAAgC;AACtC,MAAM,iBAAiB;AACvB,MAAM,uBAAuB;AA+B7B,IAAM,2BAAN,cAAuC,cAAc;CACnD,MAAe;CACf;CAEA,MAAM,OAAyB;EAC7B,OAAO;CACT;CAEA,MAAM,YAA2B;EAC/B,MAAM,IAAI,MAAM,4DAA4D;CAC9E;CAEA,MAAM,aAA4B;EAChC,MAAM,IAAI,2BAA2B,oEAAoE;CAC3G;CAEA,MAAM,OAA+B;EACnC,OAAO;GACL,SAAS,KAAK,aAAa;GAC3B,UAAU,KAAK,YAAY;GAC3B,QAAQ,KAAK;GACb,QAAQ,KAAK;GACb,iBAAiB;EACnB;CACF;AACF;AAEA,SAAS,WAAW,KAAqB;CACvC,IAAI,0BAA0B,KAAK,GAAG,GAAG,OAAO;CAChD,OAAO,IAAI,IAAI,QAAQ,MAAM,OAA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AAI;CACb;CAEA,aAA6C;EAC3C,IAAI,CAAC,KAAK,SACR,KAAK,UAAU,IAAI,uBAAuB,EAAE,QAAQ,KAAK,QAAQ,CAAC;EAEpE,OAAO,KAAK;CACd;AACF;;;AC9YA,MAAa,kCAAmF;CAC9F,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;EACZ,MAAM;EACN,UAAU,CAAC,iBAAiB;EAC5B,YAAY;GACV,QAAQ;IACN,MAAM;IACN,aAAa;GACf;GACA,iBAAiB;IACf,MAAM;IACN,aAAa;GACf;GACA,kBAAkB;IAChB,MAAM;IACN,aAAa;GACf;GACA,WAAW;IACT,MAAM;IACN,aAAa;IACb,SAAS;GACX;GACA,gBAAgB;IACd,MAAM;IACN,aAAa;IACb,SAAS;IACT,SAAS;IACT,SAAS;GACX;GACA,wBAAwB;IACtB,MAAM;IACN,aAAa;IACb,SAAS;GACX;EACF;CACF;CACA,gBAAe,WAAU,IAAI,wBAAwB,MAAM;AAC7D"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,sBAAsB,EAGvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAiB,MAAM,wBAAwB,CAAC;AAQtE,KAAK,sBAAsB,GAAG,IAAI,CAAC,sBAAsB,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAC/E,KAAK,kBAAkB,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE;IAAE,mBAAmB,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,cAAc,CAAA;CAAE,KAAK,MAAM,CAAC,CAAC;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Runtime sandbox provider for Mastra workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -31,9 +31,9 @@
31
31
  "tsdown": "0.22.9",
32
32
  "typescript": "^6.0.3",
33
33
  "vitest": "4.1.10",
34
- "@internal/lint": "0.0.122",
35
- "@mastra/core": "1.58.0",
36
- "@internal/types-builder": "0.0.97"
34
+ "@internal/lint": "0.0.123",
35
+ "@internal/types-builder": "0.0.98",
36
+ "@mastra/core": "1.60.0-alpha.8"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@mastra/core": ">=1.12.0-0 <2.0.0-0"