@deepseek-ai/dsh-tool-fs 0.2.1-alpha.1 → 0.2.1-alpha.2

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.i18n.yaml CHANGED
@@ -15,8 +15,8 @@
15
15
  en: d152484eb41ac6b4
16
16
  zh: 09388d293f9be9cb
17
17
  /deepseek-ai-dsh-tool-fs/use-this-package:
18
- en: 8fd62afcdabe55d4
19
- zh: 9bdcae272575be8c
18
+ en: c7da73c9e2691ea1
19
+ zh: 0eba82c1c3553ab9
20
20
  /deepseek-ai-dsh-tool-fs/use-this-package/minimal-composition:
21
21
  en: eb21d89a3ecbd2d4
22
22
  zh: f05ccbb1e7515f32
@@ -39,8 +39,8 @@
39
39
  en: 454b5291db9ba847
40
40
  zh: 9fe7081dfb416c93
41
41
  /deepseek-ai-dsh-tool-fs/understand-the-implementation/source-map:
42
- en: e8220ed04480aadc
43
- zh: 1cc5f9a505953102
42
+ en: ec1517d657fbce14
43
+ zh: be0038b88f7b68fc
44
44
  /deepseek-ai-dsh-tool-fs/understand-the-implementation/per-tool-flow:
45
45
  en: d741e01be9fddb76
46
46
  zh: 7aa1d7ca719a4aac
@@ -90,8 +90,8 @@
90
90
  en: ebd38733c0490428
91
91
  zh: b45101c325efe784
92
92
  /deepseek-ai-dsh-tool-fs/model-experience/read-result/what-the-model-sees:
93
- en: 06e250bd8788248a
94
- zh: e00d36b48068909a
93
+ en: 8f7a10746df88c03
94
+ zh: d4fab398b14db940
95
95
  /deepseek-ai-dsh-tool-fs/model-experience/read-result/token-effect:
96
96
  en: 4269b4368622ec2f
97
97
  zh: f4df80c1fb6972f1
@@ -102,8 +102,8 @@
102
102
  en: 9dac44e6d0b9d8de
103
103
  zh: 7bc4dc1c5df39eaf
104
104
  /deepseek-ai-dsh-tool-fs/model-experience/image-read-result/what-the-model-sees:
105
- en: 9252b6d73776c5ff
106
- zh: d6e433450989399e
105
+ en: 9b5070a15f565c20
106
+ zh: 96043df8c0ae7f76
107
107
  /deepseek-ai-dsh-tool-fs/model-experience/image-read-result/token-effect:
108
108
  en: 68bd5255f1c9ca48
109
109
  zh: 0474213531c1aae3
@@ -114,8 +114,8 @@
114
114
  en: 1b3b6cfa3605d0b4
115
115
  zh: 78e37c2aa4f76d54
116
116
  /deepseek-ai-dsh-tool-fs/model-experience/write-and-edit-results/what-the-model-sees:
117
- en: bb2a92e0e43e3273
118
- zh: a744395576b48a93
117
+ en: 816b07ebfddab5f8
118
+ zh: 0e80580a5902c7ed
119
119
  /deepseek-ai-dsh-tool-fs/model-experience/write-and-edit-results/token-effect:
120
120
  en: fb4d0b17a99f49cf
121
121
  zh: 17460a2a5d72f6cc
package/README.md CHANGED
@@ -25,6 +25,8 @@ Use `dsh-tool-fs` to let a model read UTF-8 files with line numbers, read suppor
25
25
  <a id="use-this-package"></a>
26
26
  ## Use this package
27
27
 
28
+ Relative paths use the Session's current working directory. A directory change affects subsequent reads and mutations without changing sandbox permission roots. Successful results return the canonical absolute path from `fs.processPath`, and root result metadata retains that operation-time path for replay and navigation.
29
+
28
30
  Mount the tools after a `ctx.fs` backend and, for read-before-write/edit behavior, the policy plugin. The model then gets line-numbered reads, atomic writes and edits, and — with an attachment store mounted — image reads; every result is capped, and failures carry stable codes with recovery instructions.
29
31
 
30
32
  ### Minimal composition
@@ -99,6 +101,7 @@ The tools are the executor; policy is an event gate. The tools inject no policy
99
101
  | [`src/read-render.ts`](src/read-render.ts) | Cordis-free windowing and envelope formatting |
100
102
  | [`src/sandbox.ts`](src/sandbox.ts) | Escalation API shared by `write`/`edit`: policy resolution and denial-marker mapping |
101
103
  | [`src/error.ts`](src/error.ts) | Stable model-facing diagnostics for guarded-mutation failures |
104
+ | [`src/mutation-result.ts`](src/mutation-result.ts) | Successful mutation observation and canonical result paths |
102
105
 
