@melra/file-runtime 0.3.0-alpha.11 → 0.3.0-alpha.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melra/file-runtime",
3
- "version": "0.3.0-alpha.11",
3
+ "version": "0.3.0-alpha.12",
4
4
  "description": "Workspace-confined file reference effect adapter for the MELRA kernel.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -21,12 +21,12 @@
21
21
  "dist"
22
22
  ],
23
23
  "dependencies": {
24
- "@melra/protocol": "0.3.0-alpha.11"
24
+ "@melra/protocol": "0.3.0-alpha.12"
25
25
  },
26
26
  "scripts": {
27
27
  "build": "tsc -p tsconfig.json",
28
28
  "clean": "rm -rf dist",
29
29
  "test": "vitest run",
30
- "typecheck": "tsc -p tsconfig.json --noEmit"
30
+ "typecheck": "tsc -p tsconfig.test.json"
31
31
  }
32
32
  }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
@@ -1,59 +0,0 @@
1
- // Copyright 2026 XAGI Labs Private Limited
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { mkdtemp, readFile, realpath, rm, symlink, writeFile } from "node:fs/promises";
4
- import { tmpdir } from "node:os";
5
- import { join, parse } from "node:path";
6
- import { afterEach, describe, expect, it } from "vitest";
7
- import { FileOperationSchema } from "@melra/protocol";
8
- import { FileRuntime } from "./index.js";
9
- const roots = [];
10
- afterEach(async () => {
11
- await Promise.all(roots.splice(0).map((root) => rm(root, { recursive: true, force: true })));
12
- });
13
- describe("FileRuntime", () => {
14
- it("writes atomically and returns a content hash", async () => {
15
- const root = await mkdtemp(join(tmpdir(), "melra-file-"));
16
- roots.push(root);
17
- const runtime = await FileRuntime.create({ root });
18
- const result = await runtime.execute(FileOperationSchema.parse({
19
- kind: "file",
20
- action: "write",
21
- path: "artifacts/result.txt",
22
- content: "verified",
23
- }));
24
- expect(result.written).toBe(true);
25
- expect(await readFile(join(root, "artifacts/result.txt"), "utf8")).toBe("verified");
26
- expect(result.sha256).toMatch(/^[a-f0-9]{64}$/);
27
- });
28
- it("blocks traversal and escaping symlinks", async () => {
29
- const root = await mkdtemp(join(tmpdir(), "melra-file-"));
30
- const outside = await mkdtemp(join(tmpdir(), "melra-outside-"));
31
- roots.push(root, outside);
32
- await writeFile(join(outside, "secret.txt"), "secret");
33
- await symlink(outside, join(root, "escape"));
34
- const runtime = await FileRuntime.create({ root });
35
- await expect(runtime.execute(FileOperationSchema.parse({
36
- kind: "file",
37
- action: "read",
38
- path: "../secret.txt",
39
- }))).rejects.toThrow("path_outside_workspace");
40
- await expect(runtime.execute(FileOperationSchema.parse({
41
- kind: "file",
42
- action: "read",
43
- path: "escape/secret.txt",
44
- }))).rejects.toThrow("path_outside_workspace");
45
- });
46
- it("creates a missing root but accepts one it cannot create", async () => {
47
- // A workspace the user has not made yet is created for them.
48
- const parent = await mkdtemp(join(tmpdir(), "melra-file-"));
49
- roots.push(parent);
50
- const nested = join(parent, "workspace", "inner");
51
- expect((await FileRuntime.create({ root: nested })).root).toBe(await realpath(nested));
52
- // Unhinged mode roots this runtime at the filesystem root. That directory
53
- // always exists, but Windows answers `mkdir C:\` with EPERM instead of the
54
- // no-op POSIX gives for an existing directory, so `create` must not ask.
55
- const driveRoot = parse(tmpdir()).root;
56
- expect((await FileRuntime.create({ root: driveRoot })).root).toBe(await realpath(driveRoot));
57
- });
58
- });
59
- //# sourceMappingURL=index.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,sCAAsC;AAEtC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,E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