@testany/hephos 0.3.8 → 0.3.10

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ReplModeInk.d.ts","sourceRoot":"","sources":["../../src/repl/ReplModeInk.tsx"],"names":[],"mappings":"AAAA;;GAEG;AA6iFH,MAAM,WAAW,gBAAgB;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,YAAY,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,QAMjF"}
1
+ {"version":3,"file":"ReplModeInk.d.ts","sourceRoot":"","sources":["../../src/repl/ReplModeInk.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAy1FH,MAAM,WAAW,gBAAgB;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,YAAY,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,QAMjF"}
@@ -10,6 +10,8 @@ import { watch } from 'fs';
10
10
  import * as path from 'path';
11
11
  import { fileURLToPath } from 'url';
12
12
  import { detectAllTools, CORE_VERSION } from '@testany/agent-chatter-core';
13
+ import { checkVersions } from '../utils/versionChecker.js';
14
+ import { Logo } from './components/Logo.js';
13
15
  import { initializeServices } from '@testany/agent-chatter-core';
14
16
  import { LocalExecutionEnvironment } from '../LocalExecutionEnvironment.js';
15
17
  import { AdapterFactory } from '../adapters/AdapterFactory.js';
@@ -23,6 +25,8 @@ import { SessionStorageService } from '@testany/agent-chatter-core';
23
25
  import { RestorePrompt } from './components/RestorePrompt.js';
24
26
  import { QueueDisplay } from './components/QueueDisplay.js';
25
27
  import { TipsBar } from './components/TipsBar.js';
28
+ import { HistoryOverlay } from './components/HistoryOverlay.js';
29
+ import { useHistory } from './hooks/useHistory.js';
26
30
  // Read version from package.json
27
31
  const __filename = fileURLToPath(import.meta.url);
28
32
  const __dirname = path.dirname(__filename);
@@ -56,7 +60,20 @@ const agentsCommands = [
56
60
  ];
57
61
  // 欢迎界面组件
58
62
  function WelcomeScreen() {
59
- return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { borderStyle: "single", borderColor: "cyan", paddingX: 2, paddingY: 1, flexDirection: "column", alignItems: "center", children: [_jsx(Text, { bold: true, color: "cyan", children: "HephOS" }), _jsx(Text, { dimColor: true, children: "Multi-AI Conversation Orchestrator" })] }), _jsxs(Text, { dimColor: true, children: [" CLI ", VERSION, " \u2022 Core ", CORE_VERSION, " \u2022 TestAny.io"] }), _jsxs(Text, { dimColor: true, children: [" Type ", _jsx(Text, { color: "green", children: "/help" }), " for available commands"] }), _jsxs(Text, { dimColor: true, children: [" Type ", _jsx(Text, { color: "green", children: "/exit" }), " to quit"] })] }));
63
+ return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { borderStyle: "round", borderColor: "cyan", paddingX: 2, paddingY: 0, flexDirection: "column", children: [_jsx(Logo, {}), _jsx(Text, { dimColor: true, children: "Multi-AI Conversation Orchestrator" }), _jsx(Text, { children: " " }), _jsxs(Text, { children: [_jsx(Text, { dimColor: true, children: " CLI version " }), _jsx(Text, { color: "white", children: VERSION })] }), _jsxs(Text, { children: [_jsx(Text, { dimColor: true, children: " Core version " }), _jsx(Text, { color: "white", children: CORE_VERSION })] })] }), _jsxs(Text, { dimColor: true, children: [" built by ", _jsx(Text, { color: "cyan", children: "TestAny.io" })] }), _jsxs(Text, { dimColor: true, children: [" Type ", _jsx(Text, { color: "green", children: "/help" }), " for available commands"] }), _jsxs(Text, { dimColor: true, children: [" Type ", _jsx(Text, { color: "green", children: "/exit" }), " to quit"] })] }));
64
+ }
65
+ // 更新通知组件
66
+ function UpdateNotification({ versionInfo }) {
67
+ const updates = [];
68
+ if (versionInfo.cli.hasUpdate && versionInfo.cli.latest) {
69
+ updates.push(_jsx(Text, { children: _jsxs(Text, { color: "yellow", children: [" CLI: ", VERSION, " \u2192 ", versionInfo.cli.latest] }) }, "cli"));
70
+ }
71
+ if (versionInfo.core.hasUpdate && versionInfo.core.latest) {
72
+ updates.push(_jsx(Text, { children: _jsxs(Text, { color: "yellow", children: [" Core: ", CORE_VERSION, " \u2192 ", versionInfo.core.latest] }) }, "core"));
73
+ }
74
+ if (updates.length === 0)
75
+ return null;
76
+ return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { color: "yellow", children: "\u2B06 Updates available:" }), updates, _jsxs(Text, { dimColor: true, children: [" Run: ", _jsx(Text, { color: "cyan", children: "npm i -g @testany/hephos" })] })] }));
60
77
  }
