The Compute Manager is responsible for secure code execution. It provides an abstraction layer for running untrusted or dynamic code in isolated environments (sandboxes).
The Code Service allows agents to prepare, deploy, and execute code snippets. It supports different runtime environments and enforces resource limits and security policies.
ICodeConnectorConnectorService.getCodeConnector()ECMASandboxThe CodeConnector extends SecureConnector and provides methods for managing the code execution lifecycle.
prepare(codeUID: string, input: CodeInput, config: CodeConfig): Promise<CodePreparationResult>: Prepares code for execution (e.g., validation, dependency resolution).deploy(codeUID: string, input: CodeInput, config: CodeConfig): Promise<CodeDeployment>: Deploys the code (e.g., to a serverless function).execute(codeUID: string, inputs: Record<string, any>, config: CodeConfig): Promise<CodeExecutionResult>: Executes the code with provided inputs.executeDeployment(codeUID: string, deploymentId: string, inputs: Record<string, any>, config: CodeConfig): Promise<CodeExecutionResult>: Executes a previously deployed function.The ECMASandbox connector executes JavaScript/TypeScript code in an isolated environment. It can run locally using Node.js's vm module or connect to a remote sandbox service.
sandboxUrl (optional) - URL of the remote sandbox service.The AWSLambda connector deploys and executes code as AWS Lambda functions. This is suitable for production environments requiring high scalability and isolation.
region, accessKeyId, secretAccessKeyTo configure the Code Service, add a Code entry to the SRE configuration:
SRE.init({
Code: {
Connector: 'ECMASandbox',
Settings: {
// sandboxUrl: 'http://localhost:3000' // Optional remote sandbox
},
},
});
The CodeService is primarily used by specific Agent Components that require dynamic code execution, such as:
Note: Do not confuse the CodeService with "Agent Skills". Agent Skills (defined via the SDK) are typically standard API endpoints or internal functions executed within the Agent's main runtime context. The CodeService is specifically for isolated, sandboxed execution of arbitrary code logic.