@loopstack/sandbox-filesystem 0.2.0

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 (38) hide show
  1. package/README.md +234 -0
  2. package/dist/index.d.ts +8 -0
  3. package/dist/index.js +25 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/sandbox-filesystem.module.d.ts +2 -0
  6. package/dist/sandbox-filesystem.module.js +46 -0
  7. package/dist/sandbox-filesystem.module.js.map +1 -0
  8. package/dist/tools/sandbox-create-directory.tool.d.ts +19 -0
  9. package/dist/tools/sandbox-create-directory.tool.js +77 -0
  10. package/dist/tools/sandbox-create-directory.tool.js.map +1 -0
  11. package/dist/tools/sandbox-delete.tool.d.ts +20 -0
  12. package/dist/tools/sandbox-delete.tool.js +77 -0
  13. package/dist/tools/sandbox-delete.tool.js.map +1 -0
  14. package/dist/tools/sandbox-exists.tool.d.ts +20 -0
  15. package/dist/tools/sandbox-exists.tool.js +89 -0
  16. package/dist/tools/sandbox-exists.tool.js.map +1 -0
  17. package/dist/tools/sandbox-file-info.tool.d.ts +27 -0
  18. package/dist/tools/sandbox-file-info.tool.js +96 -0
  19. package/dist/tools/sandbox-file-info.tool.js.map +1 -0
  20. package/dist/tools/sandbox-list-directory.tool.d.ts +26 -0
  21. package/dist/tools/sandbox-list-directory.tool.js +102 -0
  22. package/dist/tools/sandbox-list-directory.tool.js.map +1 -0
  23. package/dist/tools/sandbox-read-file.tool.d.ts +22 -0
  24. package/dist/tools/sandbox-read-file.tool.js +71 -0
  25. package/dist/tools/sandbox-read-file.tool.js.map +1 -0
  26. package/dist/tools/sandbox-write-file.tool.d.ts +24 -0
  27. package/dist/tools/sandbox-write-file.tool.js +96 -0
  28. package/dist/tools/sandbox-write-file.tool.js.map +1 -0
  29. package/package.json +51 -0
  30. package/src/index.ts +8 -0
  31. package/src/sandbox-filesystem.module.ts +48 -0
  32. package/src/tools/sandbox-create-directory.tool.ts +93 -0
  33. package/src/tools/sandbox-delete.tool.ts +87 -0
  34. package/src/tools/sandbox-exists.tool.ts +102 -0
  35. package/src/tools/sandbox-file-info.tool.ts +119 -0
  36. package/src/tools/sandbox-list-directory.tool.ts +131 -0
  37. package/src/tools/sandbox-read-file.tool.ts +82 -0
  38. package/src/tools/sandbox-write-file.tool.ts +121 -0
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ import { ToolResult } from '@loopstack/common';
3
+ import { ToolBase, WorkflowExecution } from '@loopstack/core';
4
+ declare const propertiesSchema: z.ZodObject<{
5
+ containerId: z.ZodString;
6
+ path: z.ZodString;
7
+ }, z.core.$strict>;
8
+ type SandboxFileInfoArgs = z.infer<typeof propertiesSchema>;
9
+ interface SandboxFileInfoResult {
10
+ path: string;
11
+ name: string;
12
+ type: 'file' | 'directory' | 'symlink' | 'other';
13
+ size: number;
14
+ permissions: string;
15
+ owner: string;
16
+ group: string;
17
+ modifiedAt: string;
18
+ accessedAt: string;
19
+ createdAt: string;
20
+ }
21
+ export declare class SandboxFileInfo extends ToolBase<SandboxFileInfoArgs> {
22
+ private readonly logger;
23
+ private sandboxCommand;
24
+ execute(args: SandboxFileInfoArgs, _ctx: WorkflowExecution): Promise<ToolResult<SandboxFileInfoResult>>;
25
+ private parseFileType;
26
+ }
27
+ export {};
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var SandboxFileInfo_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.SandboxFileInfo = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const zod_1 = require("zod");
16
+ const common_2 = require("@loopstack/common");
17
+ const core_1 = require("@loopstack/core");
18
+ const sandbox_tool_1 = require("@loopstack/sandbox-tool");
19
+ const propertiesSchema = zod_1.z
20
+ .object({
21
+ containerId: zod_1.z.string().describe('The ID of the container to get file info from'),
22
+ path: zod_1.z.string().describe('The path to the file or directory'),
23
+ })
24
+ .strict();
25
+ let SandboxFileInfo = SandboxFileInfo_1 = class SandboxFileInfo extends core_1.ToolBase {
26
+ logger = new common_1.Logger(SandboxFileInfo_1.name);
27
+ sandboxCommand;
28
+ async execute(args, _ctx) {
29
+ const { containerId, path: targetPath } = args;
30
+ this.logger.debug(`Getting file info for ${targetPath} in container ${containerId}`);
31
+ const result = await this.sandboxCommand.execute({
32
+ containerId,
33
+ executable: 'stat',
34
+ args: ['-c', '%F|%s|%A|%U|%G|%y|%x|%w', targetPath],
35
+ workingDirectory: '/',
36
+ timeout: 10000,
37
+ });
38
+ if (!result.data) {
39
+ this.logger.error(`Failed to get file info for ${targetPath}: No result data`);
40
+ throw new Error(`Failed to get file info for ${targetPath}: No result data`);
41
+ }
42
+ if (result.data.exitCode !== 0) {
43
+ this.logger.error(`Failed to get file info for ${targetPath}: ${result.data.stderr || 'Unknown error'}`);
44
+ throw new Error(`Failed to get file info for ${targetPath}: ${result.data.stderr || 'Unknown error'}`);
45
+ }
46
+ const output = result.data.stdout.trim();
47
+ const parts = output.split('|');
48
+ if (parts.length < 8) {
49
+ this.logger.error(`Unexpected stat output format: ${output}`);
50
+ throw new Error(`Unexpected stat output format: ${output}`);
51
+ }
52
+ const [typeStr, sizeStr, permissions, owner, group, mtime, atime, ctime] = parts;
53
+ const name = targetPath.split('/').pop() || targetPath;
54
+ const fileType = this.parseFileType(typeStr);
55
+ this.logger.debug(`Retrieved info for ${targetPath}: type=${fileType}, size=${sizeStr}`);
56
+ return {
57
+ data: {
58
+ path: targetPath,
59
+ name,
60
+ type: fileType,
61
+ size: parseInt(sizeStr, 10),
62
+ permissions,
63
+ owner,
64
+ group,
65
+ modifiedAt: mtime,
66
+ accessedAt: atime,
67
+ createdAt: ctime === '-' ? mtime : ctime,
68
+ },
69
+ };
70
+ }
71
+ parseFileType(typeStr) {
72
+ const lower = typeStr.toLowerCase();
73
+ if (lower.includes('regular'))
74
+ return 'file';
75
+ if (lower.includes('directory'))
76
+ return 'directory';
77
+ if (lower.includes('symbolic link'))
78
+ return 'symlink';
79
+ return 'other';
80
+ }
81
+ };
82
+ exports.SandboxFileInfo = SandboxFileInfo;
83
+ __decorate([
84
+ (0, common_2.Tool)(),
85
+ __metadata("design:type", sandbox_tool_1.SandboxCommand)
86
+ ], SandboxFileInfo.prototype, "sandboxCommand", void 0);
87
+ exports.SandboxFileInfo = SandboxFileInfo = SandboxFileInfo_1 = __decorate([
88
+ (0, common_1.Injectable)(),
89
+ (0, common_2.BlockConfig)({
90
+ config: {
91
+ description: 'Get detailed information about a file or directory in a sandbox container',
92
+ },
93
+ }),
94
+ (0, common_2.WithArguments)(propertiesSchema)
95
+ ], SandboxFileInfo);
96
+ //# sourceMappingURL=sandbox-file-info.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-file-info.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-file-info.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,2CAAoD;AACpD,6BAAwB;AACxB,8CAAiF;AACjF,0CAA8D;AAC9D,0DAAyD;AAEzD,MAAM,gBAAgB,GAAG,OAAC;KACvB,MAAM,CAAC;IACN,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+CAA+C,CAAC;IACjF,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;CAC/D,CAAC;KACD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I,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC;YAAE,OAAO,SAAS,CAAC;QACtD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AApEY,0CAAe;AAGV;IAAf,IAAA,aAAI,GAAE;8BAAyB,6BAAc;uDAAC;0BAHpC,eAAe;IAP3B,IAAA,mBAAU,GAAE;IACZ,IAAA,oBAAW,EAAC;QACX,MAAM,EAAE;YACN,WAAW,EAAE,2EAA2E;SACzF;KACF,CAAC;IACD,IAAA,sBAAa,EAAC,gBAAgB,CAAC;GACnB,eAAe,CAoE3B"}
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import { ToolResult } from '@loopstack/common';
3
+ import { ToolBase, WorkflowExecution } from '@loopstack/core';
4
+ declare const propertiesSchema: z.ZodObject<{
5
+ containerId: z.ZodString;
6
+ path: z.ZodString;
7
+ recursive: z.ZodDefault<z.ZodBoolean>;
8
+ }, z.core.$strict>;
9
+ type SandboxListDirectoryArgs = z.infer<typeof propertiesSchema>;
10
+ interface FileEntry {
11
+ name: string;
12
+ type: 'file' | 'directory' | 'symlink' | 'other';
13
+ size: number;
14
+ path: string;
15
+ }
16
+ interface SandboxListDirectoryResult {
17
+ path: string;
18
+ entries: FileEntry[];
19
+ }
20
+ export declare class SandboxListDirectory extends ToolBase<SandboxListDirectoryArgs> {
21
+ private readonly logger;
22
+ private sandboxCommand;
23
+ execute(args: SandboxListDirectoryArgs, _ctx: WorkflowExecution): Promise<ToolResult<SandboxListDirectoryResult>>;
24
+ private parseFileType;
25
+ }
26
+ export {};
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var SandboxListDirectory_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.SandboxListDirectory = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const zod_1 = require("zod");
16
+ const common_2 = require("@loopstack/common");
17
+ const core_1 = require("@loopstack/core");
18
+ const sandbox_tool_1 = require("@loopstack/sandbox-tool");
19
+ const propertiesSchema = zod_1.z
20
+ .object({
21
+ containerId: zod_1.z.string().describe('The ID of the container to list the directory from'),
22
+ path: zod_1.z.string().describe('The path to the directory to list'),
23
+ recursive: zod_1.z.boolean().default(false).describe('Whether to list directories recursively'),
24
+ })
25
+ .strict();
26
+ let SandboxListDirectory = SandboxListDirectory_1 = class SandboxListDirectory extends core_1.ToolBase {
27
+ logger = new common_1.Logger(SandboxListDirectory_1.name);
28
+ sandboxCommand;
29
+ async execute(args, _ctx) {
30
+ const { containerId, path: dirPath, recursive } = args;
31
+ this.logger.debug(`Listing directory ${dirPath} in container ${containerId} (recursive: ${recursive})`);
32
+ const command = recursive
33
+ ? `find '${dirPath.replace(/'/g, "'\\''")}' -printf '%y %s %p\\n'`
34
+ : `find '${dirPath.replace(/'/g, "'\\''")}' -maxdepth 1 -printf '%y %s %p\\n'`;
35
+ const result = await this.sandboxCommand.execute({
36
+ containerId,
37
+ executable: 'sh',
38
+ args: ['-c', command],
39
+ workingDirectory: '/',
40
+ timeout: 30000,
41
+ });
42
+ if (!result.data) {
43
+ this.logger.error(`Failed to list directory ${dirPath}: No result data`);
44
+ throw new Error(`Failed to list directory ${dirPath}: No result data`);
45
+ }
46
+ if (result.data.exitCode !== 0) {
47
+ this.logger.error(`Failed to list directory ${dirPath}: ${result.data.stderr || 'Unknown error'}`);
48
+ throw new Error(`Failed to list directory ${dirPath}: ${result.data.stderr || 'Unknown error'}`);
49
+ }
50
+ const entries = [];
51
+ const lines = result.data.stdout.split('\n').filter((line) => line.trim());
52
+ for (const line of lines) {
53
+ const match = line.match(/^(\S)\s+(\d+)\s+(.+)$/);
54
+ if (match) {
55
+ const [, typeChar, sizeStr, fullPath] = match;
56
+ const name = fullPath.split('/').pop() || fullPath;
57
+ if (fullPath === dirPath)
58
+ continue;
59
+ entries.push({
60
+ name,
61
+ type: this.parseFileType(typeChar),
62
+ size: parseInt(sizeStr, 10),
63
+ path: fullPath,
64
+ });
65
+ }
66
+ }
67
+ this.logger.debug(`Listed ${entries.length} entries in ${dirPath}`);
68
+ return {
69
+ data: {
70
+ path: dirPath,
71
+ entries,
72
+ },
73
+ };
74
+ }
75
+ parseFileType(typeChar) {
76
+ switch (typeChar) {
77
+ case 'f':
78
+ return 'file';
79
+ case 'd':
80
+ return 'directory';
81
+ case 'l':
82
+ return 'symlink';
83
+ default:
84
+ return 'other';
85
+ }
86
+ }
87
+ };
88
+ exports.SandboxListDirectory = SandboxListDirectory;
89
+ __decorate([
90
+ (0, common_2.Tool)(),
91
+ __metadata("design:type", sandbox_tool_1.SandboxCommand)
92
+ ], SandboxListDirectory.prototype, "sandboxCommand", void 0);
93
+ exports.SandboxListDirectory = SandboxListDirectory = SandboxListDirectory_1 = __decorate([
94
+ (0, common_1.Injectable)(),
95
+ (0, common_2.BlockConfig)({
96
+ config: {
97
+ description: 'List files and directories in a sandbox container',
98
+ },
99
+ }),
100
+ (0, common_2.WithArguments)(propertiesSchema)
101
+ ], SandboxListDirectory);
102
+ //# sourceMappingURL=sandbox-list-directory.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-list-directory.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-list-directory.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,2CAAoD;AACpD,6BAAwB;AACxB,8CAAiF;AACjF,0CA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C,CAAC;YACL,CAAC;QACH,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,OAAO,CAAC,MAAM,eAAe,OAAO,EAAE,CAAC,CAAC;QAEpE,OAAO;YACL,IAAI,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,OAAO;aACR;SACF,CAAC;IACJ,CAAC;IAEO,aAAa,CAAC,QAAgB;QACpC,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,GAAG;gBACN,OAAO,MAAM,CAAC;YAChB,KAAK,GAAG;gBACN,OAAO,WAAW,CAAC;YACrB,KAAK,GAAG;gBACN,OAAO,SAAS,CAAC;YACnB;gBACE,OAAO,OAAO,CAAC;QACnB,CAAC;IACH,CAAC;CACF,CAAA;AAhFY,oDAAoB;AAGf;IAAf,IAAA,aAAI,GAAE;8BAAyB,6BAAc;4DAAC;+BAHpC,oBAAoB;IAPhC,IAAA,mBAAU,GAAE;IACZ,IAAA,oBAAW,EAAC;QACX,MAAM,EAAE;YACN,WAAW,EAAE,mDAAmD;SACjE;KACF,CAAC;IACD,IAAA,sBAAa,EAAC,gBAAgB,CAAC;GACnB,oBAAoB,CAgFhC"}
@@ -0,0 +1,22 @@
1
+ import { z } from 'zod';
2
+ import { ToolResult } from '@loopstack/common';
3
+ import { ToolBase, WorkflowExecution } from '@loopstack/core';
4
+ declare const propertiesSchema: z.ZodObject<{
5
+ containerId: z.ZodString;
6
+ path: z.ZodString;
7
+ encoding: z.ZodDefault<z.ZodEnum<{
8
+ utf8: "utf8";
9
+ base64: "base64";
10
+ }>>;
11
+ }, z.core.$strict>;
12
+ type SandboxReadFileArgs = z.infer<typeof propertiesSchema>;
13
+ interface SandboxReadFileResult {
14
+ content: string;
15
+ encoding: string;
16
+ }
17
+ export declare class SandboxReadFile extends ToolBase<SandboxReadFileArgs> {
18
+ private readonly logger;
19
+ private sandboxCommand;
20
+ execute(args: SandboxReadFileArgs, _ctx: WorkflowExecution): Promise<ToolResult<SandboxReadFileResult>>;
21
+ }
22
+ export {};
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var SandboxReadFile_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.SandboxReadFile = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const zod_1 = require("zod");
16
+ const common_2 = require("@loopstack/common");
17
+ const core_1 = require("@loopstack/core");
18
+ const sandbox_tool_1 = require("@loopstack/sandbox-tool");
19
+ const propertiesSchema = zod_1.z
20
+ .object({
21
+ containerId: zod_1.z.string().describe('The ID of the container to read the file from'),
22
+ path: zod_1.z.string().describe('The path to the file to read'),
23
+ encoding: zod_1.z.enum(['utf8', 'base64']).default('utf8').describe('The encoding to use when reading the file'),
24
+ })
25
+ .strict();
26
+ let SandboxReadFile = SandboxReadFile_1 = class SandboxReadFile extends core_1.ToolBase {
27
+ logger = new common_1.Logger(SandboxReadFile_1.name);
28
+ sandboxCommand;
29
+ async execute(args, _ctx) {
30
+ const { containerId, path, encoding } = args;
31
+ this.logger.debug(`Reading file ${path} from container ${containerId} (encoding: ${encoding})`);
32
+ const executable = encoding === 'base64' ? 'base64' : 'cat';
33
+ const result = await this.sandboxCommand.execute({
34
+ containerId,
35
+ executable,
36
+ args: [path],
37
+ workingDirectory: '/',
38
+ timeout: 30000,
39
+ });
40
+ if (!result.data) {
41
+ this.logger.error(`Failed to read file ${path}: No result data`);
42
+ throw new Error(`Failed to read file ${path}: No result data`);
43
+ }
44
+ if (result.data.exitCode !== 0) {
45
+ this.logger.error(`Failed to read file ${path}: ${result.data.stderr || 'Unknown error'}`);
46
+ throw new Error(`Failed to read file ${path}: ${result.data.stderr || 'Unknown error'}`);
47
+ }
48
+ this.logger.debug(`Successfully read file ${path} (${result.data.stdout.length} characters)`);
49
+ return {
50
+ data: {
51
+ content: result.data.stdout,
52
+ encoding,
53
+ },
54
+ };
55
+ }
56
+ };
57
+ exports.SandboxReadFile = SandboxReadFile;
58
+ __decorate([
59
+ (0, common_2.Tool)(),
60
+ __metadata("design:type", sandbox_tool_1.SandboxCommand)
61
+ ], SandboxReadFile.prototype, "sandboxCommand", void 0);
62
+ exports.SandboxReadFile = SandboxReadFile = SandboxReadFile_1 = __decorate([
63
+ (0, common_1.Injectable)(),
64
+ (0, common_2.BlockConfig)({
65
+ config: {
66
+ description: 'Read file contents from a sandbox container',
67
+ },
68
+ }),
69
+ (0, common_2.WithArguments)(propertiesSchema)
70
+ ], SandboxReadFile);
71
+ //# sourceMappingURL=sandbox-read-file.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-read-file.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-read-file.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,2CAAoD;AACpD,6BAAwB;AACxB,8CAAiF;AACjF,0CAA8D;AAC9D,0DAAyD;AAEzD,MAAM,gBAAgB,GAAG,OAAC;KACvB,MAAM,CAAC;IACN,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+CAA+C,CAAC;IACjF,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;IACzD,QAAQ,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM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AAE,CAAC,CAAC;QAC3F,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,cAAc,CAAC,CAAC;QAE9F,OAAO;YACL,IAAI,EAAE;gBACJ,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM;gBAC3B,QAAQ;aACT;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAtCY,0CAAe;AAGV;IAAf,IAAA,aAAI,GAAE;8BAAyB,6BAAc;uDAAC;0BAHpC,eAAe;IAP3B,IAAA,mBAAU,GAAE;IACZ,IAAA,oBAAW,EAAC;QACX,MAAM,EAAE;YACN,WAAW,EAAE,6CAA6C;SAC3D;KACF,CAAC;IACD,IAAA,sBAAa,EAAC,gBAAgB,CAAC;GACnB,eAAe,CAsC3B"}
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ import { ToolResult } from '@loopstack/common';
3
+ import { ToolBase, WorkflowExecution } from '@loopstack/core';
4
+ declare const propertiesSchema: z.ZodObject<{
5
+ containerId: z.ZodString;
6
+ path: z.ZodString;
7
+ content: z.ZodString;
8
+ encoding: z.ZodDefault<z.ZodEnum<{
9
+ utf8: "utf8";
10
+ base64: "base64";
11
+ }>>;
12
+ createParentDirs: z.ZodDefault<z.ZodBoolean>;
13
+ }, z.core.$strict>;
14
+ type SandboxWriteFileArgs = z.infer<typeof propertiesSchema>;
15
+ interface SandboxWriteFileResult {
16
+ path: string;
17
+ bytesWritten: number;
18
+ }
19
+ export declare class SandboxWriteFile extends ToolBase<SandboxWriteFileArgs> {
20
+ private readonly logger;
21
+ private sandboxCommand;
22
+ execute(args: SandboxWriteFileArgs, _ctx: WorkflowExecution): Promise<ToolResult<SandboxWriteFileResult>>;
23
+ }
24
+ export {};
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var SandboxWriteFile_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.SandboxWriteFile = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const path = require("path");
16
+ const zod_1 = require("zod");
17
+ const common_2 = require("@loopstack/common");
18
+ const core_1 = require("@loopstack/core");
19
+ const sandbox_tool_1 = require("@loopstack/sandbox-tool");
20
+ const propertiesSchema = zod_1.z
21
+ .object({
22
+ containerId: zod_1.z.string().describe('The ID of the container to write the file to'),
23
+ path: zod_1.z.string().describe('The path where the file should be written'),
24
+ content: zod_1.z.string().describe('The content to write to the file'),
25
+ encoding: zod_1.z.enum(['utf8', 'base64']).default('utf8').describe('The encoding of the content'),
26
+ createParentDirs: zod_1.z.boolean().default(true).describe("Whether to create parent directories if they don't exist"),
27
+ })
28
+ .strict();
29
+ let SandboxWriteFile = SandboxWriteFile_1 = class SandboxWriteFile extends core_1.ToolBase {
30
+ logger = new common_1.Logger(SandboxWriteFile_1.name);
31
+ sandboxCommand;
32
+ async execute(args, _ctx) {
33
+ const { containerId, path: filePath, content, encoding, createParentDirs } = args;
34
+ this.logger.debug(`Writing file ${filePath} to container ${containerId} (encoding: ${encoding})`);
35
+ if (createParentDirs) {
36
+ const parentDir = path.posix.dirname(filePath);
37
+ if (parentDir !== '/' && parentDir !== '.') {
38
+ this.logger.debug(`Creating parent directory ${parentDir}`);
39
+ const mkdirResult = await this.sandboxCommand.execute({
40
+ containerId,
41
+ executable: 'mkdir',
42
+ args: ['-p', parentDir],
43
+ workingDirectory: '/',
44
+ timeout: 5000,
45
+ });
46
+ if (!mkdirResult.data) {
47
+ this.logger.error(`Failed to create parent directory ${parentDir}: No result data`);
48
+ throw new Error(`Failed to create parent directory ${parentDir}: No result data`);
49
+ }
50
+ if (mkdirResult.data.exitCode !== 0) {
51
+ this.logger.error(`Failed to create parent directory ${parentDir}: ${mkdirResult.data.stderr || 'Unknown error'}`);
52
+ throw new Error(`Failed to create parent directory ${parentDir}: ${mkdirResult.data.stderr || 'Unknown error'}`);
53
+ }
54
+ }
55
+ }
56
+ const base64Content = encoding === 'utf8' ? Buffer.from(content, 'utf8').toString('base64') : content.replace(/[^A-Za-z0-9+/=]/g, '');
57
+ const result = await this.sandboxCommand.execute({
58
+ containerId,
59
+ executable: 'sh',
60
+ args: ['-c', `echo '${base64Content}' | base64 -d > '${filePath.replace(/'/g, "'\\''")}'`],
61
+ workingDirectory: '/',
62
+ timeout: 30000,
63
+ });
64
+ if (!result.data) {
65
+ this.logger.error(`Failed to write file ${filePath}: No result data`);
66
+ throw new Error(`Failed to write file ${filePath}: No result data`);
67
+ }
68
+ if (result.data.exitCode !== 0) {
69
+ this.logger.error(`Failed to write file ${filePath}: ${result.data.stderr || 'Unknown error'}`);
70
+ throw new Error(`Failed to write file ${filePath}: ${result.data.stderr || 'Unknown error'}`);
71
+ }
72
+ const bytesWritten = encoding === 'utf8' ? Buffer.from(content, 'utf8').length : Buffer.from(content, 'base64').length;
73
+ this.logger.log(`Successfully wrote ${bytesWritten} bytes to ${filePath} in container ${containerId}`);
74
+ return {
75
+ data: {
76
+ path: filePath,
77
+ bytesWritten,
78
+ },
79
+ };
80
+ }
81
+ };
82
+ exports.SandboxWriteFile = SandboxWriteFile;
83
+ __decorate([
84
+ (0, common_2.Tool)(),
85
+ __metadata("design:type", sandbox_tool_1.SandboxCommand)
86
+ ], SandboxWriteFile.prototype, "sandboxCommand", void 0);
87
+ exports.SandboxWriteFile = SandboxWriteFile = SandboxWriteFile_1 = __decorate([
88
+ (0, common_1.Injectable)(),
89
+ (0, common_2.BlockConfig)({
90
+ config: {
91
+ description: 'Write content to a file in a sandbox container',
92
+ },
93
+ }),
94
+ (0, common_2.WithArguments)(propertiesSchema)
95
+ ], SandboxWriteFile);
96
+ //# sourceMappingURL=sandbox-write-file.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-write-file.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-write-file.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,2CAAoD;AACpD,6BAA6B;AAC7B,6BAAwB;AACxB,8CAAiF;AACjF,0CAA8D;AAC9D,0DAAyD;AAEzD,MAAM,gBAAgB,GAAG,OAAC;KACvB,MAAM,CAAC;IACN,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC;IAChF,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IACtE,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;IAChE,QAAQ,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,6BAA6B,CAAC;IAC5F,gBAAgB,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,0DAA0D,CAAC;CACjH,CAAC;KACD,MAAM,EAAE,CAAC;AAgBL,IAAM,gBAAgB,wBAAtB,MAAM,gBAAiB,SAAQ,eAA8B;IACjD,MAAM,GAAG,IAAI,eAAM,CAAC,kBAAgB,CAAC,IAAI,CAAC,CAAC;IAE5C,cAAc,CAAiB;IAE/C,KAAK,CAAC,OAAO,CAAC,IAA0B,EAAE,IAAuB;QAC/D,MA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;QAEpG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,sBAAsB,YAAY,aAAa,QAAQ,iBAAiB,WAAW,EAAE,CAAC,CAAC;QAEvG,OAAO;YACL,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,YAAY;aACb;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA1EY,4CAAgB;AAGX;IAAf,IAAA,aAAI,GAAE;8BAAyB,6BAAc;wDAAC;2BAHpC,gBAAgB;IAP5B,IAAA,mBAAU,GAAE;IACZ,IAAA,oBAAW,EAAC;QACX,MAAM,EAAE;YACN,WAAW,EAAE,gDAAgD;SAC9D;KACF,CAAC;IACD,IAAA,sBAAa,EAAC,gBAAgB,CAAC;GACnB,gBAAgB,CA0E5B"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@loopstack/sandbox-filesystem",
3
+ "displayName": "Sandbox Filesystem",
4
+ "description": "Secure, controlled filesystem operations within Docker sandbox environments",
5
+ "version": "0.2.0",
6
+ "author": {
7
+ "name": "Tobias Blättermann, Jakob Klippel"
8
+ },
9
+ "keywords": [
10
+ "sandbox",
11
+ "filesystem",
12
+ "docker"
13
+ ],
14
+ "license": "Apache-2.0",
15
+ "main": "dist/index.js",
16
+ "types": "dist/index.d.ts",
17
+ "exports": {
18
+ ".": "./dist/index.js",
19
+ "./src/*": "./src/*"
20
+ },
21
+ "scripts": {
22
+ "build": "nest build",
23
+ "compile": "tsc --noEmit",
24
+ "format": "prettier --write .",
25
+ "lint": "eslint .",
26
+ "test": "jest --passWithNoTests",
27
+ "watch": "nest build --watch"
28
+ },
29
+ "dependencies": {
30
+ "@loopstack/common": "^0.18.0",
31
+ "@loopstack/core": "^0.18.0",
32
+ "@loopstack/sandbox-tool": "^0.2.0",
33
+ "@nestjs/common": "^11.1.12",
34
+ "zod": "^4.3.5"
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "src"
39
+ ],
40
+ "jest": {
41
+ "testEnvironment": "node",
42
+ "rootDir": "src",
43
+ "testRegex": ".*\\.spec\\.ts$",
44
+ "transform": {
45
+ "^.+\\.ts$": "ts-jest"
46
+ },
47
+ "testTimeout": 10000,
48
+ "forceExit": true,
49
+ "maxWorkers": 1
50
+ }
51
+ }
package/src/index.ts ADDED
@@ -0,0 +1,8 @@
1
+ export * from './sandbox-filesystem.module';
2
+ export * from './tools/sandbox-read-file.tool';
3
+ export * from './tools/sandbox-write-file.tool';
4
+ export * from './tools/sandbox-list-directory.tool';
5
+ export * from './tools/sandbox-create-directory.tool';
6
+ export * from './tools/sandbox-delete.tool';
7
+ export * from './tools/sandbox-exists.tool';
8
+ export * from './tools/sandbox-file-info.tool';
@@ -0,0 +1,48 @@
1
+ /*
2
+ Copyright 2025 The Loopstack Authors.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+ import { Module } from '@nestjs/common';
17
+ import { LoopCoreModule } from '@loopstack/core';
18
+ import { SandboxToolModule } from '@loopstack/sandbox-tool';
19
+ import { SandboxCreateDirectory } from './tools/sandbox-create-directory.tool';
20
+ import { SandboxDelete } from './tools/sandbox-delete.tool';
21
+ import { SandboxExists } from './tools/sandbox-exists.tool';
22
+ import { SandboxFileInfo } from './tools/sandbox-file-info.tool';
23
+ import { SandboxListDirectory } from './tools/sandbox-list-directory.tool';
24
+ import { SandboxReadFile } from './tools/sandbox-read-file.tool';
25
+ import { SandboxWriteFile } from './tools/sandbox-write-file.tool';
26
+
27
+ @Module({
28
+ imports: [LoopCoreModule, SandboxToolModule],
29
+ providers: [
30
+ SandboxReadFile,
31
+ SandboxWriteFile,
32
+ SandboxListDirectory,
33
+ SandboxCreateDirectory,
34
+ SandboxDelete,
35
+ SandboxExists,
36
+ SandboxFileInfo,
37
+ ],
38
+ exports: [
39
+ SandboxReadFile,
40
+ SandboxWriteFile,
41
+ SandboxListDirectory,
42
+ SandboxCreateDirectory,
43
+ SandboxDelete,
44
+ SandboxExists,
45
+ SandboxFileInfo,
46
+ ],
47
+ })
48
+ export class SandboxFilesystemModule {}