@deepseek-ai/dsh-tool-working-directory 0.2.2-rc.1 → 0.2.2-rc.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: 87d7d2dbd7777429
17
17
  /deepseek-ai-dsh-tool-working-directory/use-this-package:
18
- en: bb750522dbdb3fef
19
- zh: 85586a5c2137afa9
18
+ en: 83ab57140ebea28e
19
+ zh: 213c36a664a21f65
20
20
  /deepseek-ai-dsh-tool-working-directory/understand-the-implementation:
21
21
  en: f361fe510916fce8
22
22
  zh: a2127f768ef9ac95
package/README.md CHANGED
@@ -25,7 +25,7 @@ Read the Session’s current directory or enter an existing directory with the s
25
25
  <a id="use-this-package"></a>
26
26
  ## Use this package
27
27
 
28
- Mount alongside `tools` and `workingDirectory`. Call `working_directory({})` to read or `working_directory({ cd: "src" })` to change directory. The tool has no configuration fields.
28
+ Mount alongside `tools` and `workingDirectory`. Call `working_directory({})` to read or `working_directory({ cd: "src" })` to change directory. The tool has no configuration fields. A call without a calling Agent fails with `ToolContextUnavailableError` (`TOOL_CONTEXT_UNAVAILABLE`), an empty `cd` with `ToolArgsError` (`INVALID_ARGS`), and a missing directory with the service's `WorkingDirectoryError` codes.
29
29
 
30
30
  ```yaml
31
31
  - name: '@deepseek-ai/dsh-tool-working-directory'
package/README.zh.md CHANGED
@@ -25,7 +25,7 @@ kind: "package-reference"
25
25
  <a id="use-this-package"></a>
26
26
  ## 使用此包
27
27
 
28
- 与 `tools` 和 `workingDirectory` 一起挂载。调用 `working_directory({})` 读取目录,或调用 `working_directory({ cd: "src" })` 改变目录。此工具没有配置字段。
28
+ 与 `tools` 和 `workingDirectory` 一起挂载。调用 `working_directory({})` 读取目录,或调用 `working_directory({ cd: "src" })` 改变目录。此工具没有配置字段。没有调用方 Agent 的调用以 `ToolContextUnavailableError`(`TOOL_CONTEXT_UNAVAILABLE`)失败,`cd` 为空以 `ToolArgsError`(`INVALID_ARGS`)失败,目录不存在时使用服务的 `WorkingDirectoryError` code。
29
29
 
30
30
  ```yaml
31
31
  - name: '@deepseek-ai/dsh-tool-working-directory'
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineTool } from "@deepseek-ai/dsh-tools";
1
+ import { ToolArgsError, ToolContextUnavailableError, defineTool } from "@deepseek-ai/dsh-tools";
2
2
  //#region lib/types/index.js
3
3
  /**
4
4
  * Read or change the calling Session's working directory.
@@ -36,7 +36,8 @@ function apply(ctx) {
36
36
  }]
37
37
  },
38
38
  async execute(args, exec) {
39
- if (exec.agent === void 0) throw new Error("working_directory requires an agent Session");
39
+ if (exec.agent === void 0) throw new ToolContextUnavailableError("working_directory requires an agent Session");
40
+ if (args.cd === "") throw new ToolArgsError(["cd must not be empty; omit it to read the current directory"]);
40
41
  return { cwd: args.cd === void 0 ? await ctx.workingDirectory.ensure(exec.agent, exec.signal) : await ctx.workingDirectory.set(exec.agent, args.cd, exec.signal) };
41
42
  }
42
43
  }));
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAIlD,0BAA0B;AAC1B,eAAO,MAAM,IAAI,2BAA2B,CAAA;AAC5C,iCAAiC;AACjC,eAAO,MAAM,MAAM,UAAgC,CAAA;AAEnD;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAwBxC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAA;AAG/F,0BAA0B;AAC1B,MAAM,CAAC,MAAM,IAAI,G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,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;YACpE,OAAO,EAAE,GAAG,EAAE,CAAA;QAChB,CAAC;KACF,CAAC,CAAC,CAAA;AACL,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-tool-working-directory",
3
3
  "description": "Read and change the active Session working directory",
4
- "version": "0.2.2-rc.1",
4
+ "version": "0.2.2-rc.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -25,24 +25,27 @@
25
25
  "files": [
26
26
  "locale/*.json",
27
27
  "lib/index.js",
28
- "lib/types/**/*.d.ts"
28
+ "lib/types/**/*.d.ts",
29
+ "lib/types/**/*.d.ts.map",
30
+ "lib/**/*.js.map",
31
+ "src"
29
32
  ],
