@gaunt-sloth/core 2.0.0-alpha.2 → 2.0.0-alpha.21

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 (158) hide show
  1. package/.gsloth.code.md +10 -0
  2. package/README.md +6 -6
  3. package/dist/config/defaults.d.ts +85 -0
  4. package/dist/config/defaults.js +103 -0
  5. package/dist/config/defaults.js.map +1 -0
  6. package/dist/config/jsonc.d.ts +12 -0
  7. package/dist/config/jsonc.js +41 -0
  8. package/dist/config/jsonc.js.map +1 -0
  9. package/dist/config/loader.d.ts +169 -0
  10. package/dist/config/loader.js +872 -0
  11. package/dist/config/loader.js.map +1 -0
  12. package/dist/config/schema.d.ts +673 -0
  13. package/dist/config/schema.js +524 -0
  14. package/dist/config/schema.js.map +1 -0
  15. package/dist/config/shell-policy.d.ts +331 -0
  16. package/dist/config/shell-policy.js +238 -0
  17. package/dist/config/shell-policy.js.map +1 -0
  18. package/dist/config/types.d.ts +596 -0
  19. package/dist/config/types.js +13 -0
  20. package/dist/config/types.js.map +1 -0
  21. package/dist/config.d.ts +18 -647
  22. package/dist/config.js +15 -516
  23. package/dist/config.js.map +1 -1
  24. package/dist/constants.d.ts +42 -0
  25. package/dist/constants.js +42 -0
  26. package/dist/constants.js.map +1 -1
  27. package/dist/core/GthAbstractAgent.d.ts +85 -2
  28. package/dist/core/GthAbstractAgent.js +398 -28
  29. package/dist/core/GthAbstractAgent.js.map +1 -1
  30. package/dist/core/GthAgentRunner.d.ts +158 -1
  31. package/dist/core/GthAgentRunner.js +367 -4
  32. package/dist/core/GthAgentRunner.js.map +1 -1
  33. package/dist/core/GthLangChainAgent.js +193 -16
  34. package/dist/core/GthLangChainAgent.js.map +1 -1
  35. package/dist/core/debugCapture.d.ts +59 -0
  36. package/dist/core/debugCapture.js +101 -0
  37. package/dist/core/debugCapture.js.map +1 -0
  38. package/dist/core/gthLeanAgentFactory.d.ts +9 -0
  39. package/dist/core/gthLeanAgentFactory.js +10 -0
  40. package/dist/core/gthLeanAgentFactory.js.map +1 -0
  41. package/dist/core/plainToolIndication.d.ts +15 -0
  42. package/dist/core/plainToolIndication.js +148 -0
  43. package/dist/core/plainToolIndication.js.map +1 -0
  44. package/dist/core/runStats.d.ts +41 -0
  45. package/dist/core/runStats.js +73 -0
  46. package/dist/core/runStats.js.map +1 -0
  47. package/dist/core/shell/ShellCommandFailedError.d.ts +54 -0
  48. package/dist/core/shell/ShellCommandFailedError.js +68 -0
  49. package/dist/core/shell/ShellCommandFailedError.js.map +1 -0
  50. package/dist/core/shell/allowlist.d.ts +75 -0
  51. package/dist/core/shell/allowlist.js +187 -0
  52. package/dist/core/shell/allowlist.js.map +1 -0
  53. package/dist/core/shell/arity.d.ts +75 -0
  54. package/dist/core/shell/arity.js +313 -0
  55. package/dist/core/shell/arity.js.map +1 -0
  56. package/dist/core/shell/judge.d.ts +161 -0
  57. package/dist/core/shell/judge.js +261 -0
  58. package/dist/core/shell/judge.js.map +1 -0
  59. package/dist/core/shell/normalize.d.ts +27 -0
  60. package/dist/core/shell/normalize.js +53 -0
  61. package/dist/core/shell/normalize.js.map +1 -0
  62. package/dist/core/toolDisplay.d.ts +101 -0
  63. package/dist/core/toolDisplay.js +374 -0
  64. package/dist/core/toolDisplay.js.map +1 -0
  65. package/dist/core/toolOutputChannel.d.ts +68 -0
  66. package/dist/core/toolOutputChannel.js +112 -0
  67. package/dist/core/toolOutputChannel.js.map +1 -0
  68. package/dist/core/types.d.ts +173 -0
  69. package/dist/core/types.js.map +1 -1
  70. package/dist/history/historyFormat.d.ts +28 -0
  71. package/dist/history/historyFormat.js +127 -0
  72. package/dist/history/historyFormat.js.map +1 -0
  73. package/dist/history/historyStore.d.ts +198 -0
  74. package/dist/history/historyStore.js +482 -0
  75. package/dist/history/historyStore.js.map +1 -0
  76. package/dist/history/recordSession.d.ts +37 -0
  77. package/dist/history/recordSession.js +56 -0
  78. package/dist/history/recordSession.js.map +1 -0
  79. package/dist/index.d.ts +4 -0
  80. package/dist/index.js +4 -0
  81. package/dist/index.js.map +1 -1
  82. package/dist/providers/anthropic.d.ts +1 -1
  83. package/dist/providers/anthropic.js +5 -10
  84. package/dist/providers/anthropic.js.map +1 -1
  85. package/dist/providers/deepseek.d.ts +1 -1
  86. package/dist/providers/deepseek.js +5 -10
  87. package/dist/providers/deepseek.js.map +1 -1
  88. package/dist/providers/geminiSchemaSanitizer.d.ts +52 -0
  89. package/dist/providers/geminiSchemaSanitizer.js +201 -0
  90. package/dist/providers/geminiSchemaSanitizer.js.map +1 -0
  91. package/dist/providers/google-genai.d.ts +1 -1
  92. package/dist/providers/google-genai.js +9 -11
  93. package/dist/providers/google-genai.js.map +1 -1
  94. package/dist/providers/groq.d.ts +1 -1
  95. package/dist/providers/groq.js +5 -10
  96. package/dist/providers/groq.js.map +1 -1
  97. package/dist/providers/huggingface.d.ts +25 -0
  98. package/dist/providers/huggingface.js +69 -0
  99. package/dist/providers/huggingface.js.map +1 -0
  100. package/dist/providers/modelCatalog.d.ts +109 -0
  101. package/dist/providers/modelCatalog.js +245 -0
  102. package/dist/providers/modelCatalog.js.map +1 -0
  103. package/dist/providers/modelDiscovery.d.ts +111 -3
  104. package/dist/providers/modelDiscovery.js +183 -27
  105. package/dist/providers/modelDiscovery.js.map +1 -1
  106. package/dist/providers/ollama.d.ts +19 -5
  107. package/dist/providers/ollama.js +60 -52
  108. package/dist/providers/ollama.js.map +1 -1
  109. package/dist/providers/openai.d.ts +1 -1
  110. package/dist/providers/openai.js +5 -10
  111. package/dist/providers/openai.js.map +1 -1
  112. package/dist/providers/openrouter.d.ts +1 -1
  113. package/dist/providers/openrouter.js +12 -12
  114. package/dist/providers/openrouter.js.map +1 -1
  115. package/dist/providers/vertexai.d.ts +1 -1
  116. package/dist/providers/vertexai.js +9 -11
  117. package/dist/providers/vertexai.js.map +1 -1
  118. package/dist/providers/xai.d.ts +1 -1
  119. package/dist/providers/xai.js +5 -10
  120. package/dist/providers/xai.js.map +1 -1
  121. package/dist/runtime/askStructured.d.ts +62 -0
  122. package/dist/runtime/askStructured.js +76 -0
  123. package/dist/runtime/askStructured.js.map +1 -0
  124. package/dist/runtime/conversation.d.ts +59 -0
  125. package/dist/runtime/conversation.js +137 -0
  126. package/dist/runtime/conversation.js.map +1 -0
  127. package/dist/runtime/singleShot.d.ts +24 -5
  128. package/dist/runtime/singleShot.js +56 -9
  129. package/dist/runtime/singleShot.js.map +1 -1
  130. package/dist/utils/aiignoreUtils.js.map +1 -1
  131. package/dist/utils/binaryOutputUtils.js.map +1 -1
  132. package/dist/utils/consoleUtils.d.ts +22 -0
  133. package/dist/utils/consoleUtils.js +45 -0
  134. package/dist/utils/consoleUtils.js.map +1 -1
  135. package/dist/utils/debugDump.d.ts +57 -0
  136. package/dist/utils/debugDump.js +236 -0
  137. package/dist/utils/debugDump.js.map +1 -0
  138. package/dist/utils/debugUtils.d.ts +13 -4
  139. package/dist/utils/debugUtils.js +36 -13
  140. package/dist/utils/debugUtils.js.map +1 -1
  141. package/dist/utils/fileUtils.d.ts +24 -2
  142. package/dist/utils/fileUtils.js +54 -12
  143. package/dist/utils/fileUtils.js.map +1 -1
  144. package/dist/utils/llmUtils.js.map +1 -1
  145. package/dist/utils/redactSecrets.d.ts +63 -0
  146. package/dist/utils/redactSecrets.js +238 -0
  147. package/dist/utils/redactSecrets.js.map +1 -0
  148. package/dist/utils/systemPromptNotes.d.ts +181 -0
  149. package/dist/utils/systemPromptNotes.js +298 -0
  150. package/dist/utils/systemPromptNotes.js.map +1 -0
  151. package/dist/utils/systemUtils.d.ts +32 -1
  152. package/dist/utils/systemUtils.js +50 -3
  153. package/dist/utils/systemUtils.js.map +1 -1
  154. package/dist/utils/toolMatching.d.ts +30 -0
  155. package/dist/utils/toolMatching.js +44 -0
  156. package/dist/utils/toolMatching.js.map +1 -0
  157. package/package.json +17 -8
  158. package/schema/gsloth-config.schema.json +2111 -0
