@themoltnet/pi-runtime 0.16.0 → 0.18.0

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.
@@ -0,0 +1,87 @@
1
+ /**
2
+ * The policy each shape resolves to. The E2E suite creates real runtime
3
+ * policies from these same values, so a live REST-resolved policy and the unit
4
+ * fixture cannot drift apart.
5
+ */
6
+ export declare const ESCAPE_POLICY_FIXTURES: Record<EscapePolicyShape, EscapePolicyFixture>;
7
+
8
+ export declare interface EscapePolicyFixture {
9
+ /** Runtime/MCP tool names the policy allows. */
10
+ tools: string[];
11
+ /** Shell argv-prefix rules, the only authority for shell invocations. */
12
+ shellCommands: Array<{
13
+ argvPrefix: [string, ...string[]];
14
+ }>;
15
+ }
16
+
17
+ /**
18
+ * Deterministic escape-technique corpus for the tool-policy gate (issue #2275
19
+ * §5). No LLM, no VM: every case is a `bash` command run through the real shell
20
+ * analyzer and the real gate, with the decision asserted.
21
+ *
22
+ * The corpus has two jobs:
23
+ *
24
+ * 1. **Regression fence.** A change that widens the gate turns a `block` case
25
+ * into a failing test rather than a quiet policy hole.
26
+ * 2. **Honest documentation of grant semantics.** Some cases are allowed *by
27
+ * design* because the operator asked for a broad grant. Those carry
28
+ * `documentsGrantBreadth: true` so a reader can tell "this is what you bought"
29
+ * from "this is contained".
30
+ *
31
+ * Adding a case: pick the fixture whose shape you are testing, run the command
32
+ * through the gate, and record the decision you observe **only if it is the
33
+ * decision you want**. A case whose observed decision is wrong does not belong
34
+ * here with its observed value — see the note on unfixed gaps at the bottom.
35
+ */
36
+ /** The policy shapes a case can be evaluated against. */
37
+ export declare type EscapePolicyShape =
38
+ /** Structured tools only, no shell grants at all. */
39
+ 'no-shell'
40
+ /** Tool grants that happen to share a name with a shell program. */
41
+ | 'tool-grant-only'
42
+ /** A multi-token argv-prefix rule: `ls -la`. */
43
+ | 'narrow-shell'
44
+ /** A three-token argv-prefix rule on a subcommand: `gh pr view`. */
45
+ | 'multi-token-shell'
46
+ /** One-token rules on programs whose flags can name another command. */
47
+ | 'one-token-escape-flags'
48
+ /** A one-token rule: `git`, i.e. "any git invocation". */
49
+ | 'one-token-shell'
50
+ /** A one-token rule on a GTFOBins-escapable program: `find`. */
51
+ | 'one-token-escapable';
52
+
53
+ export declare const TOOL_POLICY_ESCAPE_CASES: ToolPolicyEscapeCase[];
54
+
55
+ /** The smaller subset the live-policy E2E replays against real runtime policies. */
56
+ export declare const TOOL_POLICY_ESCAPE_E2E_CASES: ToolPolicyEscapeCase[];
57
+
58
+ /**
59
+ * The gate's verdict:
60
+ * - `{ allow: true }` — let the tool run.
61
+ * - `{ allow: false, reason }` — block it (enforce mode).
62
+ * - `{ audit, ... }` — would-block, but proceed and record it (watch mode).
63
+ */
64
+ declare type ToolPolicyDecisionReason = 'policy_off' | 'executor_protocol_tool' | 'policy_allowed' | 'shell_command_prefix_allowed' | 'shell_command_unresolvable' | 'arbitrary_code_interpreter' | 'shell_output_redirection_not_permitted' | 'unsafe_environment_assignment' | 'tool_not_permitted';
65
+
66
+ export declare interface ToolPolicyEscapeCase {
67
+ name: string;
68
+ policyShape: EscapePolicyShape;
69
+ command: string;
70
+ expectedAllow: boolean;
71
+ reasonCode: ToolPolicyDecisionReason;
72
+ /** Executable names the decision must report, when it reports any. */
73
+ missing?: string[];
74
+ /** Short technique family, for grouping failures in test output. */
75
+ technique: string;
76
+ /**
77
+ * Set when the case is allowed because the operator granted it broadly, not
78
+ * because the gate contained anything. These are the cost of a broad rule,
79
+ * stated out loud.
80
+ */
81
+ documentsGrantBreadth?: true;
82
+ /** Included in the smaller live-policy E2E subset. */
83
+ e2e?: true;
84
+ source: string;
85
+ }
86
+
87
+ export { }