@gaunt-sloth/core 2.0.0-beta.1 → 2.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/LICENSE +6 -6
  2. package/dist/config/loader.d.ts +13 -0
  3. package/dist/config/loader.js +55 -11
  4. package/dist/config/loader.js.map +1 -1
  5. package/dist/config/schema.d.ts +10 -0
  6. package/dist/config/schema.js +46 -24
  7. package/dist/config/schema.js.map +1 -1
  8. package/dist/config/shell-policy.d.ts +142 -1
  9. package/dist/config/shell-policy.js +114 -7
  10. package/dist/config/shell-policy.js.map +1 -1
  11. package/dist/config/types.d.ts +19 -0
  12. package/dist/config/types.js.map +1 -1
  13. package/dist/constants.d.ts +10 -0
  14. package/dist/constants.js +10 -0
  15. package/dist/constants.js.map +1 -1
  16. package/dist/core/GthAbstractAgent.d.ts +31 -0
  17. package/dist/core/GthAbstractAgent.js +159 -4
  18. package/dist/core/GthAbstractAgent.js.map +1 -1
  19. package/dist/core/GthAgentRunner.d.ts +314 -18
  20. package/dist/core/GthAgentRunner.js +1032 -101
  21. package/dist/core/GthAgentRunner.js.map +1 -1
  22. package/dist/core/approvals/approvalRequest.d.ts +247 -0
  23. package/dist/core/approvals/approvalRequest.js +315 -0
  24. package/dist/core/approvals/approvalRequest.js.map +1 -0
  25. package/dist/core/approvals/grants.d.ts +165 -9
  26. package/dist/core/approvals/grants.js +702 -57
  27. package/dist/core/approvals/grants.js.map +1 -1
  28. package/dist/core/plainToolIndication.d.ts +11 -1
  29. package/dist/core/plainToolIndication.js +25 -10
  30. package/dist/core/plainToolIndication.js.map +1 -1
  31. package/dist/core/shell/abstention.d.ts +1 -1
  32. package/dist/core/shell/abstention.js +65 -11
  33. package/dist/core/shell/abstention.js.map +1 -1
  34. package/dist/core/shell/alignment.d.ts +491 -0
  35. package/dist/core/shell/alignment.js +687 -0
  36. package/dist/core/shell/alignment.js.map +1 -0
  37. package/dist/core/shell/approvalCapture.d.ts +53 -41
  38. package/dist/core/shell/approvalCapture.js +0 -42
  39. package/dist/core/shell/approvalCapture.js.map +1 -1
  40. package/dist/core/shell/approvalStop.d.ts +121 -3
  41. package/dist/core/shell/approvalStop.js +153 -90
  42. package/dist/core/shell/approvalStop.js.map +1 -1
  43. package/dist/core/shell/hardline.d.ts +26 -4
  44. package/dist/core/shell/hardline.js +321 -16
  45. package/dist/core/shell/hardline.js.map +1 -1
  46. package/dist/core/shell/negotiation.d.ts +352 -63
  47. package/dist/core/shell/negotiation.js +295 -123
  48. package/dist/core/shell/negotiation.js.map +1 -1
  49. package/dist/core/shell/openWorld.d.ts +135 -0
  50. package/dist/core/shell/openWorld.js +572 -35
  51. package/dist/core/shell/openWorld.js.map +1 -1
  52. package/dist/core/shell/provenance.d.ts +91 -0
  53. package/dist/core/shell/provenance.js +136 -0
  54. package/dist/core/shell/provenance.js.map +1 -0
  55. package/dist/core/shell/rater.d.ts +394 -163
  56. package/dist/core/shell/rater.js +536 -238
  57. package/dist/core/shell/rater.js.map +1 -1
  58. package/dist/core/shell/raterHealth.d.ts +101 -0
  59. package/dist/core/shell/raterHealth.js +121 -0
  60. package/dist/core/shell/raterHealth.js.map +1 -0
  61. package/dist/core/shell/raterModel.d.ts +17 -8
  62. package/dist/core/shell/raterModel.js +11 -8
  63. package/dist/core/shell/raterModel.js.map +1 -1
  64. package/dist/core/shell/rejection.d.ts +20 -5
  65. package/dist/core/shell/rejection.js +18 -4
  66. package/dist/core/shell/rejection.js.map +1 -1
  67. package/dist/core/toolDisplay.d.ts +42 -0
  68. package/dist/core/toolDisplay.js +31 -0
  69. package/dist/core/toolDisplay.js.map +1 -1
  70. package/dist/core/types.d.ts +134 -16
  71. package/dist/core/types.js.map +1 -1
  72. package/dist/providers/configurationPassthrough.d.ts +36 -6
  73. package/dist/providers/configurationPassthrough.js +40 -28
  74. package/dist/providers/configurationPassthrough.js.map +1 -1
  75. package/dist/providers/openrouter.js +36 -6
  76. package/dist/providers/openrouter.js.map +1 -1
  77. package/dist/providers/vertexai.js +21 -0
  78. package/dist/providers/vertexai.js.map +1 -1
  79. package/dist/utils/binaryOutputUtils.js +103 -21
  80. package/dist/utils/binaryOutputUtils.js.map +1 -1
  81. package/dist/utils/fileUtils.d.ts +7 -1
  82. package/dist/utils/fileUtils.js +17 -3
  83. package/dist/utils/fileUtils.js.map +1 -1
  84. package/dist/utils/globalConfigUtils.d.ts +5 -2
  85. package/dist/utils/globalConfigUtils.js +14 -3
  86. package/dist/utils/globalConfigUtils.js.map +1 -1
  87. package/dist/utils/vertexaiUtils.js +61 -3
  88. package/dist/utils/vertexaiUtils.js.map +1 -1
  89. package/package.json +4 -4
  90. package/schema/gsloth-config.schema.json +34 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alignment.js","sourceRoot":"","sources":["../../../src/core/shell/alignment.ts"],"names":[],"mappings":"AAmFA,OAAO,EACL,SAAS,EAET,YAAY,EACZ,aAAa,EACb,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAGzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACL,aAAa,EACb,YAAY,EACZ,OAAO,EACP,6BAA6B,EAC7B,kCAAkC,EAClC,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEnE,mGAAmG;AACnG,MAAM,CAAC,MAAM,mBAAmB,GAAG,6BAA6B,CAAC;AACjE,0EAA0E;AAC1E,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AACvD,6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,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