61
78
  // 命令提示组件
62
79
  // In alternateBuffer mode, we need a fixed height to prevent layout jumps
@@ -215,6 +232,8 @@ function App({ registryPath, debug = false, proxyUrl }) {
215
232
  const [isExiting, setIsExiting] = useState(false);
216
233
  const [queueState, setQueueState] = useState(null);
217
234
  const [showTips, setShowTips] = useState(true); // Tips bar visibility (default: on)
235
+ // Command history management
236
+ const history = useHistory();
218
237
  // Track previous queue size to detect DROP-triggered clears
219
238
  const prevQueueSizeRef = useRef(0);
220
239
  // Streaming event handling
@@ -256,16 +275,56 @@ function App({ registryPath, debug = false, proxyUrl }) {
256
275
  }
257
276
  };
258
277
  }, []);
278
+ // Version check on startup - append update notification if available
279
+ useEffect(() => {
280
+ let cancelled = false;
281
+ checkVersions(VERSION, CORE_VERSION).then(versionInfo => {
282
+ if (cancelled)
283
+ return;
284
+ if (versionInfo.cli.hasUpdate || versionInfo.core.hasUpdate) {
285
+ setOutput(prev => [
286
+ ...prev,
287
+ _jsx(UpdateNotification, { versionInfo: versionInfo }, "update-notification")
288
+ ]);
289
+ }
290
+ }).catch(() => {
291
+ // Silently ignore version check failures
292
+ });
293
+ return () => { cancelled = true; };
294
+ }, []);
259
295
  // 获取当前匹配的命令
260
296
  const getMatches = () => {
261
297
  if (!input.startsWith('/'))
262
298
  return [];
263
299
  return commands.filter(cmd => cmd.name.startsWith(input));
264
300
  };
301
+ /**
302
+ * Safely stringify and truncate values (including message parts or tool outputs).
303
+ */
265
304
  const truncate = (val, max = 100) => {
266
- if (!val)
305
+ if (val === undefined || val === null)
267
306
  return '';
268
- return val.length > max ? `${val.slice(0, max)}…` : val;
307
+ const toStringSafe = (v) => {
308
+ if (typeof v === 'string')
309
+ return v;
310
+ if (Array.isArray(v))
311
+ return v.map(toStringSafe).join(' ');
312
+ if (typeof v === 'object') {
313
+ // Common streaming/tool part shape: { type, text }
314
+ const maybeText = v.text;
315
+ if (typeof maybeText === 'string')
316
+ return maybeText;
317
+ try {
318
+ return JSON.stringify(v);
319
+ }
320
+ catch {
321
+ return String(v);
322
+ }
323
+ }
324
+ return String(v);
325
+ };
326
+ const str = toStringSafe(val);
327
+ return str.length > max ? `${str.slice(0, max)}…` : str;
269
328
  };
