@gaunt-sloth/core 2.0.0-alpha.8 → 2.0.0-beta.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.
Files changed (275) hide show
  1. package/.gsloth.review.md +2 -0
  2. package/README.md +71 -20
  3. package/dist/config/colour.d.ts +38 -0
  4. package/dist/config/colour.js +36 -0
  5. package/dist/config/colour.js.map +1 -0
  6. package/dist/config/configDiscovery.d.ts +79 -0
  7. package/dist/config/configDiscovery.js +80 -0
  8. package/dist/config/configDiscovery.js.map +1 -0
  9. package/dist/config/defaults.d.ts +20 -20
  10. package/dist/config/defaults.js +10 -8
  11. package/dist/config/defaults.js.map +1 -1
  12. package/dist/config/filesystem-tools.d.ts +41 -0
  13. package/dist/config/filesystem-tools.js +56 -0
  14. package/dist/config/filesystem-tools.js.map +1 -0
  15. package/dist/config/loader.d.ts +171 -19
  16. package/dist/config/loader.js +1054 -144
  17. package/dist/config/loader.js.map +1 -1
  18. package/dist/config/mouse.d.ts +50 -0
  19. package/dist/config/mouse.js +44 -0
  20. package/dist/config/mouse.js.map +1 -0
  21. package/dist/config/profiles.d.ts +68 -0
  22. package/dist/config/profiles.js +93 -0
  23. package/dist/config/profiles.js.map +1 -0
  24. package/dist/config/providerKeys.d.ts +69 -0
  25. package/dist/config/providerKeys.js +69 -0
  26. package/dist/config/providerKeys.js.map +1 -0
  27. package/dist/config/schema.d.ts +2671 -138
  28. package/dist/config/schema.js +1361 -85
  29. package/dist/config/schema.js.map +1 -1
  30. package/dist/config/shell-policy.d.ts +899 -111
  31. package/dist/config/shell-policy.js +800 -70
  32. package/dist/config/shell-policy.js.map +1 -1
  33. package/dist/config/tool-descriptions.d.ts +211 -0
  34. package/dist/config/tool-descriptions.js +272 -0
  35. package/dist/config/tool-descriptions.js.map +1 -0
  36. package/dist/config/types.d.ts +352 -41
  37. package/dist/config/types.js +1 -0
  38. package/dist/config/types.js.map +1 -1
  39. package/dist/config.d.ts +35 -1
  40. package/dist/config.js +16 -1
  41. package/dist/config.js.map +1 -1
  42. package/dist/constants.d.ts +28 -1
  43. package/dist/constants.js +28 -1
  44. package/dist/constants.js.map +1 -1
  45. package/dist/core/GthAbstractAgent.d.ts +166 -11
  46. package/dist/core/GthAbstractAgent.js +484 -45
  47. package/dist/core/GthAbstractAgent.js.map +1 -1
  48. package/dist/core/GthAgentRunner.d.ts +543 -57
  49. package/dist/core/GthAgentRunner.js +1494 -140
  50. package/dist/core/GthAgentRunner.js.map +1 -1
  51. package/dist/core/GthLangChainAgent.d.ts +117 -2
  52. package/dist/core/GthLangChainAgent.js +602 -29
  53. package/dist/core/GthLangChainAgent.js.map +1 -1
  54. package/dist/core/approvals/annotations.d.ts +122 -0
  55. package/dist/core/approvals/annotations.js +137 -0
  56. package/dist/core/approvals/annotations.js.map +1 -0
  57. package/dist/core/approvals/grants.d.ts +216 -0
  58. package/dist/core/approvals/grants.js +469 -0
  59. package/dist/core/approvals/grants.js.map +1 -0
  60. package/dist/core/approvals/matcher.d.ts +202 -0
  61. package/dist/core/approvals/matcher.js +267 -0
  62. package/dist/core/approvals/matcher.js.map +1 -0
  63. package/dist/core/approvals/mcpSubjects.d.ts +40 -0
  64. package/dist/core/approvals/mcpSubjects.js +99 -0
  65. package/dist/core/approvals/mcpSubjects.js.map +1 -0
  66. package/dist/core/approvals/promptHeader.d.ts +28 -0
  67. package/dist/core/approvals/promptHeader.js +62 -0
  68. package/dist/core/approvals/promptHeader.js.map +1 -0
  69. package/dist/core/approvals/toolAnnotationSources.d.ts +105 -0
  70. package/dist/core/approvals/toolAnnotationSources.js +277 -0
  71. package/dist/core/approvals/toolAnnotationSources.js.map +1 -0
  72. package/dist/core/approvals/toolHost.d.ts +46 -0
  73. package/dist/core/approvals/toolHost.js +108 -0
  74. package/dist/core/approvals/toolHost.js.map +1 -0
  75. package/dist/core/debugCapture.d.ts +74 -0
  76. package/dist/core/debugCapture.js +100 -0
  77. package/dist/core/debugCapture.js.map +1 -0
  78. package/dist/core/gthLeanAgentFactory.d.ts +4 -4
  79. package/dist/core/gthLeanAgentFactory.js +4 -4
  80. package/dist/core/launchBanner.d.ts +127 -0
  81. package/dist/core/launchBanner.js +414 -0
  82. package/dist/core/launchBanner.js.map +1 -0
  83. package/dist/core/modelLabel.d.ts +19 -0
  84. package/dist/core/modelLabel.js +26 -0
  85. package/dist/core/modelLabel.js.map +1 -0
  86. package/dist/core/plainToolIndication.d.ts +15 -0
  87. package/dist/core/plainToolIndication.js +174 -0
  88. package/dist/core/plainToolIndication.js.map +1 -0
  89. package/dist/core/reasoningBlocks.d.ts +65 -0
  90. package/dist/core/reasoningBlocks.js +103 -0
  91. package/dist/core/reasoningBlocks.js.map +1 -0
  92. package/dist/core/refusal.d.ts +53 -0
  93. package/dist/core/refusal.js +133 -0
  94. package/dist/core/refusal.js.map +1 -0
  95. package/dist/core/runHeader.d.ts +38 -0
  96. package/dist/core/runHeader.js +42 -0
  97. package/dist/core/runHeader.js.map +1 -0
  98. package/dist/core/runStats.d.ts +14 -3
  99. package/dist/core/runStats.js +48 -3
  100. package/dist/core/runStats.js.map +1 -1
  101. package/dist/core/shell/ShellCommandFailedError.d.ts +3 -4
  102. package/dist/core/shell/ShellCommandFailedError.js +3 -4
  103. package/dist/core/shell/ShellCommandFailedError.js.map +1 -1
  104. package/dist/core/shell/abstention.d.ts +88 -0
  105. package/dist/core/shell/abstention.js +184 -0
  106. package/dist/core/shell/abstention.js.map +1 -0
  107. package/dist/core/shell/approvalCapture.d.ts +271 -0
  108. package/dist/core/shell/approvalCapture.js +108 -0
  109. package/dist/core/shell/approvalCapture.js.map +1 -0
  110. package/dist/core/shell/approvalStop.d.ts +123 -0
  111. package/dist/core/shell/approvalStop.js +269 -0
  112. package/dist/core/shell/approvalStop.js.map +1 -0
  113. package/dist/core/shell/arity.d.ts +6 -0
  114. package/dist/core/shell/arity.js +20 -6
  115. package/dist/core/shell/arity.js.map +1 -1
  116. package/dist/core/shell/denylist.d.ts +11 -0
  117. package/dist/core/shell/denylist.js +37 -0
  118. package/dist/core/shell/denylist.js.map +1 -0
  119. package/dist/core/shell/escalationSeverity.d.ts +141 -0
  120. package/dist/core/shell/escalationSeverity.js +89 -0
  121. package/dist/core/shell/escalationSeverity.js.map +1 -0
  122. package/dist/core/shell/framing.d.ts +190 -0
  123. package/dist/core/shell/framing.js +633 -0
  124. package/dist/core/shell/framing.js.map +1 -0
  125. package/dist/core/shell/hardline.d.ts +103 -0
  126. package/dist/core/shell/hardline.js +780 -0
  127. package/dist/core/shell/hardline.js.map +1 -0
  128. package/dist/core/shell/negotiation.d.ts +328 -0
  129. package/dist/core/shell/negotiation.js +488 -0
  130. package/dist/core/shell/negotiation.js.map +1 -0
  131. package/dist/core/shell/normalize.d.ts +44 -4
  132. package/dist/core/shell/normalize.js +61 -7
  133. package/dist/core/shell/normalize.js.map +1 -1
  134. package/dist/core/shell/openWorld.d.ts +263 -0
  135. package/dist/core/shell/openWorld.js +1188 -0
  136. package/dist/core/shell/openWorld.js.map +1 -0
  137. package/dist/core/shell/rater.d.ts +873 -0
  138. package/dist/core/shell/rater.js +1454 -0
  139. package/dist/core/shell/rater.js.map +1 -0
  140. package/dist/core/shell/raterModel.d.ts +41 -0
  141. package/dist/core/shell/raterModel.js +51 -0
  142. package/dist/core/shell/raterModel.js.map +1 -0
  143. package/dist/core/shell/raterVocabulary.d.ts +121 -0
  144. package/dist/core/shell/raterVocabulary.js +116 -0
  145. package/dist/core/shell/raterVocabulary.js.map +1 -0
  146. package/dist/core/shell/rejection.d.ts +69 -0
  147. package/dist/core/shell/rejection.js +38 -0
  148. package/dist/core/shell/rejection.js.map +1 -0
  149. package/dist/core/toolCallRepair/grammar.d.ts +41 -0
  150. package/dist/core/toolCallRepair/grammar.js +116 -0
  151. package/dist/core/toolCallRepair/grammar.js.map +1 -0
  152. package/dist/core/toolCallRepair/index.d.ts +2 -0
  153. package/dist/core/toolCallRepair/index.js +7 -0
  154. package/dist/core/toolCallRepair/index.js.map +1 -0
  155. package/dist/core/toolCallRepair/payload.d.ts +36 -0
  156. package/dist/core/toolCallRepair/payload.js +341 -0
  157. package/dist/core/toolCallRepair/payload.js.map +1 -0
  158. package/dist/core/toolCallRepair/promote.d.ts +45 -0
  159. package/dist/core/toolCallRepair/promote.js +90 -0
  160. package/dist/core/toolCallRepair/promote.js.map +1 -0
  161. package/dist/core/toolDisplay.d.ts +123 -0
  162. package/dist/core/toolDisplay.js +451 -0
  163. package/dist/core/toolDisplay.js.map +1 -0
  164. package/dist/core/toolOutputChannel.d.ts +95 -0
  165. package/dist/core/toolOutputChannel.js +165 -0
  166. package/dist/core/toolOutputChannel.js.map +1 -0
  167. package/dist/core/types.d.ts +349 -16
  168. package/dist/core/types.js.map +1 -1
  169. package/dist/history/historyFormat.d.ts +12 -3
  170. package/dist/history/historyFormat.js +50 -8
  171. package/dist/history/historyFormat.js.map +1 -1
  172. package/dist/history/historyStore.d.ts +77 -0
  173. package/dist/history/historyStore.js +173 -6
  174. package/dist/history/historyStore.js.map +1 -1
  175. package/dist/history/recordSession.d.ts +10 -1
  176. package/dist/history/recordSession.js +27 -0
  177. package/dist/history/recordSession.js.map +1 -1
  178. package/dist/providers/anthropic.js +12 -0
  179. package/dist/providers/anthropic.js.map +1 -1
  180. package/dist/providers/configurationPassthrough.d.ts +107 -0
  181. package/dist/providers/configurationPassthrough.js +148 -0
  182. package/dist/providers/configurationPassthrough.js.map +1 -0
  183. package/dist/providers/geminiSchemaSanitizer.d.ts +55 -0
  184. package/dist/providers/geminiSchemaSanitizer.js +347 -0
  185. package/dist/providers/geminiSchemaSanitizer.js.map +1 -0
  186. package/dist/providers/geminiThinking.d.ts +60 -0
  187. package/dist/providers/geminiThinking.js +92 -0
  188. package/dist/providers/geminiThinking.js.map +1 -0
  189. package/dist/providers/google-genai.js +18 -1
  190. package/dist/providers/google-genai.js.map +1 -1
  191. package/dist/providers/groq.js +12 -0
  192. package/dist/providers/groq.js.map +1 -1
  193. package/dist/providers/huggingface.d.ts +25 -0
  194. package/dist/providers/huggingface.js +69 -0
  195. package/dist/providers/huggingface.js.map +1 -0
  196. package/dist/providers/modelCatalog.d.ts +109 -0
  197. package/dist/providers/modelCatalog.js +245 -0
  198. package/dist/providers/modelCatalog.js.map +1 -0
  199. package/dist/providers/modelDiscovery.d.ts +99 -5
  200. package/dist/providers/modelDiscovery.js +191 -35
  201. package/dist/providers/modelDiscovery.js.map +1 -1
  202. package/dist/providers/ollama.d.ts +18 -4
  203. package/dist/providers/ollama.js +67 -37
  204. package/dist/providers/ollama.js.map +1 -1
  205. package/dist/providers/openai.js +34 -0
  206. package/dist/providers/openai.js.map +1 -1
  207. package/dist/providers/openrouter.d.ts +26 -4
  208. package/dist/providers/openrouter.js +83 -26
  209. package/dist/providers/openrouter.js.map +1 -1
  210. package/dist/providers/vertexai.js +19 -1
  211. package/dist/providers/vertexai.js.map +1 -1
  212. package/dist/providers/xai.js +20 -0
  213. package/dist/providers/xai.js.map +1 -1
  214. package/dist/runtime/askStructured.d.ts +105 -0
  215. package/dist/runtime/askStructured.js +120 -0
  216. package/dist/runtime/askStructured.js.map +1 -0
  217. package/dist/runtime/conversation.d.ts +64 -0
  218. package/dist/runtime/conversation.js +171 -0
  219. package/dist/runtime/conversation.js.map +1 -0
  220. package/dist/runtime/singleShot.d.ts +37 -6
  221. package/dist/runtime/singleShot.js +113 -67
  222. package/dist/runtime/singleShot.js.map +1 -1
  223. package/dist/runtime/structuredOutput.d.ts +104 -0
  224. package/dist/runtime/structuredOutput.js +393 -0
  225. package/dist/runtime/structuredOutput.js.map +1 -0
  226. package/dist/utils/ProgressIndicator.d.ts +21 -0
  227. package/dist/utils/ProgressIndicator.js +30 -3
  228. package/dist/utils/ProgressIndicator.js.map +1 -1
  229. package/dist/utils/aiignoreUtils.js.map +1 -1
  230. package/dist/utils/binaryOutputUtils.js.map +1 -1
  231. package/dist/utils/consoleUtils.d.ts +95 -0
  232. package/dist/utils/consoleUtils.js +112 -2
  233. package/dist/utils/consoleUtils.js.map +1 -1
  234. package/dist/utils/crashHandler.d.ts +87 -0
  235. package/dist/utils/crashHandler.js +128 -0
  236. package/dist/utils/crashHandler.js.map +1 -0
  237. package/dist/utils/debugDump.d.ts +134 -0
  238. package/dist/utils/debugDump.js +381 -0
  239. package/dist/utils/debugDump.js.map +1 -0
  240. package/dist/utils/debugUtils.d.ts +13 -4
  241. package/dist/utils/debugUtils.js +36 -13
  242. package/dist/utils/debugUtils.js.map +1 -1
  243. package/dist/utils/displayWidth.d.ts +53 -0
  244. package/dist/utils/displayWidth.js +195 -0
  245. package/dist/utils/displayWidth.js.map +1 -0
  246. package/dist/utils/fileUtils.js.map +1 -1
  247. package/dist/utils/globalConfigUtils.d.ts +14 -2
  248. package/dist/utils/globalConfigUtils.js +22 -4
  249. package/dist/utils/globalConfigUtils.js.map +1 -1
  250. package/dist/utils/llmUtils.d.ts +39 -8
  251. package/dist/utils/llmUtils.js +76 -8
  252. package/dist/utils/llmUtils.js.map +1 -1
  253. package/dist/utils/redactSecrets.d.ts +63 -0
  254. package/dist/utils/redactSecrets.js +286 -0
  255. package/dist/utils/redactSecrets.js.map +1 -0
  256. package/dist/utils/systemPromptNotes.d.ts +222 -0
  257. package/dist/utils/systemPromptNotes.js +338 -0
  258. package/dist/utils/systemPromptNotes.js.map +1 -0
  259. package/dist/utils/systemUtils.d.ts +18 -1
  260. package/dist/utils/systemUtils.js +38 -3
  261. package/dist/utils/systemUtils.js.map +1 -1
  262. package/dist/utils/toolMatching.d.ts +30 -0
  263. package/dist/utils/toolMatching.js +44 -0
  264. package/dist/utils/toolMatching.js.map +1 -0
  265. package/dist/utils/untrustedText.d.ts +86 -0
  266. package/dist/utils/untrustedText.js +101 -0
  267. package/dist/utils/untrustedText.js.map +1 -0
  268. package/package.json +21 -7
  269. package/schema/gsloth-config.schema.json +1921 -326
  270. package/dist/core/shell/allowlist.d.ts +0 -75
  271. package/dist/core/shell/allowlist.js +0 -187
  272. package/dist/core/shell/allowlist.js.map +0 -1
  273. package/dist/core/shell/judge.d.ts +0 -161
  274. package/dist/core/shell/judge.js +0 -261
  275. package/dist/core/shell/judge.js.map +0 -1
