@blaxel/core 0.2.10 → 0.2.11-dev.88
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/authentication/index.js +0 -1
- package/dist/cache/index.js +0 -1
- package/dist/common/internal.js +1 -0
- package/dist/jobs/jobs.js +1 -1
- package/dist/sandbox/filesystem/filesystem.d.ts +1 -3
- package/dist/sandbox/filesystem/filesystem.js +0 -151
- package/dist/sandbox/filesystem/types.d.ts +0 -113
- package/dist/sandbox/filesystem/types.js +0 -24
- package/dist/sandbox/process/index.d.ts +0 -1
- package/dist/sandbox/process/index.js +0 -1
- package/dist/sandbox/process/process.d.ts +0 -3
- package/dist/sandbox/process/process.js +0 -128
- package/dist/tools/mcpTool.d.ts +2 -0
- package/dist/tools/mcpTool.js +15 -5
- package/package.json +1 -1
- package/dist/sandbox/process/types.d.ts +0 -120
- package/dist/sandbox/process/types.js +0 -26
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.authentication = authentication;
|
|
7
|
-
/* eslint-disable */
|
|
8
7
|
const path_1 = require("path");
|
|
9
8
|
const yaml_1 = __importDefault(require("yaml"));
|
|
10
9
|
const env_js_1 = require("../common/env.js");
|
package/dist/cache/index.js
CHANGED
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.findFromCache = findFromCache;
|
|
7
|
-
/* eslint-disable */
|
|
8
7
|
const yaml_1 = __importDefault(require("yaml"));
|
|
9
8
|
const node_js_1 = require("../common/node.js");
|
|
10
9
|
const cache = new Map();
|
package/dist/common/internal.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAlphanumericLimitedHash = getAlphanumericLimitedHash;
|
|
4
4
|
exports.getGlobalUniqueHash = getGlobalUniqueHash;
|
|
5
|
+
/* eslint-disable */
|
|
5
6
|
// Pure JS MD5 implementation (public domain, compact)
|
|
6
7
|
function md5(input) {
|
|
7
8
|
function cmn(q, a, b, x, s, t) {
|
package/dist/jobs/jobs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Sandbox } from "../../client/types.gen.js";
|
|
2
2
|
import { SandboxAction } from "../action.js";
|
|
3
3
|
import { Directory, SuccessResponse } from "../client/index.js";
|
|
4
|
-
import { CopyResponse, SandboxFilesystemFile,
|
|
4
|
+
import { CopyResponse, SandboxFilesystemFile, WatchEvent } from "./types.js";
|
|
5
5
|
export declare class SandboxFileSystem extends SandboxAction {
|
|
6
6
|
constructor(sandbox: Sandbox);
|
|
7
7
|
mkdir(path: string, permissions?: string): Promise<SuccessResponse>;
|
|
@@ -20,6 +20,4 @@ export declare class SandboxFileSystem extends SandboxAction {
|
|
|
20
20
|
close: () => void;
|
|
21
21
|
};
|
|
22
22
|
private formatPath;
|
|
23
|
-
get toolsWithoutExecute(): ToolWithoutExecute;
|
|
24
|
-
get tools(): ToolWithExecute;
|
|
25
23
|
}
|
|
@@ -9,7 +9,6 @@ const node_js_1 = require("../../common/node.js");
|
|
|
9
9
|
const settings_js_1 = require("../../common/settings.js");
|
|
10
10
|
const action_js_1 = require("../action.js");
|
|
11
11
|
const index_js_1 = require("../client/index.js");
|
|
12
|
-
const types_js_1 = require("./types.js");
|
|
13
12
|
class SandboxFileSystem extends action_js_1.SandboxAction {
|
|
14
13
|
constructor(sandbox) {
|
|
15
14
|
super(sandbox);
|
|
@@ -290,155 +289,5 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
|
|
|
290
289
|
}
|
|
291
290
|
return path;
|
|
292
291
|
}
|
|
293
|
-
get toolsWithoutExecute() {
|
|
294
|
-
return {
|
|
295
|
-
cp: {
|
|
296
|
-
description: "Copy a file or directory",
|
|
297
|
-
parameters: types_js_1.CpParamsSchema,
|
|
298
|
-
},
|
|
299
|
-
mkdir: {
|
|
300
|
-
description: "Create a directory",
|
|
301
|
-
parameters: types_js_1.MkdirParamsSchema,
|
|
302
|
-
},
|
|
303
|
-
ls: {
|
|
304
|
-
description: "List a directory",
|
|
305
|
-
parameters: types_js_1.LsParamsSchema,
|
|
306
|
-
},
|
|
307
|
-
rm: {
|
|
308
|
-
description: "Remove a file or directory",
|
|
309
|
-
parameters: types_js_1.RmParamsSchema,
|
|
310
|
-
},
|
|
311
|
-
read: {
|
|
312
|
-
description: "Read a file",
|
|
313
|
-
parameters: types_js_1.ReadParamsSchema,
|
|
314
|
-
},
|
|
315
|
-
write: {
|
|
316
|
-
description: "Write a file",
|
|
317
|
-
parameters: types_js_1.WriteParamsSchema,
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
get tools() {
|
|
322
|
-
return {
|
|
323
|
-
cp: {
|
|
324
|
-
description: "Copy a file or directory",
|
|
325
|
-
parameters: types_js_1.CpParamsSchema,
|
|
326
|
-
execute: async (args) => {
|
|
327
|
-
try {
|
|
328
|
-
const result = await this.cp(args.source, args.destination);
|
|
329
|
-
return JSON.stringify(result);
|
|
330
|
-
}
|
|
331
|
-
catch (e) {
|
|
332
|
-
if (e instanceof Error) {
|
|
333
|
-
return JSON.stringify({
|
|
334
|
-
message: e.message,
|
|
335
|
-
source: args.source,
|
|
336
|
-
destination: args.destination
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
return "An unknown error occurred";
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
},
|
|
343
|
-
mkdir: {
|
|
344
|
-
description: "Create a directory",
|
|
345
|
-
parameters: types_js_1.MkdirParamsSchema,
|
|
346
|
-
execute: async (args) => {
|
|
347
|
-
try {
|
|
348
|
-
const result = await this.mkdir(args.path, args.permissions);
|
|
349
|
-
return JSON.stringify(result);
|
|
350
|
-
}
|
|
351
|
-
catch (e) {
|
|
352
|
-
if (e instanceof Error) {
|
|
353
|
-
return JSON.stringify({
|
|
354
|
-
message: e.message,
|
|
355
|
-
path: args.path,
|
|
356
|
-
permissions: args.permissions
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
return "An unknown error occurred";
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
-
ls: {
|
|
364
|
-
description: "List a directory",
|
|
365
|
-
parameters: types_js_1.LsParamsSchema,
|
|
366
|
-
execute: async (args) => {
|
|
367
|
-
try {
|
|
368
|
-
const result = await this.ls(args.path);
|
|
369
|
-
return JSON.stringify(result);
|
|
370
|
-
}
|
|
371
|
-
catch (e) {
|
|
372
|
-
if (e instanceof Error) {
|
|
373
|
-
return JSON.stringify({
|
|
374
|
-
message: e.message,
|
|
375
|
-
path: args.path
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
return "An unknown error occurred";
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
},
|
|
382
|
-
rm: {
|
|
383
|
-
description: "Remove a file or directory",
|
|
384
|
-
parameters: types_js_1.RmParamsSchema,
|
|
385
|
-
execute: async (args) => {
|
|
386
|
-
try {
|
|
387
|
-
const result = await this.rm(args.path, args.recursive);
|
|
388
|
-
return JSON.stringify(result);
|
|
389
|
-
}
|
|
390
|
-
catch (e) {
|
|
391
|
-
if (e instanceof Error) {
|
|
392
|
-
return JSON.stringify({
|
|
393
|
-
message: e.message,
|
|
394
|
-
path: args.path,
|
|
395
|
-
recursive: args.recursive
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
return "An unknown error occurred";
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
},
|
|
402
|
-
read: {
|
|
403
|
-
description: "Read a file",
|
|
404
|
-
parameters: types_js_1.ReadParamsSchema,
|
|
405
|
-
execute: async (args) => {
|
|
406
|
-
try {
|
|
407
|
-
const result = await this.read(args.path);
|
|
408
|
-
return JSON.stringify(result);
|
|
409
|
-
}
|
|
410
|
-
catch (e) {
|
|
411
|
-
if (e instanceof Error) {
|
|
412
|
-
return JSON.stringify({
|
|
413
|
-
message: e.message,
|
|
414
|
-
path: args.path
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
return "An unknown error occurred";
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
},
|
|
421
|
-
write: {
|
|
422
|
-
description: "Write a file",
|
|
423
|
-
parameters: types_js_1.WriteParamsSchema,
|
|
424
|
-
execute: async (args) => {
|
|
425
|
-
try {
|
|
426
|
-
const result = await this.write(args.path, args.content);
|
|
427
|
-
return JSON.stringify(result);
|
|
428
|
-
}
|
|
429
|
-
catch (e) {
|
|
430
|
-
if (e instanceof Error) {
|
|
431
|
-
return JSON.stringify({
|
|
432
|
-
message: e.message,
|
|
433
|
-
path: args.path,
|
|
434
|
-
content: args.content
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
return "An unknown error occurred";
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
292
|
}
|
|
444
293
|
exports.SandboxFileSystem = SandboxFileSystem;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
1
|
export type CopyResponse = {
|
|
3
2
|
message: string;
|
|
4
3
|
source: string;
|
|
@@ -14,115 +13,3 @@ export type SandboxFilesystemFile = {
|
|
|
14
13
|
path: string;
|
|
15
14
|
content: string;
|
|
16
15
|
};
|
|
17
|
-
export declare const CpParamsSchema: z.ZodObject<{
|
|
18
|
-
source: z.ZodString;
|
|
19
|
-
destination: z.ZodString;
|
|
20
|
-
}, "strip", z.ZodTypeAny, {
|
|
21
|
-
source: string;
|
|
22
|
-
destination: string;
|
|
23
|
-
}, {
|
|
24
|
-
source: string;
|
|
25
|
-
destination: string;
|
|
26
|
-
}>;
|
|
27
|
-
export declare const MkdirParamsSchema: z.ZodObject<{
|
|
28
|
-
path: z.ZodString;
|
|
29
|
-
permissions: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
30
|
-
}, "strip", z.ZodTypeAny, {
|
|
31
|
-
path: string;
|
|
32
|
-
permissions: string;
|
|
33
|
-
}, {
|
|
34
|
-
path: string;
|
|
35
|
-
permissions?: string | undefined;
|
|
36
|
-
}>;
|
|
37
|
-
export declare const LsParamsSchema: z.ZodObject<{
|
|
38
|
-
path: z.ZodString;
|
|
39
|
-
}, "strip", z.ZodTypeAny, {
|
|
40
|
-
path: string;
|
|
41
|
-
}, {
|
|
42
|
-
path: string;
|
|
43
|
-
}>;
|
|
44
|
-
export declare const RmParamsSchema: z.ZodObject<{
|
|
45
|
-
path: z.ZodString;
|
|
46
|
-
recursive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
47
|
-
}, "strip", z.ZodTypeAny, {
|
|
48
|
-
path: string;
|
|
49
|
-
recursive: boolean;
|
|
50
|
-
}, {
|
|
51
|
-
path: string;
|
|
52
|
-
recursive?: boolean | undefined;
|
|
53
|
-
}>;
|
|
54
|
-
export declare const ReadParamsSchema: z.ZodObject<{
|
|
55
|
-
path: z.ZodString;
|
|
56
|
-
}, "strip", z.ZodTypeAny, {
|
|
57
|
-
path: string;
|
|
58
|
-
}, {
|
|
59
|
-
path: string;
|
|
60
|
-
}>;
|
|
61
|
-
export declare const WriteParamsSchema: z.ZodObject<{
|
|
62
|
-
path: z.ZodString;
|
|
63
|
-
content: z.ZodString;
|
|
64
|
-
}, "strip", z.ZodTypeAny, {
|
|
65
|
-
path: string;
|
|
66
|
-
content: string;
|
|
67
|
-
}, {
|
|
68
|
-
path: string;
|
|
69
|
-
content: string;
|
|
70
|
-
}>;
|
|
71
|
-
export type ToolWithoutExecute = {
|
|
72
|
-
cp: {
|
|
73
|
-
description: string;
|
|
74
|
-
parameters: typeof CpParamsSchema;
|
|
75
|
-
};
|
|
76
|
-
mkdir: {
|
|
77
|
-
description: string;
|
|
78
|
-
parameters: typeof MkdirParamsSchema;
|
|
79
|
-
};
|
|
80
|
-
ls: {
|
|
81
|
-
description: string;
|
|
82
|
-
parameters: typeof LsParamsSchema;
|
|
83
|
-
};
|
|
84
|
-
rm: {
|
|
85
|
-
description: string;
|
|
86
|
-
parameters: typeof RmParamsSchema;
|
|
87
|
-
};
|
|
88
|
-
read: {
|
|
89
|
-
description: string;
|
|
90
|
-
parameters: typeof ReadParamsSchema;
|
|
91
|
-
};
|
|
92
|
-
write: {
|
|
93
|
-
description: string;
|
|
94
|
-
parameters: typeof WriteParamsSchema;
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
export type ToolWithExecute = {
|
|
98
|
-
cp: {
|
|
99
|
-
description: string;
|
|
100
|
-
parameters: typeof CpParamsSchema;
|
|
101
|
-
execute: (args: z.infer<typeof CpParamsSchema>) => Promise<string>;
|
|
102
|
-
};
|
|
103
|
-
mkdir: {
|
|
104
|
-
description: string;
|
|
105
|
-
parameters: typeof MkdirParamsSchema;
|
|
106
|
-
execute: (args: z.infer<typeof MkdirParamsSchema>) => Promise<string>;
|
|
107
|
-
};
|
|
108
|
-
ls: {
|
|
109
|
-
description: string;
|
|
110
|
-
parameters: typeof LsParamsSchema;
|
|
111
|
-
execute: (args: z.infer<typeof LsParamsSchema>) => Promise<string>;
|
|
112
|
-
};
|
|
113
|
-
rm: {
|
|
114
|
-
description: string;
|
|
115
|
-
parameters: typeof RmParamsSchema;
|
|
116
|
-
execute: (args: z.infer<typeof RmParamsSchema>) => Promise<string>;
|
|
117
|
-
};
|
|
118
|
-
read: {
|
|
119
|
-
description: string;
|
|
120
|
-
parameters: typeof ReadParamsSchema;
|
|
121
|
-
execute: (args: z.infer<typeof ReadParamsSchema>) => Promise<string>;
|
|
122
|
-
};
|
|
123
|
-
write: {
|
|
124
|
-
description: string;
|
|
125
|
-
parameters: typeof WriteParamsSchema;
|
|
126
|
-
execute: (args: z.infer<typeof WriteParamsSchema>) => Promise<string>;
|
|
127
|
-
};
|
|
128
|
-
};
|
|
@@ -1,26 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WriteParamsSchema = exports.ReadParamsSchema = exports.RmParamsSchema = exports.LsParamsSchema = exports.MkdirParamsSchema = exports.CpParamsSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
exports.CpParamsSchema = zod_1.z.object({
|
|
6
|
-
source: zod_1.z.string().describe("Source file or directory path"),
|
|
7
|
-
destination: zod_1.z.string().describe("Destination file or directory path"),
|
|
8
|
-
}).describe("Parameters for copying a file or directory");
|
|
9
|
-
exports.MkdirParamsSchema = zod_1.z.object({
|
|
10
|
-
path: zod_1.z.string().describe("Directory path to create"),
|
|
11
|
-
permissions: zod_1.z.string().optional().default("0755").describe("Permissions for the new directory (default 0755)"),
|
|
12
|
-
}).describe("Parameters for creating a directory");
|
|
13
|
-
exports.LsParamsSchema = zod_1.z.object({
|
|
14
|
-
path: zod_1.z.string().describe("Directory path to list"),
|
|
15
|
-
}).describe("Parameters for listing a directory");
|
|
16
|
-
exports.RmParamsSchema = zod_1.z.object({
|
|
17
|
-
path: zod_1.z.string().describe("File or directory path to remove"),
|
|
18
|
-
recursive: zod_1.z.boolean().optional().default(false).describe("Whether to remove recursively (default false)"),
|
|
19
|
-
}).describe("Parameters for removing a file or directory");
|
|
20
|
-
exports.ReadParamsSchema = zod_1.z.object({
|
|
21
|
-
path: zod_1.z.string().describe("File path to read"),
|
|
22
|
-
}).describe("Parameters for reading a file");
|
|
23
|
-
exports.WriteParamsSchema = zod_1.z.object({
|
|
24
|
-
path: zod_1.z.string().describe("File path to write to"),
|
|
25
|
-
content: zod_1.z.string().describe("Content to write to the file"),
|
|
26
|
-
}).describe("Parameters for writing to a file");
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Sandbox } from "../../client/types.gen.js";
|
|
2
2
|
import { SandboxAction } from "../action.js";
|
|
3
3
|
import { DeleteProcessByIdentifierKillResponse, DeleteProcessByIdentifierResponse, GetProcessByIdentifierResponse, GetProcessResponse, PostProcessResponse, ProcessRequest } from "../client/index.js";
|
|
4
|
-
import { ProcessToolWithExecute, ProcessToolWithoutExecute } from "./types.js";
|
|
5
4
|
export declare class SandboxProcess extends SandboxAction {
|
|
6
5
|
constructor(sandbox: Sandbox);
|
|
7
6
|
streamLogs(identifier: string, options: {
|
|
@@ -21,6 +20,4 @@ export declare class SandboxProcess extends SandboxAction {
|
|
|
21
20
|
stop(identifier: string): Promise<DeleteProcessByIdentifierResponse>;
|
|
22
21
|
kill(identifier: string): Promise<DeleteProcessByIdentifierKillResponse>;
|
|
23
22
|
logs(identifier: string, type?: "stdout" | "stderr" | "all"): Promise<string>;
|
|
24
|
-
get toolsWithoutExecute(): ProcessToolWithoutExecute;
|
|
25
|
-
get tools(): ProcessToolWithExecute;
|
|
26
23
|
}
|
|
@@ -4,7 +4,6 @@ exports.SandboxProcess = void 0;
|
|
|
4
4
|
const settings_js_1 = require("../../common/settings.js");
|
|
5
5
|
const action_js_1 = require("../action.js");
|
|
6
6
|
const index_js_1 = require("../client/index.js");
|
|
7
|
-
const types_js_1 = require("./types.js");
|
|
8
7
|
class SandboxProcess extends action_js_1.SandboxAction {
|
|
9
8
|
constructor(sandbox) {
|
|
10
9
|
super(sandbox);
|
|
@@ -141,132 +140,5 @@ class SandboxProcess extends action_js_1.SandboxAction {
|
|
|
141
140
|
}
|
|
142
141
|
throw new Error("Unsupported log type");
|
|
143
142
|
}
|
|
144
|
-
get toolsWithoutExecute() {
|
|
145
|
-
return {
|
|
146
|
-
exec: {
|
|
147
|
-
description: "Execute a process in the sandbox",
|
|
148
|
-
parameters: types_js_1.ExecParamsSchema,
|
|
149
|
-
},
|
|
150
|
-
wait: {
|
|
151
|
-
description: "Wait for a process to finish by identifier",
|
|
152
|
-
parameters: types_js_1.WaitParamsSchema,
|
|
153
|
-
},
|
|
154
|
-
get: {
|
|
155
|
-
description: "Get process info by identifier",
|
|
156
|
-
parameters: types_js_1.GetParamsSchema,
|
|
157
|
-
},
|
|
158
|
-
list: {
|
|
159
|
-
description: "List all processes in the sandbox",
|
|
160
|
-
parameters: types_js_1.ListParamsSchema,
|
|
161
|
-
},
|
|
162
|
-
stop: {
|
|
163
|
-
description: "Stop a process by identifier",
|
|
164
|
-
parameters: types_js_1.StopParamsSchema,
|
|
165
|
-
},
|
|
166
|
-
kill: {
|
|
167
|
-
description: "Kill a process by identifier",
|
|
168
|
-
parameters: types_js_1.KillParamsSchema,
|
|
169
|
-
},
|
|
170
|
-
logs: {
|
|
171
|
-
description: "Get logs for a process by identifier",
|
|
172
|
-
parameters: types_js_1.LogsParamsSchema,
|
|
173
|
-
},
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
get tools() {
|
|
177
|
-
return {
|
|
178
|
-
exec: {
|
|
179
|
-
description: "Execute a process in the sandbox",
|
|
180
|
-
parameters: types_js_1.ExecParamsSchema,
|
|
181
|
-
execute: async (args) => {
|
|
182
|
-
try {
|
|
183
|
-
const result = await this.exec(args.process);
|
|
184
|
-
return JSON.stringify(result);
|
|
185
|
-
}
|
|
186
|
-
catch (e) {
|
|
187
|
-
return JSON.stringify({ message: e.message, process: args.process });
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
wait: {
|
|
192
|
-
description: "Wait for a process to finish by identifier",
|
|
193
|
-
parameters: types_js_1.WaitParamsSchema,
|
|
194
|
-
execute: async (args) => {
|
|
195
|
-
try {
|
|
196
|
-
const result = await this.wait(args.identifier, { maxWait: args.maxWait, interval: args.interval });
|
|
197
|
-
return JSON.stringify(result);
|
|
198
|
-
}
|
|
199
|
-
catch (e) {
|
|
200
|
-
return JSON.stringify({ message: e.message, identifier: args.identifier });
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
get: {
|
|
205
|
-
description: "Get process info by identifier",
|
|
206
|
-
parameters: types_js_1.GetParamsSchema,
|
|
207
|
-
execute: async (args) => {
|
|
208
|
-
try {
|
|
209
|
-
const result = await this.get(args.identifier);
|
|
210
|
-
return JSON.stringify(result);
|
|
211
|
-
}
|
|
212
|
-
catch (e) {
|
|
213
|
-
return JSON.stringify({ message: e.message, identifier: args.identifier });
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
list: {
|
|
218
|
-
description: "List all processes in the sandbox",
|
|
219
|
-
parameters: types_js_1.ListParamsSchema,
|
|
220
|
-
execute: async () => {
|
|
221
|
-
try {
|
|
222
|
-
const result = await this.list();
|
|
223
|
-
return JSON.stringify(result);
|
|
224
|
-
}
|
|
225
|
-
catch (e) {
|
|
226
|
-
return JSON.stringify({ message: e.message });
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
stop: {
|
|
231
|
-
description: "Stop a process by identifier",
|
|
232
|
-
parameters: types_js_1.StopParamsSchema,
|
|
233
|
-
execute: async (args) => {
|
|
234
|
-
try {
|
|
235
|
-
const result = await this.stop(args.identifier);
|
|
236
|
-
return JSON.stringify(result);
|
|
237
|
-
}
|
|
238
|
-
catch (e) {
|
|
239
|
-
return JSON.stringify({ message: e.message, identifier: args.identifier });
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
},
|
|
243
|
-
kill: {
|
|
244
|
-
description: "Kill a process by identifier",
|
|
245
|
-
parameters: types_js_1.KillParamsSchema,
|
|
246
|
-
execute: async (args) => {
|
|
247
|
-
try {
|
|
248
|
-
const result = await this.kill(args.identifier);
|
|
249
|
-
return JSON.stringify(result);
|
|
250
|
-
}
|
|
251
|
-
catch (e) {
|
|
252
|
-
return JSON.stringify({ message: e.message, identifier: args.identifier });
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
},
|
|
256
|
-
logs: {
|
|
257
|
-
description: "Get logs for a process by identifier",
|
|
258
|
-
parameters: types_js_1.LogsParamsSchema,
|
|
259
|
-
execute: async (args) => {
|
|
260
|
-
try {
|
|
261
|
-
const result = await this.logs(args.identifier, args.type || "all");
|
|
262
|
-
return JSON.stringify({ logs: result });
|
|
263
|
-
}
|
|
264
|
-
catch (e) {
|
|
265
|
-
return JSON.stringify({ message: e.message, identifier: args.identifier });
|
|
266
|
-
}
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
143
|
}
|
|
272
144
|
exports.SandboxProcess = SandboxProcess;
|
package/dist/tools/mcpTool.d.ts
CHANGED
package/dist/tools/mcpTool.js
CHANGED
|
@@ -13,6 +13,8 @@ const zodSchema_js_1 = require("./zodSchema.js");
|
|
|
13
13
|
const McpToolCache = new Map();
|
|
14
14
|
class McpTool {
|
|
15
15
|
name;
|
|
16
|
+
type;
|
|
17
|
+
pluralType;
|
|
16
18
|
client;
|
|
17
19
|
transport;
|
|
18
20
|
timer;
|
|
@@ -20,6 +22,13 @@ class McpTool {
|
|
|
20
22
|
startPromise;
|
|
21
23
|
constructor(name, ms = 5000) {
|
|
22
24
|
this.name = name;
|
|
25
|
+
this.type = "function";
|
|
26
|
+
this.pluralType = "functions";
|
|
27
|
+
if (name.startsWith("sandbox/") || name.startsWith("sandboxes/")) {
|
|
28
|
+
this.name = name.split("/")[1];
|
|
29
|
+
this.type = "sandbox";
|
|
30
|
+
this.pluralType = "sandboxes";
|
|
31
|
+
}
|
|
23
32
|
if (env_js_1.env.BL_CLOUD) {
|
|
24
33
|
this.ms = 0;
|
|
25
34
|
}
|
|
@@ -42,16 +51,16 @@ class McpTool {
|
|
|
42
51
|
return null;
|
|
43
52
|
}
|
|
44
53
|
get externalUrl() {
|
|
45
|
-
return new URL(`${settings_js_1.settings.runUrl}/${settings_js_1.settings.workspace}
|
|
54
|
+
return new URL(`${settings_js_1.settings.runUrl}/${settings_js_1.settings.workspace}/${this.pluralType}/${this.name}`);
|
|
46
55
|
}
|
|
47
56
|
get internalUrl() {
|
|
48
|
-
const hash = (0, internal_js_1.getGlobalUniqueHash)(settings_js_1.settings.workspace,
|
|
57
|
+
const hash = (0, internal_js_1.getGlobalUniqueHash)(settings_js_1.settings.workspace, this.type, this.name);
|
|
49
58
|
return new URL(`${settings_js_1.settings.runInternalProtocol}://bl-${settings_js_1.settings.env}-${hash}.${settings_js_1.settings.runInternalHostname}`);
|
|
50
59
|
}
|
|
51
60
|
get forcedUrl() {
|
|
52
61
|
const envVar = this.name.replace(/-/g, "_").toUpperCase();
|
|
53
|
-
if (env_js_1.env[`
|
|
54
|
-
return new URL(env_js_1.env[`
|
|
62
|
+
if (env_js_1.env[`BL_${this.pluralType.toUpperCase()}_${envVar}_URL`]) {
|
|
63
|
+
return new URL(env_js_1.env[`BL_${this.pluralType.toUpperCase()}_${envVar}_URL`]);
|
|
55
64
|
}
|
|
56
65
|
return null;
|
|
57
66
|
}
|
|
@@ -68,7 +77,8 @@ class McpTool {
|
|
|
68
77
|
this.startPromise = this.startPromise || (async () => {
|
|
69
78
|
await (0, index_js_2.authenticate)();
|
|
70
79
|
try {
|
|
71
|
-
logger_js_1.logger.debug(`MCP:${this.name}:Connecting`);
|
|
80
|
+
logger_js_1.logger.debug(`MCP:${this.name}:Connecting::${this.url.toString()}`);
|
|
81
|
+
console.log("MCP: Connecting to");
|
|
72
82
|
this.transport = new client_js_1.BlaxelMcpClientTransport(this.url.toString(), settings_js_1.settings.headers);
|
|
73
83
|
await this.client.connect(this.transport);
|
|
74
84
|
logger_js_1.logger.debug(`MCP:${this.name}:Connected`);
|
package/package.json
CHANGED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const ExecParamsSchema: z.ZodObject<{
|
|
3
|
-
process: z.ZodAny;
|
|
4
|
-
}, "strip", z.ZodTypeAny, {
|
|
5
|
-
process?: any;
|
|
6
|
-
}, {
|
|
7
|
-
process?: any;
|
|
8
|
-
}>;
|
|
9
|
-
export declare const WaitParamsSchema: z.ZodObject<{
|
|
10
|
-
identifier: z.ZodString;
|
|
11
|
-
maxWait: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
12
|
-
interval: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
13
|
-
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
identifier: string;
|
|
15
|
-
maxWait: number;
|
|
16
|
-
interval: number;
|
|
17
|
-
}, {
|
|
18
|
-
identifier: string;
|
|
19
|
-
maxWait?: number | undefined;
|
|
20
|
-
interval?: number | undefined;
|
|
21
|
-
}>;
|
|
22
|
-
export declare const GetParamsSchema: z.ZodObject<{
|
|
23
|
-
identifier: z.ZodString;
|
|
24
|
-
}, "strip", z.ZodTypeAny, {
|
|
25
|
-
identifier: string;
|
|
26
|
-
}, {
|
|
27
|
-
identifier: string;
|
|
28
|
-
}>;
|
|
29
|
-
export declare const ListParamsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
30
|
-
export declare const StopParamsSchema: z.ZodObject<{
|
|
31
|
-
identifier: z.ZodString;
|
|
32
|
-
}, "strip", z.ZodTypeAny, {
|
|
33
|
-
identifier: string;
|
|
34
|
-
}, {
|
|
35
|
-
identifier: string;
|
|
36
|
-
}>;
|
|
37
|
-
export declare const KillParamsSchema: z.ZodObject<{
|
|
38
|
-
identifier: z.ZodString;
|
|
39
|
-
}, "strip", z.ZodTypeAny, {
|
|
40
|
-
identifier: string;
|
|
41
|
-
}, {
|
|
42
|
-
identifier: string;
|
|
43
|
-
}>;
|
|
44
|
-
export declare const LogsParamsSchema: z.ZodObject<{
|
|
45
|
-
identifier: z.ZodString;
|
|
46
|
-
type: z.ZodDefault<z.ZodOptional<z.ZodEnum<["stdout", "stderr", "all"]>>>;
|
|
47
|
-
}, "strip", z.ZodTypeAny, {
|
|
48
|
-
type: "stdout" | "stderr" | "all";
|
|
49
|
-
identifier: string;
|
|
50
|
-
}, {
|
|
51
|
-
identifier: string;
|
|
52
|
-
type?: "stdout" | "stderr" | "all" | undefined;
|
|
53
|
-
}>;
|
|
54
|
-
export type ProcessToolWithoutExecute = {
|
|
55
|
-
exec: {
|
|
56
|
-
description: string;
|
|
57
|
-
parameters: typeof ExecParamsSchema;
|
|
58
|
-
};
|
|
59
|
-
wait: {
|
|
60
|
-
description: string;
|
|
61
|
-
parameters: typeof WaitParamsSchema;
|
|
62
|
-
};
|
|
63
|
-
get: {
|
|
64
|
-
description: string;
|
|
65
|
-
parameters: typeof GetParamsSchema;
|
|
66
|
-
};
|
|
67
|
-
list: {
|
|
68
|
-
description: string;
|
|
69
|
-
parameters: typeof ListParamsSchema;
|
|
70
|
-
};
|
|
71
|
-
stop: {
|
|
72
|
-
description: string;
|
|
73
|
-
parameters: typeof StopParamsSchema;
|
|
74
|
-
};
|
|
75
|
-
kill: {
|
|
76
|
-
description: string;
|
|
77
|
-
parameters: typeof KillParamsSchema;
|
|
78
|
-
};
|
|
79
|
-
logs: {
|
|
80
|
-
description: string;
|
|
81
|
-
parameters: typeof LogsParamsSchema;
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
export type ProcessToolWithExecute = {
|
|
85
|
-
exec: {
|
|
86
|
-
description: string;
|
|
87
|
-
parameters: typeof ExecParamsSchema;
|
|
88
|
-
execute: (args: z.infer<typeof ExecParamsSchema>) => Promise<string>;
|
|
89
|
-
};
|
|
90
|
-
wait: {
|
|
91
|
-
description: string;
|
|
92
|
-
parameters: typeof WaitParamsSchema;
|
|
93
|
-
execute: (args: z.infer<typeof WaitParamsSchema>) => Promise<string>;
|
|
94
|
-
};
|
|
95
|
-
get: {
|
|
96
|
-
description: string;
|
|
97
|
-
parameters: typeof GetParamsSchema;
|
|
98
|
-
execute: (args: z.infer<typeof GetParamsSchema>) => Promise<string>;
|
|
99
|
-
};
|
|
100
|
-
list: {
|
|
101
|
-
description: string;
|
|
102
|
-
parameters: typeof ListParamsSchema;
|
|
103
|
-
execute: (args: z.infer<typeof ListParamsSchema>) => Promise<string>;
|
|
104
|
-
};
|
|
105
|
-
stop: {
|
|
106
|
-
description: string;
|
|
107
|
-
parameters: typeof StopParamsSchema;
|
|
108
|
-
execute: (args: z.infer<typeof StopParamsSchema>) => Promise<string>;
|
|
109
|
-
};
|
|
110
|
-
kill: {
|
|
111
|
-
description: string;
|
|
112
|
-
parameters: typeof KillParamsSchema;
|
|
113
|
-
execute: (args: z.infer<typeof KillParamsSchema>) => Promise<string>;
|
|
114
|
-
};
|
|
115
|
-
logs: {
|
|
116
|
-
description: string;
|
|
117
|
-
parameters: typeof LogsParamsSchema;
|
|
118
|
-
execute: (args: z.infer<typeof LogsParamsSchema>) => Promise<string>;
|
|
119
|
-
};
|
|
120
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LogsParamsSchema = exports.KillParamsSchema = exports.StopParamsSchema = exports.ListParamsSchema = exports.GetParamsSchema = exports.WaitParamsSchema = exports.ExecParamsSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
exports.ExecParamsSchema = zod_1.z.object({
|
|
6
|
-
process: zod_1.z.any().describe("ProcessRequest object to execute in the sandbox"), // Refine if you have a zod schema for ProcessRequest
|
|
7
|
-
}).describe("Parameters for executing a process in the sandbox");
|
|
8
|
-
exports.WaitParamsSchema = zod_1.z.object({
|
|
9
|
-
identifier: zod_1.z.string().describe("Process identifier to wait for"),
|
|
10
|
-
maxWait: zod_1.z.number().optional().default(60000).describe("Maximum wait time in milliseconds (default 60000)"),
|
|
11
|
-
interval: zod_1.z.number().optional().default(1000).describe("Polling interval in milliseconds (default 1000)"),
|
|
12
|
-
}).describe("Parameters for waiting for a process to finish");
|
|
13
|
-
exports.GetParamsSchema = zod_1.z.object({
|
|
14
|
-
identifier: zod_1.z.string().describe("Process identifier to get info for"),
|
|
15
|
-
}).describe("Parameters for getting process info");
|
|
16
|
-
exports.ListParamsSchema = zod_1.z.object({}).describe("Parameters for listing all processes (none)");
|
|
17
|
-
exports.StopParamsSchema = zod_1.z.object({
|
|
18
|
-
identifier: zod_1.z.string().describe("Process identifier to stop"),
|
|
19
|
-
}).describe("Parameters for stopping a process");
|
|
20
|
-
exports.KillParamsSchema = zod_1.z.object({
|
|
21
|
-
identifier: zod_1.z.string().describe("Process identifier to kill"),
|
|
22
|
-
}).describe("Parameters for killing a process");
|
|
23
|
-
exports.LogsParamsSchema = zod_1.z.object({
|
|
24
|
-
identifier: zod_1.z.string().describe("Process identifier to get logs for"),
|
|
25
|
-
type: zod_1.z.enum(["stdout", "stderr", "all"]).optional().default("all").describe("Type of logs to retrieve: stdout, stderr, or all (default all)"),
|
|
26
|
-
}).describe("Parameters for retrieving process logs");
|