@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 +3 -2
- package/locale/de.json +6 -0
- package/locale/en.json +6 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +9 -4
- package/src/index.ts +43 -0
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
|
|
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
package/locale/en.json
ADDED
package/locale/es.json
ADDED
package/locale/fr.json
ADDED
package/locale/ja.json
ADDED
package/locale/pt.json
ADDED
package/locale/ru.json
ADDED
package/locale/zh.json
ADDED
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.
|
|
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
|
|
27
|
-
"@unieai/rabi-tools": "0.2.
|
|
28
|
-
"@unieai/rabi-working-directory": "0.2.
|
|
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
|
+
}
|