@@ -47,8 +47,9 @@
47
47
  import type { ApprovalRung } from '#src/config.js';
48
48
  import type { ToolApprovalScope } from '#src/core/types.js';
49
49
  import type { AbstentionDefect } from '#src/core/shell/abstention.js';
50
+ import type { AlignmentCallCapture } from '#src/core/shell/alignment.js';
50
51
  import type { NegotiationCounters } from '#src/core/shell/negotiation.js';
51
- import type { FailClosedCause, PreflightFloorKind, RaterNegotiationContext, RaterNegotiationRound, ShellSafetyVerdict } from '#src/core/shell/rater.js';
52
+ import type { FailClosedCause, PreflightFloorKind, RaterCallFailure, ShellSafetyVerdict } from '#src/core/shell/rater.js';
52
53
  /**
53
54
  * How many gated decisions one session keeps. A ring buffer for the same reason the debug-log one
54
55
  * is: each record carries a full rating prompt (a few KB), and a long `auto` session makes a lot of
@@ -86,34 +87,6 @@ export type ApprovalDecidingStage = 'not-gated' | 'deny-list' | 'bypass' | 'hard
86
87
  export type ApprovalCaptureAction = 'approve' | 'reject' | 'escalate' | 'halt' | 'error';
87
88
  /** How an escalation ended once it reached (or failed to reach) a person. */
88
89
  export type ApprovalHumanAnswer = 'approve' | 'reject' | 'no-human';
