teapot-coding-agent 0.1.0 → 0.1.1
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/dist/agent/agent.js +5 -2
- package/dist/agent/llm.js +31 -4
- package/dist/log/events.js +2 -2
- package/dist/master.js +2 -2
- package/package.json +4 -5
- package/public/assets/index-CFs1UF6R.js +9 -0
- package/public/assets/index-D2kic6g_.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/dist/agent/agent.js
CHANGED
|
@@ -362,7 +362,8 @@ export class Agent {
|
|
|
362
362
|
* already backsoff 429/5xx; this covers exhausted rate limits and 400s).
|
|
363
363
|
*/
|
|
364
364
|
async llmCall(messages, tools) {
|
|
365
|
-
const maxAttempts =
|
|
365
|
+
const maxAttempts = 4;
|
|
366
|
+
const waits = [30_000, 60_000, 120_000];
|
|
366
367
|
for (let attempt = 1;; attempt++) {
|
|
367
368
|
if (this.stopRequested)
|
|
368
369
|
throw Object.assign(new Error("stopped"), { name: "StopRequested" });
|
|
@@ -377,7 +378,7 @@ export class Agent {
|
|
|
377
378
|
throw err;
|
|
378
379
|
if (attempt >= maxAttempts)
|
|
379
380
|
throw err;
|
|
380
|
-
const waitMs = attempt
|
|
381
|
+
const waitMs = waits[Math.min(attempt - 1, waits.length - 1)];
|
|
381
382
|
await this.log.append("system_note", this.currentSession, this.currentBranch, {
|
|
382
383
|
event: "llm-retry",
|
|
383
384
|
attempt,
|
|
@@ -421,6 +422,7 @@ export class Agent {
|
|
|
421
422
|
role: "assistant",
|
|
422
423
|
content: m.content ?? "",
|
|
423
424
|
toolCalls: m.tool_calls?.map((c) => ({ id: c.id, name: c.function.name })),
|
|
425
|
+
reasoning: res.reasoning,
|
|
424
426
|
});
|
|
425
427
|
this.messages.push(m);
|
|
426
428
|
if (!m.tool_calls?.length)
|
|
@@ -511,6 +513,7 @@ export class Agent {
|
|
|
511
513
|
await this.log.append("message", this.currentSession, this.currentBranch, {
|
|
512
514
|
role: "assistant",
|
|
513
515
|
content: res.message.content ?? "",
|
|
516
|
+
reasoning: res.reasoning,
|
|
514
517
|
});
|
|
515
518
|
this.messages.push(res.message);
|
|
516
519
|
}
|
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,9 @@ 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)}`);
|
|
62
89
|
}
|
|
63
90
|
}
|
package/dist/log/events.js
CHANGED
|
@@ -17,13 +17,13 @@ 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
|
+
filePath;
|
|
26
|
+
agentId;
|
|
27
27
|
constructor(filePath, agentId) {
|
|
28
28
|
this.filePath = filePath;
|
|
29
29
|
this.agentId = agentId;
|
package/dist/master.js
CHANGED
|
@@ -66,11 +66,11 @@ export function loadedRaw() {
|
|
|
66
66
|
return masterRawConfig;
|
|
67
67
|
}
|
|
68
68
|
export class Master {
|
|
69
|
-
config;
|
|
70
|
-
configPath;
|
|
71
69
|
agents = new Map();
|
|
72
70
|
tasks = [];
|
|
73
71
|
startedAt = Date.now();
|
|
72
|
+
config;
|
|
73
|
+
configPath;
|
|
74
74
|
constructor(config, configPath) {
|
|
75
75
|
this.config = config;
|
|
76
76
|
this.configPath = configPath;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teapot-coding-agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
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=I,c=1,l=2,u={owned:null,cleanups:null,context:null,owner:null},d=null,f=null,p=null,m=null,h=null,g=0;function _(e,t){let n=p,r=d,i=e.length===0,a=t===void 0?r:t,o=i?u:{owned:null,cleanups:null,context:a?a.context:null,owner:a},s=i?e:()=>e(()=>S(()=>B(o)));d=o,p=null;try{return P(s,!0)}finally{p=n,d=r}}function v(e,t){t=t?Object.assign({},a,t):a;let n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0};return[O.bind(n),e=>(typeof e==`function`&&(e=f&&f.running&&f.sources.has(n)?e(n.tValue):e(n.value)),k(n,e))]}function y(e,t,n){A(M(e,t,!1,c))}function b(e,t,n){s=L;let r=M(e,t,!1,c),i=D&&ee(D);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),h?h.push(r):A(r)}function x(e,t,n){n=n?Object.assign({},a,n):a;let r=M(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,A(r),O.bind(r)}function S(e){if(p===null)return e();let t=p;p=null;try{return e()}finally{p=t}}function C(e){b(()=>S(e))}function w(e){return d===null||(d.cleanups===null?d.cleanups=[e]:d.cleanups.push(e)),e}var[T,E]=v(!1);function ee(e){let t;return d&&d.context&&(t=d.context[e.id])!==void 0?t:e.defaultValue}var D;function O(){let e=f&&f.running;if(this.sources&&(e?this.tState:this.state)){if((e?this.tState:this.state)===c)A(this);else{let e=m;m=null,P(()=>R(this),!1),m=e}}if(p){let e=this.observers;if(!e||e[e.length-1]!==p){let t=e?e.length:0;p.sources?(p.sources.push(this),p.sourceSlots.push(t)):(p.sources=[this],p.sourceSlots=[t]),e?(e.push(p),this.observerSlots.push(p.sources.length-1)):(this.observers=[p],this.observerSlots=[p.sources.length-1])}}return e&&f.sources.has(this)?this.tValue:this.value}function k(e,t,n){let r=f&&f.running&&f.sources.has(e)?e.tValue:e.value;if(!e.comparator||!e.comparator(r,t)){if(f){let r=f.running;(r||!n&&f.sources.has(e))&&(f.sources.add(e),e.tValue=t),r||(e.value=t)}else e.value=t;e.observers&&e.observers.length&&P(()=>{for(let t=0;t<e.observers.length;t+=1){let n=e.observers[t],r=f&&f.running;r&&f.disposed.has(n)||((r?!n.tState:!n.state)&&(n.pure?m.push(n):h.push(n),n.observers&&z(n)),r?n.tState=c:n.state=c)}if(m.length>1e6)throw m=[],Error()},!1)}return t}function A(e){if(!e.fn)return;B(e);let t=g;j(e,f&&f.running&&f.sources.has(e)?e.tValue:e.value,t),f&&!f.running&&f.sources.has(e)&&queueMicrotask(()=>{P(()=>{f&&(f.running=!0),p=d=e,j(e,e.tValue,t),p=d=null},!1)})}function j(e,t,n){let r,i=d,a=p;p=d=e;try{r=e.fn(t)}catch(t){return e.pure&&(f&&f.running?(e.tState=c,e.tOwned&&e.tOwned.forEach(B),e.tOwned=void 0):(e.state=c,e.owned&&e.owned.forEach(B),e.owned=null)),e.updatedAt=n+1,re(t)}finally{p=a,d=i}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&`observers`in e?k(e,r,!0):f&&f.running&&e.pure?(f.sources.has(e)||(e.value=r),f.sources.add(e),e.tValue=r):e.value=r,e.updatedAt=n)}function M(e,t,n,r=c,i){let a={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:d,context:d?d.context:null,pure:n};return f&&f.running&&(a.state=0,a.tState=r),d===null||d!==u&&(f&&f.running&&d.pure?d.tOwned?d.tOwned.push(a):d.tOwned=[a]:d.owned?d.owned.push(a):d.owned=[a]),a}function N(e){let t=f&&f.running;if((t?e.tState:e.state)===0)return;if((t?e.tState:e.state)===l)return R(e);if(e.suspense&&S(e.suspense.inFallback))return e.suspense.effects.push(e);let n=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<g);){if(t&&f.disposed.has(e))return;(t?e.tState:e.state)&&n.push(e)}for(let r=n.length-1;r>=0;r--){if(e=n[r],t){let t=e,i=n[r+1];for(;(t=t.owner)&&t!==i;)if(f.disposed.has(t))return}if((t?e.tState:e.state)===c)A(e);else if((t?e.tState:e.state)===l){let t=m;m=null,P(()=>R(e,n[0]),!1),m=t}}}function P(e,t){if(m)return e();let n=!1;t||(m=[]),h?n=!0:h=[],g++;try{let t=e();return F(n),t}catch(e){n||(h=null),m=null,re(e)}}function F(e){if(m&&=(I(m),null),e)return;let t;if(f){if(!f.promises.size&&!f.queue.size){let e=f.sources,n=f.disposed;h.push.apply(h,f.effects),t=f.resolve;for(let e of h)`tState`in e&&(e.state=e.tState),delete e.tState;f=null,P(()=>{for(let e of n)B(e);for(let t of e){if(t.value=t.tValue,t.owned)for(let e=0,n=t.owned.length;e<n;e++)B(t.owned[e]);t.tOwned&&(t.owned=t.tOwned),delete t.tValue,delete t.tOwned,t.tState=0}E(!1)},!1)}else if(f.running){f.running=!1,f.effects.push.apply(f.effects,h),h=null,E(!0);return}}let n=h;h=null,n.length&&P(()=>s(n),!1),t&&t()}function I(e){for(let t=0;t<e.length;t++)N(e[t])}function L(t){let r,i=0;for(r=0;r<t.length;r++){let e=t[r];e.user?t[i++]=e:N(e)}if(e.context){if(e.count){e.effects||=[],e.effects.push(...t.slice(0,i));return}n()}for(e.effects&&(e.done||!e.count)&&(t=[...e.effects,...t],i+=e.effects.length,delete e.effects),r=0;r<i;r++)N(t[r])}function R(e,t){let n=f&&f.running;n?e.tState=0:e.state=0;for(let r=0;r<e.sources.length;r+=1){let i=e.sources[r];if(i.sources){let e=n?i.tState:i.state;e===c?i!==t&&(!i.updatedAt||i.updatedAt<g)&&N(i):e===l&&R(i,t)}}}function z(e){let t=f&&f.running;for(let n=0;n<e.observers.length;n+=1){let r=e.observers[n];(t?!r.tState:!r.state)&&(t?r.tState=l:r.state=l,r.pure?m.push(r):h.push(r),r.observers&&z(r))}}function B(e){let t;if(e.sources)for(;e.sources.length;){let t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){let e=r.pop(),i=t.observerSlots.pop();n<r.length&&(e.sourceSlots[i]=n,r[n]=e,t.observerSlots[n]=i)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)B(e.tOwned[t]);delete e.tOwned}if(f&&f.running&&e.pure)V(e,!0);else if(e.owned){for(t=e.owned.length-1;t>=0;t--)B(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}f&&f.running?e.tState=0:e.state=0}function V(e,t){if(t||(e.tState=0,f.disposed.add(e)),e.owned)for(let t=0;t<e.owned.length;t++)V(e.owned[t])}function te(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`,{cause:e})}function ne(e,t,n){try{for(let n of t)n(e)}catch(e){re(e,n&&n.owner||null)}}function re(e,t=d){let n=o&&t&&t.context&&t.context[o],r=te(e);if(!n)throw r;h?h.push({fn(){ne(r,n,t)},state:c}):ne(r,n,t)}var ie=Symbol(`fallback`);function ae(e){for(let t=0;t<e.length;t++)e[t]()}function oe(e,t,n={}){let r=[],a=[],o=[],s=0,c=t.length>1?[]:null;return w(()=>ae(o)),()=>{let l=e()||[],u=l.length,d,f;return l[i],S(()=>{let e,t,i,m,h,g,v,y,b;if(u===0)s!==0&&(ae(o),o=[],r=[],a=[],s=0,c&&=[]),n.fallback&&(r=[ie],a[0]=_(e=>(o[0]=e,n.fallback())),s=1);else if(s===0){for(a=Array(u),f=0;f<u;f++)r[f]=l[f],a[f]=_(p);s=u}else{for(i=Array(u),m=Array(u),c&&(h=Array(u)),g=0,v=Math.min(s,u);g<v&&r[g]===l[g];g++);for(v=s-1,y=u-1;v>=g&&y>=g&&r[v]===l[y];v--,y--)i[y]=a[v],m[y]=o[v],c&&(h[y]=c[v]);for(e=new Map,t=Array(y+1),f=y;f>=g;f--)b=l[f],d=e.get(b),t[f]=d===void 0?-1:d,e.set(b,f);for(d=g;d<=v;d++)b=r[d],f=e.get(b),f!==void 0&&f!==-1?(i[f]=a[d],m[f]=o[d],c&&(h[f]=c[d]),f=t[f],e.set(b,f)):o[d]();for(f=g;f<u;f++)f in i?(a[f]=i[f],o[f]=m[f],c&&(c[f]=h[f],c[f](f))):a[f]=_(p);a=a.slice(0,s=u),r=l.slice(0)}return a});function p(e){if(o[f]=e,c){let[e,n]=v(f);return c[f]=n,t(l[f],e)}return t(l[f])}}}function H(e,t){return S(()=>e(t||{}))}var se=e=>`Stale read from <${e}>.`;function U(e){let t=`fallback`in e&&{fallback:()=>e.fallback};return x(oe(()=>e.each,e.children,t||void 0))}function W(e){let t=e.keyed,n=x(()=>e.when,void 0,void 0),r=t?n:x(n,void 0,{equals:(e,t)=>!e==!t});return x(()=>{let i=r();if(i){let a=e.children;return typeof a==`function`&&a.length>0?S(()=>a(t?i:()=>{if(!S(r))throw se(`Show`);return n()})):a}return e.fallback},void 0,void 0)}var G=e=>x(()=>e());function ce(e,t,n){let r=n.length,i=t.length,a=r,o=0,s=0,c=t[i-1].nextSibling,l=null;for(;o<i||s<a;){if(t[o]===n[s]){o++,s++;continue}for(;t[i-1]===n[a-1];)i--,a--;if(i===o){let t=a<r?s?n[s-1].nextSibling:n[a-s]:c;for(;s<a;)e.insertBefore(n[s++],t)}else if(a===s)for(;o<i;)(!l||!l.has(t[o]))&&t[o].remove(),o++;else if(t[o]===n[a-1]&&n[s]===t[i-1]){let r=t[--i].nextSibling;e.insertBefore(n[s++],t[o++].nextSibling),e.insertBefore(n[--a],r),t[i]=n[a]}else{if(!l){l=new Map;let e=s;for(;e<a;)l.set(n[e],e++)}let r=l.get(t[o]);if(r!=null){if(s<r&&r<a){let c=o,u=1,d;for(;++c<i&&c<a&&(d=l.get(t[c]))!=null&&d===r+u;)u++;if(u>r-s){let i=t[o];for(;s<r;)e.insertBefore(n[s++],i)}else e.replaceChild(n[s++],t[o++])}else o++}else t[o++].remove()}}}var le=`_$DX_DELEGATE`;function ue(e,t,n,r={}){let i;return _(r=>{i=r,t===document?e():X(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{i(),t.textContent=``}}function K(e,t,n,r){let i,a=()=>{let t=r?document.createElementNS(`http://www.w3.org/1998/Math/MathML`,`template`):document.createElement(`template`);return t.innerHTML=e,n?t.content.firstChild.firstChild:r?t.firstChild:t.content.firstChild},o=t?()=>S(()=>document.importNode(i||=a(),!0)):()=>(i||=a()).cloneNode(!0);return o.cloneNode=o,o}function de(e,t=window.document){let n=t[le]||(t[le]=new Set);for(let r=0,i=e.length;r<i;r++){let i=e[r];n.has(i)||(n.add(i),t.addEventListener(i,me))}}function fe(e,t,n){pe(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function q(e,t){pe(e)||(t==null?e.removeAttribute(`class`):e.className=t)}function J(e,t,n,r){if(r)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){let r=n[0];e.addEventListener(t,n[0]=t=>r.call(e,n[1],t))}else e.addEventListener(t,n,typeof n!=`function`&&n)}function Y(e,t,n){n==null?e.style.removeProperty(t):e.style.setProperty(t,n)}function X(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!=`function`)return Z(e,t,r,n);y(r=>Z(e,t(),r,n),r)}function pe(t){return!!e.context&&!e.done&&(!t||t.isConnected)}function me(t){if(e.registry&&e.events&&e.events.find(([e,n])=>n===t))return;let n=t.target,r=`$$${t.type}`,i=t.target,a=t.currentTarget,o=e=>Object.defineProperty(t,"target",{configurable:!0,value:e}),s=()=>{let e=n[r];if(e&&!n.disabled){let i=n[`${r}Data`];if(i===void 0?e.call(n,t):e.call(n,i,t),t.cancelBubble)return}return n.host&&typeof n.host!=`string`&&!n.host._$host&&n.contains(t.target)&&o(n.host),!0},c=()=>{for(;s()&&(n=n._$host||n.parentNode||n.host););};if(Object.defineProperty(t,"currentTarget",{configurable:!0,get(){return n||document}}),e.registry&&!e.done&&(e.done=_$HY.done=!0),t.composedPath){let e=t.composedPath();o(e[0]);for(let t=0;t<e.length-2&&(n=e[t],s());t++){if(n._$host){n=n._$host,c();break}if(n.parentNode===a)break}}else c();o(i)}function Z(e,t,n,r,i){let a=pe(e);if(a){!n&&(n=[...e.childNodes]);let t=[];for(let e=0;e<n.length;e++){let r=n[e];r.nodeType===8&&r.data.slice(0,2)===`!$`?r.remove():t.push(r)}n=t}for(;typeof n==`function`;)n=n();if(t===n)return n;let o=typeof t,s=r!==void 0;if(e=s&&n[0]&&n[0].parentNode||e,o===`string`||o===`number`){if(a||o===`number`&&(t=t.toString(),t===n))return n;if(s){let i=n[0];i&&i.nodeType===3?i.data!==t&&(i.data=t):i=document.createTextNode(t),n=Q(e,n,r,i)}else n=n!==``&&typeof n==`string`?e.firstChild.data=t:e.textContent=t}else if(t==null||o===`boolean`){if(a)return n;n=Q(e,n,r)}else if(o===`function`)return y(()=>{let i=t();for(;typeof i==`function`;)i=i();n=Z(e,i,n,r)}),()=>n;else if(Array.isArray(t)){let o=[],c=n&&Array.isArray(n);if(he(o,t,n,i))return y(()=>n=Z(e,o,n,r,!0)),()=>n;if(a){if(!o.length)return n;if(r===void 0)return n=[...e.childNodes];let t=o[0];if(t.parentNode!==e)return n;let i=[t];for(;(t=t.nextSibling)!==r;)i.push(t);return n=i}if(o.length===0){if(n=Q(e,n,r),s)return n}else c?n.length===0?ge(e,o,r):ce(e,n,o):(n&&Q(e),ge(e,o));n=o}else if(t.nodeType){if(a&&t.parentNode)return n=s?[t]:t;if(Array.isArray(n)){if(s)return n=Q(e,n,r,t);Q(e,n,null,t)}else n==null||n===``||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}return n}function he(e,t,n,r){let i=!1;for(let a=0,o=t.length;a<o;a++){let o=t[a],s=n&&n[e.length],c;if(o!=null&&o!==!0&&o!==!1){if((c=typeof o)==`object`&&o.nodeType)e.push(o);else if(Array.isArray(o))i=he(e,o,s)||i;else if(c===`function`){if(r){for(;typeof o==`function`;)o=o();i=he(e,Array.isArray(o)?o:[o],Array.isArray(s)?s:[s])||i}else e.push(o),i=!0}else{let t=String(o);s&&s.nodeType===3&&s.data===t?e.push(s):e.push(document.createTextNode(t))}}}return i}function ge(e,t,n=null){for(let r=0,i=t.length;r<i;r++)e.insertBefore(t[r],n)}function Q(e,t,n,r){if(n===void 0)return e.textContent=``;let i=r||document.createTextNode(``);if(t.length){let r=!1;for(let a=t.length-1;a>=0;a--){let o=t[a];if(i!==o){let t=o.parentNode===e;!r&&!a?t?e.replaceChild(i,o):e.insertBefore(i,n):t&&o.remove()}else r=!0}}else e.insertBefore(i,n);return[i]}function _e(e){let t=ve(e.replace(/\r\n/g,`
|
|
2
|
+
`)).split(`
|
|
3
|
+
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(/^```\w*\s*$/.test(e)){let e=[];for(r++;r<t.length&&!/^```\s*$/.test(t[r]);)e.push(t[r++]);r++,n.push(`<pre><code>${e.join(`
|
|
4
|
+
`)}</code></pre>`);continue}let a=e.match(/^(#{1,4})\s+(.*)$/);if(a){n.push(`<h${a[1].length}>${i(a[2])}</h${a[1].length}>`),r++;continue}let o=/^\s*\d+[.)]\s+/.test(e);if(o||/^\s*[-*]\s+/.test(e)){let e=[];for(;r<t.length;){let n=t[r].match(/^\s*[-*]\s+(.*)$/)??(o?t[r].match(/^\s*\d+[.)]\s+(.*)$/):null);if(!n)break;e.push(`<li>${i(n[1])}</li>`),r++}n.push(o?`<ol>${e.join(``)}</ol>`:`<ul>${e.join(``)}</ul>`);continue}if(/^\s*$/.test(e)){r++;continue}let s=[];for(;r<t.length&&!/^\s*$/.test(t[r])&&!/^#{1,4}\s/.test(t[r])&&!/^```/.test(t[r])&&!/^\s*([-*]|\d+[.)])\s/.test(t[r]);)s.push(t[r++]);n.push(`<p>${s.map(i).join(`<br>`)}</p>`)}return n.join(`
|
|
5
|
+
`);function i(e){return e.replace(/`([^`]+)`/g,`<code>$1</code>`).replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`).replace(/(^|\W)\*([^*]+)\*(?=\W|$)/g,`$1<em>$2</em>`).replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g,`<a href="$2" rel="noopener noreferrer" target="_blank">$1</a>`)}}function ve(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var ye=K(`<br>`),be=K(`<span class=sub>ℹ`),xe=K(`<header class=chan-head><span class=hash>#</span><span class=title></span><span></span><span class=sub> · <!>/<!> · turns <!> · tools </span><span style=margin-left:auto;display:flex;gap:4px><button class=iconbtn title="toggle details panel">▤`),Se=K(`<div class=feed>`),Ce=K(`<button class=jump>↓ `),we=K(`<div class=composer><form><input type=text><label><input type=checkbox>auto-start</label><button type=submit>send</button></form><div class=hint>enter to send · prompts are appended to the conversation and the agent keeps working toward its goal`),Te=K(`<h3>controls`),Ee=K(`<div class=btnrow><button>▶ start</button><button>■ stop</button><button>⑂ fork</button><button title="remove agent">🗑`),De=K(`<h3>goal <span>`),Oe=K(`<form style=display:flex;gap:4px;margin-bottom:6px><input id=goal-input type=text placeholder="set new goal…"style="flex:1;background:var(--bg-darkest);border:none;border-radius:6px;padding:6px 8px;color:var(--fg);font:inherit"><button type=submit style="background:var(--acc);border:none;border-radius:6px;color:#fff;padding:0 10px;cursor:pointer">✓`),ke=K(`<div class=card>`),Ae=K(`<h3>latest progress`),je=K(`<div class=card>
|
|
6
|
+
<!>
|
|
7
|
+
<span class=muted>`),Me=K(`<h3>branches`),Ne=K(`<h3>runtime`),Pe=K(`<div class="card muted">turns <!> · tools <!>
|
|
8
|
+
tokens in/out <!>/<!>
|
|
9
|
+
`),Fe=K(`<div class=layout><nav class=sidebar><h1>🫖 teapot<span style=float:right;display:flex;gap:4px><button class=iconbtn title="new agent">+</button><button class=iconbtn title=settings>⚙</button></span></h1><div class=agent-list></div><div class=metrics></div></nav><section class=channel></section><aside>`),Ie=K(`<span title="goal done">✓`),Le=K(`<div><span></span><span>`),Re=K(`<div class=muted style=display:grid;place-items:center;height:100%>select an agent`),ze=K(`<div class=muted style=display:grid;place-items:center;height:100%>no events yet — say something or press ▶ start`),Be=K(`<div class=muted>none yet`),Ve=K(`<div><span>`),He=K(`<div> → `),Ue=K(`<div class=avatar>`),We=K(`<div class=msg-head><span class=author></span><span class=ts></span><span class=ts>`),Ge=K(`<div><div class=msg-body>`),Ke=K(`<span style=width:38px>`),qe=K(`<div class=content>`),Je=K(`<details class=reasoning><summary>💭 reasoning</summary><div class=mono>`),Ye=K(`<details class=embed><summary><b>⚙ </b> <span class=meta></span></summary><div class=mono>`),Xe=K(`<details><summary><span class=meta></span></summary><div class=mono></div><div class=meta>ms`),Ze=K(`<div class=meta>`),Qe=K(`<div class=meta>⚠ `),$e=K(`<div class=meta>→ `),et=K(`<div class=embed style=border-color:var(--ok)><div>📈 `),tt=K(`<div class="embed fail"><div class=mono>⚠ `),nt=K(`<div class="content muted">`),rt=K(`<div class=overlay><div class=modal><div class=modal-head><b></b><button class=iconbtn>✕`),it=K(`<span style=color:var(--err);font-size:13px>`),at=K(`<form style=display:flex;flex-direction:column;gap:10px><label>workspace directory<div style=display:flex;gap:6px><input type=text class="w100 mono"><button type=button>go</button><button type=button>↑</button></div></label><div class=dirlist></div><div style=display:flex;gap:10px><label style=flex:1>agent name <input type=text placeholder="(directory name)"></label><label>provider<select></select></label><label style=flex:1>model <input type=text placeholder="(provider default)"></label></div><button type=submit style=align-self:flex-end>create & start`),ot=K(`<div class=direntry>📁 `),st=K(`<option>`),ct=K(`<form style=display:flex;flex-direction:column;gap:10px><label>providers (<!>)<textarea rows=8 class="mono w100"></textarea></label><div style=display:flex;gap:10px><label style=flex:1>default provider <input type=text></label><label>progress interval (min) <input type=number min=1 style=width:90px></label></div><label>scheduled tasks (JSON array)<textarea rows=7 class="mono w100"></textarea></label><button type=submit style=align-self:flex-end>save`),lt={user:{name:`you`,icon:`🧑`,color:`#faa81a`},message:{name:`agent`,icon:`🫖`,color:`#5865f2`},tool_call:{name:`tool`,icon:`🔧`,color:`#3ba0c9`},progress:{name:`progress`,icon:`📈`,color:`#3ba55d`}},ut=e=>lt[e.type]??{name:e.type,icon:`•`,color:`#9298a5`},dt=new Set([`user`,`message`,`prompt`,`tool_call`,`tool_result`,`progress`]),ft=e=>dt.has(e.type),pt=e=>{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`};async function $(e,t){let n=await fetch(e,t);if(!n.ok)throw Error(`${e}: ${n.status}`);return n.json()}function mt(){let[e,t]=v([]),[n,r]=v(null),[i,a]=v([]),[o,s]=v([]),[c,l]=v(null),[u,d]=v(``),[f,p]=v(!0),[m,h]=v({providers:{}}),[g,_]=v(!1),[b,S]=v(!1),[w,T]=v(!1),[E,ee]=v(!0),[D,O]=v(0),k=x(()=>i().filter(ft)),A=()=>$(`/api/config`).then(h).catch(()=>{}),j=x(()=>e().find(e=>e.id===n())),M=()=>$(`/api/agents`).then(e=>t(e.agents)).catch(()=>{}),N=()=>$(`/api/metrics`).then(l).catch(()=>{});async function P(e){try{let[t,n]=await Promise.all([$(`/api/agents/${e}/events?limit=300`),$(`/api/agents/${e}/branches`)]);a(t.events),s(n.branches)}catch{}}function F(){return document.querySelector(`.feed`)}function I(){let e=F();return!e||e.scrollHeight-e.scrollTop-e.clientHeight<80}function L(e=!1){let t=F();t&&(e||E())&&(t.scrollTop=t.scrollHeight,O(0))}async function R(e){r(e),await P(e),requestAnimationFrame(()=>L(!0))}C(()=>{A(),M().then(()=>e()[0]&&R(e()[0].id)),N();let t=null;new EventSource(`/api/events`).onmessage=e=>{JSON.parse(e.data),!t&&(t=setTimeout(async()=>{if(t=null,await M(),await N(),n()){let e=i().length;await P(n()),i().length!==e&&(I()?L(!0):O(D()+(i().length-e)))}},400))},setInterval(N,3e4)});let z=async e=>{if(e.preventDefault(),!n()||!u().trim())return;let t=u();d(``),await $(`/api/agents/${n()}/prompt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t,start:f()})})},B=e=>()=>n()&&$(`/api/agents/${n()}${e}`,{method:`POST`}).then(M),V=async e=>{e.preventDefault();let t=document.getElementById(`goal-input`);!n()||!t.value.trim()||(await $(`/api/agents/${n()}/goal`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t.value})}),t.value=``,M())};return[(()=>{var i=Fe(),a=i.firstChild,s=a.firstChild,l=s.firstChild.nextSibling.firstChild,m=l.nextSibling,h=s.nextSibling,g=h.nextSibling,v=a.nextSibling,b=v.nextSibling;return l.$$click=()=>{A(),_(!0)},m.$$click=()=>{A(),S(!0)},X(h,H(U,{get each(){return e()},children:e=>(()=>{var t=Le(),r=t.firstChild,i=r.nextSibling;return t.$$click=()=>R(e.id),X(i,()=>e.id),X(t,H(W,{get when(){return e.goal.status===`done`},get children(){return Ie()}}),null),y(i=>{var a=`agent-item`+(e.id===n()?` sel`:``),o=`dot ${e.status}`;return a!==i.e&&q(t,i.e=a),o!==i.t&&q(r,i.t=o),i},{e:void 0,t:void 0}),t})()})),X(g,H(W,{get when(){return c()},get children(){return[`master rss `,G(()=>c().rssMb),`MB · heap `,G(()=>c().heapUsedMb),`MB`,ye(),`load1 `,G(()=>c().loadavg1),` · up `,G(()=>Math.floor(c().uptimeSec/60)),`m`]}})),X(v,H(W,{get when(){return j()},get fallback(){return Re()},get children(){return[(()=>{var e=xe(),t=e.firstChild.nextSibling,n=t.nextSibling,r=n.nextSibling,i=r.firstChild,a=i.nextSibling,o=a.nextSibling.nextSibling,s=o.nextSibling.nextSibling;s.nextSibling;var c=r.nextSibling,l=c.firstChild;return X(t,()=>j().id),X(n,()=>j().status),X(r,()=>j().model,i),X(r,()=>j().session,a),X(r,()=>j().branch,o),X(r,()=>j().stats.turns,s),X(r,()=>j().stats.toolCalls,null),X(c,H(W,{get when(){return j().statusReason},get children(){var e=be();return y(()=>fe(e,`title`,j().statusReason)),e}}),l),l.$$click=()=>T(!w()),y(()=>q(n,`badge ${j().status}`)),e})(),(()=>{var e=Se();return e.addEventListener(`scroll`,()=>{let e=I();e&&D()&&O(0),ee(e)}),X(e,H(W,{get when(){return k().length>0},get fallback(){return ze()},get children(){return H(U,{get each(){return k()},children:(e,t)=>H(ht,{e,get prev(){return k()[t()-1]}})})}})),e})(),H(W,{get when(){return!E()||D()>0},get children(){var e=Ce();return e.firstChild,e.$$click=()=>L(!0),X(e,(()=>{var e=G(()=>D()>0);return()=>e()?`${D()} new message${D()>1?`s`:``}`:`jump to present`})(),null),e}}),(()=>{var e=we(),t=e.firstChild,n=t.firstChild,r=n.nextSibling.firstChild;return t.addEventListener(`submit`,z),n.$$input=e=>d(e.currentTarget.value),r.addEventListener(`change`,e=>p(e.currentTarget.checked)),y(()=>fe(n,`placeholder`,`message #${j().id}`)),y(()=>n.value=u()),y(()=>r.checked=f()),e})()]}})),X(b,H(W,{get when(){return j()},get children(){return[Te(),(()=>{var n=Ee(),i=n.firstChild,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling;return J(i,`click`,B(`/start`),!0),J(a,`click`,B(`/stop`),!0),o.$$click=()=>$(`/api/agents/${j().id}/fork`,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`}).then(()=>R(j().id)),s.$$click=async()=>{confirm(`remove agent ${j().id}? (log is kept)`)&&(await $(`/api/agents/${j().id}`,{method:`DELETE`}),r(null),t(e().filter(e=>e.id!==j().id)))},n})(),(()=>{var e=De(),t=e.firstChild.nextSibling;return X(t,()=>j().goal.status),y(()=>q(t,`badge ${j().goal.status===`done`?`done`:``}`)),e})(),(()=>{var e=Oe();return e.addEventListener(`submit`,V),e})(),(()=>{var e=ke();return X(e,()=>j().goal.text||`no goal set`),e})(),Ae(),H(W,{get when(){return j().latestProgress},get fallback(){return Be()},get children(){var e=je(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling.nextSibling;return X(e,()=>j().latestProgress.doing,t),X(e,()=>j().latestProgress.recent??``,n),X(r,()=>j().latestProgress.ts),e}}),Me(),H(U,{get each(){return o()},children:e=>(()=>{var t=Ve(),n=t.firstChild;return X(t,()=>e.branch,n),X(n,()=>e.events),y(()=>q(t,`branch-row`+(e.branch===j().branch?` cur`:``))),t})()}),Ne(),(()=>{var e=Pe(),t=e.firstChild.nextSibling,n=t.nextSibling.nextSibling,r=n.nextSibling.nextSibling,i=r.nextSibling.nextSibling;return i.nextSibling,X(e,()=>j().stats.turns,t),X(e,()=>j().stats.toolCalls,n),X(e,()=>j().stats.inputTokens,r),X(e,()=>j().stats.outputTokens,i),X(e,()=>j().workspace,null),e})()]}})),y(()=>q(b,`rightbar`+(w()?` open`:``))),i})(),H(W,{get when(){return g()},get children(){return H(bt,{get providers(){return Object.keys(m().providers??{})},onClose:()=>_(!1),onCreated:e=>{_(!1),M(),R(e)}})}}),H(W,{get when(){return b()},get children(){return H(xt,{get cfg(){return m()},onClose:()=>S(!1),onSaved:A})}})]}function ht(e){let t=e.e,n=ut(t),r=e.prev&&e.prev.type===t.type&&t.session===e.prev.session&&t.branch===e.prev.branch;return t.type===`state`?t.data.from===t.data.to?null:(()=>{var e=He(),n=e.firstChild;return X(e,()=>t.data.from,n),X(e,()=>t.data.to,null),X(e,(()=>{var e=G(()=>!!t.data.reason);return()=>e()?` — ${t.data.reason}`:``})(),null),y(()=>q(e,`divider-msg`+(t.data.to===`error`?` err`:``))),e})():(()=>{var e=Ge(),i=e.firstChild;return q(e,`msg`+(r?` grouped`:``)),X(e,H(W,{when:!r,get fallback(){return Ke()},get children(){var e=Ue();return X(e,()=>n.icon),y(t=>{var r=n.color+`33`,i=`1px solid ${n.color}66`;return r!==t.e&&Y(e,`background`,t.e=r),i!==t.t&&Y(e,`border`,t.t=i),t},{e:void 0,t:void 0}),e}}),i),X(i,H(W,{when:!r,get children(){var e=We(),r=e.firstChild,i=r.nextSibling,a=i.nextSibling;return X(r,()=>n.name),X(i,()=>pt(t.ts)),X(a,()=>t.branch),y(e=>Y(r,`color`,n.color)),e}}),null),X(i,H(gt,{e:t}),null),e})()}function gt(e){let t=e.e;switch(t.type){case`prompt`:return(()=>{var e=qe();return y(()=>e.innerHTML=_e(String(t.data.text??``))),e})();case`message`:return[H(W,{get when(){return G(()=>typeof t.data.reasoning==`string`)()&&t.data.reasoning.trim()},get children(){var e=Je(),n=e.firstChild.nextSibling;return X(n,()=>String(t.data.reasoning)),e}}),(()=>{var e=qe();return y(()=>e.innerHTML=_e(String(t.data.content??``))),e})()];case`tool_call`:{let e=JSON.stringify(t.data.args,null,1),n=vt(JSON.stringify(t.data.args??{}),110);return(()=>{var r=Ye(),i=r.firstChild,a=i.firstChild;a.firstChild;var o=a.nextSibling.nextSibling,s=i.nextSibling;return X(a,()=>String(t.data.name),null),X(o,n),X(s,e),r})()}case`tool_result`:{let e=String(t.data.result);return(()=>{var n=Xe(),r=n.firstChild,i=r.firstChild,a=r.nextSibling,o=a.nextSibling,s=o.firstChild;return X(i,()=>vt(e,120)),X(a,()=>_t(e,4e3)),X(o,()=>t.data.durationMs,s),X(o,()=>t.data.ok?``:` · FAILED`,null),y(()=>q(n,`embed`+(t.data.ok?``:` fail`))),n})()}case`progress`:return(()=>{var e=et(),n=e.firstChild;return n.firstChild,X(n,()=>String(t.data.doing??``),null),X(e,H(W,{get when(){return t.data.recent},get children(){var e=Ze();return X(e,()=>String(t.data.recent)),e}}),null),X(e,H(W,{get when(){return t.data.problems},get children(){var e=Qe();return e.firstChild,X(e,()=>String(t.data.problems),null),e}}),null),X(e,H(W,{get when(){return t.data.next},get children(){var e=$e();return e.firstChild,X(e,()=>String(t.data.next),null),e}}),null),e})();case`error`:return(()=>{var e=tt(),n=e.firstChild;return n.firstChild,X(n,()=>String(t.data.message??``),null),e})();default:return(()=>{var e=nt();return X(e,()=>_t(JSON.stringify(t.data),200)),e})()}}function _t(e,t){return e.length>t?e.slice(0,t)+` …`:e}function vt(e,t){return _t(e.replace(/\s+/g,` `).trim(),t)}function yt(e){return(()=>{var t=rt(),n=t.firstChild,r=n.firstChild.firstChild,i=r.nextSibling;return t.$$click=t=>t.target===t.currentTarget&&e.onClose(),X(r,()=>e.title),J(i,`click`,e.onClose,!0),X(n,()=>e.children,null),t})()}function bt(e){let[t,n]=v(`~`),[r,i]=v([]),[a,o]=v(``),[s,c]=v(e.providers[0]??``),[l,u]=v(``),[d,f]=v(``);async function p(e){let t=await $(`/api/fs${e?`?path=${encodeURIComponent(e)}`:``}`);n(t.path),i(t.entries)}C(()=>p(t()));let m=async n=>{n.preventDefault(),f(``);try{let n=await $(`/api/agents`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({workspace:t(),id:a(),provider:s()||void 0,model:l()||void 0})});e.onCreated(n.agent.id)}catch(e){f(String(e.message))}};return H(yt,{title:`new agent`,get onClose(){return e.onClose},get children(){var i=at(),f=i.firstChild,h=f.firstChild.nextSibling.firstChild,g=h.nextSibling,_=g.nextSibling,v=f.nextSibling,b=v.nextSibling,x=b.firstChild,S=x.firstChild.nextSibling,C=x.nextSibling,w=C.firstChild.nextSibling,T=C.nextSibling.firstChild.nextSibling,E=b.nextSibling;return i.addEventListener(`submit`,m),h.$$input=e=>n(e.currentTarget.value),g.$$click=()=>p(t()),_.$$click=()=>p(`..`),X(v,H(U,{get each(){return r()},children:e=>(()=>{var n=ot();return n.firstChild,n.$$click=()=>p(`${t()}/${e}`.replace(/\/+/g,`/`)),X(n,e,null),n})()})),S.$$input=e=>o(e.currentTarget.value),w.addEventListener(`change`,e=>c(e.currentTarget.value)),X(w,H(U,{get each(){return e.providers},children:e=>(()=>{var t=st();return X(t,e),t})()})),T.$$input=e=>u(e.currentTarget.value),X(i,H(W,{get when(){return d()},get children(){var e=it();return X(e,d),e}}),E),y(()=>h.value=t()),y(()=>S.value=a()),y(()=>w.value=s()),y(()=>T.value=l()),i}})}function xt(e){let[t,n]=v(JSON.stringify(Object.fromEntries(Object.entries(e.cfg.providers??{}).map(([e,t])=>[e,{baseUrl:t.baseUrl,apiKey:t.apiKey??``,model:t.model??``}])),null,2)),[r,i]=v(e.cfg.defaultProvider??Object.keys(e.cfg.providers??{})[0]??``),[a,o]=v(Math.round((e.cfg.progressIntervalMs??6e5)/6e4)),[s,c]=v(JSON.stringify(e.cfg.tasks??[],null,2)),[l,u]=v(``),d=async n=>{n.preventDefault(),u(``);let i,o;try{i=JSON.parse(t())}catch{return u(`providers: invalid JSON`)}try{o=JSON.parse(s())}catch{return u(`tasks: invalid JSON`)}try{await $(`/api/config`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({providers:i,defaultProvider:r(),progressIntervalMs:Math.max(1,a())*6e4,tasks:o})}),e.onSaved(),e.onClose()}catch(e){u(String(e.message))}};return H(yt,{title:`settings`,get onClose(){return e.onClose},get children(){var u=ct(),f=u.firstChild,p=f.firstChild.nextSibling,m=p.nextSibling.nextSibling,h=f.nextSibling,g=h.firstChild,_=g.firstChild.nextSibling,v=g.nextSibling.firstChild.nextSibling,b=h.nextSibling,x=b.firstChild.nextSibling,S=b.nextSibling;return u.addEventListener(`submit`,d),X(f,()=>e.cfg.configPath,p),m.$$input=e=>n(e.currentTarget.value),_.$$input=e=>i(e.currentTarget.value),v.$$input=e=>o(Number(e.currentTarget.value)),x.$$input=e=>c(e.currentTarget.value),X(u,H(W,{get when(){return l()},get children(){var e=it();return X(e,l),e}}),S),y(()=>m.value=t()),y(()=>_.value=r()),y(()=>v.value=a()),y(()=>x.value=s()),u}})}de([`click`,`input`]),ue(()=>H(mt,{}),document.getElementById(`root`));
|
|
@@ -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}.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-CFs1UF6R.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="/assets/index-D2kic6g_.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`));
|