@@ -9,8 +9,20 @@ const loggingState = {
9
9
  const consoleLevelState = {
10
10
  currentLevel: StatusLevel.INFO, // Default to INFO level, not debug
11
11
  };
12
- // ANSI color codes
13
- const ANSI_COLORS = {
12
+ /**
13
+ * ANSI color codes — the 16-colour slots only, deliberately. A 16-colour slot is rendered with the
14
+ * user's OWN terminal theme colour, so output looks native in light and dark schemes alike; a
15
+ * 256-colour or 24-bit escape would pin us to one palette and clash with half of them.
16
+ *
17
+ * Exported so the surfaces that build their own pre-styled blocks (rather than passing a whole
18
+ * message through {@link colorText}) still draw from this one table — see
19
+ * `core/launchBanner.ts`, which paints only the face half of each banner row.
20
+ *
21
+ * `as const` because `packages/core` publishes `"./*.js": "./dist/*.js"`, so this is PUBLIC API of a
22
+ * published package: without it any consumer could assign `ANSI_COLORS.magenta` and repaint the
23
+ * whole CLI from the outside. Read-only, one table, no remote control.
24
+ */
25
+ export const ANSI_COLORS = {
14
26
  red: '\x1b[31m',
15
27
  yellow: '\x1b[33m',
16
28
  green: '\x1b[32m',
@@ -87,9 +99,40 @@ export function displayError(message) {
87
99
  writeToSessionLog(message + '\n');
88
100
  su.log(coloredMessage);
89
101
  }
102
+ /**
103
+ * Optional capture buffer for warning advisories (TUI-C19). When a capture window is open
104
+ * (see {@link beginWarningCapture}), every {@link displayWarning} message is also collected
105
+ * here so a surface that takes over the screen — the Ink TUI — can re-surface warnings that
106
+ * would otherwise print once and scroll out of sight. `null` when no window is open, so the
107
+ * plain-CLI path and the session log are entirely untouched.
108
+ */
109
+ let warningCapture = null;
110
+ /**
111
+ * Open a warning-capture window: from now until {@link endWarningCapture}, each
112
+ * `displayWarning` message is buffered (IN ADDITION to being printed/logged as usual). Used by
113
+ * the TUI session module to grab the transient load-time config advisories and thread them into
114
+ * the persistent notice surface. Idempotent-ish: a second call starts a fresh buffer.
115
+ */
116
+ export const beginWarningCapture = () => {
117
+ warningCapture = [];
118
+ };
119
+ /**
120
+ * Close the warning-capture window opened by {@link beginWarningCapture} and return everything
121
+ * collected (empty array if none / never opened). Always call this — a `try/finally` around the
122
+ * captured work — so a throw can't leak the capture state into later warnings.
123
+ */
124
+ export const endWarningCapture = () => {
125
+ const captured = warningCapture ?? [];
126
+ warningCapture = null;
127
+ return captured;
128
+ };
90
129
  export function displayWarning(message) {
91
130
  if (!shouldDisplayLevel(StatusLevel.WARNING))
92
131
  return;
132
+ // Collect into the active capture window (if any) so the TUI can re-surface it later. Done
133
+ // after the level guard so a user who quieted warnings sees them neither printed nor captured.
134
+ if (warningCapture)
135
+ warningCapture.push(message);
93
136
  const coloredMessage = colorText(message, 'yellow');
94
137
  writeToSessionLog(message + '\n');
95
138
  su.warn(coloredMessage);
@@ -114,9 +157,76 @@ export function display(message) {
114
157
  writeToSessionLog(message + '\n');
115
158
  su.log(message);
116
159
  }
160
+ /**
161
+ * TUI-C30 — print one pre-styled tool-call indication block (the plain surface's compact
162
+ * `✓ name(args…)` + greyed preview, built by `core/plainToolIndication.ts`). Same INFO-level
163
+ * gate, stdout channel and session-log treatment as {@link displayInfo} — matching the stream
164
+ * discipline of the existing tool notices — but WITHOUT the blanket dim wrap: the block styles
165
+ * each line itself (diff colours, per-line dim), and an outer wrapper would be broken by the
166
+ * inner resets. The session log gets the ANSI-stripped text via {@link writeToSessionLog}.
167
+ */
168
+ export function displayToolIndication(message) {
169
+ if (!shouldDisplayLevel(StatusLevel.INFO))
170
+ return;
171
+ writeToSessionLog(message + '\n');
172
+ su.info(message);
173
+ }
174
+ /**
175
+ * TUI-C33 — print the interactive-launch banner (the pre-styled block built by
176
+ * `core/launchBanner.ts`) on the plain surface. Same DISPLAY-level gate and stdout channel as
177
+ * {@link display}, so a quieted console silences it too, but deliberately NOT routed through
178
+ * {@link writeToSessionLog}: the session log is a transcript of the conversation, not a screenshot
179
+ * of the screen, and a five-row sloth at the top of it is noise. The block also styles itself (the
180
+ * face half of each row carries the colour), so no outer wrap is applied.
181
+ */
182
+ export function displayLaunchBanner(message) {
183
+ if (!shouldDisplayLevel(StatusLevel.DISPLAY))
184
+ return;
185
+ su.log(message);
186
+ }
117
187
  export function formatInputPrompt(message) {
118
188
  return colorText(message, 'magenta');
119
189
  }
190
+ const DIALOG_TONE_COLOURS = {
191
+ plain: null,
192
+ notice: 'dim',
193
+ warn: 'yellow',
194
+ danger: 'red',
195
+ prompt: 'magenta',
196
+ };
197
+ /**
198
+ * Print one line of an interactive dialog — an approval prompt, an attack banner — **on stderr**.
199
+ *
200
+ * ## One dialog, one stream
201
+ *
202
+ * A dialog's meaning is carried by the ORDER of its lines: a heading, then whose words the next
203
+ * lines are, then the words. Two streams cannot promise an order. Only writes to the *same* stream
204
+ * are delivered in the order they were made — across stdout and stderr nothing is promised, and the
205
+ * difference is observable the moment the two go to different places: with stdout a pipe or a file
206
+ * it is block-buffered while stderr is not, so a captured run can carry a rater's answer above the
207
+ * command it answers. A security dialog whose line order holds only on a terminal is not a gate, so
208
+ * every line of one goes through here and through nothing else.
209
+ *
210
+ * **stderr, because a prompt is not program output.** It is the conventional home for interaction,
211
+ * it is not block-buffered, and it leaves stdout carrying only what the run produced. The cost is
212
+ * real and is documented for users: piping stdout (`gth code --no-tui | tee log`) no longer captures
213
+ * the dialog — the terminal still shows it, `2>` still collects it, and an enabled session log still
214
+ * records it. The log write here is UNCONDITIONAL, which the gated helpers' is not: theirs sits
215
+ * behind the level guard, so a quieted console drops those lines from the transcript as well as
216
+ * from the screen. A dialog stays whole in both places.
217
+ *
218
+ * ## Not level-gated, on purpose
219
+ *
220
+ * The dialog is a QUESTION, not a status message, and the level filter is per line: gated, a quieted
221
+ * console prints the parts above its threshold and drops the rest, which is how an approval prompt
222
+ * comes to show a severity heading with no command under it. Half a dialog is worse than none,
223
+ * because it still looks like a whole one.
224
+ */
225
+ export function displayDialogLine(message, tone = 'plain') {
226
+ const colour = DIALOG_TONE_COLOURS[tone];
227
+ writeToSessionLog(message + '\n');
228
+ su.error(colour ? colorText(message, colour) : message);
229
+ }
120
230
  /**
121
231
  * Display a debug message to the console and log it.
122
232
  * This function also integrates with debugUtils to output logs when at debug level.
@@ -1 +1 @@
1
- {"version":3,"file":"consoleUtils.js","sourceRoot":"","sources":["../../src/utils/consoleUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAwB,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACpG,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAapD,MAAM,YAAY,GAAiB;IACjC,cAAc,EAAE,SAAS;IACzB,oBAAoB,EAAE,KAAK;CAC5B,CAAC;AAEF,MAAM,iBAAiB,GAAsB;IAC3C,YAAY,EAAE,WAAW,CAAC,IAAI,EAAE,mCAAmC;CACpE,CAAC;AAEF,mBAAmB;AACnB,MAAM,WAAW,GAAG;IAClB,GAAG,EAAE,UAAU;IACf,MAAM,EAAE,UAAU;IAClB,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,UAAU;IACnB,GAAG,EAAE,SAAS;IACd,KAAK,EAAE,SAAS;CACjB,CAAC;AAEF,qCAAqC;AACrC,SAAS,SAAS,CAAC,IAAY,EAAE,KAA+B;IAC9D,IAAI,CAAC,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,WAAW,CAAC,KAAK,EAAE,CAAC;AAC5D,CAAC;AAED,gCAAgC;AAChC,MAAM,iBAAiB,GAAG,CAAC,OAAe,EAAQ,EAAE;IAClD,IAAI,YAAY,CAAC,oBAAoB,EAAE,CAAC;QACtC,gDAAgD;QAChD,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,C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AG,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAEpC,oBAAoB;IACpB,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1E,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC3C,CAAC;IAED,mBAAmB;IACnB,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QAC1E,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC1C,CAAC;IAED,qDAAqD;IACrD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC3C,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,SAAS;YACZ,OAAO,MAAM,CAAC,KAAK,CAAC;QACtB,KAAK,QAAQ;YACX,OAAO,MAAM,CAAC,KAAK,CAAC;QACtB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * GS2-48 — a process-level crash handler that writes an unattended, GS2-47-redacted debug snapshot
4
+ * when the process DIES, then exits — the counterpart to GS2-46's `/debug-dump`, which only helps
5
+ * while the process is alive to run the slash command. Most real failures are the process dying, at
6
+ * which point a slash command can't help, so this fires unconditionally, regardless of whether
7
+ * `debugLog` was ever turned on for the session (the snapshot draws on the always-on in-memory
8
+ * ring buffer — see {@link file://./debugUtils.ts}).
9
+ *
10
+ * SCOPE (deliberate): only `uncaughtException` and `unhandledRejection` are handled. Fatal SIGNALS
11
+ * are intentionally left to a follow-up — `SIGINT`/`SIGTERM` are already GRACEFUL-exit paths
12
+ * ({@link file://./systemUtils.ts} closes the log stream and exits 0), the TUI owns raw-mode Ctrl-C,
13
+ * and dumping a crash file on every Ctrl-C would be noise, not signal. Adding signal capture without
14
+ * fighting those handlers is a separate, careful piece of work.
15
+ *
16
+ * Exiting on these two events is NOT a behavioural regression: Node's default for an unhandled
17
+ * rejection is already to throw (terminate), and its default for an uncaught exception is to print
18
+ * the error and exit(1). This handler replicates that terminal behaviour (it still prints the
19
+ * ORIGINAL error) and only ADDS the snapshot — an uncaughtException LISTENER suppresses Node's own
20
+ * auto-print, which is exactly why the handler prints the error itself.
21
+ *
22
+ * CRASH-SAFETY invariants (the whole point of the node):
23
+ * - The handler is fully SYNCHRONOUS — no `async`/`await`, returns no promise. An async handler that
24
+ * rejected would raise a fresh `unhandledRejection` and re-enter, the exact loop the brief forbids.
25
+ * - A module-level {@link handling} guard is set BEFORE any work, so a throw anywhere inside cannot
26
+ * re-enter the handler and loop; a genuine re-entry short-circuits straight to exit.
27
+ * - Snapshotting is wrapped in try/catch; if it fails, the handler DEGRADES to printing the original
28
+ * error plus a one-line "failed to write crash snapshot" reason and still exits — it never masks
29
+ * the original error and never re-enters.
30
+ * - stderr is written with `fs.writeSync(2, …)`, NOT the async `consoleUtils`/`systemUtils` stream:
31
+ * `process.exit()` truncates pending async pipe writes, so the printed snapshot path (asserted by
32
+ * the e2e over a pipe) could be lost. This is a conscious, documented deviation from the
33
+ * "use consoleUtils for output" rule — that path is unsafe at crash time.
34
+ */
35
+ /**
36
+ * Session-supplied context folded into the snapshot when a crash fires. All optional: a crash before
37
+ * a session registers anything still produces a useful snapshot (error + stack + debugLog buffer +
38
+ * env), just without config/transcript.
39
+ */
40
+ export interface CrashContext {
41
+ /** The effective resolved config. */
42
+ config?: unknown;
43
+ /** Model display name. */
44
+ modelDisplayName?: string;
45
+ /** The in-flight turn's transcript tail. */
46
+ transcriptTail?: unknown;
47
+ }
48
+ /** Replace the crash context wholesale. */
49
+ export declare function setCrashContext(ctx: CrashContext): void;
50
+ /**
51
+ * Merge a partial update into the crash context. The running agent calls this as it learns things
52
+ * (config at init, transcript tail before each turn) so a crash mid-run captures the latest state.
53
+ */
54
+ export declare function updateCrashContext(patch: Partial<CrashContext>): void;
55
+ /** Clear the crash context (e.g. when a session ends). */
56
+ export declare function clearCrashContext(): void;
57
+ /** Read the current crash context (used as the default context source by the installed handler). */
58
+ export declare function getCrashContext(): CrashContext;
59
+ /**
60
+ * The crash-handling body. Exported (rather than only closed over by the listeners) so it can be
61
+ * unit-tested directly with an injected `exit` and `getContext`, without registering real process
62
+ * listeners or killing the test runner.
63
+ *
64
+ * @param error the thrown value / rejection reason
65
+ * @param origin `'uncaughtException'` | `'unhandledRejection'`
66
+ * @param exit terminator (default {@link process.exit}); injectable so tests capture the code
67
+ * @param getContext source of the snapshot context (default the module context)
68
+ */
69
+ export declare function handleCrash(error: unknown, origin: string, exit?: (code: number) => void, getContext?: () => CrashContext): void;
70
+ /** Options for {@link installCrashHandler}. */
71
+ export interface InstallCrashHandlerOptions {
72
+ /** Terminator (default {@link process.exit}). Injectable for tests. */
73
+ exit?: (code: number) => void;
74
+ /** Snapshot-context source (default the module crash context). */
75
+ getContext?: () => CrashContext;
76
+ }
77
+ /**
78
+ * Install the process-level crash handler (idempotent). Registers `uncaughtException` and
79
+ * `unhandledRejection` listeners that write a redacted snapshot and exit. Inert on a normal exit —
80
+ * no `exit`/`beforeExit` hook is registered, so a clean run behaves exactly as before.
81
+ */
82
+ export declare function installCrashHandler(options?: InstallCrashHandlerOptions): void;
83
+ /**
84
+ * Remove the crash-handler listeners and reset internal state. Primarily for tests (so the module
85
+ * singleton's `handling`/`installed` flags don't leak between cases); harmless in production.
86
+ */
87
+ export declare function uninstallCrashHandler(): void;
@@ -0,0 +1,128 @@
1
+ import { writeSync } from 'node:fs';
2
+ import { writeCrashSnapshot } from '#src/utils/debugDump.js';
3
+ /** The live context read at crash time. Updated in place by the running session (see below). */
4
+ let crashContext = {};
5
+ /** Replace the crash context wholesale. */
6
+ export function setCrashContext(ctx) {
7
+ crashContext = ctx ?? {};
8
+ }
9
+ /**
10
+ * Merge a partial update into the crash context. The running agent calls this as it learns things
11
+ * (config at init, transcript tail before each turn) so a crash mid-run captures the latest state.
12
+ */
13
+ export function updateCrashContext(patch) {
14
+ crashContext = { ...crashContext, ...patch };
15
+ }
16
+ /** Clear the crash context (e.g. when a session ends). */
17
+ export function clearCrashContext() {
18
+ crashContext = {};
19
+ }
20
+ /** Read the current crash context (used as the default context source by the installed handler). */
21
+ export function getCrashContext() {
22
+ return crashContext;
23
+ }
24
+ /**
25
+ * Re-entry guard. Module-level so it survives across the two listeners and any nested failure: once
26
+ * we are handling a crash, a second crash (including one thrown by the handler itself) must NOT
27
+ * re-run the snapshot logic — it goes straight to exit.
28
+ */
29
+ let handling = false;
30
+ /** Whether {@link installCrashHandler} has already registered listeners (idempotent install). */
31
+ let installed = false;
32
+ let onUncaughtException;
33
+ let onUnhandledRejection;
34
+ /** A short, never-throwing, single-block rendering of the original error for stderr. */
35
+ function describeError(error) {
36
+ try {
37
+ if (error instanceof Error) {
38
+ return error.stack ?? `${error.name}: ${error.message}`;
39
+ }
40
+ return String(error);
41
+ }
42
+ catch {
43
+ return '<unprintable error>';
44
+ }
45
+ }
46
+ /** Write a line to fd 2 (stderr) synchronously, swallowing any failure — last-resort output. */
47
+ function writeStderr(line) {
48
+ try {
49
+ writeSync(2, line);
50
+ }
51
+ catch {
52
+ // Nothing more we can safely do if even fd 2 is gone.
53
+ }
54
+ }
55
+ /**
56
+ * The crash-handling body. Exported (rather than only closed over by the listeners) so it can be
57
+ * unit-tested directly with an injected `exit` and `getContext`, without registering real process
58
+ * listeners or killing the test runner.
59
+ *
60
+ * @param error the thrown value / rejection reason
61
+ * @param origin `'uncaughtException'` | `'unhandledRejection'`
62
+ * @param exit terminator (default {@link process.exit}); injectable so tests capture the code
63
+ * @param getContext source of the snapshot context (default the module context)
64
+ */
65
+ export function handleCrash(error, origin, exit = (code) => process.exit(code), getContext = getCrashContext) {
66
+ // GUARD FIRST — before touching anything that could throw — so a failure below (or a crash raised
67
+ // WHILE handling) can never re-enter and loop.
68
+ if (handling) {
69
+ writeStderr(`\n[gaunt-sloth] crash handler re-entered while handling ${origin}; exiting.\n`);
70
+ exit(1);
71
+ return;
72
+ }
73
+ handling = true;
74
+ const original = describeError(error);
75
+ try {
76
+ const ctx = getContext();
77
+ const { crashDir } = writeCrashSnapshot({
78
+ error,
79
+ origin,
80
+ config: ctx.config,
81
+ modelDisplayName: ctx.modelDisplayName,
82
+ transcriptTail: ctx.transcriptTail,
83
+ });
84
+ // Surface the ORIGINAL error first (Node's own auto-print is suppressed by our listener), then
85
+ // the snapshot path. writeSync so the path is not truncated by the imminent process.exit.
86
+ writeStderr(`\n[gaunt-sloth] fatal ${origin}:\n${original}\n`);
87
+ writeStderr(`[gaunt-sloth] crash snapshot written to: ${crashDir}\n`);
88
+ }
89
+ catch (snapErr) {
90
+ // Snapshotting itself failed — DEGRADE: still surface the original error + a short reason, never
91
+ // mask it, never re-enter.
92
+ const reason = snapErr instanceof Error ? snapErr.message : String(snapErr);
93
+ writeStderr(`\n[gaunt-sloth] fatal ${origin}:\n${original}\n`);
94
+ writeStderr(`[gaunt-sloth] failed to write crash snapshot: ${reason}\n`);
95
+ }
96
+ exit(1);
97
+ }
98
+ /**
99
+ * Install the process-level crash handler (idempotent). Registers `uncaughtException` and
100
+ * `unhandledRejection` listeners that write a redacted snapshot and exit. Inert on a normal exit —
101
+ * no `exit`/`beforeExit` hook is registered, so a clean run behaves exactly as before.
102
+ */
103
+ export function installCrashHandler(options = {}) {
104
+ if (installed)
105
+ return;
106
+ installed = true;
107
+ const exit = options.exit ?? ((code) => process.exit(code));
108
+ const getContext = options.getContext ?? getCrashContext;
109
+ onUncaughtException = (error) => handleCrash(error, 'uncaughtException', exit, getContext);
110
+ onUnhandledRejection = (reason) => handleCrash(reason, 'unhandledRejection', exit, getContext);
111
+ process.on('uncaughtException', onUncaughtException);
112
+ process.on('unhandledRejection', onUnhandledRejection);
113
+ }
114
+ /**
115
+ * Remove the crash-handler listeners and reset internal state. Primarily for tests (so the module
116
+ * singleton's `handling`/`installed` flags don't leak between cases); harmless in production.
117
+ */
118
+ export function uninstallCrashHandler() {
119
+ if (onUncaughtException)
120
+ process.removeListener('uncaughtException', onUncaughtException);
121
+ if (onUnhandledRejection)
122
+ process.removeListener('unhandledRejection', onUnhandledRejection);
123
+ onUncaughtException = undefined;
124
+ onUnhandledRejection = undefined;
125
+ installed = false;
126
+ handling = false;
127
+ }
128
+ //# sourceMappingURL=crashHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crashHandler.js","sourceRoot":"","sources":["../../src/utils/crashHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAmD7D,gGAAgG;AAChG,IAAI,YAAY,GAAiB,EAAE,CAAC;AAEpC,2CAA2C;AAC3C,MAAM,UAAU,eAAe,CAAC,GAAiB;IAC/C,YAAY,GAAG,GAAG,IAAI,EAAE,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAA4B;IAC7D,YAAY,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,EAAE,CAAC;AAC/C,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,iBAAiB;IAC/B,YAAY,GAAG,EAAE,CAAC;AACpB,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,eAAe;IAC7B,OAA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AAC;IAC9D,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAC;IACrD,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;AACzD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,mBAAmB;QAAE,OAAO,CAAC,cAAc,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAC;IAC1F,IAAI,oBAAoB;QAAE,OAAO,CAAC,cAAc,CAAC,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;IAC7F,mBAAmB,GAAG,SAAS,CAAC;IAChC,oBAAoB,GAAG,SAAS,CAAC;IACjC,SAAS,GAAG,KAAK,CAAC;IAClB,QAAQ,GAAG,KAAK,CAAC;AACnB,CAAC"}
@@ -0,0 +1,134 @@
1
+ import type { LastModelRequest } from '#src/core/debugCapture.js';
2
+ import type { ApprovalDecisionCapture } from '#src/core/shell/approvalCapture.js';
3
+ /**
4
+ * GS2-46/GS2-47 — `/debug-dump`: a live-session diagnostic archive. GS2-46 shipped it raw; GS2-47
5
+ * adds a shared secret-redaction pass ({@link file://./redactSecrets.ts}) that is ON BY DEFAULT and
6
+ * applied to EVERY artifact before it hits disk. The caller opts out via `redact: false`, in which
7
+ * case the archive is raw and the caller surfaces the loud "may contain secrets" warning; when
8
+ * redaction is on the caller shows a softened "secrets redacted; review before sharing" note.
9
+ */
10
+ /** Input to {@link writeDebugDump}. */
11
+ export interface WriteDebugDumpInput {
12
+ /** The full transcript (all turns, tool calls + results). Opaque — serialized as JSON. */
13
+ transcript: unknown;
14
+ /** The resolved effective config (the live `GthConfig`). Opaque — serialized as JSON. */
15
+ config: unknown;
16
+ /** Model display name, already resolved by the caller. */
17
+ modelDisplayName?: string;
18
+ /**
19
+ * GS2-47 — apply the shared secret-redaction pass to every artifact before writing. Defaults to
20
+ * ON: omitted or any value other than the literal `false` redacts (read-site `!== false`, matching
21
+ * the config default so an opt-out has to be explicit). `false` writes a RAW archive (the caller
22
+ * is then responsible for the loud "may contain secrets" warning).
23
+ */
24
+ redact?: boolean;
25
+ /**
26
+ * Working directory for git-state collection. Defaults to `process.cwd()`; overridable for
27
+ * tests so the "not a git repo" / "inside a git repo" paths are both exercisable without
28
+ * depending on where the test runner happens to execute.
29
+ */
30
+ cwd?: string;
31
+ /**
32
+ * GS2-56 — the always-on snapshot of the last model request (the composed system prompt, tool
33
+ * defs with schema, model params, tool-choice, and the AS-SENT post-summarization messages),
34
+ * threaded straight from `agent.lastModelRequest` by the caller (both the TUI and the readline
35
+ * `--no-tui` surface). ADDITIVE & optional: when present, `writeDebugDump` writes
36
+ * `model-request.json` (the extras) and `model-messages.json` (the as-sent messages, distinct
37
+ * from the conversation-view `transcript.json`), both routed through the same redaction pass as
38
+ * every other artifact. Absent (no model call yet / a surface with no agent handle) ⇒ those two
39
+ * files are simply omitted.
40
+ */
41
+ modelRequest?: LastModelRequest;
42
+ /**
43
+ * [[TUI-C27]] — the approvals gate's own record of every gated decision this session made:
44
+ * **what the rater was SHOWN and what it ANSWERED**, on the approving branch as much as the
45
+ * rejecting one, plus which stage of the gate decided.
46
+ *
47
+ * Threaded straight from `runner.getApprovalCaptures()` by the caller, exactly as
48
+ * {@link modelRequest} is threaded from the agent. ADDITIVE & optional: present and non-empty ⇒
49
+ * `approvals.json`; absent or empty ⇒ the file is simply omitted (a session that gated nothing
50
+ * has nothing to say about it).
51
+ *
52
+ * It goes through the same {@link renderStructured} pass as `transcript.json` and
53
+ * `model-messages.json` — the [[GS2-47]]/[[GS2-54]] literal + pattern redaction over the secret
54
+ * values {@link collectSecretValues} harvested from env and config. That is deliberate reuse
55
+ * rather than a policy of its own: the captured rating prompt carries the user's own last five
56
+ * messages verbatim plus the command, so it is at least as sensitive as the transcript, and a
57
+ * second redaction policy for one artifact is how two policies come to disagree.
58
+ */
59
+ approvals?: readonly ApprovalDecisionCapture[];
60
+ }
61
+ export interface WriteDebugDumpResult {
62
+ /** The absolute path to the archive directory just written. */
63
+ archiveDir: string;
64
+ }
65
+ /**
66
+ * The filesystem-safe directory-name segment for one dump: the ISO timestamp with `:` and `.`
67
+ * (illegal on Windows, noisy everywhere) replaced by `-`. This is the ONLY path component
68
+ * debugDump generates — and the only one it is responsible for sanitizing. The parent it is joined
69
+ * under (the global `~/.gsloth` dir) is supplied by the environment and may legitimately carry a
70
+ * drive-letter colon on Windows (`C:\…`), which is not ours to strip. Exported so the invariant
71
+ * "the generated segment is colon-free" is testable on any platform without asserting anything
72
+ * about the (platform-dependent) parent path (GS2-50).
73
+ */
74
+ export declare function debugDumpDirName(date?: Date): string;
75
+ /**
76
+ * Write one timestamped `/debug-dump` archive under the GLOBAL `~/.gsloth/debug-dumps/<timestamp>/`
77
+ * (via `ensureGlobalGslothDir()` — mirrors how `resolveHistoryDbPath()` builds its path under the
78
+ * same dir — NOT the per-project cwd-relative helper of the same name elsewhere in this codebase).
79
+ * Contains: the full transcript, the resolved config, env/version info, the in-memory debugLog
80
+ * ring buffer, and (best-effort) git repo state.
81
+ *
82
+ * GS2-47 — unless `input.redact === false`, the shared secret-redaction pass
83
+ * ({@link file://./redactSecrets.ts}) is applied to EVERY artifact before it is written: the literal
84
+ * values of secret-named env vars + inline config secrets are substituted everywhere, a tight set of
85
+ * provider-key/auth-header patterns is masked, and the config's sensitive fields are masked in place.
86
+ * On opt-out the archive is raw and the caller surfaces the loud "may contain secrets" warning.
87
+ */
88
+ export declare function writeDebugDump(input: WriteDebugDumpInput): WriteDebugDumpResult;
89
+ /** Input to {@link writeCrashSnapshot}. */
90
+ export interface WriteCrashSnapshotInput {
91
+ /** The thrown error / rejection reason. Need not be an `Error`. */
92
+ error: unknown;
93
+ /** Where the failure came from — e.g. `'uncaughtException'` / `'unhandledRejection'`. */
94
+ origin: string;
95
+ /** The effective resolved config, if the crashing process had one registered. Opaque. */
96
+ config?: unknown;
97
+ /** Model display name, if known. */
98
+ modelDisplayName?: string;
99
+ /** The in-flight turn's transcript tail, if a session registered one. Opaque. */
100
+ transcriptTail?: unknown;
101
+ }
102
+ export interface WriteCrashSnapshotResult {
103
+ /** The absolute path to the crash directory just written. */
104
+ crashDir: string;
105
+ /** The absolute path to the `crash.json` file inside it. */
106
+ crashFile: string;
107
+ }
108
+ /**
109
+ * GS2-48 — write a MINIMAL, ALWAYS-REDACTED crash snapshot to
110
+ * `~/.gsloth/debug-dumps/crash-<timestamp>/crash.json` and return its paths.
111
+ *
112
+ * This is the unattended sibling of {@link writeDebugDump}: it fires from the process-level crash
113
+ * handler ({@link file://./crashHandler.ts}) with no human present, so — unlike `/debug-dump` — it
114
+ * exposes NO `redact` opt-out. Redaction (GS2-47, hard-dep) is MANDATORY and applied to the whole
115
+ * snapshot. It reuses this module's location convention (`ensureGlobalGslothDir()` + `debug-dumps/`)
116
+ * and rendering helpers, but deliberately stays minimal and crash-safe:
117
+ * - a SINGLE `crash.json` (not the multi-file interactive archive);
118
+ * - it does NOT shell out for git state (a subprocess is unsafe/slow while the process is dying);
119
+ * - it keeps only the last {@link CRASH_DEBUG_LOG_TAIL_LINES} debugLog lines and the transcript TAIL.
120
+ *
121
+ * Redaction shape (conscious choice): the entire normalized snapshot is passed through
122
+ * {@link redactValue} in one pass. That is stricter than {@link writeDebugDump}, which uses
123
+ * {@link redactText} (literal+pattern only) for its non-config artifacts to avoid field-masking a
124
+ * legitimately `token`/`secret`-named field in tool output. For an unattended crash file the
125
+ * over-masking is the SAFE direction and buys uniform circular-ref / depth / function handling in
126
+ * one place, so it is intended, not an oversight. The config subtree is stripped of live instances
127
+ * first (as `writeDebugDump` does) so a live LLM client's internals never serialize.
128
+ *
129
+ * Callers wrap this in their own try/catch (see {@link file://./crashHandler.ts}); it does its best
130
+ * to be fail-safe internally (`redactValue`/`safeStringify` never throw), but the ONE unavoidably
131
+ * throwing operation is the `mkdirSync`/`writeFileSync` to disk — an unwritable `~/.gsloth` is what
132
+ * the handler's degraded path is for.
133
+ */
134
+ export declare function writeCrashSnapshot(input: WriteCrashSnapshotInput): WriteCrashSnapshotResult;