89
- /**
90
- * §5.1's negotiation context **as it was handed to the prompt builder**, plus the one distinction a
91
- * reader of the archive keeps needing and could never make.
92
- *
93
- * **`userMessagesPopulated` is the field the node exists for.** Round 1 is context-free *by design*
94
- * (§5.1: *"round 1 sees the command alone"*), so an empty window is not a bug — and a reader with no
95
- * access to the source cannot know that. {@link userMessagesNote} states which case this is in
96
- * words, so the answer to *"were the user's messages in view on round N?"* is one field and one
97
- * sentence rather than a source-reading exercise across three files.
98
- */
99
- export interface RaterNegotiationCapture {
100
- /** 1-based index of this rating within the current negotiation. */
101
- round: number;
102
- /** Whether this rating was a round-1 (context-free) rating. */
103
- roundOne: boolean;
104
- /** Whether a §5.1 context was supplied at all (it is not, at a rung that does not negotiate). */
105
- contextSupplied: boolean;
106
- /** The justification admitted into THIS rating. Withheld at round 1 by `contextFor`, by design. */
107
- justification?: string;
108
- /** `<negotiation_so_far>` as handed over: the completed rounds, oldest first. */
109
- priorRounds: RaterNegotiationRound[];
110
- /** `<user_messages>` as handed over, oldest first, before the builder's last-5 + truncation. */
111
- userMessages: string[];
112
- /** Whether that window carried anything. THE distinction this facility turns on. */
113
- userMessagesPopulated: boolean;
114
- /** Why the window looks the way it does, in words, for a reader who has never seen the spec. */
115
- userMessagesNote: string;
116
- }
117
90
  /**
118
91
  * One rating call: what the rater was SHOWN and what it ANSWERED, captured at the send site.
119
92
  *
@@ -133,19 +106,31 @@ export interface RaterCallCapture {
133
106
  timeoutMs: number;
134
107
  /** §5.2 — whether a rejection would be handed back to the AGENT rather than to a person. */
135
108
  negotiable: boolean;
136
- /** **The exact strings sent.** Captured, never re-rendered. */
109
+ /**
110
+ * **The exact strings sent.** Captured, never re-rendered.
111
+ *
112
+ * [[EXT-127]] — and there is no longer a negotiation record beside them, because there is no
113
+ * longer a negotiation in this call: the classifier is handed one command and nothing else, so
114
+ * *"were the user's messages in view for this rating?"* has one answer at every round, and it is
115
+ * no. That question moved with the context it was about, to {@link AlignmentCallCapture}.
116
+ */
137
117
  prompt: {
138
118
  system: string;
139
119
  user: string;
140
120
  };
141
- /** What the negotiation looked like at the moment of this call. */
142
- negotiation: RaterNegotiationCapture;
143
121
  /** The model's answer BEFORE it is parsed or mapped, so a malformed one stays visible. */
144
122
  rawResponse?: unknown;
145
123
  /** The verdict this call resolved to, including a fail-closed one. */
146
124
  verdict?: ShellSafetyVerdict;
147
125
  /** Set when the verdict is the gate failing closed rather than the model judging ([[EXT-66]]). */
148
126
  failClosed?: FailClosedCause;
127
+ /**
128
+ * [[EXT-82]] — the provider's own account of a call that never reached the model, when the
129
+ * `threw` arm carried one. Already sanitised where it was built ({@link RaterCallFailure}), which
130
+ * is not an exemption from the archive's redaction pass but a consequence of the same value being
131
+ * carried into the verdict a user reads live, where no such pass runs.
132
+ */
133
+ providerError?: RaterCallFailure;
149
134
  }
150
135
  /** A declared entry or runtime grant that decided the call, rendered as the user would read it. */