@@ -1 +1 @@
1
- {"version":3,"file":"GthAgentRunner.js","sourceRoot":"","s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3B,CAAC;IAED;;;;;;;;OAQG;IACI,WAAW;QAChB,IAAI,CAAC,SAAS,GAAG,oBAAoB,EAAE,CAAC;QACxC,cAAc,CAAC,uBAAuB,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,OAAO;QACX,QAAQ,CAAC,+BAA+B,CAAC,CAAC;QAC1C,qFAAqF;QACrF,0FAA0F;QAC1F,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAC3C,IAAI,IAAI,CAAC,KAAK,IAAI,SAAS,IAAI,IAAI,CAAC,KAAK,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YACtF,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,QAAQ,CAAC,iCAAiC,CAAC,CAAC;IAC9C,CAAC;CACF"}
@@ -1,9 +1,13 @@
1
1
  import { StatusLevel } from '#src/core/types.js';
2
2
  import { GthAbstractAgent } from '#src/core/GthAbstractAgent.js';
3
3
  import { debugLog, debugLogObject } from '#src/utils/debugUtils.js';
4
- import { formatToolCalls } from '#src/utils/llmUtils.js';
4
+ import { buildSystemMessages, formatToolCalls, readChatPrompt, readCodePrompt, readExecPrompt, } from '#src/utils/llmUtils.js';
5
5
  import { getCurrentWorkDir } from '#src/utils/systemUtils.js';
