@noppu-labs/opencode-permission-reviewer 3.2.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/NOTICE +2 -2
  3. package/dist/explain.js +2723 -2723
  4. package/dist/index.d.ts +638 -538
  5. package/dist/index.js +9745 -9730
  6. package/dist/rpc.d.ts +1 -1
  7. package/dist/rpc.js +1 -1
  8. package/dist/tui/{opencode → adapters/opencode}/event-normalizer.ts +2 -2
  9. package/dist/tui/{config-fields.ts → modules/config/models/config-fields.ts} +2 -2
  10. package/dist/tui/{config-knobs.ts → modules/config/models/config-knobs.ts} +1 -1
  11. package/dist/tui/{config-policy-rules.ts → modules/config/models/config-policy-rules.ts} +2 -2
  12. package/dist/tui/{config-risk-policy.ts → modules/config/models/config-risk-policy.ts} +2 -1
  13. package/dist/tui/{config.ts → modules/config/services/config.ts} +5 -5
  14. package/dist/tui/{config → modules/config/services}/layer-read.ts +4 -3
  15. package/dist/tui/{config → modules/config/services}/loader.ts +3 -3
  16. package/dist/tui/{reviewer-model.ts → modules/config/services/reviewer-model.ts} +6 -3
  17. package/dist/tui/{config → modules/config/services}/risk-policy-clamp.ts +2 -2
  18. package/dist/tui/{system-one-routing.ts → modules/config/services/system-one-routing.ts} +1 -1
  19. package/dist/tui/{config → modules/config/services}/trust-boundary.ts +4 -4
  20. package/dist/tui/{config → modules/config/services}/trusted-degradation.ts +2 -2
  21. package/dist/tui/{config-rule-condition.ts → modules/policy/config-rule-condition.ts} +1 -1
  22. package/dist/tui/{ui-protocol.ts → modules/status/models/ui-protocol.ts} +9 -9
  23. package/dist/tui/{ui-state.ts → modules/status/services/ui-state.ts} +2 -2
  24. package/dist/tui/{ui-status-extras.ts → modules/status/services/ui-status-extras.ts} +4 -2
  25. package/dist/tui/{ui-status-parse.ts → modules/status/services/ui-status-parse.ts} +5 -5
  26. package/dist/tui/tui.tsx +5 -5
  27. package/dist/tui/ui/action-fit.ts +10 -2
  28. package/dist/tui/ui/attribution.ts +4 -3
  29. package/dist/tui/ui/components.tsx +1 -1
  30. package/dist/tui/ui/config-notices.ts +1 -1
  31. package/dist/tui/ui/fit-parts.ts +1 -1
  32. package/dist/tui/ui/manual-toast.ts +3 -3
  33. package/dist/tui/ui/review-feed.ts +3 -3
  34. package/dist/tui/ui/review-overlay.tsx +1 -1
  35. package/dist/tui/ui/review-result.tsx +1 -1
  36. package/dist/tui/ui/review-store.ts +3 -3
  37. package/dist/tui/ui/review-theme.ts +1 -1
  38. package/dist/tui/ui/v1-host.ts +5 -2
  39. package/dist/tui/ui/v2.tsx +1 -1
  40. package/package.json +3 -3
  41. package/dist/tui/types.ts +0 -357
  42. /package/dist/tui/{config → modules/config/services}/jsonc.ts +0 -0
  43. /package/dist/tui/{config → modules/config/services}/trust-boundary-keys.ts +0 -0
  44. /package/dist/tui/{failure-kind.ts → modules/status/models/failure-kind.ts} +0 -0
  45. /package/dist/tui/{ui → modules/status/models}/rpc.ts +0 -0
  46. /package/dist/tui/{ui-text-elide.ts → modules/status/services/ui-text-elide.ts} +0 -0
  47. /package/dist/tui/{descriptor-io.ts → utils/descriptor-io.ts} +0 -0
  48. /package/dist/tui/{is-record.ts → utils/is-record.ts} +0 -0
