@noppu-labs/opencode-permission-reviewer 3.0.0 → 3.2.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.
- package/CHANGELOG.md +155 -0
- package/MIGRATION.md +6 -8
- package/README.md +16 -7
- package/dist/explain.d.ts +3 -4
- package/dist/explain.js +9219 -5219
- package/dist/index.d.ts +1011 -863
- package/dist/index.js +17541 -12853
- package/dist/rpc.d.ts +38 -38
- package/dist/rpc.js +30 -21
- package/dist/tui/config/loader.ts +14 -1
- package/dist/tui/config/trust-boundary-keys.ts +2 -0
- package/dist/tui/config/trust-boundary.ts +13 -0
- package/dist/tui/config-fields.ts +21 -1
- package/dist/tui/config.ts +12 -2
- package/dist/tui/failure-kind.ts +28 -0
- package/dist/tui/system-one-routing.ts +110 -0
- package/dist/tui/tui.tsx +19 -9
- package/dist/tui/types.ts +39 -2
- package/dist/tui/ui/action-fit.ts +161 -0
- package/dist/tui/ui/action-spans.tsx +60 -0
- package/dist/tui/ui/attribution.ts +113 -0
- package/dist/tui/ui/components.tsx +41 -5
- package/dist/tui/ui/config-notices.ts +137 -0
- package/dist/tui/ui/fit-parts.ts +76 -0
- package/dist/tui/ui/manual-toast.ts +87 -0
- package/dist/tui/ui/review-feed.ts +30 -5
- package/dist/tui/ui/review-overlay.tsx +33 -5
- package/dist/tui/ui/review-result.tsx +23 -5
- package/dist/tui/ui/review-theme.ts +8 -1
- package/dist/tui/ui/v1-host.ts +37 -10
- package/dist/tui/ui/v2.tsx +17 -1
- package/dist/tui/ui-protocol.ts +63 -20
- package/dist/tui/ui-state.ts +16 -1
- package/dist/tui/ui-status-extras.ts +165 -0
- package/dist/tui/ui-status-parse.ts +60 -2
- package/dist/tui/ui-text-elide.ts +89 -0
- package/package.json +14 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,179 +1,220 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { TypeSafeClient } from "@typesafe-ai/sdk";
|
|
2
|
+
import "@opencode/client";
|
|
3
|
+
import { Plugin } from "@opencode-ai/plugin";
|
|
4
|
+
import { Plugin as Plugin$1 } from "@opencode/plugin";
|
|
5
|
+
import "@opencode/plugin/promise/permission";
|
|
6
|
+
//#region src/verified-ssh-script.d.ts
|
|
4
7
|
interface VerifiedScriptEvidence {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
sha256: string;
|
|
9
|
+
destination: string;
|
|
10
|
+
port?: number;
|
|
11
|
+
shell: "bash" | "sh";
|
|
12
|
+
bytes?: number;
|
|
13
|
+
status: "full" | "reused" | "unavailable";
|
|
14
|
+
text: string;
|
|
15
|
+
cacheKey?: string;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/shell-token.d.ts
|
|
19
|
+
/** A run of a token's value that shares one quoting. `opaque` marks text the
|
|
20
|
+
* lexer kept whole from a substitution (an unquoted backtick form): it is
|
|
21
|
+
* the substitution's command, not the outer command's, so no operator in it
|
|
22
|
+
* acts on the outer command. It stays unquoted otherwise: a glob character
|
|
23
|
+
* in it reads as it did before. */
|
|
24
|
+
interface TokenSpan {
|
|
25
|
+
text: string;
|
|
26
|
+
quoted: boolean;
|
|
27
|
+
opaque?: true;
|
|
13
28
|
}
|
|
14
|
-
|
|
15
29
|
interface ShellToken {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
/** Original text including any surrounding quotes. */
|
|
31
|
+
raw: string;
|
|
32
|
+
/** Unquoted/normalized value used for comparisons. */
|
|
33
|
+
value: string;
|
|
34
|
+
/** Value split into spans by quoting: every character of `value` appears
|
|
35
|
+
* in exactly one span, marked `quoted` when it came from inside quotes
|
|
36
|
+
* or from a backslash escape. An operator character (`>`, `*`, …) only
|
|
37
|
+
* acts as an operator while it sits in an UNQUOTED span: a glued, partly
|
|
38
|
+
* quoted `>"/dev/sda"` still redirects, while `'>/dev/sda'` is data.
|
|
39
|
+
* A zero-width quoted span can end a word: it marks an empty quote right
|
|
40
|
+
* after text that ends like a redirection operator (`<<<''`), and holds no
|
|
41
|
+
* character of `value`. */
|
|
42
|
+
spans?: TokenSpan[];
|
|
29
43
|
}
|
|
30
44
|
interface ShellSegment {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
tokens: ShellToken[];
|
|
46
|
+
/** Separator that terminated this segment (`;`, `|`, `||`, `&`, `&&`, `(`,
|
|
47
|
+
* `)`). Newlines and carriage returns are reported as `;`. Absent for the
|
|
48
|
+
* final segment when the command does not end with a separator. A segment
|
|
49
|
+
* with no tokens and `endedBy` `(` or `)` is a paren marker: it exists so
|
|
50
|
+
* grouping events are never lost, and carries no command of its own. */
|
|
51
|
+
endedBy?: string;
|
|
52
|
+
/** The last separator seen before this segment's first token, counting
|
|
53
|
+
* separators whose (empty) segment was dropped: in `( a ) | b`, segment
|
|
54
|
+
* `b` ended up after a dropped empty segment, so its separator lineage is
|
|
55
|
+
* `)` and then `|`, and `precededBy` reports `|`. Absent for the first
|
|
56
|
+
* segment. */
|
|
57
|
+
precededBy?: string;
|
|
44
58
|
}
|
|
45
|
-
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/walk-sink.d.ts
|
|
61
|
+
/** A command the walk resolves, wrapper or not: its basename, the words of
|
|
62
|
+
* its level and its index among them, and whether it runs inside the
|
|
63
|
+
* remote command of an ssh, mosh or autossh. */
|
|
64
|
+
interface PeeledHead {
|
|
65
|
+
head: string;
|
|
66
|
+
tokens: readonly ShellToken[];
|
|
67
|
+
index: number;
|
|
68
|
+
remote: boolean;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/capability/capability-types.d.ts
|
|
46
72
|
/** How completely the command could be statically analyzed. */
|
|
47
|
-
type ParserCompleteness =
|
|
73
|
+
type ParserCompleteness =
|
|
48
74
|
/** Fully parsed: no variables, globs, substitutions, or heredoc bodies. */
|
|
49
|
-
"complete-for-supported-form"
|
|
75
|
+
"complete-for-supported-form" |
|
|
50
76
|
/** Some constructs could not be resolved (variables, partial heredoc). */
|
|
51
|
-
|
|
77
|
+
"partial" |
|
|
52
78
|
/** Heavy dynamic constructs (command substitution, eval, dynamic heredoc). */
|
|
53
|
-
|
|
79
|
+
"opaque";
|
|
54
80
|
/** A redirection extracted from a parsed command segment. */
|
|
55
81
|
interface Redirection {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
82
|
+
/** `>` `>>` `<` `2>` `&>` etc. */
|
|
83
|
+
operator: string;
|
|
84
|
+
/** Target path (file descriptor targets normalized to a path when possible). */
|
|
85
|
+
target: string;
|
|
86
|
+
/** Whether the target was quoted in the source (affects literal-ness). */
|
|
87
|
+
quoted: boolean;
|
|
62
88
|
}
|
|
63
89
|
/** A heredoc extracted before lexing so its body never reaches the lexer/brake. */
|
|
64
90
|
interface HeredocRecord {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
/** The literal delimiter token as it appeared (`EOF`, `END`, …). */
|
|
92
|
+
delimiter: string;
|
|
93
|
+
/** `<<` (expansion on) or `<<-` (tabs stripped) — normalized form. */
|
|
94
|
+
operator: string;
|
|
95
|
+
/** Whether the delimiter was quoted, disabling expansion (`<<'EOF'`). */
|
|
96
|
+
expansionDisabled: boolean;
|
|
97
|
+
/** Bounded + redacted body (truncated to a safe length). */
|
|
98
|
+
bodyBounded: string;
|
|
99
|
+
/** SHA-256 of the full, unredacted body (stable identity without leaking it). */
|
|
100
|
+
bodySha256: string;
|
|
101
|
+
/** Whether the body was truncated for storage. */
|
|
102
|
+
truncated: boolean;
|
|
103
|
+
/** Output path associated with the heredoc when a `> path` precedes it. */
|
|
104
|
+
outputTarget?: string;
|
|
105
|
+
/** Whether the body is dynamically constructed (unresolvable expansion). */
|
|
106
|
+
dynamic: boolean;
|
|
81
107
|
}
|
|
82
108
|
/** A command parsed into a reusable structure. Wraps the existing lexer output
|
|
83
109
|
* plus pre-extracted redirections and heredocs. */
|
|
84
110
|
interface ParsedCommand {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
111
|
+
/** The command after heredoc bodies were replaced with placeholders. */
|
|
112
|
+
sanitizedCommand: string;
|
|
113
|
+
/** Lexed segments of the sanitized command. */
|
|
114
|
+
segments: ShellSegment[];
|
|
115
|
+
/** Effective commands (wrappers peeled) per segment. */
|
|
116
|
+
effective: ShellToken[][];
|
|
117
|
+
/** Redirections grouped by segment index. */
|
|
118
|
+
redirections: Redirection[][];
|
|
119
|
+
/** Heredocs extracted before lexing. */
|
|
120
|
+
heredocs: HeredocRecord[];
|
|
121
|
+
/** Whether the original command contained any dynamic constructs. */
|
|
122
|
+
hasDynamicConstructs: boolean;
|
|
123
|
+
/** True when the lexer's depth or expansion budget stopped command-string
|
|
124
|
+
* resolution early; `effective` is then a prefix of the real structure and
|
|
125
|
+
* deterministic facts do not cover the whole command. */
|
|
126
|
+
analysisTruncated: boolean;
|
|
127
|
+
/** The effective commands that run on the far side of an ssh with no
|
|
128
|
+
* remote command, from the script it reads. They are among `effective`
|
|
129
|
+
* too. */
|
|
130
|
+
remoteCommands?: ShellToken[][];
|
|
131
|
+
/** Every command the walk resolves, wrappers among them, at every level:
|
|
132
|
+
* command strings, `env -S`, `watch` and ssh remote commands. */
|
|
133
|
+
heads: readonly PeeledHead[];
|
|
134
|
+
/** The redirections each walked segment and command string carries
|
|
135
|
+
* itself, whether or not it yields an effective command: the shell
|
|
136
|
+
* opens them before it runs anything (`>f ssh h`). */
|
|
137
|
+
segmentRedirections: readonly (readonly Redirection[])[];
|
|
138
|
+
/** An interpreter among the commands runs code from a heredoc or
|
|
139
|
+
* here-string. */
|
|
140
|
+
stdinCode?: boolean;
|
|
101
141
|
}
|
|
102
142
|
/** What the action can do, what it appears to do, and analysis confidence. */
|
|
103
143
|
interface CapabilityAssessment {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
144
|
+
/** Best single-label summary of the dominant capability. */
|
|
145
|
+
actionClass: Provenanced<CapabilityActionClass>;
|
|
146
|
+
/** Human-readable summary of the detected surface. */
|
|
147
|
+
summary: string;
|
|
148
|
+
/** Executes an interpreter or runtime (sh, python, node, bun, …). */
|
|
149
|
+
executesCode: Provenanced<boolean | "unknown">;
|
|
150
|
+
/** Executes code that lives in the repository (scripts, test files). */
|
|
151
|
+
executesRepositoryCode: Provenanced<boolean | "unknown">;
|
|
152
|
+
/** Executes ad-hoc code generated by the agent (heredoc/inline). */
|
|
153
|
+
createsAdHocCode: Provenanced<boolean | "unknown">;
|
|
154
|
+
/** Invokes a known test runner (pytest, jest, bun test, …). */
|
|
155
|
+
invokesExistingTestRunner: Provenanced<boolean | "unknown">;
|
|
156
|
+
/** Runs a package manager that may execute lifecycle scripts. */
|
|
157
|
+
invokesPackageLifecycleScripts: Provenanced<boolean | "unknown">;
|
|
158
|
+
/** Reads literal credential material through a known file reader. */
|
|
159
|
+
credentialRead: Provenanced<boolean | "unknown">;
|
|
160
|
+
/** Detected file-write surface. */
|
|
161
|
+
writeEffects: {
|
|
162
|
+
temporaryWrite: Provenanced<boolean | "unknown">;
|
|
163
|
+
workspaceWrite: Provenanced<boolean | "unknown">;
|
|
164
|
+
externalWrite: Provenanced<boolean | "unknown">;
|
|
165
|
+
deletion: Provenanced<boolean | "unknown">;
|
|
166
|
+
};
|
|
167
|
+
/** Detected network surface. */
|
|
168
|
+
network: {
|
|
169
|
+
observed: Provenanced<boolean | "unknown">;
|
|
170
|
+
possible: Provenanced<boolean | "unknown">;
|
|
171
|
+
/** Hosts/destinations observed literally in the command. */
|
|
172
|
+
destinations: string[];
|
|
173
|
+
observedAccess: Provenanced<boolean | "unknown">;
|
|
174
|
+
possibleAccess: Provenanced<boolean | "unknown">;
|
|
175
|
+
};
|
|
176
|
+
/** Detected process side-effects. */
|
|
177
|
+
process: {
|
|
178
|
+
childProcesses: Provenanced<boolean | "unknown">;
|
|
179
|
+
persistence: Provenanced<boolean | "unknown">;
|
|
180
|
+
privilegeEscalation: Provenanced<boolean | "unknown">;
|
|
181
|
+
};
|
|
182
|
+
/** Detected remote-operation surface (ssh, etc.). */
|
|
183
|
+
remote: {
|
|
184
|
+
enabled: Provenanced<boolean | "unknown">;
|
|
185
|
+
mutationHint: Provenanced<boolean | "unknown">;
|
|
186
|
+
};
|
|
187
|
+
/** Detected git mutation surface. */
|
|
188
|
+
git: {
|
|
189
|
+
observed: Provenanced<boolean | "unknown">;
|
|
190
|
+
possible: Provenanced<boolean | "unknown">;
|
|
191
|
+
observedAccess: Provenanced<boolean | "unknown">;
|
|
192
|
+
possibleAccess: Provenanced<boolean | "unknown">;
|
|
193
|
+
};
|
|
194
|
+
/** How completely the command could be analyzed. */
|
|
195
|
+
parserCompleteness: ParserCompleteness;
|
|
196
|
+
/** Free-form warnings about analysis limitations. */
|
|
197
|
+
analysisWarnings: string[];
|
|
158
198
|
}
|
|
159
|
-
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/system-one/system-one-types.d.ts
|
|
160
201
|
declare const SYSTEM_ONE_BASES: readonly ["authorized_routine", "authorized_reversible_change", "insufficient_authorization", "scope_mismatch", "insufficient_evidence", "destructive_effect", "credential_or_private_data", "security_or_privilege_change", "external_or_remote_effect", "trusted_policy_restriction", "conflicting_evidence"];
|
|
161
202
|
type SystemOnePrimaryBasis = (typeof SYSTEM_ONE_BASES)[number];
|
|
162
203
|
interface SystemOneChoiceScore<T extends string> {
|
|
163
|
-
|
|
164
|
-
|
|
204
|
+
choice: T;
|
|
205
|
+
confidence: number;
|
|
165
206
|
}
|
|
166
207
|
/** Probability (0-1) that each safety question is true. */
|
|
167
208
|
interface SystemOneSignals {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
209
|
+
materialAuthorization: number;
|
|
210
|
+
withinIntentScope: number;
|
|
211
|
+
unauthorizedDataLoss: number;
|
|
212
|
+
untrustedSensitiveDisclosure: number;
|
|
213
|
+
excessiveCredentialAccess: number;
|
|
214
|
+
unauthorizedSecurityChange: number;
|
|
215
|
+
unauthorizedExternalMutation: number;
|
|
216
|
+
essentialEvidenceMissing: number;
|
|
217
|
+
absolutePolicyDeny: number;
|
|
177
218
|
}
|
|
178
219
|
/**
|
|
179
220
|
* Jev's own answer, kept apart from the final decision because a reasoning
|
|
@@ -181,24 +222,25 @@ interface SystemOneSignals {
|
|
|
181
222
|
* and the provider-reported model ID only; never evidence text.
|
|
182
223
|
*/
|
|
183
224
|
interface SystemOneScores {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
225
|
+
/** Versioned model ID the provider reported as having answered. */
|
|
226
|
+
returnedModel: string;
|
|
227
|
+
outcome: SystemOneChoiceScore<ReviewOutcome> & {
|
|
228
|
+
probabilities: Record<ReviewOutcome, number>;
|
|
229
|
+
};
|
|
230
|
+
supporting: {
|
|
231
|
+
riskLevel: SystemOneChoiceScore<RiskLevel>;
|
|
232
|
+
userAuthorization: SystemOneChoiceScore<UserAuthorization>;
|
|
233
|
+
scopeAlignment: SystemOneChoiceScore<ScopeAlignment>;
|
|
234
|
+
evidenceCompleteness: SystemOneChoiceScore<EvidenceSufficiency>;
|
|
235
|
+
primaryBasis: SystemOneChoiceScore<SystemOnePrimaryBasis>;
|
|
236
|
+
};
|
|
237
|
+
signals: SystemOneSignals;
|
|
238
|
+
/** Consistency checks that failed; any one marks an allow or deny difficult. */
|
|
239
|
+
contradictions: string[];
|
|
240
|
+
reasoningRecommended: boolean;
|
|
200
241
|
}
|
|
201
|
-
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/types.d.ts
|
|
202
244
|
type RiskLevel = "low" | "medium" | "high" | "critical";
|
|
203
245
|
type UserAuthorization = "high" | "medium" | "low" | "unknown";
|
|
204
246
|
type ReviewOutcome = "allow" | "deny" | "escalate";
|
|
@@ -208,41 +250,43 @@ type EvidenceSufficiency = "sufficient" | "partial" | "insufficient" | "unknown"
|
|
|
208
250
|
type EscalationMode = "manual" | "deny";
|
|
209
251
|
/** Effective disposition applied to an internal escalate result. */
|
|
210
252
|
type EscalationDisposition = "manual" | "deny";
|
|
253
|
+
/** Where an escalation that starts at Jev goes; `reasoning-first` sends every one to the escalation reviewer. */
|
|
254
|
+
type SystemOneEscalationMode = "standard" | "reasoning-first";
|
|
211
255
|
interface ReviewDecision {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
256
|
+
/** Structured-decision schema version. Always 2 for the current schema. */
|
|
257
|
+
version: 2;
|
|
258
|
+
outcome: ReviewOutcome;
|
|
259
|
+
risk_level: RiskLevel;
|
|
260
|
+
user_authorization: UserAuthorization;
|
|
261
|
+
/** How well the request aligns with the recovered user/delegated intent. */
|
|
262
|
+
scope_alignment: ScopeAlignment;
|
|
263
|
+
/** Whether the evidence was sufficient to decide confidently. */
|
|
264
|
+
evidence_completeness: EvidenceSufficiency;
|
|
265
|
+
rationale: string;
|
|
266
|
+
confidence: number;
|
|
267
|
+
/** Optional script-only semantic analysis. Never conveys authorization. */
|
|
268
|
+
script_analysis?: string;
|
|
225
269
|
}
|
|
226
270
|
interface PermissionToolSource {
|
|
227
|
-
|
|
228
|
-
|
|
271
|
+
messageID: string;
|
|
272
|
+
callID: string;
|
|
229
273
|
}
|
|
230
274
|
interface PermissionRequest {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
275
|
+
id: string;
|
|
276
|
+
sessionID: string;
|
|
277
|
+
permission: string;
|
|
278
|
+
patterns: string[];
|
|
279
|
+
metadata: Record<string, unknown>;
|
|
280
|
+
always: string[];
|
|
281
|
+
tool?: PermissionToolSource;
|
|
238
282
|
}
|
|
239
283
|
interface MessageWithParts {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
284
|
+
info: Record<string, unknown> & {
|
|
285
|
+
id?: string;
|
|
286
|
+
role?: string;
|
|
287
|
+
structured?: unknown;
|
|
288
|
+
};
|
|
289
|
+
parts: Array<Record<string, unknown>>;
|
|
246
290
|
}
|
|
247
291
|
/** Deterministic risk×authorization matrix that gates reviewer `allow`
|
|
248
292
|
* outcomes. For each risk level, lists the authorization levels that permit an
|
|
@@ -250,15 +294,15 @@ interface MessageWithParts {
|
|
|
250
294
|
* risk (the action is escalated). Only ever RESTRICTS; deny/escalate are always
|
|
251
295
|
* preserved. */
|
|
252
296
|
interface RiskPolicy {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
297
|
+
allow: {
|
|
298
|
+
low: UserAuthorization[];
|
|
299
|
+
medium: UserAuthorization[];
|
|
300
|
+
high: UserAuthorization[];
|
|
301
|
+
critical: UserAuthorization[];
|
|
302
|
+
};
|
|
303
|
+
minimumConfidence: number;
|
|
304
|
+
onInvalidDecision: "manual" | "deny";
|
|
305
|
+
onReviewerFailure: "manual" | "deny";
|
|
262
306
|
}
|
|
263
307
|
/** Conservative repository trust model. A repository cannot mark itself trusted
|
|
264
308
|
* through project configuration alone — trust comes from global config or an
|
|
@@ -268,300 +312,320 @@ type RepositoryTrust = "trusted" | "untrusted" | "unknown";
|
|
|
268
312
|
* is optional; the rule matches when ALL specified fields match. A missing
|
|
269
313
|
* `when` (or `{ always: true }`) makes the rule universal. */
|
|
270
314
|
interface PolicyCondition {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
315
|
+
/** Explicit catch-all: valid only as the sole key. */
|
|
316
|
+
always?: true;
|
|
317
|
+
actionClass?: CapabilityActionClass[];
|
|
318
|
+
actorProfile?: ActorProfile[];
|
|
319
|
+
writesWorkspace?: boolean;
|
|
320
|
+
writesExternal?: boolean;
|
|
321
|
+
writesTemporary?: boolean;
|
|
322
|
+
deletion?: boolean;
|
|
323
|
+
executesCode?: boolean;
|
|
324
|
+
createsAdHocCode?: boolean;
|
|
325
|
+
packageManagement?: boolean;
|
|
326
|
+
gitMutation?: boolean;
|
|
327
|
+
networkObserved?: boolean;
|
|
328
|
+
credentialRead?: boolean;
|
|
329
|
+
privilegeEscalation?: boolean;
|
|
330
|
+
remoteEnabled?: boolean;
|
|
331
|
+
persistence?: boolean;
|
|
332
|
+
repositoryTrust?: RepositoryTrust[];
|
|
289
333
|
}
|
|
290
334
|
/** A declarative rule that routes a request based on capability+actor facts.
|
|
291
335
|
* `when` is optional: omitting it (or `{ always: true }`) matches every
|
|
292
336
|
* request. An explicitly empty `when: {}` is rejected at load. */
|
|
293
337
|
interface PolicyRule {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
338
|
+
id: string;
|
|
339
|
+
source: "builtin" | "global" | "project" | "inline";
|
|
340
|
+
when?: PolicyCondition;
|
|
341
|
+
effect: "review" | "manual" | "deny" | "allow";
|
|
342
|
+
reason: string;
|
|
299
343
|
}
|
|
300
344
|
/** The result of evaluating the declarative policy. */
|
|
301
345
|
interface PolicyTrace {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
346
|
+
/** Stable hash of the effective rule set (not the matched rules) for audit
|
|
347
|
+
* reproducibility. */
|
|
348
|
+
effectivePolicyHash: string;
|
|
349
|
+
matchedRules: Array<{
|
|
350
|
+
id: string;
|
|
351
|
+
source: string;
|
|
352
|
+
effect: string;
|
|
353
|
+
reason: string;
|
|
354
|
+
}>;
|
|
355
|
+
/** The route the engine computed (counterfactual in observe mode: what enforce
|
|
356
|
+
* mode WOULD have done with the same facts and rules). */
|
|
357
|
+
finalRoute: "review" | "manual" | "deny" | "allow";
|
|
358
|
+
mode: "observe" | "enforce";
|
|
315
359
|
}
|
|
316
360
|
type ReviewerOutputFormat = "json_schema" | "text";
|
|
317
361
|
interface EscalationReviewerConfig {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
362
|
+
model: string;
|
|
363
|
+
variant: string;
|
|
364
|
+
outputFormat: ReviewerOutputFormat;
|
|
365
|
+
timeoutMs: number;
|
|
322
366
|
}
|
|
323
367
|
interface ReviewerConfig {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
368
|
+
model: string;
|
|
369
|
+
variant: string;
|
|
370
|
+
/** How the reviewer model returns its decision. `json_schema` requests
|
|
371
|
+
* OpenCode's structured-output format (requires provider support); `text`
|
|
372
|
+
* asks the model to emit JSON in plain text and parses it locally. */
|
|
373
|
+
outputFormat: ReviewerOutputFormat;
|
|
374
|
+
/** Optional reasoning reviewer for valid System One decisions that remain
|
|
375
|
+
* uncertain or conflict with deterministic review gates. */
|
|
376
|
+
escalationReviewer?: EscalationReviewerConfig;
|
|
377
|
+
/** Calibrated outcome-confidence floor for System One decisions. */
|
|
378
|
+
systemOneConfidenceThreshold: number;
|
|
379
|
+
/** Minimum combined non-escalate probability for routing an explicit
|
|
380
|
+
* System One escalation to the optional reasoning reviewer. */
|
|
381
|
+
systemOneReasoningThreshold: number;
|
|
382
|
+
/** Read through resolveSystemOneRouting, which applies the Jev and escalationReviewer conditions. */
|
|
383
|
+
systemOneEscalation: SystemOneEscalationMode;
|
|
384
|
+
/** Send uncertain Jev denials to the escalation reviewer. Read through resolveSystemOneRouting. */
|
|
385
|
+
systemOneDenialReview: boolean;
|
|
386
|
+
timeoutMs: number;
|
|
387
|
+
/** Total review budget, including context, queueing, and retries. */
|
|
388
|
+
reviewBudgetMs?: number;
|
|
389
|
+
maxContextChars: number;
|
|
390
|
+
maxPartChars: number;
|
|
391
|
+
maxEnrichmentChars: number;
|
|
392
|
+
maxIntentChars: number;
|
|
393
|
+
transcriptMessages: number;
|
|
394
|
+
intentMessages: number;
|
|
395
|
+
historyMessages: number;
|
|
396
|
+
confidenceThreshold: number;
|
|
397
|
+
retainReviewSessions: boolean;
|
|
398
|
+
audit: boolean;
|
|
399
|
+
auditPath?: string;
|
|
400
|
+
policy?: string;
|
|
401
|
+
debug: boolean;
|
|
402
|
+
/** When "observe", actor evidence is collected and audited but never enforces
|
|
403
|
+
* new gates; "enforce" applies declarative policy routes. */
|
|
404
|
+
enforcementMode: "observe" | "enforce";
|
|
405
|
+
/**
|
|
406
|
+
* How internal `escalate` results are disposed before UI/reply.
|
|
407
|
+
* - `manual` (default): leave the request for a human (interactive mode).
|
|
408
|
+
* - `deny`: convert every final escalation into a reject with rationale
|
|
409
|
+
* (non-interactive fail-closed). Never relaxes an explicit deny.
|
|
410
|
+
*/
|
|
411
|
+
escalationMode: EscalationMode;
|
|
412
|
+
/** Max hops when walking session parents (default 8). */
|
|
413
|
+
maxSessionDepth: number;
|
|
414
|
+
/** Max parent sessions fetched during lineage traversal. */
|
|
415
|
+
maxParentSessions: number;
|
|
416
|
+
/** Trusted name→profile mappings (empty by default; no mappings shipped). */
|
|
417
|
+
actorProfiles: Record<string, ActorProfile>;
|
|
418
|
+
/** Deterministic risk×authorization gate, configurable but defaults reproduce
|
|
419
|
+
* the previous hard-coded matrix exactly. */
|
|
420
|
+
riskPolicy: RiskPolicy;
|
|
421
|
+
/** Repository trust level derived from global config (never from project). */
|
|
422
|
+
repositoryTrust: RepositoryTrust;
|
|
423
|
+
/** Declarative policy rules (empty by default; observe mode audits the trace
|
|
424
|
+
* without enforcing). Project-sourced allow rules are rejected. */
|
|
425
|
+
policyRules: PolicyRule[];
|
|
426
|
+
/** Capture user answers to agent ask dialogs (question tool) and surface
|
|
427
|
+
* them to the reviewer as scoped authorization evidence. */
|
|
428
|
+
askDecisions: boolean;
|
|
429
|
+
/** Non-empty when a TRUSTED config source (global file, inline options)
|
|
430
|
+
* existed but could not be fully honored (malformed file, unreadable file,
|
|
431
|
+
* or rules dropped by validation). Degraded configs block automatic
|
|
432
|
+
* approval: restrictions may have been lost, so requests escalate instead. */
|
|
433
|
+
configDegraded?: string[];
|
|
434
|
+
/** Non-empty when a setting was invalid and fell back to its default, or is
|
|
435
|
+
* on but inert. Informational only: never affects a decision. */
|
|
436
|
+
configWarnings?: string[];
|
|
386
437
|
}
|
|
387
438
|
interface ReviewEnvelope {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
439
|
+
request: PermissionRequest;
|
|
440
|
+
directory: string;
|
|
441
|
+
worktree: string;
|
|
442
|
+
transcript: string;
|
|
443
|
+
intentHistory: string;
|
|
444
|
+
enrichment: string;
|
|
445
|
+
verifiedScript?: VerifiedScriptEvidence;
|
|
446
|
+
sshAudit: NonNullable<ReviewAuditRecord["ssh"]>;
|
|
447
|
+
preflightDenial?: string;
|
|
448
|
+
/** Agent-aware context (actor, lineage, intent). Observe-only: flows into the
|
|
449
|
+
* reviewer prompt and audit as evidence, never into enforcement decisions.
|
|
450
|
+
* Optional so older callers/tests still compile. */
|
|
451
|
+
actor?: ActorContext;
|
|
452
|
+
lineage?: SessionLineage;
|
|
453
|
+
intent?: IntentContext;
|
|
454
|
+
evidenceCompleteness?: EvidenceCompleteness;
|
|
455
|
+
/** Structured capability facts derived from the bash command. Observe-only:
|
|
456
|
+
* feeds the reviewer prompt and audit, never enforcement. */
|
|
457
|
+
capability?: CapabilityAssessment;
|
|
458
|
+
/** The policy trace produced for this request, surfaced to the reviewer prompt
|
|
459
|
+
* as EFFECTIVE_POLICY_SUMMARY and to audit. Observe-only. */
|
|
460
|
+
policyTrace?: PolicyTrace;
|
|
461
|
+
/** Per-phase timing captured during evidence assembly (context/enrichment).
|
|
462
|
+
* The reviewer and reply phases are timed in the coordinator. */
|
|
463
|
+
timings?: {
|
|
464
|
+
contextMs?: number;
|
|
465
|
+
enrichmentMs?: number;
|
|
466
|
+
reviewerMs?: number;
|
|
467
|
+
replyMs?: number;
|
|
468
|
+
};
|
|
469
|
+
/** False when a material part of the action under review (e.g. an elided
|
|
470
|
+
* command segment) never reached the rendered evidence. Blocking: the
|
|
471
|
+
* coordinator must not auto-approve an action the reviewer could not see
|
|
472
|
+
* in full, whatever confidence the model reports. */
|
|
473
|
+
actionEvidenceComplete?: boolean;
|
|
474
|
+
/** The parsed command reused across evidence providers. */
|
|
475
|
+
parsedCommand?: ParsedCommand;
|
|
476
|
+
/** Operational purpose of the pending action (evidence, never authorization). */
|
|
477
|
+
actionPurpose?: ActionPurpose;
|
|
478
|
+
/** User answers to agent ask dialogs in this session or its ancestors,
|
|
479
|
+
* captured live from question events. Observe-only: flows into the reviewer
|
|
480
|
+
* prompt (USER_ASK_DECISIONS) and audit, never into enforcement. */
|
|
481
|
+
askDecisions?: AskDecision[];
|
|
431
482
|
}
|
|
432
483
|
interface ApprovedAnnotation {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
484
|
+
requestID: string;
|
|
485
|
+
sessionID: string;
|
|
486
|
+
decision: ReviewDecision;
|
|
487
|
+
}
|
|
488
|
+
/** Why a System One (Jev) result was handed to the reasoning reviewer. */
|
|
489
|
+
type HandoffTrigger = "jev-escalate" | "jev-uncertain-allow" | "jev-gate" | "jev-invalid" | "jev-failure" | "jev-uncertain-deny";
|
|
490
|
+
/** The primary model, routing reason and hand-off trigger of a review a
|
|
491
|
+
* second reviewer decided. */
|
|
492
|
+
interface EscalatedFrom {
|
|
493
|
+
model: string;
|
|
494
|
+
reason: string;
|
|
495
|
+
trigger?: HandoffTrigger;
|
|
436
496
|
}
|
|
497
|
+
/** How an escalation that left the System One backend was reached. */
|
|
498
|
+
type ManualResolution = "reviewer" | "reasoning-escalated" | "reasoning-unavailable" | "budget-exhausted";
|
|
437
499
|
interface ReviewExecutionResult {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
500
|
+
kind: "allow" | "deny" | "escalate";
|
|
501
|
+
decision?: ReviewDecision;
|
|
502
|
+
reason: string;
|
|
503
|
+
reviewSessionID?: string;
|
|
504
|
+
/** Which layer produced this result; threaded into the audit record. */
|
|
505
|
+
decisionSource?: DecisionSource;
|
|
506
|
+
/** Actual model that produced the final reviewer decision. */
|
|
507
|
+
reviewerModel?: string;
|
|
508
|
+
/** Primary model, routing reason and hand-off trigger when a second
|
|
509
|
+
* reviewer was used. */
|
|
510
|
+
reviewerEscalatedFrom?: EscalatedFrom;
|
|
511
|
+
/** Jev's scores whenever it returned a parsed decision. */
|
|
512
|
+
systemOne?: SystemOneScores;
|
|
513
|
+
/**
|
|
514
|
+
* Structured outcome from the reviewer LLM before gates/disposition.
|
|
515
|
+
* Absent when no valid structured decision was produced.
|
|
516
|
+
*/
|
|
517
|
+
reviewerOutcome?: ReviewOutcome;
|
|
518
|
+
/**
|
|
519
|
+
* How an internal escalate was disposed at the enforcement boundary.
|
|
520
|
+
* Absent when the result was never an escalate (explicit allow/deny) or when
|
|
521
|
+
* the request was already answered manually (`manual-superseded`).
|
|
522
|
+
*/
|
|
523
|
+
escalationDisposition?: EscalationDisposition;
|
|
524
|
+
/** Set only by the System One backend, on escalations; kept when a
|
|
525
|
+
* disposition turns one into a deny. */
|
|
526
|
+
resolution?: ManualResolution;
|
|
464
527
|
}
|
|
465
528
|
/** Generic policy templates, NOT automatic trust levels. */
|
|
466
529
|
type ActorProfile = "read-only" | "validation" | "workspace" | "operator" | "reviewer" | "unknown";
|
|
467
530
|
/** High-level classification of what the action does. */
|
|
468
531
|
type CapabilityActionClass = "read-only" | "workspace-write" | "temporary-write" | "external-write" | "destruction" | "code-execution" | "package-management" | "git-mutation" | "network" | "remote-operation" | "service-management" | "persistence" | "privilege-escalation" | "unknown";
|
|
469
|
-
|
|
532
|
+
//#endregion
|
|
533
|
+
//#region src/actor-context-types.d.ts
|
|
470
534
|
/** Reliability of a derived fact. */
|
|
471
535
|
type EvidenceConfidence = "confirmed" | "high" | "medium" | "low" | "unknown";
|
|
472
536
|
/** Every non-trivial derived fact carries provenance so the LLM and audit can
|
|
473
537
|
* weigh claims by how reliably they were established. */
|
|
474
538
|
interface Provenanced<T> {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
539
|
+
value: T;
|
|
540
|
+
source: "permission-event" | "tool-message" | "session-api" | "parent-session" | "global-config" | "project-config" | "effective-permissions" | "static-analysis" | "heuristic" | "unavailable";
|
|
541
|
+
confidence: EvidenceConfidence;
|
|
542
|
+
notes?: string[];
|
|
479
543
|
}
|
|
480
544
|
/** Normalized effective-permission summary when the SDK exposes it.
|
|
481
545
|
* The v1 SDK does not expose effective rules, so this stays `undefined`. */
|
|
482
546
|
interface EffectivePermissionSummary {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
547
|
+
edit: "allow" | "ask" | "deny" | "mixed" | "unknown";
|
|
548
|
+
bash: "allow" | "ask" | "deny" | "mixed" | "unknown";
|
|
549
|
+
task: "allow" | "ask" | "deny" | "mixed" | "unknown";
|
|
550
|
+
externalDirectory: "allow" | "ask" | "deny" | "mixed" | "unknown";
|
|
551
|
+
source: "session" | "agent-config" | "derived" | "unknown";
|
|
488
552
|
}
|
|
489
553
|
/** Who is requesting the permission. */
|
|
490
554
|
interface ActorContext {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
555
|
+
agentName: Provenanced<string | undefined>;
|
|
556
|
+
mode: Provenanced<string | undefined>;
|
|
557
|
+
profile: Provenanced<ActorProfile>;
|
|
558
|
+
sessionID: string;
|
|
559
|
+
parentSessionID: Provenanced<string | undefined>;
|
|
560
|
+
rootSessionID: Provenanced<string>;
|
|
561
|
+
delegationDepth: Provenanced<number>;
|
|
562
|
+
effectivePermissions?: EffectivePermissionSummary;
|
|
563
|
+
identityCompleteness: "complete" | "partial" | "unknown";
|
|
500
564
|
}
|
|
501
565
|
/** A node in the session ancestry chain. */
|
|
502
566
|
interface SessionNode {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
567
|
+
sessionID: string;
|
|
568
|
+
parentID?: string;
|
|
569
|
+
title?: string;
|
|
570
|
+
version?: string;
|
|
571
|
+
actorName?: string;
|
|
572
|
+
mode?: string;
|
|
573
|
+
createdAt?: number;
|
|
510
574
|
}
|
|
511
575
|
/** The resolved session ancestry with failure modes made explicit. */
|
|
512
576
|
interface SessionLineage {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
577
|
+
origin?: "human-root" | "delegated" | "unknown";
|
|
578
|
+
nodes: SessionNode[];
|
|
579
|
+
rootSessionID: string;
|
|
580
|
+
depth: number;
|
|
581
|
+
cycleDetected: boolean;
|
|
582
|
+
truncated: boolean;
|
|
583
|
+
missingParents: string[];
|
|
520
584
|
}
|
|
521
585
|
/** A single authorization/intent statement. */
|
|
522
586
|
interface IntentBlock {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
587
|
+
sessionID: string;
|
|
588
|
+
messageID: string;
|
|
589
|
+
actor: "user" | "assistant" | "system" | "unknown";
|
|
590
|
+
text: string;
|
|
591
|
+
synthetic: boolean;
|
|
592
|
+
createdAt?: number;
|
|
593
|
+
provenance: Provenanced<"intent">;
|
|
530
594
|
}
|
|
531
595
|
/** One user decision on an agent-initiated ask dialog (question tool). The
|
|
532
596
|
* question text is agent-generated and untrusted; only the answer is a user
|
|
533
597
|
* authorization signal, scoped to the subject and time of the ask. */
|
|
534
598
|
interface AskDecision {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
599
|
+
/** Epoch ms when the reply (or dismissal) was observed. */
|
|
600
|
+
at: number;
|
|
601
|
+
/** What the agent asked, already redacted and truncated. */
|
|
602
|
+
question: string;
|
|
603
|
+
/** The option labels the user selected, or a dismissal marker. */
|
|
604
|
+
answer: string;
|
|
541
605
|
}
|
|
542
606
|
/** Direct user intent kept separate from delegated task. */
|
|
543
607
|
interface IntentContext {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
608
|
+
directUserIntent: IntentBlock[];
|
|
609
|
+
delegatedTask: IntentBlock[];
|
|
610
|
+
localSessionIntent: IntentBlock[];
|
|
611
|
+
conflictingInstructions: string[];
|
|
612
|
+
latestExplicitAuthorization?: IntentBlock;
|
|
613
|
+
completeness: "complete" | "partial" | "insufficient";
|
|
550
614
|
}
|
|
551
615
|
/** Meta-summary of what evidence was available. */
|
|
552
616
|
interface EvidenceCompleteness {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
617
|
+
permission: boolean;
|
|
618
|
+
actor: boolean;
|
|
619
|
+
lineage: boolean;
|
|
620
|
+
directUserIntent: boolean;
|
|
621
|
+
delegatedTask: boolean;
|
|
622
|
+
/** Whether a non-unavailable ACTION_PURPOSE was recovered. */
|
|
623
|
+
purpose: boolean;
|
|
624
|
+
capability: boolean;
|
|
625
|
+
repositoryState: boolean;
|
|
626
|
+
referencedCode: boolean;
|
|
627
|
+
reasons: string[];
|
|
628
|
+
overall: "sufficient" | "partial" | "insufficient";
|
|
565
629
|
}
|
|
566
630
|
/**
|
|
567
631
|
* Operational purpose of the pending action — what the agent appears to be
|
|
@@ -569,171 +633,183 @@ interface EvidenceCompleteness {
|
|
|
569
633
|
* user authorization by itself.
|
|
570
634
|
*/
|
|
571
635
|
interface ActionPurpose {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
636
|
+
text?: string;
|
|
637
|
+
source: "agent-context" | "intent-derived" | "unavailable";
|
|
638
|
+
confidence: EvidenceConfidence;
|
|
575
639
|
}
|
|
576
|
-
|
|
640
|
+
//#endregion
|
|
641
|
+
//#region src/audit-record.d.ts
|
|
577
642
|
/** Which layer produced the final decision for a request. Threaded into the
|
|
578
643
|
* audit record so reports can split outcomes by source. */
|
|
579
644
|
type DecisionSource = "emergency-brake" | "deterministic-policy" | "llm-reviewer" | "system-one-reviewer" | "manual-superseded" | "failure-safe";
|
|
580
645
|
interface ReviewAuditRecord {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
privilegeEscalation?: boolean;
|
|
705
|
-
persistence?: boolean;
|
|
706
|
-
remoteEnabled?: boolean;
|
|
707
|
-
gitMutation?: boolean;
|
|
708
|
-
};
|
|
709
|
-
/** Additive policy trace for audit (observe-only). */
|
|
710
|
-
policyTrace?: {
|
|
711
|
-
effectivePolicyHash: string;
|
|
712
|
-
matchedRules: Array<{
|
|
713
|
-
id: string;
|
|
714
|
-
source: string;
|
|
715
|
-
effect: string;
|
|
716
|
-
reason: string;
|
|
717
|
-
}>;
|
|
718
|
-
finalRoute: string;
|
|
719
|
-
mode: string;
|
|
646
|
+
/**
|
|
647
|
+
* Audit schema version. Present on every record; readers default a missing
|
|
648
|
+
* field to `1` (additive — old records are still valid).
|
|
649
|
+
* Bump only on a breaking change to the record shape.
|
|
650
|
+
*/
|
|
651
|
+
schemaVersion?: number;
|
|
652
|
+
reviewID?: string;
|
|
653
|
+
hostRequestID?: string;
|
|
654
|
+
hostGeneration?: "v1" | "v2";
|
|
655
|
+
hostVersion?: string;
|
|
656
|
+
generation?: string;
|
|
657
|
+
nativeAction?: string;
|
|
658
|
+
directory?: string;
|
|
659
|
+
application?: "evaluation-returned" | "reply-accepted" | "human-pending" | "superseded" | "cancelled" | "unknown";
|
|
660
|
+
pluginVersion?: string;
|
|
661
|
+
effectiveConfigHash?: string;
|
|
662
|
+
actionFingerprint?: string;
|
|
663
|
+
/** Version of the structured-decision schema the reviewer was asked to emit. */
|
|
664
|
+
decisionSchemaVersion?: number;
|
|
665
|
+
/** Version of the reviewer system prompt used for this decision. */
|
|
666
|
+
promptVersion?: string;
|
|
667
|
+
/** Which layer produced the outcome (brake, policy, reviewer, supersede,
|
|
668
|
+
* failure-safe). Absent on legacy v1 records. */
|
|
669
|
+
decisionSource?: DecisionSource;
|
|
670
|
+
timestamp: string;
|
|
671
|
+
durationMs: number;
|
|
672
|
+
requestID: string;
|
|
673
|
+
sessionID: string;
|
|
674
|
+
permission: string;
|
|
675
|
+
/** Stable hash of the canonical request (permission, patterns, metadata,
|
|
676
|
+
* tool) for cross-record correlation. Absent on legacy v1 records. */
|
|
677
|
+
actionHash?: string;
|
|
678
|
+
outcome: ReviewExecutionResult["kind"];
|
|
679
|
+
reason: string;
|
|
680
|
+
riskLevel?: RiskLevel;
|
|
681
|
+
userAuthorization?: UserAuthorization;
|
|
682
|
+
/** How well the action aligned with the recovered intent (from the reviewer
|
|
683
|
+
* decision). Absent when no reviewer decision was reached. */
|
|
684
|
+
scopeAlignment?: ScopeAlignment;
|
|
685
|
+
confidence?: number;
|
|
686
|
+
/**
|
|
687
|
+
* Structured outcome emitted by the reviewer LLM before gates/disposition.
|
|
688
|
+
* Absent when no valid structured decision was produced (brake, policy,
|
|
689
|
+
* failure-safe, supersede).
|
|
690
|
+
*/
|
|
691
|
+
reviewerOutcome?: ReviewOutcome;
|
|
692
|
+
/**
|
|
693
|
+
* How an internal escalate was disposed. Present only when the logical result
|
|
694
|
+
* was escalate (or a gate converted allow→escalate) and enforcement chose
|
|
695
|
+
* manual or deny. Absent for explicit deny, allow, and manual-superseded.
|
|
696
|
+
*/
|
|
697
|
+
escalationDisposition?: EscalationDisposition;
|
|
698
|
+
/** The model that produced the final reviewer decision. */
|
|
699
|
+
reviewerModel?: string;
|
|
700
|
+
/** Present when a System One result was handed to a reasoning reviewer;
|
|
701
|
+
* `trigger` says why. */
|
|
702
|
+
reviewerEscalatedFrom?: EscalatedFrom;
|
|
703
|
+
/** How an escalation from the System One backend was reached. */
|
|
704
|
+
resolution?: ManualResolution;
|
|
705
|
+
/** Warnings on the resolved config (inert or invalid settings); present
|
|
706
|
+
* only when there are any. Not the evidence `warnings` below. */
|
|
707
|
+
configWarnings?: string[];
|
|
708
|
+
/** Jev's scores whenever it returned a parsed decision, including when a
|
|
709
|
+
* reasoning reviewer made the final call. */
|
|
710
|
+
systemOne?: SystemOneScores;
|
|
711
|
+
/** Per-phase timings. Absent on legacy v1 records and on deterministic paths
|
|
712
|
+
* that never reach that phase. */
|
|
713
|
+
timings?: {
|
|
714
|
+
contextMs?: number;
|
|
715
|
+
enrichmentMs?: number;
|
|
716
|
+
reviewerMs?: number;
|
|
717
|
+
replyMs?: number;
|
|
718
|
+
};
|
|
719
|
+
/** Non-fatal warnings accumulated during evidence collection/analysis. */
|
|
720
|
+
warnings?: string[];
|
|
721
|
+
reviewerSessionID?: string;
|
|
722
|
+
/** Content identity and inspection mode only; never script text or local path. */
|
|
723
|
+
verifiedScript?: {
|
|
724
|
+
sha256: string;
|
|
725
|
+
status: "full" | "reused" | "unavailable";
|
|
726
|
+
bytes?: number;
|
|
727
|
+
};
|
|
728
|
+
/** Root session of the request's ancestry (additive; absent when lineage was
|
|
729
|
+
* unavailable). */
|
|
730
|
+
rootSessionID?: string;
|
|
731
|
+
/** Overall evidence completeness for the request (additive). */
|
|
732
|
+
evidenceCompleteness?: string;
|
|
733
|
+
/** Resolved actor snapshot for audit (additive). Uses identityCompleteness
|
|
734
|
+
* (not the decision's numeric confidence) to avoid field ambiguity; v2 also
|
|
735
|
+
* carries identitySource + confidence. */
|
|
736
|
+
actor?: {
|
|
737
|
+
name?: string;
|
|
738
|
+
mode?: string;
|
|
739
|
+
profile: ActorProfile;
|
|
740
|
+
identityCompleteness: "complete" | "partial" | "unknown";
|
|
741
|
+
/** How the agent identity was established (tool-message, session-api,
|
|
742
|
+
* unavailable, …). Absent on legacy v1 records. */
|
|
743
|
+
identitySource?: string;
|
|
744
|
+
/** Reliability of the identity claim. Absent on legacy v1 records. */
|
|
745
|
+
confidence?: EvidenceConfidence;
|
|
746
|
+
delegationDepth?: number;
|
|
747
|
+
};
|
|
748
|
+
ssh?: Array<{
|
|
749
|
+
destination: string;
|
|
750
|
+
port?: string;
|
|
751
|
+
remoteCommandSha256?: string;
|
|
752
|
+
stdinSource?: string;
|
|
753
|
+
stdinStatus?: string;
|
|
754
|
+
stdinReason?: string;
|
|
755
|
+
}>;
|
|
756
|
+
/** Additive capability snapshot for audit (observe-only). */
|
|
757
|
+
capability?: {
|
|
758
|
+
actionClass: string;
|
|
759
|
+
summary: string;
|
|
760
|
+
parserCompleteness: string;
|
|
761
|
+
executesCode?: boolean;
|
|
762
|
+
createsAdHocCode?: boolean;
|
|
763
|
+
invokesPackageLifecycleScripts?: boolean;
|
|
764
|
+
writeEffects?: {
|
|
765
|
+
temporaryWrite?: boolean;
|
|
766
|
+
workspaceWrite?: boolean;
|
|
767
|
+
externalWrite?: boolean;
|
|
768
|
+
deletion?: boolean;
|
|
720
769
|
};
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
770
|
+
networkObserved?: boolean;
|
|
771
|
+
credentialRead?: boolean;
|
|
772
|
+
privilegeEscalation?: boolean;
|
|
773
|
+
persistence?: boolean;
|
|
774
|
+
remoteEnabled?: boolean;
|
|
775
|
+
gitMutation?: boolean;
|
|
776
|
+
};
|
|
777
|
+
/** Additive policy trace for audit (observe-only). */
|
|
778
|
+
policyTrace?: {
|
|
779
|
+
effectivePolicyHash: string;
|
|
780
|
+
matchedRules: Array<{
|
|
781
|
+
id: string;
|
|
782
|
+
source: string;
|
|
783
|
+
effect: string;
|
|
784
|
+
reason: string;
|
|
727
785
|
}>;
|
|
786
|
+
finalRoute: string;
|
|
787
|
+
mode: string;
|
|
788
|
+
};
|
|
789
|
+
/** Additive snapshot of the ask decisions surfaced to the reviewer prompt
|
|
790
|
+
* (observe-only; capped to the most recent few). */
|
|
791
|
+
askDecisions?: Array<{
|
|
792
|
+
at: number;
|
|
793
|
+
question: string;
|
|
794
|
+
answer: string;
|
|
795
|
+
}>;
|
|
728
796
|
}
|
|
729
|
-
|
|
730
|
-
|
|
797
|
+
//#endregion
|
|
798
|
+
//#region src/audit.d.ts
|
|
799
|
+
export declare const DEFAULT_AUDIT_PATH = "~/.local/share/opencode/permission-reviewer-audit.jsonl";
|
|
731
800
|
type AuditLogger = (message: string, details?: unknown) => void;
|
|
732
|
-
declare function createAuditWriter(config: ReviewerConfig, logger?: AuditLogger): ((record: ReviewAuditRecord) => Promise<void>) | undefined;
|
|
733
|
-
|
|
801
|
+
export declare function createAuditWriter(config: ReviewerConfig, logger?: AuditLogger): ((record: ReviewAuditRecord) => Promise<void>) | undefined;
|
|
802
|
+
//#endregion
|
|
803
|
+
//#region src/config/sources.d.ts
|
|
734
804
|
/** The host passing an options object does not attest who authored it. */
|
|
735
805
|
type InlineOptionsTrust = "trusted" | "project" | "unknown";
|
|
736
|
-
|
|
806
|
+
//#endregion
|
|
807
|
+
//#region src/config/loader.d.ts
|
|
808
|
+
interface LoadOptions {
|
|
809
|
+
/** Off for a caller that shows `configWarnings` another way, such as the TUI
|
|
810
|
+
* from server statuses. */
|
|
811
|
+
printConfigWarnings?: boolean;
|
|
812
|
+
}
|
|
737
813
|
/** Load and merge config from global, project, and inline sources.
|
|
738
814
|
*
|
|
739
815
|
* Precedence (lowest to highest): builtin defaults → global → project → inline,
|
|
@@ -744,47 +820,99 @@ type InlineOptionsTrust = "trusted" | "project" | "unknown";
|
|
|
744
820
|
*
|
|
745
821
|
* When no global or project files exist (the common case), the result is
|
|
746
822
|
* byte-identical to calling `resolveConfig(inlineOptions)` directly. */
|
|
747
|
-
declare function loadResolvedConfig(inlineOptions: Record<string, unknown> | undefined, directory?: string, inlineTrust?: InlineOptionsTrust): ReviewerConfig;
|
|
748
|
-
|
|
823
|
+
export declare function loadResolvedConfig(inlineOptions: Record<string, unknown> | undefined, directory?: string, inlineTrust?: InlineOptionsTrust, { printConfigWarnings }?: LoadOptions): ReviewerConfig;
|
|
824
|
+
//#endregion
|
|
825
|
+
//#region src/system-one/backend.d.ts
|
|
826
|
+
/** Jev's hand-off to the reasoning reviewer, on the second "reviewing" status
|
|
827
|
+
* and on the result of a handed-off review. */
|
|
828
|
+
interface HandoffInfo {
|
|
829
|
+
from: string;
|
|
830
|
+
to: string;
|
|
831
|
+
trigger: HandoffTrigger;
|
|
832
|
+
/** Jev's failure ("timeout"), only when `trigger` is `jev-failure`. */
|
|
833
|
+
failureKind?: string;
|
|
834
|
+
}
|
|
835
|
+
//#endregion
|
|
836
|
+
//#region src/ui-status-extras.d.ts
|
|
837
|
+
interface StatusExtrasOptions {
|
|
838
|
+
handoff?: HandoffInfo;
|
|
839
|
+
resolution?: ManualResolution;
|
|
840
|
+
decidedBy?: string;
|
|
841
|
+
configWarnings?: readonly string[];
|
|
842
|
+
configDegraded?: readonly string[];
|
|
843
|
+
}
|
|
844
|
+
//#endregion
|
|
845
|
+
//#region src/ui-protocol.d.ts
|
|
749
846
|
type ReviewUiPhase = "reviewing" | "approved" | "denied" | "manual" | "unknown";
|
|
847
|
+
/** One command of a shell action as the server split it, for the TUI to fit
|
|
848
|
+
* to its width. Built by `src/ui-action-segments.ts`. */
|
|
849
|
+
interface ActionSegment {
|
|
850
|
+
/** The segment as typed in the command, heredoc bodies left out,
|
|
851
|
+
* whitespace collapsed, at most 200 code points. */
|
|
852
|
+
text: string;
|
|
853
|
+
/** The operator that ends this segment: "|", "||", "&&", ";", "&". */
|
|
854
|
+
separator?: string;
|
|
855
|
+
/** Total body lines of the segment's heredocs, whose bodies are not
|
|
856
|
+
* shown. */
|
|
857
|
+
heredocLines?: number;
|
|
858
|
+
}
|
|
750
859
|
interface ReviewUiStatus {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
860
|
+
version: 1;
|
|
861
|
+
requestID: string;
|
|
862
|
+
sessionID: string;
|
|
863
|
+
phase: ReviewUiPhase;
|
|
864
|
+
permission: string;
|
|
865
|
+
action: string;
|
|
866
|
+
model: string;
|
|
867
|
+
variant: string;
|
|
868
|
+
emittedAt: number;
|
|
869
|
+
timeoutMs: number;
|
|
870
|
+
reason?: string;
|
|
871
|
+
decision?: ReviewDecision;
|
|
872
|
+
/**
|
|
873
|
+
* When phase is `denied` and this is `"deny"`, the block came from fail-closed
|
|
874
|
+
* escalation disposition rather than an explicit reviewer/policy deny.
|
|
875
|
+
*/
|
|
876
|
+
escalationDisposition?: EscalationDisposition;
|
|
877
|
+
/** Resolved actor (absent on the initial "reviewing" phase, before context
|
|
878
|
+
* collection completes). */
|
|
879
|
+
actorName?: string;
|
|
880
|
+
actorProfile?: ActorProfile;
|
|
881
|
+
/** Jev's hand-off to the reasoning reviewer, on the second "reviewing"
|
|
882
|
+
* status and on the result of a handed-off review. */
|
|
883
|
+
handoff?: HandoffInfo;
|
|
884
|
+
/** How a manual outcome came about; chooses the manual-review toast. */
|
|
885
|
+
resolution?: ManualResolution;
|
|
886
|
+
/** The model that made the decision, on a final status a reviewer model
|
|
887
|
+
* decided; absent on a brake, policy or failure-safe result. */
|
|
888
|
+
decidedBy?: string;
|
|
889
|
+
/** The server's config warnings and degraded-config reasons. V1 carries them
|
|
890
|
+
* on every status; V2 reads them from the `status` RPC. */
|
|
891
|
+
configWarnings?: string[];
|
|
892
|
+
configDegraded?: string[];
|
|
893
|
+
/** The action split at its top-level shell operators. Absent when the
|
|
894
|
+
* server did not segment it or left the segments off to fit the status
|
|
895
|
+
* cap, and from a server that predates segments. */
|
|
896
|
+
actionSegments?: ActionSegment[];
|
|
772
897
|
}
|
|
773
|
-
declare function permissionAction(request: PermissionRequest): string;
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
declare function
|
|
787
|
-
|
|
898
|
+
export declare function permissionAction(request: PermissionRequest): string;
|
|
899
|
+
type UiStatusOptions = {
|
|
900
|
+
model: string;
|
|
901
|
+
variant: string;
|
|
902
|
+
timeoutMs: number;
|
|
903
|
+
reason?: string;
|
|
904
|
+
decision?: ReviewDecision;
|
|
905
|
+
escalationDisposition?: EscalationDisposition;
|
|
906
|
+
emittedAt?: number;
|
|
907
|
+
actorName?: string;
|
|
908
|
+
actorProfile?: ActorProfile;
|
|
909
|
+
actionSegments?: ActionSegment[];
|
|
910
|
+
} & StatusExtrasOptions;
|
|
911
|
+
export declare function createUiStatus(request: PermissionRequest, phase: ReviewUiPhase, options: UiStatusOptions): ReviewUiStatus;
|
|
912
|
+
export declare function encodeUiStatus(status: ReviewUiStatus): string;
|
|
913
|
+
export declare function decodeUiStatus(command: string): ReviewUiStatus | undefined;
|
|
914
|
+
//#endregion
|
|
915
|
+
//#region src/context/ask-decisions.d.ts
|
|
788
916
|
/**
|
|
789
917
|
* Captures user answers to agent ask dialogs (the `question` tool) from the
|
|
790
918
|
* OpenCode event stream and exposes them as compact, session-scoped
|
|
@@ -811,61 +939,66 @@ declare function decodeUiStatus(command: string): ReviewUiStatus | undefined;
|
|
|
811
939
|
* as a custom answer must never land in the registry, prompt, or audit.
|
|
812
940
|
*/
|
|
813
941
|
/** Marker recorded when the user dismisses an ask without answering. */
|
|
814
|
-
declare const DISMISSED_ANSWER = "Dismissed by user";
|
|
942
|
+
export declare const DISMISSED_ANSWER = "Dismissed by user";
|
|
815
943
|
type Logger$1 = (message: string, details?: unknown) => void;
|
|
816
944
|
/** What the evidence assembler consumes: a bounded, lineage-scoped query. */
|
|
817
945
|
interface AskDecisionSource {
|
|
818
|
-
|
|
946
|
+
recentFor(sessionIDs: string[], limit?: number): AskDecision[];
|
|
819
947
|
}
|
|
820
|
-
declare class AskDecisionRegistry implements AskDecisionSource {
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
948
|
+
export declare class AskDecisionRegistry implements AskDecisionSource {
|
|
949
|
+
private readonly pending;
|
|
950
|
+
private readonly resolved;
|
|
951
|
+
private readonly log;
|
|
952
|
+
private readonly now;
|
|
953
|
+
constructor(logger?: Logger$1, now?: () => number);
|
|
954
|
+
/**
|
|
955
|
+
* Observe one raw event. Total: never throws; anything malformed or
|
|
956
|
+
* unrelated is dropped silently. Must be called synchronously from the event
|
|
957
|
+
* hook so registry mutations are visible to reviews started later.
|
|
958
|
+
*/
|
|
959
|
+
observe(event: unknown): void;
|
|
960
|
+
/**
|
|
961
|
+
* Decisions visible to a review running in `sessionIDs` (the requesting
|
|
962
|
+
* session plus its resolved ancestors), oldest first, bounded to the most
|
|
963
|
+
* recent `limit`. Sibling and unrelated sessions are never visible.
|
|
964
|
+
*/
|
|
965
|
+
recentFor(sessionIDs: string[], limit?: number): AskDecision[];
|
|
966
|
+
/** Observed-but-unresolved asks (diagnostics only). */
|
|
967
|
+
pendingCount(): number;
|
|
968
|
+
/** Resolved decisions retained (diagnostics only). */
|
|
969
|
+
resolvedCount(): number;
|
|
970
|
+
private onAsked;
|
|
971
|
+
private onReplied;
|
|
972
|
+
private onRejected;
|
|
973
|
+
private store;
|
|
846
974
|
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
975
|
+
//#endregion
|
|
976
|
+
//#region src/opencode/v2/server-state.d.ts
|
|
977
|
+
type Context = Parameters<Plugin$1.Plugin["setup"]>[0];
|
|
978
|
+
//#endregion
|
|
979
|
+
//#region src/opencode/v2/server.d.ts
|
|
850
980
|
declare function setup(ctx: Context): Promise<() => Promise<void>>;
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
981
|
+
//#endregion
|
|
982
|
+
//#region src/config.d.ts
|
|
983
|
+
export declare function resolveConfig(options: Record<string, unknown> | undefined): ReviewerConfig;
|
|
984
|
+
//#endregion
|
|
985
|
+
//#region src/ssh-evidence.d.ts
|
|
854
986
|
interface SshAuditSummary {
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
987
|
+
destination: string;
|
|
988
|
+
port?: string;
|
|
989
|
+
remoteCommandSha256?: string;
|
|
990
|
+
stdinSource?: string;
|
|
991
|
+
stdinStatus?: string;
|
|
992
|
+
stdinReason?: string;
|
|
861
993
|
}
|
|
862
994
|
interface SshEnrichmentResult {
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
995
|
+
text: string;
|
|
996
|
+
audit: SshAuditSummary[];
|
|
997
|
+
preflightDenial?: string;
|
|
866
998
|
}
|
|
867
|
-
declare function enrichSshEvidence(request: PermissionRequest, directory: string, worktree: string, maxChars: number): Promise<SshEnrichmentResult>;
|
|
868
|
-
|
|
999
|
+
export declare function enrichSshEvidence(request: PermissionRequest, directory: string, worktree: string, maxChars: number): Promise<SshEnrichmentResult>;
|
|
1000
|
+
//#endregion
|
|
1001
|
+
//#region src/evidence/provider.d.ts
|
|
869
1002
|
/**
|
|
870
1003
|
* A single piece of evidence gathered about a permission request. The runtime
|
|
871
1004
|
* only consumes `text`, `audit`, and `preflightDenial` today; the remaining
|
|
@@ -873,20 +1006,20 @@ declare function enrichSshEvidence(request: PermissionRequest, directory: string
|
|
|
873
1006
|
* changing the interface.
|
|
874
1007
|
*/
|
|
875
1008
|
interface EvidenceFragment {
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1009
|
+
kind: "ssh" | "local_script" | "git";
|
|
1010
|
+
text: string;
|
|
1011
|
+
audit?: SshAuditSummary[];
|
|
1012
|
+
preflightDenial?: string;
|
|
1013
|
+
warnings?: string[];
|
|
1014
|
+
durationMs?: number;
|
|
882
1015
|
}
|
|
883
1016
|
interface EvidenceScope {
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
1017
|
+
directory: string;
|
|
1018
|
+
worktree: string;
|
|
1019
|
+
maxChars: number;
|
|
887
1020
|
}
|
|
888
1021
|
interface EvidenceProviderInput extends EvidenceScope {
|
|
889
|
-
|
|
1022
|
+
request: PermissionRequest;
|
|
890
1023
|
}
|
|
891
1024
|
/**
|
|
892
1025
|
* Enriches a permission request with one category of evidence (SSH analysis,
|
|
@@ -894,78 +1027,82 @@ interface EvidenceProviderInput extends EvidenceScope {
|
|
|
894
1027
|
* fragments are assembled into a single review envelope.
|
|
895
1028
|
*/
|
|
896
1029
|
interface EvidenceProvider {
|
|
897
|
-
|
|
898
|
-
|
|
1030
|
+
readonly id: string;
|
|
1031
|
+
collect(input: EvidenceProviderInput): Promise<EvidenceFragment>;
|
|
899
1032
|
}
|
|
900
|
-
|
|
1033
|
+
//#endregion
|
|
1034
|
+
//#region src/opencode/adapter.d.ts
|
|
901
1035
|
/** What the plugin learned about the host client at startup. */
|
|
902
1036
|
interface OpenCodeCapabilities {
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
1037
|
+
/** A public SDK method to answer a permission request exists. */
|
|
1038
|
+
publicPermissionReply: boolean;
|
|
1039
|
+
/** That public method can carry a free-text feedback `message`. */
|
|
1040
|
+
permissionReplyMessage: boolean;
|
|
1041
|
+
/** The authenticated raw `_client.post` transport is reachable. */
|
|
1042
|
+
rawAuthenticatedTransport: boolean;
|
|
1043
|
+
/** `client.session.get` is available (lineage walking depends on it). */
|
|
1044
|
+
sessionGet: boolean;
|
|
1045
|
+
/** Session records expose a `parentID` (lineage traversal). */
|
|
1046
|
+
sessionParentID: boolean;
|
|
1047
|
+
/** Assistant messages carry an `agent` field (actor identity). */
|
|
1048
|
+
assistantAgentMetadata: boolean;
|
|
1049
|
+
/** Assistant messages carry a `mode` field (actor identity). */
|
|
1050
|
+
assistantModeMetadata: boolean;
|
|
1051
|
+
/** Effective permission rules can be resolved per session. */
|
|
1052
|
+
effectivePermissions: boolean;
|
|
1053
|
+
/** `client.tui.publish` is available for status broadcasting. */
|
|
1054
|
+
tuiPublish: boolean;
|
|
921
1055
|
}
|
|
922
|
-
|
|
1056
|
+
//#endregion
|
|
1057
|
+
//#region src/opencode/types.d.ts
|
|
923
1058
|
interface ClientResponse<T> {
|
|
924
|
-
|
|
925
|
-
|
|
1059
|
+
data?: T;
|
|
1060
|
+
error?: unknown;
|
|
926
1061
|
}
|
|
927
1062
|
interface OpenCodeClientLike {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
1063
|
+
session: {
|
|
1064
|
+
create(options: unknown): Promise<ClientResponse<Record<string, unknown>>>;
|
|
1065
|
+
messages(options: unknown): Promise<ClientResponse<unknown>>;
|
|
1066
|
+
prompt(options: unknown): Promise<ClientResponse<Record<string, unknown>>>;
|
|
1067
|
+
delete?(options: unknown): Promise<ClientResponse<unknown>>;
|
|
1068
|
+
abort?(options: unknown): Promise<ClientResponse<unknown>>;
|
|
1069
|
+
/** Fetch session metadata (parentID, title, …). Optional: the actor resolver
|
|
1070
|
+
* degrades to "lineage unavailable" when the host client does not expose it. */
|
|
1071
|
+
get?(options: unknown): Promise<ClientResponse<unknown>>;
|
|
1072
|
+
};
|
|
1073
|
+
tool: {
|
|
1074
|
+
ids(options?: unknown): Promise<ClientResponse<string[]>>;
|
|
1075
|
+
};
|
|
1076
|
+
/** Host MCP inventory, keyed by server name. The V1 host exposes
|
|
1077
|
+
* `mcp.status({ query: { directory } })` and returns `{}` for a location
|
|
1078
|
+
* whose config excludes MCP. Optional so narrow clients still typecheck;
|
|
1079
|
+
* the reviewer guard fails closed when it is absent. */
|
|
1080
|
+
mcp?: {
|
|
1081
|
+
status(options?: unknown): Promise<ClientResponse<Record<string, unknown>>>;
|
|
1082
|
+
};
|
|
948
1083
|
}
|
|
949
1084
|
interface RuntimeContext {
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
1085
|
+
hostVersion?: string;
|
|
1086
|
+
client: OpenCodeClientLike;
|
|
1087
|
+
/** What the plugin learned about the host client at startup (probe result).
|
|
1088
|
+
* Surfaced to diagnostics and available to any future adapter consumer. */
|
|
1089
|
+
capabilities: OpenCodeCapabilities;
|
|
1090
|
+
permissionReply(options: unknown): Promise<ClientResponse<unknown>>;
|
|
1091
|
+
publishUiStatus?(status: ReviewUiStatus): Promise<ClientResponse<unknown>>;
|
|
1092
|
+
writeAudit?(record: ReviewAuditRecord): Promise<void>;
|
|
1093
|
+
directory: string;
|
|
1094
|
+
worktree: string;
|
|
1095
|
+
/** Where reviewer sessions run when isolation is available: a directory
|
|
1096
|
+
* without project instructions or project config. Production resolves the
|
|
1097
|
+
* shared data directory; tests inject a scratch path so they never touch
|
|
1098
|
+
* the developer's HOME. */
|
|
1099
|
+
reviewerDirectoryBase?: string;
|
|
965
1100
|
}
|
|
966
|
-
|
|
1101
|
+
//#endregion
|
|
1102
|
+
//#region src/core/coordinator-state.d.ts
|
|
967
1103
|
type Logger = (message: string, details?: unknown) => void;
|
|
968
|
-
|
|
1104
|
+
//#endregion
|
|
1105
|
+
//#region src/core/review-coordinator.d.ts
|
|
969
1106
|
/**
|
|
970
1107
|
* Owns the review lifecycle for permission requests: orchestration, the
|
|
971
1108
|
* supersede state machine, and the model call. The adapter (transport) and the
|
|
@@ -973,87 +1110,92 @@ type Logger = (message: string, details?: unknown) => void;
|
|
|
973
1110
|
* races.
|
|
974
1111
|
*/
|
|
975
1112
|
declare class ReviewCoordinator {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1113
|
+
private readonly state;
|
|
1114
|
+
private readonly limiter;
|
|
1115
|
+
private readonly pending;
|
|
1116
|
+
constructor(ctx: RuntimeContext, config: ReviewerConfig, logger?: Logger, providers?: EvidenceProvider[], askDecisions?: AskDecisionSource);
|
|
1117
|
+
pendingCount(): number;
|
|
1118
|
+
waitForIdle(): Promise<void>;
|
|
1119
|
+
dispose(): Promise<void>;
|
|
1120
|
+
handle(request: PermissionRequest): void;
|
|
1121
|
+
process(request: PermissionRequest): Promise<ReviewExecutionResult>;
|
|
1122
|
+
handlePermissionReply(event: unknown): void;
|
|
1123
|
+
/**
|
|
1124
|
+
* @deprecated No-op. Approvals no longer annotate tool results so they do not
|
|
1125
|
+
* contaminate the primary agent context. Kept for public API compatibility;
|
|
1126
|
+
* the plugin no longer registers a host hook that calls this. Rationale
|
|
1127
|
+
* remains in audit, TUI, and debug.
|
|
1128
|
+
*/
|
|
1129
|
+
annotateToolResult(callID: string, output: {
|
|
1130
|
+
output?: unknown;
|
|
1131
|
+
metadata?: unknown;
|
|
1132
|
+
}): void;
|
|
996
1133
|
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
declare
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
readonly minLength: 3;
|
|
1028
|
-
readonly maxLength: 2000;
|
|
1029
|
-
readonly description: "One concise sentence explaining the main reason for the decision";
|
|
1030
|
-
};
|
|
1031
|
-
readonly confidence: {
|
|
1032
|
-
readonly type: "number";
|
|
1033
|
-
readonly minimum: 0;
|
|
1034
|
-
readonly maximum: 1;
|
|
1035
|
-
};
|
|
1036
|
-
readonly scope_alignment: {
|
|
1037
|
-
readonly type: "string";
|
|
1038
|
-
readonly enum: readonly ["aligned", "partial", "misaligned", "unknown"];
|
|
1039
|
-
readonly description: "How well the request aligns with the recovered user or delegated intent: aligned (within scope), partial (tangential), misaligned (outside scope), unknown (insufficient context).";
|
|
1040
|
-
};
|
|
1041
|
-
readonly evidence_completeness: {
|
|
1042
|
-
readonly type: "string";
|
|
1043
|
-
readonly enum: readonly ["sufficient", "partial", "insufficient", "unknown"];
|
|
1044
|
-
readonly description: "Whether the evidence was sufficient to decide: sufficient, partial (some gaps), insufficient (major gaps), unknown.";
|
|
1045
|
-
};
|
|
1046
|
-
readonly script_analysis: {
|
|
1047
|
-
readonly type: "string";
|
|
1048
|
-
readonly minLength: 20;
|
|
1049
|
-
readonly maxLength: 1500;
|
|
1050
|
-
readonly description: "Optional factual analysis of a fully supplied verified script. Describe effects and uncertainty, never user authorization or an approval.";
|
|
1051
|
-
};
|
|
1134
|
+
//#endregion
|
|
1135
|
+
//#region src/decision.d.ts
|
|
1136
|
+
export declare function parseDecision(value: unknown): ReviewDecision | undefined;
|
|
1137
|
+
//#endregion
|
|
1138
|
+
//#region src/decision-gates.d.ts
|
|
1139
|
+
export declare function enforceDecision(decision: ReviewDecision, config: ReviewerConfig): ReviewExecutionResult;
|
|
1140
|
+
//#endregion
|
|
1141
|
+
//#region src/decision-schema.d.ts
|
|
1142
|
+
export declare const DECISION_SCHEMA: {
|
|
1143
|
+
readonly type: "object";
|
|
1144
|
+
readonly additionalProperties: false;
|
|
1145
|
+
readonly required: readonly ["version", "outcome", "risk_level", "user_authorization", "scope_alignment", "evidence_completeness", "rationale", "confidence"];
|
|
1146
|
+
readonly properties: {
|
|
1147
|
+
readonly version: {
|
|
1148
|
+
readonly type: "number";
|
|
1149
|
+
readonly enum: readonly [2];
|
|
1150
|
+
readonly description: "Structured-decision schema version. Must be exactly 2.";
|
|
1151
|
+
};
|
|
1152
|
+
readonly outcome: {
|
|
1153
|
+
readonly type: "string";
|
|
1154
|
+
readonly enum: readonly ["allow", "deny", "escalate"];
|
|
1155
|
+
readonly description: "allow executes once, deny rejects, escalate leaves the request for a human";
|
|
1156
|
+
};
|
|
1157
|
+
readonly risk_level: {
|
|
1158
|
+
readonly type: "string";
|
|
1159
|
+
readonly enum: readonly ["low", "medium", "high", "critical"];
|
|
1160
|
+
};
|
|
1161
|
+
readonly user_authorization: {
|
|
1162
|
+
readonly type: "string";
|
|
1163
|
+
readonly enum: readonly ["high", "medium", "low", "unknown"];
|
|
1052
1164
|
};
|
|
1165
|
+
readonly rationale: {
|
|
1166
|
+
readonly type: "string";
|
|
1167
|
+
readonly minLength: 3;
|
|
1168
|
+
readonly maxLength: 2000;
|
|
1169
|
+
readonly description: "One concise sentence explaining the main reason for the decision";
|
|
1170
|
+
};
|
|
1171
|
+
readonly confidence: {
|
|
1172
|
+
readonly type: "number";
|
|
1173
|
+
readonly minimum: 0;
|
|
1174
|
+
readonly maximum: 1;
|
|
1175
|
+
};
|
|
1176
|
+
readonly scope_alignment: {
|
|
1177
|
+
readonly type: "string";
|
|
1178
|
+
readonly enum: readonly ["aligned", "partial", "misaligned", "unknown"];
|
|
1179
|
+
readonly description: "How well the request aligns with the recovered user or delegated intent: aligned (within scope), partial (tangential), misaligned (outside scope), unknown (insufficient context).";
|
|
1180
|
+
};
|
|
1181
|
+
readonly evidence_completeness: {
|
|
1182
|
+
readonly type: "string";
|
|
1183
|
+
readonly enum: readonly ["sufficient", "partial", "insufficient", "unknown"];
|
|
1184
|
+
readonly description: "Whether the evidence was sufficient to decide: sufficient, partial (some gaps), insufficient (major gaps), unknown.";
|
|
1185
|
+
};
|
|
1186
|
+
readonly script_analysis: {
|
|
1187
|
+
readonly type: "string";
|
|
1188
|
+
readonly minLength: 20;
|
|
1189
|
+
readonly maxLength: 1500;
|
|
1190
|
+
readonly description: "Optional factual analysis of a fully supplied verified script. Describe effects and uncertainty, never user authorization or an approval.";
|
|
1191
|
+
};
|
|
1192
|
+
};
|
|
1053
1193
|
};
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1194
|
+
//#endregion
|
|
1195
|
+
//#region src/emergency-brake.d.ts
|
|
1196
|
+
export declare function emergencyBrakeReason(request: PermissionRequest): string | undefined;
|
|
1197
|
+
//#endregion
|
|
1198
|
+
//#region src/escalation.d.ts
|
|
1057
1199
|
/**
|
|
1058
1200
|
* Categories that can be hardened independently of the global escalation mode
|
|
1059
1201
|
* via `riskPolicy.onInvalidDecision` / `riskPolicy.onReviewerFailure`.
|
|
@@ -1071,7 +1213,7 @@ type EscalationCategory = "general" | "invalid-decision" | "reviewer-failure";
|
|
|
1071
1213
|
*
|
|
1072
1214
|
* `manual-superseded` is never converted: the request is already closed.
|
|
1073
1215
|
*/
|
|
1074
|
-
declare function resolveEscalationDisposition(result: ReviewExecutionResult, config: ReviewerConfig, category?: EscalationCategory): EscalationDisposition;
|
|
1216
|
+
export declare function resolveEscalationDisposition(result: ReviewExecutionResult, config: ReviewerConfig, category?: EscalationCategory): EscalationDisposition;
|
|
1075
1217
|
/**
|
|
1076
1218
|
* Single enforcement boundary: convert an internal escalate into the effective
|
|
1077
1219
|
* disposition used for UI, reply, and audit. Allow/deny and manual-superseded
|
|
@@ -1084,20 +1226,23 @@ declare function resolveEscalationDisposition(result: ReviewExecutionResult, con
|
|
|
1084
1226
|
* structured decision. `reviewerOutcome` is only set when a structured
|
|
1085
1227
|
* decision actually existed.
|
|
1086
1228
|
*/
|
|
1087
|
-
declare function applyEscalationDisposition(result: ReviewExecutionResult, config: ReviewerConfig, category?: EscalationCategory): ReviewExecutionResult;
|
|
1088
|
-
|
|
1229
|
+
export declare function applyEscalationDisposition(result: ReviewExecutionResult, config: ReviewerConfig, category?: EscalationCategory): ReviewExecutionResult;
|
|
1230
|
+
//#endregion
|
|
1231
|
+
//#region src/git-evidence.d.ts
|
|
1089
1232
|
interface GitEnrichmentResult {
|
|
1090
|
-
|
|
1233
|
+
text: string;
|
|
1091
1234
|
}
|
|
1092
|
-
declare function enrichGitEvidence(request: PermissionRequest, directory: string, maxChars: number, worktree?: string): Promise<GitEnrichmentResult>;
|
|
1093
|
-
|
|
1235
|
+
export declare function enrichGitEvidence(request: PermissionRequest, directory: string, maxChars: number, worktree?: string): Promise<GitEnrichmentResult>;
|
|
1236
|
+
//#endregion
|
|
1237
|
+
//#region src/local-script-evidence.d.ts
|
|
1094
1238
|
interface LocalScriptEnrichmentResult {
|
|
1095
|
-
|
|
1239
|
+
text: string;
|
|
1096
1240
|
}
|
|
1097
1241
|
/** `rootDirectory` is the approved evidence root, which can sit above
|
|
1098
1242
|
* `directory` (package-script expansion passes the session directory). */
|
|
1099
|
-
declare function enrichLocalScriptEvidence(request: PermissionRequest, directory: string, worktree: string, maxChars: number, rootDirectory?: string): Promise<LocalScriptEnrichmentResult>;
|
|
1100
|
-
|
|
1243
|
+
export declare function enrichLocalScriptEvidence(request: PermissionRequest, directory: string, worktree: string, maxChars: number, rootDirectory?: string): Promise<LocalScriptEnrichmentResult>;
|
|
1244
|
+
//#endregion
|
|
1245
|
+
//#region src/opencode/event-normalizer.d.ts
|
|
1101
1246
|
/**
|
|
1102
1247
|
* Normalize a raw OpenCode event into a {@link PermissionRequest}.
|
|
1103
1248
|
*
|
|
@@ -1105,36 +1250,39 @@ declare function enrichLocalScriptEvidence(request: PermissionRequest, directory
|
|
|
1105
1250
|
* `permission.asked` event, so callers can ignore irrelevant events without
|
|
1106
1251
|
* inspecting their shape.
|
|
1107
1252
|
*/
|
|
1108
|
-
declare function extractPermissionRequest(event: unknown): PermissionRequest | undefined;
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1253
|
+
export declare function extractPermissionRequest(event: unknown): PermissionRequest | undefined;
|
|
1254
|
+
//#endregion
|
|
1255
|
+
//#region src/redact.d.ts
|
|
1256
|
+
export declare function redactSecrets(input: string): string;
|
|
1257
|
+
//#endregion
|
|
1258
|
+
//#region src/ui-state.d.ts
|
|
1112
1259
|
interface UiStateOptions {
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1260
|
+
model: string;
|
|
1261
|
+
variant: string;
|
|
1262
|
+
timeoutMs: number;
|
|
1116
1263
|
}
|
|
1117
|
-
declare class ReviewUiState {
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1264
|
+
export declare class ReviewUiState {
|
|
1265
|
+
private readonly options;
|
|
1266
|
+
private readonly requests;
|
|
1267
|
+
private readonly acknowledged;
|
|
1268
|
+
constructor(options: UiStateOptions);
|
|
1269
|
+
asked(request: PermissionRequest, now?: number): ReviewUiStatus;
|
|
1270
|
+
apply(status: ReviewUiStatus): boolean;
|
|
1271
|
+
replied(requestID: string): void;
|
|
1272
|
+
remove(requestID: string): void;
|
|
1273
|
+
get(requestID: string): ReviewUiStatus | undefined;
|
|
1274
|
+
all(): ReviewUiStatus[];
|
|
1275
|
+
activeFor(sessionID: string, parentOf: (sessionID: string) => string | undefined): ReviewUiStatus | undefined;
|
|
1276
|
+
expire(now?: number): ReviewUiStatus[];
|
|
1277
|
+
dismissResults(now?: number): string[];
|
|
1131
1278
|
}
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
declare const
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1279
|
+
//#endregion
|
|
1280
|
+
//#region src/index.d.ts
|
|
1281
|
+
export declare const server: Plugin;
|
|
1282
|
+
declare const module: {
|
|
1283
|
+
id: string;
|
|
1284
|
+
server: Plugin;
|
|
1285
|
+
setup: typeof setup;
|
|
1138
1286
|
};
|
|
1139
|
-
|
|
1140
|
-
export { type ActionPurpose, type ActorContext, type ActorProfile, ReviewCoordinator as ApprovalReviewerRuntime, type ApprovedAnnotation, type AskDecision,
|
|
1287
|
+
//#endregion
|
|
1288
|
+
export { type ActionPurpose, type ActorContext, type ActorProfile, ReviewCoordinator as ApprovalReviewerRuntime, type ApprovedAnnotation, type AskDecision, type CapabilityActionClass, type CapabilityAssessment, type DecisionSource, type EffectivePermissionSummary, type EscalatedFrom, type EscalationDisposition, type EscalationMode, type EscalationReviewerConfig, type EvidenceCompleteness, type EvidenceConfidence, type EvidenceSufficiency, type HandoffTrigger, type HeredocRecord, type IntentBlock, type IntentContext, type ManualResolution, type MessageWithParts, type ParsedCommand, type ParserCompleteness, type PermissionRequest, type PermissionToolSource, type PolicyCondition, type PolicyRule, type PolicyTrace, type Provenanced, type Redirection, type RepositoryTrust, type ReviewAuditRecord, type ReviewDecision, type ReviewEnvelope, type ReviewExecutionResult, type ReviewOutcome, type ReviewerConfig, type ReviewerOutputFormat, type RiskLevel, type RiskPolicy, type SYSTEM_ONE_BASES, type ScopeAlignment, type SessionLineage, type SessionNode, type SystemOneChoiceScore, type SystemOneEscalationMode, type SystemOnePrimaryBasis, type SystemOneScores, type SystemOneSignals, type UserAuthorization, module as default };
|