aegisai-harness 0.72.1 → 0.74.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 +178 -1
- package/public/style.css +28 -0
- package/src/conversation_export.js +67 -0
- package/src/index.js +60 -0
- 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.74.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.74.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.74.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.74.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.74.0-Setup
|
|
14
14
|
Compression=lzma2
|
|
15
15
|
SolidCompression=yes
|
|
16
16
|
PrivilegesRequired=lowest
|
package/public/app.js
CHANGED
|
@@ -340,6 +340,7 @@ function App() {
|
|
|
340
340
|
const [showSessions, setShowSessions] = useState(false);
|
|
341
341
|
const [cfg, setCfg] = useState({});
|
|
342
342
|
const [theme, setTheme] = useState(localStorage.getItem('theme') || 'dark');
|
|
343
|
+
const THEMES = ['dark', 'light', 'high-contrast', 'solarized'];
|
|
343
344
|
const [view, setView] = useState(localStorage.getItem('onboarded') ? 'chat' : 'onboarding');
|
|
344
345
|
const [toasts, setToasts] = useState([]);
|
|
345
346
|
const [toolLog, setToolLog] = useState([]);
|
|
@@ -361,6 +362,11 @@ function App() {
|
|
|
361
362
|
}, [theme]);
|
|
362
363
|
|
|
363
364
|
useEffect(() => { updateCtx(); }, []);
|
|
365
|
+
useEffect(() => {
|
|
366
|
+
API('/api/version').then((v) => {
|
|
367
|
+
if (v.version && v.version !== '0.73.0') toast('Update available: v' + v.version, 'info');
|
|
368
|
+
}).catch(() => {});
|
|
369
|
+
}, []);
|
|
364
370
|
|
|
365
371
|
useEffect(() => {
|
|
366
372
|
const handler = (e) => {
|
|
@@ -483,8 +489,71 @@ function App() {
|
|
|
483
489
|
{ icon: '🗑️', label: 'Clear Chat', keywords: 'clear reset', run: () => { setMessages([]); setToolLog([]); toast('Chat cleared', 'info'); } },
|
|
484
490
|
{ icon: '📊', label: 'Context Info', keywords: 'context tokens', run: () => toast('Context: ' + ctx.tokens + '/' + ctx.limit, 'info') },
|
|
485
491
|
{ icon: '🔧', label: 'Tools', keywords: 'tools list', run: () => toast('64+ tools available', 'info') },
|
|
492
|
+
{ icon: '📤', label: 'Export Chat', keywords: 'export markdown json', run: () => exportChat('markdown') },
|
|
493
|
+
{ icon: '⚖️', label: 'Compare Models', keywords: 'compare models', run: () => setShowCompare(true) },
|
|
486
494
|
];
|
|
487
495
|
|
|
496
|
+
const [showFiles, setShowFiles] = useState(false);
|
|
497
|
+
const [showSearch, setShowSearch] = useState(false);
|
|
498
|
+
const [showShortcuts, setShowShortcuts] = useState(false);
|
|
499
|
+
const [searchQuery, setSearchQuery] = useState('');
|
|
500
|
+
const [searchResults, setSearchResults] = useState([]);
|
|
501
|
+
const [fileDir, setFileDir] = useState('');
|
|
502
|
+
const [fileEntries, setFileEntries] = useState([]);
|
|
503
|
+
const [fileContent, setFileContent] = useState('');
|
|
504
|
+
const [selectedFile, setSelectedFile] = useState('');
|
|
505
|
+
const [showCompare, setShowCompare] = useState(false);
|
|
506
|
+
const [compareModels, setCompareModels] = useState('');
|
|
507
|
+
const [comparePrompt, setComparePrompt] = useState('');
|
|
508
|
+
const [compareResult, setCompareResult] = useState(null);
|
|
509
|
+
const [comparing, setComparing] = useState(false);
|
|
510
|
+
|
|
511
|
+
async function exportChat(format) {
|
|
512
|
+
try {
|
|
513
|
+
const r = await fetch('/api/export', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ format, title: 'Chat Export' }) });
|
|
514
|
+
const d = await r.json();
|
|
515
|
+
if (d.ok) toast('Exported to ' + d.path, 'success');
|
|
516
|
+
else toast('Export failed: ' + (d.error || 'unknown'), 'error');
|
|
517
|
+
} catch (e) { toast('Export failed: ' + e.message, 'error'); }
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
async function loadFiles(dir) {
|
|
521
|
+
try {
|
|
522
|
+
const d = await API('/api/files?dir=' + encodeURIComponent(dir || ''));
|
|
523
|
+
setFileDir(d.dir || dir);
|
|
524
|
+
setFileEntries(d.entries || []);
|
|
525
|
+
} catch (e) { toast('Failed to load files: ' + e.message, 'error'); }
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
async function searchConversations() {
|
|
529
|
+
if (!searchQuery.trim()) return;
|
|
530
|
+
try {
|
|
531
|
+
const d = await API('/api/search-sessions?q=' + encodeURIComponent(searchQuery));
|
|
532
|
+
setSearchResults(d.results || []);
|
|
533
|
+
} catch (e) { toast('Search failed: ' + e.message, 'error'); }
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
async function openFile(filePath) {
|
|
537
|
+
try {
|
|
538
|
+
const d = await API('/api/file?path=' + encodeURIComponent(filePath));
|
|
539
|
+
setSelectedFile(filePath);
|
|
540
|
+
setFileContent(d.content || '');
|
|
541
|
+
} catch (e) { toast('Failed to read file: ' + e.message, 'error'); }
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
async function runCompare() {
|
|
545
|
+
if (!comparePrompt.trim() || !compareModels.trim()) { toast('Enter a prompt and models', 'error'); return; }
|
|
546
|
+
setComparing(true);
|
|
547
|
+
try {
|
|
548
|
+
const models = compareModels.split(',').map((m) => m.trim()).filter(Boolean);
|
|
549
|
+
const r = await fetch('/api/compare', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ prompt: comparePrompt, models }) });
|
|
550
|
+
const d = await r.json();
|
|
551
|
+
setCompareResult(d);
|
|
552
|
+
toast('Comparison complete', 'success');
|
|
553
|
+
} catch (e) { toast('Compare failed: ' + e.message, 'error'); }
|
|
554
|
+
setComparing(false);
|
|
555
|
+
}
|
|
556
|
+
|
|
488
557
|
if (view === 'onboarding') {
|
|
489
558
|
return html`<${OnboardingWizard} onComplete=${() => setView('chat')} />`;
|
|
490
559
|
}
|
|
@@ -495,14 +564,122 @@ function App() {
|
|
|
495
564
|
<${CommandPalette} open=${showPalette} onClose=${() => setShowPalette(false)} commands=${commands} />
|
|
496
565
|
${showConfig ? html`<${ConfigModal} cfg=${cfg} setCfg=${setCfg} onClose=${() => setShowConfig(false)} />` : null}
|
|
497
566
|
${showHelp ? html`<${HelpPanel} onClose=${() => setShowHelp(false)} />` : null}
|
|
567
|
+
${showShortcuts ? html`
|
|
568
|
+
<div class="modal-backdrop" onClick=${() => setShowShortcuts(false)}>
|
|
569
|
+
<div class="modal" onClick=${(e) => e.stopPropagation()}>
|
|
570
|
+
<h2>Keyboard Shortcuts</h2>
|
|
571
|
+
<div class="shortcuts-list">
|
|
572
|
+
<div class="shortcut-item"><kbd>Ctrl+K</kbd> <span>Command palette</span></div>
|
|
573
|
+
<div class="shortcut-item"><kbd>Ctrl+N</kbd> <span>New chat</span></div>
|
|
574
|
+
<div class="shortcut-item"><kbd>Ctrl+B</kbd> <span>Toggle sessions</span></div>
|
|
575
|
+
<div class="shortcut-item"><kbd>Ctrl+,</kbd> <span>Settings</span></div>
|
|
576
|
+
<div class="shortcut-item"><kbd>Ctrl+/</kbd> <span>Help</span></div>
|
|
577
|
+
<div class="shortcut-item"><kbd>Ctrl+Shift+F</kbd> <span>Search conversations</span></div>
|
|
578
|
+
<div class="shortcut-item"><kbd>Ctrl+Shift+E</kbd> <span>Export chat</span></div>
|
|
579
|
+
<div class="shortcut-item"><kbd>Ctrl+Shift+C</kbd> <span>Compare models</span></div>
|
|
580
|
+
<div class="shortcut-item"><kbd>Ctrl+Shift+T</kbd> <span>Cycle theme</span></div>
|
|
581
|
+
<div class="shortcut-item"><kbd>Esc</kbd> <span>Close modals</span></div>
|
|
582
|
+
<div class="shortcut-item"><kbd>Enter</kbd> <span>Send message</span></div>
|
|
583
|
+
<div class="shortcut-item"><kbd>Shift+Enter</kbd> <span>New line in input</span></div>
|
|
584
|
+
</div>
|
|
585
|
+
<div class="modal-actions">
|
|
586
|
+
<button onClick=${() => setShowShortcuts(false)}>Close</button>
|
|
587
|
+
</div>
|
|
588
|
+
</div>
|
|
589
|
+
</div>
|
|
590
|
+
` : null}
|
|
591
|
+
${showSearch ? html`
|
|
592
|
+
<div class="modal-backdrop" onClick=${() => setShowSearch(false)}>
|
|
593
|
+
<div class="modal" style="max-width: 600px" onClick=${(e) => e.stopPropagation()}>
|
|
594
|
+
<h2>Search Conversations</h2>
|
|
595
|
+
<div class="search-bar">
|
|
596
|
+
<input value=${searchQuery} onInput=${(e) => setSearchQuery(e.target.value)} placeholder="Search messages..." style="flex:1" onKeyDown=${(e) => { if (e.key === 'Enter') searchConversations(); }} />
|
|
597
|
+
<button class="btn-primary" onClick=${searchConversations}>Search</button>
|
|
598
|
+
</div>
|
|
599
|
+
${searchResults.length > 0 ? html`
|
|
600
|
+
<div class="search-results">
|
|
601
|
+
${searchResults.map((r) => html`
|
|
602
|
+
<div class="search-result-item">
|
|
603
|
+
<span class="search-role">${r.role}</span>
|
|
604
|
+
<span class="search-snippet">${r.snippet}</span>
|
|
605
|
+
</div>
|
|
606
|
+
`)}
|
|
607
|
+
</div>
|
|
608
|
+
` : searchQuery ? html`<p class="hint">No results found.</p>` : null}
|
|
609
|
+
<div class="modal-actions">
|
|
610
|
+
<button onClick=${() => setShowSearch(false)}>Close</button>
|
|
611
|
+
</div>
|
|
612
|
+
</div>
|
|
613
|
+
</div>
|
|
614
|
+
` : null}
|
|
615
|
+
${showFiles ? html`
|
|
616
|
+
<div class="modal-backdrop" onClick=${() => setShowFiles(false)}>
|
|
617
|
+
<div class="modal" style="max-width: 800px; max-height: 80vh" onClick=${(e) => e.stopPropagation()}>
|
|
618
|
+
<h2>File Browser</h2>
|
|
619
|
+
<p class="hint">${fileDir}</p>
|
|
620
|
+
<div class="file-browser">
|
|
621
|
+
<div class="file-list">
|
|
622
|
+
${fileEntries.map((e) => html`
|
|
623
|
+
<div class=${'file-item' + (e.type === 'dir' ? ' dir' : '')} onClick=${() => e.type === 'dir' ? loadFiles(e.path) : openFile(e.path)}>
|
|
624
|
+
<span class="file-icon">${e.type === 'dir' ? '📁' : '📄'}</span>
|
|
625
|
+
<span class="file-name">${e.name}</span>
|
|
626
|
+
${e.type === 'file' ? html`<span class="file-size">${e.size > 1024 ? (e.size / 1024).toFixed(1) + ' KB' : e.size + ' B'}</span>` : null}
|
|
627
|
+
</div>
|
|
628
|
+
`)}
|
|
629
|
+
</div>
|
|
630
|
+
${selectedFile ? html`
|
|
631
|
+
<div class="file-preview">
|
|
632
|
+
<h3>${selectedFile.split(/[\\/]/).pop()}</h3>
|
|
633
|
+
<pre class="file-content">${fileContent.slice(0, 5000)}</pre>
|
|
634
|
+
</div>
|
|
635
|
+
` : null}
|
|
636
|
+
</div>
|
|
637
|
+
<div class="modal-actions">
|
|
638
|
+
<button onClick=${() => setShowFiles(false)}>Close</button>
|
|
639
|
+
</div>
|
|
640
|
+
</div>
|
|
641
|
+
</div>
|
|
642
|
+
` : null}
|
|
643
|
+
${showCompare ? html`
|
|
644
|
+
<div class="modal-backdrop" onClick=${() => setShowCompare(false)}>
|
|
645
|
+
<div class="modal" style="max-width: 800px" onClick=${(e) => e.stopPropagation()}>
|
|
646
|
+
<h2>Compare Models</h2>
|
|
647
|
+
<label>Prompt
|
|
648
|
+
<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)" />
|
|
649
|
+
</label>
|
|
650
|
+
<label>Models (comma-separated)
|
|
651
|
+
<input value=${compareModels} onInput=${(e) => setCompareModels(e.target.value)} placeholder="e.g. llama3.2:3b, mistral, phi3:mini" />
|
|
652
|
+
</label>
|
|
653
|
+
<div class="modal-actions">
|
|
654
|
+
<button class="btn-primary" onClick=${runCompare} disabled=${comparing}>${comparing ? 'Comparing...' : 'Compare'}</button>
|
|
655
|
+
<button onClick=${() => setShowCompare(false)}>Close</button>
|
|
656
|
+
</div>
|
|
657
|
+
${compareResult ? html`
|
|
658
|
+
<div class="compare-results">
|
|
659
|
+
${compareResult.comparison.results.map((r) => html`
|
|
660
|
+
<div class="compare-card">
|
|
661
|
+
<h3>${r.model} ${r.ok ? '✓' : '✗'} ${r.duration}ms</h3>
|
|
662
|
+
<div class="compare-reply">${r.ok ? r.reply.slice(0, 500) : r.error}</div>
|
|
663
|
+
</div>
|
|
664
|
+
`)}
|
|
665
|
+
<p class="hint">Fastest: ${compareResult.comparison.fastest} | Shortest: ${compareResult.comparison.shortest} | Longest: ${compareResult.comparison.longest}</p>
|
|
666
|
+
</div>
|
|
667
|
+
` : null}
|
|
668
|
+
</div>
|
|
669
|
+
</div>
|
|
670
|
+
` : null}
|
|
498
671
|
<${SessionSidebar} open=${showSessions} onClose=${() => setShowSessions(false)} onSelect=${(s) => { toast('Loaded session: ' + (s.title || s.id), 'info'); }} />
|
|
499
672
|
<header class="topbar">
|
|
500
673
|
<h1>AegisAi Harness</h1>
|
|
501
674
|
<span class="ctx-meter">ctx ${ctx.tokens}/${ctx.limit}${ctx.compacted ? ' · compacted' : ''}</span>
|
|
502
675
|
<button onClick=${() => setShowSessions(true)} title="Sessions (Ctrl+B)">📂</button>
|
|
503
|
-
<button onClick=${() =>
|
|
676
|
+
<button onClick=${() => { const idx = THEMES.indexOf(theme); const next = THEMES[(idx + 1) % THEMES.length]; setTheme(next); localStorage.setItem('theme', next); toast('Theme: ' + next, 'info'); }} title="Cycle theme (${theme})">${theme === 'dark' ? '☀️' : theme === 'light' ? '🌙' : theme === 'high-contrast' ? '🔲' : '🌅'}</button>
|
|
504
677
|
<button onClick=${() => setShowConfig(true)} title="Settings (Ctrl+,)">⚙️</button>
|
|
505
678
|
<button onClick=${() => setShowPalette(true)} title="Command palette (Ctrl+K)">⌘</button>
|
|
679
|
+
<button onClick=${() => setShowFiles(true) || loadFiles('')} title="File browser">📁</button>
|
|
680
|
+
<button onClick=${() => setShowSearch(true)} title="Search conversations">🔍</button>
|
|
681
|
+
<button onClick=${() => exportChat('markdown')} title="Export chat as Markdown">📤</button>
|
|
682
|
+
<button onClick=${() => setShowCompare(true)} title="Compare models">⚖️</button>
|
|
506
683
|
<button onClick=${() => setShowHelp(true)} title="Help (Ctrl+/)">?</button>
|
|
507
684
|
</header>
|
|
508
685
|
<div class="main-layout">
|
package/public/style.css
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
[data-theme="light"] {
|
|
5
5
|
--bg: #ffffff; --fg: #24292f; --accent: #0969da; --border: #d0d7de; --panel: #f6f8fa; --input: #ffffff; --danger: #cf222e; --success: #1a7f37; --warning: #9a6700;
|
|
6
6
|
}
|
|
7
|
+
[data-theme="high-contrast"] {
|
|
8
|
+
--bg: #000000; --fg: #ffffff; --accent: #ffff00; --border: #ffffff; --panel: #0a0a0a; --input: #000000; --danger: #ff0000; --success: #00ff00; --warning: #ffff00;
|
|
9
|
+
}
|
|
10
|
+
[data-theme="solarized"] {
|
|
11
|
+
--bg: #002b36; --fg: #839496; --accent: #268bd2; --border: #586e75; --panel: #073642; --input: #002b36; --danger: #dc322f; --success: #859900; --warning: #b58900;
|
|
12
|
+
}
|
|
7
13
|
* { box-sizing: border-box; }
|
|
8
14
|
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--fg); }
|
|
9
15
|
.app { display: flex; flex-direction: column; height: 100vh; }
|
|
@@ -250,6 +256,28 @@ kbd { background: var(--panel); border: 1px solid var(--border); border-radius:
|
|
|
250
256
|
.scan-results, .hf-results { margin: 8px 0; max-height: 200px; overflow-y: auto; }
|
|
251
257
|
.scan-item, .hf-item { display: flex; align-items: center; gap: 8px; padding: 6px; border-bottom: 1px solid var(--border); font-size: 12px; }
|
|
252
258
|
.hf-item .model-name { flex: 1; }
|
|
259
|
+
/* Shortcuts */
|
|
260
|
+
.shortcuts-list { margin: 8px 0; }
|
|
261
|
+
.shortcut-item { display: flex; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
|
|
262
|
+
.shortcut-item kbd { background: var(--panel); border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; font-size: 12px; font-family: monospace; min-width: 100px; text-align: center; }
|
|
263
|
+
.shortcut-item span { font-size: 13px; }
|
|
264
|
+
/* File browser */
|
|
265
|
+
.file-browser { display: flex; gap: 12px; margin: 8px 0; }
|
|
266
|
+
.file-list { flex: 1; max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 4px; }
|
|
267
|
+
.file-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 13px; }
|
|
268
|
+
.file-item:hover { background: var(--border); }
|
|
269
|
+
.file-item.dir { font-weight: 500; }
|
|
270
|
+
.file-icon { width: 20px; text-align: center; }
|
|
271
|
+
.file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
272
|
+
.file-size { font-size: 11px; color: var(--muted); }
|
|
273
|
+
.file-preview { flex: 1; border: 1px solid var(--border); border-radius: 6px; padding: 8px; max-height: 300px; overflow-y: auto; }
|
|
274
|
+
.file-preview h3 { margin: 0 0 8px; font-size: 13px; }
|
|
275
|
+
.file-content { font-size: 12px; line-height: 1.4; white-space: pre-wrap; word-break: break-all; margin: 0; }
|
|
276
|
+
/* Compare */
|
|
277
|
+
.compare-results { margin-top: 16px; max-height: 400px; overflow-y: auto; }
|
|
278
|
+
.compare-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 8px; }
|
|
279
|
+
.compare-card h3 { margin: 0 0 8px; font-size: 13px; }
|
|
280
|
+
.compare-reply { font-size: 13px; line-height: 1.5; white-space: pre-wrap; max-height: 200px; overflow-y: auto; }
|
|
253
281
|
/* Modal backdrop */
|
|
254
282
|
.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
283
|
|
|
@@ -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
|
@@ -281,6 +281,23 @@ async function main() {
|
|
|
281
281
|
sendJson(res, 200, { models: found, backend });
|
|
282
282
|
return;
|
|
283
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
|
+
}
|
|
284
301
|
if (req.method === 'GET' && req.url.split('?')[0] === '/api/models/hf-search') {
|
|
285
302
|
const q = new URL(req.url, 'http://x').searchParams.get('q') || '';
|
|
286
303
|
let results = [];
|
|
@@ -379,6 +396,47 @@ async function main() {
|
|
|
379
396
|
require('./mcp_server').createHandler()(req, res);
|
|
380
397
|
return;
|
|
381
398
|
}
|
|
399
|
+
if (req.method === 'GET' && req.url.split('?')[0] === '/api/search-sessions') {
|
|
400
|
+
const q = (new URL(req.url, 'http://x').searchParams.get('q') || '').toLowerCase();
|
|
401
|
+
const results = [];
|
|
402
|
+
for (const [sid, msgs] of sessions.entries()) {
|
|
403
|
+
for (const m of msgs) {
|
|
404
|
+
if ((m.content || '').toLowerCase().includes(q)) {
|
|
405
|
+
results.push({ sessionId: sid, role: m.role, snippet: (m.content || '').slice(0, 100), match: true });
|
|
406
|
+
break;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
sendJson(res, 200, { results, query: q });
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
if (req.method === 'GET' && req.url.split('?')[0] === '/api/files') {
|
|
414
|
+
const dir = new URL(req.url, 'http://x').searchParams.get('dir') || process.cwd();
|
|
415
|
+
let entries = [];
|
|
416
|
+
try {
|
|
417
|
+
const fs = require('fs');
|
|
418
|
+
const path = require('path');
|
|
419
|
+
const items = fs.readdirSync(dir, { withFileTypes: true });
|
|
420
|
+
entries = items.map((e) => ({
|
|
421
|
+
name: e.name,
|
|
422
|
+
type: e.isDirectory() ? 'dir' : 'file',
|
|
423
|
+
size: e.isFile() ? (fs.statSync(path.join(dir, e.name)).size) : 0,
|
|
424
|
+
path: path.join(dir, e.name),
|
|
425
|
+
})).sort((a, b) => (a.type === b.type ? a.name.localeCompare(b.name) : (a.type === 'dir' ? -1 : 1)));
|
|
426
|
+
} catch (e) {}
|
|
427
|
+
sendJson(res, 200, { dir, entries });
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if (req.method === 'GET' && req.url.split('?')[0] === '/api/file') {
|
|
431
|
+
const filePath = new URL(req.url, 'http://x').searchParams.get('path');
|
|
432
|
+
if (!filePath) { sendJson(res, 400, { error: 'path required' }); return; }
|
|
433
|
+
try {
|
|
434
|
+
const fs = require('fs');
|
|
435
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
436
|
+
sendJson(res, 200, { content, path: filePath });
|
|
437
|
+
} catch (e) { sendJson(res, 500, { error: String(e.message || e) }); }
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
382
440
|
if (req.method === 'GET' && req.url.split('?')[0] === '/api/projects') {
|
|
383
441
|
const list = require('./projects').list();
|
|
384
442
|
const details = list.map((n) => require('./projects').get(n));
|
|
@@ -698,6 +756,8 @@ async function main() {
|
|
|
698
756
|
if (t.startsWith('/think ')) { console.log(JSON.stringify(require('./sequential_thinking').think(t.slice(7).trim()), null, 2)); rl.prompt(); return; }
|
|
699
757
|
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; }
|
|
700
758
|
if (t === '/time') { console.log(JSON.stringify(require('./time_tool').now())); rl.prompt(); return; }
|
|
759
|
+
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; }
|
|
760
|
+
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; }
|
|
701
761
|
if (t.startsWith('/time ')) { console.log(JSON.stringify(require('./time_tool').now(t.slice(6).trim()))); rl.prompt(); return; }
|
|
702
762
|
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; }
|
|
703
763
|
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