151
136
  export interface ApprovalRuleMatchCapture {
@@ -180,8 +165,35 @@ export interface PreflightFloorCapture {
180
165
  * Whether the floor changed the outcome. A preflight only ever RAISES, and only `safe` sits below
181
166
  * the floor — so a finding on a `destructive` verdict is the floor AGREEING with the rater, not
182
167
  * overriding it, and reporting those two the same way would misattribute the decision.
168
+ *
169
+ * Read together with {@link floorApplied}: this says whether the rating SAT below the floor, and
170
+ * that says whether the floor was applied to the call at all.
183
171
  */
184
172
  rewroteRating: boolean;
173
+ /**
174
+ * [[EXT-106]] §4.6 — **whether the decision readers actually applied the finding above.** `false`
175
+ * when the user-provenance carve-out lifted it, i.e. the preflight fired on the command and the
176
+ * floor, the negotiation test and the action all ignored it because the user had named every host
177
+ * themselves.
178
+ *
179
+ * **The finding is still reported when this is `false`, and that is the point.** This block is a
180
+ * diagnostic archive a user opens about their own session, and a command that reached the open
181
+ * world without anyone confirming it is exactly the one they most need to find in it. Nulling the
182
+ * record out on a carve would delete the audit trail for the whole of the new behaviour.
183
+ *
184
+ * **Written from the decision's own reader** (`effectivePreflightFloorFinding`), never derived a
185
+ * second time from the carved hosts: the floor has two arms, only that function resolves which of
186
+ * them wins, and a command tripping both is floored by the script-env-leak arm while the
187
+ * open-world arm would have carved. A second derivation says "carved, not floored" about a call
188
+ * that was floored and did reach a human.
189
+ */
190
+ floorApplied: boolean;
191
+ /**
192
+ * [[EXT-106]] §4.6 — the host literals the carve-out matched, present only when
193
+ * {@link floorApplied} is `false`. Every host in the command is here, because the carve-out
194
+ * requires every one of them to have been named by the user.
195
+ */
196
+ carvedHosts?: string[];
185
197
  }
186
198
  /** One gated tool call, from arrival to outcome. */
187
199
  export interface ApprovalDecisionCapture {
@@ -222,6 +234,15 @@ export interface ApprovalDecisionCapture {
222
234
  budget: NegotiationCounters;
223
235
  /** The rating, when one was made. Absent for every stage that decided without a model. */
224
236
  rating?: RaterCallCapture;
237
+ /**
238
+ * [[EXT-127]] — the alignment check, when the classifier declined and a checker was consulted.
239
+ *
240
+ * **It is a SECOND record beside {@link rating}, not a field inside it**, because the two are two
241
+ * model calls with two contexts and often two models. Collapsing them would make the archive
242
+ * unable to answer the question the split exists to let a reader ask: what did each of them see,
243
+ * and which of them decided this?
244
+ */
245
+ alignment?: AlignmentCallCapture;
225
246
  /** The error that ended the decision, when one did. */
226
247
  error?: string;
227
248
  }
@@ -260,12 +281,3 @@ export declare class ApprovalCaptureLog {
260
281
  * serialising anything of the instance.
261
282
  */
262
283
  export declare function raterModelLabel(model: unknown): string | undefined;
263
- /**
264
- * Describe the §5.1 context a rating is about to be made with — **as it was handed to the prompt
265
- * builder**, so the record and the prompt cannot come to describe two different ratings.
266
- *
267
- * The note is the legibility half of the acceptance: an empty user-messages window means one thing
268
- * at round 1 (by design) and something else entirely at round 3, and a reader of the archive has no
269
- * way to tell them apart from a `[]`.
270
- */
271
- export declare function describeRaterNegotiation(negotiation: RaterNegotiationContext | undefined): RaterNegotiationCapture;
@@ -63,46 +63,4 @@ export function raterModelLabel(model) {
63
63
  return `${type}/${id}`;
64
64
  return id ?? type;
65
65
  }
66
- /**
67
- * Describe the §5.1 context a rating is about to be made with — **as it was handed to the prompt
68
- * builder**, so the record and the prompt cannot come to describe two different ratings.
69
- *
70
- * The note is the legibility half of the acceptance: an empty user-messages window means one thing
71
- * at round 1 (by design) and something else entirely at round 3, and a reader of the archive has no
72
- * way to tell them apart from a `[]`.
73
- */
74
- export function describeRaterNegotiation(negotiation) {
75
- const priorRounds = [...(negotiation?.priorRounds ?? [])];
76
- const userMessages = [...(negotiation?.userMessages ?? [])];
77
- const roundOne = priorRounds.length === 0;
78
- const populated = userMessages.length > 0;
79
- return {
80
- round: priorRounds.length + 1,
81
- roundOne,
82
- contextSupplied: negotiation !== undefined,
83
- ...(negotiation?.justification !== undefined
84
- ? { justification: negotiation.justification }
85
- : {}),
86
- priorRounds,
87
- userMessages,
88
- userMessagesPopulated: populated,
89
- userMessagesNote: userMessagesNote(negotiation !== undefined, roundOne, populated),
90
- };
91
- }
92
- /** The sentence {@link describeRaterNegotiation} puts on the window, for a reader with no spec. */
93
- function userMessagesNote(contextSupplied, roundOne, populated) {
94
- if (!contextSupplied) {
95
- return ('No negotiation context was supplied for this rating (the rung does not negotiate, or this ' +
96
- 'was the allow-list tripwire), so the rater saw the command alone. An empty window here is ' +
97
- 'not a defect.');
98
- }
99
- if (roundOne) {
100
- return ('Round 1: spec §5.1 admits no justification, no transcript and no user messages, so the ' +
101
- 'rater saw the command alone. An empty window here is BY DESIGN, not a defect.');
102
- }
103
- return populated
104
- ? "Round 2 or later: the user's own recent messages WERE in the rater's view for this rating."
105
- : 'Round 2 or later, and the window is still empty — the conversation had no non-blank user ' +
106
- 'message to admit. This one IS worth looking at.';
107
- }
108
66
  //# sourceMappingURL=approvalCapture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"approvalCapture.js","sourceRoot":"","sources":["../../../src/core/shell/approvalCapture.ts"],"names":[],"mappings":"AA0DA;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AA4LvC;;;;;;GAMG;AACH,MAAM,OAAO,kBAAkB;IACrB,OAAO,GAA8B,EAAE,CAAC;IAEhD;;;;;;OAMG;IACH,KAAK,CAAC,MAA+B;QACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1B,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,oBAAoB;YAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACN,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAED,+DAA+D;IAC/D,KAAK;QACH,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC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AC;IACpB,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC1D,MAAM,CAAC,GAAG,KAKT,CAAC;IACF,IAAI,IAAwB,CAAC;IAC7B,IAAI,CAAC;QACH,IAAI,GAAG,OAAO,CAAC,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,GAAG,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAClE,CAAC;IACrB,IAAI,EAAE,IAAI,IAAI;QAAE,OAAO,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC;IACvC,OAAO,EAAE,IAAI,IAAI,CAAC;AACpB,CAAC"}
@@ -1,3 +1,94 @@
1
+ /**
2
+ * @module core/shell/approvalStop
3
+ *
4
+ * CFG-27 — the two ways the approvals gate **ends a run** rather than answering a tool call.
5
+ * Both are thrown from `GthAgentRunner.decideToolApproval`, both carry the command and the reason
6
+ * a person needs to see, and both are re-thrown UNCHANGED by `processMessages` (which otherwise
7
+ * wraps failures as `Agent processing failed: …`) so the explanation reaches the user intact.
8
+ *
9
+ * They are errors rather than {@link ../types.js ToolApprovalDecision}s on purpose. A decision is
10
+ * something the model observes as a `ToolMessage` and can respond to; these two are precisely the
11
+ * cases where the spec says the model gets no move at all:
12
+ *
13
+ * - **{@link AttackHaltError}** (§4.2) — an `attack` outcome *halts the run*. "A halt ends the
14
+ * agent loop. It is not a rejection the model can respond to, and no rung except `bypass` can
15
+ * turn it into anything else."
16
+ * - **{@link NonInteractiveEscalationError}** (§6.2) — where no human can answer, *every*
17
+ * escalation is an immediate non-zero exit carrying the command, the rating and its reason.
18
+ * There is no prompt, no waiting, and never a timeout into approval. Teams that need specific
19
+ * commands to run unattended declare them in `approvals.allow` (§3), which is consulted before
20
+ * the rater and therefore never escalates.
21
+ *
22
+ * Exit code: neither class sets one. The single-shot runtime (`runSingleShot`) already reports a
23
+ * thrown run as `ok: false`, and each command entry point turns that into `setExitCode(1)` — so
24
+ * "immediate non-zero exit carrying the explanation" is what a caller already gets, without a new
25
+ * exit path that could diverge from the existing one.
26
+ *
27
+ * ## [[TUI-C71]] — a stop message is UNTRUSTED TEXT, and it is made safe in two places
28
+ *
29
+ * Every string a stop carries except this module's own sentences is written by something other
30
+ * than the user: the command the agent proposed, the rater's outcome and reason, the
31
+ * `approvals.escalate` entry that matched, and the whole §5 negotiation. On an `attack` verdict
32
+ * that is the *worst* text in the system by construction — the rater judged the command's own
33
+ * structure to evidence deception or obfuscation — so a stop is the one message most likely to
34
+ * carry a payload crafted to forge terminal output, and the last one that may be printed raw.
35
+ *
36
+ * The defence [[TUI-C26]] built has two halves, and they belong at different times:
37
+ *
38
+ * 1. **Neutralisation is done HERE, at construction, unconditionally.** It needs no width and no
39
+ * screen, it is idempotent, and it is the half every consumer needs — a thrown stop reaches the
40
+ * Ink transcript, `--no-tui` stderr, a session log, the approvals archive (`record.error`), an
41
+ * eval turn record, AG-UI and a CI job's output, and only some of those are terminals. Doing it
42
+ * at each render site would mean every present and future consumer had to remember; doing it
43
+ * once here means none of them can forget. After it, `{@link message}` contains no control or
44
+ * format character at all: a carriage return is the five printable characters `\x0d`, and —
45
+ * because LF is a control character too — untrusted text cannot even open a new line, let alone
46
+ * reach column 0 on one.
47
+ * 2. **The gutter and the width bound are done at RENDER, by the surface** ({@link
48
+ * approvalStopRows} for the plain surfaces, `<ApprovalStopMessage>` for the Ink TUI). They
49
+ * cannot be done here: framing is arithmetic against a terminal width, an `Error.message` has
50
+ * no width, and a block wrapped for an 80-column terminal is wrong for every other one. What
51
+ * they buy over neutralisation alone is the last case it cannot close — one very long
52
+ * neutralised line that the *terminal* wraps, whose continuation starts at column 0 carrying
53
+ * whatever the attacker chose to put at that offset. That route is measured, not theorised: on
54
+ * a 120-column terminal the neutralised `Command:` line of a hostile command is ~164 columns.
55
+ *
56
+ * **Because half of it is the surface's job, the surfaces are enumerated rather than assumed.**
57
+ * Every place that catches an `ApprovalStopError` and prints it calls {@link approvalStopRows} (or
58
+ * the Ink component): `runtime/singleShot.ts`, `runtime/conversation.ts`,
59
+ * `agent/modules/interactiveSessionModule.ts` (both its per-turn catch and its outermost one, which
60
+ * is where the `-m` path lands), `review/modules/reviewModule.ts`, `app/commands/prCommand.ts`
61
+ * (which catches what the PR-discovery agent throws) and `app/tui/components/App.tsx`.
62
+ * **Adding a surface that catches a stop means adding it to that list.**
63
+ *
64
+ * **That list is over the ERROR, and the error is not the only way a stop reaches a screen.** Some
65
+ * consumers take {@link message} and hand the *string* onward, at which point no `instanceof` can
66
+ * find it again: `runConversation` records it as a turn's `error`, and `evalRunner` folds that into
67
+ * an eval case's `reasons`, which `batch/reporters/textReporter.ts` prints — a terminal, reached
68
+ * without any of its code ever seeing this class. That one frames the text itself. So the honest
69
+ * statement is not "every other consumer is a non-terminal" but: **a consumer that prints to a
70
+ * terminal frames what it prints, whether it holds the error or only its text**, and the ones that
71
+ * legitimately do neither are the file and protocol sinks (the approvals archive, the JUnit/JSON
72
+ * reports, the AG-UI event) plus `reviewModule`'s `displayDebug` of the raw error, which is a debug
73
+ * channel. All of them still inherit the neutralisation, which is what keeps the worst case a
74
+ * wrapped line rather than a repainted screen.
75
+ *
76
+ * **The structured fields stay RAW; only the message is neutralised.** That is what answers the
77
+ * obvious objection to construction-time work — that it stops the error being a faithful record of
78
+ * what was proposed. `{@link ApprovalStopError.command}`, `reason`, `outcome`, `escalatedBy` and
79
+ * `negotiation` are the command as the agent wrote it, byte for byte, for any consumer that needs
80
+ * the truth rather than a screen; the message is the *presentation*, and a presentation that can
81
+ * repaint the terminal is not one. The render path frames from those raw fields, so its gutter
82
+ * numbers the command's real lines rather than one escaped line.
83
+ *
84
+ * **One parts list, two renderings** ({@link ApprovalStopPart}). The message string and the framed
85
+ * block are both derived from {@link ApprovalStopError.parts}, so they cannot come to describe one
86
+ * stop two ways — the same argument `renderNegotiationTranscript` makes for its own two surfaces.
87
+ * A part is tagged with *who wrote it*, which is the only distinction any of this rests on: the
88
+ * gate's own prose can be painted as it is because nothing can forge it, and everything else goes
89
+ * through the shared renderer.
90
+ */
91
+ import type { ApprovalSubject } from '#src/core/approvals/matcher.js';
1
92
  /**
2
93
  * One piece of a stop message, tagged with who wrote it.
3
94
  *
@@ -67,7 +158,11 @@ export declare function approvalStopRows(parts: readonly ApprovalStopPart[], opt
67
158
  * cannot shows {@link message}, which is already neutralised and is already the whole explanation.
68
159
  */
69
160
  export declare abstract class ApprovalStopError extends Error {
70
- /** The command that ended the run, exactly as the agent proposed it. */
161
+ /**
162
+ * What ended the run, exactly as the agent proposed it: the command for a shell subject, and the
163
+ * registered tool name for a gated tool or MCP call. The field name predates the gate widening
164
+ * past the shell; {@link subjectParts} is what decides the word the MESSAGE calls it.
165
+ */
71
166
  readonly command: string;
72
167
  /** The message's pieces, tagged with who wrote each — see {@link ApprovalStopPart}. */
73
168
  readonly parts: readonly ApprovalStopPart[];
@@ -93,7 +188,7 @@ export declare abstract class ApprovalStopError extends Error {
93
188
  export declare class AttackHaltError extends ApprovalStopError {
94
189
  /** The rater's explanation of what the command's structure showed. */
95
190
  readonly reason: string;
96
- constructor(command: string, reason: string);
191
+ constructor(command: string, reason: string, subject?: ApprovalSubject);
97
192
  }
98
193
  /**
99
194
  * §6.2 — an escalation with nobody to ask (CI, one-shot runs, servers). Fails the build loudly,
@@ -119,5 +214,28 @@ export declare class NonInteractiveEscalationError extends ApprovalStopError {
119
214
  * the last command and give no hint that the agent had already been told twice what to fix.
120
215
  */
121
216
  readonly negotiation: string | undefined;
122
- constructor(command: string, outcome?: string, reason?: string, escalatedBy?: string, negotiation?: string);
217
+ /**
218
+ * [[EXT-106]] §4 — **the `approvals.allow` entry that would let THIS command run**, rendered in the
219
+ * object form a user writes in a config file, or `undefined` when none can soundly be derived.
220
+ *
221
+ * A refusal that stands has to say what would lift it, and a generic example leaves the reader to
222
+ * translate it — for a command the deterministic preflight floors, that translation is the entire
223
+ * remedy. `approvals.allow` is consulted before the rater and therefore before §4.6's preflight,
224
+ * so it is the one thing that lifts a floor the agent cannot argue past.
225
+ *
226
+ * **Derived by the caller, never here.** The caller holds what an entry has to be derived from —
227
+ * the normalized command for a shell subject (`shellApprovalEntryFor`), the tool's identity and
228
+ * host for a tool or MCP one (`toolGrantEntry`) — and it is the same derivation the escalation
229
+ * menu's *always approve* stores, so a message and a menu cannot promise different things about
230
+ * one call. `undefined` falls back to the general form, which is the right answer whenever a
231
+ * specific one would be wrong — an entry that is subtly too broad, or simply inert, is worse than
232
+ * none. That is what a call whose MCP server could not be attributed gets: `toolGrantEntry`
233
+ * returns `null` for it, because `server` cannot hold the unresolved sentinel.
234
+ *
235
+ * **It is untrusted text.** It embeds the command the model proposed, so it is carried as a
236
+ * labelled `value` part and neutralised with every other untrusted string; putting it in an `own`
237
+ * part would route model-authored bytes into the one part class a surface may paint raw.
238
+ */
239
+ readonly allowEntry: string | undefined;
240
+ constructor(command: string, outcome?: string, reason?: string, escalatedBy?: string, negotiation?: string, allowEntry?: string, subject?: ApprovalSubject);
123
241
  }