@blaxel/core 0.2.9-preview.11 → 0.2.9

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.
@@ -1,21 +1,7 @@
1
- import { Sandbox } from "../client/types.gen.js";
2
- import { SandboxAction } from "./action.js";
3
- import { Directory, SuccessResponse } from "./client/index.js";
4
- export type CopyResponse = {
5
- message: string;
6
- source: string;
7
- destination: string;
8
- };
9
- export type WatchEvent = {
10
- op: "CREATE" | "WRITE" | "REMOVE" | "RENAME" | "CHMOD";
11
- path: string;
12
- name: string;
13
- content?: string;
14
- };
15
- export type SandboxFilesystemFile = {
16
- path: string;
17
- content: string;
18
- };
1
+ import { Sandbox } from "../../client/types.gen.js";
2
+ import { SandboxAction } from "../action.js";
3
+ import { Directory, SuccessResponse } from "../client/index.js";
4
+ import { CopyResponse, SandboxFilesystemFile, ToolWithExecute, ToolWithoutExecute, WatchEvent } from "./types.js";
19
5
  export declare class SandboxFileSystem extends SandboxAction {
20
6
  constructor(sandbox: Sandbox);
21
7
  mkdir(path: string, permissions?: string): Promise<SuccessResponse>;
@@ -34,4 +20,6 @@ export declare class SandboxFileSystem extends SandboxAction {
34
20
  close: () => void;
35
21
  };
36
22
  private formatPath;
23
+ get toolsWithoutExecute(): ToolWithoutExecute;
24
+ get tools(): ToolWithExecute;
37
25
  }
@@ -5,10 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SandboxFileSystem = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
- const node_js_1 = require("../common/node.js");
9
- const settings_js_1 = require("../common/settings.js");
10
- const action_js_1 = require("./action.js");
11
- const index_js_1 = require("./client/index.js");
8
+ const zod_1 = __importDefault(require("zod"));
9
+ const node_js_1 = require("../../common/node.js");
10
+ const settings_js_1 = require("../../common/settings.js");
11
+ const action_js_1 = require("../action.js");
12
+ const index_js_1 = require("../client/index.js");
12
13
  class SandboxFileSystem extends action_js_1.SandboxAction {
13
14
  constructor(sandbox) {
14
15
  super(sandbox);
@@ -289,5 +290,187 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
289
290
  }
290
291
  return path;
291
292
  }
