The Code Connector manages the secure execution of code snippets. It abstracts the underlying runtime environment, whether it's a local sandbox or a cloud function.
ICodeRequestprepare(codeUID, input, config)Prepares code for execution. This might involves compiling, validating, or resolving dependencies.
string - Unique identifier for the code.CodeInput - Contains source code and dependencies.CodeConfig - Runtime configuration (e.g., 'nodejs', timeout).Promise<CodePreparationResult>execute(codeUID, inputs, config)Executes code immediately.
Record<string, any> - Arguments to pass to the code.Promise<CodeExecutionResult>deploy(codeUID, input, config)Deploys the code for future execution (e.g., creating a Lambda function).
Promise<CodeDeployment>executeDeployment(codeUID, deploymentId, inputs, config)Executes a previously deployed function.
string - ID of the deployment.Promise<CodeExecutionResult>Executes JavaScript/TypeScript in an isolated VM or remote sandbox service.
sandboxUrl: Optional URL for remote execution.Deploys and executes code as AWS Lambda functions.
region: AWS Region.accessKeyId: AWS Access Key.secretAccessKey: AWS Secret Key.const codeService = ConnectorService.getCodeConnector().requester(candidate);
const result = await codeService.execute('script-1', {
code: 'export default async ({ name }) => `Hello ${name}`;',
inputs: { name: 'World' }
}, { runtime: 'nodejs' });
console.log(result.output); // "Hello World"