@cloudflare/sandbox 0.5.6 → 0.6.1
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/Dockerfile +54 -56
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -6
- package/.turbo/turbo-build.log +0 -23
- package/CHANGELOG.md +0 -463
- package/src/clients/base-client.ts +0 -356
- package/src/clients/command-client.ts +0 -133
- package/src/clients/file-client.ts +0 -300
- package/src/clients/git-client.ts +0 -98
- package/src/clients/index.ts +0 -64
- package/src/clients/interpreter-client.ts +0 -339
- package/src/clients/port-client.ts +0 -105
- package/src/clients/process-client.ts +0 -198
- package/src/clients/sandbox-client.ts +0 -39
- package/src/clients/types.ts +0 -88
- package/src/clients/utility-client.ts +0 -156
- package/src/errors/adapter.ts +0 -238
- package/src/errors/classes.ts +0 -594
- package/src/errors/index.ts +0 -109
- package/src/file-stream.ts +0 -175
- package/src/index.ts +0 -121
- package/src/interpreter.ts +0 -168
- package/src/openai/index.ts +0 -465
- package/src/request-handler.ts +0 -184
- package/src/sandbox.ts +0 -1937
- package/src/security.ts +0 -119
- package/src/sse-parser.ts +0 -147
- package/src/storage-mount/credential-detection.ts +0 -41
- package/src/storage-mount/errors.ts +0 -51
- package/src/storage-mount/index.ts +0 -17
- package/src/storage-mount/provider-detection.ts +0 -93
- package/src/storage-mount/types.ts +0 -17
- package/src/version.ts +0 -6
- package/tests/base-client.test.ts +0 -582
- package/tests/command-client.test.ts +0 -444
- package/tests/file-client.test.ts +0 -831
- package/tests/file-stream.test.ts +0 -310
- package/tests/get-sandbox.test.ts +0 -172
- package/tests/git-client.test.ts +0 -455
- package/tests/openai-shell-editor.test.ts +0 -434
- package/tests/port-client.test.ts +0 -283
- package/tests/process-client.test.ts +0 -649
- package/tests/request-handler.test.ts +0 -292
- package/tests/sandbox.test.ts +0 -890
- package/tests/sse-parser.test.ts +0 -291
- package/tests/storage-mount/credential-detection.test.ts +0 -119
- package/tests/storage-mount/provider-detection.test.ts +0 -77
- package/tests/utility-client.test.ts +0 -339
- package/tests/version.test.ts +0 -16
- package/tests/wrangler.jsonc +0 -35
- package/tsconfig.json +0 -11
- package/tsdown.config.ts +0 -13
- package/vitest.config.ts +0 -31
package/src/clients/types.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import type { Logger } from '@repo/shared';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Minimal interface for container fetch functionality
|
|
5
|
-
*/
|
|
6
|
-
export interface ContainerStub {
|
|
7
|
-
containerFetch(
|
|
8
|
-
url: string,
|
|
9
|
-
options: RequestInit,
|
|
10
|
-
port?: number
|
|
11
|
-
): Promise<Response>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Shared HTTP client configuration options
|
|
16
|
-
*/
|
|
17
|
-
export interface HttpClientOptions {
|
|
18
|
-
logger?: Logger;
|
|
19
|
-
baseUrl?: string;
|
|
20
|
-
port?: number;
|
|
21
|
-
stub?: ContainerStub;
|
|
22
|
-
onCommandComplete?: (
|
|
23
|
-
success: boolean,
|
|
24
|
-
exitCode: number,
|
|
25
|
-
stdout: string,
|
|
26
|
-
stderr: string,
|
|
27
|
-
command: string
|
|
28
|
-
) => void;
|
|
29
|
-
onError?: (error: string, command?: string) => void;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Base response interface for all API responses
|
|
34
|
-
*/
|
|
35
|
-
export interface BaseApiResponse {
|
|
36
|
-
success: boolean;
|
|
37
|
-
timestamp: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Standard error response structure - matches BaseHandler.createErrorResponse()
|
|
42
|
-
*/
|
|
43
|
-
export interface ApiErrorResponse {
|
|
44
|
-
success: false;
|
|
45
|
-
error: string;
|
|
46
|
-
code: string;
|
|
47
|
-
details?: any;
|
|
48
|
-
timestamp: string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Validation error response structure - matches ValidationMiddleware
|
|
53
|
-
*/
|
|
54
|
-
export interface ValidationErrorResponse {
|
|
55
|
-
error: string;
|
|
56
|
-
message: string;
|
|
57
|
-
details?: any[];
|
|
58
|
-
timestamp: string;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Legacy error response interface - deprecated, use ApiErrorResponse
|
|
63
|
-
*/
|
|
64
|
-
export interface ErrorResponse {
|
|
65
|
-
error: string;
|
|
66
|
-
details?: string;
|
|
67
|
-
code?: string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* HTTP request configuration
|
|
72
|
-
*/
|
|
73
|
-
export interface RequestConfig extends RequestInit {
|
|
74
|
-
endpoint: string;
|
|
75
|
-
data?: Record<string, any>;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Typed response handler
|
|
80
|
-
*/
|
|
81
|
-
export type ResponseHandler<T> = (response: Response) => Promise<T>;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Common session-aware request interface
|
|
85
|
-
*/
|
|
86
|
-
export interface SessionRequest {
|
|
87
|
-
sessionId?: string;
|
|
88
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { BaseHttpClient } from './base-client';
|
|
2
|
-
import type { BaseApiResponse, HttpClientOptions } from './types';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Response interface for ping operations
|
|
6
|
-
*/
|
|
7
|
-
export interface PingResponse extends BaseApiResponse {
|
|
8
|
-
message: string;
|
|
9
|
-
uptime?: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Response interface for getting available commands
|
|
14
|
-
*/
|
|
15
|
-
export interface CommandsResponse extends BaseApiResponse {
|
|
16
|
-
availableCommands: string[];
|
|
17
|
-
count: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Response interface for getting container version
|
|
22
|
-
*/
|
|
23
|
-
export interface VersionResponse extends BaseApiResponse {
|
|
24
|
-
version: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Request interface for creating sessions
|
|
29
|
-
*/
|
|
30
|
-
export interface CreateSessionRequest {
|
|
31
|
-
id: string;
|
|
32
|
-
env?: Record<string, string>;
|
|
33
|
-
cwd?: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Response interface for creating sessions
|
|
38
|
-
*/
|
|
39
|
-
export interface CreateSessionResponse extends BaseApiResponse {
|
|
40
|
-
id: string;
|
|
41
|
-
message: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Request interface for deleting sessions
|
|
46
|
-
*/
|
|
47
|
-
export interface DeleteSessionRequest {
|
|
48
|
-
sessionId: string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Response interface for deleting sessions
|
|
53
|
-
*/
|
|
54
|
-
export interface DeleteSessionResponse extends BaseApiResponse {
|
|
55
|
-
sessionId: string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Client for health checks and utility operations
|
|
60
|
-
*/
|
|
61
|
-
export class UtilityClient extends BaseHttpClient {
|
|
62
|
-
/**
|
|
63
|
-
* Ping the sandbox to check if it's responsive
|
|
64
|
-
*/
|
|
65
|
-
async ping(): Promise<string> {
|
|
66
|
-
try {
|
|
67
|
-
const response = await this.get<PingResponse>('/api/ping');
|
|
68
|
-
|
|
69
|
-
this.logSuccess('Ping successful', response.message);
|
|
70
|
-
return response.message;
|
|
71
|
-
} catch (error) {
|
|
72
|
-
this.logError('ping', error);
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Get list of available commands in the sandbox environment
|
|
79
|
-
*/
|
|
80
|
-
async getCommands(): Promise<string[]> {
|
|
81
|
-
try {
|
|
82
|
-
const response = await this.get<CommandsResponse>('/api/commands');
|
|
83
|
-
|
|
84
|
-
this.logSuccess(
|
|
85
|
-
'Commands retrieved',
|
|
86
|
-
`${response.count} commands available`
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
return response.availableCommands;
|
|
90
|
-
} catch (error) {
|
|
91
|
-
this.logError('getCommands', error);
|
|
92
|
-
throw error;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Create a new execution session
|
|
98
|
-
* @param options - Session configuration (id, env, cwd)
|
|
99
|
-
*/
|
|
100
|
-
async createSession(
|
|
101
|
-
options: CreateSessionRequest
|
|
102
|
-
): Promise<CreateSessionResponse> {
|
|
103
|
-
try {
|
|
104
|
-
const response = await this.post<CreateSessionResponse>(
|
|
105
|
-
'/api/session/create',
|
|
106
|
-
options
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
this.logSuccess('Session created', `ID: ${options.id}`);
|
|
110
|
-
return response;
|
|
111
|
-
} catch (error) {
|
|
112
|
-
this.logError('createSession', error);
|
|
113
|
-
throw error;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Delete an execution session
|
|
119
|
-
* @param sessionId - Session ID to delete
|
|
120
|
-
*/
|
|
121
|
-
async deleteSession(sessionId: string): Promise<DeleteSessionResponse> {
|
|
122
|
-
try {
|
|
123
|
-
const response = await this.post<DeleteSessionResponse>(
|
|
124
|
-
'/api/session/delete',
|
|
125
|
-
{ sessionId }
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
this.logSuccess('Session deleted', `ID: ${sessionId}`);
|
|
129
|
-
return response;
|
|
130
|
-
} catch (error) {
|
|
131
|
-
this.logError('deleteSession', error);
|
|
132
|
-
throw error;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Get the container version
|
|
138
|
-
* Returns the version embedded in the Docker image during build
|
|
139
|
-
*/
|
|
140
|
-
async getVersion(): Promise<string> {
|
|
141
|
-
try {
|
|
142
|
-
const response = await this.get<VersionResponse>('/api/version');
|
|
143
|
-
|
|
144
|
-
this.logSuccess('Version retrieved', response.version);
|
|
145
|
-
return response.version;
|
|
146
|
-
} catch (error) {
|
|
147
|
-
// If version endpoint doesn't exist (old container), return 'unknown'
|
|
148
|
-
// This allows for backward compatibility
|
|
149
|
-
this.logger.debug(
|
|
150
|
-
'Failed to get container version (may be old container)',
|
|
151
|
-
{ error }
|
|
152
|
-
);
|
|
153
|
-
return 'unknown';
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
package/src/errors/adapter.ts
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error adapter that converts ErrorResponse to appropriate Error class
|
|
3
|
-
*
|
|
4
|
-
* Simple switch statement - we trust the container sends correct context
|
|
5
|
-
* No validation overhead since we control both sides
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type {
|
|
9
|
-
CodeExecutionContext,
|
|
10
|
-
CommandErrorContext,
|
|
11
|
-
CommandNotFoundContext,
|
|
12
|
-
ContextNotFoundContext,
|
|
13
|
-
ErrorResponse,
|
|
14
|
-
FileExistsContext,
|
|
15
|
-
FileNotFoundContext,
|
|
16
|
-
FileSystemContext,
|
|
17
|
-
GitAuthFailedContext,
|
|
18
|
-
GitBranchNotFoundContext,
|
|
19
|
-
GitErrorContext,
|
|
20
|
-
GitRepositoryNotFoundContext,
|
|
21
|
-
InternalErrorContext,
|
|
22
|
-
InterpreterNotReadyContext,
|
|
23
|
-
InvalidPortContext,
|
|
24
|
-
PortAlreadyExposedContext,
|
|
25
|
-
PortErrorContext,
|
|
26
|
-
PortNotExposedContext,
|
|
27
|
-
ProcessErrorContext,
|
|
28
|
-
ProcessNotFoundContext,
|
|
29
|
-
ValidationFailedContext
|
|
30
|
-
} from '@repo/shared/errors';
|
|
31
|
-
import { ErrorCode } from '@repo/shared/errors';
|
|
32
|
-
|
|
33
|
-
import {
|
|
34
|
-
CodeExecutionError,
|
|
35
|
-
CommandError,
|
|
36
|
-
CommandNotFoundError,
|
|
37
|
-
ContextNotFoundError,
|
|
38
|
-
CustomDomainRequiredError,
|
|
39
|
-
FileExistsError,
|
|
40
|
-
FileNotFoundError,
|
|
41
|
-
FileSystemError,
|
|
42
|
-
GitAuthenticationError,
|
|
43
|
-
GitBranchNotFoundError,
|
|
44
|
-
GitCheckoutError,
|
|
45
|
-
GitCloneError,
|
|
46
|
-
GitError,
|
|
47
|
-
GitNetworkError,
|
|
48
|
-
GitRepositoryNotFoundError,
|
|
49
|
-
InterpreterNotReadyError,
|
|
50
|
-
InvalidGitUrlError,
|
|
51
|
-
InvalidPortError,
|
|
52
|
-
PermissionDeniedError,
|
|
53
|
-
PortAlreadyExposedError,
|
|
54
|
-
PortError,
|
|
55
|
-
PortInUseError,
|
|
56
|
-
PortNotExposedError,
|
|
57
|
-
ProcessError,
|
|
58
|
-
ProcessNotFoundError,
|
|
59
|
-
SandboxError,
|
|
60
|
-
ServiceNotRespondingError,
|
|
61
|
-
ValidationFailedError
|
|
62
|
-
} from './classes';
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Convert ErrorResponse to appropriate Error class
|
|
66
|
-
* Simple switch statement - we trust the container sends correct context
|
|
67
|
-
*/
|
|
68
|
-
export function createErrorFromResponse(errorResponse: ErrorResponse): Error {
|
|
69
|
-
// We trust the container sends correct context, use type assertions
|
|
70
|
-
switch (errorResponse.code) {
|
|
71
|
-
// File System Errors
|
|
72
|
-
case ErrorCode.FILE_NOT_FOUND:
|
|
73
|
-
return new FileNotFoundError(
|
|
74
|
-
errorResponse as unknown as ErrorResponse<FileNotFoundContext>
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
case ErrorCode.FILE_EXISTS:
|
|
78
|
-
return new FileExistsError(
|
|
79
|
-
errorResponse as unknown as ErrorResponse<FileExistsContext>
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
case ErrorCode.PERMISSION_DENIED:
|
|
83
|
-
return new PermissionDeniedError(
|
|
84
|
-
errorResponse as unknown as ErrorResponse<FileSystemContext>
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
case ErrorCode.IS_DIRECTORY:
|
|
88
|
-
case ErrorCode.NOT_DIRECTORY:
|
|
89
|
-
case ErrorCode.NO_SPACE:
|
|
90
|
-
case ErrorCode.TOO_MANY_FILES:
|
|
91
|
-
case ErrorCode.RESOURCE_BUSY:
|
|
92
|
-
case ErrorCode.READ_ONLY:
|
|
93
|
-
case ErrorCode.NAME_TOO_LONG:
|
|
94
|
-
case ErrorCode.TOO_MANY_LINKS:
|
|
95
|
-
case ErrorCode.FILESYSTEM_ERROR:
|
|
96
|
-
return new FileSystemError(
|
|
97
|
-
errorResponse as unknown as ErrorResponse<FileSystemContext>
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
// Command Errors
|
|
101
|
-
case ErrorCode.COMMAND_NOT_FOUND:
|
|
102
|
-
return new CommandNotFoundError(
|
|
103
|
-
errorResponse as unknown as ErrorResponse<CommandNotFoundContext>
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
case ErrorCode.COMMAND_PERMISSION_DENIED:
|
|
107
|
-
case ErrorCode.COMMAND_EXECUTION_ERROR:
|
|
108
|
-
case ErrorCode.INVALID_COMMAND:
|
|
109
|
-
case ErrorCode.STREAM_START_ERROR:
|
|
110
|
-
return new CommandError(
|
|
111
|
-
errorResponse as unknown as ErrorResponse<CommandErrorContext>
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
// Process Errors
|
|
115
|
-
case ErrorCode.PROCESS_NOT_FOUND:
|
|
116
|
-
return new ProcessNotFoundError(
|
|
117
|
-
errorResponse as unknown as ErrorResponse<ProcessNotFoundContext>
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
case ErrorCode.PROCESS_PERMISSION_DENIED:
|
|
121
|
-
case ErrorCode.PROCESS_ERROR:
|
|
122
|
-
return new ProcessError(
|
|
123
|
-
errorResponse as unknown as ErrorResponse<ProcessErrorContext>
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
// Port Errors
|
|
127
|
-
case ErrorCode.PORT_ALREADY_EXPOSED:
|
|
128
|
-
return new PortAlreadyExposedError(
|
|
129
|
-
errorResponse as unknown as ErrorResponse<PortAlreadyExposedContext>
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
case ErrorCode.PORT_NOT_EXPOSED:
|
|
133
|
-
return new PortNotExposedError(
|
|
134
|
-
errorResponse as unknown as ErrorResponse<PortNotExposedContext>
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
case ErrorCode.INVALID_PORT_NUMBER:
|
|
138
|
-
case ErrorCode.INVALID_PORT:
|
|
139
|
-
return new InvalidPortError(
|
|
140
|
-
errorResponse as unknown as ErrorResponse<InvalidPortContext>
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
case ErrorCode.SERVICE_NOT_RESPONDING:
|
|
144
|
-
return new ServiceNotRespondingError(
|
|
145
|
-
errorResponse as unknown as ErrorResponse<PortErrorContext>
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
case ErrorCode.PORT_IN_USE:
|
|
149
|
-
return new PortInUseError(
|
|
150
|
-
errorResponse as unknown as ErrorResponse<PortErrorContext>
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
case ErrorCode.PORT_OPERATION_ERROR:
|
|
154
|
-
return new PortError(
|
|
155
|
-
errorResponse as unknown as ErrorResponse<PortErrorContext>
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
case ErrorCode.CUSTOM_DOMAIN_REQUIRED:
|
|
159
|
-
return new CustomDomainRequiredError(
|
|
160
|
-
errorResponse as unknown as ErrorResponse<InternalErrorContext>
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
// Git Errors
|
|
164
|
-
case ErrorCode.GIT_REPOSITORY_NOT_FOUND:
|
|
165
|
-
return new GitRepositoryNotFoundError(
|
|
166
|
-
errorResponse as unknown as ErrorResponse<GitRepositoryNotFoundContext>
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
case ErrorCode.GIT_AUTH_FAILED:
|
|
170
|
-
return new GitAuthenticationError(
|
|
171
|
-
errorResponse as unknown as ErrorResponse<GitAuthFailedContext>
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
case ErrorCode.GIT_BRANCH_NOT_FOUND:
|
|
175
|
-
return new GitBranchNotFoundError(
|
|
176
|
-
errorResponse as unknown as ErrorResponse<GitBranchNotFoundContext>
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
case ErrorCode.GIT_NETWORK_ERROR:
|
|
180
|
-
return new GitNetworkError(
|
|
181
|
-
errorResponse as unknown as ErrorResponse<GitErrorContext>
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
case ErrorCode.GIT_CLONE_FAILED:
|
|
185
|
-
return new GitCloneError(
|
|
186
|
-
errorResponse as unknown as ErrorResponse<GitErrorContext>
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
case ErrorCode.GIT_CHECKOUT_FAILED:
|
|
190
|
-
return new GitCheckoutError(
|
|
191
|
-
errorResponse as unknown as ErrorResponse<GitErrorContext>
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
case ErrorCode.INVALID_GIT_URL:
|
|
195
|
-
return new InvalidGitUrlError(
|
|
196
|
-
errorResponse as unknown as ErrorResponse<ValidationFailedContext>
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
case ErrorCode.GIT_OPERATION_FAILED:
|
|
200
|
-
return new GitError(
|
|
201
|
-
errorResponse as unknown as ErrorResponse<GitErrorContext>
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
// Code Interpreter Errors
|
|
205
|
-
case ErrorCode.INTERPRETER_NOT_READY:
|
|
206
|
-
return new InterpreterNotReadyError(
|
|
207
|
-
errorResponse as unknown as ErrorResponse<InterpreterNotReadyContext>
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
case ErrorCode.CONTEXT_NOT_FOUND:
|
|
211
|
-
return new ContextNotFoundError(
|
|
212
|
-
errorResponse as unknown as ErrorResponse<ContextNotFoundContext>
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
case ErrorCode.CODE_EXECUTION_ERROR:
|
|
216
|
-
return new CodeExecutionError(
|
|
217
|
-
errorResponse as unknown as ErrorResponse<CodeExecutionContext>
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
// Validation Errors
|
|
221
|
-
case ErrorCode.VALIDATION_FAILED:
|
|
222
|
-
return new ValidationFailedError(
|
|
223
|
-
errorResponse as unknown as ErrorResponse<ValidationFailedContext>
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
// Generic Errors
|
|
227
|
-
case ErrorCode.INVALID_JSON_RESPONSE:
|
|
228
|
-
case ErrorCode.UNKNOWN_ERROR:
|
|
229
|
-
case ErrorCode.INTERNAL_ERROR:
|
|
230
|
-
return new SandboxError(
|
|
231
|
-
errorResponse as unknown as ErrorResponse<InternalErrorContext>
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
default:
|
|
235
|
-
// Fallback for unknown error codes
|
|
236
|
-
return new SandboxError(errorResponse);
|
|
237
|
-
}
|
|
238
|
-
}
|