@gaunt-sloth/core 2.0.0-alpha.3 → 2.0.0-alpha.30

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 (271) hide show
  1. package/README.md +52 -20
  2. package/dist/config/colour.d.ts +38 -0
  3. package/dist/config/colour.js +36 -0
  4. package/dist/config/colour.js.map +1 -0
  5. package/dist/config/defaults.d.ts +84 -0
  6. package/dist/config/defaults.js +99 -0
  7. package/dist/config/defaults.js.map +1 -0
  8. package/dist/config/filesystem-tools.d.ts +41 -0
  9. package/dist/config/filesystem-tools.js +56 -0
  10. package/dist/config/filesystem-tools.js.map +1 -0
  11. package/dist/config/jsonc.d.ts +12 -0
  12. package/dist/config/jsonc.js +41 -0
  13. package/dist/config/jsonc.js.map +1 -0
  14. package/dist/config/loader.d.ts +246 -0
  15. package/dist/config/loader.js +1321 -0
  16. package/dist/config/loader.js.map +1 -0
  17. package/dist/config/mouse.d.ts +50 -0
  18. package/dist/config/mouse.js +44 -0
  19. package/dist/config/mouse.js.map +1 -0
  20. package/dist/config/profiles.d.ts +68 -0
  21. package/dist/config/profiles.js +93 -0
  22. package/dist/config/profiles.js.map +1 -0
  23. package/dist/config/providerKeys.d.ts +69 -0
  24. package/dist/config/providerKeys.js +69 -0
  25. package/dist/config/providerKeys.js.map +1 -0
  26. package/dist/config/schema.d.ts +2999 -0
  27. package/dist/config/schema.js +1519 -0
  28. package/dist/config/schema.js.map +1 -0
  29. package/dist/config/shell-policy.d.ts +896 -0
  30. package/dist/config/shell-policy.js +750 -0
  31. package/dist/config/shell-policy.js.map +1 -0
  32. package/dist/config/tool-descriptions.d.ts +211 -0
  33. package/dist/config/tool-descriptions.js +272 -0
  34. package/dist/config/tool-descriptions.js.map +1 -0
  35. package/dist/config/types.d.ts +760 -0
  36. package/dist/config/types.js +13 -0
  37. package/dist/config/types.js.map +1 -0
  38. package/dist/config.d.ts +34 -827
  39. package/dist/config.js +25 -657
  40. package/dist/config.js.map +1 -1
  41. package/dist/constants.d.ts +46 -0
  42. package/dist/constants.js +46 -0
  43. package/dist/constants.js.map +1 -1
  44. package/dist/core/GthAbstractAgent.d.ts +135 -2
  45. package/dist/core/GthAbstractAgent.js +496 -30
  46. package/dist/core/GthAbstractAgent.js.map +1 -1
  47. package/dist/core/GthAgentRunner.d.ts +568 -54
  48. package/dist/core/GthAgentRunner.js +1537 -136
  49. package/dist/core/GthAgentRunner.js.map +1 -1
  50. package/dist/core/GthLangChainAgent.d.ts +115 -0
  51. package/dist/core/GthLangChainAgent.js +644 -17
  52. package/dist/core/GthLangChainAgent.js.map +1 -1
  53. package/dist/core/approvals/annotations.d.ts +122 -0
  54. package/dist/core/approvals/annotations.js +137 -0
  55. package/dist/core/approvals/annotations.js.map +1 -0
  56. package/dist/core/approvals/grants.d.ts +216 -0
  57. package/dist/core/approvals/grants.js +469 -0
  58. package/dist/core/approvals/grants.js.map +1 -0
  59. package/dist/core/approvals/matcher.d.ts +202 -0
  60. package/dist/core/approvals/matcher.js +267 -0
  61. package/dist/core/approvals/matcher.js.map +1 -0
  62. package/dist/core/approvals/mcpSubjects.d.ts +40 -0
  63. package/dist/core/approvals/mcpSubjects.js +99 -0
  64. package/dist/core/approvals/mcpSubjects.js.map +1 -0
  65. package/dist/core/approvals/toolAnnotationSources.d.ts +105 -0
  66. package/dist/core/approvals/toolAnnotationSources.js +277 -0
  67. package/dist/core/approvals/toolAnnotationSources.js.map +1 -0
  68. package/dist/core/approvals/toolHost.d.ts +46 -0
  69. package/dist/core/approvals/toolHost.js +108 -0
  70. package/dist/core/approvals/toolHost.js.map +1 -0
  71. package/dist/core/debugCapture.d.ts +75 -0
  72. package/dist/core/debugCapture.js +101 -0
  73. package/dist/core/debugCapture.js.map +1 -0
  74. package/dist/core/gthLeanAgentFactory.d.ts +9 -0
  75. package/dist/core/gthLeanAgentFactory.js +10 -0
  76. package/dist/core/gthLeanAgentFactory.js.map +1 -0
  77. package/dist/core/launchBanner.d.ts +120 -0
  78. package/dist/core/launchBanner.js +418 -0
  79. package/dist/core/launchBanner.js.map +1 -0
  80. package/dist/core/plainToolIndication.d.ts +15 -0
  81. package/dist/core/plainToolIndication.js +174 -0
  82. package/dist/core/plainToolIndication.js.map +1 -0
  83. package/dist/core/reasoningBlocks.d.ts +60 -0
  84. package/dist/core/reasoningBlocks.js +98 -0
  85. package/dist/core/reasoningBlocks.js.map +1 -0
  86. package/dist/core/refusal.d.ts +53 -0
  87. package/dist/core/refusal.js +133 -0
  88. package/dist/core/refusal.js.map +1 -0
  89. package/dist/core/runStats.d.ts +52 -0
  90. package/dist/core/runStats.js +118 -0
  91. package/dist/core/runStats.js.map +1 -0
  92. package/dist/core/shell/ShellCommandFailedError.d.ts +54 -0
  93. package/dist/core/shell/ShellCommandFailedError.js +68 -0
  94. package/dist/core/shell/ShellCommandFailedError.js.map +1 -0
  95. package/dist/core/shell/abstention.d.ts +88 -0
  96. package/dist/core/shell/abstention.js +184 -0
  97. package/dist/core/shell/abstention.js.map +1 -0
  98. package/dist/core/shell/approvalCapture.d.ts +271 -0
  99. package/dist/core/shell/approvalCapture.js +108 -0
  100. package/dist/core/shell/approvalCapture.js.map +1 -0
  101. package/dist/core/shell/approvalStop.d.ts +84 -0
  102. package/dist/core/shell/approvalStop.js +119 -0
  103. package/dist/core/shell/approvalStop.js.map +1 -0
  104. package/dist/core/shell/arity.d.ts +6 -0
  105. package/dist/core/shell/arity.js +20 -6
  106. package/dist/core/shell/arity.js.map +1 -1
  107. package/dist/core/shell/denylist.d.ts +11 -0
  108. package/dist/core/shell/denylist.js +37 -0
  109. package/dist/core/shell/denylist.js.map +1 -0
  110. package/dist/core/shell/escalationSeverity.d.ts +141 -0
  111. package/dist/core/shell/escalationSeverity.js +89 -0
  112. package/dist/core/shell/escalationSeverity.js.map +1 -0
  113. package/dist/core/shell/framing.d.ts +190 -0
  114. package/dist/core/shell/framing.js +633 -0
  115. package/dist/core/shell/framing.js.map +1 -0
  116. package/dist/core/shell/hardline.d.ts +81 -0
  117. package/dist/core/shell/hardline.js +607 -0
  118. package/dist/core/shell/hardline.js.map +1 -0
  119. package/dist/core/shell/negotiation.d.ts +249 -0
  120. package/dist/core/shell/negotiation.js +355 -0
  121. package/dist/core/shell/negotiation.js.map +1 -0
  122. package/dist/core/shell/normalize.d.ts +44 -4
  123. package/dist/core/shell/normalize.js +61 -7
  124. package/dist/core/shell/normalize.js.map +1 -1
  125. package/dist/core/shell/openWorld.d.ts +263 -0
  126. package/dist/core/shell/openWorld.js +1188 -0
  127. package/dist/core/shell/openWorld.js.map +1 -0
  128. package/dist/core/shell/rater.d.ts +935 -0
  129. package/dist/core/shell/rater.js +1473 -0
  130. package/dist/core/shell/rater.js.map +1 -0
  131. package/dist/core/shell/raterModel.d.ts +41 -0
  132. package/dist/core/shell/raterModel.js +51 -0
  133. package/dist/core/shell/raterModel.js.map +1 -0
  134. package/dist/core/shell/rejection.d.ts +69 -0
  135. package/dist/core/shell/rejection.js +38 -0
  136. package/dist/core/shell/rejection.js.map +1 -0
  137. package/dist/core/toolCallRepair/grammar.d.ts +41 -0
  138. package/dist/core/toolCallRepair/grammar.js +116 -0
  139. package/dist/core/toolCallRepair/grammar.js.map +1 -0
  140. package/dist/core/toolCallRepair/index.d.ts +2 -0
  141. package/dist/core/toolCallRepair/index.js +7 -0
  142. package/dist/core/toolCallRepair/index.js.map +1 -0
  143. package/dist/core/toolCallRepair/payload.d.ts +36 -0
  144. package/dist/core/toolCallRepair/payload.js +341 -0
  145. package/dist/core/toolCallRepair/payload.js.map +1 -0
  146. package/dist/core/toolCallRepair/promote.d.ts +45 -0
  147. package/dist/core/toolCallRepair/promote.js +90 -0
  148. package/dist/core/toolCallRepair/promote.js.map +1 -0
  149. package/dist/core/toolDisplay.d.ts +123 -0
  150. package/dist/core/toolDisplay.js +451 -0
  151. package/dist/core/toolDisplay.js.map +1 -0
  152. package/dist/core/toolOutputChannel.d.ts +95 -0
  153. package/dist/core/toolOutputChannel.js +165 -0
  154. package/dist/core/toolOutputChannel.js.map +1 -0
  155. package/dist/core/types.d.ts +294 -12
  156. package/dist/core/types.js.map +1 -1
  157. package/dist/history/historyFormat.d.ts +28 -0
  158. package/dist/history/historyFormat.js +127 -0
  159. package/dist/history/historyFormat.js.map +1 -0
  160. package/dist/history/historyStore.d.ts +198 -0
  161. package/dist/history/historyStore.js +482 -0
  162. package/dist/history/historyStore.js.map +1 -0
  163. package/dist/history/recordSession.d.ts +37 -0
  164. package/dist/history/recordSession.js +56 -0
  165. package/dist/history/recordSession.js.map +1 -0
  166. package/dist/index.d.ts +4 -0
  167. package/dist/index.js +4 -0
  168. package/dist/index.js.map +1 -1
  169. package/dist/providers/anthropic.d.ts +1 -1
  170. package/dist/providers/anthropic.js +5 -10
  171. package/dist/providers/anthropic.js.map +1 -1
  172. package/dist/providers/deepseek.d.ts +1 -1
  173. package/dist/providers/deepseek.js +5 -10
  174. package/dist/providers/deepseek.js.map +1 -1
  175. package/dist/providers/geminiSchemaSanitizer.d.ts +55 -0
  176. package/dist/providers/geminiSchemaSanitizer.js +347 -0
  177. package/dist/providers/geminiSchemaSanitizer.js.map +1 -0
  178. package/dist/providers/geminiThinking.d.ts +52 -0
  179. package/dist/providers/geminiThinking.js +72 -0
  180. package/dist/providers/geminiThinking.js.map +1 -0
  181. package/dist/providers/google-genai.d.ts +1 -1
  182. package/dist/providers/google-genai.js +12 -11
  183. package/dist/providers/google-genai.js.map +1 -1
  184. package/dist/providers/groq.d.ts +1 -1
  185. package/dist/providers/groq.js +5 -10
  186. package/dist/providers/groq.js.map +1 -1
  187. package/dist/providers/huggingface.d.ts +25 -0
  188. package/dist/providers/huggingface.js +69 -0
  189. package/dist/providers/huggingface.js.map +1 -0
  190. package/dist/providers/modelCatalog.d.ts +109 -0
  191. package/dist/providers/modelCatalog.js +245 -0
  192. package/dist/providers/modelCatalog.js.map +1 -0
  193. package/dist/providers/modelDiscovery.d.ts +153 -6
  194. package/dist/providers/modelDiscovery.js +295 -41
  195. package/dist/providers/modelDiscovery.js.map +1 -1
  196. package/dist/providers/ollama.d.ts +19 -5
  197. package/dist/providers/ollama.js +60 -52
  198. package/dist/providers/ollama.js.map +1 -1
  199. package/dist/providers/openai.d.ts +1 -1
  200. package/dist/providers/openai.js +39 -10
  201. package/dist/providers/openai.js.map +1 -1
  202. package/dist/providers/openrouter.d.ts +4 -5
  203. package/dist/providers/openrouter.js +20 -35
  204. package/dist/providers/openrouter.js.map +1 -1
  205. package/dist/providers/vertexai.d.ts +1 -1
  206. package/dist/providers/vertexai.js +12 -11
  207. package/dist/providers/vertexai.js.map +1 -1
  208. package/dist/providers/xai.d.ts +1 -1
  209. package/dist/providers/xai.js +5 -10
  210. package/dist/providers/xai.js.map +1 -1
  211. package/dist/runtime/askStructured.d.ts +105 -0
  212. package/dist/runtime/askStructured.js +120 -0
  213. package/dist/runtime/askStructured.js.map +1 -0
  214. package/dist/runtime/conversation.d.ts +60 -0
  215. package/dist/runtime/conversation.js +151 -0
  216. package/dist/runtime/conversation.js.map +1 -0
  217. package/dist/runtime/singleShot.d.ts +25 -5
  218. package/dist/runtime/singleShot.js +95 -36
  219. package/dist/runtime/singleShot.js.map +1 -1
  220. package/dist/runtime/structuredOutput.d.ts +104 -0
  221. package/dist/runtime/structuredOutput.js +393 -0
  222. package/dist/runtime/structuredOutput.js.map +1 -0
  223. package/dist/utils/ProgressIndicator.d.ts +21 -0
  224. package/dist/utils/ProgressIndicator.js +30 -3
  225. package/dist/utils/ProgressIndicator.js.map +1 -1
  226. package/dist/utils/aiignoreUtils.js.map +1 -1
  227. package/dist/utils/binaryOutputUtils.js.map +1 -1
  228. package/dist/utils/consoleUtils.d.ts +52 -0
  229. package/dist/utils/consoleUtils.js +72 -2
  230. package/dist/utils/consoleUtils.js.map +1 -1
  231. package/dist/utils/crashHandler.d.ts +87 -0
  232. package/dist/utils/crashHandler.js +128 -0
  233. package/dist/utils/crashHandler.js.map +1 -0
  234. package/dist/utils/debugDump.d.ts +134 -0
  235. package/dist/utils/debugDump.js +381 -0
  236. package/dist/utils/debugDump.js.map +1 -0
  237. package/dist/utils/debugUtils.d.ts +13 -4
  238. package/dist/utils/debugUtils.js +36 -13
  239. package/dist/utils/debugUtils.js.map +1 -1
  240. package/dist/utils/displayWidth.d.ts +53 -0
  241. package/dist/utils/displayWidth.js +195 -0
  242. package/dist/utils/displayWidth.js.map +1 -0
  243. package/dist/utils/fileUtils.d.ts +24 -2
  244. package/dist/utils/fileUtils.js +54 -12
  245. package/dist/utils/fileUtils.js.map +1 -1
  246. package/dist/utils/llmUtils.d.ts +39 -8
  247. package/dist/utils/llmUtils.js +76 -8
  248. package/dist/utils/llmUtils.js.map +1 -1
  249. package/dist/utils/redactSecrets.d.ts +63 -0
  250. package/dist/utils/redactSecrets.js +286 -0
  251. package/dist/utils/redactSecrets.js.map +1 -0
  252. package/dist/utils/systemPromptNotes.d.ts +225 -0
  253. package/dist/utils/systemPromptNotes.js +340 -0
  254. package/dist/utils/systemPromptNotes.js.map +1 -0
  255. package/dist/utils/systemUtils.d.ts +49 -1
  256. package/dist/utils/systemUtils.js +67 -3
  257. package/dist/utils/systemUtils.js.map +1 -1
  258. package/dist/utils/toolMatching.d.ts +30 -0
  259. package/dist/utils/toolMatching.js +44 -0
  260. package/dist/utils/toolMatching.js.map +1 -0
  261. package/dist/utils/untrustedText.d.ts +66 -0
  262. package/dist/utils/untrustedText.js +80 -0
  263. package/dist/utils/untrustedText.js.map +1 -0
  264. package/package.json +22 -6
  265. package/schema/gsloth-config.schema.json +3134 -0
  266. package/dist/core/shell/allowlist.d.ts +0 -75
  267. package/dist/core/shell/allowlist.js +0 -187
  268. package/dist/core/shell/allowlist.js.map +0 -1
  269. package/dist/core/shell/judge.d.ts +0 -161
  270. package/dist/core/shell/judge.js +0 -261
  271. package/dist/core/shell/judge.js.map +0 -1
