dsh-auto-review 0.4.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 +91 -0
- package/LICENSE +201 -0
- package/README.es.md +226 -0
- package/README.hi.md +226 -0
- package/README.md +226 -0
- package/README.pt.md +226 -0
- package/README.zh.md +226 -0
- package/cordis.patch.yml +27 -0
- package/lib/client.js +494 -0
- package/lib/client.js.map +1 -0
- package/lib/events-CFl6CHZi.js +344 -0
- package/lib/index.js +5305 -0
- package/lib/invariant.js +223 -0
- package/lib/types/client/ReviewPanel.d.ts +29 -0
- package/lib/types/client/ReviewPanel.d.ts.map +1 -0
- package/lib/types/client/ReviewPanel.js +63 -0
- package/lib/types/client/ReviewPanel.js.map +1 -0
- package/lib/types/client/index.d.ts +31 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/index.js +51 -0
- package/lib/types/client/index.js.map +1 -0
- package/lib/types/client/locales.d.ts +49 -0
- package/lib/types/client/locales.d.ts.map +1 -0
- package/lib/types/client/locales.js +82 -0
- package/lib/types/client/locales.js.map +1 -0
- package/lib/types/client/present.d.ts +25 -0
- package/lib/types/client/present.d.ts.map +1 -0
- package/lib/types/client/present.js +36 -0
- package/lib/types/client/present.js.map +1 -0
- package/lib/types/client/styles.d.ts +9 -0
- package/lib/types/client/styles.d.ts.map +1 -0
- package/lib/types/client/styles.js +130 -0
- package/lib/types/client/styles.js.map +1 -0
- package/lib/types/config.d.ts +200 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/config.js +154 -0
- package/lib/types/config.js.map +1 -0
- package/lib/types/events.d.ts +347 -0
- package/lib/types/events.d.ts.map +1 -0
- package/lib/types/events.js +369 -0
- package/lib/types/events.js.map +1 -0
- package/lib/types/index.d.ts +26 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +26 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/invariant.d.ts +28 -0
- package/lib/types/invariant.d.ts.map +1 -0
- package/lib/types/invariant.js +306 -0
- package/lib/types/invariant.js.map +1 -0
- package/lib/types/messages.d.ts +38 -0
- package/lib/types/messages.d.ts.map +1 -0
- package/lib/types/messages.js +65 -0
- package/lib/types/messages.js.map +1 -0
- package/lib/types/projection-types.d.ts +61 -0
- package/lib/types/projection-types.d.ts.map +1 -0
- package/lib/types/projection-types.js +8 -0
- package/lib/types/projection-types.js.map +1 -0
- package/lib/types/projection.d.ts +93 -0
- package/lib/types/projection.d.ts.map +1 -0
- package/lib/types/projection.js +197 -0
- package/lib/types/projection.js.map +1 -0
- package/lib/types/review.d.ts +141 -0
- package/lib/types/review.d.ts.map +1 -0
- package/lib/types/review.js +389 -0
- package/lib/types/review.js.map +1 -0
- package/lib/types/runtime.d.ts +160 -0
- package/lib/types/runtime.d.ts.map +1 -0
- package/lib/types/runtime.js +486 -0
- package/lib/types/runtime.js.map +1 -0
- package/package.json +132 -0
- package/src/client/ReviewPanel.tsx +164 -0
- package/src/client/index.ts +72 -0
- package/src/client/locales.ts +87 -0
- package/src/client/present.ts +58 -0
- package/src/client/styles.ts +131 -0
- package/src/config.ts +346 -0
- package/src/events.ts +553 -0
- package/src/index.ts +28 -0
- package/src/invariant.ts +326 -0
- package/src/messages.ts +91 -0
- package/src/projection-types.ts +61 -0
- package/src/projection.ts +224 -0
- package/src/review.ts +428 -0
- package/src/runtime.ts +562 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable session vocabulary for `dsh-auto-review`: the `autoReview/state`
|
|
3
|
+
* per-session override, the `autoReview/verdict` audit event, and the pure
|
|
4
|
+
* folds that read them back from a session log.
|
|
5
|
+
*
|
|
6
|
+
* The model-visible ⟺ logged invariant holds by construction: the verdict is
|
|
7
|
+
* log-only (UI-auditable, never in the model transcript), and the only
|
|
8
|
+
* model-visible auto-review content is the deny reason injected into the
|
|
9
|
+
* denied call's `tool/result`, which carries the `reviewId` marker that links
|
|
10
|
+
* it back to this event.
|
|
11
|
+
* @module dsh-auto-review/events
|
|
12
|
+
*/
|
|
13
|
+
/** Closed {@link AutoReviewFallback} list for runtime normalization. */
|
|
14
|
+
export const AUTO_REVIEW_FALLBACKS = ['timeout', 'cancelled', 'unavailable', 'schema'];
|
|
15
|
+
/**
|
|
16
|
+
* Brand a string as an {@link AutoReviewVerdictId}.
|
|
17
|
+
* @param id - the raw id string.
|
|
18
|
+
* @returns the same string, branded (a compile-time cast — no runtime cost).
|
|
19
|
+
*/
|
|
20
|
+
export function AutoReviewVerdictId(id) {
|
|
21
|
+
return id;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Brand a string as an {@link AutoReviewCircuitId}.
|
|
25
|
+
* @param id - the raw id string.
|
|
26
|
+
* @returns the same string, branded (a compile-time cast — no runtime cost).
|
|
27
|
+
*/
|
|
28
|
+
export function AutoReviewCircuitId(id) {
|
|
29
|
+
return id;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Brand a string as an {@link AutoReviewRejectionId}.
|
|
33
|
+
* @param id - the raw id string.
|
|
34
|
+
* @returns the same string, branded (a compile-time cast — no runtime cost).
|
|
35
|
+
*/
|
|
36
|
+
export function AutoReviewRejectionId(id) {
|
|
37
|
+
return id;
|
|
38
|
+
}
|
|
39
|
+
/** Stable marker prefix inside every injected deny reason, parsed by the invariant companion. */
|
|
40
|
+
export const DENY_MARKER = '[auto-review]';
|
|
41
|
+
/** Regex extracting the reviewId from an injected deny reason. */
|
|
42
|
+
export const DENY_MARKER_PATTERN = /\[auto-review\] review ([^\s]+) denied/u;
|
|
43
|
+
/** Stable marker prefix inside every injected fallback rejection text (a distinct vocabulary from {@link DENY_MARKER}). */
|
|
44
|
+
export const FALLBACK_MARKER = '[auto-review-fallback]';
|
|
45
|
+
/** Regex extracting the reviewId from an injected fallback rejection. */
|
|
46
|
+
export const FALLBACK_MARKER_PATTERN = /\[auto-review-fallback\] review ([^\s]+) failed/u;
|
|
47
|
+
/** Stable marker prefix inside every injected circuit rejection text. */
|
|
48
|
+
export const CIRCUIT_MARKER = '[auto-review-circuit]';
|
|
49
|
+
/** Regex extracting the circuitId and tool name from an injected circuit rejection. */
|
|
50
|
+
export const CIRCUIT_MARKER_PATTERN = /\[auto-review-circuit\] circuit ([^\s]+) rejected tool "([^"]+)" before review/u;
|
|
51
|
+
/** Stable marker prefix inside every injected hard-disable (`never`) rejection text. */
|
|
52
|
+
export const NEVER_MARKER = '[auto-review-never]';
|
|
53
|
+
/** Regex extracting the rejectionId and tool name from an injected never rejection. */
|
|
54
|
+
export const NEVER_MARKER_PATTERN = /\[auto-review-never\] rejection ([^\s]+) hard-disabled tool "([^"]+)"/u;
|
|
55
|
+
/**
|
|
56
|
+
* Build the model-visible deny text injected into a denied tool result. The
|
|
57
|
+
* embedded reviewId is what makes the model-visible text reconstructable
|
|
58
|
+
* from the session log (model-visible ⟺ logged).
|
|
59
|
+
* @param reviewId - the verdict event's id.
|
|
60
|
+
* @param toolName - the denied tool.
|
|
61
|
+
* @param reason - the reviewer's reason (already truncated).
|
|
62
|
+
* @returns the exact error text shown to the model.
|
|
63
|
+
*/
|
|
64
|
+
export function denyResultText(reviewId, toolName, reason) {
|
|
65
|
+
return `Error: ${DENY_MARKER} review ${reviewId} denied tool "${toolName}": ${reason}`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Build the model-visible text injected into a tool result whose review
|
|
69
|
+
* failed and was rejected by the fallback policy. The embedded reviewId
|
|
70
|
+
* links it to the recorded fallback verdict (model-visible ⟺ logged).
|
|
71
|
+
* @param reviewId - the fallback verdict event's id.
|
|
72
|
+
* @param fallback - the failure category (timeout/unavailable/schema).
|
|
73
|
+
* @param error - the failure detail (already truncated upstream).
|
|
74
|
+
* @returns the exact error text shown to the model.
|
|
75
|
+
*/
|
|
76
|
+
export function fallbackResultText(reviewId, fallback, error) {
|
|
77
|
+
return `Error: ${FALLBACK_MARKER} review ${reviewId} failed (${fallback}) and the request was rejected: ${error}`;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Build the model-visible text injected into a tool result rejected by a
|
|
81
|
+
* tripped circuit breaker. The embedded circuitId links it to the recorded
|
|
82
|
+
* `autoReview/circuit` event (model-visible ⟺ logged).
|
|
83
|
+
* @param circuitId - the circuit event's id.
|
|
84
|
+
* @param toolName - the rejected tool.
|
|
85
|
+
* @param explanation - why the breaker rejects (trip kind and count).
|
|
86
|
+
* @returns the exact error text shown to the model.
|
|
87
|
+
*/
|
|
88
|
+
export function circuitResultText(circuitId, toolName, explanation) {
|
|
89
|
+
return `Error: ${CIRCUIT_MARKER} circuit ${circuitId} rejected tool "${toolName}" before review: ${explanation}`;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Build the model-visible text injected into a tool result rejected by a
|
|
93
|
+
* `never` policy (a hard disable: risk rule or tool-policy table entry). The
|
|
94
|
+
* embedded rejectionId links it to the recorded `autoReview/rejection` event
|
|
95
|
+
* (model-visible ⟺ logged).
|
|
96
|
+
* @param rejectionId - the rejection event's id.
|
|
97
|
+
* @param toolName - the hard-disabled tool.
|
|
98
|
+
* @param source - which rule or policy entry disabled it.
|
|
99
|
+
* @returns the exact error text shown to the model.
|
|
100
|
+
*/
|
|
101
|
+
export function neverResultText(rejectionId, toolName, source) {
|
|
102
|
+
return `Error: ${NEVER_MARKER} rejection ${rejectionId} hard-disabled tool "${toolName}": ${source}`;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The session's auto-review override: the last `autoReview/state` event, or
|
|
106
|
+
* `undefined` when the session never switched (callers apply the configured
|
|
107
|
+
* `enableByDefault`). The pure fold — replay IS the state.
|
|
108
|
+
* @param events - session events in log order (other types are skipped).
|
|
109
|
+
* @returns the enabled flag of the last switch, or undefined without one.
|
|
110
|
+
*/
|
|
111
|
+
export function effectiveAutoReviewState(events) {
|
|
112
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
113
|
+
const event = events[index];
|
|
114
|
+
if (event.type === 'autoReview/state')
|
|
115
|
+
return event.data.enabled;
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The verdict events inside the session's CURRENT open turn, oldest first.
|
|
121
|
+
* A turn without `turn/start` (or one already closed by `turn/end`) yields
|
|
122
|
+
* an empty list.
|
|
123
|
+
* @param events - session events in log order.
|
|
124
|
+
* @returns the open turn's verdict payloads.
|
|
125
|
+
*/
|
|
126
|
+
export function openTurnVerdicts(events) {
|
|
127
|
+
let openSeq = -1;
|
|
128
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
129
|
+
const type = events[index].type;
|
|
130
|
+
if (type === 'turn/end')
|
|
131
|
+
return [];
|
|
132
|
+
if (type === 'turn/start') {
|
|
133
|
+
openSeq = events[index].seq;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (openSeq < 0)
|
|
138
|
+
return [];
|
|
139
|
+
const verdicts = [];
|
|
140
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
141
|
+
const event = events[index];
|
|
142
|
+
if (event.seq <= openSeq)
|
|
143
|
+
break;
|
|
144
|
+
if (event.type === 'autoReview/verdict')
|
|
145
|
+
verdicts.push(event.data);
|
|
146
|
+
}
|
|
147
|
+
verdicts.reverse();
|
|
148
|
+
return verdicts;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* How many REAL AI verdicts the session's CURRENT open turn has consumed.
|
|
152
|
+
* Fallback verdicts do not count: they are budgeted separately by
|
|
153
|
+
* {@link autoReviewFailuresInOpenTurn}, so a failing reviewer does not eat
|
|
154
|
+
* the AI-decision budget. A turn without `turn/start` (or one already closed
|
|
155
|
+
* by `turn/end`) counts zero.
|
|
156
|
+
* @param events - session events in log order.
|
|
157
|
+
* @returns the decision-carrying verdict count inside the current open turn.
|
|
158
|
+
*/
|
|
159
|
+
export function autoReviewsInOpenTurn(events) {
|
|
160
|
+
return openTurnVerdicts(events).filter(data => data.decision !== undefined).length;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* How many reviewer FAILURES the session's CURRENT open turn has consumed —
|
|
164
|
+
* `autoReview/verdict` events carrying a fallback other than `cancelled`
|
|
165
|
+
* (a user withdrawal is not a reviewer failure). The answerer delegates once
|
|
166
|
+
* the budget is exhausted so a broken reviewer costs one timeout instead of
|
|
167
|
+
* `maxFailuresPerTurn` of them.
|
|
168
|
+
* @param events - session events in log order.
|
|
169
|
+
* @returns the failure count inside the current open turn.
|
|
170
|
+
*/
|
|
171
|
+
export function autoReviewFailuresInOpenTurn(events) {
|
|
172
|
+
return openTurnVerdicts(events).filter(data => data.fallback !== undefined && data.fallback !== 'cancelled').length;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Whether a verdict is a denial of the request: a reviewer deny, or an allow
|
|
176
|
+
* overridden by the risk policy (`escalation: 'risk-policy'` with the deny
|
|
177
|
+
* outcome). The circuit breaker and the approve list count both.
|
|
178
|
+
* @param data - the verdict payload.
|
|
179
|
+
* @returns true when the request was denied.
|
|
180
|
+
*/
|
|
181
|
+
export function isDenial(data) {
|
|
182
|
+
return data.decision === 'deny' || data.escalation === 'risk-policy';
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The trailing run of consecutive denials in the current open turn —
|
|
186
|
+
* the circuit breaker's `consecutiveDenies` signal.
|
|
187
|
+
* @param events - session events in log order.
|
|
188
|
+
* @returns the length of the trailing denial run.
|
|
189
|
+
*/
|
|
190
|
+
export function consecutiveDeniesInOpenTurn(events) {
|
|
191
|
+
const verdicts = openTurnVerdicts(events);
|
|
192
|
+
let count = 0;
|
|
193
|
+
for (let index = verdicts.length - 1; index >= 0; index -= 1) {
|
|
194
|
+
if (!isDenial(verdicts[index]))
|
|
195
|
+
break;
|
|
196
|
+
count += 1;
|
|
197
|
+
}
|
|
198
|
+
return count;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* How many of the last {@link windowSize} decision verdicts in the current
|
|
202
|
+
* open turn are denials — the circuit breaker's `windowDenies` signal.
|
|
203
|
+
* @param events - session events in log order.
|
|
204
|
+
* @param windowSize - how many recent verdicts the window counts.
|
|
205
|
+
* @returns the denial count inside the window.
|
|
206
|
+
*/
|
|
207
|
+
export function deniesInRecentVerdicts(events, windowSize) {
|
|
208
|
+
const decisions = openTurnVerdicts(events).filter(data => data.decision !== undefined);
|
|
209
|
+
return decisions.slice(-windowSize).filter(data => isDenial(data)).length;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The current open turn's circuit trip, when one was recorded.
|
|
213
|
+
* @param events - session events in log order.
|
|
214
|
+
* @returns the last `autoReview/circuit` payload in the open turn, or undefined.
|
|
215
|
+
*/
|
|
216
|
+
export function circuitInOpenTurn(events) {
|
|
217
|
+
let openSeq = -1;
|
|
218
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
219
|
+
const type = events[index].type;
|
|
220
|
+
if (type === 'turn/end')
|
|
221
|
+
return undefined;
|
|
222
|
+
if (type === 'turn/start') {
|
|
223
|
+
openSeq = events[index].seq;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (openSeq < 0)
|
|
228
|
+
return undefined;
|
|
229
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
230
|
+
const event = events[index];
|
|
231
|
+
if (event.seq <= openSeq)
|
|
232
|
+
break;
|
|
233
|
+
if (event.type === 'autoReview/circuit')
|
|
234
|
+
return event.data;
|
|
235
|
+
}
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* The most recent deny verdicts, newest first — the `/auto-review approve`
|
|
240
|
+
* candidate list.
|
|
241
|
+
* @param events - session events in log order.
|
|
242
|
+
* @param limit - how many to collect.
|
|
243
|
+
* @returns up to {@link limit} deny verdicts, newest first.
|
|
244
|
+
*/
|
|
245
|
+
export function lastDeniedVerdicts(events, limit) {
|
|
246
|
+
const result = [];
|
|
247
|
+
for (let index = events.length - 1; index >= 0 && result.length < limit; index -= 1) {
|
|
248
|
+
const event = events[index];
|
|
249
|
+
if (event.type !== 'autoReview/verdict' || !isDenial(event.data))
|
|
250
|
+
continue;
|
|
251
|
+
const data = event.data;
|
|
252
|
+
result.push({
|
|
253
|
+
reviewId: data.reviewId,
|
|
254
|
+
toolName: data.toolName,
|
|
255
|
+
...data.reason !== undefined ? { reason: data.reason } : {},
|
|
256
|
+
...data.riskLevel !== undefined ? { riskLevel: data.riskLevel } : {},
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
return result;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Whether a human one-shot override is pending for a tool: the latest
|
|
263
|
+
* `autoReview/override` for the tool is still unconsumed (no verdict for the
|
|
264
|
+
* tool after it) and unexpired. An override is consumed by the NEXT
|
|
265
|
+
* same-tool review regardless of its decision — single-use by construction.
|
|
266
|
+
* @param events - session events in log order.
|
|
267
|
+
* @param toolName - the tool an approval request is about.
|
|
268
|
+
* @param ttlMs - the override lifetime.
|
|
269
|
+
* @param now - the current epoch milliseconds.
|
|
270
|
+
* @returns the overridden deny verdict's id, or undefined without a pending override.
|
|
271
|
+
*/
|
|
272
|
+
export function activeOverride(events, toolName, ttlMs, now) {
|
|
273
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
274
|
+
const event = events[index];
|
|
275
|
+
if (event.type === 'autoReview/verdict' && event.data.toolName === toolName)
|
|
276
|
+
return undefined;
|
|
277
|
+
if (event.type === 'autoReview/override' && event.data.toolName === toolName) {
|
|
278
|
+
return now - event.time <= ttlMs ? event.data.reviewId : undefined;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return undefined;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Fold one session's review statistics: verdict counts, never-rejection
|
|
285
|
+
* count, mean duration, and the three most recent verdicts.
|
|
286
|
+
* @param events - session events in log order.
|
|
287
|
+
* @returns the statistics.
|
|
288
|
+
*/
|
|
289
|
+
export function reviewStats(events) {
|
|
290
|
+
let allows = 0;
|
|
291
|
+
let denies = 0;
|
|
292
|
+
let fallbacks = 0;
|
|
293
|
+
let rejections = 0;
|
|
294
|
+
let decided = 0;
|
|
295
|
+
let durationSum = 0;
|
|
296
|
+
for (const event of events) {
|
|
297
|
+
if (event.type === 'autoReview/rejection') {
|
|
298
|
+
rejections += 1;
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
if (event.type !== 'autoReview/verdict')
|
|
302
|
+
continue;
|
|
303
|
+
const data = event.data;
|
|
304
|
+
if (data.decision === 'allow')
|
|
305
|
+
allows += 1;
|
|
306
|
+
else if (data.decision === 'deny')
|
|
307
|
+
denies += 1;
|
|
308
|
+
else
|
|
309
|
+
fallbacks += 1;
|
|
310
|
+
if (data.decision !== undefined) {
|
|
311
|
+
decided += 1;
|
|
312
|
+
durationSum += data.durationMs;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
const recent = [];
|
|
316
|
+
for (let index = events.length - 1; index >= 0 && recent.length < 3; index -= 1) {
|
|
317
|
+
const event = events[index];
|
|
318
|
+
if (event.type === 'autoReview/verdict')
|
|
319
|
+
recent.push(event.data);
|
|
320
|
+
}
|
|
321
|
+
return { allows, denies, fallbacks, rejections, avgDurationMs: decided === 0 ? 0 : Math.round(durationSum / decided), recent };
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Correlate a pending approval request with the `approval/asked` event the
|
|
325
|
+
* service just appended. The service appends the asked event synchronously
|
|
326
|
+
* before waterfall dispatch, so the matching event is the last unpaired
|
|
327
|
+
* asked event whose call id (or, without one, tool name) matches the request.
|
|
328
|
+
* @param events - session events in log order.
|
|
329
|
+
* @param toolName - the request's tool name.
|
|
330
|
+
* @param callId - the request's call id, when present.
|
|
331
|
+
* @returns the asked event's approval id, or undefined when the chain is broken.
|
|
332
|
+
*/
|
|
333
|
+
export function correlateApprovalId(events, toolName, callId) {
|
|
334
|
+
const decided = new Set();
|
|
335
|
+
let candidate;
|
|
336
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
337
|
+
const event = events[index];
|
|
338
|
+
if (event.type === 'approval/decided') {
|
|
339
|
+
decided.add(event.data.id);
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (event.type !== 'approval/asked')
|
|
343
|
+
continue;
|
|
344
|
+
const asked = event.data;
|
|
345
|
+
if (decided.has(asked.id))
|
|
346
|
+
continue;
|
|
347
|
+
if (callId !== undefined ? asked.callId === callId : asked.toolName === toolName) {
|
|
348
|
+
candidate = asked.id;
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return candidate;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Find the already-presented tool call the approval request refers to — the
|
|
356
|
+
* `tool/call` event whose arguments the model produced and the UI streamed.
|
|
357
|
+
* @param events - session events in log order.
|
|
358
|
+
* @param callId - the exact call to find.
|
|
359
|
+
* @returns the call's raw arguments JSON string, or undefined without one.
|
|
360
|
+
*/
|
|
361
|
+
export function findPresentedCall(events, callId) {
|
|
362
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
363
|
+
const event = events[index];
|
|
364
|
+
if (event.type === 'tool/call' && event.data.callId === callId)
|
|
365
|
+
return event.data.arguments;
|
|
366
|
+
}
|
|
367
|
+
return undefined;
|
|
368
|
+
}
|
|
369
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA2IH,wEAAwE;AACxE,MAAM,CAAC,MAAM,qBAAqB,GAAkC,CAAC,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAA;AAWrH;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAAU;IAC5C,OAAO,EAAyB,CAAA;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C,IAAI,KAAK,gBAAgB;YAAE,SAAQ;QAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAA;QACxB,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAAE,SAAQ;QACnC,IAAI,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjF,SAAS,GAAG,KAAK,CAAC,EAAE,CAAA;YACpB,MAAK;QACP,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA+B,EAAE,MAAc;IAC/E,KAAK,IAAI,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC3D,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAiB,CAAA;QAC3C,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,MAAM;YAAE,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAA;IAC7F,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dsh-auto-review` — second-model AI auto-review for DeepSeek Harness
|
|
3
|
+
* approval requests. Registers an answerer on the `approval/request`
|
|
4
|
+
* waterfall that, when a session has auto-review enabled and the configured
|
|
5
|
+
* tool/risk policy says `ai`, runs a read-only one-shot reviewer subagent
|
|
6
|
+
* (`toolFilter` allow-list, structured verdict schema) and settles the
|
|
7
|
+
* request from its verdict; every other request delegates via `next()` to
|
|
8
|
+
* the human answerer chain. Failures fall back per `fallbackPolicy` (default
|
|
9
|
+
* fail-closed `rejected`).
|
|
10
|
+
*
|
|
11
|
+
* Function plugin — no default export (the Loader unwraps
|
|
12
|
+
* `exports.default ?? exports`, and a stray default would discard
|
|
13
|
+
* `name`/`inject`/`Config`/`apply`).
|
|
14
|
+
* @module dsh-auto-review
|
|
15
|
+
*/
|
|
16
|
+
import { apply } from './runtime.ts';
|
|
17
|
+
export declare const name = "auto-review";
|
|
18
|
+
export declare const inject: string[];
|
|
19
|
+
export { apply };
|
|
20
|
+
export { AutoReviewRuntime } from './runtime.ts';
|
|
21
|
+
export * from './config.ts';
|
|
22
|
+
export * from './events.ts';
|
|
23
|
+
export * from './review.ts';
|
|
24
|
+
export * from './projection.ts';
|
|
25
|
+
export * from './projection-types.ts';
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEpC,eAAO,MAAM,IAAI,gBAAgB,CAAA;AACjC,eAAO,MAAM,MAAM,UAAiD,CAAA;AAEpE,OAAO,EAAE,KAAK,EAAE,CAAA;AAChB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dsh-auto-review` — second-model AI auto-review for DeepSeek Harness
|
|
3
|
+
* approval requests. Registers an answerer on the `approval/request`
|
|
4
|
+
* waterfall that, when a session has auto-review enabled and the configured
|
|
5
|
+
* tool/risk policy says `ai`, runs a read-only one-shot reviewer subagent
|
|
6
|
+
* (`toolFilter` allow-list, structured verdict schema) and settles the
|
|
7
|
+
* request from its verdict; every other request delegates via `next()` to
|
|
8
|
+
* the human answerer chain. Failures fall back per `fallbackPolicy` (default
|
|
9
|
+
* fail-closed `rejected`).
|
|
10
|
+
*
|
|
11
|
+
* Function plugin — no default export (the Loader unwraps
|
|
12
|
+
* `exports.default ?? exports`, and a stray default would discard
|
|
13
|
+
* `name`/`inject`/`Config`/`apply`).
|
|
14
|
+
* @module dsh-auto-review
|
|
15
|
+
*/
|
|
16
|
+
import { apply } from "./runtime.js";
|
|
17
|
+
export const name = 'auto-review';
|
|
18
|
+
export const inject = ['approval', 'subagents', 'commands', 'tools'];
|
|
19
|
+
export { apply };
|
|
20
|
+
export { AutoReviewRuntime } from "./runtime.js";
|
|
21
|
+
export * from "./config.js";
|
|
22
|
+
export * from "./events.js";
|
|
23
|
+
export * from "./review.js";
|
|
24
|
+
export * from "./projection.js";
|
|
25
|
+
export * from "./projection-types.js";
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEpC,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAA;AACjC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;AAEpE,OAAO,EAAE,KAAK,EAAE,CAAA;AAChB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-owned invariant companion for `dsh-auto-review`:
|
|
3
|
+
*
|
|
4
|
+
* 1. Every `autoReview/verdict` audit event references an `approval/asked`
|
|
5
|
+
* event that precedes it in the same session, at most one verdict exists
|
|
6
|
+
* per asked event, and payload fields obey the closed vocabularies
|
|
7
|
+
* (decision/reason/riskLevel/outcome/fallback). The same chain holds for
|
|
8
|
+
* `autoReview/rejection` events (hard-disable rejections).
|
|
9
|
+
* 2. Model-visible ⟺ logged: every `tool/result` carrying the deny marker
|
|
10
|
+
* links to a recorded `deny` verdict with a matching call id, every
|
|
11
|
+
* `tool/result` carrying the fallback marker links to a recorded fallback
|
|
12
|
+
* verdict that was rejected, and every `tool/result` carrying the never
|
|
13
|
+
* marker links to a recorded rejection that settled rejected.
|
|
14
|
+
*
|
|
15
|
+
* @module dsh-auto-review/invariant
|
|
16
|
+
*/
|
|
17
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
18
|
+
/** Cordis companion plugin name. */
|
|
19
|
+
export declare const name = "auto-review-invariant";
|
|
20
|
+
/** Service required before the companion can reserve package ownership. */
|
|
21
|
+
export declare const inject: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Register this package's invariant companion.
|
|
24
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
25
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
26
|
+
*/
|
|
27
|
+
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
28
|
+
//# sourceMappingURL=invariant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invariant.d.ts","sourceRoot":"","sources":["../../src/invariant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAOlD,oCAAoC;AACpC,eAAO,MAAM,IAAI,0BAA0B,CAAA;AAC3C,2EAA2E;AAC3E,eAAO,MAAM,MAAM,UAAiB,CAAA;AAoSpC;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,KAAK,OAAO,KAAG,OAAO,CAAC,MAAM,IAAI,CACU,CAAA"}
|