@dirgha/code 1.13.2 → 1.14.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/dist/cli/flags.js +15 -14
- package/dist/cli/flags.js.map +1 -1
- package/dist/cli/main.js +232 -124
- package/dist/cli/main.js.map +1 -1
- package/dist/tui/ink/App.d.ts +10 -10
- package/dist/tui/ink/App.js +358 -236
- package/dist/tui/ink/App.js.map +1 -1
- package/dist/tui/ink/components/InputBox.d.ts +4 -2
- package/dist/tui/ink/components/InputBox.js +66 -31
- package/dist/tui/ink/components/InputBox.js.map +1 -1
- package/package.json +1 -1
package/dist/tui/ink/App.js
CHANGED
|
@@ -14,58 +14,58 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
* overlay state lives in `use-overlays.ts`. This component stays
|
|
15
15
|
* focused on layout and lifecycle.
|
|
16
16
|
*/
|
|
17
|
-
import * as React from
|
|
18
|
-
import { Box, Static, Text, useApp, useInput } from
|
|
19
|
-
import { randomUUID } from
|
|
20
|
-
import { appendAudit } from
|
|
21
|
-
import { maybeCompact } from
|
|
22
|
-
import { contextWindowFor } from
|
|
23
|
-
import { buildAgentHooksFromConfig } from
|
|
24
|
-
import { loadProjectPrimer, composeSystemPrompt } from
|
|
25
|
-
import { probeGitState, renderGitState } from
|
|
26
|
-
import { loadSoul } from
|
|
27
|
-
import { modePreamble } from
|
|
28
|
-
import { runAgentLoop } from
|
|
29
|
-
import { createErrorClassifier } from
|
|
30
|
-
import { createToolExecutor } from
|
|
31
|
-
import { createInkApprovalBus } from
|
|
32
|
-
import { ApprovalPrompt } from
|
|
33
|
-
import { PRICES } from
|
|
34
|
-
import { Logo } from
|
|
35
|
-
import { StatusBar } from
|
|
36
|
-
import { StreamingText } from
|
|
37
|
-
import { ThinkingBlock } from
|
|
38
|
-
import { ToolBox } from
|
|
39
|
-
import { ToolGroup } from
|
|
40
|
-
import { InputBox } from
|
|
41
|
-
import { PromptQueueIndicator } from
|
|
42
|
-
import { ModelPicker } from
|
|
43
|
-
import { ModelSwitchPrompt } from
|
|
44
|
-
import { ProviderPicker } from
|
|
45
|
-
import { HelpOverlay } from
|
|
46
|
-
import { KeySetOverlay } from
|
|
47
|
-
import { saveKey } from
|
|
48
|
-
import { AtFileComplete } from
|
|
49
|
-
import { SlashComplete } from
|
|
50
|
-
import { ThemePicker } from
|
|
51
|
-
import { ThemeProvider } from
|
|
52
|
-
import { writeFile, mkdir, readFile } from
|
|
53
|
-
import { homedir } from
|
|
54
|
-
import { join as pathJoin } from
|
|
55
|
-
import { useEventProjection } from
|
|
56
|
-
import { useOverlays } from
|
|
57
|
-
import { createRequire } from
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import { Box, Static, Text, useApp, useInput } from "ink";
|
|
19
|
+
import { randomUUID } from "node:crypto";
|
|
20
|
+
import { appendAudit } from "../../audit/writer.js";
|
|
21
|
+
import { maybeCompact } from "../../context/compaction.js";
|
|
22
|
+
import { contextWindowFor } from "../../intelligence/prices.js";
|
|
23
|
+
import { buildAgentHooksFromConfig } from "../../hooks/config-bridge.js";
|
|
24
|
+
import { loadProjectPrimer, composeSystemPrompt, } from "../../context/primer.js";
|
|
25
|
+
import { probeGitState, renderGitState } from "../../context/git-state.js";
|
|
26
|
+
import { loadSoul } from "../../context/soul.js";
|
|
27
|
+
import { modePreamble } from "../../context/mode.js";
|
|
28
|
+
import { runAgentLoop } from "../../kernel/agent-loop.js";
|
|
29
|
+
import { createErrorClassifier } from "../../intelligence/error-classifier.js";
|
|
30
|
+
import { createToolExecutor } from "../../tools/exec.js";
|
|
31
|
+
import { createInkApprovalBus, } from "./ink-approval-bus.js";
|
|
32
|
+
import { ApprovalPrompt, } from "./components/ApprovalPrompt.js";
|
|
33
|
+
import { PRICES } from "../../intelligence/prices.js";
|
|
34
|
+
import { Logo } from "./components/Logo.js";
|
|
35
|
+
import { StatusBar } from "./components/StatusBar.js";
|
|
36
|
+
import { StreamingText } from "./components/StreamingText.js";
|
|
37
|
+
import { ThinkingBlock } from "./components/ThinkingBlock.js";
|
|
38
|
+
import { ToolBox } from "./components/ToolBox.js";
|
|
39
|
+
import { ToolGroup } from "./components/ToolGroup.js";
|
|
40
|
+
import { InputBox } from "./components/InputBox.js";
|
|
41
|
+
import { PromptQueueIndicator } from "./components/PromptQueueIndicator.js";
|
|
42
|
+
import { ModelPicker } from "./components/ModelPicker.js";
|
|
43
|
+
import { ModelSwitchPrompt } from "./components/ModelSwitchPrompt.js";
|
|
44
|
+
import { ProviderPicker, } from "./components/ProviderPicker.js";
|
|
45
|
+
import { HelpOverlay, } from "./components/HelpOverlay.js";
|
|
46
|
+
import { KeySetOverlay } from "./components/KeySetOverlay.js";
|
|
47
|
+
import { saveKey } from "../../auth/keystore.js";
|
|
48
|
+
import { AtFileComplete } from "./components/AtFileComplete.js";
|
|
49
|
+
import { SlashComplete } from "./components/SlashComplete.js";
|
|
50
|
+
import { ThemePicker } from "./components/ThemePicker.js";
|
|
51
|
+
import { ThemeProvider } from "./theme-context.js";
|
|
52
|
+
import { writeFile, mkdir, readFile } from "node:fs/promises";
|
|
53
|
+
import { homedir } from "node:os";
|
|
54
|
+
import { join as pathJoin } from "node:path";
|
|
55
|
+
import { useEventProjection, } from "./use-event-projection.js";
|
|
56
|
+
import { useOverlays } from "./use-overlays.js";
|
|
57
|
+
import { createRequire } from "node:module";
|
|
58
58
|
// Pulled from the installed package.json so the TUI title matches the
|
|
59
59
|
// shipped binary version. Falls back to '0.0.0-dev' if the file isn't
|
|
60
60
|
// reachable (e.g. an unusual deploy layout).
|
|
61
61
|
const VERSION = (() => {
|
|
62
62
|
try {
|
|
63
63
|
const req = createRequire(import.meta.url);
|
|
64
|
-
const pkg = req(
|
|
65
|
-
return typeof pkg.version ===
|
|
64
|
+
const pkg = req("../../../package.json");
|
|
65
|
+
return typeof pkg.version === "string" ? pkg.version : "0.0.0-dev";
|
|
66
66
|
}
|
|
67
67
|
catch {
|
|
68
|
-
return
|
|
68
|
+
return "0.0.0-dev";
|
|
69
69
|
}
|
|
70
70
|
})();
|
|
71
71
|
export function App(props) {
|
|
@@ -74,7 +74,7 @@ export function App(props) {
|
|
|
74
74
|
const historyRef = React.useRef(initialHistory(props));
|
|
75
75
|
const abortRef = React.useRef(null);
|
|
76
76
|
const [transcript, setTranscript] = React.useState([]);
|
|
77
|
-
const [input, setInput] = React.useState(
|
|
77
|
+
const [input, setInput] = React.useState("");
|
|
78
78
|
const [busy, setBusy] = React.useState(false);
|
|
79
79
|
// Prompt queue: while a turn is streaming the user can still type and
|
|
80
80
|
// press Enter. Submissions land here instead of being dropped, then
|
|
@@ -87,14 +87,14 @@ export function App(props) {
|
|
|
87
87
|
// Multi-step picker stage. Stage 1 = ProviderPicker (default when
|
|
88
88
|
// overlays.active === 'models'); stage 2 = ModelPicker filtered to
|
|
89
89
|
// the picked provider. Resets to 'provider' on every fresh open.
|
|
90
|
-
const [pickerStage, setPickerStage] = React.useState(
|
|
90
|
+
const [pickerStage, setPickerStage] = React.useState("provider");
|
|
91
91
|
const [pickerProvider, setPickerProvider] = React.useState(null);
|
|
92
92
|
// Pending model-switch prompt — set when the kernel emits an error
|
|
93
93
|
// with a `failoverModel` hint. Cleared when the user answers
|
|
94
94
|
// [y|n|p]. While set, an inline ModelSwitchPrompt renders below
|
|
95
95
|
// the input box; submitting any other prompt also clears it.
|
|
96
96
|
const [pendingFailover, setPendingFailover] = React.useState(null);
|
|
97
|
-
const lastUserPromptRef = React.useRef(
|
|
97
|
+
const lastUserPromptRef = React.useRef("");
|
|
98
98
|
// Approval bus — single instance per App so subscriptions persist across
|
|
99
99
|
// turns. Replaces the legacy `createTuiApprovalBus` that wrote prompts
|
|
100
100
|
// direct to stdout (overdrawn by Ink) and read stdin raw (hung on
|
|
@@ -108,11 +108,11 @@ export function App(props) {
|
|
|
108
108
|
const bus = approvalBusRef.current;
|
|
109
109
|
if (!bus)
|
|
110
110
|
return;
|
|
111
|
-
return bus.subscribe(req => setPendingApproval(req));
|
|
111
|
+
return bus.subscribe((req) => setPendingApproval(req));
|
|
112
112
|
}, []);
|
|
113
113
|
// Mode state: SlashContext.setMode flips it live so /mode plan|act|verify|ask
|
|
114
114
|
// takes effect on the next turn (system-prompt rebuild downstream picks it up).
|
|
115
|
-
const [mode, setMode] = React.useState(props.config.mode ??
|
|
115
|
+
const [mode, setMode] = React.useState(props.config.mode ?? "act");
|
|
116
116
|
const projection = useEventProjection(props.events);
|
|
117
117
|
const overlays = useOverlays();
|
|
118
118
|
// Live counters for the in-progress turn — drive the StatusBar
|
|
@@ -122,22 +122,22 @@ export function App(props) {
|
|
|
122
122
|
const [liveDurationMs, setLiveDurationMs] = React.useState(0);
|
|
123
123
|
const turnStartRef = React.useRef(0);
|
|
124
124
|
React.useEffect(() => {
|
|
125
|
-
const unsub = props.events.subscribe(ev => {
|
|
126
|
-
if (ev.type ===
|
|
125
|
+
const unsub = props.events.subscribe((ev) => {
|
|
126
|
+
if (ev.type === "agent_start") {
|
|
127
127
|
turnStartRef.current = Date.now();
|
|
128
128
|
setLiveOutputTokens(0);
|
|
129
129
|
setLiveDurationMs(0);
|
|
130
130
|
}
|
|
131
|
-
else if (ev.type ===
|
|
131
|
+
else if (ev.type === "text_delta" || ev.type === "thinking_delta") {
|
|
132
132
|
// Approximate output-token count by char/4 — same heuristic
|
|
133
133
|
// the rest of the codebase uses for streaming-side estimates.
|
|
134
134
|
const delta = (ev.delta?.length ?? 0) / 4;
|
|
135
|
-
setLiveOutputTokens(prev => prev + delta);
|
|
135
|
+
setLiveOutputTokens((prev) => prev + delta);
|
|
136
136
|
}
|
|
137
|
-
else if (ev.type ===
|
|
137
|
+
else if (ev.type === "usage") {
|
|
138
138
|
setLiveOutputTokens(ev.outputTokens ?? 0);
|
|
139
139
|
}
|
|
140
|
-
else if (ev.type ===
|
|
140
|
+
else if (ev.type === "agent_end") {
|
|
141
141
|
setLiveDurationMs(0);
|
|
142
142
|
setLiveOutputTokens(0);
|
|
143
143
|
}
|
|
@@ -159,15 +159,33 @@ export function App(props) {
|
|
|
159
159
|
// is empty for the most common surface (the interactive UI). Effect
|
|
160
160
|
// re-installs only if events ref changes (it shouldn't).
|
|
161
161
|
React.useEffect(() => {
|
|
162
|
-
const unsub = props.events.subscribe(ev => {
|
|
163
|
-
if (ev.type ===
|
|
164
|
-
void appendAudit({
|
|
162
|
+
const unsub = props.events.subscribe((ev) => {
|
|
163
|
+
if (ev.type === "tool_exec_end") {
|
|
164
|
+
void appendAudit({
|
|
165
|
+
kind: "tool",
|
|
166
|
+
actor: sessionIdRef.current,
|
|
167
|
+
summary: `${ev.id} ${ev.isError ? "error" : "done"} ${ev.durationMs}ms`,
|
|
168
|
+
toolId: ev.id,
|
|
169
|
+
isError: ev.isError,
|
|
170
|
+
durationMs: ev.durationMs,
|
|
171
|
+
});
|
|
165
172
|
}
|
|
166
|
-
else if (ev.type ===
|
|
167
|
-
void appendAudit({
|
|
173
|
+
else if (ev.type === "agent_end") {
|
|
174
|
+
void appendAudit({
|
|
175
|
+
kind: "turn-end",
|
|
176
|
+
actor: sessionIdRef.current,
|
|
177
|
+
summary: `model=${currentModel} stop=${ev.stopReason} in=${ev.usage.inputTokens} out=${ev.usage.outputTokens}`,
|
|
178
|
+
model: currentModel,
|
|
179
|
+
stopReason: ev.stopReason,
|
|
180
|
+
usage: ev.usage,
|
|
181
|
+
});
|
|
168
182
|
}
|
|
169
|
-
else if (ev.type ===
|
|
170
|
-
void appendAudit({
|
|
183
|
+
else if (ev.type === "error") {
|
|
184
|
+
void appendAudit({
|
|
185
|
+
kind: "error",
|
|
186
|
+
actor: sessionIdRef.current,
|
|
187
|
+
summary: ev.message,
|
|
188
|
+
});
|
|
171
189
|
if (ev.failoverModel) {
|
|
172
190
|
setPendingFailover({
|
|
173
191
|
failedModel: currentModel,
|
|
@@ -190,47 +208,51 @@ export function App(props) {
|
|
|
190
208
|
// typing. The drain-effect below submits queued prompts FIFO once
|
|
191
209
|
// `busy` flips false.
|
|
192
210
|
if (busy) {
|
|
193
|
-
setPromptQueue(q => [...q, value]);
|
|
194
|
-
setInput(
|
|
211
|
+
setPromptQueue((q) => [...q, value]);
|
|
212
|
+
setInput("");
|
|
195
213
|
return;
|
|
196
214
|
}
|
|
197
|
-
setInput(
|
|
215
|
+
setInput("");
|
|
198
216
|
// Remember the last user prompt so we can re-submit it after a
|
|
199
217
|
// failover model swap (D2 — auto-prompt model switch on failure).
|
|
200
218
|
lastUserPromptRef.current = value;
|
|
201
219
|
// A new submission supersedes any pending failover prompt.
|
|
202
220
|
setPendingFailover(null);
|
|
203
|
-
if (value ===
|
|
221
|
+
if (value === "/exit" || value === "/quit") {
|
|
204
222
|
exit();
|
|
205
223
|
return;
|
|
206
224
|
}
|
|
207
|
-
if (value ===
|
|
225
|
+
if (value === "/clear") {
|
|
208
226
|
historyRef.current = initialHistory(props);
|
|
209
227
|
setTranscript([]);
|
|
210
228
|
projection.clear();
|
|
211
229
|
return;
|
|
212
230
|
}
|
|
213
231
|
// `/model` with no args opens the picker; `/model <id>` sets directly.
|
|
214
|
-
if (value ===
|
|
215
|
-
overlays.openOverlay(
|
|
232
|
+
if (value === "/model" || value === "/models") {
|
|
233
|
+
overlays.openOverlay("models");
|
|
216
234
|
return;
|
|
217
235
|
}
|
|
218
|
-
if (value.startsWith(
|
|
219
|
-
const id = value.slice(
|
|
220
|
-
if (id !==
|
|
236
|
+
if (value.startsWith("/model ")) {
|
|
237
|
+
const id = value.slice("/model ".length).trim();
|
|
238
|
+
if (id !== "") {
|
|
221
239
|
setCurrentModel(id);
|
|
222
|
-
const note = {
|
|
223
|
-
|
|
240
|
+
const note = {
|
|
241
|
+
kind: "notice",
|
|
242
|
+
id: randomUUID(),
|
|
243
|
+
text: `Model set to ${id}`,
|
|
244
|
+
};
|
|
245
|
+
setTranscript((prev) => [...prev, note]);
|
|
224
246
|
}
|
|
225
247
|
return;
|
|
226
248
|
}
|
|
227
|
-
if (value ===
|
|
228
|
-
overlays.openOverlay(
|
|
249
|
+
if (value === "/help" || value === "/?") {
|
|
250
|
+
overlays.openOverlay("help");
|
|
229
251
|
return;
|
|
230
252
|
}
|
|
231
253
|
// `/theme` with no args opens the picker; `/theme <name>` sets directly.
|
|
232
|
-
if (value ===
|
|
233
|
-
overlays.openOverlay(
|
|
254
|
+
if (value === "/theme" || value === "/themes") {
|
|
255
|
+
overlays.openOverlay("theme");
|
|
234
256
|
return;
|
|
235
257
|
}
|
|
236
258
|
// Anything else starting with `/` goes through the SlashRegistry — that
|
|
@@ -241,13 +263,17 @@ export function App(props) {
|
|
|
241
263
|
// contract. Without this dispatch, unrecognised slash commands fell
|
|
242
264
|
// through to runTurn() and were sent to the LLM as user prompts —
|
|
243
265
|
// surprising behaviour that S1/2026-04-27 fixes.
|
|
244
|
-
if (value.startsWith(
|
|
266
|
+
if (value.startsWith("/")) {
|
|
245
267
|
const ctx = {
|
|
246
|
-
get model() {
|
|
247
|
-
|
|
268
|
+
get model() {
|
|
269
|
+
return currentModel;
|
|
270
|
+
},
|
|
271
|
+
get sessionId() {
|
|
272
|
+
return sessionIdRef.current;
|
|
273
|
+
},
|
|
248
274
|
setModel: (m) => setCurrentModel(m),
|
|
249
|
-
showHelp: () =>
|
|
250
|
-
compact: async () =>
|
|
275
|
+
showHelp: () => "",
|
|
276
|
+
compact: async () => "(compaction is automatic)",
|
|
251
277
|
clear: () => {
|
|
252
278
|
historyRef.current = initialHistory(props);
|
|
253
279
|
setTranscript([]);
|
|
@@ -255,25 +281,36 @@ export function App(props) {
|
|
|
255
281
|
},
|
|
256
282
|
listSessions: async () => {
|
|
257
283
|
const ids = await props.sessions.list();
|
|
258
|
-
return ids.length === 0
|
|
284
|
+
return ids.length === 0
|
|
285
|
+
? "(no saved sessions)"
|
|
286
|
+
: ids.map((id) => `- ${id}`).join("\n");
|
|
259
287
|
},
|
|
260
288
|
loadSession: async (id) => {
|
|
261
289
|
const s = await props.sessions.open(id);
|
|
262
290
|
return s ? `Loaded ${id}.` : `Session ${id} not found.`;
|
|
263
291
|
},
|
|
264
|
-
listSkills: async () =>
|
|
292
|
+
listSkills: async () => "(run `dirgha skills` for the full list)",
|
|
265
293
|
showCost: () => `model=${currentModel}`,
|
|
266
|
-
exit: (code = 0) => {
|
|
294
|
+
exit: (code = 0) => {
|
|
295
|
+
exit();
|
|
296
|
+
process.exit(code);
|
|
297
|
+
},
|
|
267
298
|
getToken: () => null,
|
|
268
299
|
setToken: () => undefined,
|
|
269
|
-
apiBase: () => process.env[
|
|
270
|
-
|
|
300
|
+
apiBase: () => process.env["DIRGHA_API_BASE"] ??
|
|
301
|
+
process.env["DIRGHA_GATEWAY_URL"] ??
|
|
302
|
+
"https://api.dirgha.ai",
|
|
303
|
+
upgradeUrl: () => process.env["DIRGHA_UPGRADE_URL"] ??
|
|
304
|
+
"https://dirgha.ai/billing/upgrade",
|
|
271
305
|
status: (msg) => {
|
|
272
|
-
setTranscript(prev => [
|
|
306
|
+
setTranscript((prev) => [
|
|
307
|
+
...prev,
|
|
308
|
+
{ kind: "notice", id: randomUUID(), text: msg },
|
|
309
|
+
]);
|
|
273
310
|
},
|
|
274
311
|
getMode: () => mode,
|
|
275
312
|
setMode: (m) => setMode(m),
|
|
276
|
-
getTheme: () =>
|
|
313
|
+
getTheme: () => props.config.theme ?? "readable",
|
|
277
314
|
setTheme: () => undefined,
|
|
278
315
|
getSession: () => null,
|
|
279
316
|
getSessionStore: () => props.sessions,
|
|
@@ -284,30 +321,43 @@ export function App(props) {
|
|
|
284
321
|
try {
|
|
285
322
|
const result = await props.slashRegistry.dispatch(value, ctx);
|
|
286
323
|
if (result.handled) {
|
|
287
|
-
const text = result.output ? String(result.output) :
|
|
288
|
-
setTranscript(prev => [
|
|
324
|
+
const text = result.output ? String(result.output) : "(ok)";
|
|
325
|
+
setTranscript((prev) => [
|
|
326
|
+
...prev,
|
|
327
|
+
{ kind: "notice", id: randomUUID(), text },
|
|
328
|
+
]);
|
|
289
329
|
}
|
|
290
330
|
else {
|
|
291
|
-
setTranscript(prev => [
|
|
292
|
-
|
|
331
|
+
setTranscript((prev) => [
|
|
332
|
+
...prev,
|
|
333
|
+
{
|
|
334
|
+
kind: "notice",
|
|
293
335
|
id: randomUUID(),
|
|
294
|
-
text: `Unknown command: ${value.split(
|
|
295
|
-
}
|
|
336
|
+
text: `Unknown command: ${value.split(" ")[0]}. Type /help for the list.`,
|
|
337
|
+
},
|
|
338
|
+
]);
|
|
296
339
|
}
|
|
297
340
|
}
|
|
298
341
|
catch (err) {
|
|
299
|
-
setTranscript(prev => [
|
|
300
|
-
|
|
342
|
+
setTranscript((prev) => [
|
|
343
|
+
...prev,
|
|
344
|
+
{
|
|
345
|
+
kind: "notice",
|
|
301
346
|
id: randomUUID(),
|
|
302
347
|
text: `[slash error] ${err instanceof Error ? err.message : String(err)}`,
|
|
303
|
-
}
|
|
348
|
+
},
|
|
349
|
+
]);
|
|
304
350
|
}
|
|
305
351
|
})();
|
|
306
352
|
return;
|
|
307
353
|
}
|
|
308
|
-
const userItem = {
|
|
309
|
-
|
|
310
|
-
|
|
354
|
+
const userItem = {
|
|
355
|
+
kind: "user",
|
|
356
|
+
id: randomUUID(),
|
|
357
|
+
text: value,
|
|
358
|
+
};
|
|
359
|
+
setTranscript((prev) => [...prev, userItem]);
|
|
360
|
+
historyRef.current.push({ role: "user", content: value });
|
|
311
361
|
void runTurn();
|
|
312
362
|
}, [busy, exit, props, projection, overlays]);
|
|
313
363
|
const runTurn = async () => {
|
|
@@ -354,16 +404,23 @@ export function App(props) {
|
|
|
354
404
|
const msg = err instanceof Error ? err.message : String(err);
|
|
355
405
|
const keyMatch = /^([A-Z][A-Z0-9_]+_API_KEY) is required/.exec(msg);
|
|
356
406
|
if (keyMatch?.[1]) {
|
|
357
|
-
setPendingKey({
|
|
407
|
+
setPendingKey({
|
|
408
|
+
keyName: keyMatch[1],
|
|
409
|
+
retryInput: lastUserPromptRef.current,
|
|
410
|
+
});
|
|
358
411
|
}
|
|
359
412
|
else {
|
|
360
|
-
projection.appendLive({
|
|
413
|
+
projection.appendLive({
|
|
414
|
+
kind: "error",
|
|
415
|
+
id: randomUUID(),
|
|
416
|
+
message: msg,
|
|
417
|
+
});
|
|
361
418
|
}
|
|
362
419
|
}
|
|
363
420
|
finally {
|
|
364
421
|
const committed = projection.commitLive();
|
|
365
422
|
if (committed.length > 0)
|
|
366
|
-
setTranscript(prev => [...prev, ...committed]);
|
|
423
|
+
setTranscript((prev) => [...prev, ...committed]);
|
|
367
424
|
setBusy(false);
|
|
368
425
|
abortRef.current = null;
|
|
369
426
|
}
|
|
@@ -393,27 +450,35 @@ export function App(props) {
|
|
|
393
450
|
useInput((_ch, key) => {
|
|
394
451
|
if (!key.escape)
|
|
395
452
|
return;
|
|
396
|
-
if (overlays.active !== null && overlays.active !==
|
|
453
|
+
if (overlays.active !== null && overlays.active !== "atfile") {
|
|
397
454
|
overlays.closeOverlay();
|
|
398
455
|
return;
|
|
399
456
|
}
|
|
400
457
|
if (busy && abortRef.current !== null) {
|
|
401
458
|
abortRef.current.abort();
|
|
402
|
-
projection.appendLive({
|
|
459
|
+
projection.appendLive({
|
|
460
|
+
kind: "notice",
|
|
461
|
+
id: randomUUID(),
|
|
462
|
+
text: "Cancelled.",
|
|
463
|
+
});
|
|
403
464
|
return;
|
|
404
465
|
}
|
|
405
466
|
if (input.length > 0)
|
|
406
|
-
setInput(
|
|
467
|
+
setInput("");
|
|
407
468
|
});
|
|
408
469
|
const handleModelPick = React.useCallback((id) => {
|
|
409
470
|
overlays.closeOverlay();
|
|
410
471
|
// Dedupe: a stale picker callback firing after the model is already
|
|
411
472
|
// set should not spam the transcript with redundant notices.
|
|
412
|
-
setCurrentModel(prev => {
|
|
473
|
+
setCurrentModel((prev) => {
|
|
413
474
|
if (prev === id)
|
|
414
475
|
return prev;
|
|
415
|
-
const note = {
|
|
416
|
-
|
|
476
|
+
const note = {
|
|
477
|
+
kind: "notice",
|
|
478
|
+
id: randomUUID(),
|
|
479
|
+
text: `Model set to ${id}`,
|
|
480
|
+
};
|
|
481
|
+
setTranscript((t) => [...t, note]);
|
|
417
482
|
// 1.10.1 — Warn the user inline if the new model's provider has
|
|
418
483
|
// no API key configured. Without this, the next ask silently
|
|
419
484
|
// 401s and the user is left wondering why nothing happens.
|
|
@@ -428,7 +493,7 @@ export function App(props) {
|
|
|
428
493
|
if (m?.[1]) {
|
|
429
494
|
// Open inline key entry instead of a static hint — the user can
|
|
430
495
|
// paste their key right here without leaving the REPL.
|
|
431
|
-
setPendingKey({ keyName: m[1], retryInput:
|
|
496
|
+
setPendingKey({ keyName: m[1], retryInput: "" });
|
|
432
497
|
return prev; // Don't switch model until the key is saved
|
|
433
498
|
}
|
|
434
499
|
}
|
|
@@ -436,25 +501,39 @@ export function App(props) {
|
|
|
436
501
|
});
|
|
437
502
|
}, [overlays, props.providers]);
|
|
438
503
|
const handleKeySetSave = React.useCallback((value) => {
|
|
439
|
-
const keyName = pendingKey?.keyName ??
|
|
504
|
+
const keyName = pendingKey?.keyName ?? "";
|
|
440
505
|
void (async () => {
|
|
441
506
|
try {
|
|
442
507
|
await saveKey(keyName, value);
|
|
443
|
-
const retryText = pendingKey?.retryInput ??
|
|
508
|
+
const retryText = pendingKey?.retryInput ?? "";
|
|
444
509
|
setPendingKey(null);
|
|
445
|
-
setTranscript(prev => [
|
|
510
|
+
setTranscript((prev) => [
|
|
511
|
+
...prev,
|
|
512
|
+
{
|
|
513
|
+
kind: "notice",
|
|
514
|
+
id: randomUUID(),
|
|
515
|
+
text: `Saved ${keyName}. Model ready.`,
|
|
516
|
+
},
|
|
517
|
+
]);
|
|
446
518
|
if (retryText) {
|
|
447
519
|
setInput(retryText);
|
|
448
520
|
}
|
|
449
521
|
}
|
|
450
522
|
catch (err) {
|
|
451
523
|
setPendingKey(null);
|
|
452
|
-
setTranscript(prev => [
|
|
524
|
+
setTranscript((prev) => [
|
|
525
|
+
...prev,
|
|
526
|
+
{
|
|
527
|
+
kind: "error",
|
|
528
|
+
id: randomUUID(),
|
|
529
|
+
message: `Failed to save key: ${err instanceof Error ? err.message : String(err)}`,
|
|
530
|
+
},
|
|
531
|
+
]);
|
|
453
532
|
}
|
|
454
533
|
})();
|
|
455
534
|
}, [pendingKey]);
|
|
456
535
|
const handleAtPick = React.useCallback((path) => {
|
|
457
|
-
setInput(current => overlays.spliceAtSelection(current, path));
|
|
536
|
+
setInput((current) => overlays.spliceAtSelection(current, path));
|
|
458
537
|
overlays.setAtQuery(null);
|
|
459
538
|
overlays.setActive(null);
|
|
460
539
|
}, [overlays]);
|
|
@@ -463,9 +542,21 @@ export function App(props) {
|
|
|
463
542
|
// a second Enter. Anything that DOES take args (model, theme, mode,
|
|
464
543
|
// memory, session, ...) gets a trailing space and waits for the arg.
|
|
465
544
|
const ARGLESS_SLASH = React.useMemo(() => new Set([
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
545
|
+
"help",
|
|
546
|
+
"exit",
|
|
547
|
+
"quit",
|
|
548
|
+
"clear",
|
|
549
|
+
"compact",
|
|
550
|
+
"models",
|
|
551
|
+
"theme",
|
|
552
|
+
"cost",
|
|
553
|
+
"status",
|
|
554
|
+
"history",
|
|
555
|
+
"login",
|
|
556
|
+
"logout",
|
|
557
|
+
"setup",
|
|
558
|
+
"upgrade",
|
|
559
|
+
"update",
|
|
469
560
|
]), []);
|
|
470
561
|
const handleSlashPick = React.useCallback((name) => {
|
|
471
562
|
// Replace the leading /<typed> with /<picked>. For commands that
|
|
@@ -473,8 +564,8 @@ export function App(props) {
|
|
|
473
564
|
// to type it. For argless commands (1.12.0 fix) we submit immediately
|
|
474
565
|
// — without this, /models<Enter> required pressing Enter TWICE: once
|
|
475
566
|
// to "pick" the autocomplete suggestion, again to submit.
|
|
476
|
-
let spliced =
|
|
477
|
-
setInput(current => {
|
|
567
|
+
let spliced = "";
|
|
568
|
+
setInput((current) => {
|
|
478
569
|
spliced = overlays.spliceSlashSelection(current, name);
|
|
479
570
|
if (spliced === `/${name}` && !ARGLESS_SLASH.has(name)) {
|
|
480
571
|
return `${spliced} `; // ready for arg input
|
|
@@ -489,27 +580,35 @@ export function App(props) {
|
|
|
489
580
|
setTimeout(() => handleSubmit(spliced || `/${name}`), 0);
|
|
490
581
|
}
|
|
491
582
|
}, [overlays, ARGLESS_SLASH, handleSubmit]);
|
|
492
|
-
const inputFocus = overlays.active === null ||
|
|
583
|
+
const inputFocus = overlays.active === null ||
|
|
584
|
+
overlays.active === "atfile" ||
|
|
585
|
+
overlays.active === "slash";
|
|
493
586
|
// Active theme name — driven by local state so the picker can flip it
|
|
494
587
|
// live. Initial value comes from config; subsequent changes are
|
|
495
588
|
// persisted to ~/.dirgha/config.json so future sessions pick it up.
|
|
496
|
-
const [themeName, setThemeName] = React.useState((props.config.theme ??
|
|
589
|
+
const [themeName, setThemeName] = React.useState((props.config.theme ?? "readable"));
|
|
497
590
|
const handleThemePick = React.useCallback((name) => {
|
|
498
591
|
overlays.closeOverlay();
|
|
499
592
|
setThemeName(name);
|
|
500
|
-
const note = {
|
|
501
|
-
|
|
593
|
+
const note = {
|
|
594
|
+
kind: "notice",
|
|
595
|
+
id: randomUUID(),
|
|
596
|
+
text: `Theme set to ${name}`,
|
|
597
|
+
};
|
|
598
|
+
setTranscript((t) => [...t, note]);
|
|
502
599
|
void (async () => {
|
|
503
600
|
try {
|
|
504
|
-
const dir = pathJoin(homedir(),
|
|
601
|
+
const dir = pathJoin(homedir(), ".dirgha");
|
|
505
602
|
await mkdir(dir, { recursive: true });
|
|
506
|
-
const path = pathJoin(dir,
|
|
507
|
-
const text = await readFile(path,
|
|
603
|
+
const path = pathJoin(dir, "config.json");
|
|
604
|
+
const text = await readFile(path, "utf8").catch(() => "");
|
|
508
605
|
const cfg = text ? JSON.parse(text) : {};
|
|
509
606
|
cfg.theme = name;
|
|
510
|
-
await writeFile(path, `${JSON.stringify(cfg, null, 2)}\n`,
|
|
607
|
+
await writeFile(path, `${JSON.stringify(cfg, null, 2)}\n`, "utf8");
|
|
608
|
+
}
|
|
609
|
+
catch {
|
|
610
|
+
/* best-effort persistence */
|
|
511
611
|
}
|
|
512
|
-
catch { /* best-effort persistence */ }
|
|
513
612
|
})();
|
|
514
613
|
}, [overlays]);
|
|
515
614
|
// BISECT: Static moved out of the transcript render. Logo stays
|
|
@@ -518,7 +617,7 @@ export function App(props) {
|
|
|
518
617
|
// streaming text appears now, the Static-around-transcript pattern
|
|
519
618
|
// was suppressing the live region updates. If still not, the bug
|
|
520
619
|
// is upstream in useEventProjection.
|
|
521
|
-
return (_jsx(ThemeProvider, { activeTheme: themeName, children: _jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: [{ key:
|
|
620
|
+
return (_jsx(ThemeProvider, { activeTheme: themeName, children: _jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: [{ key: "logo" }], children: (_item) => _jsx(Logo, { version: VERSION }, "logo") }), _jsx(Box, { flexDirection: "column", children: renderTranscript([...transcript, ...projection.liveItems]) }), pendingApproval !== null && approvalBusRef.current && (_jsx(ApprovalPrompt, { request: pendingApproval, onResolve: (decision) => {
|
|
522
621
|
approvalBusRef.current?.resolve(pendingApproval.id, decision);
|
|
523
622
|
} })), pendingFailover !== null && (_jsx(ModelSwitchPrompt, { failedModel: pendingFailover.failedModel, failoverModel: pendingFailover.failoverModel, onAccept: (failover) => {
|
|
524
623
|
const lastPrompt = pendingFailover.lastPrompt;
|
|
@@ -530,33 +629,54 @@ export function App(props) {
|
|
|
530
629
|
}
|
|
531
630
|
}, onReject: () => setPendingFailover(null), onPicker: () => {
|
|
532
631
|
setPendingFailover(null);
|
|
533
|
-
overlays.openOverlay(
|
|
534
|
-
} })), _jsx(PromptQueueIndicator, { queued: promptQueue }), _jsx(InputBox, { value: input, onChange: setInput, onSubmit: handleSubmit, busy: busy, vimMode: props.config.vimMode === true, onAtQueryChange: overlays.setAtQuery, onSlashQueryChange: overlays.setSlashQuery, onRequestOverlay: overlays.openOverlay,
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
632
|
+
overlays.openOverlay("models");
|
|
633
|
+
} })), _jsx(PromptQueueIndicator, { queued: promptQueue }), _jsx(InputBox, { value: input, onChange: setInput, onSubmit: handleSubmit, busy: busy, vimMode: props.config.vimMode === true, onAtQueryChange: overlays.setAtQuery, onSlashQueryChange: overlays.setSlashQuery, onRequestOverlay: overlays.openOverlay, onRequestYoloToggle: () => {
|
|
634
|
+
const next = mode === "yolo" ? "act" : "yolo";
|
|
635
|
+
setMode(next);
|
|
636
|
+
setTranscript((prev) => [
|
|
637
|
+
...prev,
|
|
638
|
+
{
|
|
639
|
+
kind: "notice",
|
|
640
|
+
id: randomUUID(),
|
|
641
|
+
text: next === "yolo"
|
|
642
|
+
? "YOLO mode ON — every tool call is auto-approved. Ctrl+Y to exit."
|
|
643
|
+
: "YOLO mode OFF — back to standard confirmation.",
|
|
644
|
+
},
|
|
645
|
+
]);
|
|
646
|
+
}, inputFocus: inputFocus }), overlays.active === "atfile" && overlays.atQuery !== null && (_jsx(AtFileComplete, { cwd: props.cwd, query: overlays.atQuery, onPick: handleAtPick, onCancel: () => {
|
|
647
|
+
overlays.setAtQuery(null);
|
|
648
|
+
overlays.setActive(null);
|
|
649
|
+
} })), overlays.active === "slash" && overlays.slashQuery !== null && (_jsx(SlashComplete, { commands: slashCommands, query: overlays.slashQuery, onPick: handleSlashPick, onCancel: () => {
|
|
650
|
+
overlays.setSlashQuery(null);
|
|
651
|
+
overlays.setActive(null);
|
|
652
|
+
} })), overlays.active === "models" &&
|
|
653
|
+
pickerStage === "provider" &&
|
|
654
|
+
(() => {
|
|
655
|
+
// Build provider entries — only include providers that actually have
|
|
656
|
+
// models in our catalogue. Without this, the picker shows providers
|
|
657
|
+
// with 0 models and the user lands on an empty model list.
|
|
658
|
+
const providers = buildProviderEntries(models, currentModel);
|
|
659
|
+
if (providers.length === 0) {
|
|
660
|
+
// Fall through to flat ModelPicker if no providers (catalogue empty).
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
663
|
+
return (_jsx(ProviderPicker, { providers: providers, onPick: (providerId) => {
|
|
664
|
+
setPickerProvider(providerId);
|
|
665
|
+
setPickerStage("model");
|
|
666
|
+
}, onCancel: () => {
|
|
667
|
+
setPickerStage("provider");
|
|
668
|
+
setPickerProvider(null);
|
|
669
|
+
overlays.closeOverlay();
|
|
670
|
+
} }));
|
|
671
|
+
})(), overlays.active === "models" && pickerStage === "model" && (_jsx(ModelPicker, { models: models.filter((m) => m.provider === pickerProvider), current: currentModel, onPick: (id) => {
|
|
552
672
|
handleModelPick(id);
|
|
553
|
-
setPickerStage(
|
|
673
|
+
setPickerStage("provider");
|
|
554
674
|
setPickerProvider(null);
|
|
555
675
|
}, onCancel: () => {
|
|
556
676
|
// Esc inside ModelPicker → back to ProviderPicker (NOT close).
|
|
557
|
-
setPickerStage(
|
|
677
|
+
setPickerStage("provider");
|
|
558
678
|
setPickerProvider(null);
|
|
559
|
-
} })), overlays.active ===
|
|
679
|
+
} })), overlays.active === "help" && (_jsx(HelpOverlay, { slashCommands: slashCommands, onClose: overlays.closeOverlay })), overlays.active === "theme" && (_jsx(ThemePicker, { current: themeName, onPick: handleThemePick, onCancel: overlays.closeOverlay })), pendingKey && (_jsx(KeySetOverlay, { keyName: pendingKey.keyName, onSave: handleKeySetSave, onCancel: () => setPendingKey(null) })), _jsx(StatusBar, { model: currentModel, provider: providerIdForModel(currentModel), inputTokens: projection.totals.inputTokens, outputTokens: projection.totals.outputTokens, costUsd: projection.totals.costUsd, cwd: props.cwd, busy: busy, mode: mode, contextWindow: contextWindowFor(currentModel), liveOutputTokens: liveOutputTokens, liveDurationMs: liveDurationMs })] }) }));
|
|
560
680
|
}
|
|
561
681
|
/**
|
|
562
682
|
* Walk the transcript and fold consecutive `tool` items into a single
|
|
@@ -576,7 +696,7 @@ function renderTranscript(items) {
|
|
|
576
696
|
toolBuf = [];
|
|
577
697
|
};
|
|
578
698
|
for (const item of items) {
|
|
579
|
-
if (item.kind ===
|
|
699
|
+
if (item.kind === "tool") {
|
|
580
700
|
toolBuf.push({
|
|
581
701
|
id: item.id,
|
|
582
702
|
name: item.name,
|
|
@@ -594,22 +714,22 @@ function renderTranscript(items) {
|
|
|
594
714
|
flushTools();
|
|
595
715
|
return out;
|
|
596
716
|
}
|
|
597
|
-
function TranscriptRow({ item }) {
|
|
717
|
+
function TranscriptRow({ item, }) {
|
|
598
718
|
switch (item.kind) {
|
|
599
|
-
case
|
|
719
|
+
case "user":
|
|
600
720
|
return (_jsxs(Box, { gap: 2, marginBottom: 1, children: [_jsx(Text, { color: "magenta", children: "\u276F" }), _jsx(Text, { color: "white", children: item.text })] }));
|
|
601
|
-
case
|
|
721
|
+
case "text":
|
|
602
722
|
return _jsx(StreamingText, { content: item.content });
|
|
603
|
-
case
|
|
723
|
+
case "thinking":
|
|
604
724
|
return _jsx(ThinkingBlock, { content: item.content });
|
|
605
|
-
case
|
|
725
|
+
case "tool":
|
|
606
726
|
// Should not be reached — tools are folded by renderTranscript() into
|
|
607
727
|
// <ToolGroup>. Kept as a safety net so an unexpected tool item still
|
|
608
728
|
// renders something rather than nothing.
|
|
609
729
|
return (_jsx(ToolBox, { name: item.name, status: item.status, argSummary: item.argSummary, outputPreview: item.outputPreview, startedAt: item.startedAt, durationMs: item.durationMs }));
|
|
610
|
-
case
|
|
730
|
+
case "error":
|
|
611
731
|
return (_jsxs(Box, { gap: 1, marginBottom: 1, children: [_jsx(Text, { color: "red", bold: true, children: "\u2717" }), _jsx(Text, { color: "red", children: item.message })] }));
|
|
612
|
-
case
|
|
732
|
+
case "notice":
|
|
613
733
|
return (_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: "yellow", children: item.text }) }));
|
|
614
734
|
}
|
|
615
735
|
}
|
|
@@ -623,89 +743,91 @@ function initialHistory(props) {
|
|
|
623
743
|
const soul = loadSoul();
|
|
624
744
|
const composedSystem = composeSystemPrompt({
|
|
625
745
|
soul: soul.text,
|
|
626
|
-
modePreamble: modePreamble(props.config.mode ??
|
|
746
|
+
modePreamble: modePreamble(props.config.mode ?? "act"),
|
|
627
747
|
primer: primer.primer,
|
|
628
748
|
gitState: renderGitState(probeGitState(props.cwd)),
|
|
629
749
|
userSystem: props.systemPrompt,
|
|
630
750
|
});
|
|
631
|
-
base.unshift({ role:
|
|
751
|
+
base.unshift({ role: "system", content: composedSystem });
|
|
632
752
|
return base;
|
|
633
753
|
}
|
|
634
754
|
function providerIdForModel(model) {
|
|
635
755
|
// Light heuristic so StatusBar has a hint without importing dispatch.
|
|
636
756
|
// Real routing still lives in providers/dispatch.ts at run time.
|
|
637
|
-
if (model.includes(
|
|
638
|
-
return
|
|
639
|
-
if (model.includes(
|
|
640
|
-
return
|
|
641
|
-
if (model.includes(
|
|
642
|
-
return
|
|
643
|
-
if (model.includes(
|
|
644
|
-
return
|
|
645
|
-
if (model.includes(
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
return
|
|
649
|
-
if (model.includes(
|
|
650
|
-
return
|
|
651
|
-
|
|
757
|
+
if (model.includes("claude"))
|
|
758
|
+
return "anthropic";
|
|
759
|
+
if (model.includes("gpt") || model.startsWith("o1") || model.startsWith("o3"))
|
|
760
|
+
return "openai";
|
|
761
|
+
if (model.includes("gemini"))
|
|
762
|
+
return "gemini";
|
|
763
|
+
if (model.includes("kimi") || model.includes("moonshot"))
|
|
764
|
+
return "nvidia";
|
|
765
|
+
if (model.includes("llama") ||
|
|
766
|
+
model.includes("nvidia") ||
|
|
767
|
+
model.includes("minimax"))
|
|
768
|
+
return "nvidia";
|
|
769
|
+
if (model.includes("fireworks"))
|
|
770
|
+
return "fireworks";
|
|
771
|
+
if (model.includes("/"))
|
|
772
|
+
return "openrouter";
|
|
773
|
+
return "local";
|
|
652
774
|
}
|
|
653
775
|
const PROVIDER_BLURB = {
|
|
654
|
-
anthropic:
|
|
655
|
-
openai:
|
|
656
|
-
gemini:
|
|
657
|
-
openrouter:
|
|
658
|
-
nvidia:
|
|
659
|
-
ollama:
|
|
660
|
-
llamacpp:
|
|
661
|
-
fireworks:
|
|
662
|
-
deepseek:
|
|
663
|
-
mistral:
|
|
664
|
-
cohere:
|
|
665
|
-
cerebras:
|
|
666
|
-
together:
|
|
667
|
-
perplexity:
|
|
668
|
-
xai:
|
|
669
|
-
groq:
|
|
670
|
-
zai:
|
|
671
|
-
local:
|
|
776
|
+
anthropic: "Claude — Opus, Sonnet, Haiku",
|
|
777
|
+
openai: "GPT family — gpt-5.5, o1/o3",
|
|
778
|
+
gemini: "Google — Gemini Pro, Flash",
|
|
779
|
+
openrouter: "Aggregator — 370+ models, free tier",
|
|
780
|
+
nvidia: "NIM — Kimi K2.5, DeepSeek V4, Qwen 3",
|
|
781
|
+
ollama: "Local Ollama models",
|
|
782
|
+
llamacpp: "Local llama.cpp models",
|
|
783
|
+
fireworks: "Hosted open models",
|
|
784
|
+
deepseek: "DeepSeek native — V3.2, reasoner",
|
|
785
|
+
mistral: "Mistral — Codestral, Magistral",
|
|
786
|
+
cohere: "Cohere — Command R / Command A",
|
|
787
|
+
cerebras: "Wafer-scale — Qwen3, Llama 4",
|
|
788
|
+
together: "Open-source hub — Llama, Qwen",
|
|
789
|
+
perplexity: "Sonar — search-grounded",
|
|
790
|
+
xai: "Grok 4 family — code + reasoning",
|
|
791
|
+
groq: "LPU — very low latency",
|
|
792
|
+
zai: "GLM-4.6 — long-context",
|
|
793
|
+
local: "Local models",
|
|
672
794
|
};
|
|
673
795
|
const PROVIDER_ENV = {
|
|
674
|
-
anthropic:
|
|
675
|
-
openai:
|
|
676
|
-
gemini:
|
|
677
|
-
openrouter:
|
|
678
|
-
nvidia:
|
|
679
|
-
fireworks:
|
|
680
|
-
deepseek:
|
|
681
|
-
mistral:
|
|
682
|
-
cohere:
|
|
683
|
-
cerebras:
|
|
684
|
-
together:
|
|
685
|
-
perplexity:
|
|
686
|
-
xai:
|
|
687
|
-
groq:
|
|
688
|
-
zai:
|
|
796
|
+
anthropic: "ANTHROPIC_API_KEY",
|
|
797
|
+
openai: "OPENAI_API_KEY",
|
|
798
|
+
gemini: "GEMINI_API_KEY",
|
|
799
|
+
openrouter: "OPENROUTER_API_KEY",
|
|
800
|
+
nvidia: "NVIDIA_API_KEY",
|
|
801
|
+
fireworks: "FIREWORKS_API_KEY",
|
|
802
|
+
deepseek: "DEEPSEEK_API_KEY",
|
|
803
|
+
mistral: "MISTRAL_API_KEY",
|
|
804
|
+
cohere: "COHERE_API_KEY",
|
|
805
|
+
cerebras: "CEREBRAS_API_KEY",
|
|
806
|
+
together: "TOGETHER_API_KEY",
|
|
807
|
+
perplexity: "PERPLEXITY_API_KEY",
|
|
808
|
+
xai: "XAI_API_KEY",
|
|
809
|
+
groq: "GROQ_API_KEY",
|
|
810
|
+
zai: "ZAI_API_KEY",
|
|
689
811
|
};
|
|
690
812
|
const PROVIDER_LABEL = {
|
|
691
|
-
anthropic:
|
|
692
|
-
openai:
|
|
693
|
-
gemini:
|
|
694
|
-
openrouter:
|
|
695
|
-
nvidia:
|
|
696
|
-
ollama:
|
|
697
|
-
llamacpp:
|
|
698
|
-
fireworks:
|
|
699
|
-
deepseek:
|
|
700
|
-
mistral:
|
|
701
|
-
cohere:
|
|
702
|
-
cerebras:
|
|
703
|
-
together:
|
|
704
|
-
perplexity:
|
|
705
|
-
xai:
|
|
706
|
-
groq:
|
|
707
|
-
zai:
|
|
708
|
-
local:
|
|
813
|
+
anthropic: "Anthropic",
|
|
814
|
+
openai: "OpenAI",
|
|
815
|
+
gemini: "Google AI",
|
|
816
|
+
openrouter: "OpenRouter",
|
|
817
|
+
nvidia: "NVIDIA NIM",
|
|
818
|
+
ollama: "Ollama (local)",
|
|
819
|
+
llamacpp: "llama.cpp (local)",
|
|
820
|
+
fireworks: "Fireworks",
|
|
821
|
+
deepseek: "DeepSeek",
|
|
822
|
+
mistral: "Mistral",
|
|
823
|
+
cohere: "Cohere",
|
|
824
|
+
cerebras: "Cerebras",
|
|
825
|
+
together: "Together AI",
|
|
826
|
+
perplexity: "Perplexity",
|
|
827
|
+
xai: "xAI (Grok)",
|
|
828
|
+
groq: "Groq",
|
|
829
|
+
zai: "Z.AI / GLM",
|
|
830
|
+
local: "Local",
|
|
709
831
|
};
|
|
710
832
|
/**
|
|
711
833
|
* Group the flat model catalogue into per-provider entries for stage 1
|
|
@@ -718,7 +840,7 @@ function buildProviderEntries(models, currentModel) {
|
|
|
718
840
|
list.push(m);
|
|
719
841
|
buckets.set(m.provider, list);
|
|
720
842
|
}
|
|
721
|
-
const currentProvider = models.find(m => m.id === currentModel)?.provider;
|
|
843
|
+
const currentProvider = models.find((m) => m.id === currentModel)?.provider;
|
|
722
844
|
const out = [];
|
|
723
845
|
for (const [id, items] of buckets) {
|
|
724
846
|
const env = PROVIDER_ENV[id];
|
|
@@ -737,7 +859,7 @@ function buildProviderEntries(models, currentModel) {
|
|
|
737
859
|
return out;
|
|
738
860
|
}
|
|
739
861
|
function defaultModelCatalogue() {
|
|
740
|
-
return PRICES.map(p => ({
|
|
862
|
+
return PRICES.map((p) => ({
|
|
741
863
|
id: p.model,
|
|
742
864
|
provider: p.provider,
|
|
743
865
|
tier: tierFromPrice(p.inputPerM),
|
|
@@ -745,11 +867,11 @@ function defaultModelCatalogue() {
|
|
|
745
867
|
}
|
|
746
868
|
function tierFromPrice(inputPerM) {
|
|
747
869
|
if (inputPerM === 0)
|
|
748
|
-
return
|
|
870
|
+
return "free";
|
|
749
871
|
if (inputPerM < 0.5)
|
|
750
|
-
return
|
|
872
|
+
return "basic";
|
|
751
873
|
if (inputPerM < 5)
|
|
752
|
-
return
|
|
753
|
-
return
|
|
874
|
+
return "pro";
|
|
875
|
+
return "premium";
|
|
754
876
|
}
|
|
755
877
|
//# sourceMappingURL=App.js.map
|