Keep seal-use probe's stdout to a single JSON document
`runProbe` wrote its progress notes and three separate JSON blobs to stdout, so every consumer parsing the output — `seal-use probe | jq`, the Agent Harness — got prose interleaved with data. The command is also in the help registry, so this was a documented command breaking its own contract. The probe now returns one `ProbeResult` and the command prints it through `printJson`; the `[probe] …` narration moves to stderr, which is the diagnostics channel. The dev-script entry point keeps the same payload and its exit code. Classified read-only too: `probe` reads tenant state and writes nothing, but the allow-list had no entry, so the MCP read-only tool refused it. Its trailing token is an enterprise selector rather than a verb, so the matcher accepts the bare form and bare-plus-selector while still refusing a third token.
This commit is contained in:
1 parent
289ef664da
commit
97bf3301a3
5 files changed
+190
-19
No files matched your search
@@ -1,8 +1,10 @@
|
||||
import { runProbe } from "../../probe.js";
|
||||
import { stringOption } from "../parser.js";
|
||||
import { printJson } from "../printer.js";
|
||||
import type { ParsedArgs } from "../types.js";
|
||||
|
||||
export async function handleProbeCommand(action: string | undefined, maybeName: string | undefined, args: ParsedArgs) {
|
||||
const corpId = maybeName ?? stringOption(args.options.corp) ?? (action && action !== "--corp" ? action : undefined);
|
||||
await runProbe({ corpId });
|
||||
// One JSON document on stdout; runProbe narrates progress on stderr only.
|
||||
printJson(await runProbe({ corpId }));
|
||||
}
|
||||
@@ -128,6 +128,14 @@ describe("CLI read-only classification", () => {
|
||||
expect(isReadOnlyCliCommand(["openapi", "extra"])).toBe(false);
|
||||
});
|
||||
|
||||
test("probe is read-only bare or with its enterprise selector, but not beyond", () => {
|
||||
// `seal-use probe [<corpId>]` takes a selector, not a verb: the allow-list
|
||||
// entry covers the bare form and the selector form is matched separately.
|
||||
expect(isReadOnlyCliCommand(["probe"])).toBe(true);
|
||||
expect(isReadOnlyCliCommand(["probe", "corp-a"])).toBe(true);
|
||||
expect(isReadOnlyCliCommand(["probe", "corp-a", "extra"])).toBe(false);
|
||||
});
|
||||
|
||||
test("refuses command lines that cannot be parsed", () => {
|
||||
expect(isReadOnlyCliCommand(["--json"])).toBe(false);
|
||||
});
|
||||
|
||||
@@ -81,9 +81,20 @@ const READ_ONLY_COMMANDS: Record<string, string[]> = {
|
||||
skill: ["dump", "status"],
|
||||
service: ["status", "logs"],
|
||||
doctor: ["", "guide", "paths", "tenant", "auth"],
|
||||
// Bare form only; the optional trailing `<corpId>` selector is handled by
|
||||
// SELECTOR_POSITIONAL_AREAS below, since a bare entry matches no tokens.
|
||||
probe: [""],
|
||||
openapi: [""]
|
||||
};
|
||||
|
||||
/**
|
||||
* Areas whose trailing positional is an enterprise selector, not a subcommand:
|
||||
* `seal-use probe [<corpId>]` has no verb to list, so its read form is the bare
|
||||
* command plus at most that one selector. A second token is not a form the area
|
||||
* accepts at all, and falls through to the refusal below.
|
||||
*/
|
||||
const SELECTOR_POSITIONAL_AREAS = new Set(["probe"]);
|
||||
|
||||
/**
|
||||
* Read-only commands handled by the CLI outside the help registry (no area/subcommand shape).
|
||||
* `help` is limited to the bare form on purpose: `help <topic>` adds nothing over the skill docs.
|
||||
@@ -110,6 +121,8 @@ export function isReadOnlyCliCommand(argv: string[]): boolean {
|
||||
}
|
||||
|
||||
if (actionTokens.length === 0 && TOP_LEVEL_READ_ONLY.has(area)) return true;
|
||||
// The `<corpId>` selector form; the bare form falls through to the `""` entry.
|
||||
if (SELECTOR_POSITIONAL_AREAS.has(area) && actionTokens.length === 1) return true;
|
||||
|
||||
const allowed = READ_ONLY_COMMANDS[area];
|
||||
if (!allowed) return false;
|
||||
|
||||
Reference in new issue
Block a user