6
- import { AIMessage } from '@langchain/core/messages';
6
+ import { isToolAllowed } from '#src/utils/toolMatching.js';
7
+ import { appendOsShellNote, appendCwdNote, appendCommitCoAuthorNote, appendModelContextNote, appendMcpServerInstructionsNote, resolveModelIdentity, } from '#src/utils/systemPromptNotes.js';
8
+ import { isShellCommandFailedError } from '#src/core/shell/ShellCommandFailedError.js';
9
+ import { extractDebugRequestExtras } from '#src/core/debugCapture.js';
10
+ import { AIMessage, ToolMessage } from '@langchain/core/messages';
7
11
  import { createAgent, createMiddleware } from 'langchain';
8
12
  /**
9
13
  * Lean agent: builds a standard `createAgent` (ReAct) graph. All run/stream/event
@@ -22,16 +26,16 @@ export class GthLangChainAgent extends GthAbstractAgent {
22
26
  streamOutput: this.config.streamOutput,
23
27
  debugLog: this.config.debugLog,
24
28
  });
25
- this.statusUpdate(StatusLevel.INFO, `Workdir: ${getCurrentWorkDir()}`);
29
+ this.headerStatus(`Workdir: ${getCurrentWorkDir()}`);
26
30
  if (this.config.modelDisplayName) {
27
- this.statusUpdate(StatusLevel.INFO, `Model: ${this.config.modelDisplayName}`);
31
+ this.headerStatus(`Model: ${this.config.modelDisplayName}`);
28
32
  }
29
33
  // An empty allowedTools allow-list disables every tool. Skip resolution entirely so we
30
34
  // don't contact MCP servers (and trigger OAuth) just to discard the result.
31
35
  const allowedTools = this.config.allowedTools;
32
36
  const toolsDisabled = Array.isArray(allowedTools) && allowedTools.length === 0;
33
37
  if (toolsDisabled) {
34
- this.statusUpdate(StatusLevel.INFO, 'Tool loading disabled by allowedTools: []; MCP/A2A servers will not be contacted. Omit allowedTools for no filtering.');
38
+ this.headerStatus('Tool loading disabled by allowedTools: []; MCP/A2A servers will not be contacted. Omit allowedTools for no filtering.');
35
39
  }
36
40
  // Resolve tools via resolver or fall back to config tools only
37
41
  debugLog('Resolving tools...');
@@ -47,19 +51,20 @@ export class GthLangChainAgent extends GthAbstractAgent {
47
51
  // Combine all tools, then apply the allowedTools name allow-list when configured.
48
52
  let tools = [...resolvedTools, ...flattenedConfigTools];
49
53
  if (Array.isArray(allowedTools)) {
50
- const allowed = new Set(allowedTools);
51
- // Filter named tools by the allow-list. ServerTools (provider-native "magic objects" such
52
- // as Anthropic web search) may have no `name`, so they can never be referenced in the
53
- // allow-list - drop-by-default would silently remove them with no recourse. Retain such
54
- // nameless tools instead; the allow-list is a name-based filter and cannot target them.
55
- tools = tools.filter((tool) => !tool.name || allowed.has(tool.name));
54
+ // Filter named tools by the allow-list. Entries match by exact name, or glob-style when
55
+ // they contain `*` (e.g. `mcp__unimarket__*`) see isToolAllowed. ServerTools
56
+ // (provider-native "magic objects" such as Anthropic web search) may have no `name`, so
57
+ // they can never be referenced in the allow-list - drop-by-default would silently remove
58
+ // them with no recourse. Retain such nameless tools instead; the allow-list is a name-based
59
+ // filter and cannot target them.
60
+ tools = tools.filter((tool) => !tool.name || isToolAllowed(tool.name, allowedTools));
56
61
  }
57
62
  if (tools.length > 0) {
58
63
  const toolNames = tools
59
64
  .map((tool) => tool.name)
60
65
  .filter((name) => name)
61
66
  .join(', ');
62
- this.statusUpdate(StatusLevel.INFO, `Loaded tools: ${toolNames}`);
67
+ this.headerStatus(`Loaded tools: ${toolNames}`);
63
68
  debugLog(`Total tools available: ${tools.length}`);
64
69
  debugLogObject('All Tools', toolNames.split(', '));
65
70
  }
@@ -87,15 +92,187 @@ export class GthLangChainAgent extends GthAbstractAgent {
87
92
  return state;
88
93
  },
89
94
  });
90
- // Combine all middleware
91
- const middleware = [...configuredMiddleware, toolCallStatusMiddleware];
92
- this.statusUpdate(StatusLevel.INFO, `Loaded middleware: ${middleware.map((m) => m.name).join(', ')}`);
93
- // Create agent with configured middleware
95
+ // EXT-21: lean-path sibling of the deep agent's GthDeepShellExitSoftening (GthDeepAgent.ts).
96
+ // `exec` / `ask --write` route through this lean `createAgent` graph, whose run_* shell/dev
97
+ // tools (GthDevToolkit.executeCommand) THROW a ShellCommandFailedError on a non-zero exit or a
98
+ // timeout-kill. langchain's default ToolNode would catch that throw into a ToolMessage but leave
99
+ // it status:'success' (✓) — misreporting a failed command. Catch it here at the tool-wrap layer
100
+ // and return an error ToolMessage that PRESERVES the full stdout/stderr body: the model's
101
+ // observation is unchanged except the status flips to 'error', which drives the ✗ (isError)
102
+ // glyph (GthAbstractAgent maps status==='error' → isError). Returning a ToolMessage (rather than
103
+ // rethrowing) keeps it a normal, observed tool result — no run-abort, no retry loop. Recognised
104
+ // via isShellCommandFailedError (instanceof + structural fallback) since core cannot import the
105
+ // throw site in the agent package. Every OTHER throw is rethrown untouched so genuine failures
106
+ // and control-flow (GraphInterrupt / AbortError) still surface.
107
+ const shellExitSoftening = createMiddleware({
108
+ name: 'GthLeanShellExitSoftening',
109
+ wrapToolCall: async (request, handler) => {
110
+ try {
111
+ return await handler(request);
112
+ }
113
+ catch (e) {
114
+ if (isShellCommandFailedError(e)) {
115
+ debugLog(`Softened shell/dev command failure (exit ${e.exitCode ?? 'timeout'}) into an ` +
116
+ `error ToolMessage for '${e.command}'`);
117
+ return new ToolMessage({
118
+ content: e.output,
119
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
+ tool_call_id: request.toolCall?.id ?? '',
121
+ status: 'error',
122
+ });
123
+ }
124
+ throw e;
125
+ }
126
+ },
127
+ });
128
+ // MCP tool-execution errors are spec-compliant RESULTS, not fatal faults. Per the MCP spec
129
+ // (2025-11-25 & draft, "Server › Tools › Error Handling"), a tool that hits an API failure, an
130
+ // input-validation problem, or a business-logic error (e.g. a disabled capability) returns a
131
+ // normal tools/call result with `isError: true`, and the CLIENT *SHOULD* hand that error to the
132
+ // model so it can self-correct. `@langchain/mcp-adapters` instead surfaces such a result by
133
+ // THROWING a ToolException at call time (its `_convertCallToolResult`). Because we install a
134
+ // wrapToolCall middleware, langchain's ToolNode treats any error a middleware rethrows as a fatal
135
+ // "middleware error" (`errorFromMiddleware && handleToolErrors !== true` → throw) and aborts the
136
+ // whole turn instead of relaying the error to the model — the opposite of the spec's client
137
+ // SHOULD. This middleware closes that gap: it catches a thrown ToolException and RETURNS it as a
138
+ // status:'error' ToolMessage (→ isError → ✗), so the model observes the error and can retry or
139
+ // explain (matching the non-stream invoke path's ToolException handling). Scope & safety: matched
140
+ // by name === 'ToolException' (the adapter's marker), so GraphInterrupt and every non-MCP throw
141
+ // fall through the final rethrow untouched. The adapter ALSO wraps a call-time AbortError into a
142
+ // ToolException (its `_callTool` catch-all), so we RETHROW when the run's abort signal is set —
143
+ // otherwise softening here would swallow user cancellation that ToolNode's own `signal?.aborted`
144
+ // guard normally enforces (bypassed once we handle the error in middleware). MCP connect/auth
145
+ // (401/403) and load failures are handled at CONNECT time (resolvers.ts throwOnLoadError +
146
+ // onConnectionError), not here, so they stay fatal as intended.
147
+ const mcpToolErrorSoftening = createMiddleware({
148
+ name: 'GthMcpToolErrorSoftening',
149
+ wrapToolCall: async (request, handler) => {
150
+ try {
151
+ return await handler(request);
152
+ }
153
+ catch (e) {
154
+ if (e instanceof Error &&
155
+ e.name === 'ToolException' &&
156
+ !request.runtime?.signal?.aborted) {
157
+ debugLog(`Softened MCP tool error into an error ToolMessage: ${e.message}`);
158
+ return new ToolMessage({
159
+ content: e.message,
160
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
161
+ tool_call_id: request.toolCall?.id ?? '',
162
+ status: 'error',
163
+ });
164
+ }
165
+ throw e;
166
+ }
167
+ },
168
+ });
169
+ // Debug-capture middleware (TUI `/debug` panel) — the lean-path sibling of GthDeepAgent's.
170
+ // Always installed but lazy: it reads `this.debugCapture` per call, so until the TUI attaches a
171
+ // sink it is a transparent pass-through (one extra await around the handler — the normal path
172
+ // pays nothing). `request.messages` is the real history at call time; `handler(request)`
173
+ // resolves to the AIMessage response. Without this, the TUI's System-prompt/Tools/Chat-history
174
+ // tabs stay empty on the (now default) lean backend.
175
+ const getDebugCapture = () => this.debugCapture;
176
+ const debugCaptureMiddleware = createMiddleware({
177
+ name: 'GthMiddlewareDebugCapture',
178
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
179
+ wrapModelCall: async (request, handler) => {
180
+ const capture = getDebugCapture();
181
+ if (!capture)
182
+ return handler(request);
183
+ try {
184
+ capture.onRequest?.(request.messages, extractDebugRequestExtras(request));
185
+ }
186
+ catch {
187
+ /* a debug sink must never break the run */
188
+ }
189
+ const response = await handler(request);
190
+ try {
191
+ capture.onResponse?.(response);
192
+ }
193
+ catch {
194
+ /* a debug sink must never break the run */
195
+ }
196
+ return response;
197
+ },
198
+ });
199
+ // shellExitSoftening FIRST so it is the outermost wrapToolCall — it must see the raw
200
+ // ShellCommandFailedError throw before any user-configured middleware could transform it.
201
+ // mcpToolErrorSoftening sits right after it, still outboard of any user-configured middleware so
202
+ // it sees the raw ToolException before a user wrapToolCall could transform it. Order between the
203
+ // two softeners is not load-bearing: they catch DISJOINT conditions (a ShellCommandFailedError
204
+ // vs a name==='ToolException') and each rethrows what it doesn't recognize, so neither can
205
+ // swallow the other.
206
+ const middleware = [
207
+ shellExitSoftening,
208
+ mcpToolErrorSoftening,
209
+ ...configuredMiddleware,
210
+ toolCallStatusMiddleware,
211
+ debugCaptureMiddleware,
212
+ ];
213
+ this.headerStatus(`Loaded middleware: ${middleware.map((m) => m.name).join(', ')}`);
214
+ // GS2-21: compose gsloth's system prompt (backstory + guidelines + per-command mode prompt +
215
+ // system prompt) EXACTLY as GthDeepAgent does, so identity profiles and `.gsloth.*.md` are
216
+ // honored on the lean backend too. Previously the lean agent gave the model NO system prompt
217
+ // (only the deep agent composed one), so `system-prompt.md` / projectGuidelines never reached
218
+ // the model — the robot (agent.backend: lean) behaved as if it never got its guidelines.
219
+ // This is passed to createAgent as `systemPrompt`, which langchain applies as the agent's
220
+ // static system message on every turn — NOT injected as a separate mid-conversation
221
+ // SystemMessage (a non-first system message that Anthropic rejects). 'code' uses the code-mode
222
+ // prompt; 'exec' uses the exec-mode prompt; chat/api/others use the chat prompt.
223
+ const modePrompt = this.command === 'code'
224
+ ? readCodePrompt(this.config)
225
+ : this.command === 'exec'
226
+ ? readExecPrompt(this.config)
227
+ : readChatPrompt(this.config);
228
+ const systemMessages = buildSystemMessages(this.config, modePrompt);
229
+ const baseSystemPrompt = typeof systemMessages[0]?.content === 'string' ? systemMessages[0].content : undefined;
230
+ // GS2-27: in `code` mode append the SHARED code-mode notes the deep backend has always carried
231
+ // — the real-cwd / path-model note (EXT-13) and the OS + shell-dialect note (EXT-26). Both are
232
+ // backend-agnostic (the lean backend also exposes `run_shell_command` and runs on the real-fs
233
+ // cwd), so composing them here closes the deep-only drift that left a lean code session with no
234
+ // cwd value and no shell-dialect guidance (e.g. on Windows). The deepagents virtual-fs-namespace
235
+ // notes stay deep-only (lean never runs virtualMode). Same order the deep backend's real-path
236
+ // branch uses: cwd note first, OS/shell note last. `getCurrentWorkDir()` is already read above
237
+ // for the status line, so the value is free.
238
+ // GS2-35: also append the commit co-authoring rule so the agent credits Gaunt Sloth (config
239
+ // `commit.coAuthor`, defaulting to the Gaunt Sloth account) in the `Co-Authored-By` trailer and
240
+ // never the underlying model name. Same code-mode gate as the shell/cwd notes — the git-commit
241
+ // capability rides on `run_shell_command`, which is a code-mode tool.
242
+ const codeNotesPrompt = this.command === 'code'
243
+ ? appendCommitCoAuthorNote(appendOsShellNote(appendCwdNote(baseSystemPrompt, getCurrentWorkDir())), this.config.commit?.coAuthor)
244
+ : baseSystemPrompt;
245
+ // GS2-34: inject the resolved provider:model identity so the agent knows which model is serving
246
+ // it (to answer "what model are you?" and reason about its own capabilities/limits). Composed
247
+ // OUTSIDE the code-mode gate above — unlike the cwd/os-shell/commit notes, that question can
248
+ // arise in ANY mode (chat/ask/code/exec), so the identity must be visible everywhere. Config
249
+ // opt-out via `injectModelContext: false` (default ON, defaulted here at the read site); when
250
+ // off — or when no model resolves — nothing is appended and the prompt is exactly as before.
251
+ // Backend-agnostic: the deep backend composes the same note (GS2-27 parity). The GS2-6
252
+ // capability note is a deferred follow-up (bare provider:model identity only for now).
253
+ const modelContextPrompt = this.config.injectModelContext !== false
254
+ ? appendModelContextNote(codeNotesPrompt, resolveModelIdentity(this.config))
255
+ : codeNotesPrompt;
256
+ // EXT-32: inject each connected MCP server's discovery `instructions` (captured during tool
257
+ // resolution) into the prompt — fenced + per-server-labelled as untrusted server-provided
258
+ // context. Mode-independent: MCP tools load in every mode, so their usage guidance applies in
259
+ // every mode (not just `code`). Empty/absent capture (or a resolver without the accessor) adds
260
+ // nothing. Composed through this shared path so it reaches the lean AND deep backends alike.
261
+ // When tools are disabled, resolveTools is skipped entirely (no MCP contact), so a REUSED
262
+ // resolver could still hold a prior run's capture — gate on toolsDisabled so no stale
263
+ // instructions leak into a tools-disabled session.
264
+ const mcpInstructions = toolsDisabled
265
+ ? []
266
+ : (this.resolvers?.getMcpServerInstructions?.() ?? []);
267
+ const systemPrompt = appendMcpServerInstructionsNote(modelContextPrompt, mcpInstructions);
268
+ // Create agent with configured middleware. Only pass systemPrompt when non-empty so we never
269
+ // hand createAgent an empty system message.
94
270
  this.agent = createAgent({
95
271
  model: this.config.llm,
96
272
  tools,
97
273
  middleware,
98
274
  checkpointer,
275
+ ...(systemPrompt ? { systemPrompt } : {}),
99
276
  });
