@stackbilt/aegis-core 0.6.5 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/aegis.mjs +356 -0
- package/package.json +21 -3
- package/public/assets/index-CQHn03rW.css +1 -0
- package/public/assets/index-CTKpNJEr.js +74 -0
- package/public/index.html +14 -0
- package/schema.sql +4 -0
- package/src/adapters/voice/cloudflare-agent.ts +0 -0
- package/src/agent-routing.ts +38 -0
- package/src/assets.ts +6 -0
- package/src/auth.ts +14 -5
- package/src/bluesky.ts +0 -0
- package/src/claude-tools/content.ts +0 -0
- package/src/claude-tools/email.ts +0 -0
- package/src/claude.ts +133 -268
- package/src/codebeast.ts +0 -0
- package/src/composite.ts +49 -79
- package/src/content/column.ts +0 -0
- package/src/content/hero-image.ts +0 -0
- package/src/content/index.ts +0 -0
- package/src/content/journal.ts +0 -0
- package/src/content/roundtable.ts +0 -0
- package/src/contracts/agenda-item.contract.ts +0 -0
- package/src/contracts/cc-task.contract.ts +0 -0
- package/src/contracts/goal.contract.ts +0 -0
- package/src/contracts/memory-entry.contract.ts +0 -0
- package/src/core.ts +5 -0
- package/src/dashboard.ts +0 -0
- package/src/decision-docs.ts +0 -0
- package/src/dispatch.ts +0 -0
- package/src/durable-objects/chat-session-auth.ts +20 -0
- package/src/durable-objects/chat-session.ts +251 -0
- package/src/edge-env.ts +0 -0
- package/src/exports.ts +0 -0
- package/src/github-projects.ts +0 -0
- package/src/groq.ts +61 -113
- package/src/index.ts +11 -1
- package/src/kernel/argus-actions.ts +0 -0
- package/src/kernel/argus-correlation.ts +0 -0
- package/src/kernel/board.ts +0 -0
- package/src/kernel/classify-memory-topic.ts +0 -0
- package/src/kernel/disambiguation.ts +55 -0
- package/src/kernel/dispatch.ts +59 -44
- package/src/kernel/dynamic-tools.ts +30 -52
- package/src/kernel/executor-port.ts +0 -0
- package/src/kernel/executor-router.ts +0 -0
- package/src/kernel/executors/claude.ts +1 -0
- package/src/kernel/executors/direct.ts +14 -0
- package/src/kernel/executors/workers-ai.ts +5 -0
- package/src/kernel/grounding/fabrication-detector.ts +0 -0
- package/src/kernel/grounding/fanout.ts +0 -0
- package/src/kernel/grounding/semantic-sanhedrin.ts +0 -0
- package/src/kernel/grounding/verify.ts +0 -0
- package/src/kernel/grounding-layer.ts +0 -0
- package/src/kernel/insight-cache.ts +0 -0
- package/src/kernel/memory/episodic.ts +3 -1
- package/src/kernel/memory/insights.ts +0 -0
- package/src/kernel/memory-guardrails.ts +0 -0
- package/src/kernel/memory-service.ts +0 -0
- package/src/kernel/patterns.ts +0 -0
- package/src/kernel/port.ts +0 -0
- package/src/kernel/provider-factory.ts +0 -0
- package/src/kernel/resilience.ts +0 -0
- package/src/kernel/router.ts +33 -11
- package/src/kernel/scheduled/agent-dispatch.ts +0 -0
- package/src/kernel/scheduled/argus-analytics.ts +0 -0
- package/src/kernel/scheduled/argus-heartbeat.ts +0 -0
- package/src/kernel/scheduled/argus-notify.ts +0 -0
- package/src/kernel/scheduled/board-sync.ts +0 -0
- package/src/kernel/scheduled/ci-watcher.ts +0 -0
- package/src/kernel/scheduled/content-drip.ts +0 -0
- package/src/kernel/scheduled/content.ts +0 -0
- package/src/kernel/scheduled/conversation-facts.ts +9 -7
- package/src/kernel/scheduled/cost-report.ts +0 -0
- package/src/kernel/scheduled/dev-activity.ts +0 -0
- package/src/kernel/scheduled/digest.ts +30 -3
- package/src/kernel/scheduled/dreaming/agenda-triage.ts +0 -0
- package/src/kernel/scheduled/dreaming/facts.ts +0 -0
- package/src/kernel/scheduled/dreaming/index.ts +0 -0
- package/src/kernel/scheduled/dreaming/llm.ts +9 -5
- package/src/kernel/scheduled/dreaming/pattern-synthesis.ts +0 -0
- package/src/kernel/scheduled/dreaming/persona.ts +0 -0
- package/src/kernel/scheduled/dreaming/symbolic.ts +0 -0
- package/src/kernel/scheduled/dreaming/task-proposals.ts +0 -0
- package/src/kernel/scheduled/entropy.ts +0 -0
- package/src/kernel/scheduled/feed-watcher.ts +0 -0
- package/src/kernel/scheduled/inbox-processor.ts +0 -0
- package/src/kernel/scheduled/issue-proposer.ts +0 -0
- package/src/kernel/scheduled/issue-watcher.ts +0 -0
- package/src/kernel/scheduled/pr-automerge.ts +0 -0
- package/src/kernel/scheduled/product-health.ts +0 -0
- package/src/kernel/scheduled/self-improvement.ts +0 -0
- package/src/kernel/scheduled/social-engage.ts +12 -8
- package/src/kernel/scheduled/task-audit.ts +0 -0
- package/src/kernel/types.ts +6 -0
- package/src/landing.ts +0 -0
- package/src/lib/audit-chain/chain.ts +0 -0
- package/src/lib/audit-chain/types.ts +0 -0
- package/src/lib/observability/errors.ts +0 -0
- package/src/operator/config.ts +0 -0
- package/src/operator/persona.ts +0 -0
- package/src/operator/prompt-builder.ts +3 -0
- package/src/pulse.ts +0 -0
- package/src/routes/bluesky.ts +0 -0
- package/src/routes/chat-ws.ts +17 -0
- package/src/routes/codebeast.ts +0 -0
- package/src/routes/content.ts +0 -0
- package/src/routes/dynamic-tools.ts +0 -0
- package/src/routes/messages.ts +11 -6
- package/src/routes/observability.ts +0 -0
- package/src/routes/operator-logs.ts +0 -0
- package/src/routes/pages.ts +12 -1
- package/src/schema-enums.ts +0 -0
- package/src/task-intelligence.ts +0 -0
- package/src/types.ts +8 -0
- package/src/ui/index.html +13 -0
- package/src/ui/main.tsx +356 -0
- package/src/ui/styles.css +391 -0
- package/src/ui.ts +594 -2
- package/src/version.ts +3 -3
- package/src/wiki/client.ts +0 -0
- package/src/wiki/types.ts +0 -0
package/src/ui.ts
CHANGED
|
@@ -1,5 +1,597 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Standalone chat shell for self-sufficient AEGIS deployments.
|
|
2
2
|
|
|
3
3
|
export function chatPage(): string {
|
|
4
|
-
return
|
|
4
|
+
return `<!DOCTYPE html>
|
|
5
|
+
<html lang="en">
|
|
6
|
+
<head>
|
|
7
|
+
<meta charset="utf-8">
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
9
|
+
<title>AEGIS</title>
|
|
10
|
+
<meta name="theme-color" content="#10100d">
|
|
11
|
+
<link rel="manifest" href="/manifest.json">
|
|
12
|
+
<style>
|
|
13
|
+
:root {
|
|
14
|
+
--bg: #10100d;
|
|
15
|
+
--panel: #171813;
|
|
16
|
+
--panel-2: #202217;
|
|
17
|
+
--line: #35382a;
|
|
18
|
+
--text: #f3f0e6;
|
|
19
|
+
--muted: #aaa38f;
|
|
20
|
+
--dim: #76705f;
|
|
21
|
+
--accent: #42d6a4;
|
|
22
|
+
--accent-2: #f5c542;
|
|
23
|
+
--danger: #ff6b6b;
|
|
24
|
+
--shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
|
|
25
|
+
color-scheme: dark;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
* { box-sizing: border-box; }
|
|
29
|
+
|
|
30
|
+
html, body {
|
|
31
|
+
margin: 0;
|
|
32
|
+
min-height: 100%;
|
|
33
|
+
background:
|
|
34
|
+
linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px) 0 0 / 56px 56px,
|
|
35
|
+
linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px) 0 0 / 56px 56px,
|
|
36
|
+
var(--bg);
|
|
37
|
+
color: var(--text);
|
|
38
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
body {
|
|
42
|
+
min-height: 100vh;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
button, input, textarea {
|
|
47
|
+
font: inherit;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.shell {
|
|
51
|
+
display: grid;
|
|
52
|
+
grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
|
|
53
|
+
height: 100vh;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.rail {
|
|
57
|
+
min-width: 0;
|
|
58
|
+
border-right: 1px solid var(--line);
|
|
59
|
+
background: rgba(16, 16, 13, 0.86);
|
|
60
|
+
backdrop-filter: blur(12px);
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-direction: column;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.brand {
|
|
66
|
+
padding: 22px;
|
|
67
|
+
border-bottom: 1px solid var(--line);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.mark {
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: space-between;
|
|
74
|
+
gap: 14px;
|
|
75
|
+
margin-bottom: 18px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.wordmark {
|
|
79
|
+
font-size: 18px;
|
|
80
|
+
letter-spacing: 0.18em;
|
|
81
|
+
font-weight: 800;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.status {
|
|
85
|
+
width: 10px;
|
|
86
|
+
height: 10px;
|
|
87
|
+
border-radius: 999px;
|
|
88
|
+
background: var(--danger);
|
|
89
|
+
box-shadow: 0 0 18px rgba(255, 107, 107, 0.7);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.status.ready {
|
|
93
|
+
background: var(--accent);
|
|
94
|
+
box-shadow: 0 0 18px rgba(66, 214, 164, 0.7);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.token-row {
|
|
98
|
+
display: grid;
|
|
99
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
100
|
+
gap: 8px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
input, textarea {
|
|
104
|
+
width: 100%;
|
|
105
|
+
border: 1px solid var(--line);
|
|
106
|
+
background: #0b0c09;
|
|
107
|
+
color: var(--text);
|
|
108
|
+
outline: none;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
input {
|
|
112
|
+
height: 38px;
|
|
113
|
+
padding: 0 11px;
|
|
114
|
+
border-radius: 6px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
input:focus, textarea:focus {
|
|
118
|
+
border-color: rgba(66, 214, 164, 0.72);
|
|
119
|
+
box-shadow: 0 0 0 3px rgba(66, 214, 164, 0.12);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
button {
|
|
123
|
+
height: 38px;
|
|
124
|
+
border: 1px solid var(--line);
|
|
125
|
+
background: var(--panel-2);
|
|
126
|
+
color: var(--text);
|
|
127
|
+
border-radius: 6px;
|
|
128
|
+
cursor: pointer;
|
|
129
|
+
padding: 0 12px;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
button:hover { border-color: rgba(66, 214, 164, 0.5); }
|
|
133
|
+
button:disabled { opacity: 0.55; cursor: wait; }
|
|
134
|
+
|
|
135
|
+
.primary {
|
|
136
|
+
background: var(--accent);
|
|
137
|
+
border-color: var(--accent);
|
|
138
|
+
color: #06100c;
|
|
139
|
+
font-weight: 800;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.conversations {
|
|
143
|
+
flex: 1;
|
|
144
|
+
min-height: 0;
|
|
145
|
+
overflow: auto;
|
|
146
|
+
padding: 10px;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.conversation {
|
|
150
|
+
width: 100%;
|
|
151
|
+
height: auto;
|
|
152
|
+
min-height: 44px;
|
|
153
|
+
text-align: left;
|
|
154
|
+
display: block;
|
|
155
|
+
margin: 0 0 6px;
|
|
156
|
+
padding: 9px 10px;
|
|
157
|
+
color: var(--muted);
|
|
158
|
+
background: transparent;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.conversation.active {
|
|
162
|
+
color: var(--text);
|
|
163
|
+
background: rgba(66, 214, 164, 0.08);
|
|
164
|
+
border-color: rgba(66, 214, 164, 0.4);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.conversation-title {
|
|
168
|
+
display: block;
|
|
169
|
+
overflow: hidden;
|
|
170
|
+
text-overflow: ellipsis;
|
|
171
|
+
white-space: nowrap;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.conversation-time {
|
|
175
|
+
display: block;
|
|
176
|
+
margin-top: 4px;
|
|
177
|
+
color: var(--dim);
|
|
178
|
+
font-size: 11px;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.workspace {
|
|
182
|
+
min-width: 0;
|
|
183
|
+
display: grid;
|
|
184
|
+
grid-template-rows: auto minmax(0, 1fr) auto;
|
|
185
|
+
height: 100vh;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.topbar {
|
|
189
|
+
height: 64px;
|
|
190
|
+
border-bottom: 1px solid var(--line);
|
|
191
|
+
display: flex;
|
|
192
|
+
align-items: center;
|
|
193
|
+
justify-content: space-between;
|
|
194
|
+
gap: 16px;
|
|
195
|
+
padding: 0 24px;
|
|
196
|
+
background: rgba(23, 24, 19, 0.88);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.title {
|
|
200
|
+
min-width: 0;
|
|
201
|
+
overflow: hidden;
|
|
202
|
+
text-overflow: ellipsis;
|
|
203
|
+
white-space: nowrap;
|
|
204
|
+
color: var(--muted);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.title strong {
|
|
208
|
+
color: var(--text);
|
|
209
|
+
font-weight: 800;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.messages {
|
|
213
|
+
min-height: 0;
|
|
214
|
+
overflow: auto;
|
|
215
|
+
padding: 28px;
|
|
216
|
+
display: flex;
|
|
217
|
+
flex-direction: column;
|
|
218
|
+
gap: 14px;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.empty {
|
|
222
|
+
margin: auto;
|
|
223
|
+
max-width: 620px;
|
|
224
|
+
color: var(--muted);
|
|
225
|
+
line-height: 1.7;
|
|
226
|
+
border: 1px solid var(--line);
|
|
227
|
+
background: rgba(23, 24, 19, 0.7);
|
|
228
|
+
box-shadow: var(--shadow);
|
|
229
|
+
border-radius: 8px;
|
|
230
|
+
padding: 26px;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.empty h1 {
|
|
234
|
+
margin: 0 0 12px;
|
|
235
|
+
color: var(--text);
|
|
236
|
+
font-size: 19px;
|
|
237
|
+
line-height: 1.2;
|
|
238
|
+
letter-spacing: 0;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.message {
|
|
242
|
+
max-width: min(820px, 94%);
|
|
243
|
+
border: 1px solid var(--line);
|
|
244
|
+
border-radius: 8px;
|
|
245
|
+
padding: 13px 15px;
|
|
246
|
+
line-height: 1.55;
|
|
247
|
+
white-space: pre-wrap;
|
|
248
|
+
overflow-wrap: anywhere;
|
|
249
|
+
background: rgba(23, 24, 19, 0.84);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.message.user {
|
|
253
|
+
align-self: flex-end;
|
|
254
|
+
background: rgba(66, 214, 164, 0.09);
|
|
255
|
+
border-color: rgba(66, 214, 164, 0.32);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.message.assistant {
|
|
259
|
+
align-self: flex-start;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.meta {
|
|
263
|
+
margin-top: 9px;
|
|
264
|
+
color: var(--dim);
|
|
265
|
+
font-size: 11px;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.composer {
|
|
269
|
+
border-top: 1px solid var(--line);
|
|
270
|
+
background: rgba(16, 16, 13, 0.92);
|
|
271
|
+
padding: 16px 20px 20px;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.composer-inner {
|
|
275
|
+
display: grid;
|
|
276
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
277
|
+
gap: 10px;
|
|
278
|
+
align-items: end;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
textarea {
|
|
282
|
+
min-height: 52px;
|
|
283
|
+
max-height: 180px;
|
|
284
|
+
resize: vertical;
|
|
285
|
+
border-radius: 8px;
|
|
286
|
+
padding: 13px 14px;
|
|
287
|
+
line-height: 1.45;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.toast {
|
|
291
|
+
position: fixed;
|
|
292
|
+
right: 18px;
|
|
293
|
+
bottom: 18px;
|
|
294
|
+
max-width: min(420px, calc(100vw - 36px));
|
|
295
|
+
background: #1b1214;
|
|
296
|
+
border: 1px solid rgba(255, 107, 107, 0.45);
|
|
297
|
+
color: #ffd4d4;
|
|
298
|
+
border-radius: 8px;
|
|
299
|
+
padding: 12px 14px;
|
|
300
|
+
box-shadow: var(--shadow);
|
|
301
|
+
display: none;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.toast.show { display: block; }
|
|
305
|
+
|
|
306
|
+
@media (max-width: 760px) {
|
|
307
|
+
body { overflow: auto; }
|
|
308
|
+
.shell {
|
|
309
|
+
grid-template-columns: 1fr;
|
|
310
|
+
height: auto;
|
|
311
|
+
min-height: 100vh;
|
|
312
|
+
}
|
|
313
|
+
.rail {
|
|
314
|
+
border-right: 0;
|
|
315
|
+
border-bottom: 1px solid var(--line);
|
|
316
|
+
max-height: 250px;
|
|
317
|
+
}
|
|
318
|
+
.workspace { height: calc(100vh - 250px); min-height: 560px; }
|
|
319
|
+
.topbar { padding: 0 14px; }
|
|
320
|
+
.messages { padding: 16px; }
|
|
321
|
+
.composer { padding: 12px; }
|
|
322
|
+
.composer-inner { grid-template-columns: 1fr; }
|
|
323
|
+
}
|
|
324
|
+
</style>
|
|
325
|
+
</head>
|
|
326
|
+
<body>
|
|
327
|
+
<main class="shell">
|
|
328
|
+
<aside class="rail">
|
|
329
|
+
<section class="brand">
|
|
330
|
+
<div class="mark">
|
|
331
|
+
<div class="wordmark">AEGIS</div>
|
|
332
|
+
<div id="statusDot" class="status"></div>
|
|
333
|
+
</div>
|
|
334
|
+
<div class="token-row">
|
|
335
|
+
<input id="tokenInput" type="password" autocomplete="off" placeholder="Access token">
|
|
336
|
+
<button id="saveToken" class="primary" type="button">Set</button>
|
|
337
|
+
</div>
|
|
338
|
+
</section>
|
|
339
|
+
<section class="brand">
|
|
340
|
+
<button id="newChat" type="button" class="primary">New Session</button>
|
|
341
|
+
</section>
|
|
342
|
+
<nav id="conversationList" class="conversations" aria-label="Conversations"></nav>
|
|
343
|
+
</aside>
|
|
344
|
+
|
|
345
|
+
<section class="workspace">
|
|
346
|
+
<header class="topbar">
|
|
347
|
+
<div class="title"><strong id="conversationTitle">Session</strong> <span id="connectionState">locked</span></div>
|
|
348
|
+
<button id="refreshConversations" type="button">Refresh</button>
|
|
349
|
+
</header>
|
|
350
|
+
|
|
351
|
+
<section id="messages" class="messages" aria-live="polite">
|
|
352
|
+
<div class="empty">
|
|
353
|
+
<h1>No messages in this session.</h1>
|
|
354
|
+
<p>Send a prompt to start a dispatch run.</p>
|
|
355
|
+
</div>
|
|
356
|
+
</section>
|
|
357
|
+
|
|
358
|
+
<form id="composer" class="composer">
|
|
359
|
+
<div class="composer-inner">
|
|
360
|
+
<textarea id="prompt" placeholder="Message AEGIS" rows="2"></textarea>
|
|
361
|
+
<button id="send" class="primary" type="submit">Send</button>
|
|
362
|
+
</div>
|
|
363
|
+
</form>
|
|
364
|
+
</section>
|
|
365
|
+
</main>
|
|
366
|
+
|
|
367
|
+
<div id="toast" class="toast"></div>
|
|
368
|
+
|
|
369
|
+
<script>
|
|
370
|
+
const els = {
|
|
371
|
+
tokenInput: document.getElementById('tokenInput'),
|
|
372
|
+
saveToken: document.getElementById('saveToken'),
|
|
373
|
+
statusDot: document.getElementById('statusDot'),
|
|
374
|
+
connectionState: document.getElementById('connectionState'),
|
|
375
|
+
conversationList: document.getElementById('conversationList'),
|
|
376
|
+
conversationTitle: document.getElementById('conversationTitle'),
|
|
377
|
+
refreshConversations: document.getElementById('refreshConversations'),
|
|
378
|
+
newChat: document.getElementById('newChat'),
|
|
379
|
+
messages: document.getElementById('messages'),
|
|
380
|
+
composer: document.getElementById('composer'),
|
|
381
|
+
prompt: document.getElementById('prompt'),
|
|
382
|
+
send: document.getElementById('send'),
|
|
383
|
+
toast: document.getElementById('toast')
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
let token = localStorage.getItem('aegis_token') || '';
|
|
387
|
+
let conversationId = localStorage.getItem('aegis_conversation_id') || '';
|
|
388
|
+
let assistantNode = null;
|
|
389
|
+
|
|
390
|
+
els.tokenInput.value = token;
|
|
391
|
+
updateAuthState();
|
|
392
|
+
if (token) loadConversations();
|
|
393
|
+
|
|
394
|
+
els.saveToken.addEventListener('click', function () {
|
|
395
|
+
token = els.tokenInput.value.trim();
|
|
396
|
+
if (token) {
|
|
397
|
+
localStorage.setItem('aegis_token', token);
|
|
398
|
+
} else {
|
|
399
|
+
localStorage.removeItem('aegis_token');
|
|
400
|
+
}
|
|
401
|
+
updateAuthState();
|
|
402
|
+
loadConversations();
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
els.refreshConversations.addEventListener('click', loadConversations);
|
|
406
|
+
els.newChat.addEventListener('click', function () {
|
|
407
|
+
conversationId = crypto.randomUUID();
|
|
408
|
+
localStorage.setItem('aegis_conversation_id', conversationId);
|
|
409
|
+
els.conversationTitle.textContent = 'Session';
|
|
410
|
+
renderMessages([]);
|
|
411
|
+
els.prompt.focus();
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
els.composer.addEventListener('submit', function (event) {
|
|
415
|
+
event.preventDefault();
|
|
416
|
+
sendMessage();
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
els.prompt.addEventListener('keydown', function (event) {
|
|
420
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
421
|
+
event.preventDefault();
|
|
422
|
+
sendMessage();
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
function updateAuthState() {
|
|
427
|
+
const ready = Boolean(token);
|
|
428
|
+
els.statusDot.classList.toggle('ready', ready);
|
|
429
|
+
els.connectionState.textContent = ready ? 'ready' : 'locked';
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function headers() {
|
|
433
|
+
return {
|
|
434
|
+
Authorization: 'Bearer ' + token,
|
|
435
|
+
'Content-Type': 'application/json'
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function showError(message) {
|
|
440
|
+
els.toast.textContent = message;
|
|
441
|
+
els.toast.classList.add('show');
|
|
442
|
+
setTimeout(function () { els.toast.classList.remove('show'); }, 4200);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
async function loadConversations() {
|
|
446
|
+
if (!token) {
|
|
447
|
+
els.conversationList.innerHTML = '';
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
try {
|
|
451
|
+
const res = await fetch('/api/conversations', { headers: headers() });
|
|
452
|
+
if (!res.ok) throw new Error('Conversations unavailable');
|
|
453
|
+
const data = await res.json();
|
|
454
|
+
renderConversations(data.conversations || []);
|
|
455
|
+
} catch (err) {
|
|
456
|
+
showError(err.message || 'Unable to load conversations');
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function renderConversations(conversations) {
|
|
461
|
+
els.conversationList.innerHTML = '';
|
|
462
|
+
conversations.forEach(function (conversation) {
|
|
463
|
+
const button = document.createElement('button');
|
|
464
|
+
button.type = 'button';
|
|
465
|
+
button.className = 'conversation' + (conversation.id === conversationId ? ' active' : '');
|
|
466
|
+
button.innerHTML =
|
|
467
|
+
'<span class="conversation-title"></span><span class="conversation-time"></span>';
|
|
468
|
+
button.querySelector('.conversation-title').textContent = conversation.title || 'Untitled';
|
|
469
|
+
button.querySelector('.conversation-time').textContent = (conversation.updated_at || '').slice(0, 16);
|
|
470
|
+
button.addEventListener('click', function () {
|
|
471
|
+
conversationId = conversation.id;
|
|
472
|
+
localStorage.setItem('aegis_conversation_id', conversationId);
|
|
473
|
+
els.conversationTitle.textContent = conversation.title || 'Session';
|
|
474
|
+
loadMessages(conversationId);
|
|
475
|
+
renderConversations(conversations);
|
|
476
|
+
});
|
|
477
|
+
els.conversationList.appendChild(button);
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
async function loadMessages(id) {
|
|
482
|
+
try {
|
|
483
|
+
const res = await fetch('/api/conversations/' + encodeURIComponent(id) + '/messages', { headers: headers() });
|
|
484
|
+
if (!res.ok) throw new Error('Messages unavailable');
|
|
485
|
+
const data = await res.json();
|
|
486
|
+
renderMessages(data.messages || []);
|
|
487
|
+
} catch (err) {
|
|
488
|
+
showError(err.message || 'Unable to load messages');
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function renderMessages(messages) {
|
|
493
|
+
els.messages.innerHTML = '';
|
|
494
|
+
if (!messages.length) {
|
|
495
|
+
const empty = document.createElement('div');
|
|
496
|
+
empty.className = 'empty';
|
|
497
|
+
empty.innerHTML = '<h1>No messages in this session.</h1><p>Send a prompt to start a dispatch run.</p>';
|
|
498
|
+
els.messages.appendChild(empty);
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
messages.forEach(function (message) {
|
|
502
|
+
addMessage(message.role, message.content, message.metadata);
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function addMessage(role, content, metadata) {
|
|
507
|
+
const node = document.createElement('article');
|
|
508
|
+
node.className = 'message ' + role;
|
|
509
|
+
const body = document.createElement('div');
|
|
510
|
+
body.textContent = content || '';
|
|
511
|
+
node.appendChild(body);
|
|
512
|
+
if (metadata && (metadata.executor || metadata.classification)) {
|
|
513
|
+
const meta = document.createElement('div');
|
|
514
|
+
meta.className = 'meta';
|
|
515
|
+
meta.textContent = [metadata.classification, metadata.executor, metadata.latencyMs ? metadata.latencyMs + 'ms' : ''].filter(Boolean).join(' / ');
|
|
516
|
+
node.appendChild(meta);
|
|
517
|
+
}
|
|
518
|
+
els.messages.appendChild(node);
|
|
519
|
+
els.messages.scrollTop = els.messages.scrollHeight;
|
|
520
|
+
return body;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
async function sendMessage() {
|
|
524
|
+
const text = els.prompt.value.trim();
|
|
525
|
+
if (!text) return;
|
|
526
|
+
if (!token) {
|
|
527
|
+
showError('Access token required');
|
|
528
|
+
els.tokenInput.focus();
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
if (!conversationId) {
|
|
532
|
+
conversationId = crypto.randomUUID();
|
|
533
|
+
localStorage.setItem('aegis_conversation_id', conversationId);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
els.prompt.value = '';
|
|
537
|
+
els.send.disabled = true;
|
|
538
|
+
if (els.messages.querySelector('.empty')) els.messages.innerHTML = '';
|
|
539
|
+
addMessage('user', text);
|
|
540
|
+
assistantNode = addMessage('assistant', '');
|
|
541
|
+
|
|
542
|
+
try {
|
|
543
|
+
const res = await fetch('/api/message/stream', {
|
|
544
|
+
method: 'POST',
|
|
545
|
+
headers: headers(),
|
|
546
|
+
body: JSON.stringify({ text: text, conversationId: conversationId })
|
|
547
|
+
});
|
|
548
|
+
if (!res.ok || !res.body) throw new Error('Dispatch unavailable');
|
|
549
|
+
await readSse(res.body);
|
|
550
|
+
await loadConversations();
|
|
551
|
+
} catch (err) {
|
|
552
|
+
if (assistantNode) assistantNode.textContent = 'Error: ' + (err.message || 'dispatch failed');
|
|
553
|
+
showError(err.message || 'Dispatch failed');
|
|
554
|
+
} finally {
|
|
555
|
+
assistantNode = null;
|
|
556
|
+
els.send.disabled = false;
|
|
557
|
+
els.prompt.focus();
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
async function readSse(body) {
|
|
562
|
+
const reader = body.getReader();
|
|
563
|
+
const decoder = new TextDecoder();
|
|
564
|
+
let buffer = '';
|
|
565
|
+
while (true) {
|
|
566
|
+
const next = await reader.read();
|
|
567
|
+
if (next.done) break;
|
|
568
|
+
buffer += decoder.decode(next.value, { stream: true });
|
|
569
|
+
const frames = buffer.split('\\n\\n');
|
|
570
|
+
buffer = frames.pop() || '';
|
|
571
|
+
frames.forEach(handleFrame);
|
|
572
|
+
}
|
|
573
|
+
if (buffer.trim()) handleFrame(buffer);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
function handleFrame(frame) {
|
|
577
|
+
const line = frame.split('\\n').find(function (part) { return part.startsWith('data: '); });
|
|
578
|
+
if (!line) return;
|
|
579
|
+
try {
|
|
580
|
+
const payload = JSON.parse(line.slice(6));
|
|
581
|
+
if (payload.type === 'delta' && assistantNode) {
|
|
582
|
+
assistantNode.textContent += payload.text;
|
|
583
|
+
els.messages.scrollTop = els.messages.scrollHeight;
|
|
584
|
+
}
|
|
585
|
+
if (payload.type === 'done' && payload.conversationId) {
|
|
586
|
+
conversationId = payload.conversationId;
|
|
587
|
+
localStorage.setItem('aegis_conversation_id', conversationId);
|
|
588
|
+
}
|
|
589
|
+
if (payload.type === 'error') showError(payload.error || 'Stream error');
|
|
590
|
+
} catch {
|
|
591
|
+
showError('Malformed stream event');
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
</script>
|
|
595
|
+
</body>
|
|
596
|
+
</html>`;
|
|
5
597
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
// Semantic version
|
|
2
|
-
// Used in /health endpoint and changelog tracking
|
|
3
|
-
export const VERSION = '0.
|
|
1
|
+
// Semantic version - bump on each deploy
|
|
2
|
+
// Used in /health endpoint and changelog tracking
|
|
3
|
+
export const VERSION = '0.8.0';
|
package/src/wiki/client.ts
CHANGED
|
File without changes
|
package/src/wiki/types.ts
CHANGED
|
File without changes
|