@@ -0,0 +1,120 @@
1
+ /**
2
+ * @module runtime/askStructured
3
+ *
4
+ * A reusable, non-agentic "ask the LLM and get a schema-validated object back" primitive — the
5
+ * structured-output half the (later) `gth workflow` host calls. Deliberately mirrors the
6
+ * *mechanism* of the structured-evaluation calls ({@link judgeEvalCase} — the EVAL GRADER in
7
+ * `@gaunt-sloth/batch`'s `judge.ts` — and its in-core sibling {@link rateShellCommand}, the
8
+ * approvals AI rater in `core/shell/rater.ts`):
9
+ * `model.withStructuredOutput(schema)` for a single structured call, `.invoke([SystemMessage,
10
+ * HumanMessage])` raced against a wall-clock timeout via `Promise.race`, a defensive `safeParse`
11
+ * re-validation, `clearTimeout` in `finally`, and — crucially — it **never throws**, returning a
12
+ * failure object instead.
13
+ *
14
+ * Differences from those two: this one is **generic** over the Zod schema and takes the
15
+ * system/user strings from the caller (they hard-code a schema and build a rubric/safety
16
+ * prompt), and it reads the model from `config.llm` (like `runSingleShot`/`rateShellCommand`),
17
+ * so the workflow host can hand it the resolved {@link GthConfig} directly. `judgeEvalCase` could
18
+ * later be refactored to delegate to this primitive — out of scope here.
19
+ */
20
+ import { HumanMessage, SystemMessage } from '@langchain/core/messages';
21
+ import { structuredOutputBoundary } from '#src/runtime/structuredOutput.js';
22
+ /**
23
+ * Default wall-clock budget (ms) for the structured LLM call — same value as their
24
+ * `EVAL_JUDGE_DEFAULT_TIMEOUT_MS` / `JUDGE_DEFAULT_TIMEOUT_MS`, kept as this module's own constant
25
+ * since the primitive is conceptually independent of them.
26
+ */
27
+ export const ASK_STRUCTURED_DEFAULT_TIMEOUT_MS = 30_000;
28
+ /**
29
+ * The exact `error` text {@link askStructured} returns when its wall-clock budget fires — i.e. the
30
+ * provider produced **no answer at all** within the budget.
31
+ *
32
+ * Exported as a builder rather than left as an inline literal because the three failure classes here
33
+ * (no response · an answer that does not fit the schema · a call that failed outright) are the
34
+ * question a reader of a red run has to answer first, and they are only distinguishable by this text.
35
+ * A caller that re-types the sentence to recognise it stops recognising it the day the wording moves,
36
+ * and silently re-files a stall as a rejection — which is precisely the confusion this exists to end.
37
+ */
38
+ export function structuredCallTimedOutError(timeoutMs) {
39
+ return `Structured call timed out after ${timeoutMs}ms with no response from the provider.`;
40
+ }
41
+ /**
42
+ * The exact `error` text {@link askStructured} returns when the provider **did** answer and the
43
+ * answer failed the caller's own schema. The counterpart of {@link structuredCallTimedOutError};
44
+ * see that doc for why both are exported rather than written inline.
45
+ */
46
+ export const STRUCTURED_CALL_UNPARSEABLE_ERROR = 'Model returned unparseable output.';
47
+ /**
48
+ * Name which failure happened, given the `error` string and the budget the call was made with.
49
+ *
50
+ * The single place the three classes are told apart. A stall and a rejection are the two failures a
51
+ * reader has to distinguish first and the two that look most alike from the outside — a red that
52
+ * cannot say which happened sends the reader to re-run a real defect, or to investigate a provider
53
+ * hiccup. Every caller that wants to say which one it was calls this rather than matching the prose
54
+ * itself, so the wording can only be got wrong in one place, and that place has a test.
55
+ *
56
+ * @param error The `error` from a `{ ok: false }` {@link AskStructuredResult}.
57
+ * @param timeoutMs The budget passed to that same {@link askStructured} call — the timeout text
58
+ * carries it, so a different value here reports a genuine timeout as `call-failed`.
59
+ */
60
+ export function classifyStructuredFailure(error, timeoutMs) {
61
+ if (error === structuredCallTimedOutError(timeoutMs))
62
+ return 'timeout';
63
+ if (error === STRUCTURED_CALL_UNPARSEABLE_ERROR)
64
+ return 'unparseable';
65
+ return 'call-failed';
66
+ }
67
+ /**
68
+ * Ask the configured model for a single schema-validated object — a non-agentic structured-output
69
+ * call that mirrors their mechanism (see the module doc) and never throws.
70
+ *
71
+ * - No usable model (`config.llm` missing or lacking `withStructuredOutput`) →
72
+ * `{ ok: false, error: 'No usable model configured.' }`.
73
+ * - Timeout → `ok: false` with the error {@link structuredCallTimedOutError} builds for that budget.
74
+ * - Output that fails `schema.safeParse` → `{ ok: false, error: {@link STRUCTURED_CALL_UNPARSEABLE_ERROR} }`.
75
+ * - Any thrown error → `{ ok: false, error: <message> }` — a provider rejection (e.g. OpenAI's 400 on
76
+ * a strict `json_schema`), an auth or transport failure. Distinct from the two above BY CODE PATH,
77
+ * so a caller can classify a failure by comparing against those two exported texts.
78
+ * - Success → `{ ok: true, value }` with the parsed data.
79
+ *
80
+ * @param schema The Zod schema the model output must satisfy; `<T>` is inferred from it.
81
+ * @param opts The model (via `config.llm`), the system/user message texts, and an optional timeout.
82
+ */
83
+ export async function askStructured(schema, opts) {
84
+ const { config, system, user } = opts;
85
+ const timeoutMs = opts.timeoutMs ?? ASK_STRUCTURED_DEFAULT_TIMEOUT_MS;
86
+ const model = config.llm;
87
+ if (!model || typeof model.withStructuredOutput !== 'function') {
88
+ return { ok: false, error: 'No usable model configured.' };
89
+ }
90
+ let timer;
91
+ try {
92
+ // EXT-88 — caller schemas are arbitrary, so this is the call site with the widest exposure to
93
+ // the optional-field problem the boundary exists for; it also does the defensive re-validation
94
+ // below, against the caller's own schema, so `<T>` is exactly what the caller declared.
95
+ const boundary = structuredOutputBoundary(schema);
96
+ const structured = model.withStructuredOutput(boundary.wireSchema);
97
+ const invokePromise = structured.invoke([new SystemMessage(system), new HumanMessage(user)]);
98
+ const TIMEOUT = Symbol('ask-structured-timeout');
99
+ const timeoutPromise = new Promise((resolve) => {
100
+ timer = setTimeout(() => resolve(TIMEOUT), timeoutMs);
101
+ });
102
+ const raced = await Promise.race([invokePromise, timeoutPromise]);
103
+ if (raced === TIMEOUT) {
104
+ return { ok: false, error: structuredCallTimedOutError(timeoutMs) };
105
+ }
106
+ const parsed = boundary.safeParse(raced);
107
+ if (!parsed.success) {
108
+ return { ok: false, error: STRUCTURED_CALL_UNPARSEABLE_ERROR };
109
+ }
110
+ return { ok: true, value: parsed.data };
111
+ }
112
+ catch (error) {
113
+ return { ok: false, error: error instanceof Error ? error.message : String(error) };
114
+ }
115
+ finally {
116
+ if (timer)
117
+ clearTimeout(timer);
118
+ }
119
+ }
120
+ //# sourceMappingURL=askStructured.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"askStructured.js","sourceRoot":"","sources":["../../src/runtime/askStructured.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,YAAY,EA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CAAC"}
@@ -0,0 +1,60 @@
1
+ import type { GthConfig } from '#src/config.js';
2
+ import type { AgentResolvers, GthAgentFactory, GthCommand } from '#src/core/types.js';
3
+ import type { GthRunStats } from '#src/core/types.js';
4
+ /**
5
+ * One turn's result inside a {@link runConversation} run: the per-turn `ok`/`answer` plus that
6
+ * turn's run stats (GS2-16 {@link GthRunStats} — token usage + invoked tools), captured PER TURN (a
7
+ * per-invoke delta, not the cumulative conversation total). `ok` is `false` when that turn's agent
8
+ * invocation failed (`error` set, `answer` empty). Extends `GthRunStats` rather than restating its
9
+ * fields — same shape {@link ../runtime/singleShot.js SingleShotResult} uses.
10
+ */
11
+ export interface ConversationTurnResult extends GthRunStats {
12
+ /** `true` when this turn completed without error, `false` when it failed. */
13
+ ok: boolean;
14
+ /** This turn's full answer text (`runner.processMessages()`'s return value). Empty on failure. */
15
+ answer: string;
16
+ /** Set when `ok` is `false`: why this turn failed. */
17
+ error?: string;
18
+ }
19
+ /**
20
+ * Run a scripted MULTI-TURN conversation and return one {@link ConversationTurnResult} per turn.
21
+ *
22
+ * This is the **conversational** counterpart to {@link ../runtime/singleShot.js runSingleShot}
23
+ * (which is stateless — a fresh agent per call). It builds the agent + resolves tools ONCE, then
24
+ * runs each turn against the ACCUMULATED message history so cross-turn "memory" / identity behaviour
25
+ * is real, and cleans up ONCE at the end (reusing runSingleShot's cleanup discipline — the resolvers
26
+ * are the caller's to tear down, exactly as with runSingleShot).
27
+ *
28
+ * **History mechanism = stateless replay of the growing message array.** Messages accumulate as
29
+ * `[user1, ai1, user2, ai2, …]`: per turn a `HumanMessage(user)` is appended, the agent runs on the
30
+ * WHOLE array, and its answer is appended as an `AIMessage` so the next turn sees it. The system
31
+ * prompt is NOT seeded here — the agent composes it via `createAgent({ systemPrompt })` (BATCH-13;
32
+ * see `runSingleShot`), so the replayed array carries only human/assistant turns. Before each
33
+ * turn the runner's thread is rotated ({@link GthAgentRunner.resetThread}) so the checkpointer starts
34
+ * empty and the replayed array is the sole history (no `add_messages` double-append). This mirrors
35
+ * the AG-UI server's "client is the source of truth for history — it sends the full message list
36
+ * every turn" model and reuses the existing `processMessages` + `resetThread` machinery with no new
37
+ * agent surface. **Known limitation (unverified pending a live pass):** replay carries prior
38
+ * *answers* (as `AIMessage` text) but NOT prior tool-call / tool-result messages — a checkpointer-
39
+ * thread approach (send only the new message, let `add_messages` accumulate) would preserve those.
40
+ *
41
+ * **Per-turn tool capture (GS2-16):** `processMessages` resets the analytics tally at its top, so
42
+ * `getRunStats()` read right after each turn returns THAT turn's tool/token delta (not cumulative).
43
+ *
44
+ * A turn that fails is recorded (`ok:false`, `error`) and the conversation STOPS (later turns depend
45
+ * on the broken context), so the returned array may be shorter than `userMessages` — the caller
46
+ * (`gth eval`'s runner) fails the un-run turns.
47
+ *
48
+ * @param source - The source label (used for output/session-file naming), e.g. `EVAL-<cellId>`.
49
+ * @param _preamble - Deprecated/ignored (BATCH-13): the agent composes the system prompt itself (via
50
+ * `createAgent({ systemPrompt })`); seeding it here too produced a second system message that
51
+ * `@langchain/anthropic` rejects. Retained positionally so existing callers need no change.
52
+ * @param userMessages - The ordered user turns to send (one conversation).
53
+ * @param config - The resolved config.
54
+ * @param resolvers - Optional agent resolvers (tools/middleware); the caller owns their cleanup.
55
+ * @param command - The originating command (defaults to `ask`); selects the agent mode prompt.
56
+ * @param agentFactory - Optional backend factory (B5); omitted = the runner's lean default, and a
57
+ * config asking for `agent.backend: 'deep'` is warned about rather than silently dropped.
58
+ * @returns One {@link ConversationTurnResult} per turn attempted, in turn order.
59
+ */
60
+ export declare function runConversation(source: string, _preamble: string, userMessages: string[], config: GthConfig, resolvers?: AgentResolvers, command?: GthCommand, agentFactory?: GthAgentFactory): Promise<ConversationTurnResult[]>;
@@ -0,0 +1,151 @@
1
+ import { defaultStatusCallback, display, displayError, displaySuccess, flushSessionLog, initSessionLogging, stopSessionLogging, } from '#src/utils/consoleUtils.js';
2
+ import { getCommandOutputFilePath } from '#src/utils/fileUtils.js';
3
+ import { GthAgentRunner } from '#src/core/GthAgentRunner.js';
4
+ import { MemorySaver } from '@langchain/langgraph';
5
+ import { AIMessage, HumanMessage } from '@langchain/core/messages';
6
+ import { ProgressIndicator } from '#src/utils/ProgressIndicator.js';
7
+ import { recordSessionSafe } from '#src/history/recordSession.js';
8
+ import { getProjectDir } from '#src/utils/systemUtils.js';
9
+ /**
10
+ * Run a scripted MULTI-TURN conversation and return one {@link ConversationTurnResult} per turn.
11
+ *
12
+ * This is the **conversational** counterpart to {@link ../runtime/singleShot.js runSingleShot}
13
+ * (which is stateless — a fresh agent per call). It builds the agent + resolves tools ONCE, then
14
+ * runs each turn against the ACCUMULATED message history so cross-turn "memory" / identity behaviour
15
+ * is real, and cleans up ONCE at the end (reusing runSingleShot's cleanup discipline — the resolvers
16
+ * are the caller's to tear down, exactly as with runSingleShot).
17
+ *
18
+ * **History mechanism = stateless replay of the growing message array.** Messages accumulate as
19
+ * `[user1, ai1, user2, ai2, …]`: per turn a `HumanMessage(user)` is appended, the agent runs on the
20
+ * WHOLE array, and its answer is appended as an `AIMessage` so the next turn sees it. The system
21
+ * prompt is NOT seeded here — the agent composes it via `createAgent({ systemPrompt })` (BATCH-13;
22
+ * see `runSingleShot`), so the replayed array carries only human/assistant turns. Before each
23
+ * turn the runner's thread is rotated ({@link GthAgentRunner.resetThread}) so the checkpointer starts
24
+ * empty and the replayed array is the sole history (no `add_messages` double-append). This mirrors
25
+ * the AG-UI server's "client is the source of truth for history — it sends the full message list
26
+ * every turn" model and reuses the existing `processMessages` + `resetThread` machinery with no new
27
+ * agent surface. **Known limitation (unverified pending a live pass):** replay carries prior
28
+ * *answers* (as `AIMessage` text) but NOT prior tool-call / tool-result messages — a checkpointer-
29
+ * thread approach (send only the new message, let `add_messages` accumulate) would preserve those.
30
+ *
31
+ * **Per-turn tool capture (GS2-16):** `processMessages` resets the analytics tally at its top, so
32
+ * `getRunStats()` read right after each turn returns THAT turn's tool/token delta (not cumulative).
33
+ *
34
+ * A turn that fails is recorded (`ok:false`, `error`) and the conversation STOPS (later turns depend
35
+ * on the broken context), so the returned array may be shorter than `userMessages` — the caller
36
+ * (`gth eval`'s runner) fails the un-run turns.
37
+ *
38
+ * @param source - The source label (used for output/session-file naming), e.g. `EVAL-<cellId>`.
39
+ * @param _preamble - Deprecated/ignored (BATCH-13): the agent composes the system prompt itself (via
40
+ * `createAgent({ systemPrompt })`); seeding it here too produced a second system message that
41
+ * `@langchain/anthropic` rejects. Retained positionally so existing callers need no change.
42
+ * @param userMessages - The ordered user turns to send (one conversation).
43
+ * @param config - The resolved config.
44
+ * @param resolvers - Optional agent resolvers (tools/middleware); the caller owns their cleanup.
45
+ * @param command - The originating command (defaults to `ask`); selects the agent mode prompt.
46
+ * @param agentFactory - Optional backend factory (B5); omitted = the runner's lean default, and a
47
+ * config asking for `agent.backend: 'deep'` is warned about rather than silently dropped.
48
+ * @returns One {@link ConversationTurnResult} per turn attempted, in turn order.
49
+ */
50
+ export async function runConversation(source, _preamble, userMessages, config, resolvers, command = 'ask', agentFactory) {
51
+ const progressIndicator = config.streamOutput ? undefined : new ProgressIndicator('Thinking.');
52
+ try {
53
+ // Resolve output path and initialize session logging if enabled (same discipline as
54
+ // runSingleShot; a no-op when `writeOutputToFile` is off, as `gth eval` forces it —
55
+ // getCommandOutputFilePath null).
56
+ const filePath = getCommandOutputFilePath(config, source);
57
+ if (filePath) {
58
+ initSessionLogging(filePath, config.streamSessionInferenceLog);
59
+ }
60
+ // Build the agent + resolve tools ONCE for the whole conversation (the MCP connection / any
61
+ // OAuth / the toolset must persist across turns so cross-turn memory is real). Cleaned up once,
62
+ // in finally.
63
+ const runner = new GthAgentRunner(defaultStatusCallback, resolvers, agentFactory);
64
+ const results = [];
65
+ // The accumulated conversation: [user1, ai1, user2, ai2, …]. Each turn replays the whole array
66
+ // against a freshly-rotated thread (see the doc block). BATCH-13: NO leading SystemMessage — the
67
+ // agent composes the system prompt via `createAgent({ systemPrompt })` (same as runSingleShot);
68
+ // seeding a preamble SystemMessage here too made two system messages, which Anthropic rejects.
69
+ const messages = [];
70
+ try {
71
+ await runner.init(command, config, new MemorySaver());
72
+ for (const userMessage of userMessages) {
73
+ // Rotate to a fresh (empty) checkpointer thread so this turn's replay of the full `messages`
74
+ // array is the sole history the agent sees — no double-append from a prior checkpoint.
75
+ runner.resetThread();
76
+ messages.push(new HumanMessage(userMessage));
77
+ const startedAt = Date.now();
78
+ let answer = '';
79
+ let ok = true;
80
+ let error;
81
+ try {
82
+ answer = await runner.processMessages(messages);
83
+ // Append this turn's answer so the NEXT turn's replay includes it (cross-turn memory).
84
+ messages.push(new AIMessage(answer));
85
+ }
86
+ catch (err) {
87
+ ok = false;
88
+ error = err instanceof Error ? err.message : String(err);
89
+ displayError(`Failed to get answer: ${error}`);
90
+ }
91
+ // GS2-16: read this turn's token/tool delta from the live agent (before cleanup). Fail-soft
92
+ // — analytics must never affect the run. `processMessages` reset the tally at its top, so
93
+ // this is THIS turn's usage, not the conversation's cumulative total.
94
+ let runStats = { tools: [] };
95
+ try {
96
+ const s = runner.getRunStats?.();
97
+ if (s)
98
+ runStats = s;
99
+ }
100
+ catch {
101
+ /* fail-soft */
102
+ }
103
+ // GS2-7 (B20): opt-in, fail-soft per-turn session history. A no-op unless `history.enabled`.
104
+ recordSessionSafe(config, {
105
+ command,
106
+ project: getProjectDir(),
107
+ model: config.modelDisplayName,
108
+ prompt: userMessage,
109
+ response: answer,
110
+ tokensInput: runStats.tokensInput,
111
+ tokensOutput: runStats.tokensOutput,
112
+ tools: runStats.tools.length > 0 ? runStats.tools : undefined,
113
+ durationMs: Date.now() - startedAt,
114
+ });
115
+ results.push({ ok, answer, error, ...runStats });
116
+ // A failed turn breaks the conversation's context — stop rather than run later turns on it.
117
+ if (!ok)
118
+ break;
119
+ }
120
+ }
121
+ finally {
122
+ await runner.cleanup();
123
+ }
124
+ progressIndicator?.stop();
125
+ if (config.writeOutputToFile === false) {
126
+ display('\n'); // something going on in some terminals, they swallow last line of output
127
+ }
128
+ if (filePath) {
129
+ try {
130
+ flushSessionLog();
131
+ stopSessionLogging();
132
+ displaySuccess(`\n\nThis report can be found in ${filePath}`);
133
+ }
134
+ catch (err) {
135
+ displayError(`Failed to write answer to file: ${filePath}`);
136
+ displayError(err instanceof Error ? err.message : String(err));
137
+ }
138
+ }
139
+ return results;
140
+ }
141
+ finally {
142
+ // EXT-53: the indicator owns a 1s setInterval — an active libuv handle that keeps Node's event
143
+ // loop from ever draining, so leaking it hangs the CLI forever after the work is done. The
144
+ // `stop()` above sits where it does for output ordering (before the trailing newline / the
145
+ // "report can be found in …" line); this `finally` guarantees the handle is also released when
146
+ // anything above throws — notably `runner.init()`, which has no catch, and `runner.cleanup()`.
147
+ // `stop()` is idempotent, so the normal path's second call is a no-op.
148
+ progressIndicator?.stop();
149
+ }
150
+ }
151
+ //# sourceMappingURL=conversation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../src/runtime/conversation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,YAAY,EACZ,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAkB1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAA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QAAQ,EAAE,CAAC,CAAC;gBAEjD,4FAA4F;gBAC5F,IAAI,CAAC,EAAE;oBAAE,MAAM;YACjB,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC;QAED,iBAAiB,EAAE,IAAI,EAAE,CAAC;QAE1B,IAAI,MAAM,CAAC,iBAAiB,KAAK,KAAK,EAAE,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,yEAAyE;QAC1F,CAAC;QACD,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC;gBACH,eAAe,EAAE,CAAC;gBAClB,kBAAkB,EAAE,CAAC;gBACrB,cAAc,CAAC,mCAAmC,QAAQ,EAAE,CAAC,CAAC;YAChE,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,YAAY,CAAC,mCAAmC,QAAQ,EAAE,CAAC,CAAC;gBAC5D,YAAY,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;YAAS,CAAC;QACT,+FAA+F;QAC/F,2FAA2F;QAC3F,2FAA2F;QAC3F,+FAA+F;QAC/F,+FAA+F;QAC/F,uEAAuE;QACvE,iBAAiB,EAAE,IAAI,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC"}
@@ -1,5 +1,18 @@
1
1
  import type { GthConfig } from '#src/config.js';
