From 89126c63f1b7bd53c9beb4b6ba209933f81b323b Mon Sep 17 00:00:00 2001 From: Oanakiaja <281723571@qq.com> Date: Tue, 27 Jan 2026 20:11:57 +0800 Subject: [PATCH] feat: release 1.0.0.160 version --- sdk/js/package.json | 2 +- .../client/requests/CodeExecuteRequest.ts | 4 + .../requests/JupyterCreateSessionRequest.ts | 2 +- .../client/requests/JupyterExecuteRequest.ts | 2 +- .../resources/nodejs/client/createSession.ts | 55 ++ .../resources/nodejs/client/deleteSession.ts | 55 ++ .../api/resources/nodejs/client/getSession.ts | 53 ++ .../src/api/resources/nodejs/client/index.ts | 5 + .../resources/nodejs/client/listSessions.ts | 36 + .../requests/NodeJsCreateSessionRequest.ts | 14 + .../client/requests/NodeJsExecuteRequest.ts | 6 + .../requests/NodeJsUpdateSessionRequest.ts | 12 + .../resources/nodejs/client/requests/index.ts | 2 + .../resources/nodejs/client/updateSession.ts | 55 ++ sdk/js/src/api/types/ActionData.ts | 9 + sdk/js/src/api/types/ActionResponse.ts | 10 + sdk/js/src/api/types/CodeExecuteResponse.ts | 2 + .../api/types/NodeJsCreateSessionResponse.ts | 14 + .../api/types/NodeJsDeleteSessionResponse.ts | 6 + sdk/js/src/api/types/NodeJsExecuteResponse.ts | 2 + sdk/js/src/api/types/NodeJsPackageInfo.ts | 11 + sdk/js/src/api/types/NodeJsRuntimeInfo.ts | 8 + sdk/js/src/api/types/NodeJsSessionInfo.ts | 18 + .../api/types/NodeJsSessionListResponse.ts | 8 + sdk/js/src/api/types/NodeJsSessionResponse.ts | 8 + .../api/types/NodeJsUpdateSessionResponse.ts | 10 + .../ResponseNodeJsCreateSessionResponse.ts | 12 + .../ResponseNodeJsDeleteSessionResponse.ts | 12 + .../ResponseNodeJsSessionListResponse.ts | 12 + .../types/ResponseNodeJsSessionResponse.ts | 12 + .../ResponseNodeJsUpdateSessionResponse.ts | 12 + sdk/js/src/api/types/ShellKillResult.ts | 6 +- sdk/js/src/api/types/index.ts | 13 + sdk/python/agent_sandbox/__init__.py | 39 ++ sdk/python/agent_sandbox/code/client.py | 32 +- sdk/python/agent_sandbox/code/raw_client.py | 20 + sdk/python/agent_sandbox/jupyter/client.py | 8 +- .../agent_sandbox/jupyter/raw_client.py | 8 +- sdk/python/agent_sandbox/nodejs/client.py | 507 +++++++++++++- sdk/python/agent_sandbox/nodejs/raw_client.py | 638 +++++++++++++++++- sdk/python/agent_sandbox/types/__init__.py | 39 ++ sdk/python/agent_sandbox/types/action_data.py | 24 + .../agent_sandbox/types/action_response.py | 10 + .../types/code_execute_response.py | 5 + .../types/node_js_create_session_response.py | 38 ++ .../types/node_js_delete_session_response.py | 22 + .../types/node_js_execute_response.py | 5 + .../types/node_js_package_info.py | 31 + .../types/node_js_runtime_info.py | 16 + .../types/node_js_session_info.py | 52 ++ .../types/node_js_session_list_response.py | 23 + .../types/node_js_session_response.py | 23 + .../types/node_js_update_session_response.py | 28 + ...esponse_node_js_create_session_response.py | 33 + ...esponse_node_js_delete_session_response.py | 33 + .../response_node_js_session_list_response.py | 33 + .../response_node_js_session_response.py | 33 + ...esponse_node_js_update_session_response.py | 33 + .../agent_sandbox/types/shell_kill_result.py | 9 +- sdk/python/pyproject.toml | 2 +- website/docs/public/v1/openapi.json | 599 +++++++++++++++- 61 files changed, 2793 insertions(+), 38 deletions(-) create mode 100644 sdk/js/src/api/resources/nodejs/client/createSession.ts create mode 100644 sdk/js/src/api/resources/nodejs/client/deleteSession.ts create mode 100644 sdk/js/src/api/resources/nodejs/client/getSession.ts create mode 100644 sdk/js/src/api/resources/nodejs/client/listSessions.ts create mode 100644 sdk/js/src/api/resources/nodejs/client/requests/NodeJsCreateSessionRequest.ts create mode 100644 sdk/js/src/api/resources/nodejs/client/requests/NodeJsUpdateSessionRequest.ts create mode 100644 sdk/js/src/api/resources/nodejs/client/updateSession.ts create mode 100644 sdk/js/src/api/types/ActionData.ts create mode 100644 sdk/js/src/api/types/NodeJsCreateSessionResponse.ts create mode 100644 sdk/js/src/api/types/NodeJsDeleteSessionResponse.ts create mode 100644 sdk/js/src/api/types/NodeJsPackageInfo.ts create mode 100644 sdk/js/src/api/types/NodeJsSessionInfo.ts create mode 100644 sdk/js/src/api/types/NodeJsSessionListResponse.ts create mode 100644 sdk/js/src/api/types/NodeJsSessionResponse.ts create mode 100644 sdk/js/src/api/types/NodeJsUpdateSessionResponse.ts create mode 100644 sdk/js/src/api/types/ResponseNodeJsCreateSessionResponse.ts create mode 100644 sdk/js/src/api/types/ResponseNodeJsDeleteSessionResponse.ts create mode 100644 sdk/js/src/api/types/ResponseNodeJsSessionListResponse.ts create mode 100644 sdk/js/src/api/types/ResponseNodeJsSessionResponse.ts create mode 100644 sdk/js/src/api/types/ResponseNodeJsUpdateSessionResponse.ts create mode 100644 sdk/python/agent_sandbox/types/action_data.py create mode 100644 sdk/python/agent_sandbox/types/node_js_create_session_response.py create mode 100644 sdk/python/agent_sandbox/types/node_js_delete_session_response.py create mode 100644 sdk/python/agent_sandbox/types/node_js_package_info.py create mode 100644 sdk/python/agent_sandbox/types/node_js_session_info.py create mode 100644 sdk/python/agent_sandbox/types/node_js_session_list_response.py create mode 100644 sdk/python/agent_sandbox/types/node_js_session_response.py create mode 100644 sdk/python/agent_sandbox/types/node_js_update_session_response.py create mode 100644 sdk/python/agent_sandbox/types/response_node_js_create_session_response.py create mode 100644 sdk/python/agent_sandbox/types/response_node_js_delete_session_response.py create mode 100644 sdk/python/agent_sandbox/types/response_node_js_session_list_response.py create mode 100644 sdk/python/agent_sandbox/types/response_node_js_session_response.py create mode 100644 sdk/python/agent_sandbox/types/response_node_js_update_session_response.py diff --git a/sdk/js/package.json b/sdk/js/package.json index 4e82936..1ff9820 100644 --- a/sdk/js/package.json +++ b/sdk/js/package.json @@ -1,6 +1,6 @@ { "name": "@agent-infra/sandbox", - "version": "1.0.6", + "version": "1.0.7", "description": "Node.js SDK for AIO Sandbox integration providing tools and interfaces", "main": "./dist/cjs/index.js", "module": "./dist/esm/index.mjs", diff --git a/sdk/js/src/api/resources/code/client/requests/CodeExecuteRequest.ts b/sdk/js/src/api/resources/code/client/requests/CodeExecuteRequest.ts index 45ea340..6825463 100644 --- a/sdk/js/src/api/resources/code/client/requests/CodeExecuteRequest.ts +++ b/sdk/js/src/api/resources/code/client/requests/CodeExecuteRequest.ts @@ -18,4 +18,8 @@ export interface CodeExecuteRequest { timeout?: number; /** Current working directory for code execution */ cwd?: string; + /** Enable stateful execution using Jupyter kernel. When True, variables and state persist across requests with the same session_id. */ + stateful?: boolean; + /** Session ID for stateful execution. Required when stateful=True to maintain state across requests. Auto-generated if not provided. */ + session_id?: string; } diff --git a/sdk/js/src/api/resources/jupyter/client/requests/JupyterCreateSessionRequest.ts b/sdk/js/src/api/resources/jupyter/client/requests/JupyterCreateSessionRequest.ts index d432896..2c549bb 100644 --- a/sdk/js/src/api/resources/jupyter/client/requests/JupyterCreateSessionRequest.ts +++ b/sdk/js/src/api/resources/jupyter/client/requests/JupyterCreateSessionRequest.ts @@ -7,7 +7,7 @@ export interface JupyterCreateSessionRequest { /** Unique identifier for the session, auto-generated if not provided */ session_id?: string; - /** Kernel name to use (e.g., 'python3', 'python3.11', 'python3.12'). Defaults to 'python3' */ + /** Kernel name: 'python3', 'python3.10', 'python3.11', 'python3.12'. Defaults to 'python3'. */ kernel_name?: string; /** Current working directory for the session */ cwd?: string; diff --git a/sdk/js/src/api/resources/jupyter/client/requests/JupyterExecuteRequest.ts b/sdk/js/src/api/resources/jupyter/client/requests/JupyterExecuteRequest.ts index 26c4f8f..d6fb930 100644 --- a/sdk/js/src/api/resources/jupyter/client/requests/JupyterExecuteRequest.ts +++ b/sdk/js/src/api/resources/jupyter/client/requests/JupyterExecuteRequest.ts @@ -11,7 +11,7 @@ export interface JupyterExecuteRequest { code: string; /** Execution timeout in seconds */ timeout?: number; - /** Kernel name to use (e.g., 'python3', 'python3.11', 'python3.12'). Defaults to 'python3' */ + /** Kernel name: 'python3', 'python3.10', 'python3.11', 'python3.12'. Defaults to 'python3'. */ kernel_name?: string; /** Session ID to maintain kernel state across requests */ session_id?: string; diff --git a/sdk/js/src/api/resources/nodejs/client/createSession.ts b/sdk/js/src/api/resources/nodejs/client/createSession.ts new file mode 100644 index 0000000..758481e --- /dev/null +++ b/sdk/js/src/api/resources/nodejs/client/createSession.ts @@ -0,0 +1,55 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as core from "../../../../core/index.js"; +import type * as Sandbox from "../../../index.js"; + +export type Error = + | Sandbox.nodejs.createSession.Error.UnprocessableEntityError + | Sandbox.nodejs.createSession.Error._Unknown; + +export namespace Error { + export interface UnprocessableEntityError { + statusCode: 422; + content: Sandbox.HttpValidationError; + } + + export interface _Unknown { + statusCode: void; + content: core.Fetcher.Error; + } + + export interface _Visitor<_Result> { + unprocessableEntityError: (value: Sandbox.HttpValidationError) => _Result; + _other: (value: core.Fetcher.Error) => _Result; + } +} + +export const Error = { + unprocessableEntityError: ( + value: Sandbox.HttpValidationError, + ): Sandbox.nodejs.createSession.Error.UnprocessableEntityError => { + return { + content: value, + statusCode: 422, + }; + }, + + _unknown: (fetcherError: core.Fetcher.Error): Sandbox.nodejs.createSession.Error._Unknown => { + return { + statusCode: undefined, + content: fetcherError, + }; + }, + + _visit: <_Result>( + value: Sandbox.nodejs.createSession.Error, + visitor: Sandbox.nodejs.createSession.Error._Visitor<_Result>, + ): _Result => { + switch (value.statusCode) { + case 422: + return visitor.unprocessableEntityError(value.content); + default: + return visitor._other(value as any); + } + }, +} as const; diff --git a/sdk/js/src/api/resources/nodejs/client/deleteSession.ts b/sdk/js/src/api/resources/nodejs/client/deleteSession.ts new file mode 100644 index 0000000..d8fb24e --- /dev/null +++ b/sdk/js/src/api/resources/nodejs/client/deleteSession.ts @@ -0,0 +1,55 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as core from "../../../../core/index.js"; +import type * as Sandbox from "../../../index.js"; + +export type Error = + | Sandbox.nodejs.deleteSession.Error.UnprocessableEntityError + | Sandbox.nodejs.deleteSession.Error._Unknown; + +export namespace Error { + export interface UnprocessableEntityError { + statusCode: 422; + content: Sandbox.HttpValidationError; + } + + export interface _Unknown { + statusCode: void; + content: core.Fetcher.Error; + } + + export interface _Visitor<_Result> { + unprocessableEntityError: (value: Sandbox.HttpValidationError) => _Result; + _other: (value: core.Fetcher.Error) => _Result; + } +} + +export const Error = { + unprocessableEntityError: ( + value: Sandbox.HttpValidationError, + ): Sandbox.nodejs.deleteSession.Error.UnprocessableEntityError => { + return { + content: value, + statusCode: 422, + }; + }, + + _unknown: (fetcherError: core.Fetcher.Error): Sandbox.nodejs.deleteSession.Error._Unknown => { + return { + statusCode: undefined, + content: fetcherError, + }; + }, + + _visit: <_Result>( + value: Sandbox.nodejs.deleteSession.Error, + visitor: Sandbox.nodejs.deleteSession.Error._Visitor<_Result>, + ): _Result => { + switch (value.statusCode) { + case 422: + return visitor.unprocessableEntityError(value.content); + default: + return visitor._other(value as any); + } + }, +} as const; diff --git a/sdk/js/src/api/resources/nodejs/client/getSession.ts b/sdk/js/src/api/resources/nodejs/client/getSession.ts new file mode 100644 index 0000000..9c07386 --- /dev/null +++ b/sdk/js/src/api/resources/nodejs/client/getSession.ts @@ -0,0 +1,53 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as core from "../../../../core/index.js"; +import type * as Sandbox from "../../../index.js"; + +export type Error = Sandbox.nodejs.getSession.Error.UnprocessableEntityError | Sandbox.nodejs.getSession.Error._Unknown; + +export namespace Error { + export interface UnprocessableEntityError { + statusCode: 422; + content: Sandbox.HttpValidationError; + } + + export interface _Unknown { + statusCode: void; + content: core.Fetcher.Error; + } + + export interface _Visitor<_Result> { + unprocessableEntityError: (value: Sandbox.HttpValidationError) => _Result; + _other: (value: core.Fetcher.Error) => _Result; + } +} + +export const Error = { + unprocessableEntityError: ( + value: Sandbox.HttpValidationError, + ): Sandbox.nodejs.getSession.Error.UnprocessableEntityError => { + return { + content: value, + statusCode: 422, + }; + }, + + _unknown: (fetcherError: core.Fetcher.Error): Sandbox.nodejs.getSession.Error._Unknown => { + return { + statusCode: undefined, + content: fetcherError, + }; + }, + + _visit: <_Result>( + value: Sandbox.nodejs.getSession.Error, + visitor: Sandbox.nodejs.getSession.Error._Visitor<_Result>, + ): _Result => { + switch (value.statusCode) { + case 422: + return visitor.unprocessableEntityError(value.content); + default: + return visitor._other(value as any); + } + }, +} as const; diff --git a/sdk/js/src/api/resources/nodejs/client/index.ts b/sdk/js/src/api/resources/nodejs/client/index.ts index 10edb1a..533df46 100644 --- a/sdk/js/src/api/resources/nodejs/client/index.ts +++ b/sdk/js/src/api/resources/nodejs/client/index.ts @@ -1,3 +1,8 @@ +export * as createSession from "./createSession.js"; +export * as deleteSession from "./deleteSession.js"; export * as executeCode from "./executeCode.js"; export * as getInfo from "./getInfo.js"; +export * as getSession from "./getSession.js"; +export * as listSessions from "./listSessions.js"; export * from "./requests/index.js"; +export * as updateSession from "./updateSession.js"; diff --git a/sdk/js/src/api/resources/nodejs/client/listSessions.ts b/sdk/js/src/api/resources/nodejs/client/listSessions.ts new file mode 100644 index 0000000..f10b66e --- /dev/null +++ b/sdk/js/src/api/resources/nodejs/client/listSessions.ts @@ -0,0 +1,36 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as core from "../../../../core/index.js"; +import type * as Sandbox from "../../../index.js"; + +export type Error = Sandbox.nodejs.listSessions.Error._Unknown; + +export namespace Error { + export interface _Unknown { + statusCode: void; + content: core.Fetcher.Error; + } + + export interface _Visitor<_Result> { + _other: (value: core.Fetcher.Error) => _Result; + } +} + +export const Error = { + _unknown: (fetcherError: core.Fetcher.Error): Sandbox.nodejs.listSessions.Error._Unknown => { + return { + statusCode: undefined, + content: fetcherError, + }; + }, + + _visit: <_Result>( + value: Sandbox.nodejs.listSessions.Error, + visitor: Sandbox.nodejs.listSessions.Error._Visitor<_Result>, + ): _Result => { + switch (value.statusCode) { + default: + return visitor._other(value as any); + } + }, +} as const; diff --git a/sdk/js/src/api/resources/nodejs/client/requests/NodeJsCreateSessionRequest.ts b/sdk/js/src/api/resources/nodejs/client/requests/NodeJsCreateSessionRequest.ts new file mode 100644 index 0000000..126d603 --- /dev/null +++ b/sdk/js/src/api/resources/nodejs/client/requests/NodeJsCreateSessionRequest.ts @@ -0,0 +1,14 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * {} + */ +export interface NodeJsCreateSessionRequest { + /** Custom session ID (auto-generated if not provided) */ + session_id?: string; + /** Working directory for the session */ + cwd?: string; + /** Maximum idle time in seconds (default 24 hours) */ + max_idle_time?: number; +} diff --git a/sdk/js/src/api/resources/nodejs/client/requests/NodeJsExecuteRequest.ts b/sdk/js/src/api/resources/nodejs/client/requests/NodeJsExecuteRequest.ts index 096c618..d962a7e 100644 --- a/sdk/js/src/api/resources/nodejs/client/requests/NodeJsExecuteRequest.ts +++ b/sdk/js/src/api/resources/nodejs/client/requests/NodeJsExecuteRequest.ts @@ -15,4 +15,10 @@ export interface NodeJsExecuteRequest { stdin?: string; /** Additional files to create in execution directory */ files?: Record; + /** Enable stateful execution with persistent REPL session */ + stateful?: boolean; + /** Session ID for stateful execution (reuse existing session) */ + session_id?: string; + /** Working directory for code execution */ + cwd?: string; } diff --git a/sdk/js/src/api/resources/nodejs/client/requests/NodeJsUpdateSessionRequest.ts b/sdk/js/src/api/resources/nodejs/client/requests/NodeJsUpdateSessionRequest.ts new file mode 100644 index 0000000..722337c --- /dev/null +++ b/sdk/js/src/api/resources/nodejs/client/requests/NodeJsUpdateSessionRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * {} + */ +export interface NodeJsUpdateSessionRequest { + /** New maximum idle time in seconds */ + max_idle_time?: number; + /** New working directory */ + cwd?: string; +} diff --git a/sdk/js/src/api/resources/nodejs/client/requests/index.ts b/sdk/js/src/api/resources/nodejs/client/requests/index.ts index 37a68d8..e39d370 100644 --- a/sdk/js/src/api/resources/nodejs/client/requests/index.ts +++ b/sdk/js/src/api/resources/nodejs/client/requests/index.ts @@ -1 +1,3 @@ +export type { NodeJsCreateSessionRequest } from "./NodeJsCreateSessionRequest.js"; export type { NodeJsExecuteRequest } from "./NodeJsExecuteRequest.js"; +export type { NodeJsUpdateSessionRequest } from "./NodeJsUpdateSessionRequest.js"; diff --git a/sdk/js/src/api/resources/nodejs/client/updateSession.ts b/sdk/js/src/api/resources/nodejs/client/updateSession.ts new file mode 100644 index 0000000..9855a13 --- /dev/null +++ b/sdk/js/src/api/resources/nodejs/client/updateSession.ts @@ -0,0 +1,55 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as core from "../../../../core/index.js"; +import type * as Sandbox from "../../../index.js"; + +export type Error = + | Sandbox.nodejs.updateSession.Error.UnprocessableEntityError + | Sandbox.nodejs.updateSession.Error._Unknown; + +export namespace Error { + export interface UnprocessableEntityError { + statusCode: 422; + content: Sandbox.HttpValidationError; + } + + export interface _Unknown { + statusCode: void; + content: core.Fetcher.Error; + } + + export interface _Visitor<_Result> { + unprocessableEntityError: (value: Sandbox.HttpValidationError) => _Result; + _other: (value: core.Fetcher.Error) => _Result; + } +} + +export const Error = { + unprocessableEntityError: ( + value: Sandbox.HttpValidationError, + ): Sandbox.nodejs.updateSession.Error.UnprocessableEntityError => { + return { + content: value, + statusCode: 422, + }; + }, + + _unknown: (fetcherError: core.Fetcher.Error): Sandbox.nodejs.updateSession.Error._Unknown => { + return { + statusCode: undefined, + content: fetcherError, + }; + }, + + _visit: <_Result>( + value: Sandbox.nodejs.updateSession.Error, + visitor: Sandbox.nodejs.updateSession.Error._Visitor<_Result>, + ): _Result => { + switch (value.statusCode) { + case 422: + return visitor.unprocessableEntityError(value.content); + default: + return visitor._other(value as any); + } + }, +} as const; diff --git a/sdk/js/src/api/types/ActionData.ts b/sdk/js/src/api/types/ActionData.ts new file mode 100644 index 0000000..c1ce6ab --- /dev/null +++ b/sdk/js/src/api/types/ActionData.ts @@ -0,0 +1,9 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * Inner data for action response. + */ +export interface ActionData { + status: "success"; + action_performed: string; +} diff --git a/sdk/js/src/api/types/ActionResponse.ts b/sdk/js/src/api/types/ActionResponse.ts index fba53f5..b3405b7 100644 --- a/sdk/js/src/api/types/ActionResponse.ts +++ b/sdk/js/src/api/types/ActionResponse.ts @@ -1,6 +1,16 @@ // This file was auto-generated by Fern from our API Definition. +import type * as Sandbox from "../index.js"; + +/** + * Response model for browser actions. + * + * Provides backward compatibility: + * - Old format: resp.json()['status'], resp.json()['action_performed'] + * - New format: resp.json()['data']['status'], resp.json()['data']['action_performed'] + */ export interface ActionResponse { status: "success"; action_performed: string; + data?: Sandbox.ActionData; } diff --git a/sdk/js/src/api/types/CodeExecuteResponse.ts b/sdk/js/src/api/types/CodeExecuteResponse.ts index 0477f61..94730e0 100644 --- a/sdk/js/src/api/types/CodeExecuteResponse.ts +++ b/sdk/js/src/api/types/CodeExecuteResponse.ts @@ -22,4 +22,6 @@ export interface CodeExecuteResponse { exit_code?: number; /** Captured error traceback lines when available */ traceback?: string[]; + /** Session ID for stateful execution (only present when stateful=True) */ + session_id?: string; } diff --git a/sdk/js/src/api/types/NodeJsCreateSessionResponse.ts b/sdk/js/src/api/types/NodeJsCreateSessionResponse.ts new file mode 100644 index 0000000..8662436 --- /dev/null +++ b/sdk/js/src/api/types/NodeJsCreateSessionResponse.ts @@ -0,0 +1,14 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Sandbox from "../index.js"; + +export interface NodeJsCreateSessionResponse { + /** Session ID */ + session_id: string; + /** Whether the session was newly created */ + created: boolean; + /** Additional message (e.g., if session already exists) */ + message?: string; + /** Session information (if created) */ + session?: Sandbox.NodeJsSessionInfo; +} diff --git a/sdk/js/src/api/types/NodeJsDeleteSessionResponse.ts b/sdk/js/src/api/types/NodeJsDeleteSessionResponse.ts new file mode 100644 index 0000000..1c30d31 --- /dev/null +++ b/sdk/js/src/api/types/NodeJsDeleteSessionResponse.ts @@ -0,0 +1,6 @@ +// This file was auto-generated by Fern from our API Definition. + +export interface NodeJsDeleteSessionResponse { + /** Whether the session was deleted */ + deleted: boolean; +} diff --git a/sdk/js/src/api/types/NodeJsExecuteResponse.ts b/sdk/js/src/api/types/NodeJsExecuteResponse.ts index ae91f65..a73900c 100644 --- a/sdk/js/src/api/types/NodeJsExecuteResponse.ts +++ b/sdk/js/src/api/types/NodeJsExecuteResponse.ts @@ -19,4 +19,6 @@ export interface NodeJsExecuteResponse { stderr?: string; /** Process exit code */ exit_code: number; + /** Session ID for stateful execution (use this to continue the session) */ + session_id?: string; } diff --git a/sdk/js/src/api/types/NodeJsPackageInfo.ts b/sdk/js/src/api/types/NodeJsPackageInfo.ts new file mode 100644 index 0000000..28e4b62 --- /dev/null +++ b/sdk/js/src/api/types/NodeJsPackageInfo.ts @@ -0,0 +1,11 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * Package information + */ +export interface NodeJsPackageInfo { + /** Package name */ + name: string; + /** Package version */ + version: string; +} diff --git a/sdk/js/src/api/types/NodeJsRuntimeInfo.ts b/sdk/js/src/api/types/NodeJsRuntimeInfo.ts index 6e0c54b..b670b95 100644 --- a/sdk/js/src/api/types/NodeJsRuntimeInfo.ts +++ b/sdk/js/src/api/types/NodeJsRuntimeInfo.ts @@ -1,5 +1,7 @@ // This file was auto-generated by Fern from our API Definition. +import type * as Sandbox from "../index.js"; + /** * NodeJS runtime information model */ @@ -14,6 +16,12 @@ export interface NodeJsRuntimeInfo { description: string; /** Runtime directory path */ runtime_directory?: string; + /** Global npm directory path */ + global_npm_directory?: string; + /** Pre-installed runtime packages */ + runtime_packages?: Sandbox.NodeJsPackageInfo[]; + /** Globally installed npm packages */ + global_packages?: Sandbox.NodeJsPackageInfo[]; /** Error message if runtime info retrieval failed */ error?: string; } diff --git a/sdk/js/src/api/types/NodeJsSessionInfo.ts b/sdk/js/src/api/types/NodeJsSessionInfo.ts new file mode 100644 index 0000000..676f5c8 --- /dev/null +++ b/sdk/js/src/api/types/NodeJsSessionInfo.ts @@ -0,0 +1,18 @@ +// This file was auto-generated by Fern from our API Definition. + +export interface NodeJsSessionInfo { + /** Session ID */ + session_id: string; + /** Working directory */ + cwd: string; + /** Session creation timestamp (ms since epoch) */ + created_at: number; + /** Last activity timestamp (ms since epoch) */ + last_used: number; + /** Maximum idle time in milliseconds */ + max_idle_time: number; + /** Seconds since last activity */ + age_seconds: number; + /** Session state: IDLE or EXECUTING */ + state: string; +} diff --git a/sdk/js/src/api/types/NodeJsSessionListResponse.ts b/sdk/js/src/api/types/NodeJsSessionListResponse.ts new file mode 100644 index 0000000..05f7e39 --- /dev/null +++ b/sdk/js/src/api/types/NodeJsSessionListResponse.ts @@ -0,0 +1,8 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Sandbox from "../index.js"; + +export interface NodeJsSessionListResponse { + /** Map of session ID to session info */ + sessions?: Record; +} diff --git a/sdk/js/src/api/types/NodeJsSessionResponse.ts b/sdk/js/src/api/types/NodeJsSessionResponse.ts new file mode 100644 index 0000000..dcd87b2 --- /dev/null +++ b/sdk/js/src/api/types/NodeJsSessionResponse.ts @@ -0,0 +1,8 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Sandbox from "../index.js"; + +export interface NodeJsSessionResponse { + /** Session information */ + session: Sandbox.NodeJsSessionInfo; +} diff --git a/sdk/js/src/api/types/NodeJsUpdateSessionResponse.ts b/sdk/js/src/api/types/NodeJsUpdateSessionResponse.ts new file mode 100644 index 0000000..600b854 --- /dev/null +++ b/sdk/js/src/api/types/NodeJsUpdateSessionResponse.ts @@ -0,0 +1,10 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Sandbox from "../index.js"; + +export interface NodeJsUpdateSessionResponse { + /** Whether the update was successful */ + updated: boolean; + /** Updated session information */ + session: Sandbox.NodeJsSessionInfo; +} diff --git a/sdk/js/src/api/types/ResponseNodeJsCreateSessionResponse.ts b/sdk/js/src/api/types/ResponseNodeJsCreateSessionResponse.ts new file mode 100644 index 0000000..7cc663c --- /dev/null +++ b/sdk/js/src/api/types/ResponseNodeJsCreateSessionResponse.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Sandbox from "../index.js"; + +export interface ResponseNodeJsCreateSessionResponse { + /** Whether the operation was successful */ + success?: boolean; + /** Operation result message */ + message?: string; + /** Data returned from the operation */ + data?: Sandbox.NodeJsCreateSessionResponse; +} diff --git a/sdk/js/src/api/types/ResponseNodeJsDeleteSessionResponse.ts b/sdk/js/src/api/types/ResponseNodeJsDeleteSessionResponse.ts new file mode 100644 index 0000000..a67f8f2 --- /dev/null +++ b/sdk/js/src/api/types/ResponseNodeJsDeleteSessionResponse.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Sandbox from "../index.js"; + +export interface ResponseNodeJsDeleteSessionResponse { + /** Whether the operation was successful */ + success?: boolean; + /** Operation result message */ + message?: string; + /** Data returned from the operation */ + data?: Sandbox.NodeJsDeleteSessionResponse; +} diff --git a/sdk/js/src/api/types/ResponseNodeJsSessionListResponse.ts b/sdk/js/src/api/types/ResponseNodeJsSessionListResponse.ts new file mode 100644 index 0000000..a242700 --- /dev/null +++ b/sdk/js/src/api/types/ResponseNodeJsSessionListResponse.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Sandbox from "../index.js"; + +export interface ResponseNodeJsSessionListResponse { + /** Whether the operation was successful */ + success?: boolean; + /** Operation result message */ + message?: string; + /** Data returned from the operation */ + data?: Sandbox.NodeJsSessionListResponse; +} diff --git a/sdk/js/src/api/types/ResponseNodeJsSessionResponse.ts b/sdk/js/src/api/types/ResponseNodeJsSessionResponse.ts new file mode 100644 index 0000000..8624763 --- /dev/null +++ b/sdk/js/src/api/types/ResponseNodeJsSessionResponse.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Sandbox from "../index.js"; + +export interface ResponseNodeJsSessionResponse { + /** Whether the operation was successful */ + success?: boolean; + /** Operation result message */ + message?: string; + /** Data returned from the operation */ + data?: Sandbox.NodeJsSessionResponse; +} diff --git a/sdk/js/src/api/types/ResponseNodeJsUpdateSessionResponse.ts b/sdk/js/src/api/types/ResponseNodeJsUpdateSessionResponse.ts new file mode 100644 index 0000000..814a975 --- /dev/null +++ b/sdk/js/src/api/types/ResponseNodeJsUpdateSessionResponse.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Sandbox from "../index.js"; + +export interface ResponseNodeJsUpdateSessionResponse { + /** Whether the operation was successful */ + success?: boolean; + /** Operation result message */ + message?: string; + /** Data returned from the operation */ + data?: Sandbox.NodeJsUpdateSessionResponse; +} diff --git a/sdk/js/src/api/types/ShellKillResult.ts b/sdk/js/src/api/types/ShellKillResult.ts index 4b2080c..c21a4a7 100644 --- a/sdk/js/src/api/types/ShellKillResult.ts +++ b/sdk/js/src/api/types/ShellKillResult.ts @@ -8,6 +8,8 @@ import type * as Sandbox from "../index.js"; export interface ShellKillResult { /** Process status */ status: Sandbox.BashCommandStatus; - /** Process return code */ - returncode: number; + /** Process exit code before termination, None if process was still running */ + exit_code?: number; + /** Deprecated: use exit_code instead. Kept for backward compatibility. */ + returncode?: number; } diff --git a/sdk/js/src/api/types/index.ts b/sdk/js/src/api/types/index.ts index e958e31..748c63a 100644 --- a/sdk/js/src/api/types/index.ts +++ b/sdk/js/src/api/types/index.ts @@ -1,3 +1,4 @@ +export * from "./ActionData.js"; export * from "./ActionResponse.js"; export * from "./ActiveSessionsResult.js"; export * from "./ActiveShellSessionsResult.js"; @@ -46,9 +47,16 @@ export * from "./MouseDownAction.js"; export * from "./MouseUpAction.js"; export * from "./MoveRelAction.js"; export * from "./MoveToAction.js"; +export * from "./NodeJsCreateSessionResponse.js"; +export * from "./NodeJsDeleteSessionResponse.js"; export * from "./NodeJsExecuteResponse.js"; export * from "./NodeJsOutput.js"; +export * from "./NodeJsPackageInfo.js"; export * from "./NodeJsRuntimeInfo.js"; +export * from "./NodeJsSessionInfo.js"; +export * from "./NodeJsSessionListResponse.js"; +export * from "./NodeJsSessionResponse.js"; +export * from "./NodeJsUpdateSessionResponse.js"; export * from "./PressAction.js"; export * from "./Resolution.js"; export * from "./Resource.js"; @@ -74,8 +82,13 @@ export * from "./ResponseJupyterExecuteResponse.js"; export * from "./ResponseJupyterInfoResponse.js"; export * from "./ResponseListStr.js"; export * from "./ResponseListToolsResultModel.js"; +export * from "./ResponseNodeJsCreateSessionResponse.js"; +export * from "./ResponseNodeJsDeleteSessionResponse.js"; export * from "./ResponseNodeJsExecuteResponse.js"; export * from "./ResponseNodeJsRuntimeInfo.js"; +export * from "./ResponseNodeJsSessionListResponse.js"; +export * from "./ResponseNodeJsSessionResponse.js"; +export * from "./ResponseNodeJsUpdateSessionResponse.js"; export * from "./ResponseShellCommandResult.js"; export * from "./ResponseShellCreateSessionResponse.js"; export * from "./ResponseShellKillResult.js"; diff --git a/sdk/python/agent_sandbox/__init__.py b/sdk/python/agent_sandbox/__init__.py index d1c2476..00edd41 100644 --- a/sdk/python/agent_sandbox/__init__.py +++ b/sdk/python/agent_sandbox/__init__.py @@ -7,6 +7,7 @@ if typing.TYPE_CHECKING: from .types import ( + ActionData, ActionResponse, ActiveSessionsResult, ActiveShellSessionsResult, @@ -55,9 +56,16 @@ MouseUpAction, MoveRelAction, MoveToAction, + NodeJsCreateSessionResponse, + NodeJsDeleteSessionResponse, NodeJsExecuteResponse, NodeJsOutput, + NodeJsPackageInfo, NodeJsRuntimeInfo, + NodeJsSessionInfo, + NodeJsSessionListResponse, + NodeJsSessionResponse, + NodeJsUpdateSessionResponse, PressAction, Resolution, Resource, @@ -88,8 +96,13 @@ ResponseJupyterInfoResponse, ResponseListStr, ResponseListToolsResultModel, + ResponseNodeJsCreateSessionResponse, + ResponseNodeJsDeleteSessionResponse, ResponseNodeJsExecuteResponse, ResponseNodeJsRuntimeInfo, + ResponseNodeJsSessionListResponse, + ResponseNodeJsSessionResponse, + ResponseNodeJsUpdateSessionResponse, ResponseShellCommandResult, ResponseShellCreateSessionResponse, ResponseShellKillResult, @@ -159,6 +172,7 @@ from .file import Command, StrReplaceEditorRequestReplaceMode _dynamic_imports: typing.Dict[str, str] = { "Action": ".browser", + "ActionData": ".types", "ActionResponse": ".types", "Action_Click": ".browser", "Action_DoubleClick": ".browser", @@ -225,9 +239,16 @@ "MouseUpAction": ".types", "MoveRelAction": ".types", "MoveToAction": ".types", + "NodeJsCreateSessionResponse": ".types", + "NodeJsDeleteSessionResponse": ".types", "NodeJsExecuteResponse": ".types", "NodeJsOutput": ".types", + "NodeJsPackageInfo": ".types", "NodeJsRuntimeInfo": ".types", + "NodeJsSessionInfo": ".types", + "NodeJsSessionListResponse": ".types", + "NodeJsSessionResponse": ".types", + "NodeJsUpdateSessionResponse": ".types", "PressAction": ".types", "Resolution": ".types", "Resource": ".types", @@ -258,8 +279,13 @@ "ResponseJupyterInfoResponse": ".types", "ResponseListStr": ".types", "ResponseListToolsResultModel": ".types", + "ResponseNodeJsCreateSessionResponse": ".types", + "ResponseNodeJsDeleteSessionResponse": ".types", "ResponseNodeJsExecuteResponse": ".types", "ResponseNodeJsRuntimeInfo": ".types", + "ResponseNodeJsSessionListResponse": ".types", + "ResponseNodeJsSessionResponse": ".types", + "ResponseNodeJsUpdateSessionResponse": ".types", "ResponseShellCommandResult": ".types", "ResponseShellCreateSessionResponse": ".types", "ResponseShellKillResult": ".types", @@ -340,6 +366,7 @@ def __dir__(): __all__ = [ "Action", + "ActionData", "ActionResponse", "Action_Click", "Action_DoubleClick", @@ -406,9 +433,16 @@ def __dir__(): "MouseUpAction", "MoveRelAction", "MoveToAction", + "NodeJsCreateSessionResponse", + "NodeJsDeleteSessionResponse", "NodeJsExecuteResponse", "NodeJsOutput", + "NodeJsPackageInfo", "NodeJsRuntimeInfo", + "NodeJsSessionInfo", + "NodeJsSessionListResponse", + "NodeJsSessionResponse", + "NodeJsUpdateSessionResponse", "PressAction", "Resolution", "Resource", @@ -439,8 +473,13 @@ def __dir__(): "ResponseJupyterInfoResponse", "ResponseListStr", "ResponseListToolsResultModel", + "ResponseNodeJsCreateSessionResponse", + "ResponseNodeJsDeleteSessionResponse", "ResponseNodeJsExecuteResponse", "ResponseNodeJsRuntimeInfo", + "ResponseNodeJsSessionListResponse", + "ResponseNodeJsSessionResponse", + "ResponseNodeJsUpdateSessionResponse", "ResponseShellCommandResult", "ResponseShellCreateSessionResponse", "ResponseShellKillResult", diff --git a/sdk/python/agent_sandbox/code/client.py b/sdk/python/agent_sandbox/code/client.py index 0d4c0cc..ec23528 100644 --- a/sdk/python/agent_sandbox/code/client.py +++ b/sdk/python/agent_sandbox/code/client.py @@ -35,6 +35,8 @@ def execute_code( code: str, timeout: typing.Optional[int] = OMIT, cwd: typing.Optional[str] = OMIT, + stateful: typing.Optional[bool] = OMIT, + session_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> ResponseCodeExecuteResponse: """ @@ -54,6 +56,12 @@ def execute_code( cwd : typing.Optional[str] Current working directory for code execution + stateful : typing.Optional[bool] + Enable stateful execution using Jupyter kernel. When True, variables and state persist across requests with the same session_id. + + session_id : typing.Optional[str] + Session ID for stateful execution. Required when stateful=True to maintain state across requests. Auto-generated if not provided. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -75,7 +83,13 @@ def execute_code( ) """ _response = self._raw_client.execute_code( - language=language, code=code, timeout=timeout, cwd=cwd, request_options=request_options + language=language, + code=code, + timeout=timeout, + cwd=cwd, + stateful=stateful, + session_id=session_id, + request_options=request_options, ) return _response.data @@ -128,6 +142,8 @@ async def execute_code( code: str, timeout: typing.Optional[int] = OMIT, cwd: typing.Optional[str] = OMIT, + stateful: typing.Optional[bool] = OMIT, + session_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> ResponseCodeExecuteResponse: """ @@ -147,6 +163,12 @@ async def execute_code( cwd : typing.Optional[str] Current working directory for code execution + stateful : typing.Optional[bool] + Enable stateful execution using Jupyter kernel. When True, variables and state persist across requests with the same session_id. + + session_id : typing.Optional[str] + Session ID for stateful execution. Required when stateful=True to maintain state across requests. Auto-generated if not provided. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -176,7 +198,13 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._raw_client.execute_code( - language=language, code=code, timeout=timeout, cwd=cwd, request_options=request_options + language=language, + code=code, + timeout=timeout, + cwd=cwd, + stateful=stateful, + session_id=session_id, + request_options=request_options, ) return _response.data diff --git a/sdk/python/agent_sandbox/code/raw_client.py b/sdk/python/agent_sandbox/code/raw_client.py index 93cfd49..8ba6d48 100644 --- a/sdk/python/agent_sandbox/code/raw_client.py +++ b/sdk/python/agent_sandbox/code/raw_client.py @@ -29,6 +29,8 @@ def execute_code( code: str, timeout: typing.Optional[int] = OMIT, cwd: typing.Optional[str] = OMIT, + stateful: typing.Optional[bool] = OMIT, + session_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[ResponseCodeExecuteResponse]: """ @@ -48,6 +50,12 @@ def execute_code( cwd : typing.Optional[str] Current working directory for code execution + stateful : typing.Optional[bool] + Enable stateful execution using Jupyter kernel. When True, variables and state persist across requests with the same session_id. + + session_id : typing.Optional[str] + Session ID for stateful execution. Required when stateful=True to maintain state across requests. Auto-generated if not provided. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -64,6 +72,8 @@ def execute_code( "code": code, "timeout": timeout, "cwd": cwd, + "stateful": stateful, + "session_id": session_id, }, headers={ "content-type": "application/json", @@ -145,6 +155,8 @@ async def execute_code( code: str, timeout: typing.Optional[int] = OMIT, cwd: typing.Optional[str] = OMIT, + stateful: typing.Optional[bool] = OMIT, + session_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[ResponseCodeExecuteResponse]: """ @@ -164,6 +176,12 @@ async def execute_code( cwd : typing.Optional[str] Current working directory for code execution + stateful : typing.Optional[bool] + Enable stateful execution using Jupyter kernel. When True, variables and state persist across requests with the same session_id. + + session_id : typing.Optional[str] + Session ID for stateful execution. Required when stateful=True to maintain state across requests. Auto-generated if not provided. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -180,6 +198,8 @@ async def execute_code( "code": code, "timeout": timeout, "cwd": cwd, + "stateful": stateful, + "session_id": session_id, }, headers={ "content-type": "application/json", diff --git a/sdk/python/agent_sandbox/jupyter/client.py b/sdk/python/agent_sandbox/jupyter/client.py index 638c169..9e337b0 100644 --- a/sdk/python/agent_sandbox/jupyter/client.py +++ b/sdk/python/agent_sandbox/jupyter/client.py @@ -57,7 +57,7 @@ def execute_code( Execution timeout in seconds kernel_name : typing.Optional[str] - Kernel name to use (e.g., 'python3', 'python3.11', 'python3.12'). Defaults to 'python3' + Kernel name: 'python3', 'python3.10', 'python3.11', 'python3.12'. Defaults to 'python3'. session_id : typing.Optional[str] Session ID to maintain kernel state across requests @@ -219,7 +219,7 @@ def create_session( Unique identifier for the session, auto-generated if not provided kernel_name : typing.Optional[str] - Kernel name to use (e.g., 'python3', 'python3.11', 'python3.12'). Defaults to 'python3' + Kernel name: 'python3', 'python3.10', 'python3.11', 'python3.12'. Defaults to 'python3'. cwd : typing.Optional[str] Current working directory for the session @@ -289,7 +289,7 @@ async def execute_code( Execution timeout in seconds kernel_name : typing.Optional[str] - Kernel name to use (e.g., 'python3', 'python3.11', 'python3.12'). Defaults to 'python3' + Kernel name: 'python3', 'python3.10', 'python3.11', 'python3.12'. Defaults to 'python3'. session_id : typing.Optional[str] Session ID to maintain kernel state across requests @@ -495,7 +495,7 @@ async def create_session( Unique identifier for the session, auto-generated if not provided kernel_name : typing.Optional[str] - Kernel name to use (e.g., 'python3', 'python3.11', 'python3.12'). Defaults to 'python3' + Kernel name: 'python3', 'python3.10', 'python3.11', 'python3.12'. Defaults to 'python3'. cwd : typing.Optional[str] Current working directory for the session diff --git a/sdk/python/agent_sandbox/jupyter/raw_client.py b/sdk/python/agent_sandbox/jupyter/raw_client.py index 0ccc72a..69f0832 100644 --- a/sdk/python/agent_sandbox/jupyter/raw_client.py +++ b/sdk/python/agent_sandbox/jupyter/raw_client.py @@ -52,7 +52,7 @@ def execute_code( Execution timeout in seconds kernel_name : typing.Optional[str] - Kernel name to use (e.g., 'python3', 'python3.11', 'python3.12'). Defaults to 'python3' + Kernel name: 'python3', 'python3.10', 'python3.11', 'python3.12'. Defaults to 'python3'. session_id : typing.Optional[str] Session ID to maintain kernel state across requests @@ -282,7 +282,7 @@ def create_session( Unique identifier for the session, auto-generated if not provided kernel_name : typing.Optional[str] - Kernel name to use (e.g., 'python3', 'python3.11', 'python3.12'). Defaults to 'python3' + Kernel name: 'python3', 'python3.10', 'python3.11', 'python3.12'. Defaults to 'python3'. cwd : typing.Optional[str] Current working directory for the session @@ -367,7 +367,7 @@ async def execute_code( Execution timeout in seconds kernel_name : typing.Optional[str] - Kernel name to use (e.g., 'python3', 'python3.11', 'python3.12'). Defaults to 'python3' + Kernel name: 'python3', 'python3.10', 'python3.11', 'python3.12'. Defaults to 'python3'. session_id : typing.Optional[str] Session ID to maintain kernel state across requests @@ -599,7 +599,7 @@ async def create_session( Unique identifier for the session, auto-generated if not provided kernel_name : typing.Optional[str] - Kernel name to use (e.g., 'python3', 'python3.11', 'python3.12'). Defaults to 'python3' + Kernel name: 'python3', 'python3.10', 'python3.11', 'python3.12'. Defaults to 'python3'. cwd : typing.Optional[str] Current working directory for the session diff --git a/sdk/python/agent_sandbox/nodejs/client.py b/sdk/python/agent_sandbox/nodejs/client.py index 9431eef..2987b5b 100644 --- a/sdk/python/agent_sandbox/nodejs/client.py +++ b/sdk/python/agent_sandbox/nodejs/client.py @@ -4,8 +4,13 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions +from ..types.response_node_js_create_session_response import ResponseNodeJsCreateSessionResponse +from ..types.response_node_js_delete_session_response import ResponseNodeJsDeleteSessionResponse from ..types.response_node_js_execute_response import ResponseNodeJsExecuteResponse from ..types.response_node_js_runtime_info import ResponseNodeJsRuntimeInfo +from ..types.response_node_js_session_list_response import ResponseNodeJsSessionListResponse +from ..types.response_node_js_session_response import ResponseNodeJsSessionResponse +from ..types.response_node_js_update_session_response import ResponseNodeJsUpdateSessionResponse from .raw_client import AsyncRawNodejsClient, RawNodejsClient # this is used as the default value for optional parameters @@ -34,13 +39,25 @@ def execute_code( timeout: typing.Optional[int] = OMIT, stdin: typing.Optional[str] = OMIT, files: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + stateful: typing.Optional[bool] = OMIT, + session_id: typing.Optional[str] = OMIT, + cwd: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> ResponseNodeJsExecuteResponse: """ Execute JavaScript code using Node.js This endpoint allows you to execute JavaScript code and get results back. - Each request creates a fresh execution environment that's cleaned up automatically. + + For stateless execution (default): + - Each request creates a fresh execution environment + - Environment is cleaned up automatically after execution + + For stateful execution (stateful=True): + - Uses persistent REPL session that maintains state between requests + - Variables, functions, and imports persist across calls + - Returns session_id to continue the session in subsequent requests + - Supports async/await at top level Parameters ---------- @@ -56,6 +73,15 @@ def execute_code( files : typing.Optional[typing.Dict[str, typing.Optional[str]]] Additional files to create in execution directory + stateful : typing.Optional[bool] + Enable stateful execution with persistent REPL session + + session_id : typing.Optional[str] + Session ID for stateful execution (reuse existing session) + + cwd : typing.Optional[str] + Working directory for code execution + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -76,13 +102,23 @@ def execute_code( ) """ _response = self._raw_client.execute_code( - code=code, timeout=timeout, stdin=stdin, files=files, request_options=request_options + code=code, + timeout=timeout, + stdin=stdin, + files=files, + stateful=stateful, + session_id=session_id, + cwd=cwd, + request_options=request_options, ) return _response.data def get_info(self, *, request_options: typing.Optional[RequestOptions] = None) -> ResponseNodeJsRuntimeInfo: """ - Get information about Node.js runtime and available languages + Get information about Node.js REPL runtime, including installed packages + + Returns Node.js version, npm version, and lists of installed packages + from both the runtime directory and global npm directory. Parameters ---------- @@ -106,6 +142,200 @@ def get_info(self, *, request_options: typing.Optional[RequestOptions] = None) - _response = self._raw_client.get_info(request_options=request_options) return _response.data + def list_sessions( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> ResponseNodeJsSessionListResponse: + """ + List all active Node.js REPL sessions + + Returns information about all active sessions including their state, + working directory, and idle time. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ResponseNodeJsSessionListResponse + Successful Response + + Examples + -------- + from agent_sandbox import Sandbox + + client = Sandbox( + base_url="https://yourhost.com/path/to/api", + ) + client.nodejs.list_sessions() + """ + _response = self._raw_client.list_sessions(request_options=request_options) + return _response.data + + def create_session( + self, + *, + session_id: typing.Optional[str] = OMIT, + cwd: typing.Optional[str] = OMIT, + max_idle_time: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ResponseNodeJsCreateSessionResponse: + """ + Create a new Node.js REPL session + + Creates a new persistent REPL session with configurable working directory + and idle timeout. Use the returned session_id in subsequent execute requests. + + Parameters + ---------- + session_id : typing.Optional[str] + Custom session ID (auto-generated if not provided) + + cwd : typing.Optional[str] + Working directory for the session + + max_idle_time : typing.Optional[int] + Maximum idle time in seconds (default 24 hours) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ResponseNodeJsCreateSessionResponse + Successful Response + + Examples + -------- + from agent_sandbox import Sandbox + + client = Sandbox( + base_url="https://yourhost.com/path/to/api", + ) + client.nodejs.create_session() + """ + _response = self._raw_client.create_session( + session_id=session_id, cwd=cwd, max_idle_time=max_idle_time, request_options=request_options + ) + return _response.data + + def get_session( + self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ResponseNodeJsSessionResponse: + """ + Get information about a specific Node.js REPL session + + Returns detailed information about a session including its state, + working directory, creation time, and idle time. + + Parameters + ---------- + session_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ResponseNodeJsSessionResponse + Successful Response + + Examples + -------- + from agent_sandbox import Sandbox + + client = Sandbox( + base_url="https://yourhost.com/path/to/api", + ) + client.nodejs.get_session( + session_id="session_id", + ) + """ + _response = self._raw_client.get_session(session_id, request_options=request_options) + return _response.data + + def delete_session( + self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ResponseNodeJsDeleteSessionResponse: + """ + Delete a Node.js REPL session + + Terminates the session and releases all associated resources. + + Parameters + ---------- + session_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ResponseNodeJsDeleteSessionResponse + Successful Response + + Examples + -------- + from agent_sandbox import Sandbox + + client = Sandbox( + base_url="https://yourhost.com/path/to/api", + ) + client.nodejs.delete_session( + session_id="session_id", + ) + """ + _response = self._raw_client.delete_session(session_id, request_options=request_options) + return _response.data + + def update_session( + self, + session_id: str, + *, + max_idle_time: typing.Optional[int] = OMIT, + cwd: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ResponseNodeJsUpdateSessionResponse: + """ + Update a Node.js REPL session configuration + + Updates session properties like maximum idle time or working directory. + + Parameters + ---------- + session_id : str + + max_idle_time : typing.Optional[int] + New maximum idle time in seconds + + cwd : typing.Optional[str] + New working directory + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ResponseNodeJsUpdateSessionResponse + Successful Response + + Examples + -------- + from agent_sandbox import Sandbox + + client = Sandbox( + base_url="https://yourhost.com/path/to/api", + ) + client.nodejs.update_session( + session_id="session_id", + ) + """ + _response = self._raw_client.update_session( + session_id, max_idle_time=max_idle_time, cwd=cwd, request_options=request_options + ) + return _response.data + class AsyncNodejsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -129,13 +359,25 @@ async def execute_code( timeout: typing.Optional[int] = OMIT, stdin: typing.Optional[str] = OMIT, files: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + stateful: typing.Optional[bool] = OMIT, + session_id: typing.Optional[str] = OMIT, + cwd: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> ResponseNodeJsExecuteResponse: """ Execute JavaScript code using Node.js This endpoint allows you to execute JavaScript code and get results back. - Each request creates a fresh execution environment that's cleaned up automatically. + + For stateless execution (default): + - Each request creates a fresh execution environment + - Environment is cleaned up automatically after execution + + For stateful execution (stateful=True): + - Uses persistent REPL session that maintains state between requests + - Variables, functions, and imports persist across calls + - Returns session_id to continue the session in subsequent requests + - Supports async/await at top level Parameters ---------- @@ -151,6 +393,15 @@ async def execute_code( files : typing.Optional[typing.Dict[str, typing.Optional[str]]] Additional files to create in execution directory + stateful : typing.Optional[bool] + Enable stateful execution with persistent REPL session + + session_id : typing.Optional[str] + Session ID for stateful execution (reuse existing session) + + cwd : typing.Optional[str] + Working directory for code execution + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -179,13 +430,23 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._raw_client.execute_code( - code=code, timeout=timeout, stdin=stdin, files=files, request_options=request_options + code=code, + timeout=timeout, + stdin=stdin, + files=files, + stateful=stateful, + session_id=session_id, + cwd=cwd, + request_options=request_options, ) return _response.data async def get_info(self, *, request_options: typing.Optional[RequestOptions] = None) -> ResponseNodeJsRuntimeInfo: """ - Get information about Node.js runtime and available languages + Get information about Node.js REPL runtime, including installed packages + + Returns Node.js version, npm version, and lists of installed packages + from both the runtime directory and global npm directory. Parameters ---------- @@ -216,3 +477,237 @@ async def main() -> None: """ _response = await self._raw_client.get_info(request_options=request_options) return _response.data + + async def list_sessions( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> ResponseNodeJsSessionListResponse: + """ + List all active Node.js REPL sessions + + Returns information about all active sessions including their state, + working directory, and idle time. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ResponseNodeJsSessionListResponse + Successful Response + + Examples + -------- + import asyncio + + from agent_sandbox import AsyncSandbox + + client = AsyncSandbox( + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.nodejs.list_sessions() + + + asyncio.run(main()) + """ + _response = await self._raw_client.list_sessions(request_options=request_options) + return _response.data + + async def create_session( + self, + *, + session_id: typing.Optional[str] = OMIT, + cwd: typing.Optional[str] = OMIT, + max_idle_time: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ResponseNodeJsCreateSessionResponse: + """ + Create a new Node.js REPL session + + Creates a new persistent REPL session with configurable working directory + and idle timeout. Use the returned session_id in subsequent execute requests. + + Parameters + ---------- + session_id : typing.Optional[str] + Custom session ID (auto-generated if not provided) + + cwd : typing.Optional[str] + Working directory for the session + + max_idle_time : typing.Optional[int] + Maximum idle time in seconds (default 24 hours) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ResponseNodeJsCreateSessionResponse + Successful Response + + Examples + -------- + import asyncio + + from agent_sandbox import AsyncSandbox + + client = AsyncSandbox( + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.nodejs.create_session() + + + asyncio.run(main()) + """ + _response = await self._raw_client.create_session( + session_id=session_id, cwd=cwd, max_idle_time=max_idle_time, request_options=request_options + ) + return _response.data + + async def get_session( + self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ResponseNodeJsSessionResponse: + """ + Get information about a specific Node.js REPL session + + Returns detailed information about a session including its state, + working directory, creation time, and idle time. + + Parameters + ---------- + session_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ResponseNodeJsSessionResponse + Successful Response + + Examples + -------- + import asyncio + + from agent_sandbox import AsyncSandbox + + client = AsyncSandbox( + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.nodejs.get_session( + session_id="session_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get_session(session_id, request_options=request_options) + return _response.data + + async def delete_session( + self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ResponseNodeJsDeleteSessionResponse: + """ + Delete a Node.js REPL session + + Terminates the session and releases all associated resources. + + Parameters + ---------- + session_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ResponseNodeJsDeleteSessionResponse + Successful Response + + Examples + -------- + import asyncio + + from agent_sandbox import AsyncSandbox + + client = AsyncSandbox( + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.nodejs.delete_session( + session_id="session_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete_session(session_id, request_options=request_options) + return _response.data + + async def update_session( + self, + session_id: str, + *, + max_idle_time: typing.Optional[int] = OMIT, + cwd: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> ResponseNodeJsUpdateSessionResponse: + """ + Update a Node.js REPL session configuration + + Updates session properties like maximum idle time or working directory. + + Parameters + ---------- + session_id : str + + max_idle_time : typing.Optional[int] + New maximum idle time in seconds + + cwd : typing.Optional[str] + New working directory + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ResponseNodeJsUpdateSessionResponse + Successful Response + + Examples + -------- + import asyncio + + from agent_sandbox import AsyncSandbox + + client = AsyncSandbox( + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.nodejs.update_session( + session_id="session_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.update_session( + session_id, max_idle_time=max_idle_time, cwd=cwd, request_options=request_options + ) + return _response.data diff --git a/sdk/python/agent_sandbox/nodejs/raw_client.py b/sdk/python/agent_sandbox/nodejs/raw_client.py index 97beab1..2e3736f 100644 --- a/sdk/python/agent_sandbox/nodejs/raw_client.py +++ b/sdk/python/agent_sandbox/nodejs/raw_client.py @@ -6,12 +6,18 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.http_validation_error import HttpValidationError +from ..types.response_node_js_create_session_response import ResponseNodeJsCreateSessionResponse +from ..types.response_node_js_delete_session_response import ResponseNodeJsDeleteSessionResponse from ..types.response_node_js_execute_response import ResponseNodeJsExecuteResponse from ..types.response_node_js_runtime_info import ResponseNodeJsRuntimeInfo +from ..types.response_node_js_session_list_response import ResponseNodeJsSessionListResponse +from ..types.response_node_js_session_response import ResponseNodeJsSessionResponse +from ..types.response_node_js_update_session_response import ResponseNodeJsUpdateSessionResponse # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -28,13 +34,25 @@ def execute_code( timeout: typing.Optional[int] = OMIT, stdin: typing.Optional[str] = OMIT, files: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + stateful: typing.Optional[bool] = OMIT, + session_id: typing.Optional[str] = OMIT, + cwd: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[ResponseNodeJsExecuteResponse]: """ Execute JavaScript code using Node.js This endpoint allows you to execute JavaScript code and get results back. - Each request creates a fresh execution environment that's cleaned up automatically. + + For stateless execution (default): + - Each request creates a fresh execution environment + - Environment is cleaned up automatically after execution + + For stateful execution (stateful=True): + - Uses persistent REPL session that maintains state between requests + - Variables, functions, and imports persist across calls + - Returns session_id to continue the session in subsequent requests + - Supports async/await at top level Parameters ---------- @@ -50,6 +68,15 @@ def execute_code( files : typing.Optional[typing.Dict[str, typing.Optional[str]]] Additional files to create in execution directory + stateful : typing.Optional[bool] + Enable stateful execution with persistent REPL session + + session_id : typing.Optional[str] + Session ID for stateful execution (reuse existing session) + + cwd : typing.Optional[str] + Working directory for code execution + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -66,6 +93,9 @@ def execute_code( "timeout": timeout, "stdin": stdin, "files": files, + "stateful": stateful, + "session_id": session_id, + "cwd": cwd, }, headers={ "content-type": "application/json", @@ -103,7 +133,10 @@ def get_info( self, *, request_options: typing.Optional[RequestOptions] = None ) -> HttpResponse[ResponseNodeJsRuntimeInfo]: """ - Get information about Node.js runtime and available languages + Get information about Node.js REPL runtime, including installed packages + + Returns Node.js version, npm version, and lists of installed packages + from both the runtime directory and global npm directory. Parameters ---------- @@ -135,6 +168,291 @@ def get_info( raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + def list_sessions( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ResponseNodeJsSessionListResponse]: + """ + List all active Node.js REPL sessions + + Returns information about all active sessions including their state, + working directory, and idle time. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ResponseNodeJsSessionListResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/nodejs/sessions", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ResponseNodeJsSessionListResponse, + parse_obj_as( + type_=ResponseNodeJsSessionListResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def create_session( + self, + *, + session_id: typing.Optional[str] = OMIT, + cwd: typing.Optional[str] = OMIT, + max_idle_time: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ResponseNodeJsCreateSessionResponse]: + """ + Create a new Node.js REPL session + + Creates a new persistent REPL session with configurable working directory + and idle timeout. Use the returned session_id in subsequent execute requests. + + Parameters + ---------- + session_id : typing.Optional[str] + Custom session ID (auto-generated if not provided) + + cwd : typing.Optional[str] + Working directory for the session + + max_idle_time : typing.Optional[int] + Maximum idle time in seconds (default 24 hours) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ResponseNodeJsCreateSessionResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/nodejs/sessions", + method="POST", + json={ + "session_id": session_id, + "cwd": cwd, + "max_idle_time": max_idle_time, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ResponseNodeJsCreateSessionResponse, + parse_obj_as( + type_=ResponseNodeJsCreateSessionResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + parse_obj_as( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get_session( + self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ResponseNodeJsSessionResponse]: + """ + Get information about a specific Node.js REPL session + + Returns detailed information about a session including its state, + working directory, creation time, and idle time. + + Parameters + ---------- + session_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ResponseNodeJsSessionResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/nodejs/sessions/{jsonable_encoder(session_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ResponseNodeJsSessionResponse, + parse_obj_as( + type_=ResponseNodeJsSessionResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + parse_obj_as( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete_session( + self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ResponseNodeJsDeleteSessionResponse]: + """ + Delete a Node.js REPL session + + Terminates the session and releases all associated resources. + + Parameters + ---------- + session_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ResponseNodeJsDeleteSessionResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/nodejs/sessions/{jsonable_encoder(session_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ResponseNodeJsDeleteSessionResponse, + parse_obj_as( + type_=ResponseNodeJsDeleteSessionResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + parse_obj_as( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update_session( + self, + session_id: str, + *, + max_idle_time: typing.Optional[int] = OMIT, + cwd: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ResponseNodeJsUpdateSessionResponse]: + """ + Update a Node.js REPL session configuration + + Updates session properties like maximum idle time or working directory. + + Parameters + ---------- + session_id : str + + max_idle_time : typing.Optional[int] + New maximum idle time in seconds + + cwd : typing.Optional[str] + New working directory + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ResponseNodeJsUpdateSessionResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/nodejs/sessions/{jsonable_encoder(session_id)}", + method="PATCH", + json={ + "max_idle_time": max_idle_time, + "cwd": cwd, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ResponseNodeJsUpdateSessionResponse, + parse_obj_as( + type_=ResponseNodeJsUpdateSessionResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + parse_obj_as( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + class AsyncRawNodejsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -147,13 +465,25 @@ async def execute_code( timeout: typing.Optional[int] = OMIT, stdin: typing.Optional[str] = OMIT, files: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + stateful: typing.Optional[bool] = OMIT, + session_id: typing.Optional[str] = OMIT, + cwd: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[ResponseNodeJsExecuteResponse]: """ Execute JavaScript code using Node.js This endpoint allows you to execute JavaScript code and get results back. - Each request creates a fresh execution environment that's cleaned up automatically. + + For stateless execution (default): + - Each request creates a fresh execution environment + - Environment is cleaned up automatically after execution + + For stateful execution (stateful=True): + - Uses persistent REPL session that maintains state between requests + - Variables, functions, and imports persist across calls + - Returns session_id to continue the session in subsequent requests + - Supports async/await at top level Parameters ---------- @@ -169,6 +499,15 @@ async def execute_code( files : typing.Optional[typing.Dict[str, typing.Optional[str]]] Additional files to create in execution directory + stateful : typing.Optional[bool] + Enable stateful execution with persistent REPL session + + session_id : typing.Optional[str] + Session ID for stateful execution (reuse existing session) + + cwd : typing.Optional[str] + Working directory for code execution + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -185,6 +524,9 @@ async def execute_code( "timeout": timeout, "stdin": stdin, "files": files, + "stateful": stateful, + "session_id": session_id, + "cwd": cwd, }, headers={ "content-type": "application/json", @@ -222,7 +564,10 @@ async def get_info( self, *, request_options: typing.Optional[RequestOptions] = None ) -> AsyncHttpResponse[ResponseNodeJsRuntimeInfo]: """ - Get information about Node.js runtime and available languages + Get information about Node.js REPL runtime, including installed packages + + Returns Node.js version, npm version, and lists of installed packages + from both the runtime directory and global npm directory. Parameters ---------- @@ -253,3 +598,288 @@ async def get_info( except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def list_sessions( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ResponseNodeJsSessionListResponse]: + """ + List all active Node.js REPL sessions + + Returns information about all active sessions including their state, + working directory, and idle time. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ResponseNodeJsSessionListResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/nodejs/sessions", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ResponseNodeJsSessionListResponse, + parse_obj_as( + type_=ResponseNodeJsSessionListResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def create_session( + self, + *, + session_id: typing.Optional[str] = OMIT, + cwd: typing.Optional[str] = OMIT, + max_idle_time: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ResponseNodeJsCreateSessionResponse]: + """ + Create a new Node.js REPL session + + Creates a new persistent REPL session with configurable working directory + and idle timeout. Use the returned session_id in subsequent execute requests. + + Parameters + ---------- + session_id : typing.Optional[str] + Custom session ID (auto-generated if not provided) + + cwd : typing.Optional[str] + Working directory for the session + + max_idle_time : typing.Optional[int] + Maximum idle time in seconds (default 24 hours) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ResponseNodeJsCreateSessionResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/nodejs/sessions", + method="POST", + json={ + "session_id": session_id, + "cwd": cwd, + "max_idle_time": max_idle_time, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ResponseNodeJsCreateSessionResponse, + parse_obj_as( + type_=ResponseNodeJsCreateSessionResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + parse_obj_as( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get_session( + self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ResponseNodeJsSessionResponse]: + """ + Get information about a specific Node.js REPL session + + Returns detailed information about a session including its state, + working directory, creation time, and idle time. + + Parameters + ---------- + session_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ResponseNodeJsSessionResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/nodejs/sessions/{jsonable_encoder(session_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ResponseNodeJsSessionResponse, + parse_obj_as( + type_=ResponseNodeJsSessionResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + parse_obj_as( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete_session( + self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ResponseNodeJsDeleteSessionResponse]: + """ + Delete a Node.js REPL session + + Terminates the session and releases all associated resources. + + Parameters + ---------- + session_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ResponseNodeJsDeleteSessionResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/nodejs/sessions/{jsonable_encoder(session_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ResponseNodeJsDeleteSessionResponse, + parse_obj_as( + type_=ResponseNodeJsDeleteSessionResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + parse_obj_as( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update_session( + self, + session_id: str, + *, + max_idle_time: typing.Optional[int] = OMIT, + cwd: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ResponseNodeJsUpdateSessionResponse]: + """ + Update a Node.js REPL session configuration + + Updates session properties like maximum idle time or working directory. + + Parameters + ---------- + session_id : str + + max_idle_time : typing.Optional[int] + New maximum idle time in seconds + + cwd : typing.Optional[str] + New working directory + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ResponseNodeJsUpdateSessionResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/nodejs/sessions/{jsonable_encoder(session_id)}", + method="PATCH", + json={ + "max_idle_time": max_idle_time, + "cwd": cwd, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ResponseNodeJsUpdateSessionResponse, + parse_obj_as( + type_=ResponseNodeJsUpdateSessionResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + parse_obj_as( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/sdk/python/agent_sandbox/types/__init__.py b/sdk/python/agent_sandbox/types/__init__.py index 23cc347..eb72124 100644 --- a/sdk/python/agent_sandbox/types/__init__.py +++ b/sdk/python/agent_sandbox/types/__init__.py @@ -6,6 +6,7 @@ from importlib import import_module if typing.TYPE_CHECKING: + from .action_data import ActionData from .action_response import ActionResponse from .active_sessions_result import ActiveSessionsResult from .active_shell_sessions_result import ActiveShellSessionsResult @@ -54,9 +55,16 @@ from .mouse_up_action import MouseUpAction from .move_rel_action import MoveRelAction from .move_to_action import MoveToAction + from .node_js_create_session_response import NodeJsCreateSessionResponse + from .node_js_delete_session_response import NodeJsDeleteSessionResponse from .node_js_execute_response import NodeJsExecuteResponse from .node_js_output import NodeJsOutput + from .node_js_package_info import NodeJsPackageInfo from .node_js_runtime_info import NodeJsRuntimeInfo + from .node_js_session_info import NodeJsSessionInfo + from .node_js_session_list_response import NodeJsSessionListResponse + from .node_js_session_response import NodeJsSessionResponse + from .node_js_update_session_response import NodeJsUpdateSessionResponse from .press_action import PressAction from .resolution import Resolution from .resource import Resource @@ -89,8 +97,13 @@ from .response_jupyter_info_response import ResponseJupyterInfoResponse from .response_list_str import ResponseListStr from .response_list_tools_result_model import ResponseListToolsResultModel + from .response_node_js_create_session_response import ResponseNodeJsCreateSessionResponse + from .response_node_js_delete_session_response import ResponseNodeJsDeleteSessionResponse from .response_node_js_execute_response import ResponseNodeJsExecuteResponse from .response_node_js_runtime_info import ResponseNodeJsRuntimeInfo + from .response_node_js_session_list_response import ResponseNodeJsSessionListResponse + from .response_node_js_session_response import ResponseNodeJsSessionResponse + from .response_node_js_update_session_response import ResponseNodeJsUpdateSessionResponse from .response_shell_command_result import ResponseShellCommandResult from .response_shell_create_session_response import ResponseShellCreateSessionResponse from .response_shell_kill_result import ResponseShellKillResult @@ -135,6 +148,7 @@ from .validation_error_loc_item import ValidationErrorLocItem from .wait_action import WaitAction _dynamic_imports: typing.Dict[str, str] = { + "ActionData": ".action_data", "ActionResponse": ".action_response", "ActiveSessionsResult": ".active_sessions_result", "ActiveShellSessionsResult": ".active_shell_sessions_result", @@ -183,9 +197,16 @@ "MouseUpAction": ".mouse_up_action", "MoveRelAction": ".move_rel_action", "MoveToAction": ".move_to_action", + "NodeJsCreateSessionResponse": ".node_js_create_session_response", + "NodeJsDeleteSessionResponse": ".node_js_delete_session_response", "NodeJsExecuteResponse": ".node_js_execute_response", "NodeJsOutput": ".node_js_output", + "NodeJsPackageInfo": ".node_js_package_info", "NodeJsRuntimeInfo": ".node_js_runtime_info", + "NodeJsSessionInfo": ".node_js_session_info", + "NodeJsSessionListResponse": ".node_js_session_list_response", + "NodeJsSessionResponse": ".node_js_session_response", + "NodeJsUpdateSessionResponse": ".node_js_update_session_response", "PressAction": ".press_action", "Resolution": ".resolution", "Resource": ".resource", @@ -216,8 +237,13 @@ "ResponseJupyterInfoResponse": ".response_jupyter_info_response", "ResponseListStr": ".response_list_str", "ResponseListToolsResultModel": ".response_list_tools_result_model", + "ResponseNodeJsCreateSessionResponse": ".response_node_js_create_session_response", + "ResponseNodeJsDeleteSessionResponse": ".response_node_js_delete_session_response", "ResponseNodeJsExecuteResponse": ".response_node_js_execute_response", "ResponseNodeJsRuntimeInfo": ".response_node_js_runtime_info", + "ResponseNodeJsSessionListResponse": ".response_node_js_session_list_response", + "ResponseNodeJsSessionResponse": ".response_node_js_session_response", + "ResponseNodeJsUpdateSessionResponse": ".response_node_js_update_session_response", "ResponseShellCommandResult": ".response_shell_command_result", "ResponseShellCreateSessionResponse": ".response_shell_create_session_response", "ResponseShellKillResult": ".response_shell_kill_result", @@ -284,6 +310,7 @@ def __dir__(): __all__ = [ + "ActionData", "ActionResponse", "ActiveSessionsResult", "ActiveShellSessionsResult", @@ -332,9 +359,16 @@ def __dir__(): "MouseUpAction", "MoveRelAction", "MoveToAction", + "NodeJsCreateSessionResponse", + "NodeJsDeleteSessionResponse", "NodeJsExecuteResponse", "NodeJsOutput", + "NodeJsPackageInfo", "NodeJsRuntimeInfo", + "NodeJsSessionInfo", + "NodeJsSessionListResponse", + "NodeJsSessionResponse", + "NodeJsUpdateSessionResponse", "PressAction", "Resolution", "Resource", @@ -365,8 +399,13 @@ def __dir__(): "ResponseJupyterInfoResponse", "ResponseListStr", "ResponseListToolsResultModel", + "ResponseNodeJsCreateSessionResponse", + "ResponseNodeJsDeleteSessionResponse", "ResponseNodeJsExecuteResponse", "ResponseNodeJsRuntimeInfo", + "ResponseNodeJsSessionListResponse", + "ResponseNodeJsSessionResponse", + "ResponseNodeJsUpdateSessionResponse", "ResponseShellCommandResult", "ResponseShellCreateSessionResponse", "ResponseShellKillResult", diff --git a/sdk/python/agent_sandbox/types/action_data.py b/sdk/python/agent_sandbox/types/action_data.py new file mode 100644 index 0000000..e6d50c8 --- /dev/null +++ b/sdk/python/agent_sandbox/types/action_data.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel + + +class ActionData(UniversalBaseModel): + """ + Inner data for action response. + """ + + status: typing.Literal["success"] = "success" + action_performed: str + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/sdk/python/agent_sandbox/types/action_response.py b/sdk/python/agent_sandbox/types/action_response.py index ce81c11..4f853d8 100644 --- a/sdk/python/agent_sandbox/types/action_response.py +++ b/sdk/python/agent_sandbox/types/action_response.py @@ -4,11 +4,21 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .action_data import ActionData class ActionResponse(UniversalBaseModel): + """ + Response model for browser actions. + + Provides backward compatibility: + - Old format: resp.json()['status'], resp.json()['action_performed'] + - New format: resp.json()['data']['status'], resp.json()['data']['action_performed'] + """ + status: typing.Literal["success"] = "success" action_performed: str + data: typing.Optional[ActionData] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/sdk/python/agent_sandbox/types/code_execute_response.py b/sdk/python/agent_sandbox/types/code_execute_response.py index 692b91f..a0699e5 100644 --- a/sdk/python/agent_sandbox/types/code_execute_response.py +++ b/sdk/python/agent_sandbox/types/code_execute_response.py @@ -52,6 +52,11 @@ class CodeExecuteResponse(UniversalBaseModel): Captured error traceback lines when available """ + session_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Session ID for stateful execution (only present when stateful=True) + """ + if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 else: diff --git a/sdk/python/agent_sandbox/types/node_js_create_session_response.py b/sdk/python/agent_sandbox/types/node_js_create_session_response.py new file mode 100644 index 0000000..7aeaed7 --- /dev/null +++ b/sdk/python/agent_sandbox/types/node_js_create_session_response.py @@ -0,0 +1,38 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .node_js_session_info import NodeJsSessionInfo + + +class NodeJsCreateSessionResponse(UniversalBaseModel): + session_id: str = pydantic.Field() + """ + Session ID + """ + + created: bool = pydantic.Field() + """ + Whether the session was newly created + """ + + message: typing.Optional[str] = pydantic.Field(default=None) + """ + Additional message (e.g., if session already exists) + """ + + session: typing.Optional[NodeJsSessionInfo] = pydantic.Field(default=None) + """ + Session information (if created) + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/sdk/python/agent_sandbox/types/node_js_delete_session_response.py b/sdk/python/agent_sandbox/types/node_js_delete_session_response.py new file mode 100644 index 0000000..7c6292c --- /dev/null +++ b/sdk/python/agent_sandbox/types/node_js_delete_session_response.py @@ -0,0 +1,22 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel + + +class NodeJsDeleteSessionResponse(UniversalBaseModel): + deleted: bool = pydantic.Field() + """ + Whether the session was deleted + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/sdk/python/agent_sandbox/types/node_js_execute_response.py b/sdk/python/agent_sandbox/types/node_js_execute_response.py index c1f9fda..c821c06 100644 --- a/sdk/python/agent_sandbox/types/node_js_execute_response.py +++ b/sdk/python/agent_sandbox/types/node_js_execute_response.py @@ -48,6 +48,11 @@ class NodeJsExecuteResponse(UniversalBaseModel): Process exit code """ + session_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Session ID for stateful execution (use this to continue the session) + """ + if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 else: diff --git a/sdk/python/agent_sandbox/types/node_js_package_info.py b/sdk/python/agent_sandbox/types/node_js_package_info.py new file mode 100644 index 0000000..480ec36 --- /dev/null +++ b/sdk/python/agent_sandbox/types/node_js_package_info.py @@ -0,0 +1,31 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel + + +class NodeJsPackageInfo(UniversalBaseModel): + """ + Package information + """ + + name: str = pydantic.Field() + """ + Package name + """ + + version: str = pydantic.Field() + """ + Package version + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/sdk/python/agent_sandbox/types/node_js_runtime_info.py b/sdk/python/agent_sandbox/types/node_js_runtime_info.py index 99965a2..006add1 100644 --- a/sdk/python/agent_sandbox/types/node_js_runtime_info.py +++ b/sdk/python/agent_sandbox/types/node_js_runtime_info.py @@ -4,6 +4,7 @@ import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .node_js_package_info import NodeJsPackageInfo class NodeJsRuntimeInfo(UniversalBaseModel): @@ -36,6 +37,21 @@ class NodeJsRuntimeInfo(UniversalBaseModel): Runtime directory path """ + global_npm_directory: typing.Optional[str] = pydantic.Field(default=None) + """ + Global npm directory path + """ + + runtime_packages: typing.Optional[typing.List[NodeJsPackageInfo]] = pydantic.Field(default=None) + """ + Pre-installed runtime packages + """ + + global_packages: typing.Optional[typing.List[NodeJsPackageInfo]] = pydantic.Field(default=None) + """ + Globally installed npm packages + """ + error: typing.Optional[str] = pydantic.Field(default=None) """ Error message if runtime info retrieval failed diff --git a/sdk/python/agent_sandbox/types/node_js_session_info.py b/sdk/python/agent_sandbox/types/node_js_session_info.py new file mode 100644 index 0000000..638c66c --- /dev/null +++ b/sdk/python/agent_sandbox/types/node_js_session_info.py @@ -0,0 +1,52 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel + + +class NodeJsSessionInfo(UniversalBaseModel): + session_id: str = pydantic.Field() + """ + Session ID + """ + + cwd: str = pydantic.Field() + """ + Working directory + """ + + created_at: float = pydantic.Field() + """ + Session creation timestamp (ms since epoch) + """ + + last_used: float = pydantic.Field() + """ + Last activity timestamp (ms since epoch) + """ + + max_idle_time: int = pydantic.Field() + """ + Maximum idle time in milliseconds + """ + + age_seconds: int = pydantic.Field() + """ + Seconds since last activity + """ + + state: str = pydantic.Field() + """ + Session state: IDLE or EXECUTING + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/sdk/python/agent_sandbox/types/node_js_session_list_response.py b/sdk/python/agent_sandbox/types/node_js_session_list_response.py new file mode 100644 index 0000000..84220c7 --- /dev/null +++ b/sdk/python/agent_sandbox/types/node_js_session_list_response.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .node_js_session_info import NodeJsSessionInfo + + +class NodeJsSessionListResponse(UniversalBaseModel): + sessions: typing.Optional[typing.Dict[str, NodeJsSessionInfo]] = pydantic.Field(default=None) + """ + Map of session ID to session info + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/sdk/python/agent_sandbox/types/node_js_session_response.py b/sdk/python/agent_sandbox/types/node_js_session_response.py new file mode 100644 index 0000000..953ac76 --- /dev/null +++ b/sdk/python/agent_sandbox/types/node_js_session_response.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .node_js_session_info import NodeJsSessionInfo + + +class NodeJsSessionResponse(UniversalBaseModel): + session: NodeJsSessionInfo = pydantic.Field() + """ + Session information + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/sdk/python/agent_sandbox/types/node_js_update_session_response.py b/sdk/python/agent_sandbox/types/node_js_update_session_response.py new file mode 100644 index 0000000..03b8d1e --- /dev/null +++ b/sdk/python/agent_sandbox/types/node_js_update_session_response.py @@ -0,0 +1,28 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .node_js_session_info import NodeJsSessionInfo + + +class NodeJsUpdateSessionResponse(UniversalBaseModel): + updated: bool = pydantic.Field() + """ + Whether the update was successful + """ + + session: NodeJsSessionInfo = pydantic.Field() + """ + Updated session information + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/sdk/python/agent_sandbox/types/response_node_js_create_session_response.py b/sdk/python/agent_sandbox/types/response_node_js_create_session_response.py new file mode 100644 index 0000000..e717c2d --- /dev/null +++ b/sdk/python/agent_sandbox/types/response_node_js_create_session_response.py @@ -0,0 +1,33 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .node_js_create_session_response import NodeJsCreateSessionResponse + + +class ResponseNodeJsCreateSessionResponse(UniversalBaseModel): + success: typing.Optional[bool] = pydantic.Field(default=None) + """ + Whether the operation was successful + """ + + message: typing.Optional[str] = pydantic.Field(default=None) + """ + Operation result message + """ + + data: typing.Optional[NodeJsCreateSessionResponse] = pydantic.Field(default=None) + """ + Data returned from the operation + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/sdk/python/agent_sandbox/types/response_node_js_delete_session_response.py b/sdk/python/agent_sandbox/types/response_node_js_delete_session_response.py new file mode 100644 index 0000000..cbd3e2b --- /dev/null +++ b/sdk/python/agent_sandbox/types/response_node_js_delete_session_response.py @@ -0,0 +1,33 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .node_js_delete_session_response import NodeJsDeleteSessionResponse + + +class ResponseNodeJsDeleteSessionResponse(UniversalBaseModel): + success: typing.Optional[bool] = pydantic.Field(default=None) + """ + Whether the operation was successful + """ + + message: typing.Optional[str] = pydantic.Field(default=None) + """ + Operation result message + """ + + data: typing.Optional[NodeJsDeleteSessionResponse] = pydantic.Field(default=None) + """ + Data returned from the operation + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/sdk/python/agent_sandbox/types/response_node_js_session_list_response.py b/sdk/python/agent_sandbox/types/response_node_js_session_list_response.py new file mode 100644 index 0000000..ed868b0 --- /dev/null +++ b/sdk/python/agent_sandbox/types/response_node_js_session_list_response.py @@ -0,0 +1,33 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .node_js_session_list_response import NodeJsSessionListResponse + + +class ResponseNodeJsSessionListResponse(UniversalBaseModel): + success: typing.Optional[bool] = pydantic.Field(default=None) + """ + Whether the operation was successful + """ + + message: typing.Optional[str] = pydantic.Field(default=None) + """ + Operation result message + """ + + data: typing.Optional[NodeJsSessionListResponse] = pydantic.Field(default=None) + """ + Data returned from the operation + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/sdk/python/agent_sandbox/types/response_node_js_session_response.py b/sdk/python/agent_sandbox/types/response_node_js_session_response.py new file mode 100644 index 0000000..803280a --- /dev/null +++ b/sdk/python/agent_sandbox/types/response_node_js_session_response.py @@ -0,0 +1,33 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .node_js_session_response import NodeJsSessionResponse + + +class ResponseNodeJsSessionResponse(UniversalBaseModel): + success: typing.Optional[bool] = pydantic.Field(default=None) + """ + Whether the operation was successful + """ + + message: typing.Optional[str] = pydantic.Field(default=None) + """ + Operation result message + """ + + data: typing.Optional[NodeJsSessionResponse] = pydantic.Field(default=None) + """ + Data returned from the operation + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/sdk/python/agent_sandbox/types/response_node_js_update_session_response.py b/sdk/python/agent_sandbox/types/response_node_js_update_session_response.py new file mode 100644 index 0000000..9ba01d6 --- /dev/null +++ b/sdk/python/agent_sandbox/types/response_node_js_update_session_response.py @@ -0,0 +1,33 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel +from .node_js_update_session_response import NodeJsUpdateSessionResponse + + +class ResponseNodeJsUpdateSessionResponse(UniversalBaseModel): + success: typing.Optional[bool] = pydantic.Field(default=None) + """ + Whether the operation was successful + """ + + message: typing.Optional[str] = pydantic.Field(default=None) + """ + Operation result message + """ + + data: typing.Optional[NodeJsUpdateSessionResponse] = pydantic.Field(default=None) + """ + Data returned from the operation + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/sdk/python/agent_sandbox/types/shell_kill_result.py b/sdk/python/agent_sandbox/types/shell_kill_result.py index 1dec99d..0e2fe55 100644 --- a/sdk/python/agent_sandbox/types/shell_kill_result.py +++ b/sdk/python/agent_sandbox/types/shell_kill_result.py @@ -17,9 +17,14 @@ class ShellKillResult(UniversalBaseModel): Process status """ - returncode: int = pydantic.Field() + exit_code: typing.Optional[int] = pydantic.Field(default=None) """ - Process return code + Process exit code before termination, None if process was still running + """ + + returncode: typing.Optional[int] = pydantic.Field(default=None) + """ + Deprecated: use exit_code instead. Kept for backward compatibility. """ if IS_PYDANTIC_V2: diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml index 040b399..b62c44a 100644 --- a/sdk/python/pyproject.toml +++ b/sdk/python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "agent-sandbox" -version = "0.0.20" +version = "0.0.21" description = "Python SDK for the All-in-One Sandbox API, >=1.0.0.156" readme = "README.md" license = { text = "Apache-2.0" } diff --git a/website/docs/public/v1/openapi.json b/website/docs/public/v1/openapi.json index ba2cd4e..187a9b4 100644 --- a/website/docs/public/v1/openapi.json +++ b/website/docs/public/v1/openapi.json @@ -3,7 +3,7 @@ "info": { "title": "FastAPI", "description": "\n- Browser\n - CDP: [/cdp/json/version](/cdp/json/version)\n- Jupyter\n - Notebook: [/jupyter](/jupyter)\n- MCP\n - Streamable HTTP: [/mcp](/mcp) or [/v1/mcp](/v1/mcp)\n", - "version": "1.0.0.143" + "version": "1.0.0.160" }, "paths": { "/v1/sandbox": { @@ -956,7 +956,7 @@ "post": { "tags": ["nodejs"], "summary": "Execute Nodejs Code", - "description": "Execute JavaScript code using Node.js\n\nThis endpoint allows you to execute JavaScript code and get results back.\nEach request creates a fresh execution environment that's cleaned up automatically.", + "description": "Execute JavaScript code using Node.js\n\nThis endpoint allows you to execute JavaScript code and get results back.\n\nFor stateless execution (default):\n- Each request creates a fresh execution environment\n- Environment is cleaned up automatically after execution\n\nFor stateful execution (stateful=True):\n- Uses persistent REPL session that maintains state between requests\n- Variables, functions, and imports persist across calls\n- Returns session_id to continue the session in subsequent requests\n- Supports async/await at top level", "operationId": "execute_nodejs_code", "requestBody": { "content": { @@ -994,7 +994,7 @@ "get": { "tags": ["nodejs"], "summary": "Nodejs Info", - "description": "Get information about Node.js runtime and available languages", + "description": "Get information about Node.js REPL runtime, including installed packages\n\nReturns Node.js version, npm version, and lists of installed packages\nfrom both the runtime directory and global npm directory.", "operationId": "get_nodejs_info", "responses": { "200": { @@ -1012,6 +1012,186 @@ "x-fern-sdk-method-name": "get_info" } }, + "/v1/nodejs/sessions": { + "get": { + "tags": ["nodejs"], + "summary": "List Nodejs Sessions", + "description": "List all active Node.js REPL sessions\n\nReturns information about all active sessions including their state,\nworking directory, and idle time.", + "operationId": "list_nodejs_sessions", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Response_NodeJSSessionListResponse_" + } + } + } + } + }, + "x-fern-sdk-group-name": "nodejs", + "x-fern-sdk-method-name": "list_sessions" + }, + "post": { + "tags": ["nodejs"], + "summary": "Create Nodejs Session", + "description": "Create a new Node.js REPL session\n\nCreates a new persistent REPL session with configurable working directory\nand idle timeout. Use the returned session_id in subsequent execute requests.", + "operationId": "create_nodejs_session", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NodeJSCreateSessionRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Response_NodeJSCreateSessionResponse_" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + }, + "x-fern-sdk-group-name": "nodejs", + "x-fern-sdk-method-name": "create_session" + } + }, + "/v1/nodejs/sessions/{session_id}": { + "get": { + "tags": ["nodejs"], + "summary": "Get Nodejs Session", + "description": "Get information about a specific Node.js REPL session\n\nReturns detailed information about a session including its state,\nworking directory, creation time, and idle time.", + "operationId": "get_nodejs_session", + "parameters": [ + { + "name": "session_id", + "in": "path", + "required": true, + "schema": { "type": "string", "title": "Session Id" } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Response_NodeJSSessionResponse_" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + }, + "x-fern-sdk-group-name": "nodejs", + "x-fern-sdk-method-name": "get_session" + }, + "patch": { + "tags": ["nodejs"], + "summary": "Update Nodejs Session", + "description": "Update a Node.js REPL session configuration\n\nUpdates session properties like maximum idle time or working directory.", + "operationId": "update_nodejs_session", + "parameters": [ + { + "name": "session_id", + "in": "path", + "required": true, + "schema": { "type": "string", "title": "Session Id" } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NodeJSUpdateSessionRequest" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Response_NodeJSUpdateSessionResponse_" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + }, + "x-fern-sdk-group-name": "nodejs", + "x-fern-sdk-method-name": "update_session" + }, + "delete": { + "tags": ["nodejs"], + "summary": "Delete Nodejs Session", + "description": "Delete a Node.js REPL session\n\nTerminates the session and releases all associated resources.", + "operationId": "delete_nodejs_session", + "parameters": [ + { + "name": "session_id", + "in": "path", + "required": true, + "schema": { "type": "string", "title": "Session Id" } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Response_NodeJSDeleteSessionResponse_" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/HTTPValidationError" } + } + } + } + }, + "x-fern-sdk-group-name": "nodejs", + "x-fern-sdk-method-name": "delete_session" + } + }, "/v1/mcp/{server_name}/tools": { "get": { "tags": ["mcp"], @@ -1587,14 +1767,31 @@ }, "components": { "schemas": { - "ActionResponse": { + "ActionData": { "properties": { "status": { "type": "string", "const": "success", "title": "Status" }, "action_performed": { "type": "string", "title": "Action Performed" } }, "type": "object", "required": ["status", "action_performed"], - "title": "ActionResponse" + "title": "ActionData", + "description": "Inner data for action response." + }, + "ActionResponse": { + "properties": { + "status": { "type": "string", "const": "success", "title": "Status" }, + "action_performed": { "type": "string", "title": "Action Performed" }, + "data": { + "anyOf": [ + { "$ref": "#/components/schemas/ActionData" }, + { "type": "null" } + ] + } + }, + "type": "object", + "required": ["status", "action_performed"], + "title": "ActionResponse", + "description": "Response model for browser actions.\n\nProvides backward compatibility:\n- Old format: resp.json()['status'], resp.json()['action_performed']\n- New format: resp.json()['data']['status'], resp.json()['data']['action_performed']" }, "ActiveSessionsResult": { "properties": { @@ -1879,6 +2076,17 @@ "title": "Cwd", "description": "Current working directory for code execution", "default": "/tmp" + }, + "stateful": { + "type": "boolean", + "title": "Stateful", + "description": "Enable stateful execution using Jupyter kernel. When True, variables and state persist across requests with the same session_id.", + "default": false + }, + "session_id": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Session Id", + "description": "Session ID for stateful execution. Required when stateful=True to maintain state across requests. Auto-generated if not provided." } }, "type": "object", @@ -1930,6 +2138,11 @@ ], "title": "Traceback", "description": "Captured error traceback lines when available" + }, + "session_id": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Session Id", + "description": "Session ID for stateful execution (only present when stateful=True)" } }, "type": "object", @@ -2653,7 +2866,7 @@ "kernel_name": { "anyOf": [{ "type": "string" }, { "type": "null" }], "title": "Kernel Name", - "description": "Kernel name to use (e.g., 'python3', 'python3.11', 'python3.12'). Defaults to 'python3'", + "description": "Kernel name: 'python3', 'python3.10', 'python3.11', 'python3.12'. Defaults to 'python3'.", "default": "python3" }, "cwd": { @@ -2709,7 +2922,7 @@ "kernel_name": { "anyOf": [{ "type": "string" }, { "type": "null" }], "title": "Kernel Name", - "description": "Kernel name to use (e.g., 'python3', 'python3.11', 'python3.12'). Defaults to 'python3'", + "description": "Kernel name: 'python3', 'python3.10', 'python3.11', 'python3.12'. Defaults to 'python3'.", "default": "python3" }, "session_id": { @@ -3003,6 +3216,73 @@ "required": ["x", "y"], "title": "MoveToAction" }, + "NodeJSCreateSessionRequest": { + "properties": { + "session_id": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Session Id", + "description": "Custom session ID (auto-generated if not provided)" + }, + "cwd": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Cwd", + "description": "Working directory for the session", + "default": "/tmp" + }, + "max_idle_time": { + "anyOf": [ + { "type": "integer", "maximum": 86400.0, "minimum": 60.0 }, + { "type": "null" } + ], + "title": "Max Idle Time", + "description": "Maximum idle time in seconds (default 24 hours)", + "default": 86400 + } + }, + "type": "object", + "title": "NodeJSCreateSessionRequest" + }, + "NodeJSCreateSessionResponse": { + "properties": { + "session_id": { + "type": "string", + "title": "Session Id", + "description": "Session ID" + }, + "created": { + "type": "boolean", + "title": "Created", + "description": "Whether the session was newly created" + }, + "message": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Message", + "description": "Additional message (e.g., if session already exists)" + }, + "session": { + "anyOf": [ + { "$ref": "#/components/schemas/NodeJSSessionInfo" }, + { "type": "null" } + ], + "description": "Session information (if created)" + } + }, + "type": "object", + "required": ["session_id", "created"], + "title": "NodeJSCreateSessionResponse" + }, + "NodeJSDeleteSessionResponse": { + "properties": { + "deleted": { + "type": "boolean", + "title": "Deleted", + "description": "Whether the session was deleted" + } + }, + "type": "object", + "required": ["deleted"], + "title": "NodeJSDeleteSessionResponse" + }, "NodeJSExecuteRequest": { "properties": { "code": { @@ -3034,6 +3314,22 @@ ], "title": "Files", "description": "Additional files to create in execution directory" + }, + "stateful": { + "anyOf": [{ "type": "boolean" }, { "type": "null" }], + "title": "Stateful", + "description": "Enable stateful execution with persistent REPL session", + "default": false + }, + "session_id": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Session Id", + "description": "Session ID for stateful execution (reuse existing session)" + }, + "cwd": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Cwd", + "description": "Working directory for code execution" } }, "type": "object", @@ -3086,6 +3382,11 @@ "type": "integer", "title": "Exit Code", "description": "Process exit code" + }, + "session_id": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Session Id", + "description": "Session ID for stateful execution (use this to continue the session)" } }, "type": "object", @@ -3148,6 +3449,24 @@ "required": ["output_type"], "title": "NodeJSOutput" }, + "NodeJSPackageInfo": { + "properties": { + "name": { + "type": "string", + "title": "Name", + "description": "Package name" + }, + "version": { + "type": "string", + "title": "Version", + "description": "Package version" + } + }, + "type": "object", + "required": ["name", "version"], + "title": "NodeJSPackageInfo", + "description": "Package information" + }, "NodeJSRuntimeInfo": { "properties": { "node_version": { @@ -3176,6 +3495,25 @@ "title": "Runtime Directory", "description": "Runtime directory path" }, + "global_npm_directory": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Global Npm Directory", + "description": "Global npm directory path" + }, + "runtime_packages": { + "items": { "$ref": "#/components/schemas/NodeJSPackageInfo" }, + "type": "array", + "title": "Runtime Packages", + "description": "Pre-installed runtime packages", + "default": [] + }, + "global_packages": { + "items": { "$ref": "#/components/schemas/NodeJSPackageInfo" }, + "type": "array", + "title": "Global Packages", + "description": "Globally installed npm packages", + "default": [] + }, "error": { "anyOf": [{ "type": "string" }, { "type": "null" }], "title": "Error", @@ -3192,6 +3530,117 @@ "title": "NodeJSRuntimeInfo", "description": "NodeJS runtime information model" }, + "NodeJSSessionInfo": { + "properties": { + "session_id": { + "type": "string", + "title": "Session Id", + "description": "Session ID" + }, + "cwd": { + "type": "string", + "title": "Cwd", + "description": "Working directory" + }, + "created_at": { + "type": "number", + "title": "Created At", + "description": "Session creation timestamp (ms since epoch)" + }, + "last_used": { + "type": "number", + "title": "Last Used", + "description": "Last activity timestamp (ms since epoch)" + }, + "max_idle_time": { + "type": "integer", + "title": "Max Idle Time", + "description": "Maximum idle time in milliseconds" + }, + "age_seconds": { + "type": "integer", + "title": "Age Seconds", + "description": "Seconds since last activity" + }, + "state": { + "type": "string", + "title": "State", + "description": "Session state: IDLE or EXECUTING" + } + }, + "type": "object", + "required": [ + "session_id", + "cwd", + "created_at", + "last_used", + "max_idle_time", + "age_seconds", + "state" + ], + "title": "NodeJSSessionInfo" + }, + "NodeJSSessionListResponse": { + "properties": { + "sessions": { + "additionalProperties": { + "$ref": "#/components/schemas/NodeJSSessionInfo" + }, + "type": "object", + "title": "Sessions", + "description": "Map of session ID to session info", + "default": {} + } + }, + "type": "object", + "title": "NodeJSSessionListResponse" + }, + "NodeJSSessionResponse": { + "properties": { + "session": { + "$ref": "#/components/schemas/NodeJSSessionInfo", + "description": "Session information" + } + }, + "type": "object", + "required": ["session"], + "title": "NodeJSSessionResponse" + }, + "NodeJSUpdateSessionRequest": { + "properties": { + "max_idle_time": { + "anyOf": [ + { "type": "integer", "maximum": 86400.0, "minimum": 60.0 }, + { "type": "null" } + ], + "title": "Max Idle Time", + "description": "New maximum idle time in seconds" + }, + "cwd": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Cwd", + "description": "New working directory" + } + }, + "type": "object", + "title": "NodeJSUpdateSessionRequest" + }, + "NodeJSUpdateSessionResponse": { + "properties": { + "updated": { + "type": "boolean", + "title": "Updated", + "description": "Whether the update was successful" + }, + "session": { + "$ref": "#/components/schemas/NodeJSSessionInfo", + "description": "Updated session information" + } + }, + "type": "object", + "required": ["updated", "session"], + "title": "NodeJSUpdateSessionResponse" + }, "PressAction": { "properties": { "action_type": { @@ -3826,6 +4275,56 @@ "type": "object", "title": "Response[List[str]]" }, + "Response_NodeJSCreateSessionResponse_": { + "properties": { + "success": { + "type": "boolean", + "title": "Success", + "description": "Whether the operation was successful", + "default": true + }, + "message": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Message", + "description": "Operation result message", + "default": "Operation successful" + }, + "data": { + "anyOf": [ + { "$ref": "#/components/schemas/NodeJSCreateSessionResponse" }, + { "type": "null" } + ], + "description": "Data returned from the operation" + } + }, + "type": "object", + "title": "Response[NodeJSCreateSessionResponse]" + }, + "Response_NodeJSDeleteSessionResponse_": { + "properties": { + "success": { + "type": "boolean", + "title": "Success", + "description": "Whether the operation was successful", + "default": true + }, + "message": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Message", + "description": "Operation result message", + "default": "Operation successful" + }, + "data": { + "anyOf": [ + { "$ref": "#/components/schemas/NodeJSDeleteSessionResponse" }, + { "type": "null" } + ], + "description": "Data returned from the operation" + } + }, + "type": "object", + "title": "Response[NodeJSDeleteSessionResponse]" + }, "Response_NodeJSExecuteResponse_": { "properties": { "success": { @@ -3876,6 +4375,81 @@ "type": "object", "title": "Response[NodeJSRuntimeInfo]" }, + "Response_NodeJSSessionListResponse_": { + "properties": { + "success": { + "type": "boolean", + "title": "Success", + "description": "Whether the operation was successful", + "default": true + }, + "message": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Message", + "description": "Operation result message", + "default": "Operation successful" + }, + "data": { + "anyOf": [ + { "$ref": "#/components/schemas/NodeJSSessionListResponse" }, + { "type": "null" } + ], + "description": "Data returned from the operation" + } + }, + "type": "object", + "title": "Response[NodeJSSessionListResponse]" + }, + "Response_NodeJSSessionResponse_": { + "properties": { + "success": { + "type": "boolean", + "title": "Success", + "description": "Whether the operation was successful", + "default": true + }, + "message": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Message", + "description": "Operation result message", + "default": "Operation successful" + }, + "data": { + "anyOf": [ + { "$ref": "#/components/schemas/NodeJSSessionResponse" }, + { "type": "null" } + ], + "description": "Data returned from the operation" + } + }, + "type": "object", + "title": "Response[NodeJSSessionResponse]" + }, + "Response_NodeJSUpdateSessionResponse_": { + "properties": { + "success": { + "type": "boolean", + "title": "Success", + "description": "Whether the operation was successful", + "default": true + }, + "message": { + "anyOf": [{ "type": "string" }, { "type": "null" }], + "title": "Message", + "description": "Operation result message", + "default": "Operation successful" + }, + "data": { + "anyOf": [ + { "$ref": "#/components/schemas/NodeJSUpdateSessionResponse" }, + { "type": "null" } + ], + "description": "Data returned from the operation" + } + }, + "type": "object", + "title": "Response[NodeJSUpdateSessionResponse]" + }, "Response_ShellCommandResult_": { "properties": { "success": { @@ -4475,14 +5049,19 @@ "$ref": "#/components/schemas/BashCommandStatus", "description": "Process status" }, + "exit_code": { + "anyOf": [{ "type": "integer" }, { "type": "null" }], + "title": "Exit Code", + "description": "Process exit code before termination, None if process was still running" + }, "returncode": { - "type": "integer", + "anyOf": [{ "type": "integer" }, { "type": "null" }], "title": "Returncode", - "description": "Process return code" + "description": "Deprecated: use exit_code instead. Kept for backward compatibility." } }, "type": "object", - "required": ["status", "returncode"], + "required": ["status"], "title": "ShellKillResult", "description": "Process termination result model" },