@blaxel/core 0.2.53 → 0.2.54-preview.14

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 (31) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/common/settings.js +2 -2
  3. package/dist/cjs/sandbox/client/sdk.gen.js +107 -1
  4. package/dist/cjs/sandbox/filesystem/filesystem.js +81 -1
  5. package/dist/cjs/sandbox/process/process.js +18 -7
  6. package/dist/cjs/types/sandbox/client/sdk.gen.d.ts +31 -1
  7. package/dist/cjs/types/sandbox/client/types.gen.d.ts +305 -0
  8. package/dist/cjs/types/sandbox/filesystem/filesystem.d.ts +5 -2
  9. package/dist/cjs/types/sandbox/filesystem/types.d.ts +20 -0
  10. package/dist/cjs/types/sandbox/process/process.d.ts +2 -1
  11. package/dist/cjs-browser/.tsbuildinfo +1 -1
  12. package/dist/cjs-browser/common/settings.js +2 -2
  13. package/dist/cjs-browser/sandbox/client/sdk.gen.js +107 -1
  14. package/dist/cjs-browser/sandbox/filesystem/filesystem.js +81 -1
  15. package/dist/cjs-browser/sandbox/process/process.js +18 -7
  16. package/dist/cjs-browser/types/sandbox/client/sdk.gen.d.ts +31 -1
  17. package/dist/cjs-browser/types/sandbox/client/types.gen.d.ts +305 -0
  18. package/dist/cjs-browser/types/sandbox/filesystem/filesystem.d.ts +5 -2
  19. package/dist/cjs-browser/types/sandbox/filesystem/types.d.ts +20 -0
  20. package/dist/cjs-browser/types/sandbox/process/process.d.ts +2 -1
  21. package/dist/esm/.tsbuildinfo +1 -1
  22. package/dist/esm/common/settings.js +2 -2
  23. package/dist/esm/sandbox/client/sdk.gen.js +100 -0
  24. package/dist/esm/sandbox/filesystem/filesystem.js +82 -2
  25. package/dist/esm/sandbox/process/process.js +18 -7
  26. package/dist/esm-browser/.tsbuildinfo +1 -1
  27. package/dist/esm-browser/common/settings.js +2 -2
  28. package/dist/esm-browser/sandbox/client/sdk.gen.js +100 -0
  29. package/dist/esm-browser/sandbox/filesystem/filesystem.js +82 -2
  30. package/dist/esm-browser/sandbox/process/process.js +18 -7
  31. package/package.json +1 -1
@@ -9,8 +9,8 @@ const index_js_1 = require("../authentication/index.js");
9
9
  const env_js_1 = require("../common/env.js");
10
10
  const node_js_1 = require("../common/node.js");
11
11
  // Build info - these placeholders are replaced at build time by build:replace-imports
12
- const BUILD_VERSION = "0.2.53";
13
- const BUILD_COMMIT = "1a161063708104c65ae116d189af51e3b9cc5ef7";
12
+ const BUILD_VERSION = "0.2.54-preview.14";
13
+ const BUILD_COMMIT = "36d148e9b7f9dd2134c772d954c8297b3c958ec3";
14
14
  const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
15
15
  // Cache for config.yaml tracking value
16
16
  let configTrackingValue = null;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // This file is auto-generated by @hey-api/openapi-ts
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getWatchFilesystemByPath = exports.getProcessByIdentifierLogsStream = exports.getProcessByIdentifierLogs = exports.deleteProcessByIdentifierKill = exports.getProcessByIdentifier = exports.deleteProcessByIdentifier = exports.postProcess = exports.getProcess = exports.getNetworkProcessByPidPorts = exports.postNetworkProcessByPidMonitor = exports.deleteNetworkProcessByPidMonitor = exports.putFilesystemByPath = exports.getFilesystemByPath = exports.deleteFilesystemByPath = exports.postFilesystemMultipartInitiateByPath = exports.getFilesystemMultipartByUploadIdParts = exports.putFilesystemMultipartByUploadIdPart = exports.postFilesystemMultipartByUploadIdComplete = exports.deleteFilesystemMultipartByUploadIdAbort = exports.getFilesystemMultipart = exports.getCodegenRerankingByPath = exports.putCodegenFastapplyByPath = exports.put = exports.post = exports.patch = exports.options = exports.get = exports.delete_ = void 0;
4
+ exports.getWatchFilesystemByPath = exports.getProcessByIdentifierLogsStream = exports.getProcessByIdentifierLogs = exports.deleteProcessByIdentifierKill = exports.getProcessByIdentifier = exports.deleteProcessByIdentifier = exports.postProcess = exports.getProcess = exports.getNetworkProcessByPidPorts = exports.postNetworkProcessByPidMonitor = exports.deleteNetworkProcessByPidMonitor = exports.putFilesystemTreeByPath = exports.getFilesystemTreeByPath = exports.deleteFilesystemTreeByPath = exports.putFilesystemByPath = exports.getFilesystemByPath = exports.deleteFilesystemByPath = exports.getFilesystemSearchByPath = exports.postFilesystemMultipartInitiateByPath = exports.getFilesystemMultipartByUploadIdParts = exports.putFilesystemMultipartByUploadIdPart = exports.postFilesystemMultipartByUploadIdComplete = exports.deleteFilesystemMultipartByUploadIdAbort = exports.getFilesystemMultipart = exports.getFilesystemFindByPath = exports.getFilesystemContentSearchByPath = exports.getCodegenRerankingByPath = exports.putCodegenFastapplyByPath = exports.put = exports.post = exports.patch = exports.options = exports.get = exports.delete_ = void 0;
5
5
  const client_fetch_1 = require("@hey-api/client-fetch");
