@noppu-labs/opencode-permission-reviewer 2.4.2 → 3.1.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 +174 -1
- package/LICENSE +21 -201
- package/LICENSE-APACHE +201 -0
- package/MIGRATION.md +2 -1
- package/NOTICE +14 -6
- package/README.md +109 -787
- package/SECURITY.md +41 -22
- package/dist/explain.d.ts +3 -4
- package/dist/explain.js +9708 -4298
- package/dist/index.d.ts +1096 -987
- package/dist/index.js +18646 -10575
- package/dist/rpc.d.ts +38 -38
- package/dist/rpc.js +30 -18
- package/dist/tui/config/jsonc.ts +71 -63
- package/dist/tui/config/layer-read.ts +120 -0
- package/dist/tui/config/loader.ts +73 -512
- package/dist/tui/config/risk-policy-clamp.ts +80 -0
- package/dist/tui/config/trust-boundary-keys.ts +102 -0
- package/dist/tui/config/trust-boundary.ts +148 -0
- package/dist/tui/config/trusted-degradation.ts +97 -0
- package/dist/tui/config-fields.ts +75 -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 +72 -431
- package/dist/tui/descriptor-io.ts +42 -0
- package/dist/tui/failure-kind.ts +28 -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/system-one-routing.ts +110 -0
- package/dist/tui/tui.tsx +97 -99
- package/dist/tui/types.ts +206 -596
- package/dist/tui/ui/action-fit.ts +161 -0
- package/dist/tui/ui/action-spans.tsx +60 -0
- package/dist/tui/ui/attribution.ts +113 -0
- package/dist/tui/ui/components.tsx +69 -137
- package/dist/tui/ui/config-notices.ts +137 -0
- package/dist/tui/ui/fit-parts.ts +76 -0
- package/dist/tui/ui/manual-toast.ts +87 -0
- package/dist/tui/ui/review-connection.ts +32 -0
- package/dist/tui/ui/review-feed.ts +156 -0
- package/dist/tui/ui/review-overlay.tsx +111 -0
- package/dist/tui/ui/review-result.tsx +74 -0
- package/dist/tui/ui/review-store.ts +88 -0
- package/dist/tui/ui/review-theme.ts +70 -0
- package/dist/tui/ui/rpc.ts +5 -2
- package/dist/tui/ui/v1-host.ts +66 -0
- package/dist/tui/ui/v2.tsx +82 -220
- package/dist/tui/ui-protocol.ts +112 -124
- package/dist/tui/ui-state.ts +86 -64
- package/dist/tui/ui-status-extras.ts +165 -0
- package/dist/tui/ui-status-parse.ts +132 -0
- package/dist/tui/ui-text-elide.ts +89 -0
- package/package.json +24 -23
- package/rpc.js +2 -1
- package/server.js +2 -2
- package/tui.tsx +2 -1
package/dist/tui/types.ts
CHANGED
|
@@ -1,51 +1,72 @@
|
|
|
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";
|
|
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";
|
|
10
31
|
|
|
11
32
|
export interface ReviewDecision {
|
|
12
33
|
/** Structured-decision schema version. Always 2 for the current schema. */
|
|
13
|
-
version: 2
|
|
14
|
-
outcome: ReviewOutcome
|
|
15
|
-
risk_level: RiskLevel
|
|
16
|
-
user_authorization: UserAuthorization
|
|
34
|
+
version: 2;
|
|
35
|
+
outcome: ReviewOutcome;
|
|
36
|
+
risk_level: RiskLevel;
|
|
37
|
+
user_authorization: UserAuthorization;
|
|
17
38
|
/** How well the request aligns with the recovered user/delegated intent. */
|
|
18
|
-
scope_alignment: ScopeAlignment
|
|
39
|
+
scope_alignment: ScopeAlignment;
|
|
19
40
|
/** Whether the evidence was sufficient to decide confidently. */
|
|
20
|
-
evidence_completeness: EvidenceSufficiency
|
|
21
|
-
rationale: string
|
|
22
|
-
confidence: number
|
|
41
|
+
evidence_completeness: EvidenceSufficiency;
|
|
42
|
+
rationale: string;
|
|
43
|
+
confidence: number;
|
|
23
44
|
/** Optional script-only semantic analysis. Never conveys authorization. */
|
|
24
|
-
script_analysis?: string
|
|
45
|
+
script_analysis?: string;
|
|
25
46
|
}
|
|
26
47
|
|
|
27
48
|
export interface PermissionToolSource {
|
|
28
|
-
messageID: string
|
|
29
|
-
callID: string
|
|
49
|
+
messageID: string;
|
|
50
|
+
callID: string;
|
|
30
51
|
}
|
|
31
52
|
|
|
32
53
|
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
|
|
54
|
+
id: string;
|
|
55
|
+
sessionID: string;
|
|
56
|
+
permission: string;
|
|
57
|
+
patterns: string[];
|
|
58
|
+
metadata: Record<string, unknown>;
|
|
59
|
+
always: string[];
|
|
60
|
+
tool?: PermissionToolSource;
|
|
40
61
|
}
|
|
41
62
|
|
|
42
63
|
export interface MessageWithParts {
|
|
43
64
|
info: Record<string, unknown> & {
|
|
44
|
-
id?: string
|
|
45
|
-
role?: string
|
|
46
|
-
structured?: unknown
|
|
47
|
-
}
|
|
48
|
-
parts: Array<Record<string, unknown
|
|
65
|
+
id?: string;
|
|
66
|
+
role?: string;
|
|
67
|
+
structured?: unknown;
|
|
68
|
+
};
|
|
69
|
+
parts: Array<Record<string, unknown>>;
|
|
49
70
|
}
|
|
50
71
|
|
|
51
72
|
/** Deterministic risk×authorization matrix that gates reviewer `allow`
|
|
@@ -55,621 +76,268 @@ export interface MessageWithParts {
|
|
|
55
76
|
* preserved. */
|
|
56
77
|
export interface RiskPolicy {
|
|
57
78
|
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"
|
|
79
|
+
low: UserAuthorization[];
|
|
80
|
+
medium: UserAuthorization[];
|
|
81
|
+
high: UserAuthorization[];
|
|
82
|
+
critical: UserAuthorization[];
|
|
83
|
+
};
|
|
84
|
+
minimumConfidence: number;
|
|
85
|
+
onInvalidDecision: "manual" | "deny";
|
|
86
|
+
onReviewerFailure: "manual" | "deny";
|
|
66
87
|
}
|
|
67
88
|
|
|
68
89
|
/** Conservative repository trust model. A repository cannot mark itself trusted
|
|
69
90
|
* through project configuration alone — trust comes from global config or an
|
|
70
91
|
* interactive decision stored outside the repo. */
|
|
71
|
-
export type RepositoryTrust = "trusted" | "untrusted" | "unknown"
|
|
92
|
+
export type RepositoryTrust = "trusted" | "untrusted" | "unknown";
|
|
72
93
|
|
|
73
94
|
/** A declarative policy condition: matches capability/actor facts. Every field
|
|
74
95
|
* is optional; the rule matches when ALL specified fields match. A missing
|
|
75
96
|
* `when` (or `{ always: true }`) makes the rule universal. */
|
|
76
97
|
export interface PolicyCondition {
|
|
77
98
|
/** 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[]
|
|
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[];
|
|
95
116
|
}
|
|
96
117
|
|
|
97
118
|
/** A declarative rule that routes a request based on capability+actor facts.
|
|
98
119
|
* `when` is optional: omitting it (or `{ always: true }`) matches every
|
|
99
120
|
* request. An explicitly empty `when: {}` is rejected at load. */
|
|
100
121
|
export interface PolicyRule {
|
|
101
|
-
id: string
|
|
102
|
-
source: "builtin" | "global" | "project" | "inline"
|
|
103
|
-
when?: PolicyCondition
|
|
104
|
-
effect: "review" | "manual" | "deny" | "allow"
|
|
105
|
-
reason: string
|
|
122
|
+
id: string;
|
|
123
|
+
source: "builtin" | "global" | "project" | "inline";
|
|
124
|
+
when?: PolicyCondition;
|
|
125
|
+
effect: "review" | "manual" | "deny" | "allow";
|
|
126
|
+
reason: string;
|
|
106
127
|
}
|
|
107
128
|
|
|
108
129
|
/** The result of evaluating the declarative policy. */
|
|
109
130
|
export interface PolicyTrace {
|
|
110
131
|
/** Stable hash of the effective rule set (not the matched rules) for audit
|
|
111
132
|
* reproducibility. */
|
|
112
|
-
effectivePolicyHash: string
|
|
113
|
-
matchedRules: Array<{
|
|
133
|
+
effectivePolicyHash: string;
|
|
134
|
+
matchedRules: Array<{
|
|
135
|
+
id: string;
|
|
136
|
+
source: string;
|
|
137
|
+
effect: string;
|
|
138
|
+
reason: string;
|
|
139
|
+
}>;
|
|
114
140
|
/** The route the engine computed (counterfactual in observe mode: what enforce
|
|
115
141
|
* mode WOULD have done with the same facts and rules). */
|
|
116
|
-
finalRoute: "review" | "manual" | "deny" | "allow"
|
|
117
|
-
mode: "observe" | "enforce"
|
|
142
|
+
finalRoute: "review" | "manual" | "deny" | "allow";
|
|
143
|
+
mode: "observe" | "enforce";
|
|
118
144
|
}
|
|
119
145
|
|
|
120
|
-
export type ReviewerOutputFormat = "json_schema" | "text"
|
|
146
|
+
export type ReviewerOutputFormat = "json_schema" | "text";
|
|
121
147
|
|
|
122
148
|
export interface EscalationReviewerConfig {
|
|
123
|
-
model: string
|
|
124
|
-
variant: string
|
|
125
|
-
outputFormat: ReviewerOutputFormat
|
|
126
|
-
timeoutMs: number
|
|
149
|
+
model: string;
|
|
150
|
+
variant: string;
|
|
151
|
+
outputFormat: ReviewerOutputFormat;
|
|
152
|
+
timeoutMs: number;
|
|
127
153
|
}
|
|
128
154
|
|
|
129
155
|
export interface ReviewerConfig {
|
|
130
|
-
model: string
|
|
131
|
-
variant: string
|
|
156
|
+
model: string;
|
|
157
|
+
variant: string;
|
|
132
158
|
/** How the reviewer model returns its decision. `json_schema` requests
|
|
133
159
|
* OpenCode's structured-output format (requires provider support); `text`
|
|
134
160
|
* asks the model to emit JSON in plain text and parses it locally. */
|
|
135
|
-
outputFormat: ReviewerOutputFormat
|
|
161
|
+
outputFormat: ReviewerOutputFormat;
|
|
136
162
|
/** Optional reasoning reviewer for valid System One decisions that remain
|
|
137
163
|
* uncertain or conflict with deterministic review gates. */
|
|
138
|
-
escalationReviewer?: EscalationReviewerConfig
|
|
164
|
+
escalationReviewer?: EscalationReviewerConfig;
|
|
139
165
|
/** Calibrated outcome-confidence floor for System One decisions. */
|
|
140
|
-
systemOneConfidenceThreshold: number
|
|
166
|
+
systemOneConfidenceThreshold: number;
|
|
141
167
|
/** Minimum combined non-escalate probability for routing an explicit
|
|
142
168
|
* System One escalation to the optional reasoning reviewer. */
|
|
143
|
-
systemOneReasoningThreshold: number
|
|
144
|
-
|
|
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;
|
|
145
175
|
/** 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
|
|
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;
|
|
160
190
|
/** When "observe", actor evidence is collected and audited but never enforces
|
|
161
191
|
* new gates; "enforce" applies declarative policy routes. */
|
|
162
|
-
enforcementMode: "observe" | "enforce"
|
|
192
|
+
enforcementMode: "observe" | "enforce";
|
|
163
193
|
/**
|
|
164
194
|
* How internal `escalate` results are disposed before UI/reply.
|
|
165
195
|
* - `manual` (default): leave the request for a human (interactive mode).
|
|
166
196
|
* - `deny`: convert every final escalation into a reject with rationale
|
|
167
197
|
* (non-interactive fail-closed). Never relaxes an explicit deny.
|
|
168
198
|
*/
|
|
169
|
-
escalationMode: EscalationMode
|
|
199
|
+
escalationMode: EscalationMode;
|
|
170
200
|
/** Max hops when walking session parents (default 8). */
|
|
171
|
-
maxSessionDepth: number
|
|
201
|
+
maxSessionDepth: number;
|
|
172
202
|
/** Max parent sessions fetched during lineage traversal. */
|
|
173
|
-
maxParentSessions: number
|
|
203
|
+
maxParentSessions: number;
|
|
174
204
|
/** Trusted name→profile mappings (empty by default; no mappings shipped). */
|
|
175
|
-
actorProfiles: Record<string, ActorProfile
|
|
205
|
+
actorProfiles: Record<string, ActorProfile>;
|
|
176
206
|
/** Deterministic risk×authorization gate, configurable but defaults reproduce
|
|
177
207
|
* the previous hard-coded matrix exactly. */
|
|
178
|
-
riskPolicy: RiskPolicy
|
|
208
|
+
riskPolicy: RiskPolicy;
|
|
179
209
|
/** Repository trust level derived from global config (never from project). */
|
|
180
|
-
repositoryTrust: RepositoryTrust
|
|
210
|
+
repositoryTrust: RepositoryTrust;
|
|
181
211
|
/** Declarative policy rules (empty by default; observe mode audits the trace
|
|
182
212
|
* without enforcing). Project-sourced allow rules are rejected. */
|
|
183
|
-
policyRules: PolicyRule[]
|
|
213
|
+
policyRules: PolicyRule[];
|
|
184
214
|
/** Capture user answers to agent ask dialogs (question tool) and surface
|
|
185
215
|
* them to the reviewer as scoped authorization evidence. */
|
|
186
|
-
askDecisions: boolean
|
|
216
|
+
askDecisions: boolean;
|
|
187
217
|
/** Non-empty when a TRUSTED config source (global file, inline options)
|
|
188
218
|
* existed but could not be fully honored (malformed file, unreadable file,
|
|
189
219
|
* or rules dropped by validation). Degraded configs block automatic
|
|
190
220
|
* approval: restrictions may have been lost, so requests escalate instead. */
|
|
191
|
-
configDegraded?: string[]
|
|
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[];
|
|
192
225
|
}
|
|
193
226
|
|
|
194
227
|
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
|
|
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;
|
|
204
237
|
/** Agent-aware context (actor, lineage, intent). Observe-only: flows into the
|
|
205
238
|
* reviewer prompt and audit as evidence, never into enforcement decisions.
|
|
206
239
|
* Optional so older callers/tests still compile. */
|
|
207
|
-
actor?: ActorContext
|
|
208
|
-
lineage?: SessionLineage
|
|
209
|
-
intent?: IntentContext
|
|
210
|
-
evidenceCompleteness?: EvidenceCompleteness
|
|
240
|
+
actor?: ActorContext;
|
|
241
|
+
lineage?: SessionLineage;
|
|
242
|
+
intent?: IntentContext;
|
|
243
|
+
evidenceCompleteness?: EvidenceCompleteness;
|
|
211
244
|
/** Structured capability facts derived from the bash command. Observe-only:
|
|
212
245
|
* feeds the reviewer prompt and audit, never enforcement. */
|
|
213
|
-
capability?: CapabilityAssessment
|
|
246
|
+
capability?: CapabilityAssessment;
|
|
214
247
|
/** The policy trace produced for this request, surfaced to the reviewer prompt
|
|
215
248
|
* as EFFECTIVE_POLICY_SUMMARY and to audit. Observe-only. */
|
|
216
|
-
policyTrace?: PolicyTrace
|
|
249
|
+
policyTrace?: PolicyTrace;
|
|
217
250
|
/** Per-phase timing captured during evidence assembly (context/enrichment).
|
|
218
251
|
* The reviewer and reply phases are timed in the coordinator. */
|
|
219
|
-
timings?: {
|
|
252
|
+
timings?: {
|
|
253
|
+
contextMs?: number;
|
|
254
|
+
enrichmentMs?: number;
|
|
255
|
+
reviewerMs?: number;
|
|
256
|
+
replyMs?: number;
|
|
257
|
+
};
|
|
220
258
|
/** False when a material part of the action under review (e.g. an elided
|
|
221
259
|
* command segment) never reached the rendered evidence. Blocking: the
|
|
222
260
|
* coordinator must not auto-approve an action the reviewer could not see
|
|
223
261
|
* in full, whatever confidence the model reports. */
|
|
224
|
-
actionEvidenceComplete?: boolean
|
|
262
|
+
actionEvidenceComplete?: boolean;
|
|
225
263
|
/** The parsed command reused across evidence providers. */
|
|
226
|
-
parsedCommand?: ParsedCommand
|
|
264
|
+
parsedCommand?: ParsedCommand;
|
|
227
265
|
/** Operational purpose of the pending action (evidence, never authorization). */
|
|
228
|
-
actionPurpose?: ActionPurpose
|
|
266
|
+
actionPurpose?: ActionPurpose;
|
|
229
267
|
/** User answers to agent ask dialogs in this session or its ancestors,
|
|
230
268
|
* captured live from question events. Observe-only: flows into the reviewer
|
|
231
269
|
* 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
|
|
270
|
+
askDecisions?: AskDecision[];
|
|
398
271
|
}
|
|
399
272
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
unauthorizedDataLoss: number
|
|
405
|
-
untrustedSensitiveDisclosure: number
|
|
406
|
-
excessiveCredentialAccess: number
|
|
407
|
-
unauthorizedSecurityChange: number
|
|
408
|
-
unauthorizedExternalMutation: number
|
|
409
|
-
essentialEvidenceMissing: number
|
|
410
|
-
absolutePolicyDeny: number
|
|
273
|
+
export interface ApprovedAnnotation {
|
|
274
|
+
requestID: string;
|
|
275
|
+
sessionID: string;
|
|
276
|
+
decision: ReviewDecision;
|
|
411
277
|
}
|
|
412
278
|
|
|
413
|
-
/**
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
429
|
-
signals: SystemOneSignals
|
|
430
|
-
/** Consistency checks that failed; any one marks an allow or deny difficult. */
|
|
431
|
-
contradictions: string[]
|
|
432
|
-
reasoningRecommended: boolean
|
|
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;
|
|
433
294
|
}
|
|
434
295
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
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";
|
|
440
302
|
|
|
441
303
|
export interface ReviewExecutionResult {
|
|
442
|
-
kind: "allow" | "deny" | "escalate"
|
|
443
|
-
decision?: ReviewDecision
|
|
444
|
-
reason: string
|
|
445
|
-
reviewSessionID?: string
|
|
304
|
+
kind: "allow" | "deny" | "escalate";
|
|
305
|
+
decision?: ReviewDecision;
|
|
306
|
+
reason: string;
|
|
307
|
+
reviewSessionID?: string;
|
|
446
308
|
/** Which layer produced this result; threaded into the audit record. */
|
|
447
|
-
decisionSource?: DecisionSource
|
|
309
|
+
decisionSource?: DecisionSource;
|
|
448
310
|
/** Actual model that produced the final reviewer decision. */
|
|
449
|
-
reviewerModel?: string
|
|
450
|
-
/** Primary model
|
|
451
|
-
|
|
311
|
+
reviewerModel?: string;
|
|
312
|
+
/** Primary model, routing reason and hand-off trigger when a second
|
|
313
|
+
* reviewer was used. */
|
|
314
|
+
reviewerEscalatedFrom?: EscalatedFrom;
|
|
452
315
|
/** Jev's scores whenever it returned a parsed decision. */
|
|
453
|
-
systemOne?: SystemOneScores
|
|
316
|
+
systemOne?: SystemOneScores;
|
|
454
317
|
/**
|
|
455
318
|
* Structured outcome from the reviewer LLM before gates/disposition.
|
|
456
319
|
* Absent when no valid structured decision was produced.
|
|
457
320
|
*/
|
|
458
|
-
reviewerOutcome?: ReviewOutcome
|
|
321
|
+
reviewerOutcome?: ReviewOutcome;
|
|
459
322
|
/**
|
|
460
323
|
* How an internal escalate was disposed at the enforcement boundary.
|
|
461
324
|
* Absent when the result was never an escalate (explicit allow/deny) or when
|
|
462
325
|
* the request was already answered manually (`manual-superseded`).
|
|
463
326
|
*/
|
|
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[]
|
|
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;
|
|
496
331
|
}
|
|
497
332
|
|
|
498
333
|
/** Generic policy templates, NOT automatic trust levels. */
|
|
499
334
|
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
|
-
}
|
|
335
|
+
| "read-only"
|
|
336
|
+
| "validation"
|
|
337
|
+
| "workspace"
|
|
338
|
+
| "operator"
|
|
339
|
+
| "reviewer"
|
|
340
|
+
| "unknown";
|
|
673
341
|
|
|
674
342
|
/** High-level classification of what the action does. */
|
|
675
343
|
export type CapabilityActionClass =
|
|
@@ -686,62 +354,4 @@ export type CapabilityActionClass =
|
|
|
686
354
|
| "service-management"
|
|
687
355
|
| "persistence"
|
|
688
356
|
| "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
|
-
}
|
|
357
|
+
| "unknown";
|