@blaxel/core 0.2.50-dev.215 → 0.2.50

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.
Files changed (85) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/agents/index.js +2 -2
  3. package/dist/cjs/authentication/clientcredentials.js +1 -4
  4. package/dist/cjs/common/internal.js +0 -40
  5. package/dist/cjs/common/settings.js +2 -5
  6. package/dist/cjs/jobs/jobs.js +2 -2
  7. package/dist/cjs/jobs/start.js +1 -32
  8. package/dist/cjs/sandbox/action.js +2 -1
  9. package/dist/cjs/sandbox/sandbox.js +10 -67
  10. package/dist/cjs/tools/mcpTool.js +2 -2
  11. package/dist/cjs/types/common/internal.d.ts +0 -2
  12. package/dist/cjs/types/common/settings.d.ts +0 -1
  13. package/dist/cjs/types/sandbox/sandbox.d.ts +6 -12
  14. package/dist/cjs/types/sandbox/types.d.ts +0 -3
  15. package/dist/cjs-browser/.tsbuildinfo +1 -1
  16. package/dist/cjs-browser/agents/index.js +2 -2
  17. package/dist/cjs-browser/authentication/clientcredentials.js +1 -4
  18. package/dist/cjs-browser/common/internal.js +0 -40
  19. package/dist/cjs-browser/common/settings.js +2 -5
  20. package/dist/cjs-browser/jobs/jobs.js +2 -2
  21. package/dist/cjs-browser/jobs/start.js +1 -32
  22. package/dist/cjs-browser/sandbox/action.js +2 -1
  23. package/dist/cjs-browser/sandbox/sandbox.js +10 -67
  24. package/dist/cjs-browser/tools/mcpTool.js +2 -2
  25. package/dist/cjs-browser/types/common/internal.d.ts +0 -2
  26. package/dist/cjs-browser/types/common/settings.d.ts +0 -1
  27. package/dist/cjs-browser/types/sandbox/sandbox.d.ts +6 -12
  28. package/dist/cjs-browser/types/sandbox/types.d.ts +0 -3
  29. package/dist/esm/.tsbuildinfo +1 -1
  30. package/dist/esm/agents/index.js +3 -3
  31. package/dist/esm/authentication/clientcredentials.js +1 -4
  32. package/dist/esm/common/internal.js +0 -38
  33. package/dist/esm/common/settings.js +2 -5
  34. package/dist/esm/jobs/jobs.js +3 -3
  35. package/dist/esm/jobs/start.js +1 -32
  36. package/dist/esm/sandbox/action.js +3 -2
  37. package/dist/esm/sandbox/sandbox.js +10 -67
  38. package/dist/esm/tools/mcpTool.js +3 -3
  39. package/dist/esm-browser/.tsbuildinfo +1 -1
  40. package/dist/esm-browser/agents/index.js +3 -3
  41. package/dist/esm-browser/authentication/clientcredentials.js +1 -4
  42. package/dist/esm-browser/common/internal.js +0 -38
  43. package/dist/esm-browser/common/settings.js +2 -5
  44. package/dist/esm-browser/jobs/jobs.js +3 -3
  45. package/dist/esm-browser/jobs/start.js +1 -32
  46. package/dist/esm-browser/sandbox/action.js +3 -2
  47. package/dist/esm-browser/sandbox/sandbox.js +10 -67
  48. package/dist/esm-browser/tools/mcpTool.js +3 -3
  49. package/package.json +2 -2
  50. package/dist/cjs/sandbox/codegen/codegen-ws.js +0 -30
  51. package/dist/cjs/sandbox/filesystem/filesystem-ws.js +0 -106
  52. package/dist/cjs/sandbox/network/network-ws.js +0 -12
  53. package/dist/cjs/sandbox/process/process-ws.js +0 -139
  54. package/dist/cjs/sandbox/websocket/client.js +0 -269
  55. package/dist/cjs/sandbox/websocket/index.js +0 -17
  56. package/dist/cjs/types/sandbox/codegen/codegen-ws.d.ts +0 -10
  57. package/dist/cjs/types/sandbox/filesystem/filesystem-ws.d.ts +0 -35
  58. package/dist/cjs/types/sandbox/network/network-ws.d.ts +0 -7
  59. package/dist/cjs/types/sandbox/process/process-ws.d.ts +0 -27
  60. package/dist/cjs/types/sandbox/websocket/client.d.ts +0 -48
  61. package/dist/cjs/types/sandbox/websocket/index.d.ts +0 -1
  62. package/dist/cjs-browser/sandbox/codegen/codegen-ws.js +0 -30
  63. package/dist/cjs-browser/sandbox/filesystem/filesystem-ws.js +0 -106
  64. package/dist/cjs-browser/sandbox/network/network-ws.js +0 -12
  65. package/dist/cjs-browser/sandbox/process/process-ws.js +0 -139
  66. package/dist/cjs-browser/sandbox/websocket/client.js +0 -269
  67. package/dist/cjs-browser/sandbox/websocket/index.js +0 -17
  68. package/dist/cjs-browser/types/sandbox/codegen/codegen-ws.d.ts +0 -10
  69. package/dist/cjs-browser/types/sandbox/filesystem/filesystem-ws.d.ts +0 -35
  70. package/dist/cjs-browser/types/sandbox/network/network-ws.d.ts +0 -7
  71. package/dist/cjs-browser/types/sandbox/process/process-ws.d.ts +0 -27
  72. package/dist/cjs-browser/types/sandbox/websocket/client.d.ts +0 -48
  73. package/dist/cjs-browser/types/sandbox/websocket/index.d.ts +0 -1
  74. package/dist/esm/sandbox/codegen/codegen-ws.js +0 -26
  75. package/dist/esm/sandbox/filesystem/filesystem-ws.js +0 -102
  76. package/dist/esm/sandbox/network/network-ws.js +0 -8
  77. package/dist/esm/sandbox/process/process-ws.js +0 -135
  78. package/dist/esm/sandbox/websocket/client.js +0 -265
  79. package/dist/esm/sandbox/websocket/index.js +0 -1
  80. package/dist/esm-browser/sandbox/codegen/codegen-ws.js +0 -26
  81. package/dist/esm-browser/sandbox/filesystem/filesystem-ws.js +0 -102
  82. package/dist/esm-browser/sandbox/network/network-ws.js +0 -8
  83. package/dist/esm-browser/sandbox/process/process-ws.js +0 -135
  84. package/dist/esm-browser/sandbox/websocket/client.js +0 -265
  85. package/dist/esm-browser/sandbox/websocket/index.js +0 -1
