aether-agent-framework 1.3.0__py3-none-any.whl
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.
- aether/__init__.py +9 -0
- aether/__main__.py +4 -0
- aether/agent.py +222 -0
- aether/cli.py +118 -0
- aether/config.py +98 -0
- aether/llm.py +227 -0
- aether/memory.py +45 -0
- aether/planner.py +31 -0
- aether/tools/__init__.py +101 -0
- aether/tools/base.py +72 -0
- aether/tools/data.py +199 -0
- aether/tools/delegate.py +163 -0
- aether/tools/files.py +150 -0
- aether/tools/knowledge.py +247 -0
- aether/tools/loader.py +85 -0
- aether/tools/net.py +141 -0
- aether/tools/productivity.py +250 -0
- aether/tools/python_exec.py +59 -0
- aether/tools/shell.py +121 -0
- aether/tools/web.py +113 -0
- aether/web/__init__.py +18 -0
- aether/web/__main__.py +62 -0
- aether/web/server.py +321 -0
- aether/web/static/index.html +470 -0
- aether_agent_framework-1.3.0.dist-info/METADATA +254 -0
- aether_agent_framework-1.3.0.dist-info/RECORD +30 -0
- aether_agent_framework-1.3.0.dist-info/WHEEL +5 -0
- aether_agent_framework-1.3.0.dist-info/entry_points.txt +3 -0
- aether_agent_framework-1.3.0.dist-info/licenses/LICENSE +21 -0
- aether_agent_framework-1.3.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>Aether — live agent dashboard</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
--bg: #0d1117; --bg2: #161b22; --bg3: #1c2230;
|
|
10
|
+
--border: #2d3646; --text: #dce3ec; --dim: #8b98a9;
|
|
11
|
+
--accent: #6ee7b7; --accent2: #38bdf8; --warn: #fbbf24; --err: #f87171;
|
|
12
|
+
--purple: #c084fc; --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
|
|
13
|
+
}
|
|
14
|
+
* { box-sizing: border-box; }
|
|
15
|
+
body {
|
|
16
|
+
margin: 0; background: var(--bg); color: var(--text);
|
|
17
|
+
font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
|
|
18
|
+
height: 100vh; display: flex; flex-direction: column; overflow: hidden;
|
|
19
|
+
}
|
|
20
|
+
header {
|
|
21
|
+
display: flex; align-items: center; gap: 10px; padding: 10px 16px;
|
|
22
|
+
background: var(--bg2); border-bottom: 1px solid var(--border); flex: 0 0 auto;
|
|
23
|
+
}
|
|
24
|
+
.logo { width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
|
|
25
|
+
box-shadow: 0 0 10px var(--accent); }
|
|
26
|
+
h1 { font-size: 16px; margin: 0; letter-spacing: .5px; }
|
|
27
|
+
.badge {
|
|
28
|
+
font: 11px var(--mono); color: var(--dim); background: var(--bg3);
|
|
29
|
+
border: 1px solid var(--border); border-radius: 20px; padding: 2px 10px;
|
|
30
|
+
white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px;
|
|
31
|
+
}
|
|
32
|
+
#status-pill {
|
|
33
|
+
margin-left: auto; font: 11px var(--mono); padding: 3px 12px; border-radius: 20px;
|
|
34
|
+
background: var(--bg3); border: 1px solid var(--border); color: var(--dim);
|
|
35
|
+
}
|
|
36
|
+
#status-pill.running { color: var(--accent2); border-color: var(--accent2);
|
|
37
|
+
animation: pulse 1.4s ease-in-out infinite; }
|
|
38
|
+
#status-pill.done { color: var(--accent); border-color: var(--accent); }
|
|
39
|
+
#status-pill.stopped { color: var(--warn); border-color: var(--warn); }
|
|
40
|
+
#status-pill.error { color: var(--err); border-color: var(--err); }
|
|
41
|
+
@keyframes pulse { 50% { opacity: .45; } }
|
|
42
|
+
|
|
43
|
+
.layout { display: flex; flex: 1 1 auto; min-height: 0; }
|
|
44
|
+
|
|
45
|
+
/* ---------------------------------------------------------- sidebar */
|
|
46
|
+
aside {
|
|
47
|
+
width: 250px; flex: 0 0 auto; background: var(--bg2);
|
|
48
|
+
border-right: 1px solid var(--border); display: flex; flex-direction: column;
|
|
49
|
+
min-height: 0;
|
|
50
|
+
}
|
|
51
|
+
.side-head {
|
|
52
|
+
font: 11px var(--mono); color: var(--dim); text-transform: uppercase;
|
|
53
|
+
letter-spacing: 1px; padding: 12px 14px 6px;
|
|
54
|
+
}
|
|
55
|
+
#history { overflow-y: auto; padding: 0 8px 8px; }
|
|
56
|
+
.hist-item {
|
|
57
|
+
padding: 8px 10px; border-radius: 8px; cursor: pointer; margin-bottom: 4px;
|
|
58
|
+
border: 1px solid transparent;
|
|
59
|
+
}
|
|
60
|
+
.hist-item:hover { background: var(--bg3); }
|
|
61
|
+
.hist-item.active { background: var(--bg3); border-color: var(--border); }
|
|
62
|
+
.hist-task { font-size: 12.5px; white-space: nowrap; overflow: hidden;
|
|
63
|
+
text-overflow: ellipsis; }
|
|
64
|
+
.hist-meta { font: 10px var(--mono); color: var(--dim); }
|
|
65
|
+
.hist-meta .st-done { color: var(--accent); } .hist-meta .st-running { color: var(--accent2); }
|
|
66
|
+
.hist-meta .st-stopped { color: var(--warn); } .hist-meta .st-error { color: var(--err); }
|
|
67
|
+
#tools { overflow-y: auto; padding: 0 14px 14px; flex: 1 1 auto;
|
|
68
|
+
border-top: 1px solid var(--border); }
|
|
69
|
+
.tool-item { font: 11px var(--mono); color: var(--dim); padding: 3px 0; }
|
|
70
|
+
.tool-item b { color: var(--text); font-weight: 600; }
|
|
71
|
+
|
|
72
|
+
/* ------------------------------------------------------------- feed */
|
|
73
|
+
main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
|
|
74
|
+
#feed { flex: 1 1 auto; overflow-y: auto; padding: 18px 22px; scroll-behavior: smooth; }
|
|
75
|
+
.empty { color: var(--dim); text-align: center; margin-top: 12vh; }
|
|
76
|
+
.empty h2 { color: var(--text); font-weight: 600; }
|
|
77
|
+
.empty code { background: var(--bg3); padding: 2px 7px; border-radius: 6px;
|
|
78
|
+
font-size: 12px; }
|
|
79
|
+
.card {
|
|
80
|
+
background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
|
|
81
|
+
padding: 10px 14px; margin-bottom: 10px; max-width: 860px;
|
|
82
|
+
}
|
|
83
|
+
.card .label {
|
|
84
|
+
font: 10px var(--mono); letter-spacing: 1.4px; color: var(--dim);
|
|
85
|
+
text-transform: uppercase; margin-bottom: 4px; display: flex; gap: 8px;
|
|
86
|
+
align-items: center;
|
|
87
|
+
}
|
|
88
|
+
.step-no { background: var(--bg3); border-radius: 10px; padding: 0 7px;
|
|
89
|
+
color: var(--accent2); }
|
|
90
|
+
.card.assistant { border-left: 3px solid var(--accent2); color: var(--dim); }
|
|
91
|
+
.card.plan { border-left: 3px solid var(--purple); }
|
|
92
|
+
.card.plan ol { margin: 4px 0 2px; padding-left: 22px; }
|
|
93
|
+
.card.plan li { margin: 2px 0; }
|
|
94
|
+
.card.tool { border-left: 3px solid var(--warn); font-family: var(--mono); }
|
|
95
|
+
.card.tool .tool-name { color: var(--warn); font-weight: 600; font-size: 13px; }
|
|
96
|
+
.card.tool.result-ok { border-left-color: var(--accent); }
|
|
97
|
+
.card.tool.result-ok .tool-name { color: var(--accent); }
|
|
98
|
+
.card.tool.result-err { border-left-color: var(--err); }
|
|
99
|
+
.card.tool.result-err .tool-name { color: var(--err); }
|
|
100
|
+
.card.task { background: #1a2332; border-color: #2b3a52; }
|
|
101
|
+
.card.result { border-left: 3px solid var(--accent); background: #11211b; }
|
|
102
|
+
.card.warning { border-left: 3px solid var(--warn); color: var(--warn);
|
|
103
|
+
font-size: 13px; }
|
|
104
|
+
.card.error { border-left: 3px solid var(--err); color: var(--err); }
|
|
105
|
+
.card.banner { text-align: center; color: var(--warn); background: transparent;
|
|
106
|
+
border: 1px dashed var(--warn); }
|
|
107
|
+
pre {
|
|
108
|
+
margin: 6px 0 0; padding: 8px 10px; background: var(--bg); border-radius: 8px;
|
|
109
|
+
font: 12px var(--mono); overflow-x: auto; white-space: pre-wrap;
|
|
110
|
+
word-break: break-word; color: var(--dim);
|
|
111
|
+
}
|
|
112
|
+
details { margin-top: 6px; }
|
|
113
|
+
summary { cursor: pointer; font: 11px var(--mono); color: var(--accent2);
|
|
114
|
+
user-select: none; }
|
|
115
|
+
.task-text { font-size: 14.5px; }
|
|
116
|
+
.result-text { white-space: pre-wrap; word-break: break-word; }
|
|
117
|
+
|
|
118
|
+
/* --------------------------------------------------------- composer */
|
|
119
|
+
#composer {
|
|
120
|
+
flex: 0 0 auto; border-top: 1px solid var(--border); background: var(--bg2);
|
|
121
|
+
padding: 12px 22px 14px;
|
|
122
|
+
}
|
|
123
|
+
.composer-row { display: flex; gap: 10px; align-items: flex-end; max-width: 860px; }
|
|
124
|
+
textarea {
|
|
125
|
+
flex: 1; resize: none; background: var(--bg3); color: var(--text);
|
|
126
|
+
border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
|
|
127
|
+
font: 14px/1.45 inherit; min-height: 46px; max-height: 160px; outline: none;
|
|
128
|
+
}
|
|
129
|
+
textarea:focus { border-color: var(--accent2); }
|
|
130
|
+
button {
|
|
131
|
+
background: var(--accent); color: #06281c; border: 0; border-radius: 10px;
|
|
132
|
+
padding: 11px 22px; font-weight: 700; font-size: 14px; cursor: pointer;
|
|
133
|
+
}
|
|
134
|
+
button:hover { filter: brightness(1.08); }
|
|
135
|
+
button:disabled { opacity: .45; cursor: not-allowed; }
|
|
136
|
+
#stop-btn { background: transparent; color: var(--err);
|
|
137
|
+
border: 1px solid var(--err); font-weight: 600; display: none; }
|
|
138
|
+
.opts { max-width: 860px; margin-top: 8px; }
|
|
139
|
+
.opts summary { color: var(--dim); font-size: 12px; }
|
|
140
|
+
.opt-grid {
|
|
141
|
+
display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
|
|
142
|
+
gap: 8px; margin-top: 8px;
|
|
143
|
+
}
|
|
144
|
+
.opt-grid label { font: 11px var(--mono); color: var(--dim); display: block;
|
|
145
|
+
margin-bottom: 3px; }
|
|
146
|
+
.opt-grid input, .opt-grid select {
|
|
147
|
+
width: 100%; background: var(--bg3); border: 1px solid var(--border);
|
|
148
|
+
color: var(--text); border-radius: 7px; padding: 6px 8px; font: 12px var(--mono);
|
|
149
|
+
outline: none;
|
|
150
|
+
}
|
|
151
|
+
.opt-grid input:focus, .opt-grid select:focus { border-color: var(--accent2); }
|
|
152
|
+
.hint { font: 11px var(--mono); color: var(--dim); margin-top: 7px; }
|
|
153
|
+
.hint b { color: var(--accent); }
|
|
154
|
+
|
|
155
|
+
/* token dialog */
|
|
156
|
+
#token-box { display: none; margin-left: 8px; }
|
|
157
|
+
#token-box input {
|
|
158
|
+
background: var(--bg3); border: 1px solid var(--border); color: var(--text);
|
|
159
|
+
border-radius: 7px; padding: 4px 8px; font: 12px var(--mono); width: 180px;
|
|
160
|
+
}
|
|
161
|
+
@media (max-width: 760px) { aside { display: none; } }
|
|
162
|
+
</style>
|
|
163
|
+
</head>
|
|
164
|
+
<body>
|
|
165
|
+
|
|
166
|
+
<header>
|
|
167
|
+
<div class="logo"></div>
|
|
168
|
+
<h1>Aether</h1>
|
|
169
|
+
<span class="badge" id="model-badge">connecting…</span>
|
|
170
|
+
<span class="badge" id="ws-badge"></span>
|
|
171
|
+
<div id="token-box"><input id="token-input" placeholder="access token"
|
|
172
|
+
type="password" autocomplete="off"></div>
|
|
173
|
+
<span id="status-pill">idle</span>
|
|
174
|
+
</header>
|
|
175
|
+
|
|
176
|
+
<div class="layout">
|
|
177
|
+
<aside>
|
|
178
|
+
<div class="side-head">Runs</div>
|
|
179
|
+
<div id="history"></div>
|
|
180
|
+
<div class="side-head">Tools (<span id="tool-count">?</span>)</div>
|
|
181
|
+
<div id="tools"></div>
|
|
182
|
+
</aside>
|
|
183
|
+
|
|
184
|
+
<main>
|
|
185
|
+
<div id="feed">
|
|
186
|
+
<div class="empty">
|
|
187
|
+
<h2>Give the agent a task</h2>
|
|
188
|
+
<p>It plans, calls tools, observes results and reports back —<br>
|
|
189
|
+
every step streams below as it happens.</p>
|
|
190
|
+
<p>Try: <code>write a haiku about recursion into poem.txt</code><br>
|
|
191
|
+
No API key? Pick provider <code>mock</code> for an offline demo.</p>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<div id="composer">
|
|
196
|
+
<div class="composer-row">
|
|
197
|
+
<textarea id="task" rows="2"
|
|
198
|
+
placeholder="Describe a task… (Enter to run, Shift+Enter for a new line)"></textarea>
|
|
199
|
+
<button id="run-btn" onclick="startRun()">Run</button>
|
|
200
|
+
<button id="stop-btn" onclick="stopRun()">Stop</button>
|
|
201
|
+
</div>
|
|
202
|
+
<details class="opts">
|
|
203
|
+
<summary>Model & runtime options</summary>
|
|
204
|
+
<div class="opt-grid">
|
|
205
|
+
<div><label>provider</label>
|
|
206
|
+
<select id="opt-provider">
|
|
207
|
+
<option value="">server default</option>
|
|
208
|
+
<option value="openai_compatible">openai_compatible</option>
|
|
209
|
+
<option value="ollama">ollama</option>
|
|
210
|
+
<option value="mock">mock (offline demo)</option>
|
|
211
|
+
</select></div>
|
|
212
|
+
<div><label>base_url</label>
|
|
213
|
+
<input id="opt-base-url" placeholder="server default"></div>
|
|
214
|
+
<div><label>model</label>
|
|
215
|
+
<input id="opt-model" placeholder="server default"></div>
|
|
216
|
+
<div><label>max_iterations</label>
|
|
217
|
+
<input id="opt-max-iter" type="number" min="1" max="200" placeholder="server default"></div>
|
|
218
|
+
</div>
|
|
219
|
+
<div class="hint">API keys are read from the server environment
|
|
220
|
+
(<b>AETHER_API_KEY</b>) — never typed in the browser.</div>
|
|
221
|
+
</details>
|
|
222
|
+
</div>
|
|
223
|
+
</main>
|
|
224
|
+
</div>
|
|
225
|
+
|
|
226
|
+
<script>
|
|
227
|
+
"use strict";
|
|
228
|
+
const $ = (id) => document.getElementById(id);
|
|
229
|
+
const feed = $("feed"), taskBox = $("task"), runBtn = $("run-btn"), stopBtn = $("stop-btn");
|
|
230
|
+
const pill = $("status-pill");
|
|
231
|
+
let currentES = null, currentRunId = null, activeRunId = null;
|
|
232
|
+
let pinned = true;
|
|
233
|
+
|
|
234
|
+
/* ------------------------------------------------------------ utilities */
|
|
235
|
+
function esc(s) {
|
|
236
|
+
return String(s ?? "").replace(/[&<>"']/g,
|
|
237
|
+
(c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]));
|
|
238
|
+
}
|
|
239
|
+
function headers() {
|
|
240
|
+
const h = { "Content-Type": "application/json" };
|
|
241
|
+
const t = token();
|
|
242
|
+
if (t) h["X-Aether-Token"] = t;
|
|
243
|
+
return h;
|
|
244
|
+
}
|
|
245
|
+
function token() { return localStorage.getItem("aether_token") || ""; }
|
|
246
|
+
function qs(extra) {
|
|
247
|
+
const t = token();
|
|
248
|
+
return (t ? "?token=" + encodeURIComponent(t) : "") + (extra || "");
|
|
249
|
+
}
|
|
250
|
+
function setPill(status) {
|
|
251
|
+
pill.className = status;
|
|
252
|
+
pill.textContent = status === "running" ? "running…" : status === "idle" ? "idle" : status;
|
|
253
|
+
}
|
|
254
|
+
function now() { return new Date().toLocaleTimeString(); }
|
|
255
|
+
|
|
256
|
+
feed.addEventListener("scroll", () => {
|
|
257
|
+
pinned = feed.scrollHeight - feed.scrollTop - feed.clientHeight < 90;
|
|
258
|
+
});
|
|
259
|
+
function autoScroll() { if (pinned) feed.scrollTop = feed.scrollHeight; }
|
|
260
|
+
|
|
261
|
+
function addCard(html, cls) {
|
|
262
|
+
document.querySelector(".empty")?.remove();
|
|
263
|
+
const div = document.createElement("div");
|
|
264
|
+
div.className = "card " + (cls || "");
|
|
265
|
+
div.innerHTML = html;
|
|
266
|
+
feed.appendChild(div);
|
|
267
|
+
autoScroll();
|
|
268
|
+
return div;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/* -------------------------------------------------------- event rendering */
|
|
272
|
+
function render(ev) {
|
|
273
|
+
switch (ev.type) {
|
|
274
|
+
case "run_start":
|
|
275
|
+
addCard(`<div class="label">task <span class="step-no">${now()}</span></div>
|
|
276
|
+
<div class="task-text">${esc(ev.task)}</div>`, "task");
|
|
277
|
+
setPill("running");
|
|
278
|
+
break;
|
|
279
|
+
case "plan":
|
|
280
|
+
addCard(`<div class="label">plan</div><ol>${ev.steps.map(s => `<li>${esc(s)}</li>`).join("")}</ol>`, "plan");
|
|
281
|
+
break;
|
|
282
|
+
case "assistant":
|
|
283
|
+
addCard(`<div class="label">thinking <span class="step-no">step ${ev.step}</span></div>
|
|
284
|
+
<div>${esc(ev.text)}</div>`, "assistant");
|
|
285
|
+
break;
|
|
286
|
+
case "tool_call": {
|
|
287
|
+
let args = "";
|
|
288
|
+
try { args = JSON.stringify(JSON.parse(ev.arguments), null, 2); }
|
|
289
|
+
catch { args = String(ev.arguments ?? ""); }
|
|
290
|
+
addCard(`<div class="label">tool call <span class="step-no">step ${ev.step}</span></div>
|
|
291
|
+
<span class="tool-name">${esc(ev.name)}</span>(…)
|
|
292
|
+
<details><summary>arguments</summary><pre>${esc(args)}</pre></details>`, "tool");
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
case "tool_result": {
|
|
296
|
+
const cls = ev.ok ? "tool result-ok" : "tool result-err";
|
|
297
|
+
const first = String(ev.result ?? "").split("\n")[0] || "(empty)";
|
|
298
|
+
addCard(`<div class="label">${ev.ok ? "result" : "error"} · ${esc(ev.name)}
|
|
299
|
+
<span class="step-no">step ${ev.step}</span></div>
|
|
300
|
+
<span class="tool-name">→</span> <span>${esc(first.slice(0, 200))}</span>
|
|
301
|
+
<details><summary>full output</summary><pre>${esc(ev.result)}</pre></details>`, cls);
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
case "loop_warning":
|
|
305
|
+
addCard(`<div class="label">warning</div>${esc(ev.text)}`, "warning");
|
|
306
|
+
break;
|
|
307
|
+
case "delegate_event": {
|
|
308
|
+
// A sub-agent (spawned via delegate_task) reported an event; show the
|
|
309
|
+
// most useful kinds inline, indented under the delegation.
|
|
310
|
+
const sub = ev.event || {};
|
|
311
|
+
const depth = ev.depth ?? 1;
|
|
312
|
+
if (sub.type === "assistant" && sub.text) {
|
|
313
|
+
addCard(`<div class="label">sub-agent · depth ${esc(depth)} <span class="step-no">step ${esc(sub.step ?? "")}</span></div>
|
|
314
|
+
<div>${esc(sub.text)}</div>`, "assistant");
|
|
315
|
+
} else if (sub.type === "tool_call" && sub.name) {
|
|
316
|
+
addCard(`<div class="label">sub-agent · depth ${esc(depth)}</div>
|
|
317
|
+
<span class="tool-name">${esc(sub.name)}</span>(…)`, "tool");
|
|
318
|
+
} else if (sub.type === "tool_result" && sub.name) {
|
|
319
|
+
const first = String(sub.result ?? "").split("\n")[0] || "(empty)";
|
|
320
|
+
addCard(`<div class="label">sub-agent · depth ${esc(depth)}</div>
|
|
321
|
+
<span class="tool-name">→</span> <span>${esc(first.slice(0, 200))}</span>`,
|
|
322
|
+
sub.ok ? "tool result-ok" : "tool result-err");
|
|
323
|
+
} else if (sub.type === "run_end") {
|
|
324
|
+
addCard(`<div class="label">sub-agent · depth ${esc(depth)} finished</div>
|
|
325
|
+
<div class="result-text">${esc(String(sub.result ?? "").slice(0, 400))}</div>`, "result");
|
|
326
|
+
}
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
case "run_error":
|
|
330
|
+
addCard(`<div class="label">error</div>${esc(ev.message)}`, "error");
|
|
331
|
+
break;
|
|
332
|
+
case "run_stopped":
|
|
333
|
+
addCard(`■ stopped by user`, "banner");
|
|
334
|
+
break;
|
|
335
|
+
case "run_end":
|
|
336
|
+
if (ev.result) addCard(`<div class="label">result</div>
|
|
337
|
+
<div class="result-text">${esc(ev.result)}</div>`, "result");
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/* ---------------------------------------------------------------- history */
|
|
343
|
+
async function loadHistory() {
|
|
344
|
+
try {
|
|
345
|
+
const r = await fetch("/api/runs" + qs(), { headers: headers() });
|
|
346
|
+
const data = await r.json();
|
|
347
|
+
const hist = $("history");
|
|
348
|
+
hist.innerHTML = "";
|
|
349
|
+
for (const run of data.runs || []) {
|
|
350
|
+
const div = document.createElement("div");
|
|
351
|
+
div.className = "hist-item" + (run.run_id === activeRunId ? " active" : "");
|
|
352
|
+
div.innerHTML = `<div class="hist-task">${esc(run.task)}</div>
|
|
353
|
+
<div class="hist-meta"><span class="st-${esc(run.status)}">${esc(run.status)}</span>
|
|
354
|
+
· ${new Date(run.created_at * 1000).toLocaleTimeString()}</div>`;
|
|
355
|
+
div.onclick = () => showRun(run.run_id);
|
|
356
|
+
hist.prepend(div);
|
|
357
|
+
}
|
|
358
|
+
} catch { /* server may be restarting */ }
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
async function showRun(runId) {
|
|
362
|
+
stopStream();
|
|
363
|
+
activeRunId = runId;
|
|
364
|
+
feed.innerHTML = "";
|
|
365
|
+
setPill("loading");
|
|
366
|
+
try {
|
|
367
|
+
const r = await fetch("/api/runs/" + runId + qs(), { headers: headers() });
|
|
368
|
+
const data = await r.json();
|
|
369
|
+
(data.events || []).forEach(render);
|
|
370
|
+
if (data.status === "running") { setPill("running"); attachStream(runId); }
|
|
371
|
+
else {
|
|
372
|
+
setPill(data.status);
|
|
373
|
+
if (data.error && !(data.events || []).some(e => e.type === "run_error"))
|
|
374
|
+
render({ type: "run_error", message: data.error });
|
|
375
|
+
}
|
|
376
|
+
} catch (e) { render({ type: "run_error", message: String(e) }); }
|
|
377
|
+
loadHistory();
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/* ------------------------------------------------------------------ stream */
|
|
381
|
+
function stopStream() { if (currentES) { currentES.close(); currentES = null; } }
|
|
382
|
+
|
|
383
|
+
function attachStream(runId) {
|
|
384
|
+
stopStream();
|
|
385
|
+
currentRunId = runId;
|
|
386
|
+
currentES = new EventSource("/api/stream/" + runId + qs());
|
|
387
|
+
currentES.onmessage = (m) => { try { render(JSON.parse(m.data)); } catch {} };
|
|
388
|
+
currentES.addEventListener("end", (e) => {
|
|
389
|
+
let status = "done";
|
|
390
|
+
try { status = JSON.parse(e.data).status || "done"; } catch {}
|
|
391
|
+
currentES.close(); currentES = null;
|
|
392
|
+
if (currentRunId === runId) setPill(status);
|
|
393
|
+
setRunning(false);
|
|
394
|
+
loadHistory();
|
|
395
|
+
});
|
|
396
|
+
currentES.onerror = () => { /* keep-alive gaps are normal; 'end' closes us */ };
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/* -------------------------------------------------------------- run / stop */
|
|
400
|
+
function setRunning(on) {
|
|
401
|
+
runBtn.disabled = on;
|
|
402
|
+
stopBtn.style.display = on ? "inline-block" : "none";
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
async function startRun() {
|
|
406
|
+
const task = taskBox.value.trim();
|
|
407
|
+
if (!task) { taskBox.focus(); return; }
|
|
408
|
+
const payload = { task };
|
|
409
|
+
for (const [key, id] of [["provider", "opt-provider"], ["base_url", "opt-base-url"],
|
|
410
|
+
["model", "opt-model"], ["max_iterations", "opt-max-iter"]])
|
|
411
|
+
if ($(id).value.trim() !== "") payload[key] = $(id).value.trim();
|
|
412
|
+
try {
|
|
413
|
+
const r = await fetch("/api/runs" + qs(), {
|
|
414
|
+
method: "POST", headers: headers(), body: JSON.stringify(payload),
|
|
415
|
+
});
|
|
416
|
+
const data = await r.json();
|
|
417
|
+
if (!r.ok) { render({ type: "run_error", message: data.error || r.status }); return; }
|
|
418
|
+
feed.innerHTML = "";
|
|
419
|
+
activeRunId = data.run_id;
|
|
420
|
+
setRunning(true);
|
|
421
|
+
setPill("running");
|
|
422
|
+
attachStream(data.run_id);
|
|
423
|
+
taskBox.value = "";
|
|
424
|
+
loadHistory();
|
|
425
|
+
} catch (e) { render({ type: "run_error", message: String(e) }); }
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
async function stopRun() {
|
|
429
|
+
if (!activeRunId) return;
|
|
430
|
+
await fetch("/api/runs/" + activeRunId + "/stop" + qs(),
|
|
431
|
+
{ method: "POST", headers: headers() });
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
taskBox.addEventListener("keydown", (e) => {
|
|
435
|
+
if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); startRun(); }
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
/* ------------------------------------------------------------------- init */
|
|
439
|
+
(async function init() {
|
|
440
|
+
try {
|
|
441
|
+
const r = await fetch("/api/health" + qs(), { headers: headers() });
|
|
442
|
+
if (r.status === 401) {
|
|
443
|
+
$("token-box").style.display = "block";
|
|
444
|
+
$("model-badge").textContent = "token required";
|
|
445
|
+
$("token-input").onchange = () => {
|
|
446
|
+
localStorage.setItem("aether_token", $("token-input").value.trim());
|
|
447
|
+
location.reload();
|
|
448
|
+
};
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
const h = await r.json();
|
|
452
|
+
$("model-badge").textContent = `${h.provider} · ${h.model}`;
|
|
453
|
+
$("ws-badge").textContent = `workspace: ${h.workspace}`;
|
|
454
|
+
setPill("idle");
|
|
455
|
+
} catch { $("model-badge").textContent = "server unreachable"; }
|
|
456
|
+
|
|
457
|
+
try {
|
|
458
|
+
const r = await fetch("/api/tools" + qs(), { headers: headers() });
|
|
459
|
+
const tools = await r.json();
|
|
460
|
+
$("tool-count").textContent = tools.length;
|
|
461
|
+
$("tools").innerHTML = tools
|
|
462
|
+
.map(t => `<div class="tool-item"><b>${esc(t.name)}</b> ${esc(t.description.slice(0, 48))}…</div>`)
|
|
463
|
+
.join("");
|
|
464
|
+
} catch { /* ignore */ }
|
|
465
|
+
|
|
466
|
+
loadHistory();
|
|
467
|
+
})();
|
|
468
|
+
</script>
|
|
469
|
+
</body>
|
|
470
|
+
</html>
|