sandbox-agent 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { NewSessionRequest, AnyMessage, AcpEnvelopeDirection, NewSessionResponse, PromptRequest, PromptResponse } from 'acp-http-client';
1
+ import { NewSessionRequest, SessionConfigOption, SessionModeState, AnyMessage, AcpEnvelopeDirection, NewSessionResponse, PromptRequest, PromptResponse, SetSessionModeResponse, SetSessionConfigOptionResponse } from 'acp-http-client';
2
2
  export { AcpRpcError } from 'acp-http-client';
3
3
 
4
4
  type SandboxAgentSpawnLogMode = "inherit" | "pipe" | "silent";
@@ -85,7 +85,7 @@ interface components {
85
85
  agents: components["schemas"]["AgentInfo"][];
86
86
  };
87
87
  /** @enum {string} */
88
- ErrorType: "invalid_request" | "conflict" | "unsupported_agent" | "agent_not_installed" | "install_failed" | "agent_process_exited" | "token_invalid" | "permission_denied" | "not_acceptable" | "unsupported_media_type" | "session_not_found" | "session_already_exists" | "mode_not_supported" | "stream_error" | "timeout";
88
+ ErrorType: "invalid_request" | "conflict" | "unsupported_agent" | "agent_not_installed" | "install_failed" | "agent_process_exited" | "token_invalid" | "permission_denied" | "not_acceptable" | "unsupported_media_type" | "not_found" | "session_not_found" | "session_already_exists" | "mode_not_supported" | "stream_error" | "timeout";
89
89
  FsActionResponse: {
90
90
  path: string;
91
91
  };
@@ -182,6 +182,116 @@ interface components {
182
182
  type: string;
183
183
  [key: string]: unknown;
184
184
  };
185
+ ProcessConfig: {
186
+ /** Format: int64 */
187
+ defaultRunTimeoutMs: number;
188
+ maxConcurrentProcesses: number;
189
+ maxInputBytesPerRequest: number;
190
+ maxLogBytesPerProcess: number;
191
+ maxOutputBytes: number;
192
+ /** Format: int64 */
193
+ maxRunTimeoutMs: number;
194
+ };
195
+ ProcessCreateRequest: {
196
+ args?: string[];
197
+ command: string;
198
+ cwd?: string | null;
199
+ env?: {
200
+ [key: string]: string;
201
+ };
202
+ interactive?: boolean;
203
+ tty?: boolean;
204
+ };
205
+ ProcessInfo: {
206
+ args: string[];
207
+ command: string;
208
+ /** Format: int64 */
209
+ createdAtMs: number;
210
+ cwd?: string | null;
211
+ /** Format: int32 */
212
+ exitCode?: number | null;
213
+ /** Format: int64 */
214
+ exitedAtMs?: number | null;
215
+ id: string;
216
+ interactive: boolean;
217
+ /** Format: int32 */
218
+ pid?: number | null;
219
+ status: components["schemas"]["ProcessState"];
220
+ tty: boolean;
221
+ };
222
+ ProcessInputRequest: {
223
+ data: string;
224
+ encoding?: string | null;
225
+ };
226
+ ProcessInputResponse: {
227
+ bytesWritten: number;
228
+ };
229
+ ProcessListResponse: {
230
+ processes: components["schemas"]["ProcessInfo"][];
231
+ };
232
+ ProcessLogEntry: {
233
+ data: string;
234
+ encoding: string;
235
+ /** Format: int64 */
236
+ sequence: number;
237
+ stream: components["schemas"]["ProcessLogsStream"];
238
+ /** Format: int64 */
239
+ timestampMs: number;
240
+ };
241
+ ProcessLogsQuery: {
242
+ follow?: boolean | null;
243
+ /** Format: int64 */
244
+ since?: number | null;
245
+ stream?: components["schemas"]["ProcessLogsStream"] | null;
246
+ tail?: number | null;
247
+ };
248
+ ProcessLogsResponse: {
249
+ entries: components["schemas"]["ProcessLogEntry"][];
250
+ processId: string;
251
+ stream: components["schemas"]["ProcessLogsStream"];
252
+ };
253
+ /** @enum {string} */
254
+ ProcessLogsStream: "stdout" | "stderr" | "combined" | "pty";
255
+ ProcessRunRequest: {
256
+ args?: string[];
257
+ command: string;
258
+ cwd?: string | null;
259
+ env?: {
260
+ [key: string]: string;
261
+ };
262
+ maxOutputBytes?: number | null;
263
+ /** Format: int64 */
264
+ timeoutMs?: number | null;
265
+ };
266
+ ProcessRunResponse: {
267
+ /** Format: int64 */
268
+ durationMs: number;
269
+ /** Format: int32 */
270
+ exitCode?: number | null;
271
+ stderr: string;
272
+ stderrTruncated: boolean;
273
+ stdout: string;
274
+ stdoutTruncated: boolean;
275
+ timedOut: boolean;
276
+ };
277
+ ProcessSignalQuery: {
278
+ /** Format: int64 */
279
+ waitMs?: number | null;
280
+ };
281
+ /** @enum {string} */
282
+ ProcessState: "running" | "exited";
283
+ ProcessTerminalResizeRequest: {
284
+ /** Format: int32 */
285
+ cols: number;
286
+ /** Format: int32 */
287
+ rows: number;
288
+ };
289
+ ProcessTerminalResizeResponse: {
290
+ /** Format: int32 */
291
+ cols: number;
292
+ /** Format: int32 */
293
+ rows: number;
294
+ };
185
295
  /** @enum {string} */
