4runr-os 1.0.46 → 1.0.48

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.
Files changed (91) hide show
  1. package/dist/index.js +6 -34
  2. package/dist/index.js.map +1 -1
  3. package/dist/ui/v3/collectors/resources.d.ts +23 -0
  4. package/dist/ui/v3/collectors/resources.d.ts.map +1 -0
  5. package/dist/ui/v3/collectors/resources.js +117 -0
  6. package/dist/ui/v3/collectors/resources.js.map +1 -0
  7. package/dist/ui/v3/commands/commandResult.d.ts +25 -0
  8. package/dist/ui/v3/commands/commandResult.d.ts.map +1 -0
  9. package/dist/ui/v3/commands/commandResult.js +19 -0
  10. package/dist/ui/v3/commands/commandResult.js.map +1 -0
  11. package/dist/ui/v3/commands/parser.d.ts +14 -0
  12. package/dist/ui/v3/commands/parser.d.ts.map +1 -0
  13. package/dist/ui/v3/commands/parser.js +29 -0
  14. package/dist/ui/v3/commands/parser.js.map +1 -0
  15. package/dist/ui/v3/commands/router.d.ts +13 -0
  16. package/dist/ui/v3/commands/router.d.ts.map +1 -0
  17. package/dist/ui/v3/commands/router.js +69 -0
  18. package/dist/ui/v3/commands/router.js.map +1 -0
  19. package/dist/ui/v3/core/event.d.ts +19 -0
  20. package/dist/ui/v3/core/event.d.ts.map +1 -0
  21. package/dist/ui/v3/core/event.js +7 -0
  22. package/dist/ui/v3/core/event.js.map +1 -0
  23. package/dist/ui/v3/core/eventBus.d.ts +33 -0
  24. package/dist/ui/v3/core/eventBus.d.ts.map +1 -0
  25. package/dist/ui/v3/core/eventBus.js +78 -0
  26. package/dist/ui/v3/core/eventBus.js.map +1 -0
  27. package/dist/ui/v3/index.d.ts +8 -0
  28. package/dist/ui/v3/index.d.ts.map +1 -0
  29. package/dist/ui/v3/index.js +30 -0
  30. package/dist/ui/v3/index.js.map +1 -0
  31. package/dist/ui/v3/state/defaultState.d.ts +9 -0
  32. package/dist/ui/v3/state/defaultState.d.ts.map +1 -0
  33. package/dist/ui/v3/state/defaultState.js +11 -0
  34. package/dist/ui/v3/state/defaultState.js.map +1 -0
  35. package/dist/ui/v3/state/feedModel.d.ts +49 -0
  36. package/dist/ui/v3/state/feedModel.d.ts.map +1 -0
  37. package/dist/ui/v3/state/feedModel.js +84 -0
  38. package/dist/ui/v3/state/feedModel.js.map +1 -0
  39. package/dist/ui/v3/state/resourcesData.d.ts +15 -0
  40. package/dist/ui/v3/state/resourcesData.d.ts.map +1 -0
  41. package/dist/ui/v3/state/resourcesData.js +7 -0
  42. package/dist/ui/v3/state/resourcesData.js.map +1 -0
  43. package/dist/ui/v3/state/uiState.d.ts +12 -0
  44. package/dist/ui/v3/state/uiState.d.ts.map +1 -0
  45. package/dist/ui/v3/state/uiState.js +8 -0
  46. package/dist/ui/v3/state/uiState.js.map +1 -0
  47. package/dist/ui/v3/state/uiStateBuilder.d.ts +16 -0
  48. package/dist/ui/v3/state/uiStateBuilder.d.ts.map +1 -0
  49. package/dist/ui/v3/state/uiStateBuilder.js +35 -0
  50. package/dist/ui/v3/state/uiStateBuilder.js.map +1 -0
  51. package/dist/ui/v3/state/value.d.ts +39 -0
  52. package/dist/ui/v3/state/value.d.ts.map +1 -0
  53. package/dist/ui/v3/state/value.js +31 -0
  54. package/dist/ui/v3/state/value.js.map +1 -0
  55. package/dist/ui/v3/ui/focus.d.ts +28 -0
  56. package/dist/ui/v3/ui/focus.d.ts.map +1 -0
  57. package/dist/ui/v3/ui/focus.js +38 -0
  58. package/dist/ui/v3/ui/focus.js.map +1 -0
  59. package/dist/ui/v3/ui/layout/hubLayout.d.ts +43 -0
  60. package/dist/ui/v3/ui/layout/hubLayout.d.ts.map +1 -0
  61. package/dist/ui/v3/ui/layout/hubLayout.js +170 -0
  62. package/dist/ui/v3/ui/layout/hubLayout.js.map +1 -0
  63. package/dist/ui/v3/ui/layout/phase1Layout.d.ts +34 -0
  64. package/dist/ui/v3/ui/layout/phase1Layout.d.ts.map +1 -0
  65. package/dist/ui/v3/ui/layout/phase1Layout.js +107 -0
  66. package/dist/ui/v3/ui/layout/phase1Layout.js.map +1 -0
  67. package/dist/ui/v3/ui/minimalRuntime.d.ts +14 -0
  68. package/dist/ui/v3/ui/minimalRuntime.d.ts.map +1 -0
  69. package/dist/ui/v3/ui/minimalRuntime.js +111 -0
  70. package/dist/ui/v3/ui/minimalRuntime.js.map +1 -0
  71. package/dist/ui/v3/ui/panels/ResourcesPanel.d.ts +16 -0
  72. package/dist/ui/v3/ui/panels/ResourcesPanel.d.ts.map +1 -0
  73. package/dist/ui/v3/ui/panels/ResourcesPanel.js +46 -0
  74. package/dist/ui/v3/ui/panels/ResourcesPanel.js.map +1 -0
  75. package/dist/ui/v3/ui/phase1Runtime.d.ts +22 -0
  76. package/dist/ui/v3/ui/phase1Runtime.d.ts.map +1 -0
  77. package/dist/ui/v3/ui/phase1Runtime.js +574 -0
  78. package/dist/ui/v3/ui/phase1Runtime.js.map +1 -0
  79. package/dist/ui/v3/ui/primitives/Panel.d.ts +39 -0
  80. package/dist/ui/v3/ui/primitives/Panel.d.ts.map +1 -0
  81. package/dist/ui/v3/ui/primitives/Panel.js +105 -0
  82. package/dist/ui/v3/ui/primitives/Panel.js.map +1 -0
  83. package/dist/ui/v3/ui/theme.d.ts +37 -0
  84. package/dist/ui/v3/ui/theme.d.ts.map +1 -0
  85. package/dist/ui/v3/ui/theme.js +40 -0
  86. package/dist/ui/v3/ui/theme.js.map +1 -0
  87. package/dist/ui/v3/ui/widgets/CommandLine.d.ts +26 -0
  88. package/dist/ui/v3/ui/widgets/CommandLine.d.ts.map +1 -0
  89. package/dist/ui/v3/ui/widgets/CommandLine.js +67 -0
  90. package/dist/ui/v3/ui/widgets/CommandLine.js.map +1 -0
  91. package/package.json +3 -2