293
+ get toolsWithoutExecute() {
294
+ return {
295
+ cp: {
296
+ description: "Copy a file or directory",
297
+ parameters: zod_1.default.object({
298
+ source: zod_1.default.string(),
299
+ destination: zod_1.default.string(),
300
+ }),
301
+ },
302
+ mkdir: {
303
+ description: "Create a directory",
304
+ parameters: zod_1.default.object({
305
+ path: zod_1.default.string(),
306
+ permissions: zod_1.default.string().optional().default("0755"),
307
+ }),
308
+ },
309
+ ls: {
310
+ description: "List a directory",
311
+ parameters: zod_1.default.object({
312
+ path: zod_1.default.string(),
313
+ }),
314
+ },
315
+ rm: {
316
+ description: "Remove a file or directory",
317
+ parameters: zod_1.default.object({
318
+ path: zod_1.default.string(),
319
+ recursive: zod_1.default.boolean().optional().default(false),
320
+ }),
321
+ },
322
+ read: {
323
+ description: "Read a file",
324
+ parameters: zod_1.default.object({
325
+ path: zod_1.default.string(),
326
+ }),
327
+ },
328
+ write: {
329
+ description: "Write a file",
330
+ parameters: zod_1.default.object({
331
+ path: zod_1.default.string(),
332
+ content: zod_1.default.string(),
333
+ }),
334
+ }
335
+ };
336
+ }
337
+ get tools() {
338
+ return {
339
+ cp: {
340
+ description: "Copy a file or directory",
341
+ parameters: zod_1.default.object({
342
+ source: zod_1.default.string(),
343
+ destination: zod_1.default.string(),
344
+ }),
345
+ execute: async (args) => {
346
+ try {
347
+ const result = await this.cp(args.source, args.destination);
348
+ return JSON.stringify(result);
349
+ }
350
+ catch (e) {
351
+ if (e instanceof Error) {
352
+ return JSON.stringify({
353
+ message: e.message,
354
+ source: args.source,
355
+ destination: args.destination
356
+ });
357
+ }
358
+ return "An unknown error occurred";
359
+ }
360
+ }
361
+ },
362
+ mkdir: {
363
+ description: "Create a directory",
364
+ parameters: zod_1.default.object({
365
+ path: zod_1.default.string(),
366
+ permissions: zod_1.default.string().optional().default("0755"),
367
+ }),
368
+ execute: async (args) => {
369
+ try {
370
+ const result = await this.mkdir(args.path, args.permissions);
371
+ return JSON.stringify(result);
372
+ }
373
+ catch (e) {
374
+ if (e instanceof Error) {
375
+ return JSON.stringify({
376
+ message: e.message,
377
+ path: args.path,
378
+ permissions: args.permissions
379
+ });
380
+ }
381
+ return "An unknown error occurred";
382
+ }
383
+ }
384
+ },
385
+ ls: {
386
+ description: "List a directory",
387
+ parameters: zod_1.default.object({
388
+ path: zod_1.default.string(),
389
+ }),
390
+ execute: async (args) => {
391
+ try {
392
+ const result = await this.ls(args.path);
393
+ return JSON.stringify(result);
394
+ }
395
+ catch (e) {
396
+ if (e instanceof Error) {
397
+ return JSON.stringify({
398
+ message: e.message,
399
+ path: args.path
400
+ });
401
+ }
402
+ return "An unknown error occurred";
403
+ }
404
+ }
405
+ },
406
+ rm: {
407
+ description: "Remove a file or directory",
408
+ parameters: zod_1.default.object({
409
+ path: zod_1.default.string(),
410
+ recursive: zod_1.default.boolean().optional().default(false),
411
+ }),
412
+ execute: async (args) => {
413
+ try {
414
+ const result = await this.rm(args.path, args.recursive);
415
+ return JSON.stringify(result);
416
+ }
417
+ catch (e) {
418
+ if (e instanceof Error) {
419
+ return JSON.stringify({
420
+ message: e.message,
421
+ path: args.path,
422
+ recursive: args.recursive
423
+ });
424
+ }
425
+ return "An unknown error occurred";
426
+ }
427
+ }
428
+ },
429
+ read: {
430
+ description: "Read a file",
431
+ parameters: zod_1.default.object({
432
+ path: zod_1.default.string(),
433
+ }),
434
+ execute: async (args) => {
435
+ try {
436
+ const result = await this.read(args.path);
437
+ return JSON.stringify(result);
438
+ }
439
+ catch (e) {
440
+ if (e instanceof Error) {
441
+ return JSON.stringify({
442
+ message: e.message,
443
+ path: args.path
444
+ });
445
+ }
446
+ return "An unknown error occurred";
447
+ }
448
+ }
449
+ },
450
+ write: {
451
+ description: "Write a file",
452
+ parameters: zod_1.default.object({
453
+ path: zod_1.default.string(),
454
+ content: zod_1.default.string(),
455
+ }),
456
+ execute: async (args) => {
457
+ try {
458
+ const result = await this.write(args.path, args.content);
459
+ return JSON.stringify(result);
460
+ }
461
+ catch (e) {
462
+ if (e instanceof Error) {
463
+ return JSON.stringify({
464
+ message: e.message,
465
+ path: args.path,
466
+ content: args.content
467
+ });
468
+ }
469
+ return "An unknown error occurred";
470
+ }
471
+ }
472
+ }
473
+ };
474
+ }
292
475
  }
293
476
  exports.SandboxFileSystem = SandboxFileSystem;
