wave-code 0.2.1 → 0.5.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.
Files changed (156) hide show
  1. package/dist/commands/plugin/disable.d.ts +2 -1
  2. package/dist/commands/plugin/disable.d.ts.map +1 -1
  3. package/dist/commands/plugin/disable.js +3 -2
  4. package/dist/commands/plugin/enable.d.ts +2 -1
  5. package/dist/commands/plugin/enable.d.ts.map +1 -1
  6. package/dist/commands/plugin/enable.js +3 -2
  7. package/dist/commands/plugin/install.d.ts +2 -1
  8. package/dist/commands/plugin/install.d.ts.map +1 -1
  9. package/dist/commands/plugin/list.d.ts.map +1 -1
  10. package/dist/commands/plugin/list.js +15 -3
  11. package/dist/commands/plugin/marketplace.d.ts +3 -0
  12. package/dist/commands/plugin/marketplace.d.ts.map +1 -1
  13. package/dist/commands/plugin/marketplace.js +15 -1
  14. package/dist/commands/plugin/uninstall.d.ts +4 -0
  15. package/dist/commands/plugin/uninstall.d.ts.map +1 -0
  16. package/dist/commands/plugin/uninstall.js +29 -0
  17. package/dist/commands/plugin/update.d.ts +4 -0
  18. package/dist/commands/plugin/update.d.ts.map +1 -0
  19. package/dist/commands/plugin/update.js +15 -0
  20. package/dist/components/ChatInterface.d.ts.map +1 -1
  21. package/dist/components/ChatInterface.js +2 -2
  22. package/dist/components/CommandSelector.d.ts.map +1 -1
  23. package/dist/components/CommandSelector.js +9 -3
  24. package/dist/components/Confirmation.d.ts.map +1 -1
  25. package/dist/components/Confirmation.js +73 -20
  26. package/dist/components/DiffDisplay.d.ts +0 -1
  27. package/dist/components/DiffDisplay.d.ts.map +1 -1
  28. package/dist/components/DiffDisplay.js +38 -59
  29. package/dist/components/DiscoverView.d.ts +3 -0
  30. package/dist/components/DiscoverView.d.ts.map +1 -0
  31. package/dist/components/DiscoverView.js +25 -0
  32. package/dist/components/FileSelector.js +1 -1
  33. package/dist/components/HistorySearch.d.ts +8 -0
  34. package/dist/components/HistorySearch.d.ts.map +1 -0
  35. package/dist/components/HistorySearch.js +67 -0
  36. package/dist/components/InputBox.d.ts +1 -1
  37. package/dist/components/InputBox.d.ts.map +1 -1
  38. package/dist/components/InputBox.js +29 -19
  39. package/dist/components/InstalledView.d.ts +3 -0
  40. package/dist/components/InstalledView.d.ts.map +1 -0
  41. package/dist/components/InstalledView.js +30 -0
  42. package/dist/components/Markdown.d.ts.map +1 -1
  43. package/dist/components/Markdown.js +24 -10
  44. package/dist/components/MarketplaceAddForm.d.ts +3 -0
  45. package/dist/components/MarketplaceAddForm.d.ts.map +1 -0
  46. package/dist/components/MarketplaceAddForm.js +26 -0
  47. package/dist/components/MarketplaceDetail.d.ts +3 -0
  48. package/dist/components/MarketplaceDetail.d.ts.map +1 -0
  49. package/dist/components/MarketplaceDetail.js +38 -0
  50. package/dist/components/MarketplaceList.d.ts +9 -0
  51. package/dist/components/MarketplaceList.d.ts.map +1 -0
  52. package/dist/components/MarketplaceList.js +16 -0
  53. package/dist/components/MarketplaceView.d.ts +3 -0
  54. package/dist/components/MarketplaceView.d.ts.map +1 -0
  55. package/dist/components/MarketplaceView.js +28 -0
  56. package/dist/components/PlanDisplay.d.ts.map +1 -1
  57. package/dist/components/PlanDisplay.js +2 -2
  58. package/dist/components/PluginDetail.d.ts +3 -0
  59. package/dist/components/PluginDetail.d.ts.map +1 -0
  60. package/dist/components/PluginDetail.js +63 -0
  61. package/dist/components/PluginList.d.ts +14 -0
  62. package/dist/components/PluginList.d.ts.map +1 -0
  63. package/dist/components/PluginList.js +12 -0
  64. package/dist/components/PluginManagerShell.d.ts +5 -0
  65. package/dist/components/PluginManagerShell.d.ts.map +1 -0
  66. package/dist/components/PluginManagerShell.js +89 -0
  67. package/dist/components/PluginManagerTypes.d.ts +33 -0
  68. package/dist/components/PluginManagerTypes.d.ts.map +1 -0
  69. package/dist/components/PluginManagerTypes.js +1 -0
  70. package/dist/components/RewindCommand.d.ts +9 -0
  71. package/dist/components/RewindCommand.d.ts.map +1 -0
  72. package/dist/components/RewindCommand.js +42 -0
  73. package/dist/components/SessionSelector.d.ts +11 -0
  74. package/dist/components/SessionSelector.d.ts.map +1 -0
  75. package/dist/components/SessionSelector.js +38 -0
  76. package/dist/components/SubagentBlock.d.ts.map +1 -1
  77. package/dist/components/SubagentBlock.js +24 -1
  78. package/dist/components/TaskManager.d.ts +6 -0
  79. package/dist/components/TaskManager.d.ts.map +1 -0
  80. package/dist/components/TaskManager.js +114 -0
  81. package/dist/components/ToolResultDisplay.d.ts.map +1 -1
  82. package/dist/components/ToolResultDisplay.js +2 -1
  83. package/dist/contexts/PluginManagerContext.d.ts +4 -0
  84. package/dist/contexts/PluginManagerContext.d.ts.map +1 -0
  85. package/dist/contexts/PluginManagerContext.js +9 -0
  86. package/dist/contexts/useChat.d.ts +7 -4
  87. package/dist/contexts/useChat.d.ts.map +1 -1
  88. package/dist/contexts/useChat.js +37 -12
  89. package/dist/hooks/useInputManager.d.ts +8 -16
  90. package/dist/hooks/useInputManager.d.ts.map +1 -1
  91. package/dist/hooks/useInputManager.js +39 -55
  92. package/dist/hooks/usePluginManager.d.ts +3 -0
  93. package/dist/hooks/usePluginManager.d.ts.map +1 -0
  94. package/dist/hooks/usePluginManager.js +227 -0
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +150 -177
  97. package/dist/managers/InputManager.d.ts +18 -26
  98. package/dist/managers/InputManager.d.ts.map +1 -1
  99. package/dist/managers/InputManager.js +93 -119
  100. package/dist/plugin-manager-cli.d.ts +6 -0
  101. package/dist/plugin-manager-cli.d.ts.map +1 -0
  102. package/dist/plugin-manager-cli.js +12 -0
  103. package/dist/session-selector-cli.d.ts +2 -0
  104. package/dist/session-selector-cli.d.ts.map +1 -0
  105. package/dist/session-selector-cli.js +25 -0
  106. package/package.json +9 -5
  107. package/src/commands/plugin/disable.ts +7 -3
  108. package/src/commands/plugin/enable.ts +7 -3
  109. package/src/commands/plugin/install.ts +2 -1
  110. package/src/commands/plugin/list.ts +21 -3
  111. package/src/commands/plugin/marketplace.ts +17 -1
  112. package/src/commands/plugin/uninstall.ts +39 -0
  113. package/src/commands/plugin/update.ts +19 -0
  114. package/src/components/ChatInterface.tsx +2 -1
  115. package/src/components/CommandSelector.tsx +10 -3
  116. package/src/components/Confirmation.tsx +115 -25
  117. package/src/components/DiffDisplay.tsx +60 -106
  118. package/src/components/DiscoverView.tsx +31 -0
  119. package/src/components/FileSelector.tsx +1 -1
  120. package/src/components/HistorySearch.tsx +148 -0
  121. package/src/components/InputBox.tsx +51 -34
  122. package/src/components/InstalledView.tsx +61 -0
  123. package/src/components/Markdown.tsx +44 -28
  124. package/src/components/MarketplaceAddForm.tsx +39 -0
  125. package/src/components/MarketplaceDetail.tsx +79 -0
  126. package/src/components/MarketplaceList.tsx +52 -0
  127. package/src/components/MarketplaceView.tsx +43 -0
  128. package/src/components/PlanDisplay.tsx +14 -19
  129. package/src/components/PluginDetail.tsx +147 -0
  130. package/src/components/PluginList.tsx +51 -0
  131. package/src/components/PluginManagerShell.tsx +189 -0
  132. package/src/components/PluginManagerTypes.ts +47 -0
  133. package/src/components/RewindCommand.tsx +114 -0
  134. package/src/components/SessionSelector.tsx +127 -0
  135. package/src/components/SubagentBlock.tsx +34 -1
  136. package/src/components/{BashShellManager.tsx → TaskManager.tsx} +79 -75
  137. package/src/components/ToolResultDisplay.tsx +6 -2
  138. package/src/contexts/PluginManagerContext.ts +15 -0
  139. package/src/contexts/useChat.tsx +51 -20
  140. package/src/hooks/useInputManager.ts +39 -71
  141. package/src/hooks/usePluginManager.ts +302 -0
  142. package/src/index.ts +241 -280
  143. package/src/managers/InputManager.ts +113 -162
  144. package/src/plugin-manager-cli.tsx +13 -0
  145. package/src/session-selector-cli.tsx +37 -0
  146. package/dist/components/BashHistorySelector.d.ts +0 -11
  147. package/dist/components/BashHistorySelector.d.ts.map +0 -1
  148. package/dist/components/BashHistorySelector.js +0 -93
  149. package/dist/components/BashShellManager.d.ts +0 -6
  150. package/dist/components/BashShellManager.d.ts.map +0 -1
  151. package/dist/components/BashShellManager.js +0 -116
  152. package/dist/hooks/usePagination.d.ts +0 -20
  153. package/dist/hooks/usePagination.d.ts.map +0 -1
  154. package/dist/hooks/usePagination.js +0 -168
  155. package/src/components/BashHistorySelector.tsx +0 -181
  156. package/src/hooks/usePagination.ts +0 -203
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from "ink";
3
+ export const MarketplaceList = ({ marketplaces, selectedIndex, }) => {
4
+ if (marketplaces.length === 0) {
5
+ return (_jsx(Box, { padding: 1, children: _jsx(Text, { dimColor: true, children: "No marketplaces registered." }) }));
6
+ }
7
+ return (_jsx(Box, { flexDirection: "column", children: marketplaces.map((marketplace, index) => {
8
+ const isSelected = index === selectedIndex;
9
+ const sourceStr = marketplace.source.source === "directory"
10
+ ? marketplace.source.path
11
+ : marketplace.source.source === "github"
12
+ ? marketplace.source.repo
13
+ : marketplace.source.url;
14
+ return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Box, { children: _jsxs(Text, { color: isSelected ? "cyan" : undefined, children: [isSelected ? "> " : " ", _jsx(Text, { bold: true, children: marketplace.name }), marketplace.isBuiltin && (_jsx(Text, { color: "yellow", children: " [Built-in]" }))] }) }), _jsx(Box, { marginLeft: 4, children: _jsxs(Text, { dimColor: true, children: ["Source: ", sourceStr] }) })] }, marketplace.name));
15
+ }) }));
16
+ };
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ export declare const MarketplaceView: React.FC;
3
+ //# sourceMappingURL=MarketplaceView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarketplaceView.d.ts","sourceRoot":"","sources":["../../src/components/MarketplaceView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAMxC,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAoCnC,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Box, Text, useInput } from "ink";
4
+ import { usePluginManagerContext } from "../contexts/PluginManagerContext.js";
5
+ import { MarketplaceList } from "./MarketplaceList.js";
6
+ export const MarketplaceView = () => {
7
+ const { marketplaces, actions } = usePluginManagerContext();
8
+ const [selectedIndex, setSelectedIndex] = useState(0);
9
+ useInput((input, key) => {
10
+ if (key.upArrow) {
11
+ setSelectedIndex(Math.max(0, selectedIndex - 1));
12
+ }
13
+ else if (key.downArrow) {
14
+ setSelectedIndex(Math.min(marketplaces.length - 1, selectedIndex + 1));
15
+ }
16
+ else if (key.return) {
17
+ const mk = marketplaces[selectedIndex];
18
+ if (mk) {
19
+ actions.setSelectedId(mk.name);
20
+ actions.setView("MARKETPLACE_DETAIL");
21
+ }
22
+ }
23
+ else if (input === "a") {
24
+ actions.setView("ADD_MARKETPLACE");
25
+ }
26
+ });
27
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: "green", children: "Press 'a' to add a new marketplace" }) }), _jsx(MarketplaceList, { marketplaces: marketplaces, selectedIndex: selectedIndex }), marketplaces.length > 0 && (_jsx(Box, { marginLeft: 4, marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Press Enter for actions" }) }))] }));
28
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"PlanDisplay.d.ts","sourceRoot":"","sources":["../../src/components/PlanDisplay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAoClD,CAAC"}
1
+ {"version":3,"file":"PlanDisplay.d.ts","sourceRoot":"","sources":["../../src/components/PlanDisplay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA+BlD,CAAC"}
@@ -6,9 +6,9 @@ export const PlanDisplay = ({ plan, isExpanded = false, }) => {
6
6
  const { stdout } = useStdout();
7
7
  const maxHeight = useMemo(() => {
8
8
  // Similar to DiffDisplay.tsx maxHeight calculation
9
- return Math.max(5, (stdout?.rows || 24) - 20);
9
+ return Math.max(5, (stdout?.rows || 24) - 25);
10
10
  }, [stdout?.rows]);
11
11
  const lines = useMemo(() => plan.split("\n"), [plan]);
12
12
  const isOverflowing = !isExpanded && lines.length > maxHeight;
13
- return (_jsx(Box, { flexDirection: "column", marginTop: 1, children: _jsxs(Box, { paddingLeft: 2, borderLeft: true, borderColor: "cyan", flexDirection: "column", children: [_jsx(Text, { color: "cyan", bold: true, children: "Plan Content:" }), _jsx(Box, { flexDirection: "column", height: isOverflowing ? maxHeight : undefined, overflow: "hidden", children: _jsx(Markdown, { children: plan }) }), isOverflowing && (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: "yellow", dimColor: true, children: ["... (plan truncated, ", lines.length, " lines total)"] }) }))] }) }));
13
+ return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Box, { flexDirection: "column", height: isOverflowing ? maxHeight : undefined, overflow: "hidden", children: _jsx(Markdown, { children: plan }) }), isOverflowing && (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: "yellow", dimColor: true, children: ["... (plan truncated, ", lines.length, " lines total)"] }) }))] }));
14
14
  };
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ export declare const PluginDetail: React.FC;
3
+ //# sourceMappingURL=PluginDetail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginDetail.d.ts","sourceRoot":"","sources":["../../src/components/PluginDetail.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAUxC,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAwIhC,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Box, Text, useInput } from "ink";
4
+ import { usePluginManagerContext } from "../contexts/PluginManagerContext.js";
5
+ const SCOPES = [
6
+ { id: "project", label: "Install for all collaborators (project scope)" },
7
+ { id: "user", label: "Install for you (user scope)" },
8
+ { id: "local", label: "Install for you, in this repo only (local scope)" },
9
+ ];
10
+ export const PluginDetail = () => {
11
+ const { state, discoverablePlugins, installedPlugins, actions } = usePluginManagerContext();
12
+ const [selectedScopeIndex, setSelectedScopeIndex] = useState(0);
13
+ const [selectedActionIndex, setSelectedActionIndex] = useState(0);
14
+ const plugin = discoverablePlugins.find((p) => `${p.name}@${p.marketplace}` === state.selectedId) ||
15
+ installedPlugins.find((p) => `${p.name}@${p.marketplace}` === state.selectedId);
16
+ const INSTALLED_ACTIONS = [
17
+ { id: "update", label: "Update plugin (reinstall)" },
18
+ { id: "uninstall", label: "Uninstall plugin" },
19
+ ];
20
+ const isInstalledAndEnabled = plugin && "enabled" in plugin && plugin.enabled;
21
+ useInput((input, key) => {
22
+ if (key.escape) {
23
+ const isFromDiscover = discoverablePlugins.find((p) => `${p.name}@${p.marketplace}` === state.selectedId);
24
+ actions.setView(isFromDiscover ? "DISCOVER" : "INSTALLED");
25
+ }
26
+ else if (key.upArrow) {
27
+ if (isInstalledAndEnabled) {
28
+ setSelectedActionIndex((prev) => prev > 0 ? prev - 1 : INSTALLED_ACTIONS.length - 1);
29
+ }
30
+ else {
31
+ setSelectedScopeIndex((prev) => prev > 0 ? prev - 1 : SCOPES.length - 1);
32
+ }
33
+ }
34
+ else if (key.downArrow) {
35
+ if (isInstalledAndEnabled) {
36
+ setSelectedActionIndex((prev) => prev < INSTALLED_ACTIONS.length - 1 ? prev + 1 : 0);
37
+ }
38
+ else {
39
+ setSelectedScopeIndex((prev) => prev < SCOPES.length - 1 ? prev + 1 : 0);
40
+ }
41
+ }
42
+ else if (key.return && plugin) {
43
+ if (isInstalledAndEnabled) {
44
+ const action = INSTALLED_ACTIONS[selectedActionIndex].id;
45
+ if (action === "uninstall") {
46
+ actions.uninstallPlugin(plugin.name, plugin.marketplace);
47
+ }
48
+ else {
49
+ actions.updatePlugin(plugin.name, plugin.marketplace);
50
+ }
51
+ actions.setView("INSTALLED");
52
+ }
53
+ else {
54
+ actions.installPlugin(plugin.name, plugin.marketplace, SCOPES[selectedScopeIndex].id);
55
+ actions.setView("INSTALLED");
56
+ }
57
+ }
58
+ });
59
+ if (!plugin) {
60
+ return (_jsx(Box, { children: _jsx(Text, { color: "red", children: "Plugin not found." }) }));
61
+ }
62
+ return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { bold: true, color: "cyan", children: plugin.name }), _jsxs(Text, { dimColor: true, children: [" @", plugin.marketplace] })] }), _jsx(Box, { marginBottom: 1, children: _jsx(Text, { children: "description" in plugin ? plugin.description : "" }) }), plugin.version && (_jsx(Box, { marginBottom: 1, children: _jsxs(Text, { children: ["Version: ", _jsx(Text, { color: "blue", children: plugin.version })] }) })), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [isInstalledAndEnabled ? (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, children: "Plugin Actions:" }), INSTALLED_ACTIONS.map((action, index) => (_jsxs(Text, { color: index === selectedActionIndex ? "yellow" : undefined, children: [index === selectedActionIndex ? "> " : " ", action.label] }, action.id))), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Use \u2191/\u2193 to select, Enter to confirm" }) })] })) : (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { bold: true, children: "Select Installation Scope:" }), SCOPES.map((scope, index) => (_jsxs(Text, { color: index === selectedScopeIndex ? "green" : undefined, children: [index === selectedScopeIndex ? "> " : " ", scope.label] }, scope.id))), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Use \u2191/\u2193 to select, Enter to install" }) })] })), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Press Esc to go back" }) })] })] }));
63
+ };
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { MarketplacePluginEntry } from "wave-agent-sdk";
3
+ interface PluginListProps {
4
+ plugins: (MarketplacePluginEntry & {
5
+ marketplace: string;
6
+ installed: boolean;
7
+ version?: string;
8
+ })[];
9
+ selectedIndex: number;
10
+ onSelect?: (index: number) => void;
11
+ }
12
+ export declare const PluginList: React.FC<PluginListProps>;
13
+ export {};
14
+ //# sourceMappingURL=PluginList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginList.d.ts","sourceRoot":"","sources":["../../src/components/PluginList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,UAAU,eAAe;IACvB,OAAO,EAAE,CAAC,sBAAsB,GAAG;QACjC,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,OAAO,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC,EAAE,CAAC;IACL,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAoChD,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from "ink";
3
+ export const PluginList = ({ plugins, selectedIndex, }) => {
4
+ if (plugins.length === 0) {
5
+ return (_jsx(Box, { padding: 1, children: _jsx(Text, { dimColor: true, children: "No plugins found." }) }));
6
+ }
7
+ return (_jsx(Box, { flexDirection: "column", children: plugins.map((plugin, index) => {
8
+ const isSelected = index === selectedIndex;
9
+ const pluginId = `${plugin.name}@${plugin.marketplace}`;
10
+ return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Box, { children: _jsxs(Text, { color: isSelected ? "cyan" : undefined, children: [isSelected ? "> " : " ", _jsx(Text, { bold: true, children: plugin.name }), _jsxs(Text, { dimColor: true, children: [" @", plugin.marketplace] }), plugin.version && _jsxs(Text, { color: "blue", children: [" v", plugin.version] })] }) }), _jsx(Box, { marginLeft: 4, children: _jsx(Text, { dimColor: true, children: plugin.description }) })] }, pluginId));
11
+ }) }));
12
+ };
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ export declare const PluginManagerShell: React.FC<{
3
+ children?: React.ReactNode;
4
+ }>;
5
+ //# sourceMappingURL=PluginManagerShell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginManagerShell.d.ts","sourceRoot":"","sources":["../../src/components/PluginManagerShell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAgLvE,CAAC"}
@@ -0,0 +1,89 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text, useInput } from "ink";
3
+ import { usePluginManager } from "../hooks/usePluginManager.js";
4
+ import { DiscoverView } from "./DiscoverView.js";
5
+ import { InstalledView } from "./InstalledView.js";
6
+ import { MarketplaceView } from "./MarketplaceView.js";
7
+ import { MarketplaceDetail } from "./MarketplaceDetail.js";
8
+ import { PluginDetail } from "./PluginDetail.js";
9
+ import { MarketplaceAddForm } from "./MarketplaceAddForm.js";
10
+ import { PluginManagerContext } from "../contexts/PluginManagerContext.js";
11
+ export const PluginManagerShell = ({ children, }) => {
12
+ const pluginManager = usePluginManager();
13
+ const { state, actions, discoverablePlugins } = pluginManager;
14
+ const setView = (view) => {
15
+ if (view !== "PLUGIN_DETAIL" &&
16
+ view !== "MARKETPLACE_DETAIL" &&
17
+ view !== "ADD_MARKETPLACE") {
18
+ actions.setSelectedId(null);
19
+ }
20
+ actions.setView(view);
21
+ };
22
+ useInput((input, key) => {
23
+ if (key.tab) {
24
+ const views = ["DISCOVER", "INSTALLED", "MARKETPLACES"];
25
+ const currentIndex = views.indexOf(state.currentView === "PLUGIN_DETAIL"
26
+ ? discoverablePlugins.find((p) => `${p.name}@${p.marketplace}` === state.selectedId)
27
+ ? "DISCOVER"
28
+ : "INSTALLED"
29
+ : state.currentView === "MARKETPLACE_DETAIL" ||
30
+ state.currentView === "ADD_MARKETPLACE"
31
+ ? "MARKETPLACES"
32
+ : state.currentView);
33
+ let nextIndex;
34
+ if (key.shift) {
35
+ nextIndex = (currentIndex - 1 + views.length) % views.length;
36
+ }
37
+ else {
38
+ nextIndex = (currentIndex + 1) % views.length;
39
+ }
40
+ setView(views[nextIndex]);
41
+ }
42
+ if (key.escape) {
43
+ if (state.currentView === "PLUGIN_DETAIL") {
44
+ const isFromDiscover = discoverablePlugins.find((p) => `${p.name}@${p.marketplace}` === state.selectedId);
45
+ setView(isFromDiscover ? "DISCOVER" : "INSTALLED");
46
+ }
47
+ else if (state.currentView === "MARKETPLACE_DETAIL" ||
48
+ state.currentView === "ADD_MARKETPLACE") {
49
+ setView("MARKETPLACES");
50
+ }
51
+ }
52
+ });
53
+ const renderView = () => {
54
+ if (state.isLoading && !state.selectedId) {
55
+ return (_jsx(Box, { padding: 1, children: _jsx(Text, { color: "yellow", children: "Loading..." }) }));
56
+ }
57
+ switch (state.currentView) {
58
+ case "DISCOVER":
59
+ return _jsx(DiscoverView, {});
60
+ case "INSTALLED":
61
+ return _jsx(InstalledView, {});
62
+ case "MARKETPLACES":
63
+ return _jsx(MarketplaceView, {});
64
+ case "MARKETPLACE_DETAIL":
65
+ return _jsx(MarketplaceDetail, {});
66
+ case "PLUGIN_DETAIL":
67
+ return _jsx(PluginDetail, {});
68
+ case "ADD_MARKETPLACE":
69
+ return _jsx(MarketplaceAddForm, {});
70
+ default:
71
+ return _jsx(DiscoverView, {});
72
+ }
73
+ };
74
+ return (_jsx(PluginManagerContext.Provider, { value: pluginManager, children: _jsxs(Box, { flexDirection: "column", width: "100%", height: "100%", borderStyle: "round", borderColor: "cyan", children: [_jsxs(Box, { paddingX: 1, borderStyle: "single", borderBottom: true, borderTop: false, borderLeft: false, borderRight: false, children: [_jsx(Box, { marginRight: 2, children: _jsx(Text, { bold: true, color: "cyan", children: "Plugin Manager" }) }), _jsxs(Box, { children: [_jsxs(Text, { color: state.currentView === "DISCOVER" ||
75
+ (state.currentView === "PLUGIN_DETAIL" &&
76
+ !!discoverablePlugins.find((p) => `${p.name}@${p.marketplace}` === state.selectedId))
77
+ ? "yellow"
78
+ : undefined, children: [" ", "Discover", " "] }), _jsxs(Text, { color: state.currentView === "INSTALLED" ||
79
+ (state.currentView === "PLUGIN_DETAIL" &&
80
+ !discoverablePlugins.find((p) => `${p.name}@${p.marketplace}` === state.selectedId))
81
+ ? "yellow"
82
+ : undefined, children: [" ", "Installed", " "] }), _jsxs(Text, { color: state.currentView === "MARKETPLACES" ||
83
+ state.currentView === "MARKETPLACE_DETAIL" ||
84
+ state.currentView === "ADD_MARKETPLACE"
85
+ ? "yellow"
86
+ : undefined, children: [" ", "Marketplaces", " "] })] })] }), _jsxs(Box, { flexGrow: 1, flexDirection: "column", padding: 1, children: [renderView(), children] }), _jsxs(Box, { paddingX: 1, borderStyle: "single", borderTop: true, borderBottom: false, borderLeft: false, borderRight: false, children: [_jsx(Text, { dimColor: true, children: state.isLoading
87
+ ? "Loading..."
88
+ : "Use Tab to switch views, arrows to navigate, Enter to select, Esc to go back" }), state.error && (_jsx(Box, { marginLeft: 2, children: _jsxs(Text, { color: "red", children: ["Error: ", state.error] }) }))] })] }) }));
89
+ };
@@ -0,0 +1,33 @@
1
+ import { KnownMarketplace, InstalledPlugin, MarketplacePluginEntry } from "wave-agent-sdk";
2
+ export type ViewType = "DISCOVER" | "INSTALLED" | "MARKETPLACES" | "PLUGIN_DETAIL" | "MARKETPLACE_DETAIL" | "ADD_MARKETPLACE";
3
+ export interface PluginManagerState {
4
+ currentView: ViewType;
5
+ selectedId: string | null;
6
+ isLoading: boolean;
7
+ error: string | null;
8
+ searchQuery: string;
9
+ }
10
+ export interface PluginManagerContextType {
11
+ state: PluginManagerState;
12
+ marketplaces: KnownMarketplace[];
13
+ installedPlugins: (InstalledPlugin & {
14
+ enabled: boolean;
15
+ })[];
16
+ discoverablePlugins: (MarketplacePluginEntry & {
17
+ marketplace: string;
18
+ installed: boolean;
19
+ version?: string;
20
+ })[];
21
+ actions: {
22
+ setView: (view: ViewType) => void;
23
+ setSelectedId: (id: string | null) => void;
24
+ addMarketplace: (source: string) => Promise<void>;
25
+ removeMarketplace: (name: string) => Promise<void>;
26
+ updateMarketplace: (name: string) => Promise<void>;
27
+ installPlugin: (name: string, marketplace: string, scope?: "user" | "project" | "local") => Promise<void>;
28
+ uninstallPlugin: (name: string, marketplace: string) => Promise<void>;
29
+ updatePlugin: (name: string, marketplace: string) => Promise<void>;
30
+ refresh: () => Promise<void>;
31
+ };
32
+ }
33
+ //# sourceMappingURL=PluginManagerTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginManagerTypes.d.ts","sourceRoot":"","sources":["../../src/components/PluginManagerTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,QAAQ,GAChB,UAAU,GACV,WAAW,GACX,cAAc,GACd,eAAe,GACf,oBAAoB,GACpB,iBAAiB,CAAC;AAEtB,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,QAAQ,CAAC;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,kBAAkB,CAAC;IAC1B,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC,gBAAgB,EAAE,CAAC,eAAe,GAAG;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,EAAE,CAAC;IAC7D,mBAAmB,EAAE,CAAC,sBAAsB,GAAG;QAC7C,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,OAAO,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC,EAAE,CAAC;IACL,OAAO,EAAE;QACP,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;QAClC,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;QAC3C,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QAClD,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QACnD,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QACnD,aAAa,EAAE,CACb,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,KACjC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnB,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QACtE,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QACnE,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;KAC9B,CAAC;CACH"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import type { Message } from "wave-agent-sdk";
3
+ export interface RewindCommandProps {
4
+ messages: Message[];
5
+ onSelect: (index: number) => void;
6
+ onCancel: () => void;
7
+ }
8
+ export declare const RewindCommand: React.FC<RewindCommandProps>;
9
+ //# sourceMappingURL=RewindCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RewindCommand.d.ts","sourceRoot":"","sources":["../../src/components/RewindCommand.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EAAE,OAAO,EAAa,MAAM,gBAAgB,CAAC;AAEzD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAuGtD,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Box, Text, useInput } from "ink";
4
+ export const RewindCommand = ({ messages, onSelect, onCancel, }) => {
5
+ // Filter user messages as checkpoints
6
+ const checkpoints = messages
7
+ .map((msg, index) => ({ msg, index }))
8
+ .filter(({ msg }) => msg.role === "user");
9
+ const [selectedIndex, setSelectedIndex] = useState(checkpoints.length - 1);
10
+ useInput((input, key) => {
11
+ if (key.return) {
12
+ if (checkpoints.length > 0 && selectedIndex >= 0) {
13
+ onSelect(checkpoints[selectedIndex].index);
14
+ }
15
+ return;
16
+ }
17
+ if (key.escape) {
18
+ onCancel();
19
+ return;
20
+ }
21
+ if (key.upArrow) {
22
+ setSelectedIndex(Math.max(0, selectedIndex - 1));
23
+ return;
24
+ }
25
+ if (key.downArrow) {
26
+ setSelectedIndex(Math.min(checkpoints.length - 1, selectedIndex + 1));
27
+ return;
28
+ }
29
+ });
30
+ if (checkpoints.length === 0) {
31
+ return (_jsxs(Box, { flexDirection: "column", paddingX: 1, borderStyle: "single", borderColor: "yellow", borderLeft: false, borderRight: false, children: [_jsx(Text, { color: "yellow", children: "No user messages found to rewind to." }), _jsx(Text, { dimColor: true, children: "Press Escape to cancel" })] }));
32
+ }
33
+ return (_jsxs(Box, { flexDirection: "column", paddingX: 1, gap: 1, borderStyle: "single", borderColor: "cyan", borderLeft: false, borderRight: false, children: [_jsx(Box, { children: _jsx(Text, { color: "cyan", bold: true, children: "Rewind: Select a message to revert to" }) }), _jsx(Box, { flexDirection: "column", children: checkpoints.map((checkpoint, index) => {
34
+ const isSelected = index === selectedIndex;
35
+ const content = checkpoint.msg.blocks
36
+ .filter((b) => b.type === "text")
37
+ .map((b) => b.content)
38
+ .join(" ")
39
+ .substring(0, 60);
40
+ return (_jsx(Box, { children: _jsxs(Text, { color: isSelected ? "black" : "white", backgroundColor: isSelected ? "cyan" : undefined, children: [isSelected ? "▶ " : " ", "[", checkpoint.index, "]", " ", content || "(No text content)", index === checkpoints.length - 1 ? " (Latest)" : ""] }) }, checkpoint.index));
41
+ }) }), _jsx(Box, { children: _jsx(Text, { dimColor: true, children: "\u2191\u2193 navigate \u2022 Enter to rewind \u2022 Esc to cancel" }) }), _jsx(Box, { children: _jsx(Text, { color: "red", dimColor: true, children: "\u26A0\uFE0F Warning: This will delete all subsequent messages and revert file changes." }) })] }));
42
+ };
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import type { SessionMetadata } from "wave-agent-sdk";
3
+ export interface SessionSelectorProps {
4
+ sessions: (SessionMetadata & {
5
+ firstMessage?: string;
6
+ })[];
7
+ onSelect: (sessionId: string) => void;
8
+ onCancel: () => void;
9
+ }
10
+ export declare const SessionSelector: React.FC<SessionSelectorProps>;
11
+ //# sourceMappingURL=SessionSelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionSelector.d.ts","sourceRoot":"","sources":["../../src/components/SessionSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,CAAC,eAAe,GAAG;QAAE,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IAC1D,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAoH1D,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Box, Text, useInput } from "ink";
4
+ export const SessionSelector = ({ sessions, onSelect, onCancel, }) => {
5
+ const [selectedIndex, setSelectedIndex] = useState(0);
6
+ useInput((input, key) => {
7
+ if (key.return) {
8
+ if (sessions.length > 0 && selectedIndex < sessions.length) {
9
+ onSelect(sessions[selectedIndex].id);
10
+ }
11
+ return;
12
+ }
13
+ if (key.escape) {
14
+ onCancel();
15
+ return;
16
+ }
17
+ if (key.upArrow) {
18
+ setSelectedIndex(Math.max(0, selectedIndex - 1));
19
+ return;
20
+ }
21
+ if (key.downArrow) {
22
+ setSelectedIndex(Math.min(sessions.length - 1, selectedIndex + 1));
23
+ return;
24
+ }
25
+ });
26
+ if (sessions.length === 0) {
27
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: "yellow", borderLeft: false, borderRight: false, paddingX: 1, width: "100%", children: [_jsx(Text, { color: "yellow", children: "No sessions found." }), _jsx(Text, { dimColor: true, children: "Press Escape to cancel" })] }));
28
+ }
29
+ const maxDisplay = 10;
30
+ const startIndex = Math.max(0, Math.min(selectedIndex - Math.floor(maxDisplay / 2), sessions.length - maxDisplay));
31
+ const displaySessions = sessions.slice(startIndex, startIndex + maxDisplay);
32
+ return (_jsxs(Box, { flexDirection: "column", paddingX: 1, gap: 1, borderStyle: "single", borderColor: "cyan", borderLeft: false, borderRight: false, width: "100%", children: [_jsx(Box, { children: _jsx(Text, { color: "cyan", bold: true, children: "Select a session to resume" }) }), _jsx(Box, { flexDirection: "column", children: displaySessions.map((session, index) => {
33
+ const actualIndex = startIndex + index;
34
+ const isSelected = actualIndex === selectedIndex;
35
+ const lastActiveAt = new Date(session.lastActiveAt).toLocaleString();
36
+ return (_jsxs(Box, { flexDirection: "column", width: "100%", children: [_jsx(Box, { width: "100%", children: _jsxs(Text, { color: isSelected ? "black" : "white", backgroundColor: isSelected ? "cyan" : undefined, children: [isSelected ? "▶ " : " ", session.id, " | ", lastActiveAt, " | ", session.latestTotalTokens, " ", "tokens"] }) }), _jsx(Box, { marginLeft: 4, width: "100%", children: _jsx(Text, { dimColor: true, italic: true, children: session.firstMessage }) })] }, session.id));
37
+ }) }), sessions.length > maxDisplay && (_jsx(Box, { children: _jsxs(Text, { dimColor: true, children: ["... showing ", displaySessions.length, " of ", sessions.length, " sessions"] }) })), _jsx(Box, { children: _jsx(Text, { dimColor: true, children: "\u2191\u2193 navigate \u2022 Enter to select \u2022 Esc to cancel" }) })] }));
38
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"SubagentBlock.d.ts","sourceRoot":"","sources":["../../src/components/SubagentBlock.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGzE,UAAU,kBAAkB;IAC1B,KAAK,EAAE,iBAAiB,CAAC;CAC1B;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAoGtD,CAAC"}
1
+ {"version":3,"file":"SubagentBlock.d.ts","sourceRoot":"","sources":["../../src/components/SubagentBlock.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIzE,UAAU,kBAAkB;IAC1B,KAAK,EAAE,iBAAiB,CAAC;CAC1B;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAoItD,CAAC"}
@@ -1,8 +1,13 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
3
  import { useChat } from "../contexts/useChat.js";
4
+ import { Markdown } from "./Markdown.js";
4
5
  export const SubagentBlock = ({ block }) => {
5
6
  const { subagentMessages } = useChat();
7
+ // If the subagent is running in the background, don't show the block
8
+ if (block.runInBackground) {
9
+ return null;
10
+ }
6
11
  // Get messages for this subagent from context
7
12
  const messages = subagentMessages[block.subagentId] || [];
8
13
  // Status indicator mapping
@@ -43,5 +48,23 @@ export const SubagentBlock = ({ block }) => {
43
48
  return { tools: tools.reverse(), totalToolCount }; // Reverse to show oldest first, newest last
44
49
  };
45
50
  const { tools: lastTwoTools, totalToolCount } = getLastTwoTools();
46
- return (_jsxs(Box, { borderRight: false, borderTop: false, borderBottom: false, borderStyle: "classic", borderColor: "magenta", paddingX: 1, paddingY: 0, flexDirection: "column", marginBottom: 1, children: [_jsx(Box, { flexDirection: "row", gap: 1, children: _jsxs(Box, { flexDirection: "row", alignItems: "center", children: [_jsxs(Text, { color: "cyan", children: ["\uD83E\uDD16 ", block.subagentName] }), _jsxs(Text, { color: statusInfo.color, dimColor: false, children: [" ", statusInfo.icon] }), _jsxs(Text, { color: "gray", dimColor: true, children: [" ", "(", messages.length, " messages)"] })] }) }), lastTwoTools.length > 0 && (_jsxs(Box, { flexDirection: "column", marginTop: 1, gap: 1, children: [totalToolCount > 2 && (_jsx(Text, { color: "gray", dimColor: true, children: "..." })), lastTwoTools.map((tool, index) => (_jsxs(Box, { flexDirection: "row", children: [_jsx(Text, { color: "magenta", children: "\uD83D\uDD27 " }), _jsx(Text, { color: "white", children: tool.name }), tool.compactParams && (_jsxs(Text, { color: "gray", children: [" ", tool.compactParams] }))] }, index)))] }))] }));
51
+ // Get the last text message content if completed
52
+ const getLastTextMessage = () => {
53
+ if (block.status !== "completed")
54
+ return null;
55
+ for (let i = messages.length - 1; i >= 0; i--) {
56
+ const message = messages[i];
57
+ if (message.role === "assistant") {
58
+ for (let j = message.blocks.length - 1; j >= 0; j--) {
59
+ const messageBlock = message.blocks[j];
60
+ if (messageBlock.type === "text" && messageBlock.content) {
61
+ return messageBlock.content;
62
+ }
63
+ }
64
+ }
65
+ }
66
+ return null;
67
+ };
68
+ const lastTextMessage = getLastTextMessage();
69
+ return (_jsxs(Box, { borderRight: false, borderTop: false, borderBottom: false, borderStyle: "classic", borderColor: "magenta", paddingX: 1, paddingY: 0, flexDirection: "column", marginBottom: 1, children: [_jsx(Box, { flexDirection: "row", gap: 1, children: _jsxs(Box, { flexDirection: "row", alignItems: "center", children: [_jsxs(Text, { color: "cyan", children: ["\uD83E\uDD16 ", block.subagentName] }), _jsxs(Text, { color: statusInfo.color, dimColor: false, children: [" ", statusInfo.icon] }), _jsxs(Text, { color: "gray", dimColor: true, children: [" ", "(", messages.length, " messages)"] })] }) }), lastTextMessage && (_jsx(Box, { marginTop: 1, children: _jsx(Markdown, { children: lastTextMessage }) })), block.status !== "completed" && lastTwoTools.length > 0 && (_jsxs(Box, { flexDirection: "column", marginTop: 1, gap: 1, children: [totalToolCount > 2 && (_jsx(Text, { color: "gray", dimColor: true, children: "..." })), lastTwoTools.map((tool, index) => (_jsxs(Box, { flexDirection: "row", children: [_jsx(Text, { color: "magenta", children: "\uD83D\uDD27 " }), _jsx(Text, { color: "white", children: tool.name }), tool.compactParams && (_jsxs(Text, { color: "gray", children: [" ", tool.compactParams] }))] }, index)))] }))] }));
47
70
  };
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ export interface TaskManagerProps {
3
+ onCancel: () => void;
4
+ }
5
+ export declare const TaskManager: React.FC<TaskManagerProps>;
6
+ //# sourceMappingURL=TaskManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaskManager.d.ts","sourceRoot":"","sources":["../../src/components/TaskManager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAcnD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA2SlD,CAAC"}
@@ -0,0 +1,114 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState, useEffect } from "react";
3
+ import { Box, Text, useInput } from "ink";
4
+ import { useChat } from "../contexts/useChat.js";
5
+ export const TaskManager = ({ onCancel }) => {
6
+ const { backgroundTasks, getBackgroundTaskOutput, stopBackgroundTask } = useChat();
7
+ const [tasks, setTasks] = useState([]);
8
+ const [selectedIndex, setSelectedIndex] = useState(0);
9
+ const [viewMode, setViewMode] = useState("list");
10
+ const [detailTaskId, setDetailTaskId] = useState(null);
11
+ const [detailOutput, setDetailOutput] = useState(null);
12
+ // Convert backgroundTasks to local Task format
13
+ useEffect(() => {
14
+ setTasks(backgroundTasks.map((task) => ({
15
+ id: task.id,
16
+ type: task.type,
17
+ description: task.description,
18
+ status: task.status,
19
+ startTime: task.startTime,
20
+ exitCode: task.exitCode,
21
+ runtime: task.runtime,
22
+ })));
23
+ }, [backgroundTasks]);
24
+ // Load detail output for selected task
25
+ useEffect(() => {
26
+ if (viewMode === "detail" && detailTaskId) {
27
+ const output = getBackgroundTaskOutput(detailTaskId);
28
+ setDetailOutput(output);
29
+ }
30
+ }, [viewMode, detailTaskId, getBackgroundTaskOutput]);
31
+ const formatDuration = (ms) => {
32
+ if (ms < 1000)
33
+ return `${ms}ms`;
34
+ if (ms < 60000)
35
+ return `${Math.round(ms / 1000)}s`;
36
+ const minutes = Math.floor(ms / 60000);
37
+ const seconds = Math.round((ms % 60000) / 1000);
38
+ return `${minutes}m ${seconds}s`;
39
+ };
40
+ const formatTime = (timestamp) => {
41
+ return new Date(timestamp).toLocaleTimeString();
42
+ };
43
+ const stopTask = (taskId) => {
44
+ stopBackgroundTask(taskId);
45
+ };
46
+ useInput((input, key) => {
47
+ if (viewMode === "list") {
48
+ // List mode navigation
49
+ if (key.return) {
50
+ if (tasks.length > 0 && selectedIndex < tasks.length) {
51
+ const selectedTask = tasks[selectedIndex];
52
+ setDetailTaskId(selectedTask.id);
53
+ setViewMode("detail");
54
+ }
55
+ return;
56
+ }
57
+ if (key.escape) {
58
+ onCancel();
59
+ return;
60
+ }
61
+ if (key.upArrow) {
62
+ setSelectedIndex(Math.max(0, selectedIndex - 1));
63
+ return;
64
+ }
65
+ if (key.downArrow) {
66
+ setSelectedIndex(Math.min(tasks.length - 1, selectedIndex + 1));
67
+ return;
68
+ }
69
+ if (input === "k" && tasks.length > 0 && selectedIndex < tasks.length) {
70
+ const selectedTask = tasks[selectedIndex];
71
+ if (selectedTask.status === "running") {
72
+ stopTask(selectedTask.id);
73
+ }
74
+ return;
75
+ }
76
+ }
77
+ else if (viewMode === "detail") {
78
+ // Detail mode navigation
79
+ if (key.escape) {
80
+ setViewMode("list");
81
+ setDetailTaskId(null);
82
+ setDetailOutput(null);
83
+ return;
84
+ }
85
+ if (input === "k" && detailTaskId) {
86
+ const task = tasks.find((t) => t.id === detailTaskId);
87
+ if (task && task.status === "running") {
88
+ stopTask(detailTaskId);
89
+ }
90
+ return;
91
+ }
92
+ }
93
+ });
94
+ if (viewMode === "detail" && detailTaskId && detailOutput) {
95
+ const task = tasks.find((t) => t.id === detailTaskId);
96
+ if (!task) {
97
+ setViewMode("list");
98
+ return null;
99
+ }
100
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: "cyan", borderBottom: false, borderLeft: false, borderRight: false, paddingTop: 1, gap: 1, children: [_jsx(Box, { children: _jsxs(Text, { color: "cyan", bold: true, children: ["Background Task Details: ", task.id] }) }), _jsxs(Box, { flexDirection: "column", gap: 1, children: [_jsx(Box, { children: _jsxs(Text, { children: [_jsx(Text, { color: "blue", children: "Type:" }), " ", task.type] }) }), task.description && (_jsx(Box, { children: _jsxs(Text, { children: [_jsx(Text, { color: "blue", children: "Description:" }), " ", task.description] }) })), _jsx(Box, { children: _jsxs(Text, { children: [_jsx(Text, { color: "blue", children: "Status:" }), " ", task.status, task.exitCode !== undefined && ` (exit code: ${task.exitCode})`] }) }), _jsx(Box, { children: _jsxs(Text, { children: [_jsx(Text, { color: "blue", children: "Started:" }), " ", formatTime(task.startTime), task.runtime !== undefined && (_jsxs(Text, { children: [" ", "| ", _jsx(Text, { color: "blue", children: "Runtime:" }), " ", formatDuration(task.runtime)] }))] }) })] }), detailOutput.stdout && (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { color: "green", bold: true, children: "OUTPUT (last 10 lines):" }), _jsx(Box, { borderStyle: "single", borderColor: "green", padding: 1, children: _jsx(Text, { children: detailOutput.stdout.split("\n").slice(-10).join("\n") }) })] })), detailOutput.stderr && (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { color: "red", bold: true, children: "ERRORS:" }), _jsx(Box, { borderStyle: "single", borderColor: "red", padding: 1, children: _jsx(Text, { color: "red", children: detailOutput.stderr.split("\n").slice(-10).join("\n") }) })] })), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { dimColor: true, children: [task.status === "running" ? "k to stop · " : "", "Esc to go back"] }) })] }));
101
+ }
102
+ if (!backgroundTasks) {
103
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: "cyan", borderBottom: false, borderLeft: false, borderRight: false, paddingTop: 1, children: [_jsx(Text, { color: "cyan", bold: true, children: "Background Tasks" }), _jsx(Text, { children: "Background tasks not available" }), _jsx(Text, { dimColor: true, children: "Press Escape to close" })] }));
104
+ }
105
+ if (tasks.length === 0) {
106
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: "cyan", borderBottom: false, borderLeft: false, borderRight: false, paddingTop: 1, children: [_jsx(Text, { color: "cyan", bold: true, children: "Background Tasks" }), _jsx(Text, { children: "No background tasks found" }), _jsx(Text, { dimColor: true, children: "Press Escape to close" })] }));
107
+ }
108
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: "cyan", borderBottom: false, borderLeft: false, borderRight: false, paddingTop: 1, gap: 1, children: [_jsx(Box, { children: _jsx(Text, { color: "cyan", bold: true, children: "Background Tasks" }) }), _jsx(Text, { dimColor: true, children: "Select a task to view details" }), tasks.map((task, index) => (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: index === selectedIndex ? "black" : "white", backgroundColor: index === selectedIndex ? "cyan" : undefined, children: [index === selectedIndex ? "▶ " : " ", index + 1, ". [", task.id, "] ", task.type, task.description ? `: ${task.description}` : "", _jsxs(Text, { color: task.status === "running"
109
+ ? "green"
110
+ : task.status === "completed"
111
+ ? "blue"
112
+ : "red", children: [" ", "(", task.status, ")"] })] }), index === selectedIndex && (_jsx(Box, { marginLeft: 4, flexDirection: "column", children: _jsxs(Text, { color: "gray", dimColor: true, children: ["Started: ", formatTime(task.startTime), task.runtime !== undefined &&
113
+ ` | Runtime: ${formatDuration(task.runtime)}`, task.exitCode !== undefined && ` | Exit: ${task.exitCode}`] }) }))] }, task.id))), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { dimColor: true, children: ["\u2191/\u2193 to select \u00B7 Enter to view \u00B7", " ", tasks[selectedIndex]?.status === "running" ? "k to stop · " : "", "Esc to close"] }) })] }));
114
+ };