@unieai/rabi-tool-working-directory 0.2.1-rc.3 → 0.2.2-rc.5

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/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineTool } from "@unieai/rabi-tools";
1
+ import { ToolArgsError, ToolContextUnavailableError, defineTool } from "@unieai/rabi-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
  }));
package/locale/de.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Arbeitsverzeichnis-Tools",
4
+ "description": "Lesen und ändern Sie das Arbeitsverzeichnis der aktuellen Sitzung."
5
+ }
6
+ }
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Working directory tools",
4
+ "description": "Read and change the current session's working directory."
5
+ }
6
+ }
package/locale/es.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Herramientas del directorio de trabajo",
4
+ "description": "Lea y cambie el directorio de trabajo de la sesión actual."
5
+ }
6
+ }
package/locale/fr.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Outils du répertoire de travail",
4
+ "description": "Lire et modifier le répertoire de travail de la session en cours."
5
+ }
6
+ }
package/locale/ja.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "作業ディレクトリツール",
4
+ "description": "現在のセッションの作業ディレクトリを読み取り、変更します。"
5
+ }
6
+ }
package/locale/pt.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Ferramentas de diretório de trabalho",
4
+ "description": "Leia e altere o diretório de trabalho da sessão atual."
5
+ }
6
+ }
package/locale/ru.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Инструменты рабочего каталога",
4
+ "description": "Прочитайте и измените рабочий каталог текущего сеанса."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "工作目录工具",
4
+ "description": "读取和修改当前会话的工作目录。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unieai/rabi-tool-working-directory",
3
3
  "description": "Read and change the active Session working directory",
4
- "version": "0.2.1-rc.3",
4
+ "version": "0.2.2-rc.5",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -14,17 +14,22 @@
14
14
  "default": "./lib/index.js"
15
15
  },
16
16
  "./src/*": "./src/*",
17
+ "./locale/*.json": "./locale/*.json",
17
18
  "./package.json": "./package.json"
18
19
  },
19
20
  "files": [
21
+ "locale/*.json",
20
22
  "lib/index.js",
21
23
  "lib/types/**/*.d.ts",
24
+ "lib/types/**/*.d.ts.map",
25
+ "lib/**/*.js.map",
26
+ "src",
22
27
  "README.md"
23
28
  ],
24
29
  "license": "MIT",
25
30
  "peerDependencies": {
26
- "@unieai/cordis": "4.0.5",
27
- "@unieai/rabi-tools": "0.2.1-rc.3",
28
- "@unieai/rabi-working-directory": "0.2.1-rc.3"
31
+ "@unieai/cordis": "4.1.0",
32
+ "@unieai/rabi-tools": "0.2.2-rc.5",
33
+ "@unieai/rabi-working-directory": "0.2.2-rc.5"
29
34
  }
30
35
  }
package/src/index.ts ADDED
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Read or change the calling Session's working directory.
3
+ * @module @unieai/rabi-tool-working-directory
4
+ */
5
+
6
+ import type { Context } from '@unieai/cordis'
7
+ import { defineTool, ToolArgsError, ToolContextUnavailableError } from '@unieai/rabi-tools'
8
+ import type {} from '@unieai/rabi-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
+ }