@@ -0,0 +1,2 @@
1
+ export * from "./filesystem.js";
2
+ export * from "./types.js";
@@ -0,0 +1,18 @@
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("./filesystem.js"), exports);
18
+ __exportStar(require("./types.js"), exports);
@@ -0,0 +1,120 @@
1
+ import { z } from "zod";
2
+ export type CopyResponse = {
3
+ message: string;
4
+ source: string;
5
+ destination: string;
6
+ };
7
+ export type WatchEvent = {
8
+ op: "CREATE" | "WRITE" | "REMOVE" | "RENAME" | "CHMOD";
9
+ path: string;
10
+ name: string;
11
+ content?: string;
12
+ };
13
+ export type SandboxFilesystemFile = {
14
+ path: string;
15
+ content: string;
16
+ };
17
+ export type ToolWithoutExecute = {
18
+ cp: {
19
+ description: string;
20
+ parameters: z.ZodObject<{
21
+ source: z.ZodString;
22
+ destination: z.ZodString;
23
+ }>;
24
+ };
25
+ mkdir: {
26
+ description: string;
27
+ parameters: z.ZodObject<{
28
+ path: z.ZodString;
29
+ permissions: z.ZodDefault<z.ZodOptional<z.ZodString>>;
30
+ }>;
31
+ };
32
+ ls: {
33
+ description: string;
34
+ parameters: z.ZodObject<{
35
+ path: z.ZodString;
36
+ }>;
37
+ };
38
+ rm: {
39
+ description: string;
40
+ parameters: z.ZodObject<{
41
+ path: z.ZodString;
42
+ }>;
43
+ };
44
+ read: {
45
+ description: string;
46
+ parameters: z.ZodObject<{
47
+ path: z.ZodString;
48
+ }>;
49
+ };
50
+ write: {
51
+ description: string;
52
+ parameters: z.ZodObject<{
53
+ path: z.ZodString;
54
+ }>;
55
+ };
56
+ };
57
+ export type ToolWithExecute = {
58
+ cp: {
59
+ description: string;
60
+ parameters: z.ZodObject<{
61
+ source: z.ZodString;
62
+ destination: z.ZodString;
63
+ }>;
64
+ execute: (args: {
65
+ source: string;
66
+ destination: string;
67
+ }) => Promise<string>;
68
+ };
69
+ mkdir: {
70
+ description: string;
71
+ parameters: z.ZodObject<{
72
+ path: z.ZodString;
73
+ permissions: z.ZodDefault<z.ZodOptional<z.ZodString>>;
74
+ }>;
75
+ execute: (args: {
76
+ path: string;
77
+ permissions: string;
78
+ }) => Promise<string>;
79
+ };
80
+ ls: {
81
+ description: string;
82
+ parameters: z.ZodObject<{
83
+ path: z.ZodString;
84
+ }>;
85
+ execute: (args: {
86
+ path: string;
87
+ }) => Promise<string>;
88
+ };
89
+ rm: {
90
+ description: string;
91
+ parameters: z.ZodObject<{
92
+ path: z.ZodString;
93
+ recursive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
94
+ }>;
95
+ execute: (args: {
96
+ path: string;
97
+ recursive: boolean;
98
+ }) => Promise<string>;
99
+ };
100
+ read: {
101
+ description: string;
102
+ parameters: z.ZodObject<{
103
+ path: z.ZodString;
104
+ }>;
105
+ execute: (args: {
106
+ path: string;
107
+ }) => Promise<string>;
108
+ };
109
+ write: {
110
+ description: string;
111
+ parameters: z.ZodObject<{
112
+ path: z.ZodString;
113
+ content: z.ZodString;
114
+ }>;
115
+ execute: (args: {
116
+ path: string;
117
+ content: string;
118
+ }) => Promise<string>;
119
+ };
120
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,3 @@
1
1
  export { deleteFilesystemByPath, deleteNetworkProcessByPidMonitor, deleteProcessByIdentifier, deleteProcessByIdentifierKill, Directory, ErrorResponse, File, FileRequest, FileWithContent, getFilesystemByPath, getNetworkProcessByPidPorts, getProcess, getProcessByIdentifier, getProcessByIdentifierLogs, getProcessByIdentifierLogsStream, PortMonitorRequest, postNetworkProcessByPidMonitor, postProcess, ProcessKillRequest, ProcessRequest, ProcessResponse, putFilesystemByPath, SuccessResponse } from "./client/index.js";
2
+ export * from "./filesystem/index.js";
2
3
  export * from "./sandbox.js";
@@ -30,5 +30,6 @@ Object.defineProperty(exports, "getProcessByIdentifierLogsStream", { enumerable:
30
30
  Object.defineProperty(exports, "postNetworkProcessByPidMonitor", { enumerable: true, get: function () { return index_js_1.postNetworkProcessByPidMonitor; } });
31
31
  Object.defineProperty(exports, "postProcess", { enumerable: true, get: function () { return index_js_1.postProcess; } });
32
32
  Object.defineProperty(exports, "putFilesystemByPath", { enumerable: true, get: function () { return index_js_1.putFilesystemByPath; } });
33
+ __exportStar(require("./filesystem/index.js"), exports);
33
34
  __exportStar(require("./sandbox.js"), exports);
34
35
  // Re-export everything from client except ClientOptions to avoid conflict
@@ -1,5 +1,5 @@
1
1
  import { Sandbox as SandboxModel } from "../client/index.js";
2
- import { SandboxFileSystem } from "./filesystem.js";
2
+ import { SandboxFileSystem } from "./filesystem/index.js";
3
3
  import { SandboxNetwork } from "./network.js";
4
4
  import { SandboxPreviews } from "./preview.js";
5
5
  import { SandboxProcess } from "./process.js";
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SandboxInstance = void 0;
4
4
  const index_js_1 = require("../client/index.js");
5
5
  const logger_js_1 = require("../common/logger.js");
6
- const filesystem_js_1 = require("./filesystem.js");
6
+ const index_js_2 = require("./filesystem/index.js");
7
7
  const network_js_1 = require("./network.js");
8
8
  const preview_js_1 = require("./preview.js");
9
9
  const process_js_1 = require("./process.js");
@@ -17,7 +17,7 @@ class SandboxInstance {
17
17
  sessions;
18
18
  constructor(sandbox) {
19
19
  this.sandbox = sandbox;
20
- this.fs = new filesystem_js_1.SandboxFileSystem(sandbox);
20
+ this.fs = new index_js_2.SandboxFileSystem(sandbox);
21
21
  this.network = new network_js_1.SandboxNetwork(sandbox);
22
22
  this.process = new process_js_1.SandboxProcess(sandbox);
23
23
  this.previews = new preview_js_1.SandboxPreviews(sandbox);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaxel/core",
3
- "version": "0.2.9-preview.11",
3
+ "version": "0.2.9",
4
4
  "description": "Blaxel Core SDK for TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Blaxel, INC (https://blaxel.ai)",