186
296
  ServerStatus: "running" | "stopped";
187
297
  ServerStatusInfo: {
@@ -694,12 +804,495 @@ interface operations {
694
804
  };
695
805
  };
696
806
  };
807
+ /**
808
+ * List all managed processes.
809
+ * @description Returns a list of all processes (running and exited) currently tracked
810
+ * by the runtime, sorted by process ID.
811
+ */
812
+ get_v1_processes: {
813
+ responses: {
814
+ /** @description List processes */
815
+ 200: {
816
+ content: {
817
+ "application/json": components["schemas"]["ProcessListResponse"];
818
+ };
819
+ };
820
+ /** @description Process API unsupported on this platform */
821
+ 501: {
822
+ content: {
823
+ "application/json": components["schemas"]["ProblemDetails"];
824
+ };
825
+ };
826
+ };
827
+ };
828
+ /**
829
+ * Create a long-lived managed process.
830
+ * @description Spawns a new process with the given command and arguments. Supports both
831
+ * pipe-based and PTY (tty) modes. Returns the process descriptor on success.
832
+ */
833
+ post_v1_processes: {
834
+ requestBody: {
835
+ content: {
836
+ "application/json": components["schemas"]["ProcessCreateRequest"];
837
+ };
838
+ };
839
+ responses: {
840
+ /** @description Started process */
841
+ 200: {
842
+ content: {
843
+ "application/json": components["schemas"]["ProcessInfo"];
844
+ };
845
+ };
846
+ /** @description Invalid request */
847
+ 400: {
848
+ content: {
849
+ "application/json": components["schemas"]["ProblemDetails"];
850
+ };
851
+ };
852
+ /** @description Process limit or state conflict */
853
+ 409: {
854
+ content: {
855
+ "application/json": components["schemas"]["ProblemDetails"];
856
+ };
857
+ };
858
+ /** @description Process API unsupported on this platform */
859
+ 501: {
860
+ content: {
861
+ "application/json": components["schemas"]["ProblemDetails"];
862
+ };
863
+ };
864
+ };
865
+ };
866
+ /**
867
+ * Get process runtime configuration.
868
+ * @description Returns the current runtime configuration for the process management API,
869
+ * including limits for concurrency, timeouts, and buffer sizes.
870
+ */
871
+ get_v1_processes_config: {
872
+ responses: {
873
+ /** @description Current runtime process config */
874
+ 200: {
875
+ content: {
876
+ "application/json": components["schemas"]["ProcessConfig"];
877
+ };
878
+ };
879
+ /** @description Process API unsupported on this platform */
880
+ 501: {
881
+ content: {
882
+ "application/json": components["schemas"]["ProblemDetails"];
883
+ };
884
+ };
885
+ };
886
+ };
887
+ /**
888
+ * Update process runtime configuration.
889
+ * @description Replaces the runtime configuration for the process management API.
890
+ * Validates that all values are non-zero and clamps default timeout to max.
891
+ */
892
+ post_v1_processes_config: {
893
+ requestBody: {
894
+ content: {
895
+ "application/json": components["schemas"]["ProcessConfig"];
896
+ };
897
+ };
898
+ responses: {
899
+ /** @description Updated runtime process config */
900
+ 200: {
901
+ content: {
902
+ "application/json": components["schemas"]["ProcessConfig"];
903
+ };
904
+ };
905
+ /** @description Invalid config */
906
+ 400: {
907
+ content: {
908
+ "application/json": components["schemas"]["ProblemDetails"];
909
+ };
910
+ };
911
+ /** @description Process API unsupported on this platform */
912
+ 501: {
913
+ content: {
914
+ "application/json": components["schemas"]["ProblemDetails"];
915
+ };
916
+ };
917
+ };
918
+ };
919
+ /**
920
+ * Run a one-shot command.
921
+ * @description Executes a command to completion and returns its stdout, stderr, exit code,
922
+ * and duration. Supports configurable timeout and output size limits.
923
+ */
924
+ post_v1_processes_run: {
925
+ requestBody: {
926
+ content: {
927
+ "application/json": components["schemas"]["ProcessRunRequest"];
928
+ };
929
+ };
930
+ responses: {
931
+ /** @description One-off command result */
932
+ 200: {
933
+ content: {
934
+ "application/json": components["schemas"]["ProcessRunResponse"];
935
+ };
936
+ };
937
+ /** @description Invalid request */
938
+ 400: {
939
+ content: {
940
+ "application/json": components["schemas"]["ProblemDetails"];
941
+ };
942
+ };
943
+ /** @description Process API unsupported on this platform */
944
+ 501: {
945
+ content: {
946
+ "application/json": components["schemas"]["ProblemDetails"];
947
+ };
948
+ };
949
+ };
950
+ };
951
+ /**
952
+ * Get a single process by ID.
953
+ * @description Returns the current state of a managed process including its status,
954
+ * PID, exit code, and creation/exit timestamps.
955
+ */
956
+ get_v1_process: {
957
+ parameters: {
958
+ path: {
959
+ /** @description Process ID */
960
+ id: string;
961
+ };
962
+ };
963
+ responses: {
964
+ /** @description Process details */
965
+ 200: {
966
+ content: {
967
+ "application/json": components["schemas"]["ProcessInfo"];
968
+ };
969
+ };
970
+ /** @description Unknown process */
971
+ 404: {
972
+ content: {
973
+ "application/json": components["schemas"]["ProblemDetails"];
974
+ };
975
+ };
976
+ /** @description Process API unsupported on this platform */
977
+ 501: {
978
+ content: {
979
+ "application/json": components["schemas"]["ProblemDetails"];
980
+ };
981
+ };
982
+ };
983
+ };
984
+ /**
985
+ * Delete a process record.
986
+ * @description Removes a stopped process from the runtime. Returns 409 if the process
987
+ * is still running; stop or kill it first.
988
+ */
989
+ delete_v1_process: {
990
+ parameters: {
991
+ path: {
992
+ /** @description Process ID */
993
+ id: string;
994
+ };
995
+ };
996
+ responses: {
997
+ /** @description Process deleted */
998
+ 204: {
999
+ content: never;
1000
+ };
1001
+ /** @description Unknown process */
1002
+ 404: {
1003
+ content: {
1004
+ "application/json": components["schemas"]["ProblemDetails"];
1005
+ };
1006
+ };
1007
+ /** @description Process is still running */
1008
+ 409: {
1009
+ content: {
1010
+ "application/json": components["schemas"]["ProblemDetails"];
1011
+ };
1012
+ };
1013
+ /** @description Process API unsupported on this platform */
1014
+ 501: {
1015
+ content: {
1016
+ "application/json": components["schemas"]["ProblemDetails"];
1017
+ };
1018
+ };
1019
+ };
1020
+ };
1021
+ /**
1022
+ * Write input to a process.
1023
+ * @description Sends data to a process's stdin (pipe mode) or PTY writer (tty mode).
1024
+ * Data can be encoded as base64, utf8, or text. Returns 413 if the decoded
1025
+ * payload exceeds the configured `maxInputBytesPerRequest` limit.
1026
+ */
1027
+ post_v1_process_input: {
1028
+ parameters: {
1029
+ path: {
1030
+ /** @description Process ID */
1031
+ id: string;
1032
+ };
1033
+ };
1034
+ requestBody: {
1035
+ content: {
1036
+ "application/json": components["schemas"]["ProcessInputRequest"];
1037
+ };
1038
+ };
1039
+ responses: {
1040
+ /** @description Input accepted */
1041
+ 200: {
1042
+ content: {
1043
+ "application/json": components["schemas"]["ProcessInputResponse"];
1044
+ };
1045
+ };
1046
+ /** @description Invalid request */
1047
+ 400: {
1048
+ content: {
1049
+ "application/json": components["schemas"]["ProblemDetails"];
1050
+ };
1051
+ };
1052
+ /** @description Process not writable */
1053
+ 409: {
1054
+ content: {
1055
+ "application/json": components["schemas"]["ProblemDetails"];
1056
+ };
1057
+ };
1058
+ /** @description Input exceeds configured limit */
1059
+ 413: {
1060
+ content: {
1061
+ "application/json": components["schemas"]["ProblemDetails"];
1062
+ };
1063
+ };
1064
+ /** @description Process API unsupported on this platform */
1065
+ 501: {
1066
+ content: {
1067
+ "application/json": components["schemas"]["ProblemDetails"];
1068
+ };
1069
+ };
1070
+ };
1071
+ };
1072
+ /**
1073
+ * Send SIGKILL to a process.
1074
+ * @description Sends SIGKILL to the process and optionally waits up to `waitMs`
1075
+ * milliseconds for the process to exit before returning.
1076
+ */
1077
+ post_v1_process_kill: {
1078
+ parameters: {
1079
+ query?: {
1080
+ /** @description Wait up to N ms for process to exit */
1081
+ waitMs?: number | null;
1082
+ };
1083
+ path: {
1084
+ /** @description Process ID */
1085
+ id: string;
1086
+ };
1087
+ };
1088
+ responses: {
1089
+ /** @description Kill signal sent */
1090
+ 200: {
1091
+ content: {
1092
+ "application/json": components["schemas"]["ProcessInfo"];
1093
+ };
1094
+ };
1095
+ /** @description Unknown process */
1096
+ 404: {
1097
+ content: {
1098
+ "application/json": components["schemas"]["ProblemDetails"];
1099
+ };
1100
+ };
1101
+ /** @description Process API unsupported on this platform */
1102
+ 501: {
1103
+ content: {
1104
+ "application/json": components["schemas"]["ProblemDetails"];
1105
+ };
1106
+ };
1107
+ };
1108
+ };
1109
+ /**
1110
+ * Fetch process logs.
1111
+ * @description Returns buffered log entries for a process. Supports filtering by stream
1112
+ * type, tail count, and sequence-based resumption. When `follow=true`,
1113
+ * returns an SSE stream that replays buffered entries then streams live output.
1114
+ */
1115
+ get_v1_process_logs: {
1116
+ parameters: {
1117
+ query?: {
1118
+ /** @description stdout|stderr|combined|pty */
1119
+ stream?: components["schemas"]["ProcessLogsStream"] | null;
1120
+ /** @description Tail N entries */
1121
+ tail?: number | null;
1122
+ /** @description Follow via SSE */
1123
+ follow?: boolean | null;
1124
+ /** @description Only entries with sequence greater than this */
1125
+ since?: number | null;
1126
+ };
1127
+ path: {
1128
+ /** @description Process ID */
1129
+ id: string;
1130
+ };
1131
+ };
1132
+ responses: {
1133
+ /** @description Process logs */
1134
+ 200: {
1135
+ content: {
1136
+ "application/json": components["schemas"]["ProcessLogsResponse"];
1137
+ };
1138
+ };
1139
+ /** @description Unknown process */
1140
+ 404: {
1141
+ content: {
1142
+ "application/json": components["schemas"]["ProblemDetails"];
1143
+ };
1144
+ };
1145
+ /** @description Process API unsupported on this platform */
1146
+ 501: {
1147
+ content: {
1148
+ "application/json": components["schemas"]["ProblemDetails"];
1149
+ };
1150
+ };
1151
+ };
1152
+ };
1153
+ /**
1154
+ * Send SIGTERM to a process.
1155
+ * @description Sends SIGTERM to the process and optionally waits up to `waitMs`
1156
+ * milliseconds for the process to exit before returning.
1157
+ */
1158
+ post_v1_process_stop: {
1159
+ parameters: {
1160
+ query?: {
1161
+ /** @description Wait up to N ms for process to exit */
1162
+ waitMs?: number | null;
1163
+ };
1164
+ path: {
1165
+ /** @description Process ID */
1166
+ id: string;
1167
+ };
1168
+ };
1169
+ responses: {
1170
+ /** @description Stop signal sent */
1171
+ 200: {
1172
+ content: {
1173
+ "application/json": components["schemas"]["ProcessInfo"];
1174
+ };
1175
+ };
1176
+ /** @description Unknown process */
1177
+ 404: {
1178
+ content: {
1179
+ "application/json": components["schemas"]["ProblemDetails"];
1180
+ };
1181
+ };
1182
+ /** @description Process API unsupported on this platform */
1183
+ 501: {
1184
+ content: {
1185
+ "application/json": components["schemas"]["ProblemDetails"];
1186
+ };
1187
+ };
1188
+ };
1189
+ };
1190
+ /**
1191
+ * Resize a process terminal.
1192
+ * @description Sets the PTY window size (columns and rows) for a tty-mode process and
1193
+ * sends SIGWINCH so the child process can adapt.
1194
+ */
1195
+ post_v1_process_terminal_resize: {
1196
+ parameters: {
1197
+ path: {
1198
+ /** @description Process ID */
1199
+ id: string;
1200
+ };
1201
+ };
1202
+ requestBody: {
1203
+ content: {
1204
+ "application/json": components["schemas"]["ProcessTerminalResizeRequest"];
1205
+ };
1206
+ };
1207
+ responses: {
1208
+ /** @description Resize accepted */
1209
+ 200: {
1210
+ content: {
1211
+ "application/json": components["schemas"]["ProcessTerminalResizeResponse"];
1212
+ };
1213
+ };
1214
+ /** @description Invalid request */
1215
+ 400: {
1216
+ content: {
1217
+ "application/json": components["schemas"]["ProblemDetails"];
1218
+ };
1219
+ };
1220
+ /** @description Unknown process */
1221
+ 404: {
1222
+ content: {
1223
+ "application/json": components["schemas"]["ProblemDetails"];
1224
+ };
1225
+ };
1226
+ /** @description Not a terminal process */
1227
+ 409: {
1228
+ content: {
1229
+ "application/json": components["schemas"]["ProblemDetails"];
1230
+ };
1231
+ };
1232
+ /** @description Process API unsupported on this platform */
1233
+ 501: {
1234
+ content: {
1235
+ "application/json": components["schemas"]["ProblemDetails"];
1236
+ };
1237
+ };
1238
+ };
1239
+ };
1240
+ /**
1241
+ * Open an interactive WebSocket terminal session.
1242
+ * @description Upgrades the connection to a WebSocket for bidirectional PTY I/O. Accepts
1243
+ * `access_token` query param for browser-based auth (WebSocket API cannot
1244
+ * send custom headers). Streams raw PTY output as binary frames and accepts
1245
+ * JSON control frames for input, resize, and close.
1246
+ */
1247
+ get_v1_process_terminal_ws: {
1248
+ parameters: {
1249
+ query?: {
1250
+ /** @description Bearer token alternative for WS auth */
1251
+ access_token?: string | null;
1252
+ };
1253
+ path: {
1254
+ /** @description Process ID */
1255
+ id: string;
1256
+ };
1257
+ };
1258
+ responses: {
1259
+ /** @description WebSocket upgraded */
1260
+ 101: {
1261
+ content: never;
1262
+ };
1263
+ /** @description Invalid websocket frame or upgrade request */
1264
+ 400: {
1265
+ content: {
1266
+ "application/json": components["schemas"]["ProblemDetails"];
1267
+ };
1268
+ };
1269
+ /** @description Unknown process */
1270
+ 404: {
1271
+ content: {
1272
+ "application/json": components["schemas"]["ProblemDetails"];
1273
+ };
1274
+ };
1275
+ /** @description Not a terminal process */
1276
+ 409: {
1277
+ content: {
1278
+ "application/json": components["schemas"]["ProblemDetails"];
1279
+ };
1280
+ };
1281
+ /** @description Process API unsupported on this platform */
1282
+ 501: {
1283
+ content: {
1284
+ "application/json": components["schemas"]["ProblemDetails"];
1285
+ };
1286
+ };
1287
+ };
1288
+ };
697
1289
  }
