@loopstack/sandbox-filesystem 0.3.0 → 0.4.1
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/README.md +31 -30
- package/dist/tools/sandbox-create-directory.tool.d.ts +5 -4
- package/dist/tools/sandbox-create-directory.tool.d.ts.map +1 -1
- package/dist/tools/sandbox-create-directory.tool.js +8 -5
- package/dist/tools/sandbox-create-directory.tool.js.map +1 -1
- package/dist/tools/sandbox-delete.tool.d.ts +5 -4
- package/dist/tools/sandbox-delete.tool.d.ts.map +1 -1
- package/dist/tools/sandbox-delete.tool.js +8 -5
- package/dist/tools/sandbox-delete.tool.js.map +1 -1
- package/dist/tools/sandbox-exists.tool.d.ts +5 -4
- package/dist/tools/sandbox-exists.tool.d.ts.map +1 -1
- package/dist/tools/sandbox-exists.tool.js +8 -5
- package/dist/tools/sandbox-exists.tool.js.map +1 -1
- package/dist/tools/sandbox-file-info.tool.d.ts +5 -4
- package/dist/tools/sandbox-file-info.tool.d.ts.map +1 -1
- package/dist/tools/sandbox-file-info.tool.js +8 -5
- package/dist/tools/sandbox-file-info.tool.js.map +1 -1
- package/dist/tools/sandbox-list-directory.tool.d.ts +5 -4
- package/dist/tools/sandbox-list-directory.tool.d.ts.map +1 -1
- package/dist/tools/sandbox-list-directory.tool.js +8 -5
- package/dist/tools/sandbox-list-directory.tool.js.map +1 -1
- package/dist/tools/sandbox-read-file.tool.d.ts +5 -4
- package/dist/tools/sandbox-read-file.tool.d.ts.map +1 -1
- package/dist/tools/sandbox-read-file.tool.js +8 -5
- package/dist/tools/sandbox-read-file.tool.js.map +1 -1
- package/dist/tools/sandbox-write-file.tool.d.ts +5 -4
- package/dist/tools/sandbox-write-file.tool.d.ts.map +1 -1
- package/dist/tools/sandbox-write-file.tool.js +8 -5
- package/dist/tools/sandbox-write-file.tool.js.map +1 -1
- package/package.json +3 -3
- package/src/tools/sandbox-create-directory.tool.ts +8 -10
- package/src/tools/sandbox-delete.tool.ts +8 -7
- package/src/tools/sandbox-exists.tool.ts +8 -7
- package/src/tools/sandbox-file-info.tool.ts +8 -7
- package/src/tools/sandbox-list-directory.tool.ts +8 -10
- package/src/tools/sandbox-read-file.tool.ts +8 -7
- package/src/tools/sandbox-write-file.tool.ts +8 -7
package/README.md
CHANGED
|
@@ -62,10 +62,8 @@ See here for more information about working with [Modules](https://loopstack.ai/
|
|
|
62
62
|
Inject the tools in your workflow class using the @InjectTool() decorator:
|
|
63
63
|
|
|
64
64
|
```typescript
|
|
65
|
-
import { Injectable } from '@nestjs/common';
|
|
66
65
|
import { z } from 'zod';
|
|
67
|
-
import {
|
|
68
|
-
import { WorkflowBase } from '@loopstack/core';
|
|
66
|
+
import { InjectTool, Input, State, Workflow } from '@loopstack/common';
|
|
69
67
|
import {
|
|
70
68
|
SandboxCreateDirectory,
|
|
71
69
|
SandboxDelete,
|
|
@@ -77,23 +75,26 @@ import {
|
|
|
77
75
|
} from '@loopstack/sandbox-filesystem';
|
|
78
76
|
import { SandboxDestroy, SandboxInit } from '@loopstack/sandbox-tool';
|
|
79
77
|
|
|
80
|
-
@
|
|
81
|
-
@BlockConfig({
|
|
78
|
+
@Workflow({
|
|
82
79
|
configFile: __dirname + '/my.workflow.yaml',
|
|
83
80
|
})
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
)
|
|
96
|
-
|
|
81
|
+
export class MyWorkflow {
|
|
82
|
+
@Input({
|
|
83
|
+
schema: z.object({
|
|
84
|
+
outputDir: z.string().default(process.cwd() + '/out'),
|
|
85
|
+
}),
|
|
86
|
+
})
|
|
87
|
+
args: { outputDir: string };
|
|
88
|
+
|
|
89
|
+
@State({
|
|
90
|
+
schema: z.object({
|
|
91
|
+
containerId: z.string().optional(),
|
|
92
|
+
fileContent: z.string().optional(),
|
|
93
|
+
fileList: z.array(z.any()).optional(),
|
|
94
|
+
}),
|
|
95
|
+
})
|
|
96
|
+
state: { containerId: string; fileContent: string; fileList: any[] };
|
|
97
|
+
|
|
97
98
|
// Sandbox lifecycle tools (from @loopstack/sandbox-tool)
|
|
98
99
|
@InjectTool() sandboxInit: SandboxInit;
|
|
99
100
|
@InjectTool() sandboxDestroy: SandboxDestroy;
|
|
@@ -124,10 +125,10 @@ transitions:
|
|
|
124
125
|
containerId: my-sandbox
|
|
125
126
|
imageName: node:18
|
|
126
127
|
containerName: my-filesystem-sandbox
|
|
127
|
-
projectOutPath: ${ args.outputDir }
|
|
128
|
+
projectOutPath: ${{ args.outputDir }}
|
|
128
129
|
rootPath: workspace
|
|
129
130
|
assign:
|
|
130
|
-
containerId: ${ result.data.containerId }
|
|
131
|
+
containerId: ${{ result.data.containerId }}
|
|
131
132
|
|
|
132
133
|
# Create a directory
|
|
133
134
|
- id: create_dir
|
|
@@ -136,7 +137,7 @@ transitions:
|
|
|
136
137
|
call:
|
|
137
138
|
- tool: sandboxCreateDirectory
|
|
138
139
|
args:
|
|
139
|
-
containerId: ${ containerId }
|
|
140
|
+
containerId: ${{ state.containerId }}
|
|
140
141
|
path: /workspace
|
|
141
142
|
recursive: true
|
|
142
143
|
|
|
@@ -147,7 +148,7 @@ transitions:
|
|
|
147
148
|
call:
|
|
148
149
|
- tool: sandboxWriteFile
|
|
149
150
|
args:
|
|
150
|
-
containerId: ${ containerId }
|
|
151
|
+
containerId: ${{ state.containerId }}
|
|
151
152
|
path: /workspace/result.txt
|
|
152
153
|
content: 'Hello from sandbox!'
|
|
153
154
|
encoding: utf8
|
|
@@ -160,11 +161,11 @@ transitions:
|
|
|
160
161
|
call:
|
|
161
162
|
- tool: sandboxReadFile
|
|
162
163
|
args:
|
|
163
|
-
containerId: ${ containerId }
|
|
164
|
+
containerId: ${{ state.containerId }}
|
|
164
165
|
path: /workspace/result.txt
|
|
165
166
|
encoding: utf8
|
|
166
167
|
assign:
|
|
167
|
-
fileContent: ${ result.data.content }
|
|
168
|
+
fileContent: ${{ result.data.content }}
|
|
168
169
|
|
|
169
170
|
# List directory contents
|
|
170
171
|
- id: list_dir
|
|
@@ -173,11 +174,11 @@ transitions:
|
|
|
173
174
|
call:
|
|
174
175
|
- tool: sandboxListDirectory
|
|
175
176
|
args:
|
|
176
|
-
containerId: ${ containerId }
|
|
177
|
+
containerId: ${{ state.containerId }}
|
|
177
178
|
path: /workspace
|
|
178
179
|
recursive: false
|
|
179
180
|
assign:
|
|
180
|
-
fileList: ${ result.data.entries }
|
|
181
|
+
fileList: ${{ result.data.entries }}
|
|
181
182
|
|
|
182
183
|
# Check file existence
|
|
183
184
|
- id: check_exists
|
|
@@ -186,7 +187,7 @@ transitions:
|
|
|
186
187
|
call:
|
|
187
188
|
- tool: sandboxExists
|
|
188
189
|
args:
|
|
189
|
-
containerId: ${ containerId }
|
|
190
|
+
containerId: ${{ state.containerId }}
|
|
190
191
|
path: /workspace/result.txt
|
|
191
192
|
|
|
192
193
|
# Get file info
|
|
@@ -196,7 +197,7 @@ transitions:
|
|
|
196
197
|
call:
|
|
197
198
|
- tool: sandboxFileInfo
|
|
198
199
|
args:
|
|
199
|
-
containerId: ${ containerId }
|
|
200
|
+
containerId: ${{ state.containerId }}
|
|
200
201
|
path: /workspace/result.txt
|
|
201
202
|
|
|
202
203
|
# Delete the file
|
|
@@ -206,7 +207,7 @@ transitions:
|
|
|
206
207
|
call:
|
|
207
208
|
- tool: sandboxDelete
|
|
208
209
|
args:
|
|
209
|
-
containerId: ${ containerId }
|
|
210
|
+
containerId: ${{ state.containerId }}
|
|
210
211
|
path: /workspace/result.txt
|
|
211
212
|
force: true
|
|
212
213
|
|
|
@@ -217,7 +218,7 @@ transitions:
|
|
|
217
218
|
call:
|
|
218
219
|
- tool: sandboxDestroy
|
|
219
220
|
args:
|
|
220
|
-
containerId: ${ containerId }
|
|
221
|
+
containerId: ${{ state.containerId }}
|
|
221
222
|
removeContainer: true
|
|
222
223
|
```
|
|
223
224
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ToolInterface, ToolResult
|
|
3
|
-
declare const
|
|
2
|
+
import { ToolInterface, ToolResult } from '@loopstack/common';
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
4
|
containerId: z.ZodString;
|
|
5
5
|
path: z.ZodString;
|
|
6
6
|
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
7
7
|
}, z.core.$strict>;
|
|
8
|
-
type SandboxCreateDirectoryArgs = z.infer<typeof
|
|
8
|
+
type SandboxCreateDirectoryArgs = z.infer<typeof inputSchema>;
|
|
9
9
|
interface SandboxCreateDirectoryResult {
|
|
10
10
|
path: string;
|
|
11
11
|
created: boolean;
|
|
@@ -13,7 +13,8 @@ interface SandboxCreateDirectoryResult {
|
|
|
13
13
|
export declare class SandboxCreateDirectory implements ToolInterface<SandboxCreateDirectoryArgs> {
|
|
14
14
|
private readonly logger;
|
|
15
15
|
private sandboxCommand;
|
|
16
|
-
|
|
16
|
+
args: SandboxCreateDirectoryArgs;
|
|
17
|
+
execute(args: SandboxCreateDirectoryArgs): Promise<ToolResult<SandboxCreateDirectoryResult>>;
|
|
17
18
|
}
|
|
18
19
|
export {};
|
|
19
20
|
//# sourceMappingURL=sandbox-create-directory.tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-create-directory.tool.d.ts","sourceRoot":"","sources":["../../src/tools/sandbox-create-directory.tool.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"sandbox-create-directory.tool.d.ts","sourceRoot":"","sources":["../../src/tools/sandbox-create-directory.tool.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA2B,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,QAAA,MAAM,WAAW;;;;kBAMN,CAAC;AAEZ,KAAK,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE9D,UAAU,4BAA4B;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qBAKa,sBAAuB,YAAW,aAAa,CAAC,0BAA0B,CAAC;IACtF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAEpD,OAAO,CAAC,cAAc,CAAiB;IAGrD,IAAI,EAAE,0BAA0B,CAAC;IAE3B,OAAO,CAAC,IAAI,EAAE,0BAA0B,GAAG,OAAO,CAAC,UAAU,CAAC,4BAA4B,CAAC,CAAC;CAyCnG"}
|
|
@@ -15,7 +15,7 @@ const common_1 = require("@nestjs/common");
|
|
|
15
15
|
const zod_1 = require("zod");
|
|
16
16
|
const common_2 = require("@loopstack/common");
|
|
17
17
|
const sandbox_tool_1 = require("@loopstack/sandbox-tool");
|
|
18
|
-
const
|
|
18
|
+
const inputSchema = zod_1.z
|
|
19
19
|
.object({
|
|
20
20
|
containerId: zod_1.z.string().describe('The ID of the container to create the directory in'),
|
|
21
21
|
path: zod_1.z.string().describe('The path of the directory to create'),
|
|
@@ -25,7 +25,8 @@ const propertiesSchema = zod_1.z
|
|
|
25
25
|
let SandboxCreateDirectory = SandboxCreateDirectory_1 = class SandboxCreateDirectory {
|
|
26
26
|
logger = new common_1.Logger(SandboxCreateDirectory_1.name);
|
|
27
27
|
sandboxCommand;
|
|
28
|
-
|
|
28
|
+
args;
|
|
29
|
+
async execute(args) {
|
|
29
30
|
const { containerId, path: dirPath, recursive } = args;
|
|
30
31
|
this.logger.debug(`Creating directory ${dirPath} in container ${containerId} (recursive: ${recursive})`);
|
|
31
32
|
const mkdirArgs = recursive ? ['-p', dirPath] : [dirPath];
|
|
@@ -64,13 +65,15 @@ __decorate([
|
|
|
64
65
|
(0, common_2.InjectTool)(),
|
|
65
66
|
__metadata("design:type", sandbox_tool_1.SandboxCommand)
|
|
66
67
|
], SandboxCreateDirectory.prototype, "sandboxCommand", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
(0, common_2.Input)({ schema: inputSchema }),
|
|
70
|
+
__metadata("design:type", Object)
|
|
71
|
+
], SandboxCreateDirectory.prototype, "args", void 0);
|
|
67
72
|
exports.SandboxCreateDirectory = SandboxCreateDirectory = SandboxCreateDirectory_1 = __decorate([
|
|
68
|
-
(0, common_1.Injectable)(),
|
|
69
73
|
(0, common_2.Tool)({
|
|
70
74
|
config: {
|
|
71
75
|
description: 'Create a directory in a sandbox container',
|
|
72
76
|
},
|
|
73
|
-
})
|
|
74
|
-
(0, common_2.WithArguments)(propertiesSchema)
|
|
77
|
+
})
|
|
75
78
|
], SandboxCreateDirectory);
|
|
76
79
|
//# sourceMappingURL=sandbox-create-directory.tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-create-directory.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-create-directory.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,
|
|
1
|
+
{"version":3,"file":"sandbox-create-directory.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-create-directory.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,2CAAwC;AACxC,6BAAwB;AACxB,8CAAuF;AACvF,0DAAyD;AAEzD,MAAM,WAAW,GAAG,OAAC;KAClB,MAAM,CAAC;IACN,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oDAAoD,CAAC;IACtF,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;IAChE,SAAS,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,0DAA0D,CAAC;CAC1G,CAAC;KACD,MAAM,EAAE,CAAC;AAcL,IAAM,sBAAsB,8BAA5B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AM,IAAI,KAAK,CAAC,8BAA8B,OAAO,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,eAAe,EAAE,CAAC,CAAC;QACrG,CAAC;QAED,IAAI,aAAa,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,OAAO,iBAAiB,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,kCAAkC,OAAO,iBAAiB,WAAW,EAAE,CAAC,CAAC;QAC3F,CAAC;QAED,OAAO;YACL,IAAI,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,CAAC;aACpC;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAjDY,wDAAsB;AAGX;IAArB,IAAA,mBAAU,GAAE;8BAAyB,6BAAc;8DAAC;AAGrD;IADC,IAAA,cAAK,EAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;;oDACE;iCANtB,sBAAsB;IALlC,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EAAE,2CAA2C;SACzD;KACF,CAAC;GACW,sBAAsB,CAiDlC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ToolInterface, ToolResult
|
|
3
|
-
declare const
|
|
2
|
+
import { ToolInterface, ToolResult } from '@loopstack/common';
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
4
|
containerId: z.ZodString;
|
|
5
5
|
path: z.ZodString;
|
|
6
6
|
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
7
7
|
force: z.ZodDefault<z.ZodBoolean>;
|
|
8
8
|
}, z.core.$strict>;
|
|
9
|
-
type SandboxDeleteArgs = z.infer<typeof
|
|
9
|
+
type SandboxDeleteArgs = z.infer<typeof inputSchema>;
|
|
10
10
|
interface SandboxDeleteResult {
|
|
11
11
|
path: string;
|
|
12
12
|
deleted: boolean;
|
|
@@ -14,7 +14,8 @@ interface SandboxDeleteResult {
|
|
|
14
14
|
export declare class SandboxDelete implements ToolInterface<SandboxDeleteArgs> {
|
|
15
15
|
private readonly logger;
|
|
16
16
|
private sandboxCommand;
|
|
17
|
-
|
|
17
|
+
args: SandboxDeleteArgs;
|
|
18
|
+
execute(args: SandboxDeleteArgs): Promise<ToolResult<SandboxDeleteResult>>;
|
|
18
19
|
}
|
|
19
20
|
export {};
|
|
20
21
|
//# sourceMappingURL=sandbox-delete.tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-delete.tool.d.ts","sourceRoot":"","sources":["../../src/tools/sandbox-delete.tool.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"sandbox-delete.tool.d.ts","sourceRoot":"","sources":["../../src/tools/sandbox-delete.tool.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA2B,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,QAAA,MAAM,WAAW;;;;;kBAON,CAAC;AAEZ,KAAK,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAErD,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qBAKa,aAAc,YAAW,aAAa,CAAC,iBAAiB,CAAC;IACpE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkC;IAE3C,OAAO,CAAC,cAAc,CAAiB;IAGrD,IAAI,EAAE,iBAAiB,CAAC;IAElB,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;CAqCjF"}
|
|
@@ -15,7 +15,7 @@ const common_1 = require("@nestjs/common");
|
|
|
15
15
|
const zod_1 = require("zod");
|
|
16
16
|
const common_2 = require("@loopstack/common");
|
|
17
17
|
const sandbox_tool_1 = require("@loopstack/sandbox-tool");
|
|
18
|
-
const
|
|
18
|
+
const inputSchema = zod_1.z
|
|
19
19
|
.object({
|
|
20
20
|
containerId: zod_1.z.string().describe('The ID of the container to delete the file/directory from'),
|
|
21
21
|
path: zod_1.z.string().describe('The path to the file or directory to delete'),
|
|
@@ -26,7 +26,8 @@ const propertiesSchema = zod_1.z
|
|
|
26
26
|
let SandboxDelete = SandboxDelete_1 = class SandboxDelete {
|
|
27
27
|
logger = new common_1.Logger(SandboxDelete_1.name);
|
|
28
28
|
sandboxCommand;
|
|
29
|
-
|
|
29
|
+
args;
|
|
30
|
+
async execute(args) {
|
|
30
31
|
const { containerId, path: targetPath, recursive, force } = args;
|
|
31
32
|
this.logger.debug(`Deleting ${targetPath} in container ${containerId} (recursive: ${recursive}, force: ${force})`);
|
|
32
33
|
const rmArgs = [];
|
|
@@ -64,13 +65,15 @@ __decorate([
|
|
|
64
65
|
(0, common_2.InjectTool)(),
|
|
65
66
|
__metadata("design:type", sandbox_tool_1.SandboxCommand)
|
|
66
67
|
], SandboxDelete.prototype, "sandboxCommand", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
(0, common_2.Input)({ schema: inputSchema }),
|
|
70
|
+
__metadata("design:type", Object)
|
|
71
|
+
], SandboxDelete.prototype, "args", void 0);
|
|
67
72
|
exports.SandboxDelete = SandboxDelete = SandboxDelete_1 = __decorate([
|
|
68
|
-
(0, common_1.Injectable)(),
|
|
69
73
|
(0, common_2.Tool)({
|
|
70
74
|
config: {
|
|
71
75
|
description: 'Delete a file or directory in a sandbox container',
|
|
72
76
|
},
|
|
73
|
-
})
|
|
74
|
-
(0, common_2.WithArguments)(propertiesSchema)
|
|
77
|
+
})
|
|
75
78
|
], SandboxDelete);
|
|
76
79
|
//# sourceMappingURL=sandbox-delete.tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-delete.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-delete.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,
|
|
1
|
+
{"version":3,"file":"sandbox-delete.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-delete.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,2CAAwC;AACxC,6BAAwB;AACxB,8CAAuF;AACvF,0DAAyD;AAEzD,MAAM,WAAW,GAAG,OAAC;KAClB,MAAM,CAAC;IACN,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2DAA2D,CAAC;IAC7F,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC;IACxE,SAAS,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,8DAA8D,CAAC;IAC9G,KAAK,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,8DAA8D,CAAC;CAC3G,CAAC;KACD,MAAM,EAAE,CAAC;AAcL,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACP,MAAM,GAAG,IAAI,eAAM,CAAC,eAAa,CAAC,IAAI,CAAC,CAAC;IAEnC,cAAc,CAAiB;IAGrD,IAAI,CAAoB;IAExB,KAAK,CAAC,OAAO,CAAC,IAAuB;QACnC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAEjE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,UAAU,iBAAiB,WAAW,gBAAgB,SAAS,YAAY,KAAK,GAAG,CAAC,CAAC;QAEnH,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,IAAI,SAAS;YAAE,MAAM,CAAC,IAAI,CAAC,I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,MAAM,EAAE;YACN,WAAW,EAAE,mDAAmD;SACjE;KACF,CAAC;GACW,aAAa,CA6CzB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ToolInterface, ToolResult
|
|
3
|
-
declare const
|
|
2
|
+
import { ToolInterface, ToolResult } from '@loopstack/common';
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
4
|
containerId: z.ZodString;
|
|
5
5
|
path: z.ZodString;
|
|
6
6
|
}, z.core.$strict>;
|
|
7
|
-
type SandboxExistsArgs = z.infer<typeof
|
|
7
|
+
type SandboxExistsArgs = z.infer<typeof inputSchema>;
|
|
8
8
|
interface SandboxExistsResult {
|
|
9
9
|
path: string;
|
|
10
10
|
exists: boolean;
|
|
@@ -13,7 +13,8 @@ interface SandboxExistsResult {
|
|
|
13
13
|
export declare class SandboxExists implements ToolInterface<SandboxExistsArgs> {
|
|
14
14
|
private readonly logger;
|
|
15
15
|
private sandboxCommand;
|
|
16
|
-
|
|
16
|
+
args: SandboxExistsArgs;
|
|
17
|
+
execute(args: SandboxExistsArgs): Promise<ToolResult<SandboxExistsResult>>;
|
|
17
18
|
private parseFileType;
|
|
18
19
|
}
|
|
19
20
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-exists.tool.d.ts","sourceRoot":"","sources":["../../src/tools/sandbox-exists.tool.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"sandbox-exists.tool.d.ts","sourceRoot":"","sources":["../../src/tools/sandbox-exists.tool.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA2B,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,QAAA,MAAM,WAAW;;;kBAKN,CAAC;AAEZ,KAAK,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAErD,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,IAAI,CAAC;CACzD;AAED,qBAKa,aAAc,YAAW,aAAa,CAAC,iBAAiB,CAAC;IACpE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkC;IAGzD,OAAO,CAAC,cAAc,CAAiB;IAGvC,IAAI,EAAE,iBAAiB,CAAC;IAElB,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;IA8ChF,OAAO,CAAC,aAAa;CAOtB"}
|
|
@@ -15,7 +15,7 @@ const common_1 = require("@nestjs/common");
|
|
|
15
15
|
const zod_1 = require("zod");
|
|
16
16
|
const common_2 = require("@loopstack/common");
|
|
17
17
|
const sandbox_tool_1 = require("@loopstack/sandbox-tool");
|
|
18
|
-
const
|
|
18
|
+
const inputSchema = zod_1.z
|
|
19
19
|
.object({
|
|
20
20
|
containerId: zod_1.z.string().describe('The ID of the container to check for file existence'),
|
|
21
21
|
path: zod_1.z.string().describe('The path to check for existence'),
|
|
@@ -24,7 +24,8 @@ const propertiesSchema = zod_1.z
|
|
|
24
24
|
let SandboxExists = SandboxExists_1 = class SandboxExists {
|
|
25
25
|
logger = new common_1.Logger(SandboxExists_1.name);
|
|
26
26
|
sandboxCommand;
|
|
27
|
-
|
|
27
|
+
args;
|
|
28
|
+
async execute(args) {
|
|
28
29
|
const { containerId, path: targetPath } = args;
|
|
29
30
|
this.logger.debug(`Checking existence of ${targetPath} in container ${containerId}`);
|
|
30
31
|
const result = await this.sandboxCommand.execute({
|
|
@@ -76,13 +77,15 @@ __decorate([
|
|
|
76
77
|
(0, common_2.InjectTool)(),
|
|
77
78
|
__metadata("design:type", sandbox_tool_1.SandboxCommand)
|
|
78
79
|
], SandboxExists.prototype, "sandboxCommand", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, common_2.Input)({ schema: inputSchema }),
|
|
82
|
+
__metadata("design:type", Object)
|
|
83
|
+
], SandboxExists.prototype, "args", void 0);
|
|
79
84
|
exports.SandboxExists = SandboxExists = SandboxExists_1 = __decorate([
|
|
80
|
-
(0, common_1.Injectable)(),
|
|
81
85
|
(0, common_2.Tool)({
|
|
82
86
|
config: {
|
|
83
87
|
description: 'Check if a file or directory exists in a sandbox container',
|
|
84
88
|
},
|
|
85
|
-
})
|
|
86
|
-
(0, common_2.WithArguments)(propertiesSchema)
|
|
89
|
+
})
|
|
87
90
|
], SandboxExists);
|
|
88
91
|
//# sourceMappingURL=sandbox-exists.tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-exists.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-exists.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,
|
|
1
|
+
{"version":3,"file":"sandbox-exists.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-exists.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,2CAAwC;AACxC,6BAAwB;AACxB,8CAAuF;AACvF,0DAAyD;AAEzD,MAAM,WAAW,GAAG,OAAC;KAClB,MAAM,CAAC;IACN,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qDAAqD,CAAC;IACvF,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;CAC7D,CAAC;KACD,MAAM,EAAE,CAAC;AAeL,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACP,MAAM,GAAG,IAAI,eAAM,CAAC,eAAa,CAAC,IAAI,CAAC,CAAC;IAGjD,cAAc,CAAiB;IAGvC,IAAI,CAAoB;IAExB,KAAK,CAAC,OAAO,CAAC,IAAuB;QACnC,MAAM,EAAE,WA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M,CAAC,CAAC;QACpC,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,UAAU,YAAY,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAE5F,OAAO;YACL,IAAI,EAAE;gBACJ,IAAI,EAAE,UAAU;gBAChB,MAAM;gBACN,IAAI;aACL;SACF,CAAC;IACJ,CAAC;IAEO,aAAa,CAAC,UAAkB;QACtC,MAAM,KAAK,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;QACvC,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC;YAAE,OAAO,MAAM,CAAC;QAC7C,IAAI,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC;YAAE,OAAO,WAAW,CAAC;QACpD,IAAI,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC;YAAE,OAAO,SAAS,CAAC;QACtD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AA9DY,sCAAa;AAIhB;IADP,IAAA,mBAAU,GAAE;8BACW,6BAAc;qDAAC;AAGvC;IADC,IAAA,cAAK,EAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;;2CACP;wBAPb,aAAa;IALzB,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EAAE,4DAA4D;SAC1E;KACF,CAAC;GACW,aAAa,CA8DzB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ToolInterface, ToolResult
|
|
3
|
-
declare const
|
|
2
|
+
import { ToolInterface, ToolResult } from '@loopstack/common';
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
4
|
containerId: z.ZodString;
|
|
5
5
|
path: z.ZodString;
|
|
6
6
|
}, z.core.$strict>;
|
|
7
|
-
type SandboxFileInfoArgs = z.infer<typeof
|
|
7
|
+
type SandboxFileInfoArgs = z.infer<typeof inputSchema>;
|
|
8
8
|
interface SandboxFileInfoResult {
|
|
9
9
|
path: string;
|
|
10
10
|
name: string;
|
|
@@ -20,7 +20,8 @@ interface SandboxFileInfoResult {
|
|
|
20
20
|
export declare class SandboxFileInfo implements ToolInterface<SandboxFileInfoArgs> {
|
|
21
21
|
private readonly logger;
|
|
22
22
|
private sandboxCommand;
|
|
23
|
-
|
|
23
|
+
args: SandboxFileInfoArgs;
|
|
24
|
+
execute(args: SandboxFileInfoArgs): Promise<ToolResult<SandboxFileInfoResult>>;
|
|
24
25
|
private parseFileType;
|
|
25
26
|
}
|
|
26
27
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-file-info.tool.d.ts","sourceRoot":"","sources":["../../src/tools/sandbox-file-info.tool.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"sandbox-file-info.tool.d.ts","sourceRoot":"","sources":["../../src/tools/sandbox-file-info.tool.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA2B,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,QAAA,MAAM,WAAW;;;kBAKN,CAAC;AAEZ,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEvD,UAAU,qBAAqB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAKa,eAAgB,YAAW,aAAa,CAAC,mBAAmB,CAAC;IACxE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAE7C,OAAO,CAAC,cAAc,CAAiB;IAGrD,IAAI,EAAE,mBAAmB,CAAC;IAEpB,OAAO,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;IAwDpF,OAAO,CAAC,aAAa;CAOtB"}
|
|
@@ -15,7 +15,7 @@ const common_1 = require("@nestjs/common");
|
|
|
15
15
|
const zod_1 = require("zod");
|
|
16
16
|
const common_2 = require("@loopstack/common");
|
|
17
17
|
const sandbox_tool_1 = require("@loopstack/sandbox-tool");
|
|
18
|
-
const
|
|
18
|
+
const inputSchema = zod_1.z
|
|
19
19
|
.object({
|
|
20
20
|
containerId: zod_1.z.string().describe('The ID of the container to get file info from'),
|
|
21
21
|
path: zod_1.z.string().describe('The path to the file or directory'),
|
|
@@ -24,7 +24,8 @@ const propertiesSchema = zod_1.z
|
|
|
24
24
|
let SandboxFileInfo = SandboxFileInfo_1 = class SandboxFileInfo {
|
|
25
25
|
logger = new common_1.Logger(SandboxFileInfo_1.name);
|
|
26
26
|
sandboxCommand;
|
|
27
|
-
|
|
27
|
+
args;
|
|
28
|
+
async execute(args) {
|
|
28
29
|
const { containerId, path: targetPath } = args;
|
|
29
30
|
this.logger.debug(`Getting file info for ${targetPath} in container ${containerId}`);
|
|
30
31
|
const result = await this.sandboxCommand.execute({
|
|
@@ -83,13 +84,15 @@ __decorate([
|
|
|
83
84
|
(0, common_2.InjectTool)(),
|
|
84
85
|
__metadata("design:type", sandbox_tool_1.SandboxCommand)
|
|
85
86
|
], SandboxFileInfo.prototype, "sandboxCommand", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, common_2.Input)({ schema: inputSchema }),
|
|
89
|
+
__metadata("design:type", Object)
|
|
90
|
+
], SandboxFileInfo.prototype, "args", void 0);
|
|
86
91
|
exports.SandboxFileInfo = SandboxFileInfo = SandboxFileInfo_1 = __decorate([
|
|
87
|
-
(0, common_1.Injectable)(),
|
|
88
92
|
(0, common_2.Tool)({
|
|
89
93
|
config: {
|
|
90
94
|
description: 'Get detailed information about a file or directory in a sandbox container',
|
|
91
95
|
},
|
|
92
|
-
})
|
|
93
|
-
(0, common_2.WithArguments)(propertiesSchema)
|
|
96
|
+
})
|
|
94
97
|
], SandboxFileInfo);
|
|
95
98
|
//# sourceMappingURL=sandbox-file-info.tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-file-info.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-file-info.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,
|
|
1
|
+
{"version":3,"file":"sandbox-file-info.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-file-info.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,2CAAwC;AACxC,6BAAwB;AACxB,8CAAuF;AACvF,0DAAyD;AAEzD,MAAM,WAAW,GAAG,OAAC;KAClB,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,MAAM,EAAE,CAAC;AAsBL,IAAM,eAAe,uBAArB,MAAM,eAAe;IACT,MAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;IAErC,cAAc,CAAiB;IAGrD,IAAI,CAAsB;IAE1B,KAAK,CAAC,OAAO,CAAC,IAAyB;QACrC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAE/C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,UAAU,iBAAiB,WAAW,EAAE,CAAC,CAAC;Q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@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ToolInterface, ToolResult
|
|
3
|
-
declare const
|
|
2
|
+
import { ToolInterface, ToolResult } from '@loopstack/common';
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
4
|
containerId: z.ZodString;
|
|
5
5
|
path: z.ZodString;
|
|
6
6
|
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
7
7
|
}, z.core.$strict>;
|
|
8
|
-
type SandboxListDirectoryArgs = z.infer<typeof
|
|
8
|
+
type SandboxListDirectoryArgs = z.infer<typeof inputSchema>;
|
|
9
9
|
interface FileEntry {
|
|
10
10
|
name: string;
|
|
11
11
|
type: 'file' | 'directory' | 'symlink' | 'other';
|
|
@@ -19,7 +19,8 @@ interface SandboxListDirectoryResult {
|
|
|
19
19
|
export declare class SandboxListDirectory implements ToolInterface<SandboxListDirectoryArgs> {
|
|
20
20
|
private readonly logger;
|
|
21
21
|
private sandboxCommand;
|
|
22
|
-
|
|
22
|
+
args: SandboxListDirectoryArgs;
|
|
23
|
+
execute(args: SandboxListDirectoryArgs): Promise<ToolResult<SandboxListDirectoryResult>>;
|
|
23
24
|
private parseFileType;
|
|
24
25
|
}
|
|
25
26
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-list-directory.tool.d.ts","sourceRoot":"","sources":["../../src/tools/sandbox-list-directory.tool.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"sandbox-list-directory.tool.d.ts","sourceRoot":"","sources":["../../src/tools/sandbox-list-directory.tool.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA2B,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,QAAA,MAAM,WAAW;;;;kBAMN,CAAC;AAEZ,KAAK,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE5D,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,0BAA0B;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB;AAED,qBAKa,oBAAqB,YAAW,aAAa,CAAC,wBAAwB,CAAC;IAClF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;IAElD,OAAO,CAAC,cAAc,CAAiB;IAGrD,IAAI,EAAE,wBAAwB,CAAC;IAEzB,OAAO,CAAC,IAAI,EAAE,wBAAwB,GAAG,OAAO,CAAC,UAAU,CAAC,0BAA0B,CAAC,CAAC;IA4D9F,OAAO,CAAC,aAAa;CAYtB"}
|
|
@@ -15,7 +15,7 @@ const common_1 = require("@nestjs/common");
|
|
|
15
15
|
const zod_1 = require("zod");
|
|
16
16
|
const common_2 = require("@loopstack/common");
|
|
17
17
|
const sandbox_tool_1 = require("@loopstack/sandbox-tool");
|
|
18
|
-
const
|
|
18
|
+
const inputSchema = zod_1.z
|
|
19
19
|
.object({
|
|
20
20
|
containerId: zod_1.z.string().describe('The ID of the container to list the directory from'),
|
|
21
21
|
path: zod_1.z.string().describe('The path to the directory to list'),
|
|
@@ -25,7 +25,8 @@ const propertiesSchema = zod_1.z
|
|
|
25
25
|
let SandboxListDirectory = SandboxListDirectory_1 = class SandboxListDirectory {
|
|
26
26
|
logger = new common_1.Logger(SandboxListDirectory_1.name);
|
|
27
27
|
sandboxCommand;
|
|
28
|
-
|
|
28
|
+
args;
|
|
29
|
+
async execute(args) {
|
|
29
30
|
const { containerId, path: dirPath, recursive } = args;
|
|
30
31
|
this.logger.debug(`Listing directory ${dirPath} in container ${containerId} (recursive: ${recursive})`);
|
|
31
32
|
const command = recursive
|
|
@@ -89,13 +90,15 @@ __decorate([
|
|
|
89
90
|
(0, common_2.InjectTool)(),
|
|
90
91
|
__metadata("design:type", sandbox_tool_1.SandboxCommand)
|
|
91
92
|
], SandboxListDirectory.prototype, "sandboxCommand", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, common_2.Input)({ schema: inputSchema }),
|
|
95
|
+
__metadata("design:type", Object)
|
|
96
|
+
], SandboxListDirectory.prototype, "args", void 0);
|
|
92
97
|
exports.SandboxListDirectory = SandboxListDirectory = SandboxListDirectory_1 = __decorate([
|
|
93
|
-
(0, common_1.Injectable)(),
|
|
94
98
|
(0, common_2.Tool)({
|
|
95
99
|
config: {
|
|
96
100
|
description: 'List files and directories in a sandbox container',
|
|
97
101
|
},
|
|
98
|
-
})
|
|
99
|
-
(0, common_2.WithArguments)(propertiesSchema)
|
|
102
|
+
})
|
|
100
103
|
], SandboxListDirectory);
|
|
101
104
|
//# sourceMappingURL=sandbox-list-directory.tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-list-directory.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-list-directory.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,
|
|
1
|
+
{"version":3,"file":"sandbox-list-directory.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-list-directory.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,2CAAwC;AACxC,6BAAwB;AACxB,8CAAuF;AACvF,0DAAyD;AAEzD,MAAM,WAAW,GAAG,OAAC;KAClB,MAAM,CAAC;IACN,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oDAAoD,CAAC;IACtF,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IAC9D,SAAS,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAA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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;AAGT;IAArB,IAAA,mBAAU,GAAE;8BAAyB,6BAAc;4DAAC;AAGrD;IADC,IAAA,cAAK,EAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;;kDACA;+BANpB,oBAAoB;IALhC,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EAAE,mDAAmD;SACjE;KACF,CAAC;GACW,oBAAoB,CAgFhC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ToolInterface, ToolResult
|
|
3
|
-
declare const
|
|
2
|
+
import { ToolInterface, ToolResult } from '@loopstack/common';
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
4
|
containerId: z.ZodString;
|
|
5
5
|
path: z.ZodString;
|
|
6
6
|
encoding: z.ZodDefault<z.ZodEnum<{
|
|
@@ -8,7 +8,7 @@ declare const propertiesSchema: z.ZodObject<{
|
|
|
8
8
|
base64: "base64";
|
|
9
9
|
}>>;
|
|
10
10
|
}, z.core.$strict>;
|
|
11
|
-
type SandboxReadFileArgs = z.infer<typeof
|
|
11
|
+
type SandboxReadFileArgs = z.infer<typeof inputSchema>;
|
|
12
12
|
interface SandboxReadFileResult {
|
|
13
13
|
content: string;
|
|
14
14
|
encoding: string;
|
|
@@ -16,7 +16,8 @@ interface SandboxReadFileResult {
|
|
|
16
16
|
export declare class SandboxReadFile implements ToolInterface<SandboxReadFileArgs> {
|
|
17
17
|
private readonly logger;
|
|
18
18
|
private sandboxCommand;
|
|
19
|
-
|
|
19
|
+
args: SandboxReadFileArgs;
|
|
20
|
+
execute(args: SandboxReadFileArgs): Promise<ToolResult<SandboxReadFileResult>>;
|
|
20
21
|
}
|
|
21
22
|
export {};
|
|
22
23
|
//# sourceMappingURL=sandbox-read-file.tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-read-file.tool.d.ts","sourceRoot":"","sources":["../../src/tools/sandbox-read-file.tool.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"sandbox-read-file.tool.d.ts","sourceRoot":"","sources":["../../src/tools/sandbox-read-file.tool.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA2B,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,QAAA,MAAM,WAAW;;;;;;;kBAMN,CAAC;AAEZ,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEvD,UAAU,qBAAqB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qBAKa,eAAgB,YAAW,aAAa,CAAC,mBAAmB,CAAC;IACxE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAE7C,OAAO,CAAC,cAAc,CAAiB;IAGrD,IAAI,EAAE,mBAAmB,CAAC;IAEpB,OAAO,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;CAiCrF"}
|
|
@@ -15,7 +15,7 @@ const common_1 = require("@nestjs/common");
|
|
|
15
15
|
const zod_1 = require("zod");
|
|
16
16
|
const common_2 = require("@loopstack/common");
|
|
17
17
|
const sandbox_tool_1 = require("@loopstack/sandbox-tool");
|
|
18
|
-
const
|
|
18
|
+
const inputSchema = zod_1.z
|
|
19
19
|
.object({
|
|
20
20
|
containerId: zod_1.z.string().describe('The ID of the container to read the file from'),
|
|
21
21
|
path: zod_1.z.string().describe('The path to the file to read'),
|
|
@@ -25,7 +25,8 @@ const propertiesSchema = zod_1.z
|
|
|
25
25
|
let SandboxReadFile = SandboxReadFile_1 = class SandboxReadFile {
|
|
26
26
|
logger = new common_1.Logger(SandboxReadFile_1.name);
|
|
27
27
|
sandboxCommand;
|
|
28
|
-
|
|
28
|
+
args;
|
|
29
|
+
async execute(args) {
|
|
29
30
|
const { containerId, path, encoding } = args;
|
|
30
31
|
this.logger.debug(`Reading file ${path} from container ${containerId} (encoding: ${encoding})`);
|
|
31
32
|
const executable = encoding === 'base64' ? 'base64' : 'cat';
|
|
@@ -58,13 +59,15 @@ __decorate([
|
|
|
58
59
|
(0, common_2.InjectTool)(),
|
|
59
60
|
__metadata("design:type", sandbox_tool_1.SandboxCommand)
|
|
60
61
|
], SandboxReadFile.prototype, "sandboxCommand", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, common_2.Input)({ schema: inputSchema }),
|
|
64
|
+
__metadata("design:type", Object)
|
|
65
|
+
], SandboxReadFile.prototype, "args", void 0);
|
|
61
66
|
exports.SandboxReadFile = SandboxReadFile = SandboxReadFile_1 = __decorate([
|
|
62
|
-
(0, common_1.Injectable)(),
|
|
63
67
|
(0, common_2.Tool)({
|
|
64
68
|
config: {
|
|
65
69
|
description: 'Read file contents from a sandbox container',
|
|
66
70
|
},
|
|
67
|
-
})
|
|
68
|
-
(0, common_2.WithArguments)(propertiesSchema)
|
|
71
|
+
})
|
|
69
72
|
], SandboxReadFile);
|
|
70
73
|
//# sourceMappingURL=sandbox-read-file.tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-read-file.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-read-file.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,
|
|
1
|
+
{"version":3,"file":"sandbox-read-file.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-read-file.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAeA,2CAAwC;AACx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AuB,IAAI,kBAAkB,CAAC,CAAC;QACjE,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,eAAe,EAAE,CAAC,CAAC;YAC3F,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,eAAe,EAAE,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;AAzCY,0CAAe;AAGJ;IAArB,IAAA,mBAAU,GAAE;8BAAyB,6BAAc;uDAAC;AAGrD;IADC,IAAA,cAAK,EAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;;6CACL;0BANf,eAAe;IAL3B,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EAAE,6CAA6C;SAC3D;KACF,CAAC;GACW,eAAe,CAyC3B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ToolInterface, ToolResult
|
|
3
|
-
declare const
|
|
2
|
+
import { ToolInterface, ToolResult } from '@loopstack/common';
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
4
|
containerId: z.ZodString;
|
|
5
5
|
path: z.ZodString;
|
|
6
6
|
content: z.ZodString;
|
|
@@ -10,7 +10,7 @@ declare const propertiesSchema: z.ZodObject<{
|
|
|
10
10
|
}>>;
|
|
11
11
|
createParentDirs: z.ZodDefault<z.ZodBoolean>;
|
|
12
12
|
}, z.core.$strict>;
|
|
13
|
-
type SandboxWriteFileArgs = z.infer<typeof
|
|
13
|
+
type SandboxWriteFileArgs = z.infer<typeof inputSchema>;
|
|
14
14
|
interface SandboxWriteFileResult {
|
|
15
15
|
path: string;
|
|
16
16
|
bytesWritten: number;
|
|
@@ -18,7 +18,8 @@ interface SandboxWriteFileResult {
|
|
|
18
18
|
export declare class SandboxWriteFile implements ToolInterface<SandboxWriteFileArgs> {
|
|
19
19
|
private readonly logger;
|
|
20
20
|
private sandboxCommand;
|
|
21
|
-
|
|
21
|
+
args: SandboxWriteFileArgs;
|
|
22
|
+
execute(args: SandboxWriteFileArgs): Promise<ToolResult<SandboxWriteFileResult>>;
|
|
22
23
|
}
|
|
23
24
|
export {};
|
|
24
25
|
//# sourceMappingURL=sandbox-write-file.tool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-write-file.tool.d.ts","sourceRoot":"","sources":["../../src/tools/sandbox-write-file.tool.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"sandbox-write-file.tool.d.ts","sourceRoot":"","sources":["../../src/tools/sandbox-write-file.tool.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA2B,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvF,QAAA,MAAM,WAAW;;;;;;;;;kBAQN,CAAC;AAEZ,KAAK,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAExD,UAAU,sBAAsB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,qBAKa,gBAAiB,YAAW,aAAa,CAAC,oBAAoB,CAAC;IAC1E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqC;IAE9C,OAAO,CAAC,cAAc,CAAiB;IAGrD,IAAI,EAAE,oBAAoB,CAAC;IAErB,OAAO,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC;CAqEvF"}
|
|
@@ -49,7 +49,7 @@ const path = __importStar(require("path"));
|
|
|
49
49
|
const zod_1 = require("zod");
|
|
50
50
|
const common_2 = require("@loopstack/common");
|
|
51
51
|
const sandbox_tool_1 = require("@loopstack/sandbox-tool");
|
|
52
|
-
const
|
|
52
|
+
const inputSchema = zod_1.z
|
|
53
53
|
.object({
|
|
54
54
|
containerId: zod_1.z.string().describe('The ID of the container to write the file to'),
|
|
55
55
|
path: zod_1.z.string().describe('The path where the file should be written'),
|
|
@@ -61,7 +61,8 @@ const propertiesSchema = zod_1.z
|
|
|
61
61
|
let SandboxWriteFile = SandboxWriteFile_1 = class SandboxWriteFile {
|
|
62
62
|
logger = new common_1.Logger(SandboxWriteFile_1.name);
|
|
63
63
|
sandboxCommand;
|
|
64
|
-
|
|
64
|
+
args;
|
|
65
|
+
async execute(args) {
|
|
65
66
|
const { containerId, path: filePath, content, encoding, createParentDirs } = args;
|
|
66
67
|
this.logger.debug(`Writing file ${filePath} to container ${containerId} (encoding: ${encoding})`);
|
|
67
68
|
if (createParentDirs) {
|
|
@@ -116,13 +117,15 @@ __decorate([
|
|
|
116
117
|
(0, common_2.InjectTool)(),
|
|
117
118
|
__metadata("design:type", sandbox_tool_1.SandboxCommand)
|
|
118
119
|
], SandboxWriteFile.prototype, "sandboxCommand", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
(0, common_2.Input)({ schema: inputSchema }),
|
|
122
|
+
__metadata("design:type", Object)
|
|
123
|
+
], SandboxWriteFile.prototype, "args", void 0);
|
|
119
124
|
exports.SandboxWriteFile = SandboxWriteFile = SandboxWriteFile_1 = __decorate([
|
|
120
|
-
(0, common_1.Injectable)(),
|
|
121
125
|
(0, common_2.Tool)({
|
|
122
126
|
config: {
|
|
123
127
|
description: 'Write content to a file in a sandbox container',
|
|
124
128
|
},
|
|
125
|
-
})
|
|
126
|
-
(0, common_2.WithArguments)(propertiesSchema)
|
|
129
|
+
})
|
|
127
130
|
], SandboxWriteFile);
|
|
128
131
|
//# sourceMappingURL=sandbox-write-file.tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-write-file.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-write-file.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,
|
|
1
|
+
{"version":3,"file":"sandbox-write-file.tool.js","sourceRoot":"","sources":["../../src/tools/sandbox-write-file.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,2CAAwC;AACxC,2CAA6B;AAC7B,6BAAwB;AACxB,8CAAuF;AACvF,0DAAyD;AAEzD,MAAM,WAAW,GAAG,OAAC;KAClB,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;AAcL,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IACV,MAAM,GAA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M,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC;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;AA7EY,4CAAgB;AAGL;IAArB,IAAA,mBAAU,GAAE;8BAAyB,6BAAc;wDAAC;AAGrD;IADC,IAAA,cAAK,EAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;;8CACJ;2BANhB,gBAAgB;IAL5B,IAAA,aAAI,EAAC;QACJ,MAAM,EAAE;YACN,WAAW,EAAE,gDAAgD;SAC9D;KACF,CAAC;GACW,gBAAgB,CA6E5B"}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"filesystem",
|
|
8
8
|
"sandbox"
|
|
9
9
|
],
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.4.1",
|
|
11
11
|
"license": "Apache-2.0",
|
|
12
12
|
"author": {
|
|
13
13
|
"name": "Tobias Blättermann, Jakob Klippel"
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"watch": "nest build --watch"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@loopstack/common": "^0.
|
|
31
|
-
"@loopstack/sandbox-tool": "^0.
|
|
30
|
+
"@loopstack/common": "^0.20.0",
|
|
31
|
+
"@loopstack/sandbox-tool": "^0.4.1",
|
|
32
32
|
"@nestjs/common": "^11.1.12",
|
|
33
33
|
"zod": "^4.3.5"
|
|
34
34
|
},
|
|
@@ -13,12 +13,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { Logger } from '@nestjs/common';
|
|
17
17
|
import { z } from 'zod';
|
|
18
|
-
import { InjectTool, Tool, ToolInterface, ToolResult
|
|
18
|
+
import { InjectTool, Input, Tool, ToolInterface, ToolResult } from '@loopstack/common';
|
|
19
19
|
import { SandboxCommand } from '@loopstack/sandbox-tool';
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const inputSchema = z
|
|
22
22
|
.object({
|
|
23
23
|
containerId: z.string().describe('The ID of the container to create the directory in'),
|
|
24
24
|
path: z.string().describe('The path of the directory to create'),
|
|
@@ -26,29 +26,27 @@ const propertiesSchema = z
|
|
|
26
26
|
})
|
|
27
27
|
.strict();
|
|
28
28
|
|
|
29
|
-
type SandboxCreateDirectoryArgs = z.infer<typeof
|
|
29
|
+
type SandboxCreateDirectoryArgs = z.infer<typeof inputSchema>;
|
|
30
30
|
|
|
31
31
|
interface SandboxCreateDirectoryResult {
|
|
32
32
|
path: string;
|
|
33
33
|
created: boolean;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
@Injectable()
|
|
37
36
|
@Tool({
|
|
38
37
|
config: {
|
|
39
38
|
description: 'Create a directory in a sandbox container',
|
|
40
39
|
},
|
|
41
40
|
})
|
|
42
|
-
@WithArguments(propertiesSchema)
|
|
43
41
|
export class SandboxCreateDirectory implements ToolInterface<SandboxCreateDirectoryArgs> {
|
|
44
42
|
private readonly logger = new Logger(SandboxCreateDirectory.name);
|
|
45
43
|
|
|
46
44
|
@InjectTool() private sandboxCommand: SandboxCommand;
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
): Promise<ToolResult<SandboxCreateDirectoryResult>> {
|
|
46
|
+
@Input({ schema: inputSchema })
|
|
47
|
+
args: SandboxCreateDirectoryArgs;
|
|
48
|
+
|
|
49
|
+
async execute(args: SandboxCreateDirectoryArgs): Promise<ToolResult<SandboxCreateDirectoryResult>> {
|
|
52
50
|
const { containerId, path: dirPath, recursive } = args;
|
|
53
51
|
|
|
54
52
|
this.logger.debug(`Creating directory ${dirPath} in container ${containerId} (recursive: ${recursive})`);
|
|
@@ -13,12 +13,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { Logger } from '@nestjs/common';
|
|
17
17
|
import { z } from 'zod';
|
|
18
|
-
import { InjectTool, Tool, ToolInterface, ToolResult
|
|
18
|
+
import { InjectTool, Input, Tool, ToolInterface, ToolResult } from '@loopstack/common';
|
|
19
19
|
import { SandboxCommand } from '@loopstack/sandbox-tool';
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const inputSchema = z
|
|
22
22
|
.object({
|
|
23
23
|
containerId: z.string().describe('The ID of the container to delete the file/directory from'),
|
|
24
24
|
path: z.string().describe('The path to the file or directory to delete'),
|
|
@@ -27,26 +27,27 @@ const propertiesSchema = z
|
|
|
27
27
|
})
|
|
28
28
|
.strict();
|
|
29
29
|
|
|
30
|
-
type SandboxDeleteArgs = z.infer<typeof
|
|
30
|
+
type SandboxDeleteArgs = z.infer<typeof inputSchema>;
|
|
31
31
|
|
|
32
32
|
interface SandboxDeleteResult {
|
|
33
33
|
path: string;
|
|
34
34
|
deleted: boolean;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
@Injectable()
|
|
38
37
|
@Tool({
|
|
39
38
|
config: {
|
|
40
39
|
description: 'Delete a file or directory in a sandbox container',
|
|
41
40
|
},
|
|
42
41
|
})
|
|
43
|
-
@WithArguments(propertiesSchema)
|
|
44
42
|
export class SandboxDelete implements ToolInterface<SandboxDeleteArgs> {
|
|
45
43
|
private readonly logger = new Logger(SandboxDelete.name);
|
|
46
44
|
|
|
47
45
|
@InjectTool() private sandboxCommand: SandboxCommand;
|
|
48
46
|
|
|
49
|
-
|
|
47
|
+
@Input({ schema: inputSchema })
|
|
48
|
+
args: SandboxDeleteArgs;
|
|
49
|
+
|
|
50
|
+
async execute(args: SandboxDeleteArgs): Promise<ToolResult<SandboxDeleteResult>> {
|
|
50
51
|
const { containerId, path: targetPath, recursive, force } = args;
|
|
51
52
|
|
|
52
53
|
this.logger.debug(`Deleting ${targetPath} in container ${containerId} (recursive: ${recursive}, force: ${force})`);
|
|
@@ -13,19 +13,19 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { Logger } from '@nestjs/common';
|
|
17
17
|
import { z } from 'zod';
|
|
18
|
-
import { InjectTool, Tool, ToolInterface, ToolResult
|
|
18
|
+
import { InjectTool, Input, Tool, ToolInterface, ToolResult } from '@loopstack/common';
|
|
19
19
|
import { SandboxCommand } from '@loopstack/sandbox-tool';
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const inputSchema = z
|
|
22
22
|
.object({
|
|
23
23
|
containerId: z.string().describe('The ID of the container to check for file existence'),
|
|
24
24
|
path: z.string().describe('The path to check for existence'),
|
|
25
25
|
})
|
|
26
26
|
.strict();
|
|
27
27
|
|
|
28
|
-
type SandboxExistsArgs = z.infer<typeof
|
|
28
|
+
type SandboxExistsArgs = z.infer<typeof inputSchema>;
|
|
29
29
|
|
|
30
30
|
interface SandboxExistsResult {
|
|
31
31
|
path: string;
|
|
@@ -33,20 +33,21 @@ interface SandboxExistsResult {
|
|
|
33
33
|
type: 'file' | 'directory' | 'symlink' | 'other' | null;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
@Injectable()
|
|
37
36
|
@Tool({
|
|
38
37
|
config: {
|
|
39
38
|
description: 'Check if a file or directory exists in a sandbox container',
|
|
40
39
|
},
|
|
41
40
|
})
|
|
42
|
-
@WithArguments(propertiesSchema)
|
|
43
41
|
export class SandboxExists implements ToolInterface<SandboxExistsArgs> {
|
|
44
42
|
private readonly logger = new Logger(SandboxExists.name);
|
|
45
43
|
|
|
46
44
|
@InjectTool()
|
|
47
45
|
private sandboxCommand: SandboxCommand;
|
|
48
46
|
|
|
49
|
-
|
|
47
|
+
@Input({ schema: inputSchema })
|
|
48
|
+
args: SandboxExistsArgs;
|
|
49
|
+
|
|
50
|
+
async execute(args: SandboxExistsArgs): Promise<ToolResult<SandboxExistsResult>> {
|
|
50
51
|
const { containerId, path: targetPath } = args;
|
|
51
52
|
|
|
52
53
|
this.logger.debug(`Checking existence of ${targetPath} in container ${containerId}`);
|
|
@@ -13,19 +13,19 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { Logger } from '@nestjs/common';
|
|
17
17
|
import { z } from 'zod';
|
|
18
|
-
import { InjectTool, Tool, ToolInterface, ToolResult
|
|
18
|
+
import { InjectTool, Input, Tool, ToolInterface, ToolResult } from '@loopstack/common';
|
|
19
19
|
import { SandboxCommand } from '@loopstack/sandbox-tool';
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const inputSchema = z
|
|
22
22
|
.object({
|
|
23
23
|
containerId: z.string().describe('The ID of the container to get file info from'),
|
|
24
24
|
path: z.string().describe('The path to the file or directory'),
|
|
25
25
|
})
|
|
26
26
|
.strict();
|
|
27
27
|
|
|
28
|
-
type SandboxFileInfoArgs = z.infer<typeof
|
|
28
|
+
type SandboxFileInfoArgs = z.infer<typeof inputSchema>;
|
|
29
29
|
|
|
30
30
|
interface SandboxFileInfoResult {
|
|
31
31
|
path: string;
|
|
@@ -40,19 +40,20 @@ interface SandboxFileInfoResult {
|
|
|
40
40
|
createdAt: string;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
@Injectable()
|
|
44
43
|
@Tool({
|
|
45
44
|
config: {
|
|
46
45
|
description: 'Get detailed information about a file or directory in a sandbox container',
|
|
47
46
|
},
|
|
48
47
|
})
|
|
49
|
-
@WithArguments(propertiesSchema)
|
|
50
48
|
export class SandboxFileInfo implements ToolInterface<SandboxFileInfoArgs> {
|
|
51
49
|
private readonly logger = new Logger(SandboxFileInfo.name);
|
|
52
50
|
|
|
53
51
|
@InjectTool() private sandboxCommand: SandboxCommand;
|
|
54
52
|
|
|
55
|
-
|
|
53
|
+
@Input({ schema: inputSchema })
|
|
54
|
+
args: SandboxFileInfoArgs;
|
|
55
|
+
|
|
56
|
+
async execute(args: SandboxFileInfoArgs): Promise<ToolResult<SandboxFileInfoResult>> {
|
|
56
57
|
const { containerId, path: targetPath } = args;
|
|
57
58
|
|
|
58
59
|
this.logger.debug(`Getting file info for ${targetPath} in container ${containerId}`);
|
|
@@ -13,12 +13,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { Logger } from '@nestjs/common';
|
|
17
17
|
import { z } from 'zod';
|
|
18
|
-
import { InjectTool, Tool, ToolInterface, ToolResult
|
|
18
|
+
import { InjectTool, Input, Tool, ToolInterface, ToolResult } from '@loopstack/common';
|
|
19
19
|
import { SandboxCommand } from '@loopstack/sandbox-tool';
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const inputSchema = z
|
|
22
22
|
.object({
|
|
23
23
|
containerId: z.string().describe('The ID of the container to list the directory from'),
|
|
24
24
|
path: z.string().describe('The path to the directory to list'),
|
|
@@ -26,7 +26,7 @@ const propertiesSchema = z
|
|
|
26
26
|
})
|
|
27
27
|
.strict();
|
|
28
28
|
|
|
29
|
-
type SandboxListDirectoryArgs = z.infer<typeof
|
|
29
|
+
type SandboxListDirectoryArgs = z.infer<typeof inputSchema>;
|
|
30
30
|
|
|
31
31
|
interface FileEntry {
|
|
32
32
|
name: string;
|
|
@@ -40,22 +40,20 @@ interface SandboxListDirectoryResult {
|
|
|
40
40
|
entries: FileEntry[];
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
@Injectable()
|
|
44
43
|
@Tool({
|
|
45
44
|
config: {
|
|
46
45
|
description: 'List files and directories in a sandbox container',
|
|
47
46
|
},
|
|
48
47
|
})
|
|
49
|
-
@WithArguments(propertiesSchema)
|
|
50
48
|
export class SandboxListDirectory implements ToolInterface<SandboxListDirectoryArgs> {
|
|
51
49
|
private readonly logger = new Logger(SandboxListDirectory.name);
|
|
52
50
|
|
|
53
51
|
@InjectTool() private sandboxCommand: SandboxCommand;
|
|
54
52
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
): Promise<ToolResult<SandboxListDirectoryResult>> {
|
|
53
|
+
@Input({ schema: inputSchema })
|
|
54
|
+
args: SandboxListDirectoryArgs;
|
|
55
|
+
|
|
56
|
+
async execute(args: SandboxListDirectoryArgs): Promise<ToolResult<SandboxListDirectoryResult>> {
|
|
59
57
|
const { containerId, path: dirPath, recursive } = args;
|
|
60
58
|
|
|
61
59
|
this.logger.debug(`Listing directory ${dirPath} in container ${containerId} (recursive: ${recursive})`);
|
|
@@ -13,12 +13,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { Logger } from '@nestjs/common';
|
|
17
17
|
import { z } from 'zod';
|
|
18
|
-
import { InjectTool, Tool, ToolInterface, ToolResult
|
|
18
|
+
import { InjectTool, Input, Tool, ToolInterface, ToolResult } from '@loopstack/common';
|
|
19
19
|
import { SandboxCommand } from '@loopstack/sandbox-tool';
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const inputSchema = z
|
|
22
22
|
.object({
|
|
23
23
|
containerId: z.string().describe('The ID of the container to read the file from'),
|
|
24
24
|
path: z.string().describe('The path to the file to read'),
|
|
@@ -26,26 +26,27 @@ const propertiesSchema = z
|
|
|
26
26
|
})
|
|
27
27
|
.strict();
|
|
28
28
|
|
|
29
|
-
type SandboxReadFileArgs = z.infer<typeof
|
|
29
|
+
type SandboxReadFileArgs = z.infer<typeof inputSchema>;
|
|
30
30
|
|
|
31
31
|
interface SandboxReadFileResult {
|
|
32
32
|
content: string;
|
|
33
33
|
encoding: string;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
@Injectable()
|
|
37
36
|
@Tool({
|
|
38
37
|
config: {
|
|
39
38
|
description: 'Read file contents from a sandbox container',
|
|
40
39
|
},
|
|
41
40
|
})
|
|
42
|
-
@WithArguments(propertiesSchema)
|
|
43
41
|
export class SandboxReadFile implements ToolInterface<SandboxReadFileArgs> {
|
|
44
42
|
private readonly logger = new Logger(SandboxReadFile.name);
|
|
45
43
|
|
|
46
44
|
@InjectTool() private sandboxCommand: SandboxCommand;
|
|
47
45
|
|
|
48
|
-
|
|
46
|
+
@Input({ schema: inputSchema })
|
|
47
|
+
args: SandboxReadFileArgs;
|
|
48
|
+
|
|
49
|
+
async execute(args: SandboxReadFileArgs): Promise<ToolResult<SandboxReadFileResult>> {
|
|
49
50
|
const { containerId, path, encoding } = args;
|
|
50
51
|
|
|
51
52
|
this.logger.debug(`Reading file ${path} from container ${containerId} (encoding: ${encoding})`);
|
|
@@ -13,13 +13,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { Logger } from '@nestjs/common';
|
|
17
17
|
import * as path from 'path';
|
|
18
18
|
import { z } from 'zod';
|
|
19
|
-
import { InjectTool, Tool, ToolInterface, ToolResult
|
|
19
|
+
import { InjectTool, Input, Tool, ToolInterface, ToolResult } from '@loopstack/common';
|
|
20
20
|
import { SandboxCommand } from '@loopstack/sandbox-tool';
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const inputSchema = z
|
|
23
23
|
.object({
|
|
24
24
|
containerId: z.string().describe('The ID of the container to write the file to'),
|
|
25
25
|
path: z.string().describe('The path where the file should be written'),
|
|
@@ -29,26 +29,27 @@ const propertiesSchema = z
|
|
|
29
29
|
})
|
|
30
30
|
.strict();
|
|
31
31
|
|
|
32
|
-
type SandboxWriteFileArgs = z.infer<typeof
|
|
32
|
+
type SandboxWriteFileArgs = z.infer<typeof inputSchema>;
|
|
33
33
|
|
|
34
34
|
interface SandboxWriteFileResult {
|
|
35
35
|
path: string;
|
|
36
36
|
bytesWritten: number;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
@Injectable()
|
|
40
39
|
@Tool({
|
|
41
40
|
config: {
|
|
42
41
|
description: 'Write content to a file in a sandbox container',
|
|
43
42
|
},
|
|
44
43
|
})
|
|
45
|
-
@WithArguments(propertiesSchema)
|
|
46
44
|
export class SandboxWriteFile implements ToolInterface<SandboxWriteFileArgs> {
|
|
47
45
|
private readonly logger = new Logger(SandboxWriteFile.name);
|
|
48
46
|
|
|
49
47
|
@InjectTool() private sandboxCommand: SandboxCommand;
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
@Input({ schema: inputSchema })
|
|
50
|
+
args: SandboxWriteFileArgs;
|
|
51
|
+
|
|
52
|
+
async execute(args: SandboxWriteFileArgs): Promise<ToolResult<SandboxWriteFileResult>> {
|
|
52
53
|
const { containerId, path: filePath, content, encoding, createParentDirs } = args;
|
|
53
54
|
|
|
54
55
|
this.logger.debug(`Writing file ${filePath} to container ${containerId} (encoding: ${encoding})`);
|