tycono 0.3.13-beta.0 → 0.3.13-beta.2
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/bin/cli.js +2 -0
- package/bin/tycono.ts +29 -3
- package/package.json +1 -1
- package/src/tui/components/CommandMode.tsx +56 -1
package/bin/cli.js
CHANGED
|
@@ -11,6 +11,8 @@ if (!process.env.__TYCONO_HEAP_SET && !process.execArgv.some(a => a.includes('ma
|
|
|
11
11
|
try {
|
|
12
12
|
execFileSync(process.execPath, [
|
|
13
13
|
'--max-old-space-size=8192',
|
|
14
|
+
'--expose-gc',
|
|
15
|
+
'--heapsnapshot-near-heap-limit=1',
|
|
14
16
|
...process.execArgv,
|
|
15
17
|
fileURLToPath(import.meta.url),
|
|
16
18
|
...process.argv.slice(2),
|
package/bin/tycono.ts
CHANGED
|
@@ -270,11 +270,37 @@ async function startServerForTui(): Promise<void> {
|
|
|
270
270
|
origLog(` API server started on port ${port}`);
|
|
271
271
|
origLog(` Logs: ${logFile}`);
|
|
272
272
|
|
|
273
|
-
// Memory monitor —
|
|
273
|
+
// Memory monitor — 10s interval, with spike detection + forced GC
|
|
274
|
+
let lastHeap = 0;
|
|
274
275
|
setInterval(() => {
|
|
275
276
|
const mem = process.memoryUsage();
|
|
276
|
-
|
|
277
|
-
|
|
277
|
+
const heapMB = Math.round(mem.heapUsed / 1024 / 1024);
|
|
278
|
+
const heapTotalMB = Math.round(mem.heapTotal / 1024 / 1024);
|
|
279
|
+
const rssMB = Math.round(mem.rss / 1024 / 1024);
|
|
280
|
+
const spike = heapMB - lastHeap;
|
|
281
|
+
|
|
282
|
+
// Always log
|
|
283
|
+
logStream.write(`[MEM] heap=${heapMB}MB/${heapTotalMB}MB rss=${rssMB}MB${spike > 50 ? ` ⚠️ SPIKE +${spike}MB` : ''}\n`);
|
|
284
|
+
|
|
285
|
+
// Spike detection: >100MB jump in 10s
|
|
286
|
+
if (spike > 100) {
|
|
287
|
+
logStream.write(`[MEM] ⛔ MEMORY SPIKE: +${spike}MB in 10s (${lastHeap}MB → ${heapMB}MB)\n`);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Warning at 2GB
|
|
291
|
+
if (heapMB > 2048 && lastHeap <= 2048) {
|
|
292
|
+
logStream.write(`[MEM] ⚠️ HEAP WARNING: ${heapMB}MB — approaching limit. Forcing GC.\n`);
|
|
293
|
+
if (global.gc) global.gc();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Critical at 4GB — force GC
|
|
297
|
+
if (heapMB > 4096) {
|
|
298
|
+
logStream.write(`[MEM] ⛔ HEAP CRITICAL: ${heapMB}MB — forcing GC\n`);
|
|
299
|
+
if (global.gc) global.gc();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
lastHeap = heapMB;
|
|
303
|
+
}, 10_000).unref();
|
|
278
304
|
|
|
279
305
|
// Graceful shutdown — mark active sessions as interrupted
|
|
280
306
|
const shutdown = () => {
|
package/package.json
CHANGED
|
@@ -286,6 +286,23 @@ function StreamLineRow({ line }: { line: StreamLine }) {
|
|
|
286
286
|
const QUICK_ACTIONS = ['waves', 'agents', 'sessions', 'ports', 'docs'] as const;
|
|
287
287
|
type QuickAction = typeof QUICK_ACTIONS[number];
|
|
288
288
|
|
|
289
|
+
/* ─── Command Autocomplete ─── */
|
|
290
|
+
const COMMANDS: Array<{ cmd: string; desc: string }> = [
|
|
291
|
+
{ cmd: '/new [text]', desc: 'Create new wave' },
|
|
292
|
+
{ cmd: '/waves', desc: 'List waves' },
|
|
293
|
+
{ cmd: '/focus <n>', desc: 'Switch wave' },
|
|
294
|
+
{ cmd: '/stop', desc: 'Stop execution' },
|
|
295
|
+
{ cmd: '/docs', desc: 'Wave files' },
|
|
296
|
+
{ cmd: '/read <path>', desc: 'Preview file' },
|
|
297
|
+
{ cmd: '/open <path>', desc: 'Open in editor' },
|
|
298
|
+
{ cmd: '/agents', desc: 'Agent tree' },
|
|
299
|
+
{ cmd: '/sessions', desc: 'Active sessions' },
|
|
300
|
+
{ cmd: '/kill <id>', desc: 'Kill session' },
|
|
301
|
+
{ cmd: '/cleanup', desc: 'Remove dead' },
|
|
302
|
+
{ cmd: '/help', desc: 'Help' },
|
|
303
|
+
{ cmd: '/quit', desc: 'Exit' },
|
|
304
|
+
];
|
|
305
|
+
|
|
289
306
|
export const CommandMode: React.FC<CommandModeProps> = ({
|
|
290
307
|
events,
|
|
291
308
|
allRoleIds,
|
|
@@ -300,6 +317,7 @@ export const CommandMode: React.FC<CommandModeProps> = ({
|
|
|
300
317
|
const [userInputs, setUserInputs] = useState<StreamLine[]>([]);
|
|
301
318
|
const [quickBarActive, setQuickBarActive] = useState(false);
|
|
302
319
|
const [quickBarIndex, setQuickBarIndex] = useState(0);
|
|
320
|
+
const [acIndex, setAcIndex] = useState(0);
|
|
303
321
|
|
|
304
322
|
// Convert events to stream lines (collapse consecutive thinking from same role)
|
|
305
323
|
const eventLines: StreamLine[] = [];
|
|
@@ -332,8 +350,45 @@ export const CommandMode: React.FC<CommandModeProps> = ({
|
|
|
332
350
|
const committedLines = allLines.slice(Math.max(0, committedRef.current - 20), committedRef.current);
|
|
333
351
|
const liveLines = allLines.slice(committedRef.current);
|
|
334
352
|
|
|
335
|
-
//
|
|
353
|
+
// Autocomplete: filter commands when input starts with /
|
|
354
|
+
const acOpen = input.startsWith('/') && input.length >= 1;
|
|
355
|
+
const acCandidates = acOpen
|
|
356
|
+
? COMMANDS.filter(c => c.cmd.startsWith(input) || c.cmd.split(' ')[0].startsWith(input))
|
|
357
|
+
: [];
|
|
358
|
+
const acVisible = acOpen && acCandidates.length > 0;
|
|
359
|
+
|
|
360
|
+
// Quick bar + autocomplete navigation
|
|
336
361
|
useInput((ch, key) => {
|
|
362
|
+
// Autocomplete mode
|
|
363
|
+
if (acVisible) {
|
|
364
|
+
if (key.downArrow) {
|
|
365
|
+
setAcIndex(i => Math.min(acCandidates.length - 1, i + 1));
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
if (key.upArrow) {
|
|
369
|
+
setAcIndex(i => Math.max(0, i - 1));
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (key.tab) {
|
|
373
|
+
// Tab → fill input with selected command (don't execute)
|
|
374
|
+
const selected = acCandidates[acIndex];
|
|
375
|
+
if (selected) {
|
|
376
|
+
const base = selected.cmd.split(' ')[0]; // e.g. "/new" from "/new [text]"
|
|
377
|
+
setInput(base + ' ');
|
|
378
|
+
setAcIndex(0);
|
|
379
|
+
}
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
if (key.escape) {
|
|
383
|
+
setInput('');
|
|
384
|
+
setAcIndex(0);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
// Don't intercept Enter — let TextInput handle it for submission
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// Quick bar mode
|
|
337
392
|
if (quickBarActive) {
|
|
338
393
|
if (key.upArrow || key.escape) {
|
|
339
394
|
setQuickBarActive(false);
|