apps/docs/src/content/docs/en/java-sdk/process.mdx
Process and session execution interface for a Sandbox.
Supports single-command execution, code execution, long-running sessions, and PTY terminal sessions.
public ExecuteResponse executeCommand(String command)
Executes a shell command with default options.
Parameters:
command String - command to executeReturns:
ExecuteResponse - execution resultThrows:
DaytonaException - if execution failspublic ExecuteResponse executeCommand(String command, String cwd, Map<String, String> env, Integer timeout)
Executes a shell command.
Parameters:
command String - command to executecwd String - working directory, or null to use sandbox defaultenv Map<String, String> - environment variables to set for the commandtimeout Integer - timeout in secondsReturns:
ExecuteResponse - execution resultThrows:
DaytonaException - if execution failspublic ExecuteResponse codeRun(String code)
Executes source code using Sandbox language tooling.
Parameters:
code String - source code to executeReturns:
ExecuteResponse - execution resultThrows:
DaytonaException - if execution failspublic ExecuteResponse codeRun(String code, Map<String, String> env, Integer timeout)
Parameters:
code String -env Map<String, String> -timeout Integer -Returns:
ExecuteResponse -public ExecuteResponse codeRun(String code, List<String> argv, Map<String, String> env, Integer timeout)
Parameters:
code String -argv List<String> -env Map<String, String> -timeout Integer -Returns:
ExecuteResponse -public void createSession(String sessionId)
Creates a persistent background session.
Parameters:
sessionId String - unique session identifierThrows:
DaytonaException - if session creation failspublic Session getSession(String sessionId)
Returns session metadata.
Parameters:
sessionId String - session identifierReturns:
Session - session metadataThrows:
DaytonaException - if retrieval failspublic Session getEntrypointSession()
Returns entrypoint session metadata.
Returns:
Session - entrypoint session metadataThrows:
DaytonaException - if retrieval failspublic SessionExecuteResponse executeSessionCommand(String sessionId, SessionExecuteRequest req)
Executes a command in an existing session.
Parameters:
sessionId String - session identifierreq SessionExecuteRequest - execution requestReturns:
SessionExecuteResponse - command execution responseThrows:
DaytonaException - if execution failspublic Command getSessionCommand(String sessionId, String commandId)
Returns metadata for a command executed in a session.
Parameters:
sessionId String - session identifiercommandId String - command identifierReturns:
Command - command metadataThrows:
DaytonaException - if retrieval failspublic SessionCommandLogsResponse getSessionCommandLogs(String sessionId, String commandId)
Returns logs for a command executed in a session.
Parameters:
sessionId String - session identifiercommandId String - command identifierReturns:
SessionCommandLogsResponse - command logsThrows:
DaytonaException - if retrieval failspublic SessionCommandLogsResponse getEntrypointLogs()
Returns one-shot logs for the sandbox entrypoint session.
Returns:
SessionCommandLogsResponse - entrypoint logsThrows:
DaytonaException - if retrieval failspublic void getEntrypointLogs(Consumer<String> onStdout, Consumer<String> onStderr)
Streams logs for the sandbox entrypoint session via WebSocket.
Parameters:
onStdout Consumer<String> - callback for stdout chunksonStderr Consumer<String> - callback for stderr chunksThrows:
DaytonaException - if streaming failspublic void sendSessionCommandInput(String sessionId, String commandId, String data)
Sends input data to a command executed in a session.
Parameters:
sessionId String - session identifiercommandId String - command identifierdata String - input text to sendThrows:
DaytonaException - if sending input failspublic void deleteSession(String sessionId)
Deletes a session.
Parameters:
sessionId String - session identifierThrows:
DaytonaException - if deletion failspublic List<Session> listSessions()
Lists all sessions in the Sandbox.
Returns:
List\<Session\> - session listThrows:
DaytonaException - if listing failspublic PtyHandle createPty(PtyCreateOptions options)
Creates a PTY terminal session.
Parameters:
options PtyCreateOptions - PTY options, or null to use defaultsReturns:
PtyHandle - PTY handle for streaming I/O and lifecycle operationsThrows:
DaytonaException - if PTY session creation failspublic PtyHandle connectPty(String sessionId)
Connects to an existing PTY terminal session.
Parameters:
sessionId String - PTY session identifierReturns:
PtyHandle - PTY handle for streaming I/O and lifecycle operationsThrows:
DaytonaException - if websocket connection setup failspublic PtyHandle connectPty(String sessionId, PtyCreateOptions options)
Connects to an existing PTY terminal session.
Parameters:
sessionId String - PTY session identifieroptions PtyCreateOptions - PTY options, used for data callback configurationReturns:
PtyHandle - PTY handle for streaming I/O and lifecycle operationsThrows:
DaytonaException - if websocket connection setup failspublic List<PtySessionInfo> listPtySessions()
Lists PTY sessions in the Sandbox.
Returns:
List\<PtySessionInfo\> - PTY session information listThrows:
DaytonaException - if listing failspublic PtySessionInfo getPtySessionInfo(String sessionId)
Returns PTY session information.
Parameters:
sessionId String - PTY session identifierReturns:
PtySessionInfo - PTY session informationThrows:
DaytonaException - if retrieval failspublic void resizePtySession(String sessionId, int cols, int rows)
Resizes an active PTY session.
Parameters:
sessionId String - PTY session identifiercols int - terminal width in columnsrows int - terminal height in rowsThrows:
DaytonaException - if resize failspublic void killPtySession(String sessionId)
Terminates a PTY session.
Parameters:
sessionId String - PTY session identifierThrows:
DaytonaException - if termination fails