51 lines
2.2 KiB
JavaScript
51 lines
2.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
import { realpath } from "node:fs/promises";
|
|
|
|
const [mode, inspectPath] = process.argv.slice(2);
|
|
assert.ok(["default", "opt-in"].includes(mode), `unsupported mode: ${mode}`);
|
|
assert.ok(inspectPath, "inspect JSON path is required");
|
|
|
|
const data = JSON.parse(await readFile(inspectPath, "utf8"));
|
|
const plugin = data.plugin;
|
|
assert.equal(plugin.id, "aios-tenant-boundary");
|
|
assert.equal(plugin.version, "2.1.0-rc.1");
|
|
assert.equal(plugin.status, "loaded");
|
|
assert.equal(plugin.activated, true);
|
|
assert.equal(await realpath(plugin.rootDir), await realpath(new URL("..", import.meta.url)));
|
|
assert.equal(await realpath(plugin.source), await realpath(new URL("../dist/index.js", import.meta.url)));
|
|
assert.equal(data.install.source, "path");
|
|
assert.equal(await realpath(data.install.installPath), await realpath(plugin.rootDir));
|
|
|
|
const hooks = data.typedHooks
|
|
.map(({ name, priority }) => ({ name, priority }))
|
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
const expectedNames = mode === "default"
|
|
? ["before_tool_call"]
|
|
: ["agent_end", "before_agent_run", "before_tool_call"];
|
|
assert.deepEqual(hooks.map(({ name }) => name), expectedNames);
|
|
assert.ok(hooks.every(({ priority }) => priority === 100));
|
|
|
|
const diagnostics = data.diagnostics ?? [];
|
|
assert.equal(
|
|
diagnostics.filter(({ level, severity }) =>
|
|
["error", "fatal"].includes(String(level ?? severity).toLowerCase())).length,
|
|
0,
|
|
);
|
|
if (mode === "default") {
|
|
assert.deepEqual(
|
|
diagnostics.map(({ level, message }) => ({ level, message })).sort((a, b) => a.message.localeCompare(b.message)),
|
|
["agent_end", "before_agent_run"].map((hook) => ({
|
|
level: "warn",
|
|
message: `typed hook "${hook}" blocked because non-bundled plugins must set plugins.entries.aios-tenant-boundary.hooks.allowConversationAccess=true`,
|
|
})).sort((a, b) => a.message.localeCompare(b.message)),
|
|
);
|
|
} else {
|
|
assert.deepEqual(diagnostics, []);
|
|
}
|
|
|
|
const properties = plugin.configJsonSchema?.properties ?? {};
|
|
for (const key of ["approvalTimeoutMs", "blockUnknownAgentRuns"]) {
|
|
assert.ok(Object.hasOwn(properties, key), `missing runtime schema property: ${key}`);
|
|
}
|