100
277
  debugLog('React agent created successfully');
101
278
  }
@@ -1 +1 @@
1
- {"version":3,"file":"GthLangChainAgent.js","sourceRoot":"","sources":["../../src/core/GthLangChainAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAM1D;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,gBAAgB;IACrD,KAAK,CAAC,IAAI,CACR,OAA+B,EAC/B,QAAmB,EACnB,YAA8C;QAE9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,QAAQ,CAAC,+CAA+C,OAAO,IAAI,SAAS,EAAE,CAAC,CAAC;QAEhF,uDAAuD;QACvD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,kBAAkB,CA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F,6FAA6F;QAC7F,uFAAuF;QACvF,uFAAuF;QACvF,MAAM,kBAAkB,GACtB,IAAI,CAAC,MAAM,CAAC,kBAAkB,KAAK,KAAK;YACtC,CAAC,CAAC,sBAAsB,CAAC,eAAe,EAAE,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC5E,CAAC,CAAC,eAAe,CAAC;QAEtB,4FAA4F;QAC5F,0FAA0F;QAC1F,8FAA8F;QAC9F,+FAA+F;QAC/F,6FAA6F;QAC7F,0FAA0F;QAC1F,sFAAsF;QACtF,mDAAmD;QACnD,MAAM,eAAe,GAAG,aAAa;YACnC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,wBAAwB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,MAAM,YAAY,GAAG,+BAA+B,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC;QAE1F,6FAA6F;QAC7F,4CAA4C;QAC5C,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC;YACvB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG;YACtB,KAAK;YACL,UAAU;YACV,YAAY;YACZ,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1C,CAAC,CAAC;QACH,QAAQ,CAAC,kCAAkC,CAAC,CAAC;IAC/C,CAAC;CACF"}
@@ -0,0 +1,59 @@
1
+ import type { BaseMessage } from '@langchain/core/messages';
2
+ /**
3
+ * The non-message parts of a `wrapModelCall` request that also shape a turn: the tool
4
+ * definitions, the system prompt, and the model params. Captured alongside the message
5
+ * history so the `/debug` panel can show the full picture of what was sent to the model.
6
+ *
7
+ * SECURITY: these are assembled from an explicit allowlist at the capture site
8
+ * (see {@link extractDebugRequestExtras}); the raw model instance (which can carry an
9
+ * `apiKey`) is never passed through here.
10
+ */
11
+ export interface DebugRequestExtras {
12
+ /** The composed system prompt string sent to the model for this call. */
13
+ systemPrompt?: string;
14
+ /** The tool definitions made available for this call (name + description + JSON schema). */
15
+ tools?: DebugToolDef[];
16
+ /** Scalar model params (model id, temperature, …) — a key-free allowlist. */
17
+ modelParams?: Record<string, unknown>;
18
+ /** The tool-choice configuration for this call, if any. */
19
+ toolChoice?: unknown;
20
+ }
21
+ /** A single tool's debug-renderable definition. */
22
+ export interface DebugToolDef {
23
+ name: string;
24
+ description?: string;
25
+ /** The tool's JSON-schema parameters, when resolvable. */
26
+ schema?: unknown;
27
+ }
28
+ /**
29
+ * Debug-capture sink for the TUI's `/debug` panel.
30
+ *
31
+ * A {@link DebugCapture} is an OPT-IN callback the TUI sets on a live agent after `init`
32
+ * (on the shared {@link import('#src/core/GthAbstractAgent.js').GthAbstractAgent} base, so
33
+ * both the lean and deep backends support it). When present, the agent's `wrapModelCall`
34
+ * middleware reports, per model call:
35
+ *
36
+ * - `request` — `request.messages: BaseMessage[]`, the real history sent to the model at
37
+ * call time (post-summarization / post-middleware), plus the {@link DebugRequestExtras}
38
+ * (tools, system prompt, model params) that also shape the turn. This is exactly what the
39
+ * model saw.
40
+ * - `response` — the resolved `AIMessage` returned by the handler, captured as a whole
41
+ * (resolved message, not per-chunk frames; keeps the streaming core untouched).
42
+ *
43
+ * The sink is read lazily inside the middleware (per call), so when no TUI debug panel is
44
+ * attached the middleware is a transparent pass-through and the normal path pays nothing.
45
+ */
46
+ export interface DebugCapture {
47
+ /** The full message history sent to the model for this call, plus the request extras. */
48
+ onRequest?(messages: BaseMessage[], extras?: DebugRequestExtras): void;
49
+ /** The resolved model response for this call (an `AIMessage`). */
50
+ onResponse?(response: unknown): void;
51
+ }
52
+ /**
53
+ * Assemble the non-message request parts ({@link DebugRequestExtras}) for the `/debug`
54
+ * panel from a `wrapModelCall` request, defensively and key-free. Never throws (the caller
55
+ * already guards, but a debug sink must never break a run) and never dumps the raw model.
56
+ * Shared by both the lean ({@link import('#src/core/GthLangChainAgent.js').GthLangChainAgent})
57
+ * and deep backends so the panel behaves identically on either.
58
+ */
59
+ export declare function extractDebugRequestExtras(request: unknown): DebugRequestExtras | undefined;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Scalar model-param fields worth surfacing in the `/debug` panel. Deliberately an
3
+ * allowlist (NOT a whole-object dump) so no credential field (`apiKey`, `accessToken`, …)
4
+ * can ever leak into the rendered debug view.
5
+ *
6
+ * `streaming` is intentionally NOT here: it is the model instance's static flag, which is
7
+ * usually `false` even when the turn streams — the GthAgentRunner decides streaming by calling
8
+ * `.stream()` vs `.invoke()`, not by this property — so surfacing it just misleads.
9
+ */
10
+ const DEBUG_MODEL_PARAM_KEYS = [
11
+ 'model',
12
+ 'modelName',
13
+ 'modelId',
14
+ 'deploymentName',
15
+ 'temperature',
16
+ 'topP',
17
+ 'topK',
18
+ 'maxTokens',
19
+ 'maxOutputTokens',
20
+ 'maxReasoningTokens',
21
+ 'reasoningEffort',
22
+ 'thinkingBudget',
23
+ 'stop',
24
+ 'provider',
25
+ ];
26
+ /** Pull the key-free scalar model params from the (provider-specific) model instance. */
27
+ function extractModelParams(model) {
28
+ if (!model || typeof model !== 'object')
29
+ return undefined;
30
+ const src = model;
31
+ const out = {};
32
+ for (const key of DEBUG_MODEL_PARAM_KEYS) {
33
+ const value = src[key];
34
+ if (value === undefined || value === null)
35
+ continue;
36
+ // Only scalars / scalar arrays — never nested objects that could carry credentials.
37
+ if (typeof value === 'object' && !Array.isArray(value))
38
+ continue;
39
+ out[key] = value;
40
+ }
41
+ // `model` / `modelName` / `modelId` are langchain aliases for the same value; collapse the
42
+ // duplicates so the panel shows the model id once instead of two identical lines.
43
+ if (typeof out.model !== 'string' && typeof out.modelName === 'string') {
44
+ out.model = out.modelName;
45
+ }
46
+ if (out.modelName === out.model)
47
+ delete out.modelName;
48
+ if (out.modelId === out.model)
49
+ delete out.modelId;
50
+ return Object.keys(out).length > 0 ? out : undefined;
51
+ }
52
+ /** Best-effort tool definition (name + description + schema) for the debug view. */
53
+ function extractToolDefs(tools) {
54
+ if (!Array.isArray(tools) || tools.length === 0)
55
+ return undefined;
56
+ const defs = [];
57
+ for (const tool of tools) {
58
+ if (!tool || typeof tool !== 'object')
59
+ continue;
60
+ const t = tool;
61
+ const name = typeof t.name === 'string' ? t.name : undefined;
62
+ if (!name)
63
+ continue;
64
+ const description = typeof t.description === 'string' ? t.description : undefined;
65
+ // LangChain StructuredTools expose a Zod/JSON `schema`; some carry it on `lc_kwargs`.
66
+ const schema = t.schema ?? undefined;
67
+ defs.push({ name, description, schema });
68
+ }
69
+ return defs.length > 0 ? defs : undefined;
70
+ }
71
+ /**
72
+ * Assemble the non-message request parts ({@link DebugRequestExtras}) for the `/debug`
73
+ * panel from a `wrapModelCall` request, defensively and key-free. Never throws (the caller
74
+ * already guards, but a debug sink must never break a run) and never dumps the raw model.
75
+ * Shared by both the lean ({@link import('#src/core/GthLangChainAgent.js').GthLangChainAgent})
76
+ * and deep backends so the panel behaves identically on either.
77
+ */
78
+ export function extractDebugRequestExtras(request) {
79
+ if (!request || typeof request !== 'object')
80
+ return undefined;
81
+ const req = request;
82
+ const systemMessage = req.systemMessage;
83
+ const systemPrompt = typeof req.systemPrompt === 'string' && req.systemPrompt
84
+ ? req.systemPrompt
85
+ : typeof systemMessage?.content === 'string'
86
+ ? systemMessage.content
87
+ : undefined;
88
+ const extras = {
89
+ systemPrompt,
90
+ tools: extractToolDefs(req.tools),
91
+ modelParams: extractModelParams(req.model),
92
+ toolChoice: req.toolChoice,
93
+ };
94
+ // Return undefined when nothing useful was captured so the renderer can show a clear empty state.
95
+ const hasAny = extras.systemPrompt !== undefined ||
96
+ extras.tools !== undefined ||
97
+ extras.modelParams !== undefined ||
98
+ extras.toolChoice !== undefined;
99
+ return hasAny ? extras : undefined;
100
+ }
101
+ //# sourceMappingURL=debugCapture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debugCapture.js","sourceRoot":"","sources":["../../src/core/debugCapture.ts"],"names":[],"mappings":"AAuDA;;;;;;;;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AAC,YAAY,KAAK,QAAQ,IAAI,GAAG,CAAC,YAAY;QACtD,CAAC,CAAC,GAAG,CAAC,YAAY;QAClB,CAAC,CAAC,OAAO,aAAa,EAAE,OAAO,KAAK,QAAQ;YAC1C,CAAC,CAAC,aAAa,CAAC,OAAO;YACvB,CAAC,CAAC,SAAS,CAAC;IAClB,MAAM,MAAM,GAAuB;QACjC,YAAY;QACZ,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC;QACjC,WAAW,EAAE,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC;QAC1C,UAAU,EAAE,GAAG,CAAC,UAAU;KAC3B,CAAC;IACF,kGAAkG;IAClG,MAAM,MAAM,GACV,MAAM,CAAC,YAAY,KAAK,SAAS;QACjC,MAAM,CAAC,KAAK,KAAK,SAAS;QAC1B,MAAM,CAAC,WAAW,KAAK,SAAS;QAChC,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC;IAClC,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACrC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { GthAgentFactory } from '#src/core/types.js';
2
+ /**
3
+ * The lean backend factory — a {@link GthAgentFactory} that produces a plain
4
+ * {@link GthLangChainAgent} (no deepagents graph). This is identical to the built-in
5
+ * default {@link GthAgentRunner} constructs when no factory is passed; exporting it lets
6
+ * `@gaunt-sloth/agent`'s {@link resolveAgentFactory} pick lean vs deep from config without
7
+ * duplicating the constructor call.
8
+ */
9
+ export declare const gthLeanAgentFactory: GthAgentFactory;
@@ -0,0 +1,10 @@
1
+ import { GthLangChainAgent } from '#src/core/GthLangChainAgent.js';
2
+ /**
3
+ * The lean backend factory — a {@link GthAgentFactory} that produces a plain
4
+ * {@link GthLangChainAgent} (no deepagents graph). This is identical to the built-in
5
+ * default {@link GthAgentRunner} constructs when no factory is passed; exporting it lets
6
+ * `@gaunt-sloth/agent`'s {@link resolveAgentFactory} pick lean vs deep from config without
7
+ * duplicating the constructor call.
8
+ */
9
+ export const gthLeanAgentFactory = (statusUpdate, resolvers) => new GthLangChainAgent(statusUpdate, resolvers);
10
+ //# sourceMappingURL=gthLeanAgentFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gthLeanAgentFactory.js","sourceRoot":"","sources":["../../src/core/gthLeanAgentFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAoB,CAAC,YAAY,EAAE,SAAS,EAAE,EAAE,CAC9E,IAAI,iBAAiB,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ export interface PlainToolIndicationObserver {
2
+ /** Feed every streamed message/chunk (the string path's existing loop) through this. */
3
+ observe(chunk: unknown): void;
4
+ }
5
+ /**
6
+ * Create the per-stream observer. State is scoped to one stream (one `agent.stream()` call);
7
+ * tool_call deltas are accumulated from `tool_call_chunks` (keyed by the provider's chunk
8
+ * `index`, which restarts per LLM round — the map is flushed into the by-id map whenever a
9
+ * `ToolMessage` arrives, mirroring `processEventStream`'s reset-per-round). Deliberately does
10
+ * NOT `concat()` whole `AIMessageChunk`s: only the tool-call slices are needed, which also
11
+ * sidesteps the TUI-C29 `__raw_response` aggregation-growth trap entirely.
12
+ *
13
+ * `emit` is injectable for tests; production uses the INFO-level `displayToolIndication`.
14
+ */
15
+ export declare function createPlainToolIndication(emit?: (text: string) => void): PlainToolIndicationObserver;