package/dist/tui/types.ts DELETED
@@ -1,357 +0,0 @@
1
- import type {
2
- ActionPurpose,
3
- ActorContext,
4
- AskDecision,
5
- EvidenceCompleteness,
6
- IntentContext,
7
- SessionLineage,
8
- } from "./actor-context-types.ts";
9
- import type { DecisionSource, ReviewAuditRecord } from "./audit-record.ts";
10
- import type {
11
- CapabilityAssessment,
12
- ParsedCommand,
13
- } from "./capability/capability-types.ts";
14
- import type { SystemOneScores } from "./system-one/system-one-types.ts";
15
-
16
- export type RiskLevel = "low" | "medium" | "high" | "critical";
17
- export type UserAuthorization = "high" | "medium" | "low" | "unknown";
18
- export type ReviewOutcome = "allow" | "deny" | "escalate";
19
- export type ScopeAlignment = "aligned" | "partial" | "misaligned" | "unknown";
20
- export type EvidenceSufficiency =
21
- | "sufficient"
22
- | "partial"
23
- | "insufficient"
24
- | "unknown";
25
- /** How final escalations are disposed after reviewer/policy/fail-safe produce them. */
26
- export type EscalationMode = "manual" | "deny";
27
- /** Effective disposition applied to an internal escalate result. */
28
- export type EscalationDisposition = "manual" | "deny";
29
- /** Where an escalation that starts at Jev goes; `reasoning-first` sends every one to the escalation reviewer. */
30
- export type SystemOneEscalationMode = "standard" | "reasoning-first";
31
-
32
- export interface ReviewDecision {
33
- /** Structured-decision schema version. Always 2 for the current schema. */
34
- version: 2;
35
- outcome: ReviewOutcome;
36
- risk_level: RiskLevel;
37
- user_authorization: UserAuthorization;
38
- /** How well the request aligns with the recovered user/delegated intent. */
39
- scope_alignment: ScopeAlignment;
40
- /** Whether the evidence was sufficient to decide confidently. */
41
- evidence_completeness: EvidenceSufficiency;
42
- rationale: string;
43
- confidence: number;
44
- /** Optional script-only semantic analysis. Never conveys authorization. */
45
- script_analysis?: string;
46
- }
47
-
48
- export interface PermissionToolSource {
49
- messageID: string;
50
- callID: string;
51
- }
52
-
53
- export interface PermissionRequest {
54
- id: string;
55
- sessionID: string;
56
- permission: string;
57
- patterns: string[];
58
- metadata: Record<string, unknown>;
59
- always: string[];
60
- tool?: PermissionToolSource;
61
- }
62
-
63
- export interface MessageWithParts {
64
- info: Record<string, unknown> & {
65
- id?: string;
66
- role?: string;
67
- structured?: unknown;
68
- };
69
- parts: Array<Record<string, unknown>>;
70
- }
71
-
72
- /** Deterministic risk×authorization matrix that gates reviewer `allow`
73
- * outcomes. For each risk level, lists the authorization levels that permit an
74
- * auto-allow. An empty array means no authorization permits auto-allow at that
75
- * risk (the action is escalated). Only ever RESTRICTS; deny/escalate are always
76
- * preserved. */
77
- export interface RiskPolicy {
78
- allow: {
79
- low: UserAuthorization[];
80
- medium: UserAuthorization[];
81
- high: UserAuthorization[];
82
- critical: UserAuthorization[];
83
- };
84
- minimumConfidence: number;
85
- onInvalidDecision: "manual" | "deny";
86
- onReviewerFailure: "manual" | "deny";
87
- }
88
-
89
- /** Conservative repository trust model. A repository cannot mark itself trusted
90
- * through project configuration alone — trust comes from global config or an
91
- * interactive decision stored outside the repo. */
92
- export type RepositoryTrust = "trusted" | "untrusted" | "unknown";
93
-
94
- /** A declarative policy condition: matches capability/actor facts. Every field
95
- * is optional; the rule matches when ALL specified fields match. A missing
96
- * `when` (or `{ always: true }`) makes the rule universal. */
97
- export interface PolicyCondition {
98
- /** Explicit catch-all: valid only as the sole key. */
99
- always?: true;
100
- actionClass?: CapabilityActionClass[];
101
- actorProfile?: ActorProfile[];
102
- writesWorkspace?: boolean;
103
- writesExternal?: boolean;
104
- writesTemporary?: boolean;
105
- deletion?: boolean;
106
- executesCode?: boolean;
107
- createsAdHocCode?: boolean;
108
- packageManagement?: boolean;
109
- gitMutation?: boolean;
110
- networkObserved?: boolean;
111
- credentialRead?: boolean;
112
- privilegeEscalation?: boolean;
113
- remoteEnabled?: boolean;
114
- persistence?: boolean;
115
- repositoryTrust?: RepositoryTrust[];
116
- }
117
-
118
- /** A declarative rule that routes a request based on capability+actor facts.
119
- * `when` is optional: omitting it (or `{ always: true }`) matches every
120
- * request. An explicitly empty `when: {}` is rejected at load. */
121
- export interface PolicyRule {
122
- id: string;
123
- source: "builtin" | "global" | "project" | "inline";
124
- when?: PolicyCondition;
125
- effect: "review" | "manual" | "deny" | "allow";
126
- reason: string;
127
- }
128
-
129
- /** The result of evaluating the declarative policy. */
130
- export interface PolicyTrace {
131
- /** Stable hash of the effective rule set (not the matched rules) for audit
132
- * reproducibility. */
133
- effectivePolicyHash: string;
134
- matchedRules: Array<{
135
- id: string;
136
- source: string;
137
- effect: string;
138
- reason: string;
139
- }>;
140
- /** The route the engine computed (counterfactual in observe mode: what enforce
141
- * mode WOULD have done with the same facts and rules). */
142
- finalRoute: "review" | "manual" | "deny" | "allow";
143
- mode: "observe" | "enforce";
144
- }
145
-
146
- export type ReviewerOutputFormat = "json_schema" | "text";
147
-
148
- export interface EscalationReviewerConfig {
149
- model: string;
150
- variant: string;
151
- outputFormat: ReviewerOutputFormat;
152
- timeoutMs: number;
153
- }
154
-
155
- export interface ReviewerConfig {
156
- model: string;
157
- variant: string;
158
- /** How the reviewer model returns its decision. `json_schema` requests
159
- * OpenCode's structured-output format (requires provider support); `text`
160
- * asks the model to emit JSON in plain text and parses it locally. */
161
- outputFormat: ReviewerOutputFormat;
162
- /** Optional reasoning reviewer for valid System One decisions that remain
163
- * uncertain or conflict with deterministic review gates. */
164
- escalationReviewer?: EscalationReviewerConfig;
165
- /** Calibrated outcome-confidence floor for System One decisions. */
166
- systemOneConfidenceThreshold: number;
167
- /** Minimum combined non-escalate probability for routing an explicit
168
- * System One escalation to the optional reasoning reviewer. */
169
- systemOneReasoningThreshold: number;
170
- /** Read through resolveSystemOneRouting, which applies the Jev and escalationReviewer conditions. */
171
- systemOneEscalation: SystemOneEscalationMode;
172
- /** Send uncertain Jev denials to the escalation reviewer. Read through resolveSystemOneRouting. */
173
- systemOneDenialReview: boolean;
174
- timeoutMs: number;
175
- /** Total review budget, including context, queueing, and retries. */
176
- reviewBudgetMs?: number;
177
- maxContextChars: number;
178
- maxPartChars: number;
179
- maxEnrichmentChars: number;
180
- maxIntentChars: number;
181
- transcriptMessages: number;
182
- intentMessages: number;
183
- historyMessages: number;
184
- confidenceThreshold: number;
185
- retainReviewSessions: boolean;
186
- audit: boolean;
187
- auditPath?: string;
188
- policy?: string;
189
- debug: boolean;
190
- /** When "observe", actor evidence is collected and audited but never enforces
191
- * new gates; "enforce" applies declarative policy routes. */
192
- enforcementMode: "observe" | "enforce";
193
- /**
194
- * How internal `escalate` results are disposed before UI/reply.
195
- * - `manual` (default): leave the request for a human (interactive mode).
196
- * - `deny`: convert every final escalation into a reject with rationale
197
- * (non-interactive fail-closed). Never relaxes an explicit deny.
198
- */
199
- escalationMode: EscalationMode;
200
- /** Max hops when walking session parents (default 8). */
201
- maxSessionDepth: number;
202
- /** Max parent sessions fetched during lineage traversal. */
203
- maxParentSessions: number;
204
- /** Trusted name→profile mappings (empty by default; no mappings shipped). */
205
- actorProfiles: Record<string, ActorProfile>;
206
- /** Deterministic risk×authorization gate, configurable but defaults reproduce
207
- * the previous hard-coded matrix exactly. */
208
- riskPolicy: RiskPolicy;
209
- /** Repository trust level derived from global config (never from project). */
210
- repositoryTrust: RepositoryTrust;
211
- /** Declarative policy rules (empty by default; observe mode audits the trace
212
- * without enforcing). Project-sourced allow rules are rejected. */
213
- policyRules: PolicyRule[];
214
- /** Capture user answers to agent ask dialogs (question tool) and surface
215
- * them to the reviewer as scoped authorization evidence. */
216
- askDecisions: boolean;
217
- /** Non-empty when a TRUSTED config source (global file, inline options)
218
- * existed but could not be fully honored (malformed file, unreadable file,
219
- * or rules dropped by validation). Degraded configs block automatic
220
- * approval: restrictions may have been lost, so requests escalate instead. */
221
- configDegraded?: string[];
222
- /** Non-empty when a setting was invalid and fell back to its default, or is
223
- * on but inert. Informational only: never affects a decision. */
224
- configWarnings?: string[];
225
- }
226
-
227
- export interface ReviewEnvelope {
228
- request: PermissionRequest;
229
- directory: string;
230
- worktree: string;
231
- transcript: string;
232
- intentHistory: string;
233
- enrichment: string;
234
- verifiedScript?: import("./verified-ssh-script.ts").VerifiedScriptEvidence;
235
- sshAudit: NonNullable<ReviewAuditRecord["ssh"]>;
236
- preflightDenial?: string;
237
- /** Agent-aware context (actor, lineage, intent). Observe-only: flows into the
238
- * reviewer prompt and audit as evidence, never into enforcement decisions.
239
- * Optional so older callers/tests still compile. */
240
- actor?: ActorContext;
241
- lineage?: SessionLineage;
242
- intent?: IntentContext;
243
- evidenceCompleteness?: EvidenceCompleteness;
244
- /** Structured capability facts derived from the bash command. Observe-only:
245
- * feeds the reviewer prompt and audit, never enforcement. */
246
- capability?: CapabilityAssessment;
247
- /** The policy trace produced for this request, surfaced to the reviewer prompt
248
- * as EFFECTIVE_POLICY_SUMMARY and to audit. Observe-only. */
249
- policyTrace?: PolicyTrace;
250
- /** Per-phase timing captured during evidence assembly (context/enrichment).
251
- * The reviewer and reply phases are timed in the coordinator. */
252
- timings?: {
253
- contextMs?: number;
254
- enrichmentMs?: number;
255
- reviewerMs?: number;
256
- replyMs?: number;
257
- };
258
- /** False when a material part of the action under review (e.g. an elided
259
- * command segment) never reached the rendered evidence. Blocking: the
260
- * coordinator must not auto-approve an action the reviewer could not see
261
- * in full, whatever confidence the model reports. */
262
- actionEvidenceComplete?: boolean;
263
- /** The parsed command reused across evidence providers. */
264
- parsedCommand?: ParsedCommand;
265
- /** Operational purpose of the pending action (evidence, never authorization). */
266
- actionPurpose?: ActionPurpose;
267
- /** User answers to agent ask dialogs in this session or its ancestors,
268
- * captured live from question events. Observe-only: flows into the reviewer
269
- * prompt (USER_ASK_DECISIONS) and audit, never into enforcement. */
270
- askDecisions?: AskDecision[];
271
- }
272
-
273
- export interface ApprovedAnnotation {
274
- requestID: string;
275
- sessionID: string;
276
- decision: ReviewDecision;
277
- }
278
-
279
- /** Why a System One (Jev) result was handed to the reasoning reviewer. */
280
- export type HandoffTrigger =
281
- | "jev-escalate"
282
- | "jev-uncertain-allow"
283
- | "jev-gate"
284
- | "jev-invalid"
285
- | "jev-failure"
286
- | "jev-uncertain-deny";
287
-
288
- /** The primary model, routing reason and hand-off trigger of a review a
289
- * second reviewer decided. */
290
- export interface EscalatedFrom {
291
- model: string;
292
- reason: string;
293
- trigger?: HandoffTrigger;
294
- }
295
-
296
- /** How an escalation that left the System One backend was reached. */
297
- export type ManualResolution =
298
- | "reviewer"
299
- | "reasoning-escalated"
300
- | "reasoning-unavailable"
301
- | "budget-exhausted";
302
-
303
- export interface ReviewExecutionResult {
304
- kind: "allow" | "deny" | "escalate";
305
- decision?: ReviewDecision;
306
- reason: string;
307
- reviewSessionID?: string;
308
- /** Which layer produced this result; threaded into the audit record. */
309
- decisionSource?: DecisionSource;
310
- /** Actual model that produced the final reviewer decision. */
311
- reviewerModel?: string;
312
- /** Primary model, routing reason and hand-off trigger when a second
313
- * reviewer was used. */
314
- reviewerEscalatedFrom?: EscalatedFrom;
315
- /** Jev's scores whenever it returned a parsed decision. */
316
- systemOne?: SystemOneScores;
317
- /**
318
- * Structured outcome from the reviewer LLM before gates/disposition.
319
- * Absent when no valid structured decision was produced.
320
- */
321
- reviewerOutcome?: ReviewOutcome;
322
- /**
323
- * How an internal escalate was disposed at the enforcement boundary.
324
- * Absent when the result was never an escalate (explicit allow/deny) or when
325
- * the request was already answered manually (`manual-superseded`).
326
- */
327
- escalationDisposition?: EscalationDisposition;
328
- /** Set only by the System One backend, on escalations; kept when a
329
- * disposition turns one into a deny. */
330
- resolution?: ManualResolution;
331
- }
332
-
333
- /** Generic policy templates, NOT automatic trust levels. */
334
- export type ActorProfile =
335
- | "read-only"
336
- | "validation"
337
- | "workspace"
338
- | "operator"
339
- | "reviewer"
340
- | "unknown";
341
-
342
- /** High-level classification of what the action does. */
343
- export type CapabilityActionClass =
344
- | "read-only"
345
- | "workspace-write"
346
- | "temporary-write"
347
- | "external-write"
348
- | "destruction"
349
- | "code-execution"
350
- | "package-management"
351
- | "git-mutation"
352
- | "network"
353
- | "remote-operation"
354
- | "service-management"
355
- | "persistence"
356
- | "privilege-escalation"
357
- | "unknown";
File without changes
File without changes