103
106
  ### Per-tool flow
104
107
 
@@ -179,7 +182,7 @@ Prefix-stable while the visible tool definitions and order are unchanged. Regist
179
182
 
180
183
  #### What the model sees
181
184
 
182
- A successful read is exactly `<path><displayPath></path>`, newline, `<type>file</type>`, newline, `<content>`, numbered lines as `<lineNumber>: <text>`, a blank line, one footer, and `</content>`. The footer is exactly `(Output capped. Showing lines <start>-<end>. Use offset=<next> to continue.)`, `(Showing lines <start>-<end> of <total>. Use offset=<next> to continue.)`, or `(End of file - total <total> lines)`. A long line ends exactly `... (line truncated to <max> chars)`. A missing read still returns `FS_NOT_FOUND`, but it records confirmed absence for the calling session; after an externally deleted file is re-read, a retried `write` can safely recreate it through the provider's no-replace guard.
185
+ A successful read is exactly `<path><resolvedPath></path>`, newline, `<type>file</type>`, newline, `<content>`, numbered lines as `<lineNumber>: <text>`, a blank line, one footer, and `</content>`. The footer is exactly `(Output capped. Showing lines <start>-<end>. Use offset=<next> to continue.)`, `(Showing lines <start>-<end> of <total>. Use offset=<next> to continue.)`, or `(End of file - total <total> lines)`. A long line ends exactly `... (line truncated to <max> chars)`. A missing read still returns `FS_NOT_FOUND`, but it records confirmed absence for the calling session; after an externally deleted file is re-read, a retried `write` can safely recreate it through the provider's no-replace guard.
183
186
 
184
187
  #### Token effect
185
188
 
@@ -193,7 +196,7 @@ Append-only; newly visible content follows the reusable request prefix and does
193
196
 
194
197
  #### What the model sees
195
198
 
196
- A successful `read_image` returns `<path><displayPath></path>`, `<type>image</type>`, and a `<content>` envelope naming the media type, normalized dimensions, and byte size, followed by the image itself as a native image block. The result is logged with its durable reference before the next model request.
199
+ A successful `read_image` returns `<path><resolvedPath></path>`, `<type>image</type>`, and a `<content>` envelope naming the media type, normalized dimensions, and byte size, followed by the image itself as a native image block. The result is logged with its durable reference before the next model request.
197
200
 
198
201
  #### Token effect
199
202
 
@@ -207,7 +210,7 @@ Append-only; newly visible content follows the reusable request prefix and does
207
210
 
208
211
  #### What the model sees
209
212
 
210
- Write returns the exact five-line envelope `<path><displayPath></path>`, `<type>file</type>`, `<content>`, `Created file` or `Updated file`, then `</content>`. Edit returns exactly `The file <displayPath> has been updated successfully.` or, for `replace_all`, `The file <displayPath> has been updated. All occurrences were successfully replaced.` The full write or replacement text remains in the assistant tool-call arguments.
213
+ Write returns the exact five-line envelope `<path><resolvedPath></path>`, `<type>file</type>`, `<content>`, `Created file` or `Updated file`, then `</content>`. Edit returns exactly `The file <resolvedPath> has been updated successfully.` or, for `replace_all`, `The file <resolvedPath> has been updated. All occurrences were successfully replaced.` The full write or replacement text remains in the assistant tool-call arguments.
211
214
 
212
215
  #### Token effect
213
216
 
package/README.zh.md CHANGED
@@ -25,6 +25,8 @@ kind: "package-reference"
25
25
  <a id="use-this-package"></a>
26
26
  ## 使用本包
27
27
 
28
+ 相对路径使用 Session 的当前工作目录。切换目录会影响后续读取和修改,但不会改变沙箱权限根目录。成功结果返回 `fs.processPath` 提供的规范化绝对路径,根调用结果元数据保留该操作发生时的路径,用于回放和导航。
29
+
28
30
  在 `ctx.fs` 后端之后挂载工具,并在需要先读后写/编辑行为时挂载策略插件。模型随后获得带行号的读取、原子的写入与编辑,以及——挂载附件存储时——图像读取;每个结果都有上限,失败携带稳定错误码与恢复指令。
29
31
 
30
32
  ### 最小组合
@@ -99,6 +101,7 @@ kind: "package-reference"
99
101
  | [`src/read-render.ts`](src/read-render.ts) | 不依赖 Cordis 的窗口构建与信封格式化 |
100
102
  | [`src/sandbox.ts`](src/sandbox.ts) | `write`/`edit` 共享的升权 API:策略解析与拒绝标记映射 |
101
103
  | [`src/error.ts`](src/error.ts) | 防护变更失败的稳定模型侧诊断 |
