@gaunt-sloth/core 2.0.0-alpha.35 → 2.0.0-alpha.36
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/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/loader.d.ts +6 -5
- package/dist/config/loader.js +229 -92
- package/dist/config/loader.js.map +1 -1
- package/dist/config/schema.d.ts +3 -2
- package/dist/config/schema.js +57 -9
- package/dist/config/schema.js.map +1 -1
- package/dist/config/shell-policy.d.ts +58 -26
- package/dist/config/shell-policy.js +60 -27
- package/dist/config/shell-policy.js.map +1 -1
- package/dist/config/tool-descriptions.d.ts +6 -6
- package/dist/config/tool-descriptions.js +7 -7
- package/dist/config/tool-descriptions.js.map +1 -1
- package/dist/config/types.d.ts +34 -31
- package/dist/config/types.js.map +1 -1
- package/dist/config.d.ts +3 -0
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -1
- package/dist/core/GthAbstractAgent.d.ts +11 -13
- package/dist/core/GthAbstractAgent.js +9 -11
- package/dist/core/GthAbstractAgent.js.map +1 -1
- package/dist/core/GthAgentRunner.d.ts +17 -33
- package/dist/core/GthAgentRunner.js +31 -41
- package/dist/core/GthAgentRunner.js.map +1 -1
- package/dist/core/GthLangChainAgent.js +25 -34
- package/dist/core/GthLangChainAgent.js.map +1 -1
- package/dist/core/approvals/toolAnnotationSources.d.ts +4 -4
- package/dist/core/approvals/toolAnnotationSources.js +8 -8
- package/dist/core/debugCapture.d.ts +2 -3
- package/dist/core/debugCapture.js +1 -2
- package/dist/core/debugCapture.js.map +1 -1
- package/dist/core/gthLeanAgentFactory.d.ts +4 -4
- package/dist/core/gthLeanAgentFactory.js +4 -4
- package/dist/core/reasoningBlocks.d.ts +7 -2
- package/dist/core/reasoningBlocks.js +7 -2
- package/dist/core/reasoningBlocks.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/approvalStop.d.ts +68 -29
- package/dist/core/shell/approvalStop.js +178 -28
- package/dist/core/shell/approvalStop.js.map +1 -1
- package/dist/core/shell/hardline.d.ts +22 -0
- package/dist/core/shell/hardline.js +81 -0
- package/dist/core/shell/hardline.js.map +1 -1
- package/dist/core/shell/negotiation.d.ts +81 -2
- package/dist/core/shell/negotiation.js +144 -11
- package/dist/core/shell/negotiation.js.map +1 -1
- package/dist/core/shell/rater.d.ts +7 -69
- package/dist/core/shell/rater.js +5 -24
- package/dist/core/shell/rater.js.map +1 -1
- package/dist/core/shell/raterVocabulary.d.ts +119 -0
- package/dist/core/shell/raterVocabulary.js +114 -0
- package/dist/core/shell/raterVocabulary.js.map +1 -0
- package/dist/core/types.d.ts +17 -3
- 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/geminiThinking.d.ts +8 -0
- package/dist/providers/geminiThinking.js +33 -13
- package/dist/providers/geminiThinking.js.map +1 -1
- package/dist/providers/google-genai.js +11 -0
- 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/ollama.js +12 -0
- package/dist/providers/ollama.js.map +1 -1
- package/dist/providers/openrouter.d.ts +23 -0
- package/dist/providers/openrouter.js +71 -4
- package/dist/providers/openrouter.js.map +1 -1
- package/dist/providers/vertexai.js +12 -0
- 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/conversation.d.ts +2 -2
- package/dist/runtime/conversation.js +19 -4
- package/dist/runtime/conversation.js.map +1 -1
- package/dist/runtime/singleShot.d.ts +2 -3
- package/dist/runtime/singleShot.js +22 -7
- package/dist/runtime/singleShot.js.map +1 -1
- package/dist/utils/systemPromptNotes.d.ts +17 -20
- package/dist/utils/systemPromptNotes.js +22 -24
- package/dist/utils/systemPromptNotes.js.map +1 -1
- package/dist/utils/untrustedText.d.ts +24 -4
- package/dist/utils/untrustedText.js +25 -4
- package/dist/utils/untrustedText.js.map +1 -1
- package/package.json +4 -4
- package/schema/gsloth-config.schema.json +0 -1
package/dist/providers/ollama.js
CHANGED
|
@@ -2,6 +2,7 @@ import { displayWarning } from '#src/utils/consoleUtils.js';
|
|
|
2
2
|
import { env } from '#src/utils/systemUtils.js';
|
|
3
3
|
import { writeConfigFileWithMessages } from '#src/utils/fileUtils.js';
|
|
4
4
|
import { buildInitConfigContent, getCuratedFallbackModel } from '#src/providers/modelDiscovery.js';
|
|
5
|
+
import { NATIVE_CLIENT_REASON, warnUnusedConfiguration, } from '#src/providers/configurationPassthrough.js';
|
|
5
6
|
/**
|
|
6
7
|
* Default Ollama daemon host, matching the Ollama CLI/library default. GS2-59 — `ChatOllama` talks
|
|
7
8
|
* to the daemon's NATIVE endpoint (`/api/chat`), NOT the OpenAI-compatible `/v1` shim this provider
|
|
@@ -68,6 +69,17 @@ export async function processJsonConfig(llmConfig) {
|
|
|
68
69
|
baseUrl: llmConfig.baseUrl ?? resolveBaseUrl(),
|
|
69
70
|
numCtx: llmConfig.numCtx ?? DEFAULT_OLLAMA_NUM_CTX,
|
|
70
71
|
};
|
|
72
|
+
// `ChatOllama` is a native client, so NOTHING in a `configuration` block reaches it — say so
|
|
73
|
+
// before dropping it, rather than letting a stale config behave differently than it reads.
|
|
74
|
+
warnUnusedConfiguration({
|
|
75
|
+
provider: 'ollama',
|
|
76
|
+
configuration: configFields.configuration,
|
|
77
|
+
consumedPaths: [],
|
|
78
|
+
reason: NATIVE_CLIENT_REASON,
|
|
79
|
+
guidance: 'Ollama runs as a local, unauthenticated daemon: point elsewhere with the OLLAMA_HOST ' +
|
|
80
|
+
'environment variable or the "baseUrl" field of the "llm" block, and set "headers" there ' +
|
|
81
|
+
'if a reverse proxy in front of it needs auth.',
|
|
82
|
+
});
|
|
71
83
|
// Strip OpenAI-client / gaunt-sloth-internal keys ChatOllama neither needs nor understands.
|
|
72
84
|
for (const key of ['type', 'apiKeyEnvironmentVariable', 'apiKey', 'configuration']) {
|
|
73
85
|
delete configFields[key];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ollama.js","sourceRoot":"","sources":["../../src/providers/ollama.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAOhD,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"ollama.js","sourceRoot":"","sources":["../../src/providers/ollama.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAOhD,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AACnG,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,4CAA4C,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,wBAAwB,CAAC;AAErD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAErC;;;;;GAKG;AACH,SAAS,cAAc;IACrB,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,CAAC;IAC7B,IAAI,CAAC,IAAI;QAAE,OAAO,mBAAmB,CAAC;IACtC,MAAM,IAAI,GAAG,cAAc,CAA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AAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,2BAA2B,CAAC,cAAc,EAAE,sBAAsB,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAC5F,cAAc,CACZ,yBAAyB,cAAc,2BAA2B;QAChE,2EAA2E;QAC3E,+CAA+C,CAClD,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
import type { BaseChatModel, BaseChatModelParams } from '@langchain/core/language_models/chat_models';
|
|
2
2
|
import type { ChatOpenRouterInput } from '@langchain/openrouter';
|
|
3
|
+
/**
|
|
4
|
+
* Build a native `ChatOpenRouter` (`@langchain/openrouter`). It is NOT a `ChatOpenAI` subclass: it
|
|
5
|
+
* talks to the OpenRouter REST API through the global `fetch` with no SDK client in between, and
|
|
6
|
+
* `_llmType()` reports `openrouter`.
|
|
7
|
+
*
|
|
8
|
+
* OpenRouter's own options are therefore native TOP-LEVEL fields of the `llm` block, forwarded by
|
|
9
|
+
* the `...restConfig` spread below: `provider` (routing preferences), `models` (the fallback list),
|
|
10
|
+
* `route`, `plugins`, `transforms`, `trace`, `minP`, `topA`, `repetitionPenalty`, `seed`,
|
|
11
|
+
* `logitBias`, `topLogprobs`, `sessionId`. Write them beside `model`, not under `configuration`.
|
|
12
|
+
*
|
|
13
|
+
* Migration note — the OpenAI-client knobs a `configuration` block used to carry are gone, because
|
|
14
|
+
* there is no client to give them to. `configuration.baseURL` still works (mapped to the native
|
|
15
|
+
* `baseURL`), and the two attribution headers are still honoured as a fallback for
|
|
16
|
+
* `siteUrl`/`siteName`. What has no injection point at all is transport: `fetch`, `fetchOptions`,
|
|
17
|
+
* `timeout`, `maxRetries`, `defaultQuery`, `dangerouslyAllowBrowser`, and any other
|
|
18
|
+
* `defaultHeaders` entry. That is an upstream surface gap, not something this module can restore —
|
|
19
|
+
* per-provider transport would need a `fetch` option added to `@langchain/openrouter`.
|
|
20
|
+
*
|
|
21
|
+
* The replacement is PROCESS-WIDE rather than per-provider, and it is verified working: run node
|
|
22
|
+
* with `--use-env-proxy` (or set `NODE_USE_ENV_PROXY=1`) together with `HTTP_PROXY`/`HTTPS_PROXY`,
|
|
23
|
+
* and the global `fetch` this model calls routes through the proxy — measured end to end against a
|
|
24
|
+
* local proxy, with a no-proxy control that stayed direct.
|
|
25
|
+
*/
|
|
3
26
|
export declare function processJsonConfig(llmConfig: ChatOpenRouterInput & BaseChatModelParams & Record<string, unknown>): Promise<BaseChatModel>;
|
|
4
27
|
export declare function init(configFileName: string, force?: boolean, model?: string): void;
|
|
@@ -2,7 +2,46 @@ import { displayWarning } from '#src/utils/consoleUtils.js';
|
|
|
2
2
|
import { env } from '#src/utils/systemUtils.js';
|
|
3
3
|
import { writeConfigFileWithMessages } from '#src/utils/fileUtils.js';
|
|
4
4
|
import { buildInitConfigContent, getCuratedFallbackModel } from '#src/providers/modelDiscovery.js';
|
|
5
|
-
|
|
5
|
+
import { NATIVE_CLIENT_REASON, warnConfigurationOverridesTopLevelField, warnUnappliedConfigurationPath, warnUnusedConfiguration, } from '#src/providers/configurationPassthrough.js';
|
|
6
|
+
/**
|
|
7
|
+
* The OpenRouter attribution headers, and the native `ChatOpenRouter` field each one is set from.
|
|
8
|
+
* Declared once because they are read in two places that MUST agree: the `siteUrl`/`siteName`
|
|
9
|
+
* fallback below, and the list of `configuration` paths this factory consumes — if those drift, the
|
|
10
|
+
* orphaned-config warning starts firing on a header that is in fact honoured.
|
|
11
|
+
*/
|
|
12
|
+
const ATTRIBUTION_HEADERS = { siteUrl: 'HTTP-Referer', siteName: 'X-Title' };
|
|
13
|
+
/**
|
|
14
|
+
* The only paths inside a user's `configuration` block that this factory reads. Everything else in
|
|
15
|
+
* it reaches nothing — see the migration note on {@link processJsonConfig}.
|
|
16
|
+
*/
|
|
17
|
+
const CONSUMED_CONFIGURATION_PATHS = [
|
|
18
|
+
'baseURL',
|
|
19
|
+
`defaultHeaders.${ATTRIBUTION_HEADERS.siteUrl}`,
|
|
20
|
+
`defaultHeaders.${ATTRIBUTION_HEADERS.siteName}`,
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* Build a native `ChatOpenRouter` (`@langchain/openrouter`). It is NOT a `ChatOpenAI` subclass: it
|
|
24
|
+
* talks to the OpenRouter REST API through the global `fetch` with no SDK client in between, and
|
|
25
|
+
* `_llmType()` reports `openrouter`.
|
|
26
|
+
*
|
|
27
|
+
* OpenRouter's own options are therefore native TOP-LEVEL fields of the `llm` block, forwarded by
|
|
28
|
+
* the `...restConfig` spread below: `provider` (routing preferences), `models` (the fallback list),
|
|
29
|
+
* `route`, `plugins`, `transforms`, `trace`, `minP`, `topA`, `repetitionPenalty`, `seed`,
|
|
30
|
+
* `logitBias`, `topLogprobs`, `sessionId`. Write them beside `model`, not under `configuration`.
|
|
31
|
+
*
|
|
32
|
+
* Migration note — the OpenAI-client knobs a `configuration` block used to carry are gone, because
|
|
33
|
+
* there is no client to give them to. `configuration.baseURL` still works (mapped to the native
|
|
34
|
+
* `baseURL`), and the two attribution headers are still honoured as a fallback for
|
|
35
|
+
* `siteUrl`/`siteName`. What has no injection point at all is transport: `fetch`, `fetchOptions`,
|
|
36
|
+
* `timeout`, `maxRetries`, `defaultQuery`, `dangerouslyAllowBrowser`, and any other
|
|
37
|
+
* `defaultHeaders` entry. That is an upstream surface gap, not something this module can restore —
|
|
38
|
+
* per-provider transport would need a `fetch` option added to `@langchain/openrouter`.
|
|
39
|
+
*
|
|
40
|
+
* The replacement is PROCESS-WIDE rather than per-provider, and it is verified working: run node
|
|
41
|
+
* with `--use-env-proxy` (or set `NODE_USE_ENV_PROXY=1`) together with `HTTP_PROXY`/`HTTPS_PROXY`,
|
|
42
|
+
* and the global `fetch` this model calls routes through the proxy — measured end to end against a
|
|
43
|
+
* local proxy, with a no-proxy control that stayed direct.
|
|
44
|
+
*/
|
|
6
45
|
// noinspection JSUnusedGlobalSymbols
|
|
7
46
|
export async function processJsonConfig(llmConfig) {
|
|
8
47
|
const { ChatOpenRouter } = await import('@langchain/openrouter');
|
|
@@ -12,15 +51,43 @@ export async function processJsonConfig(llmConfig) {
|
|
|
12
51
|
}
|
|
13
52
|
const { type: _type, apiKeyEnvironmentVariable: _envVar, configuration, siteUrl, siteName, ...restConfig } = llmConfig;
|
|
14
53
|
const configObj = configuration;
|
|
15
|
-
|
|
16
|
-
|
|
54
|
+
// The one place that decides whether the user's `configuration.baseURL` is applied; the warning
|
|
55
|
+
// below reads THIS result instead of re-testing the value, so the guard and what the user is told
|
|
56
|
+
// cannot drift apart.
|
|
57
|
+
const baseURLOverride = configObj?.baseURL ? { baseURL: configObj.baseURL } : {};
|
|
58
|
+
warnUnusedConfiguration({
|
|
59
|
+
provider: 'openrouter',
|
|
60
|
+
configuration,
|
|
61
|
+
consumedPaths: CONSUMED_CONFIGURATION_PATHS,
|
|
62
|
+
reason: NATIVE_CLIENT_REASON,
|
|
63
|
+
// Scope the advice to the options that HAVE a top-level home: told plainly to "put it at the
|
|
64
|
+
// top level", a user with a transport key would move it from a warned location to an unwarned
|
|
65
|
+
// one, which is worse than where they started.
|
|
66
|
+
guidance: 'OpenRouter\'s own options are native top-level fields of the "llm" block — set "provider" ' +
|
|
67
|
+
'(routing preferences), "models", "route", "plugins" or "transforms" beside "model" rather ' +
|
|
68
|
+
'than under "configuration". Transport settings (proxy, custom fetch, timeout, other ' +
|
|
69
|
+
'headers) have no top-level field and no per-provider hook at all: run node with ' +
|
|
70
|
+
'--use-env-proxy (or set NODE_USE_ENV_PROXY=1) plus HTTP_PROXY/HTTPS_PROXY to route this ' +
|
|
71
|
+
'provider through a proxy process-wide.',
|
|
72
|
+
});
|
|
73
|
+
warnUnappliedConfigurationPath('openrouter', configuration, 'baseURL', 'baseURL' in baseURLOverride, 'Give it the full base URL of the OpenRouter-compatible endpoint, or remove it to use the ' +
|
|
74
|
+
'default https://openrouter.ai/api/v1.');
|
|
75
|
+
// `baseURL` is ALSO a native top-level field of `ChatOpenRouter`, forwarded by `...restConfig`
|
|
76
|
+
// below — and the block's value is spread after it, so it wins. Both are honoured surfaces, so
|
|
77
|
+
// the defect is only the silence: say which one takes effect rather than dropping the other
|
|
78
|
+
// without a word.
|
|
79
|
+
warnConfigurationOverridesTopLevelField('openrouter', 'baseURL', restConfig.baseURL, baseURLOverride.baseURL);
|
|
80
|
+
const resolvedSiteUrl = siteUrl ??
|
|
81
|
+
configObj?.defaultHeaders?.[ATTRIBUTION_HEADERS.siteUrl] ??
|
|
82
|
+
'https://gauntsloth.app/';
|
|
83
|
+
const resolvedSiteName = siteName ?? configObj?.defaultHeaders?.[ATTRIBUTION_HEADERS.siteName] ?? 'Gaunt Sloth';
|
|
17
84
|
return new ChatOpenRouter({
|
|
18
85
|
...restConfig,
|
|
19
86
|
apiKey: openRouterApiKey,
|
|
20
87
|
model: llmConfig.model || getCuratedFallbackModel('openrouter'),
|
|
21
88
|
siteUrl: resolvedSiteUrl,
|
|
22
89
|
siteName: resolvedSiteName,
|
|
23
|
-
...
|
|
90
|
+
...baseURLOverride,
|
|
24
91
|
});
|
|
25
92
|
}
|
|
26
93
|
function getApiKey(llmConfig) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openrouter.js","sourceRoot":"","sources":["../../src/providers/openrouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAOhD,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"openrouter.js","sourceRoot":"","sources":["../../src/providers/openrouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAOhD,OAAO,E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CAAC;AACJ,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,cAAsB,EAAE,KAAK,GAAG,KAAK,EAAE,KAAc;IACxE,yDAAyD;IACzD,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,2BAA2B,CAAC,cAAc,EAAE,sBAAsB,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAChG,cAAc,CACZ,yBAAyB,cAAc,uBAAuB;QAC5D,qDAAqD,CACxD,CAAC;AACJ,CAAC"}
|
|
@@ -15,6 +15,7 @@ import { writeConfigFileWithMessages } from '#src/utils/fileUtils.js';
|
|
|
15
15
|
import { buildInitConfigContent, getCuratedFallbackModel } from '#src/providers/modelDiscovery.js';
|
|
16
16
|
import { applyGeminiToolSchemaSanitizer } from '#src/providers/geminiSchemaSanitizer.js';
|
|
17
17
|
import { applyGeminiThoughtSummaries } from '#src/providers/geminiThinking.js';
|
|
18
|
+
import { NATIVE_CLIENT_REASON, warnUnusedConfiguration, } from '#src/providers/configurationPassthrough.js';
|
|
18
19
|
export function init(configFileName, force = false, model) {
|
|
19
20
|
// Determine which content to use based on file extension
|
|
20
21
|
if (!configFileName.endsWith('.json')) {
|
|
@@ -33,6 +34,17 @@ export async function processJsonConfig(llmConfig) {
|
|
|
33
34
|
};
|
|
34
35
|
delete configFields.type;
|
|
35
36
|
delete configFields.apiKeyEnvironmentVariable;
|
|
37
|
+
// `ChatGoogle` is a native client for the Gemini API, so nothing in a `configuration` block
|
|
38
|
+
// reaches it — say so before dropping it.
|
|
39
|
+
warnUnusedConfiguration({
|
|
40
|
+
provider: 'vertexai',
|
|
41
|
+
configuration: llmConfig.configuration,
|
|
42
|
+
consumedPaths: [],
|
|
43
|
+
reason: NATIVE_CLIENT_REASON,
|
|
44
|
+
guidance: 'ChatGoogle talks to Vertex AI through its own client instead: set "customHeaders", ' +
|
|
45
|
+
'"endpoint", "apiVersion" or "location" as top-level fields of the "llm" block beside ' +
|
|
46
|
+
'"model".',
|
|
47
|
+
});
|
|
36
48
|
// GS2-58: normalise every tool's JSON-Schema at the ChatGoogle boundary so Gemini's OpenAPI-3.0
|
|
37
49
|
// subset accepts built-in, custom, and MCP tools alike (see geminiSchemaSanitizer).
|
|
38
50
|
// CFG-33: Vertex serves the same Gemini models through the same ChatGoogle class, so it has the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vertexai.js","sourceRoot":"","sources":["../../src/providers/vertexai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAI5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AACnG,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"vertexai.js","sourceRoot":"","sources":["../../src/providers/vertexai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAI5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AACnG,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,4CAA4C,CAAC;AAEpD,MAAM,UAAU,IAAI,CAAC,cAAsB,EAAE,KAAK,GAAG,KAAK,EAAE,KAAc;IACxE,yDAAyD;IACzD,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,2BAA2B,CAAC,cAAc,EAAE,sBAAsB,CAAC,UAAU,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAC9F,cAAc,CACZ,+GAA+G,CAChH,CAAC;AACJ,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,SAAmF;IAEnF,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC;IAC9D,MAAM,YAAY,GAAG;QACnB,GAAG,SAAS;QACZ,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,uBAAuB,CAAC,UAAU,CAAC;QAC7D,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,OAAO,YAAY,CAAC,IAAI,CAAC;IACzB,OAAO,YAAY,CAAC,yBAAyB,CAAC;IAC9C,4FAA4F;IAC5F,0CAA0C;IAC1C,uBAAuB,CAAC;QACtB,QAAQ,EAAE,UAAU;QACpB,aAAa,EAAG,SAAyC,CAAC,aAAa;QACvE,aAAa,EAAE,EAAE;QACjB,MAAM,EAAE,oBAAoB;QAC5B,QAAQ,EACN,qFAAqF;YACrF,uFAAuF;YACvF,UAAU;KACb,CAAC,CAAC;IACH,gGAAgG;IAChG,oFAAoF;IACpF,gGAAgG;IAChG,yFAAyF;IACzF,OAAO,2BAA2B,CAAC,8BAA8B,CAAC,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AACnG,CAAC"}
|
package/dist/providers/xai.js
CHANGED
|
@@ -2,11 +2,31 @@ import { displayWarning } from '#src/utils/consoleUtils.js';
|
|
|
2
2
|
import { env } from '#src/utils/systemUtils.js';
|
|
3
3
|
import { writeConfigFileWithMessages } from '#src/utils/fileUtils.js';
|
|
4
4
|
import { buildInitConfigContent, getCuratedFallbackModel } from '#src/providers/modelDiscovery.js';
|
|
5
|
+
import { warnUnusedConfiguration } from '#src/providers/configurationPassthrough.js';
|
|
5
6
|
// Function to process JSON config and create XAI LLM instance
|
|
6
7
|
export async function processJsonConfig(llmConfig) {
|
|
7
8
|
const { ChatXAI } = await import('@langchain/xai');
|
|
8
9
|
// Use config value if available, otherwise use the environment variable
|
|
9
10
|
const apiKey = llmConfig.apiKey || env.XAI_API_KEY;
|
|
11
|
+
// `ChatXAI` DOES build an OpenAI client, and still consumes none of the user's block: its
|
|
12
|
+
// constructor passes `configuration: { baseURL: fields.baseURL ?? <xAI default> }` to `super`,
|
|
13
|
+
// replacing whatever was set here. So the reason clause is xai's own — the shared native-client
|
|
14
|
+
// sentence would be a false explanation — and the replacements are the top-level fields that were
|
|
15
|
+
// measured to reach the client: `baseURL` (a declared `ChatXAIInput` field) and `timeout` (read
|
|
16
|
+
// by the OpenAI base class from the same spread). Headers reach it by no route at all.
|
|
17
|
+
warnUnusedConfiguration({
|
|
18
|
+
provider: 'xai',
|
|
19
|
+
configuration: llmConfig.configuration,
|
|
20
|
+
consumedPaths: [],
|
|
21
|
+
reason: 'builds its OpenAI client with a "configuration" block of its own, replacing anything set here',
|
|
22
|
+
// The escape hatch is only followable with the key hint: the "openai" provider reads
|
|
23
|
+
// OPENAI_API_KEY, so a user who moves to it for the headers alone hits a missing-key error.
|
|
24
|
+
guidance: 'Set "baseURL" or "timeout" as top-level fields of the "llm" block instead, beside "model". ' +
|
|
25
|
+
'Extra headers have no home on this provider at all — to send them, use the "openai" ' +
|
|
26
|
+
'provider with "configuration.baseURL" pointed at the xAI endpoint, and set ' +
|
|
27
|
+
'"apiKeyEnvironmentVariable" to XAI_API_KEY there, since that provider otherwise reads ' +
|
|
28
|
+
'OPENAI_API_KEY.',
|
|
29
|
+
});
|
|
10
30
|
return new ChatXAI({
|
|
11
31
|
...llmConfig,
|
|
12
32
|
apiKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xai.js","sourceRoot":"","sources":["../../src/providers/xai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAOhD,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"xai.js","sourceRoot":"","sources":["../../src/providers/xai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAOhD,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AACnG,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAErF,8DAA8D;AAC9D,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,SAA6C;IAE7C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACnD,wEAAwE;IACxE,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,WAAW,CAAC;IACnD,0FAA0F;IAC1F,+FAA+F;IAC/F,gGAAgG;IAChG,kGAAkG;IAClG,gGAAgG;IAChG,uFAAuF;IACvF,uBAAuB,CAAC;QACtB,QAAQ,EAAE,KAAK;QACf,aAAa,EAAG,SAAyC,CAAC,aAAa;QACvE,aAAa,EAAE,EAAE;QACjB,MAAM,EACJ,+FAA+F;QACjG,qFAAqF;QACrF,4FAA4F;QAC5F,QAAQ,EACN,6FAA6F;YAC7F,sFAAsF;YACtF,6EAA6E;YAC7E,wFAAwF;YACxF,iBAAiB;KACpB,CAAC,CAAC;IACH,OAAO,IAAI,OAAO,CAAC;QACjB,GAAG,SAAS;QACZ,MAAM;QACN,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,uBAAuB,CAAC,KAAK,CAAC;KACzD,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,cAAsB,EAAE,KAAK,GAAG,KAAK,EAAE,KAAc;IACxE,yDAAyD;IACzD,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,2BAA2B,CAAC,cAAc,EAAE,sBAAsB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IACzF,cAAc,CACZ,2BAA2B,cAAc,4BAA4B;QACnE,6CAA6C,CAChD,CAAC;AACJ,CAAC"}
|
|
@@ -53,8 +53,8 @@ export interface ConversationTurnResult extends GthRunStats {
|
|
|
53
53
|
* @param config - The resolved config.
|
|
54
54
|
* @param resolvers - Optional agent resolvers (tools/middleware); the caller owns their cleanup.
|
|
55
55
|
* @param command - The originating command (defaults to `ask`); selects the agent mode prompt.
|
|
56
|
-
* @param agentFactory - Optional backend factory (B5); omitted = the runner's lean default,
|
|
57
|
-
*
|
|
56
|
+
* @param agentFactory - Optional backend factory (B5); omitted = the runner's lean default, which
|
|
57
|
+
* is also what the shared backend seam resolves to.
|
|
58
58
|
* @returns One {@link ConversationTurnResult} per turn attempted, in turn order.
|
|
59
59
|
*/
|
|
60
60
|
export declare function runConversation(source: string, _preamble: string, userMessages: string[], config: GthConfig, resolvers?: AgentResolvers, command?: GthCommand, agentFactory?: GthAgentFactory): Promise<ConversationTurnResult[]>;
|
|
@@ -5,7 +5,8 @@ import { MemorySaver } from '@langchain/langgraph';
|
|
|
5
5
|
import { AIMessage, HumanMessage } from '@langchain/core/messages';
|
|
6
6
|
import { ProgressIndicator } from '#src/utils/ProgressIndicator.js';
|
|
7
7
|
import { recordSessionSafe } from '#src/history/recordSession.js';
|
|
8
|
-
import { getProjectDir } from '#src/utils/systemUtils.js';
|
|
8
|
+
import { getProjectDir, stdout } from '#src/utils/systemUtils.js';
|
|
9
|
+
import { ApprovalStopError, approvalStopRows } from '#src/core/shell/approvalStop.js';
|
|
9
10
|
/**
|
|
10
11
|
* Run a scripted MULTI-TURN conversation and return one {@link ConversationTurnResult} per turn.
|
|
11
12
|
*
|
|
@@ -43,8 +44,8 @@ import { getProjectDir } from '#src/utils/systemUtils.js';
|
|
|
43
44
|
* @param config - The resolved config.
|
|
44
45
|
* @param resolvers - Optional agent resolvers (tools/middleware); the caller owns their cleanup.
|
|
45
46
|
* @param command - The originating command (defaults to `ask`); selects the agent mode prompt.
|
|
46
|
-
* @param agentFactory - Optional backend factory (B5); omitted = the runner's lean default,
|
|
47
|
-
*
|
|
47
|
+
* @param agentFactory - Optional backend factory (B5); omitted = the runner's lean default, which
|
|
48
|
+
* is also what the shared backend seam resolves to.
|
|
48
49
|
* @returns One {@link ConversationTurnResult} per turn attempted, in turn order.
|
|
49
50
|
*/
|
|
50
51
|
export async function runConversation(source, _preamble, userMessages, config, resolvers, command = 'ask', agentFactory) {
|
|
@@ -86,7 +87,21 @@ export async function runConversation(source, _preamble, userMessages, config, r
|
|
|
86
87
|
catch (err) {
|
|
87
88
|
ok = false;
|
|
88
89
|
error = err instanceof Error ? err.message : String(err);
|
|
89
|
-
|
|
90
|
+
// [[TUI-C71]] — the SAME branch `runSingleShot` carries, and for a sharper reason: this
|
|
91
|
+
// surface wires no tool-approval callback either, so every escalation it meets is a
|
|
92
|
+
// §6.2 `NonInteractiveEscalationError` — the error class that carries the command, the
|
|
93
|
+
// rating, the rater's reason AND the whole negotiation transcript. The hostile path is
|
|
94
|
+
// not an edge case here, it is the only path. `error` above keeps the neutralised
|
|
95
|
+
// message for the turn record, which is a data consumer and wants the string.
|
|
96
|
+
if (err instanceof ApprovalStopError) {
|
|
97
|
+
displayError('Failed to get answer:');
|
|
98
|
+
for (const row of approvalStopRows(err.parts, { columns: stdout.columns })) {
|
|
99
|
+
displayError(row);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
displayError(`Failed to get answer: ${error}`);
|
|
104
|
+
}
|
|
90
105
|
}
|
|
91
106
|
// GS2-16: read this turn's token/tool delta from the live agent (before cleanup). Fail-soft
|
|
92
107
|
// — analytics must never affect the run. `processMessages` reset the tally at its top, so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../src/runtime/conversation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,YAAY,EACZ,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../src/runtime/conversation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,YAAY,EACZ,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC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AC;gBACrB,cAAc,CAAC,mCAAmC,QAAQ,EAAE,CAAC,CAAC;YAChE,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,YAAY,CAAC,mCAAmC,QAAQ,EAAE,CAAC,CAAC;gBAC5D,YAAY,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;YAAS,CAAC;QACT,+FAA+F;QAC/F,2FAA2F;QAC3F,2FAA2F;QAC3F,+FAA+F;QAC/F,+FAA+F;QAC/F,uEAAuE;QACvE,iBAAiB,EAAE,IAAI,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC"}
|
|
@@ -28,9 +28,8 @@ export interface SingleShotResult extends GthRunStats {
|
|
|
28
28
|
* @param resolvers - Optional agent resolvers (tools/middleware)
|
|
29
29
|
* @param command - The originating command (defaults to `ask`); selects the agent mode prompt
|
|
30
30
|
* @param agentFactory - Optional backend factory (B5). When omitted the runner uses its built-in
|
|
31
|
-
* lean {@link GthLangChainAgent} default
|
|
32
|
-
*
|
|
33
|
-
* `resolveAgentFactory(config, 'lean')` so an explicit `agent.backend` is honored.
|
|
31
|
+
* lean {@link GthLangChainAgent} default. The app layer passes `resolveAgentFactory(config,
|
|
32
|
+
* 'lean')`, which resolves to the same agent through the shared backend seam.
|
|
34
33
|
* @returns A {@link SingleShotResult}: `ok` is `true` when the run completed without error, `false`
|
|
35
34
|
* when it failed (so callers such as `exec` can set a non-zero exit code); `answer`/`tokensInput`/
|
|
36
35
|
* `tokensOutput`/`tools` carry the SUT's answer text and run stats for callers that need them
|
|
@@ -5,7 +5,8 @@ import { MemorySaver } from '@langchain/langgraph';
|
|
|
5
5
|
import { HumanMessage } from '@langchain/core/messages';
|
|
6
6
|
import { ProgressIndicator } from '#src/utils/ProgressIndicator.js';
|
|
7
7
|
import { recordSessionSafe } from '#src/history/recordSession.js';
|
|
8
|
-
import { getProjectDir } from '#src/utils/systemUtils.js';
|
|
8
|
+
import { getProjectDir, stdout } from '#src/utils/systemUtils.js';
|
|
9
|
+
import { ApprovalStopError, approvalStopRows } from '#src/core/shell/approvalStop.js';
|
|
9
10
|
/**
|
|
10
11
|
* Ask a question and get an answer from the LLM.
|
|
11
12
|
*
|
|
@@ -21,9 +22,8 @@ import { getProjectDir } from '#src/utils/systemUtils.js';
|
|
|
21
22
|
* @param resolvers - Optional agent resolvers (tools/middleware)
|
|
22
23
|
* @param command - The originating command (defaults to `ask`); selects the agent mode prompt
|
|
23
24
|
* @param agentFactory - Optional backend factory (B5). When omitted the runner uses its built-in
|
|
24
|
-
* lean {@link GthLangChainAgent} default
|
|
25
|
-
*
|
|
26
|
-
* `resolveAgentFactory(config, 'lean')` so an explicit `agent.backend` is honored.
|
|
25
|
+
* lean {@link GthLangChainAgent} default. The app layer passes `resolveAgentFactory(config,
|
|
26
|
+
* 'lean')`, which resolves to the same agent through the shared backend seam.
|
|
27
27
|
* @returns A {@link SingleShotResult}: `ok` is `true` when the run completed without error, `false`
|
|
28
28
|
* when it failed (so callers such as `exec` can set a non-zero exit code); `answer`/`tokensInput`/
|
|
29
29
|
* `tokensOutput`/`tools` carry the SUT's answer text and run stats for callers that need them
|
|
@@ -31,8 +31,8 @@ import { getProjectDir } from '#src/utils/systemUtils.js';
|
|
|
31
31
|
*/
|
|
32
32
|
export async function runSingleShot(source,
|
|
33
33
|
// BATCH-13: `_preamble` is retained for signature stability but is NO LONGER injected as a
|
|
34
|
-
// SystemMessage. The agent
|
|
35
|
-
//
|
|
34
|
+
// SystemMessage. The agent (lean `GthLangChainAgent`, since GS2-21) COMPOSES the full system
|
|
35
|
+
// prompt itself from the config — backstory + guidelines +
|
|
36
36
|
// per-command mode prompt + system prompt, PLUS the model-identity (GS2-34) and MCP-instructions
|
|
37
37
|
// (EXT-32) notes — and hand it to `createAgent` as `systemPrompt`. Also passing this preamble as a
|
|
38
38
|
// leading SystemMessage produced TWO system messages, which `@langchain/anthropic` rejects
|
|
@@ -60,7 +60,22 @@ _preamble, content, config, resolvers, command = 'ask', agentFactory) {
|
|
|
60
60
|
}
|
|
61
61
|
catch (err) {
|
|
62
62
|
succeeded = false;
|
|
63
|
-
|
|
63
|
+
// [[TUI-C71]] — §6.2's escalation and §4.2's halt reach a person HERE and nowhere else on
|
|
64
|
+
// this path: there is no prompt to attach anything to, so this message is the whole
|
|
65
|
+
// explanation and it is built almost entirely out of model-authored text. Its untrusted
|
|
66
|
+
// halves go through the [[TUI-C26]] gutter, one row per line, so a payload crafted to forge
|
|
67
|
+
// terminal chrome cannot reach column 0 even on a line the terminal would have wrapped. The
|
|
68
|
+
// rows are printed on the same channel as the wrapper so a redirected stderr still carries
|
|
69
|
+
// the whole thing.
|
|
70
|
+
if (err instanceof ApprovalStopError) {
|
|
71
|
+
displayError('Failed to get answer:');
|
|
72
|
+
for (const row of approvalStopRows(err.parts, { columns: stdout.columns })) {
|
|
73
|
+
displayError(row);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
displayError(`Failed to get answer: ${err instanceof Error ? err.message : String(err)}`);
|
|
78
|
+
}
|
|
64
79
|
}
|
|
65
80
|
finally {
|
|
66
81
|
await runner.cleanup();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleShot.js","sourceRoot":"","sources":["../../src/runtime/singleShot.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,YAAY,EACZ,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,E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,cAAc,CAAC,mCAAmC,QAAQ,EAAE,CAAC,CAAC;YAChE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,YAAY,CAAC,mCAAmC,QAAQ,EAAE,CAAC,CAAC;gBAC5D,YAAY,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;QAED,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC9D,CAAC;YAAS,CAAC;QACT,+FAA+F;QAC/F,2FAA2F;QAC3F,2FAA2F;QAC3F,+FAA+F;QAC/F,wFAAwF;QACxF,uEAAuE;QACvE,iBAAiB,EAAE,IAAI,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC"}
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared code-mode system-prompt augmentations (GS2-27).
|
|
3
3
|
*
|
|
4
|
-
* These notes describe capabilities
|
|
5
|
-
*
|
|
6
|
-
* the
|
|
7
|
-
*
|
|
8
|
-
* composed ONLY inside `GthDeepAgent.init()` (EXT-13/EXT-26), so the now-default lean backend never
|
|
9
|
-
* received them — accidental deep-only drift of the same class GS2-21 fixed for the main prompt.
|
|
10
|
-
*
|
|
11
|
-
* They live here in core so BOTH backends compose from ONE source. `GthDeepAgent` re-exports them
|
|
12
|
-
* for back-compat with existing importers. The deepagents virtual-fs-namespace notes
|
|
13
|
-
* (`appendVirtualCwdNote` / `PATH_NAMESPACE_GUIDANCE` / the correction middleware) are NOT here:
|
|
14
|
-
* they are genuinely deep-only (a deepagents artifact — lean never runs virtualMode) and stay in
|
|
15
|
-
* `GthDeepAgent`.
|
|
4
|
+
* These notes describe capabilities of the agent itself — the opt-in `run_shell_command` tool and
|
|
5
|
+
* the real filesystem cwd — rather than of any one graph builder, which is why they live in core
|
|
6
|
+
* rather than beside the agent that composes them: a note composed inside one backend is a note
|
|
7
|
+
* the next backend silently loses, the drift GS2-21 fixed for the main prompt.
|
|
16
8
|
*/
|
|
17
9
|
import type { McpServerInstruction } from '#src/core/types.js';
|
|
18
10
|
import { type FilesystemToolsConfig } from '#src/config/filesystem-tools.js';
|
|
@@ -120,9 +112,9 @@ export interface CommitCoAuthor {
|
|
|
120
112
|
* that string; the identity decorates only the default. An unresolvable identity (`undefined`) falls
|
|
121
113
|
* back to the plain default name, never to a placeholder.
|
|
122
114
|
*
|
|
123
|
-
* Backend-agnostic: composed through the shared code path so
|
|
124
|
-
*
|
|
125
|
-
*
|
|
115
|
+
* Backend-agnostic: composed through the shared code path, so any backend injects it (the
|
|
116
|
+
* git-commit capability rides on `run_shell_command`, exposed in code mode). Returns the note alone
|
|
117
|
+
* when there is no base prompt.
|
|
126
118
|
*/
|
|
127
119
|
export declare function appendCommitCoAuthorNote(systemPrompt: string | undefined, coAuthor?: CommitCoAuthor, modelIdentity?: ResolvedModelIdentity, filesystem?: FilesystemToolsConfig): string;
|
|
128
120
|
/**
|
|
@@ -150,9 +142,14 @@ export interface ResolvedModelIdentity {
|
|
|
150
142
|
* - PROVIDER: the configured `config.modelProviderType` (the raw `llm.type` the loader stashed —
|
|
151
143
|
* `openrouter`/`deepseek`/`xai`/`anthropic`/…) when present, otherwise the live LangChain
|
|
152
144
|
* model's `_llmType()` (the source the AG-UI `/info` endpoint reports). GS2-53 — preferring the
|
|
153
|
-
* configured `type`
|
|
154
|
-
*
|
|
155
|
-
*
|
|
145
|
+
* configured `type` is what stops a provider being labelled with the client it happens to be
|
|
146
|
+
* built on: `_llmType()` is the model CLASS's own label and does not track the gth provider
|
|
147
|
+
* namespace, so `huggingface` (a `ChatOpenAI` aimed at the HF router) reports `openai`, and
|
|
148
|
+
* `google-genai` and `vertexai` both report `google`. It is also the safer source in general:
|
|
149
|
+
* `_llmType()` is the model class's opinion, while the `type` is
|
|
150
|
+
* the user's own declaration, so a provider swapped onto a different client (as `openrouter`
|
|
151
|
+
* was) keeps its configured label without this file needing to know. The `type` is absent for
|
|
152
|
+
* module configs (which
|
|
156
153
|
* hand us an already-built LLM), where we fall back to `_llmType()` unchanged. The MODEL half is
|
|
157
154
|
* always exact.
|
|
158
155
|
*
|
|
@@ -216,8 +213,8 @@ export declare const MCP_INSTRUCTIONS_TRUNCATION_MARKER = "\u2026 [truncated]";
|
|
|
216
213
|
* the model reads is gsloth's own authority, not the server text — server instructions may not
|
|
217
214
|
* override the system instructions, safety rules, or the user's directives.
|
|
218
215
|
*
|
|
219
|
-
* Backend-agnostic: composed through the shared path so
|
|
220
|
-
*
|
|
216
|
+
* Backend-agnostic: composed through the shared path, so any backend injects it.
|
|
217
|
+
* Empty/absent contributes NOTHING: when no server supplied
|
|
221
218
|
* (non-whitespace) instructions the base prompt is returned unchanged — no empty header, no dangling
|
|
222
219
|
* label. Each server's text is trimmed and capped at {@link MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER}.
|
|
223
220
|
* Returns the block alone when there is no base prompt.
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared code-mode system-prompt augmentations (GS2-27).
|
|
3
3
|
*
|
|
4
|
-
* These notes describe capabilities
|
|
5
|
-
*
|
|
6
|
-
* the
|
|
7
|
-
*
|
|
8
|
-
* composed ONLY inside `GthDeepAgent.init()` (EXT-13/EXT-26), so the now-default lean backend never
|
|
9
|
-
* received them — accidental deep-only drift of the same class GS2-21 fixed for the main prompt.
|
|
10
|
-
*
|
|
11
|
-
* They live here in core so BOTH backends compose from ONE source. `GthDeepAgent` re-exports them
|
|
12
|
-
* for back-compat with existing importers. The deepagents virtual-fs-namespace notes
|
|
13
|
-
* (`appendVirtualCwdNote` / `PATH_NAMESPACE_GUIDANCE` / the correction middleware) are NOT here:
|
|
14
|
-
* they are genuinely deep-only (a deepagents artifact — lean never runs virtualMode) and stay in
|
|
15
|
-
* `GthDeepAgent`.
|
|
4
|
+
* These notes describe capabilities of the agent itself — the opt-in `run_shell_command` tool and
|
|
5
|
+
* the real filesystem cwd — rather than of any one graph builder, which is why they live in core
|
|
6
|
+
* rather than beside the agent that composes them: a note composed inside one backend is a note
|
|
7
|
+
* the next backend silently loses, the drift GS2-21 fixed for the main prompt.
|
|
16
8
|
*/
|
|
17
9
|
import { DEFAULT_COMMIT_CO_AUTHOR_EMAIL, DEFAULT_COMMIT_CO_AUTHOR_NAME } from '#src/constants.js';
|
|
18
10
|
import { isWriteFileToolRegistered, WRITE_FILE_TOOL_NAME, } from '#src/config/filesystem-tools.js';
|
|
@@ -144,9 +136,9 @@ export function appendCwdNote(systemPrompt, cwd) {
|
|
|
144
136
|
* that string; the identity decorates only the default. An unresolvable identity (`undefined`) falls
|
|
145
137
|
* back to the plain default name, never to a placeholder.
|
|
146
138
|
*
|
|
147
|
-
* Backend-agnostic: composed through the shared code path so
|
|
148
|
-
*
|
|
149
|
-
*
|
|
139
|
+
* Backend-agnostic: composed through the shared code path, so any backend injects it (the
|
|
140
|
+
* git-commit capability rides on `run_shell_command`, exposed in code mode). Returns the note alone
|
|
141
|
+
* when there is no base prompt.
|
|
150
142
|
*/
|
|
151
143
|
export function appendCommitCoAuthorNote(systemPrompt, coAuthor, modelIdentity, filesystem) {
|
|
152
144
|
// EXT-83 — ONE place composes the name, so the parenthesised shape stays a one-line change. The
|
|
@@ -199,9 +191,14 @@ export function appendCommitCoAuthorNote(systemPrompt, coAuthor, modelIdentity,
|
|
|
199
191
|
* - PROVIDER: the configured `config.modelProviderType` (the raw `llm.type` the loader stashed —
|
|
200
192
|
* `openrouter`/`deepseek`/`xai`/`anthropic`/…) when present, otherwise the live LangChain
|
|
201
193
|
* model's `_llmType()` (the source the AG-UI `/info` endpoint reports). GS2-53 — preferring the
|
|
202
|
-
* configured `type`
|
|
203
|
-
*
|
|
204
|
-
*
|
|
194
|
+
* configured `type` is what stops a provider being labelled with the client it happens to be
|
|
195
|
+
* built on: `_llmType()` is the model CLASS's own label and does not track the gth provider
|
|
196
|
+
* namespace, so `huggingface` (a `ChatOpenAI` aimed at the HF router) reports `openai`, and
|
|
197
|
+
* `google-genai` and `vertexai` both report `google`. It is also the safer source in general:
|
|
198
|
+
* `_llmType()` is the model class's opinion, while the `type` is
|
|
199
|
+
* the user's own declaration, so a provider swapped onto a different client (as `openrouter`
|
|
200
|
+
* was) keeps its configured label without this file needing to know. The `type` is absent for
|
|
201
|
+
* module configs (which
|
|
205
202
|
* hand us an already-built LLM), where we fall back to `_llmType()` unchanged. The MODEL half is
|
|
206
203
|
* always exact.
|
|
207
204
|
*
|
|
@@ -216,10 +213,11 @@ export function appendCommitCoAuthorNote(systemPrompt, coAuthor, modelIdentity,
|
|
|
216
213
|
*/
|
|
217
214
|
export function resolveModelIdentity(config) {
|
|
218
215
|
const llm = config?.llm;
|
|
219
|
-
// Prefer the configured provider `type` over the live model's `_llmType()`:
|
|
220
|
-
//
|
|
221
|
-
// would mislabel the provider half. Only fall
|
|
222
|
-
// (non-blank) `type` was threaded (e.g. module
|
|
216
|
+
// Prefer the configured provider `type` over the live model's `_llmType()`: that is the model
|
|
217
|
+
// class's own label rather than the gth provider namespace (`huggingface` reports `openai`, and
|
|
218
|
+
// both Gemini providers report `google`), so it would mislabel the provider half. Only fall
|
|
219
|
+
// through to the guarded `_llmType()` when no (non-blank) `type` was threaded (e.g. module
|
|
220
|
+
// configs that build the LLM themselves).
|
|
223
221
|
let provider = config?.modelProviderType?.trim() || undefined;
|
|
224
222
|
if (!provider) {
|
|
225
223
|
try {
|
|
@@ -304,8 +302,8 @@ function capMcpText(text) {
|
|
|
304
302
|
* the model reads is gsloth's own authority, not the server text — server instructions may not
|
|
305
303
|
* override the system instructions, safety rules, or the user's directives.
|
|
306
304
|
*
|
|
307
|
-
* Backend-agnostic: composed through the shared path so
|
|
308
|
-
*
|
|
305
|
+
* Backend-agnostic: composed through the shared path, so any backend injects it.
|
|
306
|
+
* Empty/absent contributes NOTHING: when no server supplied
|
|
309
307
|
* (non-whitespace) instructions the base prompt is returned unchanged — no empty header, no dangling
|
|
310
308
|
* label. Each server's text is trimmed and capped at {@link MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER}.
|
|
311
309
|
* Returns the block alone when there is no base prompt.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemPromptNotes.js","sourceRoot":"","sources":["../../src/utils/systemPromptNotes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"systemPromptNotes.js","sourceRoot":"","sources":["../../src/utils/systemPromptNotes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,8BAA8B,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClG,OAAO,EACL,yBAAyB,EACzB,oBAAoB,GAErB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,aAAa,GACd,MAAM,6BAA6B,CAAC;AAErC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAC5B,4FAA4F;IAC5F,wFAAwF;IACxF,2DAA2D,CAAC;AAE9D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,iBAAiB,CAAC,YAAgC;IAChE,IAAI,IAAY,CAAC;IACjB,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,IAAI;YACF,sFAAsF;gBACtF,qFAAqF;gBACrF,uFAAuF;gBACvF,4FAA4F;gBAC5F,6BAA6B,iBAAiB,EAAE,CAAC;IACrD,CAAC;SAAM,CAAC;QACN,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;QACjE,IAAI;YACF,0BAA0B,MAAM,yDAAyD;gBACzF,qFAAqF;gBACrF,+CAA+C,iBAAiB,EAAE,CAAC;IACvE,CAAC;IACD,OAAO,YAAY,CAAC,C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