@toddzheng024/dscode-bundle 0.7.17 → 0.7.19

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.7.17",
2
+ "version": "0.7.19",
3
3
  "type": "module",
4
4
  "license": "MIT",
5
5
  "author": "Todd Zheng",
@@ -94,6 +94,9 @@ export function apply(ctx, config) {
94
94
  announce(req.agent, `Automatic review rejected ${req.toolName}: ${decision.reason}. Do not retry the same outcome via another command or tool. Continue only with a materially safer alternative or ask the user.${state.blocked ? ' Stop this turn: three consecutive denials.' : ''}`);
95
95
  return 'rejected';
96
96
  }
97
+ // Only an explicit allow runs: `defer` and any future verdict value fall back
98
+ // to the human instead of being read as approval.
99
+ if (decision.decision !== 'allow') return fallback(decision.reason ?? 'Unrecognized review verdict.', details);
97
100
  state.denials = 0;
98
101
  return 'allowed-once';
99
102
  };
@@ -132,13 +135,18 @@ export function apply(ctx, config) {
132
135
  verdict = undefined;
133
136
  }
134
137
  if (verdict !== undefined) {
135
- return applyVerdict({ decision: verdict.decision, reason: verdict.reason }, {
138
+ const jevDetails = {
136
139
  actionHash, provider: 'openrouter', model: verdict.model, source: 'jev',
137
140
  choice: verdict.choice, confidence: verdict.confidence, denyProbability: verdict.denyProbability,
138
141
  authorized: verdict.authorized, destructive: verdict.destructive, credentialRisk: verdict.credentialRisk,
139
142
  durationMs: verdict.durationMs ?? (Date.now() - started),
140
143
  usage: verdict.usage ?? null, usageComplete: verdict.usage != null,
141
- });
144
+ };
145
+ // Jev hands its risk guards over when the instruction authorizes the work;
146
+ // the reviewer model below sees the pending arguments and decides, and its
147
+ // own `human` verdict still reaches the user.
148
+ if (verdict.decision !== 'defer') return applyVerdict({ decision: verdict.decision, reason: verdict.reason }, jevDetails);
149
+ record(req, { decision: 'deferred', reason: verdict.reason, ...jevDetails });
142
150
  }
143
151
  // A caller that cancelled must not fall through to a reviewer request.
144
152
  if (req.signal?.aborted) {
@@ -100,10 +100,18 @@ export function approvalVerdict(answers, thresholds = DEFAULT_THRESHOLDS) {
100
100
  }
101
101
 
102
102
  // Everything below guards the allow direction: high risk or a non-allowing
103
- // answer never runs without the human.
104
- if (credentialRisk >= thresholds.credentialRisk) return { decision: 'human', reason: 'Automatic review found possible credential handling.', ...detail };
105
- if (destructive >= thresholds.destructiveCeiling) return { decision: 'human', reason: 'Automatic review judged this action hard to undo.', ...detail };
106
- if (verdict.choice !== 'allow') return { decision: 'human', reason: 'Automatic review asked for a human decision.', ...detail };
107
- if (confidence < thresholds.autoAllow) return { decision: 'human', reason: `Automatic review was not confident enough (${confidence.toFixed(2)}).`, ...detail };
103
+ // answer must not run on Jev's word alone. None of these guards is a denial, so
104
+ // when the instruction itself authorizes the work they defer to the reviewer
105
+ // model, which sees the exact pending arguments and the retained instruction:
106
+ // Jev's scores are coarse, and this deployment already allows ordinary network
107
+ // access and a CLI's own stored credentials. A caller that does not know
108
+ // `defer` must treat it as "review me", never as an allow.
109
+ const guard = reason => authorized >= thresholds.authorizedVeto
110
+ ? { decision: 'defer', reason, ...detail }
111
+ : { decision: 'human', reason, ...detail };
112
+ if (credentialRisk >= thresholds.credentialRisk) return guard('Automatic review found possible credential handling.');
113
+ if (destructive >= thresholds.destructiveCeiling) return guard('Automatic review judged this action hard to undo.');
114
+ if (verdict.choice !== 'allow') return guard('Automatic review asked for a human decision.');
115
+ if (confidence < thresholds.autoAllow) return guard(`Automatic review was not confident enough (${confidence.toFixed(2)}).`);
108
116
  return { decision: 'allow', reason: 'Automatic review approved the action.', ...detail };
109
117
  }