698
1290
 
699
1291
  type ProblemDetails = components["schemas"]["ProblemDetails"];
700
1292
  type HealthResponse = JsonResponse<operations["get_v1_health"], 200>;
701
1293
  type AgentListResponse = JsonResponse<operations["get_v1_agents"], 200>;
702
1294
  type AgentInfo = components["schemas"]["AgentInfo"];
1295
+ type AgentQuery = QueryParams<operations["get_v1_agents"]>;
703
1296
  type AgentInstallRequest = JsonRequestBody<operations["post_v1_agent_install"]>;
704
1297
  type AgentInstallResponse = JsonResponse<operations["post_v1_agent_install"], 200>;
705
1298
  type AcpEnvelope = components["schemas"]["AcpEnvelope"];
@@ -720,6 +1313,54 @@ type McpConfigQuery = QueryParams<operations["get_v1_config_mcp"]>;
720
1313
  type McpServerConfig = components["schemas"]["McpServerConfig"];
721
1314
  type SkillsConfigQuery = QueryParams<operations["get_v1_config_skills"]>;
722
1315
  type SkillsConfig = components["schemas"]["SkillsConfig"];
1316
+ type ProcessConfig = JsonResponse<operations["get_v1_processes_config"], 200>;
1317
+ type ProcessCreateRequest = JsonRequestBody<operations["post_v1_processes"]>;
1318
+ type ProcessInfo = components["schemas"]["ProcessInfo"];
1319
+ type ProcessInputRequest = JsonRequestBody<operations["post_v1_process_input"]>;
1320
+ type ProcessInputResponse = JsonResponse<operations["post_v1_process_input"], 200>;
1321
+ type ProcessListResponse = JsonResponse<operations["get_v1_processes"], 200>;
1322
+ type ProcessLogEntry = components["schemas"]["ProcessLogEntry"];
1323
+ type ProcessLogsQuery = QueryParams<operations["get_v1_process_logs"]>;
1324
+ type ProcessLogsResponse = JsonResponse<operations["get_v1_process_logs"], 200>;
1325
+ type ProcessLogsStream = components["schemas"]["ProcessLogsStream"];
1326
+ type ProcessRunRequest = JsonRequestBody<operations["post_v1_processes_run"]>;
1327
+ type ProcessRunResponse = JsonResponse<operations["post_v1_processes_run"], 200>;
1328
+ type ProcessSignalQuery = QueryParams<operations["post_v1_process_stop"]>;
1329
+ type ProcessState = components["schemas"]["ProcessState"];
1330
+ type ProcessTerminalResizeRequest = JsonRequestBody<operations["post_v1_process_terminal_resize"]>;
1331
+ type ProcessTerminalResizeResponse = JsonResponse<operations["post_v1_process_terminal_resize"], 200>;
1332
+ type ProcessTerminalClientFrame = {
1333
+ type: "input";
1334
+ data: string;
1335
+ encoding?: string;
1336
+ } | {
1337
+ type: "resize";
1338
+ cols: number;
1339
+ rows: number;
1340
+ } | {
1341
+ type: "close";
1342
+ };
1343
+ interface ProcessTerminalReadyFrame {
1344
+ type: "ready";
1345
+ processId: string;
1346
+ }
1347
+ interface ProcessTerminalExitFrame {
1348
+ type: "exit";
1349
+ exitCode?: number | null;
1350
+ }
1351
+ interface ProcessTerminalErrorFrame {
1352
+ type: "error";
1353
+ message: string;
1354
+ }
1355
+ type ProcessTerminalServerFrame = ProcessTerminalReadyFrame | ProcessTerminalExitFrame | ProcessTerminalErrorFrame;
1356
+ type TerminalReadyStatus = ProcessTerminalReadyFrame;
1357
+ type TerminalExitStatus = ProcessTerminalExitFrame;
1358
+ type TerminalErrorStatus = ProcessTerminalErrorFrame;
1359
+ type TerminalStatusMessage = ProcessTerminalServerFrame;
1360
+ interface TerminalResizePayload {
1361
+ cols: number;
1362
+ rows: number;
1363
+ }
723
1364
  interface SessionRecord {
724
1365
  id: string;
725
1366
  agent: string;
@@ -728,6 +1369,8 @@ interface SessionRecord {
728
1369
  createdAt: number;
729
1370
  destroyedAt?: number;
730
1371
  sessionInit?: Omit<NewSessionRequest, "_meta">;
1372
+ configOptions?: SessionConfigOption[];
1373
+ modes?: SessionModeState | null;
731
1374
  }
732
1375
  type SessionEventSender = "client" | "agent";
733
1376
  interface SessionEvent {
@@ -798,12 +1441,17 @@ type QueryParams<T> = T extends {
798
1441
  };
799
1442
  } ? Q : never;
800
1443
 
1444
+ interface SandboxAgentHealthWaitOptions {
1445
+ timeoutMs?: number;
1446
+ }
801
1447
  interface SandboxAgentConnectCommonOptions {
802
1448
  headers?: HeadersInit;
803
1449
  persist?: SessionPersistDriver;
804
1450
  replayMaxEvents?: number;
805
1451
  replayMaxChars?: number;
1452
+ signal?: AbortSignal;
806
1453
  token?: string;
1454
+ waitForHealth?: boolean | SandboxAgentHealthWaitOptions;
807
1455
  }
808
1456
  type SandboxAgentConnectOptions = (SandboxAgentConnectCommonOptions & {
809
1457
  baseUrl: string;
@@ -824,22 +1472,66 @@ interface SessionCreateRequest {
824
1472
  id?: string;
825
1473
  agent: string;
826
1474
  sessionInit?: Omit<NewSessionRequest, "_meta">;
1475
+ model?: string;
1476
+ mode?: string;
1477
+ thoughtLevel?: string;
827
1478
  }
828
1479
  interface SessionResumeOrCreateRequest {
829
1480
  id: string;
830
1481
  agent: string;
831
1482
  sessionInit?: Omit<NewSessionRequest, "_meta">;
1483
+ model?: string;
1484
+ mode?: string;
1485
+ thoughtLevel?: string;
832
1486
  }
833
1487
  interface SessionSendOptions {
834
1488
  notification?: boolean;
835
1489
  }
836
1490
  type SessionEventListener = (event: SessionEvent) => void;
1491
+ type ProcessLogListener = (entry: ProcessLogEntry) => void;
1492
+ type ProcessLogFollowQuery = Omit<ProcessLogsQuery, "follow">;
1493
+ interface AgentQueryOptions {
1494
+ config?: boolean;
1495
+ noCache?: boolean;
1496
+ }
1497
+ interface ProcessLogSubscription {
1498
+ close(): void;
1499
+ closed: Promise<void>;
1500
+ }
1501
+ interface ProcessTerminalWebSocketUrlOptions {
1502
+ accessToken?: string;
1503
+ }
1504
+ interface ProcessTerminalConnectOptions extends ProcessTerminalWebSocketUrlOptions {
1505
+ protocols?: string | string[];
1506
+ WebSocket?: typeof WebSocket;
1507
+ }
1508
+ type ProcessTerminalSessionOptions = ProcessTerminalConnectOptions;
837
1509
  declare class SandboxAgentError extends Error {
838
1510
  readonly status: number;
839
1511
  readonly problem?: ProblemDetails;
840
1512
  readonly response: Response;
841
1513
  constructor(status: number, problem: ProblemDetails | undefined, response: Response);
842
1514
  }
1515
+ declare class UnsupportedSessionCategoryError extends Error {
1516
+ readonly sessionId: string;
1517
+ readonly category: string;
1518
+ readonly availableCategories: string[];
1519
+ constructor(sessionId: string, category: string, availableCategories: string[]);
1520
+ }
1521
+ declare class UnsupportedSessionValueError extends Error {
1522
+ readonly sessionId: string;
1523
+ readonly category: string;
1524
+ readonly configId: string;
1525
+ readonly requestedValue: string;
1526
+ readonly allowedValues: string[];
1527
+ constructor(sessionId: string, category: string, configId: string, requestedValue: string, allowedValues: string[]);
1528
+ }
1529
+ declare class UnsupportedSessionConfigOptionError extends Error {
1530
+ readonly sessionId: string;
1531
+ readonly configId: string;
1532
+ readonly availableConfigIds: string[];
1533
+ constructor(sessionId: string, configId: string, availableConfigIds: string[]);
1534
+ }
843
1535
  declare class Session {
844
1536
  private record;
845
1537
  private readonly sandbox;
@@ -853,6 +1545,12 @@ declare class Session {
853
1545
  refresh(): Promise<Session>;
854
1546
  send(method: string, params?: Record<string, unknown>, options?: SessionSendOptions): Promise<unknown>;
855
1547
  prompt(prompt: PromptRequest["prompt"]): Promise<PromptResponse>;
1548
+ setMode(modeId: string): Promise<SetSessionModeResponse | void>;
1549
+ setConfigOption(configId: string, value: string): Promise<SetSessionConfigOptionResponse>;
1550
+ setModel(model: string): Promise<SetSessionConfigOptionResponse>;
1551
+ setThoughtLevel(thoughtLevel: string): Promise<SetSessionConfigOptionResponse>;
1552
+ getConfigOptions(): Promise<SessionConfigOption[]>;
1553
+ getModes(): Promise<SessionModeState | null>;
856
1554
  onEvent(listener: SessionEventListener): () => void;
857
1555
  toRecord(): SessionRecord;
858
1556
  apply(record: SessionRecord): void;
@@ -890,15 +1588,43 @@ declare class LiveAcpConnection {
890
1588
  private resolveSessionId;
891
1589
  private localFromEnvelopeParams;
892
1590
  }
1591
+ declare class ProcessTerminalSession {
1592
+ readonly socket: WebSocket;
1593
+ readonly closed: Promise<void>;
1594
+ private readonly readyListeners;
1595
+ private readonly dataListeners;
1596
+ private readonly exitListeners;
1597
+ private readonly errorListeners;
1598
+ private readonly closeListeners;
1599
+ private closeSignalSent;
1600
+ private closedResolve;
1601
+ constructor(socket: WebSocket);
1602
+ onReady(listener: (status: TerminalReadyStatus) => void): () => void;
1603
+ onData(listener: (data: Uint8Array) => void): () => void;
1604
+ onExit(listener: (status: TerminalExitStatus) => void): () => void;
1605
+ onError(listener: (error: TerminalErrorStatus | Error) => void): () => void;
1606
+ onClose(listener: () => void): () => void;
1607
+ sendInput(data: string | ArrayBuffer | ArrayBufferView): void;
1608
+ resize(payload: TerminalResizePayload): void;
1609
+ close(): void;
1610
+ private handleMessage;
1611
+ private sendFrame;
1612
+ private emitError;
1613
+ }
893
1614
  declare class SandboxAgent {
894
1615
  private readonly baseUrl;
895
1616
  private readonly token?;
896
1617
  private readonly fetcher;
897
1618
  private readonly defaultHeaders?;
1619
+ private readonly healthWait;
1620
+ private readonly healthWaitAbortController;
898
1621
  private readonly persist;
899
1622
  private readonly replayMaxEvents;
900
1623
  private readonly replayMaxChars;
901
1624
  private spawnHandle?;
1625
+ private healthPromise?;
1626
+ private healthError?;
1627
+ private disposed;
902
1628
  private readonly liveConnections;
903
1629
  private readonly pendingLiveConnections;
904
1630
  private readonly sessionHandles;
@@ -916,18 +1642,36 @@ declare class SandboxAgent {
916
1642
  resumeSession(id: string): Promise<Session>;
917
1643
  resumeOrCreateSession(request: SessionResumeOrCreateRequest): Promise<Session>;
918
1644
  destroySession(id: string): Promise<Session>;
1645
+ setSessionMode(sessionId: string, modeId: string): Promise<{
1646
+ session: Session;
1647
+ response: SetSessionModeResponse | void;
1648
+ }>;
1649
+ setSessionConfigOption(sessionId: string, configId: string, value: string): Promise<{
1650
+ session: Session;
1651
+ response: SetSessionConfigOptionResponse;
1652
+ }>;
1653
+ setSessionModel(sessionId: string, model: string): Promise<{
1654
+ session: Session;
1655
+ response: SetSessionConfigOptionResponse;
1656
+ }>;
1657
+ setSessionThoughtLevel(sessionId: string, thoughtLevel: string): Promise<{
1658
+ session: Session;
1659
+ response: SetSessionConfigOptionResponse;
1660
+ }>;
1661
+ getSessionConfigOptions(sessionId: string): Promise<SessionConfigOption[]>;
1662
+ getSessionModes(sessionId: string): Promise<SessionModeState | null>;
1663
+ private setSessionCategoryValue;
1664
+ private hydrateSessionConfigOptions;
919
1665
  sendSessionMethod(sessionId: string, method: string, params: Record<string, unknown>, options?: SessionSendOptions): Promise<{
920
1666
  session: Session;
921
1667
  response: unknown;
922
1668
  }>;
1669
+ private sendSessionMethodInternal;
1670
+ private persistSessionStateFromMethod;
923
1671
  onSessionEvent(sessionId: string, listener: SessionEventListener): () => void;
924
1672
  getHealth(): Promise<HealthResponse>;
925
- listAgents(options?: {
926
- config?: boolean;
927
- }): Promise<AgentListResponse>;
928
- getAgent(agent: string, options?: {
929
- config?: boolean;
930
- }): Promise<AgentInfo>;
1673
+ listAgents(options?: AgentQueryOptions): Promise<AgentListResponse>;
1674
+ getAgent(agent: string, options?: AgentQueryOptions): Promise<AgentInfo>;
931
1675
  installAgent(agent: string, request?: AgentInstallRequest): Promise<AgentInstallResponse>;
932
1676
  listAcpServers(): Promise<AcpServerListResponse>;
933
1677
  listFsEntries(query?: FsEntriesQuery): Promise<FsEntry[]>;
@@ -944,8 +1688,25 @@ declare class SandboxAgent {
944
1688
  getSkillsConfig(query: SkillsConfigQuery): Promise<SkillsConfig>;
945
1689
  setSkillsConfig(query: SkillsConfigQuery, config: SkillsConfig): Promise<void>;
946
1690
  deleteSkillsConfig(query: SkillsConfigQuery): Promise<void>;
1691
+ getProcessConfig(): Promise<ProcessConfig>;
1692
+ setProcessConfig(config: ProcessConfig): Promise<ProcessConfig>;
1693
+ createProcess(request: ProcessCreateRequest): Promise<ProcessInfo>;
1694
+ runProcess(request: ProcessRunRequest): Promise<ProcessRunResponse>;
1695
+ listProcesses(): Promise<ProcessListResponse>;
1696
+ getProcess(id: string): Promise<ProcessInfo>;
1697
+ stopProcess(id: string, query?: ProcessSignalQuery): Promise<ProcessInfo>;
1698
+ killProcess(id: string, query?: ProcessSignalQuery): Promise<ProcessInfo>;
1699
+ deleteProcess(id: string): Promise<void>;
1700
+ getProcessLogs(id: string, query?: ProcessLogFollowQuery): Promise<ProcessLogsResponse>;
1701
+ followProcessLogs(id: string, listener: ProcessLogListener, query?: ProcessLogFollowQuery): Promise<ProcessLogSubscription>;
1702
+ sendProcessInput(id: string, request: ProcessInputRequest): Promise<ProcessInputResponse>;
1703
+ resizeProcessTerminal(id: string, request: ProcessTerminalResizeRequest): Promise<ProcessTerminalResizeResponse>;
1704
+ buildProcessTerminalWebSocketUrl(id: string, options?: ProcessTerminalWebSocketUrlOptions): string;
1705
+ connectProcessTerminalWebSocket(id: string, options?: ProcessTerminalConnectOptions): WebSocket;
1706
+ connectProcessTerminal(id: string, options?: ProcessTerminalSessionOptions): ProcessTerminalSession;
947
1707
  private getLiveConnection;
948
1708
  private persistObservedEnvelope;
1709
+ private persistSessionStateFromEvent;
949
1710
  private allocateSessionEventIndex;
950
1711
  private ensureSessionEventIndexSeeded;
951
1712
  private findMaxPersistedSessionEventIndex;
@@ -954,8 +1715,12 @@ declare class SandboxAgent {
954
1715
  private requireSessionRecord;
955
1716
  private requestJson;
956
1717
  private requestRaw;
1718
+ private startHealthWait;
1719
+ private awaitHealthy;
1720
+ private runHealthWait;
957
1721
  private buildHeaders;
958
1722
  private buildUrl;
1723
+ private requestHealth;
959
1724
  }
960
1725
 
961
1726
  interface InspectorUrlOptions {
@@ -979,4 +1744,4 @@ interface InspectorUrlOptions {
979
1744
  */
980
1745
  declare function buildInspectorUrl(options: InspectorUrlOptions): string;
981
1746
 
982
- export { type AcpEnvelope, type AcpServerInfo, type AcpServerListResponse, type AgentInfo, type AgentInstallRequest, type AgentInstallResponse, type AgentListResponse, type FsActionResponse, type FsDeleteQuery, type FsEntriesQuery, type FsEntry, type FsMoveRequest, type FsMoveResponse, type FsPathQuery, type FsStat, type FsUploadBatchQuery, type FsUploadBatchResponse, type FsWriteResponse, type HealthResponse, InMemorySessionPersistDriver, type InMemorySessionPersistDriverOptions, type InspectorUrlOptions, type ListEventsRequest, type ListPage, type ListPageRequest, LiveAcpConnection, type McpConfigQuery, type McpServerConfig, type ProblemDetails, SandboxAgent, type SandboxAgentConnectOptions, SandboxAgentError, type SandboxAgentSpawnLogMode, type SandboxAgentSpawnOptions, type SandboxAgentStartOptions, Session, type SessionCreateRequest, type SessionEvent, type SessionEventListener, type SessionPersistDriver, type SessionRecord, type SessionResumeOrCreateRequest, type SessionSendOptions, type SkillsConfig, type SkillsConfigQuery, buildInspectorUrl };
1747
+ export { type AcpEnvelope, type AcpServerInfo, type AcpServerListResponse, type AgentInfo, type AgentInstallRequest, type AgentInstallResponse, type AgentListResponse, type AgentQuery, type AgentQueryOptions, type FsActionResponse, type FsDeleteQuery, type FsEntriesQuery, type FsEntry, type FsMoveRequest, type FsMoveResponse, type FsPathQuery, type FsStat, type FsUploadBatchQuery, type FsUploadBatchResponse, type FsWriteResponse, type HealthResponse, InMemorySessionPersistDriver, type InMemorySessionPersistDriverOptions, type InspectorUrlOptions, type ListEventsRequest, type ListPage, type ListPageRequest, LiveAcpConnection, type McpConfigQuery, type McpServerConfig, type ProblemDetails, type ProcessConfig, type ProcessCreateRequest, type ProcessInfo, type ProcessInputRequest, type ProcessInputResponse, type ProcessListResponse, type ProcessLogEntry, type ProcessLogFollowQuery, type ProcessLogListener, type ProcessLogSubscription, type ProcessLogsQuery, type ProcessLogsResponse, type ProcessLogsStream, type ProcessRunRequest, type ProcessRunResponse, type ProcessSignalQuery, type ProcessState, type ProcessTerminalClientFrame, type ProcessTerminalConnectOptions, type ProcessTerminalErrorFrame, type ProcessTerminalExitFrame, type ProcessTerminalReadyFrame, type ProcessTerminalResizeRequest, type ProcessTerminalResizeResponse, type ProcessTerminalServerFrame, ProcessTerminalSession, type ProcessTerminalSessionOptions, type ProcessTerminalWebSocketUrlOptions, SandboxAgent, type SandboxAgentConnectOptions, SandboxAgentError, type SandboxAgentHealthWaitOptions, type SandboxAgentSpawnLogMode, type SandboxAgentSpawnOptions, type SandboxAgentStartOptions, Session, type SessionCreateRequest, type SessionEvent, type SessionEventListener, type SessionPersistDriver, type SessionRecord, type SessionResumeOrCreateRequest, type SessionSendOptions, type SkillsConfig, type SkillsConfigQuery, type TerminalErrorStatus, type TerminalExitStatus, type TerminalReadyStatus, type TerminalResizePayload, type TerminalStatusMessage, UnsupportedSessionCategoryError, UnsupportedSessionConfigOptionError, UnsupportedSessionValueError, buildInspectorUrl };