2
- import type { AgentResolvers, GthCommand } from '#src/core/types.js';
2
+ import type { AgentResolvers, GthAgentFactory, GthCommand } from '#src/core/types.js';
3
+ import type { GthRunStats } from '#src/core/types.js';
4
+ /**
5
+ * Result of a {@link runSingleShot} run: the pass/fail contract callers such as `ask`/`exec` have
6
+ * always used (`ok`), plus the SUT's answer text and run stats (GS2-16's {@link GthRunStats}) that
7
+ * were already computed internally but previously discarded. Extends `GthRunStats` rather than
8
+ * restating `tokensInput`/`tokensOutput`/`tools` as parallel fields.
9
+ */
10
+ export interface SingleShotResult extends GthRunStats {
11
+ /** `true` when the run completed without error, `false` when it failed. */
12
+ ok: boolean;
13
+ /** The SUT's full answer text (`runner.processMessages()`'s return value). Empty on failure. */
14
+ answer: string;
15
+ }
3
16
  /**
4
17
  * Ask a question and get an answer from the LLM.
5
18
  *
@@ -8,12 +21,19 @@ import type { AgentResolvers, GthCommand } from '#src/core/types.js';
8
21
  * is forwarded to the agent so it can pick the right mode prompt (e.g. exec-mode for `exec`).
9
22
  *
10
23
  * @param source - The source of the question (used for file naming)
11
- * @param preamble - The preamble to send to the LLM
24
+ * @param _preamble - Deprecated/ignored (BATCH-13): the agent composes the system prompt itself;
25
+ * see the body comment. Retained positionally so existing callers need no change.
12
26
  * @param content - The content of the question
13
27
  * @param config - The resolved config
14
28
  * @param resolvers - Optional agent resolvers (tools/middleware)
15
29
  * @param command - The originating command (defaults to `ask`); selects the agent mode prompt
16
- * @returns `true` when the run completed without error, `false` when it failed (so callers
17
- * such as `exec` can set a non-zero exit code).
30
+ * @param agentFactory - Optional backend factory (B5). When omitted the runner uses its built-in
31
+ * lean {@link GthLangChainAgent} default and warns if `agent.backend` asked for `deep`, since
32
+ * omitting it opts the run out of that key. The app layer passes
33
+ * `resolveAgentFactory(config, 'lean')` so an explicit `agent.backend` is honored.
34
+ * @returns A {@link SingleShotResult}: `ok` is `true` when the run completed without error, `false`
35
+ * when it failed (so callers such as `exec` can set a non-zero exit code); `answer`/`tokensInput`/
36
+ * `tokensOutput`/`tools` carry the SUT's answer text and run stats for callers that need them
37
+ * (e.g. `gth batch`/`gth eval`).
18
38
  */