104
+ | [`src/mutation-result.ts`](src/mutation-result.ts) | 成功变更的观察记录与规范化结果路径 |
102
105
 
103
106
  ### 各工具流程
104
107
 
@@ -179,7 +182,7 @@ Read a file before editing it (the default fs-observation-policy requires it), u
179
182
 
180
183
  #### 模型看到的内容
181
184
 
182
- 成功读取结果精确为 `<path><displayPath></path>`、换行、`<type>file</type>`、换行、`<content>`、形如 `<lineNumber>: <text>` 的编号行、一个空行、一条 footer 和 `</content>`。footer 精确为 `(Output capped. Showing lines <start>-<end>. Use offset=<next> to continue.)`、`(Showing lines <start>-<end> of <total>. Use offset=<next> to continue.)` 或 `(End of file - total <total> lines)`。长行结尾精确为 `... (line truncated to <max> chars)`。读取缺失目标仍返回 `FS_NOT_FOUND`,但会为调用会话记录确认缺失;外部删除的文件被重新读取后,重试的 `write` 可以通过提供方的不替换防护安全地重新创建该文件。
185
+ 成功读取结果精确为 `<path><resolvedPath></path>`、换行、`<type>file</type>`、换行、`<content>`、形如 `<lineNumber>: <text>` 的编号行、一个空行、一条 footer 和 `</content>`。footer 精确为 `(Output capped. Showing lines <start>-<end>. Use offset=<next> to continue.)`、`(Showing lines <start>-<end> of <total>. Use offset=<next> to continue.)` 或 `(End of file - total <total> lines)`。长行结尾精确为 `... (line truncated to <max> chars)`。读取缺失目标仍返回 `FS_NOT_FOUND`,但会为调用会话记录确认缺失;外部删除的文件被重新读取后,重试的 `write` 可以通过提供方的不替换防护安全地重新创建该文件。
183
186
 
184
187
  #### Token 影响
185
188
 
@@ -193,7 +196,7 @@ Read a file before editing it (the default fs-observation-policy requires it), u
193
196
 
194
197
  #### 模型看到的内容
195
198
 
196
- 成功的 `read_image` 返回 `<path><displayPath></path>`、`<type>image</type>` 和写明媒体类型、规范化尺寸与字节数的 `<content>` 信封,随后是作为原生图像块的图像本身。结果会随持久引用写入会话日志,然后才进入下一次模型请求。
199
+ 成功的 `read_image` 返回 `<path><resolvedPath></path>`、`<type>image</type>` 和写明媒体类型、规范化尺寸与字节数的 `<content>` 信封,随后是作为原生图像块的图像本身。结果会随持久引用写入会话日志,然后才进入下一次模型请求。
197
200
 
198
201
  #### Token 影响
199
202
 
@@ -207,7 +210,7 @@ Read a file before editing it (the default fs-observation-policy requires it), u
207
210
 
208
211
  #### 模型看到的内容
209
212
 
210
- 写入精确返回五行包络:`<path><displayPath></path>`、`<type>file</type>`、`<content>`、`Created file` 或 `Updated file`,以及 `</content>`。编辑精确返回 `The file <displayPath> has been updated successfully.`;对于 `replace_all`,精确返回 `The file <displayPath> has been updated. All occurrences were successfully replaced.`。完整写入或替换文本仍保留在 assistant 工具调用参数中。
213
+ 写入精确返回五行包络:`<path><resolvedPath></path>`、`<type>file</type>`、`<content>`、`Created file` 或 `Updated file`,以及 `</content>`。编辑精确返回 `The file <resolvedPath> has been updated successfully.`;对于 `replace_all`,精确返回 `The file <resolvedPath> has been updated. All occurrences were successfully replaced.`。完整写入或替换文本仍保留在 assistant 工具调用参数中。
211
214
 
212
215
  #### Token 影响
213
216
 