270
329
  /**
271
330
  * Append node(s) to output, with optional sliding window to keep render fast.
@@ -409,6 +468,8 @@ function App({ registryPath, debug = false, proxyUrl }) {
409
468
  }
410
469
  case 'tool.completed':
411
470
  logEventToDebug(`[tool.completed] ${ev.toolId || ev.toolName} output=${truncate(ev.output)}${ev.error ? ` error=${ev.error}` : ''}`);
471
+ // TEMP debug: capture raw shape to pinpoint object-to-React issues in UAT
472
+ logEventToDebug(`[tool.completed raw] type=${typeof ev.output} isArray=${Array.isArray(ev.output)} sample=${truncate(ev.output, 200)}`);
412
473
  return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: "green", children: ["\u23BF ", truncate(ev.output)] }), ev.error && _jsxs(Text, { color: "red", children: [" error: ", ev.error] })] }, key));
413
474
  case 'turn.completed':
414
475
  return null; // internal state, UI already shows ✓ agent 完成
@@ -503,7 +564,30 @@ function App({ registryPath, debug = false, proxyUrl }) {
503
564
  };
504
565
  // Handle input submission (Enter key)
505
566
  const handleInputSubmit = (value) => {
506
- const trimmed = value.trim();
567
+ let submittedValue = value;
568
+ // Exit search mode if active (user submitted with Enter while in search mode)
569
+ // Use the selected history entry as the submitted value for consistency
570
+ if (history.searchMode) {
571
+ const selectedEntry = history.acceptSearch();
572
+ if (selectedEntry !== null) {
573
+ submittedValue = selectedEntry;
574
+ setInput(selectedEntry); // Sync input state
575
+ }
576
+ }
577
+ // Exit history mode if active (user submitted with Enter while browsing history)
578
+ // Use the selected history entry as the submitted value for consistency
579
+ else if (history.isActive) {
580
+ const selectedEntry = history.acceptHistory();
581
+ if (selectedEntry !== null) {
582
+ submittedValue = selectedEntry;
583
+ setInput(selectedEntry); // Sync input state
584
+ }
585
+ }
586
+ const trimmed = submittedValue.trim();
587
+ // Add to history (filtering handled by hook)
588
+ if (trimmed) {
589
+ history.addEntry(trimmed);
590
+ }
507
591
  // Handle / commands
508
592
  if (trimmed.startsWith('/')) {
509
593
  const cmd = trimmed.split(' ')[0].toLowerCase();
@@ -588,8 +672,21 @@ function App({ registryPath, debug = false, proxyUrl }) {
588
672
  }
589
673
  return;
590
674
  }
591
- // ESC key - Cancel agent execution in conversation mode
675
+ // ESC key - Exit search/history mode or cancel agent execution
592
676
  if (key.escape) {
677
+ // First, check if we're in search mode
678
+ if (history.searchMode) {
679
+ const savedInput = history.exitSearchMode();
680
+ setInput(savedInput);
681
+ return;
682
+ }
683
+ // Then check if we're in history browsing mode
684
+ if (history.isActive) {
685
+ const savedInput = history.exitHistory();
686
+ setInput(savedInput);
687
+ return;
688
+ }
689
+ // Cancel agent execution in conversation mode
593
690
  if (mode === 'conversation' && activeCoordinator && executingAgent) {
594
691
  // Check if ESC cancellation is allowed (LLD-05: use uiPrefs)
595
692
  if (uiPrefs.allowEscCancel) {
@@ -603,8 +700,80 @@ function App({ registryPath, debug = false, proxyUrl }) {
603
700
  }
604
701
  }
605
702
  }
703
+ // Ctrl+R - Enter search mode or search backward
704
+ if (key.ctrl && inputChar === 'r') {
705
+ if (mode === 'normal' || mode === 'conversation') {
706
+ if (history.searchMode) {
707
+ // Already in search mode - search backward
708
+ const result = history.searchBackward();
709
+ if (result !== null) {
710
+ setInput(result);
711
+ }
712
+ }
713
+ else {
714
+ // Enter search mode
715
+ history.enterSearchMode(input);
716
+ }
717
+ return;
718
+ }
719
+ }
720
+ // Ctrl+S - Search forward (only in search mode)
721
+ if (key.ctrl && inputChar === 's') {
722
+ if (history.searchMode) {
723
+ const result = history.searchForward();
724
+ if (result !== null) {
725
+ setInput(result);
726
+ }
727
+ return;
728
+ }
729
+ }
730
+ // Ctrl+P - Navigate to previous (older) history entry (same as ↑)
731
+ if (key.ctrl && inputChar === 'p') {
732
+ if (mode === 'normal' || mode === 'conversation') {
733
+ // In search mode, navigate search results
734
+ if (history.searchMode) {
735
+ const result = history.searchBackward();
736
+ if (result !== null) {
737
+ setInput(result);
738
+ }
739
+ return;
740
+ }
741
+ // Regular history navigation
742
+ const historyEntry = history.navigateUp(input);
743
+ if (historyEntry !== null) {
744
+ setInput(historyEntry);
745
+ }
746
+ return;
747
+ }
748
+ }
749
+ // Ctrl+N - Navigate to next (newer) history entry (same as ↓)
750
+ if (key.ctrl && inputChar === 'n') {
751
+ if (mode === 'normal' || mode === 'conversation') {
752
+ // In search mode, navigate search results
753
+ if (history.searchMode) {
754
+ const result = history.searchForward();
755
+ if (result !== null) {
756
+ setInput(result);
757
+ }
758
+ return;
759
+ }
760
+ // Regular history navigation
761
+ const historyEntry = history.navigateDown();
762
+ if (historyEntry !== null) {
763
+ setInput(historyEntry);
764
+ }
765
+ return;
766
+ }
767
+ }
606
768
  // Ctrl+C 退出或取消
607
769
  if (key.ctrl && inputChar === 'c') {
770
+ // First, clean up any search/history state
771
+ if (history.searchMode) {
772
+ history.exitSearchMode();
773
+ }
774
+ else if (history.isActive) {
775
+ history.exitHistory();
776
+ }
608
777
  if (mode === 'conversation' && activeCoordinator) {
609
778
  // 退出对话模式
610
779
  // stop() is async, fire-and-forget for UI responsiveness
@@ -684,14 +853,60 @@ function App({ registryPath, debug = false, proxyUrl }) {
684
853
  // normal/conversation/wizard/form 由 TextInput 的 onSubmit 处理
685
854
  return;
686
855
  }
856
+ // Alt+↑ - Large jump backward (skip 5 entries)
857
+ // Cross-platform: key.meta captures Option key on macOS, Alt key on Windows/Linux
858
+ // in most modern terminal emulators (Windows Terminal, iTerm2, etc.)
859
+ if (key.meta && key.upArrow) {
860
+ if ((mode === 'normal' || mode === 'conversation') && !history.searchMode) {
861
+ const historyEntry = history.jumpUp(input);
862
+ if (historyEntry !== null) {
863
+ setInput(historyEntry);
864
+ }
865
+ return;
866
+ }
867
+ }
868
+ // Alt+↓ - Large jump forward (skip 5 entries)
869
+ // Cross-platform: key.meta captures Option key on macOS, Alt key on Windows/Linux
870
+ if (key.meta && key.downArrow) {
871
+ if ((mode === 'normal' || mode === 'conversation') && !history.searchMode && history.isActive) {
872
+ const historyEntry = history.jumpDown();
873
+ if (historyEntry !== null) {
874
+ setInput(historyEntry);
875
+ }
876
+ return;
877
+ }
878
+ }
687
879
  // 处理不同模式下的上下键导航
688
880
  if (key.upArrow) {
881
+ // Search mode takes priority - navigate search results
882
+ if (history.searchMode) {
883
+ const result = history.searchBackward();
884
+ if (result !== null) {
885
+ setInput(result);
886
+ }
887
+ return;
888
+ }
689
889
  if (mode === 'normal') {
690
890
  const matches = getMatches();
691
891
  if (matches.length > 0) {
892
+ // Command hint navigation has priority
692
893
  setSelectedIndex(prev => (prev > 0 ? prev - 1 : matches.length - 1));
693
894
  return;
694
895
  }
896
+ // No command hints - use regular history navigation
897
+ const historyEntry = history.navigateUp(input);
898
+ if (historyEntry !== null) {
899
+ setInput(historyEntry);
900
+ }
901
+ return;
902
+ }
903
+ else if (mode === 'conversation') {
904
+ // Regular history navigation in conversation mode
905
+ const historyEntry = history.navigateUp(input);
906
+ if (historyEntry !== null) {
907
+ setInput(historyEntry);
908
+ }
909
+ return;
695
910
  }
696
911
  else if (mode === 'menu' && menuItems.length > 0) {
697
912
  setSelectedIndex(prev => (prev > 0 ? prev - 1 : menuItems.length - 1));
@@ -703,12 +918,35 @@ function App({ registryPath, debug = false, proxyUrl }) {
703
918
  }
704
919
  }
705
920
  if (key.downArrow) {
921
+ // Search mode takes priority - navigate search results
922
+ if (history.searchMode) {
923
+ const result = history.searchForward();
924
+ if (result !== null) {
925
+ setInput(result);
926
+ }
927
+ return;
928
+ }
706
929
  if (mode === 'normal') {
707
930
  const matches = getMatches();
708
931
  if (matches.length > 0) {
932
+ // Command hint navigation has priority
709
933
  setSelectedIndex(prev => (prev < matches.length - 1 ? prev + 1 : 0));
710
934
  return;
711
935
  }
936
+ // No command hints - use regular history navigation
937
+ const historyEntry = history.navigateDown();
938
+ if (historyEntry !== null) {
939
+ setInput(historyEntry);
940
+ }
941
+ return;
942
+ }
943
+ else if (mode === 'conversation') {
944
+ // Regular history navigation in conversation mode
945
+ const historyEntry = history.navigateDown();
946
+ if (historyEntry !== null) {
947
+ setInput(historyEntry);
948
+ }
949
+ return;
712
950
  }
713
951
  else if (mode === 'menu' && menuItems.length > 0) {
714
952
  setSelectedIndex(prev => (prev < menuItems.length - 1 ? prev + 1 : 0));
@@ -1563,6 +1801,13 @@ function App({ registryPath, debug = false, proxyUrl }) {
1563
1801
  }
1564
1802
  }
1565
1803
  }
1804
+ // Show search/history mode indicator in conversation mode
1805
+ if (history.searchMode) {
1806
+ return _jsxs(Text, { color: "yellow", children: ["[search:", teamName, "] ", history.searchQuery ? `"${history.searchQuery}"` : '', "> "] });
1807
+ }
1808
+ if (history.isActive) {
1809
+ return _jsxs(Text, { color: "green", bold: true, children: ["[history:", teamName, "] ", memberPrompt, "> "] });
1810
+ }
1566
1811
  return _jsxs(Text, { color: "green", bold: true, children: ["[conversation:", teamName, "] ", memberPrompt, "> "] });
1567
1812
  }
1568
1813
  case 'wizard':
@@ -1570,10 +1815,16 @@ function App({ registryPath, debug = false, proxyUrl }) {
1570
1815
  case 'form':
1571
1816
  return _jsx(Text, { color: "cyan", bold: true, children: "[form] input> " });
1572
1817
  default:
1573
- // 'normal' mode
1818
+ // 'normal' mode - show search/history mode indicator
1819
+ if (history.searchMode) {
1820
+ return _jsxs(Text, { color: "yellow", children: ["[search] ", history.searchQuery ? `"${history.searchQuery}"` : '', "> "] });
1821
+ }
1822
+ if (history.isActive) {
1823
+ return _jsx(Text, { color: "cyan", children: "[history] hephos> " });
1824
+ }
1574
1825
  return _jsx(Text, { color: "cyan", children: "[normal] hephos> " });
1575
1826
  }
1576
- })(), _jsx(TextInput, { value: input, onChange: setInput, onSubmit: handleInputSubmit, placeholder: " " })] }), _jsx(Text, { color: mode === 'conversation' ? 'green' : 'cyan', dimColor: true, children: '─'.repeat(terminalWidth - 4) })] })), !isExiting && mode === 'normal' && _jsx(CommandHints, { input: input, selectedIndex: selectedIndex }), !isExiting && mode === 'conversation' && (_jsx(TipsBar, { visible: showTips, terminalWidth: terminalWidth }))] }));
1827
+ })(), _jsx(TextInput, { value: input, onChange: setInput, onSubmit: handleInputSubmit, placeholder: " " })] }), _jsx(Text, { color: mode === 'conversation' ? 'green' : 'cyan', dimColor: true, children: '─'.repeat(terminalWidth - 4) })] })), !isExiting && (mode === 'normal' || mode === 'conversation') && (history.isActive || history.searchMode) && (_jsx(HistoryOverlay, { visible: true, entries: history.entries, currentIndex: history.currentIndex, searchMode: history.searchMode, searchQuery: history.searchQuery, terminalWidth: terminalWidth })), !isExiting && mode === 'normal' && !history.isActive && !history.searchMode && _jsx(CommandHints, { input: input, selectedIndex: selectedIndex }), !isExiting && mode === 'conversation' && !history.isActive && !history.searchMode && (_jsx(TipsBar, { visible: showTips, terminalWidth: terminalWidth }))] }));
1577
1828
  }
1578
1829
  export function startReplInk(registryPath, options = {}) {
1579
1830
  render(_jsx(App, { registryPath: registryPath, debug: options.debug, proxyUrl: options.proxyUrl }), {