aegisai-harness 0.71.1 → 0.73.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/CHANGELOG.md +1 -1
- package/README.md +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/packaging/windows/installer.iss +2 -2
- package/public/app.js +104 -7
- package/public/style.css +5 -0
- package/src/conversation_export.js +67 -0
- package/src/index.js +45 -1
- package/src/model_compare.js +71 -0
- package/src/version.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to AegisAi Harness are documented here.
|
|
4
4
|
|
|
5
|
-
## [0.
|
|
5
|
+
## [0.73.0] - 2026-11-24
|
|
6
6
|
|
|
7
7
|
### Fixed
|
|
8
8
|
- Installation: Windows installer now preflights Node.js 22.13+ with actionable messages; launcher no longer hides npm failures, uses `--omit=dev`, and records a dependency marker. Inno uninstall removes stale `node_modules`/lockfiles; `install.ps1` preserves `data/` and handles GitHub source zips.
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ A **feature-rich, local-only AI agent harness** — OpenCode-class runtime, but
|
|
|
10
10
|
offline-first: no cloud dependencies, no telemetry. 66 milestones, ~200 modules,
|
|
11
11
|
257 tests, CI green.
|
|
12
12
|
|
|
13
|
-
> Status: v0.
|
|
13
|
+
> Status: v0.73.0 (see [ROADMAP.md](./ROADMAP.md)).
|
|
14
14
|
> **Successor to [aegisai-next](https://github.com/user6811992/aegisai-next)** — that project is deprecated; all features have been ported here.
|
|
15
15
|
> **Live docs:** https://user6811992.github.io/aegisai-harness/
|
|
16
16
|
|
package/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AegisAi Harness — agent-readable catalog
|
|
2
2
|
|
|
3
|
-
A feature-rich, local-only AI agent harness. CLI-first, offline-first. v0.
|
|
3
|
+
A feature-rich, local-only AI agent harness. CLI-first, offline-first. v0.73.0.
|
|
4
4
|
|
|
5
5
|
## Capabilities
|
|
6
6
|
- Multi-backend LLM adapter (Ollama + OpenAI-compatible + 18 providers)
|
package/package.json
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
[Setup]
|
|
5
5
|
AppId={{8F3D1B2A-6C4E-4B9A-9D21-AE615A010001}}
|
|
6
6
|
AppName=AegisAi Harness
|
|
7
|
-
AppVersion=0.
|
|
7
|
+
AppVersion=0.73.0
|
|
8
8
|
AppPublisher=AegisAi
|
|
9
9
|
AppPublisherURL=https://github.com/user6811992/aegisai-harness
|
|
10
10
|
DefaultDirName={autopf}\AegisAiHarness
|
|
11
11
|
DefaultGroupName=AegisAi Harness
|
|
12
12
|
OutputDir=..\..\dist
|
|
13
|
-
OutputBaseFilename=AegisAi-Harness-0.
|
|
13
|
+
OutputBaseFilename=AegisAi-Harness-0.73.0-Setup
|
|
14
14
|
Compression=lzma2
|
|
15
15
|
SolidCompression=yes
|
|
16
16
|
PrivilegesRequired=lowest
|
package/public/app.js
CHANGED
|
@@ -424,15 +424,52 @@ function App() {
|
|
|
424
424
|
setMessages((m) => [...m, { role: 'user', content: text }]);
|
|
425
425
|
setLoading(true);
|
|
426
426
|
setToolLog([]);
|
|
427
|
+
// Add empty assistant message for streaming
|
|
428
|
+
setMessages((m) => [...m, { role: 'assistant', content: '' }]);
|
|
427
429
|
try {
|
|
428
|
-
const r = await fetch('/api/chat', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: text }) });
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
430
|
+
const r = await fetch('/api/chat', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: text, stream: true }) });
|
|
431
|
+
if (!r.ok) throw new Error('HTTP ' + r.status);
|
|
432
|
+
const reader = r.body.getReader();
|
|
433
|
+
const decoder = new TextDecoder();
|
|
434
|
+
let buffer = '';
|
|
435
|
+
let fullReply = '';
|
|
436
|
+
while (true) {
|
|
437
|
+
const { done, value } = await reader.read();
|
|
438
|
+
if (done) break;
|
|
439
|
+
buffer += decoder.decode(value, { stream: true });
|
|
440
|
+
const lines = buffer.split('\\n\\n');
|
|
441
|
+
buffer = lines.pop() || '';
|
|
442
|
+
for (const line of lines) {
|
|
443
|
+
if (!line.startsWith('data: ')) continue;
|
|
444
|
+
try {
|
|
445
|
+
const data = JSON.parse(line.slice(6));
|
|
446
|
+
if (data.type === 'token') {
|
|
447
|
+
fullReply += data.content;
|
|
448
|
+
setMessages((m) => {
|
|
449
|
+
const updated = [...m];
|
|
450
|
+
updated[updated.length - 1] = { role: 'assistant', content: fullReply };
|
|
451
|
+
return updated;
|
|
452
|
+
});
|
|
453
|
+
} else if (data.type === 'tool_call') {
|
|
454
|
+
toast('Tool: ' + data.name, 'info');
|
|
455
|
+
} else if (data.type === 'done') {
|
|
456
|
+
if (data.toolLog) setToolLog(data.toolLog);
|
|
457
|
+
updateCtx();
|
|
458
|
+
toast('Response received', 'success');
|
|
459
|
+
}
|
|
460
|
+
} catch (e) {}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
434
463
|
} catch (e) {
|
|
435
|
-
setMessages((m) =>
|
|
464
|
+
setMessages((m) => {
|
|
465
|
+
const updated = [...m];
|
|
466
|
+
if (updated.length > 0 && updated[updated.length - 1].role === 'assistant' && !updated[updated.length - 1].content) {
|
|
467
|
+
updated[updated.length - 1] = { role: 'assistant', content: 'Error: ' + e.message };
|
|
468
|
+
} else {
|
|
469
|
+
updated.push({ role: 'assistant', content: 'Error: ' + e.message });
|
|
470
|
+
}
|
|
471
|
+
return updated;
|
|
472
|
+
});
|
|
436
473
|
toast('Error: ' + e.message, 'error');
|
|
437
474
|
} finally { setLoading(false); }
|
|
438
475
|
}
|
|
@@ -446,8 +483,38 @@ function App() {
|
|
|
446
483
|
{ icon: '🗑️', label: 'Clear Chat', keywords: 'clear reset', run: () => { setMessages([]); setToolLog([]); toast('Chat cleared', 'info'); } },
|
|
447
484
|
{ icon: '📊', label: 'Context Info', keywords: 'context tokens', run: () => toast('Context: ' + ctx.tokens + '/' + ctx.limit, 'info') },
|
|
448
485
|
{ icon: '🔧', label: 'Tools', keywords: 'tools list', run: () => toast('64+ tools available', 'info') },
|
|
486
|
+
{ icon: '📤', label: 'Export Chat', keywords: 'export markdown json', run: () => exportChat('markdown') },
|
|
487
|
+
{ icon: '⚖️', label: 'Compare Models', keywords: 'compare models', run: () => setShowCompare(true) },
|
|
449
488
|
];
|
|
450
489
|
|
|
490
|
+
const [showCompare, setShowCompare] = useState(false);
|
|
491
|
+
const [compareModels, setCompareModels] = useState('');
|
|
492
|
+
const [comparePrompt, setComparePrompt] = useState('');
|
|
493
|
+
const [compareResult, setCompareResult] = useState(null);
|
|
494
|
+
const [comparing, setComparing] = useState(false);
|
|
495
|
+
|
|
496
|
+
async function exportChat(format) {
|
|
497
|
+
try {
|
|
498
|
+
const r = await fetch('/api/export', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ format, title: 'Chat Export' }) });
|
|
499
|
+
const d = await r.json();
|
|
500
|
+
if (d.ok) toast('Exported to ' + d.path, 'success');
|
|
501
|
+
else toast('Export failed: ' + (d.error || 'unknown'), 'error');
|
|
502
|
+
} catch (e) { toast('Export failed: ' + e.message, 'error'); }
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
async function runCompare() {
|
|
506
|
+
if (!comparePrompt.trim() || !compareModels.trim()) { toast('Enter a prompt and models', 'error'); return; }
|
|
507
|
+
setComparing(true);
|
|
508
|
+
try {
|
|
509
|
+
const models = compareModels.split(',').map((m) => m.trim()).filter(Boolean);
|
|
510
|
+
const r = await fetch('/api/compare', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ prompt: comparePrompt, models }) });
|
|
511
|
+
const d = await r.json();
|
|
512
|
+
setCompareResult(d);
|
|
513
|
+
toast('Comparison complete', 'success');
|
|
514
|
+
} catch (e) { toast('Compare failed: ' + e.message, 'error'); }
|
|
515
|
+
setComparing(false);
|
|
516
|
+
}
|
|
517
|
+
|
|
451
518
|
if (view === 'onboarding') {
|
|
452
519
|
return html`<${OnboardingWizard} onComplete=${() => setView('chat')} />`;
|
|
453
520
|
}
|
|
@@ -458,6 +525,34 @@ function App() {
|
|
|
458
525
|
<${CommandPalette} open=${showPalette} onClose=${() => setShowPalette(false)} commands=${commands} />
|
|
459
526
|
${showConfig ? html`<${ConfigModal} cfg=${cfg} setCfg=${setCfg} onClose=${() => setShowConfig(false)} />` : null}
|
|
460
527
|
${showHelp ? html`<${HelpPanel} onClose=${() => setShowHelp(false)} />` : null}
|
|
528
|
+
${showCompare ? html`
|
|
529
|
+
<div class="modal-backdrop" onClick=${() => setShowCompare(false)}>
|
|
530
|
+
<div class="modal" style="max-width: 800px" onClick=${(e) => e.stopPropagation()}>
|
|
531
|
+
<h2>Compare Models</h2>
|
|
532
|
+
<label>Prompt
|
|
533
|
+
<textarea value=${comparePrompt} onInput=${(e) => setComparePrompt(e.target.value)} placeholder="Enter a prompt to compare..." rows="3" style="width:100%;padding:8px;border:1px solid var(--border);border-radius:6px;background:var(--input);color:var(--fg)" />
|
|
534
|
+
</label>
|
|
535
|
+
<label>Models (comma-separated)
|
|
536
|
+
<input value=${compareModels} onInput=${(e) => setCompareModels(e.target.value)} placeholder="e.g. llama3.2:3b, mistral, phi3:mini" />
|
|
537
|
+
</label>
|
|
538
|
+
<div class="modal-actions">
|
|
539
|
+
<button class="btn-primary" onClick=${runCompare} disabled=${comparing}>${comparing ? 'Comparing...' : 'Compare'}</button>
|
|
540
|
+
<button onClick=${() => setShowCompare(false)}>Close</button>
|
|
541
|
+
</div>
|
|
542
|
+
${compareResult ? html`
|
|
543
|
+
<div class="compare-results">
|
|
544
|
+
${compareResult.comparison.results.map((r) => html`
|
|
545
|
+
<div class="compare-card">
|
|
546
|
+
<h3>${r.model} ${r.ok ? '✓' : '✗'} ${r.duration}ms</h3>
|
|
547
|
+
<div class="compare-reply">${r.ok ? r.reply.slice(0, 500) : r.error}</div>
|
|
548
|
+
</div>
|
|
549
|
+
`)}
|
|
550
|
+
<p class="hint">Fastest: ${compareResult.comparison.fastest} | Shortest: ${compareResult.comparison.shortest} | Longest: ${compareResult.comparison.longest}</p>
|
|
551
|
+
</div>
|
|
552
|
+
` : null}
|
|
553
|
+
</div>
|
|
554
|
+
</div>
|
|
555
|
+
` : null}
|
|
461
556
|
<${SessionSidebar} open=${showSessions} onClose=${() => setShowSessions(false)} onSelect=${(s) => { toast('Loaded session: ' + (s.title || s.id), 'info'); }} />
|
|
462
557
|
<header class="topbar">
|
|
463
558
|
<h1>AegisAi Harness</h1>
|
|
@@ -466,6 +561,8 @@ function App() {
|
|
|
466
561
|
<button onClick=${() => setTheme(theme === 'dark' ? 'light' : 'dark')} title="Toggle theme">${theme === 'dark' ? '☀️' : '🌙'}</button>
|
|
467
562
|
<button onClick=${() => setShowConfig(true)} title="Settings (Ctrl+,)">⚙️</button>
|
|
468
563
|
<button onClick=${() => setShowPalette(true)} title="Command palette (Ctrl+K)">⌘</button>
|
|
564
|
+
<button onClick=${() => exportChat('markdown')} title="Export chat as Markdown">📤</button>
|
|
565
|
+
<button onClick=${() => setShowCompare(true)} title="Compare models">⚖️</button>
|
|
469
566
|
<button onClick=${() => setShowHelp(true)} title="Help (Ctrl+/)">?</button>
|
|
470
567
|
</header>
|
|
471
568
|
<div class="main-layout">
|
package/public/style.css
CHANGED
|
@@ -250,6 +250,11 @@ kbd { background: var(--panel); border: 1px solid var(--border); border-radius:
|
|
|
250
250
|
.scan-results, .hf-results { margin: 8px 0; max-height: 200px; overflow-y: auto; }
|
|
251
251
|
.scan-item, .hf-item { display: flex; align-items: center; gap: 8px; padding: 6px; border-bottom: 1px solid var(--border); font-size: 12px; }
|
|
252
252
|
.hf-item .model-name { flex: 1; }
|
|
253
|
+
/* Compare */
|
|
254
|
+
.compare-results { margin-top: 16px; max-height: 400px; overflow-y: auto; }
|
|
255
|
+
.compare-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 8px; }
|
|
256
|
+
.compare-card h3 { margin: 0 0 8px; font-size: 13px; }
|
|
257
|
+
.compare-reply { font-size: 13px; line-height: 1.5; white-space: pre-wrap; max-height: 200px; overflow-y: auto; }
|
|
253
258
|
/* Modal backdrop */
|
|
254
259
|
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px); }
|
|
255
260
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/conversation_export.js
|
|
2
|
+
// Export conversations to Markdown, JSON, and PDF (text-based).
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
function toMarkdown(messages, meta) {
|
|
7
|
+
meta = meta || {};
|
|
8
|
+
const lines = [];
|
|
9
|
+
lines.push('# Conversation Export');
|
|
10
|
+
lines.push('');
|
|
11
|
+
if (meta.title) lines.push('**Title:** ' + meta.title);
|
|
12
|
+
if (meta.model) lines.push('**Model:** ' + meta.model);
|
|
13
|
+
if (meta.date) lines.push('**Date:** ' + meta.date);
|
|
14
|
+
lines.push('');
|
|
15
|
+
lines.push('---');
|
|
16
|
+
lines.push('');
|
|
17
|
+
for (const m of messages) {
|
|
18
|
+
const role = (m.role || 'unknown').charAt(0).toUpperCase() + (m.role || 'unknown').slice(1);
|
|
19
|
+
lines.push('## ' + role);
|
|
20
|
+
lines.push('');
|
|
21
|
+
lines.push(m.content || '');
|
|
22
|
+
lines.push('');
|
|
23
|
+
}
|
|
24
|
+
return lines.join('\n');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function toJSON(messages, meta) {
|
|
28
|
+
return JSON.stringify({ meta: meta || {}, messages: messages || [], exportedAt: new Date().toISOString() }, null, 2);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function toText(messages, meta) {
|
|
32
|
+
meta = meta || {};
|
|
33
|
+
const lines = [];
|
|
34
|
+
if (meta.title) lines.push('Title: ' + meta.title);
|
|
35
|
+
if (meta.model) lines.push('Model: ' + meta.model);
|
|
36
|
+
if (meta.date) lines.push('Date: ' + meta.date);
|
|
37
|
+
lines.push('');
|
|
38
|
+
for (const m of messages) {
|
|
39
|
+
lines.push('[' + (m.role || 'unknown').toUpperCase() + ']');
|
|
40
|
+
lines.push(m.content || '');
|
|
41
|
+
lines.push('');
|
|
42
|
+
}
|
|
43
|
+
return lines.join('\n');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Simple PDF-like text output (not a real PDF, but a text file with .pdf extension for compatibility)
|
|
47
|
+
// For real PDF, would need a library. This produces a readable text document.
|
|
48
|
+
function toPDF(messages, meta) {
|
|
49
|
+
// Produce a simple text-based document that can be opened in any text editor
|
|
50
|
+
// In a real implementation, this would use a PDF library like pdfkit
|
|
51
|
+
const text = toText(messages, meta);
|
|
52
|
+
return { content: text, mimeType: 'text/plain', extension: '.txt', note: 'PDF generation requires pdfkit; returning text format' };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function exportToFile(messages, meta, format, outputPath) {
|
|
56
|
+
format = (format || 'markdown').toLowerCase();
|
|
57
|
+
let content, ext;
|
|
58
|
+
if (format === 'json') { content = toJSON(messages, meta); ext = '.json'; }
|
|
59
|
+
else if (format === 'text' || format === 'txt') { content = toText(messages, meta); ext = '.txt'; }
|
|
60
|
+
else if (format === 'pdf') { const r = toPDF(messages, meta); content = r.content; ext = r.extension; }
|
|
61
|
+
else { content = toMarkdown(messages, meta); ext = '.md'; }
|
|
62
|
+
const filePath = outputPath || path.join(process.cwd(), 'conversation-export' + ext);
|
|
63
|
+
fs.writeFileSync(filePath, content, 'utf8');
|
|
64
|
+
return { ok: true, path: filePath, format, bytes: Buffer.byteLength(content) };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = { toMarkdown, toJSON, toText, toPDF, exportToFile };
|
package/src/index.js
CHANGED
|
@@ -196,13 +196,38 @@ async function main() {
|
|
|
196
196
|
const parsed = await readJson(req);
|
|
197
197
|
const sid = parsed.sessionId || 'default';
|
|
198
198
|
const history = Array.isArray(parsed.history) ? parsed.history : (sessions.get(sid) || []);
|
|
199
|
+
const stream = parsed.stream === true;
|
|
200
|
+
const autoApprove = process.env.AEGISAI_WEB_AUTO_APPROVE === 'true';
|
|
201
|
+
if (stream) {
|
|
202
|
+
res.writeHead(200, { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*' });
|
|
203
|
+
let fullReply = '';
|
|
204
|
+
const result = await runAgent({
|
|
205
|
+
model: parsed.model || process.env.AEGISAI_MODEL || 'llama3.2:3b',
|
|
206
|
+
messages: history.concat([{ role: 'user', content: parsed.message || '' }]),
|
|
207
|
+
projectRoot: process.cwd(),
|
|
208
|
+
onEvent: (e) => {
|
|
209
|
+
if (e.type === 'token') { fullReply += (e.content || ''); res.write('data: ' + JSON.stringify({ type: 'token', content: e.content || '' }) + '\\n\\n'); }
|
|
210
|
+
else if (e.type === 'tool_call') { res.write('data: ' + JSON.stringify({ type: 'tool_call', name: e.name, args: e.args }) + '\\n\\n'); }
|
|
211
|
+
else if (e.type === 'tool_result') { res.write('data: ' + JSON.stringify({ type: 'tool_result', preview: (e.preview || '').slice(0, 200) }) + '\\n\\n'); }
|
|
212
|
+
else if (e.type === 'status') { res.write('data: ' + JSON.stringify({ type: 'status', message: e.message }) + '\\n\\n'); }
|
|
213
|
+
},
|
|
214
|
+
autoApprove,
|
|
215
|
+
approvalHandler: async () => false,
|
|
216
|
+
});
|
|
217
|
+
const reply = (result.final && result.final.final) || fullReply;
|
|
218
|
+
const updated = history.concat([{ role: 'user', content: parsed.message || '' }, { role: 'assistant', content: reply }]);
|
|
219
|
+
sessions.set(sid, updated);
|
|
220
|
+
res.write('data: ' + JSON.stringify({ type: 'done', reply, toolLog: result.toolLog || [] }) + '\\n\\n');
|
|
221
|
+
res.end();
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
199
224
|
const result = await runAgent({
|
|
200
225
|
model: parsed.model || process.env.AEGISAI_MODEL || 'llama3.2:3b',
|
|
201
226
|
messages: history.concat([{ role: 'user', content: parsed.message || '' }]),
|
|
202
227
|
projectRoot: process.cwd(),
|
|
203
228
|
onEvent: () => {},
|
|
204
229
|
// Tool execution from the browser is opt-in. Default: no writes.
|
|
205
|
-
autoApprove
|
|
230
|
+
autoApprove,
|
|
206
231
|
approvalHandler: async () => false,
|
|
207
232
|
});
|
|
208
233
|
const reply = (result.final && result.final.final) || '';
|
|
@@ -256,6 +281,23 @@ async function main() {
|
|
|
256
281
|
sendJson(res, 200, { models: found, backend });
|
|
257
282
|
return;
|
|
258
283
|
}
|
|
284
|
+
if (req.method === 'POST' && req.url.split('?')[0] === '/api/export') {
|
|
285
|
+
const parsed = await readJson(req);
|
|
286
|
+
const sid = parsed.sessionId || 'default';
|
|
287
|
+
const history = sessions.get(sid) || [];
|
|
288
|
+
const format = parsed.format || 'markdown';
|
|
289
|
+
const meta = { title: parsed.title, model: process.env.AEGISAI_MODEL || 'llama3.2:3b', date: new Date().toISOString() };
|
|
290
|
+
const result = require('./conversation_export').exportToFile(history.map((m) => ({ role: m.role, content: m.content })), meta, format, null);
|
|
291
|
+
sendJson(res, 200, result);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (req.method === 'POST' && req.url.split('?')[0] === '/api/compare') {
|
|
295
|
+
const parsed = await readJson(req);
|
|
296
|
+
const models = parsed.models || [process.env.AEGISAI_MODEL || 'llama3.2:3b'];
|
|
297
|
+
const result = await require('./model_compare').compare(parsed.prompt || '', models, { projectRoot: process.cwd() });
|
|
298
|
+
sendJson(res, 200, { comparison: result, formatted: require('./model_compare').formatComparison(result) });
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
259
301
|
if (req.method === 'GET' && req.url.split('?')[0] === '/api/models/hf-search') {
|
|
260
302
|
const q = new URL(req.url, 'http://x').searchParams.get('q') || '';
|
|
261
303
|
let results = [];
|
|
@@ -673,6 +715,8 @@ async function main() {
|
|
|
673
715
|
if (t.startsWith('/think ')) { console.log(JSON.stringify(require('./sequential_thinking').think(t.slice(7).trim()), null, 2)); rl.prompt(); return; }
|
|
674
716
|
if (t.startsWith('/fetch ')) { const r = await require('./fetch_url').fetch(t.slice(7).trim()); console.log(JSON.stringify(r, null, 2).slice(0, 2000)); rl.prompt(); return; }
|
|
675
717
|
if (t === '/time') { console.log(JSON.stringify(require('./time_tool').now())); rl.prompt(); return; }
|
|
718
|
+
if (t.startsWith('/export ')) { const p = t.slice(8).trim().split('|').map((x) => x.trim()); const r = require('./conversation_export').exportToFile(lastToolLog.length ? [] : [], { title: p[1] || 'export', model: process.env.AEGISAI_MODEL || 'llama3.2:3b' }, p[0] || 'markdown', p[2]); console.log(JSON.stringify(r)); rl.prompt(); return; }
|
|
719
|
+
if (t.startsWith('/compare ')) { const p = t.slice(9).trim().split('|').map((x) => x.trim()); const r = await require('./model_compare').compare(p[0] || '', p.slice(1).filter(Boolean), { projectRoot: root }); console.log(require('./model_compare').formatComparison(r).slice(0, 3000)); rl.prompt(); return; }
|
|
676
720
|
if (t.startsWith('/time ')) { console.log(JSON.stringify(require('./time_tool').now(t.slice(6).trim()))); rl.prompt(); return; }
|
|
677
721
|
if (t.startsWith('/mcp-registry ')) { const r = await require('./mcp_registry_browser').browse(t.slice(14).trim()); console.log(JSON.stringify(r, null, 2).slice(0, 2000)); rl.prompt(); return; }
|
|
678
722
|
if (t === '/everything-manifest') { console.log(JSON.stringify(require('./mcp_everything').manifest(), null, 2).slice(0, 1500)); rl.prompt(); return; }
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// src/model_compare.js
|
|
2
|
+
// Multi-model comparison: send the same prompt to multiple models and compare responses.
|
|
3
|
+
const { runAgent } = require('./agent/run');
|
|
4
|
+
|
|
5
|
+
async function compare(prompt, models, opts) {
|
|
6
|
+
opts = opts || {};
|
|
7
|
+
const projectRoot = opts.projectRoot || process.cwd();
|
|
8
|
+
const results = [];
|
|
9
|
+
for (const model of models) {
|
|
10
|
+
const start = Date.now();
|
|
11
|
+
try {
|
|
12
|
+
const r = await runAgent({
|
|
13
|
+
model,
|
|
14
|
+
messages: [{ role: 'user', content: prompt }],
|
|
15
|
+
projectRoot,
|
|
16
|
+
onEvent: () => {},
|
|
17
|
+
autoApprove: true,
|
|
18
|
+
tokenBudgetTotal: opts.tokenBudget || 0,
|
|
19
|
+
});
|
|
20
|
+
const duration = Date.now() - start;
|
|
21
|
+
results.push({
|
|
22
|
+
model,
|
|
23
|
+
ok: true,
|
|
24
|
+
reply: (r.final && r.final.final) || '',
|
|
25
|
+
toolLog: r.toolLog || [],
|
|
26
|
+
tokenStats: r.final && r.final.tokenStats,
|
|
27
|
+
duration,
|
|
28
|
+
});
|
|
29
|
+
} catch (e) {
|
|
30
|
+
results.push({ model, ok: false, error: String(e.message || e), duration: Date.now() - start });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
prompt,
|
|
35
|
+
models,
|
|
36
|
+
results,
|
|
37
|
+
fastest: results.filter((r) => r.ok).sort((a, b) => a.duration - b.duration)[0]?.model,
|
|
38
|
+
shortest: results.filter((r) => r.ok).sort((a, b) => (a.reply || '').length - (b.reply || '').length)[0]?.model,
|
|
39
|
+
longest: results.filter((r) => r.ok).sort((a, b) => (b.reply || '').length - (a.reply || '').length)[0]?.model,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function formatComparison(comparison) {
|
|
44
|
+
const lines = [];
|
|
45
|
+
lines.push('# Multi-Model Comparison');
|
|
46
|
+
lines.push('');
|
|
47
|
+
lines.push('**Prompt:** ' + comparison.prompt);
|
|
48
|
+
lines.push('');
|
|
49
|
+
lines.push('**Models:** ' + comparison.models.join(', '));
|
|
50
|
+
lines.push('');
|
|
51
|
+
for (const r of comparison.results) {
|
|
52
|
+
lines.push('## ' + r.model);
|
|
53
|
+
lines.push('');
|
|
54
|
+
if (r.ok) {
|
|
55
|
+
lines.push(r.reply);
|
|
56
|
+
lines.push('');
|
|
57
|
+
lines.push(`_Duration: ${r.duration}ms | Tokens: ${r.tokenStats ? r.tokenStats.total : 'N/A'} | Tools: ${r.toolLog.length}_`);
|
|
58
|
+
} else {
|
|
59
|
+
lines.push('**Error:** ' + r.error);
|
|
60
|
+
}
|
|
61
|
+
lines.push('');
|
|
62
|
+
lines.push('---');
|
|
63
|
+
lines.push('');
|
|
64
|
+
}
|
|
65
|
+
if (comparison.fastest) lines.push('**Fastest:** ' + comparison.fastest);
|
|
66
|
+
if (comparison.shortest) lines.push('**Shortest response:** ' + comparison.shortest);
|
|
67
|
+
if (comparison.longest) lines.push('**Longest response:** ' + comparison.longest);
|
|
68
|
+
return lines.join('\n');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = { compare, formatComparison };
|
package/src/version.js
CHANGED