@dexto/tools-filesystem 1.18.1 → 1.19.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.
@@ -83,9 +83,13 @@ function createDirectoryAccessApprovalHandlers(options) {
83
83
  path: canonicalPath,
84
84
  parentDir: lexicalPaths.parentDir === lexicalPaths.path ? canonicalPath : path.dirname(canonicalPath)
85
85
  };
86
- const isAllowed = await resolvedFileSystemService.isPathWithinConfigAllowed(paths.path);
87
- if (isAllowed) {
88
- return false;
86
+ if (options.operation === "read") {
87
+ const isAllowed = await resolvedFileSystemService.isPathWithinConfigAllowed(
88
+ paths.path
89
+ );
90
+ if (isAllowed) {
91
+ return false;
92
+ }
89
93
  }
90
94
  const approvalManager = context.services?.approval;
91
95
  if (!approvalManager) {
@@ -1 +1 @@
1
- {"version":3,"file":"directory-approval.d.ts","sourceRoot":"","sources":["../src/directory-approval.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAEzC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAIpE,KAAK,0BAA0B,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAE5D,KAAK,sBAAsB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC;AAKF,wBAAgB,0BAA0B,CACtC,aAAa,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,0BAA0B,GACvC,MAAM,CAKR;AAED,wBAAgB,4BAA4B,CACxC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,EACrD,aAAa,GAAE,WAAW,CA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BAA0B,GACvC,MAAM,CAKR;AAED,wBAAgB,4BAA4B,CACxC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,EACrD,aAAa,GAAE,WAAW,CAAC,SAAS,GAAG,MAAM,CAAgC,EAC7E,SAAS,CAAC,EAAE,0BAA0B,GACvC,OAAO,CAgCT;AAED,wBAAgB,eAAe,CAC3B,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,MAAM,GACjB,sBAAsB,CAGxB;AAED,wBAAgB,qCAAqC,CAAC,KAAK,CAAC,OAAO,SAAS,UAAU,EAAE,OAAO,EAAE;IAC7F,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,0BAA0B,CAAC;IACtC,WAAW,EAAE,OAAO,CAAC;IACrB,oBAAoB,EAAE,uBAAuB,CAAC;IAC9C,YAAY,EAAE,CACV,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EACxB,iBAAiB,EAAE,iBAAiB,KACnC,sBAAsB,CAAC;CAC/B,GAAG;IACA,aAAa,EAAE,CACX,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EACxB,OAAO,EAAE,oBAAoB,KAC5B,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;CAChC,CAoDA"}
@@ -147,7 +147,7 @@ async function readWorkspaceFile(resolvedPath, filePath) {
147
147
  tempWorkspaceRoot = tempDir;
148
148
  approvalManager = new import_core.ApprovalManager(
149
149
  {
150
- permissions: { mode: "manual" },
150
+ permissions: { mode: "asks-you" },
151
151
  elicitation: { enabled: true }
152
152
  },
153
153
  mockLogger,
@@ -176,6 +176,59 @@ async function readWorkspaceFile(resolvedPath, filePath) {
176
176
  );
177
177
  (0, import_vitest.expect)(decision).toBe(false);
178
178
  });
179
+ (0, import_vitest.it)("should return a directory key for writes and edits within config-allowed roots", async () => {
180
+ const testFile = path.join(tempDir, "test.txt");
181
+ await fs.writeFile(testFile, "old content");
182
+ const writeTool = (0, import_write_file_tool.createWriteFileTool)(getFileSystemService, import_test_helpers.allowAllPaths);
183
+ const editTool = (0, import_edit_file_tool.createEditFileTool)(
184
+ getFileSystemService,
185
+ import_test_helpers.allowAllPaths,
186
+ 10 * 1024 * 1024
187
+ );
188
+ await (0, import_vitest.expect)(
189
+ callNeedsApproval(
190
+ writeTool.needsApproval,
191
+ writeTool.inputSchema.parse({ file_path: testFile, content: "new" }),
192
+ toolContext
193
+ )
194
+ ).resolves.toBe((0, import_directory_approval.createDirectoryApprovalKey)(tempDir, "write"));
195
+ await (0, import_vitest.expect)(
196
+ callNeedsApproval(
197
+ editTool.needsApproval,
198
+ editTool.inputSchema.parse({
199
+ file_path: testFile,
200
+ old_string: "old",
201
+ new_string: "new"
202
+ }),
203
+ toolContext
204
+ )
205
+ ).resolves.toBe((0, import_directory_approval.createDirectoryApprovalKey)(tempDir, "edit"));
206
+ });
207
+ (0, import_vitest.it)("should stop asking for edits in a directory approved for the session", async () => {
208
+ const testFile = path.join(tempDir, "test.txt");
209
+ await fs.writeFile(testFile, "old content");
210
+ const editTool = (0, import_edit_file_tool.createEditFileTool)(
211
+ getFileSystemService,
212
+ import_test_helpers.allowAllPaths,
213
+ 10 * 1024 * 1024
214
+ );
215
+ await approvalManager.addApprovedKey(
216
+ (0, import_directory_approval.createDirectoryApprovalKey)(tempDir, "edit"),
217
+ "session",
218
+ toolContext.sessionId
219
+ );
220
+ await (0, import_vitest.expect)(
221
+ callNeedsApproval(
222
+ editTool.needsApproval,
223
+ editTool.inputSchema.parse({
224
+ file_path: testFile,
225
+ old_string: "old",
226
+ new_string: "new"
227
+ }),
228
+ toolContext
229
+ )
230
+ ).resolves.toBe(false);
231
+ });
179
232
  (0, import_vitest.it)("should return a directory approval key for external paths", async () => {
180
233
  const tool = (0, import_read_file_tool.createReadFileTool)(getFileSystemService, import_test_helpers.allowAllPaths, 10 * 1024 * 1024);
181
234
  const needsApproval = tool.needsApproval;
@@ -127,7 +127,7 @@ describe("Directory Approval Integration Tests", () => {
127
127
  tempWorkspaceRoot = tempDir;
128
128
  approvalManager = new ApprovalManager(
129
129
  {
130
- permissions: { mode: "manual" },
130
+ permissions: { mode: "asks-you" },
131
131
  elicitation: { enabled: true }
132
132
  },
133
133
  mockLogger,
@@ -156,6 +156,59 @@ describe("Directory Approval Integration Tests", () => {
156
156
  );
157
157
  expect(decision).toBe(false);
158
158
  });
159
+ it("should return a directory key for writes and edits within config-allowed roots", async () => {
160
+ const testFile = path.join(tempDir, "test.txt");
161
+ await fs.writeFile(testFile, "old content");
162
+ const writeTool = createWriteFileTool(getFileSystemService, allowAllPaths);
163
+ const editTool = createEditFileTool(
164
+ getFileSystemService,
165
+ allowAllPaths,
166
+ 10 * 1024 * 1024
167
+ );
168
+ await expect(
169
+ callNeedsApproval(
170
+ writeTool.needsApproval,
171
+ writeTool.inputSchema.parse({ file_path: testFile, content: "new" }),
172
+ toolContext
173
+ )
174
+ ).resolves.toBe(createDirectoryApprovalKey(tempDir, "write"));
175
+ await expect(
176
+ callNeedsApproval(
177
+ editTool.needsApproval,
178
+ editTool.inputSchema.parse({
179
+ file_path: testFile,
180
+ old_string: "old",
181
+ new_string: "new"
182
+ }),
183
+ toolContext
184
+ )
185
+ ).resolves.toBe(createDirectoryApprovalKey(tempDir, "edit"));
186
+ });
187
+ it("should stop asking for edits in a directory approved for the session", async () => {
188
+ const testFile = path.join(tempDir, "test.txt");
189
+ await fs.writeFile(testFile, "old content");
190
+ const editTool = createEditFileTool(
191
+ getFileSystemService,
192
+ allowAllPaths,
193
+ 10 * 1024 * 1024
194
+ );
195
+ await approvalManager.addApprovedKey(
196
+ createDirectoryApprovalKey(tempDir, "edit"),
197
+ "session",
198
+ toolContext.sessionId
199
+ );
200
+ await expect(
201
+ callNeedsApproval(
202
+ editTool.needsApproval,
203
+ editTool.inputSchema.parse({
204
+ file_path: testFile,
205
+ old_string: "old",
206
+ new_string: "new"
207
+ }),
208
+ toolContext
209
+ )
210
+ ).resolves.toBe(false);
211
+ });
159
212
  it("should return a directory approval key for external paths", async () => {
160
213
  const tool = createReadFileTool(getFileSystemService, allowAllPaths, 10 * 1024 * 1024);
161
214
  const needsApproval = tool.needsApproval;
@@ -47,9 +47,13 @@ function createDirectoryAccessApprovalHandlers(options) {
47
47
  path: canonicalPath,
48
48
  parentDir: lexicalPaths.parentDir === lexicalPaths.path ? canonicalPath : path.dirname(canonicalPath)
49
49
  };
50
- const isAllowed = await resolvedFileSystemService.isPathWithinConfigAllowed(paths.path);
51
- if (isAllowed) {
52
- return false;
50
+ if (options.operation === "read") {
51
+ const isAllowed = await resolvedFileSystemService.isPathWithinConfigAllowed(
52
+ paths.path
53
+ );
54
+ if (isAllowed) {
55
+ return false;
56
+ }
53
57
  }
54
58
  const approvalManager = context.services?.approval;
55
59
  if (!approvalManager) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexto/tools-filesystem",
3
- "version": "1.18.1",
3
+ "version": "1.19.0",
4
4
  "description": "FileSystem tools factory for Dexto agents",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -23,8 +23,8 @@
23
23
  "minimatch": "^10.2.4",
24
24
  "safe-regex": "^2.1.1",
25
25
  "zod": "^4.3.6",
26
- "@dexto/agent-config": "1.18.1",
27
- "@dexto/core": "1.18.1"
26
+ "@dexto/agent-config": "1.19.0",
27
+ "@dexto/core": "1.19.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/diff": "^5.2.3",