teapot-coding-agent 0.1.0 → 0.2.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 +47 -13
- package/dist/agent/llm.js +101 -4
- package/dist/log/events.js +10 -2
- package/dist/master.js +69 -2
- package/dist/server/api.js +21 -12
- package/package.json +4 -5
- package/public/assets/index-BnXTX56y.js +9 -0
- package/public/assets/index-DMV4C8AE.css +1 -0
- package/public/index.html +2 -2
- package/public/assets/index-CxlAQ_0i.css +0 -1
- package/public/assets/index-DkqgYCzJ.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,14 +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
|
-
|
|
365
|
-
|
|
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) {
|
|
381
|
+
const maxAttempts = 4;
|
|
382
|
+
const waits = [30_000, 60_000, 120_000];
|
|
366
383
|
for (let attempt = 1;; attempt++) {
|
|
367
384
|
if (this.stopRequested)
|
|
368
385
|
throw Object.assign(new Error("stopped"), { name: "StopRequested" });
|
|
369
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
|
+
});
|
|
370
394
|
try {
|
|
371
|
-
return await this.callLlm(messages, tools);
|
|
395
|
+
return await this.callLlm(messages, tools, onDelta);
|
|
372
396
|
}
|
|
373
397
|
catch (err) {
|
|
374
398
|
this.abort = null;
|
|
@@ -377,7 +401,7 @@ export class Agent {
|
|
|
377
401
|
throw err;
|
|
378
402
|
if (attempt >= maxAttempts)
|
|
379
403
|
throw err;
|
|
380
|
-
const waitMs = attempt
|
|
404
|
+
const waitMs = waits[Math.min(attempt - 1, waits.length - 1)];
|
|
381
405
|
await this.log.append("system_note", this.currentSession, this.currentBranch, {
|
|
382
406
|
event: "llm-retry",
|
|
383
407
|
attempt,
|
|
@@ -410,7 +434,15 @@ export class Agent {
|
|
|
410
434
|
detail: "llm turn start",
|
|
411
435
|
turn: ++this.stats.turns,
|
|
412
436
|
});
|
|
413
|
-
|
|
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
|
+
});
|
|
414
446
|
if (res.usage) {
|
|
415
447
|
this.stats.inputTokens += res.usage.inputTokens ?? 0;
|
|
416
448
|
this.stats.outputTokens += res.usage.outputTokens ?? 0;
|
|
@@ -421,6 +453,7 @@ export class Agent {
|
|
|
421
453
|
role: "assistant",
|
|
422
454
|
content: m.content ?? "",
|
|
423
455
|
toolCalls: m.tool_calls?.map((c) => ({ id: c.id, name: c.function.name })),
|
|
456
|
+
reasoning: res.reasoning,
|
|
424
457
|
});
|
|
425
458
|
this.messages.push(m);
|
|
426
459
|
if (!m.tool_calls?.length)
|
|
@@ -511,6 +544,7 @@ export class Agent {
|
|
|
511
544
|
await this.log.append("message", this.currentSession, this.currentBranch, {
|
|
512
545
|
role: "assistant",
|
|
513
546
|
content: res.message.content ?? "",
|
|
547
|
+
reasoning: res.reasoning,
|
|
514
548
|
});
|
|
515
549
|
this.messages.push(res.message);
|
|
516
550
|
}
|
package/dist/agent/llm.js
CHANGED
|
@@ -43,11 +43,38 @@ export async function chat(cfg, messages, tools, signal) {
|
|
|
43
43
|
messages: sanitize(messages),
|
|
44
44
|
...(tools.length ? { tools } : {}),
|
|
45
45
|
}, { signal });
|
|
46
|
-
const
|
|
47
|
-
|
|
46
|
+
const raw = res.choices?.[0];
|
|
47
|
+
const rm = raw?.message;
|
|
48
|
+
if (!rm)
|
|
48
49
|
throw new Error("LLM API returned no choices");
|
|
50
|
+
// normalize: providers attach extra fields (reasoning, refusal, ...) and
|
|
51
|
+
// nullable content — keep only what our protocol understands
|
|
52
|
+
const message = {
|
|
53
|
+
role: "assistant",
|
|
54
|
+
content: typeof rm.content === "string" ? rm.content : "",
|
|
55
|
+
};
|
|
56
|
+
const reasoning = typeof rm.reasoning === "string" && rm.reasoning ? rm.reasoning : undefined;
|
|
57
|
+
const calls = rm.tool_calls;
|
|
58
|
+
if (calls?.length) {
|
|
59
|
+
message.tool_calls = calls.map((c, i) => ({
|
|
60
|
+
id: c.id ?? `call_${i}`,
|
|
61
|
+
type: "function",
|
|
62
|
+
function: { name: c.function?.name ?? "", arguments: c.function?.arguments ?? "{}" },
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
// some gateways answer 200 with finish_reason "error"; those tool calls /
|
|
66
|
+
// text are often truncated garbage — discard the whole completion so the
|
|
67
|
+
// caller retries cleanly instead of poisoning history
|
|
68
|
+
const finishReason = raw?.finish_reason;
|
|
69
|
+
if (finishReason === "error") {
|
|
70
|
+
throw new Error("LLM API error: provider returned an errored completion");
|
|
71
|
+
}
|
|
72
|
+
if (!message.content && !message.tool_calls) {
|
|
73
|
+
throw new Error("LLM API error: empty completion");
|
|
74
|
+
}
|
|
49
75
|
return {
|
|
50
76
|
message,
|
|
77
|
+
reasoning,
|
|
51
78
|
usage: res.usage
|
|
52
79
|
? { inputTokens: res.usage.prompt_tokens, outputTokens: res.usage.completion_tokens }
|
|
53
80
|
: undefined,
|
|
@@ -55,9 +82,79 @@ export async function chat(cfg, messages, tools, signal) {
|
|
|
55
82
|
}
|
|
56
83
|
catch (err) {
|
|
57
84
|
const e = err;
|
|
58
|
-
if (e.status === undefined)
|
|
85
|
+
if (e.status === undefined && !String(err.message).includes("provider returned"))
|
|
59
86
|
throw err; // not an API error (abort, bug, ...)
|
|
60
87
|
const detail = e.error?.message ?? e.message ?? "unknown provider error";
|
|
61
|
-
throw new Error(`LLM API error ${e.status}: ${String(detail).slice(0, 500)}`);
|
|
88
|
+
throw new Error(`LLM API error ${e.status ?? "?"}: ${String(detail).slice(0, 500)}`);
|
|
89
|
+
}
|
|
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;
|
|
62
159
|
}
|
|
63
160
|
}
|
package/dist/log/events.js
CHANGED
|
@@ -17,13 +17,15 @@ import { createWriteStream } from "node:fs";
|
|
|
17
17
|
import { mkdirSync } from "node:fs";
|
|
18
18
|
import path from "node:path";
|
|
19
19
|
export class EventLog {
|
|
20
|
-
filePath;
|
|
21
|
-
agentId;
|
|
22
20
|
stream = null;
|
|
23
21
|
seq = 0;
|
|
24
22
|
chain = Promise.resolve();
|
|
25
23
|
/** branch -> last event id (in-memory reconstruction of parent chains) */
|
|
26
24
|
lastByBranch = new Map();
|
|
25
|
+
/** optional observer (e.g. console logger wired by the master) */
|
|
26
|
+
onEvent = null;
|
|
27
|
+
filePath;
|
|
28
|
+
agentId;
|
|
27
29
|
constructor(filePath, agentId) {
|
|
28
30
|
this.filePath = filePath;
|
|
29
31
|
this.agentId = 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,12 +65,78 @@ 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
|
-
config;
|
|
70
|
-
configPath;
|
|
71
135
|
agents = new Map();
|
|
72
136
|
tasks = [];
|
|
73
137
|
startedAt = Date.now();
|
|
138
|
+
config;
|
|
139
|
+
configPath;
|
|
74
140
|
constructor(config, configPath) {
|
|
75
141
|
this.config = config;
|
|
76
142
|
this.configPath = configPath;
|
|
@@ -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
|
@@ -205,25 +205,34 @@ export function buildApp(master) {
|
|
|
205
205
|
const stream = new ReadableStream({
|
|
206
206
|
start(controller) {
|
|
207
207
|
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 = () => {
|
|
208
|
+
let closed = false;
|
|
209
|
+
const cleanup = () => {
|
|
210
|
+
closed = true;
|
|
216
211
|
clearInterval(ka);
|
|
217
212
|
bus.off("update", onUpdate);
|
|
218
213
|
};
|
|
214
|
+
const send = (data) => {
|
|
215
|
+
if (closed)
|
|
216
|
+
return;
|
|
217
|
+
try {
|
|
218
|
+
controller.enqueue(enc.encode(`data: ${JSON.stringify(data)}\n\n`));
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
// client vanished mid-write — never let this reach event emitters
|
|
222
|
+
cleanup();
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
send({ kind: "hello", agents: [...master.agents.values()].map((a) => a.snapshot()) });
|
|
226
|
+
const onUpdate = (ev) => send(ev);
|
|
227
|
+
bus.on("update", onUpdate);
|
|
228
|
+
// keep-alive ping every 30s so proxies don't close the stream
|
|
229
|
+
const ka = setInterval(() => send({ kind: "ping" }), 30_000);
|
|
230
|
+
c.req.raw.signal.addEventListener("abort", cleanup);
|
|
219
231
|
},
|
|
220
232
|
cancel() {
|
|
221
|
-
/*
|
|
233
|
+
/* cleanup also runs via the abort listener above */
|
|
222
234
|
},
|
|
223
235
|
});
|
|
224
|
-
c.req.raw.signal.addEventListener("abort", () => {
|
|
225
|
-
/* node-server closes the stream; cleanup runs on cancel */
|
|
226
|
-
});
|
|
227
236
|
return c.body(stream);
|
|
228
237
|
});
|
|
229
238
|
// RFC 2324 / HTCPCP compliance
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teapot-coding-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"packageManager": "pnpm@11.3.0",
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
21
|
+
"node": ">=24"
|
|
22
22
|
},
|
|
23
23
|
"bin": {
|
|
24
24
|
"teapot": "dist/index.js"
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"build-server": "tsc -p tsconfig.json",
|
|
34
34
|
"build-web": "vite build",
|
|
35
35
|
"start": "node dist/index.js",
|
|
36
|
-
"dev": "
|
|
36
|
+
"dev": "node src/index.ts",
|
|
37
37
|
"dev-web": "vite",
|
|
38
|
-
"test": "node --
|
|
38
|
+
"test": "node --test test/*.test.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@hono/node-server": "^1.14.0",
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "^24.0.0",
|
|
47
47
|
"solid-js": "^1.9.15",
|
|
48
|
-
"tsx": "^4.20.0",
|
|
49
48
|
"typescript": "^5.8.0",
|
|
50
49
|
"vite": "^8.2.2",
|
|
51
50
|
"vite-plugin-solid": "^2.11.14"
|
|
@@ -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(()=>R(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[D.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=ne;let r=j(e,t,!1,c),i=E&&te(E);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),D.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[ee,T]=v(!1);function te(e){let t;return d&&d.context&&(t=d.context[e.id])!==void 0?t:e.defaultValue}var E;function D(){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(()=>I(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&&L(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;R(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(R),e.tOwned=void 0):(e.state=c,e.owned&&e.owned.forEach(R),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 I(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(()=>I(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)R(e);for(let t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)R(t.owned[e]);t.tOwned&&(t.owned=t.tOwned),delete t.tValue,delete t.tOwned,t.tState=0}T(!1)},!1)}else if(f.running){f.running=!1,f.effects.push.apply(f.effects,h),h=null,T(!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 ne(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 I(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&&I(i,t)}}}function L(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&&L(r))}}function R(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--)R(e.tOwned[t]);delete e.tOwned}if(f&&f.running&&e.pure)z(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)R(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 z(e,t){if(t||(e.tState=0,f.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)z(e.owned[t])}function B(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`,{cause:e})}function V(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=B(e);if(!n)throw r;h?h.push({fn(){V(r,n,t)},state:c}):V(r,n,t)}var re=Symbol(`fallback`);function ie(e){for(let t=0;t<e.length;t++)e[t]()}function ae(e,t,n={}){let r=[],a=[],o=[],s=0,c=t.length>1?[]:null;return w(()=>ie(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&&(ie(o),o=[],r=[],a=[],s=0,c&&=[]),n.fallback&&(r=[re],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 U(e,t){return S(()=>e(t||{}))}var oe=e=>`Stale read from <${e}>.`;function W(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return x(ae(()=>e.each,e.children,t||void 0))}function G(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 oe(`Show`);return n()})):a}return e.fallback},void 0,void 0)}var K=e=>x(()=>e());function se(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 ce=`_$DX_DELEGATE`;function le(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 q(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 ue(e,t=window.document){let n=t[ce]||(t[ce]=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 de(e,t,n){pe(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function J(e,t){pe(e)||(t==null?e.removeAttribute(`class`):e.className=t)}function Y(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 fe(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):se(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=q(`<br>`),be=q(`<span class=sub>ℹ`),xe=q(`<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=q(`<details class=reasoning><summary>💭 reasoning</summary><div class=mono>`),Ce=q(`<div class=content><span class=cursor>▍`),we=q(`<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=q(`<div class=feed>`),Ee=q(`<button class=jump>↓ `),De=q(`<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=q(`<h3>controls`),ke=q(`<div class=btnrow><button>▶ start</button><button>■ stop</button><button>⑂ fork</button><button title="remove agent">🗑`),Ae=q(`<h3>goal <span>`),je=q(`<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=q(`<div class=card>`),Ne=q(`<h3>latest progress`),Pe=q(`<div class=card>
|
|
6
|
+
<!>
|
|
7
|
+
<span class=muted>`),Fe=q(`<h3>branches`),Ie=q(`<h3>runtime`),Le=q(`<div class="card muted">turns <!> · tools <!>
|
|
8
|
+
tokens in/out <!>/<!>
|
|
9
|
+
`),Re=q(`<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>`),ze=q(`<span title="goal done">✓`),Be=q(`<div><span></span><span>`),Ve=q(`<div class=muted style=display:grid;place-items:center;height:100%>select an agent`),He=q(`<div class=muted style=display:grid;place-items:center;height:100%>no events yet — say something or press ▶ start`),Ue=q(`<div class="content muted">thinking…`),We=q(`<div class=muted>none yet`),Ge=q(`<div><span>`),Ke=q(`<div> → `),qe=q(`<div class=avatar>`),Je=q(`<div class=msg-head><span class=author></span><span class=ts></span><span class=ts>`),Ye=q(`<div><div class=msg-body>`),Xe=q(`<span style=width:38px>`),Ze=q(`<div class=content>`),Qe=q(`<details class=embed><summary><b>⚙ </b> <span class=meta></span></summary><div class=mono>`),$e=q(`<details><summary><span class=meta></span></summary><div class=mono></div><div class=meta>ms`),et=q(`<div class=meta>`),tt=q(`<div class=meta>⚠ `),nt=q(`<div class=meta>→ `),rt=q(`<div class=embed style=border-color:var(--ok)><div>📈 `),it=q(`<div class="embed fail"><div class=mono>⚠ `),at=q(`<div class="content muted">`),ot=q(`<div class=overlay><div class=modal><div class=modal-head><b></b><button class=iconbtn>✕`),st=q(`<span style=color:var(--err);font-size:13px>`),ct=q(`<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`),lt=q(`<div class=direntry>📁 `),ut=q(`<option>`),dt=q(`<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`),ft={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`}},pt=e=>ft[e.type]??{name:e.type,icon:`•`,color:`#9298a5`},mt=new Set([`user`,`message`,`prompt`,`tool_call`,`tool_result`,`progress`]),ht=e=>mt.has(e.type),gt=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 _t(){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,ee]=v(!1),[T,te]=v(!0),[E,D]=v(0),[O,k]=v(null),A=x(()=>i().filter(ht)),j=()=>$(`/api/config`).then(h).catch(()=>{}),M=x(()=>e().find(e=>e.id===n())),N=()=>$(`/api/agents`).then(e=>t(e.agents)).catch(()=>{}),P=()=>$(`/api/metrics`).then(l).catch(()=>{});async function F(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 ne(){return document.querySelector(`.feed`)}function I(){let e=ne();return!e||e.scrollHeight-e.scrollTop-e.clientHeight<80}function L(e=!1){let t=ne();t&&(e||T())&&(t.scrollTop=t.scrollHeight,D(0))}async function R(e){r(e),k(null),await F(e),requestAnimationFrame(()=>L(!0))}C(()=>{j(),N().then(()=>e()[0]&&R(e()[0].id)),P();let t=null;new EventSource(`/api/events`).onmessage=e=>{let r=JSON.parse(e.data);if(r.kind===`llm-delta`){r.agentId===n()&&k({text:r.text??``,reasoning:r.reasoning??``});return}t||=setTimeout(async()=>{if(t=null,await N(),await P(),n()){let e=i().length;await F(n()),i().length!==e&&(k(null),I()?L(!0):D(E()+(i().length-e)))}},400)},setInterval(P,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(N),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=``,N())};return[(()=>{var i=Re(),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=()=>{j(),_(!0)},m.$$click=()=>{j(),S(!0)},X(h,U(W,{get each(){return e()},children:e=>(()=>{var t=Be(),r=t.firstChild,i=r.nextSibling;return t.$$click=()=>R(e.id),X(i,()=>e.id),X(t,U(G,{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&&J(t,i.e=a),o!==i.t&&J(r,i.t=o),i},{e:void 0,t:void 0}),t})()})),X(g,U(G,{get when(){return c()},get children(){return[`master rss `,K(()=>c().rssMb),`MB · heap `,K(()=>c().heapUsedMb),`MB`,ye(),`load1 `,K(()=>c().loadavg1),` · up `,K(()=>Math.floor(c().uptimeSec/60)),`m`]}})),X(v,U(G,{get when(){return M()},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 X(t,()=>M().id),X(n,()=>M().status),X(r,()=>M().model,i),X(r,()=>M().session,a),X(r,()=>M().branch,o),X(r,()=>M().stats.turns,s),X(r,()=>M().stats.toolCalls,null),X(c,U(G,{get when(){return M().statusReason},get children(){var e=be();return y(()=>de(e,`title`,M().statusReason)),e}}),l),l.$$click=()=>ee(!w()),y(()=>J(n,`badge ${M().status}`)),e})(),(()=>{var e=Te();return e.addEventListener(`scroll`,()=>{let e=I();e&&E()&&D(0),te(e)}),X(e,U(G,{get when(){return A().length>0},get fallback(){return He()},get children(){return[U(W,{get each(){return A()},children:(e,t)=>U(vt,{e,get prev(){return A()[t()-1]}})}),U(G,{get when(){return O()},get children(){var e=we(),t=e.firstChild.nextSibling;return t.firstChild,X(t,U(G,{get when(){return O().reasoning},get children(){var e=Se(),t=e.firstChild.nextSibling;return X(t,()=>O().reasoning),e}}),null),X(t,U(G,{get when(){return O().text},get fallback(){return Ue()},get children(){var e=Ce(),t=e.firstChild;return X(e,()=>O().text,t),e}}),null),e}})]}})),e})(),U(G,{get when(){return!T()||E()>0},get children(){var e=Ee();return e.firstChild,e.$$click=()=>L(!0),X(e,(()=>{var e=K(()=>E()>0);return()=>e()?`${E()} new message${E()>1?`s`:``}`:`jump to present`})(),null),e}}),(()=>{var e=De(),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(()=>de(n,`placeholder`,`message #${M().id}`)),y(()=>n.value=u()),y(()=>r.checked=f()),e})()]}})),X(b,U(G,{get when(){return M()},get children(){return[Oe(),(()=>{var n=ke(),i=n.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling;return Y(i,`click`,B(`/start`),!0),Y(a,`click`,B(`/stop`),!0),o.$$click=()=>$(`/api/agents/${M().id}/fork`,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`}).then(()=>R(M().id)),s.$$click=async()=>{confirm(`remove agent ${M().id}? (log is kept)`)&&(await $(`/api/agents/${M().id}`,{method:`DELETE`}),r(null),t(e().filter(e=>e.id!==M().id)))},n})(),(()=>{var e=Ae(),t=e.firstChild.nextSibling;return X(t,()=>M().goal.status),y(()=>J(t,`badge ${M().goal.status===`done`?`done`:``}`)),e})(),(()=>{var e=je();return e.addEventListener(`submit`,V),e})(),(()=>{var e=Me();return X(e,()=>M().goal.text||`no goal set`),e})(),Ne(),U(G,{get when(){return M().latestProgress},get fallback(){return We()},get children(){var e=Pe(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling.nextSibling;return X(e,()=>M().latestProgress.doing,t),X(e,()=>M().latestProgress.recent??``,n),X(r,()=>M().latestProgress.ts),e}}),Fe(),U(W,{get each(){return o()},children:e=>(()=>{var t=Ge(),n=t.firstChild;return X(t,()=>e.branch,n),X(n,()=>e.events),y(()=>J(t,`branch-row`+(e.branch===M().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,X(e,()=>M().stats.turns,t),X(e,()=>M().stats.toolCalls,n),X(e,()=>M().stats.inputTokens,r),X(e,()=>M().stats.outputTokens,i),X(e,()=>M().workspace,null),e})()]}})),y(()=>J(b,`rightbar`+(w()?` open`:``))),i})(),U(G,{get when(){return g()},get children(){return U(Ct,{get providers(){return Object.keys(m().providers??{})},onClose:()=>_(!1),onCreated:e=>{_(!1),N(),R(e)}})}}),U(G,{get when(){return b()},get children(){return U(wt,{get cfg(){return m()},onClose:()=>S(!1),onSaved:j})}})]}function vt(e){let t=e.e,n=pt(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 X(e,()=>t.data.from,n),X(e,()=>t.data.to,null),X(e,(()=>{var e=K(()=>!!t.data.reason);return()=>e()?` — ${t.data.reason}`:``})(),null),y(()=>J(e,`divider-msg`+(t.data.to===`error`?` err`:``))),e})():(()=>{var e=Ye(),i=e.firstChild;return J(e,`msg`+(r?` grouped`:``)),X(e,U(G,{when:!r,get fallback(){return Xe()},get children(){var e=qe();return X(e,()=>n.icon),y(t=>{var r=n.color+`33`,i=`1px solid ${n.color}66`;return r!==t.e&&fe(e,`background`,t.e=r),i!==t.t&&fe(e,`border`,t.t=i),t},{e:void 0,t:void 0}),e}}),i),X(i,U(G,{when:!r,get children(){var e=Je(),r=e.firstChild,i=r.nextSibling,a=i.nextSibling;return X(r,()=>n.name),X(i,()=>gt(t.ts)),X(a,()=>t.branch),y(e=>fe(r,`color`,n.color)),e}}),null),X(i,U(yt,{e:t}),null),e})()}function yt(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[U(G,{get when(){return K(()=>typeof t.data.reasoning==`string`)()&&t.data.reasoning.trim()},get children(){var e=Se(),n=e.firstChild.nextSibling;return X(n,()=>String(t.data.reasoning)),e}}),(()=>{var e=Ze();return y(()=>e.innerHTML=_e(String(t.data.content??``))),e})()];case`tool_call`:{let e=JSON.stringify(t.data.args,null,1),n=xt(JSON.stringify(t.data.args??{}),110);return(()=>{var r=Qe(),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=$e(),r=n.firstChild,i=r.firstChild,a=r.nextSibling,o=a.nextSibling,s=o.firstChild;return X(i,()=>xt(e,120)),X(a,()=>bt(e,4e3)),X(o,()=>t.data.durationMs,s),X(o,()=>t.data.ok?``:` · FAILED`,null),y(()=>J(n,`embed`+(t.data.ok?``:` fail`))),n})()}case`progress`:return(()=>{var e=rt(),n=e.firstChild;return n.firstChild,X(n,()=>String(t.data.doing??``),null),X(e,U(G,{get when(){return t.data.recent},get children(){var e=et();return X(e,()=>String(t.data.recent)),e}}),null),X(e,U(G,{get when(){return t.data.problems},get children(){var e=tt();return e.firstChild,X(e,()=>String(t.data.problems),null),e}}),null),X(e,U(G,{get when(){return t.data.next},get children(){var e=nt();return e.firstChild,X(e,()=>String(t.data.next),null),e}}),null),e})();case`error`:return(()=>{var e=it(),n=e.firstChild;return n.firstChild,X(n,()=>String(t.data.message??``),null),e})();default:return(()=>{var e=at();return X(e,()=>bt(JSON.stringify(t.data),200)),e})()}}function bt(e,t){return e.length>t?e.slice(0,t)+` …`:e}function xt(e,t){return bt(e.replace(/\s+/g,` `).trim(),t)}function St(e){return(()=>{var t=ot(),n=t.firstChild,r=n.firstChild.firstChild,i=r.nextSibling;return t.$$click=t=>t.target===t.currentTarget&&e.onClose(),X(r,()=>e.title),Y(i,`click`,e.onClose,!0),X(n,()=>e.children,null),t})()}function Ct(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 U(St,{title:`new agent`,get onClose(){return e.onClose},get children(){var i=ct(),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,ee=C.nextSibling.firstChild.nextSibling,T=b.nextSibling;return i.addEventListener(`submit`,m),h.$$input=e=>n(e.currentTarget.value),g.$$click=()=>p(t()),_.$$click=()=>p(`..`),X(v,U(W,{get each(){return r()},children:e=>(()=>{var n=lt();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,U(W,{get each(){return e.providers},children:e=>(()=>{var t=ut();return X(t,e),t})()})),ee.$$input=e=>u(e.currentTarget.value),X(i,U(G,{get when(){return d()},get children(){var e=st();return X(e,d),e}}),T),y(()=>h.value=t()),y(()=>S.value=a()),y(()=>w.value=s()),y(()=>ee.value=l()),i}})}function wt(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 U(St,{title:`settings`,get onClose(){return e.onClose},get children(){var u=dt(),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,U(G,{get when(){return l()},get children(){var e=st();return X(e,l),e}}),S),y(()=>m.value=t()),y(()=>_.value=r()),y(()=>v.value=a()),y(()=>x.value=s()),u}})}ue([`click`,`input`]),le(()=>U(_t,{}),document.getElementById(`root`));
|
|
@@ -0,0 +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}.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}}.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-BnXTX56y.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DMV4C8AE.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="root"></div>
|
|
@@ -1 +0,0 @@
|
|
|
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:100vh;display:grid}@media (width<=1100px){.layout{grid-template-columns:220px 1fr}.rightbar{display:none}}.sidebar{background:var(--bg-darkest);padding:10px 8px;overflow-y:auto}.sidebar h1{color:var(--fg);margin:0;padding:4px 8px 10px;font-size:14px}.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;display:flex}.chan-head{border-bottom:2px solid var(--line);background:var(--bg-dark);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{flex:1;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 .mono{white-space:pre-wrap;word-break:break-word;font-family:ui-monospace,Menlo,monospace;font-size:12.5px}.embed .meta{color:var(--dim);margin-top:3px;font-size:11px}.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);padding:14px;font-size:13px;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,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=te,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(()=>L(o)));d=o,p=null;try{return F(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[k.bind(n),e=>(typeof e==`function`&&(e=f&&f.running&&f.sources.has(n)?e(n.tValue):e(n.value)),A(n,e))]}function y(e,t,n){j(N(e,t,!1,c))}function b(e,t,n){s=ne;let r=N(e,t,!1,c),i=O&&D(O);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),h?h.push(r):j(r)}function x(e,t,n){n=n?Object.assign({},a,n):a;let r=N(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,j(r),k.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 D(e){let t;return d&&d.context&&(t=d.context[e.id])!==void 0?t:e.defaultValue}var O;function k(){let e=f&&f.running;if(this.sources&&(e?this.tState:this.state)){if((e?this.tState:this.state)===c)j(this);else{let e=m;m=null,F(()=>I(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 A(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&&F(()=>{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&&re(n)),r?n.tState=c:n.state=c)}if(m.length>1e6)throw m=[],Error()},!1)}return t}function j(e){if(!e.fn)return;L(e);let t=g;M(e,f&&f.running&&f.sources.has(e)?e.tValue:e.value,t),f&&!f.running&&f.sources.has(e)&&queueMicrotask(()=>{F(()=>{f&&(f.running=!0),p=d=e,M(e,e.tValue,t),p=d=null},!1)})}function M(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(L),e.tOwned=void 0):(e.state=c,e.owned&&e.owned.forEach(L),e.owned=null)),e.updatedAt=n+1,R(t)}finally{p=a,d=i}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&`observers`in e?A(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 N(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 P(e){let t=f&&f.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===l)return I(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)j(e);else if((t?e.tState:e.state)===l){let t=m;m=null,F(()=>I(e,n[0]),!1),m=t}}}function F(e,t){if(m)return e();let n=!1;t||(m=[]),h?n=!0:h=[],g++;try{let t=e();return ee(n),t}catch(e){n||(h=null),m=null,R(e)}}function ee(e){if(m&&=(te(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,F(()=>{for(let e of n)L(e);for(let t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)L(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&&F(()=>s(n),!1),t&&t()}function te(e){for(let t=0;t<e.length;t++)P(e[t])}function ne(t){let r,i=0;for(r=0;r<t.length;r++){let e=t[r];e.user?t[i++]=e:P(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++)P(t[r])}function I(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)&&P(i):e===l&&I(i,t)}}}function re(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&&re(r))}}function L(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--)L(e.tOwned[t]);delete e.tOwned}if(f&&f.running&&e.pure)ie(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)L(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 ie(e,t){if(t||(e.tState=0,f.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)ie(e.owned[t])}function ae(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`,{cause:e})}function oe(e,t,n){try{for(let n of t)n(e)}catch(e){R(e,n&&n.owner||null)}}function R(e,t=d){let n=o&&t&&t.context&&t.context[o],r=ae(e);if(!n)throw r;h?h.push({fn(){oe(r,n,t)},state:c}):oe(r,n,t)}var se=Symbol(`fallback`);function ce(e){for(let t=0;t<e.length;t++)e[t]()}function le(e,t,n={}){let r=[],a=[],o=[],s=0,c=t.length>1?[]:null;return w(()=>ce(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&&(ce(o),o=[],r=[],a=[],s=0,c&&=[]),n.fallback&&(r=[se],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 z(e,t){return S(()=>e(t||{}))}var ue=e=>`Stale read from <${e}>.`;function B(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return x(le(()=>e.each,e.children,t||void 0))}function V(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 ue(`Show`);return n()})):a}return e.fallback},void 0,void 0)}var H=e=>x(()=>e());function de(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 fe=`_$DX_DELEGATE`;function pe(e,t,n,r={}){let i;return _(r=>{i=r,t===document?e():q(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{i(),t.textContent=``}}function U(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 me(e,t=window.document){let n=t[fe]||(t[fe]=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,ge))}}function he(e,t,n){J(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function W(e,t){J(e)||(t==null?e.removeAttribute(`class`):e.className=t)}function G(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 K(e,t,n){n==null?e.style.removeProperty(t):e.style.setProperty(t,n)}function q(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!=`function`)return Y(e,t,r,n);y(r=>Y(e,t(),r,n),r)}function J(t){return!!e.context&&!e.done&&(!t||t.isConnected)}function ge(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 Y(e,t,n,r,i){let a=J(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=Z(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=Z(e,n,r)}else if(o===`function`)return y(()=>{let i=t();for(;typeof i==`function`;)i=i();n=Y(e,i,n,r)}),()=>n;else if(Array.isArray(t)){let o=[],c=n&&Array.isArray(n);if(X(o,t,n,i))return y(()=>n=Y(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=Z(e,n,r),s)return n}else c?n.length===0?_e(e,o,r):de(e,n,o):(n&&Z(e),_e(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=Z(e,n,r,t);Z(e,n,null,t)}else n==null||n===``||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}return n}function X(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=X(e,o,s)||i;else if(c===`function`){if(r){for(;typeof o==`function`;)o=o();i=X(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 _e(e,t,n=null){for(let r=0,i=t.length;r<i;r++)e.insertBefore(t[r],n)}function Z(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 ve(e){let t=ye(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 ye(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var be=U(`<br>`),xe=U(`<span class=sub>`),Se=U(`<header class=chan-head><span class=hash>#</span><span class=title></span><span></span><span class=sub> · <!>/<!> · turns <!> · tools `),Ce=U(`<div class=feed>`),we=U(`<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=U(`<h3>controls`),Ee=U(`<div class=btnrow><button>▶ start</button><button>■ stop</button><button>⑂ fork</button><button title="remove agent">🗑`),De=U(`<h3>goal <span>`),Oe=U(`<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=U(`<div class=card>`),Ae=U(`<h3>latest progress`),je=U(`<div class=card>
|
|
6
|
-
<!>
|
|
7
|
-
<span class=muted>`),Me=U(`<h3>branches`),Ne=U(`<h3>runtime`),Pe=U(`<div class="card muted">turns <!> · tools <!>
|
|
8
|
-
tokens in/out <!>/<!>
|
|
9
|
-
`),Fe=U(`<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=metrics></div></nav><section class=channel></section><aside class=rightbar>`),Ie=U(`<span title="goal done">✓`),Le=U(`<div><span></span><span>`),Re=U(`<div class=muted style=display:grid;place-items:center;height:100%>select an agent`),ze=U(`<div class=muted>none yet`),Be=U(`<div><span>`),Ve=U(`<div> → `),He=U(`<div class=avatar>`),Ue=U(`<div class=msg-head><span class=author></span><span class=ts></span><span class=ts>`),We=U(`<div><div class=msg-body>`),Ge=U(`<span style=width:38px>`),Ke=U(`<div class=content>`),qe=U(`<div class=embed><b>⚙ </b><div class=mono>`),Je=U(`<div><div class=mono></div><div class=meta>ms`),Ye=U(`<div class=meta>`),Xe=U(`<div class=meta>⚠ `),Ze=U(`<div class=meta>→ `),Qe=U(`<div class=embed style=border-color:var(--ok)><div>📈 `),$e=U(`<div class="embed fail"><div class=mono>⚠ `),et=U(`<div class="content muted">`),tt=U(`<div class=overlay><div class=modal><div class=modal-head><b></b><button class=iconbtn>✕`),nt=U(`<span style=color:var(--err);font-size:13px>`),rt=U(`<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`),it=U(`<div class=direntry>📁 `),at=U(`<option>`),ot=U(`<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`),st={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`}},ct=e=>st[e.type]??{name:e.type,icon:`•`,color:`#9298a5`},lt=new Set([`user`,`message`,`prompt`,`tool_call`,`tool_result`,`progress`]),ut=e=>lt.has(e.type),dt=e=>{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`};async function Q(e,t){let n=await fetch(e,t);if(!n.ok)throw Error(`${e}: ${n.status}`);return n.json()}function ft(){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=()=>Q(`/api/config`).then(h).catch(()=>{}),T=x(()=>e().find(e=>e.id===n())),E=()=>Q(`/api/agents`).then(e=>t(e.agents)).catch(()=>{}),D=()=>Q(`/api/metrics`).then(l).catch(()=>{});async function O(e){try{let[t,n]=await Promise.all([Q(`/api/agents/${e}/events?limit=300`),Q(`/api/agents/${e}/branches`)]);a(t.events),s(n.branches)}catch{}}async function k(e){r(e),await O(e),requestAnimationFrame(A)}function A(){let e=document.querySelector(`.feed`);e&&(e.scrollTop=e.scrollHeight)}C(()=>{w(),E().then(()=>e()[0]&&k(e()[0].id)),D();let t=null;new EventSource(`/api/events`).onmessage=e=>{JSON.parse(e.data),!t&&(t=setTimeout(async()=>{if(t=null,await E(),await D(),n()){let e=i().length;await O(n()),i().length!==e&&A()}},400))},setInterval(D,3e4)});let j=async e=>{if(e.preventDefault(),!n()||!u().trim())return;let t=u();d(``),await Q(`/api/agents/${n()}/prompt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t,start:f()})})},M=e=>()=>n()&&Q(`/api/agents/${n()}${e}`,{method:`POST`}).then(E),N=async e=>{e.preventDefault();let t=document.getElementById(`goal-input`);!n()||!t.value.trim()||(await Q(`/api/agents/${n()}/goal`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t.value})}),t.value=``,E())};return[(()=>{var a=Fe(),s=a.firstChild,l=s.firstChild,m=l.firstChild.nextSibling.firstChild,h=m.nextSibling,g=l.nextSibling,v=s.nextSibling,b=v.nextSibling;return m.$$click=()=>{w(),_(!0)},h.$$click=()=>{w(),S(!0)},q(s,z(B,{get each(){return e()},children:e=>(()=>{var t=Le(),r=t.firstChild,i=r.nextSibling;return t.$$click=()=>k(e.id),q(i,()=>e.id),q(t,z(V,{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&&W(t,i.e=a),o!==i.t&&W(r,i.t=o),i},{e:void 0,t:void 0}),t})()}),g),q(g,z(V,{get when(){return c()},get children(){return[`master rss `,H(()=>c().rssMb),`MB · heap `,H(()=>c().heapUsedMb),`MB`,be(),`load1 `,H(()=>c().loadavg1),` · up `,H(()=>Math.floor(c().uptimeSec/60)),`m`]}})),q(v,z(V,{get when(){return T()},get fallback(){return Re()},get children(){return[(()=>{var e=Se(),t=e.firstChild.nextSibling,n=t.nextSibling,r=n.nextSibling,i=r.firstChild,a=i.nextSibling,o=a.nextSibling.nextSibling,s=o.nextSibling.nextSibling;return s.nextSibling,q(t,()=>T().id),q(n,()=>T().status),q(e,z(V,{get when(){return T().statusReason},get children(){var e=xe();return q(e,()=>T().statusReason),e}}),r),q(r,()=>T().model,i),q(r,()=>T().session,a),q(r,()=>T().branch,o),q(r,()=>T().stats.turns,s),q(r,()=>T().stats.toolCalls,null),y(()=>W(n,`badge ${T().status}`)),e})(),(()=>{var e=Ce();return q(e,z(B,{get each(){return i().filter(ut)},children:(e,t)=>z(pt,{e,get prev(){return i().filter(ut)[t()-1]}})})),e})(),(()=>{var e=we(),t=e.firstChild,n=t.firstChild,r=n.nextSibling.firstChild;return t.addEventListener(`submit`,j),n.$$input=e=>d(e.currentTarget.value),r.addEventListener(`change`,e=>p(e.currentTarget.checked)),y(()=>he(n,`placeholder`,`message #${T().id}`)),y(()=>n.value=u()),y(()=>r.checked=f()),e})()]}})),q(b,z(V,{get when(){return T()},get children(){return[Te(),(()=>{var n=Ee(),i=n.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling;return G(i,`click`,M(`/start`),!0),G(a,`click`,M(`/stop`),!0),o.$$click=()=>Q(`/api/agents/${T().id}/fork`,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`}).then(()=>k(T().id)),s.$$click=async()=>{confirm(`remove agent ${T().id}? (log is kept)`)&&(await Q(`/api/agents/${T().id}`,{method:`DELETE`}),r(null),t(e().filter(e=>e.id!==T().id)))},n})(),(()=>{var e=De(),t=e.firstChild.nextSibling;return q(t,()=>T().goal.status),y(()=>W(t,`badge ${T().goal.status===`done`?`done`:``}`)),e})(),(()=>{var e=Oe();return e.addEventListener(`submit`,N),e})(),(()=>{var e=ke();return q(e,()=>T().goal.text||`no goal set`),e})(),Ae(),z(V,{get when(){return T().latestProgress},get fallback(){return ze()},get children(){var e=je(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling.nextSibling;return q(e,()=>T().latestProgress.doing,t),q(e,()=>T().latestProgress.recent??``,n),q(r,()=>T().latestProgress.ts),e}}),Me(),z(B,{get each(){return o()},children:e=>(()=>{var t=Be(),n=t.firstChild;return q(t,()=>e.branch,n),q(n,()=>e.events),y(()=>W(t,`branch-row`+(e.branch===T().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,q(e,()=>T().stats.turns,t),q(e,()=>T().stats.toolCalls,n),q(e,()=>T().stats.inputTokens,r),q(e,()=>T().stats.outputTokens,i),q(e,()=>T().workspace,null),e})()]}})),a})(),z(V,{get when(){return g()},get children(){return z(gt,{get providers(){return Object.keys(m().providers??{})},onClose:()=>_(!1),onCreated:e=>{_(!1),E(),k(e)}})}}),z(V,{get when(){return b()},get children(){return z(_t,{get cfg(){return m()},onClose:()=>S(!1),onSaved:w})}})]}function pt(e){let t=e.e,n=ct(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=Ve(),n=e.firstChild;return q(e,()=>t.data.from,n),q(e,()=>t.data.to,null),q(e,(()=>{var e=H(()=>!!t.data.reason);return()=>e()?` — ${t.data.reason}`:``})(),null),y(()=>W(e,`divider-msg`+(t.data.to===`error`?` err`:``))),e})():(()=>{var e=We(),i=e.firstChild;return W(e,`msg`+(r?` grouped`:``)),q(e,z(V,{when:!r,get fallback(){return Ge()},get children(){var e=He();return q(e,()=>n.icon),y(t=>{var r=n.color+`33`,i=`1px solid ${n.color}66`;return r!==t.e&&K(e,`background`,t.e=r),i!==t.t&&K(e,`border`,t.t=i),t},{e:void 0,t:void 0}),e}}),i),q(i,z(V,{when:!r,get children(){var e=Ue(),r=e.firstChild,i=r.nextSibling,a=i.nextSibling;return q(r,()=>n.name),q(i,()=>dt(t.ts)),q(a,()=>t.branch),y(e=>K(r,`color`,n.color)),e}}),null),q(i,z(mt,{e:t}),null),e})()}function mt(e){let t=e.e;switch(t.type){case`prompt`:return(()=>{var e=Ke();return y(()=>e.innerHTML=ve(String(t.data.text??``))),e})();case`message`:return(()=>{var e=Ke();return y(()=>e.innerHTML=ve(String(t.data.content??``))),e})();case`tool_call`:return(()=>{var e=qe(),n=e.firstChild;n.firstChild;var r=n.nextSibling;return q(n,()=>String(t.data.name),null),q(r,()=>$(JSON.stringify(t.data.args,null,1),500)),e})();case`tool_result`:return(()=>{var e=Je(),n=e.firstChild,r=n.nextSibling,i=r.firstChild;return q(n,()=>$(String(t.data.result),700)),q(r,()=>t.data.durationMs,i),q(r,()=>t.data.ok?``:` · FAILED`,null),y(()=>W(e,`embed`+(t.data.ok?``:` fail`))),e})();case`progress`:return(()=>{var e=Qe(),n=e.firstChild;return n.firstChild,q(n,()=>String(t.data.doing??``),null),q(e,z(V,{get when(){return t.data.recent},get children(){var e=Ye();return q(e,()=>String(t.data.recent)),e}}),null),q(e,z(V,{get when(){return t.data.problems},get children(){var e=Xe();return e.firstChild,q(e,()=>String(t.data.problems),null),e}}),null),q(e,z(V,{get when(){return t.data.next},get children(){var e=Ze();return e.firstChild,q(e,()=>String(t.data.next),null),e}}),null),e})();case`error`:return(()=>{var e=$e(),n=e.firstChild;return n.firstChild,q(n,()=>String(t.data.message??``),null),e})();default:return(()=>{var e=et();return q(e,()=>$(JSON.stringify(t.data),200)),e})()}}function $(e,t){return e.length>t?e.slice(0,t)+` …`:e}function ht(e){return(()=>{var t=tt(),n=t.firstChild,r=n.firstChild.firstChild,i=r.nextSibling;return t.$$click=t=>t.target===t.currentTarget&&e.onClose(),q(r,()=>e.title),G(i,`click`,e.onClose,!0),q(n,()=>e.children,null),t})()}function gt(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 Q(`/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 Q(`/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 z(ht,{title:`new agent`,get onClose(){return e.onClose},get children(){var i=rt(),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(`..`),q(v,z(B,{get each(){return r()},children:e=>(()=>{var n=it();return n.firstChild,n.$$click=()=>p(`${t()}/${e}`.replace(/\/+/g,`/`)),q(n,e,null),n})()})),S.$$input=e=>o(e.currentTarget.value),w.addEventListener(`change`,e=>c(e.currentTarget.value)),q(w,z(B,{get each(){return e.providers},children:e=>(()=>{var t=at();return q(t,e),t})()})),T.$$input=e=>u(e.currentTarget.value),q(i,z(V,{get when(){return d()},get children(){var e=nt();return q(e,d),e}}),E),y(()=>h.value=t()),y(()=>S.value=a()),y(()=>w.value=s()),y(()=>T.value=l()),i}})}function _t(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 Q(`/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 z(ht,{title:`settings`,get onClose(){return e.onClose},get children(){var u=ot(),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),q(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),q(u,z(V,{get when(){return l()},get children(){var e=nt();return q(e,l),e}}),S),y(()=>m.value=t()),y(()=>_.value=r()),y(()=>v.value=a()),y(()=>x.value=s()),u}})}me([`click`,`input`]),pe(()=>z(ft,{}),document.getElementById(`root`));
|