grok-cli-hurry-mode 1.0.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 (137) hide show
  1. package/.grok/settings.json +3 -0
  2. package/LICENSE +21 -0
  3. package/README.md +452 -0
  4. package/dist/agent/grok-agent.d.ts +54 -0
  5. package/dist/agent/grok-agent.js +674 -0
  6. package/dist/agent/grok-agent.js.map +1 -0
  7. package/dist/agent/index.d.ts +14 -0
  8. package/dist/agent/index.js +137 -0
  9. package/dist/agent/index.js.map +1 -0
  10. package/dist/commands/mcp.d.ts +2 -0
  11. package/dist/commands/mcp.js +245 -0
  12. package/dist/commands/mcp.js.map +1 -0
  13. package/dist/grok/client.d.ts +49 -0
  14. package/dist/grok/client.js +85 -0
  15. package/dist/grok/client.js.map +1 -0
  16. package/dist/grok/tools.d.ts +8 -0
  17. package/dist/grok/tools.js +357 -0
  18. package/dist/grok/tools.js.map +1 -0
  19. package/dist/hooks/use-enhanced-input.d.ts +37 -0
  20. package/dist/hooks/use-enhanced-input.js +217 -0
  21. package/dist/hooks/use-enhanced-input.js.map +1 -0
  22. package/dist/hooks/use-input-handler.d.ts +34 -0
  23. package/dist/hooks/use-input-handler.js +611 -0
  24. package/dist/hooks/use-input-handler.js.map +1 -0
  25. package/dist/hooks/use-input-history.d.ts +9 -0
  26. package/dist/hooks/use-input-history.js +64 -0
  27. package/dist/hooks/use-input-history.js.map +1 -0
  28. package/dist/index.d.ts +2 -0
  29. package/dist/index.js +151949 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/mcp/client.d.ts +29 -0
  32. package/dist/mcp/client.js +167 -0
  33. package/dist/mcp/client.js.map +1 -0
  34. package/dist/mcp/config.d.ts +13 -0
  35. package/dist/mcp/config.js +51 -0
  36. package/dist/mcp/config.js.map +1 -0
  37. package/dist/mcp/transports.d.ts +51 -0
  38. package/dist/mcp/transports.js +229 -0
  39. package/dist/mcp/transports.js.map +1 -0
  40. package/dist/node_modules/react/index.js +1841 -0
  41. package/dist/tools/bash.d.ts +10 -0
  42. package/dist/tools/bash.js +81 -0
  43. package/dist/tools/bash.js.map +1 -0
  44. package/dist/tools/confirmation-tool.d.ts +16 -0
  45. package/dist/tools/confirmation-tool.js +75 -0
  46. package/dist/tools/confirmation-tool.js.map +1 -0
  47. package/dist/tools/index.d.ts +6 -0
  48. package/dist/tools/index.js +16 -0
  49. package/dist/tools/index.js.map +1 -0
  50. package/dist/tools/morph-editor.d.ts +36 -0
  51. package/dist/tools/morph-editor.js +347 -0
  52. package/dist/tools/morph-editor.js.map +1 -0
  53. package/dist/tools/search.d.ts +69 -0
  54. package/dist/tools/search.js +341 -0
  55. package/dist/tools/search.js.map +1 -0
  56. package/dist/tools/text-editor.d.ts +16 -0
  57. package/dist/tools/text-editor.js +565 -0
  58. package/dist/tools/text-editor.js.map +1 -0
  59. package/dist/tools/todo-tool.d.ts +20 -0
  60. package/dist/tools/todo-tool.js +135 -0
  61. package/dist/tools/todo-tool.js.map +1 -0
  62. package/dist/types/index.d.ts +30 -0
  63. package/dist/types/index.js +3 -0
  64. package/dist/types/index.js.map +1 -0
  65. package/dist/ui/app.d.ts +7 -0
  66. package/dist/ui/app.js +160 -0
  67. package/dist/ui/app.js.map +1 -0
  68. package/dist/ui/components/api-key-input.d.ts +7 -0
  69. package/dist/ui/components/api-key-input.js +124 -0
  70. package/dist/ui/components/api-key-input.js.map +1 -0
  71. package/dist/ui/components/chat-history.d.ts +8 -0
  72. package/dist/ui/components/chat-history.js +177 -0
  73. package/dist/ui/components/chat-history.js.map +1 -0
  74. package/dist/ui/components/chat-input.d.ts +9 -0
  75. package/dist/ui/components/chat-input.js +87 -0
  76. package/dist/ui/components/chat-input.js.map +1 -0
  77. package/dist/ui/components/chat-interface.d.ts +8 -0
  78. package/dist/ui/components/chat-interface.js +344 -0
  79. package/dist/ui/components/chat-interface.js.map +1 -0
  80. package/dist/ui/components/command-suggestions.d.ts +17 -0
  81. package/dist/ui/components/command-suggestions.js +68 -0
  82. package/dist/ui/components/command-suggestions.js.map +1 -0
  83. package/dist/ui/components/confirmation-dialog.d.ts +11 -0
  84. package/dist/ui/components/confirmation-dialog.js +167 -0
  85. package/dist/ui/components/confirmation-dialog.js.map +1 -0
  86. package/dist/ui/components/diff-renderer.d.ts +13 -0
  87. package/dist/ui/components/diff-renderer.js +217 -0
  88. package/dist/ui/components/diff-renderer.js.map +1 -0
  89. package/dist/ui/components/loading-spinner.d.ts +8 -0
  90. package/dist/ui/components/loading-spinner.js +92 -0
  91. package/dist/ui/components/loading-spinner.js.map +1 -0
  92. package/dist/ui/components/mcp-status.d.ts +5 -0
  93. package/dist/ui/components/mcp-status.js +74 -0
  94. package/dist/ui/components/mcp-status.js.map +1 -0
  95. package/dist/ui/components/model-selection.d.ts +12 -0
  96. package/dist/ui/components/model-selection.js +28 -0
  97. package/dist/ui/components/model-selection.js.map +1 -0
  98. package/dist/ui/shared/max-sized-box.d.ts +8 -0
  99. package/dist/ui/shared/max-sized-box.js +15 -0
  100. package/dist/ui/shared/max-sized-box.js.map +1 -0
  101. package/dist/ui/utils/code-colorizer.d.ts +2 -0
  102. package/dist/ui/utils/code-colorizer.js +18 -0
  103. package/dist/ui/utils/code-colorizer.js.map +1 -0
  104. package/dist/ui/utils/colors.d.ts +14 -0
  105. package/dist/ui/utils/colors.js +18 -0
  106. package/dist/ui/utils/colors.js.map +1 -0
  107. package/dist/ui/utils/markdown-renderer.d.ts +4 -0
  108. package/dist/ui/utils/markdown-renderer.js +29 -0
  109. package/dist/ui/utils/markdown-renderer.js.map +1 -0
  110. package/dist/utils/confirmation-service.d.ts +33 -0
  111. package/dist/utils/confirmation-service.js +113 -0
  112. package/dist/utils/confirmation-service.js.map +1 -0
  113. package/dist/utils/custom-instructions.d.ts +1 -0
  114. package/dist/utils/custom-instructions.js +53 -0
  115. package/dist/utils/custom-instructions.js.map +1 -0
  116. package/dist/utils/model-config.d.ts +28 -0
  117. package/dist/utils/model-config.js +49 -0
  118. package/dist/utils/model-config.js.map +1 -0
  119. package/dist/utils/settings-manager.d.ts +94 -0
  120. package/dist/utils/settings-manager.js +275 -0
  121. package/dist/utils/settings-manager.js.map +1 -0
  122. package/dist/utils/settings.d.ts +1 -0
  123. package/dist/utils/settings.js +8 -0
  124. package/dist/utils/settings.js.map +1 -0
  125. package/dist/utils/text-utils.d.ts +80 -0
  126. package/dist/utils/text-utils.js +197 -0
  127. package/dist/utils/text-utils.js.map +1 -0
  128. package/dist/utils/token-counter.d.ts +33 -0
  129. package/dist/utils/token-counter.js +83 -0
  130. package/dist/utils/token-counter.js.map +1 -0
  131. package/dist/yoga.wasm +0 -0
  132. package/eslint.config.mjs +28 -0
  133. package/fix.awk +41 -0
  134. package/grok-logo-screenshot.png +0 -0
  135. package/package.json +68 -0
  136. package/sed_cmd.sh +35 -0
  137. package/temp.txt +29 -0
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ChatHistory = ChatHistory;
7
+ const react_1 = __importDefault(require("react"));
8
+ const ink_1 = require("ink");
9
+ const diff_renderer_js_1 = require("./diff-renderer.js");
10
+ const markdown_renderer_js_1 = require("../utils/markdown-renderer.js");
11
+ // Memoized ChatEntry component to prevent unnecessary re-renders
12
+ const MemoizedChatEntry = react_1.default.memo(({ entry, index }) => {
13
+ const renderDiff = (diffContent, filename) => {
14
+ return (<diff_renderer_js_1.DiffRenderer diffContent={diffContent} filename={filename} terminalWidth={80}/>);
15
+ };
16
+ const renderFileContent = (content) => {
17
+ const lines = content.split("\n");
18
+ // Calculate minimum indentation like DiffRenderer does
19
+ let baseIndentation = Infinity;
20
+ for (const line of lines) {
21
+ if (line.trim() === "")
22
+ continue;
23
+ const firstCharIndex = line.search(/\S/);
24
+ const currentIndent = firstCharIndex === -1 ? 0 : firstCharIndex;
25
+ baseIndentation = Math.min(baseIndentation, currentIndent);
26
+ }
27
+ if (!isFinite(baseIndentation)) {
28
+ baseIndentation = 0;
29
+ }
30
+ return lines.map((line, index) => {
31
+ const displayContent = line.substring(baseIndentation);
32
+ return (<ink_1.Text key={index} color="gray">
33
+ {displayContent}
34
+ </ink_1.Text>);
35
+ });
36
+ };
37
+ switch (entry.type) {
38
+ case "user":
39
+ return (<ink_1.Box key={index} flexDirection="column" marginTop={1}>
40
+ <ink_1.Box>
41
+ <ink_1.Text color="gray">
42
+ {">"} {entry.content}
43
+ </ink_1.Text>
44
+ </ink_1.Box>
45
+ </ink_1.Box>);
46
+ case "assistant":
47
+ return (<ink_1.Box key={index} flexDirection="column" marginTop={1}>
48
+ <ink_1.Box flexDirection="row" alignItems="flex-start">
49
+ <ink_1.Text color="white">⏺ </ink_1.Text>
50
+ <ink_1.Box flexDirection="column" flexGrow={1}>
51
+ {entry.toolCalls ? (
52
+ // If there are tool calls, just show plain text
53
+ <ink_1.Text color="white">{entry.content.trim()}</ink_1.Text>) : (
54
+ // If no tool calls, render as markdown
55
+ <markdown_renderer_js_1.MarkdownRenderer content={entry.content.trim()}/>)}
56
+ {entry.isStreaming && <ink_1.Text color="cyan">█</ink_1.Text>}
57
+ </ink_1.Box>
58
+ </ink_1.Box>
59
+ </ink_1.Box>);
60
+ case "tool_call":
61
+ case "tool_result":
62
+ const getToolActionName = (toolName) => {
63
+ // Handle MCP tools with mcp__servername__toolname format
64
+ if (toolName.startsWith("mcp__")) {
65
+ const parts = toolName.split("__");
66
+ if (parts.length >= 3) {
67
+ const serverName = parts[1];
68
+ const actualToolName = parts.slice(2).join("__");
69
+ return `${serverName.charAt(0).toUpperCase() + serverName.slice(1)}(${actualToolName.replace(/_/g, " ")})`;
70
+ }
71
+ }
72
+ switch (toolName) {
73
+ case "view_file":
74
+ return "Read";
75
+ case "str_replace_editor":
76
+ return "Update";
77
+ case "create_file":
78
+ return "Create";
79
+ case "bash":
80
+ return "Bash";
81
+ case "search":
82
+ return "Search";
83
+ case "create_todo_list":
84
+ return "Created Todo";
85
+ case "update_todo_list":
86
+ return "Updated Todo";
87
+ default:
88
+ return "Tool";
89
+ }
90
+ };
91
+ const toolName = entry.toolCall?.function?.name || "unknown";
92
+ const actionName = getToolActionName(toolName);
93
+ const getFilePath = (toolCall) => {
94
+ if (toolCall?.function?.arguments) {
95
+ try {
96
+ const args = JSON.parse(toolCall.function.arguments);
97
+ if (toolCall.function.name === "search") {
98
+ return args.query;
99
+ }
100
+ return args.path || args.file_path || args.command || "";
101
+ }
102
+ catch {
103
+ return "";
104
+ }
105
+ }
106
+ return "";
107
+ };
108
+ const filePath = getFilePath(entry.toolCall);
109
+ const isExecuting = entry.type === "tool_call" || !entry.toolResult;
110
+ // Format JSON content for better readability
111
+ const formatToolContent = (content, toolName) => {
112
+ if (toolName.startsWith("mcp__")) {
113
+ try {
114
+ // Try to parse as JSON and format it
115
+ const parsed = JSON.parse(content);
116
+ if (Array.isArray(parsed)) {
117
+ // For arrays, show a summary instead of full JSON
118
+ return `Found ${parsed.length} items`;
119
+ }
120
+ else if (typeof parsed === 'object') {
121
+ // For objects, show a formatted version
122
+ return JSON.stringify(parsed, null, 2);
123
+ }
124
+ }
125
+ catch {
126
+ // If not JSON, return as is
127
+ return content;
128
+ }
129
+ }
130
+ return content;
131
+ };
132
+ const shouldShowDiff = entry.toolCall?.function?.name === "str_replace_editor" &&
133
+ entry.toolResult?.success &&
134
+ entry.content.includes("Updated") &&
135
+ entry.content.includes("---") &&
136
+ entry.content.includes("+++");
137
+ const shouldShowFileContent = (entry.toolCall?.function?.name === "view_file" ||
138
+ entry.toolCall?.function?.name === "create_file") &&
139
+ entry.toolResult?.success &&
140
+ !shouldShowDiff;
141
+ return (<ink_1.Box key={index} flexDirection="column" marginTop={1}>
142
+ <ink_1.Box>
143
+ <ink_1.Text color="magenta">⏺</ink_1.Text>
144
+ <ink_1.Text color="white">
145
+ {" "}
146
+ {filePath ? `${actionName}(${filePath})` : actionName}
147
+ </ink_1.Text>
148
+ </ink_1.Box>
149
+ <ink_1.Box marginLeft={2} flexDirection="column">
150
+ {isExecuting ? (<ink_1.Text color="cyan">⎿ Executing...</ink_1.Text>) : shouldShowFileContent ? (<ink_1.Box flexDirection="column">
151
+ <ink_1.Text color="gray">⎿ File contents:</ink_1.Text>
152
+ <ink_1.Box marginLeft={2} flexDirection="column">
153
+ {renderFileContent(entry.content)}
154
+ </ink_1.Box>
155
+ </ink_1.Box>) : shouldShowDiff ? (
156
+ // For diff results, show only the summary line, not the raw content
157
+ <ink_1.Text color="gray">⎿ {entry.content.split("\n")[0]}</ink_1.Text>) : (<ink_1.Text color="gray">⎿ {formatToolContent(entry.content, toolName)}</ink_1.Text>)}
158
+ </ink_1.Box>
159
+ {shouldShowDiff && !isExecuting && (<ink_1.Box marginLeft={4} flexDirection="column">
160
+ {renderDiff(entry.content, filePath)}
161
+ </ink_1.Box>)}
162
+ </ink_1.Box>);
163
+ default:
164
+ return null;
165
+ }
166
+ });
167
+ MemoizedChatEntry.displayName = "MemoizedChatEntry";
168
+ function ChatHistory({ entries, isConfirmationActive = false, }) {
169
+ // Filter out tool_call entries with "Executing..." when confirmation is active
170
+ const filteredEntries = isConfirmationActive
171
+ ? entries.filter((entry) => !(entry.type === "tool_call" && entry.content === "Executing..."))
172
+ : entries;
173
+ return (<ink_1.Box flexDirection="column">
174
+ {filteredEntries.slice(-20).map((entry, index) => (<MemoizedChatEntry key={`${entry.timestamp.getTime()}-${index}`} entry={entry} index={index}/>))}
175
+ </ink_1.Box>);
176
+ }
177
+ //# sourceMappingURL=chat-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-history.js","sourceRoot":"","sources":["../../../src/ui/components/chat-history.tsx"],"names":[],"mappings":";;;;;AAiNA,kCAuBC;AAxOD,kDAA0B;AAC1B,6BAAgC;AAEhC,yDAAkD;AAClD,wEAAiE;AAOjE,iEAAiE;AACjE,MAAM,iBAAiB,GAAG,eAAK,CAAC,IAAI,CAClC,CAAC,EAA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AAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC,CACF,CAAC;AAEF,iBAAiB,CAAC,WAAW,GAAG,mBAAmB,CAAC;AAEpD,SAAgB,WAAW,CAAC,EAC1B,OAAO,EACP,oBAAoB,GAAG,KAAK,GACX;IACjB,+EAA+E;IAC/E,MAAM,eAAe,GAAG,oBAAoB;QAC1C,CAAC,CAAC,OAAO,CAAC,MAAM,CACZ,CAAC,KAAK,EAAE,EAAE,CACR,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,OAAO,KAAK,cAAc,CAAC,CACpE;QACH,CAAC,CAAC,OAAO,CAAC;IAEZ,OAAO,CACL,CAAC,SAAG,CAAC,aAAa,CAAC,QAAQ,CACzB;MAAA,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAChD,CAAC,iBAAiB,CAChB,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,KAAK,EAAE,CAAC,CAC7C,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,KAAK,CAAC,CAAC,KAAK,CAAC,EACb,CACH,CAAC,CACJ;IAAA,EAAE,SAAG,CAAC,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ interface ChatInputProps {
3
+ input: string;
4
+ cursorPosition: number;
5
+ isProcessing: boolean;
6
+ isStreaming: boolean;
7
+ }
8
+ export declare function ChatInput({ input, cursorPosition, isProcessing, isStreaming, }: ChatInputProps): React.JSX.Element;
9
+ export {};
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ChatInput = ChatInput;
7
+ const react_1 = __importDefault(require("react"));
8
+ const ink_1 = require("ink");
9
+ function ChatInput({ input, cursorPosition, isProcessing, isStreaming, }) {
10
+ const beforeCursor = input.slice(0, cursorPosition);
11
+ const afterCursor = input.slice(cursorPosition);
12
+ // Handle multiline input display
13
+ const lines = input.split("\n");
14
+ const isMultiline = lines.length > 1;
15
+ // Calculate cursor position across lines
16
+ let currentLineIndex = 0;
17
+ let currentCharIndex = 0;
18
+ let totalChars = 0;
19
+ for (let i = 0; i < lines.length; i++) {
20
+ if (totalChars + lines[i].length >= cursorPosition) {
21
+ currentLineIndex = i;
22
+ currentCharIndex = cursorPosition - totalChars;
23
+ break;
24
+ }
25
+ totalChars += lines[i].length + 1; // +1 for newline
26
+ }
27
+ const showCursor = !isProcessing && !isStreaming;
28
+ const borderColor = isProcessing || isStreaming ? "yellow" : "blue";
29
+ const promptColor = "cyan";
30
+ // Display placeholder when input is empty
31
+ const placeholderText = "Ask me anything...";
32
+ const isPlaceholder = !input;
33
+ if (isMultiline) {
34
+ return (<ink_1.Box borderStyle="round" borderColor={borderColor} paddingY={0} marginTop={1}>
35
+ {lines.map((line, index) => {
36
+ const isCurrentLine = index === currentLineIndex;
37
+ const promptChar = index === 0 ? "❯" : "│";
38
+ if (isCurrentLine) {
39
+ const beforeCursorInLine = line.slice(0, currentCharIndex);
40
+ const cursorChar = line.slice(currentCharIndex, currentCharIndex + 1) || " ";
41
+ const afterCursorInLine = line.slice(currentCharIndex + 1);
42
+ return (<ink_1.Box key={index}>
43
+ <ink_1.Text color={promptColor}>{promptChar} </ink_1.Text>
44
+ <ink_1.Text>
45
+ {beforeCursorInLine}
46
+ {showCursor && (<ink_1.Text backgroundColor="white" color="black">
47
+ {cursorChar}
48
+ </ink_1.Text>)}
49
+ {!showCursor && cursorChar !== " " && cursorChar}
50
+ {afterCursorInLine}
51
+ </ink_1.Text>
52
+ </ink_1.Box>);
53
+ }
54
+ else {
55
+ return (<ink_1.Box key={index}>
56
+ <ink_1.Text color={promptColor}>{promptChar} </ink_1.Text>
57
+ <ink_1.Text>{line}</ink_1.Text>
58
+ </ink_1.Box>);
59
+ }
60
+ })}
61
+ </ink_1.Box>);
62
+ }
63
+ // Single line input box
64
+ const cursorChar = input.slice(cursorPosition, cursorPosition + 1) || " ";
65
+ const afterCursorText = input.slice(cursorPosition + 1);
66
+ return (<ink_1.Box borderStyle="round" borderColor={borderColor} paddingX={1} paddingY={0} marginTop={1}>
67
+ <ink_1.Box>
68
+ <ink_1.Text color={promptColor}>❯ </ink_1.Text>
69
+ {isPlaceholder ? (<>
70
+ <ink_1.Text color="gray" dimColor>
71
+ {placeholderText}
72
+ </ink_1.Text>
73
+ {showCursor && (<ink_1.Text backgroundColor="white" color="black">
74
+ {" "}
75
+ </ink_1.Text>)}
76
+ </>) : (<ink_1.Text>
77
+ {beforeCursor}
78
+ {showCursor && (<ink_1.Text backgroundColor="white" color="black">
79
+ {cursorChar}
80
+ </ink_1.Text>)}
81
+ {!showCursor && cursorChar !== " " && cursorChar}
82
+ {afterCursorText}
83
+ </ink_1.Text>)}
84
+ </ink_1.Box>
85
+ </ink_1.Box>);
86
+ }
87
+ //# sourceMappingURL=chat-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-input.js","sourceRoot":"","sources":["../../../src/ui/components/chat-input.tsx"],"names":[],"mappings":";;;;;AAUA,8BAyHC;AAnID,kDAA0B;AAC1B,6BAAgC;AAShC,SAAgB,SAAS,CAAC,EACxB,KAAK,EACL,cAAc,EACd,YAAY,EACZ,WAAW,GACI;IACf,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IACpD,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAEhD,iCAAiC;IACjC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAErC,yCAAyC;IACzC,IA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 import React from "react";
2
+ import { GrokAgent } from "../../agent/grok-agent.js";
3
+ interface ChatInterfaceProps {
4
+ agent?: GrokAgent;
5
+ initialMessage?: string;
6
+ }
7
+ export default function ChatInterface({ agent, initialMessage, }: ChatInterfaceProps): React.JSX.Element;
8
+ export {};
@@ -0,0 +1,344 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.default = ChatInterface;
40
+ const react_1 = __importStar(require("react"));
41
+ const ink_1 = require("ink");
42
+ const use_input_handler_js_1 = require("../../hooks/use-input-handler.js");
43
+ const loading_spinner_js_1 = require("./loading-spinner.js");
44
+ const command_suggestions_js_1 = require("./command-suggestions.js");
45
+ const model_selection_js_1 = require("./model-selection.js");
46
+ const chat_history_js_1 = require("./chat-history.js");
47
+ const chat_input_js_1 = require("./chat-input.js");
48
+ const mcp_status_js_1 = require("./mcp-status.js");
49
+ const confirmation_dialog_js_1 = __importDefault(require("./confirmation-dialog.js"));
50
+ const confirmation_service_js_1 = require("../../utils/confirmation-service.js");
51
+ const api_key_input_js_1 = __importDefault(require("./api-key-input.js"));
52
+ const cfonts_1 = __importDefault(require("cfonts"));
53
+ // Main chat component that handles input when agent is available
54
+ function ChatInterfaceWithAgent({ agent, initialMessage, }) {
55
+ const [chatHistory, setChatHistory] = (0, react_1.useState)([]);
56
+ const [isProcessing, setIsProcessing] = (0, react_1.useState)(false);
57
+ const [processingTime, setProcessingTime] = (0, react_1.useState)(0);
58
+ const [tokenCount, setTokenCount] = (0, react_1.useState)(0);
59
+ const [isStreaming, setIsStreaming] = (0, react_1.useState)(false);
60
+ const [confirmationOptions, setConfirmationOptions] = (0, react_1.useState)(null);
61
+ const scrollRef = (0, react_1.useRef)();
62
+ const processingStartTime = (0, react_1.useRef)(0);
63
+ const confirmationService = confirmation_service_js_1.ConfirmationService.getInstance();
64
+ const { input, cursorPosition, showCommandSuggestions, selectedCommandIndex, showModelSelection, selectedModelIndex, commandSuggestions, availableModels, autoEditEnabled, } = (0, use_input_handler_js_1.useInputHandler)({
65
+ agent,
66
+ chatHistory,
67
+ setChatHistory,
68
+ setIsProcessing,
69
+ setIsStreaming,
70
+ setTokenCount,
71
+ setProcessingTime,
72
+ processingStartTime,
73
+ isProcessing,
74
+ isStreaming,
75
+ isConfirmationActive: !!confirmationOptions,
76
+ });
77
+ (0, react_1.useEffect)(() => {
78
+ // Only clear console on non-Windows platforms or if not PowerShell
79
+ // Windows PowerShell can have issues with console.clear() causing flickering
80
+ const isWindows = process.platform === "win32";
81
+ const isPowerShell = process.env.ComSpec?.toLowerCase().includes("powershell") ||
82
+ process.env.PSModulePath !== undefined;
83
+ if (!isWindows || !isPowerShell) {
84
+ console.clear();
85
+ }
86
+ // Add top padding
87
+ console.log(" ");
88
+ // Generate logo with margin to match Ink paddingX={2}
89
+ const grokLogo = cfonts_1.default.render("GROK", {
90
+ font: "tiny",
91
+ align: "left",
92
+ colors: ["yellow", "red"],
93
+ space: true,
94
+ maxLength: "0",
95
+ gradient: ["yellow", "red", "cyan"],
96
+ independentGradient: false,
97
+ transitionGradient: true,
98
+ env: "node",
99
+ });
100
+ // Add horizontal margin (2 spaces) to match Ink paddingX={2}
101
+ const hurryLogo = cfonts_1.default.render("HURRY MODE", {
102
+ font: "tiny",
103
+ align: "left",
104
+ colors: ["yellow", "red"],
105
+ space: true,
106
+ maxLength: 0,
107
+ gradient: ["yellow", "red", "cyan"],
108
+ independentGradient: false,
109
+ transitionGradient: true,
110
+ env: "node",
111
+ });
112
+ const logoOutput = grokLogo.string + "\n" + hurryLogo.string;
113
+ const logoLines = logoOutput.split("\n");
114
+ logoLines.forEach((line) => {
115
+ if (line.trim()) {
116
+ console.log(" " + line); // Add 2 spaces for horizontal margin
117
+ }
118
+ else {
119
+ console.log(line); // Keep empty lines as-is
120
+ }
121
+ });
122
+ console.log(" "); // Spacing after logo
123
+ setChatHistory([]);
124
+ }, []);
125
+ // Process initial message if provided (streaming for faster feedback)
126
+ (0, react_1.useEffect)(() => {
127
+ if (initialMessage && agent) {
128
+ const userEntry = {
129
+ type: "user",
130
+ content: initialMessage,
131
+ timestamp: new Date(),
132
+ };
133
+ setChatHistory([userEntry]);
134
+ const processInitialMessage = async () => {
135
+ setIsProcessing(true);
136
+ setIsStreaming(true);
137
+ try {
138
+ let streamingEntry = null;
139
+ for await (const chunk of agent.processUserMessageStream(initialMessage)) {
140
+ switch (chunk.type) {
141
+ case "content":
142
+ if (chunk.content) {
143
+ if (!streamingEntry) {
144
+ const newStreamingEntry = {
145
+ type: "assistant",
146
+ content: chunk.content,
147
+ timestamp: new Date(),
148
+ isStreaming: true,
149
+ };
150
+ setChatHistory((prev) => [...prev, newStreamingEntry]);
151
+ streamingEntry = newStreamingEntry;
152
+ }
153
+ else {
154
+ setChatHistory((prev) => prev.map((entry, idx) => idx === prev.length - 1 && entry.isStreaming
155
+ ? { ...entry, content: entry.content + chunk.content }
156
+ : entry));
157
+ }
158
+ }
159
+ break;
160
+ case "token_count":
161
+ if (chunk.tokenCount !== undefined) {
162
+ setTokenCount(chunk.tokenCount);
163
+ }
164
+ break;
165
+ case "tool_calls":
166
+ if (chunk.toolCalls) {
167
+ // Stop streaming for the current assistant message
168
+ setChatHistory((prev) => prev.map((entry) => entry.isStreaming
169
+ ? {
170
+ ...entry,
171
+ isStreaming: false,
172
+ toolCalls: chunk.toolCalls,
173
+ }
174
+ : entry));
175
+ streamingEntry = null;
176
+ // Add individual tool call entries to show tools are being executed
177
+ chunk.toolCalls.forEach((toolCall) => {
178
+ const toolCallEntry = {
179
+ type: "tool_call",
180
+ content: "Executing...",
181
+ timestamp: new Date(),
182
+ toolCall: toolCall,
183
+ };
184
+ setChatHistory((prev) => [...prev, toolCallEntry]);
185
+ });
186
+ }
187
+ break;
188
+ case "tool_result":
189
+ if (chunk.toolCall && chunk.toolResult) {
190
+ setChatHistory((prev) => prev.map((entry) => {
191
+ if (entry.isStreaming) {
192
+ return { ...entry, isStreaming: false };
193
+ }
194
+ if (entry.type === "tool_call" &&
195
+ entry.toolCall?.id === chunk.toolCall?.id) {
196
+ return {
197
+ ...entry,
198
+ type: "tool_result",
199
+ content: chunk.toolResult.success
200
+ ? chunk.toolResult.output || "Success"
201
+ : chunk.toolResult.error || "Error occurred",
202
+ toolResult: chunk.toolResult,
203
+ };
204
+ }
205
+ return entry;
206
+ }));
207
+ streamingEntry = null;
208
+ }
209
+ break;
210
+ case "done":
211
+ if (streamingEntry) {
212
+ setChatHistory((prev) => prev.map((entry) => entry.isStreaming ? { ...entry, isStreaming: false } : entry));
213
+ }
214
+ setIsStreaming(false);
215
+ break;
216
+ }
217
+ }
218
+ }
219
+ catch (error) {
220
+ const errorEntry = {
221
+ type: "assistant",
222
+ content: `Error: ${error.message}`,
223
+ timestamp: new Date(),
224
+ };
225
+ setChatHistory((prev) => [...prev, errorEntry]);
226
+ setIsStreaming(false);
227
+ }
228
+ setIsProcessing(false);
229
+ processingStartTime.current = 0;
230
+ };
231
+ processInitialMessage();
232
+ }
233
+ }, [initialMessage, agent]);
234
+ (0, react_1.useEffect)(() => {
235
+ const handleConfirmationRequest = (options) => {
236
+ setConfirmationOptions(options);
237
+ };
238
+ confirmationService.on("confirmation-requested", handleConfirmationRequest);
239
+ return () => {
240
+ confirmationService.off("confirmation-requested", handleConfirmationRequest);
241
+ };
242
+ }, [confirmationService]);
243
+ (0, react_1.useEffect)(() => {
244
+ if (!isProcessing && !isStreaming) {
245
+ setProcessingTime(0);
246
+ return;
247
+ }
248
+ if (processingStartTime.current === 0) {
249
+ processingStartTime.current = Date.now();
250
+ }
251
+ const interval = setInterval(() => {
252
+ setProcessingTime(Math.floor((Date.now() - processingStartTime.current) / 1000));
253
+ }, 1000);
254
+ return () => clearInterval(interval);
255
+ }, [isProcessing, isStreaming]);
256
+ const handleConfirmation = (dontAskAgain) => {
257
+ confirmationService.confirmOperation(true, dontAskAgain);
258
+ setConfirmationOptions(null);
259
+ };
260
+ const handleRejection = (feedback) => {
261
+ confirmationService.rejectOperation(feedback);
262
+ setConfirmationOptions(null);
263
+ // Reset processing states when operation is cancelled
264
+ setIsProcessing(false);
265
+ setIsStreaming(false);
266
+ setTokenCount(0);
267
+ setProcessingTime(0);
268
+ processingStartTime.current = 0;
269
+ };
270
+ return (<ink_1.Box flexDirection="column" paddingX={2}>
271
+ {/* Show tips only when no chat history and no confirmation dialog */}
272
+ {chatHistory.length === 0 && !confirmationOptions && (<ink_1.Box flexDirection="column" marginBottom={2}>
273
+ <ink_1.Text color="cyan" bold>
274
+ Tips for getting started:
275
+ </ink_1.Text>
276
+ <ink_1.Box marginTop={1} flexDirection="column">
277
+ <ink_1.Text color="gray">
278
+ 1. Ask questions, edit files, or run commands.
279
+ </ink_1.Text>
280
+ <ink_1.Text color="gray">2. Be specific for the best results.</ink_1.Text>
281
+ <ink_1.Text color="gray">
282
+ 3. Create GROK.md files to customize your interactions with Grok.
283
+ </ink_1.Text>
284
+ <ink_1.Text color="gray">
285
+ 4. Press Shift+Tab to toggle auto-edit mode.
286
+ </ink_1.Text>
287
+ <ink_1.Text color="gray">5. /help for more information.</ink_1.Text>
288
+ </ink_1.Box>
289
+ </ink_1.Box>)}
290
+
291
+ <ink_1.Box flexDirection="column" marginBottom={1}>
292
+ <ink_1.Text color="gray">
293
+ Type your request in natural language. Ctrl+C to clear, 'exit' to
294
+ quit.
295
+ </ink_1.Text>
296
+ </ink_1.Box>
297
+
298
+ <ink_1.Box flexDirection="column" ref={scrollRef}>
299
+ <chat_history_js_1.ChatHistory entries={chatHistory} isConfirmationActive={!!confirmationOptions}/>
300
+ </ink_1.Box>
301
+
302
+ {/* Show confirmation dialog if one is pending */}
303
+ {confirmationOptions && (<confirmation_dialog_js_1.default operation={confirmationOptions.operation} filename={confirmationOptions.filename} showVSCodeOpen={confirmationOptions.showVSCodeOpen} content={confirmationOptions.content} onConfirm={handleConfirmation} onReject={handleRejection}/>)}
304
+
305
+ {!confirmationOptions && (<>
306
+ <loading_spinner_js_1.LoadingSpinner isActive={isProcessing || isStreaming} processingTime={processingTime} tokenCount={tokenCount}/>
307
+
308
+ <chat_input_js_1.ChatInput input={input} cursorPosition={cursorPosition} isProcessing={isProcessing} isStreaming={isStreaming}/>
309
+
310
+ <ink_1.Box flexDirection="row" marginTop={1}>
311
+ <ink_1.Box marginRight={2}>
312
+ <ink_1.Text color="cyan">
313
+ {autoEditEnabled ? "▶" : "⏸"} auto-edit:{" "}
314
+ {autoEditEnabled ? "on" : "off"}
315
+ </ink_1.Text>
316
+ <ink_1.Text color="gray" dimColor>
317
+ {" "}
318
+ (shift + tab)
319
+ </ink_1.Text>
320
+ </ink_1.Box>
321
+ <ink_1.Box marginRight={2}>
322
+ <ink_1.Text color="yellow">≋ {agent.getCurrentModel()}</ink_1.Text>
323
+ </ink_1.Box>
324
+ <mcp_status_js_1.MCPStatus />
325
+ </ink_1.Box>
326
+
327
+ <command_suggestions_js_1.CommandSuggestions suggestions={commandSuggestions} input={input} selectedIndex={selectedCommandIndex} isVisible={showCommandSuggestions}/>
328
+
329
+ <model_selection_js_1.ModelSelection models={availableModels} selectedIndex={selectedModelIndex} isVisible={showModelSelection} currentModel={agent.getCurrentModel()}/>
330
+ </>)}
331
+ </ink_1.Box>);
332
+ }
333
+ // Main component that handles API key input or chat interface
334
+ function ChatInterface({ agent, initialMessage, }) {
335
+ const [currentAgent, setCurrentAgent] = (0, react_1.useState)(agent || null);
336
+ const handleApiKeySet = (newAgent) => {
337
+ setCurrentAgent(newAgent);
338
+ };
339
+ if (!currentAgent) {
340
+ return <api_key_input_js_1.default onApiKeySet={handleApiKeySet}/>;
341
+ }
342
+ return (<ChatInterfaceWithAgent agent={currentAgent} initialMessage={initialMessage}/>);
343
+ }
344
+ //# sourceMappingURL=chat-interface.js.map