6
6
  const client_gen_1 = require("./client.gen");
7
7
  /**
@@ -175,6 +175,40 @@ const getCodegenRerankingByPath = (options) => {
175
175
  });
176
176
  };
177
177
  exports.getCodegenRerankingByPath = getCodegenRerankingByPath;
178
+ /**
179
+ * Search for text content in files
180
+ * Searches for text content inside files using ripgrep. Returns matching lines with context.
181
+ */
182
+ const getFilesystemContentSearchByPath = (options) => {
183
+ return (options.client ?? client_gen_1.client).get({
184
+ security: [
185
+ {
186
+ scheme: 'bearer',
187
+ type: 'http'
188
+ }
189
+ ],
190
+ url: '/filesystem-content-search/{path}',
191
+ ...options
192
+ });
193
+ };
194
+ exports.getFilesystemContentSearchByPath = getFilesystemContentSearchByPath;
195
+ /**
196
+ * Find files and directories
197
+ * Finds files and directories using the find command.
198
+ */
199
+ const getFilesystemFindByPath = (options) => {
200
+ return (options.client ?? client_gen_1.client).get({
201
+ security: [
202
+ {
203
+ scheme: 'bearer',
204
+ type: 'http'
205
+ }
206
+ ],
207
+ url: '/filesystem-find/{path}',
208
+ ...options
209
+ });
210
+ };
211
+ exports.getFilesystemFindByPath = getFilesystemFindByPath;
178
212
  /**
179
213
  * List multipart uploads
180
214
  * List all active multipart uploads
@@ -290,6 +324,23 @@ const postFilesystemMultipartInitiateByPath = (options) => {
290
324
  });
291
325
  };
292
326
  exports.postFilesystemMultipartInitiateByPath = postFilesystemMultipartInitiateByPath;
327
+ /**
328
+ * Fuzzy search for files and directories
329
+ * Performs fuzzy search on filesystem paths using fuzzy matching algorithm. Optimized alternative to find and grep commands.
330
+ */
331
+ const getFilesystemSearchByPath = (options) => {
332
+ return (options.client ?? client_gen_1.client).get({
333
+ security: [
334
+ {
335
+ scheme: 'bearer',
336
+ type: 'http'
337
+ }
338
+ ],
339
+ url: '/filesystem-search/{path}',
340
+ ...options
341
+ });
342
+ };
343
+ exports.getFilesystemSearchByPath = getFilesystemSearchByPath;
293
344
  /**
294
345
  * Delete file or directory
295
346
  * Delete a file or directory
@@ -345,6 +396,61 @@ const putFilesystemByPath = (options) => {
345
396
  });
346
397
  };
347
398
  exports.putFilesystemByPath = putFilesystemByPath;
399
+ /**
400
+ * Delete directory tree
401
+ * Delete a directory tree recursively
402
+ */
403
+ const deleteFilesystemTreeByPath = (options) => {
404
+ return (options.client ?? client_gen_1.client).delete({
405
+ security: [
406
+ {
407
+ scheme: 'bearer',
408
+ type: 'http'
409
+ }
410
+ ],
411
+ url: '/filesystem/tree/{path}',
412
+ ...options
413
+ });
414
+ };
415
+ exports.deleteFilesystemTreeByPath = deleteFilesystemTreeByPath;
416
+ /**
417
+ * Get directory tree
418
+ * Get a recursive directory tree structure starting from the specified path
419
+ */
420
+ const getFilesystemTreeByPath = (options) => {
421
+ return (options.client ?? client_gen_1.client).get({
422
+ security: [
423
+ {
424
+ scheme: 'bearer',
425
+ type: 'http'
426
+ }
427
+ ],
428
+ url: '/filesystem/tree/{path}',
429
+ ...options
430
+ });
431
+ };
432
+ exports.getFilesystemTreeByPath = getFilesystemTreeByPath;
433
+ /**
434
+ * Create or update directory tree
435
+ * Create or update multiple files within a directory tree structure
436
+ */
437
+ const putFilesystemTreeByPath = (options) => {
438
+ return (options.client ?? client_gen_1.client).put({
439
+ security: [
440
+ {
441
+ scheme: 'bearer',
442
+ type: 'http'
443
+ }
444
+ ],
445
+ url: '/filesystem/tree/{path}',
446
+ ...options,
447
+ headers: {
448
+ 'Content-Type': 'application/json',
449
+ ...options?.headers
450
+ }
451
+ });
452
+ };
453
+ exports.putFilesystemTreeByPath = putFilesystemTreeByPath;
348
454
  /**
349
455
  * Stop monitoring ports for a process
350
456
  * Stop monitoring for new ports opened by a process
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SandboxFileSystem = void 0;
4
- const settings_js_1 = require("../../common/settings.js");
5
4
  const node_js_1 = require("../../common/node.js");
5
+ const settings_js_1 = require("../../common/settings.js");
6
6
  const action_js_1 = require("../action.js");
7
7
  const index_js_1 = require("../client/index.js");
8
8
  // Multipart upload constants
@@ -199,6 +199,86 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
199
199
  }
200
200
  return data;
201
201
  }
202
+ async search(query, path = "/", options) {
203
+ const formattedPath = this.formatPath(path);
204
+ const queryParams = {};
205
+ if (options?.maxResults !== undefined) {
206
+ queryParams.maxResults = options.maxResults;
207
+ }
208
+ if (options?.patterns && options.patterns.length > 0) {
209
+ queryParams.patterns = options.patterns.join(',');
210
+ }
211
+ if (options?.excludeDirs && options.excludeDirs.length > 0) {
212
+ queryParams.excludeDirs = options.excludeDirs.join(',');
213
+ }
214
+ if (options?.excludeHidden !== undefined) {
215
+ queryParams.excludeHidden = options.excludeHidden;
216
+ }
217
+ const result = await (0, index_js_1.getFilesystemSearchByPath)({
218
+ path: { path: formattedPath },
219
+ query: queryParams,
220
+ baseUrl: this.url,
221
+ client: this.client,
222
+ });
223
+ this.handleResponseError(result.response, result.data, result.error);
224
+ return result.data;
225
+ }
226
+ async find(path, options) {
227
+ const formattedPath = this.formatPath(path);
228
+ const queryParams = {};
229
+ if (options?.type) {
230
+ queryParams.type = options.type;
231
+ }
232
+ if (options?.patterns && options.patterns.length > 0) {
233
+ queryParams.patterns = options.patterns.join(',');
234
+ }
235
+ if (options?.maxResults !== undefined) {
236
+ queryParams.maxResults = options.maxResults;
237
+ }
238
+ if (options?.excludeDirs && options.excludeDirs.length > 0) {
239
+ queryParams.excludeDirs = options.excludeDirs.join(',');
240
+ }
241
+ if (options?.excludeHidden !== undefined) {
242
+ queryParams.excludeHidden = options.excludeHidden;
243
+ }
244
+ const result = await (0, index_js_1.getFilesystemFindByPath)({
245
+ path: { path: formattedPath },
246
+ query: queryParams,
247
+ baseUrl: this.url,
248
+ client: this.client,
249
+ });
250
+ this.handleResponseError(result.response, result.data, result.error);
251
+ return result.data;
252
+ }
253
+ async grep(query, path = "/", options) {
254
+ const formattedPath = this.formatPath(path);
255
+ const queryParams = {
256
+ query,
257
+ };
258
+ if (options?.caseSensitive !== undefined) {
259
+ queryParams.caseSensitive = options.caseSensitive;
260
+ }
261
+ if (options?.contextLines !== undefined) {
262
+ queryParams.contextLines = options.contextLines;
263
+ }
264
+ if (options?.maxResults !== undefined) {
265
+ queryParams.maxResults = options.maxResults;
266
+ }
267
+ if (options?.filePattern) {
268
+ queryParams.filePattern = options.filePattern;
269
+ }
270
+ if (options?.excludeDirs && options.excludeDirs.length > 0) {
271
+ queryParams.excludeDirs = options.excludeDirs.join(',');
272
+ }
273
+ const result = await (0, index_js_1.getFilesystemContentSearchByPath)({
274
+ path: { path: formattedPath },
275
+ query: queryParams,
276
+ baseUrl: this.url,
277
+ client: this.client,
278
+ });
279
+ this.handleResponseError(result.response, result.data, result.error);
280
+ return result.data;
281
+ }
202
282
  async cp(source, destination, { maxWait = 180000 } = {}) {
203
283
  let process = await this.process.exec({
204
284
  command: `cp -r ${source} ${destination}`,
@@ -8,8 +8,16 @@ class SandboxProcess extends action_js_1.SandboxAction {
8
8
  constructor(sandbox) {
9
9
  super(sandbox);
10
10
  }
11
- streamLogs(identifier, options) {
11
+ streamLogs(identifier, options = {}) {
12
12
  const controller = new AbortController();
13
+ const handleError = (err) => {
14
+ if (options.onError) {
15
+ options.onError(err);
16
+ }
17
+ else {
18
+ console.error("Stream error:", err);
19
+ }
20
+ };
13
21
  void (async () => {
14
22
  try {
15
23
  const headers = this.sandbox.forceUrl ? this.sandbox.headers : settings_js_1.settings.headers;
@@ -19,10 +27,13 @@ class SandboxProcess extends action_js_1.SandboxAction {
19
27
  headers,
20
28
  });
21
29
  if (stream.status !== 200) {
22
- throw new Error(`Failed to stream logs: ${await stream.text()}`);
30
+ handleError(new Error(`Failed to stream logs: ${await stream.text()}`));
31
+ return;
32
+ }
33
+ if (!stream.body) {
34
+ handleError(new Error('No stream body'));
35
+ return;
23
36
  }
24
- if (!stream.body)
25
- throw new Error('No stream body');
26
37
  const reader = stream.body.getReader();
27
38
  const decoder = new TextDecoder();
28
39
  let buffer = '';
@@ -54,10 +65,10 @@ class SandboxProcess extends action_js_1.SandboxAction {
54
65
  }
55
66
  }
56
67
  catch (err) {
57
- if (err && typeof err === 'object' && 'name' in err && err.name !== 'AbortError') {
58
- console.error("Stream error:", err);
59
- throw new Error(err instanceof Error ? err.message : 'Unknown stream error');
68
+ if (err && typeof err === 'object' && 'name' in err && err.name === 'AbortError') {
69
+ return;
60
70
  }
71
+ handleError(err instanceof Error ? err : new Error('Unknown stream error'));
61
72
  }
62
73
  })();
63
74
  return {
@@ -1,5 +1,5 @@
1
1
  import { type Options as ClientOptions, type TDataShape, type Client } from '@hey-api/client-fetch';
2
- import type { DeleteData, GetData, OptionsData, PatchData, PostData, PutData, PutCodegenFastapplyByPathData, GetCodegenRerankingByPathData, GetFilesystemMultipartData, DeleteFilesystemMultipartByUploadIdAbortData, PostFilesystemMultipartByUploadIdCompleteData, PutFilesystemMultipartByUploadIdPartData, GetFilesystemMultipartByUploadIdPartsData, PostFilesystemMultipartInitiateByPathData, DeleteFilesystemByPathData, GetFilesystemByPathData, PutFilesystemByPathData, DeleteNetworkProcessByPidMonitorData, PostNetworkProcessByPidMonitorData, GetNetworkProcessByPidPortsData, GetProcessData, PostProcessData, DeleteProcessByIdentifierData, GetProcessByIdentifierData, DeleteProcessByIdentifierKillData, GetProcessByIdentifierLogsData, GetProcessByIdentifierLogsStreamData, GetWatchFilesystemByPathData } from './types.gen';
2
+ import type { DeleteData, GetData, OptionsData, PatchData, PostData, PutData, PutCodegenFastapplyByPathData, GetCodegenRerankingByPathData, GetFilesystemContentSearchByPathData, GetFilesystemFindByPathData, GetFilesystemMultipartData, DeleteFilesystemMultipartByUploadIdAbortData, PostFilesystemMultipartByUploadIdCompleteData, PutFilesystemMultipartByUploadIdPartData, GetFilesystemMultipartByUploadIdPartsData, PostFilesystemMultipartInitiateByPathData, GetFilesystemSearchByPathData, DeleteFilesystemByPathData, GetFilesystemByPathData, PutFilesystemByPathData, DeleteFilesystemTreeByPathData, GetFilesystemTreeByPathData, PutFilesystemTreeByPathData, DeleteNetworkProcessByPidMonitorData, PostNetworkProcessByPidMonitorData, GetNetworkProcessByPidPortsData, GetProcessData, PostProcessData, DeleteProcessByIdentifierData, GetProcessByIdentifierData, DeleteProcessByIdentifierKillData, GetProcessByIdentifierLogsData, GetProcessByIdentifierLogsStreamData, GetWatchFilesystemByPathData } from './types.gen';
3
3
  export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
4
4
  /**
5
5
  * You can provide a client instance returned by `createClient()` instead of
@@ -84,6 +84,16 @@ export declare const putCodegenFastapplyByPath: <ThrowOnError extends boolean =
84
84
  * The response will be a list of file paths and contents ordered from most relevant to least relevant.
85
85
  */