30
33
  "license": "MIT",
31
34
  "peerDependencies": {
32
35
  "@deepseek-ai/cordis": "~4.1.0",
33
- "@deepseek-ai/dsh-tools": "0.2.2-rc.1",
34
- "@deepseek-ai/dsh-working-directory": "0.2.2-rc.1"
36
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.2",
37
+ "@deepseek-ai/dsh-working-directory": "0.2.2-rc.2"
35
38
  },
36
39
  "devDependencies": {
37
40
  "@deepseek-ai/cordis": "~4.1.0",
38
- "@deepseek-ai/dsh-tools": "0.2.2-rc.1",
39
- "@deepseek-ai/dsh-working-directory": "0.2.2-rc.1",
40
- "@deepseek-ai/dsh-agent-loop-testkit": "0.2.2-rc.1",
41
- "@deepseek-ai/dsh-fs-local": "0.2.2-rc.1",
42
- "@deepseek-ai/dsh-agent-loop": "0.2.2-rc.1",
43
- "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
44
- "@deepseek-ai/dsh-session": "0.2.2-rc.1",
45
- "@deepseek-ai/dsh-session-projection": "0.2.2-rc.1",
46
- "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.1"
41
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.2",
42
+ "@deepseek-ai/dsh-working-directory": "0.2.2-rc.2",
43
+ "@deepseek-ai/dsh-agent-loop-testkit": "0.2.2-rc.2",
44
+ "@deepseek-ai/dsh-fs-local": "0.2.2-rc.2",
45
+ "@deepseek-ai/dsh-agent-loop": "0.2.2-rc.2",
46
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.2",
47
+ "@deepseek-ai/dsh-session": "0.2.2-rc.2",
48
+ "@deepseek-ai/dsh-session-projection": "0.2.2-rc.2",
49
+ "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.2"
47
50
  }
48
51
  }
package/src/index.ts ADDED
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Read or change the calling Session's working directory.
3
+ * @module @deepseek-ai/dsh-tool-working-directory
4
+ */
5
+
6
+ import type { Context } from '@deepseek-ai/cordis'
7
+ import { defineTool, ToolArgsError, ToolContextUnavailableError } from '@deepseek-ai/dsh-tools'
8
+ import type {} from '@deepseek-ai/dsh-working-directory'
9
+
10
+ /** Cordis plugin name. */
11
+ export const name = 'tool-working-directory'
12
+ /** Services used by the tool. */
13
+ export const inject = ['tools', 'workingDirectory']
14
+
15
+ /**
16
+ * Register the working-directory tool for this composition.
17
+ * @param ctx - context providing the tool registry and directory owner.
18
+ */
19
+ export function apply(ctx: Context): void {
20
+ ctx.tools.register(defineTool({
21
+ name: 'working_directory',
22
+ description: 'Read the current working directory, or change it with cd. Relative paths use the current directory. Existing shells and running processes keep their own directories.',
23
+ parameters: {
24
+ cd: { type: 'string', description: 'Existing directory to enter. Omit to read the current directory.' },
25
+ },
26
+ output: {
27
+ schema: {
28
+ type: 'object',
29
+ additionalProperties: false,
30
+ properties: { cwd: { type: 'string', required: true, description: 'Current absolute working directory.' } },
31
+ },
32
+ render: (_args, value) => [{ type: 'text', text: value.cwd }],
33
+ },
34
+ async execute(args, exec) {
35
+ if (exec.agent === undefined) throw new ToolContextUnavailableError('working_directory requires an agent Session')
36
+ if (args.cd === '') throw new ToolArgsError(['cd must not be empty; omit it to read the current directory'])
37
+ const cwd = args.cd === undefined
38
+ ? await ctx.workingDirectory.ensure(exec.agent, exec.signal)
39
+ : await ctx.workingDirectory.set(exec.agent, args.cd, exec.signal)
40
+ return { cwd }
41
+ },
42
+ }))
43
+ }