teapot-coding-agent 0.1.1 → 0.3.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 +25 -0
- package/dist/agent/agent.js +42 -11
- package/dist/agent/llm.js +70 -0
- package/dist/log/events.js +8 -0
- package/dist/master.js +67 -0
- package/dist/server/api.js +76 -17
- package/package.json +5 -3
- package/public/assets/index-6mOD4zV4.js +9 -0
- package/public/assets/{index-D2kic6g_.css → index-DZvHiLwS.css} +1 -1
- package/public/index.html +2 -2
- package/public/assets/index-CFs1UF6R.js +0 -9
package/README.md
CHANGED
|
@@ -18,6 +18,31 @@ tab, and any number of long-running agents.
|
|
|
18
18
|
|
|
19
19
|
## Quick start
|
|
20
20
|
|
|
21
|
+
Requires Node.js **>= 24** (TypeScript is executed natively in dev mode).
|
|
22
|
+
|
|
23
|
+
### Install globally from npm
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm install -g teapot-coding-agent
|
|
27
|
+
mkdir -p ~/.config/teapot-coding-agent
|
|
28
|
+
curl -o ~/.config/teapot-coding-agent/config.json \
|
|
29
|
+
https://raw.githubusercontent.com/akku1139/teapot/main/teapot.config.example.json # then edit it
|
|
30
|
+
teapot
|
|
31
|
+
# open http://localhost:7788
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The global install puts a `teapot` binary on your PATH (it serves the compiled
|
|
35
|
+
server plus the pre-built web UI — no build step, no repo checkout needed).
|
|
36
|
+
Alternatives:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npx teapot-coding-agent # run without installing
|
|
40
|
+
teapot ~/my-config.json # explicit config path
|
|
41
|
+
TEAPOT_PORT=8080 teapot # env overrides work as usual
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Run from a checkout (development)
|
|
45
|
+
|
|
21
46
|
```sh
|
|
22
47
|
pnpm install
|
|
23
48
|
mkdir -p ~/.config/teapot-coding-agent
|
package/dist/agent/agent.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { promises as fs } from "node:fs";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { EventLog, readEvents } from "../log/events.js";
|
|
12
|
-
import { chat } from "./llm.js";
|
|
12
|
+
import { chat, chatStream } from "./llm.js";
|
|
13
13
|
import { executeTool, toolSpecs, currentSkills } from "./tools.js";
|
|
14
14
|
import { bus } from "../bus.js";
|
|
15
15
|
const SYSTEM_TEMPLATE = `You are a coding agent working autonomously inside a workspace.
|
|
@@ -101,9 +101,9 @@ export class Agent {
|
|
|
101
101
|
"When the current task matches a description below, call load_skill(name) first and follow it.\n" +
|
|
102
102
|
this.skillsCache.map((s) => `- ${s.name}: ${s.description || "(no description)"}`).join("\n"));
|
|
103
103
|
}
|
|
104
|
-
callLlm(messages, tools) {
|
|
105
|
-
const fn = this.opts.chatFn ??
|
|
106
|
-
return fn(this.opts.llm, messages, tools, this.abort?.signal);
|
|
104
|
+
callLlm(messages, tools, onDelta) {
|
|
105
|
+
const fn = this.opts.chatFn ?? chatStream;
|
|
106
|
+
return fn(this.opts.llm, messages, tools, this.abort?.signal, onDelta);
|
|
107
107
|
}
|
|
108
108
|
/** expose id for metrics */
|
|
109
109
|
opts_id() {
|
|
@@ -241,13 +241,22 @@ export class Agent {
|
|
|
241
241
|
return fs.readFile(path.join(this.workspace, "GOAL.md"), "utf8").catch(() => null);
|
|
242
242
|
}
|
|
243
243
|
parseGoalFile(text) {
|
|
244
|
-
|
|
245
|
-
const
|
|
244
|
+
// humans and agents may append their own status lines — latest wins
|
|
245
|
+
const all = [...text.matchAll(/status:\s*(\w+)/gi)];
|
|
246
|
+
const last = all[all.length - 1]?.[1];
|
|
247
|
+
const status = last === "done" ? "done" : last === "paused" ? "paused" : "active";
|
|
246
248
|
return { text: text.trim(), status, updatedAt: new Date().toISOString() };
|
|
247
249
|
}
|
|
248
250
|
async writeGoalFile() {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
+
// don't let previously-appended bookkeeping lines accumulate in the body
|
|
252
|
+
let body = this.goal.text.trimEnd();
|
|
253
|
+
for (let i = 0; i < 4; i++) {
|
|
254
|
+
const stripped = body.replace(/\n+(?:status|updated):[^\n]*$/i, "").trimEnd();
|
|
255
|
+
if (stripped === body)
|
|
256
|
+
break;
|
|
257
|
+
body = stripped;
|
|
258
|
+
}
|
|
259
|
+
await fs.writeFile(path.join(this.workspace, "GOAL.md"), `${body}\n\nstatus: ${this.goal.status}\nupdated: ${this.goal.updatedAt}\n`, "utf8");
|
|
251
260
|
}
|
|
252
261
|
async setGoal(text) {
|
|
253
262
|
this.goal = { text, status: "active", updatedAt: new Date().toISOString() };
|
|
@@ -361,15 +370,29 @@ export class Agent {
|
|
|
361
370
|
* immediately, plus loop-level retries for provider flakiness (the SDK
|
|
362
371
|
* already backsoff 429/5xx; this covers exhausted rate limits and 400s).
|
|
363
372
|
*/
|
|
364
|
-
|
|
373
|
+
/**
|
|
374
|
+
* One LLM call with a fresh abort controller so stop() can interrupt it
|
|
375
|
+
* immediately, plus loop-level retries for provider flakiness (the SDK
|
|
376
|
+
* already backsoff 429/5xx; this covers exhausted rate limits and 400s).
|
|
377
|
+
* When onDelta is given, cumulative stream snapshots are forwarded to the
|
|
378
|
+
* UI via the bus (reset to empty at the start of every attempt).
|
|
379
|
+
*/
|
|
380
|
+
async llmCall(messages, tools, onDelta) {
|
|
365
381
|
const maxAttempts = 4;
|
|
366
382
|
const waits = [30_000, 60_000, 120_000];
|
|
367
383
|
for (let attempt = 1;; attempt++) {
|
|
368
384
|
if (this.stopRequested)
|
|
369
385
|
throw Object.assign(new Error("stopped"), { name: "StopRequested" });
|
|
370
386
|
this.abort = new AbortController();
|
|
387
|
+
if (onDelta)
|
|
388
|
+
bus.emit("update", {
|
|
389
|
+
kind: "llm-delta",
|
|
390
|
+
agentId: this.opts.id,
|
|
391
|
+
text: "",
|
|
392
|
+
reasoning: "",
|
|
393
|
+
});
|
|
371
394
|
try {
|
|
372
|
-
return await this.callLlm(messages, tools);
|
|
395
|
+
return await this.callLlm(messages, tools, onDelta);
|
|
373
396
|
}
|
|
374
397
|
catch (err) {
|
|
375
398
|
this.abort = null;
|
|
@@ -411,7 +434,15 @@ export class Agent {
|
|
|
411
434
|
detail: "llm turn start",
|
|
412
435
|
turn: ++this.stats.turns,
|
|
413
436
|
});
|
|
414
|
-
|
|
437
|
+
// stream the assistant reply live to connected clients
|
|
438
|
+
const res = await this.llmCall(this.buildMessages(), allToolSpecs(), (s) => {
|
|
439
|
+
bus.emit("update", {
|
|
440
|
+
kind: "llm-delta",
|
|
441
|
+
agentId: this.opts.id,
|
|
442
|
+
text: s.text,
|
|
443
|
+
reasoning: s.reasoning,
|
|
444
|
+
});
|
|
445
|
+
});
|
|
415
446
|
if (res.usage) {
|
|
416
447
|
this.stats.inputTokens += res.usage.inputTokens ?? 0;
|
|
417
448
|
this.stats.outputTokens += res.usage.outputTokens ?? 0;
|
package/dist/agent/llm.js
CHANGED
|
@@ -88,3 +88,73 @@ export async function chat(cfg, messages, tools, signal) {
|
|
|
88
88
|
throw new Error(`LLM API error ${e.status ?? "?"}: ${String(detail).slice(0, 500)}`);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Streaming variant of chat(): same result shape, but calls onDelta with
|
|
93
|
+
* cumulative {text, reasoning} snapshots as chunks arrive so the UI can show
|
|
94
|
+
* the response live. Falls back to plain chat() once if the provider rejects
|
|
95
|
+
* streaming before producing any chunk.
|
|
96
|
+
*/
|
|
97
|
+
export async function chatStream(cfg, messages, tools, signal, onDelta) {
|
|
98
|
+
let gotChunk = false;
|
|
99
|
+
try {
|
|
100
|
+
const stream = await client(cfg).chat.completions.create({
|
|
101
|
+
model: cfg.model,
|
|
102
|
+
messages: sanitize(messages),
|
|
103
|
+
...(tools.length ? { tools } : {}),
|
|
104
|
+
stream: true,
|
|
105
|
+
}, { signal });
|
|
106
|
+
let text = "";
|
|
107
|
+
let reasoning = "";
|
|
108
|
+
const calls = {};
|
|
109
|
+
let finishReason;
|
|
110
|
+
let usage;
|
|
111
|
+
for await (const chunk of stream) {
|
|
112
|
+
gotChunk = true;
|
|
113
|
+
const ch = chunk;
|
|
114
|
+
const c = ch.choices?.[0];
|
|
115
|
+
const d = c?.delta;
|
|
116
|
+
if (d?.content)
|
|
117
|
+
text += d.content;
|
|
118
|
+
if (d?.reasoning)
|
|
119
|
+
reasoning += d.reasoning;
|
|
120
|
+
for (const tc of d?.tool_calls ?? []) {
|
|
121
|
+
const i = tc.index ?? 0;
|
|
122
|
+
calls[i] ??= { id: "", name: "", args: "" };
|
|
123
|
+
if (tc.id)
|
|
124
|
+
calls[i].id = tc.id;
|
|
125
|
+
if (tc.function?.name)
|
|
126
|
+
calls[i].name += tc.function.name;
|
|
127
|
+
if (tc.function?.arguments)
|
|
128
|
+
calls[i].args += tc.function.arguments;
|
|
129
|
+
}
|
|
130
|
+
if (c?.finish_reason)
|
|
131
|
+
finishReason = c.finish_reason;
|
|
132
|
+
if (ch.usage)
|
|
133
|
+
usage = { inputTokens: ch.usage.prompt_tokens, outputTokens: ch.usage.completion_tokens };
|
|
134
|
+
if (onDelta)
|
|
135
|
+
onDelta({ text, reasoning });
|
|
136
|
+
}
|
|
137
|
+
if (finishReason === "error")
|
|
138
|
+
throw new Error("LLM API error: provider returned an errored completion");
|
|
139
|
+
const message = { role: "assistant", content: text };
|
|
140
|
+
const list = Object.keys(calls)
|
|
141
|
+
.map(Number)
|
|
142
|
+
.sort((a, b) => a - b)
|
|
143
|
+
.map((i) => calls[i]);
|
|
144
|
+
if (list.length)
|
|
145
|
+
message.tool_calls = list.map((c, i) => ({
|
|
146
|
+
id: c.id || `call_${i}`,
|
|
147
|
+
type: "function",
|
|
148
|
+
function: { name: c.name, arguments: c.args || "{}" },
|
|
149
|
+
}));
|
|
150
|
+
if (!message.content && !message.tool_calls)
|
|
151
|
+
throw new Error("LLM API error: empty completion");
|
|
152
|
+
return { message, reasoning: reasoning || undefined, usage };
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
// provider may not support streaming at all — one clean fallback
|
|
156
|
+
if (!gotChunk && !signal?.aborted)
|
|
157
|
+
return chat(cfg, messages, tools, signal);
|
|
158
|
+
throw err;
|
|
159
|
+
}
|
|
160
|
+
}
|
package/dist/log/events.js
CHANGED
|
@@ -22,6 +22,8 @@ export class EventLog {
|
|
|
22
22
|
chain = Promise.resolve();
|
|
23
23
|
/** branch -> last event id (in-memory reconstruction of parent chains) */
|
|
24
24
|
lastByBranch = new Map();
|
|
25
|
+
/** optional observer (e.g. console logger wired by the master) */
|
|
26
|
+
onEvent = null;
|
|
25
27
|
filePath;
|
|
26
28
|
agentId;
|
|
27
29
|
constructor(filePath, agentId) {
|
|
@@ -87,6 +89,12 @@ export class EventLog {
|
|
|
87
89
|
data,
|
|
88
90
|
};
|
|
89
91
|
this.lastByBranch.set(branch, evt.id);
|
|
92
|
+
try {
|
|
93
|
+
this.onEvent?.(evt);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
/* observer must never break the log */
|
|
97
|
+
}
|
|
90
98
|
const p = new Promise((resolve, reject) => {
|
|
91
99
|
this.chain = this.chain.then(() => {
|
|
92
100
|
if (!this.stream)
|
package/dist/master.js
CHANGED
|
@@ -65,6 +65,72 @@ export function loadConfig(configPath) {
|
|
|
65
65
|
export function loadedRaw() {
|
|
66
66
|
return masterRawConfig;
|
|
67
67
|
}
|
|
68
|
+
/* ---------- console activity log ---------- */
|
|
69
|
+
const isTTY = process.stdout.isTTY;
|
|
70
|
+
const c = (code, s) => (isTTY ? `\x1b[${code}m${s}\x1b[0m` : s);
|
|
71
|
+
const dim = (s) => c("2", s);
|
|
72
|
+
const clip1 = (s, n) => {
|
|
73
|
+
const one = String(s ?? "").replace(/\s+/g, " ").trim();
|
|
74
|
+
return one.length > n ? one.slice(0, n) + "…" : one;
|
|
75
|
+
};
|
|
76
|
+
const hhmmss = () => new Date().toTimeString().slice(0, 8);
|
|
77
|
+
/** Print one agent event as a compact human-readable console line. */
|
|
78
|
+
function printAgentEvent(e) {
|
|
79
|
+
const ts = dim(hhmmss());
|
|
80
|
+
const who = c("36", e.agent); // cyan
|
|
81
|
+
const d = e.data;
|
|
82
|
+
let line = null;
|
|
83
|
+
switch (e.type) {
|
|
84
|
+
case "prompt":
|
|
85
|
+
line = `${c("33", "▶ prompt")} (${d.source}) ${clip1(d.text, 110)}`;
|
|
86
|
+
break;
|
|
87
|
+
case "tool_call":
|
|
88
|
+
line = `${c("36", "⚙ exec")} ${d.name} ${dim(clip1(JSON.stringify(d.args ?? {}), 130))}`;
|
|
89
|
+
break;
|
|
90
|
+
case "tool_result": {
|
|
91
|
+
const ok = d.ok !== false;
|
|
92
|
+
const mark = ok ? c("32", "✔ done") : c("31", "✖ fail");
|
|
93
|
+
line = `${mark} ${d.name} ${dim(`${d.durationMs}ms`)} ${dim(clip1(d.result, 90))}`;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case "state": {
|
|
97
|
+
if (d.from === d.to && !d.reason && !d.detail)
|
|
98
|
+
break;
|
|
99
|
+
if (d.detail === "llm turn start") {
|
|
100
|
+
line = `${c("35", "· llm")} turn ${d.turn}`;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
line = `${c("35", "◆ state")} ${d.from}→${d.to}${d.reason ? ` (${clip1(d.reason, 80)})` : ""}`;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case "message":
|
|
107
|
+
if (d.final && d.content)
|
|
108
|
+
line = `${c("34", "🏁 final")} ${clip1(d.content, 140)}`;
|
|
109
|
+
break; // regular assistant messages are visible in the UI
|
|
110
|
+
case "progress":
|
|
111
|
+
line = `${c("32", "📈 progress")} ${clip1(d.doing, 100)}`;
|
|
112
|
+
break;
|
|
113
|
+
case "goal":
|
|
114
|
+
line = `🎯 goal ${d.event}: ${clip1(d.text ?? d.status, 100)}`;
|
|
115
|
+
break;
|
|
116
|
+
case "error":
|
|
117
|
+
line = `${c("31", "⚠ error")} ${clip1(d.message, 160)}`;
|
|
118
|
+
break;
|
|
119
|
+
case "system_note": {
|
|
120
|
+
if (d.event === "llm-retry")
|
|
121
|
+
line = `${c("33", "↻ retry")} attempt ${d.attempt} in ${Math.round(Number(d.waitMs) / 1000)}s — ${clip1(d.error, 100)}`;
|
|
122
|
+
else if (d.event === "context-compacted")
|
|
123
|
+
line = `${c("33", "🗜 compact")} tokens ${d.tokensBefore}→${d.tokensAfter} (${d.mode})`;
|
|
124
|
+
else if (d.event === "session-restored")
|
|
125
|
+
line = `${c("33", "⟲ restore")} branch ${d.branch}, ${d.messages} messages`;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
default:
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
if (line)
|
|
132
|
+
console.log(`${dim(ts)} ${who} ${line}`);
|
|
133
|
+
}
|
|
68
134
|
export class Master {
|
|
69
135
|
agents = new Map();
|
|
70
136
|
tasks = [];
|
|
@@ -153,6 +219,7 @@ export class Master {
|
|
|
153
219
|
...(this.config.contextTokenBudget ? { contextTokenBudget: this.config.contextTokenBudget } : {}),
|
|
154
220
|
globalSkillsDir: path.join(CONFIG_DIR, "skills"),
|
|
155
221
|
});
|
|
222
|
+
agent.log.onEvent = (e) => printAgentEvent(e);
|
|
156
223
|
await agent.init();
|
|
157
224
|
this.agents.set(ac.id, agent);
|
|
158
225
|
if (persist) {
|
package/dist/server/api.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* REST + SSE API on Hono, plus static file serving for the web UI.
|
|
3
3
|
*/
|
|
4
4
|
import { Hono } from "hono";
|
|
5
|
-
import { serve } from "@hono/node-server";
|
|
5
|
+
import { serve, upgradeWebSocket } from "@hono/node-server";
|
|
6
|
+
import { WebSocketServer } from "ws";
|
|
6
7
|
import { readFileSync } from "node:fs";
|
|
7
8
|
import { promises as fs } from "node:fs";
|
|
8
9
|
import { fileURLToPath } from "node:url";
|
|
@@ -12,6 +13,45 @@ import { bus } from "../bus.js";
|
|
|
12
13
|
import { readEvents } from "../log/events.js";
|
|
13
14
|
export function buildApp(master) {
|
|
14
15
|
const app = new Hono();
|
|
16
|
+
// ---- realtime events over WebSocket (replaces SSE for the web UI) ----
|
|
17
|
+
app.get("/api/ws", upgradeWebSocket(() => {
|
|
18
|
+
let onUpdate = null;
|
|
19
|
+
let ka = null;
|
|
20
|
+
return {
|
|
21
|
+
onOpen(_evt, ws) {
|
|
22
|
+
const send = (data) => {
|
|
23
|
+
try {
|
|
24
|
+
ws.send(JSON.stringify(data));
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
/* client gone */
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
send({ kind: "hello", agents: [...master.agents.values()].map((a) => a.snapshot()) });
|
|
31
|
+
onUpdate = (ev) => send(ev);
|
|
32
|
+
bus.on("update", onUpdate);
|
|
33
|
+
// app-level liveness ping every 30s
|
|
34
|
+
ka = setInterval(() => send({ kind: "ping" }), 30_000);
|
|
35
|
+
},
|
|
36
|
+
onMessage(evt, ws) {
|
|
37
|
+
// clients may send {"kind":"ping"} — nothing else to do today
|
|
38
|
+
try {
|
|
39
|
+
const m = JSON.parse(String(evt.data));
|
|
40
|
+
if (m?.kind === "ping")
|
|
41
|
+
ws.send(JSON.stringify({ kind: "pong" }));
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
/* ignore junk */
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
onClose() {
|
|
48
|
+
if (ka)
|
|
49
|
+
clearInterval(ka);
|
|
50
|
+
if (onUpdate)
|
|
51
|
+
bus.off("update", onUpdate);
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}));
|
|
15
55
|
// ---- agents ----
|
|
16
56
|
app.get("/api/agents", (c) => c.json({ agents: [...master.agents.values()].map((a) => a.snapshot()) }));
|
|
17
57
|
// create + start an agent on an arbitrary directory
|
|
@@ -205,25 +245,34 @@ export function buildApp(master) {
|
|
|
205
245
|
const stream = new ReadableStream({
|
|
206
246
|
start(controller) {
|
|
207
247
|
const enc = new TextEncoder();
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
bus.on("update", onUpdate);
|
|
212
|
-
// keep-alive comment every 30s so proxies don't close the stream
|
|
213
|
-
const ka = setInterval(() => controller.enqueue(enc.encode(": ping\n\n")), 30_000);
|
|
214
|
-
;
|
|
215
|
-
controller._cleanup = () => {
|
|
248
|
+
let closed = false;
|
|
249
|
+
const cleanup = () => {
|
|
250
|
+
closed = true;
|
|
216
251
|
clearInterval(ka);
|
|
217
252
|
bus.off("update", onUpdate);
|
|
218
253
|
};
|
|
254
|
+
const send = (data) => {
|
|
255
|
+
if (closed)
|
|
256
|
+
return;
|
|
257
|
+
try {
|
|
258
|
+
controller.enqueue(enc.encode(`data: ${JSON.stringify(data)}\n\n`));
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
// client vanished mid-write — never let this reach event emitters
|
|
262
|
+
cleanup();
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
send({ kind: "hello", agents: [...master.agents.values()].map((a) => a.snapshot()) });
|
|
266
|
+
const onUpdate = (ev) => send(ev);
|
|
267
|
+
bus.on("update", onUpdate);
|
|
268
|
+
// keep-alive ping every 30s so proxies don't close the stream
|
|
269
|
+
const ka = setInterval(() => send({ kind: "ping" }), 30_000);
|
|
270
|
+
c.req.raw.signal.addEventListener("abort", cleanup);
|
|
219
271
|
},
|
|
220
272
|
cancel() {
|
|
221
|
-
/*
|
|
273
|
+
/* cleanup also runs via the abort listener above */
|
|
222
274
|
},
|
|
223
275
|
});
|
|
224
|
-
c.req.raw.signal.addEventListener("abort", () => {
|
|
225
|
-
/* node-server closes the stream; cleanup runs on cancel */
|
|
226
|
-
});
|
|
227
276
|
return c.body(stream);
|
|
228
277
|
});
|
|
229
278
|
// RFC 2324 / HTCPCP compliance
|
|
@@ -238,13 +287,22 @@ export function buildApp(master) {
|
|
|
238
287
|
".svg": "image/svg+xml",
|
|
239
288
|
".ico": "image/x-icon",
|
|
240
289
|
};
|
|
241
|
-
|
|
290
|
+
const indexHtml = () => {
|
|
242
291
|
try {
|
|
243
|
-
return
|
|
292
|
+
return readFileSync(path.join(webRoot, "index.html"), "utf8");
|
|
244
293
|
}
|
|
245
294
|
catch {
|
|
246
|
-
return
|
|
295
|
+
return null;
|
|
247
296
|
}
|
|
297
|
+
};
|
|
298
|
+
app.get("/", (c) => {
|
|
299
|
+
const html = indexHtml();
|
|
300
|
+
return html ? c.html(html) : c.text("web UI not built — run: pnpm build-web", 404);
|
|
301
|
+
});
|
|
302
|
+
// SPA deep links: /session/<agentId> serves the app; the client routes it
|
|
303
|
+
app.get("/session/*", (c) => {
|
|
304
|
+
const html = indexHtml();
|
|
305
|
+
return html ? c.html(html) : c.text("web UI not built — run: pnpm build-web", 404);
|
|
248
306
|
});
|
|
249
307
|
app.get("/assets/*", (c) => {
|
|
250
308
|
const rel = c.req.path.replace("/assets/", "");
|
|
@@ -261,7 +319,8 @@ export function buildApp(master) {
|
|
|
261
319
|
return app;
|
|
262
320
|
}
|
|
263
321
|
export function serveApp(app, port) {
|
|
264
|
-
|
|
322
|
+
const wss = new WebSocketServer({ noServer: true });
|
|
323
|
+
serve({ fetch: app.fetch, port, websocket: { server: wss } }, (info) => {
|
|
265
324
|
console.log(`[teapot] master listening on http://localhost:${info.port}`);
|
|
266
325
|
});
|
|
267
326
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teapot-coding-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A lightweight, always-on multi-agent harness for AI coding agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0-or-later",
|
|
@@ -38,12 +38,14 @@
|
|
|
38
38
|
"test": "node --test test/*.test.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@hono/node-server": "^1.
|
|
41
|
+
"@hono/node-server": "^2.1.1",
|
|
42
42
|
"hono": "^4.7.0",
|
|
43
|
-
"openai": "^5.0.0"
|
|
43
|
+
"openai": "^5.0.0",
|
|
44
|
+
"ws": "^8.21.3"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@types/node": "^24.0.0",
|
|
48
|
+
"@types/ws": "^8.18.1",
|
|
47
49
|
"solid-js": "^1.9.15",
|
|
48
50
|
"typescript": "^5.8.0",
|
|
49
51
|
"vite": "^8.2.2",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return t(this.context.count)},getNextContextId(){return t(this.context.count++)}};function t(t){let n=String(t),r=n.length-1;return e.context.id+(r?String.fromCharCode(96+r):``)+n}function n(t){e.context=t}var r=(e,t)=>e===t,i=Symbol(`solid-track`),a={equals:r},o=null,s=F,c=1,l=2,u={owned:null,cleanups:null,context:null,owner:null},d=null,f=null,p=null,m=null,h=null,g=0;function _(e,t){let n=p,r=d,i=e.length===0,a=t===void 0?r:t,o=i?u:{owned:null,cleanups:null,context:a?a.context:null,owner:a},s=i?e:()=>e(()=>S(()=>z(o)));d=o,p=null;try{return N(s,!0)}finally{p=n,d=r}}function v(e,t){t=t?Object.assign({},a,t):a;let n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0};return[te.bind(n),e=>(typeof e==`function`&&(e=f&&f.running&&f.sources.has(n)?e(n.tValue):e(n.value)),O(n,e))]}function y(e,t,n){k(j(e,t,!1,c))}function b(e,t,n){s=I;let r=j(e,t,!1,c),i=D&&ee(D);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),h?h.push(r):k(r)}function x(e,t,n){n=n?Object.assign({},a,n):a;let r=j(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,k(r),te.bind(r)}function S(e){if(p===null)return e();let t=p;p=null;try{return e()}finally{p=t}}function C(e){b(()=>S(e))}function w(e){return d===null||(d.cleanups===null?d.cleanups=[e]:d.cleanups.push(e)),e}var[T,E]=v(!1);function ee(e){let t;return d&&d.context&&(t=d.context[e.id])!==void 0?t:e.defaultValue}var D;function te(){let e=f&&f.running;if(this.sources&&(e?this.tState:this.state)){if((e?this.tState:this.state)===c)k(this);else{let e=m;m=null,N(()=>L(this),!1),m=e}}if(p){let e=this.observers;if(!e||e[e.length-1]!==p){let t=e?e.length:0;p.sources?(p.sources.push(this),p.sourceSlots.push(t)):(p.sources=[this],p.sourceSlots=[t]),e?(e.push(p),this.observerSlots.push(p.sources.length-1)):(this.observers=[p],this.observerSlots=[p.sources.length-1])}}return e&&f.sources.has(this)?this.tValue:this.value}function O(e,t,n){let r=f&&f.running&&f.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(r,t)){if(f){let r=f.running;(r||!n&&f.sources.has(e))&&(f.sources.add(e),e.tValue=t),r||(e.value=t)}else e.value=t;e.observers&&e.observers.length&&N(()=>{for(let t=0;t<e.observers.length;t+=1){let n=e.observers[t],r=f&&f.running;r&&f.disposed.has(n)||((r?!n.tState:!n.state)&&(n.pure?m.push(n):h.push(n),n.observers&&R(n)),r?n.tState=c:n.state=c)}if(m.length>1e6)throw m=[],Error()},!1)}return t}function k(e){if(!e.fn)return;z(e);let t=g;A(e,f&&f.running&&f.sources.has(e)?e.tValue:e.value,t),f&&!f.running&&f.sources.has(e)&&queueMicrotask(()=>{N(()=>{f&&(f.running=!0),p=d=e,A(e,e.tValue,t),p=d=null},!1)})}function A(e,t,n){let r,i=d,a=p;p=d=e;try{r=e.fn(t)}catch(t){return e.pure&&(f&&f.running?(e.tState=c,e.tOwned&&e.tOwned.forEach(z),e.tOwned=void 0):(e.state=c,e.owned&&e.owned.forEach(z),e.owned=null)),e.updatedAt=n+1,H(t)}finally{p=a,d=i}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&`observers`in e?O(e,r,!0):f&&f.running&&e.pure?(f.sources.has(e)||(e.value=r),f.sources.add(e),e.tValue=r):e.value=r,e.updatedAt=n)}function j(e,t,n,r=c,i){let a={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:d,context:d?d.context:null,pure:n};return f&&f.running&&(a.state=0,a.tState=r),d===null||d!==u&&(f&&f.running&&d.pure?d.tOwned?d.tOwned.push(a):d.tOwned=[a]:d.owned?d.owned.push(a):d.owned=[a]),a}function M(e){let t=f&&f.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===l)return L(e);if(e.suspense&&S(e.suspense.inFallback))return e.suspense.effects.push(e);let n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<g);){if(t&&f.disposed.has(e))return;(t?e.tState:e.state)&&n.push(e)}for(let r=n.length-1;r>=0;r--){if(e=n[r],t){let t=e,i=n[r+1];for(;(t=t.owner)&&t!==i;)if(f.disposed.has(t))return}if((t?e.tState:e.state)===c)k(e);else if((t?e.tState:e.state)===l){let t=m;m=null,N(()=>L(e,n[0]),!1),m=t}}}function N(e,t){if(m)return e();let n=!1;t||(m=[]),h?n=!0:h=[],g++;try{let t=e();return P(n),t}catch(e){n||(h=null),m=null,H(e)}}function P(e){if(m&&=(F(m),null),e)return;let t;if(f){if(!f.promises.size&&!f.queue.size){let e=f.sources,n=f.disposed;h.push.apply(h,f.effects),t=f.resolve;for(let e of h)`tState`in e&&(e.state=e.tState),delete e.tState;f=null,N(()=>{for(let e of n)z(e);for(let t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)z(t.owned[e]);t.tOwned&&(t.owned=t.tOwned),delete t.tValue,delete t.tOwned,t.tState=0}E(!1)},!1)}else if(f.running){f.running=!1,f.effects.push.apply(f.effects,h),h=null,E(!0);return}}let n=h;h=null,n.length&&N(()=>s(n),!1),t&&t()}function F(e){for(let t=0;t<e.length;t++)M(e[t])}function I(t){let r,i=0;for(r=0;r<t.length;r++){let e=t[r];e.user?t[i++]=e:M(e)}if(e.context){if(e.count){e.effects||=[],e.effects.push(...t.slice(0,i));return}n()}for(e.effects&&(e.done||!e.count)&&(t=[...e.effects,...t],i+=e.effects.length,delete e.effects),r=0;r<i;r++)M(t[r])}function L(e,t){let n=f&&f.running;n?e.tState=0:e.state=0;for(let r=0;r<e.sources.length;r+=1){let i=e.sources[r];if(i.sources){let e=n?i.tState:i.state;e===c?i!==t&&(!i.updatedAt||i.updatedAt<g)&&M(i):e===l&&L(i,t)}}}function R(e){let t=f&&f.running;for(let n=0;n<e.observers.length;n+=1){let r=e.observers[n];(t?!r.tState:!r.state)&&(t?r.tState=l:r.state=l,r.pure?m.push(r):h.push(r),r.observers&&R(r))}}function z(e){let t;if(e.sources)for(;e.sources.length;){let t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){let e=r.pop(),i=t.observerSlots.pop();n<r.length&&(e.sourceSlots[i]=n,r[n]=e,t.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)z(e.tOwned[t]);delete e.tOwned}if(f&&f.running&&e.pure)B(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)z(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}f&&f.running?e.tState=0:e.state=0}function B(e,t){if(t||(e.tState=0,f.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)B(e.owned[t])}function V(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`,{cause:e})}function ne(e,t,n){try{for(let n of t)n(e)}catch(e){H(e,n&&n.owner||null)}}function H(e,t=d){let n=o&&t&&t.context&&t.context[o],r=V(e);if(!n)throw r;h?h.push({fn(){ne(r,n,t)},state:c}):ne(r,n,t)}var U=Symbol(`fallback`);function W(e){for(let t=0;t<e.length;t++)e[t]()}function re(e,t,n={}){let r=[],a=[],o=[],s=0,c=t.length>1?[]:null;return w(()=>W(o)),()=>{let l=e()||[],u=l.length,d,f;return l[i],S(()=>{let e,t,i,m,h,g,v,y,b;if(u===0)s!==0&&(W(o),o=[],r=[],a=[],s=0,c&&=[]),n.fallback&&(r=[U],a[0]=_(e=>(o[0]=e,n.fallback())),s=1);else if(s===0){for(a=Array(u),f=0;f<u;f++)r[f]=l[f],a[f]=_(p);s=u}else{for(i=Array(u),m=Array(u),c&&(h=Array(u)),g=0,v=Math.min(s,u);g<v&&r[g]===l[g];g++);for(v=s-1,y=u-1;v>=g&&y>=g&&r[v]===l[y];v--,y--)i[y]=a[v],m[y]=o[v],c&&(h[y]=c[v]);for(e=new Map,t=Array(y+1),f=y;f>=g;f--)b=l[f],d=e.get(b),t[f]=d===void 0?-1:d,e.set(b,f);for(d=g;d<=v;d++)b=r[d],f=e.get(b),f!==void 0&&f!==-1?(i[f]=a[d],m[f]=o[d],c&&(h[f]=c[d]),f=t[f],e.set(b,f)):o[d]();for(f=g;f<u;f++)f in i?(a[f]=i[f],o[f]=m[f],c&&(c[f]=h[f],c[f](f))):a[f]=_(p);a=a.slice(0,s=u),r=l.slice(0)}return a});function p(e){if(o[f]=e,c){let[e,n]=v(f);return c[f]=n,t(l[f],e)}return t(l[f])}}}function G(e,t){return S(()=>e(t||{}))}var ie=e=>`Stale read from <${e}>.`;function K(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return x(re(()=>e.each,e.children,t||void 0))}function q(e){let t=e.keyed,n=x(()=>e.when,void 0,void 0),r=t?n:x(n,void 0,{equals:(e,t)=>!e==!t});return x(()=>{let i=r();if(i){let a=e.children;return typeof a==`function`&&a.length>0?S(()=>a(t?i:()=>{if(!S(r))throw ie(`Show`);return n()})):a}return e.fallback},void 0,void 0)}var J=e=>x(()=>e());function ae(e,t,n){let r=n.length,i=t.length,a=r,o=0,s=0,c=t[i-1].nextSibling,l=null;for(;o<i||s<a;){if(t[o]===n[s]){o++,s++;continue}for(;t[i-1]===n[a-1];)i--,a--;if(i===o){let t=a<r?s?n[s-1].nextSibling:n[a-s]:c;for(;s<a;)e.insertBefore(n[s++],t)}else if(a===s)for(;o<i;)(!l||!l.has(t[o]))&&t[o].remove(),o++;else if(t[o]===n[a-1]&&n[s]===t[i-1]){let r=t[--i].nextSibling;e.insertBefore(n[s++],t[o++].nextSibling),e.insertBefore(n[--a],r),t[i]=n[a]}else{if(!l){l=new Map;let e=s;for(;e<a;)l.set(n[e],e++)}let r=l.get(t[o]);if(r!=null){if(s<r&&r<a){let c=o,u=1,d;for(;++c<i&&c<a&&(d=l.get(t[c]))!=null&&d===r+u;)u++;if(u>r-s){let i=t[o];for(;s<r;)e.insertBefore(n[s++],i)}else e.replaceChild(n[s++],t[o++])}else o++}else t[o++].remove()}}}var oe=`_$DX_DELEGATE`;function se(e,t,n,r={}){let i;return _(r=>{i=r,t===document?e():Z(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{i(),t.textContent=``}}function Y(e,t,n,r){let i,a=()=>{let t=r?document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`template`):document.createElement(`template`);return t.innerHTML=e,n?t.content.firstChild.firstChild:r?t.firstChild:t.content.firstChild},o=t?()=>S(()=>document.importNode(i||=a(),!0)):()=>(i||=a()).cloneNode(!0);return o.cloneNode=o,o}function ce(e,t=window.document){let n=t[oe]||(t[oe]=new Set);for(let r=0,i=e.length;r<i;r++){let i=e[r];n.has(i)||(n.add(i),t.addEventListener(i,pe))}}function le(e,t,n){fe(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function X(e,t){fe(e)||(t==null?e.removeAttribute(`class`):e.className=t)}function ue(e,t,n,r){if(r)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){let r=n[0];e.addEventListener(t,n[0]=t=>r.call(e,n[1],t))}else e.addEventListener(t,n,typeof n!=`function`&&n)}function de(e,t,n){n==null?e.style.removeProperty(t):e.style.setProperty(t,n)}function Z(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!=`function`)return me(e,t,r,n);y(r=>me(e,t(),r,n),r)}function fe(t){return!!e.context&&!e.done&&(!t||t.isConnected)}function pe(t){if(e.registry&&e.events&&e.events.find(([e,n])=>n===t))return;let n=t.target,r=`$$${t.type}`,i=t.target,a=t.currentTarget,o=e=>Object.defineProperty(t,"target",{configurable:!0,value:e}),s=()=>{let e=n[r];if(e&&!n.disabled){let i=n[`${r}Data`];if(i===void 0?e.call(n,t):e.call(n,i,t),t.cancelBubble)return}return n.host&&typeof n.host!=`string`&&!n.host._$host&&n.contains(t.target)&&o(n.host),!0},c=()=>{for(;s()&&(n=n._$host||n.parentNode||n.host););};if(Object.defineProperty(t,"currentTarget",{configurable:!0,get(){return n||document}}),e.registry&&!e.done&&(e.done=_$HY.done=!0),t.composedPath){let e=t.composedPath();o(e[0]);for(let t=0;t<e.length-2&&(n=e[t],s());t++){if(n._$host){n=n._$host,c();break}if(n.parentNode===a)break}}else c();o(i)}function me(e,t,n,r,i){let a=fe(e);if(a){!n&&(n=[...e.childNodes]);let t=[];for(let e=0;e<n.length;e++){let r=n[e];r.nodeType===8&&r.data.slice(0,2)===`!$`?r.remove():t.push(r)}n=t}for(;typeof n==`function`;)n=n();if(t===n)return n;let o=typeof t,s=r!==void 0;if(e=s&&n[0]&&n[0].parentNode||e,o===`string`||o===`number`){if(a||o===`number`&&(t=t.toString(),t===n))return n;if(s){let i=n[0];i&&i.nodeType===3?i.data!==t&&(i.data=t):i=document.createTextNode(t),n=Q(e,n,r,i)}else n=n!==``&&typeof n==`string`?e.firstChild.data=t:e.textContent=t}else if(t==null||o===`boolean`){if(a)return n;n=Q(e,n,r)}else if(o===`function`)return y(()=>{let i=t();for(;typeof i==`function`;)i=i();n=me(e,i,n,r)}),()=>n;else if(Array.isArray(t)){let o=[],c=n&&Array.isArray(n);if(he(o,t,n,i))return y(()=>n=me(e,o,n,r,!0)),()=>n;if(a){if(!o.length)return n;if(r===void 0)return n=[...e.childNodes];let t=o[0];if(t.parentNode!==e)return n;let i=[t];for(;(t=t.nextSibling)!==r;)i.push(t);return n=i}if(o.length===0){if(n=Q(e,n,r),s)return n}else c?n.length===0?ge(e,o,r):ae(e,n,o):(n&&Q(e),ge(e,o));n=o}else if(t.nodeType){if(a&&t.parentNode)return n=s?[t]:t;if(Array.isArray(n)){if(s)return n=Q(e,n,r,t);Q(e,n,null,t)}else n==null||n===``||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}return n}function he(e,t,n,r){let i=!1;for(let a=0,o=t.length;a<o;a++){let o=t[a],s=n&&n[e.length],c;if(o!=null&&o!==!0&&o!==!1){if((c=typeof o)==`object`&&o.nodeType)e.push(o);else if(Array.isArray(o))i=he(e,o,s)||i;else if(c===`function`){if(r){for(;typeof o==`function`;)o=o();i=he(e,Array.isArray(o)?o:[o],Array.isArray(s)?s:[s])||i}else e.push(o),i=!0}else{let t=String(o);s&&s.nodeType===3&&s.data===t?e.push(s):e.push(document.createTextNode(t))}}}return i}function ge(e,t,n=null){for(let r=0,i=t.length;r<i;r++)e.insertBefore(t[r],n)}function Q(e,t,n,r){if(n===void 0)return e.textContent=``;let i=r||document.createTextNode(``);if(t.length){let r=!1;for(let a=t.length-1;a>=0;a--){let o=t[a];if(i!==o){let t=o.parentNode===e;!r&&!a?t?e.replaceChild(i,o):e.insertBefore(i,n):t&&o.remove()}else r=!0}}else e.insertBefore(i,n);return[i]}function _e(e){let t=ve(e.replace(/\r\n/g,`
|
|
2
|
+
`)).split(`
|
|
3
|
+
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(/^```\w*\s*$/.test(e)){let e=[];for(r++;r<t.length&&!/^```\s*$/.test(t[r]);)e.push(t[r++]);r++,n.push(`<pre><code>${e.join(`
|
|
4
|
+
`)}</code></pre>`);continue}let a=e.match(/^(#{1,4})\s+(.*)$/);if(a){n.push(`<h${a[1].length}>${i(a[2])}</h${a[1].length}>`),r++;continue}let o=/^\s*\d+[.)]\s+/.test(e);if(o||/^\s*[-*]\s+/.test(e)){let e=[];for(;r<t.length;){let n=t[r].match(/^\s*[-*]\s+(.*)$/)??(o?t[r].match(/^\s*\d+[.)]\s+(.*)$/):null);if(!n)break;e.push(`<li>${i(n[1])}</li>`),r++}n.push(o?`<ol>${e.join(``)}</ol>`:`<ul>${e.join(``)}</ul>`);continue}if(/^\s*$/.test(e)){r++;continue}let s=[];for(;r<t.length&&!/^\s*$/.test(t[r])&&!/^#{1,4}\s/.test(t[r])&&!/^```/.test(t[r])&&!/^\s*([-*]|\d+[.)])\s/.test(t[r]);)s.push(t[r++]);n.push(`<p>${s.map(i).join(`<br>`)}</p>`)}return n.join(`
|
|
5
|
+
`);function i(e){return e.replace(/`([^`]+)`/g,`<code>$1</code>`).replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`).replace(/(^|\W)\*([^*]+)\*(?=\W|$)/g,`$1<em>$2</em>`).replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g,`<a href="$2" rel="noopener noreferrer" target="_blank">$1</a>`)}}function ve(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var ye=Y(`<br>`),be=Y(`<span class=sub>ℹ`),xe=Y(`<header class=chan-head><span class=hash>#</span><span class=title></span><span></span><span class=sub> · <!>/<!> · turns <!> · tools </span><span style=margin-left:auto;display:flex;gap:4px><button class=iconbtn title="toggle details panel">▤`),Se=Y(`<details class=reasoning><summary>💭 reasoning</summary><div class=mono>`),Ce=Y(`<div class=content><span class=cursor>▍`),we=Y(`<div class="msg live"><div class=avatar style="background:#5865f233;border:1px solid #5865f266">🫖</div><div class=msg-body><div class=msg-head><span class=author style=color:var(--acc)>agent</span><span class=ts>streaming…`),Te=Y(`<div class=feed>`),Ee=Y(`<button class=jump>↓ `),De=Y(`<div class=composer><form><input type=text><label><input type=checkbox>auto-start</label><button type=submit>send</button></form><div class=hint>enter to send · prompts are appended to the conversation and the agent keeps working toward its goal`),Oe=Y(`<h3>controls`),ke=Y(`<div class=btnrow><button>▶ start</button><button>■ stop</button><button>⑂ fork</button><button title="remove agent">🗑`),Ae=Y(`<h3>goal <span>`),je=Y(`<form style=display:flex;gap:4px;margin-bottom:6px><input id=goal-input type=text placeholder="set new goal…"style="flex:1;background:var(--bg-darkest);border:none;border-radius:6px;padding:6px 8px;color:var(--fg);font:inherit"><button type=submit style="background:var(--acc);border:none;border-radius:6px;color:#fff;padding:0 10px;cursor:pointer">✓`),Me=Y(`<div class=card>`),Ne=Y(`<h3>latest progress`),Pe=Y(`<div class=card>
|
|
6
|
+
<!>
|
|
7
|
+
<span class=muted>`),Fe=Y(`<h3>branches`),Ie=Y(`<h3>runtime`),Le=Y(`<div class="card muted">turns <!> · tools <!>
|
|
8
|
+
tokens in/out <!>/<!>
|
|
9
|
+
`),Re=Y(`<div class=layout><nav class=sidebar><h1>🫖 teapot<span></span><span style=float:right;display:flex;gap:4px><button class=iconbtn title="new agent">+</button><button class=iconbtn title=settings>⚙</button></span></h1><div class=agent-list></div><div class=metrics></div></nav><section class=channel></section><aside>`),ze=Y(`<span title="goal done">✓`),Be=Y(`<div><span></span><span>`),Ve=Y(`<div class=muted style=display:grid;place-items:center;height:100%>select an agent`),He=Y(`<div class=muted style=display:grid;place-items:center;height:100%>no events yet — say something or press ▶ start`),Ue=Y(`<div class="content muted">thinking…`),We=Y(`<div class=muted>none yet`),Ge=Y(`<div><span>`),Ke=Y(`<div> → `),qe=Y(`<div class=avatar>`),Je=Y(`<div class=msg-head><span class=author></span><span class=ts></span><span class=ts>`),Ye=Y(`<div><div class=msg-body>`),Xe=Y(`<span style=width:38px>`),Ze=Y(`<div class=content>`),Qe=Y(`<div class=msgfoot><span>copy summary`),$e=Y(`<details class=embed><summary><b>⚙ </b> <span class=meta></span></summary><div class=mono>`),et=Y(`<details><summary><span class=meta></span></summary><div class=mono></div><div class=meta>ms`),tt=Y(`<div class=meta>`),nt=Y(`<div class=meta>⚠ `),rt=Y(`<div class=meta>→ `),it=Y(`<div class=embed style=border-color:var(--ok)><div>📈 `),at=Y(`<div class="embed fail"><div class=mono>⚠ `),ot=Y(`<div class="content muted">`),st=Y(`<button class=copybtn title="copy to clipboard">`),ct=Y(`<div class=overlay><div class=modal><div class=modal-head><b></b><button class=iconbtn>✕`),lt=Y(`<span style=color:var(--err);font-size:13px>`),ut=Y(`<form style=display:flex;flex-direction:column;gap:10px><label>workspace directory<div style=display:flex;gap:6px><input type=text class="w100 mono"><button type=button>go</button><button type=button>↑</button></div></label><div class=dirlist></div><div style=display:flex;gap:10px><label style=flex:1>agent name <input type=text placeholder="(directory name)"></label><label>provider<select></select></label><label style=flex:1>model <input type=text placeholder="(provider default)"></label></div><button type=submit style=align-self:flex-end>create & start`),dt=Y(`<div class=direntry>📁 `),ft=Y(`<option>`),pt=Y(`<form style=display:flex;flex-direction:column;gap:10px><label>providers (<!>)<textarea rows=8 class="mono w100"></textarea></label><div style=display:flex;gap:10px><label style=flex:1>default provider <input type=text></label><label>progress interval (min) <input type=number min=1 style=width:90px></label></div><label>scheduled tasks (JSON array)<textarea rows=7 class="mono w100"></textarea></label><button type=submit style=align-self:flex-end>save`),mt={user:{name:`you`,icon:`🧑`,color:`#faa81a`},message:{name:`agent`,icon:`🫖`,color:`#5865f2`},tool_call:{name:`tool`,icon:`🔧`,color:`#3ba0c9`},progress:{name:`progress`,icon:`📈`,color:`#3ba55d`}},ht=e=>mt[e.type]??{name:e.type,icon:`•`,color:`#9298a5`},gt=new Set([`user`,`message`,`prompt`,`tool_call`,`tool_result`,`progress`]),_t=e=>gt.has(e.type),vt=e=>{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`};async function $(e,t){let n=await fetch(e,t);if(!n.ok)throw Error(`${e}: ${n.status}`);return n.json()}function yt(){let[e,t]=v([]),[n,r]=v(null),[i,a]=v([]),[o,s]=v([]),[c,l]=v(null),[u,d]=v(``),[f,p]=v(!0),[m,h]=v({providers:{}}),[g,_]=v(!1),[S,T]=v(!1),[E,ee]=v(!1),[D,te]=v(!0),[O,k]=v(0),[A,j]=v(null),M=x(()=>i().filter(_t)),N=()=>$(`/api/config`).then(h).catch(()=>{}),P=x(()=>e().find(e=>e.id===n())),F=()=>$(`/api/agents`).then(e=>t(e.agents)).catch(()=>{}),I=()=>$(`/api/metrics`).then(l).catch(()=>{});async function L(e){try{let[t,n]=await Promise.all([$(`/api/agents/${e}/events?limit=300`),$(`/api/agents/${e}/branches`)]);a(t.events),s(n.branches)}catch{}}function R(){return document.querySelector(`.feed`)}function z(){let e=R();return!e||e.scrollHeight-e.scrollTop-e.clientHeight<80}function B(e=!1){let t=R();t&&(e||D())&&(t.scrollTop=t.scrollHeight,k(0))}async function V(e,t=!0){r(e),j(null),localStorage.setItem(`teapot.session`,e),ae(e,t),await L(e),requestAnimationFrame(()=>B(!0))}let[ne,H]=v(!1),U=null,W=null;w(()=>U?.close());function re(){let e=location.protocol===`https:`?`wss://`:`ws://`;U=new WebSocket(`${e}${location.host}/api/ws`),U.onopen=()=>H(!0),U.onclose=()=>{H(!1),setTimeout(re,1500)},U.onerror=()=>U?.close(),U.onmessage=e=>{let t=JSON.parse(e.data);if(t.kind!==`ping`&&t.kind!==`pong`){if(t.kind===`llm-delta`){t.agentId===n()&&j({text:t.text??``,reasoning:t.reasoning??``});return}W||=setTimeout(async()=>{if(W=null,await F(),await I(),n()){let e=i().length;await L(n()),i().length!==e&&(j(null),z()?B(!0):k(O()+(i().length-e)))}},400)}}}let ie=()=>decodeURIComponent(location.pathname.split(`/`)[2]??``);function ae(e,t=!0){let n=`/session/${encodeURIComponent(e)}`;t?history.pushState(null,``,n):history.replaceState(null,``,n)}window.addEventListener(`popstate`,()=>{let t=ie();t&&e().some(e=>e.id===t)&&t!==n()&&V(t,!1)}),b(()=>{let e=P();document.title=e?`${e.status===`running`?`▶ `:e.status===`error`?`⚠ `:``}${e.id} · teapot`:`teapot`}),window.addEventListener(`keydown`,t=>{let r=t.target;if(r&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.isContentEditable)){t.key===`Escape`&&r.blur();return}if(t.key===`Escape`){g()?_(!1):S()?T(!1):E()&&ee(!1);return}if(!(g()||S())){if(t.key===`/`)t.preventDefault(),document.querySelector(`.composer input[type=text]`)?.focus();else if(t.key===`ArrowDown`||t.key===`ArrowUp`){let r=e();if(r.length===0)return;t.preventDefault();let i=r.findIndex(e=>e.id===n()),a=t.key===`ArrowDown`?Math.min(i+1,r.length-1):Math.max(i-1,0);a!==i&&V(r[a].id)}}}),C(()=>{N(),F().then(()=>{let t=ie()||localStorage.getItem(`teapot.session`)||``,n=e().find(e=>e.id===t)??e()[0];n&&V(n.id,!1)}),I(),re(),setInterval(I,3e4)});let oe=async e=>{if(e.preventDefault(),!n()||!u().trim())return;let t=u();d(``),await $(`/api/agents/${n()}/prompt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t,start:f()})})},se=e=>()=>n()&&$(`/api/agents/${n()}${e}`,{method:`POST`}).then(F),Y=async e=>{e.preventDefault();let t=document.getElementById(`goal-input`);!n()||!t.value.trim()||(await $(`/api/agents/${n()}/goal`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t.value})}),t.value=``,F())};return[(()=>{var i=Re(),a=i.firstChild,s=a.firstChild,l=s.firstChild.nextSibling,m=l.nextSibling.firstChild,h=m.nextSibling,g=s.nextSibling,v=g.nextSibling,b=a.nextSibling,x=b.nextSibling;return m.$$click=()=>{N(),_(!0)},h.$$click=()=>{N(),T(!0)},Z(g,G(K,{get each(){return e()},children:e=>(()=>{var t=Be(),r=t.firstChild,i=r.nextSibling;return t.$$click=()=>V(e.id),Z(i,()=>e.id),Z(t,G(q,{get when(){return e.goal.status===`done`},get children(){return ze()}}),null),y(i=>{var a=`agent-item`+(e.id===n()?` sel`:``),o=`dot ${e.status}`;return a!==i.e&&X(t,i.e=a),o!==i.t&&X(r,i.t=o),i},{e:void 0,t:void 0}),t})()})),Z(v,G(q,{get when(){return c()},get children(){return[`master rss `,J(()=>c().rssMb),`MB · heap `,J(()=>c().heapUsedMb),`MB`,ye(),`load1 `,J(()=>c().loadavg1),` · up `,J(()=>Math.floor(c().uptimeSec/60)),`m`]}})),Z(b,G(q,{get when(){return P()},get fallback(){return Ve()},get children(){return[(()=>{var e=xe(),t=e.firstChild.nextSibling,n=t.nextSibling,r=n.nextSibling,i=r.firstChild,a=i.nextSibling,o=a.nextSibling.nextSibling,s=o.nextSibling.nextSibling;s.nextSibling;var c=r.nextSibling,l=c.firstChild;return Z(t,()=>P().id),Z(n,()=>P().status),Z(r,()=>P().model,i),Z(r,()=>P().session,a),Z(r,()=>P().branch,o),Z(r,()=>P().stats.turns,s),Z(r,()=>P().stats.toolCalls,null),Z(c,G(q,{get when(){return P().statusReason},get children(){var e=be();return y(()=>le(e,`title`,P().statusReason)),e}}),l),l.$$click=()=>ee(!E()),y(()=>X(n,`badge ${P().status}`)),e})(),(()=>{var e=Te();return e.addEventListener(`scroll`,()=>{let e=z();e&&O()&&k(0),te(e)}),Z(e,G(q,{get when(){return M().length>0},get fallback(){return He()},get children(){return[G(K,{get each(){return M()},children:(e,t)=>G(bt,{e,get prev(){return M()[t()-1]}})}),G(q,{get when(){return A()},get children(){var e=we(),t=e.firstChild.nextSibling;return t.firstChild,Z(t,G(q,{get when(){return A().reasoning},get children(){var e=Se(),t=e.firstChild.nextSibling;return Z(t,()=>A().reasoning),e}}),null),Z(t,G(q,{get when(){return A().text},get fallback(){return Ue()},get children(){var e=Ce(),t=e.firstChild;return Z(e,()=>A().text,t),e}}),null),e}})]}})),e})(),G(q,{get when(){return!D()||O()>0},get children(){var e=Ee();return e.firstChild,e.$$click=()=>B(!0),Z(e,(()=>{var e=J(()=>O()>0);return()=>e()?`${O()} new message${O()>1?`s`:``}`:`jump to present`})(),null),e}}),(()=>{var e=De(),t=e.firstChild,n=t.firstChild,r=n.nextSibling.firstChild;return t.addEventListener(`submit`,oe),n.$$input=e=>d(e.currentTarget.value),r.addEventListener(`change`,e=>p(e.currentTarget.checked)),y(()=>le(n,`placeholder`,`message #${P().id}`)),y(()=>n.value=u()),y(()=>r.checked=f()),e})()]}})),Z(x,G(q,{get when(){return P()},get children(){return[Oe(),(()=>{var n=ke(),i=n.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling;return ue(i,`click`,se(`/start`),!0),ue(a,`click`,se(`/stop`),!0),o.$$click=()=>$(`/api/agents/${P().id}/fork`,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`}).then(()=>V(P().id)),s.$$click=async()=>{confirm(`remove agent ${P().id}? (log is kept)`)&&(await $(`/api/agents/${P().id}`,{method:`DELETE`}),r(null),t(e().filter(e=>e.id!==P().id)))},n})(),(()=>{var e=Ae(),t=e.firstChild.nextSibling;return Z(t,()=>P().goal.status),y(()=>X(t,`badge ${P().goal.status===`done`?`done`:``}`)),e})(),(()=>{var e=je();return e.addEventListener(`submit`,Y),e})(),(()=>{var e=Me();return Z(e,()=>P().goal.text||`no goal set`),e})(),Ne(),G(q,{get when(){return P().latestProgress},get fallback(){return We()},get children(){var e=Pe(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling.nextSibling;return Z(e,()=>P().latestProgress.doing,t),Z(e,()=>P().latestProgress.recent??``,n),Z(r,()=>P().latestProgress.ts),e}}),Fe(),G(K,{get each(){return o()},children:e=>(()=>{var t=Ge(),n=t.firstChild;return Z(t,()=>e.branch,n),Z(n,()=>e.events),y(()=>X(t,`branch-row`+(e.branch===P().branch?` cur`:``))),t})()}),Ie(),(()=>{var e=Le(),t=e.firstChild.nextSibling,n=t.nextSibling.nextSibling,r=n.nextSibling.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,Z(e,()=>P().stats.turns,t),Z(e,()=>P().stats.toolCalls,n),Z(e,()=>P().stats.inputTokens,r),Z(e,()=>P().stats.outputTokens,i),Z(e,()=>P().workspace,null),e})()]}})),y(e=>{var t=`conn`+(ne()?` ok`:``),n=ne()?`live (websocket)`:`reconnecting…`,r=`rightbar`+(E()?` open`:``);return t!==e.e&&X(l,e.e=t),n!==e.t&&le(l,`title`,e.t=n),r!==e.a&&X(x,e.a=r),e},{e:void 0,t:void 0,a:void 0}),i})(),G(q,{get when(){return g()},get children(){return G(Et,{get providers(){return Object.keys(m().providers??{})},onClose:()=>_(!1),onCreated:e=>{_(!1),F(),V(e)}})}}),G(q,{get when(){return S()},get children(){return G(Dt,{get cfg(){return m()},onClose:()=>T(!1),onSaved:N})}})]}function bt(e){let t=e.e,n=ht(t),r=e.prev&&e.prev.type===t.type&&t.session===e.prev.session&&t.branch===e.prev.branch;return t.type===`state`?t.data.from===t.data.to?null:(()=>{var e=Ke(),n=e.firstChild;return Z(e,()=>t.data.from,n),Z(e,()=>t.data.to,null),Z(e,(()=>{var e=J(()=>!!t.data.reason);return()=>e()?` — ${t.data.reason}`:``})(),null),y(()=>X(e,`divider-msg`+(t.data.to===`error`?` err`:``))),e})():(()=>{var e=Ye(),i=e.firstChild;return X(e,`msg`+(r?` grouped`:``)),Z(e,G(q,{when:!r,get fallback(){return Xe()},get children(){var e=qe();return Z(e,()=>n.icon),y(t=>{var r=n.color+`33`,i=`1px solid ${n.color}66`;return r!==t.e&&de(e,`background`,t.e=r),i!==t.t&&de(e,`border`,t.t=i),t},{e:void 0,t:void 0}),e}}),i),Z(i,G(q,{when:!r,get children(){var e=Je(),r=e.firstChild,i=r.nextSibling,a=i.nextSibling;return Z(r,()=>n.name),Z(i,()=>vt(t.ts)),Z(a,()=>t.branch),y(e=>de(r,`color`,n.color)),e}}),null),Z(i,G(xt,{e:t}),null),e})()}function xt(e){let t=e.e;switch(t.type){case`prompt`:return(()=>{var e=Ze();return y(()=>e.innerHTML=_e(String(t.data.text??``))),e})();case`message`:return[G(q,{get when(){return J(()=>typeof t.data.reasoning==`string`)()&&t.data.reasoning.trim()},get children(){var e=Se(),n=e.firstChild.nextSibling;return Z(n,()=>String(t.data.reasoning)),e}}),(()=>{var e=Ze();return y(()=>e.innerHTML=_e(String(t.data.content??``))),e})(),G(q,{get when(){return t.data.final},get children(){var e=Qe(),n=e.firstChild;return Z(e,G(wt,{get text(){return String(t.data.content??``)}}),n),e}})];case`tool_call`:{let e=JSON.stringify(t.data.args,null,1),n=Ct(JSON.stringify(t.data.args??{}),110);return(()=>{var r=$e(),i=r.firstChild,a=i.firstChild;a.firstChild;var o=a.nextSibling.nextSibling,s=i.nextSibling;return Z(a,()=>String(t.data.name),null),Z(o,n),Z(s,e),r})()}case`tool_result`:{let e=String(t.data.result);return(()=>{var n=et(),r=n.firstChild,i=r.firstChild,a=r.nextSibling,o=a.nextSibling,s=o.firstChild;return Z(i,()=>Ct(e,120)),Z(r,G(wt,{text:e}),null),Z(a,()=>St(e,4e3)),Z(o,()=>t.data.durationMs,s),Z(o,()=>t.data.ok?``:` · FAILED`,null),y(()=>X(n,`embed`+(t.data.ok?``:` fail`))),n})()}case`progress`:return(()=>{var e=it(),n=e.firstChild;return n.firstChild,Z(n,()=>String(t.data.doing??``),null),Z(e,G(q,{get when(){return t.data.recent},get children(){var e=tt();return Z(e,()=>String(t.data.recent)),e}}),null),Z(e,G(q,{get when(){return t.data.problems},get children(){var e=nt();return e.firstChild,Z(e,()=>String(t.data.problems),null),e}}),null),Z(e,G(q,{get when(){return t.data.next},get children(){var e=rt();return e.firstChild,Z(e,()=>String(t.data.next),null),e}}),null),e})();case`error`:return(()=>{var e=at(),n=e.firstChild;return n.firstChild,Z(n,()=>String(t.data.message??``),null),e})();default:return(()=>{var e=ot();return Z(e,()=>St(JSON.stringify(t.data),200)),e})()}}function St(e,t){return e.length>t?e.slice(0,t)+` …`:e}function Ct(e,t){return St(e.replace(/\s+/g,` `).trim(),t)}function wt(e){let[t,n]=v(!1);return(()=>{var r=st();return r.$$click=t=>{t.stopPropagation(),navigator.clipboard.writeText(e.text).then(()=>{n(!0),setTimeout(()=>n(!1),900)})},Z(r,()=>t()?`✓`:`⧉`),r})()}function Tt(e){return(()=>{var t=ct(),n=t.firstChild,r=n.firstChild.firstChild,i=r.nextSibling;return t.$$click=t=>t.target===t.currentTarget&&e.onClose(),Z(r,()=>e.title),ue(i,`click`,e.onClose,!0),Z(n,()=>e.children,null),t})()}function Et(e){let[t,n]=v(`~`),[r,i]=v([]),[a,o]=v(``),[s,c]=v(e.providers[0]??``),[l,u]=v(``),[d,f]=v(``);async function p(e){let t=await $(`/api/fs${e?`?path=${encodeURIComponent(e)}`:``}`);n(t.path),i(t.entries)}C(()=>p(t()));let m=async n=>{n.preventDefault(),f(``);try{let n=await $(`/api/agents`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({workspace:t(),id:a(),provider:s()||void 0,model:l()||void 0})});e.onCreated(n.agent.id)}catch(e){f(String(e.message))}};return G(Tt,{title:`new agent`,get onClose(){return e.onClose},get children(){var i=ut(),f=i.firstChild,h=f.firstChild.nextSibling.firstChild,g=h.nextSibling,_=g.nextSibling,v=f.nextSibling,b=v.nextSibling,x=b.firstChild,S=x.firstChild.nextSibling,C=x.nextSibling,w=C.firstChild.nextSibling,T=C.nextSibling.firstChild.nextSibling,E=b.nextSibling;return i.addEventListener(`submit`,m),h.$$input=e=>n(e.currentTarget.value),g.$$click=()=>p(t()),_.$$click=()=>p(`..`),Z(v,G(K,{get each(){return r()},children:e=>(()=>{var n=dt();return n.firstChild,n.$$click=()=>p(`${t()}/${e}`.replace(/\/+/g,`/`)),Z(n,e,null),n})()})),S.$$input=e=>o(e.currentTarget.value),w.addEventListener(`change`,e=>c(e.currentTarget.value)),Z(w,G(K,{get each(){return e.providers},children:e=>(()=>{var t=ft();return Z(t,e),t})()})),T.$$input=e=>u(e.currentTarget.value),Z(i,G(q,{get when(){return d()},get children(){var e=lt();return Z(e,d),e}}),E),y(()=>h.value=t()),y(()=>S.value=a()),y(()=>w.value=s()),y(()=>T.value=l()),i}})}function Dt(e){let[t,n]=v(JSON.stringify(Object.fromEntries(Object.entries(e.cfg.providers??{}).map(([e,t])=>[e,{baseUrl:t.baseUrl,apiKey:t.apiKey??``,model:t.model??``}])),null,2)),[r,i]=v(e.cfg.defaultProvider??Object.keys(e.cfg.providers??{})[0]??``),[a,o]=v(Math.round((e.cfg.progressIntervalMs??6e5)/6e4)),[s,c]=v(JSON.stringify(e.cfg.tasks??[],null,2)),[l,u]=v(``),d=async n=>{n.preventDefault(),u(``);let i,o;try{i=JSON.parse(t())}catch{return u(`providers: invalid JSON`)}try{o=JSON.parse(s())}catch{return u(`tasks: invalid JSON`)}try{await $(`/api/config`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({providers:i,defaultProvider:r(),progressIntervalMs:Math.max(1,a())*6e4,tasks:o})}),e.onSaved(),e.onClose()}catch(e){u(String(e.message))}};return G(Tt,{title:`settings`,get onClose(){return e.onClose},get children(){var u=pt(),f=u.firstChild,p=f.firstChild.nextSibling,m=p.nextSibling.nextSibling,h=f.nextSibling,g=h.firstChild,_=g.firstChild.nextSibling,v=g.nextSibling.firstChild.nextSibling,b=h.nextSibling,x=b.firstChild.nextSibling,S=b.nextSibling;return u.addEventListener(`submit`,d),Z(f,()=>e.cfg.configPath,p),m.$$input=e=>n(e.currentTarget.value),_.$$input=e=>i(e.currentTarget.value),v.$$input=e=>o(Number(e.currentTarget.value)),x.$$input=e=>c(e.currentTarget.value),Z(u,G(q,{get when(){return l()},get children(){var e=lt();return Z(e,l),e}}),S),y(()=>m.value=t()),y(()=>_.value=r()),y(()=>v.value=a()),y(()=>x.value=s()),u}})}ce([`click`,`input`]),se(()=>G(yt,{}),document.getElementById(`root`));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--bg-darkest:#1a1c22;--bg-dark:#232630;--bg-mid:#2b2e39;--bg-light:#343845;--fg:#dcdee4;--dim:#9298a5;--line:#1d2027;--acc:#5865f2;--ok:#3ba55d;--warn:#faa81a;--err:#ed4245;--tool:#3ba0c9;font-family:gg sans,ui-sans-serif,system-ui,-apple-system,Segoe UI,sans-serif}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}body{background:var(--bg-dark);color:var(--fg);font-size:15px}.layout{grid-template-columns:250px 1fr 300px;height:100dvh;display:grid;overflow:hidden}@media (width<=1100px){.layout{grid-template-columns:220px 1fr}.rightbar{z-index:5;width:min(320px,88vw);transition:transform .18s;position:fixed;top:0;bottom:0;right:0;transform:translate(100%);box-shadow:-8px 0 24px #0007}.rightbar.open{transform:none}}.sidebar{background:var(--bg-darkest);flex-direction:column;padding:10px 8px;display:flex;overflow-y:auto}.sidebar h1{color:var(--fg);flex-shrink:0;margin:0;padding:4px 8px 10px;font-size:14px}.agent-list{flex:1;min-height:0;overflow-y:auto}.agent-item{cursor:pointer;color:var(--dim);border-radius:6px;align-items:center;gap:8px;margin-bottom:2px;padding:7px 10px;display:flex}.agent-item:hover{background:var(--bg-mid)}.agent-item.sel{background:var(--bg-mid);color:var(--fg)}.dot{border-radius:50%;flex-shrink:0;width:9px;height:9px}.dot.running{background:var(--ok);box-shadow:0 0 6px var(--ok)}.dot.idle{background:var(--warn)}.dot.stopped{background:var(--dim)}.dot.error{background:var(--err);box-shadow:0 0 6px var(--err)}.sidebar .metrics{color:var(--dim);border-top:1px solid var(--line);margin-top:12px;padding:8px 10px;font-size:11px;line-height:1.7}.channel{flex-direction:column;min-width:0;min-height:0;display:flex;position:relative;overflow:hidden}.chan-head{border-bottom:2px solid var(--line);background:var(--bg-dark);flex-shrink:0;align-items:center;gap:10px;padding:10px 16px;display:flex}.chan-head .hash{color:var(--dim);font-size:20px}.chan-head .title{font-weight:700}.chan-head .sub{color:var(--dim);text-overflow:ellipsis;white-space:nowrap;margin-left:8px;font-size:12px;overflow:hidden}.badge{background:var(--bg-light);vertical-align:middle;border-radius:10px;padding:1px 8px;font-size:11px}.badge.running{color:var(--ok)}.badge.error{color:var(--err)}.badge.idle{color:var(--warn)}.badge.done{color:var(--acc)}.feed{overscroll-behavior:contain;flex:1;min-height:0;padding:14px 0 8px;overflow-y:auto}.msg{gap:14px;padding:3px 18px;display:flex}.msg:hover{background:#ffffff08}.msg.grouped{padding-top:0}.avatar{border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:38px;height:38px;margin-top:2px;font-size:17px;display:flex}.msg-body{flex:1;min-width:0}.msg-head{align-items:baseline;gap:8px;display:flex}.author{font-size:14.5px;font-weight:600}.ts{color:var(--dim);font-size:11px}.content{white-space:pre-wrap;word-break:break-word;line-height:1.45}.content p{margin:2px 0}.content pre{background:var(--bg-darkest);border-radius:6px;padding:8px;overflow-x:auto}.content code{background:var(--bg-darkest);border-radius:4px;padding:1px 4px;font-size:13px}.content h1,.content h2,.content h3,.content h4{margin:8px 0 2px;font-size:15px}.embed{border-left:3px solid var(--tool);background:var(--bg-darkest);border-radius:4px;margin-top:3px;padding:6px 10px;font-size:13.5px}.embed.fail{border-color:var(--err)}.embed summary{cursor:pointer;-webkit-user-select:none;user-select:none;list-style-position:outside}.embed summary::marker{color:var(--dim)}.embed[open] summary{margin-bottom:4px}.embed .mono{white-space:pre-wrap;word-break:break-word;max-height:340px;font-family:ui-monospace,Menlo,monospace;font-size:12.5px;overflow-y:auto}.embed .meta{color:var(--dim);margin-top:3px;font-size:11px}.reasoning{border-left:3px dashed var(--bg-light);color:var(--dim);background:#ffffff05;border-radius:4px;margin:2px 0;padding:2px 10px;font-size:12.5px}.reasoning summary{cursor:pointer;-webkit-user-select:none;user-select:none;opacity:.75}.reasoning summary:hover{opacity:1;color:var(--fg)}.reasoning[open] summary{margin-bottom:4px}.reasoning .mono{white-space:pre-wrap;word-break:break-word;max-height:260px;overflow-y:auto}.jump{background:var(--acc);color:#fff;cursor:pointer;z-index:2;border:none;border-radius:999px;padding:6px 14px;font-size:12.5px;font-weight:600;position:absolute;bottom:86px;left:50%;transform:translate(-50%);box-shadow:0 4px 14px #0008}.divider-msg{color:var(--dim);align-items:center;gap:10px;padding:4px 18px;font-size:11.5px;display:flex}.divider-msg:before,.divider-msg:after{content:"";background:var(--line);flex:1;height:1px}.divider-msg.err{color:var(--err)}.day-divider{align-items:center;gap:10px;padding:14px 18px 6px;display:flex}.day-divider:before,.day-divider:after{content:"";background:var(--bg-light);flex:1;height:1px}.day-divider span{color:var(--dim);font-size:11px}.composer{padding:0 16px 18px}.composer form{background:var(--bg-light);border-radius:10px;align-items:center;gap:8px;padding:10px 12px;display:flex}.composer input[type=text]{color:var(--fg);font:inherit;background:0 0;border:none;outline:none;flex:1}.composer button{background:var(--acc);color:#fff;cursor:pointer;border:none;border-radius:8px;padding:7px 14px;font-weight:600}.composer button:hover{opacity:.9}.composer label{color:var(--dim);white-space:nowrap;align-items:center;gap:4px;font-size:12px;display:flex}.hint{color:var(--dim);margin-top:5px;font-size:11px}.rightbar{background:var(--bg-dark);border-left:2px solid var(--line);flex-direction:column;min-height:0;padding:14px;font-size:13px;display:flex;overflow-y:auto}.rightbar h3{text-transform:uppercase;letter-spacing:.04em;color:var(--dim);margin:14px 0 6px;font-size:11px}.rightbar h3:first-child{margin-top:0}.card{background:var(--bg-darkest);white-space:pre-wrap;word-break:break-word;border-radius:8px;max-height:200px;padding:10px;overflow-y:auto}.muted{color:var(--dim)}.branch-row{color:var(--dim);cursor:pointer;justify-content:space-between;padding:3px 0;font-size:12px;display:flex}.branch-row:hover,.branch-row.cur{color:var(--fg)}.btnrow{gap:6px;margin:8px 0;display:flex}.btnrow button{background:var(--bg-light);color:var(--fg);cursor:pointer;border:none;border-radius:6px;padding:6px 10px;font-size:13px}.btnrow button:hover{filter:brightness(1.2)}.iconbtn{background:var(--bg-light);color:var(--fg);cursor:pointer;border:none;border-radius:6px;width:26px;height:24px;font-size:13px}.iconbtn:hover{filter:brightness(1.3)}.overlay{z-index:10;background:#0009;place-items:center;display:grid;position:fixed;inset:0}.modal{background:var(--bg-mid);border-radius:10px;width:min(620px,92vw);max-height:88vh;padding:16px 18px;overflow-y:auto}.modal-head{justify-content:space-between;align-items:center;margin-bottom:12px;font-size:16px;display:flex}.modal label{color:var(--dim);flex-direction:column;gap:4px;font-size:12.5px;display:flex}.modal input[type=text],.modal input[type=number],.modal select,.modal textarea{background:var(--bg-darkest);color:var(--fg);font:inherit;border:none;border-radius:6px;outline:none;padding:7px 9px}.modal textarea{resize:vertical}.w100{width:100%}.mono{font-family:ui-monospace,Menlo,monospace;font-size:13px}.dirlist{background:var(--bg-darkest);border-radius:6px;max-height:160px;padding:4px;overflow-y:auto}.direntry{cursor:pointer;border-radius:4px;padding:4px 8px;font-size:14px}.direntry:hover{background:var(--bg-light)}
|
|
1
|
+
:root{--bg-darkest:#1a1c22;--bg-dark:#232630;--bg-mid:#2b2e39;--bg-light:#343845;--fg:#dcdee4;--dim:#9298a5;--line:#1d2027;--acc:#5865f2;--ok:#3ba55d;--warn:#faa81a;--err:#ed4245;--tool:#3ba0c9;font-family:gg sans,ui-sans-serif,system-ui,-apple-system,Segoe UI,sans-serif}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}body{background:var(--bg-dark);color:var(--fg);font-size:15px}.layout{grid-template-columns:250px 1fr 300px;height:100dvh;display:grid;overflow:hidden}@media (width<=1100px){.layout{grid-template-columns:220px 1fr}.rightbar{z-index:5;width:min(320px,88vw);transition:transform .18s;position:fixed;top:0;bottom:0;right:0;transform:translate(100%);box-shadow:-8px 0 24px #0007}.rightbar.open{transform:none}}.sidebar{background:var(--bg-darkest);flex-direction:column;padding:10px 8px;display:flex;overflow-y:auto}.sidebar h1{color:var(--fg);flex-shrink:0;margin:0;padding:4px 8px 10px;font-size:14px}.agent-list{flex:1;min-height:0;overflow-y:auto}.agent-item{cursor:pointer;color:var(--dim);border-radius:6px;align-items:center;gap:8px;margin-bottom:2px;padding:7px 10px;display:flex}.agent-item:hover{background:var(--bg-mid)}.agent-item.sel{background:var(--bg-mid);color:var(--fg)}.dot{border-radius:50%;flex-shrink:0;width:9px;height:9px}.dot.running{background:var(--ok);box-shadow:0 0 6px var(--ok)}.dot.idle{background:var(--warn)}.dot.stopped{background:var(--dim)}.dot.error{background:var(--err);box-shadow:0 0 6px var(--err)}.sidebar .metrics{color:var(--dim);border-top:1px solid var(--line);margin-top:12px;padding:8px 10px;font-size:11px;line-height:1.7}.channel{flex-direction:column;min-width:0;min-height:0;display:flex;position:relative;overflow:hidden}.chan-head{border-bottom:2px solid var(--line);background:var(--bg-dark);flex-shrink:0;align-items:center;gap:10px;padding:10px 16px;display:flex}.chan-head .hash{color:var(--dim);font-size:20px}.chan-head .title{font-weight:700}.chan-head .sub{color:var(--dim);text-overflow:ellipsis;white-space:nowrap;margin-left:8px;font-size:12px;overflow:hidden}.badge{background:var(--bg-light);vertical-align:middle;border-radius:10px;padding:1px 8px;font-size:11px}.badge.running{color:var(--ok)}.badge.error{color:var(--err)}.badge.idle{color:var(--warn)}.badge.done{color:var(--acc)}.feed{overscroll-behavior:contain;flex:1;min-height:0;padding:14px 0 8px;overflow-y:auto}.msg{gap:14px;padding:3px 18px;display:flex}.msg:hover{background:#ffffff08}.msg.grouped{padding-top:0}.avatar{border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:38px;height:38px;margin-top:2px;font-size:17px;display:flex}.msg-body{flex:1;min-width:0}.msg-head{align-items:baseline;gap:8px;display:flex}.author{font-size:14.5px;font-weight:600}.ts{color:var(--dim);font-size:11px}.content{white-space:pre-wrap;word-break:break-word;line-height:1.45}.content p{margin:2px 0}.content pre{background:var(--bg-darkest);border-radius:6px;padding:8px;overflow-x:auto}.content code{background:var(--bg-darkest);border-radius:4px;padding:1px 4px;font-size:13px}.content h1,.content h2,.content h3,.content h4{margin:8px 0 2px;font-size:15px}.embed{border-left:3px solid var(--tool);background:var(--bg-darkest);border-radius:4px;margin-top:3px;padding:6px 10px;font-size:13.5px}.embed.fail{border-color:var(--err)}.embed summary{cursor:pointer;-webkit-user-select:none;user-select:none;list-style-position:outside}.embed summary::marker{color:var(--dim)}.embed[open] summary{margin-bottom:4px}.embed .mono{white-space:pre-wrap;word-break:break-word;max-height:340px;font-family:ui-monospace,Menlo,monospace;font-size:12.5px;overflow-y:auto}.embed .meta{color:var(--dim);margin-top:3px;font-size:11px}.reasoning{border-left:3px dashed var(--bg-light);color:var(--dim);background:#ffffff05;border-radius:4px;margin:2px 0;padding:2px 10px;font-size:12.5px}.reasoning summary{cursor:pointer;-webkit-user-select:none;user-select:none;opacity:.75}.reasoning summary:hover{opacity:1;color:var(--fg)}.reasoning[open] summary{margin-bottom:4px}.reasoning .mono{white-space:pre-wrap;word-break:break-word;max-height:260px;overflow-y:auto}.msg.live .avatar{animation:1.6s ease-in-out infinite pulse}.cursor{color:var(--acc);animation:1s step-end infinite blink}@keyframes blink{50%{opacity:0}}@keyframes pulse{50%{opacity:.55}}.conn{background:var(--err);vertical-align:middle;width:8px;height:8px;box-shadow:0 0 6px var(--err);border-radius:50%;margin-left:8px;display:inline-block}.conn.ok{background:var(--ok);box-shadow:0 0 6px var(--ok)}.copybtn{border:1px solid var(--bg-light);color:var(--dim);cursor:pointer;background:0 0;border-radius:4px;flex-shrink:0;padding:0 5px;font-size:11px;line-height:16px}.copybtn:hover{color:var(--fg);filter:brightness(1.3)}.embed summary{align-items:center;gap:6px;display:flex}.msgfoot{color:var(--dim);align-items:center;gap:6px;margin-top:4px;font-size:11px;display:flex}.jump{background:var(--acc);color:#fff;cursor:pointer;z-index:2;border:none;border-radius:999px;padding:6px 14px;font-size:12.5px;font-weight:600;position:absolute;bottom:86px;left:50%;transform:translate(-50%);box-shadow:0 4px 14px #0008}.divider-msg{color:var(--dim);align-items:center;gap:10px;padding:4px 18px;font-size:11.5px;display:flex}.divider-msg:before,.divider-msg:after{content:"";background:var(--line);flex:1;height:1px}.divider-msg.err{color:var(--err)}.day-divider{align-items:center;gap:10px;padding:14px 18px 6px;display:flex}.day-divider:before,.day-divider:after{content:"";background:var(--bg-light);flex:1;height:1px}.day-divider span{color:var(--dim);font-size:11px}.composer{padding:0 16px 18px}.composer form{background:var(--bg-light);border-radius:10px;align-items:center;gap:8px;padding:10px 12px;display:flex}.composer input[type=text]{color:var(--fg);font:inherit;background:0 0;border:none;outline:none;flex:1}.composer button{background:var(--acc);color:#fff;cursor:pointer;border:none;border-radius:8px;padding:7px 14px;font-weight:600}.composer button:hover{opacity:.9}.composer label{color:var(--dim);white-space:nowrap;align-items:center;gap:4px;font-size:12px;display:flex}.hint{color:var(--dim);margin-top:5px;font-size:11px}.rightbar{background:var(--bg-dark);border-left:2px solid var(--line);flex-direction:column;min-height:0;padding:14px;font-size:13px;display:flex;overflow-y:auto}.rightbar h3{text-transform:uppercase;letter-spacing:.04em;color:var(--dim);margin:14px 0 6px;font-size:11px}.rightbar h3:first-child{margin-top:0}.card{background:var(--bg-darkest);white-space:pre-wrap;word-break:break-word;border-radius:8px;max-height:200px;padding:10px;overflow-y:auto}.muted{color:var(--dim)}.branch-row{color:var(--dim);cursor:pointer;justify-content:space-between;padding:3px 0;font-size:12px;display:flex}.branch-row:hover,.branch-row.cur{color:var(--fg)}.btnrow{gap:6px;margin:8px 0;display:flex}.btnrow button{background:var(--bg-light);color:var(--fg);cursor:pointer;border:none;border-radius:6px;padding:6px 10px;font-size:13px}.btnrow button:hover{filter:brightness(1.2)}.iconbtn{background:var(--bg-light);color:var(--fg);cursor:pointer;border:none;border-radius:6px;width:26px;height:24px;font-size:13px}.iconbtn:hover{filter:brightness(1.3)}.overlay{z-index:10;background:#0009;place-items:center;display:grid;position:fixed;inset:0}.modal{background:var(--bg-mid);border-radius:10px;width:min(620px,92vw);max-height:88vh;padding:16px 18px;overflow-y:auto}.modal-head{justify-content:space-between;align-items:center;margin-bottom:12px;font-size:16px;display:flex}.modal label{color:var(--dim);flex-direction:column;gap:4px;font-size:12.5px;display:flex}.modal input[type=text],.modal input[type=number],.modal select,.modal textarea{background:var(--bg-darkest);color:var(--fg);font:inherit;border:none;border-radius:6px;outline:none;padding:7px 9px}.modal textarea{resize:vertical}.w100{width:100%}.mono{font-family:ui-monospace,Menlo,monospace;font-size:13px}.dirlist{background:var(--bg-darkest);border-radius:6px;max-height:160px;padding:4px;overflow-y:auto}.direntry{cursor:pointer;border-radius:4px;padding:4px 8px;font-size:14px}.direntry:hover{background:var(--bg-light)}
|
package/public/index.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
6
|
<title>teapot</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-6mOD4zV4.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DZvHiLwS.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="root"></div>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return t(this.context.count)},getNextContextId(){return t(this.context.count++)}};function t(t){let n=String(t),r=n.length-1;return e.context.id+(r?String.fromCharCode(96+r):``)+n}function n(t){e.context=t}var r=(e,t)=>e===t,i=Symbol(`solid-track`),a={equals:r},o=null,s=I,c=1,l=2,u={owned:null,cleanups:null,context:null,owner:null},d=null,f=null,p=null,m=null,h=null,g=0;function _(e,t){let n=p,r=d,i=e.length===0,a=t===void 0?r:t,o=i?u:{owned:null,cleanups:null,context:a?a.context:null,owner:a},s=i?e:()=>e(()=>S(()=>B(o)));d=o,p=null;try{return P(s,!0)}finally{p=n,d=r}}function v(e,t){t=t?Object.assign({},a,t):a;let n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0};return[O.bind(n),e=>(typeof e==`function`&&(e=f&&f.running&&f.sources.has(n)?e(n.tValue):e(n.value)),k(n,e))]}function y(e,t,n){A(M(e,t,!1,c))}function b(e,t,n){s=L;let r=M(e,t,!1,c),i=D&&ee(D);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),h?h.push(r):A(r)}function x(e,t,n){n=n?Object.assign({},a,n):a;let r=M(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,A(r),O.bind(r)}function S(e){if(p===null)return e();let t=p;p=null;try{return e()}finally{p=t}}function C(e){b(()=>S(e))}function w(e){return d===null||(d.cleanups===null?d.cleanups=[e]:d.cleanups.push(e)),e}var[T,E]=v(!1);function ee(e){let t;return d&&d.context&&(t=d.context[e.id])!==void 0?t:e.defaultValue}var D;function O(){let e=f&&f.running;if(this.sources&&(e?this.tState:this.state)){if((e?this.tState:this.state)===c)A(this);else{let e=m;m=null,P(()=>R(this),!1),m=e}}if(p){let e=this.observers;if(!e||e[e.length-1]!==p){let t=e?e.length:0;p.sources?(p.sources.push(this),p.sourceSlots.push(t)):(p.sources=[this],p.sourceSlots=[t]),e?(e.push(p),this.observerSlots.push(p.sources.length-1)):(this.observers=[p],this.observerSlots=[p.sources.length-1])}}return e&&f.sources.has(this)?this.tValue:this.value}function k(e,t,n){let r=f&&f.running&&f.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(r,t)){if(f){let r=f.running;(r||!n&&f.sources.has(e))&&(f.sources.add(e),e.tValue=t),r||(e.value=t)}else e.value=t;e.observers&&e.observers.length&&P(()=>{for(let t=0;t<e.observers.length;t+=1){let n=e.observers[t],r=f&&f.running;r&&f.disposed.has(n)||((r?!n.tState:!n.state)&&(n.pure?m.push(n):h.push(n),n.observers&&z(n)),r?n.tState=c:n.state=c)}if(m.length>1e6)throw m=[],Error()},!1)}return t}function A(e){if(!e.fn)return;B(e);let t=g;j(e,f&&f.running&&f.sources.has(e)?e.tValue:e.value,t),f&&!f.running&&f.sources.has(e)&&queueMicrotask(()=>{P(()=>{f&&(f.running=!0),p=d=e,j(e,e.tValue,t),p=d=null},!1)})}function j(e,t,n){let r,i=d,a=p;p=d=e;try{r=e.fn(t)}catch(t){return e.pure&&(f&&f.running?(e.tState=c,e.tOwned&&e.tOwned.forEach(B),e.tOwned=void 0):(e.state=c,e.owned&&e.owned.forEach(B),e.owned=null)),e.updatedAt=n+1,re(t)}finally{p=a,d=i}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&`observers`in e?k(e,r,!0):f&&f.running&&e.pure?(f.sources.has(e)||(e.value=r),f.sources.add(e),e.tValue=r):e.value=r,e.updatedAt=n)}function M(e,t,n,r=c,i){let a={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:d,context:d?d.context:null,pure:n};return f&&f.running&&(a.state=0,a.tState=r),d===null||d!==u&&(f&&f.running&&d.pure?d.tOwned?d.tOwned.push(a):d.tOwned=[a]:d.owned?d.owned.push(a):d.owned=[a]),a}function N(e){let t=f&&f.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===l)return R(e);if(e.suspense&&S(e.suspense.inFallback))return e.suspense.effects.push(e);let n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<g);){if(t&&f.disposed.has(e))return;(t?e.tState:e.state)&&n.push(e)}for(let r=n.length-1;r>=0;r--){if(e=n[r],t){let t=e,i=n[r+1];for(;(t=t.owner)&&t!==i;)if(f.disposed.has(t))return}if((t?e.tState:e.state)===c)A(e);else if((t?e.tState:e.state)===l){let t=m;m=null,P(()=>R(e,n[0]),!1),m=t}}}function P(e,t){if(m)return e();let n=!1;t||(m=[]),h?n=!0:h=[],g++;try{let t=e();return F(n),t}catch(e){n||(h=null),m=null,re(e)}}function F(e){if(m&&=(I(m),null),e)return;let t;if(f){if(!f.promises.size&&!f.queue.size){let e=f.sources,n=f.disposed;h.push.apply(h,f.effects),t=f.resolve;for(let e of h)`tState`in e&&(e.state=e.tState),delete e.tState;f=null,P(()=>{for(let e of n)B(e);for(let t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)B(t.owned[e]);t.tOwned&&(t.owned=t.tOwned),delete t.tValue,delete t.tOwned,t.tState=0}E(!1)},!1)}else if(f.running){f.running=!1,f.effects.push.apply(f.effects,h),h=null,E(!0);return}}let n=h;h=null,n.length&&P(()=>s(n),!1),t&&t()}function I(e){for(let t=0;t<e.length;t++)N(e[t])}function L(t){let r,i=0;for(r=0;r<t.length;r++){let e=t[r];e.user?t[i++]=e:N(e)}if(e.context){if(e.count){e.effects||=[],e.effects.push(...t.slice(0,i));return}n()}for(e.effects&&(e.done||!e.count)&&(t=[...e.effects,...t],i+=e.effects.length,delete e.effects),r=0;r<i;r++)N(t[r])}function R(e,t){let n=f&&f.running;n?e.tState=0:e.state=0;for(let r=0;r<e.sources.length;r+=1){let i=e.sources[r];if(i.sources){let e=n?i.tState:i.state;e===c?i!==t&&(!i.updatedAt||i.updatedAt<g)&&N(i):e===l&&R(i,t)}}}function z(e){let t=f&&f.running;for(let n=0;n<e.observers.length;n+=1){let r=e.observers[n];(t?!r.tState:!r.state)&&(t?r.tState=l:r.state=l,r.pure?m.push(r):h.push(r),r.observers&&z(r))}}function B(e){let t;if(e.sources)for(;e.sources.length;){let t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){let e=r.pop(),i=t.observerSlots.pop();n<r.length&&(e.sourceSlots[i]=n,r[n]=e,t.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)B(e.tOwned[t]);delete e.tOwned}if(f&&f.running&&e.pure)V(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)B(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}f&&f.running?e.tState=0:e.state=0}function V(e,t){if(t||(e.tState=0,f.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)V(e.owned[t])}function te(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`,{cause:e})}function ne(e,t,n){try{for(let n of t)n(e)}catch(e){re(e,n&&n.owner||null)}}function re(e,t=d){let n=o&&t&&t.context&&t.context[o],r=te(e);if(!n)throw r;h?h.push({fn(){ne(r,n,t)},state:c}):ne(r,n,t)}var ie=Symbol(`fallback`);function ae(e){for(let t=0;t<e.length;t++)e[t]()}function oe(e,t,n={}){let r=[],a=[],o=[],s=0,c=t.length>1?[]:null;return w(()=>ae(o)),()=>{let l=e()||[],u=l.length,d,f;return l[i],S(()=>{let e,t,i,m,h,g,v,y,b;if(u===0)s!==0&&(ae(o),o=[],r=[],a=[],s=0,c&&=[]),n.fallback&&(r=[ie],a[0]=_(e=>(o[0]=e,n.fallback())),s=1);else if(s===0){for(a=Array(u),f=0;f<u;f++)r[f]=l[f],a[f]=_(p);s=u}else{for(i=Array(u),m=Array(u),c&&(h=Array(u)),g=0,v=Math.min(s,u);g<v&&r[g]===l[g];g++);for(v=s-1,y=u-1;v>=g&&y>=g&&r[v]===l[y];v--,y--)i[y]=a[v],m[y]=o[v],c&&(h[y]=c[v]);for(e=new Map,t=Array(y+1),f=y;f>=g;f--)b=l[f],d=e.get(b),t[f]=d===void 0?-1:d,e.set(b,f);for(d=g;d<=v;d++)b=r[d],f=e.get(b),f!==void 0&&f!==-1?(i[f]=a[d],m[f]=o[d],c&&(h[f]=c[d]),f=t[f],e.set(b,f)):o[d]();for(f=g;f<u;f++)f in i?(a[f]=i[f],o[f]=m[f],c&&(c[f]=h[f],c[f](f))):a[f]=_(p);a=a.slice(0,s=u),r=l.slice(0)}return a});function p(e){if(o[f]=e,c){let[e,n]=v(f);return c[f]=n,t(l[f],e)}return t(l[f])}}}function H(e,t){return S(()=>e(t||{}))}var se=e=>`Stale read from <${e}>.`;function U(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return x(oe(()=>e.each,e.children,t||void 0))}function W(e){let t=e.keyed,n=x(()=>e.when,void 0,void 0),r=t?n:x(n,void 0,{equals:(e,t)=>!e==!t});return x(()=>{let i=r();if(i){let a=e.children;return typeof a==`function`&&a.length>0?S(()=>a(t?i:()=>{if(!S(r))throw se(`Show`);return n()})):a}return e.fallback},void 0,void 0)}var G=e=>x(()=>e());function ce(e,t,n){let r=n.length,i=t.length,a=r,o=0,s=0,c=t[i-1].nextSibling,l=null;for(;o<i||s<a;){if(t[o]===n[s]){o++,s++;continue}for(;t[i-1]===n[a-1];)i--,a--;if(i===o){let t=a<r?s?n[s-1].nextSibling:n[a-s]:c;for(;s<a;)e.insertBefore(n[s++],t)}else if(a===s)for(;o<i;)(!l||!l.has(t[o]))&&t[o].remove(),o++;else if(t[o]===n[a-1]&&n[s]===t[i-1]){let r=t[--i].nextSibling;e.insertBefore(n[s++],t[o++].nextSibling),e.insertBefore(n[--a],r),t[i]=n[a]}else{if(!l){l=new Map;let e=s;for(;e<a;)l.set(n[e],e++)}let r=l.get(t[o]);if(r!=null){if(s<r&&r<a){let c=o,u=1,d;for(;++c<i&&c<a&&(d=l.get(t[c]))!=null&&d===r+u;)u++;if(u>r-s){let i=t[o];for(;s<r;)e.insertBefore(n[s++],i)}else e.replaceChild(n[s++],t[o++])}else o++}else t[o++].remove()}}}var le=`_$DX_DELEGATE`;function ue(e,t,n,r={}){let i;return _(r=>{i=r,t===document?e():X(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{i(),t.textContent=``}}function K(e,t,n,r){let i,a=()=>{let t=r?document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`template`):document.createElement(`template`);return t.innerHTML=e,n?t.content.firstChild.firstChild:r?t.firstChild:t.content.firstChild},o=t?()=>S(()=>document.importNode(i||=a(),!0)):()=>(i||=a()).cloneNode(!0);return o.cloneNode=o,o}function de(e,t=window.document){let n=t[le]||(t[le]=new Set);for(let r=0,i=e.length;r<i;r++){let i=e[r];n.has(i)||(n.add(i),t.addEventListener(i,me))}}function fe(e,t,n){pe(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function q(e,t){pe(e)||(t==null?e.removeAttribute(`class`):e.className=t)}function J(e,t,n,r){if(r)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){let r=n[0];e.addEventListener(t,n[0]=t=>r.call(e,n[1],t))}else e.addEventListener(t,n,typeof n!=`function`&&n)}function Y(e,t,n){n==null?e.style.removeProperty(t):e.style.setProperty(t,n)}function X(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!=`function`)return Z(e,t,r,n);y(r=>Z(e,t(),r,n),r)}function pe(t){return!!e.context&&!e.done&&(!t||t.isConnected)}function me(t){if(e.registry&&e.events&&e.events.find(([e,n])=>n===t))return;let n=t.target,r=`$$${t.type}`,i=t.target,a=t.currentTarget,o=e=>Object.defineProperty(t,"target",{configurable:!0,value:e}),s=()=>{let e=n[r];if(e&&!n.disabled){let i=n[`${r}Data`];if(i===void 0?e.call(n,t):e.call(n,i,t),t.cancelBubble)return}return n.host&&typeof n.host!=`string`&&!n.host._$host&&n.contains(t.target)&&o(n.host),!0},c=()=>{for(;s()&&(n=n._$host||n.parentNode||n.host););};if(Object.defineProperty(t,"currentTarget",{configurable:!0,get(){return n||document}}),e.registry&&!e.done&&(e.done=_$HY.done=!0),t.composedPath){let e=t.composedPath();o(e[0]);for(let t=0;t<e.length-2&&(n=e[t],s());t++){if(n._$host){n=n._$host,c();break}if(n.parentNode===a)break}}else c();o(i)}function Z(e,t,n,r,i){let a=pe(e);if(a){!n&&(n=[...e.childNodes]);let t=[];for(let e=0;e<n.length;e++){let r=n[e];r.nodeType===8&&r.data.slice(0,2)===`!$`?r.remove():t.push(r)}n=t}for(;typeof n==`function`;)n=n();if(t===n)return n;let o=typeof t,s=r!==void 0;if(e=s&&n[0]&&n[0].parentNode||e,o===`string`||o===`number`){if(a||o===`number`&&(t=t.toString(),t===n))return n;if(s){let i=n[0];i&&i.nodeType===3?i.data!==t&&(i.data=t):i=document.createTextNode(t),n=Q(e,n,r,i)}else n=n!==``&&typeof n==`string`?e.firstChild.data=t:e.textContent=t}else if(t==null||o===`boolean`){if(a)return n;n=Q(e,n,r)}else if(o===`function`)return y(()=>{let i=t();for(;typeof i==`function`;)i=i();n=Z(e,i,n,r)}),()=>n;else if(Array.isArray(t)){let o=[],c=n&&Array.isArray(n);if(he(o,t,n,i))return y(()=>n=Z(e,o,n,r,!0)),()=>n;if(a){if(!o.length)return n;if(r===void 0)return n=[...e.childNodes];let t=o[0];if(t.parentNode!==e)return n;let i=[t];for(;(t=t.nextSibling)!==r;)i.push(t);return n=i}if(o.length===0){if(n=Q(e,n,r),s)return n}else c?n.length===0?ge(e,o,r):ce(e,n,o):(n&&Q(e),ge(e,o));n=o}else if(t.nodeType){if(a&&t.parentNode)return n=s?[t]:t;if(Array.isArray(n)){if(s)return n=Q(e,n,r,t);Q(e,n,null,t)}else n==null||n===``||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}return n}function he(e,t,n,r){let i=!1;for(let a=0,o=t.length;a<o;a++){let o=t[a],s=n&&n[e.length],c;if(o!=null&&o!==!0&&o!==!1){if((c=typeof o)==`object`&&o.nodeType)e.push(o);else if(Array.isArray(o))i=he(e,o,s)||i;else if(c===`function`){if(r){for(;typeof o==`function`;)o=o();i=he(e,Array.isArray(o)?o:[o],Array.isArray(s)?s:[s])||i}else e.push(o),i=!0}else{let t=String(o);s&&s.nodeType===3&&s.data===t?e.push(s):e.push(document.createTextNode(t))}}}return i}function ge(e,t,n=null){for(let r=0,i=t.length;r<i;r++)e.insertBefore(t[r],n)}function Q(e,t,n,r){if(n===void 0)return e.textContent=``;let i=r||document.createTextNode(``);if(t.length){let r=!1;for(let a=t.length-1;a>=0;a--){let o=t[a];if(i!==o){let t=o.parentNode===e;!r&&!a?t?e.replaceChild(i,o):e.insertBefore(i,n):t&&o.remove()}else r=!0}}else e.insertBefore(i,n);return[i]}function _e(e){let t=ve(e.replace(/\r\n/g,`
|
|
2
|
-
`)).split(`
|
|
3
|
-
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(/^```\w*\s*$/.test(e)){let e=[];for(r++;r<t.length&&!/^```\s*$/.test(t[r]);)e.push(t[r++]);r++,n.push(`<pre><code>${e.join(`
|
|
4
|
-
`)}</code></pre>`);continue}let a=e.match(/^(#{1,4})\s+(.*)$/);if(a){n.push(`<h${a[1].length}>${i(a[2])}</h${a[1].length}>`),r++;continue}let o=/^\s*\d+[.)]\s+/.test(e);if(o||/^\s*[-*]\s+/.test(e)){let e=[];for(;r<t.length;){let n=t[r].match(/^\s*[-*]\s+(.*)$/)??(o?t[r].match(/^\s*\d+[.)]\s+(.*)$/):null);if(!n)break;e.push(`<li>${i(n[1])}</li>`),r++}n.push(o?`<ol>${e.join(``)}</ol>`:`<ul>${e.join(``)}</ul>`);continue}if(/^\s*$/.test(e)){r++;continue}let s=[];for(;r<t.length&&!/^\s*$/.test(t[r])&&!/^#{1,4}\s/.test(t[r])&&!/^```/.test(t[r])&&!/^\s*([-*]|\d+[.)])\s/.test(t[r]);)s.push(t[r++]);n.push(`<p>${s.map(i).join(`<br>`)}</p>`)}return n.join(`
|
|
5
|
-
`);function i(e){return e.replace(/`([^`]+)`/g,`<code>$1</code>`).replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`).replace(/(^|\W)\*([^*]+)\*(?=\W|$)/g,`$1<em>$2</em>`).replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g,`<a href="$2" rel="noopener noreferrer" target="_blank">$1</a>`)}}function ve(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var ye=K(`<br>`),be=K(`<span class=sub>ℹ`),xe=K(`<header class=chan-head><span class=hash>#</span><span class=title></span><span></span><span class=sub> · <!>/<!> · turns <!> · tools </span><span style=margin-left:auto;display:flex;gap:4px><button class=iconbtn title="toggle details panel">▤`),Se=K(`<div class=feed>`),Ce=K(`<button class=jump>↓ `),we=K(`<div class=composer><form><input type=text><label><input type=checkbox>auto-start</label><button type=submit>send</button></form><div class=hint>enter to send · prompts are appended to the conversation and the agent keeps working toward its goal`),Te=K(`<h3>controls`),Ee=K(`<div class=btnrow><button>▶ start</button><button>■ stop</button><button>⑂ fork</button><button title="remove agent">🗑`),De=K(`<h3>goal <span>`),Oe=K(`<form style=display:flex;gap:4px;margin-bottom:6px><input id=goal-input type=text placeholder="set new goal…"style="flex:1;background:var(--bg-darkest);border:none;border-radius:6px;padding:6px 8px;color:var(--fg);font:inherit"><button type=submit style="background:var(--acc);border:none;border-radius:6px;color:#fff;padding:0 10px;cursor:pointer">✓`),ke=K(`<div class=card>`),Ae=K(`<h3>latest progress`),je=K(`<div class=card>
|
|
6
|
-
<!>
|
|
7
|
-
<span class=muted>`),Me=K(`<h3>branches`),Ne=K(`<h3>runtime`),Pe=K(`<div class="card muted">turns <!> · tools <!>
|
|
8
|
-
tokens in/out <!>/<!>
|
|
9
|
-
`),Fe=K(`<div class=layout><nav class=sidebar><h1>🫖 teapot<span style=float:right;display:flex;gap:4px><button class=iconbtn title="new agent">+</button><button class=iconbtn title=settings>⚙</button></span></h1><div class=agent-list></div><div class=metrics></div></nav><section class=channel></section><aside>`),Ie=K(`<span title="goal done">✓`),Le=K(`<div><span></span><span>`),Re=K(`<div class=muted style=display:grid;place-items:center;height:100%>select an agent`),ze=K(`<div class=muted style=display:grid;place-items:center;height:100%>no events yet — say something or press ▶ start`),Be=K(`<div class=muted>none yet`),Ve=K(`<div><span>`),He=K(`<div> → `),Ue=K(`<div class=avatar>`),We=K(`<div class=msg-head><span class=author></span><span class=ts></span><span class=ts>`),Ge=K(`<div><div class=msg-body>`),Ke=K(`<span style=width:38px>`),qe=K(`<div class=content>`),Je=K(`<details class=reasoning><summary>💭 reasoning</summary><div class=mono>`),Ye=K(`<details class=embed><summary><b>⚙ </b> <span class=meta></span></summary><div class=mono>`),Xe=K(`<details><summary><span class=meta></span></summary><div class=mono></div><div class=meta>ms`),Ze=K(`<div class=meta>`),Qe=K(`<div class=meta>⚠ `),$e=K(`<div class=meta>→ `),et=K(`<div class=embed style=border-color:var(--ok)><div>📈 `),tt=K(`<div class="embed fail"><div class=mono>⚠ `),nt=K(`<div class="content muted">`),rt=K(`<div class=overlay><div class=modal><div class=modal-head><b></b><button class=iconbtn>✕`),it=K(`<span style=color:var(--err);font-size:13px>`),at=K(`<form style=display:flex;flex-direction:column;gap:10px><label>workspace directory<div style=display:flex;gap:6px><input type=text class="w100 mono"><button type=button>go</button><button type=button>↑</button></div></label><div class=dirlist></div><div style=display:flex;gap:10px><label style=flex:1>agent name <input type=text placeholder="(directory name)"></label><label>provider<select></select></label><label style=flex:1>model <input type=text placeholder="(provider default)"></label></div><button type=submit style=align-self:flex-end>create & start`),ot=K(`<div class=direntry>📁 `),st=K(`<option>`),ct=K(`<form style=display:flex;flex-direction:column;gap:10px><label>providers (<!>)<textarea rows=8 class="mono w100"></textarea></label><div style=display:flex;gap:10px><label style=flex:1>default provider <input type=text></label><label>progress interval (min) <input type=number min=1 style=width:90px></label></div><label>scheduled tasks (JSON array)<textarea rows=7 class="mono w100"></textarea></label><button type=submit style=align-self:flex-end>save`),lt={user:{name:`you`,icon:`🧑`,color:`#faa81a`},message:{name:`agent`,icon:`🫖`,color:`#5865f2`},tool_call:{name:`tool`,icon:`🔧`,color:`#3ba0c9`},progress:{name:`progress`,icon:`📈`,color:`#3ba55d`}},ut=e=>lt[e.type]??{name:e.type,icon:`•`,color:`#9298a5`},dt=new Set([`user`,`message`,`prompt`,`tool_call`,`tool_result`,`progress`]),ft=e=>dt.has(e.type),pt=e=>{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`};async function $(e,t){let n=await fetch(e,t);if(!n.ok)throw Error(`${e}: ${n.status}`);return n.json()}function mt(){let[e,t]=v([]),[n,r]=v(null),[i,a]=v([]),[o,s]=v([]),[c,l]=v(null),[u,d]=v(``),[f,p]=v(!0),[m,h]=v({providers:{}}),[g,_]=v(!1),[b,S]=v(!1),[w,T]=v(!1),[E,ee]=v(!0),[D,O]=v(0),k=x(()=>i().filter(ft)),A=()=>$(`/api/config`).then(h).catch(()=>{}),j=x(()=>e().find(e=>e.id===n())),M=()=>$(`/api/agents`).then(e=>t(e.agents)).catch(()=>{}),N=()=>$(`/api/metrics`).then(l).catch(()=>{});async function P(e){try{let[t,n]=await Promise.all([$(`/api/agents/${e}/events?limit=300`),$(`/api/agents/${e}/branches`)]);a(t.events),s(n.branches)}catch{}}function F(){return document.querySelector(`.feed`)}function I(){let e=F();return!e||e.scrollHeight-e.scrollTop-e.clientHeight<80}function L(e=!1){let t=F();t&&(e||E())&&(t.scrollTop=t.scrollHeight,O(0))}async function R(e){r(e),await P(e),requestAnimationFrame(()=>L(!0))}C(()=>{A(),M().then(()=>e()[0]&&R(e()[0].id)),N();let t=null;new EventSource(`/api/events`).onmessage=e=>{JSON.parse(e.data),!t&&(t=setTimeout(async()=>{if(t=null,await M(),await N(),n()){let e=i().length;await P(n()),i().length!==e&&(I()?L(!0):O(D()+(i().length-e)))}},400))},setInterval(N,3e4)});let z=async e=>{if(e.preventDefault(),!n()||!u().trim())return;let t=u();d(``),await $(`/api/agents/${n()}/prompt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t,start:f()})})},B=e=>()=>n()&&$(`/api/agents/${n()}${e}`,{method:`POST`}).then(M),V=async e=>{e.preventDefault();let t=document.getElementById(`goal-input`);!n()||!t.value.trim()||(await $(`/api/agents/${n()}/goal`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t.value})}),t.value=``,M())};return[(()=>{var i=Fe(),a=i.firstChild,s=a.firstChild,l=s.firstChild.nextSibling.firstChild,m=l.nextSibling,h=s.nextSibling,g=h.nextSibling,v=a.nextSibling,b=v.nextSibling;return l.$$click=()=>{A(),_(!0)},m.$$click=()=>{A(),S(!0)},X(h,H(U,{get each(){return e()},children:e=>(()=>{var t=Le(),r=t.firstChild,i=r.nextSibling;return t.$$click=()=>R(e.id),X(i,()=>e.id),X(t,H(W,{get when(){return e.goal.status===`done`},get children(){return Ie()}}),null),y(i=>{var a=`agent-item`+(e.id===n()?` sel`:``),o=`dot ${e.status}`;return a!==i.e&&q(t,i.e=a),o!==i.t&&q(r,i.t=o),i},{e:void 0,t:void 0}),t})()})),X(g,H(W,{get when(){return c()},get children(){return[`master rss `,G(()=>c().rssMb),`MB · heap `,G(()=>c().heapUsedMb),`MB`,ye(),`load1 `,G(()=>c().loadavg1),` · up `,G(()=>Math.floor(c().uptimeSec/60)),`m`]}})),X(v,H(W,{get when(){return j()},get fallback(){return Re()},get children(){return[(()=>{var e=xe(),t=e.firstChild.nextSibling,n=t.nextSibling,r=n.nextSibling,i=r.firstChild,a=i.nextSibling,o=a.nextSibling.nextSibling,s=o.nextSibling.nextSibling;s.nextSibling;var c=r.nextSibling,l=c.firstChild;return X(t,()=>j().id),X(n,()=>j().status),X(r,()=>j().model,i),X(r,()=>j().session,a),X(r,()=>j().branch,o),X(r,()=>j().stats.turns,s),X(r,()=>j().stats.toolCalls,null),X(c,H(W,{get when(){return j().statusReason},get children(){var e=be();return y(()=>fe(e,`title`,j().statusReason)),e}}),l),l.$$click=()=>T(!w()),y(()=>q(n,`badge ${j().status}`)),e})(),(()=>{var e=Se();return e.addEventListener(`scroll`,()=>{let e=I();e&&D()&&O(0),ee(e)}),X(e,H(W,{get when(){return k().length>0},get fallback(){return ze()},get children(){return H(U,{get each(){return k()},children:(e,t)=>H(ht,{e,get prev(){return k()[t()-1]}})})}})),e})(),H(W,{get when(){return!E()||D()>0},get children(){var e=Ce();return e.firstChild,e.$$click=()=>L(!0),X(e,(()=>{var e=G(()=>D()>0);return()=>e()?`${D()} new message${D()>1?`s`:``}`:`jump to present`})(),null),e}}),(()=>{var e=we(),t=e.firstChild,n=t.firstChild,r=n.nextSibling.firstChild;return t.addEventListener(`submit`,z),n.$$input=e=>d(e.currentTarget.value),r.addEventListener(`change`,e=>p(e.currentTarget.checked)),y(()=>fe(n,`placeholder`,`message #${j().id}`)),y(()=>n.value=u()),y(()=>r.checked=f()),e})()]}})),X(b,H(W,{get when(){return j()},get children(){return[Te(),(()=>{var n=Ee(),i=n.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling;return J(i,`click`,B(`/start`),!0),J(a,`click`,B(`/stop`),!0),o.$$click=()=>$(`/api/agents/${j().id}/fork`,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`}).then(()=>R(j().id)),s.$$click=async()=>{confirm(`remove agent ${j().id}? (log is kept)`)&&(await $(`/api/agents/${j().id}`,{method:`DELETE`}),r(null),t(e().filter(e=>e.id!==j().id)))},n})(),(()=>{var e=De(),t=e.firstChild.nextSibling;return X(t,()=>j().goal.status),y(()=>q(t,`badge ${j().goal.status===`done`?`done`:``}`)),e})(),(()=>{var e=Oe();return e.addEventListener(`submit`,V),e})(),(()=>{var e=ke();return X(e,()=>j().goal.text||`no goal set`),e})(),Ae(),H(W,{get when(){return j().latestProgress},get fallback(){return Be()},get children(){var e=je(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling.nextSibling;return X(e,()=>j().latestProgress.doing,t),X(e,()=>j().latestProgress.recent??``,n),X(r,()=>j().latestProgress.ts),e}}),Me(),H(U,{get each(){return o()},children:e=>(()=>{var t=Ve(),n=t.firstChild;return X(t,()=>e.branch,n),X(n,()=>e.events),y(()=>q(t,`branch-row`+(e.branch===j().branch?` cur`:``))),t})()}),Ne(),(()=>{var e=Pe(),t=e.firstChild.nextSibling,n=t.nextSibling.nextSibling,r=n.nextSibling.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,X(e,()=>j().stats.turns,t),X(e,()=>j().stats.toolCalls,n),X(e,()=>j().stats.inputTokens,r),X(e,()=>j().stats.outputTokens,i),X(e,()=>j().workspace,null),e})()]}})),y(()=>q(b,`rightbar`+(w()?` open`:``))),i})(),H(W,{get when(){return g()},get children(){return H(bt,{get providers(){return Object.keys(m().providers??{})},onClose:()=>_(!1),onCreated:e=>{_(!1),M(),R(e)}})}}),H(W,{get when(){return b()},get children(){return H(xt,{get cfg(){return m()},onClose:()=>S(!1),onSaved:A})}})]}function ht(e){let t=e.e,n=ut(t),r=e.prev&&e.prev.type===t.type&&t.session===e.prev.session&&t.branch===e.prev.branch;return t.type===`state`?t.data.from===t.data.to?null:(()=>{var e=He(),n=e.firstChild;return X(e,()=>t.data.from,n),X(e,()=>t.data.to,null),X(e,(()=>{var e=G(()=>!!t.data.reason);return()=>e()?` — ${t.data.reason}`:``})(),null),y(()=>q(e,`divider-msg`+(t.data.to===`error`?` err`:``))),e})():(()=>{var e=Ge(),i=e.firstChild;return q(e,`msg`+(r?` grouped`:``)),X(e,H(W,{when:!r,get fallback(){return Ke()},get children(){var e=Ue();return X(e,()=>n.icon),y(t=>{var r=n.color+`33`,i=`1px solid ${n.color}66`;return r!==t.e&&Y(e,`background`,t.e=r),i!==t.t&&Y(e,`border`,t.t=i),t},{e:void 0,t:void 0}),e}}),i),X(i,H(W,{when:!r,get children(){var e=We(),r=e.firstChild,i=r.nextSibling,a=i.nextSibling;return X(r,()=>n.name),X(i,()=>pt(t.ts)),X(a,()=>t.branch),y(e=>Y(r,`color`,n.color)),e}}),null),X(i,H(gt,{e:t}),null),e})()}function gt(e){let t=e.e;switch(t.type){case`prompt`:return(()=>{var e=qe();return y(()=>e.innerHTML=_e(String(t.data.text??``))),e})();case`message`:return[H(W,{get when(){return G(()=>typeof t.data.reasoning==`string`)()&&t.data.reasoning.trim()},get children(){var e=Je(),n=e.firstChild.nextSibling;return X(n,()=>String(t.data.reasoning)),e}}),(()=>{var e=qe();return y(()=>e.innerHTML=_e(String(t.data.content??``))),e})()];case`tool_call`:{let e=JSON.stringify(t.data.args,null,1),n=vt(JSON.stringify(t.data.args??{}),110);return(()=>{var r=Ye(),i=r.firstChild,a=i.firstChild;a.firstChild;var o=a.nextSibling.nextSibling,s=i.nextSibling;return X(a,()=>String(t.data.name),null),X(o,n),X(s,e),r})()}case`tool_result`:{let e=String(t.data.result);return(()=>{var n=Xe(),r=n.firstChild,i=r.firstChild,a=r.nextSibling,o=a.nextSibling,s=o.firstChild;return X(i,()=>vt(e,120)),X(a,()=>_t(e,4e3)),X(o,()=>t.data.durationMs,s),X(o,()=>t.data.ok?``:` · FAILED`,null),y(()=>q(n,`embed`+(t.data.ok?``:` fail`))),n})()}case`progress`:return(()=>{var e=et(),n=e.firstChild;return n.firstChild,X(n,()=>String(t.data.doing??``),null),X(e,H(W,{get when(){return t.data.recent},get children(){var e=Ze();return X(e,()=>String(t.data.recent)),e}}),null),X(e,H(W,{get when(){return t.data.problems},get children(){var e=Qe();return e.firstChild,X(e,()=>String(t.data.problems),null),e}}),null),X(e,H(W,{get when(){return t.data.next},get children(){var e=$e();return e.firstChild,X(e,()=>String(t.data.next),null),e}}),null),e})();case`error`:return(()=>{var e=tt(),n=e.firstChild;return n.firstChild,X(n,()=>String(t.data.message??``),null),e})();default:return(()=>{var e=nt();return X(e,()=>_t(JSON.stringify(t.data),200)),e})()}}function _t(e,t){return e.length>t?e.slice(0,t)+` …`:e}function vt(e,t){return _t(e.replace(/\s+/g,` `).trim(),t)}function yt(e){return(()=>{var t=rt(),n=t.firstChild,r=n.firstChild.firstChild,i=r.nextSibling;return t.$$click=t=>t.target===t.currentTarget&&e.onClose(),X(r,()=>e.title),J(i,`click`,e.onClose,!0),X(n,()=>e.children,null),t})()}function bt(e){let[t,n]=v(`~`),[r,i]=v([]),[a,o]=v(``),[s,c]=v(e.providers[0]??``),[l,u]=v(``),[d,f]=v(``);async function p(e){let t=await $(`/api/fs${e?`?path=${encodeURIComponent(e)}`:``}`);n(t.path),i(t.entries)}C(()=>p(t()));let m=async n=>{n.preventDefault(),f(``);try{let n=await $(`/api/agents`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({workspace:t(),id:a(),provider:s()||void 0,model:l()||void 0})});e.onCreated(n.agent.id)}catch(e){f(String(e.message))}};return H(yt,{title:`new agent`,get onClose(){return e.onClose},get children(){var i=at(),f=i.firstChild,h=f.firstChild.nextSibling.firstChild,g=h.nextSibling,_=g.nextSibling,v=f.nextSibling,b=v.nextSibling,x=b.firstChild,S=x.firstChild.nextSibling,C=x.nextSibling,w=C.firstChild.nextSibling,T=C.nextSibling.firstChild.nextSibling,E=b.nextSibling;return i.addEventListener(`submit`,m),h.$$input=e=>n(e.currentTarget.value),g.$$click=()=>p(t()),_.$$click=()=>p(`..`),X(v,H(U,{get each(){return r()},children:e=>(()=>{var n=ot();return n.firstChild,n.$$click=()=>p(`${t()}/${e}`.replace(/\/+/g,`/`)),X(n,e,null),n})()})),S.$$input=e=>o(e.currentTarget.value),w.addEventListener(`change`,e=>c(e.currentTarget.value)),X(w,H(U,{get each(){return e.providers},children:e=>(()=>{var t=st();return X(t,e),t})()})),T.$$input=e=>u(e.currentTarget.value),X(i,H(W,{get when(){return d()},get children(){var e=it();return X(e,d),e}}),E),y(()=>h.value=t()),y(()=>S.value=a()),y(()=>w.value=s()),y(()=>T.value=l()),i}})}function xt(e){let[t,n]=v(JSON.stringify(Object.fromEntries(Object.entries(e.cfg.providers??{}).map(([e,t])=>[e,{baseUrl:t.baseUrl,apiKey:t.apiKey??``,model:t.model??``}])),null,2)),[r,i]=v(e.cfg.defaultProvider??Object.keys(e.cfg.providers??{})[0]??``),[a,o]=v(Math.round((e.cfg.progressIntervalMs??6e5)/6e4)),[s,c]=v(JSON.stringify(e.cfg.tasks??[],null,2)),[l,u]=v(``),d=async n=>{n.preventDefault(),u(``);let i,o;try{i=JSON.parse(t())}catch{return u(`providers: invalid JSON`)}try{o=JSON.parse(s())}catch{return u(`tasks: invalid JSON`)}try{await $(`/api/config`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({providers:i,defaultProvider:r(),progressIntervalMs:Math.max(1,a())*6e4,tasks:o})}),e.onSaved(),e.onClose()}catch(e){u(String(e.message))}};return H(yt,{title:`settings`,get onClose(){return e.onClose},get children(){var u=ct(),f=u.firstChild,p=f.firstChild.nextSibling,m=p.nextSibling.nextSibling,h=f.nextSibling,g=h.firstChild,_=g.firstChild.nextSibling,v=g.nextSibling.firstChild.nextSibling,b=h.nextSibling,x=b.firstChild.nextSibling,S=b.nextSibling;return u.addEventListener(`submit`,d),X(f,()=>e.cfg.configPath,p),m.$$input=e=>n(e.currentTarget.value),_.$$input=e=>i(e.currentTarget.value),v.$$input=e=>o(Number(e.currentTarget.value)),x.$$input=e=>c(e.currentTarget.value),X(u,H(W,{get when(){return l()},get children(){var e=it();return X(e,l),e}}),S),y(()=>m.value=t()),y(()=>_.value=r()),y(()=>v.value=a()),y(()=>x.value=s()),u}})}de([`click`,`input`]),ue(()=>H(mt,{}),document.getElementById(`root`));
|