@useavalon/caelence-agent 0.2.2-canary.5 → 0.2.2-canary.7
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/desktop/src/App.tsx +226 -74
- package/desktop/src/BubbleClip.tsx +58 -0
- package/desktop/src/PipelineTrack.tsx +19 -0
- package/desktop/src/PlatformPane.tsx +98 -0
- package/desktop/src/ReplySources.tsx +267 -0
- package/desktop/src/ShimmerPhrase.tsx +71 -0
- package/desktop/src/SkillsPanel.tsx +0 -7
- package/desktop/src/api.ts +24 -1
- package/desktop/src/app.css +906 -47
- package/desktop/src/clip.test.ts +16 -0
- package/desktop/src/clip.ts +26 -0
- package/desktop/src/pipeline.test.ts +86 -0
- package/desktop/src/pipeline.ts +131 -0
- package/desktop/src/platform.test.ts +30 -0
- package/desktop/src/platform.ts +76 -0
- package/desktop/src/preview-render.test.ts +79 -0
- package/desktop/src/preview-render.ts +254 -0
- package/desktop/src/queue.test.ts +18 -1
- package/desktop/src/queue.ts +8 -0
- package/desktop/src/reply-sources.test.ts +73 -0
- package/desktop/src/reply-sources.ts +116 -0
- package/desktop/src/rich-text.test.ts +26 -0
- package/desktop/src/rich-text.ts +51 -2
- package/desktop/src/stream.test.ts +41 -2
- package/desktop/src/stream.ts +22 -3
- package/desktop/src/styles/primitives.css +6 -3
- package/desktop/src/thought.test.ts +65 -18
- package/desktop/src/thought.ts +41 -11
- package/desktop/src/tool-label.test.ts +12 -0
- package/desktop/src/tool-label.ts +28 -0
- package/package.json +2 -2
- package/src/cli/models.ts +3 -1
- package/src/cli/openrouter-live.test.ts +29 -0
- package/src/cli/openrouter-live.ts +9 -1
- package/src/core/events.ts +1 -0
- package/src/core/run-turn.ts +7 -0
- package/src/core/session.ts +3 -0
- package/src/desktop/bridge.test.ts +51 -0
- package/src/desktop/bridge.ts +84 -6
- package/src/desktop/preview-kind.test.ts +20 -0
- package/src/desktop/preview-kind.ts +29 -0
package/desktop/src/stream.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AgentEvent } from "./api";
|
|
2
2
|
import type { AttachmentPreview } from "./composer-files";
|
|
3
|
+
import { isPlatformTool, toolEventOutput } from "./platform";
|
|
3
4
|
import { inputFromPreview, toolLabel } from "./tool-label";
|
|
4
5
|
|
|
5
6
|
export type ToolStatus = "running" | "ok" | "fail";
|
|
@@ -24,6 +25,7 @@ export type StreamLine =
|
|
|
24
25
|
count: number;
|
|
25
26
|
preview: string;
|
|
26
27
|
error?: string;
|
|
28
|
+
output?: string;
|
|
27
29
|
}
|
|
28
30
|
| { key: string; type: "system"; text: string }
|
|
29
31
|
| { key: string; type: "error"; text: string }
|
|
@@ -63,7 +65,8 @@ export function previewInput(input: Record<string, unknown>): string {
|
|
|
63
65
|
const pattern = typeof input.pattern === "string" ? input.pattern : undefined;
|
|
64
66
|
const prompt = typeof input.prompt === "string" ? input.prompt : undefined;
|
|
65
67
|
const label = typeof input.label === "string" ? input.label : undefined;
|
|
66
|
-
const
|
|
68
|
+
const name = typeof input.name === "string" ? input.name : undefined;
|
|
69
|
+
const raw = label ?? cmd ?? path ?? pattern ?? prompt ?? name ?? JSON.stringify(input);
|
|
67
70
|
return raw.length > 80 ? `${raw.slice(0, 79)}…` : raw;
|
|
68
71
|
}
|
|
69
72
|
|
|
@@ -86,7 +89,12 @@ export function applyEvent(lines: StreamLine[], event: AgentEvent): StreamLine[]
|
|
|
86
89
|
case "tool_call_start": {
|
|
87
90
|
const label = toolLabel(event.toolName, event.input);
|
|
88
91
|
const last = lines[lines.length - 1];
|
|
89
|
-
if (
|
|
92
|
+
if (
|
|
93
|
+
last?.type === "tool" &&
|
|
94
|
+
last.status !== "fail" &&
|
|
95
|
+
last.label === label &&
|
|
96
|
+
!isPlatformTool(event.toolName)
|
|
97
|
+
) {
|
|
90
98
|
return [
|
|
91
99
|
...lines.slice(0, -1),
|
|
92
100
|
{
|
|
@@ -116,7 +124,16 @@ export function applyEvent(lines: StreamLine[], event: AgentEvent): StreamLine[]
|
|
|
116
124
|
case "tool_call_end":
|
|
117
125
|
return lines.map((line) =>
|
|
118
126
|
line.type === "tool" && line.callId === event.callId
|
|
119
|
-
? {
|
|
127
|
+
? {
|
|
128
|
+
...line,
|
|
129
|
+
status: event.success ? "ok" : "fail",
|
|
130
|
+
error: event.error,
|
|
131
|
+
...(event.output
|
|
132
|
+
? { output: event.output }
|
|
133
|
+
: event.result !== undefined
|
|
134
|
+
? { output: toolEventOutput(event.result) }
|
|
135
|
+
: {}),
|
|
136
|
+
}
|
|
120
137
|
: line,
|
|
121
138
|
);
|
|
122
139
|
case "session_meta":
|
|
@@ -163,6 +180,7 @@ export function linesFromTranscript(
|
|
|
163
180
|
status: ToolStatus;
|
|
164
181
|
preview: string;
|
|
165
182
|
error?: string;
|
|
183
|
+
output?: string;
|
|
166
184
|
}
|
|
167
185
|
>,
|
|
168
186
|
): StreamLine[] {
|
|
@@ -192,6 +210,7 @@ export function linesFromTranscript(
|
|
|
192
210
|
count: 1,
|
|
193
211
|
preview: message.preview,
|
|
194
212
|
error: message.error,
|
|
213
|
+
...(message.output ? { output: message.output } : {}),
|
|
195
214
|
};
|
|
196
215
|
});
|
|
197
216
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* Caelence primitives. Colour only through role aliases. Radii 4 / 8 / 12 / full.
|
|
2
|
-
Icon tiles use --icon-tile / --r-tile.
|
|
2
|
+
Buttons are rounded rects (12, compact 8). Icon tiles use --icon-tile / --r-tile.
|
|
3
|
+
Handles are always round. */
|
|
3
4
|
|
|
4
5
|
.cel-btn {
|
|
5
6
|
display: inline-flex;
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
font-weight: 600;
|
|
12
13
|
line-height: 1;
|
|
13
14
|
padding: 13px 20px;
|
|
14
|
-
border-radius: var(--r-
|
|
15
|
+
border-radius: var(--r-lg);
|
|
15
16
|
border: 1px solid transparent;
|
|
16
17
|
cursor: pointer;
|
|
17
18
|
text-decoration: none;
|
|
@@ -73,11 +74,13 @@
|
|
|
73
74
|
.cel-btn--sm {
|
|
74
75
|
font-size: 13px;
|
|
75
76
|
padding: 8px 14px;
|
|
77
|
+
border-radius: var(--r-md);
|
|
76
78
|
}
|
|
77
79
|
.cel-btn--compact {
|
|
78
80
|
font-size: 13px;
|
|
79
81
|
padding: 5px 10px;
|
|
80
82
|
gap: 6px;
|
|
83
|
+
border-radius: var(--r-md);
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
.cel-tile {
|
|
@@ -462,7 +465,7 @@
|
|
|
462
465
|
}
|
|
463
466
|
|
|
464
467
|
.cel-float {
|
|
465
|
-
box-shadow: 0
|
|
468
|
+
box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--ink) 36%, transparent);
|
|
466
469
|
}
|
|
467
470
|
|
|
468
471
|
/* Hover tip. A floating layer, so the same shadow as menus is allowed.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import {
|
|
3
3
|
groupTranscriptLines,
|
|
4
|
+
liveStatusPhrases,
|
|
4
5
|
type ToolLine,
|
|
5
6
|
thoughtSummary,
|
|
6
7
|
thoughtTools,
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
function tool(partial: Partial<ToolLine> & Pick<ToolLine, "key" | "label" | "status">): ToolLine {
|
|
11
12
|
return {
|
|
12
13
|
type: "tool",
|
|
13
|
-
name: "
|
|
14
|
+
name: "read_file",
|
|
14
15
|
callId: partial.key,
|
|
15
16
|
count: 1,
|
|
16
17
|
preview: "",
|
|
@@ -22,8 +23,8 @@ describe("thought fold", () => {
|
|
|
22
23
|
test("hides consecutive tool rows behind one thought block", () => {
|
|
23
24
|
const blocks = groupTranscriptLines([
|
|
24
25
|
{ key: "u-0", type: "user", text: "cv", userTurnIndex: 0 },
|
|
25
|
-
tool({ key: "t1", label: "
|
|
26
|
-
tool({ key: "t2", label: "
|
|
26
|
+
tool({ key: "t1", label: "Reading src/a.ts", status: "ok", name: "read_file" }),
|
|
27
|
+
tool({ key: "t2", label: "Searching files", status: "ok", name: "grep" }),
|
|
27
28
|
{ key: "a-1", type: "assistant", text: "done" },
|
|
28
29
|
]);
|
|
29
30
|
expect(blocks.map((block) => block.type)).toEqual(["line", "thought", "line"]);
|
|
@@ -31,14 +32,33 @@ describe("thought fold", () => {
|
|
|
31
32
|
expect(
|
|
32
33
|
thoughtSummary(blocks[1]?.type === "thought" ? thoughtTools(blocks[1].entries) : [], false)
|
|
33
34
|
.headline,
|
|
34
|
-
).toBe("Explored 1 search");
|
|
35
|
+
).toBe("Explored 1 file, 1 search");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("keeps integration tools as their own window", () => {
|
|
39
|
+
const blocks = groupTranscriptLines([
|
|
40
|
+
{ key: "u-0", type: "user", text: "pages", userTurnIndex: 0 },
|
|
41
|
+
tool({
|
|
42
|
+
key: "t1",
|
|
43
|
+
label: "Notion fetch",
|
|
44
|
+
status: "ok",
|
|
45
|
+
name: "notion__notion_fetch",
|
|
46
|
+
output: '{"title":"Notes"}',
|
|
47
|
+
}),
|
|
48
|
+
{ key: "a-1", type: "assistant", text: "here" },
|
|
49
|
+
]);
|
|
50
|
+
expect(blocks.map((block) => block.type)).toEqual(["line", "line", "line"]);
|
|
51
|
+
expect(blocks[1]).toMatchObject({
|
|
52
|
+
type: "line",
|
|
53
|
+
line: { type: "tool", name: "notion__notion_fetch" },
|
|
54
|
+
});
|
|
35
55
|
});
|
|
36
56
|
|
|
37
57
|
test("stays live between tool calls until the assistant replies", () => {
|
|
38
58
|
const blocks = groupTranscriptLines([
|
|
39
59
|
{ key: "u-0", type: "user", text: "cv", userTurnIndex: 0 },
|
|
40
|
-
tool({ key: "t1", label: "
|
|
41
|
-
tool({ key: "t2", label: "
|
|
60
|
+
tool({ key: "t1", label: "Reading src/a.ts", status: "ok", name: "read_file" }),
|
|
61
|
+
tool({ key: "t2", label: "Searching files", status: "ok", name: "grep" }),
|
|
42
62
|
]);
|
|
43
63
|
expect(blocks[1]?.type === "thought" && blocks[1].live).toBe(true);
|
|
44
64
|
const settled = groupTranscriptLines([
|
|
@@ -50,22 +70,49 @@ describe("thought fold", () => {
|
|
|
50
70
|
});
|
|
51
71
|
|
|
52
72
|
test("warmup headlines rotate without inventing a duration", () => {
|
|
53
|
-
expect(warmupHeadline(0)).toBe("
|
|
54
|
-
expect(warmupHeadline(1)).toBe("
|
|
55
|
-
expect(warmupHeadline(2)).toBe("
|
|
56
|
-
expect(warmupHeadline(3)).toBe("
|
|
57
|
-
expect(thoughtSummary([], true, { warmup: true, seed: 1 }).headline).toBe("
|
|
73
|
+
expect(warmupHeadline(0)).toBe("Thinking");
|
|
74
|
+
expect(warmupHeadline(1)).toBe("Looking this over");
|
|
75
|
+
expect(warmupHeadline(2)).toBe("Working it out");
|
|
76
|
+
expect(warmupHeadline(3)).toBe("Thinking");
|
|
77
|
+
expect(thoughtSummary([], true, { warmup: true, seed: 1 }).headline).toBe("Thinking");
|
|
78
|
+
expect(liveStatusPhrases([], true)).toEqual([
|
|
79
|
+
"Thinking",
|
|
80
|
+
"Looking this over",
|
|
81
|
+
"Working it out",
|
|
82
|
+
]);
|
|
58
83
|
});
|
|
59
84
|
|
|
60
|
-
test("live
|
|
85
|
+
test("live phrases follow the in-flight tool then thinking", () => {
|
|
61
86
|
const tools = [
|
|
62
|
-
tool({ key: "t1", label: "
|
|
63
|
-
tool({ key: "t2", label: "
|
|
87
|
+
tool({ key: "t1", label: "Searching files", status: "ok", name: "grep" }),
|
|
88
|
+
tool({ key: "t2", label: "Reading src/a.ts", status: "running", name: "read_file" }),
|
|
64
89
|
];
|
|
65
|
-
expect(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
90
|
+
expect(liveStatusPhrases(tools)[0]).toBe("Reading src/a.ts");
|
|
91
|
+
expect(liveStatusPhrases(tools)).toContain("Thinking");
|
|
92
|
+
expect(thoughtSummary(tools, true)).toEqual({ headline: "Reading src/a.ts" });
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("skill reads use a pipeline headline instead of thinking", () => {
|
|
96
|
+
const tools = [
|
|
97
|
+
tool({
|
|
98
|
+
key: "t1",
|
|
99
|
+
label: "Reading Copywriting",
|
|
100
|
+
status: "ok",
|
|
101
|
+
name: "read_skill",
|
|
102
|
+
preview: '{"name":"copywriting"}',
|
|
103
|
+
}),
|
|
104
|
+
tool({
|
|
105
|
+
key: "t2",
|
|
106
|
+
label: "Reading RMBC",
|
|
107
|
+
status: "running",
|
|
108
|
+
name: "read_skill",
|
|
109
|
+
preview: '{"name":"copy-rmbc"}',
|
|
110
|
+
}),
|
|
111
|
+
];
|
|
112
|
+
expect(liveStatusPhrases(tools)[0]).toBe("Running RMBC");
|
|
113
|
+
expect(liveStatusPhrases(tools)).toContain("Running Copywriting");
|
|
114
|
+
expect(liveStatusPhrases(tools)).not.toContain("Thinking");
|
|
115
|
+
expect(thoughtSummary(tools, false).headline).toBe("Ran Copywriting");
|
|
69
116
|
});
|
|
70
117
|
|
|
71
118
|
test("done headlines follow thought, explored, or worked", () => {
|
package/desktop/src/thought.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { pipelineProgress } from "./pipeline";
|
|
2
|
+
import { isPlatformTool } from "./platform";
|
|
1
3
|
import type { StreamLine } from "./stream";
|
|
2
4
|
import { eventCountSuffix } from "./tool-label";
|
|
3
5
|
|
|
@@ -10,7 +12,8 @@ export type TranscriptBlock =
|
|
|
10
12
|
| { type: "thought"; entries: FoldEntry[]; live: boolean };
|
|
11
13
|
|
|
12
14
|
function isFoldLine(line: StreamLine): line is ToolLine | Extract<StreamLine, { type: "thought" }> {
|
|
13
|
-
|
|
15
|
+
if (line.type === "thought") return true;
|
|
16
|
+
return line.type === "tool" && !isPlatformTool(line.name);
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
export function thoughtTools(entries: FoldEntry[]): ToolLine[] {
|
|
@@ -46,14 +49,46 @@ export function groupTranscriptLines(lines: StreamLine[]): TranscriptBlock[] {
|
|
|
46
49
|
|
|
47
50
|
const WRITE_LABEL = /^(?:Writing|Editing)\b/u;
|
|
48
51
|
const WRITE_NAME = /write_file|edit_file|str_replace|apply_patch|shell|bash|git_commit/i;
|
|
49
|
-
const
|
|
52
|
+
export const WARMUP_PHRASES = ["Thinking", "Looking this over", "Working it out"] as const;
|
|
50
53
|
|
|
51
54
|
function isWriteTool(tool: ToolLine): boolean {
|
|
52
55
|
return WRITE_LABEL.test(tool.label) || WRITE_NAME.test(tool.name);
|
|
53
56
|
}
|
|
54
57
|
|
|
58
|
+
function pushPhrase(out: string[], value: string): void {
|
|
59
|
+
const text = value.trim();
|
|
60
|
+
if (!text) return;
|
|
61
|
+
if (out.some((item) => item.toLowerCase() === text.toLowerCase())) return;
|
|
62
|
+
out.push(text);
|
|
63
|
+
}
|
|
64
|
+
|
|
55
65
|
export function warmupHeadline(seed: number): string {
|
|
56
|
-
return
|
|
66
|
+
return WARMUP_PHRASES[Math.abs(seed) % WARMUP_PHRASES.length] ?? "Thinking";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function liveStatusPhrases(tools: ToolLine[], warmup = false): string[] {
|
|
70
|
+
if (warmup || tools.length === 0) return [...WARMUP_PHRASES];
|
|
71
|
+
const pipe = pipelineProgress(tools);
|
|
72
|
+
const out: string[] = [];
|
|
73
|
+
if (pipe) {
|
|
74
|
+
pushPhrase(out, pipe.title);
|
|
75
|
+
pushPhrase(out, `Running ${pipe.family}`);
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
const running = [...tools].reverse().find((tool) => tool.status === "running");
|
|
79
|
+
const current = running ?? [...tools].reverse().find((tool) => tool.label.trim());
|
|
80
|
+
if (current) {
|
|
81
|
+
pushPhrase(out, `${current.label}${eventCountSuffix(current.count)}`);
|
|
82
|
+
if (/^Reading\b/u.test(current.label) || current.name === "read_file")
|
|
83
|
+
pushPhrase(out, "Reading");
|
|
84
|
+
if (/search|grep|glob/i.test(current.name) || /^Searching\b/u.test(current.label)) {
|
|
85
|
+
pushPhrase(out, "Searching");
|
|
86
|
+
}
|
|
87
|
+
if (isWriteTool(current)) pushPhrase(out, "Editing");
|
|
88
|
+
}
|
|
89
|
+
pushPhrase(out, "Thinking");
|
|
90
|
+
pushPhrase(out, "Looking this over");
|
|
91
|
+
return out;
|
|
57
92
|
}
|
|
58
93
|
|
|
59
94
|
export function thoughtSummary(
|
|
@@ -61,16 +96,11 @@ export function thoughtSummary(
|
|
|
61
96
|
live: boolean,
|
|
62
97
|
options?: { warmup?: boolean; seed?: number },
|
|
63
98
|
): { headline: string; activity?: string } {
|
|
64
|
-
if (live && options?.warmup) {
|
|
65
|
-
return { headline: warmupHeadline(options.seed ?? 0) };
|
|
66
|
-
}
|
|
67
99
|
if (live) {
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
headline: "Thinking",
|
|
71
|
-
...(running ? { activity: `${running.label}${eventCountSuffix(running.count)}` } : {}),
|
|
72
|
-
};
|
|
100
|
+
return { headline: liveStatusPhrases(tools, options?.warmup).at(0) ?? "Thinking" };
|
|
73
101
|
}
|
|
102
|
+
const pipe = pipelineProgress(tools);
|
|
103
|
+
if (pipe && !tools.some(isWriteTool)) return { headline: `Ran ${pipe.family}` };
|
|
74
104
|
if (tools.some(isWriteTool)) return { headline: "Worked" };
|
|
75
105
|
if (tools.length === 0) return { headline: "Thought" };
|
|
76
106
|
const files = new Set<string>();
|
|
@@ -14,4 +14,16 @@ describe("tool labels", () => {
|
|
|
14
14
|
expect(toolLabel("exec", { command: "bun test" })).toBe("Running: bun test");
|
|
15
15
|
expect(toolLabel("web_search")).toBe("Searching the web");
|
|
16
16
|
});
|
|
17
|
+
|
|
18
|
+
test("uses an active phrase for a lone tool name", () => {
|
|
19
|
+
expect(toolLabel("task")).toBe("Handling task");
|
|
20
|
+
expect(toolLabel("mystery")).toBe("Using mystery");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("names the skill on read_skill and task", () => {
|
|
24
|
+
expect(toolLabel("read_skill", { name: "copy-harry-dry" })).toBe("Reading Harry Dry");
|
|
25
|
+
expect(toolLabel("task", { label: "copy-edit", skills: ["copy-editor"] })).toBe(
|
|
26
|
+
"Handling copy-edit",
|
|
27
|
+
);
|
|
28
|
+
});
|
|
17
29
|
});
|
|
@@ -12,10 +12,26 @@ const TOOL_LABELS: Record<string, string> = {
|
|
|
12
12
|
todo_write: "Updating todos",
|
|
13
13
|
grep: "Searching files",
|
|
14
14
|
glob: "Finding files",
|
|
15
|
+
task: "Handling task",
|
|
16
|
+
read_skill: "Reading skill",
|
|
17
|
+
git_status: "Checking git",
|
|
18
|
+
git_diff: "Reading diff",
|
|
19
|
+
git_log: "Reading log",
|
|
20
|
+
git_commit: "Committing",
|
|
15
21
|
};
|
|
16
22
|
|
|
17
23
|
const EVENT_COUNT_RE = /\s×(\d+)$/u;
|
|
18
24
|
|
|
25
|
+
function prettySkillLabel(raw: string): string {
|
|
26
|
+
const id = raw.trim().split("/").pop()?.split("@").pop() ?? raw;
|
|
27
|
+
if (id === "copy-rmbc") return "RMBC";
|
|
28
|
+
if (id === "copy-harry-dry") return "Harry Dry";
|
|
29
|
+
if (id === "copy-editor") return "Copy editor";
|
|
30
|
+
if (id === "copywriting") return "Copywriting";
|
|
31
|
+
const spaced = id.replace(/[-_]+/g, " ").trim();
|
|
32
|
+
return spaced ? spaced.charAt(0).toUpperCase() + spaced.slice(1) : raw.trim();
|
|
33
|
+
}
|
|
34
|
+
|
|
19
35
|
export function prettifyToolName(name: string): string {
|
|
20
36
|
const local = name.includes("__") ? (name.split("__").at(-1) ?? name) : name;
|
|
21
37
|
const stripped = local.replace(/^[a-z0-9]+_/i, (prefix) => {
|
|
@@ -33,6 +49,17 @@ export function toolLabel(toolName: string, input: Record<string, unknown> = {})
|
|
|
33
49
|
if (toolName === "edit_file" && path) return `Editing ${path}`;
|
|
34
50
|
if (toolName === "read_file" && path) return `Reading ${path}`;
|
|
35
51
|
if (toolName === "exec" && command) return `Running: ${command}`;
|
|
52
|
+
if (toolName === "read_skill") {
|
|
53
|
+
const skill = typeof input.name === "string" ? input.name.trim() : "";
|
|
54
|
+
return skill ? `Reading ${prettySkillLabel(skill)}` : "Reading skill";
|
|
55
|
+
}
|
|
56
|
+
if (toolName === "task") {
|
|
57
|
+
const label = typeof input.label === "string" ? input.label.trim() : "";
|
|
58
|
+
if (label) return `Handling ${label}`;
|
|
59
|
+
const skills = Array.isArray(input.skills) ? input.skills : [];
|
|
60
|
+
const skill = typeof skills[0] === "string" ? skills[0].trim() : "";
|
|
61
|
+
return skill ? `Handling ${prettySkillLabel(skill)}` : "Handling task";
|
|
62
|
+
}
|
|
36
63
|
const known = TOOL_LABELS[toolName];
|
|
37
64
|
if (known) return known;
|
|
38
65
|
const pretty = prettifyToolName(toolName);
|
|
@@ -42,6 +69,7 @@ export function toolLabel(toolName: string, input: Record<string, unknown> = {})
|
|
|
42
69
|
const hostLabel = host.charAt(0).toUpperCase() + host.slice(1);
|
|
43
70
|
return `${hostLabel} ${pretty.toLowerCase()}`;
|
|
44
71
|
}
|
|
72
|
+
if (!/\s/.test(pretty) && !/ing$/i.test(pretty)) return `Using ${pretty.toLowerCase()}`;
|
|
45
73
|
return pretty;
|
|
46
74
|
}
|
|
47
75
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useavalon/caelence-agent",
|
|
3
|
-
"version": "0.2.2-canary.
|
|
3
|
+
"version": "0.2.2-canary.7",
|
|
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",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
],
|
|
40
40
|
"scripts": {
|
|
41
41
|
"start": "bun bin/harness.ts",
|
|
42
|
-
"test": "bun test src/core src/tools src/skills src/evals src/cli src/observability src/desktop src/integrations src/media 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",
|
|
42
|
+
"test": "bun test src/core src/tools src/skills src/evals src/cli src/observability src/desktop src/integrations src/media 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",
|
|
43
43
|
"typecheck": "bunx tsc --noEmit -p tsconfig.json",
|
|
44
44
|
"lint": "biome ci .",
|
|
45
45
|
"format": "biome format --write .",
|
package/src/cli/models.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { prettyLiveModelName } from "./openrouter-live.ts";
|
|
2
|
+
|
|
1
3
|
export interface ModelOption {
|
|
2
4
|
id: string;
|
|
3
5
|
label: string;
|
|
@@ -31,7 +33,7 @@ export function modelPickerItems(
|
|
|
31
33
|
live?: ReadonlyMap<string, string>,
|
|
32
34
|
): Array<{ id: string; label: string; hint?: string }> {
|
|
33
35
|
const items = HARNESS_MODELS.map((model) => {
|
|
34
|
-
const target = live?.get(model.id)?.trim();
|
|
36
|
+
const target = prettyLiveModelName(live?.get(model.id)?.trim() ?? "").trim();
|
|
35
37
|
const hint = target && target.toLowerCase() !== model.label.toLowerCase() ? target : undefined;
|
|
36
38
|
return { id: model.id, label: model.label, ...(hint ? { hint } : {}) };
|
|
37
39
|
});
|
|
@@ -20,6 +20,17 @@ describe("parseLiveTargetNames", () => {
|
|
|
20
20
|
expect(names.get("~x-ai/grok-latest")).toBe("Grok 4.6");
|
|
21
21
|
expect(names.get("openai/gpt-5.6-sol")).toBe("GPT-5.6 Sol");
|
|
22
22
|
});
|
|
23
|
+
|
|
24
|
+
test("drops Router from Auto labels", () => {
|
|
25
|
+
const names = parseLiveTargetNames({
|
|
26
|
+
data: [
|
|
27
|
+
{ id: "openrouter/auto", name: "OpenRouter: Auto Router" },
|
|
28
|
+
{ id: "openrouter/auto-beta", name: "Auto Router Beta" },
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
expect(names.get("openrouter/auto")).toBe("Auto");
|
|
32
|
+
expect(names.get("openrouter/auto-beta")).toBe("Auto beta");
|
|
33
|
+
});
|
|
23
34
|
});
|
|
24
35
|
|
|
25
36
|
describe("model picker live names", () => {
|
|
@@ -32,4 +43,22 @@ describe("model picker live names", () => {
|
|
|
32
43
|
expect(grok?.label).toBe("Grok latest");
|
|
33
44
|
expect(grok?.hint).toBe("Grok 4.6");
|
|
34
45
|
});
|
|
46
|
+
|
|
47
|
+
test("does not hint Auto Router on Auto", () => {
|
|
48
|
+
const items = modelPickerItems(
|
|
49
|
+
"openrouter/auto",
|
|
50
|
+
new Map([
|
|
51
|
+
["openrouter/auto", "Auto Router"],
|
|
52
|
+
["openrouter/auto-beta", "Auto Router Beta"],
|
|
53
|
+
]),
|
|
54
|
+
);
|
|
55
|
+
expect(items.find((item) => item.id === "openrouter/auto")).toEqual({
|
|
56
|
+
id: "openrouter/auto",
|
|
57
|
+
label: "Auto",
|
|
58
|
+
});
|
|
59
|
+
expect(items.find((item) => item.id === "openrouter/auto-beta")).toEqual({
|
|
60
|
+
id: "openrouter/auto-beta",
|
|
61
|
+
label: "Auto beta",
|
|
62
|
+
});
|
|
63
|
+
});
|
|
35
64
|
});
|
|
@@ -9,7 +9,15 @@ function displayName(id: string, rawName: string): string {
|
|
|
9
9
|
const trimmed = rawName.trim();
|
|
10
10
|
if (!trimmed) return id;
|
|
11
11
|
const colon = trimmed.indexOf(": ");
|
|
12
|
-
|
|
12
|
+
const name = colon >= 0 ? trimmed.slice(colon + 2) : trimmed;
|
|
13
|
+
return prettyLiveModelName(name);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** OpenRouter calls Auto "Auto Router". Product copy is Auto / Auto beta. */
|
|
17
|
+
export function prettyLiveModelName(name: string): string {
|
|
18
|
+
const lower = name.toLowerCase().replace(/[_-]+/g, " ").replace(/\s+/g, " ").trim();
|
|
19
|
+
if (!/\bauto\b/.test(lower) || !/\brouter\b/.test(lower)) return name;
|
|
20
|
+
return /\bbeta\b/.test(lower) ? "Auto beta" : "Auto";
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
/** Human name of the concrete model a `~latest` alias currently resolves to. */
|
package/src/core/events.ts
CHANGED
package/src/core/run-turn.ts
CHANGED
|
@@ -140,6 +140,7 @@ export async function runTurn(
|
|
|
140
140
|
status: event.success ? "ok" : "fail",
|
|
141
141
|
preview: started?.preview ?? "",
|
|
142
142
|
...(event.error ? { error: event.error } : {}),
|
|
143
|
+
...(event.output ? { output: event.output } : {}),
|
|
143
144
|
});
|
|
144
145
|
}
|
|
145
146
|
emit(event);
|
|
@@ -411,6 +412,7 @@ async function invokeGuardedBody(
|
|
|
411
412
|
callId,
|
|
412
413
|
success,
|
|
413
414
|
...(success ? { result: finalResult.structuredContent } : {}),
|
|
415
|
+
...(success ? { output: clipToolOutput(toolResultText(finalResult)) } : {}),
|
|
414
416
|
...(errorText !== undefined ? { error: errorText } : {}),
|
|
415
417
|
});
|
|
416
418
|
return finalResult;
|
|
@@ -426,6 +428,11 @@ function previewToolInput(input: Record<string, unknown>): string {
|
|
|
426
428
|
return raw.length > 80 ? `${raw.slice(0, 79)}…` : raw;
|
|
427
429
|
}
|
|
428
430
|
|
|
431
|
+
function clipToolOutput(text: string): string {
|
|
432
|
+
const max = 8000;
|
|
433
|
+
return text.length <= max ? text : `${text.slice(0, max)}\n…`;
|
|
434
|
+
}
|
|
435
|
+
|
|
429
436
|
export function buildSystemPrompt(input: {
|
|
430
437
|
name: string;
|
|
431
438
|
cwd: string;
|
package/src/core/session.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type SessionMessage =
|
|
|
17
17
|
status: "ok" | "fail";
|
|
18
18
|
preview: string;
|
|
19
19
|
error?: string;
|
|
20
|
+
output?: string;
|
|
20
21
|
}
|
|
21
22
|
| {
|
|
22
23
|
kind: "compaction_checkpoint";
|
|
@@ -36,6 +37,7 @@ export type ChatTranscriptLine =
|
|
|
36
37
|
status: "ok" | "fail";
|
|
37
38
|
preview: string;
|
|
38
39
|
error?: string;
|
|
40
|
+
output?: string;
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
export interface Session {
|
|
@@ -126,6 +128,7 @@ export function sessionTranscript(session: Session): ChatTranscriptLine[] {
|
|
|
126
128
|
status: message.status,
|
|
127
129
|
preview: message.preview,
|
|
128
130
|
...(message.error ? { error: message.error } : {}),
|
|
131
|
+
...(message.output ? { output: message.output } : {}),
|
|
129
132
|
});
|
|
130
133
|
}
|
|
131
134
|
}
|
|
@@ -269,6 +269,57 @@ describe("desktop bridge", () => {
|
|
|
269
269
|
}
|
|
270
270
|
});
|
|
271
271
|
|
|
272
|
+
test("previews a project file and rejects escape", async () => {
|
|
273
|
+
const ctx = await withBridge();
|
|
274
|
+
try {
|
|
275
|
+
await writeFile(join(ctx.cwd, "note.txt"), "preview me");
|
|
276
|
+
const ok = await fetch(`${ctx.ready.url}/file-preview?path=note.txt`, {
|
|
277
|
+
headers: ctx.headers,
|
|
278
|
+
});
|
|
279
|
+
expect(ok.ok).toBe(true);
|
|
280
|
+
const body = (await ok.json()) as { text?: string; path?: string; kind?: string };
|
|
281
|
+
expect(body.path).toBe("note.txt");
|
|
282
|
+
expect(body.text).toBe("preview me");
|
|
283
|
+
expect(body.kind).toBe("text");
|
|
284
|
+
const blocked = await fetch(`${ctx.ready.url}/file-preview?path=../secret`, {
|
|
285
|
+
headers: ctx.headers,
|
|
286
|
+
});
|
|
287
|
+
expect(blocked.status).toBe(400);
|
|
288
|
+
} finally {
|
|
289
|
+
await ctx.close();
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
test("previews images as bytes and rejects escape", async () => {
|
|
294
|
+
const ctx = await withBridge();
|
|
295
|
+
try {
|
|
296
|
+
const png = Buffer.from(
|
|
297
|
+
"89504e470d0a1a0a0000000d49484452000000010000000108060000001f15c4890000000a49444154789c63000100000500010d0a2db40000000049454e44ae426082",
|
|
298
|
+
"hex",
|
|
299
|
+
);
|
|
300
|
+
await writeFile(join(ctx.cwd, "dot.png"), png);
|
|
301
|
+
const meta = await fetch(`${ctx.ready.url}/file-preview?path=dot.png`, {
|
|
302
|
+
headers: ctx.headers,
|
|
303
|
+
});
|
|
304
|
+
expect(meta.ok).toBe(true);
|
|
305
|
+
const body = (await meta.json()) as { kind?: string; mime?: string };
|
|
306
|
+
expect(body.kind).toBe("image");
|
|
307
|
+
expect(body.mime).toBe("image/png");
|
|
308
|
+
const bytes = await fetch(`${ctx.ready.url}/file-bytes?path=dot.png`, {
|
|
309
|
+
headers: ctx.headers,
|
|
310
|
+
});
|
|
311
|
+
expect(bytes.ok).toBe(true);
|
|
312
|
+
expect(bytes.headers.get("content-type")).toBe("image/png");
|
|
313
|
+
expect(Buffer.from(await bytes.arrayBuffer()).equals(png)).toBe(true);
|
|
314
|
+
const blocked = await fetch(`${ctx.ready.url}/file-bytes?path=../secret.png`, {
|
|
315
|
+
headers: ctx.headers,
|
|
316
|
+
});
|
|
317
|
+
expect(blocked.status).toBe(400);
|
|
318
|
+
} finally {
|
|
319
|
+
await ctx.close();
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
|
|
272
323
|
test("rejects a missing local path", async () => {
|
|
273
324
|
const ctx = await withBridge();
|
|
274
325
|
try {
|