86
86
  export declare const getCodegenRerankingByPath: <ThrowOnError extends boolean = false>(options: Options<GetCodegenRerankingByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").RerankingResponse, import("./types.gen").ErrorResponse, ThrowOnError>;
87
+ /**
88
+ * Search for text content in files
89
+ * Searches for text content inside files using ripgrep. Returns matching lines with context.
90
+ */
91
+ export declare const getFilesystemContentSearchByPath: <ThrowOnError extends boolean = false>(options: Options<GetFilesystemContentSearchByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").ContentSearchResponse, import("./types.gen").ErrorResponse, ThrowOnError>;
92
+ /**
93
+ * Find files and directories
94
+ * Finds files and directories using the find command.
95
+ */
96
+ export declare const getFilesystemFindByPath: <ThrowOnError extends boolean = false>(options: Options<GetFilesystemFindByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").FindResponse, import("./types.gen").ErrorResponse, ThrowOnError>;
87
97
  /**
88
98
  * List multipart uploads
89
99
  * List all active multipart uploads
@@ -114,6 +124,11 @@ export declare const getFilesystemMultipartByUploadIdParts: <ThrowOnError extend
114
124
  * Initiate a multipart upload session for a file
115
125
  */
116
126
  export declare const postFilesystemMultipartInitiateByPath: <ThrowOnError extends boolean = false>(options: Options<PostFilesystemMultipartInitiateByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").MultipartInitiateResponse, import("./types.gen").ErrorResponse, ThrowOnError>;
127
+ /**
128
+ * Fuzzy search for files and directories
129
+ * Performs fuzzy search on filesystem paths using fuzzy matching algorithm. Optimized alternative to find and grep commands.
130
+ */
131
+ export declare const getFilesystemSearchByPath: <ThrowOnError extends boolean = false>(options: Options<GetFilesystemSearchByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").FuzzySearchResponse, import("./types.gen").ErrorResponse, ThrowOnError>;
117
132
  /**
118
133
  * Delete file or directory
119
134
  * Delete a file or directory
@@ -129,6 +144,21 @@ export declare const getFilesystemByPath: <ThrowOnError extends boolean = false>
129
144
  * Create or update a file or directory
130
145
  */
131
146
  export declare const putFilesystemByPath: <ThrowOnError extends boolean = false>(options: Options<PutFilesystemByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").SuccessResponse, import("./types.gen").ErrorResponse, ThrowOnError>;
147
+ /**
148
+ * Delete directory tree
149
+ * Delete a directory tree recursively
150
+ */
151
+ export declare const deleteFilesystemTreeByPath: <ThrowOnError extends boolean = false>(options: Options<DeleteFilesystemTreeByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").SuccessResponse, import("./types.gen").ErrorResponse, ThrowOnError>;
152
+ /**
153
+ * Get directory tree
154
+ * Get a recursive directory tree structure starting from the specified path
155
+ */
156
+ export declare const getFilesystemTreeByPath: <ThrowOnError extends boolean = false>(options: Options<GetFilesystemTreeByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").File | import("./types.gen").Directory | import("./types.gen").FileWithContent | Blob, import("./types.gen").ErrorResponse, ThrowOnError>;
157
+ /**
158
+ * Create or update directory tree
159
+ * Create or update multiple files within a directory tree structure
160
+ */
161
+ export declare const putFilesystemTreeByPath: <ThrowOnError extends boolean = false>(options: Options<PutFilesystemTreeByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").File | import("./types.gen").Directory | import("./types.gen").FileWithContent | Blob, import("./types.gen").ErrorResponse, ThrowOnError>;
132
162
  /**
133
163
  * Stop monitoring ports for a process
134
164
  * Stop monitoring for new ports opened by a process