@gaunt-sloth/core 2.0.0-alpha.4 → 2.0.0-alpha.40
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/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 +21 -21
- package/dist/config/defaults.js +11 -9
- 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/jsonc.d.ts +12 -0
- package/dist/config/jsonc.js +41 -0
- package/dist/config/jsonc.js.map +1 -0
- package/dist/config/loader.d.ts +165 -6
- package/dist/config/loader.js +963 -109
- 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 +2695 -130
- package/dist/config/schema.js +1385 -68
- 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 +372 -34
- 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 +45 -0
- package/dist/constants.js +45 -0
- package/dist/constants.js.map +1 -1
- package/dist/core/GthAbstractAgent.d.ts +190 -11
- package/dist/core/GthAbstractAgent.js +551 -35
- package/dist/core/GthAbstractAgent.js.map +1 -1
- package/dist/core/GthAgentRunner.d.ts +565 -57
- package/dist/core/GthAgentRunner.js +1546 -140
- package/dist/core/GthAgentRunner.js.map +1 -1
- package/dist/core/GthLangChainAgent.d.ts +117 -2
- package/dist/core/GthLangChainAgent.js +644 -18
- 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 +9 -0
- package/dist/core/gthLeanAgentFactory.js +10 -0
- package/dist/core/gthLeanAgentFactory.js.map +1 -0
- 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 +52 -0
- package/dist/core/runStats.js +118 -0
- package/dist/core/runStats.js.map +1 -0
- package/dist/core/shell/ShellCommandFailedError.d.ts +53 -0
- package/dist/core/shell/ShellCommandFailedError.js +67 -0
- package/dist/core/shell/ShellCommandFailedError.js.map +1 -0
- 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 +378 -16
- package/dist/core/types.js.map +1 -1
- package/dist/history/historyFormat.d.ts +28 -0
- package/dist/history/historyFormat.js +127 -0
- package/dist/history/historyFormat.js.map +1 -0
- package/dist/history/historyStore.d.ts +198 -0
- package/dist/history/historyStore.js +482 -0
- package/dist/history/historyStore.js.map +1 -0
- package/dist/history/recordSession.d.ts +37 -0
- package/dist/history/recordSession.js +56 -0
- package/dist/history/recordSession.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.js +17 -10
- 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/deepseek.d.ts +1 -1
- package/dist/providers/deepseek.js +5 -10
- package/dist/providers/deepseek.js.map +1 -1
- 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.d.ts +1 -1
- package/dist/providers/google-genai.js +23 -11
- package/dist/providers/google-genai.js.map +1 -1
- package/dist/providers/groq.d.ts +1 -1
- package/dist/providers/groq.js +17 -10
- 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 +153 -6
- package/dist/providers/modelDiscovery.js +295 -41
- package/dist/providers/modelDiscovery.js.map +1 -1
- package/dist/providers/ollama.d.ts +19 -5
- package/dist/providers/ollama.js +72 -52
- package/dist/providers/ollama.js.map +1 -1
- package/dist/providers/openai.d.ts +1 -1
- package/dist/providers/openai.js +39 -10
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/openrouter.d.ts +27 -5
- package/dist/providers/openrouter.js +88 -36
- package/dist/providers/openrouter.js.map +1 -1
- package/dist/providers/vertexai.d.ts +1 -1
- package/dist/providers/vertexai.js +24 -11
- package/dist/providers/vertexai.js.map +1 -1
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/xai.js +25 -10
- 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 +39 -5
- package/dist/runtime/singleShot.js +115 -36
- 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.d.ts +20 -1
- package/dist/utils/fileUtils.js +35 -2
- package/dist/utils/fileUtils.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 -6
- package/schema/gsloth-config.schema.json +1979 -353
- 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 @@
|
|
|
1
|
+
{"version":3,"file":"historyStore.js","sourceRoot":"","sources":["../../src/history/historyStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,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Y,EAAE,CAAC,CAAC,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS;QAC3E,OAAO,EAAE,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;QAC5D,KAAK;QACL,UAAU,EAAE,CAAC,CAAC,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;KACtE,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAe,EAAE,SAAS,GAAG,KAAK;IACrE,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC;IACtD,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACvE,OAAO,OAAO,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAc,EACd,OAAO,GAA4B,EAAE;IAErC,OAAO,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* GS2-7 (B20) — the opt-in bridge from a finished run to the {@link HistoryStore}.
|
|
4
|
+
*
|
|
5
|
+
* {@link recordSessionSafe} is the ONE entry point the run path calls. It is a no-op unless
|
|
6
|
+
* `history.enabled` is true, and it swallows every error, so:
|
|
7
|
+
* - a **default run** (history absent/false) opens nothing, writes nothing, and behaves exactly
|
|
8
|
+
* as before — the stateless identity is preserved; and
|
|
9
|
+
* - even with history **on**, a DB problem (locked/corrupt/read-only fs) can never abort or alter
|
|
10
|
+
* the run: the worst case is that one session isn't recorded.
|
|
11
|
+
*/
|
|
12
|
+
import type { ConversationMeta, SessionRecord } from '#src/history/historyStore.js';
|
|
13
|
+
/** The subset of the resolved config the recorder reads (structural, to avoid a hard type dep). */
|
|
14
|
+
export interface HistoryConfigView {
|
|
15
|
+
history?: {
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
dbPath?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Record one finished session IFF `history.enabled` is true. Returns the new row id, or `null`
|
|
22
|
+
* when history is disabled or anything went wrong (both are non-events for the caller).
|
|
23
|
+
*
|
|
24
|
+
* Deliberately fully guarded: opening the store, ensuring the global dir, and the insert all run
|
|
25
|
+
* behind a single try/catch, and the store itself is fail-soft. Callers put this in a `finally`
|
|
26
|
+
* (or after a run) without a try/catch of their own.
|
|
27
|
+
*/
|
|
28
|
+
export declare function recordSessionSafe(config: HistoryConfigView, record: SessionRecord): number | null;
|
|
29
|
+
/**
|
|
30
|
+
* GS2-19 — open one conversation for an interactive session IFF `history.enabled`, returning its id
|
|
31
|
+
* (or `null` when disabled / anything failed). The session passes that id on every
|
|
32
|
+
* {@link recordSessionSafe} so all its turns group under one conversation. Same guarantees as the
|
|
33
|
+
* recorder: a no-op by default, fully fail-soft, never throws. When it returns `null` under an
|
|
34
|
+
* enabled store (a rare open failure), turns simply fall back to per-turn 1-turn conversations —
|
|
35
|
+
* grouping is lost but nothing is dropped or crashed.
|
|
36
|
+
*/
|
|
37
|
+
export declare function openConversationSafe(config: HistoryConfigView, meta: ConversationMeta): number | null;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { openHistoryStore, resolveHistoryDbPath } from '#src/history/historyStore.js';
|
|
2
|
+
/**
|
|
3
|
+
* Record one finished session IFF `history.enabled` is true. Returns the new row id, or `null`
|
|
4
|
+
* when history is disabled or anything went wrong (both are non-events for the caller).
|
|
5
|
+
*
|
|
6
|
+
* Deliberately fully guarded: opening the store, ensuring the global dir, and the insert all run
|
|
7
|
+
* behind a single try/catch, and the store itself is fail-soft. Callers put this in a `finally`
|
|
8
|
+
* (or after a run) without a try/catch of their own.
|
|
9
|
+
*/
|
|
10
|
+
export function recordSessionSafe(config, record) {
|
|
11
|
+
try {
|
|
12
|
+
if (!config?.history?.enabled)
|
|
13
|
+
return null;
|
|
14
|
+
const dbPath = resolveHistoryDbPath(config.history.dbPath, /* ensureDir */ true);
|
|
15
|
+
const store = openHistoryStore(dbPath, { create: true });
|
|
16
|
+
if (!store)
|
|
17
|
+
return null;
|
|
18
|
+
try {
|
|
19
|
+
return store.record(record);
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
store.close();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* GS2-19 — open one conversation for an interactive session IFF `history.enabled`, returning its id
|
|
31
|
+
* (or `null` when disabled / anything failed). The session passes that id on every
|
|
32
|
+
* {@link recordSessionSafe} so all its turns group under one conversation. Same guarantees as the
|
|
33
|
+
* recorder: a no-op by default, fully fail-soft, never throws. When it returns `null` under an
|
|
34
|
+
* enabled store (a rare open failure), turns simply fall back to per-turn 1-turn conversations —
|
|
35
|
+
* grouping is lost but nothing is dropped or crashed.
|
|
36
|
+
*/
|
|
37
|
+
export function openConversationSafe(config, meta) {
|
|
38
|
+
try {
|
|
39
|
+
if (!config?.history?.enabled)
|
|
40
|
+
return null;
|
|
41
|
+
const dbPath = resolveHistoryDbPath(config.history.dbPath, /* ensureDir */ true);
|
|
42
|
+
const store = openHistoryStore(dbPath, { create: true });
|
|
43
|
+
if (!store)
|
|
44
|
+
return null;
|
|
45
|
+
try {
|
|
46
|
+
return store.openConversation(meta);
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
store.close();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=recordSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recordSession.js","sourceRoot":"","sources":["../../src/history/recordSession.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAOtF;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAyB,EAAE,MAAqB;IAChF,IAAI,CAAC;QACH,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO;YAAE,OAAO,IAAI,CAAC;QAC3C,MAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;QACjF,MAAM,KAAK,GAAG,gBAAgB,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QACxB,IAAI,CAAC;YACH,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC9B,CAAC;gBAAS,CAAC;YACT,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAyB,EACzB,IAAsB;IAEtB,IAAI,CAAC;QACH,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO;YAAE,OAAO,IAAI,CAAC;QAC3C,MAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;QACjF,MAAM,KAAK,GAAG,gBAAgB,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QACxB,IAAI,CAAC;YACH,OAAO,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC;gBAAS,CAAC;YACT,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export * from '#src/constants.js';
|
|
2
2
|
export * from '#src/core/types.js';
|
|
3
|
+
export { gthLeanAgentFactory } from '#src/core/gthLeanAgentFactory.js';
|
|
3
4
|
export * from '#src/config.js';
|
|
4
5
|
export * from '#src/providers/modelDiscovery.js';
|
|
6
|
+
export * from '#src/history/historyStore.js';
|
|
7
|
+
export * from '#src/history/recordSession.js';
|
|
8
|
+
export * from '#src/history/historyFormat.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export * from '#src/constants.js';
|
|
2
2
|
export * from '#src/core/types.js';
|
|
3
|
+
export { gthLeanAgentFactory } from '#src/core/gthLeanAgentFactory.js';
|
|
3
4
|
export * from '#src/config.js';
|
|
4
5
|
export * from '#src/providers/modelDiscovery.js';
|
|
6
|
+
export * from '#src/history/historyStore.js';
|
|
7
|
+
export * from '#src/history/recordSession.js';
|
|
8
|
+
export * from '#src/history/historyFormat.js';
|
|
5
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kCAAkC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC"}
|
|
@@ -4,4 +4,4 @@ import type { BaseChatModel, BaseChatModelParams } from '@langchain/core/languag
|
|
|
4
4
|
* Function to process JSON config and create Anthropic LLM instance
|
|
5
5
|
*/
|
|
6
6
|
export declare function processJsonConfig(llmConfig: AnthropicInput & BaseChatModelParams): Promise<BaseChatModel>;
|
|
7
|
-
export declare function init(configFileName: string): void;
|
|
7
|
+
export declare function init(configFileName: string, force?: boolean, model?: string): void;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { displayWarning } from '#src/utils/consoleUtils.js';
|
|
2
|
-
import {
|
|
2
|
+
import { writeConfigFileWithMessages } from '#src/utils/fileUtils.js';
|
|
3
|
+
import { buildInitConfigContent, getCuratedFallbackModel } from '#src/providers/modelDiscovery.js';
|
|
4
|
+
import { NATIVE_CLIENT_REASON, warnUnusedConfiguration, } from '#src/providers/configurationPassthrough.js';
|
|
3
5
|
import { env } from '#src/utils/systemUtils.js';
|
|
4
6
|
/**
|
|
5
7
|
* Function to process JSON config and create Anthropic LLM instance
|
|
@@ -9,25 +11,30 @@ export async function processJsonConfig(llmConfig) {
|
|
|
9
11
|
const anthropic = await import('@langchain/anthropic');
|
|
10
12
|
// Use config value if available, otherwise use the environment variable
|
|
11
13
|
const anthropicApiKey = llmConfig.apiKey || env.ANTHROPIC_API_KEY;
|
|
14
|
+
// `ChatAnthropic` builds an Anthropic SDK client from its own `clientOptions`, so nothing in a
|
|
15
|
+
// `configuration` block reaches it — say so before dropping it.
|
|
16
|
+
warnUnusedConfiguration({
|
|
17
|
+
provider: 'anthropic',
|
|
18
|
+
configuration: llmConfig.configuration,
|
|
19
|
+
consumedPaths: [],
|
|
20
|
+
reason: NATIVE_CLIENT_REASON,
|
|
21
|
+
guidance: 'ChatAnthropic builds an Anthropic SDK client instead: put client options such as a custom ' +
|
|
22
|
+
'base URL, a timeout or extra headers under "clientOptions" in the "llm" block, or set ' +
|
|
23
|
+
'"anthropicApiUrl" there for the base URL alone.',
|
|
24
|
+
});
|
|
12
25
|
return new anthropic.ChatAnthropic({
|
|
13
26
|
...llmConfig,
|
|
14
27
|
apiKey: anthropicApiKey,
|
|
15
|
-
model: llmConfig.model || '
|
|
28
|
+
model: llmConfig.model || getCuratedFallbackModel('anthropic'),
|
|
16
29
|
});
|
|
17
30
|
}
|
|
18
|
-
const jsonContent = `{
|
|
19
|
-
"llm": {
|
|
20
|
-
"type": "anthropic",
|
|
21
|
-
"model": "claude-sonnet-4-6"
|
|
22
|
-
}
|
|
23
|
-
}`;
|
|
24
31
|
// noinspection JSUnusedGlobalSymbols
|
|
25
|
-
export function init(configFileName) {
|
|
32
|
+
export function init(configFileName, force = false, model) {
|
|
26
33
|
// Determine which content to use based on file extension
|
|
27
34
|
if (!configFileName.endsWith('.json')) {
|
|
28
35
|
throw new Error('Only JSON config is supported.');
|
|
29
36
|
}
|
|
30
|
-
|
|
37
|
+
writeConfigFileWithMessages(configFileName, buildInitConfigContent('anthropic', model), force);
|
|
31
38
|
displayWarning(`You need to update your ${configFileName} to add your Anthropic API key, ` +
|
|
32
39
|
'or define ANTHROPIC_API_KEY environment variable.');
|
|
33
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names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AW,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAC/F,cAAc,CACZ,2BAA2B,cAAc,kCAAkC;QACzE,mDAAmD,CACtD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List the paths inside a `configuration` block that the calling factory will NOT read.
|
|
3
|
+
*
|
|
4
|
+
* `consumedPaths` entries are either a whole key (`baseURL`) or a dotted one-level path
|
|
5
|
+
* (`defaultHeaders.X-Title`). The dotted form matters because consumption is genuinely PARTIAL:
|
|
6
|
+
* openrouter reads two named attribution headers out of `defaultHeaders` and drops every other
|
|
7
|
+
* header in it. Reporting `defaultHeaders` as wholly consumed would silence the warning for
|
|
8
|
+
* exactly the case the user most needs it for — an auth header for a self-hosted gateway that is
|
|
9
|
+
* quietly discarded.
|
|
10
|
+
*
|
|
11
|
+
* A `configuration` that is not a record at all (`configuration: "https://x/v1"`, a plausible typo
|
|
12
|
+
* for the block) has no paths and is reported as nothing. That is NOT a silent drop: `llm.configuration`
|
|
13
|
+
* is `z.record` in `schema.ts`, and every config layer goes through the loader's `validateRawConfigLayer`,
|
|
14
|
+
* so a non-record value is a hard, path-scoped validation error that ends the run before any provider
|
|
15
|
+
* factory is reached. The schema is the gate for the shape; this function is the gate for the
|
|
16
|
+
* contents. `configurationPassthrough.spec.ts` pins that boundary — if the schema ever stops
|
|
17
|
+
* requiring a record, the case has to be handled here instead.
|
|
18
|
+
*/
|
|
19
|
+
export declare function findUnusedConfigurationPaths(configuration: unknown, consumedPaths: readonly string[]): string[];
|
|
20
|
+
/**
|
|
21
|
+
* The `reason` for a provider built on a NATIVE client: there is no OpenAI client anywhere in the
|
|
22
|
+
* chain, so the block has nothing to be handed to.
|
|
23
|
+
*
|
|
24
|
+
* A shared clause is only safe while it is true of every caller that passes it, and nothing in the
|
|
25
|
+
* language can check that: the field takes any string, so a caller can pass this sentence — or
|
|
26
|
+
* another provider's — for a provider it is false of, and a warning that states a false reason is
|
|
27
|
+
* the same defect as the silence it replaces. Requiring the field stops one narrow version of that
|
|
28
|
+
* (a default nobody re-read against the new caller) and stops nothing else; copying the neighbouring
|
|
29
|
+
* call site is the likelier move and is exactly how a false clause would spread.
|
|
30
|
+
*
|
|
31
|
+
* What actually holds it is `configurationPassthrough.spec.ts`, which pins every warned provider's
|
|
32
|
+
* printed clause IN ITS SLOT beside that provider's own name. A clause that migrates to a provider
|
|
33
|
+
* it is false of reddens a cell, and editing THIS sentence reddens every caller that passes it —
|
|
34
|
+
* which is the point: a shared clause has to be re-checked against each of them.
|
|
35
|
+
*/
|
|
36
|
+
export declare const NATIVE_CLIENT_REASON = "does not build an OpenAI client, so a \"configuration\" block is not passed through to one";
|
|
37
|
+
/**
|
|
38
|
+
* Warn — naming the provider, saying why the block is dropped, naming every dropped path, and
|
|
39
|
+
* pointing at the replacement — when a user's `configuration` block carries settings this provider
|
|
40
|
+
* cannot consume.
|
|
41
|
+
*
|
|
42
|
+
* Warn rather than throw: a provider that reads SOME of the block (openrouter still honours
|
|
43
|
+
* `configuration.baseURL`) would otherwise refuse a config that is partly valid, and an upgrading
|
|
44
|
+
* user whose only config sets one dead transport key would be left with no way to start at all.
|
|
45
|
+
*
|
|
46
|
+
* Takes ONE named-field object rather than a positional list. `reason` and `guidance` are both free
|
|
47
|
+
* text, so as adjacent positionals they could be transposed with nothing to catch it: `tsc` sees two
|
|
48
|
+
* strings, and the rendered message still contains both sentences — only their order is wrong, which
|
|
49
|
+
* no `toContain` check on either one can see. Named fields make that mistake visible where it is
|
|
50
|
+
* written; the slot-anchored pins in `configurationPassthrough.spec.ts` are what catch it if it is
|
|
51
|
+
* written anyway.
|
|
52
|
+
*/
|
|
53
|
+
export interface UnusedConfigurationWarning {
|
|
54
|
+
/** The gth provider namespace, printed to the user (`anthropic`, `xai`, …). */
|
|
55
|
+
provider: string;
|
|
56
|
+
/** The user's `llm.configuration` block, exactly as it arrived. */
|
|
57
|
+
configuration: unknown;
|
|
58
|
+
/**
|
|
59
|
+
* The paths inside the block this factory genuinely reads — whole keys or dotted one-level paths.
|
|
60
|
+
* Required rather than defaulted to `[]`, so a new caller has to state what its factory consumes
|
|
61
|
+
* instead of inheriting an answer.
|
|
62
|
+
*/
|
|
63
|
+
consumedPaths: readonly string[];
|
|
64
|
+
/**
|
|
65
|
+
* Why THIS provider drops the block, as a clause completing `the "<provider>" provider …`. Pass
|
|
66
|
+
* {@link NATIVE_CLIENT_REASON} for a native-client provider; a provider that builds an OpenAI
|
|
67
|
+
* client and then overrides the block needs its own, because that sentence would be false for it.
|
|
68
|
+
*/
|
|
69
|
+
reason: string;
|
|
70
|
+
/**
|
|
71
|
+
* What to do instead, naming the replacement on THIS provider's own client — never a generic
|
|
72
|
+
* "move it up a level", which for some keys moves a setting from a warned location to an unwarned
|
|
73
|
+
* one.
|
|
74
|
+
*/
|
|
75
|
+
guidance: string;
|
|
76
|
+
}
|
|
77
|
+
export declare function warnUnusedConfiguration({ provider, configuration, consumedPaths, reason, guidance, }: UnusedConfigurationWarning): void;
|
|
78
|
+
/**
|
|
79
|
+
* Warn when a `configuration` path the factory DOES consume silently beats a top-level field of the
|
|
80
|
+
* `llm` block that sets the same thing.
|
|
81
|
+
*
|
|
82
|
+
* Neither value is unusable here and neither location is wrong, so this is not a case for
|
|
83
|
+
* {@link warnUnusedConfiguration}: both are honoured surfaces, and the only defect is that one wins
|
|
84
|
+
* without saying so. The user's config then reads as two settings and behaves as one.
|
|
85
|
+
*
|
|
86
|
+
* Values are never printed — a base URL can carry credentials — so the message names the two paths
|
|
87
|
+
* and which of them takes effect.
|
|
88
|
+
*
|
|
89
|
+
* @param appliedValue The value the factory actually applied. Pass the result of the SAME expression
|
|
90
|
+
* that decides it, never a second copy of the test, for the reason given on
|
|
91
|
+
* {@link warnUnappliedConfigurationPath}.
|
|
92
|
+
*/
|
|
93
|
+
export declare function warnConfigurationOverridesTopLevelField(provider: string, field: string, topLevelValue: unknown, appliedValue: unknown): void;
|
|
94
|
+
/**
|
|
95
|
+
* Warn when a path the factory DECLARES it consumes is present in the user's block but was not in
|
|
96
|
+
* fact applied — the empty string or `null` a factory's own guard skips.
|
|
97
|
+
*
|
|
98
|
+
* {@link findUnusedConfigurationPaths} cannot see this and must not: the path genuinely IS consumed,
|
|
99
|
+
* so it is correctly absent from the unused list — and the user's setting still goes nowhere.
|
|
100
|
+
* "Declared supported, in fact dropped" is the same silence this module exists to end, so it gets
|
|
101
|
+
* its own message: the "no OpenAI client" reason above would be the wrong reason for it.
|
|
102
|
+
*
|
|
103
|
+
* @param applied Whether the factory actually used the value. Pass the result of the SAME expression
|
|
104
|
+
* that decides it (`'baseURL' in baseURLOverride`), never a second copy of the test — a re-test is
|
|
105
|
+
* exactly how the guard and what the user is told drift apart.
|
|
106
|
+
*/
|
|
107
|
+
export declare function warnUnappliedConfigurationPath(provider: string, configuration: unknown, path: string, applied: boolean, guidance: string): void;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { displayWarning } from '#src/utils/consoleUtils.js';
|
|
2
|
+
/**
|
|
3
|
+
* `configuration` is `ChatOpenAI`'s own constructor field, which LangChain forwards to the OpenAI
|
|
4
|
+
* Node SDK's `ClientOptions`. It therefore only means anything for a provider that ends up handing
|
|
5
|
+
* the user's block to such a client: `openai` and `huggingface` build one directly, and `deepseek`
|
|
6
|
+
* spreads the user's block over its own defaults. For those, a block is a supported, working
|
|
7
|
+
* passthrough and MUST be left alone.
|
|
8
|
+
*
|
|
9
|
+
* **Descending from `ChatOpenAI` is NOT evidence of a passthrough — read the constructor.** `xai`
|
|
10
|
+
* descends from it and still consumes nothing: `ChatXAI` REPLACES `configuration` with a block of
|
|
11
|
+
* its own before calling `super`, so a timeout, headers, and even a base URL set there all reach
|
|
12
|
+
* nothing. Reading ancestry as consumption is exactly how a provider keeps its silence here, so
|
|
13
|
+
* classify a provider by what its constructor does with the block, never by what it extends.
|
|
14
|
+
*
|
|
15
|
+
* A provider on a NATIVE (non-OpenAI-SDK) client has nothing to hand the block to, so anything the
|
|
16
|
+
* factory does not read itself goes nowhere. `llmConfigSchema` is a `z.looseObject`, so an orphaned
|
|
17
|
+
* block also passes validation without a word — which is the 2.0 config policy's exact failure mode:
|
|
18
|
+
* a removed key is fine, a SILENTLY IGNORED one is not, because the config then behaves differently
|
|
19
|
+
* than it reads. This is the one place that turns that silence into a message, so a second native
|
|
20
|
+
* provider does not have to reinvent it.
|
|
21
|
+
*
|
|
22
|
+
* **Scope: paths INSIDE a `configuration` block, and nothing else.** A top-level key of the `llm`
|
|
23
|
+
* block that the chosen provider does not read — `llm.defaultHeaders` on `xai`, say — is the same
|
|
24
|
+
* silently-ignored-key defect, and this module does not cover it: the loose schema accepts it, no
|
|
25
|
+
* factory reads it, and nothing is printed. Guidance that sends a setting "to the top level" is
|
|
26
|
+
* therefore only safe for a field that provider actually has, which is why every `guidance` here
|
|
27
|
+
* names the replacement rather than a direction.
|
|
28
|
+
*
|
|
29
|
+
* Use it from a native-client factory only, and pass the paths that factory genuinely consumes.
|
|
30
|
+
*/
|
|
31
|
+
/** A `configuration` sub-object is a plain record; anything else cannot carry consumable settings. */
|
|
32
|
+
function isPlainRecord(value) {
|
|
33
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* List the paths inside a `configuration` block that the calling factory will NOT read.
|
|
37
|
+
*
|
|
38
|
+
* `consumedPaths` entries are either a whole key (`baseURL`) or a dotted one-level path
|
|
39
|
+
* (`defaultHeaders.X-Title`). The dotted form matters because consumption is genuinely PARTIAL:
|
|
40
|
+
* openrouter reads two named attribution headers out of `defaultHeaders` and drops every other
|
|
41
|
+
* header in it. Reporting `defaultHeaders` as wholly consumed would silence the warning for
|
|
42
|
+
* exactly the case the user most needs it for — an auth header for a self-hosted gateway that is
|
|
43
|
+
* quietly discarded.
|
|
44
|
+
*
|
|
45
|
+
* A `configuration` that is not a record at all (`configuration: "https://x/v1"`, a plausible typo
|
|
46
|
+
* for the block) has no paths and is reported as nothing. That is NOT a silent drop: `llm.configuration`
|
|
47
|
+
* is `z.record` in `schema.ts`, and every config layer goes through the loader's `validateRawConfigLayer`,
|
|
48
|
+
* so a non-record value is a hard, path-scoped validation error that ends the run before any provider
|
|
49
|
+
* factory is reached. The schema is the gate for the shape; this function is the gate for the
|
|
50
|
+
* contents. `configurationPassthrough.spec.ts` pins that boundary — if the schema ever stops
|
|
51
|
+
* requiring a record, the case has to be handled here instead.
|
|
52
|
+
*/
|
|
53
|
+
export function findUnusedConfigurationPaths(configuration, consumedPaths) {
|
|
54
|
+
if (!isPlainRecord(configuration))
|
|
55
|
+
return [];
|
|
56
|
+
const unused = [];
|
|
57
|
+
for (const [key, value] of Object.entries(configuration)) {
|
|
58
|
+
if (consumedPaths.includes(key))
|
|
59
|
+
continue;
|
|
60
|
+
const consumedSubKeys = consumedPaths
|
|
61
|
+
.filter((path) => path.startsWith(`${key}.`))
|
|
62
|
+
.map((path) => path.slice(key.length + 1));
|
|
63
|
+
if (consumedSubKeys.length > 0 && isPlainRecord(value)) {
|
|
64
|
+
for (const subKey of Object.keys(value)) {
|
|
65
|
+
if (!consumedSubKeys.includes(subKey))
|
|
66
|
+
unused.push(`${key}.${subKey}`);
|
|
67
|
+
}
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
unused.push(key);
|
|
71
|
+
}
|
|
72
|
+
return unused;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The `reason` for a provider built on a NATIVE client: there is no OpenAI client anywhere in the
|
|
76
|
+
* chain, so the block has nothing to be handed to.
|
|
77
|
+
*
|
|
78
|
+
* A shared clause is only safe while it is true of every caller that passes it, and nothing in the
|
|
79
|
+
* language can check that: the field takes any string, so a caller can pass this sentence — or
|
|
80
|
+
* another provider's — for a provider it is false of, and a warning that states a false reason is
|
|
81
|
+
* the same defect as the silence it replaces. Requiring the field stops one narrow version of that
|
|
82
|
+
* (a default nobody re-read against the new caller) and stops nothing else; copying the neighbouring
|
|
83
|
+
* call site is the likelier move and is exactly how a false clause would spread.
|
|
84
|
+
*
|
|
85
|
+
* What actually holds it is `configurationPassthrough.spec.ts`, which pins every warned provider's
|
|
86
|
+
* printed clause IN ITS SLOT beside that provider's own name. A clause that migrates to a provider
|
|
87
|
+
* it is false of reddens a cell, and editing THIS sentence reddens every caller that passes it —
|
|
88
|
+
* which is the point: a shared clause has to be re-checked against each of them.
|
|
89
|
+
*/
|
|
90
|
+
export const NATIVE_CLIENT_REASON = 'does not build an OpenAI client, so a "configuration" block is not passed through to one';
|
|
91
|
+
export function warnUnusedConfiguration({ provider, configuration, consumedPaths, reason, guidance, }) {
|
|
92
|
+
const unused = findUnusedConfigurationPaths(configuration, consumedPaths);
|
|
93
|
+
if (unused.length === 0)
|
|
94
|
+
return;
|
|
95
|
+
displayWarning(`Ignoring ${unused.map((path) => `llm.configuration.${path}`).join(', ')} — ` +
|
|
96
|
+
`the "${provider}" provider ${reason}. ${guidance}`);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Warn when a `configuration` path the factory DOES consume silently beats a top-level field of the
|
|
100
|
+
* `llm` block that sets the same thing.
|
|
101
|
+
*
|
|
102
|
+
* Neither value is unusable here and neither location is wrong, so this is not a case for
|
|
103
|
+
* {@link warnUnusedConfiguration}: both are honoured surfaces, and the only defect is that one wins
|
|
104
|
+
* without saying so. The user's config then reads as two settings and behaves as one.
|
|
105
|
+
*
|
|
106
|
+
* Values are never printed — a base URL can carry credentials — so the message names the two paths
|
|
107
|
+
* and which of them takes effect.
|
|
108
|
+
*
|
|
109
|
+
* @param appliedValue The value the factory actually applied. Pass the result of the SAME expression
|
|
110
|
+
* that decides it, never a second copy of the test, for the reason given on
|
|
111
|
+
* {@link warnUnappliedConfigurationPath}.
|
|
112
|
+
*/
|
|
113
|
+
export function warnConfigurationOverridesTopLevelField(provider, field, topLevelValue, appliedValue) {
|
|
114
|
+
// Nothing to lose: no top-level field set, or the block's value was not applied over it.
|
|
115
|
+
if (topLevelValue === undefined || topLevelValue === null || topLevelValue === '')
|
|
116
|
+
return;
|
|
117
|
+
if (appliedValue === undefined || appliedValue === null)
|
|
118
|
+
return;
|
|
119
|
+
// The same endpoint written twice is redundant, not a conflict, and warning on it would train
|
|
120
|
+
// users to ignore the message.
|
|
121
|
+
if (topLevelValue === appliedValue)
|
|
122
|
+
return;
|
|
123
|
+
displayWarning(`Ignoring llm.${field} — the "${provider}" provider also has llm.configuration.${field} set, ` +
|
|
124
|
+
`and that one takes precedence. Set only one of the two so the "llm" block reads the way it ` +
|
|
125
|
+
`behaves.`);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Warn when a path the factory DECLARES it consumes is present in the user's block but was not in
|
|
129
|
+
* fact applied — the empty string or `null` a factory's own guard skips.
|
|
130
|
+
*
|
|
131
|
+
* {@link findUnusedConfigurationPaths} cannot see this and must not: the path genuinely IS consumed,
|
|
132
|
+
* so it is correctly absent from the unused list — and the user's setting still goes nowhere.
|
|
133
|
+
* "Declared supported, in fact dropped" is the same silence this module exists to end, so it gets
|
|
134
|
+
* its own message: the "no OpenAI client" reason above would be the wrong reason for it.
|
|
135
|
+
*
|
|
136
|
+
* @param applied Whether the factory actually used the value. Pass the result of the SAME expression
|
|
137
|
+
* that decides it (`'baseURL' in baseURLOverride`), never a second copy of the test — a re-test is
|
|
138
|
+
* exactly how the guard and what the user is told drift apart.
|
|
139
|
+
*/
|
|
140
|
+
export function warnUnappliedConfigurationPath(provider, configuration, path, applied, guidance) {
|
|
141
|
+
if (applied)
|
|
142
|
+
return;
|
|
143
|
+
if (!isPlainRecord(configuration) || !(path in configuration))
|
|
144
|
+
return;
|
|
145
|
+
displayWarning(`Ignoring llm.configuration.${path} — it is set for the "${provider}" provider but carries no ` +
|
|
146
|
+
`usable value, so it is not applied. ${guidance}`);
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=configurationPassthrough.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configurationPass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B;IAEhB,IAAI,OAAO;QAAE,OAAO;IACpB,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,aAAa,CAAC;QAAE,OAAO;IACtE,cAAc,CACZ,8BAA8B,IAAI,yBAAyB,QAAQ,4BAA4B;QAC7F,uCAAuC,QAAQ,EAAE,CACpD,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { BaseChatModel, BaseChatModelParams } from '@langchain/core/language_models/chat_models';
|
|
2
2
|
import { ChatDeepSeekInput } from '@langchain/deepseek';
|
|
3
3
|
export declare function processJsonConfig(llmConfig: ChatDeepSeekInput & BaseChatModelParams): Promise<BaseChatModel>;
|
|
4
|
-
export declare function init(configFileName: string): void;
|
|
4
|
+
export declare function init(configFileName: string, force?: boolean, model?: string): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { displayWarning } from '#src/utils/consoleUtils.js';
|
|
2
2
|
import { env } from '#src/utils/systemUtils.js';
|
|
3
|
-
import {
|
|
3
|
+
import { writeConfigFileWithMessages } from '#src/utils/fileUtils.js';
|
|
4
|
+
import { buildInitConfigContent, getCuratedFallbackModel } from '#src/providers/modelDiscovery.js';
|
|
4
5
|
// Function to process JSON config and create DeepSeek LLM instance
|
|
5
6
|
export async function processJsonConfig(llmConfig) {
|
|
6
7
|
const deepseek = await import('@langchain/deepseek');
|
|
@@ -9,21 +10,15 @@ export async function processJsonConfig(llmConfig) {
|
|
|
9
10
|
return new deepseek.ChatDeepSeek({
|
|
10
11
|
...llmConfig,
|
|
11
12
|
apiKey: deepseekApiKey,
|
|
12
|
-
model: llmConfig.model || 'deepseek
|
|
13
|
+
model: llmConfig.model || getCuratedFallbackModel('deepseek'),
|
|
13
14
|
});
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
"llm": {
|
|
17
|
-
"type": "deepseek",
|
|
18
|
-
"model": "deepseek-v4-pro"
|
|
19
|
-
}
|
|
20
|
-
}`;
|
|
21
|
-
export function init(configFileName) {
|
|
16
|
+
export function init(configFileName, force = false, model) {
|
|
22
17
|
// Determine which content to use based on file extension
|
|
23
18
|
if (!configFileName.endsWith('.json')) {
|
|
24
19
|
throw new Error('Only JSON config is supported.');
|
|
25
20
|
}
|
|
26
|
-
|
|
21
|
+
writeConfigFileWithMessages(configFileName, buildInitConfigContent('deepseek', model), force);
|
|
27
22
|
displayWarning(`You need to update your ${configFileName} to add your DeepSeek API key, ` +
|
|
28
23
|
'or define DEEPSEEK_API_KEY environment variable.');
|
|
29
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepseek.js","sourceRoot":"","sources":["../../src/providers/deepseek.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAOhD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"deepseek.js","sourceRoot":"","sources":["../../src/providers/deepseek.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;AAEnG,mEAAmE;AACnE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,SAAkD;IAElD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACrD,yEAAyE;IACzE,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,gBAAgB,CAAC;IAChE,OAAO,IAAI,QAAQ,CAAC,YAAY,CAAC;QAC/B,GAAG,SAAS;QACZ,MAAM,EAAE,cAAc;QACtB,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,uBAAuB,CAAC,UAAU,CAAC;KAC9D,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,UAAU,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAC9F,cAAc,CACZ,2BAA2B,cAAc,iCAAiC;QACxE,kDAAkD,CACrD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* GS2-58 — systemic Gemini tool-schema sanitizer at the `@langchain/google` provider boundary.
|
|
4
|
+
*
|
|
5
|
+
* Google Gemini's function-declaration schema is a SELECT SUBSET of OpenAPI 3.0. `@langchain/google`'s
|
|
6
|
+
* own `removeAdditionalProperties` strips only `additionalProperties`, so every other JSON-Schema-draft
|
|
7
|
+
* keyword the subset does not declare (`exclusiveMinimum`/`exclusiveMaximum`/`multipleOf`, `$defs`,
|
|
8
|
+
* `patternProperties`, `const`, `$ref`, `allOf`/`oneOf`/`not`, …) is passed straight to the wire, and
|
|
9
|
+
* Gemini 400s at tool-declaration send time — before any tool runs.
|
|
10
|
+
*
|
|
11
|
+
* This is the DURABLE fix (GS2-58, fix-cycle 1): rather than a denylist that is always one unknown
|
|
12
|
+
* keyword behind, {@link sanitizeGeminiToolSchema} is an ALLOWLIST — it keeps ONLY the fields the
|
|
13
|
+
* installed Gemini `Schema` type declares and drops everything else, so a future keyword in ANY tool
|
|
14
|
+
* (built-in, custom, or MCP — including schemas gaunt-sloth does not author) cannot re-break Gemini.
|
|
15
|
+
*
|
|
16
|
+
* The allowlist ({@link GEMINI_SUPPORTED_SCHEMA_KEYWORDS}) is derived DIRECTLY from the authoritative
|
|
17
|
+
* in-repo type — the `Gemini.Tools.Schema` interface in
|
|
18
|
+
* `node_modules/@langchain/google/dist/chat_models/api-types.d.{ts,cts}` (a `FunctionDeclaration`'s
|
|
19
|
+
* `parameters?: Schema`), "a select subset of an OpenAPI 3.0 schema object". Keeping it aligned with
|
|
20
|
+
* that type (not a remembered list) is what prevents a stale allowlist silently over-stripping.
|
|
21
|
+
*
|
|
22
|
+
* Scope is the google/gemini provider path ONLY: {@link applyGeminiToolSchemaSanitizer} is wired into
|
|
23
|
+
* the `google-genai` and `vertexai` presets' `processJsonConfig`. It leaves OpenAI/Anthropic/Ollama
|
|
24
|
+
* wiring untouched, and does not weaken the GS2-56/57 build-time denylist guard (that test still runs;
|
|
25
|
+
* this transform runs ahead of the wire send, so a sanitized tool is what Gemini sees).
|
|
26
|
+
*/
|
|
27
|
+
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
28
|
+
/**
|
|
29
|
+
* The EXACT set of schema keywords Gemini's function-declaration schema accepts, transcribed field-
|
|
30
|
+
* for-field from the `Gemini.Tools.Schema` interface in
|
|
31
|
+
* `@langchain/google/dist/chat_models/api-types.d.ts`. Anything not in this set is dropped (allowlist).
|
|
32
|
+
*
|
|
33
|
+
* Note `anyOf` IS supported (unions / nullable) and MUST survive — only `allOf`/`oneOf`/`not` are
|
|
34
|
+
* absent from the type and therefore dropped. `exclusiveMinimum`/`exclusiveMaximum` are NOT in the type
|
|
35
|
+
* either; they are handled specially by rewriting them to `minimum`/`maximum` (see {@link sanitizeNode})
|
|
36
|
+
* before the allowlist filter runs.
|
|
37
|
+
*/
|
|
38
|
+
export declare const GEMINI_SUPPORTED_SCHEMA_KEYWORDS: ReadonlySet<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Pure, recursive normaliser: returns a cleaned DEEP COPY of a JSON-Schema containing only keywords
|
|
41
|
+
* Gemini's function-declaration `Schema` accepts, so its OpenAPI-3.0 subset accepts the tool. At each
|
|
42
|
+
* node the SAFE composition keywords are first RESOLVED into supported equivalents
|
|
43
|
+
* ({@link resolveComposition}: `const` → `enum`, clean `allOf` → shallow merge) and only then does the
|
|
44
|
+
* allowlist drop the rest. Does not mutate the input. `anyOf` unions survive; `$ref`/`oneOf`/`not` are
|
|
45
|
+
* dropped (see {@link resolveComposition} for why the last three are deferred, not resolved).
|
|
46
|
+
*/
|
|
47
|
+
export declare function sanitizeGeminiToolSchema<T = unknown>(schema: T): T;
|
|
48
|
+
/**
|
|
49
|
+
* Wire the sanitizer into a ChatGoogle model at the tool-binding boundary. Overrides the instance's
|
|
50
|
+
* `bindTools` so every tool passed to it — built-in, custom, or MCP, via `createAgent`/`createDeepAgent`
|
|
51
|
+
* which both call `model.bindTools(tools)` — is sanitized before it reaches `@langchain/google`'s
|
|
52
|
+
* Gemini converter. Provider-scoped: only the google-genai/vertexai presets call this, so no other
|
|
53
|
+
* provider's tools are affected. Returns the same model instance for convenient chaining.
|
|
54
|
+
*/
|
|
55
|
+
export declare function applyGeminiToolSchemaSanitizer<T extends BaseChatModel>(model: T): T;
|