Remove REA permission grants, scope ceilings, approval confirmations, and inert settings. Preserve selected local evidence, accept caller-chosen commands and paths, and report actual runtime failures. Harden provider results, schema serialization, snapshot evidence binding, archive paths, source maps, native screenshots, managed EH parsing, and cancellation cleanup. Regenerate tool metadata and document direct invocation. BREAKING CHANGE: Removed permission configuration and policy commands, approval fields, filesystem scope inputs, and fixed confirmation options. Process capture inherits the host environment and accepts command names; callers must refresh tool schemas and migrate removed fields.
183 lines
5.3 KiB
TypeScript
183 lines
5.3 KiB
TypeScript
import { execFile } from "node:child_process";
|
|
import { promisify } from "node:util";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
import { z } from "zod";
|
|
|
|
const execute = promisify(execFile);
|
|
const bridgePath = new URL(
|
|
"../../../../bridge/hopper_bridge.py",
|
|
import.meta.url,
|
|
);
|
|
const probePath = new URL(
|
|
"../../../fixtures/hopperBridgeFacadeProbe.py",
|
|
import.meta.url,
|
|
);
|
|
|
|
const probeResultSchema = z.strictObject({
|
|
imported_without_hopper: z.strictObject({
|
|
type: z.literal("CapabilityUnavailableError"),
|
|
diagnostic_type: z.literal("capability_unavailable"),
|
|
}),
|
|
current_document: z.literal("fixture"),
|
|
current_address: z.literal("0x401000"),
|
|
strings: z.strictObject({ "0x401234": z.literal("fixture string") }),
|
|
procedure_references: z.strictObject({
|
|
procedure: z.strictObject({
|
|
address: z.literal("0x401000"),
|
|
name: z.literal("fixture-procedure"),
|
|
classification: z.null(),
|
|
}),
|
|
direction: z.literal("outgoing"),
|
|
reference_kinds_available: z.literal(false),
|
|
unresolved_calls: z.array(z.unknown()),
|
|
references: z.array(z.unknown()),
|
|
}),
|
|
inventory_replies: z.array(
|
|
z.strictObject({
|
|
id: z.number().int(),
|
|
result: z.array(
|
|
z.strictObject({ address: z.string(), value: z.string() }),
|
|
),
|
|
}),
|
|
),
|
|
provider_faults: z.array(
|
|
z.strictObject({
|
|
id: z.literal(1),
|
|
error: z.strictObject({
|
|
code: z.literal(-32000),
|
|
message: z.string(),
|
|
type: z.literal("bridge_exception"),
|
|
}),
|
|
}),
|
|
),
|
|
malformed_requests: z.array(z.unknown()),
|
|
session_document_reused: z.literal(true),
|
|
shared_document_shutdown: z.strictObject({
|
|
shutdown: z.literal(true),
|
|
analysis_stopped: z.literal(false),
|
|
document_closed: z.literal(false),
|
|
document_retained: z.literal(true),
|
|
}),
|
|
analysis_guard: z.strictObject({
|
|
type: z.literal("CapabilityUnavailableError"),
|
|
diagnostic_type: z.literal("capability_unavailable"),
|
|
message: z.string(),
|
|
}),
|
|
bridge_messages: z.tuple([
|
|
z.strictObject({
|
|
id: z.literal(7),
|
|
event: z.strictObject({
|
|
type: z.literal("progress"),
|
|
phase: z.literal("hopper_bridge"),
|
|
completed: z.literal(0),
|
|
total: z.literal(1),
|
|
message: z.literal("Hopper bridge started request"),
|
|
}),
|
|
}),
|
|
z.strictObject({
|
|
id: z.literal(7),
|
|
event: z.strictObject({
|
|
type: z.literal("diagnostic"),
|
|
error: z.strictObject({
|
|
code: z.literal(-32000),
|
|
message: z.literal("RuntimeError: Hopper bridge operation failed"),
|
|
type: z.literal("bridge_exception"),
|
|
}),
|
|
}),
|
|
}),
|
|
z.strictObject({
|
|
id: z.literal(7),
|
|
error: z.strictObject({
|
|
code: z.literal(-32000),
|
|
message: z.literal("RuntimeError: Hopper bridge operation failed"),
|
|
type: z.literal("bridge_exception"),
|
|
}),
|
|
}),
|
|
]),
|
|
invalid_id_response: z.strictObject({
|
|
id: z.literal(0),
|
|
error: z.strictObject({
|
|
code: z.literal(-32000),
|
|
message: z.literal("Invalid Hopper bridge request"),
|
|
type: z.literal("invalid_request"),
|
|
}),
|
|
}),
|
|
});
|
|
|
|
describe("Hopper API facade", () => {
|
|
it("imports without Hopper globals and gates exhaustive work during analysis", async () => {
|
|
const { stdout } = await execute(
|
|
"python3",
|
|
[probePath.pathname, bridgePath.pathname],
|
|
{
|
|
encoding: "utf8",
|
|
timeout: 3_000,
|
|
maxBuffer: 1_024 * 1_024,
|
|
},
|
|
);
|
|
const result = probeResultSchema.parse(JSON.parse(stdout));
|
|
expect(result.provider_faults.map((reply) => reply.error.message)).toEqual([
|
|
"TypeError: Hopper bridge operation failed",
|
|
"ValueError: Hopper bridge operation failed",
|
|
"KeyError: Hopper bridge operation failed",
|
|
]);
|
|
expect(result.malformed_requests).toEqual([
|
|
...[0, 0, 0, 0, 0, 2, 3, 0, 4, 5, 6, 7].map((id) => ({
|
|
id,
|
|
error: {
|
|
code: -32000,
|
|
type: "invalid_request",
|
|
message: "Invalid Hopper bridge request",
|
|
},
|
|
})),
|
|
{
|
|
id: 8,
|
|
error: {
|
|
code: -32000,
|
|
type: "authorization",
|
|
message: "Invalid bridge capability",
|
|
},
|
|
},
|
|
{ id: 9, result: "0x401000" },
|
|
]);
|
|
expect(result.inventory_replies).toEqual([
|
|
{
|
|
id: 1,
|
|
result: [
|
|
{ address: "0x2", value: "string-2" },
|
|
{ address: "0x10", value: "string-16" },
|
|
{ address: "0x100", value: "string-256" },
|
|
],
|
|
},
|
|
{
|
|
id: 2,
|
|
result: [
|
|
{ address: "0x2", value: "name-2" },
|
|
{ address: "0x10", value: "name-16" },
|
|
{ address: "0x100", value: "name-256" },
|
|
],
|
|
},
|
|
{ id: 3, result: [{ address: "0x10", value: "string-16" }] },
|
|
{ id: 4, result: [{ address: "0x10", value: "name-16" }] },
|
|
{ id: 5, result: [] },
|
|
{ id: 6, result: [] },
|
|
]);
|
|
expect(result.procedure_references).toEqual({
|
|
procedure: {
|
|
address: "0x401000",
|
|
name: "fixture-procedure",
|
|
classification: null,
|
|
},
|
|
direction: "outgoing",
|
|
reference_kinds_available: false,
|
|
unresolved_calls: [],
|
|
references: [],
|
|
});
|
|
expect(stdout).not.toContain("supersecret");
|
|
expect(result.analysis_guard.message).toContain(
|
|
"requires completed Hopper background analysis",
|
|
);
|
|
});
|
|
});
|