Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-harness/blob/main/cli/src/ui/App.tsx # omega-harness Agent skills for operating, encoding and communicating in Omega (.om) and the AIEN repositories Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-harness / cli / src / ui / App.tsx` 973 lines · 31621 bytes Raw Blame History 1 import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; 2 import { Box, Static, Text, useApp, useInput, useStdout } from 'ink'; 3 import Spinner from 'ink-spinner'; 4 import TextInput from 'ink-text-input'; 5 import { 6 CLI_VERSION, 7 SYMBOL, 8 THEME, 9 renderBanner, 10 } from '../brand.js'; 11 import { 12 DEFAULT_GEMINI_MODEL, 13 DEFAULT_INKLING_MODEL, 14 RECOMMENDED_MODELS, 15 detectGitBranch, 16 formatShortPath, 17 writePersistedConfig, 18 type ApprovalMode, 19 type OmegaConfig, 20 type ProviderKind, 21 } from '../config.js'; 22 import { 23 buildSystemPrompt, 24 compileAndRunOmFile, 25 compileOmFile, 26 discoverSkills, 27 readPinInfo, 28 } from '../harness.js'; 29 import { 30 OmegaAgent, 31 type ApprovalDecision, 32 type TokenUsage, 33 type ToolEvent, 34 } from '../agent.js'; 35 import { probeInkling, type InklingHealth } from '../inkling.js'; 36 import { TOOL_DECLARATIONS } from '../tools.js'; 37 import { formatMemories } from '../state.js'; 38 import { SLASH_COMMANDS, matchSlashCommands } from '../commands.js'; 39 import { Markdown } from './Markdown.js'; 40 41 interface TranscriptItem { 42 id: string; 43 kind: 'banner' | 'user' | 'assistant' | 'system' | 'error' | 'tool'; 44 text?: string; 45 tool?: ToolEvent; 46 } 47 48 interface PendingApproval { 49 event: ToolEvent; 50 resolve: (decision: ApprovalDecision) => void; 51 } 52 53 export interface AppProps { 54 config: OmegaConfig; 55 cwd: string; 56 initialPrompt?: string; 57 initialSkills?: string[]; 58 resumeSession?: string; 59 } 60 61 const ToolCard: React.FC<{ tool: ToolEvent }> = ({ tool }) => { 62 const icon = 63 tool.status === 'success' 64 ? '✓' 65 : tool.status === 'error' 66 ? '✗' 67 : tool.status === 'denied' 68 ? '⊘' 69 : '…'; 70 const color = 71 tool.status === 'success' 72 ? THEME.success 73 : tool.status === 'error' 74 ? THEME.error 75 : tool.status === 'denied' 76 ? THEME.warning 77 : THEME.symbol; 78 79 return ( 80 88 89 {tool.status === 'running' ? ( 90 91 {' '} 92 93 ) : ( 94 95 {icon}{' '} 96 97 )} 98 99 {SYMBOL} {tool.name} 100 101 {tool.argsPreview ? ( 102 ({tool.argsPreview}) 103 ) : null} 104 105 {tool.preview ? ( 106 107 {tool.preview} 108 109 ) : null} 110 111 ); 112 }; 113 114 export const App: React.FC = ({ 115 config, 116 cwd, 117 initialPrompt, 118 initialSkills = [], 119 resumeSession, 120 }) => { 121 const { exit } = useApp(); 122 const { stdout } = useStdout(); 123 const columns = stdout?.columns || 80; 124 125 const [provider, setProvider] = useState(config.provider); 126 const [endpoint, setEndpoint] = useState(config.endpoint); 127 const [apiKey, setApiKey] = useState(config.apiKey); 128 const [model, setModel] = useState(config.model); 129 const [approvalMode, setApprovalMode] = useState(config.approvalMode); 130 const [activeSkills, setActiveSkills] = useState( 131 Array.from(new Set([...config.defaultSkills, ...initialSkills])) 132 ); 133 const [inklingHealth, setInklingHealth] = useState(null); 134 const [usage, setUsage] = useState({ 135 promptTokens: 0, 136 outputTokens: 0, 137 totalTokens: 0, 138 }); 139 140 const skills = useMemo(() => discoverSkills(config.harnessRoot), [config.harnessRoot]); 141 const pinInfo = useMemo( 142 () => readPinInfo(config.harnessRoot, config.omcPath), 143 [config.harnessRoot, config.omcPath] 144 ); 145 const gitBranch = useMemo(() => detectGitBranch(cwd), [cwd]); 146 147 const [items, setItems] = useState(() => [ 148 { id: 'banner-0', kind: 'banner' }, 149 ]); 150 const [input, setInput] = useState(''); 151 const [inputKey, setInputKey] = useState(0); 152 const [history, setHistory] = useState([]); 153 const [historyIdx, setHistoryIdx] = useState(-1); 154 155 const [busy, setBusy] = useState(false); 156 const [elapsedSec, setElapsedSec] = useState(0); 157 const [streamingText, setStreamingText] = useState(''); 158 const [liveTools, setLiveTools] = useState([]); 159 const [pendingApproval, setPendingApproval] = useState(null); 160 161 const agentRef = useRef(new OmegaAgent(apiKey)); 162 const abortRef = useRef(null); 163 const initialSentRef = useRef(false); 164 165 const pushItem = useCallback((item: Omit) => { 166 setItems((prev) => [ 167 ...prev, 168 { ...item, id: `${Date.now()}-${Math.random().toString(36).slice(2, 7)}` }, 169 ]); 170 }, []); 171 172 const refreshInklingHealth = useCallback( 173 async (ep = endpoint, key = apiKey) => { 174 const h = await probeInkling(ep, key); 175 setInklingHealth(h); 176 return h; 177 }, 178 [endpoint, apiKey] 179 ); 180 181 useEffect(() => { 182 if (provider === 'inkling') { 183 void refreshInklingHealth(endpoint, apiKey); 184 } 185 }, [provider, endpoint, apiKey, refreshInklingHealth]); 186 187 useEffect(() => { 188 if (!busy) { 189 setElapsedSec(0); 190 return; 191 } 192 const start = Date.now(); 193 const timer = setInterval(() => { 194 setElapsedSec(Math.floor((Date.now() - start) / 1000)); 195 }, 500); 196 return () => clearInterval(timer); 197 }, [busy]); 198 199 const runPrompt = useCallback( 200 async (text: string) => { 201 if (provider === 'gemini' && !apiKey) { 202 pushItem({ 203 kind: 'error', 204 text: 'No Gemini API key configured. Run `/auth ` or switch to `/provider inkling`.', 205 }); 206 return; 207 } 208 209 pushItem({ kind: 'user', text }); 210 setBusy(true); 211 setStreamingText(''); 212 setLiveTools([]); 213 214 const controller = new AbortController(); 215 abortRef.current = controller; 216 217 const systemInstruction = buildSystemPrompt({ 218 harnessRoot: config.harnessRoot, 219 cwd, 220 activeSkills, 221 approvalMode, 222 pinInfo, 223 }); 224 225 const finishedTools: ToolEvent[] = []; 226 227 try { 228 const finalText = await agentRef.current.sendTurn(text, { 229 provider, 230 endpoint, 231 apiKey, 232 model, 233 systemInstruction, 234 toolContext: { 235 cwd, 236 harnessRoot: config.harnessRoot, 237 omcPath: config.omcPath, 238 approvalMode, 239 }, 240 signal: controller.signal, 241 callbacks: { 242 onTextDelta: (chunk) => { 243 setStreamingText((prev) => prev + chunk); 244 }, 245 onToolStart: (ev) => { 246 finishedTools.push(ev); 247 setLiveTools([...finishedTools]); 248 }, 249 onToolUpdate: (ev) => { 250 const idx = finishedTools.findIndex((t) => t.id === ev.id); 251 if (idx >= 0) finishedTools[idx] = ev; 252 setLiveTools([...finishedTools]); 253 }, 254 onRequestApproval: (ev) => 255 new Promise((resolve) => { 256 setPendingApproval({ event: ev, resolve }); 257 }), 258 onUsageUpdate: (u) => setUsage({ ...u }), 259 }, 260 }); 261 262 for (const t of finishedTools) { 263 pushItem({ kind: 'tool', tool: t }); 264 } 265 if (finalText.trim()) { 266 pushItem({ kind: 'assistant', text: finalText }); 267 } 268 try { 269 agentRef.current.saveSession('latest'); 270 } catch { 271 // ignore persistence error 272 } 273 if (provider === 'inkling') { 274 void refreshInklingHealth(endpoint, apiKey); 275 } 276 } catch (err: unknown) { 277 for (const t of finishedTools) { 278 pushItem({ kind: 'tool', tool: t }); 279 } 280 const msg = err instanceof Error ? err.message : String(err); 281 pushItem({ kind: 'error', text: msg }); 282 } finally { 283 abortRef.current = null; 284 setStreamingText(''); 285 setLiveTools([]); 286 setBusy(false); 287 } 288 }, 289 [ 290 activeSkills, 291 apiKey, 292 approvalMode, 293 config.harnessRoot, 294 config.omcPath, 295 cwd, 296 endpoint, 297 model, 298 pinInfo, 299 provider, 300 pushItem, 301 refreshInklingHealth, 302 ] 303 ); 304 305 useEffect(() => { 306 if (resumeSession) { 307 const res = agentRef.current.loadSession(resumeSession); 308 if (res.ok) { 309 setUsage({ ...agentRef.current.usage }); 310 pushItem({ 311 kind: 'system', 312 text: `Resumed session "${resumeSession}" (${res.turns} previous turns, saved ${res.savedAt || 'earlier'}).`, 313 }); 314 } 315 } 316 }, [resumeSession, pushItem]); 317 318 useEffect(() => { 319 if (initialPrompt && !initialSentRef.current) { 320 initialSentRef.current = true; 321 void runPrompt(initialPrompt); 322 } 323 }, [initialPrompt, runPrompt]); 324 325 const handleSlashCommand = useCallback( 326 async (raw: string) => { 327 const parts = raw.trim().split(/\s+/); 328 const cmd = parts[0].toLowerCase(); 329 const arg = parts.slice(1).join(' ').trim(); 330 331 switch (cmd) { 332 case '/exit': 333 case '/quit': 334 exit(); 335 return; 336 337 case '/help': { 338 const lines = [ 339 `${SYMBOL} Omega Harness CLI v${CLI_VERSION} — Slash Commands`, 340 '', 341 ...SLASH_COMMANDS.map((c) => ` ${c.usage.padEnd(36)} ${c.description}`), 342 '', 343 'Shortcuts & Tips:', 344 ' @path/to/file.om Attach a file directly into your prompt', 345 ' Up / Down Browse prompt history', 346 ' Ctrl+C Cancel active generation (or exit when idle)', 347 ]; 348 pushItem({ kind: 'system', text: lines.join('\n') }); 349 return; 350 } 351 352 case '/status': { 353 const h = await refreshInklingHealth(endpoint, apiKey); 354 const lines = [ 355 `Provider: ${provider}`, 356 `Inkling URL: ${h.endpoint}`, 357 `Status: ${h.online ? 'ONLINE' : `OFFLINE (${h.error || 'unreachable'})`}`, 358 `Engine: ${h.engine}`, 359 `Model: ${h.model || model}`, 360 ...(h.contextWindow !== undefined 361 ? [`Context: ${h.contextWindow.toLocaleString()} tokens/slot`] 362 : []), 363 ...(h.kvPrefixHits !== undefined 364 ? [`KV Cache Hits: ${h.kvPrefixHits}`] 365 : []), 366 ...(h.slotsMax !== undefined 367 ? [`KV Slots: ${h.slotsActive ?? 0} / ${h.slotsMax} active`] 368 : []), 369 ...(h.arborisTransitions !== undefined 370 ? [ 371 `Arboris: ACTIVE (transitions=${h.arborisTransitions}, top8=${h.arborisTransitions > 0 ? ((100 * (h.arborisTop8Hits ?? 0)) / (h.arborisTransitions * 8)).toFixed(1) : '0.0'}%, top16=${h.arborisTransitions > 0 ? ((100 * (h.arborisTop16Hits ?? 0)) / (h.arborisTransitions * 8)).toFixed(1) : '0.0'}%)`, 372 ] 373 : []), 374 ...(!h.online 375 ? [ 376 '', 377 'To connect to Inkling-2-Mini on Spark:', 378 ' 1. On Spark: spark-window run build/inkling2/inkling2-serve', 379 ' 2. Tunnel: ssh -N -L 8080:127.0.0.1:8080 spark', 380 ] 381 : []), 382 ]; 383 pushItem({ kind: h.online ? 'system' : 'error', text: lines.join('\n') }); 384 return; 385 } 386 387 case '/tools': { 388 const lines = [ 389 `Ω Available Agent Tools (${TOOL_DECLARATIONS.length}):`, 390 ...TOOL_DECLARATIONS.map((t) => ` • ${(t.name || '').padEnd(26)} ${t.description || ''}`), 391 ]; 392 pushItem({ kind: 'system', text: lines.join('\n') }); 393 return; 394 } 395 396 case '/agents': { 397 const out = agentRef.current.state.formatSubagents(); 398 pushItem({ kind: 'system', text: `Ω Subagents:\n${out}` }); 399 return; 400 } 401 402 case '/tasks': { 403 const out = agentRef.current.state.formatTodos(); 404 pushItem({ kind: 'system', text: `Ω Session Tasks:\n${out}` }); 405 return; 406 } 407 408 case '/memory': { 409 const out = formatMemories(arg || undefined); 410 pushItem({ kind: 'system', text: `Ω Persistent Memory:\n${out}` }); 411 return; 412 } 413 414 case '/endpoint': { 415 if (!arg) { 416 pushItem({ 417 kind: 'system', 418 text: `Current Inkling endpoint: ${endpoint}\nSwitch with: /endpoint http://127.0.0.1:8080`, 419 }); 420 return; 421 } 422 const clean = arg.replace(/\/+$/, ''); 423 setEndpoint(clean); 424 writePersistedConfig({ endpoint: clean }); 425 const h = await refreshInklingHealth(clean, apiKey); 426 pushItem({ 427 kind: h.online ? 'system' : 'error', 428 text: `Endpoint set to ${clean} (${h.online ? `ONLINE · ${h.engine}` : `OFFLINE: ${h.error}`})`, 429 }); 430 return; 431 } 432 433 case '/provider': { 434 if (!arg || (arg !== 'inkling' && arg !== 'gemini')) { 435 pushItem({ 436 kind: 'system', 437 text: `Active provider: ${provider}\nAvailable: inkling (default) | gemini\nUsage: /provider `, 438 }); 439 return; 440 } 441 const next = arg as ProviderKind; 442 const nextModel = next === 'inkling' ? DEFAULT_INKLING_MODEL : DEFAULT_GEMINI_MODEL; 443 setProvider(next); 444 setModel(nextModel); 445 writePersistedConfig({ provider: next, model: nextModel }); 446 pushItem({ 447 kind: 'system', 448 text: `Switched provider to ${next} (model: ${nextModel}).`, 449 }); 450 return; 451 } 452 453 case '/skills': { 454 const lines = [ 455 `Omega Harness Skills (${skills.length} in ${formatShortPath(config.harnessRoot)}/skills):`, 456 ...skills.map((s) => { 457 const pinned = activeSkills.includes(s.name) ? ' [PINNED]' : ''; 458 return ` • ${s.name}${pinned} — ${s.description.slice(0, 92)}${s.description.length > 92 ? '…' : ''}`; 459 }), 460 '', 461 'Use `/skill ` to pin/unpin a skill in the system prompt.', 462 ]; 463 pushItem({ kind: 'system', text: lines.join('\n') }); 464 return; 465 } 466 467 case '/skill': { 468 if (!arg) { 469 pushItem({ kind: 'system', text: 'Usage: /skill (run /skills to list all)' }); 470 return; 471 } 472 const found = skills.find((s) => s.name.toLowerCase() === arg.toLowerCase()); 473 if (!found) { 474 pushItem({ kind: 'error', text: `Unknown skill "${arg}". Run /skills to see available skills.` }); 475 return; 476 } 477 if (activeSkills.includes(found.name)) { 478 setActiveSkills((prev) => prev.filter((x) => x !== found.name)); 479 pushItem({ kind: 'system', text: `Unpinned skill: ${found.name}` }); 480 } else { 481 setActiveSkills((prev) => [...prev, found.name]); 482 pushItem({ kind: 'system', text: `Pinned skill into active system prompt: ${found.name}` }); 483 } 484 return; 485 } 486 487 case '/model': { 488 if (!arg) { 489 const recs = RECOMMENDED_MODELS[provider]; 490 const lines = [ 491 `Active model (${provider}): ${model}`, 492 'Recommended models:', 493 ...recs.map((m) => ` • ${m.id.padEnd(24)} ${m.note}`), 494 'Switch with: /model ', 495 ]; 496 pushItem({ kind: 'system', text: lines.join('\n') }); 497 return; 498 } 499 setModel(arg); 500 writePersistedConfig({ model: arg }); 501 pushItem({ kind: 'system', text: `Switched model to ${arg} (saved as default).` }); 502 return; 503 } 504 505 case '/mode': { 506 const valid: ApprovalMode[] = ['default', 'auto-edit', 'yolo', 'omega-only']; 507 if (!arg || !valid.includes(arg as ApprovalMode)) { 508 pushItem({ 509 kind: 'system', 510 text: `Current mode: ${approvalMode}\nAvailable modes: ${valid.join(' | ')}\nUsage: /mode `, 511 }); 512 return; 513 } 514 const next = arg as ApprovalMode; 515 setApprovalMode(next); 516 pushItem({ kind: 'system', text: `Approval mode set to: ${next}` }); 517 return; 518 } 519 520 case '/pin': { 521 const lines = [ 522 `Harness root: ${config.harnessRoot}`, 523 `PIN omega-mv: ${pinInfo.omegaMvCommit || '(missing)'}`, 524 `PIN omc-sha256: ${pinInfo.omcSha256 || '(missing)'}`, 525 `Local omc: ${pinInfo.localOmcPath || '(not found)'}`, 526 `Local sha256: ${pinInfo.localOmcSha256 || '(n/a)'}`, 527 `Match: ${pinInfo.pinMatches === undefined ? 'unknown' : pinInfo.pinMatches ? 'EXACT MATCH' : 'DIFFERENT (local/macOS build)'}`, 528 ]; 529 pushItem({ kind: 'system', text: lines.join('\n') }); 530 return; 531 } 532 533 case '/compile': { 534 if (!arg) { 535 pushItem({ kind: 'system', text: 'Usage: /compile ' }); 536 return; 537 } 538 const res = compileOmFile(arg.startsWith('/') ? arg : `${cwd}/${arg}`, { 539 omcPath: config.omcPath, 540 harnessRoot: config.harnessRoot, 541 }); 542 if (res.ok) { 543 pushItem({ 544 kind: 'system', 545 text: `✓ omc compile PASS: ${arg} (${res.binarySize} bytes)`, 546 }); 547 } else { 548 const extra = res.errorDoc 549 ? `\n meaning: ${res.errorDoc.meaning}${res.errorDoc.fix ? `\n fix: ${res.errorDoc.fix}` : ''}` 550 : ''; 551 pushItem({ kind: 'error', text: `✗ omc compile FAIL: ${res.stderr}${extra}` }); 552 } 553 return; 554 } 555 556 case '/run': { 557 if (!arg) { 558 pushItem({ kind: 'system', text: 'Usage: /run ' }); 559 return; 560 } 561 const res = compileAndRunOmFile(arg.startsWith('/') ? arg : `${cwd}/${arg}`, { 562 omcPath: config.omcPath, 563 harnessRoot: config.harnessRoot, 564 }); 565 if (!res.compile.ok) { 566 pushItem({ kind: 'error', text: `✗ omc compile FAIL: ${res.compile.stderr}` }); 567 return; 568 } 569 const out = [ 570 `compile: PASS (${res.compile.binarySize} bytes)`, 571 `exit: ${res.exitCode ?? 'null'}${res.timedOut ? ' (TIMED OUT)' : ''}`, 572 res.stdout ? `stdout:\n${res.stdout}` : '', 573 res.stderr ? `stderr:\n${res.stderr}` : '', 574 ] 575 .filter(Boolean) 576 .join('\n'); 577 pushItem({ kind: res.exitCode === 0 ? 'system' : 'error', text: out }); 578 return; 579 } 580 581 case '/resume': { 582 const name = arg || 'latest'; 583 const res = agentRef.current.loadSession(name); 584 if (res.ok) { 585 setUsage({ ...agentRef.current.usage }); 586 pushItem({ 587 kind: 'system', 588 text: `✓ Resumed session "${name}" (${res.turns} turns, saved ${res.savedAt || 'earlier'}).`, 589 }); 590 } else { 591 pushItem({ kind: 'error', text: `No saved session named "${name}".` }); 592 } 593 return; 594 } 595 596 case '/clear': 597 agentRef.current.clearHistory(); 598 setItems([{ id: `banner-${Date.now()}`, kind: 'banner' }]); 599 return; 600 601 case '/compact': { 602 setBusy(true); 603 try { 604 const summary = await agentRef.current.compactHistory({ 605 provider, 606 model, 607 endpoint, 608 apiKey, 609 }); 610 pushItem({ kind: 'system', text: `Session compacted:\n${summary}` }); 611 } catch (err: unknown) { 612 pushItem({ kind: 'error', text: err instanceof Error ? err.message : String(err) }); 613 } finally { 614 setBusy(false); 615 } 616 return; 617 } 618 619 case '/stats': { 620 const turns = agentRef.current.getTurnCount(); 621 const calls = agentRef.current.toolCallCount; 622 pushItem({ 623 kind: 'system', 624 text: [ 625 `Provider: ${provider}${provider === 'inkling' ? ` (${endpoint})` : ''}`, 626 `Model: ${model}`, 627 `Mode: ${approvalMode}`, 628 `Turns: ${turns}`, 629 `Tool calls: ${calls}`, 630 `Tokens: ${usage.totalTokens.toLocaleString()} (in: ${usage.promptTokens.toLocaleString()}, out: ${usage.outputTokens.toLocaleString()})`, 631 `Skills: ${activeSkills.length ? activeSkills.join(', ') : '(on-demand)'}`, 632 ].join('\n'), 633 }); 634 return; 635 } 636 637 case '/auth': { 638 if (!arg) { 639 const status = apiKey 640 ? `Configured (${apiKey.slice(0, 6)}…${apiKey.slice(-4)})` 641 : provider === 'inkling' 642 ? 'Not required for local Inkling (optional bearer token)' 643 : 'Not configured'; 644 pushItem({ 645 kind: 'system', 646 text: `API key: ${status}\nSet with: /auth (saved to ~/.config/omega-harness/config.json, mode 0600)`, 647 }); 648 return; 649 } 650 writePersistedConfig({ apiKey: arg }); 651 setApiKey(arg); 652 agentRef.current.setApiKey(arg); 653 pushItem({ 654 kind: 'system', 655 text: '✓ API key saved to ~/.config/omega-harness/config.json (0600).', 656 }); 657 return; 658 } 659 660 default: 661 pushItem({ kind: 'error', text: `Unknown command "${cmd}". Type /help for available commands.` }); 662 } 663 }, 664 [ 665 activeSkills, 666 apiKey, 667 approvalMode, 668 config.harnessRoot, 669 config.omcPath, 670 cwd, 671 endpoint, 672 exit, 673 model, 674 pinInfo, 675 provider, 676 pushItem, 677 refreshInklingHealth, 678 skills, 679 usage, 680 ] 681 ); 682 683 const handleSubmit = useCallback( 684 (value: string) => { 685 const trimmed = value.trim(); 686 setInput(''); 687 setInputKey((k) => k + 1); 688 setHistoryIdx(-1); 689 690 if (!trimmed) return; 691 setHistory((prev) => [trimmed, ...prev.slice(0, 99)]); 692 693 if (trimmed.startsWith('/')) { 694 void handleSlashCommand(trimmed); 695 } else { 696 void runPrompt(trimmed); 697 } 698 }, 699 [handleSlashCommand, runPrompt] 700 ); 701 702 useInput((ch, key) => { 703 if (pendingApproval) { 704 const lower = ch.toLowerCase(); 705 if (lower === 'y' || key.return) { 706 const p = pendingApproval; 707 setPendingApproval(null); 708 p.resolve('allow'); 709 } else if (lower === 'a') { 710 const p = pendingApproval; 711 setPendingApproval(null); 712 p.resolve('always'); 713 } else if (lower === 'n' || key.escape) { 714 const p = pendingApproval; 715 setPendingApproval(null); 716 p.resolve('deny'); 717 } 718 return; 719 } 720 721 if (key.ctrl && ch === 'c') { 722 if (busy && abortRef.current) { 723 abortRef.current.abort(); 724 } else { 725 exit(); 726 } 727 return; 728 } 729 730 if (!busy && key.upArrow && history.length > 0) { 731 const nextIdx = Math.min(history.length - 1, historyIdx + 1); 732 setHistoryIdx(nextIdx); 733 setInput(history[nextIdx]); 734 setInputKey((k) => k + 1); 735 } else if (!busy && key.downArrow) { 736 if (historyIdx <= 0) { 737 setHistoryIdx(-1); 738 setInput(''); 739 } else { 740 const nextIdx = historyIdx - 1; 741 setHistoryIdx(nextIdx); 742 setInput(history[nextIdx]); 743 } 744 setInputKey((k) => k + 1); 745 } 746 }); 747 748 const slashSuggestions = useMemo(() => matchSlashCommands(input), [input]); 749 const bannerLines = useMemo(() => renderBanner(columns), [columns]); 750 751 const inklingBadge = 752 provider === 'inkling' 753 ? inklingHealth === null 754 ? 'probing…' 755 : inklingHealth.online 756 ? inklingHealth.slotsMax !== undefined 757 ? `online · ${inklingHealth.slotsActive ?? 0}/${inklingHealth.slotsMax} slots` 758 : 'online' 759 : 'offline' 760 : 'gemini-sdk'; 761 762 return ( 763 764 765 {(item) => { 766 if (item.kind === 'banner') { 767 return ( 768 769 {bannerLines.map((line, i) => ( 770 {line} 771 ))} 772 773 774 775 {SYMBOL} Omega Harness CLI 776 777 778 {' '} 779 v{CLI_VERSION} · {provider === 'inkling' ? `Inkling (${endpoint})` : 'Gemini SDK'} ·{' '} 780 {skills.length} skills · {pinInfo.localOmcPath ? 'omc ready' : 'omc not found'} 781 782 783 784 Type a prompt, /status for Inkling health,{' '} 785 /help for commands,{' '} 786 @file to attach context. 787 788 789 790 ); 791 } 792 793 if (item.kind === 'user') { 794 return ( 795 796 797 >{' '} 798 799 800 {item.text} 801 802 803 ); 804 } 805 806 if (item.kind === 'tool' && item.tool) { 807 return ( 808 809 810 811 ); 812 } 813 814 if (item.kind === 'assistant') { 815 return ( 816 817 818 {SYMBOL}{' '} 819 820 821 822 823 824 ); 825 } 826 827 if (item.kind === 'error') { 828 return ( 829 830 ✗ {item.text} 831 832 ); 833 } 834 835 return ( 836 837 {item.text} 838 839 ); 840 }} 841 842 843 {/* Live tool executions during active turn */} 844 {liveTools.map((t) => ( 845 846 ))} 847 848 {/* Live streaming assistant text */} 849 {streamingText ? ( 850 851 852 {SYMBOL}{' '} 853 854 855 856 857 858 ) : null} 859 860 {/* Interactive tool approval prompt */} 861 {pendingApproval ? ( 862 869 870 {SYMBOL} Approve tool call: {pendingApproval.event.name} 871 872 {pendingApproval.event.argsPreview ? ( 873 {pendingApproval.event.argsPreview} 874 ) : null} 875 876 Press [Y]es (Enter) ·{' '} 877 [A]lways allow {pendingApproval.event.name} ·{' '} 878 [N]o (Esc) 879 880 881 ) : null} 882 883 {/* Offline hint banner for Inkling when idle */} 884 {!busy && provider === 'inkling' && inklingHealth && !inklingHealth.online ? ( 885 886 887 ! Inkling offline at {endpoint} — tunnel Spark: `ssh -N -L 8080:127.0.0.1:8080 spark` (or `/endpoint <url>`) 888 889 890 ) : null} 891 892 {/* Spinner when waiting */} 893 {busy && !pendingApproval ? ( 894 895 896 {SYMBOL} {provider === 'inkling' ? 'Inkling' : 'Gemini'} thinking… ({elapsedSec}s) · Ctrl+C to cancel 897 898 899 ) : null} 900 901 {/* Slash command autocomplete dropdown */} 902 {!busy && slashSuggestions.length > 0 ? ( 903 910 {slashSuggestions.slice(0, 7).map((c) => ( 911 912 913 {c.usage.padEnd(34)} 914 915 {c.description} 916 917 ))} 918 919 ) : null} 920 921 {/* Gemini-CLI-style bordered prompt input box with Ω symbol */} 922 927 928 {SYMBOL} >{' '} 929 930 {busy ? ( 931 working… 932 ) : ( 933 940 )} 941 942 943 {/* Bottom status bar */} 944 945 946 {formatShortPath(cwd)} 947 {gitBranch ? ` (${gitBranch})` : ''} 948 949 950 951 [{approvalMode}] 952 953 {activeSkills.length > 0 ? ` · ${activeSkills.length} pinned` : ''} 954 {' · '} 955 {model} 956 {' · '} 957 966 {inklingBadge} 967 968 {usage.totalTokens > 0 ? ` · ${usage.totalTokens.toLocaleString()} tok` : ''} 969 970 971 972 ); 973 };