@@ -1,269 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebSocketClient = void 0;
4
- const uuid_1 = require("uuid");
5
- const node_js_1 = require("../../common/node.js");
6
- const settings_js_1 = require("../../common/settings.js");
7
- class WebSocketClient {
8
- ws = null;
9
- WebSocketClass = null;
10
- url;
11
- reconnect;
12
- reconnectInterval;
13
- maxReconnectAttempts;
14
- reconnectAttempts = 0;
15
- pendingRequests = new Map();
16
- streamHandlers = new Map();
17
- isClosing = false;
18
- connectionPromise = null;
19
- heartbeatInterval = null;
20
- reconnectTimeout = null;
21
- lastPongReceived = Date.now();
22
- constructor(options) {
23
- this.url = options.url;
24
- this.reconnect = options.reconnect ?? true;
25
- this.reconnectInterval = options.reconnectInterval ?? 5000;
26
- this.maxReconnectAttempts = options.maxReconnectAttempts ?? 5;
27
- }
28
- async connect() {
29
- if (this.connectionPromise) {
30
- return this.connectionPromise;
31
- }
32
- this.connectionPromise = this.initializeConnection();
33
- return this.connectionPromise;
34
- }
35
- async initializeConnection() {
36
- return new Promise((resolve, reject) => {
37
- // Get WebSocket class and connect
38
- void (async () => {
39
- try {
40
- // Get WebSocket class if not already loaded
41
- if (!this.WebSocketClass) {
42
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
43
- this.WebSocketClass = await (0, node_js_1.getWebSocket)();
44
- }
45
- // Convert http/https URL to ws/wss
46
- let wsUrl = this.url;
47
- if (wsUrl.startsWith("http://")) {
48
- wsUrl = wsUrl.replace("http://", "ws://");
49
- }
50
- else if (wsUrl.startsWith("https://")) {
51
- wsUrl = wsUrl.replace("https://", "wss://");
52
- }
53
- // Add /ws endpoint if not present
54
- if (!wsUrl.endsWith("/ws")) {
55
- wsUrl = `${wsUrl}/ws`;
56
- }
57
- wsUrl = `${wsUrl}?token=${settings_js_1.settings.token}`;
58
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
59
- this.ws = new this.WebSocketClass(wsUrl);
60
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
61
- this.ws.onopen = () => {
62
- this.reconnectAttempts = 0;
63
- this.startHeartbeat();
64
- resolve();
65
- };
66
- this.ws.onmessage = (event) => {
67
- this.handleMessage(event);
68
- };
69
- this.ws.onerror = (error) => {
70
- console.error("WebSocket error:", error);
71
- reject(new Error("WebSocket connection error"));
72
- };
73
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
74
- this.ws.onclose = () => {
75
- this.stopHeartbeat();
76
- this.connectionPromise = null;
77
- if (!this.isClosing && this.reconnect && this.reconnectAttempts < this.maxReconnectAttempts) {
78
- this.reconnectAttempts++;
79
- this.reconnectTimeout = setTimeout(() => {
80
- this.connect().catch(console.error);
81
- }, this.reconnectInterval);
82
- // Allow process to exit even if reconnect timeout is pending
83
- if (this.reconnectTimeout.unref) {
84
- this.reconnectTimeout.unref();
85
- }
86
- }
87
- else {
88
- // Reject all pending requests
89
- this.pendingRequests.forEach(({ reject }) => {
90
- reject(new Error("WebSocket connection closed"));
91
- });
92
- this.pendingRequests.clear();
93
- }
94
- };
95
- // Handle pong messages for heartbeat
96
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
97
- if (typeof this.ws.on === 'function') {
98
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
99
- this.ws.on('pong', () => {
100
- this.lastPongReceived = Date.now();
101
- });
102
- }
103
- }
104
- catch (error) {
105
- reject(error instanceof Error ? error : new Error(String(error)));
106
- }
107
- })();
108
- });
109
- }
110
- startHeartbeat() {
111
- // Send ping every 30 seconds
112
- this.heartbeatInterval = setInterval(() => {
113
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
114
- if (this.ws && this.WebSocketClass && this.ws.readyState === this.WebSocketClass.OPEN) {
115
- // Check if we received a pong recently (within 60 seconds)
116
- if (Date.now() - this.lastPongReceived > 60000) {
117
- console.warn("WebSocket heartbeat timeout, closing connection");
118
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
119
- this.ws.close();
120
- return;
121
- }
122
- // Send ping
123
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
124
- if (typeof this.ws.ping === 'function') {
125
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
126
- this.ws.ping();
127
- }
128
- }
129
- }, 30000);
130
- // Allow process to exit even if heartbeat interval is active
131
- if (this.heartbeatInterval.unref) {
132
- this.heartbeatInterval.unref();
133
- }
134
- }
135
- stopHeartbeat() {
136
- if (this.heartbeatInterval) {
137
- clearInterval(this.heartbeatInterval);
138
- this.heartbeatInterval = null;
139
- }
140
- }
141
- handleMessage(event) {
142
- try {
143
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
144
- const response = JSON.parse(String(event.data));
145
- // Check if this is a streaming response
146
- if (response.stream) {
147
- const streamHandler = this.streamHandlers.get(response.id);
148
- if (streamHandler) {
149
- // Call the data handler with the response data
150
- streamHandler.onData(response.data);
151
- // If stream is done, call end handler and clean up
152
- if (response.done) {
153
- streamHandler.onEnd();
154
- this.streamHandlers.delete(response.id);
155
- }
156
- }
157
- return;
158
- }
159
- // Regular request-response handling
160
- const pending = this.pendingRequests.get(response.id);
161
- if (pending) {
162
- this.pendingRequests.delete(response.id);
163
- if (response.success) {
164
- pending.resolve(response.data);
165
- }
166
- else {
167
- pending.reject(new Error(response.error || "Unknown error"));
168
- }
169
- }
170
- }
171
- catch (error) {
172
- console.error("Failed to parse WebSocket message:", error);
173
- }
174
- }
175
- async send(operation, data = {}) {
176
- // Ensure we're connected
177
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
178
- if (!this.ws || !this.WebSocketClass || this.ws.readyState !== this.WebSocketClass.OPEN) {
179
- await this.connect();
180
- }
181
- return new Promise((resolve, reject) => {
182
- const id = (0, uuid_1.v4)();
183
- const message = {
184
- id,
185
- operation,
186
- data,
187
- };
188
- // Store the promise handlers
189
- this.pendingRequests.set(id, { resolve, reject });
190
- // Set a timeout for the request (60 seconds)
191
- setTimeout(() => {
192
- if (this.pendingRequests.has(id)) {
193
- this.pendingRequests.delete(id);
194
- reject(new Error("Request timeout"));
195
- }
196
- }, 60000);
197
- // Send the message
198
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
199
- if (this.ws && this.WebSocketClass && this.ws.readyState === this.WebSocketClass.OPEN) {
200
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
201
- this.ws.send(JSON.stringify(message));
202
- }
203
- else {
204
- this.pendingRequests.delete(id);
205
- reject(new Error("WebSocket not connected"));
206
- }
207
- });
208
- }
209
- sendStream(operation, data, onData, onEnd) {
210
- // Ensure we're connected
211
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
212
- if (!this.ws || !this.WebSocketClass || this.ws.readyState !== this.WebSocketClass.OPEN) {
213
- throw new Error("WebSocket not connected");
214
- }
215
- const id = (0, uuid_1.v4)();
216
- const message = {
217
- id,
218
- operation,
219
- data,
220
- };
221
- // Store the stream handlers
222
- this.streamHandlers.set(id, { onData, onEnd });
223
- // Send the message
224
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
225
- this.ws.send(JSON.stringify(message));
226
- return id;
227
- }
228
- cancelStream(id) {
229
- this.streamHandlers.delete(id);
230
- }
231
- close() {
232
- this.isClosing = true;
233
- this.reconnect = false;
234
- this.stopHeartbeat();
235
- // Clear reconnect timeout if any
236
- if (this.reconnectTimeout) {
237
- clearTimeout(this.reconnectTimeout);
238
- this.reconnectTimeout = null;
239
- }
240
- if (this.ws) {
241
- // In Node.js (ws package), use terminate() to forcefully close the connection
242
- // This immediately closes the socket without waiting for the close handshake
243
- // In browser, terminate() doesn't exist, so we fall back to close()
244
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
245
- if (typeof this.ws.terminate === 'function') {
246
- // Node.js ws package - force immediate close
247
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
248
- this.ws.terminate();
249
- }
250
- else {
251
- // Browser WebSocket - graceful close
252
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
253
- this.ws.close();
254
- }
255
- this.ws = null;
256
- }
257
- // Reject all pending requests
258
- this.pendingRequests.forEach(({ reject }) => {
259
- reject(new Error("WebSocket client closed"));
260
- });
261
- this.pendingRequests.clear();
262
- this.connectionPromise = null;
263
- }
264
- get isConnected() {
265
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
266
- return this.ws !== null && this.WebSocketClass !== null && this.ws.readyState === this.WebSocketClass.OPEN;
267
- }
268
- }
269
- exports.WebSocketClient = WebSocketClient;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./client.js"), exports);
@@ -1,10 +0,0 @@
1
- import { Sandbox } from "../../client/types.gen.js";
2
- import { SandboxAction } from "../action.js";
3
- import { WebSocketClient } from "../websocket/index.js";
4
- import { ApplyEditResponse, RerankingResponse } from "../client/types.gen.js";
5
- export declare class SandboxCodegenWebSocket extends SandboxAction {
6
- private wsClient;
7
- constructor(sandbox: Sandbox, wsClient: WebSocketClient);
8
- fastapply(path: string, codeEdit: string, model?: string): Promise<ApplyEditResponse>;
9
- reranking(path: string, query: string, scoreThreshold?: number, tokenLimit?: number, filePattern?: string): Promise<RerankingResponse>;
10
- }
@@ -1,35 +0,0 @@
1
- import { SandboxAction } from "../action.js";
2
- import { WebSocketClient } from "../websocket/index.js";
3
- import { Directory, SuccessResponse } from "../client/index.js";
4
- import { SandboxProcess } from "../process/index.js";
5
- import { SandboxProcessWebSocket } from "../process/process-ws.js";
6
- import { CopyResponse, SandboxFilesystemFile, WatchEvent } from "./types.js";
7
- import { SandboxConfiguration } from "../types.js";
8
- export declare class SandboxFileSystemWebSocket extends SandboxAction {
9
- private process;
10
- private wsClient;
11
- private httpClient;
12
- constructor(sandbox: SandboxConfiguration, process: SandboxProcess | SandboxProcessWebSocket, wsClient: WebSocketClient);
13
- mkdir(path: string, permissions?: string): Promise<SuccessResponse>;
14
- write(path: string, content: string): Promise<SuccessResponse>;
15
- writeBinary(path: string, content: Buffer | Blob | File | Uint8Array | string): Promise<SuccessResponse>;
16
- writeTree(files: SandboxFilesystemFile[], destinationPath?: string | null): Promise<Directory>;
17
- read(path: string): Promise<string>;
18
- readBinary(path: string): Promise<Blob>;
19
- download(src: string, destinationPath: string, options?: {
20
- mode?: number;
21
- }): Promise<void>;
22
- rm(path: string, recursive?: boolean): Promise<SuccessResponse>;
23
- ls(path: string): Promise<Directory>;
24
- cp(source: string, destination: string, { maxWait }?: {
25
- maxWait?: number;
26
- }): Promise<CopyResponse>;
27
- watch(path: string, callback: (fileEvent: WatchEvent) => void | Promise<void>, options?: {
28
- onError?: (error: Error) => void;
29
- withContent: boolean;
30
- ignore?: string[];
31
- }): {
32
- close: () => void;
33
- };
34
- private formatPath;
35
- }
@@ -1,7 +0,0 @@
1
- import { Sandbox } from "../../client/types.gen.js";
2
- import { SandboxAction } from "../action.js";
3
- import { WebSocketClient } from "../websocket/index.js";
4
- export declare class SandboxNetworkWebSocket extends SandboxAction {
5
- private wsClient;
6
- constructor(sandbox: Sandbox, wsClient: WebSocketClient);
7
- }
@@ -1,27 +0,0 @@
1
- import { Sandbox } from "../../client/types.gen.js";
2
- import { SandboxAction } from "../action.js";
3
- import { WebSocketClient } from "../websocket/index.js";
4
- import { ProcessRequest, ProcessResponse, SuccessResponse } from "../client/index.js";
5
- import { ProcessRequestWithLog, ProcessResponseWithLog } from "../types.js";
6
- export declare class SandboxProcessWebSocket extends SandboxAction {
7
- private wsClient;
8
- private httpClient;
9
- constructor(sandbox: Sandbox, wsClient: WebSocketClient);
10
- streamLogs(identifier: string, options: {
11
- onLog?: (log: string) => void;
12
- onStdout?: (stdout: string) => void;
13
- onStderr?: (stderr: string) => void;
14
- }): {
15
- close: () => void;
16
- };
17
- exec(process: ProcessRequest | ProcessRequestWithLog): Promise<ProcessResponse | ProcessResponseWithLog>;
18
- wait(identifier: string, { maxWait, interval }?: {
19
- maxWait?: number;
20
- interval?: number;
21
- }): Promise<ProcessResponse>;
22
- get(identifier: string): Promise<ProcessResponse>;
23
- list(): Promise<ProcessResponse[]>;
24
- stop(identifier: string): Promise<SuccessResponse>;
25
- kill(identifier: string): Promise<SuccessResponse>;
26
- logs(identifier: string, type?: "stdout" | "stderr" | "all"): Promise<string>;
27
- }
@@ -1,48 +0,0 @@
1
- export interface WebSocketMessage {
2
- id: string;
3
- operation: string;
4
- data: Record<string, any>;
5
- }
6
- export interface WebSocketResponse {
7
- id: string;
8
- success: boolean;
9
- data?: any;
10
- error?: string;
11
- status?: number;
12
- stream?: boolean;
13
- done?: boolean;
14
- }
15
- export interface WebSocketClientOptions {
16
- url: string;
17
- headers?: Record<string, string>;
18
- reconnect?: boolean;
19
- reconnectInterval?: number;
20
- maxReconnectAttempts?: number;
21
- }
22
- export declare class WebSocketClient {
23
- private ws;
24
- private WebSocketClass;
25
- private url;
26
- private reconnect;
27
- private reconnectInterval;
28
- private maxReconnectAttempts;
29
- private reconnectAttempts;
30
- private pendingRequests;
31
- private streamHandlers;
32
- private isClosing;
33
- private connectionPromise;
34
- private heartbeatInterval;
35
- private reconnectTimeout;
36
- private lastPongReceived;
37
- constructor(options: WebSocketClientOptions);
38
- connect(): Promise<void>;
39
- private initializeConnection;
40
- private startHeartbeat;
41
- private stopHeartbeat;
42
- private handleMessage;
43
- send<T = any>(operation: string, data?: Record<string, any>): Promise<T>;
44
- sendStream(operation: string, data: Record<string, any>, onData: (data: any) => void, onEnd: () => void): string;
45
- cancelStream(id: string): void;
46
- close(): void;
47
- get isConnected(): boolean;
48
- }
@@ -1 +0,0 @@
1
- export * from "./client.js";
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SandboxCodegenWebSocket = void 0;
4
- const action_js_1 = require("../action.js");
5
- class SandboxCodegenWebSocket extends action_js_1.SandboxAction {
6
- wsClient;
7
- constructor(sandbox, wsClient) {
8
- super(sandbox);
9
- this.wsClient = wsClient;
10
- }
11
- async fastapply(path, codeEdit, model) {
12
- const data = await this.wsClient.send("codegen:fastapply", {
13
- path,
14
- codeEdit,
15
- model,
16
- });
17
- return data;
18
- }
19
- async reranking(path, query, scoreThreshold, tokenLimit, filePattern) {
20
- const data = await this.wsClient.send("codegen:reranking", {
21
- path,
22
- query,
23
- scoreThreshold,
24
- tokenLimit,
25
- filePattern,
26
- });
27
- return data;
28
- }
29
- }
30
- exports.SandboxCodegenWebSocket = SandboxCodegenWebSocket;
@@ -1,106 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SandboxFileSystemWebSocket = void 0;
4
- const action_js_1 = require("../action.js");
5
- const filesystem_js_1 = require("./filesystem.js");
6
- class SandboxFileSystemWebSocket extends action_js_1.SandboxAction {
7
- process;
8
- wsClient;
9
- httpClient;
10
- constructor(sandbox, process, wsClient) {
11
- super(sandbox);
12
- this.process = process;
13
- this.wsClient = wsClient;
14
- // Create HTTP client for fallback operations
15
- this.httpClient = new filesystem_js_1.SandboxFileSystem(sandbox, process);
16
- }
17
- async mkdir(path, permissions = "0755") {
18
- path = this.formatPath(path);
19
- const data = await this.wsClient.send("filesystem:create", {
20
- path,
21
- isDirectory: true,
22
- permissions,
23
- });
24
- return data;
25
- }
26
- async write(path, content) {
27
- path = this.formatPath(path);
28
- const data = await this.wsClient.send("filesystem:create", {
29
- path,
30
- content,
31
- isDirectory: false,
32
- });
33
- return data;
34
- }
35
- async writeBinary(path, content) {
36
- return this.httpClient.writeBinary(path, content);
37
- }
38
- async writeTree(files, destinationPath = null) {
39
- const path = this.formatPath(destinationPath ?? "");
40
- const filesMap = files.reduce((acc, file) => {
41
- acc[file.path] = file.content;
42
- return acc;
43
- }, {});
44
- const data = await this.wsClient.send("filesystem:tree:create", {
45
- path,
46
- files: filesMap,
47
- });
48
- return data;
49
- }
50
- async read(path) {
51
- path = this.formatPath(path);
52
- const data = await this.wsClient.send("filesystem:get", { path });
53
- return data.content;
54
- }
55
- async readBinary(path) {
56
- // Binary downloads are better suited for HTTP
57
- // Fall back to HTTP client for binary operations
58
- return this.httpClient.readBinary(path);
59
- }
60
- async download(src, destinationPath, options = {}) {
61
- // File downloads are better suited for HTTP
62
- // Fall back to HTTP client
63
- return this.httpClient.download(src, destinationPath, options);
64
- }
65
- async rm(path, recursive = false) {
66
- path = this.formatPath(path);
67
- const data = await this.wsClient.send("filesystem:delete", {
68
- path,
69
- recursive,
70
- });
71
- return data;
72
- }
73
- async ls(path) {
74
- path = this.formatPath(path);
75
- const data = await this.wsClient.send("filesystem:get", { path });
76
- return data;
77
- }
78
- async cp(source, destination, { maxWait = 180000 } = {}) {
79
- // Copy operation is typically done via process execution
80
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
81
- let process = await this.process.exec({
82
- command: `cp -r ${source} ${destination}`,
83
- });
84
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
85
- process = await this.process.wait(process.pid, { maxWait, interval: 100 });
86
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
87
- if (process.status === "failed") {
88
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
89
- throw new Error(`Could not copy ${source} to ${destination} cause: ${process.logs}`);
90
- }
91
- return {
92
- message: "Files copied",
93
- source,
94
- destination,
95
- };
96
- }
97
- watch(path, callback, options) {
98
- // File watching uses HTTP streaming which is already optimized
99
- // Fall back to HTTP client
100
- return this.httpClient.watch(path, callback, options);
101
- }
102
- formatPath(path) {
103
- return path;
104
- }
105
- }
106
- exports.SandboxFileSystemWebSocket = SandboxFileSystemWebSocket;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SandboxNetworkWebSocket = void 0;
4
- const action_js_1 = require("../action.js");
5
- class SandboxNetworkWebSocket extends action_js_1.SandboxAction {
6
- wsClient;
7
- constructor(sandbox, wsClient) {
8
- super(sandbox);
9
- this.wsClient = wsClient;
10
- }
11
- }
12
- exports.SandboxNetworkWebSocket = SandboxNetworkWebSocket;