@useavalon/caelence-agent 0.5.0 → 0.6.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/README.md +6 -4
- package/desktop/src/DeskComposer.tsx +10 -0
- package/desktop/src/SettingsPanel.tsx +18 -0
- package/desktop/src/api.ts +11 -1
- package/desktop/src/app.css +8 -3
- package/desktop/src/desk-types.ts +1 -0
- package/desktop/src/useDeskPicker.ts +17 -1
- package/package.json +1 -1
- package/src/cli/main.test.ts +12 -0
- package/src/cli/main.ts +45 -5
- package/src/cli/slash-dispatch.test.ts +43 -0
- package/src/cli/slash-dispatch.ts +34 -0
- package/src/cli/slash.test.ts +1 -0
- package/src/cli/slash.ts +2 -0
- package/src/cli/tui.tsx +8 -1
- package/src/config.ts +7 -0
- package/src/core/events.ts +7 -9
- package/src/core/reasoning.test.ts +37 -0
- package/src/core/reasoning.ts +32 -0
- package/src/core/run-turn.test.ts +112 -0
- package/src/core/run-turn.ts +2 -1
- package/src/core/strands.test.ts +106 -2
- package/src/core/strands.ts +46 -11
- package/src/core/usage.test.ts +80 -1
- package/src/core/usage.ts +35 -3
- package/src/desktop/bridge.test.ts +27 -0
- package/src/desktop/bridge.ts +17 -5
- package/src/index.ts +12 -0
- package/src/runtime.test.ts +27 -0
- package/src/runtime.ts +20 -0
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ export default {
|
|
|
53
53
|
evalsDir: "evals",
|
|
54
54
|
theme: "caelence",
|
|
55
55
|
mode: "agent",
|
|
56
|
+
reasoningEffort: "low",
|
|
56
57
|
tools: { exec: { approval: "prompt" } },
|
|
57
58
|
mcp: [],
|
|
58
59
|
// browser: { enabled: true }, // see Browser
|
|
@@ -62,7 +63,7 @@ export default {
|
|
|
62
63
|
|
|
63
64
|
| File | Role |
|
|
64
65
|
|------|------|
|
|
65
|
-
| `harness.config.ts` | Name, model, mode, skills, evals, theme, approvals |
|
|
66
|
+
| `harness.config.ts` | Name, model, reasoning effort, mode, skills, evals, theme, approvals |
|
|
66
67
|
| `skills/**/SKILL.md` | Skills the agent can load |
|
|
67
68
|
| `evals/<suite>/eval.ts` | Eval suites |
|
|
68
69
|
| `AGENTS.md` | Project instructions |
|
|
@@ -72,7 +73,7 @@ export default {
|
|
|
72
73
|
| `.harness/memory/` | Project memory facts, if enabled |
|
|
73
74
|
| `~/.harness/integrations.json` | Connected hosted MCP servers |
|
|
74
75
|
|
|
75
|
-
The desktop stores the OpenRouter key in `~/.harness`. The terminal UI reads `OPENROUTER_API_KEY`, and optionally `OPENROUTER_MODEL` and `
|
|
76
|
+
The desktop stores the OpenRouter key in `~/.harness`. The terminal UI reads `OPENROUTER_API_KEY`, and optionally `OPENROUTER_MODEL`, `OPENROUTER_BASE_URL`, and `HARNESS_REASONING_EFFORT`.
|
|
76
77
|
|
|
77
78
|
## Commands
|
|
78
79
|
|
|
@@ -90,7 +91,7 @@ caelence skill remove <name> Uninstall a user skill, or disable a project skill
|
|
|
90
91
|
caelence help This list
|
|
91
92
|
```
|
|
92
93
|
|
|
93
|
-
Flags: `--mode ask|plan|agent`, `--cwd <path>`, `-m` / `--message <text>`.
|
|
94
|
+
Flags: `--mode ask|plan|agent`, `--effort none|minimal|low|medium|high|xhigh`, `--cwd <path>`, `-m` / `--message <text>`.
|
|
94
95
|
|
|
95
96
|
`caelence chat -m` is the non-interactive path for scripts and CI: it sends one message, prints the reply and any tool lines, then exits without opening the desktop or the terminal UI. `--mode` still applies, and if stdin is not a TTY, tool approval is deny.
|
|
96
97
|
|
|
@@ -115,6 +116,7 @@ In the desktop and the terminal UI, `/` opens slash commands, and Tab completes
|
|
|
115
116
|
/resume pick a session by title
|
|
116
117
|
/model pick a model
|
|
117
118
|
/mode ask, plan, or agent
|
|
119
|
+
/effort reasoning effort
|
|
118
120
|
/compact summarize earlier turns
|
|
119
121
|
/memory remember across chats
|
|
120
122
|
/image [prompt] generate an image
|
|
@@ -280,7 +282,7 @@ await harness.runTurn("fix the failing test", (event) => {
|
|
|
280
282
|
harness.close();
|
|
281
283
|
```
|
|
282
284
|
|
|
283
|
-
`runTurn` streams `AgentEvent`s (text, tools, usage, errors) while it writes the session under `.harness/sessions`. Optional arguments include `config`, `mode`, `provider`, `extraTools`, `approvalPolicy`, and `observability`: pass a fake provider in tests, add MCP tools of your own through `extraTools`, and implement `approvalAsk` when a host UI needs to prompt for `exec` and `git_commit`.
|
|
285
|
+
`runTurn` streams `AgentEvent`s (text, tools, usage, errors) while it writes the session under `.harness/sessions`. Optional arguments include `config`, `mode`, `reasoningEffort`, `provider`, `extraTools`, `approvalPolicy`, and `observability`: pass a fake provider in tests, add MCP tools of your own through `extraTools`, and implement `approvalAsk` when a host UI needs to prompt for `exec` and `git_commit`. Hosts that call `constructOpenRouterProvider` can pass `reasoningEffort` there too. `createConstructAgent({ contextManager })` can pass a Strands context strategy per turn; `Offload` and `ContextManagerStrategy` are re-exported so a host does not need its own copy of the SDK.
|
|
284
286
|
|
|
285
287
|
If you only need types or tracing, `HarnessConfig` / `loadConfig` and the observability entry do not require constructing a harness at all.
|
|
286
288
|
|
|
@@ -289,6 +289,16 @@ export function DeskComposeBar(props: Readonly<{ desk: DeskReady }>): React.Reac
|
|
|
289
289
|
<span className="desk-compose-mode__dot" aria-hidden="true" />
|
|
290
290
|
{titleCase(desk.state.mode)}
|
|
291
291
|
</button>
|
|
292
|
+
<button
|
|
293
|
+
type="button"
|
|
294
|
+
className="desk-compose-effort"
|
|
295
|
+
aria-label="Choose reasoning effort"
|
|
296
|
+
disabled={!canPick}
|
|
297
|
+
onClick={() => void desk.openComposerPicker("effort")}
|
|
298
|
+
>
|
|
299
|
+
<span>{desk.state.reasoningEffort}</span>
|
|
300
|
+
<CaretDownIcon size={12} weight="bold" />
|
|
301
|
+
</button>
|
|
292
302
|
<ComposeMicControl
|
|
293
303
|
status={desk.status}
|
|
294
304
|
listening={desk.listening}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
2
|
import { errorMessage } from "../../src/core/errors";
|
|
3
|
+
import { REASONING_EFFORTS } from "../../src/core/reasoning";
|
|
3
4
|
import {
|
|
4
5
|
type BridgeClient,
|
|
5
6
|
type DesktopSettings,
|
|
@@ -54,6 +55,7 @@ export function SettingsPanel(
|
|
|
54
55
|
const result = await saveSettings(props.bridge, {
|
|
55
56
|
mode: settings.mode,
|
|
56
57
|
modelId: settings.modelId,
|
|
58
|
+
reasoningEffort: settings.reasoningEffort,
|
|
57
59
|
...(apiKey.trim() ? { apiKey: apiKey.trim() } : {}),
|
|
58
60
|
...(googleClientId.trim() ? { googleClientId: googleClientId.trim() } : {}),
|
|
59
61
|
...(microsoftClientId.trim() ? { microsoftClientId: microsoftClientId.trim() } : {}),
|
|
@@ -173,6 +175,22 @@ export function SettingsPanel(
|
|
|
173
175
|
</select>
|
|
174
176
|
</span>
|
|
175
177
|
</label>
|
|
178
|
+
<label>
|
|
179
|
+
<span>Reasoning effort</span>
|
|
180
|
+
<span className="desk-select-wrap">
|
|
181
|
+
<select
|
|
182
|
+
className="cel-input desk-select"
|
|
183
|
+
value={settings.reasoningEffort}
|
|
184
|
+
onChange={(event) => setSettings({ ...settings, reasoningEffort: event.target.value })}
|
|
185
|
+
>
|
|
186
|
+
{REASONING_EFFORTS.map((effort) => (
|
|
187
|
+
<option key={effort} value={effort}>
|
|
188
|
+
{effort}
|
|
189
|
+
</option>
|
|
190
|
+
))}
|
|
191
|
+
</select>
|
|
192
|
+
</span>
|
|
193
|
+
</label>
|
|
176
194
|
<button type="submit" className="cel-btn cel-btn--secondary cel-btn--compact">
|
|
177
195
|
Save
|
|
178
196
|
</button>
|
package/desktop/src/api.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface DesktopState {
|
|
|
16
16
|
name: string;
|
|
17
17
|
cwd: string;
|
|
18
18
|
mode: string;
|
|
19
|
+
reasoningEffort: string;
|
|
19
20
|
modelId: string;
|
|
20
21
|
modelLabel: string;
|
|
21
22
|
modelTarget?: string;
|
|
@@ -47,7 +48,14 @@ export interface SlashCommand {
|
|
|
47
48
|
slot?: string;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
export type SlashPickerKind =
|
|
51
|
+
export type SlashPickerKind =
|
|
52
|
+
| "model"
|
|
53
|
+
| "mode"
|
|
54
|
+
| "effort"
|
|
55
|
+
| "resume"
|
|
56
|
+
| "image"
|
|
57
|
+
| "video"
|
|
58
|
+
| "transcribe";
|
|
51
59
|
|
|
52
60
|
export type SlashOutcome =
|
|
53
61
|
| { kind: "text"; text: string }
|
|
@@ -161,6 +169,7 @@ export interface DesktopSettings {
|
|
|
161
169
|
hasApiKey: boolean;
|
|
162
170
|
apiKeyHint: string;
|
|
163
171
|
mode: string;
|
|
172
|
+
reasoningEffort: string;
|
|
164
173
|
modelId: string;
|
|
165
174
|
modelLabel: string;
|
|
166
175
|
hasGoogleOAuth: boolean;
|
|
@@ -415,6 +424,7 @@ export function saveSettings(
|
|
|
415
424
|
apiKey?: string;
|
|
416
425
|
mode?: string;
|
|
417
426
|
modelId?: string;
|
|
427
|
+
reasoningEffort?: string;
|
|
418
428
|
googleClientId?: string;
|
|
419
429
|
googleClientSecret?: string;
|
|
420
430
|
microsoftClientId?: string;
|
package/desktop/src/app.css
CHANGED
|
@@ -2180,7 +2180,8 @@ p.desk-line__caption {
|
|
|
2180
2180
|
|
|
2181
2181
|
.desk-compose-icon:hover:not(:disabled),
|
|
2182
2182
|
.desk-compose-model:hover:not(:disabled),
|
|
2183
|
-
.desk-compose-mode:hover:not(:disabled)
|
|
2183
|
+
.desk-compose-mode:hover:not(:disabled),
|
|
2184
|
+
.desk-compose-effort:hover:not(:disabled) {
|
|
2184
2185
|
background: var(--bg);
|
|
2185
2186
|
color: var(--icon-hover);
|
|
2186
2187
|
}
|
|
@@ -2188,6 +2189,7 @@ p.desk-line__caption {
|
|
|
2188
2189
|
.desk-compose-icon:disabled,
|
|
2189
2190
|
.desk-compose-model:disabled,
|
|
2190
2191
|
.desk-compose-mode:disabled,
|
|
2192
|
+
.desk-compose-effort:disabled,
|
|
2191
2193
|
.desk-compose-send:disabled {
|
|
2192
2194
|
opacity: 0.4;
|
|
2193
2195
|
cursor: not-allowed;
|
|
@@ -2200,7 +2202,8 @@ p.desk-line__caption {
|
|
|
2200
2202
|
}
|
|
2201
2203
|
|
|
2202
2204
|
.desk-compose-model,
|
|
2203
|
-
.desk-compose-mode
|
|
2205
|
+
.desk-compose-mode,
|
|
2206
|
+
.desk-compose-effort {
|
|
2204
2207
|
display: inline-flex;
|
|
2205
2208
|
align-items: center;
|
|
2206
2209
|
gap: 4px;
|
|
@@ -2220,6 +2223,7 @@ p.desk-line__caption {
|
|
|
2220
2223
|
}
|
|
2221
2224
|
|
|
2222
2225
|
.desk-compose-model span,
|
|
2226
|
+
.desk-compose-effort span,
|
|
2223
2227
|
.desk-compose-mode {
|
|
2224
2228
|
overflow: hidden;
|
|
2225
2229
|
text-overflow: ellipsis;
|
|
@@ -2274,7 +2278,8 @@ p.desk-line__caption {
|
|
|
2274
2278
|
}
|
|
2275
2279
|
|
|
2276
2280
|
.desk-compose-model,
|
|
2277
|
-
.desk-compose-mode
|
|
2281
|
+
.desk-compose-mode,
|
|
2282
|
+
.desk-compose-effort {
|
|
2278
2283
|
max-width: 7.5rem;
|
|
2279
2284
|
height: 30px;
|
|
2280
2285
|
padding: 0 10px;
|
|
@@ -51,6 +51,7 @@ export function isUploadEditPending(pending: PendingApproval): boolean {
|
|
|
51
51
|
export function pickerSelectedId(kind: SlashPickerKind, current: DesktopState): string | undefined {
|
|
52
52
|
if (kind === "model") return current.modelId;
|
|
53
53
|
if (kind === "mode") return current.mode;
|
|
54
|
+
if (kind === "effort") return current.reasoningEffort;
|
|
54
55
|
if (kind === "image") return current.imageModelId;
|
|
55
56
|
if (kind === "video") return current.videoModelId;
|
|
56
57
|
if (kind === "transcribe") return current.transcribeModelId;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from "react";
|
|
10
10
|
import { draftAfterPicker } from "../../src/cli/slash";
|
|
11
11
|
import { AGENT_MODES } from "../../src/core/mode";
|
|
12
|
+
import { DEFAULT_REASONING_EFFORT, REASONING_EFFORTS } from "../../src/core/reasoning";
|
|
12
13
|
import {
|
|
13
14
|
type BridgeClient,
|
|
14
15
|
type DesktopState,
|
|
@@ -55,7 +56,7 @@ export function useDeskPicker(input: {
|
|
|
55
56
|
const pickerRequestRef = useRef(0);
|
|
56
57
|
|
|
57
58
|
const openComposerPicker = useCallback(
|
|
58
|
-
async (kind: "model" | "mode") => {
|
|
59
|
+
async (kind: "model" | "mode" | "effort") => {
|
|
59
60
|
if (
|
|
60
61
|
!bridge ||
|
|
61
62
|
listening ||
|
|
@@ -84,6 +85,21 @@ export function useDeskPicker(input: {
|
|
|
84
85
|
setStatus("picker");
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
88
|
+
if (kind === "effort") {
|
|
89
|
+
const items = REASONING_EFFORTS.map((id) => ({
|
|
90
|
+
id,
|
|
91
|
+
label: id,
|
|
92
|
+
...(id === DEFAULT_REASONING_EFFORT ? { hint: "default" } : {}),
|
|
93
|
+
}));
|
|
94
|
+
setPicker({
|
|
95
|
+
title: "Reasoning effort",
|
|
96
|
+
kind: "effort",
|
|
97
|
+
items,
|
|
98
|
+
index: pickerStartIndex(items, state?.reasoningEffort),
|
|
99
|
+
});
|
|
100
|
+
setStatus("picker");
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
87
103
|
try {
|
|
88
104
|
const result = await getModels(bridge);
|
|
89
105
|
if (requestId !== pickerRequestRef.current) return;
|
package/package.json
CHANGED
package/src/cli/main.test.ts
CHANGED
|
@@ -40,6 +40,18 @@ describe("parseCliArgs", () => {
|
|
|
40
40
|
expect(parsed.message).toBe("hello");
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
+
test("reads --effort", () => {
|
|
44
|
+
const parsed = parseCliArgs(["--effort", "high", "chat", "-m", "hello"]);
|
|
45
|
+
expect(parsed.cmd).toBe("chat");
|
|
46
|
+
expect(parsed.effort).toBe("high");
|
|
47
|
+
expect(parsed.message).toBe("hello");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("treats a bare --effort as present with no value", () => {
|
|
51
|
+
expect(parseCliArgs(["--effort"]).effort).toBe("");
|
|
52
|
+
expect(parseCliArgs(["chat", "-m", "hello"]).effort).toBeUndefined();
|
|
53
|
+
});
|
|
54
|
+
|
|
43
55
|
test("marks --cwd as explicit", () => {
|
|
44
56
|
expect(parseCliArgs(["eval"]).cwdExplicit).toBe(false);
|
|
45
57
|
expect(parseCliArgs(["--cwd", "/tmp/proj", "eval"]).cwdExplicit).toBe(true);
|
package/src/cli/main.ts
CHANGED
|
@@ -8,6 +8,11 @@ import { loadConfig, resolveOpenRouter } from "../config.ts";
|
|
|
8
8
|
import { errorMessage } from "../core/errors.ts";
|
|
9
9
|
import type { AgentEvent } from "../core/events.ts";
|
|
10
10
|
import { type AgentMode, tryParseAgentMode } from "../core/mode.ts";
|
|
11
|
+
import {
|
|
12
|
+
REASONING_EFFORT_USAGE,
|
|
13
|
+
type ReasoningEffort,
|
|
14
|
+
tryParseReasoningEffort,
|
|
15
|
+
} from "../core/reasoning.ts";
|
|
11
16
|
import { formatUsage } from "../core/usage.ts";
|
|
12
17
|
import { applyStoredOpenRouterKey } from "../desktop/secrets.ts";
|
|
13
18
|
import { createOpenRouterChat, listEvalSuites, runNamedEval } from "../evals/runner.ts";
|
|
@@ -53,6 +58,8 @@ Usage:
|
|
|
53
58
|
|
|
54
59
|
Flags:
|
|
55
60
|
--mode ask|plan|agent Read-only, plan, or implement (default agent)
|
|
61
|
+
--effort none|minimal|low|medium|high|xhigh
|
|
62
|
+
OpenRouter reasoning effort (default low)
|
|
56
63
|
--cwd <path> Workspace folder
|
|
57
64
|
-m, --message <text> Chat message
|
|
58
65
|
--name <name> Init project name (with --examples)
|
|
@@ -71,7 +78,7 @@ Install in another project:
|
|
|
71
78
|
bun add github:useAvalon/caelence-agent
|
|
72
79
|
bunx ${CLI_NAME}
|
|
73
80
|
|
|
74
|
-
Desktop: paste an OpenRouter key in Settings. Optional env: OPENROUTER_API_KEY, OPENROUTER_MODEL, OPENROUTER_BASE_URL
|
|
81
|
+
Desktop: paste an OpenRouter key in Settings. Optional env: OPENROUTER_API_KEY, OPENROUTER_MODEL, OPENROUTER_BASE_URL, HARNESS_REASONING_EFFORT
|
|
75
82
|
Optional Langfuse: LANGFUSE_SECRET_KEY, LANGFUSE_PUBLIC_KEY, LANGFUSE_BASE_URL
|
|
76
83
|
Optional LLM-as-judge: LANGFUSE_QUALITY_EVAL=1 (off unless set; spends OpenRouter)
|
|
77
84
|
`);
|
|
@@ -144,13 +151,21 @@ function hasCargo(env: NodeJS.ProcessEnv): boolean {
|
|
|
144
151
|
return existsSync(resolve(homedir(), ".cargo/bin/cargo"));
|
|
145
152
|
}
|
|
146
153
|
|
|
147
|
-
function takeFlag(
|
|
154
|
+
function takeFlag(
|
|
155
|
+
args: string[],
|
|
156
|
+
name: string,
|
|
157
|
+
): {
|
|
158
|
+
value?: string;
|
|
159
|
+
rest: string[];
|
|
160
|
+
present: boolean;
|
|
161
|
+
} {
|
|
148
162
|
const idx = args.indexOf(name);
|
|
149
|
-
if (idx < 0) return { rest: args };
|
|
163
|
+
if (idx < 0) return { rest: args, present: false };
|
|
150
164
|
const value = args[idx + 1];
|
|
151
165
|
return {
|
|
152
166
|
value,
|
|
153
167
|
rest: [...args.slice(0, idx), ...args.slice(idx + 2)],
|
|
168
|
+
present: true,
|
|
154
169
|
};
|
|
155
170
|
}
|
|
156
171
|
|
|
@@ -162,6 +177,7 @@ export function parseCliArgs(argv: string[]): {
|
|
|
162
177
|
name?: string;
|
|
163
178
|
message?: string;
|
|
164
179
|
mode?: string;
|
|
180
|
+
effort?: string;
|
|
165
181
|
} {
|
|
166
182
|
let args = argv;
|
|
167
183
|
const cwdFlag = takeFlag(args, "--cwd");
|
|
@@ -170,6 +186,8 @@ export function parseCliArgs(argv: string[]): {
|
|
|
170
186
|
args = nameFlag.rest;
|
|
171
187
|
const modeFlag = takeFlag(args, "--mode");
|
|
172
188
|
args = modeFlag.rest;
|
|
189
|
+
const effortFlag = takeFlag(args, "--effort");
|
|
190
|
+
args = effortFlag.rest;
|
|
173
191
|
const shortMsg = takeFlag(args, "-m");
|
|
174
192
|
args = shortMsg.rest;
|
|
175
193
|
const longMsg = takeFlag(args, "--message");
|
|
@@ -183,6 +201,7 @@ export function parseCliArgs(argv: string[]): {
|
|
|
183
201
|
name: nameFlag.value,
|
|
184
202
|
message: shortMsg.value ?? longMsg.value,
|
|
185
203
|
mode: modeFlag.value,
|
|
204
|
+
effort: effortFlag.present ? (effortFlag.value ?? "") : undefined,
|
|
186
205
|
};
|
|
187
206
|
}
|
|
188
207
|
|
|
@@ -191,6 +210,11 @@ function resolveCliMode(raw: string | undefined): AgentMode | undefined | "inval
|
|
|
191
210
|
return tryParseAgentMode(raw) ?? "invalid";
|
|
192
211
|
}
|
|
193
212
|
|
|
213
|
+
function resolveCliEffort(raw: string | undefined): ReasoningEffort | undefined | "invalid" {
|
|
214
|
+
if (raw === undefined) return undefined;
|
|
215
|
+
return tryParseReasoningEffort(raw) ?? "invalid";
|
|
216
|
+
}
|
|
217
|
+
|
|
194
218
|
type ParsedCli = ReturnType<typeof parseCliArgs>;
|
|
195
219
|
|
|
196
220
|
function agentCwd(parsed: ParsedCli): string {
|
|
@@ -387,11 +411,17 @@ async function runChat(parsed: ParsedCli, mode: AgentMode | undefined): Promise<
|
|
|
387
411
|
process.stderr.write(`${CLI_NAME} chat -m <text>\n`);
|
|
388
412
|
return 1;
|
|
389
413
|
}
|
|
414
|
+
const effort = resolveCliEffort(parsed.effort);
|
|
415
|
+
if (effort === "invalid") {
|
|
416
|
+
process.stderr.write(`${REASONING_EFFORT_USAGE}\n`);
|
|
417
|
+
return 1;
|
|
418
|
+
}
|
|
390
419
|
const tty = Boolean(process.stdin.isTTY);
|
|
391
420
|
const harness = await createHarness({
|
|
392
421
|
cwd: agentCwd(parsed),
|
|
393
422
|
approvalPolicy: tty ? undefined : "deny",
|
|
394
423
|
...(mode ? { mode } : {}),
|
|
424
|
+
...(effort ? { reasoningEffort: effort } : {}),
|
|
395
425
|
});
|
|
396
426
|
try {
|
|
397
427
|
await harness.runTurn(message, printEvent, {
|
|
@@ -409,10 +439,15 @@ async function runChat(parsed: ParsedCli, mode: AgentMode | undefined): Promise<
|
|
|
409
439
|
return 0;
|
|
410
440
|
}
|
|
411
441
|
|
|
412
|
-
async function runTui(
|
|
442
|
+
async function runTui(
|
|
443
|
+
cwd: string,
|
|
444
|
+
mode: AgentMode | undefined,
|
|
445
|
+
effort: ReasoningEffort | undefined,
|
|
446
|
+
): Promise<number> {
|
|
413
447
|
const harness = await createHarness({
|
|
414
448
|
cwd,
|
|
415
449
|
...(mode ? { mode } : {}),
|
|
450
|
+
...(effort ? { reasoningEffort: effort } : {}),
|
|
416
451
|
});
|
|
417
452
|
try {
|
|
418
453
|
await startTui(harness);
|
|
@@ -461,8 +496,13 @@ export async function main(argv = process.argv.slice(2)): Promise<number> {
|
|
|
461
496
|
process.stderr.write("Mode is ask, plan, or agent.\n");
|
|
462
497
|
return 1;
|
|
463
498
|
}
|
|
499
|
+
const effort = resolveCliEffort(parsed.effort);
|
|
500
|
+
if (effort === "invalid") {
|
|
501
|
+
process.stderr.write(`${REASONING_EFFORT_USAGE}\n`);
|
|
502
|
+
return 1;
|
|
503
|
+
}
|
|
464
504
|
applyStoredOpenRouterKey();
|
|
465
|
-
return runTui(agentCwd(parsed), mode);
|
|
505
|
+
return runTui(agentCwd(parsed), mode, effort);
|
|
466
506
|
}
|
|
467
507
|
const handler = COMMANDS[cmd];
|
|
468
508
|
if (handler) return handler(parsed);
|
|
@@ -35,6 +35,7 @@ function fakeHarness(overrides: Partial<HarnessRuntime> = {}): HarnessRuntime {
|
|
|
35
35
|
systemPrompt: "",
|
|
36
36
|
modelId: "openai/gpt-5.6-sol",
|
|
37
37
|
mode: "agent",
|
|
38
|
+
reasoningEffort: "low",
|
|
38
39
|
runTurn: async () => undefined,
|
|
39
40
|
setModel(id) {
|
|
40
41
|
this.modelId = id;
|
|
@@ -42,6 +43,9 @@ function fakeHarness(overrides: Partial<HarnessRuntime> = {}): HarnessRuntime {
|
|
|
42
43
|
setMode(mode) {
|
|
43
44
|
this.mode = mode;
|
|
44
45
|
},
|
|
46
|
+
setReasoningEffort(effort) {
|
|
47
|
+
this.reasoningEffort = effort;
|
|
48
|
+
},
|
|
45
49
|
hasApiKey: false,
|
|
46
50
|
setApiKey() {},
|
|
47
51
|
setSession() {},
|
|
@@ -178,6 +182,45 @@ describe("dispatchSlash", () => {
|
|
|
178
182
|
expect(harness.mode).toBe("agent");
|
|
179
183
|
});
|
|
180
184
|
|
|
185
|
+
test("effort without an argument opens a picker", async () => {
|
|
186
|
+
const result = await dispatchSlash(fakeHarness(), "/effort");
|
|
187
|
+
expect(result.kind).toBe("picker");
|
|
188
|
+
if (result.kind === "picker") {
|
|
189
|
+
expect(result.picker).toBe("effort");
|
|
190
|
+
expect(result.items.map((item) => item.id)).toEqual([
|
|
191
|
+
"none",
|
|
192
|
+
"minimal",
|
|
193
|
+
"low",
|
|
194
|
+
"medium",
|
|
195
|
+
"high",
|
|
196
|
+
"xhigh",
|
|
197
|
+
]);
|
|
198
|
+
expect(result.items.find((item) => item.id === "low")?.hint).toBe("default");
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
test("effort picker stores the effort without a transcript line", async () => {
|
|
203
|
+
const harness = fakeHarness();
|
|
204
|
+
const result = await applyPickerChoice(harness, "effort", "high");
|
|
205
|
+
expect(result).toEqual({ kind: "applied" });
|
|
206
|
+
expect(harness.reasoningEffort).toBe("high");
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
test("effort with a value sets it", async () => {
|
|
210
|
+
const harness = fakeHarness();
|
|
211
|
+
const result = await dispatchSlash(harness, "/effort xhigh");
|
|
212
|
+
expect(result).toEqual({ kind: "applied" });
|
|
213
|
+
expect(harness.reasoningEffort).toBe("xhigh");
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
test("effort rejects an unknown value", async () => {
|
|
217
|
+
const result = await dispatchSlash(fakeHarness(), "/effort max");
|
|
218
|
+
expect(result).toEqual({
|
|
219
|
+
kind: "text",
|
|
220
|
+
text: "Effort is none, minimal, low, medium, high, or xhigh.",
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
181
224
|
test("skill picker adds a catalog skill and disables project skills", async () => {
|
|
182
225
|
const harness = fakeHarness();
|
|
183
226
|
const added = await applyPickerChoice(harness, "skill", "obra/superpowers@brainstorming");
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { resolveOpenRouter } from "../config.ts";
|
|
2
2
|
import { errorMessage } from "../core/errors.ts";
|
|
3
3
|
import { AGENT_MODES, tryParseAgentMode } from "../core/mode.ts";
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_REASONING_EFFORT,
|
|
6
|
+
REASONING_EFFORT_USAGE,
|
|
7
|
+
REASONING_EFFORTS,
|
|
8
|
+
tryParseReasoningEffort,
|
|
9
|
+
} from "../core/reasoning.ts";
|
|
4
10
|
import type { Session } from "../core/session.ts";
|
|
5
11
|
import { maskSecret, writeOpenRouterKey } from "../desktop/secrets.ts";
|
|
6
12
|
import { listEvalSuites, runNamedEval } from "../evals/runner.ts";
|
|
@@ -37,6 +43,7 @@ import { formatSkillList, parseSlashLine, resolveSlashSubmit, SLASH_HELP } from
|
|
|
37
43
|
export type SlashPickerKind =
|
|
38
44
|
| "model"
|
|
39
45
|
| "mode"
|
|
46
|
+
| "effort"
|
|
40
47
|
| "resume"
|
|
41
48
|
| "image"
|
|
42
49
|
| "video"
|
|
@@ -58,6 +65,7 @@ export type SlashOutcome =
|
|
|
58
65
|
const PICKER_KINDS = new Set<SlashPickerKind>([
|
|
59
66
|
"model",
|
|
60
67
|
"mode",
|
|
68
|
+
"effort",
|
|
61
69
|
"resume",
|
|
62
70
|
"image",
|
|
63
71
|
"video",
|
|
@@ -292,6 +300,25 @@ async function handleMode(harness: HarnessRuntime, arg: string): Promise<SlashOu
|
|
|
292
300
|
};
|
|
293
301
|
}
|
|
294
302
|
|
|
303
|
+
async function handleEffort(harness: HarnessRuntime, arg: string): Promise<SlashOutcome> {
|
|
304
|
+
if (arg) {
|
|
305
|
+
const next = tryParseReasoningEffort(arg);
|
|
306
|
+
if (!next) return { kind: "text", text: REASONING_EFFORT_USAGE };
|
|
307
|
+
harness.setReasoningEffort(next);
|
|
308
|
+
return { kind: "applied" };
|
|
309
|
+
}
|
|
310
|
+
return {
|
|
311
|
+
kind: "picker",
|
|
312
|
+
title: "Reasoning effort",
|
|
313
|
+
picker: "effort",
|
|
314
|
+
items: REASONING_EFFORTS.map((item) => ({
|
|
315
|
+
id: item,
|
|
316
|
+
label: item,
|
|
317
|
+
...(item === DEFAULT_REASONING_EFFORT ? { hint: "default" } : {}),
|
|
318
|
+
})),
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
|
|
295
322
|
async function handleMediaPicker(
|
|
296
323
|
harness: HarnessRuntime,
|
|
297
324
|
arg: string,
|
|
@@ -437,6 +464,7 @@ const SLASH_HANDLERS: Record<string, SlashHandler> = {
|
|
|
437
464
|
},
|
|
438
465
|
model: handleModel,
|
|
439
466
|
mode: handleMode,
|
|
467
|
+
effort: handleEffort,
|
|
440
468
|
compact: async (harness) => {
|
|
441
469
|
const ok = await harness.compact();
|
|
442
470
|
return { kind: "text", text: ok ? "Compacted earlier turns." : "Nothing to compact." };
|
|
@@ -504,6 +532,12 @@ export async function applyPickerChoice(
|
|
|
504
532
|
harness.setMode(next);
|
|
505
533
|
return { kind: "applied" };
|
|
506
534
|
}
|
|
535
|
+
if (picker === "effort") {
|
|
536
|
+
const next = tryParseReasoningEffort(id);
|
|
537
|
+
if (!next) return { kind: "text", text: REASONING_EFFORT_USAGE };
|
|
538
|
+
harness.setReasoningEffort(next);
|
|
539
|
+
return { kind: "applied" };
|
|
540
|
+
}
|
|
507
541
|
const writePref = MEDIA_PICKER_PREFS[picker];
|
|
508
542
|
if (writePref) {
|
|
509
543
|
writePref(id);
|
package/src/cli/slash.test.ts
CHANGED
|
@@ -121,6 +121,7 @@ describe("resolveSlashSubmit", () => {
|
|
|
121
121
|
test("opens pickers for empty model, mode, and media commands", () => {
|
|
122
122
|
expect(resolveSlashSubmit("/image")).toEqual({ action: "send", line: "/image" });
|
|
123
123
|
expect(resolveSlashSubmit("/mode")).toEqual({ action: "send", line: "/mode" });
|
|
124
|
+
expect(resolveSlashSubmit("/effort")).toEqual({ action: "send", line: "/effort" });
|
|
124
125
|
expect(resolveSlashSubmit("/integrations")).toEqual({ action: "send", line: "/integrations" });
|
|
125
126
|
expect(resolveSlashSubmit("/skill find")).toEqual({ action: "send", line: "/skill find" });
|
|
126
127
|
expect(resolveSlashSubmit("/settings")).toEqual({ action: "send", line: "/settings" });
|
package/src/cli/slash.ts
CHANGED
|
@@ -19,6 +19,7 @@ export const SLASH_COMMANDS: SlashCommand[] = [
|
|
|
19
19
|
{ name: "resume", hint: "pick a session by title" },
|
|
20
20
|
{ name: "model", hint: "pick a model" },
|
|
21
21
|
{ name: "mode", hint: "ask, plan, or agent" },
|
|
22
|
+
{ name: "effort", hint: "reasoning effort" },
|
|
22
23
|
{ name: "compact", hint: "summarize earlier turns" },
|
|
23
24
|
{ name: "memory", hint: "remember across chats", arg: true },
|
|
24
25
|
{ name: "image", hint: "generate an image", arg: true, slot: "[prompt]" },
|
|
@@ -58,6 +59,7 @@ export function formatSlashCommand(command: SlashCommand): string {
|
|
|
58
59
|
export const PICKS_WHEN_EMPTY = new Set([
|
|
59
60
|
"model",
|
|
60
61
|
"mode",
|
|
62
|
+
"effort",
|
|
61
63
|
"resume",
|
|
62
64
|
"image",
|
|
63
65
|
"video",
|
package/src/cli/tui.tsx
CHANGED
|
@@ -170,6 +170,7 @@ function Header(
|
|
|
170
170
|
title: string;
|
|
171
171
|
status: UiStatus;
|
|
172
172
|
mode: string;
|
|
173
|
+
effort: string;
|
|
173
174
|
spend?: string;
|
|
174
175
|
}>,
|
|
175
176
|
): React.ReactElement {
|
|
@@ -184,7 +185,7 @@ function Header(
|
|
|
184
185
|
<Text bold> {PRODUCT_NAME}</Text>
|
|
185
186
|
<Text color={props.theme.muted}>
|
|
186
187
|
{" "}
|
|
187
|
-
{props.title} · {props.mode} · {label}
|
|
188
|
+
{props.title} · {props.mode} · {props.effort} · {label}
|
|
188
189
|
{target && target.toLowerCase() !== label.toLowerCase() ? ` · ${target}` : ""}
|
|
189
190
|
{props.spend ? ` · ${props.spend}` : ""}
|
|
190
191
|
</Text>
|
|
@@ -464,6 +465,7 @@ function ApprovalCard(props: Readonly<{ theme: Theme; req: ApprovalRequest }>):
|
|
|
464
465
|
function pickerSelectedValue(picker: SlashPickerKind, harness: HarnessRuntime): string | undefined {
|
|
465
466
|
if (picker === "model") return harness.modelId;
|
|
466
467
|
if (picker === "mode") return harness.mode;
|
|
468
|
+
if (picker === "effort") return harness.reasoningEffort;
|
|
467
469
|
const prefs = readMediaPrefs();
|
|
468
470
|
if (picker === "image") return prefs.imageModel;
|
|
469
471
|
if (picker === "video") return prefs.videoModel;
|
|
@@ -663,6 +665,7 @@ function App(props: Readonly<{ harness: HarnessRuntime; theme: Theme }>): React.
|
|
|
663
665
|
const [title, setTitle] = useState("New chat");
|
|
664
666
|
const [model, setModel] = useState(harness.modelId);
|
|
665
667
|
const [mode, setMode] = useState(harness.mode);
|
|
668
|
+
const [effort, setEffort] = useState(harness.reasoningEffort);
|
|
666
669
|
const [mediaLine, setMediaLine] = useState(() => formatMediaComposerLine(readMediaPrefs()));
|
|
667
670
|
const [spend, setSpend] = useState<TokenUsage | undefined>(harness.spend);
|
|
668
671
|
const [slashIndex, setSlashIndex] = useState(0);
|
|
@@ -772,6 +775,7 @@ function App(props: Readonly<{ harness: HarnessRuntime; theme: Theme }>): React.
|
|
|
772
775
|
}
|
|
773
776
|
setModel(harness.modelId);
|
|
774
777
|
setMode(harness.mode);
|
|
778
|
+
setEffort(harness.reasoningEffort);
|
|
775
779
|
refreshMedia();
|
|
776
780
|
const nextDraft = draftAfterPicker(state.kind);
|
|
777
781
|
if (nextDraft) setValue(nextDraft);
|
|
@@ -815,6 +819,7 @@ function App(props: Readonly<{ harness: HarnessRuntime; theme: Theme }>): React.
|
|
|
815
819
|
if (outcome.kind === "applied" || outcome.kind === "hold") {
|
|
816
820
|
setModel(harness.modelId);
|
|
817
821
|
setMode(harness.mode);
|
|
822
|
+
setEffort(harness.reasoningEffort);
|
|
818
823
|
refreshMedia();
|
|
819
824
|
return;
|
|
820
825
|
}
|
|
@@ -826,6 +831,7 @@ function App(props: Readonly<{ harness: HarnessRuntime; theme: Theme }>): React.
|
|
|
826
831
|
pushSystem(outcome.text);
|
|
827
832
|
setModel(harness.modelId);
|
|
828
833
|
setMode(harness.mode);
|
|
834
|
+
setEffort(harness.reasoningEffort);
|
|
829
835
|
return;
|
|
830
836
|
}
|
|
831
837
|
if (outcome.kind === "clear") {
|
|
@@ -988,6 +994,7 @@ function App(props: Readonly<{ harness: HarnessRuntime; theme: Theme }>): React.
|
|
|
988
994
|
title={title}
|
|
989
995
|
status={status}
|
|
990
996
|
mode={mode}
|
|
997
|
+
effort={effort}
|
|
991
998
|
spend={spend ? formatUsage(spend) : undefined}
|
|
992
999
|
/>
|
|
993
1000
|
{picker ? (
|
package/src/config.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { Theme, ThemeName } from "./cli/theme.ts";
|
|
|
6
6
|
import type { ExecApprovalPolicy } from "./core/approval.ts";
|
|
7
7
|
import type { HookConfig } from "./core/hooks.ts";
|
|
8
8
|
import type { AgentMode } from "./core/mode.ts";
|
|
9
|
+
import type { ReasoningEffort } from "./core/reasoning.ts";
|
|
9
10
|
import type { HarnessDecisionsConfig } from "./decisions/config.ts";
|
|
10
11
|
import type { StatusVerbsConfig } from "./status/status-verbs.ts";
|
|
11
12
|
|
|
@@ -18,6 +19,11 @@ export interface ExtraMcpServerConfig {
|
|
|
18
19
|
export interface HarnessConfig {
|
|
19
20
|
name: string;
|
|
20
21
|
model: string;
|
|
22
|
+
/**
|
|
23
|
+
* OpenRouter reasoning effort for the chat model (`none`, `minimal`, `low`, `medium`, `high`,
|
|
24
|
+
* `xhigh`). Defaults to `low`. `HARNESS_REASONING_EFFORT` overrides it.
|
|
25
|
+
*/
|
|
26
|
+
reasoningEffort?: ReasoningEffort;
|
|
21
27
|
instructionsFile: string;
|
|
22
28
|
skillsDir: string;
|
|
23
29
|
evalsDir: string;
|
|
@@ -80,6 +86,7 @@ export const OPENROUTER_DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
|
|
|
80
86
|
export const DEFAULT_CONFIG: HarnessConfig = {
|
|
81
87
|
name: "caelence",
|
|
82
88
|
model: DEFAULT_MODEL,
|
|
89
|
+
reasoningEffort: "low",
|
|
83
90
|
instructionsFile: "AGENTS.md",
|
|
84
91
|
skillsDir: "skills",
|
|
85
92
|
evalsDir: "evals",
|