--- title: "Interpreter" hideTitleOnPage: true --- ## InterpreterContext **Properties**: - `id` _string_ - `language` _string_ - `sandboxId` _string_ - `#transport` _HttpTransport_ - `#executionQueue` _ContextExecutionQueue_ - `#onClose` _() =\> Promise\_ ### Constructors #### Constructor ```ts new InterpreterContext( transport: HttpTransport, sandboxId: string, id: string, language: string, executionQueue: ContextExecutionQueue, onClose: () => Promise): InterpreterContext; ``` **Parameters**: - `transport` _HttpTransport_ - `sandboxId` _string_ - `id` _string_ - `language` _string_ - `executionQueue` _ContextExecutionQueue_ - `onClose` _() = \> Promise\_ **Returns**: - `InterpreterContext` ### Methods #### close() ```ts close(): Promise; ``` **Returns**: - `Promise` #### run() ```ts run( code: string, options: Omit = {}): Promise; ``` Execute code inside this explicit interpreter context. If the named context vanished, the daemon's typed SESSION_NOT_FOUND error surfaces unchanged so the caller can recreate the context and decide what code, if any, is safe to rerun. **Parameters**: - `code` _string_ - `options` _Omit\ = \{\}_ **Returns**: - `Promise` #### toJSON() ```ts toJSON(): InterpreterContextJSON; ``` **Returns**: - `InterpreterContextJSON` *** ## InterpreterService ### Constructors #### Constructor ```ts new InterpreterService( transport: HttpTransport, process: ProcessService): InterpreterService; ``` **Parameters**: - `transport` _HttpTransport_ - `process` _ProcessService_ **Returns**: - `InterpreterService` ### Methods #### connectContext() ```ts connectContext(sessionId: string, language: string): InterpreterContext; ``` **Parameters**: - `sessionId` _string_ - `language` _string_ **Returns**: - `InterpreterContext` #### connectContext() ```ts connectContext(context: InterpreterContextJSON): InterpreterContext; ``` **Parameters**: - `context` _InterpreterContextJSON_ **Returns**: - `InterpreterContext` #### connectContext() ```ts connectContext( sessionIdOrContext: string | InterpreterContextJSON, language?: string): InterpreterContext; ``` **Parameters**: - `sessionIdOrContext` _string \| InterpreterContextJSON_ - `language?` _string_ **Returns**: - `InterpreterContext` #### createContext() ```ts createContext(options: InterpreterContextOptions): Promise; ``` **Parameters**: - `options` _InterpreterContextOptions_ **Returns**: - `Promise` #### deleteContext() ```ts deleteContext( sessionIdOrContext: string | InterpreterContext | InterpreterContextJSON): Promise; ``` **Parameters**: - `sessionIdOrContext` _string \| InterpreterContext \| InterpreterContextJSON_ **Returns**: - `Promise` #### listContexts() ```ts listContexts(): Promise; ``` **Returns**: - `Promise` #### run() ```ts run(code: string, options: InterpreterRunOptions = {}): Promise; ``` Execute code and return the parsed interpreter result. Rehydrated `kind:'code'` process handles can replay logs and wait/kill, but they do not recreate this decomposed result on another worker. A vanished explicit context surfaces the daemon's typed SESSION_NOT_FOUND error; callers decide whether to recreate the context and what to rerun. **Parameters**: - `code` _string_ - `options` _InterpreterRunOptions = \{\}_ **Returns**: - `Promise` *** ## InterpreterError **Properties**: - `name` _string_ - `value` _string_ - `traceback` _string\[\]_ *** ## InterpreterLogs **Properties**: - `stdout` _string_ - `stderr` _string_ *** ## InterpreterOutput **Properties**: - `data` _Record\_ - `isMainResult` _boolean_ - `text?` _string_ - `html?` _string_ - `png?` _string_ - `svg?` _string_ - `json?` _unknown_ *** ## InterpreterProcess ```ts type InterpreterProcess = WaitResult & { processId: string } ``` *** ## InterpreterRunOptions **Properties**: - `language?` _'python' \| 'typescript' \| 'javascript' \| string_ - `sessionId?` _string_ - `context?` _InterpreterContextReference \| InterpreterContextJSON_ - `isolated?` _boolean_ - `cwd?` _string_ - `env?` _Record\_ - `timeout?` _number_ - Caller wait budget in milliseconds; `0` waits unbounded. *** ## InterpreterContextJSON **Properties**: - `sandboxId` _string_ - `contextId` _string_ - `language` _string_ *** ## InterpreterContextOptions **Properties**: - `id?` _string_ - `language` _'python' \| 'typescript' \| 'javascript' \| string_ - `cwd?` _string_ - `env?` _Record\_ *** ## InterpreterContextReference **Properties**: - `sandboxId` _string_ - `id` _string_ - `language` _string_ *** ## InterpreterResult **Properties**: - `process` _InterpreterProcess_ - `results` _InterpreterOutput\[\]_ - `logs` _InterpreterLogs_ - `error?` _InterpreterError_