package/lib/index.js CHANGED
@@ -158,29 +158,18 @@ function readMetaFromMeta(meta) {
158
158
  //#endregion
159
159
  //#region lib/types/session-cwd.js
160
160
  /**
161
- * Derive the working directory a filesystem tool resolves relative paths against: the calling
162
- * agent's per-session workspace (`exec.agent.session.header.cwd`), so each session's
163
- * `read`/`write`/`edit` act on its workspace, not the server's launch directory.
164
- * Non-agent calls return `undefined`, leaving the fallback in the provider rather than reading
165
- * `process.cwd()` at the tool boundary.
161
+ * Resolution options for filesystem calls in the Session's current directory.
162
+ * Non-agent calls leave directory defaults to the filesystem provider.
166
163
  * @module @deepseek-ai/dsh-tool-fs/session-cwd
167
164
  */
168
165
  /**
169
- * The session workspace cwd for this call, or `undefined` when none applies.
170
- * @param exec - the tool-execution context; only its optional `agent` is read.
171
- * @returns the calling agent's session cwd, or undefined for a non-agent caller (the backend then applies its own default).
166
+ * Resolve the current directory and cancellation for a filesystem call.
167
+ * @param ctx - context containing the working-directory service.
168
+ * @param exec - tool execution supplying the agent and cancellation.
169
+ * @returns filesystem resolution options for this call.
172
170
  */
173
- function sessionCwd(exec) {
174
- return exec.agent?.session.header.cwd;
175
- }
176
- /**
177
- * Resolution options shared by all model-facing filesystem tools.
178
- * @param exec - the tool-execution context supplying session cwd and cancellation.
179
- * @param policyWorkspaceRoot - resolved per-call root, when a mutation carries sandbox policy.
180
- * @returns provider resolution options for the current tool call.
181
- */
182
- function sessionResolveOptions(exec, policyWorkspaceRoot) {
183
- const cwd = policyWorkspaceRoot ?? sessionCwd(exec);
171
+ async function sessionResolveOptions(ctx, exec) {
172
+ const cwd = exec.agent === void 0 ? void 0 : await ctx.workingDirectory.ensure(exec.agent, exec.signal);
184
173
  return {
185
174
  ...cwd !== void 0 ? { cwd } : {},
186
175
  signal: exec.signal
@@ -195,12 +184,12 @@ function sessionResolveOptions(exec, policyWorkspaceRoot) {
195
184
  /**
196
185
  * Resolve a model-supplied path, observe absence, and require a regular file.
197
186
  * @param ctx - the plugin context providing filesystem resolution and observation events.
198
- * @param exec - the current tool execution, including session cwd and cancellation.
187
+ * @param exec - the current tool execution, including the owning Agent and cancellation.
199
188
  * @param requestedPath - the raw path supplied to the tool.
200
189
  * @returns the resolved target and its single stat result.
201
190
  */
202
191
  async function resolveRegularReadTarget(ctx, exec, requestedPath) {
203
- const target = await ctx.fs.resolve(requestedPath, sessionResolveOptions(exec));
192
+ const target = await ctx.fs.resolve(requestedPath, await sessionResolveOptions(ctx, exec));
204
193
  const info = await ctx.fs.stat(target, exec.signal);
205
194
  if (info === void 0) {
206
195
  ctx.emit("fs/observed", target, { kind: "absent" }, exec);
@@ -283,7 +272,8 @@ function applyReadTool(ctx, caps) {
283
272
  properties: {
284
273
  path: {
285
274
  type: "string",
286
- required: true
275
+ required: true,
276
+ description: "Canonical absolute path in the filesystem execution world."
287
277
  },
288
278
  offset: {
289
279
  type: "integer",
@@ -352,7 +342,7 @@ function applyReadTool(ctx, caps) {
352
342
  maxBytes: caps.maxBytes
353
343
  }, target.displayPath);
354
344
  const outcome = {
355
- path: target.displayPath,
345
+ path: ctx.fs.processPath(target),
356
346
  offset: input.offset,
357
347
  lines: window.lines,
358
348
  totalLines: window.totalLines
@@ -453,6 +443,16 @@ function diffsFromMeta(meta) {
453
443
  if (!Array.isArray(diffs) || diffs.length === 0 || !diffs.every(isFileDiff)) return void 0;
454
444
  return diffs;
455
445
  }
446
+ /**
447
+ * Read the operation's file path even when the applied diff is empty.
448
+ * @param meta - opaque persisted result metadata.
449
+ * @returns the recorded path, or undefined for old or malformed metadata.
450
+ */
451
+ function pathFromMeta(meta) {
452
+ if (typeof meta !== "object" || meta === null || Array.isArray(meta)) return void 0;
453
+ const path = meta.path;
454
+ return typeof path === "string" && path.length > 0 ? path : void 0;
455
+ }
456
456
  //#endregion
457
457
  //#region lib/types/error.js
458
458
  /**
@@ -479,6 +479,28 @@ function remediateFsError(error, displayPath) {
479
479
  return error;
480
480
  }
481
481
  //#endregion
482
+ //#region lib/types/mutation-result.js
483
+ /** Shared observation and result fields for successful file mutations. */
484
+ /**
485
+ * Record the new file version and expose the mutation result with its canonical path.
486
+ * @param ctx - filesystem and observation event owner.
487
+ * @param target - resolved file that was mutated.
488
+ * @param outcome - successful provider result; its version stays in the observation event.
489
+ * @param exec - calling tool execution.
490
+ * @returns the provider's result fields without the version, plus the canonical absolute path.
491
+ */
492
+ function mutationResult(ctx, target, outcome, exec) {
493
+ const { version, ...result } = outcome;
494
+ ctx.emit("fs/observed", target, {
495
+ kind: "present",
496
+ version
497
+ }, exec);
498
+ return {
499
+ path: ctx.fs.processPath(target),
500
+ ...result
501
+ };
502
+ }
503
+ //#endregion
482
504
  //#region lib/types/write.js
483
505
  /**
484
506
  * Model-facing full-file write. It obtains an optional intent from the single policy slot, calls
@@ -546,7 +568,8 @@ function applyWriteTool(ctx, sandbox) {
546
568
  properties: {
547
569
  path: {
548
570
  type: "string",
549
- required: true
571
+ required: true,
572
+ description: "Canonical absolute path in the filesystem execution world."
550
573
  },
551
574
  operation: {
552
575
  type: "string",
@@ -567,9 +590,10 @@ function applyWriteTool(ctx, sandbox) {
567
590
  type: "text",
568
591
  text: formatWriteOutput(value.path, value)
569
592
  }],
570
- presentationMeta: (args, value) => ({
593
+ presentationMeta: (_args, value) => ({
571
594
  operation: value.operation,
572
- diffs: value.before === null ? [] : computeHunkDiffs(args.file_path, value.before, value.after).map(({ path, oldText, newText }) => ({
595
+ path: value.path,
596
+ diffs: value.before === null ? [] : computeHunkDiffs(value.path, value.before, value.after).map(({ path, oldText, newText }) => ({
573
597
  path,
574
598
  oldText,
575
599
  newText
@@ -579,7 +603,7 @@ function applyWriteTool(ctx, sandbox) {
579
603
  async execute(args, exec) {
580
604
  const input = parseWriteArgs(args);
581
605
  const sandboxPolicy = await sandbox.resolvePolicy("write", args, exec);
582
- const target = await ctx.fs.resolve(input.filePath, sessionResolveOptions(exec, sandboxPolicy?.workspaceRoot));
606
+ const target = await ctx.fs.resolve(input.filePath, await sessionResolveOptions(ctx, exec));
583
607
  const intent = await ctx.waterfall("fs/write-intent", target, exec, () => void 0);
584
608
  let outcome;
585
609
  try {
@@ -587,16 +611,7 @@ function applyWriteTool(ctx, sandbox) {
587
611
  } catch (error) {
588
612
  throw remediateFsError(sandbox.mapError(error, sandboxPolicy), target.displayPath);
589
613
  }
590
- ctx.emit("fs/observed", target, {
591
- kind: "present",
592
- version: outcome.version
593
- }, exec);
594
- return {
595
- path: target.displayPath,
596
- operation: outcome.operation,
597
- before: outcome.before,
598
- after: outcome.after
599
- };
614
+ return mutationResult(ctx, target, outcome, exec);
600
615
  },
601
616
  presentCall(args) {
602
617
  return {
@@ -613,7 +628,7 @@ function applyWriteTool(ctx, sandbox) {
613
628
  presentResult(args, result) {
614
629
  if (result.isError) return void 0;
615
630
  const diffs = diffsFromMeta(result.meta) ?? [{
616
- path: args.file_path,
631
+ path: pathFromMeta(result.meta) ?? args.file_path,
617
632
  oldText: null,
618
633
  newText: args.content
619
634
  }];
@@ -703,7 +718,8 @@ function applyEditTool(ctx, sandbox) {
703
718
  properties: {
704
719
  path: {
705
720
  type: "string",
706
- required: true
721
+ required: true,
722
+ description: "Canonical absolute path in the filesystem execution world."
707
723
  },
708
724
  before: {
709
725
  type: "string",
@@ -719,16 +735,19 @@ function applyEditTool(ctx, sandbox) {
719
735
  type: "text",
720
736
  text: formatEditOutput(value.path, args.replace_all ?? false)
721
737
  }],
722
- presentationMeta: (args, value) => ({ diffs: computeHunkDiffs(args.file_path, value.before, value.after).map(({ path, oldText, newText }) => ({
723
- path,
724
- oldText,
725
- newText
726
- })) })
738
+ presentationMeta: (_args, value) => ({
739
+ path: value.path,
740
+ diffs: computeHunkDiffs(value.path, value.before, value.after).map(({ path, oldText, newText }) => ({
741
+ path,
742
+ oldText,
743
+ newText
744
+ }))
745
+ })
727
746
  },
728
747
  async execute(args, exec) {
729
748
  const input = parseEditArgs(args);
730
749
  const sandboxPolicy = await sandbox.resolvePolicy("edit", args, exec);
731
- const target = await ctx.fs.resolve(input.filePath, sessionResolveOptions(exec, sandboxPolicy?.workspaceRoot));
750
+ const target = await ctx.fs.resolve(input.filePath, await sessionResolveOptions(ctx, exec));
732
751
  let outcome;
733
752
  try {
734
753
  const intent = await ctx.waterfall("fs/edit-intent", target, exec, () => void 0);
@@ -740,15 +759,7 @@ function applyEditTool(ctx, sandbox) {
740
759
  } catch (error) {
741
760
  throw remediateFsError(sandbox.mapError(error, sandboxPolicy), target.displayPath);
742
761
  }
743
- ctx.emit("fs/observed", target, {
744
- kind: "present",
745
- version: outcome.version
746
- }, exec);
747
- return {
748
- path: target.displayPath,
749
- before: outcome.before,
750
- after: outcome.after
751
- };
762
+ return mutationResult(ctx, target, outcome, exec);
752
763
  },
753
764
  presentCall(args) {
754
765
  return {
@@ -986,7 +997,8 @@ function applyReadImageTool(ctx) {
986
997
  properties: {
987
998
  path: {
988
999
  type: "string",
989
- required: true
1000
+ required: true,
1001
+ description: "Canonical absolute path in the filesystem execution world."
990
1002
  },
991
1003
  image: IMAGE_VALUE_SCHEMA
992
1004
  }
@@ -1033,7 +1045,7 @@ function applyReadImageTool(ctx) {
1033
1045
  version: info.version
1034
1046
  }, exec);
1035
1047
  return {
1036
- path: target.displayPath,
1048
+ path: ctx.fs.processPath(target),
1037
1049
  image: {
1038
1050
  attachmentId: ref.attachmentId,
1039
1051
  mediaType: ref.mediaType,
@@ -1109,9 +1121,9 @@ var FsSandboxController = class {
1109
1121
  /**
1110
1122
  * The policy to stamp onto this mutation: an approved escalation grant (a
1111
1123
  * strictly wider retry resolved through `ctx.approval` before anything
1112
- * executes), else the session's standing mode. Repeating the standing mode
1113
- * requires no approval. The calling session's cwd is
1114
- * always carried as the workspace root. Validates the escalation argument
1124
+ * executes), else the Session's standing mode. Repeating the standing mode
1125
+ * requires no approval. The workspace root is the original Session
1126
+ * directory, or the deployment fallback when absent. Validates the escalation argument
1115
1127
  * pairing first.
1116
1128
  * @param toolName - the mutating tool's name, for the approval audit trail.
1117
1129
  * @param args - the call's escalation arguments.
@@ -1176,7 +1188,8 @@ const name = "tool-fs";
1176
1188
  const inject = [
1177
1189
  "tools",
1178
1190
  "fs",
1179
- "systemPrompt"
1191
+ "systemPrompt",
1192
+ "workingDirectory"
1180
1193
  ];
1181
1194
  const Config = z.object({
1182
1195
  readLimit: z.number().default(READ_LIMIT),
@@ -38,4 +38,10 @@ export declare function computeHunkDiffs(path: string, before: string, after: st
38
38
  * @returns validated hunks, or `undefined` for absent or malformed data.
39
39
  */
40
40
  export declare function diffsFromMeta(meta: unknown): FileDiff[] | undefined;
41
+ /**
42
+ * Read the operation's file path even when the applied diff is empty.
43
+ * @param meta - opaque persisted result metadata.
44
+ * @returns the recorded path, or undefined for old or malformed metadata.
45
+ */
46
+ export declare function pathFromMeta(meta: unknown): string | undefined;
41
47
  //# sourceMappingURL=diff.d.ts.map
@@ -0,0 +1,18 @@
1
+ /** Shared observation and result fields for successful file mutations. */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ import type { FsTarget, FsVersion } from '@deepseek-ai/dsh-fs';
4
+ import type { ToolExecution } from '@deepseek-ai/dsh-tools';
5
+ /**
6
+ * Record the new file version and expose the mutation result with its canonical path.
7
+ * @param ctx - filesystem and observation event owner.
8
+ * @param target - resolved file that was mutated.
9
+ * @param outcome - successful provider result; its version stays in the observation event.
10
+ * @param exec - calling tool execution.
11
+ * @returns the provider's result fields without the version, plus the canonical absolute path.
12
+ */
13
+ export declare function mutationResult<T extends {
14
+ version: FsVersion;
15
+ }>(ctx: Context, target: FsTarget, outcome: T, exec: ToolExecution): Omit<T, 'version'> & {
16
+ path: string;
17
+ };
18
+ //# sourceMappingURL=mutation-result.d.ts.map
@@ -21,6 +21,7 @@ import type { ToolExecution } from '@deepseek-ai/dsh-tools';
21
21
  export declare function sniffImageMediaType(data: Uint8Array): ImageMediaType | undefined;
22
22
  /** The structured outcome declared by the `read_image` output schema. */
23
23
  export interface ImageReadValue {
24
+ /** Canonical absolute path in the filesystem provider's execution world. */
24
25
  path: string;
25
26
  image: {
26
27
  attachmentId: string;
@@ -8,7 +8,7 @@ import type { ToolExecution } from '@deepseek-ai/dsh-tools';
8
8
  /**
9
9
  * Resolve a model-supplied path, observe absence, and require a regular file.
10
10
  * @param ctx - the plugin context providing filesystem resolution and observation events.
11
- * @param exec - the current tool execution, including session cwd and cancellation.
11
+ * @param exec - the current tool execution, including the owning Agent and cancellation.
12
12
  * @param requestedPath - the raw path supplied to the tool.
13
13
  * @returns the resolved target and its single stat result.
14
14
  */
@@ -52,9 +52,9 @@ export declare class FsSandboxController {
52
52
  /**
53
53
  * The policy to stamp onto this mutation: an approved escalation grant (a
54
54
  * strictly wider retry resolved through `ctx.approval` before anything
55
- * executes), else the session's standing mode. Repeating the standing mode
56
- * requires no approval. The calling session's cwd is
57
- * always carried as the workspace root. Validates the escalation argument
55
+ * executes), else the Session's standing mode. Repeating the standing mode
56
+ * requires no approval. The workspace root is the original Session
57
+ * directory, or the deployment fallback when absent. Validates the escalation argument
58
58
  * pairing first.
59
59
  * @param toolName - the mutating tool's name, for the approval audit trail.
60
60
  * @param args - the call's escalation arguments.
@@ -1,26 +1,18 @@
1
1
  /**
2
- * Derive the working directory a filesystem tool resolves relative paths against: the calling
3
- * agent's per-session workspace (`exec.agent.session.header.cwd`), so each session's
4
- * `read`/`write`/`edit` act on its workspace, not the server's launch directory.
5
- * Non-agent calls return `undefined`, leaving the fallback in the provider rather than reading
6
- * `process.cwd()` at the tool boundary.
2
+ * Resolution options for filesystem calls in the Session's current directory.
3
+ * Non-agent calls leave directory defaults to the filesystem provider.
7
4
  * @module @deepseek-ai/dsh-tool-fs/session-cwd
8
5
  */
6
+ import type { Context } from '@deepseek-ai/cordis';
9
7
  import type { ToolExecution } from '@deepseek-ai/dsh-tools';
10
8
  /**
11
- * The session workspace cwd for this call, or `undefined` when none applies.
12
- * @param exec - the tool-execution context; only its optional `agent` is read.
13
- * @returns the calling agent's session cwd, or undefined for a non-agent caller (the backend then applies its own default).
9
+ * Resolve the current directory and cancellation for a filesystem call.
10
+ * @param ctx - context containing the working-directory service.
11
+ * @param exec - tool execution supplying the agent and cancellation.
12
+ * @returns filesystem resolution options for this call.
14
13
  */
15
- export declare function sessionCwd(exec: ToolExecution): string | undefined;
16
- /**
17
- * Resolution options shared by all model-facing filesystem tools.
18
- * @param exec - the tool-execution context supplying session cwd and cancellation.
19
- * @param policyWorkspaceRoot - resolved per-call root, when a mutation carries sandbox policy.
20
- * @returns provider resolution options for the current tool call.
21
- */
22
- export declare function sessionResolveOptions(exec: ToolExecution, policyWorkspaceRoot?: string): {
14
+ export declare function sessionResolveOptions(ctx: Context, exec: ToolExecution): Promise<{
23
15
  cwd?: string;
24
16
  signal?: AbortSignal;
25
- };
17
+ }>;
26
18
  //# sourceMappingURL=session-cwd.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-tool-fs",
3
3
  "description": "Model-facing filesystem tools (read, write, edit) over the DeepSeek Harness filesystem seam (ctx.fs)",
4
- "version": "0.2.1-alpha.1",
4
+ "version": "0.2.1-alpha.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -28,41 +28,43 @@
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
30
  "diff": "^9.0.0",
31
- "@deepseek-ai/dsh-util-code-language": "0.2.1-alpha.1",
32
- "@deepseek-ai/schemastery": "~3.18.5-alpha.1"
31
+ "@deepseek-ai/schemastery": "~3.18.5-alpha.1",
32
+ "@deepseek-ai/dsh-util-code-language": "0.2.1-alpha.2"
33
33
  },
34
34
  "peerDependencies": {
35
- "@deepseek-ai/dsh-fs": "0.2.1-alpha.1",
36
- "@deepseek-ai/dsh-llm": "0.2.1-alpha.1",
37
- "@deepseek-ai/dsh-sandbox": "0.2.1-alpha.1",
38
- "@deepseek-ai/dsh-sandbox-policy": "0.2.1-alpha.1",
39
- "@deepseek-ai/dsh-session": "0.2.1-alpha.1",
40
- "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.1",
41
- "@deepseek-ai/dsh-tools": "0.2.1-alpha.1",
42
- "@deepseek-ai/dsh-user-approval": "0.2.1-alpha.1",
35
+ "@deepseek-ai/dsh-attachment": "0.2.1-alpha.2",
36
+ "@deepseek-ai/dsh-fs": "0.2.1-alpha.2",
37
+ "@deepseek-ai/dsh-llm": "0.2.1-alpha.2",
38
+ "@deepseek-ai/dsh-sandbox": "0.2.1-alpha.2",
39
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.1-alpha.2",
40
+ "@deepseek-ai/dsh-session": "0.2.1-alpha.2",
41
+ "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.2",
42
+ "@deepseek-ai/dsh-tools": "0.2.1-alpha.2",
43
+ "@deepseek-ai/dsh-user-approval": "0.2.1-alpha.2",
43
44
  "@deepseek-ai/cordis": "~4.0.5-alpha.1",
44
- "@deepseek-ai/dsh-attachment": "0.2.1-alpha.1"
45
+ "@deepseek-ai/dsh-working-directory": "0.2.1-alpha.2"
45
46
  },
46
47
  "devDependencies": {
47
- "@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
48
- "@deepseek-ai/dsh-agent-loop": "0.2.1-alpha.1",
49
- "@deepseek-ai/dsh-agent-loop-testkit": "0.2.1-alpha.1",
50
- "@deepseek-ai/dsh-attachment": "0.2.1-alpha.1",
51
- "@deepseek-ai/dsh-fs": "0.2.1-alpha.1",
52
- "@deepseek-ai/dsh-fs-local": "0.2.1-alpha.1",
53
- "@deepseek-ai/dsh-fs-observation-policy": "0.2.1-alpha.1",
54
- "@deepseek-ai/dsh-llm": "0.2.1-alpha.1",
55
- "@deepseek-ai/dsh-llm-deepseek": "0.2.1-alpha.1",
56
- "@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.1-alpha.1",
57
- "@deepseek-ai/dsh-sandbox": "0.2.1-alpha.1",
58
- "@deepseek-ai/dsh-sandbox-policy": "0.2.1-alpha.1",
59
- "@deepseek-ai/dsh-session": "0.2.1-alpha.1",
60
- "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.1",
61
- "@deepseek-ai/dsh-user-approval": "0.2.1-alpha.1",
48
+ "@deepseek-ai/dsh-agent": "0.2.1-alpha.2",
49
+ "@deepseek-ai/dsh-agent-loop": "0.2.1-alpha.2",
50
+ "@deepseek-ai/dsh-agent-loop-testkit": "0.2.1-alpha.2",
51
+ "@deepseek-ai/dsh-attachment": "0.2.1-alpha.2",
52
+ "@deepseek-ai/dsh-fs": "0.2.1-alpha.2",
53
+ "@deepseek-ai/dsh-fs-local": "0.2.1-alpha.2",
54
+ "@deepseek-ai/dsh-fs-observation-policy": "0.2.1-alpha.2",
55
+ "@deepseek-ai/dsh-llm": "0.2.1-alpha.2",
56
+ "@deepseek-ai/dsh-llm-deepseek": "0.2.1-alpha.2",
57
+ "@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.1-alpha.2",
58
+ "@deepseek-ai/dsh-sandbox": "0.2.1-alpha.2",
59
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.1-alpha.2",
60
+ "@deepseek-ai/dsh-session": "0.2.1-alpha.2",
61
+ "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.2",
62
+ "@deepseek-ai/dsh-tools": "0.2.1-alpha.2",
63
+ "@deepseek-ai/dsh-user-approval": "0.2.1-alpha.2",
62
64
  "@deepseek-ai/cordis": "~4.0.5-alpha.1",
63
- "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.1",
64
- "@deepseek-ai/dsh-scope": "0.2.1-alpha.1",
65
- "@deepseek-ai/dsh-ptc-runtime": "0.2.1-alpha.1",
66
- "@deepseek-ai/dsh-tools": "0.2.1-alpha.1"
65
+ "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.2",
66
+ "@deepseek-ai/dsh-scope": "0.2.1-alpha.2",
67
+ "@deepseek-ai/dsh-ptc-runtime": "0.2.1-alpha.2",
68
+ "@deepseek-ai/dsh-working-directory": "0.2.1-alpha.2"
67
69
  }
68
70
  }