@aexhq/tool-write 7.0.1 → 8.0.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.
package/README.md CHANGED
@@ -11,8 +11,7 @@ const tools = [write({ env: workspace })];
11
11
  ```
12
12
 
13
13
  Requires a writable workspace. The chosen Environment prepares and executes the
14
- packaged Node 22 runtime in `dist/runtime/write.mjs`; `dist/runtime/registry.json`
15
- contains its manifest and contract digest. The Environment owns isolation and resource grants.
16
- The factory requires an explicit `env` and accepts no other options.
14
+ exact published package through its `./runtime` export. The Environment owns isolation and resource grants.
15
+ Omit `env` to run in the registering Node application; pass `{ env: workspace }` for an isolated prepared Environment. The factory accepts no configuration options.
17
16
 
18
17
  Run `npm test --workspace @aexhq/tool-write` from the repository root.
package/dist/index.d.ts CHANGED
@@ -1,9 +1 @@
1
- export declare const write: (placement: {
2
- readonly env: import("@aexhq/brain").Environment;
3
- } & Record<never, never>) => import("@aexhq/brain").PlacedTool<{
4
- path: string;
5
- content: string;
6
- }, {
7
- path: string;
8
- bytes: number;
9
- }>;
1
+ export declare const write: typeof import("./packages/tool-write/src/index.js")["write"];
package/dist/index.js CHANGED
@@ -1,9 +1,2 @@
1
- import { tool } from "@aexhq/brain";
2
- import { inputSchema, outputSchema } from "./schema.js";
3
- export const write = tool({
4
- name: "write",
5
- description: "Write UTF-8 text to a file in the Environment workspace, creating parent directories.",
6
- input: inputSchema,
7
- output: outputSchema,
8
- implementation: Object.freeze({ type: "aex_official_tool", version: 1, name: "write" }),
9
- });
1
+ import { bindTool } from "@aexhq/brain";
2
+ export const write = bindTool({"definition":{"name":"write","description":"Write UTF-8 text to a file in the Environment workspace, creating parent directories.","inputSchema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"path":{"type":"string","minLength":1},"content":{"type":"string"}},"required":["path","content"]},"outputSchema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"path":{"type":"string"},"bytes":{"type":"integer","minimum":0,"maximum":9007199254740991}},"required":["path","bytes"],"additionalProperties":false}}}, {"type":"node_package","package":"@aexhq/tool-write","version":"8.0.0","entry":"./runtime","export":"write"}, { url: new URL("./packages/tool-write/src/index.js", import.meta.url), export: "write" });
@@ -0,0 +1,7 @@
1
+ import type { z } from "zod";
2
+ import type { inputSchema } from "../src/schema.js";
3
+ import { type RuntimeContext } from "../../../shared/tool-runtime.js";
4
+ export declare function run(input: z.output<typeof inputSchema>, context: RuntimeContext): Promise<{
5
+ path: string;
6
+ bytes: number;
7
+ }>;
@@ -0,0 +1,9 @@
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
+ import { dirname } from "node:path";
3
+ import { workspacePath } from "../../../shared/tool-runtime.js";
4
+ export async function run(input, context) {
5
+ const target = workspacePath(context.workspace, input.path);
6
+ await mkdir(dirname(target), { recursive: true });
7
+ await writeFile(target, input.content);
8
+ return { path: input.path, bytes: new TextEncoder().encode(input.content).byteLength };
9
+ }
@@ -0,0 +1,7 @@
1
+ export declare const write: import("@aexhq/brain").ToolFactory<undefined, {
2
+ path: string;
3
+ content: string;
4
+ }, {
5
+ path: string;
6
+ bytes: number;
7
+ }>;
@@ -0,0 +1,10 @@
1
+ import { tool } from "@aexhq/brain";
2
+ import { run } from "../runtime/run.js";
3
+ import { inputSchema, outputSchema } from "./schema.js";
4
+ export const write = tool({
5
+ name: "write",
6
+ description: "Write UTF-8 text to a file in the Environment workspace, creating parent directories.",
7
+ input: inputSchema,
8
+ output: outputSchema,
9
+ run: async (input, context) => context.finish(await run(input, { workspace: process.cwd(), signal: context.signal })),
10
+ });
@@ -0,0 +1,5 @@
1
+ export interface RuntimeContext {
2
+ readonly signal: AbortSignal;
3
+ readonly workspace: string;
4
+ }
5
+ export declare function workspacePath(workspace: string, requested: string): string;
@@ -0,0 +1,10 @@
1
+ import { isAbsolute, relative, resolve } from "node:path";
2
+ export function workspacePath(workspace, requested) {
3
+ const root = resolve(workspace);
4
+ const target = resolve(root, requested);
5
+ const within = relative(root, target);
6
+ if (within === ".." || within.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) || isAbsolute(within)) {
7
+ throw new Error(`${requested} is outside the Environment workspace`);
8
+ }
9
+ return target;
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aexhq/tool-write",
3
- "version": "7.0.1",
3
+ "version": "8.0.0",
4
4
  "description": "Write UTF-8 text to a file in the Environment workspace, creating parent directories.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://aex.dev",
@@ -23,23 +23,37 @@
23
23
  "types": "./dist/index.d.ts",
24
24
  "import": "./dist/index.js"
25
25
  },
26
- "./package.json": "./package.json"
26
+ "./package.json": "./package.json",
27
+ "./runtime": {
28
+ "types": "./dist/packages/tool-write/src/index.d.ts",
29
+ "import": "./dist/packages/tool-write/src/index.js"
30
+ }
27
31
  },
28
32
  "files": [
29
33
  "dist",
30
34
  "README.md"
31
35
  ],
32
36
  "scripts": {
33
- "build": "node ../../tools/clean-dist.mjs && tsc -p tsconfig.json && tsc -p tsconfig.runtime.json && node ../../tools/build-tool-runtime.mjs",
37
+ "build": "node ../../tools/clean-dist.mjs && tsc -p tsconfig.json && node ../../tools/build-tool-runtime.mjs",
34
38
  "test": "npm run build && node --test test/*.test.mjs",
35
39
  "prepack": "npm run build"
36
40
  },
37
41
  "dependencies": {
38
- "@aexhq/brain": "0.29.0",
42
+ "@aexhq/brain": "0.30.0",
39
43
  "zod": "4.4.3"
40
44
  },
41
45
  "devDependencies": {
42
46
  "@types/node": "^24.3.0",
43
47
  "typescript": "^5.9.2"
48
+ },
49
+ "brain": {
50
+ "tools": {
51
+ ".": {
52
+ "runtime": "./runtime",
53
+ "exports": [
54
+ "write"
55
+ ]
56
+ }
57
+ }
44
58
  }
45
59
  }