@capybara-hq/testing 0.1.0-rc.19 → 0.1.0-rc.20
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/dist/index.d.ts
CHANGED
|
@@ -23,4 +23,5 @@ export { FAKE_EXTENSIONS, type FakeExtensionName, fakeExtensionDir, fakeExtensio
|
|
|
23
23
|
export { cardRecorded, cookieRequest, createAgent, createConversation, createLocalAccount, createOrg, eventsOf, joinOrg, type KernelApp, type KernelRequest, type KernelRequestOptions, type KernelResponse, login, pidOwningLocalPort, postMessage, sleep, startTestKernel, TEST_PASSWORD, type TestKernel, testKernelConfig, truncateTables, waitFor, waitForEvent, waitForTerminal, } from "./kernel-helpers.js";
|
|
24
24
|
export { isPngBase64, pdfBase64, pdfSampleWord, redPngBase64, solidPngBase64, } from "./media-samples.js";
|
|
25
25
|
export { type ConformanceTarget, checkDeclaredParameters, describeModelProviderConformance, MEDIA_SAMPLES, thinkingReplayParams, } from "./model-conformance.js";
|
|
26
|
+
export { type NativeFixtureEntry, runSandboxNativeConformance, type SandboxNativeFixture, } from "./sandbox-native-conformance.js";
|
|
26
27
|
export { openSse, type SseClient, type SseMessage } from "./sse.js";
|
package/dist/index.js
CHANGED
|
@@ -23,4 +23,5 @@ export { FAKE_EXTENSIONS, fakeExtensionDir, fakeExtensionEntry, packFixture, } f
|
|
|
23
23
|
export { cardRecorded, cookieRequest, createAgent, createConversation, createLocalAccount, createOrg, eventsOf, joinOrg, login, pidOwningLocalPort, postMessage, sleep, startTestKernel, TEST_PASSWORD, testKernelConfig, truncateTables, waitFor, waitForEvent, waitForTerminal, } from "./kernel-helpers.js";
|
|
24
24
|
export { isPngBase64, pdfBase64, pdfSampleWord, redPngBase64, solidPngBase64, } from "./media-samples.js";
|
|
25
25
|
export { checkDeclaredParameters, describeModelProviderConformance, MEDIA_SAMPLES, thinkingReplayParams, } from "./model-conformance.js";
|
|
26
|
+
export { runSandboxNativeConformance, } from "./sandbox-native-conformance.js";
|
|
26
27
|
export { openSse } from "./sse.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SandboxOperation } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
/** Fixture setup only. All paths and symlink targets are absolute and inside the owned root. */
|
|
3
|
+
export type NativeFixtureEntry = {
|
|
4
|
+
path: string;
|
|
5
|
+
kind: "directory";
|
|
6
|
+
} | {
|
|
7
|
+
path: string;
|
|
8
|
+
kind: "file";
|
|
9
|
+
data: Uint8Array;
|
|
10
|
+
} | {
|
|
11
|
+
path: string;
|
|
12
|
+
kind: "symlink";
|
|
13
|
+
target: string;
|
|
14
|
+
};
|
|
15
|
+
/** Supplies isolated ordinary files and fresh native operations; never a permission grant. */
|
|
16
|
+
export interface SandboxNativeFixture {
|
|
17
|
+
/** An empty owned temporary directory, expressed as an absolute POSIX device path. */
|
|
18
|
+
root: string;
|
|
19
|
+
/** A new operation ID for each factory call, consumed by one native method invocation. */
|
|
20
|
+
operation(): Promise<Pick<SandboxOperation, "readFile" | "writeFile" | "stat" | "list" | "scan">>;
|
|
21
|
+
/** Creates entries and their parents inside root; preserves entries from earlier seed calls. */
|
|
22
|
+
seed(entries: readonly NativeFixtureEntry[]): Promise<void>;
|
|
23
|
+
/** Removes fixture-owned resources, including after an assertion failure. */
|
|
24
|
+
dispose(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Checks ordinary native API compatibility in a fixture-owned temporary root. Each invocation
|
|
28
|
+
* gets a fresh operation. Passing does not establish OS enforcement or permission capabilities.
|
|
29
|
+
* The fixture owns setup and cleanup; no official plugin, database or network service is used.
|
|
30
|
+
*/
|
|
31
|
+
export declare function runSandboxNativeConformance(fixture: SandboxNativeFixture): Promise<void>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { posix } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Checks ordinary native API compatibility in a fixture-owned temporary root. Each invocation
|
|
5
|
+
* gets a fresh operation. Passing does not establish OS enforcement or permission capabilities.
|
|
6
|
+
* The fixture owns setup and cleanup; no official plugin, database or network service is used.
|
|
7
|
+
*/
|
|
8
|
+
export async function runSandboxNativeConformance(fixture) {
|
|
9
|
+
const path = (name) => posix.join(fixture.root, name);
|
|
10
|
+
const signal = new AbortController().signal;
|
|
11
|
+
const fresh = async () => {
|
|
12
|
+
const operation = await fixture.operation();
|
|
13
|
+
assert(operation.list && operation.scan, "Native conformance requires list and scan");
|
|
14
|
+
return operation;
|
|
15
|
+
};
|
|
16
|
+
const read = async (name, maxBytes) => (await fresh()).readFile(path(name), { maxBytes, signal });
|
|
17
|
+
const stat = async (name) => (await fresh()).stat(path(name), signal);
|
|
18
|
+
const write = async (name, data) => (await fresh()).writeFile(path(name), data, signal);
|
|
19
|
+
const list = async (name, limit) => (await fresh()).list(path(name), { limit, signal });
|
|
20
|
+
const scan = async (name) => (await fresh()).scan(path(name), { signal });
|
|
21
|
+
const directory = (name) => ({ path: path(name), kind: "directory" });
|
|
22
|
+
const file = (name) => ({
|
|
23
|
+
path: path(name),
|
|
24
|
+
kind: "file",
|
|
25
|
+
data: new Uint8Array(),
|
|
26
|
+
});
|
|
27
|
+
const link = (name, target) => ({
|
|
28
|
+
path: path(name),
|
|
29
|
+
kind: "symlink",
|
|
30
|
+
target: path(target),
|
|
31
|
+
});
|
|
32
|
+
const candidates = (names) => names.map((name) => ({
|
|
33
|
+
path: path(name),
|
|
34
|
+
suggestedName: posix.basename(name),
|
|
35
|
+
}));
|
|
36
|
+
try {
|
|
37
|
+
assert.equal(await stat("missing"), null, "missing stat must return null");
|
|
38
|
+
assert.equal(await read("missing", 10), null, "missing read must return null");
|
|
39
|
+
assert.equal(await list("missing", 10), null, "missing list must return null");
|
|
40
|
+
assert.deepEqual(await scan("missing"), [], "missing scan must be empty");
|
|
41
|
+
await fixture.seed([directory("empty")]);
|
|
42
|
+
assert.equal((await stat("empty"))?.isDir, true);
|
|
43
|
+
assert.equal(await read("empty", 10), null, "directory read must return null");
|
|
44
|
+
assert.deepEqual(await list("empty", 0), { entries: [], truncated: false });
|
|
45
|
+
const bytes = new Uint8Array([0, 255, 128, 10, 65, 0]);
|
|
46
|
+
await write("parents/nested/binary", bytes);
|
|
47
|
+
assert.deepEqual(await stat("parents/nested/binary"), { size: 6, isDir: false });
|
|
48
|
+
assert.deepEqual(await read("parents/nested/binary", 6), { data: bytes, truncated: false });
|
|
49
|
+
assert.deepEqual(await read("parents/nested/binary", 100), { data: bytes, truncated: false });
|
|
50
|
+
assert.deepEqual(await read("parents/nested/binary", 3), {
|
|
51
|
+
data: new Uint8Array([0, 255, 128]),
|
|
52
|
+
truncated: true,
|
|
53
|
+
});
|
|
54
|
+
assert.deepEqual(await read("parents/nested/binary", 0), {
|
|
55
|
+
data: new Uint8Array(),
|
|
56
|
+
truncated: true,
|
|
57
|
+
});
|
|
58
|
+
await write("parents/nested/binary", new Uint8Array());
|
|
59
|
+
assert.deepEqual(await read("parents/nested/binary", 0), {
|
|
60
|
+
data: new Uint8Array(),
|
|
61
|
+
truncated: false,
|
|
62
|
+
});
|
|
63
|
+
assert.deepEqual(await stat("parents/nested/binary"), { size: 0, isDir: false });
|
|
64
|
+
assert.equal(await stat("parents/nested/binary/missing"), null);
|
|
65
|
+
assert.equal(await read("parents/nested/binary/missing", 10), null);
|
|
66
|
+
assert.equal(await list("parents/nested/binary/missing", 10), null);
|
|
67
|
+
assert.deepEqual(await scan("parents/nested/binary/missing"), []);
|
|
68
|
+
await assert.rejects(() => list("parents/nested/binary", 5));
|
|
69
|
+
await assert.rejects(() => scan("parents/nested/binary"));
|
|
70
|
+
await fixture.seed([
|
|
71
|
+
directory("listing/B"),
|
|
72
|
+
file("listing/a"),
|
|
73
|
+
file("listing/\u{1f600}"),
|
|
74
|
+
file("listing/\ue000"),
|
|
75
|
+
link("listing/alias", "listing/B"),
|
|
76
|
+
link("listing/dangling", "listing/missing"),
|
|
77
|
+
link("file-link", "listing/a"),
|
|
78
|
+
]);
|
|
79
|
+
assert.deepEqual(await list("listing", 0), { entries: [], truncated: true });
|
|
80
|
+
assert.deepEqual(await list("listing", 2), {
|
|
81
|
+
entries: [
|
|
82
|
+
{ name: "B", isDir: true },
|
|
83
|
+
{ name: "a", isDir: false },
|
|
84
|
+
],
|
|
85
|
+
truncated: true,
|
|
86
|
+
});
|
|
87
|
+
assert.deepEqual(await list("listing", 6), {
|
|
88
|
+
entries: [
|
|
89
|
+
{ name: "B", isDir: true },
|
|
90
|
+
{ name: "a", isDir: false },
|
|
91
|
+
{ name: "alias", isDir: true },
|
|
92
|
+
{ name: "dangling", isDir: false },
|
|
93
|
+
{ name: "\u{1f600}", isDir: false },
|
|
94
|
+
{ name: "\ue000", isDir: false },
|
|
95
|
+
],
|
|
96
|
+
truncated: false,
|
|
97
|
+
});
|
|
98
|
+
await write("file-link", bytes);
|
|
99
|
+
assert.deepEqual(await read("listing/a", 6), { data: bytes, truncated: false });
|
|
100
|
+
assert.deepEqual(await stat("file-link"), { size: 6, isDir: false });
|
|
101
|
+
assert.deepEqual(await list("listing/alias", 1), { entries: [], truncated: false });
|
|
102
|
+
assert.equal(await read("listing/dangling", 10), null);
|
|
103
|
+
await assert.rejects(() => write("listing/dangling", bytes));
|
|
104
|
+
assert.equal(await stat("listing/missing"), null, "dangling writes must not create a target");
|
|
105
|
+
await fixture.seed([file("percent/a%2f%ZZ/AGENTS.md"), file("percent/a%5c%/AGENTS.md")]);
|
|
106
|
+
assert.deepEqual(await scan("percent"), candidates(["percent/a%2f%ZZ", "percent/a%5c%"]));
|
|
107
|
+
const longName = "x".repeat(65);
|
|
108
|
+
await fixture.seed([
|
|
109
|
+
file("scan/AGENTS.md"),
|
|
110
|
+
file("scan/a/.git"),
|
|
111
|
+
file("scan/a/deep/AGENTS.md"),
|
|
112
|
+
file("scan/a/deep/too-deep/.git"),
|
|
113
|
+
directory("scan/false-hit/AGENTS.md"),
|
|
114
|
+
file("scan/.hidden/.git"),
|
|
115
|
+
file("scan/node_modules/.git"),
|
|
116
|
+
file("scan/Library/.git"),
|
|
117
|
+
file("scan/a/node_modules/.git"),
|
|
118
|
+
file("scan/a/Library/.git"),
|
|
119
|
+
file(`scan/${longName}/.git`),
|
|
120
|
+
file(`scan/${longName}/valid/.git`),
|
|
121
|
+
file("scan/ leading/.git"),
|
|
122
|
+
file("scan/ trailing /.git"),
|
|
123
|
+
file("scan/ leading/valid/.git"),
|
|
124
|
+
link("scan/link", "scan/a"),
|
|
125
|
+
]);
|
|
126
|
+
assert.deepEqual(await scan("scan"), candidates([
|
|
127
|
+
"scan",
|
|
128
|
+
"scan/ leading/valid",
|
|
129
|
+
"scan/a",
|
|
130
|
+
"scan/a/Library",
|
|
131
|
+
"scan/a/deep",
|
|
132
|
+
`scan/${longName}/valid`,
|
|
133
|
+
]), "scan must descend past hits and invalid names, and apply depth/skips exactly");
|
|
134
|
+
await fixture.seed([
|
|
135
|
+
...Array.from({ length: 51 }, (_, i) => file(`results/b${String(i).padStart(3, "0")}/.git`)),
|
|
136
|
+
file("results/a/deep/.git"),
|
|
137
|
+
]);
|
|
138
|
+
assert.deepEqual(await scan("results"), candidates([
|
|
139
|
+
"results/a/deep",
|
|
140
|
+
...Array.from({ length: 49 }, (_, i) => `results/b${String(i).padStart(3, "0")}`),
|
|
141
|
+
]), "scan truncates to 50 only after sorting all visited candidates");
|
|
142
|
+
await fixture.seed([
|
|
143
|
+
...Array.from({ length: 500 }, (_, i) => directory(`visits/d${String(i).padStart(3, "0")}`)),
|
|
144
|
+
file("visits/d498/.git"),
|
|
145
|
+
file("visits/d499/.git"),
|
|
146
|
+
file("visits/d000/deep/.git"),
|
|
147
|
+
]);
|
|
148
|
+
assert.deepEqual(await scan("visits"), candidates(["visits/d498"]), "base counts as visit one; breadth-first visit 500 includes d498, excludes d499 and depth two");
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
await fixture.dispose();
|
|
152
|
+
}
|
|
153
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/testing",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.20",
|
|
4
4
|
"description": "Test helpers for Capybara: test containers, dual-replica harness and fake third-party servers",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -47,18 +47,18 @@
|
|
|
47
47
|
"tsx": "^4.23.15",
|
|
48
48
|
"ws": "^8.22.0",
|
|
49
49
|
"zod": "^4.6.7",
|
|
50
|
-
"@capybara-hq/kernel": "^0.1.0-rc.
|
|
50
|
+
"@capybara-hq/kernel": "^0.1.0-rc.35"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/pg": "^8.23.1",
|
|
54
54
|
"@types/ws": "^8.18.2",
|
|
55
|
-
"@capybara-hq/plugin-
|
|
56
|
-
"@capybara-hq/plugin-
|
|
55
|
+
"@capybara-hq/plugin-client": "^0.1.0-rc.5",
|
|
56
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.25"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"vitest": "^5.0.5",
|
|
60
|
-
"@capybara-hq/plugin-
|
|
61
|
-
"@capybara-hq/plugin-
|
|
60
|
+
"@capybara-hq/plugin-tools": "^0.1.0-rc.15",
|
|
61
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.25"
|
|
62
62
|
},
|
|
63
63
|
"peerDependenciesMeta": {
|
|
64
64
|
"@capybara-hq/plugin-tools": {
|