19
- export declare function runSingleShot(source: string, preamble: string, content: string, config: GthConfig, resolvers?: AgentResolvers, command?: GthCommand): Promise<boolean>;
39
+ export declare function runSingleShot(source: string, _preamble: string, content: string, config: GthConfig, resolvers?: AgentResolvers, command?: GthCommand, agentFactory?: GthAgentFactory): Promise<SingleShotResult>;
@@ -2,8 +2,10 @@ import { defaultStatusCallback, display, displayError, displaySuccess, flushSess
2
2
  import { getCommandOutputFilePath } from '#src/utils/fileUtils.js';
3
3
  import { GthAgentRunner } from '#src/core/GthAgentRunner.js';
4
4
  import { MemorySaver } from '@langchain/langgraph';
5
- import { HumanMessage, SystemMessage } from '@langchain/core/messages';
5
+ import { HumanMessage } from '@langchain/core/messages';
6
6
  import { ProgressIndicator } from '#src/utils/ProgressIndicator.js';
7
+ import { recordSessionSafe } from '#src/history/recordSession.js';
8
+ import { getProjectDir } from '#src/utils/systemUtils.js';
7
9
  /**
8
10
  * Ask a question and get an answer from the LLM.
9
11
  *
@@ -12,51 +14,108 @@ import { ProgressIndicator } from '#src/utils/ProgressIndicator.js';
12
14
  * is forwarded to the agent so it can pick the right mode prompt (e.g. exec-mode for `exec`).
13
15
  *
14
16
  * @param source - The source of the question (used for file naming)
15
- * @param preamble - The preamble to send to the LLM
17
+ * @param _preamble - Deprecated/ignored (BATCH-13): the agent composes the system prompt itself;
18
+ * see the body comment. Retained positionally so existing callers need no change.
16
19
  * @param content - The content of the question
17
20
  * @param config - The resolved config
18
21
  * @param resolvers - Optional agent resolvers (tools/middleware)
19
22
  * @param command - The originating command (defaults to `ask`); selects the agent mode prompt
20
- * @returns `true` when the run completed without error, `false` when it failed (so callers
21
- * such as `exec` can set a non-zero exit code).
23
+ * @param agentFactory - Optional backend factory (B5). When omitted the runner uses its built-in
24
+ * lean {@link GthLangChainAgent} default and warns if `agent.backend` asked for `deep`, since
25
+ * omitting it opts the run out of that key. The app layer passes
26
+ * `resolveAgentFactory(config, 'lean')` so an explicit `agent.backend` is honored.
27
+ * @returns A {@link SingleShotResult}: `ok` is `true` when the run completed without error, `false`
28
+ * when it failed (so callers such as `exec` can set a non-zero exit code); `answer`/`tokensInput`/
29
+ * `tokensOutput`/`tools` carry the SUT's answer text and run stats for callers that need them
30
+ * (e.g. `gth batch`/`gth eval`).
22
31
  */
23
- export async function runSingleShot(source, preamble, content, config, resolvers, command = 'ask') {
32
+ export async function runSingleShot(source,
33
+ // BATCH-13: `_preamble` is retained for signature stability but is NO LONGER injected as a
34
+ // SystemMessage. The agent backends (lean `GthLangChainAgent` since GS2-21, and `GthDeepAgent`)
35
+ // each COMPOSE the full system prompt themselves from the same config — backstory + guidelines +
36
+ // per-command mode prompt + system prompt, PLUS the model-identity (GS2-34) and MCP-instructions
37
+ // (EXT-32) notes — and hand it to `createAgent` as `systemPrompt`. Also passing this preamble as a
38
+ // leading SystemMessage produced TWO system messages, which `@langchain/anthropic` rejects
39
+ // ("System messages are only permitted as the first passed message"), breaking EVERY single-shot
40
+ // run (ask/exec/batch/eval) on Anthropic on BOTH backends (Google/OpenAI silently merged them).
41
+ // The agent's composed prompt is a superset of this preamble, so dropping it is content-preserving.
42
+ _preamble, content, config, resolvers, command = 'ask', agentFactory) {
24
43
  const progressIndicator = config.streamOutput ? undefined : new ProgressIndicator('Thinking.');
25
- const messages = [new SystemMessage(preamble), new HumanMessage(content)];
26
- // Resolve output path and initialize session logging if enabled
27
- const filePath = getCommandOutputFilePath(config, source);
28
- if (filePath) {
29
- initSessionLogging(filePath, config.streamSessionInferenceLog);
30
- }
31
- // Run via Agent Runner (consistent with interactive session)
32
- const runner = new GthAgentRunner(defaultStatusCallback, resolvers);
33
- let succeeded = true;
34
44
  try {
35
- await runner.init(command, config, new MemorySaver());
36
- await runner.processMessages(messages);
37
- }
38
- catch (err) {
39
- succeeded = false;
40
- displayError(`Failed to get answer: ${err instanceof Error ? err.message : String(err)}`);
41
- }
42
- finally {
43
- await runner.cleanup();
44
- }
45
- progressIndicator?.stop();
46
- if (config.writeOutputToFile === false) {
47
- display('\n'); // something going on in some terminals, they swallow last line of output
48
- }
49
- if (filePath) {
45
+ // Only the human turn: the agent supplies the system prompt via `createAgent({ systemPrompt })`.
46
+ const messages = [new HumanMessage(content)];
47
+ // Resolve output path and initialize session logging if enabled
48
+ const filePath = getCommandOutputFilePath(config, source);
49
+ if (filePath) {
50
+ initSessionLogging(filePath, config.streamSessionInferenceLog);
51
+ }
52
+ // Run via Agent Runner (consistent with interactive session)
53
+ const runner = new GthAgentRunner(defaultStatusCallback, resolvers, agentFactory);
54
+ let succeeded = true;
55
+ let responseText = '';
56
+ const startedAt = Date.now();
50
57
  try {
51
- flushSessionLog();
52
- stopSessionLogging();
53
- displaySuccess(`\n\nThis report can be found in ${filePath}`);
58
+ await runner.init(command, config, new MemorySaver());
59
+ responseText = await runner.processMessages(messages);
60
+ }
61
+ catch (err) {
62
+ succeeded = false;
63
+ displayError(`Failed to get answer: ${err instanceof Error ? err.message : String(err)}`);
54
64
  }
55
- catch (error) {
56
- displayError(`Failed to write answer to file: ${filePath}`);
57
- displayError(error instanceof Error ? error.message : String(error));
65
+ finally {
66
+ await runner.cleanup();
58
67
  }
68
+ // GS2-16: live token usage + invoked tool names for this run (fail-soft; empty when the
69
+ // provider reported no usage / the runner has no stats). Read post-cleanup — the runner
70
+ // snapshots stats at cleanup() so this still reflects the finished run.
71
+ let runStats = { tools: [] };
72
+ try {
73
+ const s = runner.getRunStats?.();
74
+ if (s)
75
+ runStats = s;
76
+ }
77
+ catch {
78
+ /* fail-soft: analytics must never affect this run */
79
+ }
80
+ // GS2-7 (B20): opt-in, fail-soft session history. A no-op unless `history.enabled`; never throws
81
+ // (recordSessionSafe is fully guarded) so a DB problem can't abort or alter this run.
82
+ // GS2-16 threads token/tool analytics; costUsd is intentionally left unset (no reliable price).
83
+ recordSessionSafe(config, {
84
+ command,
85
+ project: getProjectDir(),
86
+ model: config.modelDisplayName,
87
+ prompt: content,
88
+ response: responseText,
89
+ tokensInput: runStats.tokensInput,
90
+ tokensOutput: runStats.tokensOutput,
91
+ tools: runStats.tools.length > 0 ? runStats.tools : undefined,
92
+ durationMs: Date.now() - startedAt,
93
+ });
94
+ progressIndicator?.stop();
95
+ if (config.writeOutputToFile === false) {
96
+ display('\n'); // something going on in some terminals, they swallow last line of output
97
+ }
98
+ if (filePath) {
99
+ try {
100
+ flushSessionLog();
101
+ stopSessionLogging();
102
+ displaySuccess(`\n\nThis report can be found in ${filePath}`);
103
+ }
104
+ catch (error) {
105
+ displayError(`Failed to write answer to file: ${filePath}`);
106
+ displayError(error instanceof Error ? error.message : String(error));
107
+ }
108
+ }
109
+ return { ok: succeeded, answer: responseText, ...runStats };
110
+ }
111
+ finally {
112
+ // EXT-53: the indicator owns a 1s setInterval — an active libuv handle that keeps Node's event
113
+ // loop from ever draining, so leaking it hangs the CLI forever after the work is done. The
114
+ // `stop()` above sits where it does for output ordering (before the trailing newline / the
115
+ // "report can be found in …" line); this `finally` guarantees the handle is also released when
116
+ // anything above throws — notably `runner.cleanup()`, which is outside the inner catch.
117
+ // `stop()` is idempotent, so the normal path's second call is a no-op.
118
+ progressIndicator?.stop();
59
119
  }
60
- return succeeded;
61
120
  }
62
121
  //# sourceMappingURL=singleShot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"singleShot.js","sourceRoot":"","sources":["../../src/runtime/singleShot.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,YAAY,EACZ,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAGpE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAc,EACd,QAAgB,EAChB,OAAe,EACf,MAAiB,EACjB,SAA0B,EAC1B,UAAsB,KAAK;IAE3B,MAAM,iBAAiB,GAAG,MAAM,CAAC,Y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