Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import type { Composio, Session } from '@composio/core'; |
| 2 | import { |
| 3 | experimental_createPythonWorkbenchHelperSource, |
| 4 | experimental_createWorkbenchEnv, |
| 5 | } from './shim'; |
| 6 | import type { LocalWorkbenchSession } from './types'; |
| 7 | |
| 8 | export async function experimental_createLocalWorkbenchSession( |
| 9 | composio: Composio, |
| 10 | session: Session<unknown, unknown, never> |
| 11 | ): Promise<LocalWorkbenchSession> { |
| 12 | if (session.workbench?.enable !== false) { |
| 13 | throw new Error( |
| 14 | 'experimental_createLocalWorkbenchSession requires a session created with workbench.enable: false. ' + |
| 15 | 'The remote workbench and a local sandbox cannot both run for one session.' |
| 16 | ); |
| 17 | } |
| 18 | |
| 19 | const { apiKey, baseURL } = composio.getConfig(); |
| 20 | if (!apiKey) { |
| 21 | throw new Error('A Composio project API key is required to create a local workbench session'); |
| 22 | } |
| 23 | |
| 24 | const env = experimental_createWorkbenchEnv({ |
| 25 | sessionId: session.sessionId, |
| 26 | backendUrl: baseURL ?? 'https://backend.composio.dev', |
| 27 | apiKey, |
| 28 | }); |
| 29 | |
| 30 | return { |
| 31 | env, |
| 32 | helperSource: experimental_createPythonWorkbenchHelperSource(), |
| 33 | }; |
| 34 | } |