@noppu-labs/opencode-permission-reviewer 3.1.0 → 3.2.1
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 +33 -0
- package/MIGRATION.md +4 -7
- package/NOTICE +2 -2
- package/README.md +1 -1
- package/dist/explain.js +2725 -2725
- package/dist/index.d.ts +638 -538
- package/dist/index.js +11560 -11504
- package/dist/rpc.d.ts +1 -1
- package/dist/rpc.js +1 -1
- package/dist/tui/{opencode → adapters/opencode}/event-normalizer.ts +2 -2
- package/dist/tui/{config-fields.ts → modules/config/models/config-fields.ts} +2 -2
- package/dist/tui/{config-knobs.ts → modules/config/models/config-knobs.ts} +1 -1
- package/dist/tui/{config-policy-rules.ts → modules/config/models/config-policy-rules.ts} +2 -2
- package/dist/tui/{config-risk-policy.ts → modules/config/models/config-risk-policy.ts} +2 -1
- package/dist/tui/{config.ts → modules/config/services/config.ts} +5 -5
- package/dist/tui/{config → modules/config/services}/layer-read.ts +4 -3
- package/dist/tui/{config → modules/config/services}/loader.ts +3 -3
- package/dist/tui/{reviewer-model.ts → modules/config/services/reviewer-model.ts} +6 -3
- package/dist/tui/{config → modules/config/services}/risk-policy-clamp.ts +2 -2
- package/dist/tui/{system-one-routing.ts → modules/config/services/system-one-routing.ts} +1 -1
- package/dist/tui/{config → modules/config/services}/trust-boundary.ts +4 -4
- package/dist/tui/{config → modules/config/services}/trusted-degradation.ts +2 -2
- package/dist/tui/{config-rule-condition.ts → modules/policy/config-rule-condition.ts} +1 -1
- package/dist/tui/{ui-protocol.ts → modules/status/models/ui-protocol.ts} +9 -9
- package/dist/tui/{ui-state.ts → modules/status/services/ui-state.ts} +2 -2
- package/dist/tui/{ui-status-extras.ts → modules/status/services/ui-status-extras.ts} +4 -2
- package/dist/tui/{ui-status-parse.ts → modules/status/services/ui-status-parse.ts} +5 -5
- package/dist/tui/tui.tsx +5 -5
- package/dist/tui/ui/action-fit.ts +10 -2
- package/dist/tui/ui/attribution.ts +4 -3
- package/dist/tui/ui/components.tsx +1 -1
- package/dist/tui/ui/config-notices.ts +1 -1
- package/dist/tui/ui/fit-parts.ts +1 -1
- package/dist/tui/ui/manual-toast.ts +3 -3
- package/dist/tui/ui/review-feed.ts +3 -3
- package/dist/tui/ui/review-overlay.tsx +1 -1
- package/dist/tui/ui/review-result.tsx +1 -1
- package/dist/tui/ui/review-store.ts +3 -3
- package/dist/tui/ui/review-theme.ts +1 -1
- package/dist/tui/ui/v1-host.ts +5 -2
- package/dist/tui/ui/v2.tsx +1 -1
- package/package.json +10 -8
- package/dist/tui/types.ts +0 -357
- /package/dist/tui/{config → modules/config/services}/jsonc.ts +0 -0
- /package/dist/tui/{config → modules/config/services}/trust-boundary-keys.ts +0 -0
- /package/dist/tui/{failure-kind.ts → modules/status/models/failure-kind.ts} +0 -0
- /package/dist/tui/{ui → modules/status/models}/rpc.ts +0 -0
- /package/dist/tui/{ui-text-elide.ts → modules/status/services/ui-text-elide.ts} +0 -0
- /package/dist/tui/{descriptor-io.ts → utils/descriptor-io.ts} +0 -0
- /package/dist/tui/{is-record.ts → utils/is-record.ts} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,257 +1,13 @@
|
|
|
1
|
-
import { TypeSafeClient } from "@typesafe-ai/sdk";
|
|
2
1
|
import "@opencode/client";
|
|
3
2
|
import { Plugin } from "@opencode-ai/plugin";
|
|
4
3
|
import { Plugin as Plugin$1 } from "@opencode/plugin";
|
|
5
4
|
import "@opencode/plugin/promise/permission";
|
|
6
|
-
//#region src/
|
|
7
|
-
interface VerifiedScriptEvidence {
|
|
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;
|
|
28
|
-
}
|
|
29
|
-
interface ShellToken {
|
|
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[];
|
|
43
|
-
}
|
|
44
|
-
interface ShellSegment {
|
|
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;
|
|
58
|
-
}
|
|
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
|
|
72
|
-
/** How completely the command could be statically analyzed. */
|
|
73
|
-
type ParserCompleteness =
|
|
74
|
-
/** Fully parsed: no variables, globs, substitutions, or heredoc bodies. */
|
|
75
|
-
"complete-for-supported-form" |
|
|
76
|
-
/** Some constructs could not be resolved (variables, partial heredoc). */
|
|
77
|
-
"partial" |
|
|
78
|
-
/** Heavy dynamic constructs (command substitution, eval, dynamic heredoc). */
|
|
79
|
-
"opaque";
|
|
80
|
-
/** A redirection extracted from a parsed command segment. */
|
|
81
|
-
interface Redirection {
|
|
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;
|
|
88
|
-
}
|
|
89
|
-
/** A heredoc extracted before lexing so its body never reaches the lexer/brake. */
|
|
90
|
-
interface HeredocRecord {
|
|
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;
|
|
107
|
-
}
|
|
108
|
-
/** A command parsed into a reusable structure. Wraps the existing lexer output
|
|
109
|
-
* plus pre-extracted redirections and heredocs. */
|
|
110
|
-
interface ParsedCommand {
|
|
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;
|
|
141
|
-
}
|
|
142
|
-
/** What the action can do, what it appears to do, and analysis confidence. */
|
|
143
|
-
interface CapabilityAssessment {
|
|
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[];
|
|
198
|
-
}
|
|
199
|
-
//#endregion
|
|
200
|
-
//#region src/system-one/system-one-types.d.ts
|
|
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"];
|
|
202
|
-
type SystemOnePrimaryBasis = (typeof SYSTEM_ONE_BASES)[number];
|
|
203
|
-
interface SystemOneChoiceScore<T extends string> {
|
|
204
|
-
choice: T;
|
|
205
|
-
confidence: number;
|
|
206
|
-
}
|
|
207
|
-
/** Probability (0-1) that each safety question is true. */
|
|
208
|
-
interface SystemOneSignals {
|
|
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;
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Jev's own answer, kept apart from the final decision because a reasoning
|
|
221
|
-
* reviewer may replace it. Numbers, enum choices, fixed contradiction strings,
|
|
222
|
-
* and the provider-reported model ID only; never evidence text.
|
|
223
|
-
*/
|
|
224
|
-
interface SystemOneScores {
|
|
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;
|
|
241
|
-
}
|
|
242
|
-
//#endregion
|
|
243
|
-
//#region src/types.d.ts
|
|
5
|
+
//#region src/kernel/review-decision.d.ts
|
|
244
6
|
type RiskLevel = "low" | "medium" | "high" | "critical";
|
|
245
7
|
type UserAuthorization = "high" | "medium" | "low" | "unknown";
|
|
246
8
|
type ReviewOutcome = "allow" | "deny" | "escalate";
|
|
247
9
|
type ScopeAlignment = "aligned" | "partial" | "misaligned" | "unknown";
|
|
248
10
|
type EvidenceSufficiency = "sufficient" | "partial" | "insufficient" | "unknown";
|
|
249
|
-
/** How final escalations are disposed after reviewer/policy/fail-safe produce them. */
|
|
250
|
-
type EscalationMode = "manual" | "deny";
|
|
251
|
-
/** Effective disposition applied to an internal escalate result. */
|
|
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";
|
|
255
11
|
interface ReviewDecision {
|
|
256
12
|
/** Structured-decision schema version. Always 2 for the current schema. */
|
|
257
13
|
version: 2;
|
|
@@ -267,27 +23,17 @@ interface ReviewDecision {
|
|
|
267
23
|
/** Optional script-only semantic analysis. Never conveys authorization. */
|
|
268
24
|
script_analysis?: string;
|
|
269
25
|
}
|
|
270
|
-
interface
|
|
271
|
-
|
|
272
|
-
callID: string;
|
|
273
|
-
}
|
|
274
|
-
interface PermissionRequest {
|
|
275
|
-
id: string;
|
|
26
|
+
interface ApprovedAnnotation {
|
|
27
|
+
requestID: string;
|
|
276
28
|
sessionID: string;
|
|
277
|
-
|
|
278
|
-
patterns: string[];
|
|
279
|
-
metadata: Record<string, unknown>;
|
|
280
|
-
always: string[];
|
|
281
|
-
tool?: PermissionToolSource;
|
|
282
|
-
}
|
|
283
|
-
interface MessageWithParts {
|
|
284
|
-
info: Record<string, unknown> & {
|
|
285
|
-
id?: string;
|
|
286
|
-
role?: string;
|
|
287
|
-
structured?: unknown;
|
|
288
|
-
};
|
|
289
|
-
parts: Array<Record<string, unknown>>;
|
|
29
|
+
decision: ReviewDecision;
|
|
290
30
|
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/kernel/reviewer-config.d.ts
|
|
33
|
+
/** How final escalations are disposed after reviewer/policy/fail-safe produce them. */
|
|
34
|
+
type EscalationMode = "manual" | "deny";
|
|
35
|
+
/** Where an escalation that starts at Jev goes; `reasoning-first` sends every one to the escalation reviewer. */
|
|
36
|
+
type SystemOneEscalationMode = "standard" | "reasoning-first";
|
|
291
37
|
/** Deterministic risk×authorization matrix that gates reviewer `allow`
|
|
292
38
|
* outcomes. For each risk level, lists the authorization levels that permit an
|
|
293
39
|
* auto-allow. An empty array means no authorization permits auto-allow at that
|
|
@@ -435,102 +181,12 @@ interface ReviewerConfig {
|
|
|
435
181
|
* on but inert. Informational only: never affects a decision. */
|
|
436
182
|
configWarnings?: string[];
|
|
437
183
|
}
|
|
438
|
-
interface ReviewEnvelope {
|
|
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[];
|
|
482
|
-
}
|
|
483
|
-
interface ApprovedAnnotation {
|
|
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;
|
|
496
|
-
}
|
|
497
|
-
/** How an escalation that left the System One backend was reached. */
|
|
498
|
-
type ManualResolution = "reviewer" | "reasoning-escalated" | "reasoning-unavailable" | "budget-exhausted";
|
|
499
|
-
interface ReviewExecutionResult {
|
|
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;
|
|
527
|
-
}
|
|
528
184
|
/** Generic policy templates, NOT automatic trust levels. */
|
|
529
185
|
type ActorProfile = "read-only" | "validation" | "workspace" | "operator" | "reviewer" | "unknown";
|
|
530
186
|
/** High-level classification of what the action does. */
|
|
531
187
|
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";
|
|
532
188
|
//#endregion
|
|
533
|
-
//#region src/actor-context-types.d.ts
|
|
189
|
+
//#region src/kernel/actor-context-types.d.ts
|
|
534
190
|
/** Reliability of a derived fact. */
|
|
535
191
|
type EvidenceConfidence = "confirmed" | "high" | "medium" | "low" | "unknown";
|
|
536
192
|
/** Every non-trivial derived fact carries provenance so the LLM and audit can
|
|
@@ -638,10 +294,95 @@ interface ActionPurpose {
|
|
|
638
294
|
confidence: EvidenceConfidence;
|
|
639
295
|
}
|
|
640
296
|
//#endregion
|
|
641
|
-
//#region src/
|
|
297
|
+
//#region src/kernel/review-result.d.ts
|
|
298
|
+
/** Effective disposition applied to an internal escalate result. */
|
|
299
|
+
type EscalationDisposition = "manual" | "deny";
|
|
300
|
+
/** Why a System One (Jev) result was handed to the reasoning reviewer. */
|
|
301
|
+
type HandoffTrigger = "jev-escalate" | "jev-uncertain-allow" | "jev-gate" | "jev-invalid" | "jev-failure" | "jev-uncertain-deny";
|
|
302
|
+
/** The primary model, routing reason and hand-off trigger of a review a
|
|
303
|
+
* second reviewer decided. */
|
|
304
|
+
interface EscalatedFrom {
|
|
305
|
+
model: string;
|
|
306
|
+
reason: string;
|
|
307
|
+
trigger?: HandoffTrigger;
|
|
308
|
+
}
|
|
309
|
+
/** How an escalation that left the System One backend was reached. */
|
|
310
|
+
type ManualResolution = "reviewer" | "reasoning-escalated" | "reasoning-unavailable" | "budget-exhausted";
|
|
311
|
+
interface ReviewExecutionResult {
|
|
312
|
+
kind: "allow" | "deny" | "escalate";
|
|
313
|
+
decision?: ReviewDecision;
|
|
314
|
+
reason: string;
|
|
315
|
+
reviewSessionID?: string;
|
|
316
|
+
/** Which layer produced this result; threaded into the audit record. */
|
|
317
|
+
decisionSource?: DecisionSource;
|
|
318
|
+
/** Actual model that produced the final reviewer decision. */
|
|
319
|
+
reviewerModel?: string;
|
|
320
|
+
/** Primary model, routing reason and hand-off trigger when a second
|
|
321
|
+
* reviewer was used. */
|
|
322
|
+
reviewerEscalatedFrom?: EscalatedFrom;
|
|
323
|
+
/** Jev's scores whenever it returned a parsed decision. */
|
|
324
|
+
systemOne?: SystemOneScores;
|
|
325
|
+
/**
|
|
326
|
+
* Structured outcome from the reviewer LLM before gates/disposition.
|
|
327
|
+
* Absent when no valid structured decision was produced.
|
|
328
|
+
*/
|
|
329
|
+
reviewerOutcome?: ReviewOutcome;
|
|
330
|
+
/**
|
|
331
|
+
* How an internal escalate was disposed at the enforcement boundary.
|
|
332
|
+
* Absent when the result was never an escalate (explicit allow/deny) or when
|
|
333
|
+
* the request was already answered manually (`manual-superseded`).
|
|
334
|
+
*/
|
|
335
|
+
escalationDisposition?: EscalationDisposition;
|
|
336
|
+
/** Set only by the System One backend, on escalations; kept when a
|
|
337
|
+
* disposition turns one into a deny. */
|
|
338
|
+
resolution?: ManualResolution;
|
|
339
|
+
}
|
|
642
340
|
/** Which layer produced the final decision for a request. Threaded into the
|
|
643
341
|
* audit record so reports can split outcomes by source. */
|
|
644
342
|
type DecisionSource = "emergency-brake" | "deterministic-policy" | "llm-reviewer" | "system-one-reviewer" | "manual-superseded" | "failure-safe";
|
|
343
|
+
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"];
|
|
344
|
+
type SystemOnePrimaryBasis = (typeof SYSTEM_ONE_BASES)[number];
|
|
345
|
+
interface SystemOneChoiceScore<T extends string> {
|
|
346
|
+
choice: T;
|
|
347
|
+
confidence: number;
|
|
348
|
+
}
|
|
349
|
+
/** Probability (0-1) that each safety question is true. */
|
|
350
|
+
interface SystemOneSignals {
|
|
351
|
+
materialAuthorization: number;
|
|
352
|
+
withinIntentScope: number;
|
|
353
|
+
unauthorizedDataLoss: number;
|
|
354
|
+
untrustedSensitiveDisclosure: number;
|
|
355
|
+
excessiveCredentialAccess: number;
|
|
356
|
+
unauthorizedSecurityChange: number;
|
|
357
|
+
unauthorizedExternalMutation: number;
|
|
358
|
+
essentialEvidenceMissing: number;
|
|
359
|
+
absolutePolicyDeny: number;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Jev's own answer, kept apart from the final decision because a reasoning
|
|
363
|
+
* reviewer may replace it. Numbers, enum choices, fixed contradiction strings,
|
|
364
|
+
* and the provider-reported model ID only; never evidence text.
|
|
365
|
+
*/
|
|
366
|
+
interface SystemOneScores {
|
|
367
|
+
/** Versioned model ID the provider reported as having answered. */
|
|
368
|
+
returnedModel: string;
|
|
369
|
+
outcome: SystemOneChoiceScore<ReviewOutcome> & {
|
|
370
|
+
probabilities: Record<ReviewOutcome, number>;
|
|
371
|
+
};
|
|
372
|
+
supporting: {
|
|
373
|
+
riskLevel: SystemOneChoiceScore<RiskLevel>;
|
|
374
|
+
userAuthorization: SystemOneChoiceScore<UserAuthorization>;
|
|
375
|
+
scopeAlignment: SystemOneChoiceScore<ScopeAlignment>;
|
|
376
|
+
evidenceCompleteness: SystemOneChoiceScore<EvidenceSufficiency>;
|
|
377
|
+
primaryBasis: SystemOneChoiceScore<SystemOnePrimaryBasis>;
|
|
378
|
+
};
|
|
379
|
+
signals: SystemOneSignals;
|
|
380
|
+
/** Consistency checks that failed; any one marks an allow or deny difficult. */
|
|
381
|
+
contradictions: string[];
|
|
382
|
+
reasoningRecommended: boolean;
|
|
383
|
+
}
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region src/modules/audit/models/audit-record.d.ts
|
|
645
386
|
interface ReviewAuditRecord {
|
|
646
387
|
/**
|
|
647
388
|
* Audit schema version. Present on every record; readers default a missing
|
|
@@ -716,113 +457,431 @@ interface ReviewAuditRecord {
|
|
|
716
457
|
reviewerMs?: number;
|
|
717
458
|
replyMs?: number;
|
|
718
459
|
};
|
|
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;
|
|
769
|
-
};
|
|
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;
|
|
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
|
-
}>;
|
|
460
|
+
/** Non-fatal warnings accumulated during evidence collection/analysis. */
|
|
461
|
+
warnings?: string[];
|
|
462
|
+
reviewerSessionID?: string;
|
|
463
|
+
/** Content identity and inspection mode only; never script text or local path. */
|
|
464
|
+
verifiedScript?: {
|
|
465
|
+
sha256: string;
|
|
466
|
+
status: "full" | "reused" | "unavailable";
|
|
467
|
+
bytes?: number;
|
|
468
|
+
};
|
|
469
|
+
/** Root session of the request's ancestry (additive; absent when lineage was
|
|
470
|
+
* unavailable). */
|
|
471
|
+
rootSessionID?: string;
|
|
472
|
+
/** Overall evidence completeness for the request (additive). */
|
|
473
|
+
evidenceCompleteness?: string;
|
|
474
|
+
/** Resolved actor snapshot for audit (additive). Uses identityCompleteness
|
|
475
|
+
* (not the decision's numeric confidence) to avoid field ambiguity; v2 also
|
|
476
|
+
* carries identitySource + confidence. */
|
|
477
|
+
actor?: {
|
|
478
|
+
name?: string;
|
|
479
|
+
mode?: string;
|
|
480
|
+
profile: ActorProfile;
|
|
481
|
+
identityCompleteness: "complete" | "partial" | "unknown";
|
|
482
|
+
/** How the agent identity was established (tool-message, session-api,
|
|
483
|
+
* unavailable, …). Absent on legacy v1 records. */
|
|
484
|
+
identitySource?: string;
|
|
485
|
+
/** Reliability of the identity claim. Absent on legacy v1 records. */
|
|
486
|
+
confidence?: EvidenceConfidence;
|
|
487
|
+
delegationDepth?: number;
|
|
488
|
+
};
|
|
489
|
+
ssh?: Array<{
|
|
490
|
+
destination: string;
|
|
491
|
+
port?: string;
|
|
492
|
+
remoteCommandSha256?: string;
|
|
493
|
+
stdinSource?: string;
|
|
494
|
+
stdinStatus?: string;
|
|
495
|
+
stdinReason?: string;
|
|
496
|
+
}>;
|
|
497
|
+
/** Additive capability snapshot for audit (observe-only). */
|
|
498
|
+
capability?: {
|
|
499
|
+
actionClass: string;
|
|
500
|
+
summary: string;
|
|
501
|
+
parserCompleteness: string;
|
|
502
|
+
executesCode?: boolean;
|
|
503
|
+
createsAdHocCode?: boolean;
|
|
504
|
+
invokesPackageLifecycleScripts?: boolean;
|
|
505
|
+
writeEffects?: {
|
|
506
|
+
temporaryWrite?: boolean;
|
|
507
|
+
workspaceWrite?: boolean;
|
|
508
|
+
externalWrite?: boolean;
|
|
509
|
+
deletion?: boolean;
|
|
510
|
+
};
|
|
511
|
+
networkObserved?: boolean;
|
|
512
|
+
credentialRead?: boolean;
|
|
513
|
+
privilegeEscalation?: boolean;
|
|
514
|
+
persistence?: boolean;
|
|
515
|
+
remoteEnabled?: boolean;
|
|
516
|
+
gitMutation?: boolean;
|
|
517
|
+
};
|
|
518
|
+
/** Additive policy trace for audit (observe-only). */
|
|
519
|
+
policyTrace?: {
|
|
520
|
+
effectivePolicyHash: string;
|
|
521
|
+
matchedRules: Array<{
|
|
522
|
+
id: string;
|
|
523
|
+
source: string;
|
|
524
|
+
effect: string;
|
|
525
|
+
reason: string;
|
|
526
|
+
}>;
|
|
527
|
+
finalRoute: string;
|
|
528
|
+
mode: string;
|
|
529
|
+
};
|
|
530
|
+
/** Additive snapshot of the ask decisions surfaced to the reviewer prompt
|
|
531
|
+
* (observe-only; capped to the most recent few). */
|
|
532
|
+
askDecisions?: Array<{
|
|
533
|
+
at: number;
|
|
534
|
+
question: string;
|
|
535
|
+
answer: string;
|
|
536
|
+
}>;
|
|
537
|
+
}
|
|
538
|
+
//#endregion
|
|
539
|
+
//#region src/modules/audit/services/audit.d.ts
|
|
540
|
+
export declare const DEFAULT_AUDIT_PATH = "~/.local/share/opencode/permission-reviewer-audit.jsonl";
|
|
541
|
+
type AuditLogger = (message: string, details?: unknown) => void;
|
|
542
|
+
export declare function createAuditWriter(config: ReviewerConfig, logger?: AuditLogger): ((record: ReviewAuditRecord) => Promise<void>) | undefined;
|
|
543
|
+
//#endregion
|
|
544
|
+
//#region src/modules/config/services/sources.d.ts
|
|
545
|
+
/** The host passing an options object does not attest who authored it. */
|
|
546
|
+
type InlineOptionsTrust = "trusted" | "project" | "unknown";
|
|
547
|
+
//#endregion
|
|
548
|
+
//#region src/modules/config/services/loader.d.ts
|
|
549
|
+
interface LoadOptions {
|
|
550
|
+
/** Off for a caller that shows `configWarnings` another way, such as the TUI
|
|
551
|
+
* from server statuses. */
|
|
552
|
+
printConfigWarnings?: boolean;
|
|
553
|
+
}
|
|
554
|
+
/** Load and merge config from global, project, and inline sources.
|
|
555
|
+
*
|
|
556
|
+
* Precedence (lowest to highest): builtin defaults → global → project → inline,
|
|
557
|
+
* with one deliberate exception: security-sensitive fields cross a trust
|
|
558
|
+
* boundary where the untrusted project layer can only TIGHTEN the trusted
|
|
559
|
+
* baseline (see mergeWithTrustBoundary), and that hardening survives even
|
|
560
|
+
* when inline set the same field.
|
|
561
|
+
*
|
|
562
|
+
* When no global or project files exist (the common case), the result is
|
|
563
|
+
* byte-identical to calling `resolveConfig(inlineOptions)` directly. */
|
|
564
|
+
export declare function loadResolvedConfig(inlineOptions: Record<string, unknown> | undefined, directory?: string, inlineTrust?: InlineOptionsTrust, { printConfigWarnings }?: LoadOptions): ReviewerConfig;
|
|
565
|
+
//#endregion
|
|
566
|
+
//#region src/kernel/permission-request.d.ts
|
|
567
|
+
interface PermissionToolSource {
|
|
568
|
+
messageID: string;
|
|
569
|
+
callID: string;
|
|
570
|
+
}
|
|
571
|
+
interface PermissionRequest {
|
|
572
|
+
id: string;
|
|
573
|
+
sessionID: string;
|
|
574
|
+
permission: string;
|
|
575
|
+
patterns: string[];
|
|
576
|
+
metadata: Record<string, unknown>;
|
|
577
|
+
always: string[];
|
|
578
|
+
tool?: PermissionToolSource;
|
|
579
|
+
}
|
|
580
|
+
//#endregion
|
|
581
|
+
//#region src/modules/evidence/ssh/verified-ssh-script.d.ts
|
|
582
|
+
interface VerifiedScriptEvidence {
|
|
583
|
+
sha256: string;
|
|
584
|
+
destination: string;
|
|
585
|
+
port?: number;
|
|
586
|
+
shell: "bash" | "sh";
|
|
587
|
+
bytes?: number;
|
|
588
|
+
status: "full" | "reused" | "unavailable";
|
|
589
|
+
text: string;
|
|
590
|
+
cacheKey?: string;
|
|
591
|
+
}
|
|
592
|
+
//#endregion
|
|
593
|
+
//#region src/modules/analysis/shell/shell-token.d.ts
|
|
594
|
+
/** A run of a token's value that shares one quoting. `opaque` marks text the
|
|
595
|
+
* lexer kept whole from a substitution (an unquoted backtick form): it is
|
|
596
|
+
* the substitution's command, not the outer command's, so no operator in it
|
|
597
|
+
* acts on the outer command. It stays unquoted otherwise: a glob character
|
|
598
|
+
* in it reads as it did before. */
|
|
599
|
+
interface TokenSpan {
|
|
600
|
+
text: string;
|
|
601
|
+
quoted: boolean;
|
|
602
|
+
opaque?: true;
|
|
603
|
+
}
|
|
604
|
+
interface ShellToken {
|
|
605
|
+
/** Original text including any surrounding quotes. */
|
|
606
|
+
raw: string;
|
|
607
|
+
/** Unquoted/normalized value used for comparisons. */
|
|
608
|
+
value: string;
|
|
609
|
+
/** Value split into spans by quoting: every character of `value` appears
|
|
610
|
+
* in exactly one span, marked `quoted` when it came from inside quotes
|
|
611
|
+
* or from a backslash escape. An operator character (`>`, `*`, …) only
|
|
612
|
+
* acts as an operator while it sits in an UNQUOTED span: a glued, partly
|
|
613
|
+
* quoted `>"/dev/sda"` still redirects, while `'>/dev/sda'` is data.
|
|
614
|
+
* A zero-width quoted span can end a word: it marks an empty quote right
|
|
615
|
+
* after text that ends like a redirection operator (`<<<''`), and holds no
|
|
616
|
+
* character of `value`. */
|
|
617
|
+
spans?: TokenSpan[];
|
|
618
|
+
}
|
|
619
|
+
interface ShellSegment {
|
|
620
|
+
tokens: ShellToken[];
|
|
621
|
+
/** Separator that terminated this segment (`;`, `|`, `||`, `&`, `&&`, `(`,
|
|
622
|
+
* `)`). Newlines and carriage returns are reported as `;`. Absent for the
|
|
623
|
+
* final segment when the command does not end with a separator. A segment
|
|
624
|
+
* with no tokens and `endedBy` `(` or `)` is a paren marker: it exists so
|
|
625
|
+
* grouping events are never lost, and carries no command of its own. */
|
|
626
|
+
endedBy?: string;
|
|
627
|
+
/** The last separator seen before this segment's first token, counting
|
|
628
|
+
* separators whose (empty) segment was dropped: in `( a ) | b`, segment
|
|
629
|
+
* `b` ended up after a dropped empty segment, so its separator lineage is
|
|
630
|
+
* `)` and then `|`, and `precededBy` reports `|`. Absent for the first
|
|
631
|
+
* segment. */
|
|
632
|
+
precededBy?: string;
|
|
633
|
+
}
|
|
634
|
+
//#endregion
|
|
635
|
+
//#region src/modules/analysis/walk/walk-sink.d.ts
|
|
636
|
+
/** A command the walk resolves, wrapper or not: its basename, the words of
|
|
637
|
+
* its level and its index among them, and whether it runs inside the
|
|
638
|
+
* remote command of an ssh, mosh or autossh. */
|
|
639
|
+
interface PeeledHead {
|
|
640
|
+
head: string;
|
|
641
|
+
tokens: readonly ShellToken[];
|
|
642
|
+
index: number;
|
|
643
|
+
remote: boolean;
|
|
644
|
+
}
|
|
645
|
+
//#endregion
|
|
646
|
+
//#region src/modules/analysis/capability/models/capability-types.d.ts
|
|
647
|
+
/** How completely the command could be statically analyzed. */
|
|
648
|
+
type ParserCompleteness =
|
|
649
|
+
/** Fully parsed: no variables, globs, substitutions, or heredoc bodies. */
|
|
650
|
+
"complete-for-supported-form" |
|
|
651
|
+
/** Some constructs could not be resolved (variables, partial heredoc). */
|
|
652
|
+
"partial" |
|
|
653
|
+
/** Heavy dynamic constructs (command substitution, eval, dynamic heredoc). */
|
|
654
|
+
"opaque";
|
|
655
|
+
/** A redirection extracted from a parsed command segment. */
|
|
656
|
+
interface Redirection {
|
|
657
|
+
/** `>` `>>` `<` `2>` `&>` etc. */
|
|
658
|
+
operator: string;
|
|
659
|
+
/** Target path (file descriptor targets normalized to a path when possible). */
|
|
660
|
+
target: string;
|
|
661
|
+
/** Whether the target was quoted in the source (affects literal-ness). */
|
|
662
|
+
quoted: boolean;
|
|
663
|
+
}
|
|
664
|
+
/** A heredoc extracted before lexing so its body never reaches the lexer/brake. */
|
|
665
|
+
interface HeredocRecord {
|
|
666
|
+
/** The literal delimiter token as it appeared (`EOF`, `END`, …). */
|
|
667
|
+
delimiter: string;
|
|
668
|
+
/** `<<` (expansion on) or `<<-` (tabs stripped) — normalized form. */
|
|
669
|
+
operator: string;
|
|
670
|
+
/** Whether the delimiter was quoted, disabling expansion (`<<'EOF'`). */
|
|
671
|
+
expansionDisabled: boolean;
|
|
672
|
+
/** Bounded + redacted body (truncated to a safe length). */
|
|
673
|
+
bodyBounded: string;
|
|
674
|
+
/** SHA-256 of the full, unredacted body (stable identity without leaking it). */
|
|
675
|
+
bodySha256: string;
|
|
676
|
+
/** Whether the body was truncated for storage. */
|
|
677
|
+
truncated: boolean;
|
|
678
|
+
/** Output path associated with the heredoc when a `> path` precedes it. */
|
|
679
|
+
outputTarget?: string;
|
|
680
|
+
/** Whether the body is dynamically constructed (unresolvable expansion). */
|
|
681
|
+
dynamic: boolean;
|
|
682
|
+
}
|
|
683
|
+
/** A command parsed into a reusable structure. Wraps the existing lexer output
|
|
684
|
+
* plus pre-extracted redirections and heredocs. */
|
|
685
|
+
interface ParsedCommand {
|
|
686
|
+
/** The command after heredoc bodies were replaced with placeholders. */
|
|
687
|
+
sanitizedCommand: string;
|
|
688
|
+
/** Lexed segments of the sanitized command. */
|
|
689
|
+
segments: ShellSegment[];
|
|
690
|
+
/** Effective commands (wrappers peeled) per segment. */
|
|
691
|
+
effective: ShellToken[][];
|
|
692
|
+
/** Redirections grouped by segment index. */
|
|
693
|
+
redirections: Redirection[][];
|
|
694
|
+
/** Heredocs extracted before lexing. */
|
|
695
|
+
heredocs: HeredocRecord[];
|
|
696
|
+
/** Whether the original command contained any dynamic constructs. */
|
|
697
|
+
hasDynamicConstructs: boolean;
|
|
698
|
+
/** True when the lexer's depth or expansion budget stopped command-string
|
|
699
|
+
* resolution early; `effective` is then a prefix of the real structure and
|
|
700
|
+
* deterministic facts do not cover the whole command. */
|
|
701
|
+
analysisTruncated: boolean;
|
|
702
|
+
/** The effective commands that run on the far side of an ssh with no
|
|
703
|
+
* remote command, from the script it reads. They are among `effective`
|
|
704
|
+
* too. */
|
|
705
|
+
remoteCommands?: ShellToken[][];
|
|
706
|
+
/** Every command the walk resolves, wrappers among them, at every level:
|
|
707
|
+
* command strings, `env -S`, `watch` and ssh remote commands. */
|
|
708
|
+
heads: readonly PeeledHead[];
|
|
709
|
+
/** The redirections each walked segment and command string carries
|
|
710
|
+
* itself, whether or not it yields an effective command: the shell
|
|
711
|
+
* opens them before it runs anything (`>f ssh h`). */
|
|
712
|
+
segmentRedirections: readonly (readonly Redirection[])[];
|
|
713
|
+
/** An interpreter among the commands runs code from a heredoc or
|
|
714
|
+
* here-string. */
|
|
715
|
+
stdinCode?: boolean;
|
|
716
|
+
}
|
|
717
|
+
/** What the action can do, what it appears to do, and analysis confidence. */
|
|
718
|
+
interface CapabilityAssessment {
|
|
719
|
+
/** Best single-label summary of the dominant capability. */
|
|
720
|
+
actionClass: Provenanced<CapabilityActionClass>;
|
|
721
|
+
/** Human-readable summary of the detected surface. */
|
|
722
|
+
summary: string;
|
|
723
|
+
/** Executes an interpreter or runtime (sh, python, node, bun, …). */
|
|
724
|
+
executesCode: Provenanced<boolean | "unknown">;
|
|
725
|
+
/** Executes code that lives in the repository (scripts, test files). */
|
|
726
|
+
executesRepositoryCode: Provenanced<boolean | "unknown">;
|
|
727
|
+
/** Executes ad-hoc code generated by the agent (heredoc/inline). */
|
|
728
|
+
createsAdHocCode: Provenanced<boolean | "unknown">;
|
|
729
|
+
/** Invokes a known test runner (pytest, jest, bun test, …). */
|
|
730
|
+
invokesExistingTestRunner: Provenanced<boolean | "unknown">;
|
|
731
|
+
/** Runs a package manager that may execute lifecycle scripts. */
|
|
732
|
+
invokesPackageLifecycleScripts: Provenanced<boolean | "unknown">;
|
|
733
|
+
/** Reads literal credential material through a known file reader. */
|
|
734
|
+
credentialRead: Provenanced<boolean | "unknown">;
|
|
735
|
+
/** Detected file-write surface. */
|
|
736
|
+
writeEffects: {
|
|
737
|
+
temporaryWrite: Provenanced<boolean | "unknown">;
|
|
738
|
+
workspaceWrite: Provenanced<boolean | "unknown">;
|
|
739
|
+
externalWrite: Provenanced<boolean | "unknown">;
|
|
740
|
+
deletion: Provenanced<boolean | "unknown">;
|
|
741
|
+
};
|
|
742
|
+
/** Detected network surface. */
|
|
743
|
+
network: {
|
|
744
|
+
observed: Provenanced<boolean | "unknown">;
|
|
745
|
+
possible: Provenanced<boolean | "unknown">;
|
|
746
|
+
/** Hosts/destinations observed literally in the command. */
|
|
747
|
+
destinations: string[];
|
|
748
|
+
observedAccess: Provenanced<boolean | "unknown">;
|
|
749
|
+
possibleAccess: Provenanced<boolean | "unknown">;
|
|
750
|
+
};
|
|
751
|
+
/** Detected process side-effects. */
|
|
752
|
+
process: {
|
|
753
|
+
childProcesses: Provenanced<boolean | "unknown">;
|
|
754
|
+
persistence: Provenanced<boolean | "unknown">;
|
|
755
|
+
privilegeEscalation: Provenanced<boolean | "unknown">;
|
|
756
|
+
};
|
|
757
|
+
/** Detected remote-operation surface (ssh, etc.). */
|
|
758
|
+
remote: {
|
|
759
|
+
enabled: Provenanced<boolean | "unknown">;
|
|
760
|
+
mutationHint: Provenanced<boolean | "unknown">;
|
|
761
|
+
};
|
|
762
|
+
/** Detected git mutation surface. */
|
|
763
|
+
git: {
|
|
764
|
+
observed: Provenanced<boolean | "unknown">;
|
|
765
|
+
possible: Provenanced<boolean | "unknown">;
|
|
766
|
+
observedAccess: Provenanced<boolean | "unknown">;
|
|
767
|
+
possibleAccess: Provenanced<boolean | "unknown">;
|
|
768
|
+
};
|
|
769
|
+
/** How completely the command could be analyzed. */
|
|
770
|
+
parserCompleteness: ParserCompleteness;
|
|
771
|
+
/** Free-form warnings about analysis limitations. */
|
|
772
|
+
analysisWarnings: string[];
|
|
773
|
+
}
|
|
774
|
+
//#endregion
|
|
775
|
+
//#region src/modules/evidence/ssh/ssh-evidence.d.ts
|
|
776
|
+
interface SshAuditSummary {
|
|
777
|
+
destination: string;
|
|
778
|
+
port?: string;
|
|
779
|
+
remoteCommandSha256?: string;
|
|
780
|
+
stdinSource?: string;
|
|
781
|
+
stdinStatus?: string;
|
|
782
|
+
stdinReason?: string;
|
|
783
|
+
}
|
|
784
|
+
interface SshEnrichmentResult {
|
|
785
|
+
text: string;
|
|
786
|
+
audit: SshAuditSummary[];
|
|
787
|
+
preflightDenial?: string;
|
|
788
|
+
}
|
|
789
|
+
export declare function enrichSshEvidence(request: PermissionRequest, directory: string, worktree: string, maxChars: number): Promise<SshEnrichmentResult>;
|
|
790
|
+
//#endregion
|
|
791
|
+
//#region src/modules/context/models/review-envelope.d.ts
|
|
792
|
+
interface ReviewEnvelope {
|
|
793
|
+
request: PermissionRequest;
|
|
794
|
+
directory: string;
|
|
795
|
+
worktree: string;
|
|
796
|
+
transcript: string;
|
|
797
|
+
intentHistory: string;
|
|
798
|
+
enrichment: string;
|
|
799
|
+
verifiedScript?: VerifiedScriptEvidence;
|
|
800
|
+
sshAudit: SshAuditSummary[];
|
|
801
|
+
preflightDenial?: string;
|
|
802
|
+
/** Agent-aware context (actor, lineage, intent). Observe-only: flows into the
|
|
803
|
+
* reviewer prompt and audit as evidence, never into enforcement decisions.
|
|
804
|
+
* Optional so older callers/tests still compile. */
|
|
805
|
+
actor?: ActorContext;
|
|
806
|
+
lineage?: SessionLineage;
|
|
807
|
+
intent?: IntentContext;
|
|
808
|
+
evidenceCompleteness?: EvidenceCompleteness;
|
|
809
|
+
/** Structured capability facts derived from the bash command. Observe-only:
|
|
810
|
+
* feeds the reviewer prompt and audit, never enforcement. */
|
|
811
|
+
capability?: CapabilityAssessment;
|
|
812
|
+
/** The policy trace produced for this request, surfaced to the reviewer prompt
|
|
813
|
+
* as EFFECTIVE_POLICY_SUMMARY and to audit. Observe-only. */
|
|
814
|
+
policyTrace?: PolicyTrace;
|
|
815
|
+
/** Per-phase timing captured during evidence assembly (context/enrichment).
|
|
816
|
+
* The reviewer and reply phases are timed in the coordinator. */
|
|
817
|
+
timings?: {
|
|
818
|
+
contextMs?: number;
|
|
819
|
+
enrichmentMs?: number;
|
|
820
|
+
reviewerMs?: number;
|
|
821
|
+
replyMs?: number;
|
|
822
|
+
};
|
|
823
|
+
/** False when a material part of the action under review (e.g. an elided
|
|
824
|
+
* command segment) never reached the rendered evidence. Blocking: the
|
|
825
|
+
* coordinator must not auto-approve an action the reviewer could not see
|
|
826
|
+
* in full, whatever confidence the model reports. */
|
|
827
|
+
actionEvidenceComplete?: boolean;
|
|
828
|
+
/** The parsed command reused across evidence providers. */
|
|
829
|
+
parsedCommand?: ParsedCommand;
|
|
830
|
+
/** Operational purpose of the pending action (evidence, never authorization). */
|
|
831
|
+
actionPurpose?: ActionPurpose;
|
|
832
|
+
/** User answers to agent ask dialogs in this session or its ancestors,
|
|
833
|
+
* captured live from question events. Observe-only: flows into the reviewer
|
|
834
|
+
* prompt (USER_ASK_DECISIONS) and audit, never into enforcement. */
|
|
835
|
+
askDecisions?: AskDecision[];
|
|
796
836
|
}
|
|
797
837
|
//#endregion
|
|
798
|
-
//#region src/
|
|
799
|
-
|
|
800
|
-
type
|
|
801
|
-
export declare function createAuditWriter(config: ReviewerConfig, logger?: AuditLogger): ((record: ReviewAuditRecord) => Promise<void>) | undefined;
|
|
838
|
+
//#region src/modules/review/models/contracts.d.ts
|
|
839
|
+
/** Receiving an approval does not prove that a tool executed. */
|
|
840
|
+
type ApplicationResult = "evaluation-returned" | "reply-accepted" | "human-pending" | "superseded" | "cancelled" | "unknown";
|
|
802
841
|
//#endregion
|
|
803
|
-
//#region src/
|
|
804
|
-
/**
|
|
805
|
-
|
|
842
|
+
//#region src/kernel/review-attempt.d.ts
|
|
843
|
+
/** What the reviewer needs from a review attempt: its cancellation, its
|
|
844
|
+
* remaining budget, and a wait that rejects once it is no longer active. */
|
|
845
|
+
interface ReviewAttemptView {
|
|
846
|
+
readonly signal: AbortSignal;
|
|
847
|
+
remainingMs(): number;
|
|
848
|
+
active(): boolean;
|
|
849
|
+
wait<T>(operation: Promise<T>): Promise<T>;
|
|
850
|
+
}
|
|
806
851
|
//#endregion
|
|
807
|
-
//#region src/
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
852
|
+
//#region src/modules/review/services/review-attempt.d.ts
|
|
853
|
+
type AttemptState = "reviewing" | "finished" | "cancelled" | "expired";
|
|
854
|
+
/** One invocation owns its deadline, identity, and terminal transition. */
|
|
855
|
+
declare class ReviewAttempt implements ReviewAttemptView {
|
|
856
|
+
readonly generation: string;
|
|
857
|
+
private readonly now;
|
|
858
|
+
application: ApplicationResult;
|
|
859
|
+
readonly evidence: Partial<Pick<ReviewEnvelope, "sshAudit" | "actor" | "capability" | "policyTrace" | "askDecisions" | "evidenceCompleteness" | "verifiedScript">> & {
|
|
860
|
+
timings?: {
|
|
861
|
+
contextMs?: number;
|
|
862
|
+
enrichmentMs?: number;
|
|
863
|
+
reviewerMs?: number;
|
|
864
|
+
replyMs?: number;
|
|
865
|
+
};
|
|
866
|
+
};
|
|
867
|
+
readonly id: string;
|
|
868
|
+
readonly controller: AbortController;
|
|
869
|
+
readonly startedAt: number;
|
|
870
|
+
readonly deadline: number;
|
|
871
|
+
private stateValue;
|
|
872
|
+
private terminalReason;
|
|
873
|
+
private readonly timer;
|
|
874
|
+
constructor(generation: string, budgetMs: number, now?: () => number, newID?: () => string);
|
|
875
|
+
get state(): AttemptState;
|
|
876
|
+
get signal(): AbortSignal;
|
|
877
|
+
remainingMs(): number;
|
|
878
|
+
active(generation?: string): boolean;
|
|
879
|
+
close(state: Exclude<AttemptState, "reviewing">): boolean;
|
|
880
|
+
/** Abort the wait even if a host operation cannot cancel its transport. */
|
|
881
|
+
wait<T>(operation: Promise<T>): Promise<T>;
|
|
812
882
|
}
|
|
813
|
-
/** Load and merge config from global, project, and inline sources.
|
|
814
|
-
*
|
|
815
|
-
* Precedence (lowest to highest): builtin defaults → global → project → inline,
|
|
816
|
-
* with one deliberate exception: security-sensitive fields cross a trust
|
|
817
|
-
* boundary where the untrusted project layer can only TIGHTEN the trusted
|
|
818
|
-
* baseline (see mergeWithTrustBoundary), and that hardening survives even
|
|
819
|
-
* when inline set the same field.
|
|
820
|
-
*
|
|
821
|
-
* When no global or project files exist (the common case), the result is
|
|
822
|
-
* byte-identical to calling `resolveConfig(inlineOptions)` directly. */
|
|
823
|
-
export declare function loadResolvedConfig(inlineOptions: Record<string, unknown> | undefined, directory?: string, inlineTrust?: InlineOptionsTrust, { printConfigWarnings }?: LoadOptions): ReviewerConfig;
|
|
824
883
|
//#endregion
|
|
825
|
-
//#region src/
|
|
884
|
+
//#region src/kernel/review-handoff.d.ts
|
|
826
885
|
/** Jev's hand-off to the reasoning reviewer, on the second "reviewing" status
|
|
827
886
|
* and on the result of a handed-off review. */
|
|
828
887
|
interface HandoffInfo {
|
|
@@ -832,8 +891,11 @@ interface HandoffInfo {
|
|
|
832
891
|
/** Jev's failure ("timeout"), only when `trigger` is `jev-failure`. */
|
|
833
892
|
failureKind?: string;
|
|
834
893
|
}
|
|
894
|
+
/** Called at most once per review, right before the reasoning reviewer is
|
|
895
|
+
* invoked; never on the budget-floor or inactive-attempt paths. */
|
|
896
|
+
type OnHandoff = (handoff: HandoffInfo) => void;
|
|
835
897
|
//#endregion
|
|
836
|
-
//#region src/ui-status-extras.d.ts
|
|
898
|
+
//#region src/modules/status/services/ui-status-extras.d.ts
|
|
837
899
|
interface StatusExtrasOptions {
|
|
838
900
|
handoff?: HandoffInfo;
|
|
839
901
|
resolution?: ManualResolution;
|
|
@@ -842,10 +904,10 @@ interface StatusExtrasOptions {
|
|
|
842
904
|
configDegraded?: readonly string[];
|
|
843
905
|
}
|
|
844
906
|
//#endregion
|
|
845
|
-
//#region src/ui-protocol.d.ts
|
|
907
|
+
//#region src/modules/status/models/ui-protocol.d.ts
|
|
846
908
|
type ReviewUiPhase = "reviewing" | "approved" | "denied" | "manual" | "unknown";
|
|
847
909
|
/** 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`. */
|
|
910
|
+
* to its width. Built by `src/modules/status/services/ui-action-segments.ts`. */
|
|
849
911
|
interface ActionSegment {
|
|
850
912
|
/** The segment as typed in the command, heredoc bodies left out,
|
|
851
913
|
* whitespace collapsed, at most 200 code points. */
|
|
@@ -912,7 +974,7 @@ export declare function createUiStatus(request: PermissionRequest, phase: Review
|
|
|
912
974
|
export declare function encodeUiStatus(status: ReviewUiStatus): string;
|
|
913
975
|
export declare function decodeUiStatus(command: string): ReviewUiStatus | undefined;
|
|
914
976
|
//#endregion
|
|
915
|
-
//#region src/context/ask-decisions.d.ts
|
|
977
|
+
//#region src/modules/context/services/ask-decisions.d.ts
|
|
916
978
|
/**
|
|
917
979
|
* Captures user answers to agent ask dialogs (the `question` tool) from the
|
|
918
980
|
* OpenCode event stream and exposes them as compact, session-scoped
|
|
@@ -973,32 +1035,23 @@ export declare class AskDecisionRegistry implements AskDecisionSource {
|
|
|
973
1035
|
private store;
|
|
974
1036
|
}
|
|
975
1037
|
//#endregion
|
|
976
|
-
//#region src/opencode/v2/server-state.d.ts
|
|
1038
|
+
//#region src/adapters/opencode/v2/server-state.d.ts
|
|
977
1039
|
type Context = Parameters<Plugin$1.Plugin["setup"]>[0];
|
|
978
1040
|
//#endregion
|
|
979
|
-
//#region src/opencode/v2/server.d.ts
|
|
1041
|
+
//#region src/adapters/opencode/v2/server.d.ts
|
|
980
1042
|
declare function setup(ctx: Context): Promise<() => Promise<void>>;
|
|
981
1043
|
//#endregion
|
|
982
|
-
//#region src/
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
stdinStatus?: string;
|
|
992
|
-
stdinReason?: string;
|
|
993
|
-
}
|
|
994
|
-
interface SshEnrichmentResult {
|
|
995
|
-
text: string;
|
|
996
|
-
audit: SshAuditSummary[];
|
|
997
|
-
preflightDenial?: string;
|
|
998
|
-
}
|
|
999
|
-
export declare function enrichSshEvidence(request: PermissionRequest, directory: string, worktree: string, maxChars: number): Promise<SshEnrichmentResult>;
|
|
1044
|
+
//#region src/adapters/opencode/event-normalizer.d.ts
|
|
1045
|
+
/**
|
|
1046
|
+
* Normalize a raw OpenCode event into a {@link PermissionRequest}.
|
|
1047
|
+
*
|
|
1048
|
+
* Returns `undefined` for anything that is not a well-formed
|
|
1049
|
+
* `permission.asked` event, so callers can ignore irrelevant events without
|
|
1050
|
+
* inspecting their shape.
|
|
1051
|
+
*/
|
|
1052
|
+
export declare function extractPermissionRequest(event: unknown): PermissionRequest | undefined;
|
|
1000
1053
|
//#endregion
|
|
1001
|
-
//#region src/evidence/provider.d.ts
|
|
1054
|
+
//#region src/modules/evidence/providers/provider.d.ts
|
|
1002
1055
|
/**
|
|
1003
1056
|
* A single piece of evidence gathered about a permission request. The runtime
|
|
1004
1057
|
* only consumes `text`, `audit`, and `preflightDenial` today; the remaining
|
|
@@ -1031,7 +1084,78 @@ interface EvidenceProvider {
|
|
|
1031
1084
|
collect(input: EvidenceProviderInput): Promise<EvidenceFragment>;
|
|
1032
1085
|
}
|
|
1033
1086
|
//#endregion
|
|
1034
|
-
//#region src/
|
|
1087
|
+
//#region src/modules/context/ports.d.ts
|
|
1088
|
+
/** Host-independent reads used to recover actor identity and intent. */
|
|
1089
|
+
interface ContextReader {
|
|
1090
|
+
messages(sessionID: string, directory: string, limit: number): Promise<unknown>;
|
|
1091
|
+
/** Literal user messages recovered independently of the operational window. */
|
|
1092
|
+
intentMessages?(sessionID: string, directory: string, limit: number): Promise<unknown>;
|
|
1093
|
+
session(sessionID: string, directory: string): Promise<unknown>;
|
|
1094
|
+
}
|
|
1095
|
+
//#endregion
|
|
1096
|
+
//#region src/modules/review/ports.d.ts
|
|
1097
|
+
/** A host call's outcome: failures arrive as `error`, not as a rejection. */
|
|
1098
|
+
interface HostResponse {
|
|
1099
|
+
error?: unknown;
|
|
1100
|
+
}
|
|
1101
|
+
/** The host members a review reads and calls. The coordinator keeps the
|
|
1102
|
+
* object it is given, so later changes to these members are seen. */
|
|
1103
|
+
interface ReviewHostContext {
|
|
1104
|
+
hostVersion?: string;
|
|
1105
|
+
directory: string;
|
|
1106
|
+
worktree: string;
|
|
1107
|
+
permissionReply(options: unknown): Promise<HostResponse>;
|
|
1108
|
+
publishUiStatus?(status: ReviewUiStatus): Promise<HostResponse>;
|
|
1109
|
+
writeAudit?(record: ReviewAuditRecord): Promise<void>;
|
|
1110
|
+
}
|
|
1111
|
+
interface ReviewerBackend {
|
|
1112
|
+
owns(sessionID: string): boolean;
|
|
1113
|
+
review(envelope: ReviewEnvelope, attempt: ReviewAttempt, onHandoff?: OnHandoff): Promise<ReviewExecutionResult>;
|
|
1114
|
+
waitForIdle(): Promise<void>;
|
|
1115
|
+
}
|
|
1116
|
+
/** What the review coordinator needs from the host. */
|
|
1117
|
+
interface ReviewHost {
|
|
1118
|
+
readonly context: ReviewHostContext;
|
|
1119
|
+
createReviewerBackend(config: ReviewerConfig, log: (message: string, details?: unknown) => void, recordReviewerMs: (envelope: ReviewEnvelope, ms: number) => void): ReviewerBackend;
|
|
1120
|
+
createContextReader(signal?: AbortSignal): ContextReader;
|
|
1121
|
+
/** Whether a reply error means another source already resolved the request. */
|
|
1122
|
+
isAlreadyResolvedError(error: unknown): boolean;
|
|
1123
|
+
}
|
|
1124
|
+
//#endregion
|
|
1125
|
+
//#region src/modules/review/services/coordinator-state.d.ts
|
|
1126
|
+
type Logger = (message: string, details?: unknown) => void;
|
|
1127
|
+
//#endregion
|
|
1128
|
+
//#region src/modules/review/services/review-coordinator.d.ts
|
|
1129
|
+
/**
|
|
1130
|
+
* Owns the review lifecycle for permission requests: orchestration, the
|
|
1131
|
+
* supersede state machine, and the model call. The adapter (transport) and the
|
|
1132
|
+
* evidence providers are injected so this class stays focused on ordering and
|
|
1133
|
+
* races.
|
|
1134
|
+
*/
|
|
1135
|
+
declare class ReviewCoordinator {
|
|
1136
|
+
private readonly state;
|
|
1137
|
+
private readonly limiter;
|
|
1138
|
+
private readonly pending;
|
|
1139
|
+
constructor(host: ReviewHost, config: ReviewerConfig, logger?: Logger, providers?: EvidenceProvider[], askDecisions?: AskDecisionSource);
|
|
1140
|
+
pendingCount(): number;
|
|
1141
|
+
waitForIdle(): Promise<void>;
|
|
1142
|
+
dispose(): Promise<void>;
|
|
1143
|
+
handle(request: PermissionRequest): void;
|
|
1144
|
+
process(request: PermissionRequest): Promise<ReviewExecutionResult>;
|
|
1145
|
+
handlePermissionReply(event: unknown): void;
|
|
1146
|
+
/**
|
|
1147
|
+
* @deprecated No-op. Approvals no longer annotate tool results so they do not
|
|
1148
|
+
* contaminate the primary agent context. Kept for public API compatibility;
|
|
1149
|
+
* the plugin no longer registers a host hook that calls this. Rationale
|
|
1150
|
+
* remains in audit, TUI, and debug.
|
|
1151
|
+
*/
|
|
1152
|
+
annotateToolResult(callID: string, output: {
|
|
1153
|
+
output?: unknown;
|
|
1154
|
+
metadata?: unknown;
|
|
1155
|
+
}): void;
|
|
1156
|
+
}
|
|
1157
|
+
//#endregion
|
|
1158
|
+
//#region src/adapters/opencode/adapter.d.ts
|
|
1035
1159
|
/** What the plugin learned about the host client at startup. */
|
|
1036
1160
|
interface OpenCodeCapabilities {
|
|
1037
1161
|
/** A public SDK method to answer a permission request exists. */
|
|
@@ -1054,7 +1178,7 @@ interface OpenCodeCapabilities {
|
|
|
1054
1178
|
tuiPublish: boolean;
|
|
1055
1179
|
}
|
|
1056
1180
|
//#endregion
|
|
1057
|
-
//#region src/opencode/types.d.ts
|
|
1181
|
+
//#region src/adapters/opencode/types.d.ts
|
|
1058
1182
|
interface ClientResponse<T> {
|
|
1059
1183
|
data?: T;
|
|
1060
1184
|
error?: unknown;
|
|
@@ -1099,46 +1223,35 @@ interface RuntimeContext {
|
|
|
1099
1223
|
reviewerDirectoryBase?: string;
|
|
1100
1224
|
}
|
|
1101
1225
|
//#endregion
|
|
1102
|
-
//#region src/
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
//#region src/core/review-coordinator.d.ts
|
|
1106
|
-
/**
|
|
1107
|
-
* Owns the review lifecycle for permission requests: orchestration, the
|
|
1108
|
-
* supersede state machine, and the model call. The adapter (transport) and the
|
|
1109
|
-
* evidence providers are injected so this class stays focused on ordering and
|
|
1110
|
-
* races.
|
|
1111
|
-
*/
|
|
1112
|
-
declare class ReviewCoordinator {
|
|
1113
|
-
private readonly state;
|
|
1114
|
-
private readonly limiter;
|
|
1115
|
-
private readonly pending;
|
|
1226
|
+
//#region src/adapters/opencode/v1/review-host.d.ts
|
|
1227
|
+
/** The review coordinator on a V1 host, built from the host's runtime context. */
|
|
1228
|
+
declare class V1ReviewCoordinator extends ReviewCoordinator {
|
|
1116
1229
|
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;
|
|
1133
1230
|
}
|
|
1134
1231
|
//#endregion
|
|
1135
|
-
//#region src/
|
|
1232
|
+
//#region src/modules/analysis/brake/emergency-brake.d.ts
|
|
1233
|
+
export declare function emergencyBrakeReason(request: PermissionRequest): string | undefined;
|
|
1234
|
+
//#endregion
|
|
1235
|
+
//#region src/modules/config/services/config.d.ts
|
|
1236
|
+
export declare function resolveConfig(options: Record<string, unknown> | undefined): ReviewerConfig;
|
|
1237
|
+
//#endregion
|
|
1238
|
+
//#region src/modules/context/models/message.d.ts
|
|
1239
|
+
interface MessageWithParts {
|
|
1240
|
+
info: Record<string, unknown> & {
|
|
1241
|
+
id?: string;
|
|
1242
|
+
role?: string;
|
|
1243
|
+
structured?: unknown;
|
|
1244
|
+
};
|
|
1245
|
+
parts: Array<Record<string, unknown>>;
|
|
1246
|
+
}
|
|
1247
|
+
//#endregion
|
|
1248
|
+
//#region src/modules/decision/decision.d.ts
|
|
1136
1249
|
export declare function parseDecision(value: unknown): ReviewDecision | undefined;
|
|
1137
1250
|
//#endregion
|
|
1138
|
-
//#region src/decision-gates.d.ts
|
|
1251
|
+
//#region src/modules/decision/decision-gates.d.ts
|
|
1139
1252
|
export declare function enforceDecision(decision: ReviewDecision, config: ReviewerConfig): ReviewExecutionResult;
|
|
1140
1253
|
//#endregion
|
|
1141
|
-
//#region src/decision-schema.d.ts
|
|
1254
|
+
//#region src/modules/decision/decision-schema.d.ts
|
|
1142
1255
|
export declare const DECISION_SCHEMA: {
|
|
1143
1256
|
readonly type: "object";
|
|
1144
1257
|
readonly additionalProperties: false;
|
|
@@ -1192,10 +1305,7 @@ export declare const DECISION_SCHEMA: {
|
|
|
1192
1305
|
};
|
|
1193
1306
|
};
|
|
1194
1307
|
//#endregion
|
|
1195
|
-
//#region src/
|
|
1196
|
-
export declare function emergencyBrakeReason(request: PermissionRequest): string | undefined;
|
|
1197
|
-
//#endregion
|
|
1198
|
-
//#region src/escalation.d.ts
|
|
1308
|
+
//#region src/modules/decision/escalation.d.ts
|
|
1199
1309
|
/**
|
|
1200
1310
|
* Categories that can be hardened independently of the global escalation mode
|
|
1201
1311
|
* via `riskPolicy.onInvalidDecision` / `riskPolicy.onReviewerFailure`.
|
|
@@ -1228,13 +1338,13 @@ export declare function resolveEscalationDisposition(result: ReviewExecutionResu
|
|
|
1228
1338
|
*/
|
|
1229
1339
|
export declare function applyEscalationDisposition(result: ReviewExecutionResult, config: ReviewerConfig, category?: EscalationCategory): ReviewExecutionResult;
|
|
1230
1340
|
//#endregion
|
|
1231
|
-
//#region src/git-evidence.d.ts
|
|
1341
|
+
//#region src/modules/evidence/git/git-evidence.d.ts
|
|
1232
1342
|
interface GitEnrichmentResult {
|
|
1233
1343
|
text: string;
|
|
1234
1344
|
}
|
|
1235
1345
|
export declare function enrichGitEvidence(request: PermissionRequest, directory: string, maxChars: number, worktree?: string): Promise<GitEnrichmentResult>;
|
|
1236
1346
|
//#endregion
|
|
1237
|
-
//#region src/local-script-evidence.d.ts
|
|
1347
|
+
//#region src/modules/evidence/local-script/local-script-evidence.d.ts
|
|
1238
1348
|
interface LocalScriptEnrichmentResult {
|
|
1239
1349
|
text: string;
|
|
1240
1350
|
}
|
|
@@ -1242,20 +1352,7 @@ interface LocalScriptEnrichmentResult {
|
|
|
1242
1352
|
* `directory` (package-script expansion passes the session directory). */
|
|
1243
1353
|
export declare function enrichLocalScriptEvidence(request: PermissionRequest, directory: string, worktree: string, maxChars: number, rootDirectory?: string): Promise<LocalScriptEnrichmentResult>;
|
|
1244
1354
|
//#endregion
|
|
1245
|
-
//#region src/
|
|
1246
|
-
/**
|
|
1247
|
-
* Normalize a raw OpenCode event into a {@link PermissionRequest}.
|
|
1248
|
-
*
|
|
1249
|
-
* Returns `undefined` for anything that is not a well-formed
|
|
1250
|
-
* `permission.asked` event, so callers can ignore irrelevant events without
|
|
1251
|
-
* inspecting their shape.
|
|
1252
|
-
*/
|
|
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
|
|
1355
|
+
//#region src/modules/status/services/ui-state.d.ts
|
|
1259
1356
|
interface UiStateOptions {
|
|
1260
1357
|
model: string;
|
|
1261
1358
|
variant: string;
|
|
@@ -1277,6 +1374,9 @@ export declare class ReviewUiState {
|
|
|
1277
1374
|
dismissResults(now?: number): string[];
|
|
1278
1375
|
}
|
|
1279
1376
|
//#endregion
|
|
1377
|
+
//#region src/utils/redact.d.ts
|
|
1378
|
+
export declare function redactSecrets(input: string): string;
|
|
1379
|
+
//#endregion
|
|
1280
1380
|
//#region src/index.d.ts
|
|
1281
1381
|
export declare const server: Plugin;
|
|
1282
1382
|
declare const module: {
|
|
@@ -1285,4 +1385,4 @@ declare const module: {
|
|
|
1285
1385
|
setup: typeof setup;
|
|
1286
1386
|
};
|
|
1287
1387
|
//#endregion
|
|
1288
|
-
export { type ActionPurpose, type ActorContext, type ActorProfile,
|
|
1388
|
+
export { type ActionPurpose, type ActorContext, type ActorProfile, V1ReviewCoordinator 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 };
|