@gaunt-sloth/core 2.0.0-alpha.1 → 2.0.0-alpha.10

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 (114) hide show
  1. package/.gsloth.code.md +10 -0
  2. package/LICENSE +7 -0
  3. package/README.md +3 -4
  4. package/dist/config/defaults.d.ts +85 -0
  5. package/dist/config/defaults.js +101 -0
  6. package/dist/config/defaults.js.map +1 -0
  7. package/dist/config/jsonc.d.ts +12 -0
  8. package/dist/config/jsonc.js +41 -0
  9. package/dist/config/jsonc.js.map +1 -0
  10. package/dist/config/loader.d.ts +109 -0
  11. package/dist/config/loader.js +663 -0
  12. package/dist/config/loader.js.map +1 -0
  13. package/dist/config/schema.d.ts +509 -0
  14. package/dist/config/schema.js +349 -0
  15. package/dist/config/schema.js.map +1 -0
  16. package/dist/config/shell-policy.d.ts +212 -0
  17. package/dist/config/shell-policy.js +142 -0
  18. package/dist/config/shell-policy.js.map +1 -0
  19. package/dist/config/types.d.ts +490 -0
  20. package/dist/config/types.js +12 -0
  21. package/dist/config/types.js.map +1 -0
  22. package/dist/config.d.ts +18 -647
  23. package/dist/config.js +15 -516
  24. package/dist/config.js.map +1 -1
  25. package/dist/constants.d.ts +24 -0
  26. package/dist/constants.js +24 -0
  27. package/dist/constants.js.map +1 -1
  28. package/dist/core/GthAbstractAgent.d.ts +57 -1
  29. package/dist/core/GthAbstractAgent.js +171 -4
  30. package/dist/core/GthAbstractAgent.js.map +1 -1
  31. package/dist/core/GthAgentRunner.d.ts +158 -1
  32. package/dist/core/GthAgentRunner.js +367 -4
  33. package/dist/core/GthAgentRunner.js.map +1 -1
  34. package/dist/core/GthLangChainAgent.js +94 -5
  35. package/dist/core/GthLangChainAgent.js.map +1 -1
  36. package/dist/core/debugCapture.d.ts +59 -0
  37. package/dist/core/debugCapture.js +101 -0
  38. package/dist/core/debugCapture.js.map +1 -0
  39. package/dist/core/gthLeanAgentFactory.d.ts +9 -0
  40. package/dist/core/gthLeanAgentFactory.js +10 -0
  41. package/dist/core/gthLeanAgentFactory.js.map +1 -0
  42. package/dist/core/runStats.d.ts +41 -0
  43. package/dist/core/runStats.js +73 -0
  44. package/dist/core/runStats.js.map +1 -0
  45. package/dist/core/shell/ShellCommandFailedError.d.ts +54 -0
  46. package/dist/core/shell/ShellCommandFailedError.js +68 -0
  47. package/dist/core/shell/ShellCommandFailedError.js.map +1 -0
  48. package/dist/core/shell/allowlist.d.ts +75 -0
  49. package/dist/core/shell/allowlist.js +187 -0
  50. package/dist/core/shell/allowlist.js.map +1 -0
  51. package/dist/core/shell/arity.d.ts +75 -0
  52. package/dist/core/shell/arity.js +313 -0
  53. package/dist/core/shell/arity.js.map +1 -0
  54. package/dist/core/shell/judge.d.ts +161 -0
  55. package/dist/core/shell/judge.js +261 -0
  56. package/dist/core/shell/judge.js.map +1 -0
  57. package/dist/core/shell/normalize.d.ts +27 -0
  58. package/dist/core/shell/normalize.js +53 -0
  59. package/dist/core/shell/normalize.js.map +1 -0
  60. package/dist/core/types.d.ts +104 -0
  61. package/dist/core/types.js.map +1 -1
  62. package/dist/history/historyFormat.d.ts +19 -0
  63. package/dist/history/historyFormat.js +85 -0
  64. package/dist/history/historyFormat.js.map +1 -0
  65. package/dist/history/historyStore.d.ts +121 -0
  66. package/dist/history/historyStore.js +315 -0
  67. package/dist/history/historyStore.js.map +1 -0
  68. package/dist/history/recordSession.d.ts +28 -0
  69. package/dist/history/recordSession.js +29 -0
  70. package/dist/history/recordSession.js.map +1 -0
  71. package/dist/index.d.ts +4 -0
  72. package/dist/index.js +4 -0
  73. package/dist/index.js.map +1 -1
  74. package/dist/providers/anthropic.d.ts +1 -1
  75. package/dist/providers/anthropic.js +5 -10
  76. package/dist/providers/anthropic.js.map +1 -1
  77. package/dist/providers/deepseek.d.ts +1 -1
  78. package/dist/providers/deepseek.js +5 -10
  79. package/dist/providers/deepseek.js.map +1 -1
  80. package/dist/providers/google-genai.d.ts +1 -1
  81. package/dist/providers/google-genai.js +5 -10
  82. package/dist/providers/google-genai.js.map +1 -1
  83. package/dist/providers/groq.d.ts +1 -1
  84. package/dist/providers/groq.js +5 -10
  85. package/dist/providers/groq.js.map +1 -1
  86. package/dist/providers/modelDiscovery.d.ts +54 -1
  87. package/dist/providers/modelDiscovery.js +106 -8
  88. package/dist/providers/modelDiscovery.js.map +1 -1
  89. package/dist/providers/ollama.d.ts +1 -1
  90. package/dist/providers/ollama.js +5 -15
  91. package/dist/providers/ollama.js.map +1 -1
  92. package/dist/providers/openai.d.ts +1 -1
  93. package/dist/providers/openai.js +5 -10
  94. package/dist/providers/openai.js.map +1 -1
  95. package/dist/providers/openrouter.d.ts +1 -1
  96. package/dist/providers/openrouter.js +7 -12
  97. package/dist/providers/openrouter.js.map +1 -1
  98. package/dist/providers/vertexai.d.ts +1 -1
  99. package/dist/providers/vertexai.js +5 -10
  100. package/dist/providers/vertexai.js.map +1 -1
  101. package/dist/providers/xai.d.ts +1 -1
  102. package/dist/providers/xai.js +5 -10
  103. package/dist/providers/xai.js.map +1 -1
  104. package/dist/runtime/singleShot.d.ts +5 -2
  105. package/dist/runtime/singleShot.js +36 -3
  106. package/dist/runtime/singleShot.js.map +1 -1
  107. package/dist/utils/fileUtils.d.ts +24 -2
  108. package/dist/utils/fileUtils.js +54 -12
  109. package/dist/utils/fileUtils.js.map +1 -1
  110. package/dist/utils/systemUtils.d.ts +31 -0
  111. package/dist/utils/systemUtils.js +38 -0
  112. package/dist/utils/systemUtils.js.map +1 -1
  113. package/package.json +16 -11
  114. package/schema/gsloth-config.schema.json +1579 -0
