Skip to main content

Class: CodeSandbox

Defined in: packages/agentos/src/safety/sandbox/executor/CodeSandbox.ts:157

Code Execution Sandbox implementation.

Provides isolated code execution with security controls.

Implements

Constructors

Constructor

new CodeSandbox(defaultConfig?): CodeSandbox

Defined in: packages/agentos/src/safety/sandbox/executor/CodeSandbox.ts:164

Parameters

defaultConfig?

Partial<SandboxConfig>

Returns

CodeSandbox

Methods

dispose()

dispose(): Promise<void>

Defined in: packages/agentos/src/safety/sandbox/executor/CodeSandbox.ts:694

Disposes of the sandbox.

Returns

Promise<void>

Implementation of

ICodeSandbox.dispose


execute()

execute(request): Promise<ExecutionResult>

Defined in: packages/agentos/src/safety/sandbox/executor/CodeSandbox.ts:183

Executes code in the sandbox.

Parameters

request

ExecutionRequest

Returns

Promise<ExecutionResult>

Implementation of

ICodeSandbox.execute


getExecution()

getExecution(executionId): Promise<ExecutionResult | undefined>

Defined in: packages/agentos/src/safety/sandbox/executor/CodeSandbox.ts:628

Gets the status of an execution.

Parameters

executionId

string

Returns

Promise<ExecutionResult | undefined>

Implementation of

ICodeSandbox.getExecution


getStats()

getStats(): SandboxStats

Defined in: packages/agentos/src/safety/sandbox/executor/CodeSandbox.ts:658

Gets sandbox statistics.

Returns

SandboxStats

Implementation of

ICodeSandbox.getStats


getSupportedLanguages()

getSupportedLanguages(): SandboxLanguage[]

Defined in: packages/agentos/src/safety/sandbox/executor/CodeSandbox.ts:651

Gets supported languages.

Returns

SandboxLanguage[]

Implementation of

ICodeSandbox.getSupportedLanguages


initialize()

initialize(logger?, defaultConfig?): Promise<void>

Defined in: packages/agentos/src/safety/sandbox/executor/CodeSandbox.ts:172

Initializes the sandbox.

Parameters

logger?

ILogger

defaultConfig?

SandboxConfig

Returns

Promise<void>

Implementation of

ICodeSandbox.initialize


isLanguageSupported()

isLanguageSupported(language): boolean

Defined in: packages/agentos/src/safety/sandbox/executor/CodeSandbox.ts:644

Checks if a language is supported.

Parameters

language

string

Returns

boolean

Implementation of

ICodeSandbox.isLanguageSupported


kill()

kill(executionId): Promise<boolean>

Defined in: packages/agentos/src/safety/sandbox/executor/CodeSandbox.ts:611

Kills a running execution.

Parameters

executionId

string

Returns

Promise<boolean>

Implementation of

ICodeSandbox.kill


listExecutions()

listExecutions(limit?): Promise<ExecutionResult[]>

Defined in: packages/agentos/src/safety/sandbox/executor/CodeSandbox.ts:635

Lists recent executions.

Parameters

limit?

number = 50

Returns

Promise<ExecutionResult[]>

Implementation of

ICodeSandbox.listExecutions


resetStats()

resetStats(): void

Defined in: packages/agentos/src/safety/sandbox/executor/CodeSandbox.ts:665

Resets statistics.

Returns

void

Implementation of

ICodeSandbox.resetStats


validateCode()

validateCode(language, code): SecurityEvent[]

Defined in: packages/agentos/src/safety/sandbox/executor/CodeSandbox.ts:672

Validates code for security issues.

Parameters

language

SandboxLanguage

code

string

Returns

SecurityEvent[]

Implementation of

ICodeSandbox.validateCode