@@ -0,0 +1,574 @@
1
+ /**
2
+ * Phase 1 Runtime
3
+ *
4
+ * Layout skeleton + dedicated command line
5
+ * - 6 read-only panels
6
+ * - 1 command line (only writable area)
7
+ * - Focus locked to command line
8
+ *
9
+ * Phase 2: Command Router
10
+ * - Command parsing and routing
11
+ * - Output to OPERATIONS FEED panel
12
+ *
13
+ * Phase 3: Operations Feed as Only Output Channel
14
+ * - EventBus system
15
+ * - All output goes through EventBus → feedStore
16
+ * - Long line truncation
17
+ */
18
+ import blessed from 'neo-blessed';
19
+ // Type assertion for blessed (textbox not in types)
20
+ const blessedLib = blessed;
21
+ import { computePhase1Layout } from './layout/phase1Layout.js';
22
+ import { feedStore, formatTimestamp } from '../state/feedModel.js';
23
+ import { parseCommand } from '../commands/parser.js';
24
+ import { routeCommand } from '../commands/router.js';
25
+ import { eventBus } from '../core/eventBus.js';
26
+ import { buildUiState } from '../state/uiStateBuilder.js';
27
+ import { renderResourcesPanel } from './panels/ResourcesPanel.js';
28
+ import { isAvailable, isUnavailable } from '../state/value.js';
29
+ let screen = null;
30
+ let panels = [];
31
+ let commandLine = null;
32
+ let statusStrip = null;
33
+ let isCleaningUp = false;
34
+ let currentCommandValue = '4runr> '; // Track current command value
35
+ let currentUiState = null; // Phase 4: Current UiState
36
+ let lastResourcesAvailable = null; // Phase 4: Track state transitions
37
+ /**
38
+ * Cleanup and exit
39
+ */
40
+ /**
41
+ * Update operations panel with latest feed entries (Phase 3)
42
+ *
43
+ * Applies truncation to prevent overflow into adjacent panels
44
+ */
45
+ function updateOperationsPanel() {
46
+ const operationsPanel = panels[3]; // OPERATIONS is 4th panel (index 3)
47
+ if (!operationsPanel)
48
+ return;
49
+ const contentLines = formatFeedEntries();
50
+ const paddingTop = '\n';
51
+ const paddingLeft = ' ';
52
+ // Calculate available space (account for border and padding)
53
+ const innerHeight = operationsPanel.height - 2; // Top and bottom border
54
+ const innerWidth = operationsPanel.width - 4; // Left/right border + padding
55
+ // Truncate to fit panel height
56
+ const displayLines = contentLines.slice(-innerHeight);
57
+ // Phase 3: Apply truncation to each line (prevents overflow)
58
+ const truncatedLines = displayLines.map(line => {
59
+ return truncateLine(line, innerWidth);
60
+ });
61
+ const content = truncatedLines
62
+ .map(line => paddingLeft + line)
63
+ .join('\n');
64
+ operationsPanel.setContent(paddingTop + content);
65
+ }
66
+ /**
67
+ * Update resources panel content (Phase 4)
68
+ *
69
+ * Updates text in-place without recreating widget (no flicker)
70
+ */
71
+ function updateResourcesPanel() {
72
+ const resourcesPanel = panels[1]; // RESOURCES is 2nd panel (index 1)
73
+ if (!resourcesPanel || !currentUiState)
74
+ return;
75
+ const contentLines = renderResourcesPanel(currentUiState.resources);
76
+ const paddingTop = '\n';
77
+ const paddingLeft = ' ';
78
+ // Calculate available space (account for border and padding)
79
+ const innerHeight = resourcesPanel.height - 2; // Top and bottom border
80
+ const innerWidth = resourcesPanel.width - 4; // Left/right border + padding
81
+ // Truncate to fit panel height (max ~6 lines)
82
+ const displayLines = contentLines.slice(0, Math.min(contentLines.length, innerHeight));
83
+ // Truncate each line to fit width (Phase 4)
84
+ const truncatedLines = displayLines.map(line => {
85
+ return truncateLine(line, innerWidth);
86
+ });
87
+ // Pad to fill available height if needed
88
+ while (truncatedLines.length < innerHeight) {
89
+ truncatedLines.push('');
90
+ }
91
+ const content = truncatedLines
92
+ .map(line => paddingLeft + line)
93
+ .join('\n');
94
+ // Update content in-place (no widget recreation = no flicker)
95
+ resourcesPanel.setContent(paddingTop + content);
96
+ }
97
+ function cleanupAndExit(code = 0) {
98
+ if (isCleaningUp)
99
+ return;
100
+ isCleaningUp = true;
101
+ // Clear render interval
102
+ if (screen && screen.renderInterval) {
103
+ clearInterval(screen.renderInterval);
104
+ }
105
+ if (screen) {
106
+ try {
107
+ screen.destroy();
108
+ }
109
+ catch (e) {
110
+ // Ignore destroy errors
111
+ }
112
+ screen = null;
113
+ }
114
+ // Restore terminal state
115
+ if (process.stdout.isTTY) {
116
+ process.stdout.write('\x1b[?25h'); // Show cursor
117
+ process.stdout.write('\x1b[?1049l'); // Exit alternate screen
118
+ }
119
+ process.exit(code);
120
+ }
121
+ /**
122
+ * Create a read-only panel
123
+ */
124
+ function createPanel(screen, boxRect, title, getContent) {
125
+ const panel = blessedLib.box({
126
+ top: boxRect.top,
127
+ left: boxRect.left,
128
+ width: boxRect.width,
129
+ height: boxRect.height,
130
+ border: {
131
+ type: 'line',
132
+ },
133
+ tags: true,
134
+ content: '', // Will be updated if getContent is provided
135
+ style: {
136
+ border: {
137
+ fg: 'cyan',
138
+ },
139
+ },
140
+ // Make panel read-only and non-focusable
141
+ clickable: false,
142
+ keys: false,
143
+ mouse: false,
144
+ input: false,
145
+ });
146
+ // Set title in top border
147
+ panel.setLabel(` {cyan-fg}${title.toUpperCase()}{/}`);
148
+ // Store content getter for updates
149
+ if (getContent) {
150
+ panel.getContent = getContent;
151
+ }
152
+ return panel;
153
+ }
154
+ /**
155
+ * Truncate line to fit width (Phase 3)
156
+ *
157
+ * Rules:
158
+ * - If text.length <= width, return as-is
159
+ * - Else return text.slice(0, width - 1) + "…"
160
+ */
161
+ function truncateLine(text, width) {
162
+ if (text.length <= width) {
163
+ return text;
164
+ }
165
+ return text.slice(0, Math.max(0, width - 1)) + '…';
166
+ }
167
+ /**
168
+ * Format feed entries for display in OPERATIONS panel (Phase 3)
169
+ */
170
+ const FEED_MAX = 12; // Show latest 12 events
171
+ function formatFeedEntries() {
172
+ const events = feedStore.getLast(FEED_MAX);
173
+ const lines = [];
174
+ if (events.length === 0) {
175
+ lines.push('No operations yet');
176
+ lines.push('Type "help" for commands');
177
+ }
178
+ else {
179
+ for (const event of events) {
180
+ const time = formatTimestamp(event.ts);
181
+ const levelColor = event.level === 'ERROR' ? 'red' : event.level === 'WARN' ? 'yellow' : 'white';
182
+ const prefix = `${time} [{${levelColor}-fg}${event.tag}{/}] `;
183
+ const message = event.message;
184
+ // Note: Truncation will be applied based on panel width in updateOperationsPanel
185
+ const line = prefix + message;
186
+ lines.push(line);
187
+ }
188
+ }
189
+ return lines;
190
+ }
191
+ /**
192
+ * Start Phase 1 runtime
193
+ */
194
+ export async function startPhase1Runtime() {
195
+ // Suppress console.log during TUI
196
+ const originalLog = console.log;
197
+ console.log = () => { };
198
+ try {
199
+ // Create screen
200
+ screen = blessedLib.screen({
201
+ smartCSR: true,
202
+ title: '4Runr Terminal UI V3 - Phase 1',
203
+ fullUnicode: true,
204
+ });
205
+ if (!screen) {
206
+ throw new Error('Failed to create screen');
207
+ }
208
+ // Handle exit keys
209
+ screen.key(['q', 'Q', 'C-c'], () => {
210
+ cleanupAndExit(0);
211
+ });
212
+ // Handle signals
213
+ process.on('SIGINT', () => cleanupAndExit(0));
214
+ process.on('SIGTERM', () => cleanupAndExit(0));
215
+ process.on('uncaughtException', (error) => {
216
+ console.log = originalLog;
217
+ console.error('Uncaught exception:', error);
218
+ cleanupAndExit(1);
219
+ });
220
+ // Compute layout
221
+ const width = screen.width;
222
+ const height = screen.height;
223
+ const layoutResult = computePhase1Layout(width, height);
224
+ if (!layoutResult.ok || !layoutResult.layout) {
225
+ // Terminal too small - show error
226
+ const errorBox = blessed.box({
227
+ top: Math.floor((height - 5) / 2),
228
+ left: Math.floor((width - 60) / 2),
229
+ width: 60,
230
+ height: 5,
231
+ border: {
232
+ type: 'line',
233
+ },
234
+ tags: true,
235
+ content: `\n ${layoutResult.errorMessage || 'Terminal too small'}\n\n Press q or Ctrl+C to exit`,
236
+ style: {
237
+ border: {
238
+ fg: 'red',
239
+ },
240
+ fg: 'red',
241
+ },
242
+ });
243
+ screen.append(errorBox);
244
+ screen.render();
245
+ return;
246
+ }
247
+ const layout = layoutResult.layout;
248
+ // Create all panels (read-only)
249
+ if (!screen)
250
+ throw new Error('Screen not initialized');
251
+ panels.push(createPanel(screen, layout.posture, 'POSTURE'));
252
+ // RESOURCES panel (Phase 4: real metrics)
253
+ const resourcesPanel = createPanel(screen, layout.resources, 'RESOURCES');
254
+ panels.push(resourcesPanel);
255
+ panels.push(createPanel(screen, layout.assets, 'ASSETS'));
256
+ // OPERATIONS panel with feed content (Phase 3: EventBus)
257
+ const operationsPanel = createPanel(screen, layout.operations, 'OPERATIONS', formatFeedEntries);
258
+ panels.push(operationsPanel);
259
+ panels.push(createPanel(screen, layout.network, 'NETWORK'));
260
+ panels.push(createPanel(screen, layout.capabilities, 'CAPABILITIES'));
261
+ // Create status strip (left side of bottom bar)
262
+ const statusWidth = Math.floor(layout.commandLine.width * 0.6); // 60% for status
263
+ statusStrip = blessedLib.box({
264
+ top: layout.commandLine.top,
265
+ left: layout.commandLine.left,
266
+ width: statusWidth,
267
+ height: layout.commandLine.height,
268
+ border: {
269
+ type: 'line',
270
+ },
271
+ tags: true,
272
+ content: ' MODE: OFFLINE | CONNECT: NO | POSTURE: UNKNOWN ',
273
+ style: {
274
+ border: {
275
+ fg: 'grey',
276
+ },
277
+ fg: 'grey',
278
+ },
279
+ clickable: false,
280
+ keys: false,
281
+ mouse: false,
282
+ input: false,
283
+ });
284
+ statusStrip.setLabel(' {grey-fg}STATUS{/}');
285
+ // Create command line (right side of bottom bar)
286
+ const commandWidth = layout.commandLine.width - statusWidth - 1; // Remaining width
287
+ commandLine = blessedLib.textbox({
288
+ top: layout.commandLine.top,
289
+ left: layout.commandLine.left + statusWidth + 1,
290
+ width: commandWidth,
291
+ height: layout.commandLine.height,
292
+ border: {
293
+ type: 'line',
294
+ },
295
+ tags: true,
296
+ content: '',
297
+ style: {
298
+ border: {
299
+ fg: 'cyan',
300
+ },
301
+ fg: 'white',
302
+ focus: {
303
+ border: {
304
+ fg: 'green',
305
+ },
306
+ fg: 'white',
307
+ },
308
+ },
309
+ input: true,
310
+ keys: true,
311
+ mouse: true,
312
+ inputOnFocus: true,
313
+ });
314
+ if (!commandLine)
315
+ throw new Error('Command line not initialized');
316
+ commandLine.setLabel(' {cyan-fg}COMMAND LINE{/}');
317
+ // Set initial prompt
318
+ commandLine.setValue('4runr> ');
319
+ // Command history (in-memory)
320
+ const commandHistory = [];
321
+ // Handle command submission (Phase 3: EventBus)
322
+ if (!commandLine)
323
+ throw new Error('Command line not initialized');
324
+ commandLine.on('submit', (value) => {
325
+ // Parse command
326
+ const parsed = parseCommand(value);
327
+ if (!parsed) {
328
+ // Empty command - do nothing, keep focus
329
+ commandLine?.focus();
330
+ screen?.render();
331
+ return;
332
+ }
333
+ // Add command to history
334
+ commandHistory.push(value);
335
+ // Phase 3: Emit command event first
336
+ eventBus.emitTag('CMD', value.trim());
337
+ // Route command (handlers emit events through EventBus)
338
+ const result = routeCommand(parsed.cmd, parsed.args);
339
+ // Process result
340
+ if (result.exitApp) {
341
+ // Exit the application
342
+ cleanupAndExit(0);
343
+ return;
344
+ }
345
+ // Clear input and restore prompt after submission
346
+ currentCommandValue = '4runr> ';
347
+ commandLine?.setValue('4runr> ');
348
+ commandLine?.clearValue();
349
+ // Keep focus on command line
350
+ commandLine?.focus();
351
+ // Update operations panel and rerender
352
+ updateOperationsPanel();
353
+ screen?.render();
354
+ });
355
+ // Track command value changes
356
+ commandLine.on('keypress', () => {
357
+ // Update tracked value (approximate)
358
+ const value = commandLine.value || '';
359
+ if (value) {
360
+ currentCommandValue = value;
361
+ }
362
+ });
363
+ // Handle resize
364
+ const currentScreen = screen;
365
+ if (currentScreen) {
366
+ currentScreen.on('resize', () => {
367
+ if (!currentScreen)
368
+ return;
369
+ // Recompute layout on resize
370
+ const newWidth = currentScreen.width;
371
+ const newHeight = currentScreen.height;
372
+ const newLayoutResult = computePhase1Layout(newWidth, newHeight);
373
+ if (newLayoutResult.ok && newLayoutResult.layout) {
374
+ // Remove old widgets
375
+ panels.forEach(panel => currentScreen.remove(panel));
376
+ if (statusStrip)
377
+ currentScreen.remove(statusStrip);
378
+ if (commandLine)
379
+ currentScreen.remove(commandLine);
380
+ // Clear arrays
381
+ panels = [];
382
+ // Recreate with new layout
383
+ const newLayout = newLayoutResult.layout;
384
+ panels.push(createPanel(currentScreen, newLayout.posture, 'POSTURE'));
385
+ // RESOURCES panel (Phase 4: real metrics)
386
+ const newResourcesPanel = createPanel(currentScreen, newLayout.resources, 'RESOURCES');
387
+ panels.push(newResourcesPanel);
388
+ panels.push(createPanel(currentScreen, newLayout.assets, 'ASSETS'));
389
+ // OPERATIONS panel with feed content (Phase 3: EventBus)
390
+ const newOperationsPanel = createPanel(currentScreen, newLayout.operations, 'OPERATIONS', formatFeedEntries);
391
+ panels.push(newOperationsPanel);
392
+ panels.push(createPanel(currentScreen, newLayout.network, 'NETWORK'));
393
+ panels.push(createPanel(currentScreen, newLayout.capabilities, 'CAPABILITIES'));
394
+ // Recreate status strip
395
+ const newStatusWidth = Math.floor(newLayout.commandLine.width * 0.6);
396
+ statusStrip = blessedLib.box({
397
+ top: newLayout.commandLine.top,
398
+ left: newLayout.commandLine.left,
399
+ width: newStatusWidth,
400
+ height: newLayout.commandLine.height,
401
+ border: { type: 'line' },
402
+ tags: true,
403
+ content: ' MODE: OFFLINE | CONNECT: NO | POSTURE: UNKNOWN ',
404
+ style: { border: { fg: 'grey' }, fg: 'grey' },
405
+ clickable: false,
406
+ keys: false,
407
+ mouse: false,
408
+ input: false,
409
+ });
410
+ if (!statusStrip)
411
+ throw new Error('Status strip not initialized');
412
+ statusStrip.setLabel(' {grey-fg}STATUS{/}');
413
+ // Recreate command line
414
+ const newCommandWidth = newLayout.commandLine.width - newStatusWidth - 1;
415
+ commandLine = blessedLib.textbox({
416
+ top: newLayout.commandLine.top,
417
+ left: newLayout.commandLine.left + newStatusWidth + 1,
418
+ width: newCommandWidth,
419
+ height: newLayout.commandLine.height,
420
+ border: { type: 'line' },
421
+ tags: true,
422
+ content: '',
423
+ style: {
424
+ border: { fg: 'cyan' },
425
+ fg: 'white',
426
+ focus: { border: { fg: 'green' }, fg: 'white' },
427
+ },
428
+ input: true,
429
+ keys: true,
430
+ mouse: true,
431
+ inputOnFocus: true,
432
+ });
433
+ if (!commandLine)
434
+ throw new Error('Command line not initialized');
435
+ commandLine.setLabel(' {cyan-fg}COMMAND LINE{/}');
436
+ commandLine.setValue(currentCommandValue);
437
+ // Re-attach event handlers (Phase 3: EventBus)
438
+ commandLine.on('submit', (value) => {
439
+ // Parse command
440
+ const parsed = parseCommand(value);
441
+ if (!parsed) {
442
+ // Empty command - do nothing, keep focus
443
+ commandLine?.focus();
444
+ currentScreen?.render();
445
+ return;
446
+ }
447
+ // Add command to history
448
+ commandHistory.push(value);
449
+ // Phase 3: Emit command event first
450
+ eventBus.emitTag('CMD', value.trim());
451
+ // Route command (handlers emit events through EventBus)
452
+ const result = routeCommand(parsed.cmd, parsed.args);
453
+ // Process result
454
+ if (result.exitApp) {
455
+ // Exit the application
456
+ cleanupAndExit(0);
457
+ return;
458
+ }
459
+ // Clear input and restore prompt after submission
460
+ currentCommandValue = '4runr> ';
461
+ commandLine?.setValue('4runr> ');
462
+ commandLine?.clearValue();
463
+ // Keep focus on command line
464
+ commandLine?.focus();
465
+ // Update operations panel and rerender
466
+ updateOperationsPanel();
467
+ updateResourcesPanel();
468
+ currentScreen?.render();
469
+ });
470
+ commandLine.on('keypress', () => {
471
+ const value = commandLine.value || '';
472
+ if (value) {
473
+ currentCommandValue = value;
474
+ }
475
+ });
476
+ commandLine.key('tab', () => {
477
+ commandLine?.focus();
478
+ screen?.render();
479
+ });
480
+ // Append all widgets
481
+ panels.forEach(panel => currentScreen.append(panel));
482
+ if (statusStrip)
483
+ currentScreen.append(statusStrip);
484
+ if (commandLine) {
485
+ currentScreen.append(commandLine);
486
+ // Force focus back to command line
487
+ commandLine.focus();
488
+ currentScreen.focused = commandLine;
489
+ }
490
+ // Update panels with current state after resize
491
+ updateOperationsPanel();
492
+ updateResourcesPanel();
493
+ }
494
+ currentScreen.render();
495
+ });
496
+ }
497
+ // Prevent Tab from moving focus to panels
498
+ if (commandLine) {
499
+ commandLine.key('tab', () => {
500
+ // Tab does nothing - stay in command line
501
+ commandLine?.focus();
502
+ screen?.render();
503
+ });
504
+ }
505
+ // Append all widgets
506
+ panels.forEach(panel => screen?.append(panel));
507
+ if (!screen)
508
+ throw new Error('Screen not initialized');
509
+ if (statusStrip)
510
+ screen.append(statusStrip);
511
+ if (commandLine)
512
+ screen.append(commandLine);
513
+ // CRITICAL: Force focus to command line on startup
514
+ if (commandLine) {
515
+ commandLine.focus();
516
+ screen.focused = commandLine;
517
+ }
518
+ // Prevent focus from entering panels
519
+ // Set screen to only allow focus on command line
520
+ const focusScreen = screen;
521
+ if (focusScreen) {
522
+ focusScreen.on('focus', (widget) => {
523
+ // If focus tries to go to a panel, redirect to command line
524
+ if (widget && typeof widget !== 'string' && panels.includes(widget)) {
525
+ if (commandLine && focusScreen) {
526
+ commandLine.focus();
527
+ focusScreen.focused = commandLine;
528
+ }
529
+ }
530
+ });
531
+ }
532
+ // Update operations panel with feed content
533
+ updateOperationsPanel();
534
+ // Phase 4: Initial UiState build
535
+ currentUiState = await buildUiState();
536
+ lastResourcesAvailable = isAvailable(currentUiState.resources);
537
+ updateResourcesPanel();
538
+ // Initial render
539
+ screen.render();
540
+ // Render loop to update operations feed and resources (every 1500ms)
541
+ const renderInterval = setInterval(async () => {
542
+ // Update operations feed
543
+ updateOperationsPanel();
544
+ // Phase 4: Update resources panel
545
+ try {
546
+ const newState = await buildUiState();
547
+ // Check for state transition (AVAILABLE → UNAVAILABLE)
548
+ const wasAvailable = lastResourcesAvailable;
549
+ const isNowAvailable = isAvailable(newState.resources);
550
+ if (wasAvailable && !isNowAvailable && isUnavailable(newState.resources)) {
551
+ // Transition to UNAVAILABLE - emit event
552
+ eventBus.emitTag('SYS', `RESOURCES UNAVAILABLE: ${newState.resources.reason || 'Unknown reason'}`, 'WARN');
553
+ }
554
+ lastResourcesAvailable = isNowAvailable;
555
+ currentUiState = newState;
556
+ updateResourcesPanel();
557
+ }
558
+ catch (error) {
559
+ // If state building fails, don't crash - just skip this update
560
+ // Error is already logged if DEBUG_NO_TUI=1
561
+ }
562
+ screen?.render();
563
+ }, 1500);
564
+ // Store interval for cleanup
565
+ screen.renderInterval = renderInterval;
566
+ // Restore console.log
567
+ console.log = originalLog;
568
+ }
569
+ catch (error) {
570
+ console.log = originalLog;
571
+ throw error;
572
+ }
573
+ }
574
+ //# sourceMappingURL=phase1Runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phase1Runtime.js","sourceRo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AsB,CAAC;gBAC5C,MAAM,cAAc,GAAG,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;gBAEvD,IAAI,YAAY,IAAI,CAAC,cAAc,IAAI,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;oBACzE,yCAAyC;oBACzC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,0BAA0B,QAAQ,CAAC,SAAS,CAAC,MAAM,IAAI,gBAAgB,EAAE,EAAE,MAAM,CAAC,CAAC;gBAC7G,CAAC;gBAED,sBAAsB,GAAG,cAAc,CAAC;gBACxC,cAAc,GAAG,QAAQ,CAAC;gBAC1B,oBAAoB,EAAE,CAAC;YACzB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,+DAA+D;gBAC/D,4CAA4C;YAC9C,CAAC;YAED,MAAM,EAAE,MAAM,EAAE,CAAC;QACnB,CAAC,EAAE,IAAI,CAAC,CAAC;QAET,6BAA6B;QAC5B,MAAc,CAAC,cAAc,GAAG,cAAc,CAAC;QAEhD,sBAAsB;QACtB,OAAO,CAAC,GAAG,GAAG,WAAW,CAAC;IAE5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,GAAG,WAAW,CAAC;QAC1B,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Panel Primitive
3
+ *
4
+ * THE ONLY WAY TO DRAW PANELS
5
+ *
6
+ * Responsibilities:
7
+ * - Draw a bordered box at given position
8
+ * - Render title in top border
9
+ * - Render content with padding
10
+ * - Enforce line budget (truncate safely)
11
+ * - Enforce line width budget (clamp to innerWidth)
12
+ */
13
+ import type { Widgets } from 'neo-blessed';
14
+ import { theme } from '../theme.js';
15
+ export interface BoxRect {
16
+ top: number;
17
+ left: number;
18
+ width: number;
19
+ height: number;
20
+ }
21
+ export interface PanelOptions {
22
+ screen: Widgets.Screen;
23
+ boxRect: BoxRect;
24
+ title: string;
25
+ lines: string[];
26
+ borderColor?: keyof typeof theme.colors;
27
+ severity?: 'info' | 'warn' | 'error';
28
+ }
29
+ /**
30
+ * Create and render a panel
31
+ *
32
+ * Rules:
33
+ * - Never crashes if content is too long (truncates)
34
+ * - Enforces line budget
35
+ * - Enforces line width budget
36
+ * - No wrapping (truncation only)
37
+ */
38
+ export declare function createPanel(options: PanelOptions): Widgets.Box;
39
+ //# sourceMappingURL=Panel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../../../src/ui/v3/ui/primitives/Panel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,OAAO,KAAK,CAAC,MAAM,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CACtC;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAwE9D"}