@useavalon/caelence-agent 0.4.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 +29 -4
- package/desktop/src/DeskComposer.tsx +10 -0
- package/desktop/src/SettingsPanel.tsx +18 -0
- package/desktop/src/api.ts +12 -1
- package/desktop/src/app.css +8 -3
- package/desktop/src/desk-types.ts +1 -0
- package/desktop/src/desktop-turn.ts +7 -0
- package/desktop/src/stream.ts +1 -0
- package/desktop/src/thought.test.ts +16 -0
- package/desktop/src/thought.ts +15 -4
- package/desktop/src/turn-verbs.ts +14 -0
- package/desktop/src/useDeskPicker.ts +17 -1
- package/package.json +7 -4
- 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-progress.ts +15 -3
- package/src/cli/tui.tsx +15 -1
- package/src/config.ts +38 -2
- package/src/core/events.ts +12 -9
- package/src/core/mode.ts +5 -0
- 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 +13 -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 +77 -1
- package/src/memory/brief.ts +62 -0
- package/src/memory/embeddings.ts +104 -0
- package/src/memory/extract.ts +9 -8
- package/src/memory/layered.test.ts +202 -0
- package/src/memory/layered.ts +125 -0
- package/src/memory/memory-store.test.ts +299 -0
- package/src/memory/memory-store.ts +295 -0
- package/src/memory/store.ts +70 -20
- package/src/observability/langfuse.ts +9 -2
- package/src/observability/types.ts +5 -0
- package/src/runtime.test.ts +27 -0
- package/src/runtime.ts +164 -34
- package/src/status/categories.ts +64 -0
- package/src/status/default-verbs.ts +190 -0
- package/src/status/status-verb-categories.json +6167 -0
- package/src/status/status-verbs.test.ts +209 -0
- package/src/status/status-verbs.ts +62 -0
- package/src/tools/background.test.ts +304 -0
- package/src/tools/background.ts +432 -0
- package/src/tools/memory.ts +94 -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
|
|
@@ -234,10 +236,33 @@ Because the agent acts as you on every site you are signed in to, this backend i
|
|
|
234
236
|
|
|
235
237
|
These checks stand in front of a model. They are not a security boundary, and a page can still try to talk the agent into something. Playwright is pinned to 0.0.83.
|
|
236
238
|
|
|
239
|
+
## Background agents
|
|
240
|
+
|
|
241
|
+
The agent can start subagents that run while it keeps working. `spawn_agent` returns an id at once, `await_agents` collects the reports, and `cancel_agent` stops one. Explore agents get only the tools that declare themselves read-only, and are the default; in ask and plan mode they are the only kind. An agent never outlives the turn that started it.
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
export default {
|
|
245
|
+
subagents: {
|
|
246
|
+
exploreModel: "z-ai/glm-5.2", // a small fast model for search; defaults to the chat model
|
|
247
|
+
maxConcurrent: 4,
|
|
248
|
+
maxPerTurn: 12,
|
|
249
|
+
// background: false turns spawn_agent off and keeps the blocking `task` tool
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
`HARNESS_EXPLORE_MODEL` and `HARNESS_SUBAGENT_MODEL` override the models. A host that calls `runTurn` itself builds the same tools with `createBackgroundAgents`.
|
|
255
|
+
|
|
237
256
|
## Memory
|
|
238
257
|
|
|
239
258
|
Turn it on from the Memory tab or `/memory on` if you want later chats to keep prefs and project decisions. After a turn the model adds a few of those to `~/.harness/memory` and `.harness/memory`, and the next session only sees the ones that fit what you asked. `/memory` lists them, `/memory delete 1` removes a line, and `/memory pin 1` copies it into `AGENTS.md`.
|
|
240
259
|
|
|
260
|
+
Recall matches on words by default. Set `memory.embeddings.enabled` (or `HARNESS_MEMORY_EMBEDDINGS=<model>`) to also match on meaning; fact text is then sent to the embeddings endpoint of your OpenRouter base URL, and the vectors are kept in `vectors.json` beside the facts. When memory is on the agent also gets `memory_search` and `memory_save`.
|
|
261
|
+
|
|
262
|
+
A host keeps memory in its own database by passing a `MemoryStore` to `createHarness`, or by implementing `MemoryBackend` (load, insert, remove, and optionally a vector index) and wrapping it with `createMemoryStore`.
|
|
263
|
+
|
|
264
|
+
For shared context across a team, `createLayeredMemoryStore` reads several stores as one, narrowest first (a project, then its workspace). The agent writes to the narrowest layer only; `promote` moves a fact wider, which a host does when a person asks. `synthesizeMemoryBrief` turns a scope's facts into a short brief to put in the prompt.
|
|
265
|
+
|
|
241
266
|
## Library
|
|
242
267
|
|
|
243
268
|
The desktop, the terminal UI, and `caelence chat -m` all call `createHarness`, so you can drive the same runtime from a bot, a script, or another host UI.
|
|
@@ -257,7 +282,7 @@ await harness.runTurn("fix the failing test", (event) => {
|
|
|
257
282
|
harness.close();
|
|
258
283
|
```
|
|
259
284
|
|
|
260
|
-
`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.
|
|
261
286
|
|
|
262
287
|
If you only need types or tracing, `HarnessConfig` / `loadConfig` and the observability entry do not require constructing a harness at all.
|
|
263
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 }
|
|
@@ -87,6 +95,7 @@ export type AgentEvent =
|
|
|
87
95
|
}
|
|
88
96
|
| { kind: "approval_request"; callId: string; toolName: string; input: Record<string, unknown> }
|
|
89
97
|
| { kind: "session_meta"; sessionId: string; title: string }
|
|
98
|
+
| { kind: "status"; verbs: string[] }
|
|
90
99
|
| {
|
|
91
100
|
kind: "usage";
|
|
92
101
|
promptTokens: number;
|
|
@@ -160,6 +169,7 @@ export interface DesktopSettings {
|
|
|
160
169
|
hasApiKey: boolean;
|
|
161
170
|
apiKeyHint: string;
|
|
162
171
|
mode: string;
|
|
172
|
+
reasoningEffort: string;
|
|
163
173
|
modelId: string;
|
|
164
174
|
modelLabel: string;
|
|
165
175
|
hasGoogleOAuth: boolean;
|
|
@@ -414,6 +424,7 @@ export function saveSettings(
|
|
|
414
424
|
apiKey?: string;
|
|
415
425
|
mode?: string;
|
|
416
426
|
modelId?: string;
|
|
427
|
+
reasoningEffort?: string;
|
|
417
428
|
googleClientId?: string;
|
|
418
429
|
googleClientSecret?: string;
|
|
419
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;
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
type StreamLine,
|
|
24
24
|
truncateAfterUserTurn,
|
|
25
25
|
} from "./stream";
|
|
26
|
+
import { setTurnVerbs } from "./turn-verbs";
|
|
26
27
|
|
|
27
28
|
export function applyDesktopTurnEvent(
|
|
28
29
|
event: AgentEvent,
|
|
@@ -42,6 +43,12 @@ export function applyDesktopTurnEvent(
|
|
|
42
43
|
});
|
|
43
44
|
setStatus("approval");
|
|
44
45
|
}
|
|
46
|
+
if (event.kind === "status") {
|
|
47
|
+
setTurnVerbs(event.verbs);
|
|
48
|
+
// A new array so the thinking label renders again with the verbs.
|
|
49
|
+
setLines((prev) => [...prev]);
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
45
52
|
setLines((prev) => applyEvent(prev, event));
|
|
46
53
|
return event.kind === "completion" || event.kind === "error";
|
|
47
54
|
}
|
package/desktop/src/stream.ts
CHANGED
|
@@ -140,4 +140,20 @@ describe("thought fold", () => {
|
|
|
140
140
|
expect(blocks[1].entries[0]).toEqual({ type: "note", text: "I should look this up." });
|
|
141
141
|
expect(blocks[1].entries[1]?.type).toBe("tool");
|
|
142
142
|
});
|
|
143
|
+
|
|
144
|
+
test("the turn's verbs replace the plain phrases", () => {
|
|
145
|
+
const verbs = ["Brewing", "Baking", "Kneading"];
|
|
146
|
+
expect(liveStatusPhrases([], true, verbs)).toEqual(verbs);
|
|
147
|
+
const reading = liveStatusPhrases(
|
|
148
|
+
[
|
|
149
|
+
{ key: "t", type: "tool", name: "read_file", label: "Reading a.ts", status: "running" },
|
|
150
|
+
] as never,
|
|
151
|
+
false,
|
|
152
|
+
verbs,
|
|
153
|
+
);
|
|
154
|
+
expect(reading[0]).toBe("Reading a.ts");
|
|
155
|
+
expect(reading).toContain("Brewing");
|
|
156
|
+
expect(reading).toContain("Baking");
|
|
157
|
+
expect(reading).not.toContain("Thinking");
|
|
158
|
+
});
|
|
143
159
|
});
|
package/desktop/src/thought.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { pipelineProgress } from "./pipeline";
|
|
|
2
2
|
import { isPlatformTool } from "./platform";
|
|
3
3
|
import type { StreamLine } from "./stream";
|
|
4
4
|
import { eventCountSuffix } from "./tool-label";
|
|
5
|
+
import { turnVerbs } from "./turn-verbs";
|
|
5
6
|
|
|
6
7
|
export type ToolLine = Extract<StreamLine, { type: "tool" }>;
|
|
7
8
|
|
|
@@ -66,8 +67,16 @@ export function warmupHeadline(seed: number): string {
|
|
|
66
67
|
return WARMUP_PHRASES[Math.abs(seed) % WARMUP_PHRASES.length] ?? "Thinking";
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
/**
|
|
71
|
+
* The phrases the thinking label rotates through. `verbs` are the turn's verbs from its `status`
|
|
72
|
+
* event; without them the plain phrases are used.
|
|
73
|
+
*/
|
|
74
|
+
export function liveStatusPhrases(
|
|
75
|
+
tools: ToolLine[],
|
|
76
|
+
warmup = false,
|
|
77
|
+
verbs: readonly string[] = turnVerbs(),
|
|
78
|
+
): string[] {
|
|
79
|
+
if (warmup || tools.length === 0) return verbs.length > 0 ? [...verbs] : [...WARMUP_PHRASES];
|
|
71
80
|
const pipe = pipelineProgress(tools);
|
|
72
81
|
const out: string[] = [];
|
|
73
82
|
if (pipe) {
|
|
@@ -86,8 +95,10 @@ export function liveStatusPhrases(tools: ToolLine[], warmup = false): string[] {
|
|
|
86
95
|
}
|
|
87
96
|
if (isWriteTool(current)) pushPhrase(out, "Editing");
|
|
88
97
|
}
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
// The tool label stays first; a couple of verbs fill the pauses between steps.
|
|
99
|
+
const [first, second] = verbs;
|
|
100
|
+
pushPhrase(out, first ?? "Thinking");
|
|
101
|
+
pushPhrase(out, second ?? "Looking this over");
|
|
91
102
|
return out;
|
|
92
103
|
}
|
|
93
104
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The verbs the current turn's `status` event carried. The thinking label reads them while it
|
|
3
|
+
* renders. They live outside React state because the label sits several layers below the place
|
|
4
|
+
* events arrive, and they change once per turn.
|
|
5
|
+
*/
|
|
6
|
+
let verbs: readonly string[] = [];
|
|
7
|
+
|
|
8
|
+
export function setTurnVerbs(next: readonly string[]): void {
|
|
9
|
+
verbs = next.filter((verb) => verb.trim().length > 0);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function turnVerbs(): readonly string[] {
|
|
13
|
+
return verbs;
|
|
14
|
+
}
|
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useavalon/caelence-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Caelence agent: Strands turn loop, local tools, skills, evals, and a themable terminal UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"exports": {
|
|
27
27
|
".": "./src/index.ts",
|
|
28
28
|
"./cli": "./src/cli/main.ts",
|
|
29
|
-
"./observability": "./src/observability/index.ts"
|
|
29
|
+
"./observability": "./src/observability/index.ts",
|
|
30
|
+
"./status-verbs": "./src/status/status-verbs.ts"
|
|
30
31
|
},
|
|
31
32
|
"files": [
|
|
32
33
|
"bin",
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
],
|
|
39
40
|
"scripts": {
|
|
40
41
|
"start": "bun bin/harness.ts",
|
|
41
|
-
"test": "bun test src/browser src/decisions src/core src/tools src/skills src/evals src/cli src/observability src/desktop src/integrations src/media src/memory src/init.test.ts src/runtime.test.ts desktop/src/rich-text.test.ts desktop/src/stream.test.ts desktop/src/dictation.test.ts desktop/src/thought.test.ts desktop/src/queue.test.ts desktop/src/composer-files.test.ts desktop/src/tool-label.test.ts desktop/src/reply-sources.test.ts desktop/src/pipeline.test.ts desktop/src/preview-render.test.ts desktop/src/session-search.test.ts desktop/src/session-select.test.ts",
|
|
42
|
+
"test": "bun test src/status src/browser src/decisions src/core src/tools src/skills src/evals src/cli src/observability src/desktop src/integrations src/media src/memory src/init.test.ts src/runtime.test.ts desktop/src/rich-text.test.ts desktop/src/stream.test.ts desktop/src/dictation.test.ts desktop/src/thought.test.ts desktop/src/queue.test.ts desktop/src/composer-files.test.ts desktop/src/tool-label.test.ts desktop/src/reply-sources.test.ts desktop/src/pipeline.test.ts desktop/src/preview-render.test.ts desktop/src/session-search.test.ts desktop/src/session-select.test.ts",
|
|
42
43
|
"typecheck": "bunx tsc --noEmit -p tsconfig.json",
|
|
43
44
|
"lint": "biome ci .",
|
|
44
45
|
"format": "biome format --write .",
|
|
@@ -66,7 +67,9 @@
|
|
|
66
67
|
"@langfuse/client": "^5.11.1",
|
|
67
68
|
"@langfuse/otel": "^5.11.1",
|
|
68
69
|
"@langfuse/tracing": "^5.11.1",
|
|
69
|
-
"@opentelemetry/
|
|
70
|
+
"@opentelemetry/exporter-trace-otlp-http": ">=0.202.0 <0.300.0",
|
|
71
|
+
"@opentelemetry/otlp-exporter-base": ">=0.202.0 <0.300.0",
|
|
72
|
+
"@opentelemetry/sdk-node": ">=0.202.0 <0.300.0"
|
|
70
73
|
},
|
|
71
74
|
"devDependencies": {
|
|
72
75
|
"@biomejs/biome": "^2.5.2",
|
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");
|