@noppu-labs/opencode-permission-reviewer 2.4.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -1
- package/LICENSE +21 -201
- package/LICENSE-APACHE +201 -0
- package/NOTICE +14 -6
- package/README.md +100 -787
- package/SECURITY.md +41 -22
- package/dist/explain.js +4932 -3522
- package/dist/index.d.ts +508 -547
- package/dist/index.js +12454 -9030
- package/dist/rpc.js +4 -1
- package/dist/tui/config/jsonc.ts +71 -63
- package/dist/tui/config/layer-read.ts +120 -0
- package/dist/tui/config/loader.ts +61 -513
- package/dist/tui/config/risk-policy-clamp.ts +80 -0
- package/dist/tui/config/trust-boundary-keys.ts +100 -0
- package/dist/tui/config/trust-boundary.ts +135 -0
- package/dist/tui/config/trusted-degradation.ts +97 -0
- package/dist/tui/config-fields.ts +55 -0
- package/dist/tui/config-knobs.ts +119 -0
- package/dist/tui/config-policy-rules.ts +86 -0
- package/dist/tui/config-risk-policy.ts +59 -0
- package/dist/tui/config-rule-condition.ts +150 -0
- package/dist/tui/config.ts +61 -430
- package/dist/tui/descriptor-io.ts +42 -0
- package/dist/tui/is-record.ts +13 -0
- package/dist/tui/opencode/event-normalizer.ts +41 -31
- package/dist/tui/reviewer-model.ts +87 -0
- package/dist/tui/tui.tsx +87 -99
- package/dist/tui/types.ts +170 -597
- package/dist/tui/ui/components.tsx +32 -136
- package/dist/tui/ui/review-connection.ts +32 -0
- package/dist/tui/ui/review-feed.ts +131 -0
- package/dist/tui/ui/review-overlay.tsx +83 -0
- package/dist/tui/ui/review-result.tsx +56 -0
- package/dist/tui/ui/review-store.ts +88 -0
- package/dist/tui/ui/review-theme.ts +63 -0
- package/dist/tui/ui/rpc.ts +5 -2
- package/dist/tui/ui/v1-host.ts +39 -0
- package/dist/tui/ui/v2.tsx +66 -220
- package/dist/tui/ui-protocol.ts +63 -118
- package/dist/tui/ui-state.ts +71 -64
- package/dist/tui/ui-status-parse.ts +74 -0
- package/package.json +16 -15
- package/rpc.js +2 -1
- package/server.js +2 -2
- package/tui.tsx +2 -1
package/dist/tui/types.ts
CHANGED
|
@@ -1,51 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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";
|
|
6
25
|
/** How final escalations are disposed after reviewer/policy/fail-safe produce them. */
|
|
7
|
-
export type EscalationMode = "manual" | "deny"
|
|
26
|
+
export type EscalationMode = "manual" | "deny";
|
|
8
27
|
/** Effective disposition applied to an internal escalate result. */
|
|
9
|
-
export type EscalationDisposition = "manual" | "deny"
|
|
28
|
+
export type EscalationDisposition = "manual" | "deny";
|
|
10
29
|
|
|
11
30
|
export interface ReviewDecision {
|
|
12
31
|
/** Structured-decision schema version. Always 2 for the current schema. */
|
|
13
|
-
version: 2
|
|
14
|
-
outcome: ReviewOutcome
|
|
15
|
-
risk_level: RiskLevel
|
|
16
|
-
user_authorization: UserAuthorization
|
|
32
|
+
version: 2;
|
|
33
|
+
outcome: ReviewOutcome;
|
|
34
|
+
risk_level: RiskLevel;
|
|
35
|
+
user_authorization: UserAuthorization;
|
|
17
36
|
/** How well the request aligns with the recovered user/delegated intent. */
|
|
18
|
-
scope_alignment: ScopeAlignment
|
|
37
|
+
scope_alignment: ScopeAlignment;
|
|
19
38
|
/** Whether the evidence was sufficient to decide confidently. */
|
|
20
|
-
evidence_completeness: EvidenceSufficiency
|
|
21
|
-
rationale: string
|
|
22
|
-
confidence: number
|
|
39
|
+
evidence_completeness: EvidenceSufficiency;
|
|
40
|
+
rationale: string;
|
|
41
|
+
confidence: number;
|
|
23
42
|
/** Optional script-only semantic analysis. Never conveys authorization. */
|
|
24
|
-
script_analysis?: string
|
|
43
|
+
script_analysis?: string;
|
|
25
44
|
}
|
|
26
45
|
|
|
27
46
|
export interface PermissionToolSource {
|
|
28
|
-
messageID: string
|
|
29
|
-
callID: string
|
|
47
|
+
messageID: string;
|
|
48
|
+
callID: string;
|
|
30
49
|
}
|
|
31
50
|
|
|
32
51
|
export interface PermissionRequest {
|
|
33
|
-
id: string
|
|
34
|
-
sessionID: string
|
|
35
|
-
permission: string
|
|
36
|
-
patterns: string[]
|
|
37
|
-
metadata: Record<string, unknown
|
|
38
|
-
always: string[]
|
|
39
|
-
tool?: PermissionToolSource
|
|
52
|
+
id: string;
|
|
53
|
+
sessionID: string;
|
|
54
|
+
permission: string;
|
|
55
|
+
patterns: string[];
|
|
56
|
+
metadata: Record<string, unknown>;
|
|
57
|
+
always: string[];
|
|
58
|
+
tool?: PermissionToolSource;
|
|
40
59
|
}
|
|
41
60
|
|
|
42
61
|
export interface MessageWithParts {
|
|
43
62
|
info: Record<string, unknown> & {
|
|
44
|
-
id?: string
|
|
45
|
-
role?: string
|
|
46
|
-
structured?: unknown
|
|
47
|
-
}
|
|
48
|
-
parts: Array<Record<string, unknown
|
|
63
|
+
id?: string;
|
|
64
|
+
role?: string;
|
|
65
|
+
structured?: unknown;
|
|
66
|
+
};
|
|
67
|
+
parts: Array<Record<string, unknown>>;
|
|
49
68
|
}
|
|
50
69
|
|
|
51
70
|
/** Deterministic risk×authorization matrix that gates reviewer `allow`
|
|
@@ -55,621 +74,233 @@ export interface MessageWithParts {
|
|
|
55
74
|
* preserved. */
|
|
56
75
|
export interface RiskPolicy {
|
|
57
76
|
allow: {
|
|
58
|
-
low: UserAuthorization[]
|
|
59
|
-
medium: UserAuthorization[]
|
|
60
|
-
high: UserAuthorization[]
|
|
61
|
-
critical: UserAuthorization[]
|
|
62
|
-
}
|
|
63
|
-
minimumConfidence: number
|
|
64
|
-
onInvalidDecision: "manual" | "deny"
|
|
65
|
-
onReviewerFailure: "manual" | "deny"
|
|
77
|
+
low: UserAuthorization[];
|
|
78
|
+
medium: UserAuthorization[];
|
|
79
|
+
high: UserAuthorization[];
|
|
80
|
+
critical: UserAuthorization[];
|
|
81
|
+
};
|
|
82
|
+
minimumConfidence: number;
|
|
83
|
+
onInvalidDecision: "manual" | "deny";
|
|
84
|
+
onReviewerFailure: "manual" | "deny";
|
|
66
85
|
}
|
|
67
86
|
|
|
68
87
|
/** Conservative repository trust model. A repository cannot mark itself trusted
|
|
69
88
|
* through project configuration alone — trust comes from global config or an
|
|
70
89
|
* interactive decision stored outside the repo. */
|
|
71
|
-
export type RepositoryTrust = "trusted" | "untrusted" | "unknown"
|
|
90
|
+
export type RepositoryTrust = "trusted" | "untrusted" | "unknown";
|
|
72
91
|
|
|
73
92
|
/** A declarative policy condition: matches capability/actor facts. Every field
|
|
74
93
|
* is optional; the rule matches when ALL specified fields match. A missing
|
|
75
94
|
* `when` (or `{ always: true }`) makes the rule universal. */
|
|
76
95
|
export interface PolicyCondition {
|
|
77
96
|
/** Explicit catch-all: valid only as the sole key. */
|
|
78
|
-
always?: true
|
|
79
|
-
actionClass?: CapabilityActionClass[]
|
|
80
|
-
actorProfile?: ActorProfile[]
|
|
81
|
-
writesWorkspace?: boolean
|
|
82
|
-
writesExternal?: boolean
|
|
83
|
-
writesTemporary?: boolean
|
|
84
|
-
deletion?: boolean
|
|
85
|
-
executesCode?: boolean
|
|
86
|
-
createsAdHocCode?: boolean
|
|
87
|
-
packageManagement?: boolean
|
|
88
|
-
gitMutation?: boolean
|
|
89
|
-
networkObserved?: boolean
|
|
90
|
-
credentialRead?: boolean
|
|
91
|
-
privilegeEscalation?: boolean
|
|
92
|
-
remoteEnabled?: boolean
|
|
93
|
-
persistence?: boolean
|
|
94
|
-
repositoryTrust?: RepositoryTrust[]
|
|
97
|
+
always?: true;
|
|
98
|
+
actionClass?: CapabilityActionClass[];
|
|
99
|
+
actorProfile?: ActorProfile[];
|
|
100
|
+
writesWorkspace?: boolean;
|
|
101
|
+
writesExternal?: boolean;
|
|
102
|
+
writesTemporary?: boolean;
|
|
103
|
+
deletion?: boolean;
|
|
104
|
+
executesCode?: boolean;
|
|
105
|
+
createsAdHocCode?: boolean;
|
|
106
|
+
packageManagement?: boolean;
|
|
107
|
+
gitMutation?: boolean;
|
|
108
|
+
networkObserved?: boolean;
|
|
109
|
+
credentialRead?: boolean;
|
|
110
|
+
privilegeEscalation?: boolean;
|
|
111
|
+
remoteEnabled?: boolean;
|
|
112
|
+
persistence?: boolean;
|
|
113
|
+
repositoryTrust?: RepositoryTrust[];
|
|
95
114
|
}
|
|
96
115
|
|
|
97
116
|
/** A declarative rule that routes a request based on capability+actor facts.
|
|
98
117
|
* `when` is optional: omitting it (or `{ always: true }`) matches every
|
|
99
118
|
* request. An explicitly empty `when: {}` is rejected at load. */
|
|
100
119
|
export interface PolicyRule {
|
|
101
|
-
id: string
|
|
102
|
-
source: "builtin" | "global" | "project" | "inline"
|
|
103
|
-
when?: PolicyCondition
|
|
104
|
-
effect: "review" | "manual" | "deny" | "allow"
|
|
105
|
-
reason: string
|
|
120
|
+
id: string;
|
|
121
|
+
source: "builtin" | "global" | "project" | "inline";
|
|
122
|
+
when?: PolicyCondition;
|
|
123
|
+
effect: "review" | "manual" | "deny" | "allow";
|
|
124
|
+
reason: string;
|
|
106
125
|
}
|
|
107
126
|
|
|
108
127
|
/** The result of evaluating the declarative policy. */
|
|
109
128
|
export interface PolicyTrace {
|
|
110
129
|
/** Stable hash of the effective rule set (not the matched rules) for audit
|
|
111
130
|
* reproducibility. */
|
|
112
|
-
effectivePolicyHash: string
|
|
113
|
-
matchedRules: Array<{
|
|
131
|
+
effectivePolicyHash: string;
|
|
132
|
+
matchedRules: Array<{
|
|
133
|
+
id: string;
|
|
134
|
+
source: string;
|
|
135
|
+
effect: string;
|
|
136
|
+
reason: string;
|
|
137
|
+
}>;
|
|
114
138
|
/** The route the engine computed (counterfactual in observe mode: what enforce
|
|
115
139
|
* mode WOULD have done with the same facts and rules). */
|
|
116
|
-
finalRoute: "review" | "manual" | "deny" | "allow"
|
|
117
|
-
mode: "observe" | "enforce"
|
|
140
|
+
finalRoute: "review" | "manual" | "deny" | "allow";
|
|
141
|
+
mode: "observe" | "enforce";
|
|
118
142
|
}
|
|
119
143
|
|
|
120
|
-
export type ReviewerOutputFormat = "json_schema" | "text"
|
|
144
|
+
export type ReviewerOutputFormat = "json_schema" | "text";
|
|
121
145
|
|
|
122
146
|
export interface EscalationReviewerConfig {
|
|
123
|
-
model: string
|
|
124
|
-
variant: string
|
|
125
|
-
outputFormat: ReviewerOutputFormat
|
|
126
|
-
timeoutMs: number
|
|
147
|
+
model: string;
|
|
148
|
+
variant: string;
|
|
149
|
+
outputFormat: ReviewerOutputFormat;
|
|
150
|
+
timeoutMs: number;
|
|
127
151
|
}
|
|
128
152
|
|
|
129
153
|
export interface ReviewerConfig {
|
|
130
|
-
model: string
|
|
131
|
-
variant: string
|
|
154
|
+
model: string;
|
|
155
|
+
variant: string;
|
|
132
156
|
/** How the reviewer model returns its decision. `json_schema` requests
|
|
133
157
|
* OpenCode's structured-output format (requires provider support); `text`
|
|
134
158
|
* asks the model to emit JSON in plain text and parses it locally. */
|
|
135
|
-
outputFormat: ReviewerOutputFormat
|
|
159
|
+
outputFormat: ReviewerOutputFormat;
|
|
136
160
|
/** Optional reasoning reviewer for valid System One decisions that remain
|
|
137
161
|
* uncertain or conflict with deterministic review gates. */
|
|
138
|
-
escalationReviewer?: EscalationReviewerConfig
|
|
162
|
+
escalationReviewer?: EscalationReviewerConfig;
|
|
139
163
|
/** Calibrated outcome-confidence floor for System One decisions. */
|
|
140
|
-
systemOneConfidenceThreshold: number
|
|
164
|
+
systemOneConfidenceThreshold: number;
|
|
141
165
|
/** Minimum combined non-escalate probability for routing an explicit
|
|
142
166
|
* System One escalation to the optional reasoning reviewer. */
|
|
143
|
-
systemOneReasoningThreshold: number
|
|
144
|
-
timeoutMs: number
|
|
167
|
+
systemOneReasoningThreshold: number;
|
|
168
|
+
timeoutMs: number;
|
|
145
169
|
/** Total review budget, including context, queueing, and retries. */
|
|
146
|
-
reviewBudgetMs?: number
|
|
147
|
-
maxContextChars: number
|
|
148
|
-
maxPartChars: number
|
|
149
|
-
maxEnrichmentChars: number
|
|
150
|
-
maxIntentChars: number
|
|
151
|
-
transcriptMessages: number
|
|
152
|
-
intentMessages: number
|
|
153
|
-
historyMessages: number
|
|
154
|
-
confidenceThreshold: number
|
|
155
|
-
retainReviewSessions: boolean
|
|
156
|
-
audit: boolean
|
|
157
|
-
auditPath?: string
|
|
158
|
-
policy?: string
|
|
159
|
-
debug: boolean
|
|
170
|
+
reviewBudgetMs?: number;
|
|
171
|
+
maxContextChars: number;
|
|
172
|
+
maxPartChars: number;
|
|
173
|
+
maxEnrichmentChars: number;
|
|
174
|
+
maxIntentChars: number;
|
|
175
|
+
transcriptMessages: number;
|
|
176
|
+
intentMessages: number;
|
|
177
|
+
historyMessages: number;
|
|
178
|
+
confidenceThreshold: number;
|
|
179
|
+
retainReviewSessions: boolean;
|
|
180
|
+
audit: boolean;
|
|
181
|
+
auditPath?: string;
|
|
182
|
+
policy?: string;
|
|
183
|
+
debug: boolean;
|
|
160
184
|
/** When "observe", actor evidence is collected and audited but never enforces
|
|
161
185
|
* new gates; "enforce" applies declarative policy routes. */
|
|
162
|
-
enforcementMode: "observe" | "enforce"
|
|
186
|
+
enforcementMode: "observe" | "enforce";
|
|
163
187
|
/**
|
|
164
188
|
* How internal `escalate` results are disposed before UI/reply.
|
|
165
189
|
* - `manual` (default): leave the request for a human (interactive mode).
|
|
166
190
|
* - `deny`: convert every final escalation into a reject with rationale
|
|
167
191
|
* (non-interactive fail-closed). Never relaxes an explicit deny.
|
|
168
192
|
*/
|
|
169
|
-
escalationMode: EscalationMode
|
|
193
|
+
escalationMode: EscalationMode;
|
|
170
194
|
/** Max hops when walking session parents (default 8). */
|
|
171
|
-
maxSessionDepth: number
|
|
195
|
+
maxSessionDepth: number;
|
|
172
196
|
/** Max parent sessions fetched during lineage traversal. */
|
|
173
|
-
maxParentSessions: number
|
|
197
|
+
maxParentSessions: number;
|
|
174
198
|
/** Trusted name→profile mappings (empty by default; no mappings shipped). */
|
|
175
|
-
actorProfiles: Record<string, ActorProfile
|
|
199
|
+
actorProfiles: Record<string, ActorProfile>;
|
|
176
200
|
/** Deterministic risk×authorization gate, configurable but defaults reproduce
|
|
177
201
|
* the previous hard-coded matrix exactly. */
|
|
178
|
-
riskPolicy: RiskPolicy
|
|
202
|
+
riskPolicy: RiskPolicy;
|
|
179
203
|
/** Repository trust level derived from global config (never from project). */
|
|
180
|
-
repositoryTrust: RepositoryTrust
|
|
204
|
+
repositoryTrust: RepositoryTrust;
|
|
181
205
|
/** Declarative policy rules (empty by default; observe mode audits the trace
|
|
182
206
|
* without enforcing). Project-sourced allow rules are rejected. */
|
|
183
|
-
policyRules: PolicyRule[]
|
|
207
|
+
policyRules: PolicyRule[];
|
|
184
208
|
/** Capture user answers to agent ask dialogs (question tool) and surface
|
|
185
209
|
* them to the reviewer as scoped authorization evidence. */
|
|
186
|
-
askDecisions: boolean
|
|
210
|
+
askDecisions: boolean;
|
|
187
211
|
/** Non-empty when a TRUSTED config source (global file, inline options)
|
|
188
212
|
* existed but could not be fully honored (malformed file, unreadable file,
|
|
189
213
|
* or rules dropped by validation). Degraded configs block automatic
|
|
190
214
|
* approval: restrictions may have been lost, so requests escalate instead. */
|
|
191
|
-
configDegraded?: string[]
|
|
215
|
+
configDegraded?: string[];
|
|
192
216
|
}
|
|
193
217
|
|
|
194
218
|
export interface ReviewEnvelope {
|
|
195
|
-
request: PermissionRequest
|
|
196
|
-
directory: string
|
|
197
|
-
worktree: string
|
|
198
|
-
transcript: string
|
|
199
|
-
intentHistory: string
|
|
200
|
-
enrichment: string
|
|
201
|
-
verifiedScript?: import("./verified-ssh-script.ts").VerifiedScriptEvidence
|
|
202
|
-
sshAudit: NonNullable<ReviewAuditRecord["ssh"]
|
|
203
|
-
preflightDenial?: string
|
|
219
|
+
request: PermissionRequest;
|
|
220
|
+
directory: string;
|
|
221
|
+
worktree: string;
|
|
222
|
+
transcript: string;
|
|
223
|
+
intentHistory: string;
|
|
224
|
+
enrichment: string;
|
|
225
|
+
verifiedScript?: import("./verified-ssh-script.ts").VerifiedScriptEvidence;
|
|
226
|
+
sshAudit: NonNullable<ReviewAuditRecord["ssh"]>;
|
|
227
|
+
preflightDenial?: string;
|
|
204
228
|
/** Agent-aware context (actor, lineage, intent). Observe-only: flows into the
|
|
205
229
|
* reviewer prompt and audit as evidence, never into enforcement decisions.
|
|
206
230
|
* Optional so older callers/tests still compile. */
|
|
207
|
-
actor?: ActorContext
|
|
208
|
-
lineage?: SessionLineage
|
|
209
|
-
intent?: IntentContext
|
|
210
|
-
evidenceCompleteness?: EvidenceCompleteness
|
|
231
|
+
actor?: ActorContext;
|
|
232
|
+
lineage?: SessionLineage;
|
|
233
|
+
intent?: IntentContext;
|
|
234
|
+
evidenceCompleteness?: EvidenceCompleteness;
|
|
211
235
|
/** Structured capability facts derived from the bash command. Observe-only:
|
|
212
236
|
* feeds the reviewer prompt and audit, never enforcement. */
|
|
213
|
-
capability?: CapabilityAssessment
|
|
237
|
+
capability?: CapabilityAssessment;
|
|
214
238
|
/** The policy trace produced for this request, surfaced to the reviewer prompt
|
|
215
239
|
* as EFFECTIVE_POLICY_SUMMARY and to audit. Observe-only. */
|
|
216
|
-
policyTrace?: PolicyTrace
|
|
240
|
+
policyTrace?: PolicyTrace;
|
|
217
241
|
/** Per-phase timing captured during evidence assembly (context/enrichment).
|
|
218
242
|
* The reviewer and reply phases are timed in the coordinator. */
|
|
219
|
-
timings?: {
|
|
243
|
+
timings?: {
|
|
244
|
+
contextMs?: number;
|
|
245
|
+
enrichmentMs?: number;
|
|
246
|
+
reviewerMs?: number;
|
|
247
|
+
replyMs?: number;
|
|
248
|
+
};
|
|
220
249
|
/** False when a material part of the action under review (e.g. an elided
|
|
221
250
|
* command segment) never reached the rendered evidence. Blocking: the
|
|
222
251
|
* coordinator must not auto-approve an action the reviewer could not see
|
|
223
252
|
* in full, whatever confidence the model reports. */
|
|
224
|
-
actionEvidenceComplete?: boolean
|
|
253
|
+
actionEvidenceComplete?: boolean;
|
|
225
254
|
/** The parsed command reused across evidence providers. */
|
|
226
|
-
parsedCommand?: ParsedCommand
|
|
255
|
+
parsedCommand?: ParsedCommand;
|
|
227
256
|
/** Operational purpose of the pending action (evidence, never authorization). */
|
|
228
|
-
actionPurpose?: ActionPurpose
|
|
257
|
+
actionPurpose?: ActionPurpose;
|
|
229
258
|
/** User answers to agent ask dialogs in this session or its ancestors,
|
|
230
259
|
* captured live from question events. Observe-only: flows into the reviewer
|
|
231
260
|
* prompt (USER_ASK_DECISIONS) and audit, never into enforcement. */
|
|
232
|
-
askDecisions?: AskDecision[]
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/** Which layer produced the final decision for a request. Threaded into the
|
|
236
|
-
* audit record so reports can split outcomes by source. */
|
|
237
|
-
export type DecisionSource =
|
|
238
|
-
| "emergency-brake"
|
|
239
|
-
| "deterministic-policy"
|
|
240
|
-
| "llm-reviewer"
|
|
241
|
-
| "system-one-reviewer"
|
|
242
|
-
| "manual-superseded"
|
|
243
|
-
| "failure-safe"
|
|
244
|
-
|
|
245
|
-
export interface ReviewAuditRecord {
|
|
246
|
-
/**
|
|
247
|
-
* Audit schema version. Present on every record; readers default a missing
|
|
248
|
-
* field to `1` (additive — old records are still valid).
|
|
249
|
-
* Bump only on a breaking change to the record shape.
|
|
250
|
-
*/
|
|
251
|
-
schemaVersion?: number
|
|
252
|
-
reviewID?: string
|
|
253
|
-
hostRequestID?: string
|
|
254
|
-
hostGeneration?: "v1" | "v2"
|
|
255
|
-
hostVersion?: string
|
|
256
|
-
generation?: string
|
|
257
|
-
nativeAction?: string
|
|
258
|
-
directory?: string
|
|
259
|
-
application?:
|
|
260
|
-
| "evaluation-returned"
|
|
261
|
-
| "reply-accepted"
|
|
262
|
-
| "human-pending"
|
|
263
|
-
| "superseded"
|
|
264
|
-
| "cancelled"
|
|
265
|
-
| "unknown"
|
|
266
|
-
pluginVersion?: string
|
|
267
|
-
effectiveConfigHash?: string
|
|
268
|
-
actionFingerprint?: string
|
|
269
|
-
/** Version of the structured-decision schema the reviewer was asked to emit. */
|
|
270
|
-
decisionSchemaVersion?: number
|
|
271
|
-
/** Version of the reviewer system prompt used for this decision. */
|
|
272
|
-
promptVersion?: string
|
|
273
|
-
/** Which layer produced the outcome (brake, policy, reviewer, supersede,
|
|
274
|
-
* failure-safe). Absent on legacy v1 records. */
|
|
275
|
-
decisionSource?: DecisionSource
|
|
276
|
-
timestamp: string
|
|
277
|
-
durationMs: number
|
|
278
|
-
requestID: string
|
|
279
|
-
sessionID: string
|
|
280
|
-
permission: string
|
|
281
|
-
/** Stable hash of the canonical request (permission, patterns, metadata,
|
|
282
|
-
* tool) for cross-record correlation. Absent on legacy v1 records. */
|
|
283
|
-
actionHash?: string
|
|
284
|
-
outcome: ReviewExecutionResult["kind"]
|
|
285
|
-
reason: string
|
|
286
|
-
riskLevel?: RiskLevel
|
|
287
|
-
userAuthorization?: UserAuthorization
|
|
288
|
-
/** How well the action aligned with the recovered intent (from the reviewer
|
|
289
|
-
* decision). Absent when no reviewer decision was reached. */
|
|
290
|
-
scopeAlignment?: ScopeAlignment
|
|
291
|
-
confidence?: number
|
|
292
|
-
/**
|
|
293
|
-
* Structured outcome emitted by the reviewer LLM before gates/disposition.
|
|
294
|
-
* Absent when no valid structured decision was produced (brake, policy,
|
|
295
|
-
* failure-safe, supersede).
|
|
296
|
-
*/
|
|
297
|
-
reviewerOutcome?: ReviewOutcome
|
|
298
|
-
/**
|
|
299
|
-
* How an internal escalate was disposed. Present only when the logical result
|
|
300
|
-
* was escalate (or a gate converted allow→escalate) and enforcement chose
|
|
301
|
-
* manual or deny. Absent for explicit deny, allow, and manual-superseded.
|
|
302
|
-
*/
|
|
303
|
-
escalationDisposition?: EscalationDisposition
|
|
304
|
-
/** The model that produced the final reviewer decision. */
|
|
305
|
-
reviewerModel?: string
|
|
306
|
-
/** Present when a System One result was handed to a reasoning reviewer. */
|
|
307
|
-
reviewerEscalatedFrom?: { model: string; reason: string }
|
|
308
|
-
/** Jev's scores whenever it returned a parsed decision, including when a
|
|
309
|
-
* reasoning reviewer made the final call. */
|
|
310
|
-
systemOne?: SystemOneScores
|
|
311
|
-
/** Per-phase timings. Absent on legacy v1 records and on deterministic paths
|
|
312
|
-
* that never reach that phase. */
|
|
313
|
-
timings?: { contextMs?: number; enrichmentMs?: number; reviewerMs?: number; replyMs?: number }
|
|
314
|
-
/** Non-fatal warnings accumulated during evidence collection/analysis. */
|
|
315
|
-
warnings?: string[]
|
|
316
|
-
reviewerSessionID?: string
|
|
317
|
-
/** Content identity and inspection mode only; never script text or local path. */
|
|
318
|
-
verifiedScript?: { sha256: string; status: "full" | "reused" | "unavailable"; bytes?: number }
|
|
319
|
-
/** Root session of the request's ancestry (additive; absent when lineage was
|
|
320
|
-
* unavailable). */
|
|
321
|
-
rootSessionID?: string
|
|
322
|
-
/** Overall evidence completeness for the request (additive). */
|
|
323
|
-
evidenceCompleteness?: string
|
|
324
|
-
/** Resolved actor snapshot for audit (additive). Uses identityCompleteness
|
|
325
|
-
* (not the decision's numeric confidence) to avoid field ambiguity; v2 also
|
|
326
|
-
* carries identitySource + confidence. */
|
|
327
|
-
actor?: {
|
|
328
|
-
name?: string
|
|
329
|
-
mode?: string
|
|
330
|
-
profile: ActorProfile
|
|
331
|
-
identityCompleteness: "complete" | "partial" | "unknown"
|
|
332
|
-
/** How the agent identity was established (tool-message, session-api,
|
|
333
|
-
* unavailable, …). Absent on legacy v1 records. */
|
|
334
|
-
identitySource?: string
|
|
335
|
-
/** Reliability of the identity claim. Absent on legacy v1 records. */
|
|
336
|
-
confidence?: EvidenceConfidence
|
|
337
|
-
delegationDepth?: number
|
|
338
|
-
}
|
|
339
|
-
ssh?: Array<{
|
|
340
|
-
destination: string
|
|
341
|
-
port?: string
|
|
342
|
-
remoteCommandSha256?: string
|
|
343
|
-
stdinSource?: string
|
|
344
|
-
stdinStatus?: string
|
|
345
|
-
stdinReason?: string
|
|
346
|
-
}>
|
|
347
|
-
/** Additive capability snapshot for audit (observe-only). */
|
|
348
|
-
capability?: {
|
|
349
|
-
actionClass: string
|
|
350
|
-
summary: string
|
|
351
|
-
parserCompleteness: string
|
|
352
|
-
executesCode?: boolean
|
|
353
|
-
createsAdHocCode?: boolean
|
|
354
|
-
invokesPackageLifecycleScripts?: boolean
|
|
355
|
-
writeEffects?: {
|
|
356
|
-
temporaryWrite?: boolean
|
|
357
|
-
workspaceWrite?: boolean
|
|
358
|
-
externalWrite?: boolean
|
|
359
|
-
deletion?: boolean
|
|
360
|
-
}
|
|
361
|
-
networkObserved?: boolean
|
|
362
|
-
credentialRead?: boolean
|
|
363
|
-
privilegeEscalation?: boolean
|
|
364
|
-
persistence?: boolean
|
|
365
|
-
remoteEnabled?: boolean
|
|
366
|
-
gitMutation?: boolean
|
|
367
|
-
}
|
|
368
|
-
/** Additive policy trace for audit (observe-only). */
|
|
369
|
-
policyTrace?: {
|
|
370
|
-
effectivePolicyHash: string
|
|
371
|
-
matchedRules: Array<{ id: string; source: string; effect: string; reason: string }>
|
|
372
|
-
finalRoute: string
|
|
373
|
-
mode: string
|
|
374
|
-
}
|
|
375
|
-
/** Additive snapshot of the ask decisions surfaced to the reviewer prompt
|
|
376
|
-
* (observe-only; capped to the most recent few). */
|
|
377
|
-
askDecisions?: Array<{ at: number; question: string; answer: string }>
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
export const SYSTEM_ONE_BASES = [
|
|
381
|
-
"authorized_routine",
|
|
382
|
-
"authorized_reversible_change",
|
|
383
|
-
"insufficient_authorization",
|
|
384
|
-
"scope_mismatch",
|
|
385
|
-
"insufficient_evidence",
|
|
386
|
-
"destructive_effect",
|
|
387
|
-
"credential_or_private_data",
|
|
388
|
-
"security_or_privilege_change",
|
|
389
|
-
"external_or_remote_effect",
|
|
390
|
-
"trusted_policy_restriction",
|
|
391
|
-
"conflicting_evidence",
|
|
392
|
-
] as const
|
|
393
|
-
export type SystemOnePrimaryBasis = (typeof SYSTEM_ONE_BASES)[number]
|
|
394
|
-
|
|
395
|
-
export interface SystemOneChoiceScore<T extends string> {
|
|
396
|
-
choice: T
|
|
397
|
-
confidence: number
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/** Probability (0-1) that each safety question is true. */
|
|
401
|
-
export interface SystemOneSignals {
|
|
402
|
-
materialAuthorization: number
|
|
403
|
-
withinIntentScope: number
|
|
404
|
-
unauthorizedDataLoss: number
|
|
405
|
-
untrustedSensitiveDisclosure: number
|
|
406
|
-
excessiveCredentialAccess: number
|
|
407
|
-
unauthorizedSecurityChange: number
|
|
408
|
-
unauthorizedExternalMutation: number
|
|
409
|
-
essentialEvidenceMissing: number
|
|
410
|
-
absolutePolicyDeny: number
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Jev's own answer, kept apart from the final decision because a reasoning
|
|
415
|
-
* reviewer may replace it. Numbers, enum choices, fixed contradiction strings,
|
|
416
|
-
* and the provider-reported model ID only; never evidence text.
|
|
417
|
-
*/
|
|
418
|
-
export interface SystemOneScores {
|
|
419
|
-
/** Versioned model ID the provider reported as having answered. */
|
|
420
|
-
returnedModel: string
|
|
421
|
-
outcome: SystemOneChoiceScore<ReviewOutcome> & { probabilities: Record<ReviewOutcome, number> }
|
|
422
|
-
supporting: {
|
|
423
|
-
riskLevel: SystemOneChoiceScore<RiskLevel>
|
|
424
|
-
userAuthorization: SystemOneChoiceScore<UserAuthorization>
|
|
425
|
-
scopeAlignment: SystemOneChoiceScore<ScopeAlignment>
|
|
426
|
-
evidenceCompleteness: SystemOneChoiceScore<EvidenceSufficiency>
|
|
427
|
-
primaryBasis: SystemOneChoiceScore<SystemOnePrimaryBasis>
|
|
428
|
-
}
|
|
429
|
-
signals: SystemOneSignals
|
|
430
|
-
/** Consistency checks that failed; any one marks an allow or deny difficult. */
|
|
431
|
-
contradictions: string[]
|
|
432
|
-
reasoningRecommended: boolean
|
|
261
|
+
askDecisions?: AskDecision[];
|
|
433
262
|
}
|
|
434
263
|
|
|
435
264
|
export interface ApprovedAnnotation {
|
|
436
|
-
requestID: string
|
|
437
|
-
sessionID: string
|
|
438
|
-
decision: ReviewDecision
|
|
265
|
+
requestID: string;
|
|
266
|
+
sessionID: string;
|
|
267
|
+
decision: ReviewDecision;
|
|
439
268
|
}
|
|
440
269
|
|
|
441
270
|
export interface ReviewExecutionResult {
|
|
442
|
-
kind: "allow" | "deny" | "escalate"
|
|
443
|
-
decision?: ReviewDecision
|
|
444
|
-
reason: string
|
|
445
|
-
reviewSessionID?: string
|
|
271
|
+
kind: "allow" | "deny" | "escalate";
|
|
272
|
+
decision?: ReviewDecision;
|
|
273
|
+
reason: string;
|
|
274
|
+
reviewSessionID?: string;
|
|
446
275
|
/** Which layer produced this result; threaded into the audit record. */
|
|
447
|
-
decisionSource?: DecisionSource
|
|
276
|
+
decisionSource?: DecisionSource;
|
|
448
277
|
/** Actual model that produced the final reviewer decision. */
|
|
449
|
-
reviewerModel?: string
|
|
278
|
+
reviewerModel?: string;
|
|
450
279
|
/** Primary model and routing reason when a second reviewer was used. */
|
|
451
|
-
reviewerEscalatedFrom?: { model: string; reason: string }
|
|
280
|
+
reviewerEscalatedFrom?: { model: string; reason: string };
|
|
452
281
|
/** Jev's scores whenever it returned a parsed decision. */
|
|
453
|
-
systemOne?: SystemOneScores
|
|
282
|
+
systemOne?: SystemOneScores;
|
|
454
283
|
/**
|
|
455
284
|
* Structured outcome from the reviewer LLM before gates/disposition.
|
|
456
285
|
* Absent when no valid structured decision was produced.
|
|
457
286
|
*/
|
|
458
|
-
reviewerOutcome?: ReviewOutcome
|
|
287
|
+
reviewerOutcome?: ReviewOutcome;
|
|
459
288
|
/**
|
|
460
289
|
* How an internal escalate was disposed at the enforcement boundary.
|
|
461
290
|
* Absent when the result was never an escalate (explicit allow/deny) or when
|
|
462
291
|
* the request was already answered manually (`manual-superseded`).
|
|
463
292
|
*/
|
|
464
|
-
escalationDisposition?: EscalationDisposition
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
// ---------------------------------------------------------------------------
|
|
468
|
-
// Agent-aware context data model.
|
|
469
|
-
//
|
|
470
|
-
// These types carry actor/lineage/intent evidence alongside a permission
|
|
471
|
-
// request. They flow into the reviewer prompt (as evidence sections) and the
|
|
472
|
-
// audit record (additive fields) WITHOUT changing enforcement: the v1 decision
|
|
473
|
-
// schema and enforceDecision are untouched (observe-only by default).
|
|
474
|
-
// ---------------------------------------------------------------------------
|
|
475
|
-
|
|
476
|
-
/** Reliability of a derived fact. */
|
|
477
|
-
export type EvidenceConfidence = "confirmed" | "high" | "medium" | "low" | "unknown"
|
|
478
|
-
|
|
479
|
-
/** Every non-trivial derived fact carries provenance so the LLM and audit can
|
|
480
|
-
* weigh claims by how reliably they were established. */
|
|
481
|
-
export interface Provenanced<T> {
|
|
482
|
-
value: T
|
|
483
|
-
source:
|
|
484
|
-
| "permission-event"
|
|
485
|
-
| "tool-message"
|
|
486
|
-
| "session-api"
|
|
487
|
-
| "parent-session"
|
|
488
|
-
| "global-config"
|
|
489
|
-
| "project-config"
|
|
490
|
-
| "effective-permissions"
|
|
491
|
-
| "static-analysis"
|
|
492
|
-
| "heuristic"
|
|
493
|
-
| "unavailable"
|
|
494
|
-
confidence: EvidenceConfidence
|
|
495
|
-
notes?: string[]
|
|
293
|
+
escalationDisposition?: EscalationDisposition;
|
|
496
294
|
}
|
|
497
295
|
|
|
498
296
|
/** Generic policy templates, NOT automatic trust levels. */
|
|
499
297
|
export type ActorProfile =
|
|
500
|
-
"read-only"
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
bash: "allow" | "ask" | "deny" | "mixed" | "unknown"
|
|
507
|
-
task: "allow" | "ask" | "deny" | "mixed" | "unknown"
|
|
508
|
-
externalDirectory: "allow" | "ask" | "deny" | "mixed" | "unknown"
|
|
509
|
-
source: "session" | "agent-config" | "derived" | "unknown"
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
/** Who is requesting the permission. */
|
|
513
|
-
export interface ActorContext {
|
|
514
|
-
agentName: Provenanced<string | undefined>
|
|
515
|
-
mode: Provenanced<string | undefined>
|
|
516
|
-
profile: Provenanced<ActorProfile>
|
|
517
|
-
sessionID: string
|
|
518
|
-
parentSessionID: Provenanced<string | undefined>
|
|
519
|
-
rootSessionID: Provenanced<string>
|
|
520
|
-
delegationDepth: Provenanced<number>
|
|
521
|
-
effectivePermissions?: EffectivePermissionSummary
|
|
522
|
-
identityCompleteness: "complete" | "partial" | "unknown"
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
/** A node in the session ancestry chain. */
|
|
526
|
-
export interface SessionNode {
|
|
527
|
-
sessionID: string
|
|
528
|
-
parentID?: string
|
|
529
|
-
title?: string
|
|
530
|
-
version?: string
|
|
531
|
-
actorName?: string
|
|
532
|
-
mode?: string
|
|
533
|
-
createdAt?: number
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
/** The resolved session ancestry with failure modes made explicit. */
|
|
537
|
-
export interface SessionLineage {
|
|
538
|
-
origin?: "human-root" | "delegated" | "unknown"
|
|
539
|
-
nodes: SessionNode[]
|
|
540
|
-
rootSessionID: string
|
|
541
|
-
depth: number
|
|
542
|
-
cycleDetected: boolean
|
|
543
|
-
truncated: boolean
|
|
544
|
-
missingParents: string[]
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
/** A single authorization/intent statement. */
|
|
548
|
-
export interface IntentBlock {
|
|
549
|
-
sessionID: string
|
|
550
|
-
messageID: string
|
|
551
|
-
actor: "user" | "assistant" | "system" | "unknown"
|
|
552
|
-
text: string
|
|
553
|
-
synthetic: boolean
|
|
554
|
-
createdAt?: number
|
|
555
|
-
provenance: Provenanced<"intent">
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
/** One user decision on an agent-initiated ask dialog (question tool). The
|
|
559
|
-
* question text is agent-generated and untrusted; only the answer is a user
|
|
560
|
-
* authorization signal, scoped to the subject and time of the ask. */
|
|
561
|
-
export interface AskDecision {
|
|
562
|
-
/** Epoch ms when the reply (or dismissal) was observed. */
|
|
563
|
-
at: number
|
|
564
|
-
/** What the agent asked, already redacted and truncated. */
|
|
565
|
-
question: string
|
|
566
|
-
/** The option labels the user selected, or a dismissal marker. */
|
|
567
|
-
answer: string
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
/** Direct user intent kept separate from delegated task. */
|
|
571
|
-
export interface IntentContext {
|
|
572
|
-
directUserIntent: IntentBlock[]
|
|
573
|
-
delegatedTask: IntentBlock[]
|
|
574
|
-
localSessionIntent: IntentBlock[]
|
|
575
|
-
conflictingInstructions: string[]
|
|
576
|
-
latestExplicitAuthorization?: IntentBlock
|
|
577
|
-
completeness: "complete" | "partial" | "insufficient"
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
/** Meta-summary of what evidence was available. */
|
|
581
|
-
export interface EvidenceCompleteness {
|
|
582
|
-
permission: boolean
|
|
583
|
-
actor: boolean
|
|
584
|
-
lineage: boolean
|
|
585
|
-
directUserIntent: boolean
|
|
586
|
-
delegatedTask: boolean
|
|
587
|
-
/** Whether a non-unavailable ACTION_PURPOSE was recovered. */
|
|
588
|
-
purpose: boolean
|
|
589
|
-
capability: boolean
|
|
590
|
-
repositoryState: boolean
|
|
591
|
-
referencedCode: boolean
|
|
592
|
-
reasons: string[]
|
|
593
|
-
overall: "sufficient" | "partial" | "insufficient"
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* Operational purpose of the pending action — what the agent appears to be
|
|
598
|
-
* trying to accomplish. This is untrusted evidence: it never demonstrates
|
|
599
|
-
* user authorization by itself.
|
|
600
|
-
*/
|
|
601
|
-
export interface ActionPurpose {
|
|
602
|
-
text?: string
|
|
603
|
-
source: "agent-context" | "intent-derived" | "unavailable"
|
|
604
|
-
confidence: EvidenceConfidence
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
// ---------------------------------------------------------------------------
|
|
608
|
-
// Capability analysis. The analyzer produces these facts from the bash
|
|
609
|
-
// command using the existing shell lexer; each fact is evidence for the reviewer
|
|
610
|
-
// prompt, never a final safety decision. Fields default to "unknown" when no
|
|
611
|
-
// detector covers them yet.
|
|
612
|
-
// ---------------------------------------------------------------------------
|
|
613
|
-
|
|
614
|
-
/** How completely the command could be statically analyzed. */
|
|
615
|
-
export type ParserCompleteness =
|
|
616
|
-
/** Fully parsed: no variables, globs, substitutions, or heredoc bodies. */
|
|
617
|
-
| "complete-for-supported-form"
|
|
618
|
-
/** Some constructs could not be resolved (variables, partial heredoc). */
|
|
619
|
-
| "partial"
|
|
620
|
-
/** Heavy dynamic constructs (command substitution, eval, dynamic heredoc). */
|
|
621
|
-
| "opaque"
|
|
622
|
-
|
|
623
|
-
/** A redirection extracted from a parsed command segment. */
|
|
624
|
-
export interface Redirection {
|
|
625
|
-
/** `>` `>>` `<` `2>` `&>` etc. */
|
|
626
|
-
operator: string
|
|
627
|
-
/** Target path (file descriptor targets normalized to a path when possible). */
|
|
628
|
-
target: string
|
|
629
|
-
/** Whether the target was quoted in the source (affects literal-ness). */
|
|
630
|
-
quoted: boolean
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
/** A heredoc extracted before lexing so its body never reaches the lexer/brake. */
|
|
634
|
-
export interface HeredocRecord {
|
|
635
|
-
/** The literal delimiter token as it appeared (`EOF`, `END`, …). */
|
|
636
|
-
delimiter: string
|
|
637
|
-
/** `<<` (expansion on) or `<<-` (tabs stripped) — normalized form. */
|
|
638
|
-
operator: string
|
|
639
|
-
/** Whether the delimiter was quoted, disabling expansion (`<<'EOF'`). */
|
|
640
|
-
expansionDisabled: boolean
|
|
641
|
-
/** Bounded + redacted body (truncated to a safe length). */
|
|
642
|
-
bodyBounded: string
|
|
643
|
-
/** SHA-256 of the full, unredacted body (stable identity without leaking it). */
|
|
644
|
-
bodySha256: string
|
|
645
|
-
/** Whether the body was truncated for storage. */
|
|
646
|
-
truncated: boolean
|
|
647
|
-
/** Output path associated with the heredoc when a `> path` precedes it. */
|
|
648
|
-
outputTarget?: string
|
|
649
|
-
/** Whether the body is dynamically constructed (unresolvable expansion). */
|
|
650
|
-
dynamic: boolean
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
/** A command parsed into a reusable structure. Wraps the existing lexer output
|
|
654
|
-
* plus pre-extracted redirections and heredocs. */
|
|
655
|
-
export interface ParsedCommand {
|
|
656
|
-
/** The command after heredoc bodies were replaced with placeholders. */
|
|
657
|
-
sanitizedCommand: string
|
|
658
|
-
/** Lexed segments of the sanitized command. */
|
|
659
|
-
segments: import("./shell-lexer.ts").ShellSegment[]
|
|
660
|
-
/** Effective commands (wrappers peeled) per segment. */
|
|
661
|
-
effective: import("./shell-lexer.ts").ShellToken[][]
|
|
662
|
-
/** Redirections grouped by segment index. */
|
|
663
|
-
redirections: Redirection[][]
|
|
664
|
-
/** Heredocs extracted before lexing. */
|
|
665
|
-
heredocs: HeredocRecord[]
|
|
666
|
-
/** Whether the original command contained any dynamic constructs. */
|
|
667
|
-
hasDynamicConstructs: boolean
|
|
668
|
-
/** True when the lexer's depth or expansion budget stopped command-string
|
|
669
|
-
* resolution early; `effective` is then a prefix of the real structure and
|
|
670
|
-
* deterministic facts do not cover the whole command. */
|
|
671
|
-
analysisTruncated: boolean
|
|
672
|
-
}
|
|
298
|
+
| "read-only"
|
|
299
|
+
| "validation"
|
|
300
|
+
| "workspace"
|
|
301
|
+
| "operator"
|
|
302
|
+
| "reviewer"
|
|
303
|
+
| "unknown";
|
|
673
304
|
|
|
674
305
|
/** High-level classification of what the action does. */
|
|
675
306
|
export type CapabilityActionClass =
|
|
@@ -686,62 +317,4 @@ export type CapabilityActionClass =
|
|
|
686
317
|
| "service-management"
|
|
687
318
|
| "persistence"
|
|
688
319
|
| "privilege-escalation"
|
|
689
|
-
| "unknown"
|
|
690
|
-
|
|
691
|
-
/** What the action can do, what it appears to do, and analysis confidence. */
|
|
692
|
-
export interface CapabilityAssessment {
|
|
693
|
-
/** Best single-label summary of the dominant capability. */
|
|
694
|
-
actionClass: Provenanced<CapabilityActionClass>
|
|
695
|
-
/** Human-readable summary of the detected surface. */
|
|
696
|
-
summary: string
|
|
697
|
-
/** Executes an interpreter or runtime (sh, python, node, bun, …). */
|
|
698
|
-
executesCode: Provenanced<boolean | "unknown">
|
|
699
|
-
/** Executes code that lives in the repository (scripts, test files). */
|
|
700
|
-
executesRepositoryCode: Provenanced<boolean | "unknown">
|
|
701
|
-
/** Executes ad-hoc code generated by the agent (heredoc/inline). */
|
|
702
|
-
createsAdHocCode: Provenanced<boolean | "unknown">
|
|
703
|
-
/** Invokes a known test runner (pytest, jest, bun test, …). */
|
|
704
|
-
invokesExistingTestRunner: Provenanced<boolean | "unknown">
|
|
705
|
-
/** Runs a package manager that may execute lifecycle scripts. */
|
|
706
|
-
invokesPackageLifecycleScripts: Provenanced<boolean | "unknown">
|
|
707
|
-
/** Reads literal credential material through a known file reader. */
|
|
708
|
-
credentialRead: Provenanced<boolean | "unknown">
|
|
709
|
-
/** Detected file-write surface. */
|
|
710
|
-
writeEffects: {
|
|
711
|
-
temporaryWrite: Provenanced<boolean | "unknown">
|
|
712
|
-
workspaceWrite: Provenanced<boolean | "unknown">
|
|
713
|
-
externalWrite: Provenanced<boolean | "unknown">
|
|
714
|
-
deletion: Provenanced<boolean | "unknown">
|
|
715
|
-
}
|
|
716
|
-
/** Detected network surface. */
|
|
717
|
-
network: {
|
|
718
|
-
observed: Provenanced<boolean | "unknown">
|
|
719
|
-
possible: Provenanced<boolean | "unknown">
|
|
720
|
-
/** Hosts/destinations observed literally in the command. */
|
|
721
|
-
destinations: string[]
|
|
722
|
-
observedAccess: Provenanced<boolean | "unknown">
|
|
723
|
-
possibleAccess: Provenanced<boolean | "unknown">
|
|
724
|
-
}
|
|
725
|
-
/** Detected process side-effects. */
|
|
726
|
-
process: {
|
|
727
|
-
childProcesses: Provenanced<boolean | "unknown">
|
|
728
|
-
persistence: Provenanced<boolean | "unknown">
|
|
729
|
-
privilegeEscalation: Provenanced<boolean | "unknown">
|
|
730
|
-
}
|
|
731
|
-
/** Detected remote-operation surface (ssh, etc.). */
|
|
732
|
-
remote: {
|
|
733
|
-
enabled: Provenanced<boolean | "unknown">
|
|
734
|
-
mutationHint: Provenanced<boolean | "unknown">
|
|
735
|
-
}
|
|
736
|
-
/** Detected git mutation surface. */
|
|
737
|
-
git: {
|
|
738
|
-
observed: Provenanced<boolean | "unknown">
|
|
739
|
-
possible: Provenanced<boolean | "unknown">
|
|
740
|
-
observedAccess: Provenanced<boolean | "unknown">
|
|
741
|
-
possibleAccess: Provenanced<boolean | "unknown">
|
|
742
|
-
}
|
|
743
|
-
/** How completely the command could be analyzed. */
|
|
744
|
-
parserCompleteness: ParserCompleteness
|
|
745
|
-
/** Free-form warnings about analysis limitations. */
|
|
746
|
-
analysisWarnings: string[]
|
|
747
|
-
}
|
|
320
|
+
| "unknown";
|