@phren/agent 0.3.30 → 0.3.32
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/agent-loop/index.js +3 -0
- package/dist/bin.js +1 -1
- package/dist/commands/model.js +4 -5
- package/dist/config.js +21 -4
- package/dist/herdr-hooks.js +89 -9
- package/dist/index.js +52 -17
- package/dist/mcp-client.js +5 -1
- package/dist/model-discovery.js +467 -0
- package/dist/models-list.js +20 -25
- package/dist/models.js +32 -9
- package/dist/multi/model-picker.js +87 -46
- package/dist/multi/picker-navigation.js +28 -0
- package/dist/multi/provider-manager.js +27 -57
- package/dist/provider-connectors.js +89 -0
- package/dist/providers/anthropic.js +20 -9
- package/dist/providers/codex.js +7 -7
- package/dist/providers/openai-compat.js +26 -1
- package/dist/providers/openai-responses.js +270 -0
- package/dist/providers/openrouter.js +14 -6
- package/dist/providers/resolve.js +67 -30
- package/dist/repl.js +2 -1
- package/dist/settings.js +72 -3
- package/dist/tools/registry.js +6 -1
- package/dist/tui/components/InputArea.js +3 -3
- package/dist/tui/components/ModelPicker.js +24 -5
- package/dist/tui/components/StatusBar.js +3 -3
- package/dist/tui/ink-entry.js +12 -17
- package/package.json +6 -6
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text, useInput } from "ink";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { pickerRows, movePicker, pickerWindow } from "../../multi/picker-navigation.js";
|
|
3
5
|
import { REASONING_LEVELS } from "../../models.js";
|
|
4
6
|
function meter(level, theme) {
|
|
5
7
|
if (!level)
|
|
@@ -9,21 +11,31 @@ function meter(level, theme) {
|
|
|
9
11
|
return "\u25cf".repeat(filled) + "\u25cb".repeat(5 - filled);
|
|
10
12
|
}
|
|
11
13
|
export function ModelPicker({ state, theme, onMove, onReasoning, onSelect, onCancel }) {
|
|
14
|
+
const [query, setQuery] = useState("");
|
|
15
|
+
const rows = pickerRows(state.models, query);
|
|
16
|
+
const visible = pickerWindow(rows, state.cursor, Math.max(3, Math.min(12, (process.stdout.rows || 24) - 10)));
|
|
17
|
+
const search = (next) => {
|
|
18
|
+
setQuery(next);
|
|
19
|
+
const matches = pickerRows(state.models, next);
|
|
20
|
+
if (matches.length && !matches.includes(state.cursor))
|
|
21
|
+
onMove(matches[0] - state.cursor);
|
|
22
|
+
};
|
|
12
23
|
useInput((input, key) => {
|
|
13
24
|
if (key.escape) {
|
|
14
25
|
onCancel();
|
|
15
26
|
return;
|
|
16
27
|
}
|
|
17
28
|
if (key.return) {
|
|
18
|
-
|
|
29
|
+
if (rows.length)
|
|
30
|
+
onSelect();
|
|
19
31
|
return;
|
|
20
32
|
}
|
|
21
33
|
if (key.upArrow) {
|
|
22
|
-
onMove(-1);
|
|
34
|
+
onMove(movePicker(rows, state.cursor, -1) - state.cursor);
|
|
23
35
|
return;
|
|
24
36
|
}
|
|
25
37
|
if (key.downArrow) {
|
|
26
|
-
onMove(1);
|
|
38
|
+
onMove(movePicker(rows, state.cursor, 1) - state.cursor);
|
|
27
39
|
return;
|
|
28
40
|
}
|
|
29
41
|
if (key.leftArrow) {
|
|
@@ -34,10 +46,17 @@ export function ModelPicker({ state, theme, onMove, onReasoning, onSelect, onCan
|
|
|
34
46
|
onReasoning(1);
|
|
35
47
|
return;
|
|
36
48
|
}
|
|
49
|
+
if (key.backspace || key.delete) {
|
|
50
|
+
search(query.slice(0, -1));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (input && !key.ctrl && !key.meta && !/[\x00-\x1f\x7f]/.test(input))
|
|
54
|
+
search((query + input).slice(0, 100));
|
|
37
55
|
});
|
|
38
56
|
const accent = theme?.statusBar.accent ?? "cyan";
|
|
39
|
-
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: accent, paddingX: 1, marginTop: 1, children: [_jsxs(Box, { children: [_jsx(Text, { bold: true, children: "Select model " }), _jsx(Text, { dimColor: true, children: "\u2191\u2193 navigate \u00b7 \u2190\u2192 reasoning \u00b7 enter select \u00b7 esc cancel" })] }),
|
|
57
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: accent, paddingX: 1, marginTop: 1, children: [_jsxs(Box, { children: [_jsx(Text, { bold: true, children: "Select model " }), _jsx(Text, { dimColor: true, children: "\u2191\u2193 navigate \u00b7 \u2190\u2192 reasoning \u00b7 enter select \u00b7 esc cancel" })] }), _jsxs(Text, { dimColor: true, children: ["Search: ", query || "type to filter", " \u00B7 ", rows.length, " models"] }), !rows.length && _jsx(Text, { dimColor: true, children: "No matching models." }), visible.map(i => {
|
|
58
|
+
const model = state.models[i];
|
|
40
59
|
const selected = i === state.cursor;
|
|
41
|
-
return (_jsxs(Text, { color: selected ? accent : undefined, dimColor: !selected, children: [selected ? "\u25b8 " : " ", model.label, _jsxs(Text, { dimColor: true, children: [" ", meter(state.reasoning[i], theme), state.reasoning[i] ? ` ${state.reasoning[i]}` : ""] }), _jsxs(Text, { dimColor: true, children: [" ", Math.round(model.contextWindow / 1000)
|
|
60
|
+
return (_jsxs(Text, { wrap: "truncate-end", color: selected ? accent : undefined, dimColor: !selected, children: [selected ? "\u25b8 " : " ", model.label, _jsxs(Text, { dimColor: true, children: [" ", meter(state.reasoning[i], theme), state.reasoning[i] ? ` ${state.reasoning[i]}` : ""] }), _jsxs(Text, { dimColor: true, children: [" ", model.contextWindow ? `${Math.round(model.contextWindow / 1000)}k` : "? context"] })] }, `${model.provider}/${model.id}`));
|
|
42
61
|
})] }));
|
|
43
62
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Text,
|
|
2
|
+
import { Box, Text, useWindowSize } from "ink";
|
|
3
3
|
function displayWidth(text) {
|
|
4
4
|
let width = 0;
|
|
5
5
|
for (const ch of text) {
|
|
@@ -26,8 +26,8 @@ function truncate(text, max) {
|
|
|
26
26
|
return out + "\u2026";
|
|
27
27
|
}
|
|
28
28
|
export function StatusBar({ provider, model, project, turns, cost, contextTokens, contextLimit, reasoningEffort, theme }) {
|
|
29
|
-
const {
|
|
30
|
-
const width =
|
|
29
|
+
const { columns } = useWindowSize();
|
|
30
|
+
const width = columns || 80;
|
|
31
31
|
const leftParts = ["\u25c6 phren", provider];
|
|
32
32
|
if (model)
|
|
33
33
|
leftParts.push(model);
|
package/dist/tui/ink-entry.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { moveReasoning } from "../multi/picker-navigation.js";
|
|
2
3
|
import { render } from "ink";
|
|
3
4
|
import { createSession, runTurn } from "../agent-loop.js";
|
|
4
5
|
import { emitHerdrHook, setHerdrHookSession } from "../herdr-hooks.js";
|
|
@@ -11,7 +12,7 @@ import * as os from "os";
|
|
|
11
12
|
import * as fs from "node:fs";
|
|
12
13
|
import { execSync } from "node:child_process";
|
|
13
14
|
import * as path from "node:path";
|
|
14
|
-
import { loadInputMode, saveInputMode, savePermissionMode, loadTheme, saveTheme, loadInputHistory, saveInputHistory } from "../settings.js";
|
|
15
|
+
import { loadInputMode, saveInputMode, savePermissionMode, loadTheme, saveTheme, loadInputHistory, saveInputHistory, saveModelSelection } from "../settings.js";
|
|
15
16
|
import { contextTokens } from "../context/usage.js";
|
|
16
17
|
import { READ_ONLY_TOOLS } from "../permissions/checker.js";
|
|
17
18
|
import { nextPermissionMode } from "./ansi.js";
|
|
@@ -20,8 +21,7 @@ import { createRequire } from "node:module";
|
|
|
20
21
|
import { randomUUID } from "node:crypto";
|
|
21
22
|
import { persistFork } from "../session/persist.js";
|
|
22
23
|
import { getTheme, THEME_NAMES } from "./themes.js";
|
|
23
|
-
import {
|
|
24
|
-
import { REASONING_LEVELS } from "../models.js";
|
|
24
|
+
import { discoverAvailableModels } from "../multi/model-picker.js";
|
|
25
25
|
const _require = createRequire(import.meta.url);
|
|
26
26
|
const AGENT_VERSION = _require("../../package.json").version;
|
|
27
27
|
export async function startInkTui(config, spawner) {
|
|
@@ -257,18 +257,20 @@ export async function startInkTui(config, spawner) {
|
|
|
257
257
|
update();
|
|
258
258
|
resolve?.(index);
|
|
259
259
|
}
|
|
260
|
-
function openModelPicker() {
|
|
260
|
+
async function openModelPicker() {
|
|
261
261
|
const providerName = config.provider.name;
|
|
262
262
|
if (!providerName)
|
|
263
263
|
return Promise.resolve(null);
|
|
264
264
|
const currentModel = config.provider.model;
|
|
265
|
-
const models =
|
|
265
|
+
const models = await discoverAvailableModels(providerName, currentModel);
|
|
266
266
|
if (models.length === 0)
|
|
267
267
|
return Promise.resolve(null);
|
|
268
|
-
let cursor = models.findIndex((m) => m.id === currentModel);
|
|
268
|
+
let cursor = models.findIndex((m) => m.provider === providerName && m.id === currentModel);
|
|
269
269
|
if (cursor < 0)
|
|
270
270
|
cursor = 0;
|
|
271
|
-
const reasoning = models.map((m) => m.id === currentModel
|
|
271
|
+
const reasoning = models.map((m) => m.provider === providerName && m.id === currentModel && config.provider.reasoningEffort && m.reasoningRange.includes(config.provider.reasoningEffort)
|
|
272
|
+
? config.provider.reasoningEffort
|
|
273
|
+
: m.reasoning);
|
|
272
274
|
modelPicker = { models, cursor, reasoning };
|
|
273
275
|
update();
|
|
274
276
|
return new Promise((resolve) => { modelPickerResolve = resolve; });
|
|
@@ -293,16 +295,8 @@ export async function startInkTui(config, spawner) {
|
|
|
293
295
|
const model = modelPicker.models[modelPicker.cursor];
|
|
294
296
|
if (model.reasoningRange.length === 0)
|
|
295
297
|
return;
|
|
296
|
-
const current = modelPicker.reasoning[modelPicker.cursor];
|
|
297
|
-
const index = current ? REASONING_LEVELS.indexOf(current) : -1;
|
|
298
|
-
const rangeIndices = model.reasoningRange.map((level) => REASONING_LEVELS.indexOf(level));
|
|
299
|
-
const candidate = delta > 0
|
|
300
|
-
? rangeIndices.find((ri) => ri > index)
|
|
301
|
-
: [...rangeIndices].reverse().find((ri) => ri < index);
|
|
302
|
-
if (candidate === undefined)
|
|
303
|
-
return;
|
|
304
298
|
const reasoning = [...modelPicker.reasoning];
|
|
305
|
-
reasoning[modelPicker.cursor] =
|
|
299
|
+
reasoning[modelPicker.cursor] = moveReasoning(model.reasoningRange, reasoning[modelPicker.cursor], delta);
|
|
306
300
|
modelPicker = { ...modelPicker, reasoning };
|
|
307
301
|
update();
|
|
308
302
|
}
|
|
@@ -310,7 +304,7 @@ export async function startInkTui(config, spawner) {
|
|
|
310
304
|
if (!modelPicker)
|
|
311
305
|
return;
|
|
312
306
|
const model = modelPicker.models[modelPicker.cursor];
|
|
313
|
-
const result = { model: model.id, reasoning: modelPicker.reasoning[modelPicker.cursor] };
|
|
307
|
+
const result = { provider: model.provider, model: model.id, reasoning: modelPicker.reasoning[modelPicker.cursor] };
|
|
314
308
|
closeModelPicker(result);
|
|
315
309
|
}
|
|
316
310
|
function openToolDetail() {
|
|
@@ -401,6 +395,7 @@ export async function startInkTui(config, spawner) {
|
|
|
401
395
|
const { resolveProvider } = await import("../providers/resolve.js");
|
|
402
396
|
const newProvider = resolveProvider(result.provider ?? config.provider.name, result.model || undefined, undefined, result.reasoning ?? undefined);
|
|
403
397
|
config.provider = newProvider;
|
|
398
|
+
saveModelSelection({ provider: newProvider.name, model: newProvider.model, reasoning: newProvider.reasoningEffort }, process.cwd());
|
|
404
399
|
config.costTracker?.reprice(newProvider.model ?? newProvider.name, newProvider.name, newProvider.baseUrl);
|
|
405
400
|
const { buildSystemPrompt } = await import("../system-prompt.js");
|
|
406
401
|
config.systemPrompt = config.rebuildSystemPrompt
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phren/agent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.32",
|
|
4
4
|
"description": "phren's coding agent: starts every session knowing your project's memory, tasks and decisions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
17
|
+
"@modelcontextprotocol/sdk": "^1.32.0",
|
|
18
|
+
"@phren/cli": "0.3.32",
|
|
18
19
|
"ajv": "^8.20.0",
|
|
19
|
-
"ink": "^
|
|
20
|
-
"react": "^19.3.0"
|
|
21
|
-
"@phren/cli": "0.3.30"
|
|
20
|
+
"ink": "^8.0.0",
|
|
21
|
+
"react": "^19.3.0"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
|
-
"node": ">=
|
|
24
|
+
"node": ">=22.19.0"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [
|
|
27
27
|
"agent",
|