@@ -1,5 +1,6 @@
1
1
  import { GthConfig, ServerTool } from '#src/config.js';
2
- import { AgentResolvers, AgentStreamEvent, GthAgentInterface, GthCommand, GthCompiledGraph, Message, StatusUpdateCallback } from '#src/core/types.js';
2
+ import { AgentResolvers, AgentStreamEvent, GthAgentInterface, GthCommand, GthCompiledGraph, GthRunStats, Message, PendingToolInterrupt, StatusUpdateCallback } from '#src/core/types.js';
3
+ import type { DebugCapture } from '#src/core/debugCapture.js';
3
4
  import { BaseMessage } from '@langchain/core/messages';
4
5
  import { RunnableConfig } from '@langchain/core/runnables';
5
6
  import { BaseToolkit, StructuredToolInterface } from '@langchain/core/tools';
@@ -24,7 +25,39 @@ export declare abstract class GthAbstractAgent implements GthAgentInterface {
24
25
  protected agent: GthCompiledGraph | null;
25
26
  protected config: GthConfig | null;
26
27
  protected command: GthCommand | undefined;
28
+ /**
29
+ * Opt-in debug sink for the TUI `/debug` panel. Set AFTER {@link init} via
30
+ * `runner.getAgent()`; read lazily inside each backend's `wrapModelCall` capture middleware
31
+ * so that when it is `undefined` (the normal path) the middleware is a transparent
32
+ * pass-through. Lives on the base so BOTH the lean and deep backends support it; the AG-UI
33
+ * server / non-TUI callers simply never set it, so those contracts are unchanged.
34
+ */
35
+ debugCapture: DebugCapture | undefined;
36
+ /**
37
+ * GS2-16 — per-run analytics tally (token usage + invoked tool names) folded from the messages
38
+ * flowing through {@link invoke} / the streaming paths. Reset at each turn boundary via
39
+ * {@link resetRunStats} (the runner is reused across turns), read via {@link getRunStats}, and
40
+ * fully fail-soft (accumulation is guarded and never throws into a run).
41
+ */
42
+ private runStatsAcc;
27
43
  constructor(statusUpdate: StatusUpdateCallback, resolvers?: AgentResolvers);
44
+ /**
45
+ * GS2-16 — clear the per-run analytics tally so the next turn starts from zero. The runner
46
+ * calls this at each turn boundary because it (and this agent) are reused across turns in an
47
+ * interactive session.
48
+ */
49
+ resetRunStats(): void;
50
+ /** GS2-16 — the analytics harvested since the last {@link resetRunStats}. Never throws. */
51
+ getRunStats(): GthRunStats;
52
+ /** GS2-16 — fold one message (or chunk) into the run tally. Fully guarded (fail-soft). */
53
+ protected recordRunStats(message: unknown): void;
54
+ /**
55
+ * GS2-16 — best-effort count of messages already in the checkpointed thread state, used by
56
+ * {@link invoke} as the baseline so it harvests only THIS turn's new messages rather than the
57
+ * whole accumulated conversation a checkpointer returns. Fail-soft: a missing `getState`, an odd
58
+ * state shape, or any error yields 0 (worst case a one-turn over-count, never a throw).
59
+ */
60
+ private getStateMessageCount;
28
61
  /**
29
62
  * Build the underlying compiled graph and assign it to {@link agent}. This is the only
30
63
  * part that differs between the lean and deep agents.
@@ -42,6 +75,19 @@ export declare abstract class GthAbstractAgent implements GthAgentInterface {
42
75
  * When stream is not appropriate use {@link invoke}.
43
76
  */
44
77
  stream(messages: Message[], runConfig: RunnableConfig): Promise<IterableReadableStream<string>>;
78
+ /**
79
+ * Resume a graph suspended on a human-in-the-loop `interrupt()` and stream the continuation
80
+ * as text. Identical plumbing to {@link stream} (Esc-to-interrupt, binary handling), except
81
+ * the graph input is a `Command({ resume })` instead of fresh `messages` — so the suspended
82
+ * tool-approval interrupt is answered and the run continues on the same thread.
83
+ */
84
+ streamResume(resumeValue: unknown, runConfig: RunnableConfig): Promise<IterableReadableStream<string>>;
85
+ /**
86
+ * Shared body for {@link stream} / {@link streamResume}: drive the compiled graph from
87
+ * `input` (fresh `{ messages }` or a resume `Command`) and surface AI text deltas as a
88
+ * string stream, with Esc-to-interrupt and binary-output materialization.
89
+ */
90
+ private streamFromInput;
45
91
  /**
46
92
  * Stream agent events as typed AgentStreamEvent objects.
47
93
  * Yields text deltas, tool call lifecycle events, and tool results.
@@ -61,6 +107,16 @@ export declare abstract class GthAbstractAgent implements GthAgentInterface {
61
107
  * the client sends in `forwardedProps.command.resume`.
62
108
  */
63
109
  streamWithEventsResume(resumeValue: unknown, runConfig: RunnableConfig, queuedMessages?: BaseMessage[], signal?: AbortSignal): AsyncGenerator<AgentStreamEvent>;
110
+ /**
111
+ * Inspect the checkpointed state for the thread and return the tool calls currently pending
112
+ * human approval (empty array when the run finished normally). A LangGraph
113
+ * `humanInTheLoopMiddleware` interrupt parks one `HITLRequest` per suspended super-step in
114
+ * `state.tasks[].interrupts[].value.actionRequests` (each `{ name, args }`); this flattens
115
+ * those into {@link PendingToolInterrupt}s. Defensive throughout — a graph without
116
+ * `getState`, or any unexpected shape, yields `[]` rather than throwing, so a missing HITL
117
+ * setup degrades to "no approval needed" instead of breaking the run.
118
+ */
119
+ getPendingToolInterrupts(runConfig: RunnableConfig): Promise<PendingToolInterrupt[]>;
64
120
  protected processEventStream(stream: IterableReadableStream<[BaseMessage, Record<string, unknown>]>): AsyncGenerator<AgentStreamEvent>;
65
121
  cleanup(): Promise<void>;
66
122
  getEffectiveConfig(config: GthConfig, command: GthCommand | undefined): GthConfig;
@@ -1,4 +1,5 @@
1
1
  import { StatusLevel, } from '#src/core/types.js';
2
+ import { accumulateMessage, createRunStatsAccumulator, finalizeRunStats, } from '#src/core/runStats.js';
2
3
  import { debugLog, debugLogError, debugLogObject } from '#src/utils/debugUtils.js';
3
4
  import { ProgressIndicator } from '#src/utils/ProgressIndicator.js';
4
5
  import { stopWaitingForEscape, waitForEscape } from '#src/utils/systemUtils.js';
@@ -25,12 +26,61 @@ export class GthAbstractAgent {
25
26
  agent = null;
26
27
  config = null;
27
28
  command = undefined;
29
+ /**
30
+ * Opt-in debug sink for the TUI `/debug` panel. Set AFTER {@link init} via
31
+ * `runner.getAgent()`; read lazily inside each backend's `wrapModelCall` capture middleware
32
+ * so that when it is `undefined` (the normal path) the middleware is a transparent
33
+ * pass-through. Lives on the base so BOTH the lean and deep backends support it; the AG-UI
34
+ * server / non-TUI callers simply never set it, so those contracts are unchanged.
35
+ */
36
+ debugCapture;
37
+ /**
38
+ * GS2-16 — per-run analytics tally (token usage + invoked tool names) folded from the messages
39
+ * flowing through {@link invoke} / the streaming paths. Reset at each turn boundary via
40
+ * {@link resetRunStats} (the runner is reused across turns), read via {@link getRunStats}, and
41
+ * fully fail-soft (accumulation is guarded and never throws into a run).
42
+ */
43
+ runStatsAcc = createRunStatsAccumulator();
28
44
  constructor(statusUpdate, resolvers) {
29
45
  this.statusUpdate = (level, message) => {
30
46
  statusUpdate(level, message);
31
47
  };
32
48
  this.resolvers = resolvers;
33
49
  }
50
+ /**
51
+ * GS2-16 — clear the per-run analytics tally so the next turn starts from zero. The runner
52
+ * calls this at each turn boundary because it (and this agent) are reused across turns in an
53
+ * interactive session.
54
+ */
55
+ resetRunStats() {
56
+ this.runStatsAcc = createRunStatsAccumulator();
57
+ }
58
+ /** GS2-16 — the analytics harvested since the last {@link resetRunStats}. Never throws. */
59
+ getRunStats() {
60
+ return finalizeRunStats(this.runStatsAcc);
61
+ }
62
+ /** GS2-16 — fold one message (or chunk) into the run tally. Fully guarded (fail-soft). */
63
+ recordRunStats(message) {
64
+ accumulateMessage(this.runStatsAcc, message);
65
+ }
66
+ /**
67
+ * GS2-16 — best-effort count of messages already in the checkpointed thread state, used by
68
+ * {@link invoke} as the baseline so it harvests only THIS turn's new messages rather than the
69
+ * whole accumulated conversation a checkpointer returns. Fail-soft: a missing `getState`, an odd
70
+ * state shape, or any error yields 0 (worst case a one-turn over-count, never a throw).
71
+ */
72
+ async getStateMessageCount(runConfig) {
73
+ try {
74
+ if (!this.agent || typeof this.agent.getState !== 'function')
75
+ return 0;
76
+ const state = await this.agent.getState(runConfig);
77
+ const messages = state?.values?.messages;
78
+ return Array.isArray(messages) ? messages.length : 0;
79
+ }
80
+ catch {
81
+ return 0;
82
+ }
83
+ }
34
84
  /**
35
85
  * Invoke LLM with a message and runnable config.
36
86
  * For streaming use {@link #stream} method, streaming is preferred if model API supports it.
@@ -48,7 +98,21 @@ export class GthAbstractAgent {
48
98
  const progress = new ProgressIndicator('Thinking.');
49
99
  try {
50
100
  debugLog('Calling agent.invoke...');
101
+ // GS2-16: capture the prior conversation length BEFORE invoking so we harvest ONLY this
102
+ // turn's NEW messages. With a checkpointer + persistent thread (a multi-turn `--no-tui`
103
+ // interactive session with `streamOutput: false`), `response.messages` is the FULL
104
+ // accumulated conversation, not just this turn — folding all of it would re-sum prior
105
+ // turns' usage_metadata and re-collect prior tools (per-turn over-count). This baseline
106
+ // slice also prevents a double-harvest by the empty-stream fallback invoke in
107
+ // GthAgentRunner: by then the streamed turn is checkpointed, so it is BEFORE the baseline.
108
+ // Fail-soft: an unreadable baseline yields 0 (a one-turn over-count at worst, never a throw).
109
+ const priorMessageCount = await this.getStateMessageCount(runConfig);
51
110
  const response = await this.agent.invoke({ messages }, runConfig);
111
+ // Harvest token usage + invoked tool names from THIS turn's new messages only (fail-soft)
112
+ // so the opt-in history recorder can populate `gth insights`.
113
+ const allMessages = Array.isArray(response.messages) ? response.messages : [];
114
+ for (const m of allMessages.slice(priorMessageCount))
115
+ this.recordRunStats(m);
52
116
  const finalMessage = response.messages[response.messages.length - 1];
53
117
  const finalContent = finalMessage?.content;
54
118
  const processedContent = !this.config.writeBinaryOutputsToFile
@@ -96,16 +160,40 @@ export class GthAbstractAgent {
96
160
  * When stream is not appropriate use {@link invoke}.
97
161
  */
98
162
  async stream(messages, runConfig) {
163
+ debugLog('=== Starting streaming invoke ===');
164
+ debugLogObject('LLM Input Messages', messages);
165
+ return this.streamFromInput({ messages }, runConfig);
166
+ }
167
+ /**
168
+ * Resume a graph suspended on a human-in-the-loop `interrupt()` and stream the continuation
169
+ * as text. Identical plumbing to {@link stream} (Esc-to-interrupt, binary handling), except
170
+ * the graph input is a `Command({ resume })` instead of fresh `messages` — so the suspended
171
+ * tool-approval interrupt is answered and the run continues on the same thread.
172
+ */
173
+ async streamResume(resumeValue, runConfig) {
174
+ debugLog('=== Starting streaming resume ===');
175
+ debugLogObject('Resume value', resumeValue);
176
+ return this.streamFromInput(new Command({ resume: resumeValue }), runConfig);
177
+ }
178
+ /**
179
+ * Shared body for {@link stream} / {@link streamResume}: drive the compiled graph from
180
+ * `input` (fresh `{ messages }` or a resume `Command`) and surface AI text deltas as a
181
+ * string stream, with Esc-to-interrupt and binary-output materialization.
182
+ */
183
+ async streamFromInput(
184
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
185
+ input, runConfig) {
99
186
  if (!this.agent || !this.config) {
100
187
  throw new Error('Agent not initialized. Call init() first.');
101
188
  }
102
- debugLog('=== Starting streaming invoke ===');
103
- debugLogObject('LLM Input Messages', messages);
104
189
  debugLogObject('Stream RunConfig', runConfig);
105
190
  this.statusUpdate(StatusLevel.INFO, '\nThinking...\n');
106
191
  const statusUpdate = this.statusUpdate;
107
192
  const config = this.config;
108
193
  const command = this.command;
194
+ // GS2-16: bound so the stream `start()` closure (whose `this` is the stream source, not the
195
+ // agent) can fold each chunk into the run tally. Fail-soft inside recordRunStats.
196
+ const recordRunStats = (m) => this.recordRunStats(m);
109
197
  const interruptState = { escape: false, messageShown: false };
110
198
  const abortController = new AbortController();
111
199
  const showInterruptMessage = () => {
@@ -123,7 +211,11 @@ export class GthAbstractAgent {
123
211
  }, this.config.canInterruptInferenceWithEsc);
124
212
  let stream;
125
213
  try {
126
- stream = await this.agent.stream({ messages }, { ...runConfig, streamMode: 'messages', signal: abortController.signal });
214
+ stream = await this.agent.stream(input, {
215
+ ...runConfig,
216
+ streamMode: 'messages',
217
+ signal: abortController.signal,
218
+ });
127
219
  }
128
220
  catch (error) {
129
221
  // If stream creation fails (e.g. an auth error), the IterableReadableStream below -
@@ -143,6 +235,9 @@ export class GthAbstractAgent {
143
235
  const binaryBlocks = [];
144
236
  for await (const [chunk, _metadata] of stream) {
145
237
  debugLogObject('Stream chunk', { chunk, _metadata });
238
+ // GS2-16: fold every chunk (AIMessageChunk usage/tool_calls, ToolMessage name) into
239
+ // the run tally before the text-only handling below.
240
+ recordRunStats(chunk);
146
241
  if (AIMessage.isInstance(chunk)) {
147
242
  const text = chunk.text ?? '';
148
243
  totalChunks++;
@@ -282,6 +377,55 @@ export class GthAbstractAgent {
282
377
  throw e;
283
378
  }
284
379
  }
380
+ /**
381
+ * Inspect the checkpointed state for the thread and return the tool calls currently pending
382
+ * human approval (empty array when the run finished normally). A LangGraph
383
+ * `humanInTheLoopMiddleware` interrupt parks one `HITLRequest` per suspended super-step in
384
+ * `state.tasks[].interrupts[].value.actionRequests` (each `{ name, args }`); this flattens
385
+ * those into {@link PendingToolInterrupt}s. Defensive throughout — a graph without
386
+ * `getState`, or any unexpected shape, yields `[]` rather than throwing, so a missing HITL
387
+ * setup degrades to "no approval needed" instead of breaking the run.
388
+ */
389
+ async getPendingToolInterrupts(runConfig) {
390
+ if (!this.agent || typeof this.agent.getState !== 'function') {
391
+ return [];
392
+ }
393
+ let state;
394
+ try {
395
+ state = await this.agent.getState(runConfig);
396
+ }
397
+ catch (e) {
398
+ debugLogError('getPendingToolInterrupts getState', e);
399
+ return [];
400
+ }
401
+ const tasks = state?.tasks;
402
+ if (!Array.isArray(tasks)) {
403
+ return [];
404
+ }
405
+ const pending = [];
406
+ for (const task of tasks) {
407
+ const interrupts = task?.interrupts;
408
+ if (!Array.isArray(interrupts))
409
+ continue;
410
+ for (const interrupt of interrupts) {
411
+ const value = interrupt?.value;
412
+ const actionRequests = value?.actionRequests;
413
+ if (!Array.isArray(actionRequests))
414
+ continue;
415
+ for (const action of actionRequests) {
416
+ const name = action?.name;
417
+ if (typeof name !== 'string')
418
+ continue;
419
+ const args = action?.args;
420
+ pending.push({
421
+ name,
422
+ args: args && typeof args === 'object' ? args : {},
423
+ });
424
+ }
425
+ }
426
+ }
427
+ return pending;
428
+ }
285
429
  async *processEventStream(stream) {
286
430
  // Aggregate AIMessageChunks via concat so tool_call_chunks collapse into
287
431
  // tool_calls with complete args (per-chunk tool_calls only ever sees that
@@ -317,6 +461,9 @@ export class GthAbstractAgent {
317
461
  }
318
462
  for await (const [chunk, _metadata] of stream) {
319
463
  debugLogObject('streamWithEvents chunk', { chunk, _metadata });
464
+ // GS2-16: fold every chunk (AIMessageChunk usage/tool_calls, ToolMessage name) into the
465
+ // run tally so the TUI turn can record real token/tool data. Fail-soft.
466
+ this.recordRunStats(chunk);
320
467
  if (AIMessageChunk.isInstance(chunk)) {
321
468
  aggregatedAIChunk = aggregatedAIChunk ? aggregatedAIChunk.concat(chunk) : chunk;
322
469
  // Reasoning deltas — Ollama (Qwen3, deepseek-r1) and Anthropic surface
@@ -341,6 +488,18 @@ export class GthAbstractAgent {
341
488
  }
342
489
  }
343
490
  else if (AIMessage.isInstance(chunk)) {
491
+ // Reasoning on a non-chunk AIMessage — a non-streamed / resumed thinking message
492
+ // (e.g. a checkpoint replay) still carries its thinking in
493
+ // additional_kwargs.reasoning_content. Mirror the AIMessageChunk branch and emit the
494
+ // same reasoning event series, otherwise the thought is silently dropped (TUI-C15).
495
+ const reasoningContent = chunk.additional_kwargs?.reasoning_content;
496
+ if (typeof reasoningContent === 'string' && reasoningContent.length > 0) {
497
+ if (!reasoningOpen) {
498
+ reasoningOpen = true;
499
+ yield { type: 'reasoning_start' };
500
+ }
501
+ yield { type: 'reasoning_delta', delta: reasoningContent };
502
+ }
344
503
  // Non-chunk AIMessage (e.g. on resumed runs) carries final tool_calls
345
504
  // directly; merge them into the aggregate so flushAggregated emits them.
346
505
  if (chunk.tool_calls && chunk.tool_calls.length > 0) {
@@ -370,7 +529,15 @@ export class GthAbstractAgent {
370
529
  // and end up with empty args.
371
530
  aggregatedAIChunk = null;
372
531
  const content = typeof chunk.content === 'string' ? chunk.content : JSON.stringify(chunk.content);
373
- yield { type: 'tool_result', id: chunk.tool_call_id, content };
532
+ // Surface the real tool-result error signal (LangChain `ToolMessage.status`) so
533
+ // consumers render the ✗/error affordance from fact, not from sniffing the result
534
+ // text. Only attach the flag on error to keep the success event shape unchanged.
535
+ yield {
536
+ type: 'tool_result',
537
+ id: chunk.tool_call_id,
538
+ content,
539
+ ...(chunk.status === 'error' ? { isError: true } : {}),
540
+ };
374
541
  }
375
542
  }
376
543
  // Close any still-open reasoning block before flushing tool calls.
@@ -1 +1 @@
1
- {"version":3,"file":"GthAbstractAgent.js","sourceRoot":"","sources":["../../src/core/GthAbstractAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,WAAW,GAEZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAA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G,aAAwC,CAAC;gBAC1D,8DAA8D;gBAC9D,IAAK,UAAkB,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,EAAE,CAAC;oBAClD,gDAAgD;oBAChD,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;oBACzF,MAAM,QAAQ,GAAG,KAAK,EAAE,MAAe,EAAE,OAAwB,EAAE,EAAE;wBACnE,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;wBACzD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;oBACnE,CAAC,CAAC;oBACF,8DAA8D;oBAC9D,UAAU,CAAC,MAAM,GAAG,QAAe,CAAC;oBACpC,8DAA8D;oBAC9D,UAAU,CAAC,IAAI,GAAG,QAAe,CAAC;gBACpC,CAAC;gBACD,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;CACF"}
@@ -1,6 +1,6 @@
1
1
  import { GthConfig } from '#src/config.js';
2
2
  import { BaseCheckpointSaver } from '@langchain/langgraph';
3
- import { AgentResolvers, AgentStreamEvent, GthAgentFactory, GthAgentInterface, GthCommand, Message, StatusUpdateCallback } from '#src/core/types.js';
3
+ import { AgentResolvers, AgentStreamEvent, GthAgentFactory, GthAgentInterface, GthCommand, GthRunStats, Message, StatusUpdateCallback, ToolApprovalCallback } from '#src/core/types.js';
4
4
  /**
5
5
  * Agent simplifies interaction with LLM and reduces it to calling a few methods
6
6
  * {@link GthAgentRunner#init} and {@link GthAgentRunner#processMessages}.
@@ -12,6 +12,47 @@ export declare class GthAgentRunner {
12
12
  private config;
13
13
  private runConfig;
14
14
  private agentFactory;
15
+ /**
16
+ * Consumer hook invoked when a run suspends on a tool-approval interrupt (e.g. the opt-in
17
+ * `run_shell_command` confirmation). Set via {@link setToolApprovalCallback}; when unset the
18
+ * runner REJECTS pending tool calls rather than hanging or auto-approving — the safe default
19
+ * for non-interactive entrypoints (a scripted `exec` run with no TTY to prompt on).
20
+ */
21
+ private toolApprovalCallback;
22
+ /** The command the runner was initialized for; selects which `devTools` config applies. */
23
+ private command;
24
+ /**
25
+ * GS2-16 — snapshot of the last turn's analytics (token usage + invoked tools), captured from
26
+ * the agent at {@link cleanup} time. Needed because {@link runSingleShot} reads stats AFTER it
27
+ * has already called `cleanup()` (which nulls the agent); interactive callers read live via
28
+ * {@link getRunStats} before cleanup. Defaults to an empty tally.
29
+ */
30
+ private lastRunStats;
31
+ /**
32
+ * EXT-12 — runtime, session-scoped auto-approve flag driven by the `/auto-approve` (a.k.a.
33
+ * `/yolo`) slash command. Because the shell tool stays gated (in `interruptOn`) in the
34
+ * interactive `code` mode, this flag is consulted at the TOP of {@link decideToolApproval}:
35
+ * when ON, a gated `run_shell_command` is auto-approved WITHOUT prompting for the rest of this
36
+ * runner's life. Never persisted, but INITIALIZED at {@link init} from the static
37
+ * `devTools.shellYolo` config flag — so a config that pre-enables auto-approval still keeps the
38
+ * tool gated and therefore toggleable (`/auto-approve off` restores the per-command prompt).
39
+ * It does NOT disable the hardline floor — catastrophic commands are still refused at exec time
40
+ * in `GthDevToolkit.executeCommand`.
41
+ */
42
+ private sessionYolo;
43
+ /**
44
+ * EXT-9 Tier-2 session allow-list — approved command prefixes that auto-approve for the
45
+ * life of THIS runner instance. Instance-scoped (not module-global) so concurrent
46
+ * sessions (ACP / AG-UI multi-session) cannot stomp each other's approvals.
47
+ */
48
+ private readonly sessionAllowlist;
49
+ /**
50
+ * EXT-9 Tier-2 persisted (`always`) allow-list, loaded lazily on first use from
51
+ * `.gsloth/.gsloth-settings/shell-allowlist.json`. Null until the shell tool is gated
52
+ * and the allow-list is enabled; null also when persistence is disabled by config.
53
+ */
54
+ private persistedAllowlist;
55
+ private persistedAllowlistLoaded;
15
56
  /**
16
57
  * @param agentFactory Produces the {@link GthAgentInterface} the runner drives.
17
58
  * Defaults to the lean {@link GthLangChainAgent} (core). `@gaunt-sloth/agent`
@@ -19,6 +60,28 @@ export declare class GthAgentRunner {
19
60
  * `createDeepAgent` graph without core depending on deepagents.
20
61
  */
21
62
  constructor(statusUpdate: StatusUpdateCallback, resolvers?: AgentResolvers, agentFactory?: GthAgentFactory);
63
+ /**
64
+ * Register the tool-approval handler the runner calls when a run suspends on a tool-approval
65
+ * interrupt (the interactive readline session wires a y/n prompt here). Pass `null` to clear.
66
+ * Without a handler the runner rejects pending tool calls (see {@link toolApprovalCallback}).
67
+ */
68
+ setToolApprovalCallback(callback: ToolApprovalCallback | null): void;
69
+ /**
70
+ * EXT-12 — flip the runtime, session-scoped auto-approve flag (the `/auto-approve` /
71
+ * `/yolo` slash command with no argument). When ON, gated `run_shell_command` calls
72
+ * auto-approve without prompting for the rest of this session; the hardline floor still applies
73
+ * at exec time. Returns the NEW state so the caller can render a notice. Session-scoped only —
74
+ * nothing is written to config.
75
+ */
76
+ toggleSessionYolo(): boolean;
77
+ /**
78
+ * EXT-12 — set the session-scoped auto-approve flag explicitly (the `/auto-approve on|off`
79
+ * slash command). Idempotent; returns the NEW state so the caller can render a notice.
80
+ * Session-scoped only — nothing is written to config.
81
+ */
82
+ setSessionYolo(on: boolean): boolean;
83
+ /** EXT-12 — current state of the runtime session-scoped auto-approve flag (see {@link toggleSessionYolo}). */
84
+ isSessionYolo(): boolean;
22
85
  /**
23
86
  * Init is split into a separate method. This may create a number of connections,
24
87
  * and we'd better have an instance by that moment, for the case things will go wrong,
@@ -29,6 +92,59 @@ export declare class GthAgentRunner {
29
92
  * processMessages deals with both streaming and non-streaming approaches.
30
93
  */
31
94
  processMessages(messages: Message[]): Promise<string>;
95
+ /**
96
+ * Accumulate a text stream into a single string. Extracted so {@link processMessages} and
97
+ * the interrupt-resume loop ({@link resolveToolInterrupts}) drain streams identically.
98
+ */
99
+ private drainTextStream;
100
+ /**
101
+ * After a streamed run ends, resolve any tool-approval interrupts it suspended on. For each
102
+ * pending tool call the {@link toolApprovalCallback} is consulted (defaulting to REJECT when
103
+ * no handler is wired, so a non-interactive run never hangs or auto-approves); the collected
104
+ * decisions are then sent back via the agent's `streamResume` as a LangChain HITL resume
105
+ * (`{ decisions }`). Because a resumed run can suspend again on the next gated tool call, this
106
+ * loops until the graph completes with no pending interrupts. Returns the concatenated text
107
+ * streamed across all resume turns (empty when nothing was resumed).
108
+ *
109
+ * No-ops (returns '') when the agent does not support interrupts (`getPendingToolInterrupts`/
110
+ * `streamResume` absent), so the lean agent and non-HITL configs are unaffected.
111
+ */
112
+ private resolveToolInterrupts;
113
+ /**
114
+ * Decide a single pending tool call (EXT-9 Tier-2). For the opt-in `run_shell_command`,
115
+ * consult the scoped allow-list FIRST: if the command's classified prefix is already
116
+ * approved (session or persisted `always`) and survives the safe-bin anti-widening
117
+ * re-validation, auto-approve SILENTLY (no human prompt). Otherwise fall through to the
118
+ * human callback; when the human grants `session`/`always` scope, record the command's
119
+ * classified prefix into the matching store so future flag-variants stop re-prompting.
120
+ *
121
+ * When no human callback is wired (non-TTY exec run) and nothing is allow-listed, reject —
122
+ * never auto-approve. Non-shell tools (or any tool when the allow-list is disabled) skip the
123
+ * allow-list and go straight to the human callback / default-reject, preserving prior behaviour.
124
+ *
125
+ * Hardline catastrophic commands remain refused at exec time regardless of any approval here
126
+ * (defense in depth in `GthDevToolkit.executeCommand`), so an allow-listed `rm -rf /` still
127
+ * cannot run.
128
+ */
129
+ private decideToolApproval;
130
+ /** Whether the EXT-10 LLM-as-judge safety gate is enabled for the active command's config. */
131
+ private isShellJudgeOn;
132
+ /** Whether the EXT-9 Tier-2 allow-list is enabled for the active command's devTools config. */
133
+ private isShellAllowlistOn;
134
+ /**
135
+ * Lazily load (once per instance) the persisted `always` allow-list, unless persistence is
136
+ * disabled by config. Returns null when persistence is off so `always` grants behave as
137
+ * `session` (in-memory only).
138
+ */
139
+ private getPersistedAllowlist;
140
+ /** Check the command against the session + persisted stores (with anti-widening re-validation). */
141
+ private isApprovedByAllowlist;
142
+ /**
143
+ * Record a human-granted approval at the given scope. `once` persists nothing. `session`
144
+ * adds the classified prefix to the in-memory store. `always` additionally persists it (or
145
+ * falls back to session-only when persistence is disabled).
146
+ */
147
+ private recordApproval;
32
148
  /**
33
149
  * Event-stream counterpart to {@link processMessages}: drives the agent's typed
34
150
  * {@link AgentStreamEvent} path using the runner's own thread-bound `runConfig`, so a
@@ -39,9 +155,50 @@ export declare class GthAgentRunner {
39
155
  * underlying `streamWithEvents` ends cleanly on abort or `interrupt()`. The string
40
156
  * path's empty-stream retry/`invoke` fallback is intentionally NOT duplicated here — the
41
157
  * TUI renders the live event stream directly; revisit if empty-stream retries are needed.
158
+ *
159
+ * Tool-approval round-trip (EXT-11): after the stream ends, a gated `run_shell_command`
160
+ * leaves the graph suspended on a `humanInTheLoopMiddleware` interrupt rather than
161
+ * completing. This is the event-stream counterpart to the readline path's
162
+ * {@link resolveToolInterrupts}: it drains any pending interrupts through
163
+ * {@link decideToolApproval} (allow-list → judge → bridged human prompt), resumes via
164
+ * `streamWithEventsResume({ decisions })`, and loops until the graph completes with no
165
+ * pending interrupts — so the executed command's output renders into the TUI. Without
166
+ * this the TUI silently finalized an empty turn (approval gate was dead code on the
167
+ * event-stream path).
42
168
  */
43
169
  processMessagesWithEvents(messages: Message[], signal?: AbortSignal): AsyncGenerator<AgentStreamEvent>;
170
+ /**
171
+ * Event-stream counterpart to {@link resolveToolInterrupts}: after a streamed run ends,
172
+ * resolve any tool-approval interrupts it suspended on, yielding the resumed run's typed
173
+ * {@link AgentStreamEvent}s so the renderer (the Ink TUI) shows the executed command's
174
+ * output. Each pending tool call is consulted via {@link decideToolApproval} — the SAME
175
+ * three-layer gate the readline path uses (allow-list auto-approve → EXT-10 judge →
176
+ * bridged human callback, defaulting to REJECT when no handler is wired) — and the
177
+ * collected decisions are sent back via `streamWithEventsResume` as a LangChain HITL
178
+ * resume (`{ decisions }`). Because a resumed run can suspend again on the next gated
179
+ * tool call, this loops until the graph completes with no pending interrupts.
180
+ *
181
+ * No-ops (yields nothing) when the agent does not support interrupts
182
+ * (`getPendingToolInterrupts`/`streamWithEventsResume` absent), so the lean agent and
183
+ * non-HITL configs are unaffected. Aborts (`signal`) propagate through the resumed stream.
184
+ */
185
+ private resolveToolInterruptsWithEvents;
44
186
  getAgent(): GthAgentInterface | null;
187
+ /**
188
+ * GS2-16 — reset the current turn's analytics tally on both the live agent and the runner's
189
+ * cached snapshot, so a new turn starts clean. Fail-soft (an agent without stats support is a
190
+ * no-op). Called at the top of each `processMessages` / `processMessagesWithEvents`.
191
+ */
192
+ private resetRunStats;
193
+ /** GS2-16 — read the live agent's run stats (fail-soft; empty tally if unavailable). */
194
+ private captureRunStats;
195
+ /**
196
+ * GS2-16 — the analytics harvested from the just-finished turn (token usage + invoked tools),
197
+ * to thread into the opt-in history recorder. Reads live from the agent when one is present,
198
+ * otherwise the snapshot captured at {@link cleanup} (the single-shot path reads post-cleanup).
199
+ * Never throws.
200
+ */
201
+ getRunStats(): GthRunStats;
45
202
  /**
46
203
  * Rotate the thread the runner drives by minting a fresh `runConfig` (new `thread_id`),
47
204
  * so subsequent turns start from an empty checkpointer thread rather than retrieving the