@gaunt-sloth/core 2.0.0-alpha.9 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gsloth.review.md +2 -0
- package/README.md +71 -20
- package/dist/config/colour.d.ts +38 -0
- package/dist/config/colour.js +36 -0
- package/dist/config/colour.js.map +1 -0
- package/dist/config/configDiscovery.d.ts +79 -0
- package/dist/config/configDiscovery.js +80 -0
- package/dist/config/configDiscovery.js.map +1 -0
- package/dist/config/defaults.d.ts +20 -20
- package/dist/config/defaults.js +10 -8
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/filesystem-tools.d.ts +41 -0
- package/dist/config/filesystem-tools.js +56 -0
- package/dist/config/filesystem-tools.js.map +1 -0
- package/dist/config/loader.d.ts +171 -19
- package/dist/config/loader.js +1054 -144
- package/dist/config/loader.js.map +1 -1
- package/dist/config/mouse.d.ts +50 -0
- package/dist/config/mouse.js +44 -0
- package/dist/config/mouse.js.map +1 -0
- package/dist/config/profiles.d.ts +68 -0
- package/dist/config/profiles.js +93 -0
- package/dist/config/profiles.js.map +1 -0
- package/dist/config/providerKeys.d.ts +69 -0
- package/dist/config/providerKeys.js +69 -0
- package/dist/config/providerKeys.js.map +1 -0
- package/dist/config/schema.d.ts +2671 -138
- package/dist/config/schema.js +1361 -85
- package/dist/config/schema.js.map +1 -1
- package/dist/config/shell-policy.d.ts +899 -111
- package/dist/config/shell-policy.js +800 -70
- package/dist/config/shell-policy.js.map +1 -1
- package/dist/config/tool-descriptions.d.ts +211 -0
- package/dist/config/tool-descriptions.js +272 -0
- package/dist/config/tool-descriptions.js.map +1 -0
- package/dist/config/types.d.ts +352 -41
- package/dist/config/types.js +1 -0
- package/dist/config/types.js.map +1 -1
- package/dist/config.d.ts +35 -1
- package/dist/config.js +16 -1
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +28 -1
- package/dist/constants.js +28 -1
- package/dist/constants.js.map +1 -1
- package/dist/core/GthAbstractAgent.d.ts +166 -11
- package/dist/core/GthAbstractAgent.js +484 -45
- package/dist/core/GthAbstractAgent.js.map +1 -1
- package/dist/core/GthAgentRunner.d.ts +543 -57
- package/dist/core/GthAgentRunner.js +1494 -140
- package/dist/core/GthAgentRunner.js.map +1 -1
- package/dist/core/GthLangChainAgent.d.ts +117 -2
- package/dist/core/GthLangChainAgent.js +602 -29
- package/dist/core/GthLangChainAgent.js.map +1 -1
- package/dist/core/approvals/annotations.d.ts +122 -0
- package/dist/core/approvals/annotations.js +137 -0
- package/dist/core/approvals/annotations.js.map +1 -0
- package/dist/core/approvals/grants.d.ts +216 -0
- package/dist/core/approvals/grants.js +469 -0
- package/dist/core/approvals/grants.js.map +1 -0
- package/dist/core/approvals/matcher.d.ts +202 -0
- package/dist/core/approvals/matcher.js +267 -0
- package/dist/core/approvals/matcher.js.map +1 -0
- package/dist/core/approvals/mcpSubjects.d.ts +40 -0
- package/dist/core/approvals/mcpSubjects.js +99 -0
- package/dist/core/approvals/mcpSubjects.js.map +1 -0
- package/dist/core/approvals/promptHeader.d.ts +28 -0
- package/dist/core/approvals/promptHeader.js +62 -0
- package/dist/core/approvals/promptHeader.js.map +1 -0
- package/dist/core/approvals/toolAnnotationSources.d.ts +105 -0
- package/dist/core/approvals/toolAnnotationSources.js +277 -0
- package/dist/core/approvals/toolAnnotationSources.js.map +1 -0
- package/dist/core/approvals/toolHost.d.ts +46 -0
- package/dist/core/approvals/toolHost.js +108 -0
- package/dist/core/approvals/toolHost.js.map +1 -0
- package/dist/core/debugCapture.d.ts +74 -0
- package/dist/core/debugCapture.js +100 -0
- package/dist/core/debugCapture.js.map +1 -0
- package/dist/core/gthLeanAgentFactory.d.ts +4 -4
- package/dist/core/gthLeanAgentFactory.js +4 -4
- package/dist/core/launchBanner.d.ts +127 -0
- package/dist/core/launchBanner.js +414 -0
- package/dist/core/launchBanner.js.map +1 -0
- package/dist/core/modelLabel.d.ts +19 -0
- package/dist/core/modelLabel.js +26 -0
- package/dist/core/modelLabel.js.map +1 -0
- package/dist/core/plainToolIndication.d.ts +15 -0
- package/dist/core/plainToolIndication.js +174 -0
- package/dist/core/plainToolIndication.js.map +1 -0
- package/dist/core/reasoningBlocks.d.ts +65 -0
- package/dist/core/reasoningBlocks.js +103 -0
- package/dist/core/reasoningBlocks.js.map +1 -0
- package/dist/core/refusal.d.ts +53 -0
- package/dist/core/refusal.js +133 -0
- package/dist/core/refusal.js.map +1 -0
- package/dist/core/runHeader.d.ts +38 -0
- package/dist/core/runHeader.js +42 -0
- package/dist/core/runHeader.js.map +1 -0
- package/dist/core/runStats.d.ts +14 -3
- package/dist/core/runStats.js +48 -3
- package/dist/core/runStats.js.map +1 -1
- package/dist/core/shell/ShellCommandFailedError.d.ts +3 -4
- package/dist/core/shell/ShellCommandFailedError.js +3 -4
- package/dist/core/shell/ShellCommandFailedError.js.map +1 -1
- package/dist/core/shell/abstention.d.ts +88 -0
- package/dist/core/shell/abstention.js +184 -0
- package/dist/core/shell/abstention.js.map +1 -0
- package/dist/core/shell/approvalCapture.d.ts +271 -0
- package/dist/core/shell/approvalCapture.js +108 -0
- package/dist/core/shell/approvalCapture.js.map +1 -0
- package/dist/core/shell/approvalStop.d.ts +123 -0
- package/dist/core/shell/approvalStop.js +269 -0
- package/dist/core/shell/approvalStop.js.map +1 -0
- package/dist/core/shell/arity.d.ts +6 -0
- package/dist/core/shell/arity.js +20 -6
- package/dist/core/shell/arity.js.map +1 -1
- package/dist/core/shell/denylist.d.ts +11 -0
- package/dist/core/shell/denylist.js +37 -0
- package/dist/core/shell/denylist.js.map +1 -0
- package/dist/core/shell/escalationSeverity.d.ts +141 -0
- package/dist/core/shell/escalationSeverity.js +89 -0
- package/dist/core/shell/escalationSeverity.js.map +1 -0
- package/dist/core/shell/framing.d.ts +190 -0
- package/dist/core/shell/framing.js +633 -0
- package/dist/core/shell/framing.js.map +1 -0
- package/dist/core/shell/hardline.d.ts +103 -0
- package/dist/core/shell/hardline.js +780 -0
- package/dist/core/shell/hardline.js.map +1 -0
- package/dist/core/shell/negotiation.d.ts +328 -0
- package/dist/core/shell/negotiation.js +488 -0
- package/dist/core/shell/negotiation.js.map +1 -0
- package/dist/core/shell/normalize.d.ts +44 -4
- package/dist/core/shell/normalize.js +61 -7
- package/dist/core/shell/normalize.js.map +1 -1
- package/dist/core/shell/openWorld.d.ts +263 -0
- package/dist/core/shell/openWorld.js +1188 -0
- package/dist/core/shell/openWorld.js.map +1 -0
- package/dist/core/shell/rater.d.ts +873 -0
- package/dist/core/shell/rater.js +1454 -0
- package/dist/core/shell/rater.js.map +1 -0
- package/dist/core/shell/raterModel.d.ts +41 -0
- package/dist/core/shell/raterModel.js +51 -0
- package/dist/core/shell/raterModel.js.map +1 -0
- package/dist/core/shell/raterVocabulary.d.ts +121 -0
- package/dist/core/shell/raterVocabulary.js +116 -0
- package/dist/core/shell/raterVocabulary.js.map +1 -0
- package/dist/core/shell/rejection.d.ts +69 -0
- package/dist/core/shell/rejection.js +38 -0
- package/dist/core/shell/rejection.js.map +1 -0
- package/dist/core/toolCallRepair/grammar.d.ts +41 -0
- package/dist/core/toolCallRepair/grammar.js +116 -0
- package/dist/core/toolCallRepair/grammar.js.map +1 -0
- package/dist/core/toolCallRepair/index.d.ts +2 -0
- package/dist/core/toolCallRepair/index.js +7 -0
- package/dist/core/toolCallRepair/index.js.map +1 -0
- package/dist/core/toolCallRepair/payload.d.ts +36 -0
- package/dist/core/toolCallRepair/payload.js +341 -0
- package/dist/core/toolCallRepair/payload.js.map +1 -0
- package/dist/core/toolCallRepair/promote.d.ts +45 -0
- package/dist/core/toolCallRepair/promote.js +90 -0
- package/dist/core/toolCallRepair/promote.js.map +1 -0
- package/dist/core/toolDisplay.d.ts +123 -0
- package/dist/core/toolDisplay.js +451 -0
- package/dist/core/toolDisplay.js.map +1 -0
- package/dist/core/toolOutputChannel.d.ts +95 -0
- package/dist/core/toolOutputChannel.js +165 -0
- package/dist/core/toolOutputChannel.js.map +1 -0
- package/dist/core/types.d.ts +349 -16
- package/dist/core/types.js.map +1 -1
- package/dist/history/historyFormat.d.ts +12 -3
- package/dist/history/historyFormat.js +50 -8
- package/dist/history/historyFormat.js.map +1 -1
- package/dist/history/historyStore.d.ts +77 -0
- package/dist/history/historyStore.js +173 -6
- package/dist/history/historyStore.js.map +1 -1
- package/dist/history/recordSession.d.ts +10 -1
- package/dist/history/recordSession.js +27 -0
- package/dist/history/recordSession.js.map +1 -1
- package/dist/providers/anthropic.js +12 -0
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/configurationPassthrough.d.ts +107 -0
- package/dist/providers/configurationPassthrough.js +148 -0
- package/dist/providers/configurationPassthrough.js.map +1 -0
- package/dist/providers/geminiSchemaSanitizer.d.ts +55 -0
- package/dist/providers/geminiSchemaSanitizer.js +347 -0
- package/dist/providers/geminiSchemaSanitizer.js.map +1 -0
- package/dist/providers/geminiThinking.d.ts +60 -0
- package/dist/providers/geminiThinking.js +92 -0
- package/dist/providers/geminiThinking.js.map +1 -0
- package/dist/providers/google-genai.js +18 -1
- package/dist/providers/google-genai.js.map +1 -1
- package/dist/providers/groq.js +12 -0
- package/dist/providers/groq.js.map +1 -1
- package/dist/providers/huggingface.d.ts +25 -0
- package/dist/providers/huggingface.js +69 -0
- package/dist/providers/huggingface.js.map +1 -0
- package/dist/providers/modelCatalog.d.ts +109 -0
- package/dist/providers/modelCatalog.js +245 -0
- package/dist/providers/modelCatalog.js.map +1 -0
- package/dist/providers/modelDiscovery.d.ts +99 -5
- package/dist/providers/modelDiscovery.js +191 -35
- package/dist/providers/modelDiscovery.js.map +1 -1
- package/dist/providers/ollama.d.ts +18 -4
- package/dist/providers/ollama.js +67 -37
- package/dist/providers/ollama.js.map +1 -1
- package/dist/providers/openai.js +34 -0
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/openrouter.d.ts +26 -4
- package/dist/providers/openrouter.js +83 -26
- package/dist/providers/openrouter.js.map +1 -1
- package/dist/providers/vertexai.js +19 -1
- package/dist/providers/vertexai.js.map +1 -1
- package/dist/providers/xai.js +20 -0
- package/dist/providers/xai.js.map +1 -1
- package/dist/runtime/askStructured.d.ts +105 -0
- package/dist/runtime/askStructured.js +120 -0
- package/dist/runtime/askStructured.js.map +1 -0
- package/dist/runtime/conversation.d.ts +64 -0
- package/dist/runtime/conversation.js +171 -0
- package/dist/runtime/conversation.js.map +1 -0
- package/dist/runtime/singleShot.d.ts +37 -6
- package/dist/runtime/singleShot.js +113 -67
- package/dist/runtime/singleShot.js.map +1 -1
- package/dist/runtime/structuredOutput.d.ts +104 -0
- package/dist/runtime/structuredOutput.js +393 -0
- package/dist/runtime/structuredOutput.js.map +1 -0
- package/dist/utils/ProgressIndicator.d.ts +21 -0
- package/dist/utils/ProgressIndicator.js +30 -3
- package/dist/utils/ProgressIndicator.js.map +1 -1
- package/dist/utils/aiignoreUtils.js.map +1 -1
- package/dist/utils/binaryOutputUtils.js.map +1 -1
- package/dist/utils/consoleUtils.d.ts +95 -0
- package/dist/utils/consoleUtils.js +112 -2
- package/dist/utils/consoleUtils.js.map +1 -1
- package/dist/utils/crashHandler.d.ts +87 -0
- package/dist/utils/crashHandler.js +128 -0
- package/dist/utils/crashHandler.js.map +1 -0
- package/dist/utils/debugDump.d.ts +134 -0
- package/dist/utils/debugDump.js +381 -0
- package/dist/utils/debugDump.js.map +1 -0
- package/dist/utils/debugUtils.d.ts +13 -4
- package/dist/utils/debugUtils.js +36 -13
- package/dist/utils/debugUtils.js.map +1 -1
- package/dist/utils/displayWidth.d.ts +53 -0
- package/dist/utils/displayWidth.js +195 -0
- package/dist/utils/displayWidth.js.map +1 -0
- package/dist/utils/fileUtils.js.map +1 -1
- package/dist/utils/globalConfigUtils.d.ts +14 -2
- package/dist/utils/globalConfigUtils.js +22 -4
- package/dist/utils/globalConfigUtils.js.map +1 -1
- package/dist/utils/llmUtils.d.ts +39 -8
- package/dist/utils/llmUtils.js +76 -8
- package/dist/utils/llmUtils.js.map +1 -1
- package/dist/utils/redactSecrets.d.ts +63 -0
- package/dist/utils/redactSecrets.js +286 -0
- package/dist/utils/redactSecrets.js.map +1 -0
- package/dist/utils/systemPromptNotes.d.ts +222 -0
- package/dist/utils/systemPromptNotes.js +338 -0
- package/dist/utils/systemPromptNotes.js.map +1 -0
- package/dist/utils/systemUtils.d.ts +18 -1
- package/dist/utils/systemUtils.js +38 -3
- package/dist/utils/systemUtils.js.map +1 -1
- package/dist/utils/toolMatching.d.ts +30 -0
- package/dist/utils/toolMatching.js +44 -0
- package/dist/utils/toolMatching.js.map +1 -0
- package/dist/utils/untrustedText.d.ts +86 -0
- package/dist/utils/untrustedText.js +101 -0
- package/dist/utils/untrustedText.js.map +1 -0
- package/package.json +21 -7
- package/schema/gsloth-config.schema.json +1921 -326
- package/dist/core/shell/allowlist.d.ts +0 -75
- package/dist/core/shell/allowlist.js +0 -187
- package/dist/core/shell/allowlist.js.map +0 -1
- package/dist/core/shell/judge.d.ts +0 -161
- package/dist/core/shell/judge.js +0 -261
- package/dist/core/shell/judge.js.map +0 -1
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
* GS2-56 — the always-on snapshot of the LAST model request, kept on
|
|
30
|
+
* {@link import('#src/core/GthAbstractAgent.js').GthAbstractAgent} independent of any
|
|
31
|
+
* {@link DebugCapture} sink. It is the SAME data the sink reports (the as-sent, post-summarization
|
|
32
|
+
* `request.messages` plus the {@link DebugRequestExtras}), captured unconditionally at each model
|
|
33
|
+
* call so `/debug-dump` can render the full model input even when the TUI `/debug` panel was never
|
|
34
|
+
* opened and on non-TUI surfaces. Reuses {@link DebugRequestExtras} rather than forking a parallel
|
|
35
|
+
* capture shape; `WriteDebugDumpInput.modelRequest` is this same type, so the caller threads
|
|
36
|
+
* `agent.lastModelRequest` straight through with no reshaping.
|
|
37
|
+
*/
|
|
38
|
+
export interface LastModelRequest {
|
|
39
|
+
/** The request extras (system prompt, tool defs with schema, model params, tool-choice). */
|
|
40
|
+
extras?: DebugRequestExtras;
|
|
41
|
+
/** The exact messages sent to the model for the last call (post-summarization / middleware). */
|
|
42
|
+
messages?: BaseMessage[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Debug-capture sink for the TUI's `/debug` panel.
|
|
46
|
+
*
|
|
47
|
+
* A {@link DebugCapture} is an OPT-IN callback the TUI sets on a live agent after `init`
|
|
48
|
+
* (on the shared {@link import('#src/core/GthAbstractAgent.js').GthAbstractAgent} base, so
|
|
49
|
+
* every backend supports it). When present, the agent's `wrapModelCall`
|
|
50
|
+
* middleware reports, per model call:
|
|
51
|
+
*
|
|
52
|
+
* - `request` — `request.messages: BaseMessage[]`, the real history sent to the model at
|
|
53
|
+
* call time (post-summarization / post-middleware), plus the {@link DebugRequestExtras}
|
|
54
|
+
* (tools, system prompt, model params) that also shape the turn. This is exactly what the
|
|
55
|
+
* model saw.
|
|
56
|
+
* - `response` — the resolved `AIMessage` returned by the handler, captured as a whole
|
|
57
|
+
* (resolved message, not per-chunk frames; keeps the streaming core untouched).
|
|
58
|
+
*
|
|
59
|
+
* The sink is read lazily inside the middleware (per call), so when no TUI debug panel is
|
|
60
|
+
* attached the middleware is a transparent pass-through and the normal path pays nothing.
|
|
61
|
+
*/
|
|
62
|
+
export interface DebugCapture {
|
|
63
|
+
/** The full message history sent to the model for this call, plus the request extras. */
|
|
64
|
+
onRequest?(messages: BaseMessage[], extras?: DebugRequestExtras): void;
|
|
65
|
+
/** The resolved model response for this call (an `AIMessage`). */
|
|
66
|
+
onResponse?(response: unknown): void;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Assemble the non-message request parts ({@link DebugRequestExtras}) for the `/debug`
|
|
70
|
+
* panel from a `wrapModelCall` request, defensively and key-free. Never throws (the caller
|
|
71
|
+
* already guards, but a debug sink must never break a run) and never dumps the raw model.
|
|
72
|
+
* Lives in core, beside the capture type itself, so every backend feeds the panel the same shape.
|
|
73
|
+
*/
|
|
74
|
+
export declare function extractDebugRequestExtras(request: unknown): DebugRequestExtras | undefined;
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
* Lives in core, beside the capture type itself, so every backend feeds the panel the same shape.
|
|
76
|
+
*/
|
|
77
|
+
export function extractDebugRequestExtras(request) {
|
|
78
|
+
if (!request || typeof request !== 'object')
|
|
79
|
+
return undefined;
|
|
80
|
+
const req = request;
|
|
81
|
+
const systemMessage = req.systemMessage;
|
|
82
|
+
const systemPrompt = typeof req.systemPrompt === 'string' && req.systemPrompt
|
|
83
|
+
? req.systemPrompt
|
|
84
|
+
: typeof systemMessage?.content === 'string'
|
|
85
|
+
? systemMessage.content
|
|
86
|
+
: undefined;
|
|
87
|
+
const extras = {
|
|
88
|
+
systemPrompt,
|
|
89
|
+
tools: extractToolDefs(req.tools),
|
|
90
|
+
modelParams: extractModelParams(req.model),
|
|
91
|
+
toolChoice: req.toolChoice,
|
|
92
|
+
};
|
|
93
|
+
// Return undefined when nothing useful was captured so the renderer can show a clear empty state.
|
|
94
|
+
const hasAny = extras.systemPrompt !== undefined ||
|
|
95
|
+
extras.tools !== undefined ||
|
|
96
|
+
extras.modelParams !== undefined ||
|
|
97
|
+
extras.toolChoice !== undefined;
|
|
98
|
+
return hasAny ? extras : undefined;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=debugCapture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugCapture.js","sourceRoot":"","sources":["../../src/core/debugCapture.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { GthAgentFactory } from '#src/core/types.js';
|
|
2
2
|
/**
|
|
3
3
|
* The lean backend factory — a {@link GthAgentFactory} that produces a plain
|
|
4
|
-
* {@link GthLangChainAgent}
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* {@link GthLangChainAgent}. This is identical to the built-in default {@link GthAgentRunner}
|
|
5
|
+
* constructs when no factory is passed; exporting it lets `@gaunt-sloth/agent`'s
|
|
6
|
+
* {@link resolveAgentFactory} hand the runner a backend without duplicating the constructor
|
|
7
|
+
* call.
|
|
8
8
|
*/
|
|
9
9
|
export declare const gthLeanAgentFactory: GthAgentFactory;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { GthLangChainAgent } from '#src/core/GthLangChainAgent.js';
|
|
2
2
|
/**
|
|
3
3
|
* The lean backend factory — a {@link GthAgentFactory} that produces a plain
|
|
4
|
-
* {@link GthLangChainAgent}
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* {@link GthLangChainAgent}. This is identical to the built-in default {@link GthAgentRunner}
|
|
5
|
+
* constructs when no factory is passed; exporting it lets `@gaunt-sloth/agent`'s
|
|
6
|
+
* {@link resolveAgentFactory} hand the runner a backend without duplicating the constructor
|
|
7
|
+
* call.
|
|
8
8
|
*/
|
|
9
9
|
export const gthLeanAgentFactory = (statusUpdate, resolvers) => new GthLangChainAgent(statusUpdate, resolvers);
|
|
10
10
|
//# sourceMappingURL=gthLeanAgentFactory.js.map
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { modelProviderLabel } from '#src/core/modelLabel.js';
|
|
2
|
+
/**
|
|
3
|
+
* TUI-C40 — the resting face, under the name the animation layer refers to it by.
|
|
4
|
+
*
|
|
5
|
+
* Every frame below is the same five lines and the same 16-column field, so swapping one in changes
|
|
6
|
+
* nothing about the layout: the right column still starts at {@link RIGHT_COLUMN} and the
|
|
7
|
+
* truncation budgets are untouched. That invariant is what makes an animation a data change rather
|
|
8
|
+
* than a geometry change, and it is asserted per frame in the specs.
|
|
9
|
+
*/
|
|
10
|
+
export declare const RESTING_FACE: readonly [" ▄█▀▀▀▀▀▀▀▀█▄", "▄▀█▄█▀▀▀▀▀▀█▄█▀▄", "█ ▀█▄▀ ▀▄█▀ █", "▀▄▀▀ ██████ ▀▀▄▀", " ▀██████████▀"];
|
|
11
|
+
/** The animations a click can play. This list is the complete set. */
|
|
12
|
+
export declare const SLOTH_ANIMATIONS: readonly ['blink', 'nod', 'look-around', 'eyeroll'];
|
|
13
|
+
export type SlothAnimation = (typeof SLOTH_ANIMATIONS)[number];
|
|
14
|
+
/** One frame of an animation and how long it stays on screen. */
|
|
15
|
+
export interface SlothAnimationStep {
|
|
16
|
+
face: readonly string[];
|
|
17
|
+
holdMs: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The four sequences, as the frames shown AFTER the resting face.
|
|
21
|
+
*
|
|
22
|
+
* Playback always settles back on {@link RESTING_FACE} once the last step's hold elapses, so no
|
|
23
|
+
* sequence lists a trailing rest — but `nod` lists rest in the MIDDLE, because nodding twice means
|
|
24
|
+
* returning to level between the two dips. None of them loops, and a click plays exactly one.
|
|
25
|
+
*/
|
|
26
|
+
export declare const SLOTH_ANIMATION_STEPS: Record<SlothAnimation, readonly SlothAnimationStep[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Pick one animation at random. `random` is injectable so a test can pin the choice — the
|
|
29
|
+
* production call passes nothing and gets `Math.random`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function pickSlothAnimation(random?: () => number): SlothAnimation;
|
|
32
|
+
/**
|
|
33
|
+
* Blank columns prepended to every art row (TUI-C36). One column of left margin, so the block does
|
|
34
|
+
* not sit flush against the edge of the terminal.
|
|
35
|
+
*/
|
|
36
|
+
export declare const LEFT_PAD = 1;
|
|
37
|
+
/**
|
|
38
|
+
* Column at which the right-hand column begins on EVERY row — the single number the whole layout
|
|
39
|
+
* and the colour split are expressed in terms of (margin + face + gutter = 22).
|
|
40
|
+
*/
|
|
41
|
+
export declare const RIGHT_COLUMN: number;
|
|
42
|
+
/** Column at which the version label begins on row 2 (right column + wordmark + gap = 44). */
|
|
43
|
+
export declare const VERSION_COLUMN: number;
|
|
44
|
+
/**
|
|
45
|
+
* Narrowest terminal that still gets the right column. The wordmark itself ends at column 40, so
|
|
46
|
+
* anything narrower than this leaves no usable room for the fields beside it; below the threshold
|
|
47
|
+
* the face prints alone (see the module docs on why wrapping is not an option).
|
|
48
|
+
*/
|
|
49
|
+
export declare const MIN_BANNER_COLUMNS: number;
|
|
50
|
+
/** The live values the banner reports, plus the terminal geometry it has to fit inside. */
|
|
51
|
+
export interface LaunchBannerInput {
|
|
52
|
+
/** Gaunt Sloth version, WITHOUT the `v` prefix (this module adds it). */
|
|
53
|
+
version?: string;
|
|
54
|
+
/** `config.modelDisplayName`. */
|
|
55
|
+
model?: string;
|
|
56
|
+
/** `config.modelProviderType`. */
|
|
57
|
+
provider?: string;
|
|
58
|
+
/** Working directory to report (`getProjectDir()`), before the home-prefix collapse. */
|
|
59
|
+
directory?: string;
|
|
60
|
+
/** The user's home dir; when `directory` sits under it the prefix collapses to `~`. */
|
|
61
|
+
homeDir?: string;
|
|
62
|
+
/** Live `stdout.columns`; `undefined` (non-TTY / tests) falls back to {@link DEFAULT_COLUMNS}. */
|
|
63
|
+
columns?: number;
|
|
64
|
+
/** Emit ANSI colour. Only {@link launchBannerText} reads this; Ink colours rows itself. */
|
|
65
|
+
colour?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* TUI-C40 — which face to draw. Defaults to {@link RESTING_FACE}, so every existing caller is
|
|
68
|
+
* unaffected and a plain launch is byte-identical to before. An animation frame differs only in
|
|
69
|
+
* these five lines: the geometry below reads the face's width from the constants, never from the
|
|
70
|
+
* strings, so a swapped frame cannot move the right column or change a truncation budget.
|
|
71
|
+
*/
|
|
72
|
+
face?: readonly string[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* One rendered banner row, pre-split at {@link RIGHT_COLUMN} so each surface can colour the two
|
|
76
|
+
* halves independently without re-deriving the geometry.
|
|
77
|
+
*/
|
|
78
|
+
export interface LaunchBannerRow {
|
|
79
|
+
/**
|
|
80
|
+
* Columns 0–21: the {@link LEFT_PAD} margin and the face, right-padded to {@link RIGHT_COLUMN}
|
|
81
|
+
* when this row has right-hand content (and left unpadded when it does not, so no row ends in
|
|
82
|
+
* trailing whitespace). Rendered in magenta — the margin is blank, so painting it is a no-op.
|
|
83
|
+
* Empty on the two blank padding rows, which carry nothing at all.
|
|
84
|
+
*/
|
|
85
|
+
face: string;
|
|
86
|
+
/** Columns 21+: wordmark, version, model/provider or directory. Default foreground, no colour. */
|
|
87
|
+
right: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The shared `model (provider)` spelling, re-exported so this module stays the documented home of
|
|
91
|
+
* the banner's fields. It lives in `modelLabel.ts` because the agent renders it too and must not
|
|
92
|
+
* import this module's console/filesystem graph to do so.
|
|
93
|
+
*/
|
|
94
|
+
export { modelProviderLabel };
|
|
95
|
+
/**
|
|
96
|
+
* Assemble the banner as {@link LaunchBannerRow}s: a blank row, the five art rows each pre-split at
|
|
97
|
+
* {@link RIGHT_COLUMN}, and a blank row. Pure — every input arrives as an argument, so the geometry
|
|
98
|
+
* is testable without a terminal, a config or a process.
|
|
99
|
+
*/
|
|
100
|
+
export declare function launchBannerRows(input: LaunchBannerInput): LaunchBannerRow[];
|
|
101
|
+
/**
|
|
102
|
+
* Render the banner as one multi-line string for the plain (readline) surface.
|
|
103
|
+
*
|
|
104
|
+
* Colour is the 16-colour `magenta` slot from {@link ANSI_COLORS} — the SAME slot the rest of the
|
|
105
|
+
* CLI uses — and never a 256-colour or 24-bit escape: the 16-colour slot picks up the violet from
|
|
106
|
+
* the user's own terminal theme, so the sloth looks native in both light and dark schemes. The
|
|
107
|
+
* right column carries no escape at all, not even dim.
|
|
108
|
+
*
|
|
109
|
+
* With `colour: false` the output contains ZERO escape sequences — not one dim wrapper, not one
|
|
110
|
+
* reset — so a monochrome session (`useColour: false`) stays genuinely clean. The caller decides;
|
|
111
|
+
* the plain surface passes `getUseColour()`, the TUI passes nothing and lets Ink's own
|
|
112
|
+
* colour-support detection make the same call.
|
|
113
|
+
*/
|
|
114
|
+
export declare function launchBannerText(input: LaunchBannerInput): string;
|
|
115
|
+
/** The process-resolved half of {@link LaunchBannerInput} — everything but the geometry. */
|
|
116
|
+
export type LaunchBannerFields = Pick<LaunchBannerInput, 'version' | 'model' | 'provider' | 'directory' | 'homeDir'>;
|
|
117
|
+
/**
|
|
118
|
+
* Read the live fields off the process, so both surfaces report the same three values from the same
|
|
119
|
+
* sources instead of each picking its own. `model`/`provider` come from the caller because only it
|
|
120
|
+
* has the resolved config (`config.modelDisplayName` / `config.modelProviderType`); the rest are
|
|
121
|
+
* process-global.
|
|
122
|
+
*
|
|
123
|
+
* Fail-soft, as in `debugDump`: `getSlothVersion()` reads the installed `package.json` through the
|
|
124
|
+
* install dir that the CLI entry point sets, and THROWS when nothing set it (an embedded caller, a
|
|
125
|
+
* unit test). A missing version drops one label — it must never stop a session from starting.
|
|
126
|
+
*/
|
|
127
|
+
export declare function launchBannerFields(model?: string, provider?: string): LaunchBannerFields;
|