@gaunt-sloth/core 2.0.0-alpha.9 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gsloth.review.md +2 -0
- package/README.md +71 -20
- package/dist/config/colour.d.ts +38 -0
- package/dist/config/colour.js +36 -0
- package/dist/config/colour.js.map +1 -0
- package/dist/config/configDiscovery.d.ts +79 -0
- package/dist/config/configDiscovery.js +80 -0
- package/dist/config/configDiscovery.js.map +1 -0
- package/dist/config/defaults.d.ts +20 -20
- package/dist/config/defaults.js +10 -8
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/filesystem-tools.d.ts +41 -0
- package/dist/config/filesystem-tools.js +56 -0
- package/dist/config/filesystem-tools.js.map +1 -0
- package/dist/config/loader.d.ts +171 -19
- package/dist/config/loader.js +1054 -144
- package/dist/config/loader.js.map +1 -1
- package/dist/config/mouse.d.ts +50 -0
- package/dist/config/mouse.js +44 -0
- package/dist/config/mouse.js.map +1 -0
- package/dist/config/profiles.d.ts +68 -0
- package/dist/config/profiles.js +93 -0
- package/dist/config/profiles.js.map +1 -0
- package/dist/config/providerKeys.d.ts +69 -0
- package/dist/config/providerKeys.js +69 -0
- package/dist/config/providerKeys.js.map +1 -0
- package/dist/config/schema.d.ts +2671 -138
- package/dist/config/schema.js +1361 -85
- package/dist/config/schema.js.map +1 -1
- package/dist/config/shell-policy.d.ts +899 -111
- package/dist/config/shell-policy.js +800 -70
- package/dist/config/shell-policy.js.map +1 -1
- package/dist/config/tool-descriptions.d.ts +211 -0
- package/dist/config/tool-descriptions.js +272 -0
- package/dist/config/tool-descriptions.js.map +1 -0
- package/dist/config/types.d.ts +352 -41
- package/dist/config/types.js +1 -0
- package/dist/config/types.js.map +1 -1
- package/dist/config.d.ts +35 -1
- package/dist/config.js +16 -1
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +28 -1
- package/dist/constants.js +28 -1
- package/dist/constants.js.map +1 -1
- package/dist/core/GthAbstractAgent.d.ts +166 -11
- package/dist/core/GthAbstractAgent.js +484 -45
- package/dist/core/GthAbstractAgent.js.map +1 -1
- package/dist/core/GthAgentRunner.d.ts +543 -57
- package/dist/core/GthAgentRunner.js +1494 -140
- package/dist/core/GthAgentRunner.js.map +1 -1
- package/dist/core/GthLangChainAgent.d.ts +117 -2
- package/dist/core/GthLangChainAgent.js +602 -29
- package/dist/core/GthLangChainAgent.js.map +1 -1
- package/dist/core/approvals/annotations.d.ts +122 -0
- package/dist/core/approvals/annotations.js +137 -0
- package/dist/core/approvals/annotations.js.map +1 -0
- package/dist/core/approvals/grants.d.ts +216 -0
- package/dist/core/approvals/grants.js +469 -0
- package/dist/core/approvals/grants.js.map +1 -0
- package/dist/core/approvals/matcher.d.ts +202 -0
- package/dist/core/approvals/matcher.js +267 -0
- package/dist/core/approvals/matcher.js.map +1 -0
- package/dist/core/approvals/mcpSubjects.d.ts +40 -0
- package/dist/core/approvals/mcpSubjects.js +99 -0
- package/dist/core/approvals/mcpSubjects.js.map +1 -0
- package/dist/core/approvals/promptHeader.d.ts +28 -0
- package/dist/core/approvals/promptHeader.js +62 -0
- package/dist/core/approvals/promptHeader.js.map +1 -0
- package/dist/core/approvals/toolAnnotationSources.d.ts +105 -0
- package/dist/core/approvals/toolAnnotationSources.js +277 -0
- package/dist/core/approvals/toolAnnotationSources.js.map +1 -0
- package/dist/core/approvals/toolHost.d.ts +46 -0
- package/dist/core/approvals/toolHost.js +108 -0
- package/dist/core/approvals/toolHost.js.map +1 -0
- package/dist/core/debugCapture.d.ts +74 -0
- package/dist/core/debugCapture.js +100 -0
- package/dist/core/debugCapture.js.map +1 -0
- package/dist/core/gthLeanAgentFactory.d.ts +4 -4
- package/dist/core/gthLeanAgentFactory.js +4 -4
- package/dist/core/launchBanner.d.ts +127 -0
- package/dist/core/launchBanner.js +414 -0
- package/dist/core/launchBanner.js.map +1 -0
- package/dist/core/modelLabel.d.ts +19 -0
- package/dist/core/modelLabel.js +26 -0
- package/dist/core/modelLabel.js.map +1 -0
- package/dist/core/plainToolIndication.d.ts +15 -0
- package/dist/core/plainToolIndication.js +174 -0
- package/dist/core/plainToolIndication.js.map +1 -0
- package/dist/core/reasoningBlocks.d.ts +65 -0
- package/dist/core/reasoningBlocks.js +103 -0
- package/dist/core/reasoningBlocks.js.map +1 -0
- package/dist/core/refusal.d.ts +53 -0
- package/dist/core/refusal.js +133 -0
- package/dist/core/refusal.js.map +1 -0
- package/dist/core/runHeader.d.ts +38 -0
- package/dist/core/runHeader.js +42 -0
- package/dist/core/runHeader.js.map +1 -0
- package/dist/core/runStats.d.ts +14 -3
- package/dist/core/runStats.js +48 -3
- package/dist/core/runStats.js.map +1 -1
- package/dist/core/shell/ShellCommandFailedError.d.ts +3 -4
- package/dist/core/shell/ShellCommandFailedError.js +3 -4
- package/dist/core/shell/ShellCommandFailedError.js.map +1 -1
- package/dist/core/shell/abstention.d.ts +88 -0
- package/dist/core/shell/abstention.js +184 -0
- package/dist/core/shell/abstention.js.map +1 -0
- package/dist/core/shell/approvalCapture.d.ts +271 -0
- package/dist/core/shell/approvalCapture.js +108 -0
- package/dist/core/shell/approvalCapture.js.map +1 -0
- package/dist/core/shell/approvalStop.d.ts +123 -0
- package/dist/core/shell/approvalStop.js +269 -0
- package/dist/core/shell/approvalStop.js.map +1 -0
- package/dist/core/shell/arity.d.ts +6 -0
- package/dist/core/shell/arity.js +20 -6
- package/dist/core/shell/arity.js.map +1 -1
- package/dist/core/shell/denylist.d.ts +11 -0
- package/dist/core/shell/denylist.js +37 -0
- package/dist/core/shell/denylist.js.map +1 -0
- package/dist/core/shell/escalationSeverity.d.ts +141 -0
- package/dist/core/shell/escalationSeverity.js +89 -0
- package/dist/core/shell/escalationSeverity.js.map +1 -0
- package/dist/core/shell/framing.d.ts +190 -0
- package/dist/core/shell/framing.js +633 -0
- package/dist/core/shell/framing.js.map +1 -0
- package/dist/core/shell/hardline.d.ts +103 -0
- package/dist/core/shell/hardline.js +780 -0
- package/dist/core/shell/hardline.js.map +1 -0
- package/dist/core/shell/negotiation.d.ts +328 -0
- package/dist/core/shell/negotiation.js +488 -0
- package/dist/core/shell/negotiation.js.map +1 -0
- package/dist/core/shell/normalize.d.ts +44 -4
- package/dist/core/shell/normalize.js +61 -7
- package/dist/core/shell/normalize.js.map +1 -1
- package/dist/core/shell/openWorld.d.ts +263 -0
- package/dist/core/shell/openWorld.js +1188 -0
- package/dist/core/shell/openWorld.js.map +1 -0
- package/dist/core/shell/rater.d.ts +873 -0
- package/dist/core/shell/rater.js +1454 -0
- package/dist/core/shell/rater.js.map +1 -0
- package/dist/core/shell/raterModel.d.ts +41 -0
- package/dist/core/shell/raterModel.js +51 -0
- package/dist/core/shell/raterModel.js.map +1 -0
- package/dist/core/shell/raterVocabulary.d.ts +121 -0
- package/dist/core/shell/raterVocabulary.js +116 -0
- package/dist/core/shell/raterVocabulary.js.map +1 -0
- package/dist/core/shell/rejection.d.ts +69 -0
- package/dist/core/shell/rejection.js +38 -0
- package/dist/core/shell/rejection.js.map +1 -0
- package/dist/core/toolCallRepair/grammar.d.ts +41 -0
- package/dist/core/toolCallRepair/grammar.js +116 -0
- package/dist/core/toolCallRepair/grammar.js.map +1 -0
- package/dist/core/toolCallRepair/index.d.ts +2 -0
- package/dist/core/toolCallRepair/index.js +7 -0
- package/dist/core/toolCallRepair/index.js.map +1 -0
- package/dist/core/toolCallRepair/payload.d.ts +36 -0
- package/dist/core/toolCallRepair/payload.js +341 -0
- package/dist/core/toolCallRepair/payload.js.map +1 -0
- package/dist/core/toolCallRepair/promote.d.ts +45 -0
- package/dist/core/toolCallRepair/promote.js +90 -0
- package/dist/core/toolCallRepair/promote.js.map +1 -0
- package/dist/core/toolDisplay.d.ts +123 -0
- package/dist/core/toolDisplay.js +451 -0
- package/dist/core/toolDisplay.js.map +1 -0
- package/dist/core/toolOutputChannel.d.ts +95 -0
- package/dist/core/toolOutputChannel.js +165 -0
- package/dist/core/toolOutputChannel.js.map +1 -0
- package/dist/core/types.d.ts +349 -16
- package/dist/core/types.js.map +1 -1
- package/dist/history/historyFormat.d.ts +12 -3
- package/dist/history/historyFormat.js +50 -8
- package/dist/history/historyFormat.js.map +1 -1
- package/dist/history/historyStore.d.ts +77 -0
- package/dist/history/historyStore.js +173 -6
- package/dist/history/historyStore.js.map +1 -1
- package/dist/history/recordSession.d.ts +10 -1
- package/dist/history/recordSession.js +27 -0
- package/dist/history/recordSession.js.map +1 -1
- package/dist/providers/anthropic.js +12 -0
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/configurationPassthrough.d.ts +107 -0
- package/dist/providers/configurationPassthrough.js +148 -0
- package/dist/providers/configurationPassthrough.js.map +1 -0
- package/dist/providers/geminiSchemaSanitizer.d.ts +55 -0
- package/dist/providers/geminiSchemaSanitizer.js +347 -0
- package/dist/providers/geminiSchemaSanitizer.js.map +1 -0
- package/dist/providers/geminiThinking.d.ts +60 -0
- package/dist/providers/geminiThinking.js +92 -0
- package/dist/providers/geminiThinking.js.map +1 -0
- package/dist/providers/google-genai.js +18 -1
- package/dist/providers/google-genai.js.map +1 -1
- package/dist/providers/groq.js +12 -0
- package/dist/providers/groq.js.map +1 -1
- package/dist/providers/huggingface.d.ts +25 -0
- package/dist/providers/huggingface.js +69 -0
- package/dist/providers/huggingface.js.map +1 -0
- package/dist/providers/modelCatalog.d.ts +109 -0
- package/dist/providers/modelCatalog.js +245 -0
- package/dist/providers/modelCatalog.js.map +1 -0
- package/dist/providers/modelDiscovery.d.ts +99 -5
- package/dist/providers/modelDiscovery.js +191 -35
- package/dist/providers/modelDiscovery.js.map +1 -1
- package/dist/providers/ollama.d.ts +18 -4
- package/dist/providers/ollama.js +67 -37
- package/dist/providers/ollama.js.map +1 -1
- package/dist/providers/openai.js +34 -0
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/openrouter.d.ts +26 -4
- package/dist/providers/openrouter.js +83 -26
- package/dist/providers/openrouter.js.map +1 -1
- package/dist/providers/vertexai.js +19 -1
- package/dist/providers/vertexai.js.map +1 -1
- package/dist/providers/xai.js +20 -0
- package/dist/providers/xai.js.map +1 -1
- package/dist/runtime/askStructured.d.ts +105 -0
- package/dist/runtime/askStructured.js +120 -0
- package/dist/runtime/askStructured.js.map +1 -0
- package/dist/runtime/conversation.d.ts +64 -0
- package/dist/runtime/conversation.js +171 -0
- package/dist/runtime/conversation.js.map +1 -0
- package/dist/runtime/singleShot.d.ts +37 -6
- package/dist/runtime/singleShot.js +113 -67
- package/dist/runtime/singleShot.js.map +1 -1
- package/dist/runtime/structuredOutput.d.ts +104 -0
- package/dist/runtime/structuredOutput.js +393 -0
- package/dist/runtime/structuredOutput.js.map +1 -0
- package/dist/utils/ProgressIndicator.d.ts +21 -0
- package/dist/utils/ProgressIndicator.js +30 -3
- package/dist/utils/ProgressIndicator.js.map +1 -1
- package/dist/utils/aiignoreUtils.js.map +1 -1
- package/dist/utils/binaryOutputUtils.js.map +1 -1
- package/dist/utils/consoleUtils.d.ts +95 -0
- package/dist/utils/consoleUtils.js +112 -2
- package/dist/utils/consoleUtils.js.map +1 -1
- package/dist/utils/crashHandler.d.ts +87 -0
- package/dist/utils/crashHandler.js +128 -0
- package/dist/utils/crashHandler.js.map +1 -0
- package/dist/utils/debugDump.d.ts +134 -0
- package/dist/utils/debugDump.js +381 -0
- package/dist/utils/debugDump.js.map +1 -0
- package/dist/utils/debugUtils.d.ts +13 -4
- package/dist/utils/debugUtils.js +36 -13
- package/dist/utils/debugUtils.js.map +1 -1
- package/dist/utils/displayWidth.d.ts +53 -0
- package/dist/utils/displayWidth.js +195 -0
- package/dist/utils/displayWidth.js.map +1 -0
- package/dist/utils/fileUtils.js.map +1 -1
- package/dist/utils/globalConfigUtils.d.ts +14 -2
- package/dist/utils/globalConfigUtils.js +22 -4
- package/dist/utils/globalConfigUtils.js.map +1 -1
- package/dist/utils/llmUtils.d.ts +39 -8
- package/dist/utils/llmUtils.js +76 -8
- package/dist/utils/llmUtils.js.map +1 -1
- package/dist/utils/redactSecrets.d.ts +63 -0
- package/dist/utils/redactSecrets.js +286 -0
- package/dist/utils/redactSecrets.js.map +1 -0
- package/dist/utils/systemPromptNotes.d.ts +222 -0
- package/dist/utils/systemPromptNotes.js +338 -0
- package/dist/utils/systemPromptNotes.js.map +1 -0
- package/dist/utils/systemUtils.d.ts +18 -1
- package/dist/utils/systemUtils.js +38 -3
- package/dist/utils/systemUtils.js.map +1 -1
- package/dist/utils/toolMatching.d.ts +30 -0
- package/dist/utils/toolMatching.js +44 -0
- package/dist/utils/toolMatching.js.map +1 -0
- package/dist/utils/untrustedText.d.ts +86 -0
- package/dist/utils/untrustedText.js +101 -0
- package/dist/utils/untrustedText.js.map +1 -0
- package/package.json +21 -7
- package/schema/gsloth-config.schema.json +1921 -326
- package/dist/core/shell/allowlist.d.ts +0 -75
- package/dist/core/shell/allowlist.js +0 -187
- package/dist/core/shell/allowlist.js.map +0 -1
- package/dist/core/shell/judge.d.ts +0 -161
- package/dist/core/shell/judge.js +0 -261
- package/dist/core/shell/judge.js.map +0 -1
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
export declare const HISTORY_DB_FILENAME = "history.db";
|
|
3
3
|
/** A single persisted session record (all analytics fields optional; populated when available). */
|
|
4
4
|
export interface SessionRecord {
|
|
5
|
+
/**
|
|
6
|
+
* GS2-19 — the parent conversation this turn belongs to. When omitted, {@link HistoryStore.record}
|
|
7
|
+
* opens a fresh single-turn conversation for the row (so a bare single-shot run = a 1-turn
|
|
8
|
+
* conversation). Interactive sessions {@link HistoryStore.openConversation | open} one conversation
|
|
9
|
+
* up-front and pass its id here on every turn, grouping the whole chat under one conversation.
|
|
10
|
+
*/
|
|
11
|
+
conversationId?: number;
|
|
5
12
|
/** ISO-8601 timestamp; defaults to now when omitted. */
|
|
6
13
|
ts?: string;
|
|
7
14
|
/** Project / working directory the run happened in. */
|
|
@@ -32,6 +39,41 @@ export interface SessionSearchResult extends SessionRecord {
|
|
|
32
39
|
/** FTS5 snippet around the match (may be empty). */
|
|
33
40
|
snippet: string;
|
|
34
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* GS2-19 — metadata for a conversation (a group of turns). Passed to
|
|
44
|
+
* {@link HistoryStore.openConversation} at interactive-session start.
|
|
45
|
+
*/
|
|
46
|
+
export interface ConversationMeta {
|
|
47
|
+
/** ISO-8601 start timestamp; defaults to now when omitted. */
|
|
48
|
+
ts?: string;
|
|
49
|
+
/** Project / working directory the conversation happened in. */
|
|
50
|
+
project?: string;
|
|
51
|
+
/** Originating command (chat/code/ask/exec/…). */
|
|
52
|
+
command?: string;
|
|
53
|
+
/** Human-readable model/provider label. */
|
|
54
|
+
model?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* GS2-19 — a conversation-grained listing row: the conversation's metadata plus the aggregate of
|
|
58
|
+
* its turns (how many, the timespan they cover, and a preview of the last one). This is the
|
|
59
|
+
* top-level unit `gth history list` shows, in place of isolated per-turn rows.
|
|
60
|
+
*/
|
|
61
|
+
export interface ConversationSummary {
|
|
62
|
+
id: number;
|
|
63
|
+
/** When the conversation was opened. */
|
|
64
|
+
startedTs: string;
|
|
65
|
+
project?: string;
|
|
66
|
+
command?: string;
|
|
67
|
+
model?: string;
|
|
68
|
+
/** Number of turns recorded under this conversation (0 for a conversation with no turns). */
|
|
69
|
+
turnCount: number;
|
|
70
|
+
/** Timestamp of the first / last turn, when any turns exist. */
|
|
71
|
+
firstTs?: string;
|
|
72
|
+
lastTs?: string;
|
|
73
|
+
/** Prompt / response of the most recent turn (a one-line preview source). */
|
|
74
|
+
lastPrompt?: string;
|
|
75
|
+
lastResponse?: string;
|
|
76
|
+
}
|
|
35
77
|
/** Aggregate analytics over the whole store (local only). */
|
|
36
78
|
export interface HistoryInsights {
|
|
37
79
|
sessionCount: number;
|
|
@@ -85,6 +127,25 @@ export declare class HistoryStore {
|
|
|
85
127
|
*/
|
|
86
128
|
static open(dbPath: string, options?: OpenHistoryStoreOptions): HistoryStore | null;
|
|
87
129
|
private initSchema;
|
|
130
|
+
/**
|
|
131
|
+
* GS2-19 — in-place, idempotent upgrade of a pre-existing GS2-7 DB (flat `sessions` rows, no
|
|
132
|
+
* grouping) to the conversation-grained model. Runs on every open (including read-only `list` /
|
|
133
|
+
* `search` opens, which open the file read-write): it adds the `conversation_id` column if an
|
|
134
|
+
* older `sessions` table lacks it, then back-fills each ungrouped turn into its own 1-turn
|
|
135
|
+
* conversation. After the first pass there are no ungrouped rows, so it is a cheap no-op.
|
|
136
|
+
*
|
|
137
|
+
* Fully fail-soft: a migration hiccup is swallowed here rather than nulling the store, so reads
|
|
138
|
+
* still work against whatever is already there and new turns just fall back to fresh 1-turn
|
|
139
|
+
* conversations. Never throws.
|
|
140
|
+
*/
|
|
141
|
+
private migrate;
|
|
142
|
+
/**
|
|
143
|
+
* GS2-19 — open a new conversation and return its id (or `null` on any error). Interactive
|
|
144
|
+
* sessions call this once at start, then pass the id on every {@link record} so all the session's
|
|
145
|
+
* turns group under it. A single-shot run does not need this: {@link record} opens a 1-turn
|
|
146
|
+
* conversation itself when no `conversationId` is supplied.
|
|
147
|
+
*/
|
|
148
|
+
openConversation(meta?: ConversationMeta): number | null;
|
|
88
149
|
/**
|
|
89
150
|
* Persist one session and its full-text index entry. Returns the new row id, or `null` on any
|
|
90
151
|
* error (the run continues regardless). The two inserts run in a transaction so a failure can't
|
|
@@ -99,6 +160,22 @@ export declare class HistoryStore {
|
|
|
99
160
|
search(query: string, limit?: number): SessionSearchResult[];
|
|
100
161
|
/** Most recent sessions, newest first. Fail-soft ([] on error). */
|
|
101
162
|
listRecent(limit?: number): SessionSearchResult[];
|
|
163
|
+
/**
|
|
164
|
+
* GS2-19 — conversations newest-first, each with its turn count, timespan, and a preview of the
|
|
165
|
+
* last turn. This is the top-level unit for `gth history list` (the turn-grained {@link listRecent}
|
|
166
|
+
* remains for callers that want raw turns). Fail-soft ([] on error).
|
|
167
|
+
*
|
|
168
|
+
* Empty conversations are **excluded** (`HAVING COUNT(s.id) > 0`): a session opens its conversation
|
|
169
|
+
* at start (before any turn), so one that exits with zero turns would otherwise show as a
|
|
170
|
+
* contentless `turnCount: 0` row. The LEFT JOIN still keeps every conversation that has ≥1 turn —
|
|
171
|
+
* including back-filled 1-turn conversations, whose single turn satisfies the HAVING.
|
|
172
|
+
*/
|
|
173
|
+
listConversations(limit?: number): ConversationSummary[];
|
|
174
|
+
/**
|
|
175
|
+
* GS2-19 — all turns of one conversation in chronological (insert) order, so a search hit can be
|
|
176
|
+
* expanded into the whole thread it belonged to. Fail-soft ([] on error / unknown id).
|
|
177
|
+
*/
|
|
178
|
+
getConversationThread(conversationId: number): SessionRecord[];
|
|
102
179
|
/**
|
|
103
180
|
* Aggregate token/cost totals, a top-tool tally, and a per-command breakdown over the whole
|
|
104
181
|
* store. Tool tallying reads each row's JSON `tools` array in JS (robust to nulls). Fail-soft:
|
|
@@ -62,18 +62,44 @@ export class HistoryStore {
|
|
|
62
62
|
if (!create && dbPath !== ':memory:' && !existsSync(dbPath)) {
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
|
+
let db;
|
|
65
66
|
try {
|
|
66
|
-
|
|
67
|
+
db = new DatabaseSync(dbPath);
|
|
67
68
|
const store = new HistoryStore(db);
|
|
68
69
|
store.initSchema();
|
|
69
70
|
return store;
|
|
70
71
|
}
|
|
71
72
|
catch {
|
|
73
|
+
// GS2-42: initSchema() (or the DatabaseSync constructor itself) can throw after the OS-level
|
|
74
|
+
// file handle is already open (e.g. a corrupt/garbage DB file — SQLite doesn't validate the
|
|
75
|
+
// file header until the first statement executes). Fail-soft-close it here before returning
|
|
76
|
+
// null, mirroring close()'s own try/catch, since on win32 an unclosed handle blocks the file
|
|
77
|
+
// from being deleted/replaced/reopened until the process exits (POSIX allows unlinking an
|
|
78
|
+
// open fd, which is why this leak was invisible there).
|
|
79
|
+
try {
|
|
80
|
+
db?.close();
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
/* ignore: db may already be in a broken state */
|
|
84
|
+
}
|
|
72
85
|
return null;
|
|
73
86
|
}
|
|
74
87
|
}
|
|
75
88
|
initSchema() {
|
|
89
|
+
// GS2-19: the `sessions` table is turn-grained (its rows are prompt→response turns, despite the
|
|
90
|
+
// name). A `conversations` table groups the turns of one interactive session; each turn carries
|
|
91
|
+
// a `conversation_id`. `conversation_id` is a plain INTEGER join key, not an enforced FK — SQLite
|
|
92
|
+
// leaves `foreign_keys` off by default and `ALTER TABLE ADD COLUMN` can't add a REFERENCES clause,
|
|
93
|
+
// so declaring one here would only make the fresh schema drift from the migrated one. The column
|
|
94
|
+
// definition is kept byte-identical between this fresh path and {@link migrate}'s ALTER.
|
|
76
95
|
this.db.exec(`
|
|
96
|
+
CREATE TABLE IF NOT EXISTS conversations (
|
|
97
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
98
|
+
started_ts TEXT NOT NULL,
|
|
99
|
+
project TEXT,
|
|
100
|
+
command TEXT,
|
|
101
|
+
model TEXT
|
|
102
|
+
);
|
|
77
103
|
CREATE TABLE IF NOT EXISTS sessions (
|
|
78
104
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
79
105
|
ts TEXT NOT NULL,
|
|
@@ -86,12 +112,77 @@ export class HistoryStore {
|
|
|
86
112
|
tokens_output INTEGER,
|
|
87
113
|
cost_usd REAL,
|
|
88
114
|
tools TEXT,
|
|
89
|
-
duration_ms INTEGER
|
|
115
|
+
duration_ms INTEGER,
|
|
116
|
+
conversation_id INTEGER
|
|
90
117
|
);
|
|
91
118
|
CREATE VIRTUAL TABLE IF NOT EXISTS sessions_fts USING fts5(
|
|
92
119
|
prompt, response, command, project
|
|
93
120
|
);
|
|
94
121
|
`);
|
|
122
|
+
this.migrate();
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* GS2-19 — in-place, idempotent upgrade of a pre-existing GS2-7 DB (flat `sessions` rows, no
|
|
126
|
+
* grouping) to the conversation-grained model. Runs on every open (including read-only `list` /
|
|
127
|
+
* `search` opens, which open the file read-write): it adds the `conversation_id` column if an
|
|
128
|
+
* older `sessions` table lacks it, then back-fills each ungrouped turn into its own 1-turn
|
|
129
|
+
* conversation. After the first pass there are no ungrouped rows, so it is a cheap no-op.
|
|
130
|
+
*
|
|
131
|
+
* Fully fail-soft: a migration hiccup is swallowed here rather than nulling the store, so reads
|
|
132
|
+
* still work against whatever is already there and new turns just fall back to fresh 1-turn
|
|
133
|
+
* conversations. Never throws.
|
|
134
|
+
*/
|
|
135
|
+
migrate() {
|
|
136
|
+
try {
|
|
137
|
+
const cols = this.db.prepare(`PRAGMA table_info(sessions)`).all();
|
|
138
|
+
const hasConversationId = cols.some((c) => c.name === 'conversation_id');
|
|
139
|
+
if (!hasConversationId) {
|
|
140
|
+
this.db.exec(`ALTER TABLE sessions ADD COLUMN conversation_id INTEGER`);
|
|
141
|
+
}
|
|
142
|
+
const orphans = this.db
|
|
143
|
+
.prepare(`SELECT id, ts, project, command, model
|
|
144
|
+
FROM sessions
|
|
145
|
+
WHERE conversation_id IS NULL
|
|
146
|
+
ORDER BY id`)
|
|
147
|
+
.all();
|
|
148
|
+
if (orphans.length === 0)
|
|
149
|
+
return;
|
|
150
|
+
this.db.exec('BEGIN');
|
|
151
|
+
try {
|
|
152
|
+
const insertConversation = this.db.prepare(`INSERT INTO conversations (started_ts, project, command, model) VALUES (?, ?, ?, ?)`);
|
|
153
|
+
const stampTurn = this.db.prepare(`UPDATE sessions SET conversation_id = ? WHERE id = ?`);
|
|
154
|
+
for (const row of orphans) {
|
|
155
|
+
const info = insertConversation.run(row.ts != null ? String(row.ts) : new Date().toISOString(), row.project != null ? String(row.project) : null, row.command != null ? String(row.command) : null, row.model != null ? String(row.model) : null);
|
|
156
|
+
stampTurn.run(Number(info.lastInsertRowid), Number(row.id));
|
|
157
|
+
}
|
|
158
|
+
this.db.exec('COMMIT');
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
this.db.exec('ROLLBACK');
|
|
162
|
+
throw e;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
/* fail-soft: a migration failure must not break opening the store or a run */
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* GS2-19 — open a new conversation and return its id (or `null` on any error). Interactive
|
|
171
|
+
* sessions call this once at start, then pass the id on every {@link record} so all the session's
|
|
172
|
+
* turns group under it. A single-shot run does not need this: {@link record} opens a 1-turn
|
|
173
|
+
* conversation itself when no `conversationId` is supplied.
|
|
174
|
+
*/
|
|
175
|
+
openConversation(meta = {}) {
|
|
176
|
+
try {
|
|
177
|
+
const ts = meta.ts ?? new Date().toISOString();
|
|
178
|
+
const info = this.db
|
|
179
|
+
.prepare(`INSERT INTO conversations (started_ts, project, command, model) VALUES (?, ?, ?, ?)`)
|
|
180
|
+
.run(ts, meta.project ?? null, meta.command ?? null, meta.model ?? null);
|
|
181
|
+
return Number(info.lastInsertRowid);
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
95
186
|
}
|
|
96
187
|
/**
|
|
97
188
|
* Persist one session and its full-text index entry. Returns the new row id, or `null` on any
|
|
@@ -104,11 +195,21 @@ export class HistoryStore {
|
|
|
104
195
|
const tools = rec.tools && rec.tools.length > 0 ? JSON.stringify(rec.tools) : null;
|
|
105
196
|
this.db.exec('BEGIN');
|
|
106
197
|
try {
|
|
198
|
+
// GS2-19: every turn belongs to a conversation. When the caller opened one up-front
|
|
199
|
+
// (interactive sessions), stamp it; otherwise open a fresh 1-turn conversation for this row
|
|
200
|
+
// (single-shot runs / bare record() calls) so the turn is never left ungrouped.
|
|
201
|
+
let conversationId = rec.conversationId ?? null;
|
|
202
|
+
if (conversationId == null) {
|
|
203
|
+
const cinfo = this.db
|
|
204
|
+
.prepare(`INSERT INTO conversations (started_ts, project, command, model) VALUES (?, ?, ?, ?)`)
|
|
205
|
+
.run(ts, rec.project ?? null, rec.command ?? null, rec.model ?? null);
|
|
206
|
+
conversationId = Number(cinfo.lastInsertRowid);
|
|
207
|
+
}
|
|
107
208
|
const insert = this.db.prepare(`INSERT INTO sessions
|
|
108
209
|
(ts, project, command, model, prompt, response,
|
|
109
|
-
tokens_input, tokens_output, cost_usd, tools, duration_ms)
|
|
110
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);
|
|
111
|
-
const info = insert.run(ts, rec.project ?? null, rec.command ?? null, rec.model ?? null, rec.prompt ?? null, rec.response ?? null, rec.tokensInput ?? null, rec.tokensOutput ?? null, rec.costUsd ?? null, tools, rec.durationMs ?? null);
|
|
210
|
+
tokens_input, tokens_output, cost_usd, tools, duration_ms, conversation_id)
|
|
211
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);
|
|
212
|
+
const info = insert.run(ts, rec.project ?? null, rec.command ?? null, rec.model ?? null, rec.prompt ?? null, rec.response ?? null, rec.tokensInput ?? null, rec.tokensOutput ?? null, rec.costUsd ?? null, tools, rec.durationMs ?? null, conversationId);
|
|
112
213
|
const id = Number(info.lastInsertRowid);
|
|
113
214
|
this.db
|
|
114
215
|
.prepare(`INSERT INTO sessions_fts (rowid, prompt, response, command, project)
|
|
@@ -141,6 +242,7 @@ export class HistoryStore {
|
|
|
141
242
|
s.model AS model, s.prompt AS prompt, s.response AS response,
|
|
142
243
|
s.tokens_input AS tokens_input, s.tokens_output AS tokens_output,
|
|
143
244
|
s.cost_usd AS cost_usd, s.tools AS tools, s.duration_ms AS duration_ms,
|
|
245
|
+
s.conversation_id AS conversation_id,
|
|
144
246
|
snippet(sessions_fts, 0, '[', ']', '…', 12) AS snippet
|
|
145
247
|
FROM sessions_fts f
|
|
146
248
|
JOIN sessions s ON s.id = f.rowid
|
|
@@ -164,7 +266,7 @@ export class HistoryStore {
|
|
|
164
266
|
try {
|
|
165
267
|
const rows = this.db
|
|
166
268
|
.prepare(`SELECT id, ts, project, command, model, prompt, response,
|
|
167
|
-
tokens_input, tokens_output, cost_usd, tools, duration_ms
|
|
269
|
+
tokens_input, tokens_output, cost_usd, tools, duration_ms, conversation_id
|
|
168
270
|
FROM sessions
|
|
169
271
|
ORDER BY id DESC
|
|
170
272
|
LIMIT ?`)
|
|
@@ -180,6 +282,70 @@ export class HistoryStore {
|
|
|
180
282
|
return [];
|
|
181
283
|
}
|
|
182
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* GS2-19 — conversations newest-first, each with its turn count, timespan, and a preview of the
|
|
287
|
+
* last turn. This is the top-level unit for `gth history list` (the turn-grained {@link listRecent}
|
|
288
|
+
* remains for callers that want raw turns). Fail-soft ([] on error).
|
|
289
|
+
*
|
|
290
|
+
* Empty conversations are **excluded** (`HAVING COUNT(s.id) > 0`): a session opens its conversation
|
|
291
|
+
* at start (before any turn), so one that exits with zero turns would otherwise show as a
|
|
292
|
+
* contentless `turnCount: 0` row. The LEFT JOIN still keeps every conversation that has ≥1 turn —
|
|
293
|
+
* including back-filled 1-turn conversations, whose single turn satisfies the HAVING.
|
|
294
|
+
*/
|
|
295
|
+
listConversations(limit = 20) {
|
|
296
|
+
try {
|
|
297
|
+
const rows = this.db
|
|
298
|
+
.prepare(`SELECT c.id AS id, c.started_ts AS started_ts, c.project AS project,
|
|
299
|
+
c.command AS command, c.model AS model,
|
|
300
|
+
COUNT(s.id) AS turn_count, MIN(s.ts) AS first_ts, MAX(s.ts) AS last_ts
|
|
301
|
+
FROM conversations c
|
|
302
|
+
LEFT JOIN sessions s ON s.conversation_id = c.id
|
|
303
|
+
GROUP BY c.id
|
|
304
|
+
HAVING COUNT(s.id) > 0
|
|
305
|
+
ORDER BY c.id DESC
|
|
306
|
+
LIMIT ?`)
|
|
307
|
+
.all(limit);
|
|
308
|
+
const lastTurn = this.db.prepare(`SELECT prompt, response FROM sessions
|
|
309
|
+
WHERE conversation_id = ? ORDER BY id DESC LIMIT 1`);
|
|
310
|
+
return rows.map((r) => {
|
|
311
|
+
const last = lastTurn.get(Number(r.id));
|
|
312
|
+
return {
|
|
313
|
+
id: Number(r.id),
|
|
314
|
+
startedTs: String(r.started_ts),
|
|
315
|
+
project: r.project != null ? String(r.project) : undefined,
|
|
316
|
+
command: r.command != null ? String(r.command) : undefined,
|
|
317
|
+
model: r.model != null ? String(r.model) : undefined,
|
|
318
|
+
turnCount: Number(r.turn_count ?? 0),
|
|
319
|
+
firstTs: r.first_ts != null ? String(r.first_ts) : undefined,
|
|
320
|
+
lastTs: r.last_ts != null ? String(r.last_ts) : undefined,
|
|
321
|
+
lastPrompt: last?.prompt != null ? String(last.prompt) : undefined,
|
|
322
|
+
lastResponse: last?.response != null ? String(last.response) : undefined,
|
|
323
|
+
};
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
catch {
|
|
327
|
+
return [];
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* GS2-19 — all turns of one conversation in chronological (insert) order, so a search hit can be
|
|
332
|
+
* expanded into the whole thread it belonged to. Fail-soft ([] on error / unknown id).
|
|
333
|
+
*/
|
|
334
|
+
getConversationThread(conversationId) {
|
|
335
|
+
try {
|
|
336
|
+
const rows = this.db
|
|
337
|
+
.prepare(`SELECT id, ts, project, command, model, prompt, response,
|
|
338
|
+
tokens_input, tokens_output, cost_usd, tools, duration_ms, conversation_id
|
|
339
|
+
FROM sessions
|
|
340
|
+
WHERE conversation_id = ?
|
|
341
|
+
ORDER BY id ASC`)
|
|
342
|
+
.all(conversationId);
|
|
343
|
+
return rows.map((r) => rowToRecord(r));
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
return [];
|
|
347
|
+
}
|
|
348
|
+
}
|
|
183
349
|
/**
|
|
184
350
|
* Aggregate token/cost totals, a top-tool tally, and a per-command breakdown over the whole
|
|
185
351
|
* store. Tool tallying reads each row's JSON `tools` array in JS (robust to nulls). Fail-soft:
|
|
@@ -281,6 +447,7 @@ function rowToRecord(r) {
|
|
|
281
447
|
}
|
|
282
448
|
}
|
|
283
449
|
return {
|
|
450
|
+
conversationId: r.conversation_id != null ? Number(r.conversation_id) : undefined,
|
|
284
451
|
ts: r.ts != null ? String(r.ts) : undefined,
|
|
285
452
|
project: r.project != null ? String(r.project) : undefined,
|
|
286
453
|
command: r.command != null ? String(r.command) : undefined,
|
|
@@ -1 +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,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAE5F,4DAA4D;AAC5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,YAAY,CAAC;AA6DhD,wEAAwE;AACxE,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC;AAC9C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACnC,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,OAAO,YAAY;IACf,EAAE,CAAe;IAEzB,YAAoB,EAAgB;QAClC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,MAAc,EAAE,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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"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - even with history **on**, a DB problem (locked/corrupt/read-only fs) can never abort or alter
|
|
10
10
|
* the run: the worst case is that one session isn't recorded.
|
|
11
11
|
*/
|
|
12
|
-
import type { SessionRecord } from '#src/history/historyStore.js';
|
|
12
|
+
import type { ConversationMeta, SessionRecord } from '#src/history/historyStore.js';
|
|
13
13
|
/** The subset of the resolved config the recorder reads (structural, to avoid a hard type dep). */
|
|
14
14
|
export interface HistoryConfigView {
|
|
15
15
|
history?: {
|
|
@@ -26,3 +26,12 @@ export interface HistoryConfigView {
|
|
|
26
26
|
* (or after a run) without a try/catch of their own.
|
|
27
27
|
*/
|
|
28
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;
|
|
@@ -26,4 +26,31 @@ export function recordSessionSafe(config, record) {
|
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
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
|
+
}
|
|
29
56
|
//# sourceMappingURL=recordSession.js.map
|
|
@@ -1 +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"}
|
|
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,IA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|
import { buildInitConfigContent, getCuratedFallbackModel } from '#src/providers/modelDiscovery.js';
|
|
4
|
+
import { NATIVE_CLIENT_REASON, warnUnusedConfiguration, } from '#src/providers/configurationPassthrough.js';
|
|
4
5
|
import { env } from '#src/utils/systemUtils.js';
|
|
5
6
|
/**
|
|
6
7
|
* Function to process JSON config and create Anthropic LLM instance
|
|
@@ -10,6 +11,17 @@ export async function processJsonConfig(llmConfig) {
|
|
|
10
11
|
const anthropic = await import('@langchain/anthropic');
|
|
11
12
|
// Use config value if available, otherwise use the environment variable
|
|
12
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
|
+
});
|
|
13
25
|
return new anthropic.ChatAnthropic({
|
|
14
26
|
...llmConfig,
|
|
15
27
|
apiKey: anthropicApiKey,
|
|
@@ -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,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AACnG,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAOhD;;GAE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UAAU,iBAAiB,CACrC,SAA+C;IAE/C,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;IACvD,wEAAwE;IACxE,MAAM,eAAe,GAAG,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,iBAAiB,CAAC;IAClE,+FAA+F;IAC/F,gEAAgE;IAChE,uBAAuB,CAAC;QACtB,QAAQ,EAAE,WAAW;QACrB,aAAa,EAAG,SAAyC,CAAC,aAAa;QACvE,aAAa,EAAE,EAAE;QACjB,MAAM,EAAE,oBAAoB;QAC5B,QAAQ,EACN,4FAA4F;YAC5F,wFAAwF;YACxF,iDAAiD;KACpD,CAAC,CAAC;IACH,OAAO,IAAI,SAAS,CAAC,aAAa,CAAC;QACjC,GAAG,SAAS;QACZ,MAAM,EAAE,eAAe;QACvB,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,uBAAuB,CAAC,WAAW,CAAC;KAC/D,CAAC,CAAC;AACL,CAAC;AAED,qCAAqC;AACrC,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,WAAW,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;
|